src/Pure/goals.ML
changeset 6390 5d58c100ca3f
parent 6189 e9dc9ec28a2d
child 6912 6721243019e7
equal deleted inserted replaced
6389:da9c26906f3f 6390:5d58c100ca3f
   102 (*Current result maker -- set by "goal", used by "result".  *)
   102 (*Current result maker -- set by "goal", used by "result".  *)
   103 val curr_mkresult = 
   103 val curr_mkresult = 
   104     ref((fn _=> error"No goal has been supplied in subgoal module") 
   104     ref((fn _=> error"No goal has been supplied in subgoal module") 
   105        : bool*thm->thm);
   105        : bool*thm->thm);
   106 
   106 
   107 val dummy = trivial(read_cterm (sign_of ProtoPure.thy)
   107 val dummy = trivial(read_cterm (Theory.sign_of ProtoPure.thy)
   108     ("PROP No_goal_has_been_supplied",propT));
   108     ("PROP No_goal_has_been_supplied",propT));
   109 
   109 
   110 (*List of previous goal stacks, for the undo operation.  Set by setstate. 
   110 (*List of previous goal stacks, for the undo operation.  Set by setstate. 
   111   A list of lists!*)
   111   A list of lists!*)
   112 val undo_list = ref([[(dummy, Seq.empty)]] : gstack list);
   112 val undo_list = ref([[(dummy, Seq.empty)]] : gstack list);
   148     and expand and cancel the locale definitions. 
   148     and expand and cancel the locale definitions. 
   149     export goes through all levels in case of nested locales, whereas
   149     export goes through all levels in case of nested locales, whereas
   150     export_thy just goes one up. **)
   150     export_thy just goes one up. **)
   151 
   151 
   152 fun get_top_scope_thms thy = 
   152 fun get_top_scope_thms thy = 
   153    let val sc = (Locale.get_scope_sg (sign_of thy))
   153    let val sc = (Locale.get_scope_sg (Theory.sign_of thy))
   154    in if (null sc) then (warning "No locale in theory"; [])
   154    in if (null sc) then (warning "No locale in theory"; [])
   155       else map (#prop o rep_thm) (map #2 (#thms(snd(hd sc))))
   155       else map (#prop o rep_thm) (map #2 (#thms(snd(hd sc))))
   156    end;
   156    end;
   157 
   157 
   158 fun implies_intr_some_hyps thy A_set th = 
   158 fun implies_intr_some_hyps thy A_set th = 
   159    let 
   159    let 
   160        val sign = sign_of thy;
   160        val sign = Theory.sign_of thy;
   161        val used_As = A_set inter #hyps(rep_thm(th));
   161        val used_As = A_set inter #hyps(rep_thm(th));
   162        val ctl = map (cterm_of sign) used_As
   162        val ctl = map (cterm_of sign) used_As
   163    in foldl (fn (x, y) => Thm.implies_intr y x) (th, ctl)
   163    in foldl (fn (x, y) => Thm.implies_intr y x) (th, ctl)
   164    end; 
   164    end; 
   165 
   165 
   286 	setmp proof_timing false (prove_goalw_cterm_general false rths chorn);
   286 	setmp proof_timing false (prove_goalw_cterm_general false rths chorn);
   287 
   287 
   288 
   288 
   289 (*Version taking the goal as a string*)
   289 (*Version taking the goal as a string*)
   290 fun prove_goalw thy rths agoal tacsf =
   290 fun prove_goalw thy rths agoal tacsf =
   291   let val sign = sign_of thy
   291   let val sign = Theory.sign_of thy
   292       val chorn = read_cterm sign (agoal,propT)
   292       val chorn = read_cterm sign (agoal,propT)
   293   in  prove_goalw_cterm_general true rths chorn tacsf end
   293   in  prove_goalw_cterm_general true rths chorn tacsf end
   294   handle ERROR => error (*from read_cterm?*)
   294   handle ERROR => error (*from read_cterm?*)
   295 		("The error(s) above occurred for " ^ quote agoal);
   295 		("The error(s) above occurred for " ^ quote agoal);
   296 
   296 
   388 (** the goal.... commands
   388 (** the goal.... commands
   389     Read main goal.  Set global variables curr_prems, curr_mkresult. 
   389     Read main goal.  Set global variables curr_prems, curr_mkresult. 
   390     Initial subgoal and premises are rewritten using rths. **)
   390     Initial subgoal and premises are rewritten using rths. **)
   391 
   391 
   392 (*Version taking the goal as a cterm; if you have a term t and theory thy, use
   392 (*Version taking the goal as a cterm; if you have a term t and theory thy, use
   393     goalw_cterm rths (cterm_of (sign_of thy) t);      *)
   393     goalw_cterm rths (cterm_of (Theory.sign_of thy) t);      *)
   394 fun agoalw_cterm atomic rths chorn = 
   394 fun agoalw_cterm atomic rths chorn = 
   395   let val (prems, st0, mkresult) = prepare_proof atomic rths chorn
   395   let val (prems, st0, mkresult) = prepare_proof atomic rths chorn
   396   in  undo_list := [];
   396   in  undo_list := [];
   397       setstate [ (st0, Seq.empty) ];  
   397       setstate [ (st0, Seq.empty) ];  
   398       curr_prems := prems;
   398       curr_prems := prems;
   402 
   402 
   403 val goalw_cterm = agoalw_cterm false;
   403 val goalw_cterm = agoalw_cterm false;
   404 
   404 
   405 (*Version taking the goal as a string*)
   405 (*Version taking the goal as a string*)
   406 fun agoalw atomic thy rths agoal = 
   406 fun agoalw atomic thy rths agoal = 
   407     agoalw_cterm atomic rths (Locale.read_cterm(sign_of thy)(agoal,propT))
   407     agoalw_cterm atomic rths (Locale.read_cterm(Theory.sign_of thy)(agoal,propT))
   408     handle ERROR => error (*from type_assign, etc via prepare_proof*)
   408     handle ERROR => error (*from type_assign, etc via prepare_proof*)
   409 	("The error(s) above occurred for " ^ quote agoal);
   409 	("The error(s) above occurred for " ^ quote agoal);
   410 
   410 
   411 val goalw = agoalw false;
   411 val goalw = agoalw false;
   412 
   412