author | Christian Urban <urbanc@in.tum.de> |
Wed, 19 Jan 2011 19:41:50 +0100 | |
changeset 2685 | 1df873b63cb2 |
parent 2676 | 028d5511c15f |
child 2707 | 747ebf2f066d |
permissions | -rw-r--r-- |
1795 | 1 |
theory TypeSchemes |
2454
9ffee4eb1ae1
renamed NewParser to Nominal2
Christian Urban <urbanc@in.tum.de>
parents:
2451
diff
changeset
|
2 |
imports "../Nominal2" |
1795 | 3 |
begin |
4 |
||
5 |
section {*** Type Schemes ***} |
|
6 |
||
2556
8ed62410236e
added a test about subtyping; disabled two tests, because of problem with function package
Christian Urban <urbanc@in.tum.de>
parents:
2524
diff
changeset
|
7 |
atom_decl name |
8ed62410236e
added a test about subtyping; disabled two tests, because of problem with function package
Christian Urban <urbanc@in.tum.de>
parents:
2524
diff
changeset
|
8 |
|
2486
b4ea19604b0b
cleaned up two examples
Christian Urban <urbanc@in.tum.de>
parents:
2480
diff
changeset
|
9 |
(* defined as a single nominal datatype *) |
1795 | 10 |
|
11 |
nominal_datatype ty = |
|
12 |
Var "name" |
|
13 |
| Fun "ty" "ty" |
|
14 |
and tys = |
|
2634
3ce1089cdbf3
changed res keyword to set+ for restrictions; comment by a referee
Christian Urban <urbanc@in.tum.de>
parents:
2630
diff
changeset
|
15 |
All xs::"name fset" ty::"ty" bind (set+) xs in ty |
2434 | 16 |
|
2468 | 17 |
thm ty_tys.distinct |
18 |
thm ty_tys.induct |
|
2617
e44551d067e6
properly exported strong exhaust theorem; cleaned up some examples
Christian Urban <urbanc@in.tum.de>
parents:
2611
diff
changeset
|
19 |
thm ty_tys.inducts |
e44551d067e6
properly exported strong exhaust theorem; cleaned up some examples
Christian Urban <urbanc@in.tum.de>
parents:
2611
diff
changeset
|
20 |
thm ty_tys.exhaust ty_tys.strong_exhaust |
2468 | 21 |
thm ty_tys.fv_defs |
22 |
thm ty_tys.bn_defs |
|
23 |
thm ty_tys.perm_simps |
|
24 |
thm ty_tys.eq_iff |
|
25 |
thm ty_tys.fv_bn_eqvt |
|
26 |
thm ty_tys.size_eqvt |
|
27 |
thm ty_tys.supports |
|
2493
2e174807c891
added postprocessed fresh-lemmas for constructors
Christian Urban <urbanc@in.tum.de>
parents:
2486
diff
changeset
|
28 |
thm ty_tys.supp |
2494
11133eb76f61
added Foo1 to explore a contrived example
Christian Urban <urbanc@in.tum.de>
parents:
2493
diff
changeset
|
29 |
thm ty_tys.fresh |
1795 | 30 |
|
2676
028d5511c15f
some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents:
2634
diff
changeset
|
31 |
|
028d5511c15f
some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents:
2634
diff
changeset
|
32 |
section {* defined as two separate nominal datatypes *} |
2486
b4ea19604b0b
cleaned up two examples
Christian Urban <urbanc@in.tum.de>
parents:
2480
diff
changeset
|
33 |
|
2308
387fcbd33820
fixed problem with bn_info
Christian Urban <urbanc@in.tum.de>
parents:
2181
diff
changeset
|
34 |
nominal_datatype ty2 = |
387fcbd33820
fixed problem with bn_info
Christian Urban <urbanc@in.tum.de>
parents:
2181
diff
changeset
|
35 |
Var2 "name" |
387fcbd33820
fixed problem with bn_info
Christian Urban <urbanc@in.tum.de>
parents:
2181
diff
changeset
|
36 |
| Fun2 "ty2" "ty2" |
387fcbd33820
fixed problem with bn_info
Christian Urban <urbanc@in.tum.de>
parents:
2181
diff
changeset
|
37 |
|
387fcbd33820
fixed problem with bn_info
Christian Urban <urbanc@in.tum.de>
parents:
2181
diff
changeset
|
38 |
nominal_datatype tys2 = |
2634
3ce1089cdbf3
changed res keyword to set+ for restrictions; comment by a referee
Christian Urban <urbanc@in.tum.de>
parents:
2630
diff
changeset
|
39 |
All2 xs::"name fset" ty::"ty2" bind (set+) xs in ty |
2337
b151399bd2c3
fixed according to changes in quotient
Christian Urban <urbanc@in.tum.de>
parents:
2308
diff
changeset
|
40 |
|
2468 | 41 |
thm tys2.distinct |
2630
8268b277d240
automated all strong induction lemmas
Christian Urban <urbanc@in.tum.de>
parents:
2622
diff
changeset
|
42 |
thm tys2.induct tys2.strong_induct |
2617
e44551d067e6
properly exported strong exhaust theorem; cleaned up some examples
Christian Urban <urbanc@in.tum.de>
parents:
2611
diff
changeset
|
43 |
thm tys2.exhaust tys2.strong_exhaust |
2468 | 44 |
thm tys2.fv_defs |
45 |
thm tys2.bn_defs |
|
46 |
thm tys2.perm_simps |
|
47 |
thm tys2.eq_iff |
|
48 |
thm tys2.fv_bn_eqvt |
|
49 |
thm tys2.size_eqvt |
|
50 |
thm tys2.supports |
|
2493
2e174807c891
added postprocessed fresh-lemmas for constructors
Christian Urban <urbanc@in.tum.de>
parents:
2486
diff
changeset
|
51 |
thm tys2.supp |
2494
11133eb76f61
added Foo1 to explore a contrived example
Christian Urban <urbanc@in.tum.de>
parents:
2493
diff
changeset
|
52 |
thm tys2.fresh |
2468 | 53 |
|
2676
028d5511c15f
some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents:
2634
diff
changeset
|
54 |
fun |
028d5511c15f
some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents:
2634
diff
changeset
|
55 |
lookup :: "(name \<times> ty2) list \<Rightarrow> name \<Rightarrow> ty2" |
028d5511c15f
some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents:
2634
diff
changeset
|
56 |
where |
028d5511c15f
some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents:
2634
diff
changeset
|
57 |
"lookup [] Y = Var2 Y" |
028d5511c15f
some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents:
2634
diff
changeset
|
58 |
| "lookup ((X, T) # Ts) Y = (if X = Y then T else lookup Ts Y)" |
2556
8ed62410236e
added a test about subtyping; disabled two tests, because of problem with function package
Christian Urban <urbanc@in.tum.de>
parents:
2524
diff
changeset
|
59 |
|
2676
028d5511c15f
some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents:
2634
diff
changeset
|
60 |
lemma lookup_eqvt[eqvt]: |
028d5511c15f
some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents:
2634
diff
changeset
|
61 |
shows "(p \<bullet> lookup Ts T) = lookup (p \<bullet> Ts) (p \<bullet> T)" |
028d5511c15f
some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents:
2634
diff
changeset
|
62 |
apply(induct Ts T rule: lookup.induct) |
028d5511c15f
some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents:
2634
diff
changeset
|
63 |
apply(simp_all) |
028d5511c15f
some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents:
2634
diff
changeset
|
64 |
done |
028d5511c15f
some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents:
2634
diff
changeset
|
65 |
|
028d5511c15f
some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents:
2634
diff
changeset
|
66 |
function |
028d5511c15f
some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents:
2634
diff
changeset
|
67 |
subst :: "(name \<times> ty2) list \<Rightarrow> ty2 \<Rightarrow> ty2" |
028d5511c15f
some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents:
2634
diff
changeset
|
68 |
where |
028d5511c15f
some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents:
2634
diff
changeset
|
69 |
"subst \<theta> (Var2 X) = lookup \<theta> X" |
028d5511c15f
some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents:
2634
diff
changeset
|
70 |
| "subst \<theta> (Fun2 T1 T2) = Fun2 (subst \<theta> T1) (subst \<theta> T2)" |
028d5511c15f
some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents:
2634
diff
changeset
|
71 |
apply(case_tac x) |
028d5511c15f
some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents:
2634
diff
changeset
|
72 |
apply(simp) |
028d5511c15f
some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents:
2634
diff
changeset
|
73 |
apply(rule_tac y="b" in ty2.exhaust) |
028d5511c15f
some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents:
2634
diff
changeset
|
74 |
apply(blast) |
028d5511c15f
some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents:
2634
diff
changeset
|
75 |
apply(blast) |
028d5511c15f
some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents:
2634
diff
changeset
|
76 |
apply(simp_all add: ty2.distinct) |
028d5511c15f
some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents:
2634
diff
changeset
|
77 |
apply(simp add: ty2.eq_iff) |
028d5511c15f
some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents:
2634
diff
changeset
|
78 |
apply(simp add: ty2.eq_iff) |
028d5511c15f
some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents:
2634
diff
changeset
|
79 |
done |
028d5511c15f
some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents:
2634
diff
changeset
|
80 |
|
028d5511c15f
some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents:
2634
diff
changeset
|
81 |
termination |
028d5511c15f
some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents:
2634
diff
changeset
|
82 |
apply(relation "measure (size o snd)") |
028d5511c15f
some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents:
2634
diff
changeset
|
83 |
apply(simp_all add: ty2.size) |
028d5511c15f
some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents:
2634
diff
changeset
|
84 |
done |
028d5511c15f
some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents:
2634
diff
changeset
|
85 |
|
028d5511c15f
some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents:
2634
diff
changeset
|
86 |
lemma subst_eqvt[eqvt]: |
028d5511c15f
some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents:
2634
diff
changeset
|
87 |
shows "(p \<bullet> subst \<theta> T) = subst (p \<bullet> \<theta>) (p \<bullet> T)" |
028d5511c15f
some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents:
2634
diff
changeset
|
88 |
apply(induct \<theta> T rule: subst.induct) |
028d5511c15f
some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents:
2634
diff
changeset
|
89 |
apply(simp_all add: lookup_eqvt) |
028d5511c15f
some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents:
2634
diff
changeset
|
90 |
done |
028d5511c15f
some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents:
2634
diff
changeset
|
91 |
|
028d5511c15f
some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents:
2634
diff
changeset
|
92 |
lemma j: |
028d5511c15f
some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents:
2634
diff
changeset
|
93 |
assumes "a \<sharp> Ts" " a \<sharp> X" |
028d5511c15f
some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents:
2634
diff
changeset
|
94 |
shows "a \<sharp> lookup Ts X" |
028d5511c15f
some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents:
2634
diff
changeset
|
95 |
using assms |
028d5511c15f
some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents:
2634
diff
changeset
|
96 |
apply(induct Ts X rule: lookup.induct) |
028d5511c15f
some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents:
2634
diff
changeset
|
97 |
apply(auto simp add: ty2.fresh fresh_Cons fresh_Pair) |
028d5511c15f
some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents:
2634
diff
changeset
|
98 |
done |
028d5511c15f
some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents:
2634
diff
changeset
|
99 |
|
028d5511c15f
some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents:
2634
diff
changeset
|
100 |
lemma i: |
028d5511c15f
some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents:
2634
diff
changeset
|
101 |
assumes "a \<sharp> t" " a \<sharp> \<theta>" |
028d5511c15f
some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents:
2634
diff
changeset
|
102 |
shows "a \<sharp> subst \<theta> t" |
028d5511c15f
some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents:
2634
diff
changeset
|
103 |
using assms |
028d5511c15f
some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents:
2634
diff
changeset
|
104 |
apply(induct \<theta> t rule: subst.induct) |
028d5511c15f
some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents:
2634
diff
changeset
|
105 |
apply(auto simp add: ty2.fresh j) |
028d5511c15f
some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents:
2634
diff
changeset
|
106 |
done |
028d5511c15f
some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents:
2634
diff
changeset
|
107 |
|
028d5511c15f
some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents:
2634
diff
changeset
|
108 |
lemma k: |
028d5511c15f
some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents:
2634
diff
changeset
|
109 |
assumes "as \<sharp>* t" " as \<sharp>* \<theta>" |
028d5511c15f
some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents:
2634
diff
changeset
|
110 |
shows "as \<sharp>* subst \<theta> t" |
028d5511c15f
some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents:
2634
diff
changeset
|
111 |
using assms |
028d5511c15f
some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents:
2634
diff
changeset
|
112 |
by (simp add: fresh_star_def i) |
028d5511c15f
some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents:
2634
diff
changeset
|
113 |
|
028d5511c15f
some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents:
2634
diff
changeset
|
114 |
lemma h: |
028d5511c15f
some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents:
2634
diff
changeset
|
115 |
assumes "as \<subseteq> bs \<union> cs" |
028d5511c15f
some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents:
2634
diff
changeset
|
116 |
and " cs \<sharp>* x" |
028d5511c15f
some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents:
2634
diff
changeset
|
117 |
shows "(as - bs) \<sharp>* x" |
028d5511c15f
some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents:
2634
diff
changeset
|
118 |
using assms |
028d5511c15f
some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents:
2634
diff
changeset
|
119 |
by (auto simp add: fresh_star_def) |
028d5511c15f
some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents:
2634
diff
changeset
|
120 |
|
028d5511c15f
some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents:
2634
diff
changeset
|
121 |
nominal_primrec |
028d5511c15f
some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents:
2634
diff
changeset
|
122 |
substs :: "(name \<times> ty2) list \<Rightarrow> tys2 \<Rightarrow> tys2" |
028d5511c15f
some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents:
2634
diff
changeset
|
123 |
where |
028d5511c15f
some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents:
2634
diff
changeset
|
124 |
"fset (map_fset atom xs) \<sharp>* \<theta> \<Longrightarrow> substs \<theta> (All2 xs t) = All2 xs (subst \<theta> t)" |
028d5511c15f
some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents:
2634
diff
changeset
|
125 |
oops |
028d5511c15f
some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents:
2634
diff
changeset
|
126 |
|
028d5511c15f
some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents:
2634
diff
changeset
|
127 |
|
028d5511c15f
some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents:
2634
diff
changeset
|
128 |
text {* Some Tests about Alpha-Equality *} |
1795 | 129 |
|
130 |
lemma |
|
131 |
shows "All {|a, b|} (Fun (Var a) (Var b)) = All {|b, a|} (Fun (Var a) (Var b))" |
|
2676
028d5511c15f
some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents:
2634
diff
changeset
|
132 |
apply(simp add: ty_tys.eq_iff Abs_eq_iff) |
1795 | 133 |
apply(rule_tac x="0::perm" in exI) |
2676
028d5511c15f
some tryes about substitution over type-schemes
Christian Urban <urbanc@in.tum.de>
parents:
2634
diff
changeset
|
134 |
apply(simp add: alphas fresh_star_def ty_tys.supp supp_at_base) |
1795 | 135 |
done |
136 |
||
137 |
lemma |
|
138 |
shows "All {|a, b|} (Fun (Var a) (Var b)) = All {|a, b|} (Fun (Var b) (Var a))" |
|
2566
a59d8e1e3a17
moved rest of the lemmas from Nominal2_FSet to the TypeScheme example
Christian Urban <urbanc@in.tum.de>
parents:
2556
diff
changeset
|
139 |
apply(simp add: ty_tys.eq_iff Abs_eq_iff) |
1795 | 140 |
apply(rule_tac x="(atom a \<rightleftharpoons> atom b)" in exI) |
2566
a59d8e1e3a17
moved rest of the lemmas from Nominal2_FSet to the TypeScheme example
Christian Urban <urbanc@in.tum.de>
parents:
2556
diff
changeset
|
141 |
apply(simp add: alphas fresh_star_def supp_at_base ty_tys.supp) |
1795 | 142 |
done |
143 |
||
144 |
lemma |
|
145 |
shows "All {|a, b, c|} (Fun (Var a) (Var b)) = All {|a, b|} (Fun (Var a) (Var b))" |
|
2566
a59d8e1e3a17
moved rest of the lemmas from Nominal2_FSet to the TypeScheme example
Christian Urban <urbanc@in.tum.de>
parents:
2556
diff
changeset
|
146 |
apply(simp add: ty_tys.eq_iff Abs_eq_iff) |
1795 | 147 |
apply(rule_tac x="0::perm" in exI) |
2566
a59d8e1e3a17
moved rest of the lemmas from Nominal2_FSet to the TypeScheme example
Christian Urban <urbanc@in.tum.de>
parents:
2556
diff
changeset
|
148 |
apply(simp add: alphas fresh_star_def ty_tys.supp supp_at_base) |
1795 | 149 |
done |
150 |
||
151 |
lemma |
|
152 |
assumes a: "a \<noteq> b" |
|
153 |
shows "\<not>(All {|a, b|} (Fun (Var a) (Var b)) = All {|c|} (Fun (Var c) (Var c)))" |
|
154 |
using a |
|
2566
a59d8e1e3a17
moved rest of the lemmas from Nominal2_FSet to the TypeScheme example
Christian Urban <urbanc@in.tum.de>
parents:
2556
diff
changeset
|
155 |
apply(simp add: ty_tys.eq_iff Abs_eq_iff) |
1795 | 156 |
apply(clarify) |
2566
a59d8e1e3a17
moved rest of the lemmas from Nominal2_FSet to the TypeScheme example
Christian Urban <urbanc@in.tum.de>
parents:
2556
diff
changeset
|
157 |
apply(simp add: alphas fresh_star_def ty_tys.eq_iff ty_tys.supp supp_at_base) |
1795 | 158 |
apply auto |
159 |
done |
|
160 |
||
2566
a59d8e1e3a17
moved rest of the lemmas from Nominal2_FSet to the TypeScheme example
Christian Urban <urbanc@in.tum.de>
parents:
2556
diff
changeset
|
161 |
|
1795 | 162 |
|
163 |
||
164 |
end |