# HG changeset patch # User Christian Urban # Date 1304433570 -3600 # Node ID 3c769bf10e633940c2cc95d0343eeeb58c928781 # Parent d7183105e304307706ea6b071702072d7acc2868 added two mutual recursive inductive definitions diff -r d7183105e304 -r 3c769bf10e63 Nominal/Ex/LF.thy --- a/Nominal/Ex/LF.thy Tue May 03 13:25:02 2011 +0100 +++ b/Nominal/Ex/LF.thy Tue May 03 15:39:30 2011 +0100 @@ -17,7 +17,22 @@ Const "ident" | Var "name" | App "trm" "trm" - | Lam "ty" n::"name" t::"trm" bind n in t + | Lam' "ty" n::"name" t::"trm" bind n in t + +abbreviation + KPi_syn::"name \ ty \ kind \ kind" ("\[_:_]._" [100,100,100] 100) +where + "\[x:A].K \ KPi A x K" + +abbreviation + TPi_syn::"name \ ty \ ty \ ty" ("\[_:_]._" [100,100,100] 100) +where + "\[x:A1].A2 \ TPi A1 x A2" + +abbreviation + Lam_syn::"name \ ty \ trm \ trm" ("Lam [_:_]._" [100,100,100] 100) +where + "Lam [x:A].M \ Lam' A x M" thm lf.distinct thm lf.induct @@ -36,7 +51,110 @@ thm lf.fresh thm lf.fresh[simplified] +nominal_datatype sig_ass = + TC_ass "ident" "kind" + | C_ass "ident" "ty" +types Sig = "sig_ass list" +types Ctx = "(name \ ty) list" +types Subst = "(name \ trm) list" + +inductive + sig_valid :: "Sig \ bool" ("\ _ sig" [60] 60) +and ctx_valid :: "Sig \ Ctx \ bool" ("_ \ _ ctx" [60,60] 60) +and trm_valid :: "Sig \ Ctx \ trm \ ty \ bool" ("_,_ \ _ : _" [60,60,60,60] 60) +and ty_valid :: "Sig \ Ctx \ ty \ kind \ bool" ("_,_ \ _ : _" [60,60,60,60] 60) +and kind_valid :: "Sig \ Ctx \ kind \ bool" ("_,_ \ _ : Kind" [60,60,60] 60) +and trm_equiv :: "Sig \ Ctx \ trm \ trm \ ty \ bool" ("_,_ \ _ = _ : _" [60,60,60,60,60] 60) +and ty_equiv :: "Sig \ Ctx \ ty \ ty \ kind \ bool" ("_,_ \ _ = _ : _" [60,60,60,60,60] 60) +and kind_equiv :: "Sig \ Ctx \ kind \ kind \ bool" ("_,_ \ _ = _ : Kind" [60,60,60,60] 60) +where +(* Signatures *) + s1: "\ [] sig" +| s2: "\\ \ sig; \,[] \ K : Kind; atom a\\\ \ \ (TC_ass a K)#\ sig" +| s3: "\\ \ sig; \,[] \ A : Type; atom c\\\ \ \ (C_ass c A)#\ sig" + +(* Contexts *) +| c1: "\ \ sig \ \ \ [] ctx" +| c2: "\\ \ \ ctx; \,\ \ A : Type; atom x\\\ \ \ \ (x,A)#\ ctx" + +(* Typing Terms *) +| t1: "\\ \ \ ctx; (x,A) \ set \\ \ \,\ \ (Var x) : A" +| t2: "\\ \ \ ctx; C_ass c A \ set \\ \ \,\ \ (Const c) : A" +| t3: "\\,\ \ M1 : \[x:A2].A1; \,\ \ M2 : A2; atom x\\\ \ \,\ \ (App M1 M2) : A1" +| t4: "\\,\ \ A1 : Type; \,(x,A1)#\ \ M2 : A2; atom x\(\,A1)\ \ \,\ \ (Lam [x:A1].M2) : \[x:A1].A2" +| t5: "\\,\ \ M : A; \,\ \ A = B : Type\ \ \,\ \ M : B " + +(* Typing Types *) +| f1: "\\ \ \ ctx; TC_ass a K \ set \\ \ \,\ \ (TConst a) : K" +| f2: "\\,\ \ A : \[x:B].K; \,\ \ M : B; atom x\\\ \ \,\ \ (TApp A M) : K" +| f3: "\\,\ \ A1 : Type; \,(x,A1)#\ \ A2 : Type; atom x\(\,A1)\ \ \,\ \ (\[x:A1].A2) : Type" +| f4: "\\,\ \ A : K; \,\ \ K = L : Kind\ \ \,\ \ A : L" + +(* Typing Kinds *) +| k1: "\ \ \ ctx \ \,\ \ Type : Kind" +| k2: "\\,\ \ A : Type; \,(x,A)#\ \ K : Kind; atom x\(\,A)\ \ \,\ \ (\[x:A].K) : Kind" + +(* Simultaneous Congruence for Terms *) +| q1: "\\ \ \ ctx; (x,A) \ set \\ \ \,\ \ (Var x) = (Var x) : A" +| q2: "\\ \ \ ctx; C_ass c A \ set \\ \ \,\ \ (Const c) = (Const c): A" +| q3: "\\,\ \ M1 = N1 : \[x:A2].A1; \,\ \ M2 = N2 : A2; atom x\\\ + \ \,\ \ (App M1 M2) = (App N1 N2) : A1" +| q4: "\\,\ \ A1' = A1 : Type; \,\ \ A1'' = A1 : Type; \,\ \ A1 : Type; + \,(x,A1)#\ \ M2 = N2 : A2; atom x\\\ \ \,\ \ (Lam [x:A1'].M2) = (Lam [x:A1''].N2) : \[x:A1].A2" + +(* Extensionality *) +| ex: "\\,\ \ M : \[x:A1].A2; \,\ \ N : \[x:A1].A2; \,\ \ A1 : Type; + \,(x,A1)#\ \ App M (Var x) = App N (Var x) : A2; atom x\\\ \ \,\ \ M = N : \[x:A1].A2" + +(* Parallel Conversion *) +| pc: "\\,\ \ A1 : Type; \,(x,A1)#\ \ M2 = N2 : A2; \,\ \ M1 = N1 : A1; atom x\\\ + \ \,\ \ App (Lam [x:A1].M2) M1 = N2 : A2" + +(* Equivalence *) +| e1: "\,\ \ M = N : A \ \,\ \ N = M : (A::ty)" +| e2: "\\,\ \ M = N : A; \,\ \ N = P : A\ \ \,\ \ M = P : (A::ty)" +(*| e3: "\,\ \ M : A \ \,\ \ M = M : (A::ty)"*) + +(* Type conversion *) +| tc: "\\,\ \ M = N : A; \,\ \ A = B : Type\ \ \,\ \ M = N : B" + +(* Types Conruence *) +| ft1: "\\ \ \ ctx; TC_ass a K \ set \\ \ \,\ \ (TConst a) = (TConst a) : K" +| ft2: "\\,\ \ A = B : \[x:C].K; \,\ \ M = N : C; atom x\\\ \ \,\ \ (TApp A M) = (TApp B N) : K" +| ft3: "\\,\ \ A1 = B1 : Type; \,\ \ A1 : Type; \,(x,A1)#\ \ A2 = B2 : Type; atom x\\\ + \ \,\ \ \[x:A1].A2 = \[x:B1].B2 : Type" + +(* Types Equivalence *) +| fe1: "\,\ \ A = (B::ty) : (K::kind) \ \,\ \ B = A : K" +| fe2: "\\,\ \ A = B : K; \,\ \ B = C : K\ \ \,\ \ A = C : (K::kind)" +(*| fe3: "\,\ \ A : K \ \,\ \ A = A : (K::kind)"*) + +(* Kind Conversion *) +| kc: "\\,\ \ A = B : K; \,\ \ K = L : Kind\ \ \,\ \ A = B : (L::kind)" + +(* Kind Congruence *) +| kc1: "\ \ \ ctx \ \,\ \ Type = Type : Kind" +| kc2: "\\,\ \ A = B : Type; \,\ \ A : Type; \,(x,A)#\ \ K = L : Kind; atom x\\\ + \ \,\ \ \[x:A].K = \[x:B].L : Kind" + +(* Kind Equivalence *) +| ke1: "\,\ \ K = L : Kind \ \,\ \ L = K : Kind" +| ke2: "\\,\ \ K = L : Kind; \,\ \ L = L' : Kind\ \ \,\ \ K = L' : Kind" +(*| ke3: "\,\ \ K : Kind \ \,\ \ K = K : Kind"*) + +(* type extensionality - needed in order to get the soundness theorem through*) +| tex: "\\,\ \ A : \[x:C].K; \,\ \ B : \[x:C].K; \,\ \ C : Type; + \,(x,C)#\ \ TApp A (Var x) = TApp B (Var x) : K; atom x\\\ \ \,\ \ A = B : \[x:C].K" + +thm sig_valid_ctx_valid_trm_valid_ty_valid_kind_valid_trm_equiv_ty_equiv_kind_equiv_def +thm sig_valid_def +thm trm_valid_def +thm ty_valid_def +thm kind_valid_def +thm trm_equiv_def +thm kind_equiv_def +thm ty_equiv_def end diff -r d7183105e304 -r 3c769bf10e63 Nominal/Ex/Lambda.thy --- a/Nominal/Ex/Lambda.thy Tue May 03 13:25:02 2011 +0100 +++ b/Nominal/Ex/Lambda.thy Tue May 03 15:39:30 2011 +0100 @@ -2,6 +2,23 @@ imports "../Nominal2" begin +inductive + even :: "nat \ bool" and + odd :: "nat \ bool" +where + "even 0" +| "odd n \ even (Suc n)" +| "even n \ odd (Suc n)" + +thm even_odd_def + +lemma + shows "p \ (even n) = even (p \ n)" +unfolding even_def +unfolding even_odd_def +apply(perm_simp) +apply(rule refl) +done atom_decl name @@ -10,18 +27,27 @@ | App "lam" "lam" | Lam x::"name" l::"lam" bind x in l ("Lam [_]. _" [100, 100] 100) + inductive triv :: "lam \ nat \ bool" where Var: "triv (Var x) n" +| App: "\triv t1 n; triv t2 n\ \ triv (App t1 t2) n" lemma "p \ (triv t x) = triv (p \ t) (p \ x)" unfolding triv_def apply(perm_simp) +apply(rule refl) oops (*apply(perm_simp)*) +ML {* + Inductive.the_inductive @{context} "Lambda.triv" +*} + +thm triv_def + equivariance triv nominal_inductive triv avoids Var: "{}::name set" apply(auto simp add: fresh_star_def)