test/Tools/isac/ProgLang/calculate.thy
author Walther Neuper <walther.neuper@jku.at>
Wed, 13 May 2020 16:10:22 +0200
changeset 59973 8a46c2e7c27a
parent 59903 5037ca1b112b
child 59997 46fe5a8c3911
permissions -rw-r--r--
shift code from Specify to Problem, Method, Test_Tool
     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/../evaluate.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   [Problem.prep_input @{theory "Test"} "pbl_ttest" [] Problem.id_empty (["test"], [], Rule_Set.empty, NONE, []),
    22     Problem.prep_input @{theory "Test"} "pbl_ttest_calc" [] Problem.id_empty
    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   [Method.prep_input (@{theory "Test"}) "met_testcal" [] Method.id_empty
    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