test/Tools/isac/ProgLang/calculate.thy
author Walther Neuper <walther.neuper@jku.at>
Wed, 08 Apr 2020 12:32:51 +0200
changeset 59852 ea7e6679080e
parent 59850 f3cac3053e7b
child 59898 68883c046963
permissions -rw-r--r--
use new struct "Rule_Set" for renaming identifiers
     1 (*  Title:      ~~test/../ProgLang/calculate.thy
     2     Author:     Walther Neuper
     3 *)
     4 
     5 theory calculate
     6 imports Isac.Build_Thydata
     7 begin
     8 
     9 text \<open>
    10   *setup* KEStore_Elems.add_pbts / add_mets is impossible in *.sml files.
    11   The respective test/../calculate.sml is called in Test_Isac.thy.
    12 \<close>
    13 
    14 ML \<open>
    15 "-calculate.thy: provides 'setup' -----------------------";
    16 "-calculate.thy: provides 'setup' -----------------------";
    17 "-calculate.thy: provides 'setup' -----------------------";
    18 \<close>
    19 
    20 setup \<open>KEStore_Elems.add_pbts
    21   [Specify.prep_pbt @{theory "Test"} "pbl_ttest" [] Celem.e_pblID (["test"], [], Rule_Set.empty, NONE, []),
    22     Specify.prep_pbt @{theory "Test"} "pbl_ttest_calc" [] Celem.e_pblID
    23       (["calculate", "test"],
    24         [("#Given", ["realTestGiven t_t"]),
    25          ("#Find", ["realTestFind s_s"])],
    26         Rule_Set.empty, NONE, [["Test", "test_calculate"]])]\<close>
    27 
    28 partial_function (tailrec) calc_test :: "real \<Rightarrow> real"
    29   where
    30 "calc_test t_t =
    31   (Repeat
    32     ((Try (Repeat (Calculate ''PLUS''))) #>
    33      (Try (Repeat (Calculate ''TIMES''))) #>
    34      (Try (Repeat (Calculate ''DIVIDE''))) #>
    35      (Try (Repeat (Calculate ''POWER''))))) t_t"
    36 setup \<open>KEStore_Elems.add_mets
    37   [Specify.prep_met (@{theory "Test"}) "met_testcal" [] Celem.e_metID
    38       (["Test","test_calculate"],
    39         [("#Given" , ["realTestGiven t_t"]), ("#Find", ["realTestFind s_s"])],
    40         {rew_ord'="sqrt_right",rls'=tval_rls,srls = Rule_Set.empty, prls = Rule_Set.empty,
    41           calc=[("PLUS", ("op +", eval_binop "#add_")),
    42               ("TIMES", ("Groups.times_class.times", eval_binop "#mult_")),
    43               ("DIVIDE", ("HOL.divide", Prog_Expr.eval_cancel "#divide_")),
    44               ("POWER", ("Prog_Expr.pow", eval_binop "#power_"))],
    45           crls=tval_rls, errpats = [], nrls= Rule_Set.empty (*, asm_rls=[],asm_thm=[]*)},
    46         @{thm calc_test.simps})]
    47 \<close>
    48 
    49 ML \<open>
    50 \<close> ML \<open>
    51 \<close> ML \<open>
    52 \<close>
    53 end