equal
deleted
inserted
replaced
13 val check_result: string -> state -> 'a Seq.seq -> 'a Seq.seq |
13 val check_result: string -> state -> 'a Seq.seq -> 'a Seq.seq |
14 val init_state: theory -> state |
14 val init_state: theory -> state |
15 val context_of: state -> context |
15 val context_of: state -> context |
16 val theory_of: state -> theory |
16 val theory_of: state -> theory |
17 val sign_of: state -> Sign.sg |
17 val sign_of: state -> Sign.sg |
|
18 val reset_thms: string -> state -> state |
18 val the_facts: state -> thm list |
19 val the_facts: state -> thm list |
19 val get_goal: state -> thm list * thm |
20 val get_goal: state -> thm list * thm |
20 val goal_facts: (state -> thm list) -> state -> state |
21 val goal_facts: (state -> thm list) -> state -> state |
21 val use_facts: state -> state |
22 val use_facts: state -> state |
22 val reset_facts: state -> state |
23 val reset_facts: state -> state |
181 val add_binds = map_context o ProofContext.add_binds_i; |
182 val add_binds = map_context o ProofContext.add_binds_i; |
182 val auto_bind_goal = map_context o ProofContext.auto_bind_goal; |
183 val auto_bind_goal = map_context o ProofContext.auto_bind_goal; |
183 val auto_bind_facts = map_context oo ProofContext.auto_bind_facts; |
184 val auto_bind_facts = map_context oo ProofContext.auto_bind_facts; |
184 val put_thms = map_context o ProofContext.put_thms; |
185 val put_thms = map_context o ProofContext.put_thms; |
185 val put_thmss = map_context o ProofContext.put_thmss; |
186 val put_thmss = map_context o ProofContext.put_thmss; |
|
187 val reset_thms = map_context o ProofContext.reset_thms; |
186 val assumptions = ProofContext.assumptions o context_of; |
188 val assumptions = ProofContext.assumptions o context_of; |
187 |
189 |
188 |
190 |
189 (* facts *) |
191 (* facts *) |
190 |
192 |
192 | the_facts state = raise STATE ("No current facts available", state); |
194 | the_facts state = raise STATE ("No current facts available", state); |
193 |
195 |
194 fun assert_facts state = (the_facts state; state); |
196 fun assert_facts state = (the_facts state; state); |
195 fun get_facts (State (Node {facts, ...}, _)) = facts; |
197 fun get_facts (State (Node {facts, ...}, _)) = facts; |
196 |
198 |
|
199 |
|
200 val thisN = "this"; |
|
201 |
197 fun put_facts facts state = |
202 fun put_facts facts state = |
198 state |
203 state |
199 |> map_current (fn (ctxt, _, mode, goal) => (ctxt, facts, mode, goal)) |
204 |> map_current (fn (ctxt, _, mode, goal) => (ctxt, facts, mode, goal)) |
200 |> put_thms ("this", if_none facts []); |
205 |> (case facts of None => reset_thms thisN | Some ths => put_thms (thisN, ths)); |
201 |
206 |
202 val reset_facts = put_facts None; |
207 val reset_facts = put_facts None; |
203 |
208 |
204 fun have_facts (name, facts) state = |
209 fun have_facts (name, facts) state = |
205 state |
210 state |
454 val casms = map #1 (assumptions state); |
459 val casms = map #1 (assumptions state); |
455 val bad_hyps = Library.gen_rems Term.aconv (hyps, map (Thm.term_of o Drule.mk_cgoal) casms); |
460 val bad_hyps = Library.gen_rems Term.aconv (hyps, map (Thm.term_of o Drule.mk_cgoal) casms); |
456 in |
461 in |
457 if not (null bad_hyps) then |
462 if not (null bad_hyps) then |
458 err ("Additional hypotheses:\n" ^ cat_lines (map (Sign.string_of_term sign) bad_hyps)) |
463 err ("Additional hypotheses:\n" ^ cat_lines (map (Sign.string_of_term sign) bad_hyps)) |
459 (* FIXME else if not (Pattern.matches tsig (t, Logic.skip_flexpairs prop)) then |
464 else if not (t aconv prop) then |
460 err ("Proved a different theorem: " ^ Sign.string_of_term sign prop) *) |
465 err ("Proved a different theorem: " ^ Sign.string_of_term sign prop) |
461 else Drule.forall_elim_vars (maxidx + 1) thm |
466 else Drule.forall_elim_vars (maxidx + 1) thm |
462 end; |
467 end; |
463 |
468 |
464 |
469 |
465 (* prepare final result *) |
470 (* prepare final result *) |
495 state |
500 state |
496 |> assert_forward |
501 |> assert_forward |
497 |> map_context (f x) |
502 |> map_context (f x) |
498 |> reset_facts; |
503 |> reset_facts; |
499 |
504 |
500 val bind = gen_bind ProofContext.add_binds; |
505 val bind = gen_bind (ProofContext.add_binds o map (apsnd Some)) |
501 val bind_i = gen_bind ProofContext.add_binds_i; |
506 val bind_i = gen_bind (ProofContext.add_binds_i o map (apsnd Some)) |
502 |
507 |
503 val match_bind = gen_bind ProofContext.match_binds; |
508 val match_bind = gen_bind ProofContext.match_binds; |
504 val match_bind_i = gen_bind ProofContext.match_binds_i; |
509 val match_bind_i = gen_bind ProofContext.match_binds_i; |
505 |
510 |
506 |
511 |
586 state |
591 state |
587 |> assert_forward_or_chain |
592 |> assert_forward_or_chain |
588 |> enter_forward |
593 |> enter_forward |
589 |> map_context_result (fn c => prepp (c, raw_propp)); |
594 |> map_context_result (fn c => prepp (c, raw_propp)); |
590 val cprop = Thm.cterm_of (sign_of state') prop; |
595 val cprop = Thm.cterm_of (sign_of state') prop; |
591 (* FIXME |
|
592 val casms = map #1 (assumptions state'); |
|
593 |
|
594 val revcut_rl = Drule.incr_indexes_wrt [] [] (cprop :: casms) [] Drule.revcut_rl; |
|
595 fun cut_asm (casm, thm) = Thm.rotate_rule ~1 1 ((Drule.assume_goal casm COMP revcut_rl) RS thm); |
|
596 |
|
597 val goal = foldr cut_asm (casms, Drule.mk_triv_goal cprop); |
|
598 *) |
|
599 val goal = Drule.mk_triv_goal cprop; |
596 val goal = Drule.mk_triv_goal cprop; |
600 in |
597 in |
601 state' |
598 state' |
602 |> opt_block |
599 |> opt_block |
603 |> put_goal (Some (((kind atts, name, prop), ([], goal)), after_qed)) |
600 |> put_goal (Some (((kind atts, name, prop), ([], goal)), after_qed)) |