equal
deleted
inserted
replaced
20 -> (term (* f *) |
20 -> (term (* f *) |
21 * term (* G(raph) *) |
21 * term (* G(raph) *) |
22 * thm list (* GIntros *) |
22 * thm list (* GIntros *) |
23 * thm (* Ginduct *) |
23 * thm (* Ginduct *) |
24 * thm (* goalstate *) |
24 * thm (* goalstate *) |
25 * (thm -> Nominal_Function_Common.nominal_function_result) (* continuation *) |
25 * (Proof.context -> thm -> Nominal_Function_Common.nominal_function_result) (* continuation *) |
26 ) * local_theory |
26 ) * local_theory |
27 |
27 |
28 val inductive_def : (binding * typ) * mixfix -> term list -> local_theory |
28 val inductive_def : (binding * typ) * mixfix -> term list -> local_theory |
29 -> (term * thm list * thm * thm) * local_theory |
29 -> (term * thm list * thm * thm) * local_theory |
30 end |
30 end |
518 |> Thm.forall_intr (Thm.cterm_of ctxt y) |
518 |> Thm.forall_intr (Thm.cterm_of ctxt y) |
519 |
519 |
520 val P2 = Thm.cterm_of ctxt (lambda y (G $ lhs $ y)) (* P2 y := (lhs, y): G *) |
520 val P2 = Thm.cterm_of ctxt (lambda y (G $ lhs $ y)) (* P2 y := (lhs, y): G *) |
521 |
521 |
522 val exactly_one = |
522 val exactly_one = |
523 ex1I |> instantiate' [SOME (Thm.ctyp_of ctxt ranT)] [SOME P2, SOME (Thm.cterm_of ctxt rhsC)] |
523 ex1I |> Thm.instantiate' [SOME (Thm.ctyp_of ctxt ranT)] [SOME P2, SOME (Thm.cterm_of ctxt rhsC)] |
524 |> curry (op COMP) existence |
524 |> curry (op COMP) existence |
525 |> curry (op COMP) uniqueness |
525 |> curry (op COMP) uniqueness |
526 |> simplify (put_simpset HOL_basic_ss ctxt addsimps [case_hyp RS sym]) |
526 |> simplify (put_simpset HOL_basic_ss ctxt addsimps [case_hyp RS sym]) |
527 |> Thm.implies_intr (Thm.cprop_of case_hyp) |
527 |> Thm.implies_intr (Thm.cprop_of case_hyp) |
528 |> fold_rev (Thm.implies_intr o Thm.cprop_of) ags |
528 |> fold_rev (Thm.implies_intr o Thm.cprop_of) ags |
554 |> Thm.cterm_of ctxt |
554 |> Thm.cterm_of ctxt |
555 |
555 |
556 val ihyp_thm = Thm.assume ihyp |> Thm.forall_elim_vars 0 |
556 val ihyp_thm = Thm.assume ihyp |> Thm.forall_elim_vars 0 |
557 val ih_intro = ihyp_thm RS (f_def RS ex1_implies_ex) |
557 val ih_intro = ihyp_thm RS (f_def RS ex1_implies_ex) |
558 val ih_elim = ihyp_thm RS (f_def RS ex1_implies_un) |
558 val ih_elim = ihyp_thm RS (f_def RS ex1_implies_un) |
559 |> instantiate' [] [NONE, SOME (Thm.cterm_of ctxt h)] |
559 |> Thm.instantiate' [] [NONE, SOME (Thm.cterm_of ctxt h)] |
560 val ih_eqvt = ihyp_thm RS (G_eqvt RS (f_def RS @{thm fundef_ex1_eqvt_at})) |
560 val ih_eqvt = ihyp_thm RS (G_eqvt RS (f_def RS @{thm fundef_ex1_eqvt_at})) |
561 val ih_inv = ihyp_thm RS (invariant COMP (f_def RS @{thm fundef_ex1_prop})) |
561 val ih_inv = ihyp_thm RS (invariant COMP (f_def RS @{thm fundef_ex1_prop})) |
562 |
562 |
563 val _ = trace_msg (K "Proving Replacement lemmas...") |
563 val _ = trace_msg (K "Proving Replacement lemmas...") |
564 val repLemmas = map (mk_replacement_lemma ctxt h ih_elim) clauses |
564 val repLemmas = map (mk_replacement_lemma ctxt h ih_elim) clauses |
600 (* wrapper -- restores quantifiers in rule specifications *) |
600 (* wrapper -- restores quantifiers in rule specifications *) |
601 fun inductive_def (binding as ((R, T), _)) intrs lthy = |
601 fun inductive_def (binding as ((R, T), _)) intrs lthy = |
602 let |
602 let |
603 val ({intrs = intrs_gen, elims = [elim_gen], preds = [ Rdef ], induct, raw_induct, ...}, lthy) = |
603 val ({intrs = intrs_gen, elims = [elim_gen], preds = [ Rdef ], induct, raw_induct, ...}, lthy) = |
604 lthy |
604 lthy |
|
605 |> Config.put Inductive.inductive_internals true |
605 |> Proof_Context.concealed |
606 |> Proof_Context.concealed |
606 |> Inductive.add_inductive_i |
607 |> Inductive.add_inductive_i |
607 {quiet_mode = true, |
608 {quiet_mode = true, |
608 verbose = ! trace, |
609 verbose = ! trace, |
609 alt_name = Binding.empty, |
610 alt_name = Binding.empty, |
614 [binding] (* relation *) |
615 [binding] (* relation *) |
615 [] (* no parameters *) |
616 [] (* no parameters *) |
616 (map (fn t => (Attrib.empty_binding, t)) intrs) (* intro rules *) |
617 (map (fn t => (Attrib.empty_binding, t)) intrs) (* intro rules *) |
617 [] (* no special monos *) |
618 [] (* no special monos *) |
618 ||> Proof_Context.restore_naming lthy |
619 ||> Proof_Context.restore_naming lthy |
|
620 ||> Config.put Inductive.inductive_internals (Config.get lthy Inductive.inductive_internals) |
619 |
621 |
620 val cert = Thm.cterm_of lthy |
622 val cert = Thm.cterm_of lthy |
621 fun requantify orig_intro thm = |
623 fun requantify orig_intro thm = |
622 let |
624 let |
623 val (qs, t) = dest_all_all orig_intro |
625 val (qs, t) = dest_all_all orig_intro |
847 |
849 |
848 val simple_induct_rule = |
850 val simple_induct_rule = |
849 subset_induct_rule |
851 subset_induct_rule |
850 |> Thm.forall_intr (Thm.cterm_of ctxt D) |
852 |> Thm.forall_intr (Thm.cterm_of ctxt D) |
851 |> Thm.forall_elim (Thm.cterm_of ctxt acc_R) |
853 |> Thm.forall_elim (Thm.cterm_of ctxt acc_R) |
852 |> atac 1 |> Seq.hd |
854 |> assume_tac ctxt 1 |> Seq.hd |
853 |> (curry op COMP) (acc_downward |
855 |> (curry op COMP) (acc_downward |
854 |> (instantiate' [SOME (Thm.ctyp_of ctxt domT)] |
856 |> (Thm.instantiate' [SOME (Thm.ctyp_of ctxt domT)] |
855 (map (SOME o Thm.cterm_of ctxt) [R, x, z])) |
857 (map (SOME o Thm.cterm_of ctxt) [R, x, z])) |
856 |> Thm.forall_intr (Thm.cterm_of ctxt z) |
858 |> Thm.forall_intr (Thm.cterm_of ctxt z) |
857 |> Thm.forall_intr (Thm.cterm_of ctxt x)) |
859 |> Thm.forall_intr (Thm.cterm_of ctxt x)) |
858 |> Thm.forall_intr (Thm.cterm_of ctxt a) |
860 |> Thm.forall_intr (Thm.cterm_of ctxt a) |
859 |> Thm.forall_intr (Thm.cterm_of ctxt P) |
861 |> Thm.forall_intr (Thm.cterm_of ctxt P) |
1061 |
1063 |
1062 val (goalstate, values) = PROFILE "prove_stuff" |
1064 val (goalstate, values) = PROFILE "prove_stuff" |
1063 (prove_stuff lthy globals G f R xclauses complete compat |
1065 (prove_stuff lthy globals G f R xclauses complete compat |
1064 compat_store G_elim G_eqvt invariant) f_defthm |
1066 compat_store G_elim G_eqvt invariant) f_defthm |
1065 |
1067 |
1066 fun mk_partial_rules provedgoal = |
1068 fun mk_partial_rules newctxt provedgoal = |
1067 let |
1069 let |
1068 val newthy = Thm.theory_of_thm provedgoal (*FIXME*) |
|
1069 val newctxt = Proof_Context.init_global newthy (*FIXME*) |
|
1070 |
|
1071 val ((graph_is_function, complete_thm), graph_is_eqvt) = |
1070 val ((graph_is_function, complete_thm), graph_is_eqvt) = |
1072 provedgoal |
1071 provedgoal |
1073 |> Conjunction.elim |
1072 |> Conjunction.elim |
1074 |>> fst o Conjunction.elim |
1073 |>> fst o Conjunction.elim |
1075 |>> Conjunction.elim |
1074 |>> Conjunction.elim |