1 (* Title: tests on DiophantEq.thy
2 Author: Mathias Lehnfeld 2011
3 (c) due to copyright terms
4 12345678901234567890123456789012345678901234567890123456789012345678901234567890
5 10 20 30 40 50 60 70 80
7 "--------------------------------------------------------";
8 "table of contents --------------------------------------";
9 "--------------------------------------------------------";
10 "----------- rewriting for usecase1 ---------------------";
11 "----------- mathengine with usecase1 -------------------";
12 "----------- rewriting for usecase2 ---------------------";
13 "----------- mathengine with usecase2 -------------------";
14 "--------------------------------------------------------";
15 "--------------------------------------------------------";
16 "--------------------------------------------------------";
18 (*there seemed to be no way to do these tests within DiophantEq.thy:
19 val thy = @{theory};(**** ME_Isa: thy 'DiophantEq' not in system
21 (*val thy = @{theory "Isac_Knowledge"};toplevel error from store_met?!?*)
23 val thy = @{theory "DiophantEq"};
24 val ctxt = Proof_Context.init_global thy;
26 "----------- rewriting for usecase1 ---------------------";
27 "----------- rewriting for usecase1 ---------------------";
28 "----------- rewriting for usecase1 ---------------------";
29 val subst = case (parseNEW ctxt "bdv::int", parseNEW ctxt "xxx::int") of
30 (SOME r, SOME s) => [(r,s)]
31 | _ => error "diophanteq.sml: syntax error in rewriting for usecase1"
32 val t = case parseNEW ctxt "xxx + 111 = abc + (123::int)" of
34 | NONE => error "diophanteq.sml: syntax error in rewriting for usecase1";
36 val SOME (t,_) = rewrite_inst_ ctxt Rewrite_Ord.function_empty Rule_Set.empty true subst
37 @{thm "int_isolate_add"} t; UnparseC.term t;
39 val SOME (thmID,thm) = adhoc_thm thy (the(LibraryC.assoc(KEStore_Elems.get_calcs @{theory},"TIMES"))) t;
40 val SOME (t,_) = rewrite_ ctxt tless_true tval_rls true thm t; UnparseC.term t;
42 val SOME (thmID,thm) = adhoc_thm thy (the(LibraryC.assoc(KEStore_Elems.get_calcs @{theory},"PLUS"))) t;
43 val SOME (t,_) = rewrite_ ctxt tless_true tval_rls true thm t; UnparseC.term t;
45 "----------- mathengine with usecase1 -------------------";
46 "----------- mathengine with usecase1 -------------------";
47 "----------- mathengine with usecase1 -------------------";
48 val p = e_pos'; val c = [];
49 val (fmz, (thy, pbl, met)) =
50 (["boolTestGiven (xxx + 111 = abc + (123::int))", "intTestGiven xxx",
52 (Context.theory_name thy, ["diophantine", "equation"],
53 ["Test", "solve_diophant"]));
54 val (p,_,f,nxt,_,pt) = CalcTreeTEST [(fmz, (thy, pbl, met))];
55 val (p,_,f,nxt,_,pt) = me nxt p c pt;
56 val (p,_,f,nxt,_,pt) = me nxt p c pt;
57 val (p,_,f,nxt,_,pt) = me nxt p c pt;
58 val (p,_,f,nxt,_,pt) = me nxt p c pt;
59 val (p,_,f,nxt,_,pt) = me nxt p c pt;
60 (* BROKEN WITH 62e72f77e695 excluded "ERROR in creating the environment.." FROM "helpless"
61 val (p,_,f,nxt,_,pt) = me nxt p c pt;
62 val (p,_,f,nxt,_,pt) = me nxt p c pt;
65 "----------- rewriting for usecase2 ---------------------";
66 "----------- rewriting for usecase2 ---------------------";
67 val thy = @{theory "Test"};
68 "----------- rewriting for usecase2 ---------------------";
70 val t = case parseNEW ctxt "xxx + abc + - 1 * 111 + (123::int)" of
72 | NONE => error "diophanteq.sml: syntax error in rewriting for usecase2";
74 val SOME (thmID,thm) = adhoc_thm thy (the(LibraryC.assoc(KEStore_Elems.get_calcs @{theory},"TIMES"))) t;
75 val SOME (t,_) = rewrite_ ctxt tless_true tval_rls true thm t; UnparseC.term t;
77 val SOME (thmID,thm) = adhoc_thm thy (the(LibraryC.assoc(KEStore_Elems.get_calcs @{theory},"PLUS"))) t;
78 val SOME (t,_) = rewrite_ ctxt tless_true tval_rls true thm t; UnparseC.term t;
81 "----------- mathengine with usecase2 -------------------";
82 "----------- mathengine with usecase2 -------------------";
83 "----------- mathengine with usecase2 -------------------";
84 val p = e_pos'; val c = [];
85 val (fmz, (thy, pbl, met)) =
86 (["intTestGiven (xxx + abc + - 1 * 111 + (123::int))", "intTestFind sss"],
87 (Context.theory_name thy, ["inttype", "test"], ["Test", "intsimp"]));
88 val (p,_,f,nxt,_,pt) = CalcTreeTEST [(fmz, (thy, pbl, met))];
89 (*nxt = ("Model_Problem", ...)*)
90 val (p,_,f,nxt,_,pt) = me nxt p c pt;
91 (*nxt = ("Add_Given", Add_Given "intTestGiven (xxx + abc + - 1 * 111 + 123)")*)
92 val (p,_,f,nxt,_,pt) = me nxt p c pt;
93 (* Add_Find ###########################################*)
94 val (p,_,f,nxt,_,pt) = me nxt p c pt;
95 (*nxt = ("Specify_Theory", ...)*)
96 val (p,_,f,nxt,_,pt) = me nxt p c pt;
97 (* BROKEN WITH 62e72f77e695 excluded "ERROR in creating the environment.." FROM "helpless"
98 (*nxt = ("Specify_Problem", ...)*)
99 val (p,_,f,nxt,_,pt) = me nxt p c pt;
100 (*nxt = ("Specify_Method", ...)*)
101 val (p,_,f,nxt,_,pt) = me nxt p c pt;
102 (*nxt = ("Empty_Tac", ...) #############################*)
103 val (p,_,f,nxt,_,pt) = me nxt p c pt;