Theory Nat_Miscellanea
sectionâ¹Auxiliary results on arithmetic⺠theory Nat_Miscellanea imports Delta_System_Lemma.ZF_Library begin (* no_notation add (infixl â¹#+⺠65) no_notation diff (infixl â¹#-⺠65) *) notation add (infixl â¹+â©Ï⺠65) notation diff (infixl â¹-â©Ï⺠65) textâ¹Most of these results will get used at some point for the calculation of arities.⺠lemmas nat_succI = Ord_succ_mem_iff [THEN iffD2,OF nat_into_Ord] lemma nat_succD : "m â nat â¹ succ(n) â succ(m) â¹ n â m" by (drule_tac j="succ(m)" in ltI,auto elim:ltD) lemmas zero_in_succ = ltD [OF nat_0_le] lemma in_n_in_nat : "m â nat â¹ n â m â¹ n â nat" by(drule ltI[of "n"],auto simp add: lt_nat_in_nat) lemma ltI_neg : "x â nat â¹ j ⤠x â¹ j â x â¹ j < x" by (simp add: le_iff) lemma succ_pred_eq : "m â nat â¹ m â 0 â¹ succ(pred(m)) = m" by (auto elim: natE) lemma succ_ltI : "succ(j) < n â¹ j < n" by (simp add: succ_leE[OF leI]) lemmas succ_leD = succ_leE[OF leI] lemma succpred_leI : "n â nat â¹ n ⤠succ(pred(n))" by (auto elim: natE) lemma succpred_n0 : "succ(n) â p â¹ pâ 0" by (auto) lemmas natEin = natE [OF lt_nat_in_nat] lemmas Un_least_lt_iffn = Un_least_lt_iff [OF nat_into_Ord nat_into_Ord] lemma pred_type : "m â nat â¹ n ⤠m â¹ nânat" by (rule leE,auto simp:in_n_in_nat ltD) lemma pred_le : "m â nat â¹ n ⤠succ(m) â¹ pred(n) ⤠m" by(rule_tac n="n" in natE,auto simp add:pred_type[of "succ(m)"]) lemma pred_le2 : "nâ nat â¹ m â nat â¹ pred(n) ⤠m â¹ n ⤠succ(m)" by(subgoal_tac "nânat",rule_tac n="n" in natE,auto) lemma Un_leD1 : "Ord(i)â¹ Ord(j)â¹ Ord(k)â¹ i ⪠j ⤠k â¹ i ⤠k" by (rule Un_least_lt_iff[THEN iffD1[THEN conjunct1]],simp_all) lemma Un_leD2 : "Ord(i)â¹ Ord(j)â¹ Ord(k)â¹ i ⪠j â¤k â¹ j ⤠k" by (rule Un_least_lt_iff[THEN iffD1[THEN conjunct2]],simp_all) lemma gt1 : "n â nat â¹ i â n â¹ i â 0 â¹ i â 1 â¹ 1<i" by(rule_tac n="i" in natE,erule in_n_in_nat,auto intro: Ord_0_lt) lemma pred_mono : "m â nat â¹ n ⤠m â¹ pred(n) ⤠pred(m)" by(rule_tac n="n" in natE,auto simp add:le_in_nat,erule_tac n="m" in natE,auto) lemma succ_mono : "m â nat â¹ n ⤠m â¹ succ(n) ⤠succ(m)" by auto lemma union_abs1 : "⦠i ⤠j â§ â¹ i ⪠j = j" by (rule Un_absorb1,erule le_imp_subset) lemma union_abs2 : "⦠i ⤠j â§ â¹ j ⪠i = j" by (rule Un_absorb2,erule le_imp_subset) lemma ord_un_max : "Ord(i) â¹ Ord(j) â¹ i ⪠j = max(i,j)" using max_def union_abs1 not_lt_iff_le leI union_abs2 by auto lemma ord_max_ty : "Ord(i) â¹Ord(j) â¹ Ord(max(i,j))" unfolding max_def by simp lemmas ord_simp_union = ord_un_max ord_max_ty max_def lemma le_succ : "xânat â¹ xâ¤succ(x)" by simp lemma le_pred : "xânat â¹ pred(x)â¤x" using pred_le[OF _ le_succ] pred_succ_eq by simp lemma not_le_anti_sym : "xânat â¹ y â nat ⹠¬ xâ¤y ⹠¬yâ¤x â¹ y=x" using Ord_linear not_le_iff_lt ltD lt_trans by auto lemma Un_le_compat : "o ⤠p â¹ q ⤠r â¹ Ord(o) â¹ Ord(p) â¹ Ord(q) â¹ Ord(r) â¹ o ⪠q ⤠p ⪠r" using le_trans[of q r "pâªr",OF _ Un_upper2_le] le_trans[of o p "pâªr",OF _ Un_upper1_le] ord_simp_union by auto lemma Un_le : "p ⤠r â¹ q ⤠r â¹ Ord(p) â¹ Ord(q) â¹ Ord(r) â¹ p ⪠q ⤠r" using ord_simp_union by auto lemma Un_leI3 : "o ⤠r â¹ p ⤠r â¹ q ⤠r â¹ Ord(o) â¹ Ord(p) â¹ Ord(q) â¹ Ord(r) â¹ o ⪠p ⪠q ⤠r" using ord_simp_union by auto lemma diff_mono : assumes "m â nat" "nânat" "p â nat" "m < n" "pâ¤m" shows "m#-p < n#-p" proof - from assms have "m#-p â nat" "m#-p +â©Ïp = m" using add_diff_inverse2 by simp_all with assms show ?thesis using less_diff_conv[of n p "m #- p",THEN iffD2] by simp qed lemma pred_Un: "x â nat â¹ y â nat â¹ pred(succ(x) ⪠y) = x ⪠pred(y)" "x â nat â¹ y â nat â¹ pred(x ⪠succ(y)) = pred(x) ⪠y" using pred_Un_distrib pred_succ_eq by simp_all lemma le_natI : "j ⤠n â¹ n â nat â¹ jânat" by(drule ltD,rule in_n_in_nat,rule nat_succ_iff[THEN iffD2,of n],simp_all) lemma le_natE : "nânat â¹ j < n â¹ jân" by(rule ltE[of j n],simp+) lemma leD : assumes "nânat" "j ⤠n" shows "j < n | j = n" using leE[OF â¹jâ¤nâº,of "j<n | j = n"] by auto lemma pred_nat_eq : assumes "nânat" shows "pred(n) = â n" using assms proof(induct) case 0 then show ?case by simp next case (succ x) then show ?case using pred_succ_eq Ord_Union_succ_eq by simp qed subsectionâ¹Some results in ordinal arithmetic⺠textâ¹The following results are auxiliary to the proof of wellfoundedness of the relation \<^term>â¹frecRâºâº lemma max_cong : assumes "x ⤠y" "Ord(y)" "Ord(z)" shows "max(x,y) ⤠max(y,z)" proof (cases "y ⤠z") case True then show ?thesis unfolding max_def using assms by simp next case False then have "z ⤠y" using assms not_le_iff_lt leI by simp then show ?thesis unfolding max_def using assms by simp qed lemma max_commutes : assumes "Ord(x)" "Ord(y)" shows "max(x,y) = max(y,x)" using assms Un_commute ord_simp_union(1) ord_simp_union(1)[symmetric] by auto lemma max_cong2 : assumes "x ⤠y" "Ord(y)" "Ord(z)" "Ord(x)" shows "max(x,z) ⤠max(y,z)" proof - from assms have " x ⪠z ⤠y ⪠z" using lt_Ord Ord_Un Un_mono[OF le_imp_subset[OF â¹xâ¤yâº]] subset_imp_le by auto then show ?thesis using ord_simp_union â¹Ord(x)⺠â¹Ord(z)⺠â¹Ord(y)⺠by simp qed lemma max_D1 : assumes "x = y" "w < z" "Ord(x)" "Ord(w)" "Ord(z)" "max(x,w) = max(y,z)" shows "zâ¤y" proof - from assms have "w < x ⪠w" using Un_upper2_lt[OF â¹w<zâº] assms ord_simp_union by simp then have "w < x" using assms lt_Un_iff[of x w w] lt_not_refl by auto then have "y = y ⪠z" using assms max_commutes ord_simp_union assms leI by simp then show ?thesis using Un_leD2 assms by simp qed lemma max_D2 : assumes "w = y ⨠w = z" "x < y" "Ord(x)" "Ord(w)" "Ord(y)" "Ord(z)" "max(x,w) = max(y,z)" shows "x<w" proof - from assms have "x < z ⪠y" using Un_upper2_lt[OF â¹x<yâº] by simp then consider (a) "x < y" | (b) "x < w" using assms ord_simp_union by simp then show ?thesis proof (cases) case a consider (c) "w = y" | (d) "w = z" using assms by auto then show ?thesis proof (cases) case c with a show ?thesis by simp next case d with a show ?thesis proof (cases "y <w") case True then show ?thesis using lt_trans[OF â¹x<yâº] by simp next case False then have "w ⤠y" using not_lt_iff_le[OF assms(5) assms(4)] by simp with â¹w=z⺠have "max(z,y) = y" unfolding max_def using assms by simp with assms have "... = x ⪠w" using ord_simp_union max_commutes by simp then show ?thesis using le_Un_iff assms by blast qed qed next case b then show ?thesis . qed qed lemma oadd_lt_mono2 : assumes "Ord(n)" "Ord(α)" "Ord(β)" "α < β" "x < n" "y < n" "0 <n" shows "n ** α + x < n **β + y" proof - consider (0) "β=0" | (s) γ where "Ord(γ)" "β = succ(γ)" | (l) "Limit(β)" using Ord_cases[OF â¹Ord(β)âº,of ?thesis] by force then show ?thesis proof cases case 0 then show ?thesis using â¹Î±<β⺠by auto next case s then have "αâ¤Î³" using â¹Î±<β⺠using leI by auto then have "n ** α ⤠n ** γ" using omult_le_mono[OF _ â¹Î±â¤Î³âº] â¹Ord(n)⺠by simp then have "n ** α + x < n ** γ + n" using oadd_lt_mono[OF _ â¹x<nâº] by simp also have "... = n ** β" using â¹Î²=succ(_)⺠omult_succ â¹Ord(β)⺠â¹Ord(n)⺠by simp finally have "n ** α + x < n ** β" by auto then show ?thesis using oadd_le_self â¹Ord(β)⺠lt_trans2 â¹Ord(n)⺠by auto next case l have "Ord(x)" using â¹x<n⺠lt_Ord by simp with l have "succ(α) < β" using Limit_has_succ â¹Î±<β⺠by simp have "n ** α + x < n ** α + n" using oadd_lt_mono[OF le_refl[OF Ord_omult[OF _ â¹Ord(α)âº]] â¹x<nâº] â¹Ord(n)⺠by simp also have "... = n ** succ(α)" using omult_succ â¹Ord(α)⺠â¹Ord(n)⺠by simp finally have "n ** α + x < n ** succ(α)" by simp with â¹succ(α) < β⺠have "n ** α + x < n ** β" using lt_trans omult_lt_mono â¹Ord(n)⺠â¹0<n⺠by auto then show ?thesis using oadd_le_self â¹Ord(β)⺠lt_trans2 â¹Ord(n)⺠by auto qed qed end
body>
Theory ZF_Miscellanea
sectionâ¹Various results missing from ZF.⺠theory ZF_Miscellanea imports ZF Nat_Miscellanea begin lemma function_subset: "function(f) â¹ gâf â¹ function(g)" unfolding function_def subset_def by auto lemma converse_refl : "refl(A,r) â¹ refl(A,converse(r))" unfolding refl_def by simp lemma Ord_lt_subset : "Ord(b) â¹ a<b â¹ aâb" by(intro subsetI,frule ltD,rule_tac Ord_trans,simp_all) lemma funcI : "f â A â B â¹ a â A â¹ b= f ` a â¹ â¨a, bâ© â f" by(simp_all add: apply_Pair) lemma vimage_fun_sing: assumes "fâAâB" "bâB" shows "{aâA . f`a=b} = f-``{b}" using assms vimage_singleton_iff function_apply_equality Pi_iff funcI by auto lemma image_fun_subset: "SâAâB â¹ CâAâ¹ {S ` x . xâ C} = S``C" using image_function[symmetric,of S C] domain_of_fun Pi_iff by auto lemma subset_Diff_Un: "X â A â¹ A = (A - X) ⪠X " by auto lemma Diff_bij: assumes "âAâF. X â A" shows "(λAâF. A-X) â bij(F, {A-X. AâF})" using assms unfolding bij_def inj_def surj_def by (auto intro:lam_type, subst subset_Diff_Un[of X]) auto lemma function_space_nonempty: assumes "bâB" shows "(λxâA. b) : A â B" using assms lam_type by force lemma vimage_lam: "(λxâA. f(x)) -`` B = { xâA . f(x) â B }" using lam_funtype[of A f, THEN [2] domain_type] lam_funtype[of A f, THEN [2] apply_equality] lamI[of _ A f] by auto blast lemma range_fun_subset_codomain: assumes "h:B â C" shows "range(h) â C" unfolding range_def domain_def converse_def using range_type[OF _ assms] by auto lemma Pi_rangeD: assumes "fâPi(A,B)" "b â range(f)" shows "âaâA. f`a = b" using assms apply_equality[OF _ assms(1), of _ b] domain_type[OF _ assms(1)] by auto lemma Pi_range_eq: "f â Pi(A,B) â¹ range(f) = {f ` x . x â A}" using Pi_rangeD[of f A B] apply_rangeI[of f A B] by blast lemma Pi_vimage_subset : "f â Pi(A,B) â¹ f-``C â A" unfolding Pi_def by auto definition minimum :: "i â i â i" where "minimum(r,B) â¡ THE b. first(b,B,r)" lemma minimum_in: "⦠well_ord(A,r); BâA; Bâ 0 â§ â¹ minimum(r,B) â B" using the_first_in unfolding minimum_def by simp lemma well_ord_surj_imp_inj_inverse: assumes "well_ord(A,r)" "h â surj(A,B)" shows "(λbâB. minimum(r, {aâA. h`a=b})) â inj(B,A)" proof - let ?f="λbâB. minimum(r, {aâA. h`a=b})" have "minimum(r, {a â A . h ` a = b}) â {aâA. h`a=b}" if "bâB" for b proof - from â¹h â surj(A,B)⺠that have "{aâA. h`a=b} â 0" unfolding surj_def by blast with â¹well_ord(A,r)⺠show "minimum(r,{aâA. h`a=b}) â {aâA. h`a=b}" using minimum_in by blast qed moreover from this have "?f : B â A" using lam_type[of B _ "λ_.A"] by simp moreover have "?f ` w = ?f ` x â¹ w = x" if "wâB" "xâB" for w x proof - from calculation that have "w = h ` minimum(r,{aâA. h`a=w})" "x = h ` minimum(r,{aâA. h`a=x})" by simp_all moreover assume "?f ` w = ?f ` x" moreover from this and that have "minimum(r, {a â A . h ` a = w}) = minimum(r, {a â A . h ` a = x})" unfolding minimum_def by simp_all moreover from calculation(1,2,4) show "w=x" by simp qed ultimately show ?thesis unfolding inj_def by blast qed lemma well_ord_surj_imp_lepoll: assumes "well_ord(A,r)" "h â surj(A,B)" shows "Bâ²A" unfolding lepoll_def using well_ord_surj_imp_inj_inverse[OF assms] by blast â â¹New result⺠lemma surj_imp_well_ord: assumes "well_ord(A,r)" "h â surj(A,B)" shows "âs. well_ord(B,s)" using assms lepoll_well_ord[OF well_ord_surj_imp_lepoll] by force lemma Pow_sing : "Pow({a}) = {0,{a}}" proof(intro equalityI,simp_all) have "z â {0,{a}}" if "z â {a}" for z using that by auto then show " Pow({a}) â {0, {a}}" by auto qed lemma Pow_cons: shows "Pow(cons(a,A)) = Pow(A) ⪠{{a} ⪠X . X: Pow(A)}" using Un_Pow_subset Pow_sing proof(intro equalityI,auto simp add:Un_Pow_subset) { fix C D assume "â B . BâPow(A) â¹ C â {a} ⪠B" "C â {a} ⪠A" "D â C" moreover from this have "âxâC . x=a ⨠xâA" by auto moreover from calculation consider (a) "D=a" | (b) "DâA" by auto from this have "DâA" proof(cases) case a with calculation show ?thesis by auto next case b then show ?thesis by simp qed } then show "âx xa. (âxaâPow(A). x â {a} ⪠xa) â¹ x â cons(a, A) â¹ xa â x â¹ xa â A" by auto qed lemma app_nm : assumes "nânat" "mânat" "fânâm" "x â nat" shows "f`x â nat" proof(cases "xân") case True then show ?thesis using assms in_n_in_nat apply_type by simp next case False then show ?thesis using assms apply_0 domain_of_fun by simp qed lemma Upair_eq_cons: "Upair(a,b) = {a,b}" unfolding cons_def by auto lemma converse_apply_eq : "converse(f) ` x = â(f -`` {x})" unfolding apply_def vimage_def by simp lemmas app_fun = apply_iff[THEN iffD1] lemma Finite_imp_lesspoll_nat: assumes "Finite(A)" shows "A ⺠nat" using assms subset_imp_lepoll[OF naturals_subset_nat] eq_lepoll_trans n_lesspoll_nat eq_lesspoll_trans unfolding Finite_def lesspoll_def by auto end
Theory Renaming
sectionâ¹Renaming of variables in internalized formulas⺠theory Renaming imports ZF_Miscellanea "ZF-Constructible.Formula" begin subsectionâ¹Renaming of free variables⺠definition union_fun :: "[i,i,i,i] â i" where "union_fun(f,g,m,p) ⡠λj â m ⪠p . if jâm then f`j else g`j" lemma union_fun_type: assumes "f â m â n" "g â p â q" shows "union_fun(f,g,m,p) â m ⪠p â n ⪠q" proof - let ?h="union_fun(f,g,m,p)" have D: "?h`x â n ⪠q" if "x â m ⪠p" for x proof (cases "x â m") case True then have "x â m ⪠p" by simp with â¹xâm⺠have "?h`x = f`x" unfolding union_fun_def beta by simp with â¹f â m â n⺠â¹xâm⺠have "?h`x â n" by simp then show ?thesis .. next case False with â¹x â m ⪠p⺠have "x â p" by auto with â¹xâm⺠have "?h`x = g`x" unfolding union_fun_def using beta by simp with â¹g â p â q⺠â¹xâp⺠have "?h`x â q" by simp then show ?thesis .. qed have A:"function(?h)" unfolding union_fun_def using function_lam by simp have " xâ (m ⪠p) à (n ⪠q)" if "xâ ?h" for x using that lamE[of x "m ⪠p" _ "x â (m ⪠p) à (n ⪠q)"] D unfolding union_fun_def by auto then have B:"?h â (m ⪠p) à (n ⪠q)" .. have "m ⪠p â domain(?h)" unfolding union_fun_def using domain_lam by simp with A B show ?thesis using Pi_iff [THEN iffD2] by simp qed lemma union_fun_action : assumes "env â list(M)" "env' â list(M)" "length(env) = m ⪠p" "â i . i â m â¶ nth(f`i,env') = nth(i,env)" "â j . j â p â¶ nth(g`j,env') = nth(j,env)" shows "â i . i â m ⪠p â¶ nth(i,env) = nth(union_fun(f,g,m,p)`i,env')" proof - let ?h = "union_fun(f,g,m,p)" have "nth(x, env) = nth(?h`x,env')" if "x â m ⪠p" for x using that proof (cases "xâm") case True with â¹xâm⺠have "?h`x = f`x" unfolding union_fun_def beta by simp with assms â¹xâm⺠have "nth(x,env) = nth(?h`x,env')" by simp then show ?thesis . next case False with â¹x â m ⪠p⺠have "x â p" "xâm" by auto then have "?h`x = g`x" unfolding union_fun_def beta by simp with assms â¹xâp⺠have "nth(x,env) = nth(?h`x,env')" by simp then show ?thesis . qed then show ?thesis by simp qed lemma id_fn_type : assumes "n â nat" shows "id(n) â n â n" unfolding id_def using â¹nânat⺠by simp lemma id_fn_action: assumes "n â nat" "envâlist(M)" shows "â j . j < n â¹ nth(j,env) = nth(id(n)`j,env)" proof - show "nth(j,env) = nth(id(n)`j,env)" if "j < n" for j using that â¹nânat⺠ltD by simp qed definition rsum :: "[i,i,i,i,i] â i" where "rsum(f,g,m,n,p) ⡠λj â m+â©Ïp . if j<m then f`j else (g`(j#-m))+â©Ïn" lemma sum_inl: assumes "m â nat" "nânat" "f â mân" "x â m" shows "rsum(f,g,m,n,p)`x = f`x" proof - from â¹mânat⺠have "mâ¤m+â©Ïp" using add_le_self[of m] by simp with assms have "xâm+â©Ïp" using ltI[of x m] lt_trans2[of x m "m+â©Ïp"] ltD by simp from assms have "x<m" using ltI by simp with â¹xâm+â©Ïp⺠show ?thesis unfolding rsum_def by simp qed lemma sum_inr: assumes "m â nat" "nânat" "pânat" "gâpâq" "m ⤠x" "x < m+â©Ïp" shows "rsum(f,g,m,n,p)`x = g`(x#-m)+â©Ïn" proof - from assms have "xânat" using in_n_in_nat[of "m+â©Ïp"] ltD by simp with assms have "¬ x<m" using not_lt_iff_le[THEN iffD2] by simp from assms have "xâm+â©Ïp" using ltD by simp with â¹Â¬ x<m⺠show ?thesis unfolding rsum_def by simp qed lemma sum_action : assumes "m â nat" "nânat" "pânat" "qânat" "f â mân" "gâpâq" "env â list(M)" "env' â list(M)" "env1 â list(M)" "env2 â list(M)" "length(env) = m" "length(env1) = p" "length(env') = n" "â i . i < m â¹ nth(i,env) = nth(f`i,env')" "â j. j < p â¹ nth(j,env1) = nth(g`j,env2)" shows "â i . i < m+â©Ïp â¶ nth(i,env@env1) = nth(rsum(f,g,m,n,p)`i,env'@env2)" proof - let ?h = "rsum(f,g,m,n,p)" from â¹mânat⺠â¹nânat⺠â¹qânat⺠have "mâ¤m+â©Ïp" "nâ¤n+â©Ïq" "qâ¤n+â©Ïq" using add_le_self[of m] add_le_self2[of n q] by simp_all from â¹pânat⺠have "p = (m+â©Ïp)#-m" using diff_add_inverse2 by simp have "nth(x, env @ env1) = nth(?h`x,env'@env2)" if "x<m+â©Ïp" for x proof (cases "x<m") case True then have 2: "?h`x= f`x" "xâm" "f`x â n" "xânat" using assms sum_inl ltD apply_type[of f m _ x] in_n_in_nat by simp_all with â¹x<m⺠assms have "f`x < n" "f`x<length(env')" "f`xânat" using ltI in_n_in_nat by simp_all with 2 â¹x<m⺠assms have "nth(x,env@env1) = nth(x,env)" using nth_append[OF â¹envâlist(M)âº] â¹xânat⺠by simp also have "... = nth(f`x,env')" using 2 â¹x<m⺠assms by simp also have "... = nth(f`x,env'@env2)" using nth_append[OF â¹env'âlist(M)âº] â¹f`x<length(env')⺠â¹f`x ânat⺠by simp also have "... = nth(?h`x,env'@env2)" using 2 by simp finally have "nth(x, env @ env1) = nth(?h`x,env'@env2)" . then show ?thesis . next case False have "xânat" using that in_n_in_nat[of "m+â©Ïp" x] ltD â¹pânat⺠â¹mânat⺠by simp with â¹length(env) = m⺠have "mâ¤x" "length(env) ⤠x" using not_lt_iff_le â¹mânat⺠â¹Â¬x<m⺠by simp_all with â¹Â¬x<m⺠â¹length(env) = m⺠have 2 : "?h`x= g`(x#-m)+â©Ïn" "¬ x <length(env)" unfolding rsum_def using sum_inr that beta ltD by simp_all from assms â¹xânat⺠â¹p=m+â©Ïp#-m⺠have "x#-m < p" using diff_mono[OF _ _ _ â¹x<m+â©Ïp⺠â¹mâ¤xâº] by simp then have "x#-mâp" using ltD by simp with â¹gâpâq⺠have "g`(x#-m) â q" by simp with â¹qânat⺠â¹length(env') = n⺠have "g`(x#-m) < q" "g`(x#-m)ânat" using ltI in_n_in_nat by simp_all with â¹qânat⺠â¹nânat⺠have "(g`(x#-m))+â©Ïn <n+â©Ïq" "n ⤠g`(x#-m)+â©Ïn" "¬ g`(x#-m)+â©Ïn < length(env')" using add_lt_mono1[of "g`(x#-m)" _ n,OF _ â¹qânatâº] add_le_self2[of n] â¹length(env') = n⺠by simp_all from assms â¹Â¬ x < length(env)⺠â¹length(env) = m⺠have "nth(x,env @ env1) = nth(x#-m,env1)" using nth_append[OF â¹envâlist(M)⺠â¹xânatâº] by simp also have "... = nth(g`(x#-m),env2)" using assms â¹x#-m < p⺠by simp also have "... = nth((g`(x#-m)+â©Ïn)#-length(env'),env2)" using â¹length(env') = n⺠diff_add_inverse2 â¹g`(x#-m)ânat⺠by simp also have "... = nth((g`(x#-m)+â©Ïn),env'@env2)" using nth_append[OF â¹env'âlist(M)âº] â¹nânat⺠â¹Â¬ g`(x#-m)+â©Ïn < length(env')⺠by simp also have "... = nth(?h`x,env'@env2)" using 2 by simp finally have "nth(x, env @ env1) = nth(?h`x,env'@env2)" . then show ?thesis . qed then show ?thesis by simp qed lemma sum_type : assumes "m â nat" "nânat" "pânat" "qânat" "f â mân" "gâpâq" shows "rsum(f,g,m,n,p) â (m+â©Ïp) â (n+â©Ïq)" proof - let ?h = "rsum(f,g,m,n,p)" from â¹mânat⺠â¹nânat⺠â¹qânat⺠have "mâ¤m+â©Ïp" "nâ¤n+â©Ïq" "qâ¤n+â©Ïq" using add_le_self[of m] add_le_self2[of n q] by simp_all from â¹pânat⺠have "p = (m+â©Ïp)#-m" using diff_add_inverse2 by simp {fix x assume 1: "xâm+â©Ïp" "x<m" with 1 have "?h`x= f`x" "xâm" using assms sum_inl ltD by simp_all with â¹fâmân⺠have "?h`x â n" by simp with â¹nânat⺠have "?h`x < n" using ltI by simp with â¹nâ¤n+â©Ïq⺠have "?h`x < n+â©Ïq" using lt_trans2 by simp then have "?h`x â n+â©Ïq" using ltD by simp } then have 1:"?h`x â n+â©Ïq" if "xâm+â©Ïp" "x<m" for x using that . {fix x assume 1: "xâm+â©Ïp" "mâ¤x" then have "x<m+â©Ïp" "xânat" using ltI in_n_in_nat[of "m+â©Ïp"] ltD by simp_all with 1 have 2 : "?h`x= g`(x#-m)+â©Ïn" using assms sum_inr ltD by simp_all from assms â¹xânat⺠â¹p=m+â©Ïp#-m⺠have "x#-m < p" using diff_mono[OF _ _ _ â¹x<m+â©Ïp⺠â¹mâ¤xâº] by simp then have "x#-mâp" using ltD by simp with â¹gâpâq⺠have "g`(x#-m) â q" by simp with â¹qânat⺠have "g`(x#-m) < q" using ltI by simp with â¹qânat⺠have "(g`(x#-m))+â©Ïn <n+â©Ïq" using add_lt_mono1[of "g`(x#-m)" _ n,OF _ â¹qânatâº] by simp with 2 have "?h`x â n+â©Ïq" using ltD by simp } then have 2:"?h`x â n+â©Ïq" if "xâm+â©Ïp" "mâ¤x" for x using that . have D: "?h`x â n+â©Ïq" if "xâm+â©Ïp" for x using that proof (cases "x<m") case True then show ?thesis using 1 that by simp next case False with â¹mânat⺠have "mâ¤x" using not_lt_iff_le that in_n_in_nat[of "m+â©Ïp"] by simp then show ?thesis using 2 that by simp qed have A:"function(?h)" unfolding rsum_def using function_lam by simp have " xâ (m +â©Ï p) à (n +â©Ï q)" if "xâ ?h" for x using that lamE[of x "m+â©Ïp" _ "x â (m +â©Ï p) à (n +â©Ï q)"] D unfolding rsum_def by auto then have B:"?h â (m +â©Ï p) à (n +â©Ï q)" .. have "m +â©Ï p â domain(?h)" unfolding rsum_def using domain_lam by simp with A B show ?thesis using Pi_iff [THEN iffD2] by simp qed lemma sum_type_id : assumes "f â length(env)âlength(env')" "env â list(M)" "env' â list(M)" "env1 â list(M)" shows "rsum(f,id(length(env1)),length(env),length(env'),length(env1)) â (length(env)+â©Ïlength(env1)) â (length(env')+â©Ïlength(env1))" using assms length_type id_fn_type sum_type by simp lemma sum_type_id_aux2 : assumes "f â mân" "m â nat" "n â nat" "env1 â list(M)" shows "rsum(f,id(length(env1)),m,n,length(env1)) â (m+â©Ïlength(env1)) â (n+â©Ïlength(env1))" using assms id_fn_type sum_type by auto lemma sum_action_id : assumes "env â list(M)" "env' â list(M)" "f â length(env)âlength(env')" "env1 â list(M)" "â i . i < length(env) â¹ nth(i,env) = nth(f`i,env')" shows "â i . i < length(env)+â©Ïlength(env1) â¹ nth(i,env@env1) = nth(rsum(f,id(length(env1)),length(env),length(env'),length(env1))`i,env'@env1)" proof - from assms have "length(env)ânat" (is "?m â _") by simp from assms have "length(env')ânat" (is "?n â _") by simp from assms have "length(env1)ânat" (is "?p â _") by simp note lenv = id_fn_action[OF â¹?pânat⺠â¹env1âlist(M)âº] note lenv_ty = id_fn_type[OF â¹?pânatâº] { fix i assume "i < length(env)+â©Ïlength(env1)" have "nth(i,env@env1) = nth(rsum(f,id(length(env1)),?m,?n,?p)`i,env'@env1)" using sum_action[OF â¹?mânat⺠â¹?nânat⺠â¹?pânat⺠â¹?pânat⺠â¹fâ?mâ?n⺠lenv_ty â¹envâlist(M)⺠â¹env'âlist(M)⺠â¹env1âlist(M)⺠â¹env1âlist(M)⺠_ _ _ assms(5) lenv ] â¹i<?m+â©Ïlength(env1)⺠by simp } then show "â i . i < ?m+â©Ïlength(env1) â¹ nth(i,env@env1) = nth(rsum(f,id(?p),?m,?n,?p)`i,env'@env1)" by simp qed lemma sum_action_id_aux : assumes "f â mân" "env â list(M)" "env' â list(M)" "env1 â list(M)" "length(env) = m" "length(env') = n" "length(env1) = p" "â i . i < m â¹ nth(i,env) = nth(f`i,env')" shows "â i . i < m+â©Ïlength(env1) â¹ nth(i,env@env1) = nth(rsum(f,id(length(env1)),m,n,length(env1))`i,env'@env1)" using assms length_type id_fn_type sum_action_id by auto definition sum_id :: "[i,i] â i" where "sum_id(m,f) â¡ rsum(λxâ1.x,f,1,1,m)" lemma sum_id0 : "mânatâ¹sum_id(m,f)`0 = 0" by(unfold sum_id_def,subst sum_inl,auto) lemma sum_idS : "pânat â¹ qânat â¹ fâpâq â¹ x â p â¹ sum_id(p,f)`(succ(x)) = succ(f`x)" by(subgoal_tac "xânat",unfold sum_id_def,subst sum_inr, simp_all add:ltI,simp_all add: app_nm in_n_in_nat) lemma sum_id_tc_aux : "p â nat â¹ q â nat â¹ f â p â q â¹ sum_id(p,f) â 1+â©Ïp â 1+â©Ïq" by (unfold sum_id_def,rule sum_type,simp_all) lemma sum_id_tc : "n â nat â¹ m â nat â¹ f â n â m â¹ sum_id(n,f) â succ(n) â succ(m)" by(rule ssubst[of "succ(n) â succ(m)" "1+â©Ïn â 1+â©Ïm"], simp,rule sum_id_tc_aux,simp_all) subsectionâ¹Renaming of formulas⺠consts ren :: "iâi" primrec "ren(Member(x,y)) = (λ n â nat . λ m â nat. λf â n â m. Member (f`x, f`y))" "ren(Equal(x,y)) = (λ n â nat . λ m â nat. λf â n â m. Equal (f`x, f`y))" "ren(Nand(p,q)) = (λ n â nat . λ m â nat. λf â n â m. Nand (ren(p)`n`m`f, ren(q)`n`m`f))" "ren(Forall(p)) = (λ n â nat . λ m â nat. λf â n â m. Forall (ren(p)`succ(n)`succ(m)`sum_id(n,f)))" lemma arity_meml : "l â nat â¹ Member(x,y) â formula â¹ arity(Member(x,y)) ⤠l â¹ x â l" by(simp,rule subsetD,rule le_imp_subset,assumption,simp) lemma arity_memr : "l â nat â¹ Member(x,y) â formula â¹ arity(Member(x,y)) ⤠l â¹ y â l" by(simp,rule subsetD,rule le_imp_subset,assumption,simp) lemma arity_eql : "l â nat â¹ Equal(x,y) â formula â¹ arity(Equal(x,y)) ⤠l â¹ x â l" by(simp,rule subsetD,rule le_imp_subset,assumption,simp) lemma arity_eqr : "l â nat â¹ Equal(x,y) â formula â¹ arity(Equal(x,y)) ⤠l â¹ y â l" by(simp,rule subsetD,rule le_imp_subset,assumption,simp) lemma nand_ar1 : "p â formula â¹ qâformula â¹arity(p) ⤠arity(Nand(p,q))" by (simp,rule Un_upper1_le,simp+) lemma nand_ar2 : "p â formula â¹ qâformula â¹arity(q) ⤠arity(Nand(p,q))" by (simp,rule Un_upper2_le,simp+) lemma nand_ar1D : "p â formula â¹ qâformula â¹ arity(Nand(p,q)) ⤠n â¹ arity(p) ⤠n" by(auto simp add: le_trans[OF Un_upper1_le[of "arity(p)" "arity(q)"]]) lemma nand_ar2D : "p â formula â¹ qâformula â¹ arity(Nand(p,q)) ⤠n â¹ arity(q) ⤠n" by(auto simp add: le_trans[OF Un_upper2_le[of "arity(p)" "arity(q)"]]) lemma ren_tc : "p â formula â¹ (â n m f . n â nat â¹ m â nat â¹ f â nâm â¹ ren(p)`n`m`f â formula)" by (induct set:formula,auto simp add: app_nm sum_id_tc) lemma arity_ren : fixes "p" assumes "p â formula" shows "â n m f . n â nat â¹ m â nat â¹ f â nâm â¹ arity(p) ⤠n â¹ arity(ren(p)`n`m`f)â¤m" using assms proof (induct set:formula) case (Member x y) then have "f`x â m" "f`y â m" using Member assms by (simp add: arity_meml apply_funtype,simp add:arity_memr apply_funtype) then show ?case using Member by (simp add: Un_least_lt ltI) next case (Equal x y) then have "f`x â m" "f`y â m" using Equal assms by (simp add: arity_eql apply_funtype,simp add:arity_eqr apply_funtype) then show ?case using Equal by (simp add: Un_least_lt ltI) next case (Nand p q) then have "arity(p)â¤arity(Nand(p,q))" "arity(q)â¤arity(Nand(p,q))" by (subst nand_ar1,simp,simp,simp,subst nand_ar2,simp+) then have "arity(p)â¤n" and "arity(q)â¤n" using Nand by (rule_tac j="arity(Nand(p,q))" in le_trans,simp,simp)+ then have "arity(ren(p)`n`m`f) ⤠m" and "arity(ren(q)`n`m`f) ⤠m" using Nand by auto then show ?case using Nand by (simp add:Un_least_lt) next case (Forall p) from Forall have "succ(n)ânat" "succ(m)ânat" by auto from Forall have 2: "sum_id(n,f) â succ(n)âsucc(m)" by (simp add:sum_id_tc) from Forall have 3:"arity(p) ⤠succ(n)" by (rule_tac n="arity(p)" in natE,simp+) then have "arity(ren(p)`succ(n)`succ(m)`sum_id(n,f))â¤succ(m)" using Forall â¹succ(n)ânat⺠â¹succ(m)ânat⺠2 by force then show ?case using Forall 2 3 ren_tc arity_type pred_le by auto qed lemma arity_forallE : "p â formula â¹ m â nat â¹ arity(Forall(p)) ⤠m â¹ arity(p) ⤠succ(m)" by(rule_tac n="arity(p)" in natE,erule arity_type,simp+) lemma env_coincidence_sum_id : assumes "m â nat" "n â nat" "Ï â list(A)" "Ï' â list(A)" "f â n â m" "â i . i < n â¹ nth(i,Ï) = nth(f`i,Ï')" "a â A" "j â succ(n)" shows "nth(j,Cons(a,Ï)) = nth(sum_id(n,f)`j,Cons(a,Ï'))" proof - let ?g="sum_id(n,f)" have "succ(n) â nat" using â¹nânat⺠by simp then have "j â nat" using â¹jâsucc(n)⺠in_n_in_nat by blast then have "nth(j,Cons(a,Ï)) = nth(?g`j,Cons(a,Ï'))" proof (cases rule:natE[OF â¹jânatâº]) case 1 then show ?thesis using assms sum_id0 by simp next case (2 i) with â¹jâsucc(n)⺠have "succ(i)âsucc(n)" by simp with â¹nânat⺠have "i â n" using nat_succD assms by simp have "f`iâm" using â¹fânâm⺠apply_type â¹iân⺠by simp then have "f`i â nat" using in_n_in_nat â¹mânat⺠by simp have "nth(succ(i),Cons(a,Ï)) = nth(i,Ï)" using â¹iânat⺠by simp also have "... = nth(f`i,Ï')" using assms â¹iân⺠ltI by simp also have "... = nth(succ(f`i),Cons(a,Ï'))" using â¹f`iânat⺠by simp also have "... = nth(?g`succ(i),Cons(a,Ï'))" using assms sum_idS[OF â¹nânat⺠â¹mânat⺠â¹fânâm⺠â¹i â nâº] cases by simp finally have "nth(succ(i),Cons(a,Ï)) = nth(?g`succ(i),Cons(a,Ï'))" . then show ?thesis using â¹j=succ(i)⺠by simp qed then show ?thesis . qed lemma sats_iff_sats_ren : assumes "Ï â formula" shows "⦠n â nat ; m â nat ; Ï â list(M) ; Ï' â list(M) ; f â n â m ; arity(Ï) ⤠n ; â i . i < n â¹ nth(i,Ï) = nth(f`i,Ï') â§ â¹ sats(M,Ï,Ï) â· sats(M,ren(Ï)`n`m`f,Ï')" using â¹Ï â formula⺠proof(induct Ï arbitrary:n m Ï Ï' f) case (Member x y) have "ren(Member(x,y))`n`m`f = Member(f`x,f`y)" using Member assms arity_type by force moreover have "x â n" using Member arity_meml by simp moreover have "y â n" using Member arity_memr by simp ultimately show ?case using Member ltI by simp next case (Equal x y) have "ren(Equal(x,y))`n`m`f = Equal(f`x,f`y)" using Equal assms arity_type by force moreover have "x â n" using Equal arity_eql by simp moreover have "y â n" using Equal arity_eqr by simp ultimately show ?case using Equal ltI by simp next case (Nand p q) have "ren(Nand(p,q))`n`m`f = Nand(ren(p)`n`m`f,ren(q)`n`m`f)" using Nand by simp moreover have "arity(p) ⤠n" using Nand nand_ar1D by simp moreover from this have "i â arity(p) â¹ i â n" for i using subsetD[OF le_imp_subset[OF â¹arity(p) ⤠nâº]] by simp moreover from this have "i â arity(p) â¹ nth(i,Ï) = nth(f`i,Ï')" for i using Nand ltI by simp moreover from this have "sats(M,p,Ï) â· sats(M,ren(p)`n`m`f,Ï')" using â¹arity(p)â¤n⺠Nand by simp have "arity(q) ⤠n" using Nand nand_ar2D by simp moreover from this have "i â arity(q) â¹ i â n" for i using subsetD[OF le_imp_subset[OF â¹arity(q) ⤠nâº]] by simp moreover from this have "i â arity(q) â¹ nth(i,Ï) = nth(f`i,Ï')" for i using Nand ltI by simp moreover from this have "sats(M,q,Ï) â· sats(M,ren(q)`n`m`f,Ï')" using assms â¹arity(q)â¤n⺠Nand by simp ultimately show ?case using Nand by simp next case (Forall p) have 0:"ren(Forall(p))`n`m`f = Forall(ren(p)`succ(n)`succ(m)`sum_id(n,f))" using Forall by simp have 1:"sum_id(n,f) â succ(n) â succ(m)" (is "?g â _") using sum_id_tc Forall by simp then have 2: "arity(p) ⤠succ(n)" using Forall le_trans[of _ "succ(pred(arity(p)))"] succpred_leI by simp have "succ(n)ânat" "succ(m)ânat" using Forall by auto then have A:"â j .j < succ(n) â¹ nth(j, Cons(a, Ï)) = nth(?g`j, Cons(a, Ï'))" if "aâM" for a using that env_coincidence_sum_id Forall ltD by force have "sats(M,p,Cons(a,Ï)) â· sats(M,ren(p)`succ(n)`succ(m)`?g,Cons(a,Ï'))" if "aâM" for a proof - have C:"Cons(a,Ï) â list(M)" "Cons(a,Ï')âlist(M)" using Forall that by auto have "sats(M,p,Cons(a,Ï)) â· sats(M,ren(p)`succ(n)`succ(m)`?g,Cons(a,Ï'))" using Forall(2)[OF â¹succ(n)ânat⺠â¹succ(m)ânat⺠C(1) C(2) 1 2 A[OF â¹aâMâº]] by simp then show ?thesis . qed then show ?case using Forall 0 1 2 by simp qed end
v class="head">
Theory Utils
theory Utils imports "ZF-Constructible.Formula" begin txtâ¹This theory encapsulates some ML utilities⺠ML_fileâ¹Utils.ml⺠end