test/Tools/isac/IsacKnowledge/diffapp.sml
branchisac-update-Isa09-2
changeset 37926 e6fc98fbcb85
parent 37924 6c53fe2519e5
equal deleted inserted replaced
37925:d957275620d4 37926:e6fc98fbcb85
   292 val (p,_,f,nxt,_,pt) = me nxt p c pt;
   292 val (p,_,f,nxt,_,pt) = me nxt p c pt;
   293 case nxt of (_,Apply_Method ["DiffApp","max_by_calculus"] ) => ()
   293 case nxt of (_,Apply_Method ["DiffApp","max_by_calculus"] ) => ()
   294 	  | _ => raise error "diffapp.sml: max-exp me, nxt = Apply_Method";
   294 	  | _ => raise error "diffapp.sml: max-exp me, nxt = Apply_Method";
   295 val (p,_,f,nxt,_,pt) = me nxt p c pt;
   295 val (p,_,f,nxt,_,pt) = me nxt p c pt;
   296 
   296 
   297 (*since 0508 Apply_Method does the 1st step, if None init_form -------------
   297 (*since 0508 Apply_Method does the 1st step, if NONE init_form -------------
   298 (*val nxt = ("Subproblem",Subproblem ("DiffApp.thy",["make","function"]))*)
   298 (*val nxt = ("Subproblem",Subproblem ("DiffApp.thy",["make","function"]))*)
   299 val (p,_,f,nxt,_,pt) = (me nxt p c pt) handle e => print_exn_G e;
   299 val (p,_,f,nxt,_,pt) = (me nxt p c pt) handle e => print_exn_G e;
   300 (*val nxt = ("Refine_Tacitly",Refine_Tacitly ["make","function"])*)
   300 (*val nxt = ("Refine_Tacitly",Refine_Tacitly ["make","function"])*)
   301 val (p,_,f,nxt,_,pt) = me nxt p c pt;
   301 val (p,_,f,nxt,_,pt) = me nxt p c pt;
   302 (*val nxt = ("Model_Problem",Model_Problem ["by_explicit","make","function"])*)
   302 (*val nxt = ("Model_Problem",Model_Problem ["by_explicit","make","function"])*)
   474 (*--- 1.line in script ---*)
   474 (*--- 1.line in script ---*)
   475 val t = str2term "(hd o (filterVar m_)) (rs_::bool list)";
   475 val t = str2term "(hd o (filterVar m_)) (rs_::bool list)";
   476 val s = subst_atomic env t;
   476 val s = subst_atomic env t;
   477 term2str s;
   477 term2str s;
   478 "(hd o filterVar A) [A = a * b, (a / 2) ^^^ 2 + (b / 2) ^^^ 2 = r ^^^ 2]";
   478 "(hd o filterVar A) [A = a * b, (a / 2) ^^^ 2 + (b / 2) ^^^ 2 = r ^^^ 2]";
   479 val Some (s',_) = rewrite_set_ thy false list_rls s;
   479 val SOME (s',_) = rewrite_set_ thy false list_rls s;
   480 val s'' = term2str s';
   480 val s'' = term2str s';
   481 if s''="A = a * b" then () else raise error "new behaviour with list_rls 1.1.";
   481 if s''="A = a * b" then () else raise error "new behaviour with list_rls 1.1.";
   482 val env = env @ [(str2term "e_::bool",str2term "A = a * b")];
   482 val env = env @ [(str2term "e_::bool",str2term "A = a * b")];
   483 
   483 
   484 (*--- 2.line: condition alone ---*)
   484 (*--- 2.line: condition alone ---*)
   485 val t = str2term "1 < length_ (rs_::bool list)";
   485 val t = str2term "1 < length_ (rs_::bool list)";
   486 val s = subst_atomic env t;
   486 val s = subst_atomic env t;
   487 term2str s;
   487 term2str s;
   488 "1 < length_ [A = a * b, (a / 2) ^^^ 2 + (b / 2) ^^^ 2 = r ^^^ 2]";
   488 "1 < length_ [A = a * b, (a / 2) ^^^ 2 + (b / 2) ^^^ 2 = r ^^^ 2]";
   489 val Some (s',_) = rewrite_set_ thy false list_rls s;
   489 val SOME (s',_) = rewrite_set_ thy false list_rls s;
   490 val s'' = term2str s';
   490 val s'' = term2str s';
   491 if s''="True" then () else raise error "new behaviour with list_rls 1.2.";
   491 if s''="True" then () else raise error "new behaviour with list_rls 1.2.";
   492 
   492 
   493 (*--- 2.line in script ---*)
   493 (*--- 2.line in script ---*)
   494 val t = str2term 
   494 val t = str2term 
   501 "if 1 < length_ [A = a * b, (a / 2) ^^^ 2 + (b / 2) ^^^ 2 = r ^^^ 2]\
   501 "if 1 < length_ [A = a * b, (a / 2) ^^^ 2 + (b / 2) ^^^ 2 = r ^^^ 2]\
   502 \then SubProblem (Reals_, [make, function], [no_met])\
   502 \then SubProblem (Reals_, [make, function], [no_met])\
   503 \      [real_ A, real_ b,\
   503 \      [real_ A, real_ b,\
   504 \       bool_list_ [A = a * b, (a / 2) ^^^ 2 + (b / 2) ^^^ 2 = r ^^^ 2]]\
   504 \       bool_list_ [A = a * b, (a / 2) ^^^ 2 + (b / 2) ^^^ 2 = r ^^^ 2]]\
   505 \else hd [A = a * b, (a / 2) ^^^ 2 + (b / 2) ^^^ 2 = r ^^^ 2]";
   505 \else hd [A = a * b, (a / 2) ^^^ 2 + (b / 2) ^^^ 2 = r ^^^ 2]";
   506 val Some (s',_) = rewrite_set_ thy false list_rls s;
   506 val SOME (s',_) = rewrite_set_ thy false list_rls s;
   507 val s'' = term2str s';
   507 val s'' = term2str s';
   508 if s'' = 
   508 if s'' = 
   509 "SubProblem (Reals_, [make, function], [no_met])\n\
   509 "SubProblem (Reals_, [make, function], [no_met])\n\
   510 \ [real_ A, real_ b,\n\
   510 \ [real_ A, real_ b,\n\
   511 \  bool_list_ [A = a * b, (a / 2) ^^^ 2 + (b / 2) ^^^ 2 = r ^^^ 2]]" then ()
   511 \  bool_list_ [A = a * b, (a / 2) ^^^ 2 + (b / 2) ^^^ 2 = r ^^^ 2]]" then ()
   540 val t = str2term "(hd o (filterVar v_)) (eqs_::bool list)";
   540 val t = str2term "(hd o (filterVar v_)) (eqs_::bool list)";
   541 val s = subst_atomic env t;
   541 val s = subst_atomic env t;
   542 term2str s;
   542 term2str s;
   543 val t = str2term 
   543 val t = str2term 
   544      "(hd o filterVar b) [A = a * b, (a / 2) ^^^ 2 + (b / 2) ^^^ 2 = r ^^^ 2]";
   544      "(hd o filterVar b) [A = a * b, (a / 2) ^^^ 2 + (b / 2) ^^^ 2 = r ^^^ 2]";
   545 val Some (t',_) = rewrite_set_ thy false list_rls t;
   545 val SOME (t',_) = rewrite_set_ thy false list_rls t;
   546 val s' = term2str t';
   546 val s' = term2str t';
   547 if s' = "A = a * b" then () else raise error "new behaviour with list_rls 2.1";
   547 if s' = "A = a * b" then () else raise error "new behaviour with list_rls 2.1";
   548 val env = env @ [(str2term "h_::bool", str2term s')];
   548 val env = env @ [(str2term "h_::bool", str2term s')];
   549 
   549 
   550 (*--- 2.line in script ---*)
   550 (*--- 2.line in script ---*)
   554 val t = str2term 
   554 val t = str2term 
   555 	    "hd (dropWhile (ident (A = a * b))\
   555 	    "hd (dropWhile (ident (A = a * b))\
   556 	    \     [A = a * b, (a / 2) ^^^ 2 + (b / 2) ^^^ 2 = r ^^^ 2])";
   556 	    \     [A = a * b, (a / 2) ^^^ 2 + (b / 2) ^^^ 2 = r ^^^ 2])";
   557 mem_rls "dropWhile_Cons" list_rls;
   557 mem_rls "dropWhile_Cons" list_rls;
   558 mem_rls "Atools.ident" list_rls;
   558 mem_rls "Atools.ident" list_rls;
   559 val Some (t',_) = rewrite_set_ thy false list_rls t;
   559 val SOME (t',_) = rewrite_set_ thy false list_rls t;
   560 val s' = term2str t';
   560 val s' = term2str t';
   561 if s' = "(a / 2) ^^^ 2 + (b / 2) ^^^ 2 = r ^^^ 2" then () 
   561 if s' = "(a / 2) ^^^ 2 + (b / 2) ^^^ 2 = r ^^^ 2" then () 
   562 else raise error "new behaviour with list_rls 2.2";
   562 else raise error "new behaviour with list_rls 2.2";
   563 val env = env @ [(str2term "e_1::bool", str2term s')];
   563 val env = env @ [(str2term "e_1::bool", str2term s')];
   564 
   564 
   565 (*--- 3.line in script ---*)
   565 (*--- 3.line in script ---*)
   566 val t = str2term "dropWhile (ident f_) (Vars (h_::bool))";
   566 val t = str2term "dropWhile (ident f_) (Vars (h_::bool))";
   567 val s = subst_atomic env t;
   567 val s = subst_atomic env t;
   568 term2str s;
   568 term2str s;
   569 val t = str2term "dropWhile (ident A) (Vars (A = a * b))";
   569 val t = str2term "dropWhile (ident A) (Vars (A = a * b))";
   570 val Some (t',_) = rewrite_set_ thy false list_rls t;
   570 val SOME (t',_) = rewrite_set_ thy false list_rls t;
   571 val s' = term2str t';
   571 val s' = term2str t';
   572 if s' = "[a, b]" then () else raise error "new behaviour with list_rls 2.3";
   572 if s' = "[a, b]" then () else raise error "new behaviour with list_rls 2.3";
   573 val env = env @ [(str2term "vs_::real list", str2term s')];
   573 val env = env @ [(str2term "vs_::real list", str2term s')];
   574 
   574 
   575 (*--- 4.line in script ---*)
   575 (*--- 4.line in script ---*)
   576 val t = str2term "hd (dropWhile (ident v_) vs_)";
   576 val t = str2term "hd (dropWhile (ident v_) vs_)";
   577 val s = subst_atomic env t;
   577 val s = subst_atomic env t;
   578 term2str s;
   578 term2str s;
   579 val t = str2term "hd (dropWhile (ident b) [a, b])";
   579 val t = str2term "hd (dropWhile (ident b) [a, b])";
   580 val Some (t',_) = rewrite_set_ thy false list_rls t;
   580 val SOME (t',_) = rewrite_set_ thy false list_rls t;
   581 val s' = term2str t';
   581 val s' = term2str t';
   582 if s' = "a" then () else raise error "new behaviour with list_rls 2.4.";
   582 if s' = "a" then () else raise error "new behaviour with list_rls 2.4.";
   583 val env = env @ [(str2term "v_1::real", str2term s')];
   583 val env = env @ [(str2term "v_1::real", str2term s')];
   584 
   584 
   585 (*--- 5.line in script ---*)
   585 (*--- 5.line in script ---*)
   598 term2str s;
   598 term2str s;
   599 val t = str2term 
   599 val t = str2term 
   600 "Substitute [(a = (rhs o hd) [a = 2 * sqrt (r ^^^ 2 - (b / 2) ^^^ 2)])]\n\
   600 "Substitute [(a = (rhs o hd) [a = 2 * sqrt (r ^^^ 2 - (b / 2) ^^^ 2)])]\n\
   601 \ (A = a * b)";
   601 \ (A = a * b)";
   602 mem_rls "Tools.rhs" list_rls;
   602 mem_rls "Tools.rhs" list_rls;
   603 val Some (t',_) = rewrite_set_ thy false list_rls t;
   603 val SOME (t',_) = rewrite_set_ thy false list_rls t;
   604 val s' = term2str t';
   604 val s' = term2str t';
   605 if s' = "Substitute [a = 2 * sqrt (r ^^^ 2 - (b / 2) ^^^ 2)] (A = a * b)" 
   605 if s' = "Substitute [a = 2 * sqrt (r ^^^ 2 - (b / 2) ^^^ 2)] (A = a * b)" 
   606 then () else raise error "new behaviour with list_rls 2.6.";
   606 then () else raise error "new behaviour with list_rls 2.6.";
   607 
   607 
   608 
   608 
   637 val s = subst_atomic env t;
   637 val s = subst_atomic env t;
   638 term2str s;
   638 term2str s;
   639 val t = str2term 
   639 val t = str2term 
   640 "(hd o filterVar A) [A = a * b, a / 2 = r * sin alpha, b / 2 = r * cos alpha]";
   640 "(hd o filterVar A) [A = a * b, a / 2 = r * sin alpha, b / 2 = r * cos alpha]";
   641 trace_rewrite:=true;
   641 trace_rewrite:=true;
   642 val Some (t',_) = rewrite_set_ thy false list_rls t;
   642 val SOME (t',_) = rewrite_set_ thy false list_rls t;
   643 trace_rewrite:=false;
   643 trace_rewrite:=false;
   644 val s' = term2str t';
   644 val s' = term2str t';
   645 if s' = "A = a * b" then() else raise error "new behaviour with list_rls 3.1.";
   645 if s' = "A = a * b" then() else raise error "new behaviour with list_rls 3.1.";
   646 val env = env @ [(str2term "h_::bool", str2term s')];
   646 val env = env @ [(str2term "h_::bool", str2term s')];
   647 
   647 
   650 val s = subst_atomic env t;
   650 val s = subst_atomic env t;
   651 term2str s;
   651 term2str s;
   652 val t = str2term 
   652 val t = str2term 
   653 "dropWhile (ident (A = a * b))\
   653 "dropWhile (ident (A = a * b))\
   654 \ [A = a * b, a / 2 = r * sin alpha, b / 2 = r * cos alpha]";
   654 \ [A = a * b, a / 2 = r * sin alpha, b / 2 = r * cos alpha]";
   655 val Some (t',_) = rewrite_set_ thy false list_rls t;
   655 val SOME (t',_) = rewrite_set_ thy false list_rls t;
   656 val s' = term2str t';
   656 val s' = term2str t';
   657 if s' = "[a / 2 = r * sin alpha, b / 2 = r * cos alpha]" 
   657 if s' = "[a / 2 = r * sin alpha, b / 2 = r * cos alpha]" 
   658 then () else raise error "new behaviour with list_rls 3.2.";
   658 then () else raise error "new behaviour with list_rls 3.2.";
   659 val env = env @ [(str2term "es_::bool list", str2term s')];
   659 val env = env @ [(str2term "es_::bool list", str2term s')];
   660 
   660 
   661 (*--- 3.line in script ---*)
   661 (*--- 3.line in script ---*)
   662 val t = str2term "dropWhile (ident (f_::real)) (Vars (h_::bool))";
   662 val t = str2term "dropWhile (ident (f_::real)) (Vars (h_::bool))";
   663 val s = subst_atomic env t;
   663 val s = subst_atomic env t;
   664 term2str s;
   664 term2str s;
   665 val t = str2term "dropWhile (ident A) (Vars (A = a * b))";
   665 val t = str2term "dropWhile (ident A) (Vars (A = a * b))";
   666 val Some (t',_) = rewrite_set_ thy false list_rls t;
   666 val SOME (t',_) = rewrite_set_ thy false list_rls t;
   667 val s' = term2str t';
   667 val s' = term2str t';
   668 if s' = "[a, b]" then () else raise error "new behaviour with list_rls 3.3.";
   668 if s' = "[a, b]" then () else raise error "new behaviour with list_rls 3.3.";
   669 val env = env @ [(str2term "vs_::real list", str2term s')];
   669 val env = env @ [(str2term "vs_::real list", str2term s')];
   670 
   670 
   671 (*--- 4.line in script ---*)
   671 (*--- 4.line in script ---*)
   672 val t = str2term "nth_ 1 vs_";
   672 val t = str2term "nth_ 1 vs_";
   673 val s = subst_atomic env t;
   673 val s = subst_atomic env t;
   674 term2str s;
   674 term2str s;
   675 val t = str2term "nth_ 1 [a, b]";
   675 val t = str2term "nth_ 1 [a, b]";
   676 val Some (t',_) = rewrite_set_ thy false list_rls t;
   676 val SOME (t',_) = rewrite_set_ thy false list_rls t;
   677 val s' = term2str t';
   677 val s' = term2str t';
   678 if s' = "a" then () else raise error "new behaviour with list_rls 3.4.";
   678 if s' = "a" then () else raise error "new behaviour with list_rls 3.4.";
   679 val env = env @ [(str2term "v_1", str2term s')];
   679 val env = env @ [(str2term "v_1", str2term s')];
   680 
   680 
   681 (*--- 5.line in script ---*)
   681 (*--- 5.line in script ---*)
   682 val t = str2term "nth_ 2 vs_";
   682 val t = str2term "nth_ 2 vs_";
   683 val s = subst_atomic env t;
   683 val s = subst_atomic env t;
   684 term2str s;
   684 term2str s;
   685 val t = str2term "nth_ 2 [a, b]";
   685 val t = str2term "nth_ 2 [a, b]";
   686 val Some (t',_) = rewrite_set_ thy false list_rls t;
   686 val SOME (t',_) = rewrite_set_ thy false list_rls t;
   687 val s' = term2str t';
   687 val s' = term2str t';
   688 if s' = "b" then () else raise error "new behaviour with list_rls 3.5.";
   688 if s' = "b" then () else raise error "new behaviour with list_rls 3.5.";
   689 val env = env @ [(str2term "v_2", str2term s')];
   689 val env = env @ [(str2term "v_2", str2term s')];
   690 
   690 
   691 (*--- 6.line in script ---*)
   691 (*--- 6.line in script ---*)
   692 val t = str2term "(hd o (filterVar v_1)) (es_::bool list)";
   692 val t = str2term "(hd o (filterVar v_1)) (es_::bool list)";
   693 val s = subst_atomic env t;
   693 val s = subst_atomic env t;
   694 term2str s;
   694 term2str s;
   695 val t = str2term 
   695 val t = str2term 
   696 	   "(hd o filterVar a) [a / 2 = r * sin alpha, b / 2 = r * cos alpha]";
   696 	   "(hd o filterVar a) [a / 2 = r * sin alpha, b / 2 = r * cos alpha]";
   697 val Some (t',_) = rewrite_set_ thy false list_rls t;
   697 val SOME (t',_) = rewrite_set_ thy false list_rls t;
   698 val s' = term2str t';
   698 val s' = term2str t';
   699 if s' = "a / 2 = r * sin alpha" then () 
   699 if s' = "a / 2 = r * sin alpha" then () 
   700 else raise error "new behaviour with list_rls 3.6.";
   700 else raise error "new behaviour with list_rls 3.6.";
   701 val e_1 = str2term "e_1::bool";
   701 val e_1 = str2term "e_1::bool";
   702 val env = env @ [(e_1, str2term s')];
   702 val env = env @ [(e_1, str2term s')];
   705 val t = str2term "(hd o (filterVar v_2)) (es_::bool list)";
   705 val t = str2term "(hd o (filterVar v_2)) (es_::bool list)";
   706 val s = subst_atomic env t;
   706 val s = subst_atomic env t;
   707 term2str s;
   707 term2str s;
   708 val t = str2term 
   708 val t = str2term 
   709 	  "(hd o filterVar b) [a / 2 = r * sin alpha, b / 2 = r * cos alpha]";
   709 	  "(hd o filterVar b) [a / 2 = r * sin alpha, b / 2 = r * cos alpha]";
   710 val Some (t',_) = rewrite_set_ thy false list_rls t;
   710 val SOME (t',_) = rewrite_set_ thy false list_rls t;
   711 val s' = term2str t';
   711 val s' = term2str t';
   712 if s' = "b / 2 = r * cos alpha" then () 
   712 if s' = "b / 2 = r * cos alpha" then () 
   713 else raise error "new behaviour with list_rls 3.7.";
   713 else raise error "new behaviour with list_rls 3.7.";
   714 val env = env @ [(str2term "e_2::bool", str2term s')];
   714 val env = env @ [(str2term "e_2::bool", str2term s')];
   715 
   715 
   738 "Substitute [(v_1 = (rhs o hd) s_1),(v_2 = (rhs o hd) s_2)] (h_::bool)";
   738 "Substitute [(v_1 = (rhs o hd) s_1),(v_2 = (rhs o hd) s_2)] (h_::bool)";
   739 val s = subst_atomic env t;
   739 val s = subst_atomic env t;
   740 term2str s;
   740 term2str s;
   741 "Substitute\n [(a = (rhs o hd) [a = 2 * r * sin alpha]),\
   741 "Substitute\n [(a = (rhs o hd) [a = 2 * r * sin alpha]),\
   742 \              (b = (rhs o hd) [b = 2 * r * cos alpha])] (A = a * b)";
   742 \              (b = (rhs o hd) [b = 2 * r * cos alpha])] (A = a * b)";
   743 val Some (s',_) = rewrite_set_ thy false list_rls s;
   743 val SOME (s',_) = rewrite_set_ thy false list_rls s;
   744 val s'' = term2str s';
   744 val s'' = term2str s';
   745 if s'' = 
   745 if s'' = 
   746 "Substitute [a = 2 * r * sin alpha, b = 2 * r * cos alpha] (A = a * b)"
   746 "Substitute [a = 2 * r * sin alpha, b = 2 * r * cos alpha] (A = a * b)"
   747 then () else raise error "new behaviour with list_rls 3.10.";
   747 then () else raise error "new behaviour with list_rls 3.10.";
   748 
   748