author | Christian Urban <christian dot urban at kcl dot ac dot uk> |
Mon, 19 May 2014 16:45:46 +0100 | |
changeset 3236 | e2da10806a34 |
parent 3235 | 5ebd327ffb96 |
permissions | -rw-r--r-- |
3217
d67a6a48f1c7
added example for locales (by Tjark Weber)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1 |
theory Local_Contexts |
d67a6a48f1c7
added example for locales (by Tjark Weber)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2 |
imports "../Nominal2" |
d67a6a48f1c7
added example for locales (by Tjark Weber)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
3 |
begin |
d67a6a48f1c7
added example for locales (by Tjark Weber)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
4 |
|
d67a6a48f1c7
added example for locales (by Tjark Weber)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
5 |
text {* |
d67a6a48f1c7
added example for locales (by Tjark Weber)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
6 |
This theory, contributed by Tjark Weber, contains examples |
d67a6a48f1c7
added example for locales (by Tjark Weber)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
7 |
and test cases that illustrate the useof Nominal2 in local |
d67a6a48f1c7
added example for locales (by Tjark Weber)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
8 |
contexts (locales, type classes, etc.). |
d67a6a48f1c7
added example for locales (by Tjark Weber)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
9 |
|
d67a6a48f1c7
added example for locales (by Tjark Weber)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
10 |
As a running example, we use a variant of the untyped lambda-calculus |
d67a6a48f1c7
added example for locales (by Tjark Weber)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
11 |
whose lambda-binder binds lists of names, rather than single names. |
d67a6a48f1c7
added example for locales (by Tjark Weber)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
12 |
*} |
d67a6a48f1c7
added example for locales (by Tjark Weber)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
13 |
|
d67a6a48f1c7
added example for locales (by Tjark Weber)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
14 |
atom_decl name |
d67a6a48f1c7
added example for locales (by Tjark Weber)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
15 |
|
d67a6a48f1c7
added example for locales (by Tjark Weber)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
16 |
nominal_datatype lam = Var name |
d67a6a48f1c7
added example for locales (by Tjark Weber)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
17 |
| App lam lam ("_ \<cdot> _" [110,110] 110) |
d67a6a48f1c7
added example for locales (by Tjark Weber)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
18 |
| Lam xs::"name list" t::lam binds xs in t ("Lam _. _" [100,100] 100) |
d67a6a48f1c7
added example for locales (by Tjark Weber)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
19 |
|
d67a6a48f1c7
added example for locales (by Tjark Weber)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
20 |
locale name_subst = |
d67a6a48f1c7
added example for locales (by Tjark Weber)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
21 |
fixes name_subst :: "name \<Rightarrow> name list \<Rightarrow> lam \<Rightarrow> lam" |
d67a6a48f1c7
added example for locales (by Tjark Weber)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
22 |
assumes name_subst_eqvt [eqvt]: |
d67a6a48f1c7
added example for locales (by Tjark Weber)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
23 |
"p \<bullet> name_subst x xs t = name_subst (p \<bullet> x) (p \<bullet> xs) (p \<bullet> t)" |
d67a6a48f1c7
added example for locales (by Tjark Weber)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
24 |
and name_subst_fresh: "supp xs \<sharp>* t \<Longrightarrow> supp xs \<sharp>* name_subst x xs t" |
d67a6a48f1c7
added example for locales (by Tjark Weber)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
25 |
|
d67a6a48f1c7
added example for locales (by Tjark Weber)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
26 |
lemma set_map_atom_eq_supp: "set (map atom xs) = supp xs" |
d67a6a48f1c7
added example for locales (by Tjark Weber)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
27 |
by (metis List.finite_set image_set supp_finite_set_at_base supp_set) |
d67a6a48f1c7
added example for locales (by Tjark Weber)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
28 |
|
d67a6a48f1c7
added example for locales (by Tjark Weber)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
29 |
lemma atom_image_set_eq_supp: "atom ` set xs = supp xs" |
d67a6a48f1c7
added example for locales (by Tjark Weber)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
30 |
by (metis image_set set_map_atom_eq_supp) |
d67a6a48f1c7
added example for locales (by Tjark Weber)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
31 |
|
3235
5ebd327ffb96
changed nominal_primrec into the more appropriate nominal_function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
3217
diff
changeset
|
32 |
nominal_function (in name_subst) |
3217
d67a6a48f1c7
added example for locales (by Tjark Weber)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
33 |
subst :: "lam \<Rightarrow> name list \<Rightarrow> lam \<Rightarrow> lam" ("_[_::=_]" [120,120,120] 120) |
d67a6a48f1c7
added example for locales (by Tjark Weber)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
34 |
where |
d67a6a48f1c7
added example for locales (by Tjark Weber)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
35 |
"(Var x)[xs::=t] = name_subst x xs t" |
d67a6a48f1c7
added example for locales (by Tjark Weber)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
36 |
| "(s \<cdot> t)[xs::=u] = s[xs::=u] \<cdot> t[xs::=u]" |
d67a6a48f1c7
added example for locales (by Tjark Weber)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
37 |
| "\<lbrakk>supp xs \<sharp>* ys; supp xs \<sharp>* u\<rbrakk> \<Longrightarrow> (Lam xs. t)[ys::=u] = Lam xs. t[ys::=u]" |
d67a6a48f1c7
added example for locales (by Tjark Weber)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
38 |
apply auto |
d67a6a48f1c7
added example for locales (by Tjark Weber)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
39 |
-- {* 3 subgoals *} |
d67a6a48f1c7
added example for locales (by Tjark Weber)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
40 |
-- {* eqvt *} |
d67a6a48f1c7
added example for locales (by Tjark Weber)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
41 |
apply (unfold eqvt_def subst_graph_def subst_graph_aux_def) |
d67a6a48f1c7
added example for locales (by Tjark Weber)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
42 |
apply (rule, perm_simp, rule) |
d67a6a48f1c7
added example for locales (by Tjark Weber)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
43 |
-- {* exhaustion *} |
d67a6a48f1c7
added example for locales (by Tjark Weber)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
44 |
apply (rule_tac y=a and c="(aa, b)" in lam.strong_exhaust) |
d67a6a48f1c7
added example for locales (by Tjark Weber)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
45 |
apply auto |
d67a6a48f1c7
added example for locales (by Tjark Weber)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
46 |
apply (metis atom_image_set_eq_supp fresh_star_Pair) |
d67a6a48f1c7
added example for locales (by Tjark Weber)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
47 |
-- {* well-defined (compatibility) *} |
d67a6a48f1c7
added example for locales (by Tjark Weber)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
48 |
apply (rename_tac xs' ys u t') |
d67a6a48f1c7
added example for locales (by Tjark Weber)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
49 |
apply (erule Abs_lst_fcb2) |
d67a6a48f1c7
added example for locales (by Tjark Weber)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
50 |
apply (metis Abs_fresh_star(3) subset_refl) |
d67a6a48f1c7
added example for locales (by Tjark Weber)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
51 |
apply (metis fresh_star_Pair set_map_atom_eq_supp) |
d67a6a48f1c7
added example for locales (by Tjark Weber)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
52 |
apply (metis fresh_star_Pair set_map_atom_eq_supp) |
d67a6a48f1c7
added example for locales (by Tjark Weber)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
53 |
apply (auto simp add: eqvt_at_def) |
d67a6a48f1c7
added example for locales (by Tjark Weber)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
54 |
apply (metis Pair_eqvt perm_supp_eq) |
d67a6a48f1c7
added example for locales (by Tjark Weber)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
55 |
apply (metis Pair_eqvt perm_supp_eq) |
d67a6a48f1c7
added example for locales (by Tjark Weber)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
56 |
done |
d67a6a48f1c7
added example for locales (by Tjark Weber)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
57 |
|
3236
e2da10806a34
changed nominal_primrec to nominal_function and termination to nominal_termination
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
3235
diff
changeset
|
58 |
nominal_termination (in name_subst) (eqvt) by lexicographic_order |
3217
d67a6a48f1c7
added example for locales (by Tjark Weber)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
59 |
|
d67a6a48f1c7
added example for locales (by Tjark Weber)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
60 |
inductive (in name_subst) beta :: "lam \<Rightarrow> lam \<Rightarrow> bool" (infix "\<longrightarrow>\<^sub>\<beta>" 90) |
d67a6a48f1c7
added example for locales (by Tjark Weber)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
61 |
where |
d67a6a48f1c7
added example for locales (by Tjark Weber)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
62 |
redex: "supp xs \<sharp>* u \<Longrightarrow> (Lam xs. t) \<cdot> u \<longrightarrow>\<^sub>\<beta> t[xs::=u]" |
d67a6a48f1c7
added example for locales (by Tjark Weber)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
63 |
| "s \<longrightarrow>\<^sub>\<beta> s' \<Longrightarrow> s \<cdot> t \<longrightarrow>\<^sub>\<beta> s' \<cdot> t" |
d67a6a48f1c7
added example for locales (by Tjark Weber)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
64 |
| "t \<longrightarrow>\<^sub>\<beta> t' \<Longrightarrow> s \<cdot> t \<longrightarrow>\<^sub>\<beta> s \<cdot> t'" |
d67a6a48f1c7
added example for locales (by Tjark Weber)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
65 |
|
d67a6a48f1c7
added example for locales (by Tjark Weber)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
66 |
equivariance (in name_subst) beta |
d67a6a48f1c7
added example for locales (by Tjark Weber)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
67 |
|
d67a6a48f1c7
added example for locales (by Tjark Weber)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
68 |
|
d67a6a48f1c7
added example for locales (by Tjark Weber)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
69 |
lemma lam_bound_fresh: "supp xs \<sharp>* (Lam xs. t)" |
d67a6a48f1c7
added example for locales (by Tjark Weber)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
70 |
by (simp add: atom_image_set_eq_supp fresh_star_def) |
d67a6a48f1c7
added example for locales (by Tjark Weber)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
71 |
|
d67a6a48f1c7
added example for locales (by Tjark Weber)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
72 |
|
d67a6a48f1c7
added example for locales (by Tjark Weber)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
73 |
lemma (in name_subst) subst_fresh: "supp xs \<sharp>* u \<Longrightarrow> supp xs \<sharp>* t[xs::=u]" |
d67a6a48f1c7
added example for locales (by Tjark Weber)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
74 |
apply (nominal_induct t avoiding: xs u rule: lam.strong_induct) |
d67a6a48f1c7
added example for locales (by Tjark Weber)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
75 |
apply (simp_all add: atom_image_set_eq_supp) |
d67a6a48f1c7
added example for locales (by Tjark Weber)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
76 |
apply (metis name_subst_fresh) |
d67a6a48f1c7
added example for locales (by Tjark Weber)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
77 |
apply (metis fresh_star_def lam.fresh(2)) |
d67a6a48f1c7
added example for locales (by Tjark Weber)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
78 |
apply (simp add: fresh_star_def) |
d67a6a48f1c7
added example for locales (by Tjark Weber)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
79 |
done |
d67a6a48f1c7
added example for locales (by Tjark Weber)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
80 |
|
d67a6a48f1c7
added example for locales (by Tjark Weber)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
81 |
nominal_inductive (in name_subst) beta |
d67a6a48f1c7
added example for locales (by Tjark Weber)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
82 |
avoids |
d67a6a48f1c7
added example for locales (by Tjark Weber)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
83 |
redex: xs |
d67a6a48f1c7
added example for locales (by Tjark Weber)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
84 |
apply (auto simp add: fresh_star_Pair) |
d67a6a48f1c7
added example for locales (by Tjark Weber)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
85 |
apply (metis atom_image_set_eq_supp fresh_star_def lam.fresh(2) lam_bound_fresh) |
d67a6a48f1c7
added example for locales (by Tjark Weber)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
86 |
apply (simp add: atom_image_set_eq_supp subst_fresh) |
d67a6a48f1c7
added example for locales (by Tjark Weber)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
87 |
done |
d67a6a48f1c7
added example for locales (by Tjark Weber)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
88 |
|
d67a6a48f1c7
added example for locales (by Tjark Weber)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
89 |
end |