src/Pure/goals.ML
changeset 8999 ad8260dc6e4a
parent 8884 d1c85d427e29
child 9533 fb68b7163969
equal deleted inserted replaced
8998:56c44eee46ad 8999:ad8260dc6e4a
    61   val printyp		: typ -> unit
    61   val printyp		: typ -> unit
    62   val pprint_term	: term -> pprint_args -> unit
    62   val pprint_term	: term -> pprint_args -> unit
    63   val pprint_typ	: typ -> pprint_args -> unit
    63   val pprint_typ	: typ -> pprint_args -> unit
    64   val print_exn		: exn -> 'a
    64   val print_exn		: exn -> 'a
    65   val print_sign_exn	: Sign.sg -> exn -> 'a
    65   val print_sign_exn	: Sign.sg -> exn -> 'a
    66   val proof_timing	: bool ref
       
    67   val prove_goal	: theory -> string -> (thm list -> tactic list) -> thm
    66   val prove_goal	: theory -> string -> (thm list -> tactic list) -> thm
    68   val prove_goalw      : theory->thm list->string->(thm list->tactic list)->thm
    67   val prove_goalw      : theory->thm list->string->(thm list->tactic list)->thm
    69   val prove_goalw_cterm	: thm list->cterm->(thm list->tactic list)->thm
    68   val prove_goalw_cterm	: thm list->cterm->(thm list->tactic list)->thm
    70   val prove_goalw_cterm_nocheck	: thm list->cterm->(thm list->tactic list)->thm
    69   val prove_goalw_cterm_nocheck	: thm list->cterm->(thm list->tactic list)->thm
    71   val push_proof	: unit -> unit
    70   val push_proof	: unit -> unit
    90 
    89 
    91 datatype proof = Proof of gstack list * thm list * (bool*thm->thm);
    90 datatype proof = Proof of gstack list * thm list * (bool*thm->thm);
    92 
    91 
    93 
    92 
    94 (*** References ***)
    93 (*** References ***)
    95 
       
    96 (*Should process time be printed after proof steps?*)
       
    97 val proof_timing = ref false;
       
    98 
    94 
    99 (*Current assumption list -- set by "goal".*)
    95 (*Current assumption list -- set by "goal".*)
   100 val curr_prems = ref([] : thm list);
    96 val curr_prems = ref([] : thm list);
   101 
    97 
   102 (*Return assumption list -- useful if you didn't save "goal"'s result. *)
    98 (*Return assumption list -- useful if you didn't save "goal"'s result. *)
   274       val tac = EVERY (tacsf prems)
   270       val tac = EVERY (tacsf prems)
   275       fun statef() = 
   271       fun statef() = 
   276 	  (case Seq.pull (tac st0) of 
   272 	  (case Seq.pull (tac st0) of 
   277 	       Some(st,_) => st
   273 	       Some(st,_) => st
   278 	     | _ => error ("prove_goal: tactic failed"))
   274 	     | _ => error ("prove_goal: tactic failed"))
   279   in  mkresult (check, cond_timeit (!proof_timing) statef)  end
   275   in  mkresult (check, cond_timeit (!Library.timing) statef)  end
   280   handle e => (print_sign_exn_unit (#sign (rep_cterm chorn)) e;
   276   handle e => (print_sign_exn_unit (#sign (rep_cterm chorn)) e;
   281 	       writeln ("The exception above was raised for\n" ^ 
   277 	       writeln ("The exception above was raised for\n" ^ 
   282 		      string_of_cterm chorn); raise e);
   278 		      string_of_cterm chorn); raise e);
   283 
   279 
   284 (*Two variants: one checking the result, one not.  
   280 (*Two variants: one checking the result, one not.  
   285   Neither prints runtime messages: they are for internal packages.*)
   281   Neither prints runtime messages: they are for internal packages.*)
   286 fun prove_goalw_cterm rths chorn = 
   282 fun prove_goalw_cterm rths chorn = 
   287 	setmp proof_timing false (prove_goalw_cterm_general true rths chorn)
   283 	setmp Library.timing false (prove_goalw_cterm_general true rths chorn)
   288 and prove_goalw_cterm_nocheck rths chorn = 
   284 and prove_goalw_cterm_nocheck rths chorn = 
   289 	setmp proof_timing false (prove_goalw_cterm_general false rths chorn);
   285 	setmp Library.timing false (prove_goalw_cterm_general false rths chorn);
   290 
   286 
   291 
   287 
   292 (*Version taking the goal as a string*)
   288 (*Version taking the goal as a string*)
   293 fun prove_goalw thy rths agoal tacsf =
   289 fun prove_goalw thy rths agoal tacsf =
   294   let val sign = Theory.sign_of thy
   290   let val sign = Theory.sign_of thy
   446 	  else if eq_thm_sg(th,th2) then ()
   442 	  else if eq_thm_sg(th,th2) then ()
   447 	  else warning ("Warning: signature of proof state has changed" ^
   443 	  else warning ("Warning: signature of proof state has changed" ^
   448 		       sign_error (#sign(rep_thm th), #sign(rep_thm th2)));
   444 		       sign_error (#sign(rep_thm th), #sign(rep_thm th2)));
   449        ((th2,ths2)::(th,ths)::pairs)));
   445        ((th2,ths2)::(th,ths)::pairs)));
   450 
   446 
   451 fun by tac = cond_timeit (!proof_timing) 
   447 fun by tac = cond_timeit (!Library.timing) 
   452     (fn() => make_command (by_com tac));
   448     (fn() => make_command (by_com tac));
   453 
   449 
   454 (* byev[tac1,...,tacn] applies tac1 THEN ... THEN tacn.
   450 (* byev[tac1,...,tacn] applies tac1 THEN ... THEN tacn.
   455    Good for debugging proofs involving prove_goal.*)
   451    Good for debugging proofs involving prove_goal.*)
   456 val byev = by o EVERY;
   452 val byev = by o EVERY;