test/Tools/isac/Knowledge/diophanteq.sml
author Mathias Lehnfeld <bonzai@inode.at>
Thu, 07 Apr 2011 16:31:05 +0200
branchdecompose-isar
changeset 41951 50bc995aa45b
parent 41949 c1859b72ae8d
child 42166 911c49949ba9
permissions -rw-r--r--
intermed. context integration

- prep_ori works with parseNEW
- unused thy function parameters removed
- thy parameter replaced by ctxt where useful
- appl_add adjusted and cleaned up - still uses parse due to error
- seek_oridts cleaned up
- split_dts cleaned up
     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 (*========== inhibit exn WN110318 ==============================================
    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 val (p,_,f,nxt,_,pt) = me nxt p c pt; 
    63 ============ inhibit exn WN110318 ============================================*)
    64 
    65 "----------- rewriting for usecase2 ---------------------";
    66 "----------- rewriting for usecase2 ---------------------";
    67 val thy = @{theory "Test"};
    68 "----------- rewriting for usecase2 ---------------------";
    69 
    70 val t = case parseNEW ctxt "xxx + abc + -1 * 111 + (123::int)" of
    71       SOME t' => t'
    72     | NONE => error "diophanteq.sml: syntax error in rewriting for usecase2";
    73 
    74 val SOME (thmID,thm) = get_calculation_ thy (the(assoc(calclist,"TIMES"))) t; 
    75 val SOME (t,_) = rewrite_ thy tless_true tval_rls true thm t; term2str t;
    76 
    77 val SOME (thmID,thm) = get_calculation_ thy (the(assoc(calclist,"PLUS"))) t; 
    78 val SOME (t,_) = rewrite_ thy tless_true tval_rls true thm t; term2str t;
    79 
    80 
    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 (*nxt = ("Specify_Problem", ...)*)
    98 val (p,_,f,nxt,_,pt) = me nxt p c pt; 
    99 (*nxt = ("Specify_Method", ...)*)
   100 val (p,_,f,nxt,_,pt) = me nxt p c pt; 
   101 (*nxt = ("Empty_Tac", ...) #############################*)
   102 val (p,_,f,nxt,_,pt) = me nxt p c pt; 
   103 (*========== inhibit exn WN110318 ==============================================
   104 ============ inhibit exn WN110318 ============================================*)