--- a/Quot/Examples/LamEx.thy Fri Jan 01 11:30:00 2010 +0100
+++ b/Quot/Examples/LamEx.thy Fri Jan 01 23:59:32 2010 +0100
@@ -4,33 +4,44 @@
atom_decl name
-thm abs_fresh(1)
-
-nominal_datatype rlam =
+datatype rlam =
rVar "name"
| rApp "rlam" "rlam"
| rLam "name" "rlam"
-print_theorems
-
-function
+fun
rfv :: "rlam \<Rightarrow> name set"
where
rfv_var: "rfv (rVar a) = {a}"
| rfv_app: "rfv (rApp t1 t2) = (rfv t1) \<union> (rfv t2)"
| rfv_lam: "rfv (rLam a t) = (rfv t) - {a}"
-sorry
+
+overloading
+ perm_rlam \<equiv> "perm :: 'x prm \<Rightarrow> rlam \<Rightarrow> rlam" (unchecked)
+begin
-termination rfv sorry
+fun
+ perm_rlam
+where
+ "perm_rlam pi (rVar a) = rVar (pi \<bullet> a)"
+| "perm_rlam pi (rApp t1 t2) = rApp (perm_rlam pi t1) (perm_rlam pi t2)"
+| "perm_rlam pi (rLam a t) = rLam (pi \<bullet> a) (perm_rlam pi t)"
+
+end
inductive
alpha :: "rlam \<Rightarrow> rlam \<Rightarrow> bool" ("_ \<approx> _" [100, 100] 100)
where
a1: "a = b \<Longrightarrow> (rVar a) \<approx> (rVar b)"
| a2: "\<lbrakk>t1 \<approx> t2; s1 \<approx> s2\<rbrakk> \<Longrightarrow> rApp t1 s1 \<approx> rApp t2 s2"
-| a3: "\<lbrakk>t \<approx> ([(a,b)]\<bullet>s); a \<notin> rfv (rLam b t)\<rbrakk> \<Longrightarrow> rLam a t \<approx> rLam b s"
+| a3: "\<lbrakk>t \<approx> ([(a,b)] \<bullet> s); a \<notin> rfv (rLam b t)\<rbrakk> \<Longrightarrow> rLam a t \<approx> rLam b s"
-print_theorems
+lemma helper:
+ fixes t::"rlam"
+ and a::"name"
+ shows "[(a, a)] \<bullet> t = t"
+by (induct t)
+ (auto simp add: calc_atm)
lemma alpha_refl:
fixes t::"rlam"
@@ -39,10 +50,7 @@
apply(simp add: a1)
apply(simp add: a2)
apply(rule a3)
- apply(subst pt_swap_bij'')
- apply(rule pt_name_inst)
- apply(rule at_name_inst)
- apply(simp)
+ apply(simp add: helper)
apply(simp)
done
@@ -51,10 +59,8 @@
sorry
quotient_type lam = rlam / alpha
- apply(rule alpha_equivp)
- done
+ by (rule alpha_equivp)
-print_quotients
quotient_definition
"Var :: name \<Rightarrow> lam"
@@ -71,15 +77,14 @@
as
"rLam"
-thm Var_def
-thm App_def
-thm Lam_def
-
quotient_definition
"fv :: lam \<Rightarrow> name set"
as
"rfv"
+thm Var_def
+thm App_def
+thm Lam_def
thm fv_def
(* definition of overloaded permutation function *)
@@ -97,22 +102,36 @@
thm perm_lam_def
-(* lemmas that need to lift *)
-lemma pi_var_com:
+(* lemmas that need to be lifted *)
+lemma pi_var_eqvt1:
fixes pi::"'x prm"
- shows "(pi\<bullet>rVar a) \<approx> rVar (pi\<bullet>a)"
- sorry
+ shows "(pi \<bullet> rVar a) \<approx> rVar (pi \<bullet> a)"
+ by (simp add: alpha_refl)
-lemma pi_app_com:
+lemma pi_var_eqvt2:
+ fixes pi::"'x prm"
+ shows "(pi \<bullet> rVar a) = rVar (pi \<bullet> a)"
+ by (simp)
+
+lemma pi_app_eqvt1:
fixes pi::"'x prm"
- shows "(pi\<bullet>rApp t1 t2) \<approx> rApp (pi\<bullet>t1) (pi\<bullet>t2)"
- sorry
+ shows "(pi \<bullet> rApp t1 t2) \<approx> rApp (pi \<bullet> t1) (pi \<bullet> t2)"
+ by (simp add: alpha_refl)
+
+lemma pi_app_eqvt2:
+ fixes pi::"'x prm"
+ shows "(pi \<bullet> rApp t1 t2) = rApp (pi \<bullet> t1) (pi \<bullet> t2)"
+ by (simp)
-lemma pi_lam_com:
+lemma pi_lam_eqvt1:
fixes pi::"'x prm"
- shows "(pi\<bullet>rLam a t) \<approx> rLam (pi\<bullet>a) (pi\<bullet>t)"
- sorry
+ shows "(pi \<bullet> rLam a t) \<approx> rLam (pi \<bullet> a) (pi \<bullet> t)"
+ by (simp add: alpha_refl)
+lemma pi_lam_eqvt2:
+ fixes pi::"'x prm"
+ shows "(pi \<bullet> rLam a t) = rLam (pi \<bullet> a) (pi \<bullet> t)"
+ by (simp add: alpha)
lemma real_alpha:
@@ -136,25 +155,20 @@
lemma rVar_rsp[quot_respect]:
"(op = ===> alpha) rVar rVar"
-by (auto intro:a1)
+by (auto intro: a1)
lemma rApp_rsp[quot_respect]: "(alpha ===> alpha ===> alpha) rApp rApp"
-by (auto intro:a2)
+by (auto intro: a2)
lemma rLam_rsp[quot_respect]: "(op = ===> alpha ===> alpha) rLam rLam"
apply(auto)
apply(rule a3)
- apply(rule_tac t="[(x,x)]\<bullet>y" and s="y" in subst)
- apply(rule sym)
- apply(rule trans)
- apply(rule pt_name3)
- apply(rule at_ds1[OF at_name_inst])
- apply(simp add: pt_name1)
- apply(assumption)
- apply(simp add: abs_fresh)
+ apply(simp add: helper)
+ apply(simp)
done
-lemma rfv_rsp[quot_respect]: "(alpha ===> op =) rfv rfv"
+lemma rfv_rsp[quot_respect]:
+ "(alpha ===> op =) rfv rfv"
sorry
lemma rvar_inject: "rVar a \<approx> rVar b = (a = b)"
@@ -164,76 +178,86 @@
done
-lemma pi_var: "(pi\<Colon>('x \<times> 'x) list) \<bullet> Var a = Var (pi \<bullet> a)"
-apply (lifting pi_var_com)
-done
+lemma pi_var1:
+ fixes pi::"'x prm"
+ shows "pi \<bullet> Var a = Var (pi \<bullet> a)"
+ by (lifting pi_var_eqvt1)
-lemma pi_app: "(pi\<Colon>('x \<times> 'x) list) \<bullet> App (x\<Colon>lam) (xa\<Colon>lam) = App (pi \<bullet> x) (pi \<bullet> xa)"
-apply (lifting pi_app_com)
-done
+lemma pi_var2:
+ fixes pi::"'x prm"
+ shows "pi \<bullet> Var a = Var (pi \<bullet> a)"
+ by (lifting pi_var_eqvt2)
+
-lemma pi_lam: "(pi\<Colon>('x \<times> 'x) list) \<bullet> Lam (a\<Colon>name) (x\<Colon>lam) = Lam (pi \<bullet> a) (pi \<bullet> x)"
-apply (lifting pi_lam_com)
-done
+lemma pi_app:
+ fixes pi::"'x prm"
+ shows "pi \<bullet> App t1 t2 = App (pi \<bullet> t1) (pi \<bullet> t2)"
+ by (lifting pi_app_eqvt2)
-lemma fv_var: "fv (Var (a\<Colon>name)) = {a}"
-apply (lifting rfv_var)
-done
+lemma pi_lam:
+ fixes pi::"'x prm"
+ shows "pi \<bullet> Lam a t = Lam (pi \<bullet> a) (pi \<bullet> t)"
+ by (lifting pi_lam_eqvt2)
-lemma fv_app: "fv (App (x\<Colon>lam) (xa\<Colon>lam)) = fv x \<union> fv xa"
-apply (lifting rfv_app)
-done
+lemma fv_var:
+ shows "fv (Var a) = {a}"
+ by (lifting rfv_var)
-lemma fv_lam: "fv (Lam (a\<Colon>name) (x\<Colon>lam)) = fv x - {a}"
-apply (lifting rfv_lam)
-done
+lemma fv_app:
+ shows "fv (App t1 t2) = fv t1 \<union> fv t2"
+ by (lifting rfv_app)
+
+lemma fv_lam:
+ shows "fv (Lam a t) = fv t - {a}"
+ by (lifting rfv_lam)
-lemma a1: "(a\<Colon>name) = (b\<Colon>name) \<Longrightarrow> Var a = Var b"
-apply (lifting a1)
-done
+lemma a1:
+ "a = b \<Longrightarrow> Var a = Var b"
+ by (lifting a1)
-lemma a2: "\<lbrakk>(x\<Colon>lam) = (xa\<Colon>lam); (xb\<Colon>lam) = (xc\<Colon>lam)\<rbrakk> \<Longrightarrow> App x xb = App xa xc"
-apply (lifting a2)
-done
+lemma a2:
+ "\<lbrakk>x = xa; xb = xc\<rbrakk> \<Longrightarrow> App x xb = App xa xc"
+ by (lifting a2)
-lemma a3: "\<lbrakk>(x\<Colon>lam) = [(a\<Colon>name, b\<Colon>name)] \<bullet> (xa\<Colon>lam); a \<notin> fv (Lam b x)\<rbrakk> \<Longrightarrow> Lam a x = Lam b xa"
-apply (lifting a3)
-done
+lemma a3:
+ "\<lbrakk>x = [(a, b)] \<bullet> xa; a \<notin> fv (Lam b x)\<rbrakk> \<Longrightarrow> Lam a x = Lam b xa"
+ by (lifting a3)
-lemma alpha_cases: "\<lbrakk>a1 = a2; \<And>a b. \<lbrakk>a1 = Var a; a2 = Var b; a = b\<rbrakk> \<Longrightarrow> P;
- \<And>x xa xb xc. \<lbrakk>a1 = App x xb; a2 = App xa xc; x = xa; xb = xc\<rbrakk> \<Longrightarrow> P;
- \<And>x a b xa. \<lbrakk>a1 = Lam a x; a2 = Lam b xa; x = [(a, b)] \<bullet> xa; a \<notin> fv (Lam b x)\<rbrakk> \<Longrightarrow> P\<rbrakk>
+lemma alpha_cases:
+ "\<lbrakk>a1 = a2; \<And>a b. \<lbrakk>a1 = Var a; a2 = Var b; a = b\<rbrakk> \<Longrightarrow> P;
+ \<And>x xa xb xc. \<lbrakk>a1 = App x xb; a2 = App xa xc; x = xa; xb = xc\<rbrakk> \<Longrightarrow> P;
+ \<And>x a b xa. \<lbrakk>a1 = Lam a x; a2 = Lam b xa; x = [(a, b)] \<bullet> xa; a \<notin> fv (Lam b x)\<rbrakk> \<Longrightarrow> P\<rbrakk>
\<Longrightarrow> P"
-apply (lifting alpha.cases)
-done
+ by (lifting alpha.cases)
-lemma alpha_induct: "\<lbrakk>(qx\<Colon>lam) = (qxa\<Colon>lam); \<And>(a\<Colon>name) b\<Colon>name. a = b \<Longrightarrow> (qxb\<Colon>lam \<Rightarrow> lam \<Rightarrow> bool) (Var a) (Var b);
- \<And>(x\<Colon>lam) (xa\<Colon>lam) (xb\<Colon>lam) xc\<Colon>lam. \<lbrakk>x = xa; qxb x xa; xb = xc; qxb xb xc\<rbrakk> \<Longrightarrow> qxb (App x xb) (App xa xc);
- \<And>(x\<Colon>lam) (a\<Colon>name) (b\<Colon>name) xa\<Colon>lam.
+lemma alpha_induct:
+ "\<lbrakk>qx = qxa; \<And>a b. a = b \<Longrightarrow> qxb (Var a) (Var b);
+ \<And>x xa xb xc. \<lbrakk>x = xa; qxb x xa; xb = xc; qxb xb xc\<rbrakk> \<Longrightarrow> qxb (App x xb) (App xa xc);
+ \<And>x a b xa.
\<lbrakk>x = [(a, b)] \<bullet> xa; qxb x ([(a, b)] \<bullet> xa); a \<notin> fv (Lam b x)\<rbrakk> \<Longrightarrow> qxb (Lam a x) (Lam b xa)\<rbrakk>
\<Longrightarrow> qxb qx qxa"
-apply (lifting alpha.induct)
-done
+ by (lifting alpha.induct)
+
+lemma var_inject:
+ "(Var a = Var b) = (a = b)"
+ by (lifting rvar_inject)
-lemma var_inject: "(Var a = Var b) = (a = b)"
-apply (lifting rvar_inject)
-done
-
-lemma lam_induct:" \<lbrakk>\<And>name. P (Var name); \<And>lam1 lam2. \<lbrakk>P lam1; P lam2\<rbrakk> \<Longrightarrow> P (App lam1 lam2);
- \<And>name lam. P lam \<Longrightarrow> P (Lam name lam)\<rbrakk> \<Longrightarrow> P lam"
-apply (lifting rlam.induct)
-done
+lemma lam_induct:
+ "\<lbrakk>\<And>name. P (Var name);
+ \<And>lam1 lam2. \<lbrakk>P lam1; P lam2\<rbrakk> \<Longrightarrow> P (App lam1 lam2);
+ \<And>name lam. P lam \<Longrightarrow> P (Lam name lam)\<rbrakk> \<Longrightarrow> P lam"
+ by (lifting rlam.induct)
lemma var_supp:
shows "supp (Var a) = ((supp a)::name set)"
apply(simp add: supp_def)
- apply(simp add: pi_var)
+ apply(simp add: pi_var2)
apply(simp add: var_inject)
done
lemma var_fresh:
fixes a::"name"
- shows "(a\<sharp>(Var b)) = (a\<sharp>b)"
+ shows "(a \<sharp> (Var b)) = (a \<sharp> b)"
apply(simp add: fresh_def)
apply(simp add: var_supp)
done