abbreviation
LetBe :: "var ==> trm ==> trm ==> trm" (‹Let _ be _ in _› [100,100,100] 100) where "Let x be t1 in t2 ≡ trm.Let x t2 t1"
type_synonym
Ctxt = "(var×tyS) list"
text‹free type variables›
consts ftv :: "'a ==> tvar list"
overloading
ftv_prod ≡"ftv :: ('a × 'b) ==> tvar list"
ftv_tvar ≡"ftv :: tvar ==> tvar list"
ftv_var ≡"ftv :: var ==> tvar list"
ftv_list ≡"ftv :: 'a list ==> tvar list"
ftv_ty ≡"ftv :: ty ==> tvar list" begin
lemma ftv_tyS_eqvt[eqvt]: fixes pi::"tvar prm" and S::"tyS" shows"pi∙(ftv S) = ftv (pi∙S)" proof (nominal_induct S rule: tyS.strong_induct) case (Ty ty) thenshow ?case by (simp add: ftv_ty_eqvt) next case (ALL tvar tyS) thenshow ?case by (metis difference_eqvt_tvar ftv_ty.simps(1) ftv_tyS.simps(2) ftv_ty_eqvt ty.perm(3) tyS.perm(4)) qed
lemma ftv_Ctxt_eqvt[eqvt]: fixes pi::"tvar prm" and Γ::"Ctxt" shows"pi∙(ftv Γ) = ftv (pi∙Γ)" by (induct Γ) (auto simp add: eqvts)
lemma lookup_fresh: fixes X::"tvar" assumes a: "X♯θ" shows"lookup θ X = TVar X" using a by (induct θ)
(auto simp add: fresh_list_cons fresh_prod fresh_atm)
overloading
psubst_ty ≡"psubst :: Subst ==> ty ==> ty" begin
nominal_primrec
psubst_ty where "θ = lookup θ X"
| "θ🪙1 → T🪙2> = (θ🪙1>) → (θ🪙2>)" by (rule TrueI)+
end
lemma psubst_ty_eqvt[eqvt]: fixes pi::"tvar prm" and θ::"Subst" and T::"ty" shows"pi∙(θ) = (pi∙θ)<(pi∙T)>" by (induct T rule: ty.induct) (simp_all add: eqvts)
overloading
psubst_tyS ≡"psubst :: Subst ==> tyS ==> tyS" begin
lemma fresh_lookup: fixes X::"tvar" and θ::"Subst" and Y::"tvar" assumes asms: "X♯Y""X♯θ" shows"X♯(lookup θ Y)" using asms by (induct θ)
(auto simp add: fresh_list_cons fresh_prod fresh_atm)
lemma fresh_psubst_ty: fixes X::"tvar" and θ::"Subst" and T::"ty" assumes asms: "X♯θ""X♯T" shows"X♯θ" using asms by (nominal_induct T rule: ty.strong_induct)
(auto simp add: fresh_list_append fresh_list_cons fresh_prod fresh_lookup)
lemma fresh_psubst_tyS: fixes X::"tvar" and θ::"Subst" and S::"tyS" assumes asms: "X♯θ""X♯S" shows"X♯θ" using asms by (nominal_induct S avoiding: θ X rule: tyS.strong_induct)
(auto simp add: fresh_psubst_ty abs_fresh)
lemma fresh_psubst_Ctxt: fixes X::"tvar" and θ::"Subst" and Γ::"Ctxt" assumes asms: "X♯θ""X♯Γ" shows"X♯θ<Γ>" using asms by (induct Γ)
(auto simp add: fresh_psubst_tyS fresh_list_cons)
lemma subst_freshfact2_ty: fixes X::"tvar" and Y::"tvar" and T::"ty" assumes asms: "X♯S" shows"X♯T[X::=S]" using asms by (nominal_induct T rule: ty.strong_induct)
(auto simp add: fresh_atm)
text‹instance of a type scheme› inductive
inst :: "ty ==> tyS ==> bool"(‹_ ≺ _› [50,51] 50) where
I_Ty[intro]: "T ≺ (Ty T)"
| I_All[intro]: "[X♯T'; T ≺ S]==> T[X::=T'] ≺∀[X].S"
equivariance inst[tvar]
nominal_inductive inst by (simp_all add: abs_fresh subst_freshfact2_ty)
lemma subst_forget_ty: fixes T::"ty" and X::"tvar" assumes a: "X♯T" shows"T[X::=S] = T" using a by (nominal_induct T rule: ty.strong_induct)
(auto simp add: fresh_atm)
lemma psubst_ty_lemma: fixes θ::"Subst" and X::"tvar" and T'::"ty" and T::"ty" assumes a: "X♯θ" shows"θ = (θ)[X::=θ]" using a proof (nominal_induct T avoiding: θ X T' rule: ty.strong_induct) case (TVar tvar) thenshow ?case by (simp add: fresh_atm(1) fresh_lookup lookup_fresh subst_forget_ty) qed auto
lemma general_preserved: fixes θ::"Subst" assumes a: "T ≺ S" shows"θ≺ θ" using a proof (nominal_induct T S avoiding: θ rule: inst.strong_induct) case (I_Ty T) thenshow ?case by (simp add: inst.I_Ty) next case (I_All X T' T S) thenshow ?case by (simp add: fresh_psubst_ty inst.I_All psubst_ty_lemma) qed
text‹typing judgements› inductive
typing :: "Ctxt ==> trm ==> ty ==> bool" (‹ _ ⊨ _ : _ › [60,60,60] 60) where
T_VAR[intro]: "[valid Γ; (x,S)∈set Γ; T ≺ S]==> Γ ⊨ Var x : T"
| T_APP[intro]: "[Γ ⊨ t🪙1 : T🪙1→T🪙2; Γ ⊨ t🪙2 : T🪙1]==> Γ ⊨ App t🪙1 t🪙2 : T🪙2"
| T_LAM[intro]: "[x♯Γ;((x,Ty T🪙1)#Γ) ⊨ t : T🪙2]==> Γ ⊨ Lam [x].t : T🪙1→T🪙2"
| T_LET[intro]: "[x♯Γ; Γ ⊨ t🪙1 : T🪙1; ((x,close Γ T🪙1)#Γ) ⊨ t🪙2 : T🪙2; set (ftv T🪙1 - ftv Γ) ♯* T🪙2] ==> Γ ⊨ Let x be t🪙1 in t🪙2 : T🪙2"
equivariance typing[tvar]
lemma fresh_tvar_trm: fixes X::"tvar" and t::"trm" shows"X♯t" by (nominal_induct t rule: trm.strong_induct)
(simp_all add: fresh_atm abs_fresh)
lemma ftv_ty: fixes T::"ty" shows"supp T = set (ftv T)" by (nominal_induct T rule: ty.strong_induct)
(simp_all add: ty.supp supp_atm)
lemma ftv_tyS: fixes S::"tyS" shows"supp S = set (ftv S)" by (nominal_induct S rule: tyS.strong_induct)
(auto simp add: tyS.supp abs_supp ftv_ty)
lemma ftv_Ctxt: fixes Γ::"Ctxt" shows"supp Γ = set (ftv Γ)" proof (induct Γ) case Nil thenshow ?case by (simp add: supp_list_nil) next case (Cons c Γ) show ?case proof (cases c) case (Pair a b) with Cons show ?thesis by (simp add: ftv_tyS supp_atm(3) supp_list_cons supp_prod) qed qed
lemma ftv_tvars: fixes Tvs::"tvar list" shows"supp Tvs = set Tvs" by (induct Tvs) (simp_all add: supp_list_nil supp_list_cons supp_atm)
lemma perm_fresh_fresh_aux: "∀(x,y)∈set (pi::tvar prm). x ♯ z ∧ y ♯ z ==> pi ∙ (z::'a::pt_tvar) = z" proof (induct pi rule: rev_induct) case Nil thenshow ?case by simp next case (snoc x xs) thenshow ?case unfolding split_paired_all pt_tvar2 using perm_fresh_fresh(1) by fastforce qed
lemma freshs_mem: fixes S::"tvar set" assumes"x ∈ S" and"S ♯* z" shows"x ♯ z" using assms by (simp add: fresh_star_def)
lemma fresh_gen_set: fixes X::"tvar" and Xs::"tvar list" assumes"X∈set Xs" shows"X♯gen T Xs" using assms by (induct Xs) (auto simp: abs_fresh)
lemma gen_supp: shows"(supp (gen T Xs)::tvar set) = supp T - supp Xs" by (induct Xs)
(auto simp add: supp_list_nil supp_list_cons tyS.supp abs_supp supp_atm)
lemma minus_Int_eq: shows"T - (T - U) = T ∩ U" by blast
lemma close_supp: shows"supp (close Γ T) = set (ftv T) ∩ set (ftv Γ)" using difference_supp ftv_ty gen_supp set_supp_eq by auto
lemma better_T_LET: assumes x: "x♯Γ" and t1: "Γ ⊨ t🪙1 : T🪙1" and t2: "((x,close Γ T🪙1)#Γ) ⊨ t🪙2 : T🪙2" shows"Γ ⊨ Let x be t🪙1 in t🪙2 : T🪙2" proof - have fin: "finite (set (ftv T🪙1 - ftv Γ))"by simp obtain pi where pi1: "(pi ∙ set (ftv T🪙1 - ftv Γ)) ♯* (T🪙2, Γ)" and pi2: "set pi ⊆ set (ftv T🪙1 - ftv Γ) × (pi ∙ set (ftv T🪙1 - ftv Γ))" by (rule at_set_avoiding [OF at_tvar_inst fin fs_tvar1, of "(T🪙2, Γ)"]) from pi1 have pi1': "(pi ∙ set (ftv T🪙1 - ftv Γ)) ♯* Γ" by (simp add: fresh_star_prod) have Gamma_fresh: "∀(x,y)∈set pi. x ♯ Γ ∧ y ♯ Γ" using freshs_mem [OF _ pi1'] subsetD [OF pi2] ftv_Ctxt fresh_def by fastforce have"∧x y. [x ∈ set (ftv T🪙1 - ftv Γ); y ∈ pi ∙ set (ftv T🪙1 - ftv Γ)] ==> x ♯ close Γ T🪙1 ∧ y ♯ close Γ T🪙1" using pi1' fresh_def fresh_gen_set freshs_mem ftv_Ctxt ftv_ty gen_supp by (metis (lifting) DiffE mem_Collect_eq set_filter) thenhave close_fresh': "∀(x, y)∈set pi. x ♯ close Γ T🪙1 ∧ y ♯ close Γ T🪙1" using pi2 by auto note x moreoverfrom Gamma_fresh perm_boolI [OF t1, of pi] have"Γ ⊨ t🪙1 : pi ∙ T🪙1" by (simp add: perm_fresh_fresh_aux eqvts fresh_tvar_trm) moreoverfrom t2 close_fresh' have"(x,(pi ∙ close Γ T🪙1))#Γ ⊨ t🪙2 : T🪙2" by (simp add: perm_fresh_fresh_aux) with Gamma_fresh have"(x,close Γ (pi ∙ T🪙1))#Γ ⊨ t🪙2 : T🪙2" by (simp add: close_eqvt perm_fresh_fresh_aux) moreoverfrom pi1 Gamma_fresh have"set (ftv (pi ∙ T🪙1) - ftv Γ) ♯* T🪙2" by (simp only: eqvts fresh_star_prod perm_fresh_fresh_aux) ultimatelyshow ?thesis by (rule T_LET) qed
lemma ftv_ty_subst: fixes T::"ty" and θ::"Subst" and X Y ::"tvar" assumes"X ∈ set (ftv T)" and"Y ∈ set (ftv (lookup θ X))" shows"Y ∈ set (ftv (θ))" using assms by (nominal_induct T rule: ty.strong_induct) (auto)
lemma ftv_tyS_subst: fixes S::"tyS" and θ::"Subst" and X Y::"tvar" assumes"X ∈ set (ftv S)" and"Y ∈ set (ftv (lookup θ X))" shows"Y ∈ set (ftv (θ))" using assms by (nominal_induct S avoiding: θ Y rule: tyS.strong_induct)
(auto simp add: ftv_ty_subst fresh_atm)
lemma ftv_Ctxt_subst: fixes Γ::"Ctxt" and θ::"Subst" assumes"X ∈ set (ftv Γ)" and"Y ∈ set (ftv (lookup θ X))" shows"Y ∈ set (ftv (θ<Γ>))" using assms by (induct Γ) (auto simp add: ftv_tyS_subst)
lemma gen_preserved1: assumes"Xs ♯* θ" shows"θ = gen (θ) Xs" using assms by (induct Xs) (auto simp add: fresh_star_def)
lemma gen_preserved2: fixes T::"ty" and Γ::"Ctxt" assumes"((ftv T) - (ftv Γ)) ♯* θ" shows"((ftv (θ)) - (ftv (θ<Γ>))) = ((ftv T) - (ftv Γ))" using assms proof(nominal_induct T rule: ty.strong_induct) case (TVar tvar) thenshow ?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 case (Fun ty1 ty2) thenshow ?case by (simp add: fresh_star_list) qed
lemma close_preserved: fixes Γ::"Ctxt" assumes"((ftv T) - (ftv Γ)) ♯* θ" shows"θ = close (θ<Γ>) (θ)" using assms by (simp add: gen_preserved1 gen_preserved2)
lemma var_fresh_for_ty: fixes x::"var" and T::"ty" shows"x♯T" by (nominal_induct T rule: ty.strong_induct) (simp_all add: fresh_atm)
lemma var_fresh_for_tyS: fixes x::"var"and S::"tyS" shows"x♯S" by (nominal_induct S rule: tyS.strong_induct) (simp_all add: abs_fresh var_fresh_for_ty)
lemma psubst_valid: fixes θ::Subst and Γ::Ctxt assumes"valid Γ" shows"valid (θ<Γ>)" using assms by (induct) (auto simp add: psubst_fresh_Ctxt)
lemma psubst_in: fixes Γ::"Ctxt" and θ::"Subst" and pi::"tvar prm" and S::"tyS" assumes a: "(x,S)∈set Γ" shows"(x,θ)∈set (θ<Γ>)" using a by (induct Γ) (auto simp add: calc_atm)
lemma typing_preserved: fixes θ::"Subst" and pi::"tvar prm" assumes"Γ ⊨ t : T" shows"(θ<Γ>) ⊨ t : (θ)" using assms proof (nominal_induct Γ t T avoiding: θ rule: typing.strong_induct) case (T_VAR Γ x S T) have a1: "valid Γ"by fact have a2: "(x, S) ∈ set Γ"by fact have a3: "T ≺ S"by fact have"valid (θ<Γ>)"using a1 by (simp add: psubst_valid) moreover have"(x,θ)∈set (θ<Γ>)"using a2 by (simp add: psubst_in) moreover have"θ≺ θ"using a3 by (simp add: general_preserved) ultimatelyshow"(θ<Γ>) ⊨ Var x : (θ)"by (simp add: typing.T_VAR) next case (T_APP Γ t1 T1 T2 t2) have"θ<Γ> ⊨ t1 : θ→ T2>" by fact thenhave"θ<Γ> ⊨ t1 : (θ) → (θ)"by simp moreover have"θ<Γ> ⊨ t2 : θ"by fact ultimatelyshow"θ<Γ> ⊨ App t1 t2 : θ"by (simp add: typing.T_APP) next case (T_LAM x Γ T1 t T2) fix pi::"tvar prm"and θ::"Subst" have"x♯Γ"by fact thenhave"x♯θ<Γ>"by (simp add: psubst_fresh_Ctxt) moreover have"θ<((x, Ty T1)#Γ)> ⊨ t : θ"by fact thenhave"((x, Ty (θ))#(θ<Γ>)) ⊨ t : θ"by (simp add: calc_atm) ultimatelyshow"θ<Γ> ⊨ Lam [x].t : θ→ T2>" by (simp add: typing.T_LAM) next case (T_LET x Γ t1 T1 t2 T2) have vc: "((ftv T1) - (ftv Γ)) ♯* θ"by fact have"x♯Γ"by fact thenhave a1: "x♯θ<Γ>"by (simp add: calc_atm psubst_fresh_Ctxt) have a2: "θ<Γ> ⊨ t1 : θ"by fact have a3: "θ<((x, close Γ T1)#Γ)> ⊨ t2 : θ"by fact from a2 a3 show"θ<Γ> ⊨ Let x be t1 in t2 : θ" by (simp add: a1 better_T_LET close_preserved vc) qed
end
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.17 Sekunden
(vorverarbeitet am 2026-05-03)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.