src/Pure/isac/smltest/OLDTESTS/tacis.sml
author Walther Neuper <neuper@ist.tugraz.at>
Wed, 21 Jul 2010 13:53:39 +0200
branchisac-from-Isabelle2009-2
changeset 37871 875b6efa7ced
permissions -rw-r--r--
added isac-hook in Pure/thm and isac-code
neuper@37871
     1
(* 
neuper@37871
     2
 use"systest/tacis.sml";
neuper@37871
     3
 use"tacis.sml";
neuper@37871
     4
   *)
neuper@37871
     5
"=================================================================";
neuper@37871
     6
"------ fetchProposedTactic -> autoCalculate (Step1 ) ------------";
neuper@37871
     7
"------ setNextTactic -> autoCalculate (Step1 ) ------------------";
neuper@37871
     8
"=================================================================";
neuper@37871
     9
neuper@37871
    10
neuper@37871
    11
neuper@37871
    12
"------ fetchProposedTactic -> autoCalculate (Step1 ) ------------";
neuper@37871
    13
"------ fetchProposedTactic -> autoCalculate (Step1 ) ------------";
neuper@37871
    14
"------ fetchProposedTactic -> autoCalculate (Step1 ) ------------";
neuper@37871
    15
 states:=[];
neuper@37871
    16
 CalcTree [(["equality (x+1=2)", "solveFor x","solutions L"], 
neuper@37871
    17
	    ("Test.thy", 
neuper@37871
    18
	     ["sqroot-test","univariate","equation","test"],
neuper@37871
    19
	     ["Test","squ-equ-test-subpbl1"]))];
neuper@37871
    20
 Iterator 1; moveActiveRoot 1;
neuper@37871
    21
 autoCalculate 1 CompleteCalcHead;
neuper@37871
    22
 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1) (*x + 1 = 2*);
neuper@37871
    23
neuper@37871
    24
 fetchProposedTactic 1 (*'Rewrite_Set norm_equation' in tacis*);
neuper@37871
    25
 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1) (*x + 1 + -1 * 2 = 0*);
neuper@37871
    26
neuper@37871
    27
 fetchProposedTactic 1 (*'Rewrite_Set Test_simplify' in tacis*);
neuper@37871
    28
 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1) (*-1 + x = 0*);
neuper@37871
    29
 val ((pt,_),_) = get_calc 1;
neuper@37871
    30
 val str = pr_ptree pr_short pt;
neuper@37871
    31
 writeln str;
neuper@37871
    32
neuper@37871
    33
 fetchProposedTactic 1 (*'Subproblem ...' in tacis*);
neuper@37871
    34
 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1) (*solve (-1 + x = 0,x)*);
neuper@37871
    35
neuper@37871
    36
 fetchProposedTactic 1 (*'Model_Problem' in tacis*);
neuper@37871
    37
 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1) (*equality ///*);
neuper@37871
    38
(*----- WN060222 since complete_mod_ case cas of Some headline -----
neuper@37871
    39
 fetchProposedTactic 1 (*'Add_Given equality (-1 + x = 0)' in tacis*);
neuper@37871
    40
 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1) (*equality (-1 + x =0)*);
neuper@37871
    41
---------------------------------------------------------------------*)
neuper@37871
    42
neuper@37871
    43
 fetchProposedTactic 1 (*'Add_Given solveFor x' in tacis*);
neuper@37871
    44
(*----- WN060222 since complete_mod_ case cas of Some headline:
neuper@37871
    45
                       (*Specify_Theory Test.thy*)
neuper@37871
    46
---------------------------------------------------------------------*)
neuper@37871
    47
 autoCalculate 1 CompleteCalcHead; refFormula 1 (get_pos 1 1) (*OK*);
neuper@37871
    48
 (*###########################################autoCalculate 1 (Step 1);*)
neuper@37871
    49
 fetchProposedTactic 1 (*'Apply_Method Test solve_linear' in tacis*);
neuper@37871
    50
 (* there was the only error ^^^^^^^^^ in step/nxt_solv ..Apply_Method..
neuper@37871
    51
 val (str', (tacis', (pt',p'))) = step ip (ptp, tacis);
neuper@37871
    52
 writeln (tacis2str tacis');
neuper@37871
    53
 ######################################################################*)
neuper@37871
    54
 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1) (*-1 + x = 0*);
neuper@37871
    55
neuper@37871
    56
 fetchProposedTactic 1 (*'Rewrite_Set_Inst isolate_bdv' in tacis*);
neuper@37871
    57
 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1) (*x = 0 + -1 * -1*);
neuper@37871
    58
neuper@37871
    59
 fetchProposedTactic 1 (*'Rewrite_Set Test_simplify' in tacis*);
neuper@37871
    60
 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1) (*x = 1*);
neuper@37871
    61
 val ((pt,_),_) = get_calc 1;
neuper@37871
    62
 val str = pr_ptree pr_short pt;
neuper@37871
    63
 writeln str;
neuper@37871
    64
neuper@37871
    65
 fetchProposedTactic 1 (*'Check_Postcond linear...' in tacis*);
neuper@37871
    66
 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1) (*[x = 1]*);
neuper@37871
    67
neuper@37871
    68
 fetchProposedTactic 1 (*'Check_elementwise Assumptions' in tacis*);
neuper@37871
    69
 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1) (*[x = 1]*);
neuper@37871
    70
neuper@37871
    71
 fetchProposedTactic 1 (*'Check_Postcond sqroot-test...' in tacis*);
neuper@37871
    72
 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1) (*[x = 1]*);
neuper@37871
    73
neuper@37871
    74
 fetchProposedTactic 1 (*'' in tacis*);
neuper@37871
    75
 val ((pt,p),tacis) = get_calc 1;
neuper@37871
    76
 val ip = get_pos 1 1;
neuper@37871
    77
 val (Form f, tac, asms) = pt_extract (pt, p);
neuper@37871
    78
 if term2str f = "[x = 1]"andalso p = ([],Res) andalso ip = ([],Res)then()else 
neuper@37871
    79
 raise error "tacis.sml: diff.behav. in fetchProposedTactic autoCalculate";
neuper@37871
    80
neuper@37871
    81
neuper@37871
    82
neuper@37871
    83
"------ setNextTactic -> autoCalculate (Step1 ) ------------------";
neuper@37871
    84
"------ setNextTactic -> autoCalculate (Step1 ) ------------------";
neuper@37871
    85
"------ setNextTactic -> autoCalculate (Step1 ) ------------------";
neuper@37871
    86
 states:=[];
neuper@37871
    87
 CalcTree [(["equality (x+1=2)", "solveFor x","solutions L"], 
neuper@37871
    88
	    ("Test.thy", 
neuper@37871
    89
	     ["sqroot-test","univariate","equation","test"],
neuper@37871
    90
	     ["Test","squ-equ-test-subpbl1"]))];
neuper@37871
    91
 Iterator 1; moveActiveRoot 1;
neuper@37871
    92
 autoCalculate 1 CompleteCalcHead;
neuper@37871
    93
 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1) (*x + 1 = 2*);
neuper@37871
    94
neuper@37871
    95
 setNextTactic 1 (Rewrite_Set "norm_equation");
neuper@37871
    96
 val (_, tacis) = get_calc 1;
neuper@37871
    97
 case tacis of [(Rewrite_Set "norm_equation",_,(([1], Res), _))] => () | _ =>
neuper@37871
    98
 raise error "tacis.sml: diff.behav. in setNextTactic -> autoCalculate (1)"; 
neuper@37871
    99
 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1) (*x + 1 + -1 * 2 = 0*);
neuper@37871
   100
neuper@37871
   101
 setNextTactic 1 (Rewrite_Set "Test_simplify");
neuper@37871
   102
 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1) (*-1 + x = 0*);
neuper@37871
   103
 val ((pt,_),_) = get_calc 1;
neuper@37871
   104
 val str = pr_ptree pr_short pt;
neuper@37871
   105
 writeln str;
neuper@37871
   106
neuper@37871
   107
 setNextTactic 1 (Subproblem ("Test.thy",["linear","univariate",
neuper@37871
   108
					  "equation","test"]));
neuper@37871
   109
 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1) (*solve (-1 + x = 0, x)*);
neuper@37871
   110
 val ((pt,_),_) = get_calc 1;
neuper@37871
   111
 val str = pr_ptree pr_short pt;
neuper@37871
   112
 writeln str;
neuper@37871
   113
neuper@37871
   114
 setNextTactic 1 (Model_Problem (*["linear","univariate","equation","test"]*));
neuper@37871
   115
 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1) (*equality ///*);
neuper@37871
   116
neuper@37871
   117
 setNextTactic 1 (Add_Given "equality (-1 + x = 0)");
neuper@37871
   118
 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1) (*equality (-1 + x = 0)*);
neuper@37871
   119
neuper@37871
   120
 setNextTactic 1 (Add_Given "solveFor x");
neuper@37871
   121
 autoCalculate 1 CompleteCalcHead; refFormula 1 (get_pos 1 1) (*OK*);
neuper@37871
   122
neuper@37871
   123
 setNextTactic 1 (Apply_Method ["Test", "solve_linear"]);
neuper@37871
   124
 val (_, tacis) = get_calc 1;
neuper@37871
   125
 case tacis of 
neuper@37871
   126
     [((Apply_Method ["Test","solve_linear"],_,(([3,1], Frm), _)))] =>() | _ =>
neuper@37871
   127
 raise error "tacis.sml: diff.behav. in setNextTactic -> autoCalculate (2)"; 
neuper@37871
   128
 (*#######################################################################*)
neuper@37871
   129
 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1) (*-1 + x = 0*);
neuper@37871
   130
neuper@37871
   131
 setNextTactic 1 (Rewrite_Set_Inst (["(bdv,x)"], "isolate_bdv"));
neuper@37871
   132
 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1) (*x = 0 + -1 * -1*);
neuper@37871
   133
neuper@37871
   134
 setNextTactic 1 (Rewrite_Set "Test_simplify");
neuper@37871
   135
 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1) (*x = 1*);
neuper@37871
   136
neuper@37871
   137
 setNextTactic 1 (Check_Postcond ["linear","univariate","equation","test"]);
neuper@37871
   138
 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1) (*[x = 1]*);
neuper@37871
   139
neuper@37871
   140
 setNextTactic 1 (Check_elementwise "Assumptions");
neuper@37871
   141
 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1) (*[x = 1]*);
neuper@37871
   142
 val ((pt,_),_) = get_calc 1;
neuper@37871
   143
 val str = pr_ptree pr_short pt;
neuper@37871
   144
 writeln str;
neuper@37871
   145
neuper@37871
   146
 setNextTactic 1 (Check_Postcond 
neuper@37871
   147
		      ["sqroot-test","univariate","equation","test"]);
neuper@37871
   148
 val (_, tacis) = get_calc 1;
neuper@37871
   149
 
neuper@37871
   150
 (*case tacis of      040609 suddenly ???!
neuper@37871
   151
     [((Check_Postcond _, _,(([], Res), _)))] =>() | _ =>
neuper@37871
   152
 raise error "tacis.sml: diff.behav. in setNextTactic -> autoCalculate (3)"; 
neuper@37871
   153
 #######################################################################*)
neuper@37871
   154
 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1) (*[x = 1]*);
neuper@37871
   155
neuper@37871
   156
 val ((pt,p),tacis) = get_calc 1;
neuper@37871
   157
 val ip = get_pos 1 1;
neuper@37871
   158
 val (Form f, tac, asms) = pt_extract (pt, p);
neuper@37871
   159
 if term2str f = "[x = 1]"andalso p = ([],Res) andalso ip = ([],Res)then()else 
neuper@37871
   160
 raise error "tacis.sml: diff.behav. in setNextTactic -> autoCalculate (4)"; 
neuper@37871
   161
neuper@37871
   162
neuper@37871
   163