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-- |
3138
b47301ebb3ca
Defining nominal functions without FCB
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff
changeset
|
1 |
theory Lambda imports "../Nominal2" begin |
b47301ebb3ca
Defining nominal functions without FCB
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff
changeset
|
2 |
|
b47301ebb3ca
Defining nominal functions without FCB
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff
changeset
|
3 |
atom_decl name |
b47301ebb3ca
Defining nominal functions without FCB
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff
changeset
|
4 |
|
b47301ebb3ca
Defining nominal functions without FCB
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff
changeset
|
5 |
nominal_datatype lam = |
b47301ebb3ca
Defining nominal functions without FCB
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff
changeset
|
6 |
Var "name" |
b47301ebb3ca
Defining nominal functions without FCB
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff
changeset
|
7 |
| App "lam" "lam" |
b47301ebb3ca
Defining nominal functions without FCB
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff
changeset
|
8 |
| Lam x::"name" l::"lam" binds x in l ("Lam [_]. _" [100, 100] 100) |
b47301ebb3ca
Defining nominal functions without FCB
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff
changeset
|
9 |
|
3235
5ebd327ffb96
changed nominal_primrec into the more appropriate nominal_function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
3143
diff
changeset
|
10 |
nominal_function lam_rec :: |
3138
b47301ebb3ca
Defining nominal functions without FCB
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff
changeset
|
11 |
"(name \<Rightarrow> 'a :: pt) \<Rightarrow> (lam \<Rightarrow> lam \<Rightarrow> 'a) \<Rightarrow> (name \<Rightarrow> lam \<Rightarrow> 'a) \<Rightarrow> 'a \<Rightarrow> 'b :: fs \<Rightarrow> lam \<Rightarrow> 'a" |
b47301ebb3ca
Defining nominal functions without FCB
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff
changeset
|
12 |
where |
b47301ebb3ca
Defining nominal functions without FCB
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff
changeset
|
13 |
"lam_rec fv fa fl fd P (Var n) = fv n" |
b47301ebb3ca
Defining nominal functions without FCB
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff
changeset
|
14 |
| "lam_rec fv fa fl fd P (App l r) = fa l r" |
b47301ebb3ca
Defining nominal functions without FCB
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff
changeset
|
15 |
| "(atom x \<sharp> P \<and> (\<forall>y s. atom y \<sharp> P \<longrightarrow> Lam [x]. t = Lam [y]. s \<longrightarrow> fl x t = fl y s)) \<Longrightarrow> |
b47301ebb3ca
Defining nominal functions without FCB
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff
changeset
|
16 |
lam_rec fv fa fl fd P (Lam [x]. t) = fl x t" |
b47301ebb3ca
Defining nominal functions without FCB
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff
changeset
|
17 |
| "(atom x \<sharp> P \<and> \<not>(\<forall>y s. atom y \<sharp> P \<longrightarrow> Lam [x]. t = Lam [y]. s \<longrightarrow> fl x t = fl y s)) \<Longrightarrow> |
b47301ebb3ca
Defining nominal functions without FCB
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff
changeset
|
18 |
lam_rec fv fa fl fd P (Lam [x]. t) = fd" |
b47301ebb3ca
Defining nominal functions without FCB
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff
changeset
|
19 |
apply (simp add: eqvt_def lam_rec_graph_def) |
b47301ebb3ca
Defining nominal functions without FCB
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff
changeset
|
20 |
apply (rule, perm_simp, rule, rule) |
b47301ebb3ca
Defining nominal functions without FCB
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff
changeset
|
21 |
apply (case_tac x) |
b47301ebb3ca
Defining nominal functions without FCB
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff
changeset
|
22 |
apply (rule_tac y="f" and c="e" in lam.strong_exhaust) |
b47301ebb3ca
Defining nominal functions without FCB
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff
changeset
|
23 |
apply metis |
b47301ebb3ca
Defining nominal functions without FCB
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff
changeset
|
24 |
apply metis |
b47301ebb3ca
Defining nominal functions without FCB
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff
changeset
|
25 |
unfolding fresh_star_def |
b47301ebb3ca
Defining nominal functions without FCB
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff
changeset
|
26 |
apply simp |
b47301ebb3ca
Defining nominal functions without FCB
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff
changeset
|
27 |
apply metis |
b47301ebb3ca
Defining nominal functions without FCB
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff
changeset
|
28 |
apply simp_all[2] |
b47301ebb3ca
Defining nominal functions without FCB
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff
changeset
|
29 |
apply (metis (no_types) Pair_inject lam.distinct)+ |
b47301ebb3ca
Defining nominal functions without FCB
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff
changeset
|
30 |
apply simp |
b47301ebb3ca
Defining nominal functions without FCB
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff
changeset
|
31 |
apply (metis (no_types) Pair_inject lam.distinct)+ |
b47301ebb3ca
Defining nominal functions without FCB
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff
changeset
|
32 |
done |
b47301ebb3ca
Defining nominal functions without FCB
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff
changeset
|
33 |
|
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
|
34 |
nominal_termination (eqvt) by lexicographic_order |
3138
b47301ebb3ca
Defining nominal functions without FCB
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff
changeset
|
35 |
|
b47301ebb3ca
Defining nominal functions without FCB
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff
changeset
|
36 |
lemma lam_rec_cong[fundef_cong]: |
b47301ebb3ca
Defining nominal functions without FCB
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff
changeset
|
37 |
" (\<And>v. l = Var v \<Longrightarrow> fv v = fv' v) \<Longrightarrow> |
b47301ebb3ca
Defining nominal functions without FCB
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff
changeset
|
38 |
(\<And>t1 t2. l = App t1 t2 \<Longrightarrow> fa t1 t2 = fa' t1 t2) \<Longrightarrow> |
b47301ebb3ca
Defining nominal functions without FCB
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff
changeset
|
39 |
(\<And>n t. l = Lam [n]. t \<Longrightarrow> fl n t = fl' n t) \<Longrightarrow> |
b47301ebb3ca
Defining nominal functions without FCB
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff
changeset
|
40 |
lam_rec fv fa fl fd P l = lam_rec fv' fa' fl' fd P l" |
b47301ebb3ca
Defining nominal functions without FCB
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff
changeset
|
41 |
apply (rule_tac y="l" and c="P" in lam.strong_exhaust) |
b47301ebb3ca
Defining nominal functions without FCB
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff
changeset
|
42 |
apply auto |
b47301ebb3ca
Defining nominal functions without FCB
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff
changeset
|
43 |
apply (case_tac "(\<forall>y s. atom y \<sharp> P \<longrightarrow> Lam [name]. lam = Lam [y]. s \<longrightarrow> fl name lam = fl y s)") |
b47301ebb3ca
Defining nominal functions without FCB
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff
changeset
|
44 |
apply (subst lam_rec.simps) apply (simp add: fresh_star_def) |
b47301ebb3ca
Defining nominal functions without FCB
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff
changeset
|
45 |
apply (subst lam_rec.simps) apply (simp add: fresh_star_def) |
b47301ebb3ca
Defining nominal functions without FCB
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff
changeset
|
46 |
using Abs1_eq_iff lam.eq_iff apply metis |
b47301ebb3ca
Defining nominal functions without FCB
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff
changeset
|
47 |
apply (subst lam_rec.simps(4)) apply (simp add: fresh_star_def) |
b47301ebb3ca
Defining nominal functions without FCB
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff
changeset
|
48 |
apply (subst lam_rec.simps(4)) apply (simp add: fresh_star_def) |
b47301ebb3ca
Defining nominal functions without FCB
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff
changeset
|
49 |
using Abs1_eq_iff lam.eq_iff apply metis |
b47301ebb3ca
Defining nominal functions without FCB
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff
changeset
|
50 |
done |
b47301ebb3ca
Defining nominal functions without FCB
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff
changeset
|
51 |
|
3235
5ebd327ffb96
changed nominal_primrec into the more appropriate nominal_function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
3143
diff
changeset
|
52 |
nominal_function substr where |
3138
b47301ebb3ca
Defining nominal functions without FCB
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff
changeset
|
53 |
[simp del]: "substr l y s = lam_rec |
b47301ebb3ca
Defining nominal functions without FCB
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff
changeset
|
54 |
(%x. if x = y then s else (Var x)) |
b47301ebb3ca
Defining nominal functions without FCB
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff
changeset
|
55 |
(%t1 t2. App (substr t1 y s) (substr t2 y s)) |
b47301ebb3ca
Defining nominal functions without FCB
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff
changeset
|
56 |
(%x t. Lam [x]. (substr t y s)) (Lam [y]. Var y) (y, s) l" |
b47301ebb3ca
Defining nominal functions without FCB
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff
changeset
|
57 |
unfolding eqvt_def substr_graph_def |
b47301ebb3ca
Defining nominal functions without FCB
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff
changeset
|
58 |
apply (rule, perm_simp, rule, rule) |
b47301ebb3ca
Defining nominal functions without FCB
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff
changeset
|
59 |
by pat_completeness auto |
b47301ebb3ca
Defining nominal functions without FCB
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff
changeset
|
60 |
|
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
|
61 |
nominal_termination (eqvt) by lexicographic_order |
3138
b47301ebb3ca
Defining nominal functions without FCB
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff
changeset
|
62 |
|
b47301ebb3ca
Defining nominal functions without FCB
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff
changeset
|
63 |
lemma fresh_fun_eqvt_app3: |
b47301ebb3ca
Defining nominal functions without FCB
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff
changeset
|
64 |
assumes e: "eqvt f" |
b47301ebb3ca
Defining nominal functions without FCB
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff
changeset
|
65 |
shows "\<lbrakk>a \<sharp> x; a \<sharp> y; a \<sharp> z\<rbrakk> \<Longrightarrow> a \<sharp> f x y z" |
b47301ebb3ca
Defining nominal functions without FCB
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff
changeset
|
66 |
using fresh_fun_eqvt_app[OF e] fresh_fun_app by (metis (lifting, full_types)) |
b47301ebb3ca
Defining nominal functions without FCB
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff
changeset
|
67 |
|
3143
1da802bd2ab1
Correct Aux and proof sketch that it's same as alpha-equality, following Dan Synek's proof.
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
3138
diff
changeset
|
68 |
lemma substr_simps: |
3138
b47301ebb3ca
Defining nominal functions without FCB
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff
changeset
|
69 |
"substr (Var x) y s = (if x = y then s else (Var x))" |
b47301ebb3ca
Defining nominal functions without FCB
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff
changeset
|
70 |
"substr (App t1 t2) y s = App (substr t1 y s) (substr t2 y s)" |
b47301ebb3ca
Defining nominal functions without FCB
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff
changeset
|
71 |
"atom x \<sharp> (y, s) \<Longrightarrow> substr (Lam [x]. t) y s = Lam [x]. (substr t y s)" |
b47301ebb3ca
Defining nominal functions without FCB
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff
changeset
|
72 |
apply (subst substr.simps) apply (simp only: lam_rec.simps) |
b47301ebb3ca
Defining nominal functions without FCB
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff
changeset
|
73 |
apply (subst substr.simps) apply (simp only: lam_rec.simps) |
b47301ebb3ca
Defining nominal functions without FCB
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff
changeset
|
74 |
apply (subst substr.simps) apply (subst lam_rec.simps) |
b47301ebb3ca
Defining nominal functions without FCB
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff
changeset
|
75 |
apply (auto simp add: Abs1_eq_iff substr.eqvt swap_fresh_fresh) |
b47301ebb3ca
Defining nominal functions without FCB
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff
changeset
|
76 |
apply (rule fresh_fun_eqvt_app3[of substr]) |
b47301ebb3ca
Defining nominal functions without FCB
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff
changeset
|
77 |
apply (simp add: eqvt_def eqvts_raw) |
b47301ebb3ca
Defining nominal functions without FCB
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff
changeset
|
78 |
apply (simp_all add: fresh_Pair) |
b47301ebb3ca
Defining nominal functions without FCB
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff
changeset
|
79 |
done |
b47301ebb3ca
Defining nominal functions without FCB
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff
changeset
|
80 |
|
b47301ebb3ca
Defining nominal functions without FCB
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff
changeset
|
81 |
end |
b47301ebb3ca
Defining nominal functions without FCB
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff
changeset
|
82 |
|
b47301ebb3ca
Defining nominal functions without FCB
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff
changeset
|
83 |
|
b47301ebb3ca
Defining nominal functions without FCB
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff
changeset
|
84 |