test/Tools/isac/BaseDefinitions/kestore.sml
author wenzelm
Thu, 16 Sep 2021 17:23:54 +0200
changeset 60405 d4ebe139100d
parent 60387 8e46f61fdb15
child 60521 23c40bb1bdbf
permissions -rw-r--r--
separate realpow constant, with additional cases not covered by Transcendental.powr;
walther@60387
     1
(* Title:  BaseDefinitions/kestore.sml
neuper@52126
     2
   Author: Walther Neuper
neuper@52126
     3
   Use is subject to license terms.
walther@60387
     4
walther@60387
     5
theory Test_Some
walther@60387
     6
  imports "Isac.Build_Isac" "$ISABELLE_ISAC_TEST/Tools/isac/ADDTESTS/accumulate-val/Lucas_Interpreter"
neuper@52126
     7
*)
neuper@52126
     8
neuper@52126
     9
"-----------------------------------------------------------------------------";
neuper@52126
    10
"-----------------------------------------------------------------------------";
neuper@52126
    11
"table of contents -----------------------------------------------------------";
neuper@52126
    12
"-----------------------------------------------------------------------------";
neuper@52126
    13
"-------- fun check_kestore_rls ----------------------------------------------";
s1210629013@55359
    14
"-------- fun Test_KEStore_Elems.add_rlss overwrites earlier data ------------";
walther@60387
    15
"-------- ERROR assoc_calc: 'Prog_Expr.is_num' not found in theory Poly ------";
neuper@52126
    16
"-----------------------------------------------------------------------------";
neuper@52126
    17
"-----------------------------------------------------------------------------";
neuper@52126
    18
neuper@52126
    19
"-------- fun check_kestore_rls ----------------------------------------------";
neuper@52126
    20
"-------- fun check_kestore_rls ----------------------------------------------";
neuper@52126
    21
"-------- fun check_kestore_rls ----------------------------------------------";
walther@59887
    22
if check_kestore_rls ("empty", ("Know_Store", Rule_Set.empty)) = 
walther@59887
    23
  "(empty, (Know_Store, Rls {#calc = 0, #rules = 0, ...))"
neuper@52126
    24
then () else error "check_kestore_rls changed"
neuper@52126
    25
;
wneuper@59592
    26
Test_KEStore_Elems.get_rlss @{theory Isac_Knowledge}
neuper@52126
    27
  |> map check_kestore_rls 
neuper@52126
    28
  |> enumerate_strings
neuper@52126
    29
  |> sort string_ord
neuper@52126
    30
(*|> map writeln*)
neuper@52126
    31
;
neuper@52139
    32
s1210629013@55359
    33
"-------- fun Test_KEStore_Elems.add_rlss overwrites earlier data -----------------";
s1210629013@55359
    34
"-------- fun Test_KEStore_Elems.add_rlss overwrites earlier data -----------------";
s1210629013@55359
    35
"-------- fun Test_KEStore_Elems.add_rlss overwrites earlier data -----------------";
neuper@52139
    36
  fun union_overwrite eq l1 l2 = fold (insert eq) l2 (*..swapped..*) l1;
neuper@52139
    37
  fun rls_eq ((id1, (thyID1, _)), (id2, (thyID2, _))) = id1 = id2 (*andalso thyID1 = thyID2*)
neuper@52139
    38
walther@59851
    39
val data1 = [("test", ("theory-1", Rule_Set.Empty)),
neuper@52139
    40
  ("test_rls", ("theory-1", 
walther@59852
    41
    Rule_Set.append_rules "test_rls" Rule_Set.empty [Thm ("refl", @{thm refl}), Thm ("subst", @{thm subst})]))]
neuper@52139
    42
val data2 = 
neuper@52139
    43
  [("test_rls", ("theory-2",
walther@59852
    44
    Rule_Set.append_rules "test_rls" Rule_Set.empty [Thm ("not_def", @{thm not_def})]))]
neuper@52139
    45
val data_3a = union rls_eq data1 data2
neuper@52139
    46
val data_3b = union_overwrite rls_eq data1 data2
neuper@52139
    47
walther@59851
    48
val SOME (_, Rule_Set.Repeat {rules, ...}) = AList.lookup op = data_3a "test_rls";
neuper@52139
    49
case rules of
neuper@52139
    50
  [Thm ("not_def", _)] => ()
neuper@52139
    51
| _ => error "union rls_eq changed: 1st argument is NOT overwritten anymore"
neuper@52139
    52
;
walther@59851
    53
val SOME (_, Rule_Set.Repeat {rules, ...}) = AList.lookup op = data_3b "test_rls";
neuper@52139
    54
case rules of
neuper@52139
    55
  [Thm ("refl", _), Thm ("subst", _)] => ()
neuper@52139
    56
| _ => error "union_overwrite rls_eq changed: 2nd argument is NOT overwritten anymore"
neuper@52139
    57
neuper@52139
    58
(* add_rlss will take union_overwrite due to argument sequence *)
neuper@52139
    59
walther@60387
    60
walther@60387
    61
"-------- ERROR assoc_calc: 'Prog_Expr.is_num' not found in theory Poly ------";
walther@60387
    62
"-------- ERROR assoc_calc: 'Prog_Expr.is_num' not found in theory Poly ------";
walther@60387
    63
"-------- ERROR assoc_calc: 'Prog_Expr.is_num' not found in theory Poly ------";
walther@60387
    64
"~~~~~ fun prep_rls' , args:"; val (thy, (Rule_Def.Repeat {id, preconds, rew_ord, erls, srls, rules, errpatts, ...})) =
walther@60387
    65
  (@{theory}, Poly_erls);
walther@60387
    66
walther@60387
    67
(*ERROR assoc_calc: 'Prog_Expr.is_num' not found in theory Poly*)
walther@60387
    68
        val sc = 
walther@60387
    69
 Auto_Prog.rules2scr_Rls thy rules;
walther@60387
    70
"~~~~~ fun rules2scr_Rls , args:"; val (thy, rules) = (thy, rules);
walther@60387
    71
    (*if*) Auto_Prog.contain_bdv rules (*else*);
walther@60387
    72
walther@60387
    73
(*+*)val t = Auto_Prog.rule2stac thy (nth 14 rules);
walther@60387
    74
(*+*)UnparseC.term_in_thy @{theory} t;
walther@60387
    75
walther@60387
    76
(*ERROR assoc_calc: 'Prog_Expr.is_num' not found in theory Poly*)
walther@60387
    77
 Auto_Prog.rule2stac thy (nth 17 rules);
walther@60387
    78
"~~~~~ fun rule2stac , args:"; val (thy, (Rule.Eval (c, _))) = (thy, (nth 17 rules));
walther@60387
    79
walther@60387
    80
(*+*)val Rule.Eval ("Prog_Expr.is_num", _) = nth 17 rules;
walther@60387
    81
(*+*)c = "Prog_Expr.is_num";                                   (* <<<<<------------ is NOT found *)
walther@60387
    82
walther@60387
    83
(*ERROR assoc_calc: 'Prog_Expr.is_num' not found in theory Poly*)
walther@60387
    84
val "is_num" =
walther@60387
    85
           assoc_calc thy c;
walther@60387
    86
"~~~~~ fun assoc_calc , args:"; val (thy, calID) = (thy, c);
walther@60387
    87
val calcs = 
walther@60387
    88
       KEStore_Elems.get_calcs thy;
walther@60387
    89
walther@60387
    90
(*+*)val ("is_polyrat_in", ("Poly.is_polyrat_in", _)) = nth 17 calcs; (* <<<<<------- is_atom <> is_num *)
walther@60387
    91
(*+*)map fst calcs = (*..WITH declare [[ML_print_depth = 999]]*)
walther@60387
    92
   ["Test.precond_rootmet", "contains_root", "Test.precond_rootpbl", "is_f_x", "primed", "is_normSqrtTerm_in", "is_rootTerm_in", "SQRT", "is_sqrtTerm_in", "is_ratequation_in", "is_rootRatAddTerm_in", "add_new_c",
walther@60387
    93
    "occur_exactly_in", "is_addUnordered", "is_polyexp", "is_poly_in", "is_polyrat_in", "POWER", "TIMES", "PLUS", "ident", "le", "is_atom", "occurs_in", "is_num", "matchsub", "Vars", "lhs", "rhs", "matches",
walther@60387
    94
    "some_occur_in", "is_even", "leq", "equal", "MINUS", "DIVIDE", "boollist2sum", "is_expanded_in", "has_degree_in", "is_multUnordered", "is_expanded"];
walther@60387
    95
(*+*)map (fst o snd) calcs = (*..WITH declare [[ML_print_depth = 999]]*)
walther@60387
    96
   ["Test.precond_rootmet", "Test.contains_root", "Test.precond_rootpbl", "Integrate.is_f_x", "Diff.primed", "RootEq.is_normSqrtTerm_in", "RootEq.is_rootTerm_in", "NthRoot.sqrt", "RootEq.is_sqrtTerm_in",
walther@60387
    97
    "RatEq.is_ratequation_in", "RootRatEq.is_rootRatAddTerm_in", "Integrate.add_new_c", "EqSystem.occur_exactly_in", "Poly.is_addUnordered", "Poly.is_polyexp", "Poly.is_poly_in", "Poly.is_polyrat_in",
wenzelm@60405
    98
    \<^const_name>\<open>realpow\<close>, "Groups.times_class.times", "Groups.plus_class.plus", "Prog_Expr.ident", "Orderings.ord_class.less", "Prog_Expr.is_atom", "Prog_Expr.occurs_in", "Prog_Expr.is_num", "Prog_Expr.matchsub",
walther@60387
    99
    "Prog_Expr.Vars", "Prog_Expr.lhs", "Prog_Expr.rhs", "Prog_Expr.matches", "Prog_Expr.some_occur_in", "Prog_Expr.is_even", "Orderings.ord_class.less_eq", "HOL.eq", "Groups.minus_class.minus",
walther@60387
   100
    "Rings.divide_class.divide", "Prog_Expr.boollist2sum", "Poly.is_expanded_in", "Poly.has_degree_in", "Poly.is_multUnordered", "Rational.is_expanded"];