add functions accessing Theory_Data in parallel to those accessing "ruleset' = Unsynchronized.ref"
updates have been done incrementally following Build_Isac.thy:
# ./bin/isabelle jedit -l HOL src/Tools/isac/ProgLang/ProgLang.thy &
# ./bin/isabelle jedit -l HOL src/Tools/isac/Interpret/Interpret.thy &
# ./bin/isabelle jedit -l HOL src/Tools/isac/xmlsrc/xmlsrc.thy &
# ./bin/isabelle jedit -l HOL src/Tools/isac/Frontend/Frontend.thy &
Note, that the original access function "fun assoc_rls" is still outcommented;
so the old and new functionality is established in parallel.
1 (*. (c) by Richard Lang, 2003 .*)
2 (* theory collecting all knowledge for LinearEquations
10 theory LinEq imports Poly Equation begin
13 Solve'_lineq'_equation
15 bool list] => bool list"
16 ("((Script Solve'_lineq'_equation (_ _ =))//
19 axioms(*axiomatization where*)
21 (*WN0509 compare PolyEq.all_left "[|Not(b=!=0)|] ==> (a = b) = (a - b = 0)"*)
22 all_left: "[|Not(b=!=0)|] ==> (a=b) = (a+(-1)*b=0)"
24 real_assoc_1: "a+(b+c) = a+b+c"
25 real_assoc_2: "a*(b*c) = a*b*c"
28 lin_isolate_add1: "(a + b*bdv = 0) = (b*bdv = (-1)*a)"
29 lin_isolate_add2: "(a + bdv = 0) = ( bdv = (-1)*a)"
30 lin_isolate_div: "[|Not(b=0)|] ==> (b*bdv = c) = (bdv = c / b)"
35 val LinEq_prls = (*3.10.02:just the following order due to subterm evaluation*)
36 append_rls "LinEq_prls" e_rls
37 [Calc ("HOL.eq",eval_equal "#equal_"),
38 Calc ("Tools.matches",eval_matches ""),
39 Calc ("Tools.lhs" ,eval_lhs ""),
40 Calc ("Tools.rhs" ,eval_rhs ""),
41 Calc ("Poly.has'_degree'_in",eval_has_degree_in ""),
42 Calc ("Poly.is'_polyrat'_in",eval_is_polyrat_in ""),
43 Calc ("Atools.occurs'_in",eval_occurs_in ""),
44 Calc ("Atools.ident",eval_ident "#ident_"),
45 Thm ("not_true",num_str @{thm not_true}),
46 Thm ("not_false",num_str @{thm not_false}),
47 Thm ("and_true",num_str @{thm and_true}),
48 Thm ("and_false",num_str @{thm and_false}),
49 Thm ("or_true",num_str @{thm or_true}),
50 Thm ("or_false",num_str @{thm or_false})
52 (* ----- erls ----- *)
54 append_rls "LinEq_crls" poly_crls
55 [Thm ("real_assoc_1",num_str @{thm real_assoc_1})
58 Calc ("Fields.inverse_class.divide", eval_cancel "#divide_e"),
59 Calc ("Atools.pow" ,eval_binop "#power_"),
63 (* ----- crls ----- *)
65 append_rls "LinEq_erls" Poly_erls
66 [Thm ("real_assoc_1",num_str @{thm real_assoc_1})
69 Calc ("Fields.inverse_class.divide", eval_cancel "#divide_e"),
70 Calc ("Atools.pow" ,eval_binop "#power_"),
74 ruleset' := overwritelthy @{theory} (!ruleset',
75 [("LinEq_erls",LinEq_erls)(*FIXXXME:del with rls.rls'*)
78 setup {* KEStore_Elems.add_rlss
79 [("LinEq_erls", (Context.theory_name @{theory}, LinEq_erls))] *}
82 val LinPoly_simplify = prep_rls(
83 Rls {id = "LinPoly_simplify", preconds = [],
84 rew_ord = ("termlessI",termlessI),
87 calc = [], errpatts = [],
89 Thm ("real_assoc_1",num_str @{thm real_assoc_1}),
90 Calc ("Groups.plus_class.plus",eval_binop "#add_"),
91 Calc ("Groups.minus_class.minus",eval_binop "#sub_"),
92 Calc ("Groups.times_class.times",eval_binop "#mult_"),
94 Calc ("Fields.inverse_class.divide", eval_cancel "#divide_e"),
95 Calc ("NthRoot.sqrt",eval_sqrt "#sqrt_"),
97 Calc ("Atools.pow" ,eval_binop "#power_")
101 ruleset' := overwritelthy @{theory} (!ruleset',
102 [("LinPoly_simplify",LinPoly_simplify)]);
104 setup {* KEStore_Elems.add_rlss
105 [("LinPoly_simplify", (Context.theory_name @{theory}, LinPoly_simplify))] *}
108 (*isolate the bound variable in an linear equation; 'bdv' is a meta-constant*)
109 val LinEq_simplify = prep_rls(
110 Rls {id = "LinEq_simplify", preconds = [],
111 rew_ord = ("e_rew_ord",e_rew_ord),
114 calc = [], errpatts = [],
116 Thm("lin_isolate_add1",num_str @{thm lin_isolate_add1}),
117 (* a+bx=0 -> bx=-a *)
118 Thm("lin_isolate_add2",num_str @{thm lin_isolate_add2}),
120 Thm("lin_isolate_div",num_str @{thm lin_isolate_div})
123 scr = EmptyScr}:rls);
124 ruleset' := overwritelthy @{theory} (!ruleset',
125 [("LinEq_simplify",LinEq_simplify)]);
127 setup {* KEStore_Elems.add_rlss
128 [("LinEq_simplify", (Context.theory_name @{theory}, LinEq_simplify))] *}
131 (*----------------------------- problem types --------------------------------*)
134 (get_pbt ["linear","univariate","equation"]);
137 (* ---------linear----------- *)
139 (prep_pbt thy "pbl_equ_univ_lin" [] e_pblID
140 (["linear","univariate","equation"],
141 [("#Given" ,["equality e_e","solveFor v_v"]),
142 ("#Where" ,["HOL.False", (*WN0509 just detected: this pbl can never be used?!?*)
143 "Not( (lhs e_e) is_polyrat_in v_v)",
144 "Not( (rhs e_e) is_polyrat_in v_v)",
145 "((lhs e_e) has_degree_in v_v)=1",
146 "((rhs e_e) has_degree_in v_v)=1"]),
147 ("#Find" ,["solutions v_v'i'"])
149 LinEq_prls, SOME "solve (e_e::bool, v_v)",
150 [["LinEq","solve_lineq_equation"]]));
152 (*-------------- methods------------------------------------------------------*)
154 (prep_met thy "met_eqlin" [] e_metID
157 {rew_ord'="tless_true",rls'=Atools_erls,calc = [], srls = e_rls, prls=e_rls,
158 crls=LinEq_crls, errpats = [], nrls = norm_Poly}, "empty_script"));
160 (* ansprechen mit ["LinEq","solve_univar_equation"] *)
162 (prep_met thy "met_eq_lin" [] e_metID
163 (["LinEq","solve_lineq_equation"],
164 [("#Given", ["equality e_e", "solveFor v_v"]),
165 ("#Where", ["Not ((lhs e_e) is_polyrat_in v_v)",
166 "((lhs e_e) has_degree_in v_v) = 1"]),
167 ("#Find", ["solutions v_v'i'"])
169 {rew_ord'="termlessI", rls'=LinEq_erls, srls=e_rls, prls=LinEq_prls,
170 calc=[], crls=LinEq_crls, errpats = [], nrls = norm_Poly},
171 "Script Solve_lineq_equation (e_e::bool) (v_v::real) = " ^
172 "(let e_e =((Try (Rewrite all_left False)) @@ " ^
173 " (Try (Repeat (Rewrite makex1_x False))) @@ " ^
174 " (Try (Rewrite_Set expand_binoms False)) @@ " ^
175 " (Try (Repeat (Rewrite_Set_Inst [(bdv, v_v::real)] " ^
176 " make_ratpoly_in False))) @@ " ^
177 " (Try (Repeat (Rewrite_Set LinPoly_simplify False))))e_e;" ^
178 " e_e = ((Try (Rewrite_Set_Inst [(bdv, v_v::real)] " ^
179 " LinEq_simplify True)) @@ " ^
180 " (Repeat(Try (Rewrite_Set LinPoly_simplify False)))) e_e " ^
181 " in ((Or_to_List e_e)::bool list))"
183 get_met ["LinEq","solve_lineq_equation"];