test/Tools/isac/Knowledge/diophanteq.sml
author Walther Neuper <neuper@ist.tugraz.at>
Fri, 12 Oct 2012 17:06:58 +0200
changeset 48761 4162c4f6f897
parent 42166 911c49949ba9
child 59238 b0c4aafb9d06
permissions -rw-r--r--
2011-->2012: ProofContext-->Proof_Context

once more; was reverted before
neuper@41931
     1
(* Title:  tests on DiophantEq.thy
neuper@41931
     2
   Author: Mathias Lehnfeld 2011
neuper@41931
     3
   (c) due to copyright terms
neuper@41931
     4
12345678901234567890123456789012345678901234567890123456789012345678901234567890
neuper@41931
     5
        10        20        30        40        50        60        70        80
neuper@41931
     6
*)
neuper@41931
     7
"--------------------------------------------------------";
neuper@41931
     8
"table of contents --------------------------------------";
neuper@41931
     9
"--------------------------------------------------------";
neuper@41931
    10
"----------- rewriting for usecase1 ---------------------";
neuper@41931
    11
"----------- mathengine with usecase1 -------------------";
neuper@41936
    12
"----------- rewriting for usecase2 ---------------------";
neuper@41936
    13
"----------- mathengine with usecase2 -------------------";
neuper@41931
    14
"--------------------------------------------------------";
neuper@41931
    15
"--------------------------------------------------------";
neuper@41931
    16
"--------------------------------------------------------";
neuper@41931
    17
neuper@41936
    18
(*there seemed to be no way to do these tests within DiophantEq.thy:
neuper@41931
    19
val thy = @{theory};(**** ME_Isa: thy 'DiophantEq' not in system
neuper@41931
    20
  from CalcTreeTest*)
neuper@41932
    21
(*val thy = @{theory "Isac"};toplevel error from store_met?!?*)
neuper@41931
    22
*)
neuper@41931
    23
val thy = @{theory "DiophantEq"};
neuper@48761
    24
val ctxt = Proof_Context.init_global thy;
neuper@41931
    25
neuper@41931
    26
"----------- rewriting for usecase1 ---------------------";
neuper@41931
    27
"----------- rewriting for usecase1 ---------------------";
neuper@41931
    28
"----------- rewriting for usecase1 ---------------------";
bonzai@41951
    29
val subst = case (parseNEW ctxt "bdv::int", parseNEW ctxt "xxx::int") of
bonzai@41951
    30
      (SOME r, SOME s) => [(r,s)]
bonzai@41951
    31
    | _ => error "diophanteq.sml: syntax error in rewriting for usecase1"
bonzai@41949
    32
val t = case parseNEW ctxt "xxx + 111 = abc + (123::int)" of
bonzai@41949
    33
      SOME t' => t'
bonzai@41949
    34
    | NONE => error "diophanteq.sml: syntax error in rewriting for usecase1";
neuper@41931
    35
neuper@41931
    36
val SOME (t,_) = rewrite_inst_ thy e_rew_ord e_rls true subst 
neuper@41931
    37
  (num_str @{thm "int_isolate_add"}) t; term2str t;
neuper@41931
    38
neuper@41931
    39
val SOME (thmID,thm) = get_calculation_ thy (the(assoc(calclist,"TIMES"))) t; 
neuper@41931
    40
val SOME (t,_) = rewrite_ thy tless_true tval_rls true thm t; term2str t;
neuper@41931
    41
neuper@41931
    42
val SOME (thmID,thm) = get_calculation_ thy (the(assoc(calclist,"PLUS"))) t; 
neuper@41931
    43
val SOME (t,_) = rewrite_ thy tless_true tval_rls true thm t; term2str t;
neuper@41931
    44
neuper@41931
    45
"----------- mathengine with usecase1 -------------------";
neuper@41931
    46
"----------- mathengine with usecase1 -------------------";
neuper@41931
    47
"----------- mathengine with usecase1 -------------------";
neuper@41934
    48
val p = e_pos'; val c = [];
neuper@41934
    49
val (fmz, (thy, pbl, met)) = 
neuper@41936
    50
  (["boolTestGiven (xxx + 111 = abc + (123::int))", "intTestGiven xxx", 
neuper@41936
    51
    "intTestFind sss"],
neuper@41934
    52
   (Context.theory_name thy, ["diophantine", "equation"], 
neuper@41934
    53
    ["Test", "solve_diophant"]));
neuper@41934
    54
val (p,_,f,nxt,_,pt) = CalcTreeTEST [(fmz, (thy, pbl, met))];
neuper@41931
    55
val (p,_,f,nxt,_,pt) = me nxt p c pt; 
neuper@41931
    56
val (p,_,f,nxt,_,pt) = me nxt p c pt; 
neuper@41931
    57
val (p,_,f,nxt,_,pt) = me nxt p c pt; 
neuper@41931
    58
val (p,_,f,nxt,_,pt) = me nxt p c pt; 
neuper@41931
    59
val (p,_,f,nxt,_,pt) = me nxt p c pt; 
neuper@41931
    60
val (p,_,f,nxt,_,pt) = me nxt p c pt; 
neuper@41933
    61
val (p,_,f,nxt,_,pt) = me nxt p c pt; 
neuper@41936
    62
neuper@41936
    63
"----------- rewriting for usecase2 ---------------------";
neuper@41936
    64
"----------- rewriting for usecase2 ---------------------";
neuper@41936
    65
val thy = @{theory "Test"};
neuper@41936
    66
"----------- rewriting for usecase2 ---------------------";
neuper@41936
    67
bonzai@41949
    68
val t = case parseNEW ctxt "xxx + abc + -1 * 111 + (123::int)" of
bonzai@41949
    69
      SOME t' => t'
bonzai@41949
    70
    | NONE => error "diophanteq.sml: syntax error in rewriting for usecase2";
neuper@41936
    71
neuper@41936
    72
val SOME (thmID,thm) = get_calculation_ thy (the(assoc(calclist,"TIMES"))) t; 
neuper@41936
    73
val SOME (t,_) = rewrite_ thy tless_true tval_rls true thm t; term2str t;
neuper@41936
    74
neuper@41936
    75
val SOME (thmID,thm) = get_calculation_ thy (the(assoc(calclist,"PLUS"))) t; 
neuper@41936
    76
val SOME (t,_) = rewrite_ thy tless_true tval_rls true thm t; term2str t;
neuper@41936
    77
neuper@41936
    78
neuper@41936
    79
"----------- mathengine with usecase2 -------------------";
neuper@41936
    80
"----------- mathengine with usecase2 -------------------";
neuper@41936
    81
"----------- mathengine with usecase2 -------------------";
neuper@41936
    82
val p = e_pos'; val c = [];
neuper@41936
    83
val (fmz, (thy, pbl, met)) = 
neuper@41936
    84
  (["intTestGiven (xxx + abc + -1 * 111 + (123::int))", "intTestFind sss"],
neuper@41936
    85
   (Context.theory_name thy, ["inttype","test"], ["Test","intsimp"]));
neuper@41936
    86
val (p,_,f,nxt,_,pt) = CalcTreeTEST [(fmz, (thy, pbl, met))];
neuper@41936
    87
(*nxt = ("Model_Problem", ...)*)
neuper@41936
    88
val (p,_,f,nxt,_,pt) = me nxt p c pt; 
neuper@41936
    89
(*nxt = ("Add_Given", Add_Given "intTestGiven (xxx + abc + -1 * 111 + 123)")*)
neuper@41936
    90
val (p,_,f,nxt,_,pt) = me nxt p c pt; 
neuper@41936
    91
(* Add_Find ###########################################*)
neuper@41936
    92
val (p,_,f,nxt,_,pt) = me nxt p c pt; 
neuper@41936
    93
(*nxt = ("Specify_Theory", ...)*)
neuper@41936
    94
val (p,_,f,nxt,_,pt) = me nxt p c pt; 
neuper@41936
    95
(*nxt = ("Specify_Problem", ...)*)
neuper@41936
    96
val (p,_,f,nxt,_,pt) = me nxt p c pt; 
neuper@41936
    97
(*nxt = ("Specify_Method", ...)*)
neuper@41936
    98
val (p,_,f,nxt,_,pt) = me nxt p c pt; 
neuper@41936
    99
(*nxt = ("Empty_Tac", ...) #############################*)
neuper@41936
   100
val (p,_,f,nxt,_,pt) = me nxt p c pt; 
t@42166
   101