122 val SchemeBranch { xs, ws, Cs, ... } = nth branches bidx |
122 val SchemeBranch { xs, ws, Cs, ... } = nth branches bidx |
123 val relevant_cases = filter (fn SchemeCase {bidx=bidx', ...} => bidx' = bidx) cases |
123 val relevant_cases = filter (fn SchemeCase {bidx=bidx', ...} => bidx' = bidx) cases |
124 |
124 |
125 val allqnames = fold (fn SchemeCase {qs, ...} => fold (insert (op =) o Free) qs) relevant_cases [] |
125 val allqnames = fold (fn SchemeCase {qs, ...} => fold (insert (op =) o Free) qs) relevant_cases [] |
126 val (Pbool :: xs') = map Free (Variable.variant_frees ctxt allqnames (("P", HOLogic.boolT) :: xs)) |
126 val (Pbool :: xs') = map Free (Variable.variant_frees ctxt allqnames (("P", HOLogic.boolT) :: xs)) |
127 val Cs' = map (Pattern.rewrite_term (ProofContext.theory_of ctxt) (filter_out (op aconv) (map Free xs ~~ xs')) []) Cs |
127 val Cs' = map (Pattern.rewrite_term (Proof_Context.theory_of ctxt) (filter_out (op aconv) (map Free xs ~~ xs')) []) Cs |
128 |
128 |
129 fun mk_case (SchemeCase {qs, oqnames, gs, lhs, ...}) = |
129 fun mk_case (SchemeCase {qs, oqnames, gs, lhs, ...}) = |
130 HOLogic.mk_Trueprop Pbool |
130 HOLogic.mk_Trueprop Pbool |
131 |> fold_rev (fn x_l => curry Logic.mk_implies (HOLogic.mk_Trueprop(HOLogic.mk_eq x_l))) |
131 |> fold_rev (fn x_l => curry Logic.mk_implies (HOLogic.mk_Trueprop(HOLogic.mk_eq x_l))) |
132 (xs' ~~ lhs) |
132 (xs' ~~ lhs) |
209 |
209 |
210 fun inject i ts = |
210 fun inject i ts = |
211 SumTree.mk_inj T n (i + 1) (foldr1 HOLogic.mk_prod ts) |
211 SumTree.mk_inj T n (i + 1) (foldr1 HOLogic.mk_prod ts) |
212 val P_of = nth (map (fn (SchemeBranch { P, ... }) => P) branches) |
212 val P_of = nth (map (fn (SchemeBranch { P, ... }) => P) branches) |
213 |
213 |
214 val thy = ProofContext.theory_of ctxt |
214 val thy = Proof_Context.theory_of ctxt |
215 val cert = cterm_of thy |
215 val cert = cterm_of thy |
216 |
216 |
217 val P_comp = mk_ind_goal thy branches |
217 val P_comp = mk_ind_goal thy branches |
218 |
218 |
219 (* Inductive Hypothesis: !!z. (z,x):R ==> P z *) |
219 (* Inductive Hypothesis: !!z. (z,x):R ==> P z *) |
349 val (ctxt', _, cases, concl) = dest_hhf ctxt t |
349 val (ctxt', _, cases, concl) = dest_hhf ctxt t |
350 val scheme as IndScheme {T=ST, branches, ...} = mk_scheme' ctxt' cases concl |
350 val scheme as IndScheme {T=ST, branches, ...} = mk_scheme' ctxt' cases concl |
351 val ([Rn,xn], ctxt'') = Variable.variant_fixes ["R","x"] ctxt' |
351 val ([Rn,xn], ctxt'') = Variable.variant_fixes ["R","x"] ctxt' |
352 val R = Free (Rn, mk_relT ST) |
352 val R = Free (Rn, mk_relT ST) |
353 val x = Free (xn, ST) |
353 val x = Free (xn, ST) |
354 val cert = cterm_of (ProofContext.theory_of ctxt) |
354 val cert = cterm_of (Proof_Context.theory_of ctxt) |
355 |
355 |
356 val ineqss = mk_ineqs R scheme |
356 val ineqss = mk_ineqs R scheme |
357 |> map (map (pairself (Thm.assume o cert))) |
357 |> map (map (pairself (Thm.assume o cert))) |
358 val complete = |
358 val complete = |
359 map_range (mk_completeness ctxt scheme #> cert #> Thm.assume) (length branches) |
359 map_range (mk_completeness ctxt scheme #> cert #> Thm.assume) (length branches) |