src/Pure/goals.ML
changeset 5311 f3f71669878e
parent 5246 99116a9e88f8
child 5614 0e8b45a7d104
equal deleted inserted replaced
5310:3e14d6d66dab 5311:f3f71669878e
    59   val print_sign_exn	: Sign.sg -> exn -> 'a
    59   val print_sign_exn	: Sign.sg -> exn -> 'a
    60   val proof_timing	: bool ref
    60   val proof_timing	: bool ref
    61   val prove_goal	: theory -> string -> (thm list -> tactic list) -> thm
    61   val prove_goal	: theory -> string -> (thm list -> tactic list) -> thm
    62   val prove_goalw      : theory->thm list->string->(thm list->tactic list)->thm
    62   val prove_goalw      : theory->thm list->string->(thm list->tactic list)->thm
    63   val prove_goalw_cterm	: thm list->cterm->(thm list->tactic list)->thm
    63   val prove_goalw_cterm	: thm list->cterm->(thm list->tactic list)->thm
       
    64   val prove_goalw_cterm_nocheck	: thm list->cterm->(thm list->tactic list)->thm
    64   val push_proof	: unit -> unit
    65   val push_proof	: unit -> unit
    65   val read		: string -> term
    66   val read		: string -> term
    66   val ren		: string -> int -> unit
    67   val ren		: string -> int -> unit
    67   val restore_proof	: proof -> thm list
    68   val restore_proof	: proof -> thm list
    68   val result		: unit -> thm  
    69   val result		: unit -> thm  
   157             forall (fn t => not(Logic.is_implies t orelse Logic.is_all t)) As;
   158             forall (fn t => not(Logic.is_implies t orelse Logic.is_all t)) As;
   158       val (As,B) = if atoms then ([],horn) else (As,B);
   159       val (As,B) = if atoms then ([],horn) else (As,B);
   159       val cAs = map (cterm_of sign) As;
   160       val cAs = map (cterm_of sign) As;
   160       val prems = map (rewrite_rule rths o forall_elim_vars(0) o assume) cAs;
   161       val prems = map (rewrite_rule rths o forall_elim_vars(0) o assume) cAs;
   161       val cB = cterm_of sign B;
   162       val cB = cterm_of sign B;
   162       val st0 = let val st = Drule.instantiate' [] [Some cB] Drule.triv_goal
   163       val st0 = let val st = Drule.mk_triv_goal cB
   163                 in  rewrite_goals_rule rths st end
   164                 in  rewrite_goals_rule rths st end
   164       (*discharges assumptions from state in the order they appear in goal;
   165       (*discharges assumptions from state in the order they appear in goal;
   165 	checks (if requested) that resulting theorem is equivalent to goal. *)
   166 	checks (if requested) that resulting theorem is equivalent to goal. *)
   166       fun mkresult (check,state) =
   167       fun mkresult (check,state) =
   167         let val state = Seq.hd (flexflex_rule state)
   168         let val state = Seq.hd (flexflex_rule state)
   223     Prove theorem using the listed tactics; check it has the specified form.
   224     Prove theorem using the listed tactics; check it has the specified form.
   224     Augment signature with all type assignments of goal.
   225     Augment signature with all type assignments of goal.
   225     Syntax is similar to "goal" command for easy keyboard use. **)
   226     Syntax is similar to "goal" command for easy keyboard use. **)
   226 
   227 
   227 (*Version taking the goal as a cterm*)
   228 (*Version taking the goal as a cterm*)
   228 fun prove_goalw_cterm rths chorn tacsf =
   229 fun prove_goalw_cterm_general check rths chorn tacsf =
   229   let val (prems, st0, mkresult) = prepare_proof false rths chorn
   230   let val (prems, st0, mkresult) = prepare_proof false rths chorn
   230       val tac = EVERY (tacsf prems)
   231       val tac = EVERY (tacsf prems)
   231       fun statef() = 
   232       fun statef() = 
   232 	  (case Seq.pull (tac st0) of 
   233 	  (case Seq.pull (tac st0) of 
   233 	       Some(st,_) => st
   234 	       Some(st,_) => st
   234 	     | _ => error ("prove_goal: tactic failed"))
   235 	     | _ => error ("prove_goal: tactic failed"))
   235   in  mkresult (true, cond_timeit (!proof_timing) statef)  end
   236   in  mkresult (check, cond_timeit (!proof_timing) statef)  end
   236   handle e => (print_sign_exn_unit (#sign (rep_cterm chorn)) e;
   237   handle e => (print_sign_exn_unit (#sign (rep_cterm chorn)) e;
   237 	       error ("The exception above was raised for\n" ^ 
   238 	       error ("The exception above was raised for\n" ^ 
   238 		      string_of_cterm chorn));
   239 		      string_of_cterm chorn));
       
   240 
       
   241 (*Two variants: one checking the result, one not*)
       
   242 val prove_goalw_cterm         = prove_goalw_cterm_general true
       
   243 and prove_goalw_cterm_nocheck = prove_goalw_cterm_general false;
   239 
   244 
   240 
   245 
   241 (*Version taking the goal as a string*)
   246 (*Version taking the goal as a string*)
   242 fun prove_goalw thy rths agoal tacsf =
   247 fun prove_goalw thy rths agoal tacsf =
   243   let val sign = sign_of thy
   248   let val sign = sign_of thy