Theory Sigma
section ‹Locally Nameless representation of basic Sigma calculus enriched with formal parameter›
theory Sigma
imports "../preliminary/FMap"
begin
subsection ‹Infrastructure for the finite maps›
axiomatization max_label :: nat where
LabelAvail: "max_label > 10"
definition "Label = {n :: nat. n ≤ max_label}"
typedef Label = Label
unfolding Label_def by auto
lemmas finite_Label_set = Finite_Set.finite_Collect_le_nat[of max_label]
lemma Univ_abs_label:
"(UNIV :: (Label set)) = Abs_Label ` {n :: nat. n ≤ max_label}"
proof -
have "∀x :: Label. x : Abs_Label ` {n :: nat. n ≤ max_label}"
proof
fix x :: Label
have "Rep_Label x ∈ {n. n ≤ max_label}"
by (fold Label_def, rule Rep_Label)
hence "Abs_Label (Rep_Label x) ∈ Abs_Label ` {n. n ≤ max_label}"
by (rule imageI)
thus "x ∈ Abs_Label ` {n. n ≤ max_label}"
by (simp add: Rep_Label_inverse)
qed
thus ?thesis by force
qed
lemma finite_Label: "finite (UNIV :: (Label set))"
by (simp add: Univ_abs_label finite_Label_set)
instance Label :: finite
proof
show "finite (UNIV :: (Label set))" by (rule finite_Label)
qed
consts
Lsuc :: "(Label set) ⇒ Label ⇒ Label"
Lmin :: "(Label set) ⇒ Label"
Lmax :: "(Label set) ⇒ Label"
definition Llt :: "[Label, Label] ⇒ bool" (infixl ‹<› 50) where
"Llt a b == Rep_Label a < Rep_Label b"
definition Lle :: "[Label, Label] ⇒ bool" (infixl ‹≤› 50) where
"Lle a b == Rep_Label a ≤ Rep_Label b"
definition Ltake_eq :: "[Label set, (Label ⇀ 'a), (Label ⇀ 'a)] ⇒ bool"
where "Ltake_eq L f g == ∀l∈L. f l = g l"
lemma Ltake_eq_all:
fixes f g
assumes "dom f = dom g" and "Ltake_eq (dom f) f g"
shows "f = g"
proof
fix x from assms show "f x = g x"
unfolding Ltake_eq_def
by (cases "x ∈ dom f", auto)
qed
lemma Ltake_eq_dom:
fixes L :: "Label set" and f :: "Label -~> 'a"
assumes "L ⊆ dom f" and "card L = card (dom f)"
shows "L = (dom f)"
proof (auto)
fix x :: Label assume "x ∈ L"
with in_mono[OF assms(1)] show "∃y. f x = Some y" by blast
next
fix x y assume "f x = Some y"
from card_seteq[OF finite_dom_fmap[of f] ‹L ⊆ dom f›] ‹card L = card (dom f)›
have "L = dom f" by simp
with ‹f x = Some y› show "x ∈ L" by force
qed
subsection ‹Object-terms in Locally Nameless representation notation, beta-reduction and substitution›