| author | wenzelm | 
| Sat, 09 Aug 2008 22:43:53 +0200 | |
| changeset 27811 | 44bc67675210 | 
| parent 26966 | 071f40487734 | 
| child 29097 | 68245155eb58 | 
| permissions | -rw-r--r-- | 
| 21087 | 1 | (* $Id$ *) | 
| 20606 
fd9b0b78a7d3
this file contains a compile-challenge suggested by Adam Chlipala;
 urbanc parents: diff
changeset | 2 | |
| 22829 
f1db55c7534d
tuned some proofs and changed variable names in some definitions of Nominal.thy
 urbanc parents: 
22541diff
changeset | 3 | (* The definitions for a challenge suggested by Adam Chlipala *) | 
| 20606 
fd9b0b78a7d3
this file contains a compile-challenge suggested by Adam Chlipala;
 urbanc parents: diff
changeset | 4 | |
| 
fd9b0b78a7d3
this file contains a compile-challenge suggested by Adam Chlipala;
 urbanc parents: diff
changeset | 5 | theory Compile | 
| 22418 
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
 urbanc parents: 
22271diff
changeset | 6 | imports "../Nominal" | 
| 20606 
fd9b0b78a7d3
this file contains a compile-challenge suggested by Adam Chlipala;
 urbanc parents: diff
changeset | 7 | begin | 
| 
fd9b0b78a7d3
this file contains a compile-challenge suggested by Adam Chlipala;
 urbanc parents: diff
changeset | 8 | |
| 
fd9b0b78a7d3
this file contains a compile-challenge suggested by Adam Chlipala;
 urbanc parents: diff
changeset | 9 | atom_decl name | 
| 
fd9b0b78a7d3
this file contains a compile-challenge suggested by Adam Chlipala;
 urbanc parents: diff
changeset | 10 | |
| 22829 
f1db55c7534d
tuned some proofs and changed variable names in some definitions of Nominal.thy
 urbanc parents: 
22541diff
changeset | 11 | nominal_datatype data = | 
| 
f1db55c7534d
tuned some proofs and changed variable names in some definitions of Nominal.thy
 urbanc parents: 
22541diff
changeset | 12 | DNat | 
| 
f1db55c7534d
tuned some proofs and changed variable names in some definitions of Nominal.thy
 urbanc parents: 
22541diff
changeset | 13 | | DProd "data" "data" | 
| 
f1db55c7534d
tuned some proofs and changed variable names in some definitions of Nominal.thy
 urbanc parents: 
22541diff
changeset | 14 | | DSum "data" "data" | 
| 20606 
fd9b0b78a7d3
this file contains a compile-challenge suggested by Adam Chlipala;
 urbanc parents: diff
changeset | 15 | |
| 22829 
f1db55c7534d
tuned some proofs and changed variable names in some definitions of Nominal.thy
 urbanc parents: 
22541diff
changeset | 16 | nominal_datatype ty = | 
| 
f1db55c7534d
tuned some proofs and changed variable names in some definitions of Nominal.thy
 urbanc parents: 
22541diff
changeset | 17 | Data "data" | 
| 
f1db55c7534d
tuned some proofs and changed variable names in some definitions of Nominal.thy
 urbanc parents: 
22541diff
changeset | 18 |   | Arrow "ty" "ty" ("_\<rightarrow>_" [100,100] 100)
 | 
| 20606 
fd9b0b78a7d3
this file contains a compile-challenge suggested by Adam Chlipala;
 urbanc parents: diff
changeset | 19 | |
| 22829 
f1db55c7534d
tuned some proofs and changed variable names in some definitions of Nominal.thy
 urbanc parents: 
22541diff
changeset | 20 | nominal_datatype trm = | 
| 
f1db55c7534d
tuned some proofs and changed variable names in some definitions of Nominal.thy
 urbanc parents: 
22541diff
changeset | 21 | Var "name" | 
| 
f1db55c7534d
tuned some proofs and changed variable names in some definitions of Nominal.thy
 urbanc parents: 
22541diff
changeset | 22 |   | Lam "\<guillemotleft>name\<guillemotright>trm" ("Lam [_]._" [100,100] 100)
 | 
| 
f1db55c7534d
tuned some proofs and changed variable names in some definitions of Nominal.thy
 urbanc parents: 
22541diff
changeset | 23 | | App "trm" "trm" | 
| 
f1db55c7534d
tuned some proofs and changed variable names in some definitions of Nominal.thy
 urbanc parents: 
22541diff
changeset | 24 | | Const "nat" | 
| 
f1db55c7534d
tuned some proofs and changed variable names in some definitions of Nominal.thy
 urbanc parents: 
22541diff
changeset | 25 | | Pr "trm" "trm" | 
| 
f1db55c7534d
tuned some proofs and changed variable names in some definitions of Nominal.thy
 urbanc parents: 
22541diff
changeset | 26 | | Fst "trm" | 
| 
f1db55c7534d
tuned some proofs and changed variable names in some definitions of Nominal.thy
 urbanc parents: 
22541diff
changeset | 27 | | Snd "trm" | 
| 
f1db55c7534d
tuned some proofs and changed variable names in some definitions of Nominal.thy
 urbanc parents: 
22541diff
changeset | 28 | | InL "trm" | 
| 
f1db55c7534d
tuned some proofs and changed variable names in some definitions of Nominal.thy
 urbanc parents: 
22541diff
changeset | 29 | | InR "trm" | 
| 
f1db55c7534d
tuned some proofs and changed variable names in some definitions of Nominal.thy
 urbanc parents: 
22541diff
changeset | 30 | | Case "trm" "\<guillemotleft>name\<guillemotright>trm" "\<guillemotleft>name\<guillemotright>trm" | 
| 
f1db55c7534d
tuned some proofs and changed variable names in some definitions of Nominal.thy
 urbanc parents: 
22541diff
changeset | 31 |           ("Case _ of inl _ \<rightarrow> _ | inr _ \<rightarrow> _" [100,100,100,100,100] 100)
 | 
| 20606 
fd9b0b78a7d3
this file contains a compile-challenge suggested by Adam Chlipala;
 urbanc parents: diff
changeset | 32 | |
| 
fd9b0b78a7d3
this file contains a compile-challenge suggested by Adam Chlipala;
 urbanc parents: diff
changeset | 33 | nominal_datatype dataI = OneI | NatI | 
| 
fd9b0b78a7d3
this file contains a compile-challenge suggested by Adam Chlipala;
 urbanc parents: diff
changeset | 34 | |
| 22829 
f1db55c7534d
tuned some proofs and changed variable names in some definitions of Nominal.thy
 urbanc parents: 
22541diff
changeset | 35 | nominal_datatype tyI = | 
| 
f1db55c7534d
tuned some proofs and changed variable names in some definitions of Nominal.thy
 urbanc parents: 
22541diff
changeset | 36 | DataI "dataI" | 
| 
f1db55c7534d
tuned some proofs and changed variable names in some definitions of Nominal.thy
 urbanc parents: 
22541diff
changeset | 37 |   | ArrowI "tyI" "tyI" ("_\<rightarrow>_" [100,100] 100)
 | 
| 20606 
fd9b0b78a7d3
this file contains a compile-challenge suggested by Adam Chlipala;
 urbanc parents: diff
changeset | 38 | |
| 22829 
f1db55c7534d
tuned some proofs and changed variable names in some definitions of Nominal.thy
 urbanc parents: 
22541diff
changeset | 39 | nominal_datatype trmI = | 
| 
f1db55c7534d
tuned some proofs and changed variable names in some definitions of Nominal.thy
 urbanc parents: 
22541diff
changeset | 40 | IVar "name" | 
| 
f1db55c7534d
tuned some proofs and changed variable names in some definitions of Nominal.thy
 urbanc parents: 
22541diff
changeset | 41 |   | ILam "\<guillemotleft>name\<guillemotright>trmI" ("ILam [_]._" [100,100] 100)
 | 
| 
f1db55c7534d
tuned some proofs and changed variable names in some definitions of Nominal.thy
 urbanc parents: 
22541diff
changeset | 42 | | IApp "trmI" "trmI" | 
| 
f1db55c7534d
tuned some proofs and changed variable names in some definitions of Nominal.thy
 urbanc parents: 
22541diff
changeset | 43 | | IUnit | 
| 
f1db55c7534d
tuned some proofs and changed variable names in some definitions of Nominal.thy
 urbanc parents: 
22541diff
changeset | 44 | | INat "nat" | 
| 
f1db55c7534d
tuned some proofs and changed variable names in some definitions of Nominal.thy
 urbanc parents: 
22541diff
changeset | 45 | | ISucc "trmI" | 
| 
f1db55c7534d
tuned some proofs and changed variable names in some definitions of Nominal.thy
 urbanc parents: 
22541diff
changeset | 46 |   | IAss "trmI" "trmI" ("_\<mapsto>_" [100,100] 100)
 | 
| 
f1db55c7534d
tuned some proofs and changed variable names in some definitions of Nominal.thy
 urbanc parents: 
22541diff
changeset | 47 | | IRef "trmI" | 
| 
f1db55c7534d
tuned some proofs and changed variable names in some definitions of Nominal.thy
 urbanc parents: 
22541diff
changeset | 48 |   | ISeq "trmI" "trmI" ("_;;_" [100,100] 100)
 | 
| 
f1db55c7534d
tuned some proofs and changed variable names in some definitions of Nominal.thy
 urbanc parents: 
22541diff
changeset | 49 | | Iif "trmI" "trmI" "trmI" | 
| 20606 
fd9b0b78a7d3
this file contains a compile-challenge suggested by Adam Chlipala;
 urbanc parents: diff
changeset | 50 | |
| 
fd9b0b78a7d3
this file contains a compile-challenge suggested by Adam Chlipala;
 urbanc parents: diff
changeset | 51 | text {* valid contexts *}
 | 
| 
fd9b0b78a7d3
this file contains a compile-challenge suggested by Adam Chlipala;
 urbanc parents: diff
changeset | 52 | |
| 23760 | 53 | inductive | 
| 22829 
f1db55c7534d
tuned some proofs and changed variable names in some definitions of Nominal.thy
 urbanc parents: 
22541diff
changeset | 54 | valid :: "(name\<times>'a::pt_name) list \<Rightarrow> bool" | 
| 22271 | 55 | where | 
| 56 | v1[intro]: "valid []" | |
| 57 | | v2[intro]: "\<lbrakk>valid \<Gamma>;a\<sharp>\<Gamma>\<rbrakk>\<Longrightarrow> valid ((a,\<sigma>)#\<Gamma>)" (* maybe dom of \<Gamma> *) | |
| 20606 
fd9b0b78a7d3
this file contains a compile-challenge suggested by Adam Chlipala;
 urbanc parents: diff
changeset | 58 | |
| 
fd9b0b78a7d3
this file contains a compile-challenge suggested by Adam Chlipala;
 urbanc parents: diff
changeset | 59 | text {* typing judgements for trms *}
 | 
| 
fd9b0b78a7d3
this file contains a compile-challenge suggested by Adam Chlipala;
 urbanc parents: diff
changeset | 60 | |
| 23760 | 61 | inductive | 
| 22829 
f1db55c7534d
tuned some proofs and changed variable names in some definitions of Nominal.thy
 urbanc parents: 
22541diff
changeset | 62 |   typing :: "(name\<times>ty) list\<Rightarrow>trm\<Rightarrow>ty\<Rightarrow>bool" (" _ \<turnstile> _ : _ " [80,80,80] 80)
 | 
| 22271 | 63 | where | 
| 64 | t0[intro]: "\<lbrakk>valid \<Gamma>; (x,\<tau>)\<in>set \<Gamma>\<rbrakk>\<Longrightarrow> \<Gamma> \<turnstile> Var x : \<tau>" | |
| 65 | | t1[intro]: "\<lbrakk>\<Gamma> \<turnstile> e1 : \<tau>1\<rightarrow>\<tau>2; \<Gamma> \<turnstile> e2 : \<tau>1\<rbrakk>\<Longrightarrow> \<Gamma> \<turnstile> App e1 e2 : \<tau>2" | |
| 66 | | t2[intro]: "\<lbrakk>x\<sharp>\<Gamma>;((x,\<tau>1)#\<Gamma>) \<turnstile> t : \<tau>2\<rbrakk> \<Longrightarrow> \<Gamma> \<turnstile> Lam [x].t : \<tau>1\<rightarrow>\<tau>2" | |
| 67 | | t3[intro]: "valid \<Gamma> \<Longrightarrow> \<Gamma> \<turnstile> Const n : Data(DNat)" | |
| 68 | | t4[intro]: "\<lbrakk>\<Gamma> \<turnstile> e1 : Data(\<sigma>1); \<Gamma> \<turnstile> e2 : Data(\<sigma>2)\<rbrakk> \<Longrightarrow> \<Gamma> \<turnstile> Pr e1 e2 : Data (DProd \<sigma>1 \<sigma>2)" | |
| 69 | | t5[intro]: "\<lbrakk>\<Gamma> \<turnstile> e : Data(DProd \<sigma>1 \<sigma>2)\<rbrakk> \<Longrightarrow> \<Gamma> \<turnstile> Fst e : Data(\<sigma>1)" | |
| 70 | | t6[intro]: "\<lbrakk>\<Gamma> \<turnstile> e : Data(DProd \<sigma>1 \<sigma>2)\<rbrakk> \<Longrightarrow> \<Gamma> \<turnstile> Snd e : Data(\<sigma>2)" | |
| 71 | | t7[intro]: "\<lbrakk>\<Gamma> \<turnstile> e : Data(\<sigma>1)\<rbrakk> \<Longrightarrow> \<Gamma> \<turnstile> InL e : Data(DSum \<sigma>1 \<sigma>2)" | |
| 72 | | t8[intro]: "\<lbrakk>\<Gamma> \<turnstile> e : Data(\<sigma>2)\<rbrakk> \<Longrightarrow> \<Gamma> \<turnstile> InR e : Data(DSum \<sigma>1 \<sigma>2)" | |
| 73 | | t9[intro]: "\<lbrakk>x1\<sharp>\<Gamma>; x2\<sharp>\<Gamma>; \<Gamma> \<turnstile> e: Data(DSum \<sigma>1 \<sigma>2); | |
| 20606 
fd9b0b78a7d3
this file contains a compile-challenge suggested by Adam Chlipala;
 urbanc parents: diff
changeset | 74 | ((x1,Data(\<sigma>1))#\<Gamma>) \<turnstile> e1 : \<tau>; ((x2,Data(\<sigma>2))#\<Gamma>) \<turnstile> e2 : \<tau>\<rbrakk> | 
| 
fd9b0b78a7d3
this file contains a compile-challenge suggested by Adam Chlipala;
 urbanc parents: diff
changeset | 75 | \<Longrightarrow> \<Gamma> \<turnstile> (Case e of inl x1 \<rightarrow> e1 | inr x2 \<rightarrow> e2) : \<tau>" | 
| 
fd9b0b78a7d3
this file contains a compile-challenge suggested by Adam Chlipala;
 urbanc parents: diff
changeset | 76 | |
| 
fd9b0b78a7d3
this file contains a compile-challenge suggested by Adam Chlipala;
 urbanc parents: diff
changeset | 77 | text {* typing judgements for Itrms *}
 | 
| 
fd9b0b78a7d3
this file contains a compile-challenge suggested by Adam Chlipala;
 urbanc parents: diff
changeset | 78 | |
| 23760 | 79 | inductive | 
| 22829 
f1db55c7534d
tuned some proofs and changed variable names in some definitions of Nominal.thy
 urbanc parents: 
22541diff
changeset | 80 |   Ityping :: "(name\<times>tyI) list\<Rightarrow>trmI\<Rightarrow>tyI\<Rightarrow>bool" (" _ I\<turnstile> _ : _ " [80,80,80] 80)
 | 
| 22271 | 81 | where | 
| 82 | t0[intro]: "\<lbrakk>valid \<Gamma>; (x,\<tau>)\<in>set \<Gamma>\<rbrakk>\<Longrightarrow> \<Gamma> I\<turnstile> IVar x : \<tau>" | |
| 83 | | t1[intro]: "\<lbrakk>\<Gamma> I\<turnstile> e1 : \<tau>1\<rightarrow>\<tau>2; \<Gamma> I\<turnstile> e2 : \<tau>1\<rbrakk>\<Longrightarrow> \<Gamma> I\<turnstile> IApp e1 e2 : \<tau>2" | |
| 84 | | t2[intro]: "\<lbrakk>x\<sharp>\<Gamma>;((x,\<tau>1)#\<Gamma>) I\<turnstile> t : \<tau>2\<rbrakk> \<Longrightarrow> \<Gamma> I\<turnstile> ILam [x].t : \<tau>1\<rightarrow>\<tau>2" | |
| 85 | | t3[intro]: "valid \<Gamma> \<Longrightarrow> \<Gamma> I\<turnstile> IUnit : DataI(OneI)" | |
| 86 | | t4[intro]: "valid \<Gamma> \<Longrightarrow> \<Gamma> I\<turnstile> INat(n) : DataI(NatI)" | |
| 87 | | t5[intro]: "\<Gamma> I\<turnstile> e : DataI(NatI) \<Longrightarrow> \<Gamma> I\<turnstile> ISucc(e) : DataI(NatI)" | |
| 88 | | t6[intro]: "\<lbrakk>\<Gamma> I\<turnstile> e : DataI(NatI)\<rbrakk> \<Longrightarrow> \<Gamma> I\<turnstile> IRef e : DataI (NatI)" | |
| 89 | | t7[intro]: "\<lbrakk>\<Gamma> I\<turnstile> e1 : DataI(NatI); \<Gamma> I\<turnstile> e2 : DataI(NatI)\<rbrakk> \<Longrightarrow> \<Gamma> I\<turnstile> e1\<mapsto>e2 : DataI(OneI)" | |
| 90 | | t8[intro]: "\<lbrakk>\<Gamma> I\<turnstile> e1 : DataI(NatI); \<Gamma> I\<turnstile> e2 : \<tau>\<rbrakk> \<Longrightarrow> \<Gamma> I\<turnstile> e1;;e2 : \<tau>" | |
| 91 | | t9[intro]: "\<lbrakk>\<Gamma> I\<turnstile> e: DataI(NatI); \<Gamma> I\<turnstile> e1 : \<tau>; \<Gamma> I\<turnstile> e2 : \<tau>\<rbrakk> \<Longrightarrow> \<Gamma> I\<turnstile> Iif e e1 e2 : \<tau>" | |
| 20606 
fd9b0b78a7d3
this file contains a compile-challenge suggested by Adam Chlipala;
 urbanc parents: diff
changeset | 92 | |
| 
fd9b0b78a7d3
this file contains a compile-challenge suggested by Adam Chlipala;
 urbanc parents: diff
changeset | 93 | text {* capture-avoiding substitution *}
 | 
| 
fd9b0b78a7d3
this file contains a compile-challenge suggested by Adam Chlipala;
 urbanc parents: diff
changeset | 94 | |
| 21543 | 95 | consts | 
| 96 |   subst :: "'a \<Rightarrow> name \<Rightarrow> 'a \<Rightarrow> 'a"  ("_[_::=_]" [100,100,100] 100)
 | |
| 20606 
fd9b0b78a7d3
this file contains a compile-challenge suggested by Adam Chlipala;
 urbanc parents: diff
changeset | 97 | |
| 21543 | 98 | nominal_primrec | 
| 99 | "(Var x)[y::=t'] = (if x=y then t' else (Var x))" | |
| 100 | "(App t1 t2)[y::=t'] = App (t1[y::=t']) (t2[y::=t'])" | |
| 101 | "\<lbrakk>x\<sharp>y; x\<sharp>t'\<rbrakk> \<Longrightarrow> (Lam [x].t)[y::=t'] = Lam [x].(t[y::=t'])" | |
| 102 | "(Const n)[y::=t'] = Const n" | |
| 103 | "(Pr e1 e2)[y::=t'] = Pr (e1[y::=t']) (e2[y::=t'])" | |
| 104 | "(Fst e)[y::=t'] = Fst (e[y::=t'])" | |
| 105 | "(Snd e)[y::=t'] = Snd (e[y::=t'])" | |
| 106 | "(InL e)[y::=t'] = InL (e[y::=t'])" | |
| 107 | "(InR e)[y::=t'] = InR (e[y::=t'])" | |
| 108 | "\<lbrakk>z\<noteq>x; x\<sharp>y; x\<sharp>e; x\<sharp>e2; z\<sharp>y; z\<sharp>e; z\<sharp>e1; x\<sharp>t'; z\<sharp>t'\<rbrakk> \<Longrightarrow> | |
| 109 | (Case e of inl x \<rightarrow> e1 | inr z \<rightarrow> e2)[y::=t'] = | |
| 110 | (Case (e[y::=t']) of inl x \<rightarrow> (e1[y::=t']) | inr z \<rightarrow> (e2[y::=t']))" | |
| 22418 
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
 urbanc parents: 
22271diff
changeset | 111 | apply(finite_guess)+ | 
| 
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
 urbanc parents: 
22271diff
changeset | 112 | apply(rule TrueI)+ | 
| 
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
 urbanc parents: 
22271diff
changeset | 113 | apply(simp add: abs_fresh)+ | 
| 
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
 urbanc parents: 
22271diff
changeset | 114 | apply(fresh_guess)+ | 
| 21543 | 115 | done | 
| 20606 
fd9b0b78a7d3
this file contains a compile-challenge suggested by Adam Chlipala;
 urbanc parents: diff
changeset | 116 | |
| 21543 | 117 | nominal_primrec (Isubst) | 
| 118 | "(IVar x)[y::=t'] = (if x=y then t' else (IVar x))" | |
| 119 | "(IApp t1 t2)[y::=t'] = IApp (t1[y::=t']) (t2[y::=t'])" | |
| 120 | "\<lbrakk>x\<sharp>y; x\<sharp>t'\<rbrakk> \<Longrightarrow> (ILam [x].t)[y::=t'] = ILam [x].(t[y::=t'])" | |
| 121 | "(INat n)[y::=t'] = INat n" | |
| 122 | "(IUnit)[y::=t'] = IUnit" | |
| 123 | "(ISucc e)[y::=t'] = ISucc (e[y::=t'])" | |
| 124 | "(IAss e1 e2)[y::=t'] = IAss (e1[y::=t']) (e2[y::=t'])" | |
| 125 | "(IRef e)[y::=t'] = IRef (e[y::=t'])" | |
| 126 | "(ISeq e1 e2)[y::=t'] = ISeq (e1[y::=t']) (e2[y::=t'])" | |
| 127 | "(Iif e e1 e2)[y::=t'] = Iif (e[y::=t']) (e1[y::=t']) (e2[y::=t'])" | |
| 22418 
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
 urbanc parents: 
22271diff
changeset | 128 | apply(finite_guess)+ | 
| 
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
 urbanc parents: 
22271diff
changeset | 129 | apply(rule TrueI)+ | 
| 
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
 urbanc parents: 
22271diff
changeset | 130 | apply(simp add: abs_fresh)+ | 
| 
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
 urbanc parents: 
22271diff
changeset | 131 | apply(fresh_guess)+ | 
| 21543 | 132 | done | 
| 20606 
fd9b0b78a7d3
this file contains a compile-challenge suggested by Adam Chlipala;
 urbanc parents: diff
changeset | 133 | |
| 22418 
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
 urbanc parents: 
22271diff
changeset | 134 | lemma Isubst_eqvt[eqvt]: | 
| 20606 
fd9b0b78a7d3
this file contains a compile-challenge suggested by Adam Chlipala;
 urbanc parents: diff
changeset | 135 | fixes pi::"name prm" | 
| 
fd9b0b78a7d3
this file contains a compile-challenge suggested by Adam Chlipala;
 urbanc parents: diff
changeset | 136 | and t1::"trmI" | 
| 
fd9b0b78a7d3
this file contains a compile-challenge suggested by Adam Chlipala;
 urbanc parents: diff
changeset | 137 | and t2::"trmI" | 
| 
fd9b0b78a7d3
this file contains a compile-challenge suggested by Adam Chlipala;
 urbanc parents: diff
changeset | 138 | and x::"name" | 
| 
fd9b0b78a7d3
this file contains a compile-challenge suggested by Adam Chlipala;
 urbanc parents: diff
changeset | 139 | shows "pi\<bullet>(t1[x::=t2]) = ((pi\<bullet>t1)[(pi\<bullet>x)::=(pi\<bullet>t2)])" | 
| 26966 
071f40487734
made the naming of the induction principles consistent: weak_induct is
 urbanc parents: 
23760diff
changeset | 140 | apply (nominal_induct t1 avoiding: x t2 rule: trmI.strong_induct) | 
| 22541 
c33b542394f3
the name for the collection of equivariance lemmas is now eqvts (changed from eqvt) in order to avoid clashes with eqvt-lemmas generated in nominal_inductive
 urbanc parents: 
22418diff
changeset | 141 | apply (simp_all add: Isubst.simps eqvts fresh_bij) | 
| 20606 
fd9b0b78a7d3
this file contains a compile-challenge suggested by Adam Chlipala;
 urbanc parents: diff
changeset | 142 | done | 
| 
fd9b0b78a7d3
this file contains a compile-challenge suggested by Adam Chlipala;
 urbanc parents: diff
changeset | 143 | |
| 
fd9b0b78a7d3
this file contains a compile-challenge suggested by Adam Chlipala;
 urbanc parents: diff
changeset | 144 | lemma Isubst_supp: | 
| 
fd9b0b78a7d3
this file contains a compile-challenge suggested by Adam Chlipala;
 urbanc parents: diff
changeset | 145 | fixes t1::"trmI" | 
| 
fd9b0b78a7d3
this file contains a compile-challenge suggested by Adam Chlipala;
 urbanc parents: diff
changeset | 146 | and t2::"trmI" | 
| 
fd9b0b78a7d3
this file contains a compile-challenge suggested by Adam Chlipala;
 urbanc parents: diff
changeset | 147 | and x::"name" | 
| 
fd9b0b78a7d3
this file contains a compile-challenge suggested by Adam Chlipala;
 urbanc parents: diff
changeset | 148 |   shows "((supp (t1[x::=t2]))::name set) \<subseteq> (supp t2)\<union>((supp t1)-{x})"
 | 
| 26966 
071f40487734
made the naming of the induction principles consistent: weak_induct is
 urbanc parents: 
23760diff
changeset | 149 | apply (nominal_induct t1 avoiding: x t2 rule: trmI.strong_induct) | 
| 21543 | 150 | apply (auto simp add: Isubst.simps trmI.supp supp_atm abs_supp supp_nat) | 
| 151 | apply blast+ | |
| 152 | done | |
| 20606 
fd9b0b78a7d3
this file contains a compile-challenge suggested by Adam Chlipala;
 urbanc parents: diff
changeset | 153 | |
| 
fd9b0b78a7d3
this file contains a compile-challenge suggested by Adam Chlipala;
 urbanc parents: diff
changeset | 154 | lemma Isubst_fresh: | 
| 
fd9b0b78a7d3
this file contains a compile-challenge suggested by Adam Chlipala;
 urbanc parents: diff
changeset | 155 | fixes x::"name" | 
| 
fd9b0b78a7d3
this file contains a compile-challenge suggested by Adam Chlipala;
 urbanc parents: diff
changeset | 156 | and y::"name" | 
| 
fd9b0b78a7d3
this file contains a compile-challenge suggested by Adam Chlipala;
 urbanc parents: diff
changeset | 157 | and t1::"trmI" | 
| 
fd9b0b78a7d3
this file contains a compile-challenge suggested by Adam Chlipala;
 urbanc parents: diff
changeset | 158 | and t2::"trmI" | 
| 
fd9b0b78a7d3
this file contains a compile-challenge suggested by Adam Chlipala;
 urbanc parents: diff
changeset | 159 | assumes a: "x\<sharp>[y].t1" "x\<sharp>t2" | 
| 
fd9b0b78a7d3
this file contains a compile-challenge suggested by Adam Chlipala;
 urbanc parents: diff
changeset | 160 | shows "x\<sharp>(t1[y::=t2])" | 
| 
fd9b0b78a7d3
this file contains a compile-challenge suggested by Adam Chlipala;
 urbanc parents: diff
changeset | 161 | using a | 
| 
fd9b0b78a7d3
this file contains a compile-challenge suggested by Adam Chlipala;
 urbanc parents: diff
changeset | 162 | apply(auto simp add: fresh_def Isubst_supp) | 
| 
fd9b0b78a7d3
this file contains a compile-challenge suggested by Adam Chlipala;
 urbanc parents: diff
changeset | 163 | apply(drule rev_subsetD) | 
| 
fd9b0b78a7d3
this file contains a compile-challenge suggested by Adam Chlipala;
 urbanc parents: diff
changeset | 164 | apply(rule Isubst_supp) | 
| 
fd9b0b78a7d3
this file contains a compile-challenge suggested by Adam Chlipala;
 urbanc parents: diff
changeset | 165 | apply(simp add: abs_supp) | 
| 
fd9b0b78a7d3
this file contains a compile-challenge suggested by Adam Chlipala;
 urbanc parents: diff
changeset | 166 | done | 
| 
fd9b0b78a7d3
this file contains a compile-challenge suggested by Adam Chlipala;
 urbanc parents: diff
changeset | 167 | |
| 
fd9b0b78a7d3
this file contains a compile-challenge suggested by Adam Chlipala;
 urbanc parents: diff
changeset | 168 | text {* big-step evaluation for trms *}
 | 
| 
fd9b0b78a7d3
this file contains a compile-challenge suggested by Adam Chlipala;
 urbanc parents: diff
changeset | 169 | |
| 23760 | 170 | inductive | 
| 22829 
f1db55c7534d
tuned some proofs and changed variable names in some definitions of Nominal.thy
 urbanc parents: 
22541diff
changeset | 171 |   big :: "trm\<Rightarrow>trm\<Rightarrow>bool" ("_ \<Down> _" [80,80] 80)
 | 
| 22271 | 172 | where | 
| 173 | b0[intro]: "Lam [x].e \<Down> Lam [x].e" | |
| 174 | | b1[intro]: "\<lbrakk>e1\<Down>Lam [x].e; e2\<Down>e2'; e[x::=e2']\<Down>e'\<rbrakk> \<Longrightarrow> App e1 e2 \<Down> e'" | |
| 175 | | b2[intro]: "Const n \<Down> Const n" | |
| 176 | | b3[intro]: "\<lbrakk>e1\<Down>e1'; e2\<Down>e2'\<rbrakk> \<Longrightarrow> Pr e1 e2 \<Down> Pr e1' e2'" | |
| 177 | | b4[intro]: "e\<Down>Pr e1 e2 \<Longrightarrow> Fst e\<Down>e1" | |
| 178 | | b5[intro]: "e\<Down>Pr e1 e2 \<Longrightarrow> Snd e\<Down>e2" | |
| 179 | | b6[intro]: "e\<Down>e' \<Longrightarrow> InL e \<Down> InL e'" | |
| 180 | | b7[intro]: "e\<Down>e' \<Longrightarrow> InR e \<Down> InR e'" | |
| 181 | | b8[intro]: "\<lbrakk>e\<Down>InL e'; e1[x::=e']\<Down>e''\<rbrakk> \<Longrightarrow> Case e of inl x1 \<rightarrow> e1 | inr x2 \<rightarrow> e2 \<Down> e''" | |
| 182 | | b9[intro]: "\<lbrakk>e\<Down>InR e'; e2[x::=e']\<Down>e''\<rbrakk> \<Longrightarrow> Case e of inl x1 \<rightarrow> e1 | inr x2 \<rightarrow> e2 \<Down> e''" | |
| 20606 
fd9b0b78a7d3
this file contains a compile-challenge suggested by Adam Chlipala;
 urbanc parents: diff
changeset | 183 | |
| 23760 | 184 | inductive | 
| 22829 
f1db55c7534d
tuned some proofs and changed variable names in some definitions of Nominal.thy
 urbanc parents: 
22541diff
changeset | 185 |   Ibig :: "((nat\<Rightarrow>nat)\<times>trmI)\<Rightarrow>((nat\<Rightarrow>nat)\<times>trmI)\<Rightarrow>bool" ("_ I\<Down> _" [80,80] 80)
 | 
| 22271 | 186 | where | 
| 187 | m0[intro]: "(m,ILam [x].e) I\<Down> (m,ILam [x].e)" | |
| 188 | | m1[intro]: "\<lbrakk>(m,e1)I\<Down>(m',ILam [x].e); (m',e2)I\<Down>(m'',e3); (m'',e[x::=e3])I\<Down>(m''',e4)\<rbrakk> | |
| 20606 
fd9b0b78a7d3
this file contains a compile-challenge suggested by Adam Chlipala;
 urbanc parents: diff
changeset | 189 | \<Longrightarrow> (m,IApp e1 e2) I\<Down> (m''',e4)" | 
| 22271 | 190 | | m2[intro]: "(m,IUnit) I\<Down> (m,IUnit)" | 
| 191 | | m3[intro]: "(m,INat(n))I\<Down>(m,INat(n))" | |
| 192 | | m4[intro]: "(m,e)I\<Down>(m',INat(n)) \<Longrightarrow> (m,ISucc(e))I\<Down>(m',INat(n+1))" | |
| 193 | | m5[intro]: "(m,e)I\<Down>(m',INat(n)) \<Longrightarrow> (m,IRef(e))I\<Down>(m',INat(m' n))" | |
| 194 | | m6[intro]: "\<lbrakk>(m,e1)I\<Down>(m',INat(n1)); (m',e2)I\<Down>(m'',INat(n2))\<rbrakk> \<Longrightarrow> (m,e1\<mapsto>e2)I\<Down>(m''(n1:=n2),IUnit)" | |
| 195 | | m7[intro]: "\<lbrakk>(m,e1)I\<Down>(m',IUnit); (m',e2)I\<Down>(m'',e)\<rbrakk> \<Longrightarrow> (m,e1;;e2)I\<Down>(m'',e)" | |
| 196 | | m8[intro]: "\<lbrakk>(m,e)I\<Down>(m',INat(n)); n\<noteq>0; (m',e1)I\<Down>(m'',e)\<rbrakk> \<Longrightarrow> (m,Iif e e1 e2)I\<Down>(m'',e)" | |
| 197 | | m9[intro]: "\<lbrakk>(m,e)I\<Down>(m',INat(0)); (m',e2)I\<Down>(m'',e)\<rbrakk> \<Longrightarrow> (m,Iif e e1 e2)I\<Down>(m'',e)" | |
| 20606 
fd9b0b78a7d3
this file contains a compile-challenge suggested by Adam Chlipala;
 urbanc parents: diff
changeset | 198 | |
| 
fd9b0b78a7d3
this file contains a compile-challenge suggested by Adam Chlipala;
 urbanc parents: diff
changeset | 199 | text {* Translation functions *}
 | 
| 
fd9b0b78a7d3
this file contains a compile-challenge suggested by Adam Chlipala;
 urbanc parents: diff
changeset | 200 | |
| 21543 | 201 | consts trans :: "trm \<Rightarrow> trmI" | 
| 20606 
fd9b0b78a7d3
this file contains a compile-challenge suggested by Adam Chlipala;
 urbanc parents: diff
changeset | 202 | |
| 21543 | 203 | nominal_primrec | 
| 204 | "trans (Var x) = (IVar x)" | |
| 205 | "trans (App e1 e2) = IApp (trans e1) (trans e2)" | |
| 206 | "trans (Lam [x].e) = ILam [x].(trans e)" | |
| 207 | "trans (Const n) = INat n" | |
| 208 | "trans (Pr e1 e2) = | |
| 209 | (let limit = IRef(INat 0) in | |
| 210 | let v1 = (trans e1) in | |
| 211 | let v2 = (trans e2) in | |
| 212 | (((ISucc limit)\<mapsto>v1);;(ISucc(ISucc limit)\<mapsto>v2));;(INat 0 \<mapsto> ISucc(ISucc(limit))))" | |
| 213 | "trans (Fst e) = IRef (ISucc (trans e))" | |
| 214 | "trans (Snd e) = IRef (ISucc (ISucc (trans e)))" | |
| 215 | "trans (InL e) = | |
| 216 | (let limit = IRef(INat 0) in | |
| 217 | let v = (trans e) in | |
| 218 | (((ISucc limit)\<mapsto>INat(0));;(ISucc(ISucc limit)\<mapsto>v));;(INat 0 \<mapsto> ISucc(ISucc(limit))))" | |
| 219 | "trans (InR e) = | |
| 220 | (let limit = IRef(INat 0) in | |
| 221 | let v = (trans e) in | |
| 222 | (((ISucc limit)\<mapsto>INat(1));;(ISucc(ISucc limit)\<mapsto>v));;(INat 0 \<mapsto> ISucc(ISucc(limit))))" | |
| 223 | "\<lbrakk>x2\<noteq>x1; x1\<sharp>e; x1\<sharp>e2; x2\<sharp>e; x2\<sharp>e1\<rbrakk> \<Longrightarrow> | |
| 224 | trans (Case e of inl x1 \<rightarrow> e1 | inr x2 \<rightarrow> e2) = | |
| 225 | (let v = (trans e) in | |
| 226 | let v1 = (trans e1) in | |
| 227 | let v2 = (trans e2) in | |
| 228 | Iif (IRef (ISucc v)) (v2[x2::=IRef (ISucc (ISucc v))]) (v1[x1::=IRef (ISucc (ISucc v))]))" | |
| 22418 
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
 urbanc parents: 
22271diff
changeset | 229 | apply(finite_guess add: Let_def)+ | 
| 
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
 urbanc parents: 
22271diff
changeset | 230 | apply(rule TrueI)+ | 
| 
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
 urbanc parents: 
22271diff
changeset | 231 | apply(simp add: abs_fresh Isubst_fresh)+ | 
| 
49e2d9744ae1
major update of the nominal package; there is now an infrastructure
 urbanc parents: 
22271diff
changeset | 232 | apply(fresh_guess add: Let_def)+ | 
| 21543 | 233 | done | 
| 20606 
fd9b0b78a7d3
this file contains a compile-challenge suggested by Adam Chlipala;
 urbanc parents: diff
changeset | 234 | |
| 21543 | 235 | consts trans_type :: "ty \<Rightarrow> tyI" | 
| 236 | ||
| 237 | nominal_primrec | |
| 238 | "trans_type (Data \<sigma>) = DataI(NatI)" | |
| 239 | "trans_type (\<tau>1\<rightarrow>\<tau>2) = (trans_type \<tau>1)\<rightarrow>(trans_type \<tau>2)" | |
| 240 | by (rule TrueI)+ | |
| 20606 
fd9b0b78a7d3
this file contains a compile-challenge suggested by Adam Chlipala;
 urbanc parents: diff
changeset | 241 | |
| 
fd9b0b78a7d3
this file contains a compile-challenge suggested by Adam Chlipala;
 urbanc parents: diff
changeset | 242 | end |