src/Provers/blast.ML
changeset 14984 edbc81e60809
parent 14913 e993eabc7197
child 15162 670ab8497818
equal deleted inserted replaced
14983:2b5e9b80a8e5 14984:edbc81e60809
   625 	  None   => stm   (*no type to attach*)
   625 	  None   => stm   (*no type to attach*)
   626 	| Some T => stm ^ "\t:: " ^ Sign.string_of_typ sign T
   626 	| Some T => stm ^ "\t:: " ^ Sign.string_of_typ sign T
   627   end;
   627   end;
   628 
   628 
   629 
   629 
   630 val prs = std_output o Output.output;
       
   631 
       
   632 (*Print tracing information at each iteration of prover*)
   630 (*Print tracing information at each iteration of prover*)
   633 fun tracing sign brs = 
   631 fun tracing sign brs = 
   634   let fun printPairs (((G,_)::_,_)::_)  = prs(traceTerm sign G)
   632   let fun printPairs (((G,_)::_,_)::_)  = immediate_output(traceTerm sign G)
   635 	| printPairs (([],(H,_)::_)::_) = prs(traceTerm sign H ^ "\t (Unsafe)")
   633 	| printPairs (([],(H,_)::_)::_) = immediate_output(traceTerm sign H ^ "\t (Unsafe)")
   636 	| printPairs _                 = ()
   634 	| printPairs _                 = ()
   637       fun printBrs (brs0 as {pairs, lits, lim, ...} :: brs) =
   635       fun printBrs (brs0 as {pairs, lits, lim, ...} :: brs) =
   638 	    (fullTrace := brs0 :: !fullTrace;
   636 	    (fullTrace := brs0 :: !fullTrace;
   639 	     seq (fn _ => prs "+") brs;
   637 	     seq (fn _ => immediate_output "+") brs;
   640 	     prs (" [" ^ Int.toString lim ^ "] ");
   638 	     immediate_output (" [" ^ Int.toString lim ^ "] ");
   641 	     printPairs pairs;
   639 	     printPairs pairs;
   642 	     writeln"")
   640 	     writeln"")
   643   in if !trace then printBrs (map normBr brs) else ()
   641   in if !trace then printBrs (map normBr brs) else ()
   644   end;
   642   end;
   645 
   643 
   648 (*Tracing: variables updated in the last branch operation?*)
   646 (*Tracing: variables updated in the last branch operation?*)
   649 fun traceVars sign ntrl =
   647 fun traceVars sign ntrl =
   650   if !trace then 
   648   if !trace then 
   651       (case !ntrail-ntrl of
   649       (case !ntrail-ntrl of
   652 	    0 => ()
   650 	    0 => ()
   653 	  | 1 => prs"\t1 variable UPDATED:"
   651 	  | 1 => immediate_output"\t1 variable UPDATED:"
   654 	  | n => prs("\t" ^ Int.toString n ^ " variables UPDATED:");
   652 	  | n => immediate_output("\t" ^ Int.toString n ^ " variables UPDATED:");
   655        (*display the instantiations themselves, though no variable names*)
   653        (*display the instantiations themselves, though no variable names*)
   656        seq (fn v => prs("   " ^ string_of sign 4 (the (!v))))
   654        seq (fn v => immediate_output("   " ^ string_of sign 4 (the (!v))))
   657            (List.take(!trail, !ntrail-ntrl));
   655            (List.take(!trail, !ntrail-ntrl));
   658        writeln"")
   656        writeln"")
   659     else ();
   657     else ();
   660 
   658 
   661 (*Tracing: how many new branches are created?*)
   659 (*Tracing: how many new branches are created?*)
   662 fun traceNew prems =
   660 fun traceNew prems =
   663     if !trace then 
   661     if !trace then 
   664         case length prems of
   662         case length prems of
   665 	    0 => prs"branch closed by rule"
   663 	    0 => immediate_output"branch closed by rule"
   666 	  | 1 => prs"branch extended (1 new subgoal)"
   664 	  | 1 => immediate_output"branch extended (1 new subgoal)"
   667 	  | n => prs("branch split: "^ Int.toString n ^ " new subgoals")
   665 	  | n => immediate_output("branch split: "^ Int.toString n ^ " new subgoals")
   668     else ();
   666     else ();
   669 
   667 
   670 
   668 
   671 
   669 
   672 (*** Code for handling equality: naive substitution, like hyp_subst_tac ***)
   670 (*** Code for handling equality: naive substitution, like hyp_subst_tac ***)
  1008 		| closeF (L::Ls) = 
  1006 		| closeF (L::Ls) = 
  1009 		    case tryClose(G,L) of
  1007 		    case tryClose(G,L) of
  1010 			None     => closeF Ls
  1008 			None     => closeF Ls
  1011 		      | Some tac => 
  1009 		      | Some tac => 
  1012 			    let val choices' = 
  1010 			    let val choices' = 
  1013 				    (if !trace then (prs"branch closed";
  1011 				    (if !trace then (immediate_output"branch closed";
  1014 						     traceVars sign ntrl)
  1012 						     traceVars sign ntrl)
  1015 				               else ();
  1013 				               else ();
  1016 				     prune (nbrs, nxtVars, 
  1014 				     prune (nbrs, nxtVars, 
  1017 					    (ntrl, nbrs, PRV) :: choices))
  1015 					    (ntrl, nbrs, PRV) :: choices))
  1018 			    in  nclosed := !nclosed + 1;
  1016 			    in  nclosed := !nclosed + 1;
  1139 		       then (*it's faster to kill ALL the alternatives*)
  1137 		       then (*it's faster to kill ALL the alternatives*)
  1140 			   (traceMsg"Excessive branching: KILLED";
  1138 			   (traceMsg"Excessive branching: KILLED";
  1141 			    clearTo ntrl;  raise NEWBRANCHES)
  1139 			    clearTo ntrl;  raise NEWBRANCHES)
  1142 		       else 
  1140 		       else 
  1143 			 traceNew prems;  
  1141 			 traceNew prems;  
  1144 			 if !trace andalso dup then prs" (duplicating)"
  1142 			 if !trace andalso dup then immediate_output" (duplicating)"
  1145 					         else ();
  1143 					         else ();
  1146 			 if !trace andalso recur then prs" (recursive)"
  1144 			 if !trace andalso recur then immediate_output" (recursive)"
  1147 					         else ();
  1145 					         else ();
  1148 			 traceVars sign ntrl;
  1146 			 traceVars sign ntrl;
  1149 			 if null prems then nclosed := !nclosed + 1
  1147 			 if null prems then nclosed := !nclosed + 1
  1150 			 else ntried := !ntried + length prems - 1;
  1148 			 else ntried := !ntried + length prems - 1;
  1151 			 prv(tac' :: tacs, 
  1149 			 prv(tac' :: tacs,