# HG changeset patch # User paulson # Date 1713988586 -3600 # Node ID 40a3fc07a587949f07520c1a902762dd6cdc68da # Parent b156869b826a23e20e56d5b1a53cec4f45b42374 More tidying of proofs diff -r b156869b826a -r 40a3fc07a587 src/HOL/Nominal/Examples/Crary.thy --- a/src/HOL/Nominal/Examples/Crary.thy Wed Apr 24 09:21:44 2024 +0100 +++ b/src/HOL/Nominal/Examples/Crary.thy Wed Apr 24 20:56:26 2024 +0100 @@ -76,7 +76,7 @@ lemma lookup_eqvt[eqvt]: fixes pi::"name prm" shows "pi\(lookup \ x) = lookup (pi\\) (pi\x)" -by (induct \) (auto simp add: perm_bij) +by (induct \) (auto simp: perm_bij) lemma lookup_fresh: fixes z::"name" @@ -84,14 +84,14 @@ shows "z\ lookup \ x" using a by (induct rule: lookup.induct) - (auto simp add: fresh_list_cons) + (auto simp: fresh_list_cons) lemma lookup_fresh': assumes a: "z\\" shows "lookup \ z = Var z" using a by (induct rule: lookup.induct) - (auto simp add: fresh_list_cons fresh_prod fresh_atm) + (auto simp: fresh_list_cons fresh_prod fresh_atm) nominal_primrec psubst :: "Subst \ trm \ trm" ("_<_>" [100,100] 130) @@ -101,11 +101,7 @@ | "x\\ \ \<(Lam [x].t)> = Lam [x].(\)" | "\<(Const n)> = Const n" | "\<(Unit)> = Unit" -apply(finite_guess)+ -apply(rule TrueI)+ -apply(simp add: abs_fresh)+ -apply(fresh_guess)+ -done + by(finite_guess | simp add: abs_fresh | fresh_guess)+ abbreviation subst :: "trm \ name \ trm \ trm" ("_[_::=_]" [100,100,100] 100) @@ -131,9 +127,8 @@ assumes a: "c\t\<^sub>1" shows "t\<^sub>1[a::=t\<^sub>2] = ([(c,a)]\t\<^sub>1)[c::=t\<^sub>2]" using a -apply(nominal_induct t\<^sub>1 avoiding: a c t\<^sub>2 rule: trm.strong_induct) -apply(simp add: trm.inject calc_atm fresh_atm abs_fresh perm_nat_def)+ -done + by (nominal_induct t\<^sub>1 avoiding: a c t\<^sub>2 rule: trm.strong_induct) + (auto simp: trm.inject calc_atm fresh_atm abs_fresh perm_nat_def) lemma fresh_psubst: fixes z::"name" @@ -141,7 +136,7 @@ shows "z\(\)" using a by (nominal_induct t avoiding: z \ t rule: trm.strong_induct) - (auto simp add: abs_fresh lookup_fresh) + (auto simp: abs_fresh lookup_fresh) lemma fresh_subst'': fixes z::"name" @@ -149,7 +144,7 @@ shows "z\t\<^sub>1[z::=t\<^sub>2]" using assms by (nominal_induct t\<^sub>1 avoiding: t\<^sub>2 z rule: trm.strong_induct) - (auto simp add: abs_fresh fresh_nat fresh_atm) + (auto simp: abs_fresh fresh_nat fresh_atm) lemma fresh_subst': fixes z::"name" @@ -157,14 +152,14 @@ shows "z\t\<^sub>1[y::=t\<^sub>2]" using assms by (nominal_induct t\<^sub>1 avoiding: y t\<^sub>2 z rule: trm.strong_induct) - (auto simp add: abs_fresh fresh_nat fresh_atm) + (auto simp: abs_fresh fresh_nat fresh_atm) lemma fresh_subst: fixes z::"name" assumes a: "z\t\<^sub>1" "z\t\<^sub>2" shows "z\t\<^sub>1[y::=t\<^sub>2]" using a -by (auto simp add: fresh_subst' abs_fresh) +by (auto simp: fresh_subst' abs_fresh) lemma fresh_psubst_simp: assumes "x\t" @@ -181,7 +176,7 @@ by (simp add: fresh_list_cons fresh_prod) moreover have " \ = Lam [y]. (\)" using fs by simp ultimately show "((x,u)#\) = \" by auto -qed (auto simp add: fresh_atm abs_fresh) +qed (auto simp: fresh_atm abs_fresh) lemma forget: fixes x::"name" @@ -189,7 +184,7 @@ shows "t[x::=t'] = t" using a by (nominal_induct t avoiding: x t' rule: trm.strong_induct) - (auto simp add: fresh_atm abs_fresh) + (auto simp: fresh_atm abs_fresh) lemma subst_fun_eq: fixes u::trm @@ -212,20 +207,20 @@ lemma psubst_empty[simp]: shows "[] = t" by (nominal_induct t rule: trm.strong_induct) - (auto simp add: fresh_list_nil) + (auto simp: fresh_list_nil) lemma psubst_subst_psubst: assumes h:"c\\" shows "\[c::=s] = ((c,s)#\)" using h by (nominal_induct t avoiding: \ c s rule: trm.strong_induct) - (auto simp add: fresh_list_cons fresh_atm forget lookup_fresh lookup_fresh' fresh_psubst) + (auto simp: fresh_list_cons fresh_atm forget lookup_fresh lookup_fresh' fresh_psubst) lemma subst_fresh_simp: assumes a: "x\\" shows "\ = Var x" using a -by (induct \ arbitrary: x) (auto simp add:fresh_list_cons fresh_prod fresh_atm) +by (induct \ arbitrary: x) (auto simp:fresh_list_cons fresh_prod fresh_atm) lemma psubst_subst_propagate: assumes "x\\" @@ -239,7 +234,7 @@ } moreover { assume h:"x\n" - then have "x\Var n" by (auto simp add: fresh_atm) + then have "x\Var n" by (auto simp: fresh_atm) moreover have "x\\" by fact ultimately have "x\\" using fresh_psubst by blast then have " \[x::=\] = \" using forget by auto @@ -291,7 +286,7 @@ shows "\(\\::ty. (a,\)\set \)" using assms by (induct \) - (auto simp add: fresh_prod fresh_list_cons fresh_atm) + (auto simp: fresh_prod fresh_list_cons fresh_atm) lemma type_unicity_in_context: assumes a: "valid \" @@ -415,15 +410,7 @@ and b: "x \ b" shows "a=b" using a b -apply (induct arbitrary: b) -apply (erule whr_inv_auto(3)) -apply (clarify) -apply (rule subst_fun_eq) -apply (simp) -apply (force) -apply (erule whr_inv_auto(6)) -apply (blast)+ -done +by (induct arbitrary: b) (use subst_fun_eq in blast)+ lemma nf_unicity : assumes "x \ a" and "x \ b" @@ -433,8 +420,7 @@ case (QAN_Reduce x t a b) have h:"x \ t" "t \ a" by fact+ have ih:"\b. t \ b \ a = b" by fact - have "x \ b" by fact - then obtain t' where "x \ t'" and hl:"t' \ b" using h by auto + obtain t' where "x \ t'" and hl:"t' \ b" using h \x \ b\ by auto then have "t=t'" using h red_unicity by auto then show "a=b" using ih hl by auto qed (auto) @@ -535,7 +521,7 @@ shows "\ \ s \ t : T \ \ \ t \ s : T" and "\ \ s \ t : T \ \ \ t \ s : T" by (induct rule: alg_equiv_alg_path_equiv.inducts) - (auto simp add: fresh_prod) + (auto simp: fresh_prod) lemma algorithmic_transitivity: shows "\ \ s \ t : T \ \ \ t \ u : T \ \ \ s \ u : T" @@ -560,7 +546,7 @@ then have "(x,T\<^sub>1)#\ \ App t (Var x) \ App u (Var x) : T\<^sub>2" using fs by (simp add: Q_Arrow_strong_inversion) with ih have "(x,T\<^sub>1)#\ \ App s (Var x) \ App u (Var x) : T\<^sub>2" by simp - then show "\ \ s \ u : T\<^sub>1\T\<^sub>2" using fs by (auto simp add: fresh_prod) + then show "\ \ s \ u : T\<^sub>1\T\<^sub>2" using fs by (auto simp: fresh_prod) next case (QAP_App \ p q T\<^sub>1 T\<^sub>2 s t u) have "\ \ App q t \ u : T\<^sub>2" by fact @@ -578,10 +564,9 @@ lemma algorithmic_weak_head_closure: shows "\ \ s \ t : T \ s' \ s \ t' \ t \ \ \ s' \ t' : T" -apply (nominal_induct \ s t T avoiding: s' t' - rule: alg_equiv_alg_path_equiv.strong_inducts(1) [of _ _ _ _ "%a b c d e. True"]) -apply(auto intro!: QAT_Arrow) -done +proof (nominal_induct \ s t T avoiding: s' t' + rule: alg_equiv_alg_path_equiv.strong_inducts(1) [of _ _ _ _ "\a b c d e. True"]) +qed(auto intro!: QAT_Arrow) lemma algorithmic_monotonicity: shows "\ \ s \ t : T \ \ \ \' \ valid \' \ \' \ s \ t : T" @@ -596,7 +581,7 @@ moreover have sub: "(x,T\<^sub>1)#\ \ (x,T\<^sub>1)#\'" using h2 by auto ultimately have "(x,T\<^sub>1)#\' \ App s (Var x) \ App t (Var x) : T\<^sub>2" using ih by simp - then show "\' \ s \ t : T\<^sub>1\T\<^sub>2" using fs by (auto simp add: fresh_prod) + then show "\' \ s \ t : T\<^sub>1\T\<^sub>2" using fs by (auto simp: fresh_prod) qed (auto) lemma path_equiv_implies_nf: @@ -613,11 +598,7 @@ | "\ \ s is t : TBase = \ \ s \ t : TBase" | "\ \ s is t : (T\<^sub>1 \ T\<^sub>2) = (\\' s' t'. \\\' \ valid \' \ \' \ s' is t' : T\<^sub>1 \ (\' \ (App s s') is (App t t') : T\<^sub>2))" -apply (auto simp add: ty.inject) -apply (subgoal_tac "(\T\<^sub>1 T\<^sub>2. b=T\<^sub>1 \ T\<^sub>2) \ b=TUnit \ b=TBase" ) -apply (force) -apply (rule ty_cases) -done +using ty_cases by (force simp: ty.inject)+ termination by lexicographic_order @@ -656,7 +637,7 @@ then have "(x,T\<^sub>1)#\ \ Var x is Var x : T\<^sub>1" using ih2 by auto then have "(x,T\<^sub>1)#\ \ App s (Var x) is App t (Var x) : T\<^sub>2" using h v by auto then have "(x,T\<^sub>1)#\ \ App s (Var x) \ App t (Var x) : T\<^sub>2" using ih1 v by auto - then show "\ \ s \ t : T\<^sub>1\T\<^sub>2" using fs by (auto simp add: fresh_prod) + then show "\ \ s \ t : T\<^sub>1\T\<^sub>2" using fs by (auto simp: fresh_prod) next case (2 \ p q) have h: "\ \ p \ q : T\<^sub>1\T\<^sub>2" by fact @@ -693,7 +674,7 @@ shows "\ \ t is s : T" using a by (nominal_induct arbitrary: \ s t rule: ty.strong_induct) - (auto simp add: algorithmic_symmetry) + (auto simp: algorithmic_symmetry) lemma logical_transitivity: assumes "\ \ s is t : T" "\ \ t is u : T" @@ -726,8 +707,13 @@ and c: "t' \ t" shows "\ \ s' is t' : T" using a b c algorithmic_weak_head_closure -by (nominal_induct arbitrary: \ s t s' t' rule: ty.strong_induct) - (auto, blast) +proof (nominal_induct arbitrary: \ s t s' t' rule: ty.strong_induct) +next + case (Arrow ty1 ty2) + then show ?case + by (smt (verit, ccfv_threshold) QAR_App log_equiv.simps(3)) +qed auto + lemma logical_weak_head_closure': assumes "\ \ s is t : T" and "s' \ s" @@ -764,11 +750,8 @@ lemma logical_pseudo_reflexivity: assumes "\' \ t is s over \" - shows "\' \ s is s over \" -proof - - from assms have "\' \ s is t over \" using logical_symmetry by blast - with assms show "\' \ s is s over \" using logical_transitivity by blast -qed + shows "\' \ s is s over \" + by (meson assms logical_symmetry logical_transitivity) lemma logical_subst_monotonicity : fixes \ \' \'' :: Ctxt @@ -796,8 +779,8 @@ moreover { assume hl:"(y,U) \ set \" - then have "\ y\\" by (induct \) (auto simp add: fresh_list_cons fresh_atm fresh_prod) - then have hf:"x\ Var y" using fs by (auto simp add: fresh_atm) + then have "\ y\\" by (induct \) (auto simp: fresh_list_cons fresh_atm fresh_prod) + then have hf:"x\ Var y" using fs by (auto simp: fresh_atm) then have "((x,s)#\) = \" "((x,t)#\') = \'" using fresh_psubst_simp by blast+ moreover have "\' \ \ is \' : U" using h1 hl by auto @@ -847,18 +830,11 @@ using h1 h2 h3 proof (nominal_induct \ s t T avoiding: \' \ \' rule: def_equiv.strong_induct) case (Q_Refl \ t T \' \ \') - have "\ \ t : T" - and "valid \'" by fact+ - moreover - have "\' \ \ is \' over \" by fact - ultimately show "\' \ \ is \' : T" using fundamental_theorem_1 by blast + then show "\' \ \ is \' : T" using fundamental_theorem_1 + by blast next case (Q_Symm \ t s T \' \ \') - have "\' \ \ is \' over \" - and "valid \'" by fact+ - moreover - have ih: "\ \' \ \'. \\' \ \ is \' over \; valid \'\ \ \' \ \ is \' : T" by fact - ultimately show "\' \ \ is \' : T" using logical_symmetry by blast + then show "\' \ \ is \' : T" using logical_symmetry by blast next case (Q_Trans \ s t T u \' \ \') have ih1: "\ \' \ \'. \\' \ \ is \' over \; valid \'\ \ \' \ \ is \' : T" by fact @@ -943,13 +919,8 @@ shows "\ \ s \ t : T" proof - have val: "valid \" using def_equiv_implies_valid asm by simp - moreover - { - fix x T - assume "(x,T) \ set \" "valid \" - then have "\ \ Var x is Var x : T" using main_lemma(2) by blast - } - ultimately have "\ \ [] is [] over \" by auto + then have "\ \ [] is [] over \" + by (simp add: QAP_Var main_lemma(2)) then have "\ \ [] is [] : T" using fundamental_theorem_2 val asm by blast then have "\ \ s is t : T" by simp then show "\ \ s \ t : T" using main_lemma(1) val by simp diff -r b156869b826a -r 40a3fc07a587 src/HOL/Nominal/Examples/Fsub.thy --- a/src/HOL/Nominal/Examples/Fsub.thy Wed Apr 24 09:21:44 2024 +0100 +++ b/src/HOL/Nominal/Examples/Fsub.thy Wed Apr 24 20:56:26 2024 +0100 @@ -492,11 +492,7 @@ | "(t \\<^sub>\ T)[y \ t'] = t[y \ t'] \\<^sub>\ T" | "X\(T,t') \ (\X<:T. t)[y \ t'] = (\X<:T. t[y \ t'])" | "x\(y,t') \ (\x:T. t)[y \ t'] = (\x:T. t[y \ t'])" -apply(finite_guess)+ -apply(rule TrueI)+ -apply(simp add: abs_fresh)+ -apply(fresh_guess add: ty_vrs_fresh abs_fresh)+ -done + by (finite_guess | simp add: abs_fresh | fresh_guess add: ty_vrs_fresh abs_fresh)+ lemma subst_trm_fresh_tyvar: fixes X::"tyvrs" diff -r b156869b826a -r 40a3fc07a587 src/HOL/Nominal/Examples/Lam_Funs.thy --- a/src/HOL/Nominal/Examples/Lam_Funs.thy Wed Apr 24 09:21:44 2024 +0100 +++ b/src/HOL/Nominal/Examples/Lam_Funs.thy Wed Apr 24 20:56:26 2024 +0100 @@ -22,11 +22,7 @@ "depth (Var x) = 1" | "depth (App t1 t2) = (max (depth t1) (depth t2)) + 1" | "depth (Lam [a].t) = (depth t) + 1" - apply(finite_guess)+ - apply(rule TrueI)+ - apply(simp add: fresh_nat) - apply(fresh_guess)+ - done + by(finite_guess | simp | fresh_guess)+ text \ The free variables of a lambda-term. A complication in this @@ -41,12 +37,8 @@ "frees (Var a) = {a}" | "frees (App t1 t2) = (frees t1) \ (frees t2)" | "frees (Lam [a].t) = (frees t) - {a}" -apply(finite_guess)+ -apply(simp)+ -apply(simp add: fresh_def) -apply(simp add: supp_of_fin_sets[OF pt_name_inst, OF at_name_inst, OF fs_at_inst[OF at_name_inst]]) -apply(simp add: supp_atm) -apply(blast) +apply(finite_guess | simp add: fresh_def | fresh_guess)+ + apply (simp add: at_fin_set_supp at_name_inst) apply(fresh_guess)+ done @@ -81,11 +73,7 @@ "\<(Var x)> = (lookup \ x)" | "\<(App e\<^sub>1 e\<^sub>2)> = App (\1>) (\2>)" | "x\\ \ \<(Lam [x].e)> = Lam [x].(\)" -apply(finite_guess)+ -apply(rule TrueI)+ -apply(simp add: abs_fresh)+ -apply(fresh_guess)+ -done + by (finite_guess | simp add: abs_fresh | fresh_guess)+ lemma psubst_eqvt[eqvt]: fixes pi::"name prm" @@ -107,10 +95,19 @@ lemma subst_supp: shows "supp(t1[a::=t2]) \ (((supp(t1)-{a})\supp(t2))::name set)" -apply(nominal_induct t1 avoiding: a t2 rule: lam.strong_induct) -apply(auto simp add: lam.supp supp_atm fresh_prod abs_supp) -apply(blast)+ -done +proof (nominal_induct t1 avoiding: a t2 rule: lam.strong_induct) + case (Var name) + then show ?case + by (simp add: lam.supp(1) supp_atm) +next + case (App lam1 lam2) + then show ?case + using lam.supp(2) by fastforce +next + case (Lam name lam) + then show ?case + using frees.simps(3) frees_equals_support by auto +qed text \ Contexts - lambda-terms with a single hole. diff -r b156869b826a -r 40a3fc07a587 src/HOL/Nominal/Examples/W.thy --- a/src/HOL/Nominal/Examples/W.thy Wed Apr 24 09:21:44 2024 +0100 +++ b/src/HOL/Nominal/Examples/W.thy Wed Apr 24 20:56:26 2024 +0100 @@ -426,7 +426,7 @@ next case (snoc x xs) then show ?case - apply (simp add: split_paired_all pt_tvar2) + unfolding split_paired_all pt_tvar2 using perm_fresh_fresh(1) by fastforce qed @@ -538,7 +538,7 @@ using assms proof(nominal_induct T rule: ty.strong_induct) case (TVar tvar) - then show ?case + then show ?case apply(auto simp add: fresh_star_def ftv_Ctxt_subst) by (metis filter.simps fresh_def fresh_psubst_Ctxt ftv_Ctxt ftv_ty.simps(1) lookup_fresh) next