test/Tools/isac/BaseDefinitions/base-definitions.sml
author wneuper <Walther.Neuper@jku.at>
Sat, 04 Feb 2023 17:00:25 +0100
changeset 60675 d841c720d288
parent 60516 795d1352493a
permissions -rw-r--r--
eliminate use of Thy_Info 22: eliminate UnparseC.term, rename "_in_ctxt" -> ""
     1 (* Title:  "Interpret/lucas-interpreter.sml"
     2    Author: Walther Neuper
     3    (c) due to copyright terms
     4 *)
     5 
     6 "-----------------------------------------------------------------------------------------------";
     7 "table of contents -----------------------------------------------------------------------------";
     8 "-----------------------------------------------------------------------------------------------";
     9 "----------- note on new realpow ------- -------------------------------------------------------";
    10 "-----------------------------------------------------------------------------------------------";
    11 "-----------------------------------------------------------------------------------------------";
    12 "-----------------------------------------------------------------------------------------------";
    13 
    14 "----------- note on new realpow ------- -------------------------------------------------------";
    15 "----------- note on new realpow ------- -------------------------------------------------------";
    16 "----------- note on new realpow ------- -------------------------------------------------------";
    17 
    18 (* these and other numeral calculations have been accomplished by Simplifier.rewrite so far *)
    19 
    20 val t = Calc_Binop.simplify @{context} @{term "4 * - 1 * 4 ::real"};
    21 if UnparseC.term @{context} t =    "- 16"
    22 then () else error "calcul  4 * - 1 * 4 \<longrightarrow> - 16";
    23 
    24 (*
    25   guess: simp_ctxt is not sufficient for simplifying the conditions in the definition -- RIGHT.
    26   note: missing cases, defined in lemma realpow_uminus_simps, go via [simp] into simp_ctxt.
    27 *)
    28 val t = Calc_Binop.simplify @{context} @{term "4 \<up> 2 ::real"};
    29 if UnparseC.term @{context} t = "16"
    30 then () else error    "calcul  4 \<up> 2 \<longrightarrow> 16";
    31 
    32 val t = Calc_Binop.simplify @{context} @{term "(- 1) \<up> 2"};
    33 if UnparseC.term @{context} t =  "1"
    34 then () else error "calcul  (- 1) \<up> 2 \<longrightarrow> 1";
    35 
    36 val t = Calc_Binop.simplify @{context} @{term "3 \<up> (- 2)"};
    37 if UnparseC.term @{context} t =  "1 / 9"
    38 then () else error "calcul  3 \<up> (- 2) \<longrightarrow> 1 / 9";
    39 
    40 val t = Calc_Binop.simplify @{context} @{term "3 \<up> - 1"};
    41 if UnparseC.term @{context} t = "1 / 3"
    42 then () else error  "calcul  3 \<up> - 1 \<longrightarrow> 1 / 3";
    43 
    44 (* note on example "4 * - 1 * 4 \<up> 2 \<le> 8 * (- 1) \<up> 2" *)
    45 (*
    46   fun Calc_Binop.simplify should simplify both sides of the inequality. 
    47   Afterwards the inequality  - 64 \<le> 8  should evaluate to True.
    48 
    49   But we get the error:
    50     rew_once: 
    51     Eval.get_pair for "BaseDefinitions.realpow" \<longrightarrow> SOME (_, "4 \<up> 2 = 4 \<up> 2")
    52     but rewrite__ on "4 * - 1 * 4 \<up> 2 \<le> 8 * (- 1) \<up> 2" \<longrightarrow> NONE
    53 
    54   The error occurs while rewriting and expecting \<longrightarrow> SOME (_, "4 \<up> 2 = 16");
    55   the rewriter takes the rhs 4 \<up> 2, the same as the lhs, 
    56   and assumes to be able to simplify, but we have lhs = rhs \<longrightarrow> NONE, 
    57   which is recognised by the rewriter as an error.
    58 
    59   Eval.get_pair ensures, that only pairs of numerals are passed to fun Calc_Binop.simplify,
    60   such that single-stepping is realised, although Simplifier.rewrite could do all at once.
    61 
    62   \<le> is a binary operator, too, but has another signature as algebraic operations.
    63   So \<le> is handled separately and not by fun Calc_Binop.simplify.
    64 *)