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
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@41931
    24
val ctxt = ProofContext.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@41936
    56
(*========== inhibit exn WN110318 ==============================================
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@41931
    61
val (p,_,f,nxt,_,pt) = me nxt p c pt; 
neuper@41933
    62
val (p,_,f,nxt,_,pt) = me nxt p c pt; 
neuper@41936
    63
============ inhibit exn WN110318 ============================================*)
neuper@41936
    64
neuper@41936
    65
"----------- rewriting for usecase2 ---------------------";
neuper@41936
    66
"----------- rewriting for usecase2 ---------------------";
neuper@41936
    67
val thy = @{theory "Test"};
neuper@41936
    68
"----------- rewriting for usecase2 ---------------------";
neuper@41936
    69
bonzai@41949
    70
val t = case parseNEW ctxt "xxx + abc + -1 * 111 + (123::int)" of
bonzai@41949
    71
      SOME t' => t'
bonzai@41949
    72
    | NONE => error "diophanteq.sml: syntax error in rewriting for usecase2";
neuper@41936
    73
neuper@41936
    74
val SOME (thmID,thm) = get_calculation_ thy (the(assoc(calclist,"TIMES"))) t; 
neuper@41936
    75
val SOME (t,_) = rewrite_ thy tless_true tval_rls true thm t; term2str t;
neuper@41936
    76
neuper@41936
    77
val SOME (thmID,thm) = get_calculation_ thy (the(assoc(calclist,"PLUS"))) t; 
neuper@41936
    78
val SOME (t,_) = rewrite_ thy tless_true tval_rls true thm t; term2str t;
neuper@41936
    79
neuper@41936
    80
neuper@41936
    81
"----------- mathengine with usecase2 -------------------";
neuper@41936
    82
"----------- mathengine with usecase2 -------------------";
neuper@41936
    83
"----------- mathengine with usecase2 -------------------";
neuper@41936
    84
val p = e_pos'; val c = [];
neuper@41936
    85
val (fmz, (thy, pbl, met)) = 
neuper@41936
    86
  (["intTestGiven (xxx + abc + -1 * 111 + (123::int))", "intTestFind sss"],
neuper@41936
    87
   (Context.theory_name thy, ["inttype","test"], ["Test","intsimp"]));
neuper@41936
    88
val (p,_,f,nxt,_,pt) = CalcTreeTEST [(fmz, (thy, pbl, met))];
neuper@41936
    89
(*nxt = ("Model_Problem", ...)*)
neuper@41936
    90
val (p,_,f,nxt,_,pt) = me nxt p c pt; 
neuper@41936
    91
(*nxt = ("Add_Given", Add_Given "intTestGiven (xxx + abc + -1 * 111 + 123)")*)
neuper@41936
    92
val (p,_,f,nxt,_,pt) = me nxt p c pt; 
neuper@41936
    93
(* Add_Find ###########################################*)
neuper@41936
    94
val (p,_,f,nxt,_,pt) = me nxt p c pt; 
neuper@41936
    95
(*nxt = ("Specify_Theory", ...)*)
neuper@41936
    96
val (p,_,f,nxt,_,pt) = me nxt p c pt; 
neuper@41936
    97
(*nxt = ("Specify_Problem", ...)*)
neuper@41936
    98
val (p,_,f,nxt,_,pt) = me nxt p c pt; 
neuper@41936
    99
(*nxt = ("Specify_Method", ...)*)
neuper@41936
   100
val (p,_,f,nxt,_,pt) = me nxt p c pt; 
neuper@41936
   101
(*nxt = ("Empty_Tac", ...) #############################*)
neuper@41936
   102
val (p,_,f,nxt,_,pt) = me nxt p c pt; 
neuper@41936
   103
(*========== inhibit exn WN110318 ==============================================
neuper@41936
   104
============ inhibit exn WN110318 ============================================*)