test/Tools/isac/Knowledge/diophanteq.sml
author Thomas Leh <t.leh@gmx.at>
Fri, 22 Jul 2011 14:01:09 +0200
branchdecompose-isar
changeset 42166 911c49949ba9
parent 41951 50bc995aa45b
child 48761 4162c4f6f897
permissions -rw-r--r--
tuned
     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
     6 *)
     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 "--------------------------------------------------------";
    17 
    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
    20   from CalcTreeTest*)
    21 (*val thy = @{theory "Isac"};toplevel error from store_met?!?*)
    22 *)
    23 val thy = @{theory "DiophantEq"};
    24 val ctxt = ProofContext.init_global thy;
    25 
    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
    33       SOME t' => t'
    34     | NONE => error "diophanteq.sml: syntax error in rewriting for usecase1";
    35 
    36 val SOME (t,_) = rewrite_inst_ thy e_rew_ord e_rls true subst 
    37   (num_str @{thm "int_isolate_add"}) t; term2str t;
    38 
    39 val SOME (thmID,thm) = get_calculation_ thy (the(assoc(calclist,"TIMES"))) t; 
    40 val SOME (t,_) = rewrite_ thy tless_true tval_rls true thm t; term2str t;
    41 
    42 val SOME (thmID,thm) = get_calculation_ thy (the(assoc(calclist,"PLUS"))) t; 
    43 val SOME (t,_) = rewrite_ thy tless_true tval_rls true thm t; term2str t;
    44 
    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", 
    51     "intTestFind sss"],
    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 val (p,_,f,nxt,_,pt) = me nxt p c pt; 
    61 val (p,_,f,nxt,_,pt) = me nxt p c pt; 
    62 
    63 "----------- rewriting for usecase2 ---------------------";
    64 "----------- rewriting for usecase2 ---------------------";
    65 val thy = @{theory "Test"};
    66 "----------- rewriting for usecase2 ---------------------";
    67 
    68 val t = case parseNEW ctxt "xxx + abc + -1 * 111 + (123::int)" of
    69       SOME t' => t'
    70     | NONE => error "diophanteq.sml: syntax error in rewriting for usecase2";
    71 
    72 val SOME (thmID,thm) = get_calculation_ thy (the(assoc(calclist,"TIMES"))) t; 
    73 val SOME (t,_) = rewrite_ thy tless_true tval_rls true thm t; term2str t;
    74 
    75 val SOME (thmID,thm) = get_calculation_ thy (the(assoc(calclist,"PLUS"))) t; 
    76 val SOME (t,_) = rewrite_ thy tless_true tval_rls true thm t; term2str t;
    77 
    78 
    79 "----------- mathengine with usecase2 -------------------";
    80 "----------- mathengine with usecase2 -------------------";
    81 "----------- mathengine with usecase2 -------------------";
    82 val p = e_pos'; val c = [];
    83 val (fmz, (thy, pbl, met)) = 
    84   (["intTestGiven (xxx + abc + -1 * 111 + (123::int))", "intTestFind sss"],
    85    (Context.theory_name thy, ["inttype","test"], ["Test","intsimp"]));
    86 val (p,_,f,nxt,_,pt) = CalcTreeTEST [(fmz, (thy, pbl, met))];
    87 (*nxt = ("Model_Problem", ...)*)
    88 val (p,_,f,nxt,_,pt) = me nxt p c pt; 
    89 (*nxt = ("Add_Given", Add_Given "intTestGiven (xxx + abc + -1 * 111 + 123)")*)
    90 val (p,_,f,nxt,_,pt) = me nxt p c pt; 
    91 (* Add_Find ###########################################*)
    92 val (p,_,f,nxt,_,pt) = me nxt p c pt; 
    93 (*nxt = ("Specify_Theory", ...)*)
    94 val (p,_,f,nxt,_,pt) = me nxt p c pt; 
    95 (*nxt = ("Specify_Problem", ...)*)
    96 val (p,_,f,nxt,_,pt) = me nxt p c pt; 
    97 (*nxt = ("Specify_Method", ...)*)
    98 val (p,_,f,nxt,_,pt) = me nxt p c pt; 
    99 (*nxt = ("Empty_Tac", ...) #############################*)
   100 val (p,_,f,nxt,_,pt) = me nxt p c pt; 
   101