1 (* Title: ZF/Constructible/Rec_Separation.thy |
1 (* Title: ZF/Constructible/Rec_Separation.thy |
2 Author: Lawrence C Paulson, Cambridge University Computer Laboratory |
2 Author: Lawrence C Paulson, Cambridge University Computer Laboratory |
3 *) |
3 *) |
4 |
4 |
5 section {*Separation for Facts About Recursion*} |
5 section \<open>Separation for Facts About Recursion\<close> |
6 |
6 |
7 theory Rec_Separation imports Separation Internalize begin |
7 theory Rec_Separation imports Separation Internalize begin |
8 |
8 |
9 text{*This theory proves all instances needed for locales @{text |
9 text\<open>This theory proves all instances needed for locales @{text |
10 "M_trancl"} and @{text "M_datatypes"}*} |
10 "M_trancl"} and @{text "M_datatypes"}\<close> |
11 |
11 |
12 lemma eq_succ_imp_lt: "[|i = succ(j); Ord(i)|] ==> j<i" |
12 lemma eq_succ_imp_lt: "[|i = succ(j); Ord(i)|] ==> j<i" |
13 by simp |
13 by simp |
14 |
14 |
15 |
15 |
16 subsection{*The Locale @{text "M_trancl"}*} |
16 subsection\<open>The Locale @{text "M_trancl"}\<close> |
17 |
17 |
18 subsubsection{*Separation for Reflexive/Transitive Closure*} |
18 subsubsection\<open>Separation for Reflexive/Transitive Closure\<close> |
19 |
19 |
20 text{*First, The Defining Formula*} |
20 text\<open>First, The Defining Formula\<close> |
21 |
21 |
22 (* "rtran_closure_mem(M,A,r,p) == |
22 (* "rtran_closure_mem(M,A,r,p) == |
23 \<exists>nnat[M]. \<exists>n[M]. \<exists>n'[M]. |
23 \<exists>nnat[M]. \<exists>n[M]. \<exists>n'[M]. |
24 omega(M,nnat) & n\<in>nnat & successor(M,n,n') & |
24 omega(M,nnat) & n\<in>nnat & successor(M,n,n') & |
25 (\<exists>f[M]. typed_function(M,n',A,f) & |
25 (\<exists>f[M]. typed_function(M,n',A,f) & |
70 \<lambda>i x. rtran_closure_mem(##Lset(i),f(x),g(x),h(x))]" |
70 \<lambda>i x. rtran_closure_mem(##Lset(i),f(x),g(x),h(x))]" |
71 apply (simp only: rtran_closure_mem_def) |
71 apply (simp only: rtran_closure_mem_def) |
72 apply (intro FOL_reflections function_reflections fun_plus_reflections) |
72 apply (intro FOL_reflections function_reflections fun_plus_reflections) |
73 done |
73 done |
74 |
74 |
75 text{*Separation for @{term "rtrancl(r)"}.*} |
75 text\<open>Separation for @{term "rtrancl(r)"}.\<close> |
76 lemma rtrancl_separation: |
76 lemma rtrancl_separation: |
77 "[| L(r); L(A) |] ==> separation (L, rtran_closure_mem(L,A,r))" |
77 "[| L(r); L(A) |] ==> separation (L, rtran_closure_mem(L,A,r))" |
78 apply (rule gen_separation_multi [OF rtran_closure_mem_reflection, of "{r,A}"], |
78 apply (rule gen_separation_multi [OF rtran_closure_mem_reflection, of "{r,A}"], |
79 auto) |
79 auto) |
80 apply (rule_tac env="[r,A]" in DPow_LsetI) |
80 apply (rule_tac env="[r,A]" in DPow_LsetI) |
81 apply (rule rtran_closure_mem_iff_sats sep_rules | simp)+ |
81 apply (rule rtran_closure_mem_iff_sats sep_rules | simp)+ |
82 done |
82 done |
83 |
83 |
84 |
84 |
85 subsubsection{*Reflexive/Transitive Closure, Internalized*} |
85 subsubsection\<open>Reflexive/Transitive Closure, Internalized\<close> |
86 |
86 |
87 (* "rtran_closure(M,r,s) == |
87 (* "rtran_closure(M,r,s) == |
88 \<forall>A[M]. is_field(M,r,A) \<longrightarrow> |
88 \<forall>A[M]. is_field(M,r,A) \<longrightarrow> |
89 (\<forall>p[M]. p \<in> s \<longleftrightarrow> rtran_closure_mem(M,A,r,p))" *) |
89 (\<forall>p[M]. p \<in> s \<longleftrightarrow> rtran_closure_mem(M,A,r,p))" *) |
90 definition |
90 definition |
116 apply (simp only: rtran_closure_def) |
116 apply (simp only: rtran_closure_def) |
117 apply (intro FOL_reflections function_reflections rtran_closure_mem_reflection) |
117 apply (intro FOL_reflections function_reflections rtran_closure_mem_reflection) |
118 done |
118 done |
119 |
119 |
120 |
120 |
121 subsubsection{*Transitive Closure of a Relation, Internalized*} |
121 subsubsection\<open>Transitive Closure of a Relation, Internalized\<close> |
122 |
122 |
123 (* "tran_closure(M,r,t) == |
123 (* "tran_closure(M,r,t) == |
124 \<exists>s[M]. rtran_closure(M,r,s) & composition(M,r,s,t)" *) |
124 \<exists>s[M]. rtran_closure(M,r,s) & composition(M,r,s,t)" *) |
125 definition |
125 definition |
126 tran_closure_fm :: "[i,i]=>i" where |
126 tran_closure_fm :: "[i,i]=>i" where |
150 apply (intro FOL_reflections function_reflections |
150 apply (intro FOL_reflections function_reflections |
151 rtran_closure_reflection composition_reflection) |
151 rtran_closure_reflection composition_reflection) |
152 done |
152 done |
153 |
153 |
154 |
154 |
155 subsubsection{*Separation for the Proof of @{text "wellfounded_on_trancl"}*} |
155 subsubsection\<open>Separation for the Proof of @{text "wellfounded_on_trancl"}\<close> |
156 |
156 |
157 lemma wellfounded_trancl_reflects: |
157 lemma wellfounded_trancl_reflects: |
158 "REFLECTS[\<lambda>x. \<exists>w[L]. \<exists>wx[L]. \<exists>rp[L]. |
158 "REFLECTS[\<lambda>x. \<exists>w[L]. \<exists>wx[L]. \<exists>rp[L]. |
159 w \<in> Z & pair(L,w,x,wx) & tran_closure(L,r,rp) & wx \<in> rp, |
159 w \<in> Z & pair(L,w,x,wx) & tran_closure(L,r,rp) & wx \<in> rp, |
160 \<lambda>i x. \<exists>w \<in> Lset(i). \<exists>wx \<in> Lset(i). \<exists>rp \<in> Lset(i). |
160 \<lambda>i x. \<exists>w \<in> Lset(i). \<exists>wx \<in> Lset(i). \<exists>rp \<in> Lset(i). |
173 apply (rule_tac env="[r,Z]" in DPow_LsetI) |
173 apply (rule_tac env="[r,Z]" in DPow_LsetI) |
174 apply (rule sep_rules tran_closure_iff_sats | simp)+ |
174 apply (rule sep_rules tran_closure_iff_sats | simp)+ |
175 done |
175 done |
176 |
176 |
177 |
177 |
178 subsubsection{*Instantiating the locale @{text M_trancl}*} |
178 subsubsection\<open>Instantiating the locale @{text M_trancl}\<close> |
179 |
179 |
180 lemma M_trancl_axioms_L: "M_trancl_axioms(L)" |
180 lemma M_trancl_axioms_L: "M_trancl_axioms(L)" |
181 apply (rule M_trancl_axioms.intro) |
181 apply (rule M_trancl_axioms.intro) |
182 apply (assumption | rule rtrancl_separation wellfounded_trancl_separation)+ |
182 apply (assumption | rule rtrancl_separation wellfounded_trancl_separation)+ |
183 done |
183 done |
186 by (rule M_trancl.intro [OF M_basic_L M_trancl_axioms_L]) |
186 by (rule M_trancl.intro [OF M_basic_L M_trancl_axioms_L]) |
187 |
187 |
188 interpretation L?: M_trancl L by (rule M_trancl_L) |
188 interpretation L?: M_trancl L by (rule M_trancl_L) |
189 |
189 |
190 |
190 |
191 subsection{*@{term L} is Closed Under the Operator @{term list}*} |
191 subsection\<open>@{term L} is Closed Under the Operator @{term list}\<close> |
192 |
192 |
193 subsubsection{*Instances of Replacement for Lists*} |
193 subsubsection\<open>Instances of Replacement for Lists\<close> |
194 |
194 |
195 lemma list_replacement1_Reflects: |
195 lemma list_replacement1_Reflects: |
196 "REFLECTS |
196 "REFLECTS |
197 [\<lambda>x. \<exists>u[L]. u \<in> B \<and> (\<exists>y[L]. pair(L,u,y,x) \<and> |
197 [\<lambda>x. \<exists>u[L]. u \<in> B \<and> (\<exists>y[L]. pair(L,u,y,x) \<and> |
198 is_wfrec(L, iterates_MH(L, is_list_functor(L,A), 0), memsn, u, y)), |
198 is_wfrec(L, iterates_MH(L, is_list_functor(L,A), 0), memsn, u, y)), |
236 apply (rule_tac env="[A,B,0,nat]" in DPow_LsetI) |
236 apply (rule_tac env="[A,B,0,nat]" in DPow_LsetI) |
237 apply (rule sep_rules list_functor_iff_sats is_iterates_iff_sats | simp)+ |
237 apply (rule sep_rules list_functor_iff_sats is_iterates_iff_sats | simp)+ |
238 done |
238 done |
239 |
239 |
240 |
240 |
241 subsection{*@{term L} is Closed Under the Operator @{term formula}*} |
241 subsection\<open>@{term L} is Closed Under the Operator @{term formula}\<close> |
242 |
242 |
243 subsubsection{*Instances of Replacement for Formulas*} |
243 subsubsection\<open>Instances of Replacement for Formulas\<close> |
244 |
244 |
245 (*FIXME: could prove a lemma iterates_replacementI to eliminate the |
245 (*FIXME: could prove a lemma iterates_replacementI to eliminate the |
246 need to expand iterates_replacement and wfrec_replacement*) |
246 need to expand iterates_replacement and wfrec_replacement*) |
247 lemma formula_replacement1_Reflects: |
247 lemma formula_replacement1_Reflects: |
248 "REFLECTS |
248 "REFLECTS |
285 auto simp add: nonempty L_nat) |
285 auto simp add: nonempty L_nat) |
286 apply (rule_tac env="[B,0,nat]" in DPow_LsetI) |
286 apply (rule_tac env="[B,0,nat]" in DPow_LsetI) |
287 apply (rule sep_rules formula_functor_iff_sats is_iterates_iff_sats | simp)+ |
287 apply (rule sep_rules formula_functor_iff_sats is_iterates_iff_sats | simp)+ |
288 done |
288 done |
289 |
289 |
290 text{*NB The proofs for type @{term formula} are virtually identical to those |
290 text\<open>NB The proofs for type @{term formula} are virtually identical to those |
291 for @{term "list(A)"}. It was a cut-and-paste job! *} |
291 for @{term "list(A)"}. It was a cut-and-paste job!\<close> |
292 |
292 |
293 |
293 |
294 subsubsection{*The Formula @{term is_nth}, Internalized*} |
294 subsubsection\<open>The Formula @{term is_nth}, Internalized\<close> |
295 |
295 |
296 (* "is_nth(M,n,l,Z) == |
296 (* "is_nth(M,n,l,Z) == |
297 \<exists>X[M]. is_iterates(M, is_tl(M), l, n, X) & is_hd(M,X,Z)" *) |
297 \<exists>X[M]. is_iterates(M, is_tl(M), l, n, X) & is_hd(M,X,Z)" *) |
298 definition |
298 definition |
299 nth_fm :: "[i,i,i]=>i" where |
299 nth_fm :: "[i,i,i]=>i" where |
326 apply (intro FOL_reflections is_iterates_reflection |
326 apply (intro FOL_reflections is_iterates_reflection |
327 hd_reflection tl_reflection) |
327 hd_reflection tl_reflection) |
328 done |
328 done |
329 |
329 |
330 |
330 |
331 subsubsection{*An Instance of Replacement for @{term nth}*} |
331 subsubsection\<open>An Instance of Replacement for @{term nth}\<close> |
332 |
332 |
333 (*FIXME: could prove a lemma iterates_replacementI to eliminate the |
333 (*FIXME: could prove a lemma iterates_replacementI to eliminate the |
334 need to expand iterates_replacement and wfrec_replacement*) |
334 need to expand iterates_replacement and wfrec_replacement*) |
335 lemma nth_replacement_Reflects: |
335 lemma nth_replacement_Reflects: |
336 "REFLECTS |
336 "REFLECTS |
354 apply (rule sep_rules is_nat_case_iff_sats tl_iff_sats |
354 apply (rule sep_rules is_nat_case_iff_sats tl_iff_sats |
355 is_wfrec_iff_sats iterates_MH_iff_sats quasinat_iff_sats | simp)+ |
355 is_wfrec_iff_sats iterates_MH_iff_sats quasinat_iff_sats | simp)+ |
356 done |
356 done |
357 |
357 |
358 |
358 |
359 subsubsection{*Instantiating the locale @{text M_datatypes}*} |
359 subsubsection\<open>Instantiating the locale @{text M_datatypes}\<close> |
360 |
360 |
361 lemma M_datatypes_axioms_L: "M_datatypes_axioms(L)" |
361 lemma M_datatypes_axioms_L: "M_datatypes_axioms(L)" |
362 apply (rule M_datatypes_axioms.intro) |
362 apply (rule M_datatypes_axioms.intro) |
363 apply (assumption | rule |
363 apply (assumption | rule |
364 list_replacement1 list_replacement2 |
364 list_replacement1 list_replacement2 |
373 done |
373 done |
374 |
374 |
375 interpretation L?: M_datatypes L by (rule M_datatypes_L) |
375 interpretation L?: M_datatypes L by (rule M_datatypes_L) |
376 |
376 |
377 |
377 |
378 subsection{*@{term L} is Closed Under the Operator @{term eclose}*} |
378 subsection\<open>@{term L} is Closed Under the Operator @{term eclose}\<close> |
379 |
379 |
380 subsubsection{*Instances of Replacement for @{term eclose}*} |
380 subsubsection\<open>Instances of Replacement for @{term eclose}\<close> |
381 |
381 |
382 lemma eclose_replacement1_Reflects: |
382 lemma eclose_replacement1_Reflects: |
383 "REFLECTS |
383 "REFLECTS |
384 [\<lambda>x. \<exists>u[L]. u \<in> B & (\<exists>y[L]. pair(L,u,y,x) & |
384 [\<lambda>x. \<exists>u[L]. u \<in> B & (\<exists>y[L]. pair(L,u,y,x) & |
385 is_wfrec(L, iterates_MH(L, big_union(L), A), memsn, u, y)), |
385 is_wfrec(L, iterates_MH(L, big_union(L), A), memsn, u, y)), |
420 apply (rule_tac env="[A,B,nat]" in DPow_LsetI) |
420 apply (rule_tac env="[A,B,nat]" in DPow_LsetI) |
421 apply (rule sep_rules is_iterates_iff_sats big_union_iff_sats | simp)+ |
421 apply (rule sep_rules is_iterates_iff_sats big_union_iff_sats | simp)+ |
422 done |
422 done |
423 |
423 |
424 |
424 |
425 subsubsection{*Instantiating the locale @{text M_eclose}*} |
425 subsubsection\<open>Instantiating the locale @{text M_eclose}\<close> |
426 |
426 |
427 lemma M_eclose_axioms_L: "M_eclose_axioms(L)" |
427 lemma M_eclose_axioms_L: "M_eclose_axioms(L)" |
428 apply (rule M_eclose_axioms.intro) |
428 apply (rule M_eclose_axioms.intro) |
429 apply (assumption | rule eclose_replacement1 eclose_replacement2)+ |
429 apply (assumption | rule eclose_replacement1 eclose_replacement2)+ |
430 done |
430 done |