handle the general case with more than two levels of nesting when discharging induction prem prems
1 (* Title: HOL/Codatatype/BNF_FP.thy
2 Author: Dmitriy Traytel, TU Muenchen
3 Author: Jasmin Blanchette, TU Muenchen
6 Composition of bounded natural functors.
9 header {* Composition of Bounded Natural Functors *}
12 imports BNF_Comp BNF_Wrap
17 lemma case_unit: "(case u of () => f) = f"
18 by (cases u) (hypsubst, rule unit.cases)
20 lemma unit_all_impI: "(P () \<Longrightarrow> Q ()) \<Longrightarrow> \<forall>x. P x \<longrightarrow> Q x"
23 lemma prod_all_impI: "(\<And>x y. P (x, y) \<Longrightarrow> Q (x, y)) \<Longrightarrow> \<forall>x. P x \<longrightarrow> Q x"
26 lemma prod_all_impI_step: "(\<And>x. \<forall>y. P (x, y) \<longrightarrow> Q (x, y)) \<Longrightarrow> \<forall>x. P x \<longrightarrow> Q x"
29 lemma all_unit_eq: "(\<And>x. PROP P x) \<equiv> PROP P ()"
32 lemma all_prod_eq: "(\<And>x. PROP P x) \<equiv> (\<And>a b. PROP P (a, b))"
35 lemma rev_bspec: "a \<in> A \<Longrightarrow> \<forall>z \<in> A. P z \<Longrightarrow> P a"
38 lemma Un_cong: "\<lbrakk>A = B; C = D\<rbrakk> \<Longrightarrow> A \<union> C = B \<union> D"
41 definition convol ("<_ , _>") where
42 "<f , g> \<equiv> %a. (f a, g a)"
47 unfolding convol_def by simp
52 unfolding convol_def by simp
54 lemma pointfree_idE: "f o g = id \<Longrightarrow> f (g x) = x"
55 unfolding o_def fun_eq_iff by simp
58 assumes gf: "g o f = id" and fg: "f o g = id"
60 unfolding bij_def inj_on_def surj_def proof safe
61 fix a1 a2 assume "f a1 = f a2"
62 hence "g ( f a1) = g (f a2)" by simp
63 thus "a1 = a2" using gf unfolding fun_eq_iff by simp
67 using fg unfolding fun_eq_iff by simp
68 thus "EX a. b = f a" by blast
71 lemma ssubst_mem: "\<lbrakk>t = s; s \<in> X\<rbrakk> \<Longrightarrow> t \<in> X" by simp
74 "sum_case (sum_case f' g') g (Inl p) = sum_case f' g' p"
75 "sum_case f (sum_case f' g') (Inr p) = sum_case f' g' p"
78 lemma one_pointE: "\<lbrakk>\<And>x. s = x \<Longrightarrow> P\<rbrakk> \<Longrightarrow> P"
81 lemma obj_one_pointE: "\<forall>x. s = x \<longrightarrow> P \<Longrightarrow> P"
85 "\<lbrakk>\<forall>x. s = f (Inl x) \<longrightarrow> P; \<forall>x. s = f (Inr x) \<longrightarrow> P\<rbrakk> \<Longrightarrow> s = f x \<longrightarrow> P"
89 "\<lbrakk>\<forall>x. s = f (Inl x) \<longrightarrow> P; \<forall>x. s = f (Inr x) \<longrightarrow> P\<rbrakk> \<Longrightarrow> \<forall>x. s = f x \<longrightarrow> P"
90 by (rule allI) (rule obj_sumE_f')
92 lemma obj_sumE: "\<lbrakk>\<forall>x. s = Inl x \<longrightarrow> P; \<forall>x. s = Inr x \<longrightarrow> P\<rbrakk> \<Longrightarrow> P"
96 "\<lbrakk>\<forall>x. s = f (Inr (Inl x)) \<longrightarrow> P; \<forall>x. s = f (Inr (Inr x)) \<longrightarrow> P\<rbrakk> \<Longrightarrow> s = f (Inr x) \<longrightarrow> P"
100 "\<lbrakk>\<forall>x. s = f (Inr (Inl x)) \<longrightarrow> P; \<forall>x. s = f (Inr (Inr x)) \<longrightarrow> P\<rbrakk> \<Longrightarrow> \<forall>x. s = f (Inr x) \<longrightarrow> P"
101 by (rule allI) (rule obj_sum_step')
104 "sum_case f g (if p then Inl x else Inr y) = (if p then f x else g y)"
107 lemma UN_compreh_bex_eq_empty:
108 "\<Union>{y. \<exists>x\<in>A. y = {}} = {}"
111 lemma UN_compreh_bex_eq_singleton:
112 "\<Union>{y. \<exists>x\<in>A. y = {f x}} = {y. \<exists>x\<in>A. y = f x}"
115 lemma mem_UN_comprehI:
116 "z \<in> {y. \<exists>x\<in>A. y = f x} \<Longrightarrow> z \<in> \<Union>{y. \<exists>x\<in>A. y = {f x}}"
117 "z \<in> {y. \<exists>x\<in>A. y = f x} \<union> B \<Longrightarrow> z \<in> \<Union>{y. \<exists>x\<in>A. y = {f x}} \<union> B"
118 "z \<in> \<Union>{y. \<exists>x\<in>A. y = F x} \<union> \<Union>{y. \<exists>x\<in>A. y = G x} \<Longrightarrow> z \<in> \<Union>{y. \<exists>x\<in>A. y = F x \<union> G x}"
119 "z \<in> \<Union>{y. \<exists>x\<in>A. y = F x} \<union> (\<Union>{y. \<exists>x\<in>A. y = G x} \<union> B) \<Longrightarrow> z \<in> \<Union>{y. \<exists>x\<in>A. y = F x \<union> G x} \<union> B"
122 lemma mem_UN_comprehI':
123 "\<exists>y. (\<exists>x\<in>A. y = F x) \<and> z \<in> y \<Longrightarrow> z \<in> \<Union>{y. \<exists>x\<in>A. y = {y. \<exists>y'\<in>F x. y = y'}}"
126 lemma mem_UN_compreh_eq: "(z : \<Union>{y. \<exists>x\<in>A. y = F x}) = (\<exists>x\<in>A. z : F x)"
129 lemma eq_UN_compreh_Un: "(xa = \<Union>{y. \<exists>x\<in>A. y = c_set1 x \<union> c_set2 x}) =
130 (xa = (\<Union>{y. \<exists>x\<in>A. y = c_set1 x} \<union> \<Union>{y. \<exists>x\<in>A. y = c_set2 x}))"
133 lemma mem_compreh_eq_iff:
134 "z \<in> {y. \<exists>x\<in>A. y = f x} = (\<exists> x. x \<in> A & z \<in> {f x})"
137 lemma ex_mem_singleton: "(\<exists>y. y \<in> A \<and> y \<in> {x}) = (x \<in> A)"
140 lemma induct_set_step:
141 "\<lbrakk>b \<in> A; c \<in> F b\<rbrakk> \<Longrightarrow> \<exists>x. x \<in> A \<and> c \<in> F x"
142 "\<lbrakk>B \<in> A; c \<in> f B\<rbrakk> \<Longrightarrow> \<exists>C. (\<exists>a \<in> A. C = f a) \<and>c \<in> C"
145 ML_file "Tools/bnf_fp_util.ML"
146 ML_file "Tools/bnf_fp_sugar_tactics.ML"
147 ML_file "Tools/bnf_fp_sugar.ML"