985
ef8a2b0b237a
Ported existing part of LF to new permutations and alphas.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
1 |
theory LFex
|
1348
|
2 |
imports "Parser"
|
985
ef8a2b0b237a
Ported existing part of LF to new permutations and alphas.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
3 |
begin
|
ef8a2b0b237a
Ported existing part of LF to new permutations and alphas.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
4 |
|
ef8a2b0b237a
Ported existing part of LF to new permutations and alphas.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
5 |
atom_decl name
|
ef8a2b0b237a
Ported existing part of LF to new permutations and alphas.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
6 |
atom_decl ident
|
ef8a2b0b237a
Ported existing part of LF to new permutations and alphas.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
7 |
|
1360
|
8 |
ML {* restricted_nominal := 2 *}
|
1348
|
9 |
|
|
10 |
nominal_datatype kind =
|
985
ef8a2b0b237a
Ported existing part of LF to new permutations and alphas.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
11 |
Type
|
1348
|
12 |
| KPi "ty" n::"name" k::"kind" bind n in k
|
|
13 |
and ty =
|
985
ef8a2b0b237a
Ported existing part of LF to new permutations and alphas.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
14 |
TConst "ident"
|
1348
|
15 |
| TApp "ty" "trm"
|
|
16 |
| TPi "ty" n::"name" t::"ty" bind n in t
|
|
17 |
and trm =
|
985
ef8a2b0b237a
Ported existing part of LF to new permutations and alphas.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
18 |
Const "ident"
|
ef8a2b0b237a
Ported existing part of LF to new permutations and alphas.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
19 |
| Var "name"
|
1348
|
20 |
| App "trm" "trm"
|
|
21 |
| Lam "ty" n::"name" t::"trm" bind n in t
|
994
333c24bd595d
More in the LF example in the new nominal way, all is clear until support.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
|
22 |
|
1244
|
23 |
lemma supports:
|
1348
|
24 |
"{} supports Type"
|
|
25 |
"(supp (atom i)) supports (TConst i)"
|
|
26 |
"(supp A \<union> supp M) supports (TApp A M)"
|
|
27 |
"(supp (atom i)) supports (Const i)"
|
|
28 |
"(supp (atom x)) supports (Var x)"
|
|
29 |
"(supp M \<union> supp N) supports (App M N)"
|
|
30 |
"(supp ty \<union> supp (atom na) \<union> supp ki) supports (KPi ty na ki)"
|
|
31 |
"(supp ty \<union> supp (atom na) \<union> supp ty2) supports (TPi ty na ty2)"
|
|
32 |
"(supp ty \<union> supp (atom na) \<union> supp trm) supports (Lam ty na trm)"
|
|
33 |
apply(simp_all add: supports_def fresh_def[symmetric] swap_fresh_fresh kind_ty_trm_perm)
|
1244
|
34 |
apply(rule_tac [!] allI)+
|
|
35 |
apply(rule_tac [!] impI)
|
|
36 |
apply(tactic {* ALLGOALS (REPEAT o etac conjE) *})
|
|
37 |
apply(simp_all add: fresh_atom)
|
|
38 |
done
|
|
39 |
|
|
40 |
lemma kind_ty_trm_fs:
|
1348
|
41 |
"finite (supp (x\<Colon>kind)) \<and> finite (supp (y\<Colon>ty)) \<and> finite (supp (z\<Colon>trm))"
|
|
42 |
apply(induct rule: kind_ty_trm_induct)
|
1244
|
43 |
apply(tactic {* ALLGOALS (rtac @{thm supports_finite} THEN' resolve_tac @{thms supports}) *})
|
|
44 |
apply(simp_all add: supp_atom)
|
|
45 |
done
|
|
46 |
|
|
47 |
instance kind and ty and trm :: fs
|
|
48 |
apply(default)
|
|
49 |
apply(simp_all only: kind_ty_trm_fs)
|
|
50 |
done
|
|
51 |
|
1344
|
52 |
lemma ex_out:
|
|
53 |
"(\<exists>x. Z x \<and> Q) = (Q \<and> (\<exists>x. Z x))"
|
|
54 |
"(\<exists>x. Q \<and> Z x) = (Q \<and> (\<exists>x. Z x))"
|
|
55 |
"(\<exists>x. P x \<and> Q \<and> Z x) = (Q \<and> (\<exists>x. P x \<and> Z x))"
|
|
56 |
"(\<exists>x. Q \<and> P x \<and> Z x) = (Q \<and> (\<exists>x. P x \<and> Z x))"
|
|
57 |
apply (blast)+
|
|
58 |
done
|
|
59 |
|
1348
|
60 |
lemma Collect_neg_conj: "{x. \<not>(P x \<and> Q x)} = {x. \<not>(P x)} \<union> {x. \<not>(Q x)}"
|
|
61 |
by (simp add: Collect_imp_eq Collect_neg_eq[symmetric])
|
|
62 |
|
1245
|
63 |
lemma supp_eqs:
|
1348
|
64 |
"supp Type = {}"
|
|
65 |
"supp rkind = fv_kind rkind \<Longrightarrow> supp (KPi rty name rkind) = supp rty \<union> supp (Abs {atom name} rkind)"
|
|
66 |
"supp (TConst i) = {atom i}"
|
|
67 |
"supp (TApp A M) = supp A \<union> supp M"
|
|
68 |
"supp rty2 = fv_ty rty2 \<Longrightarrow> supp (TPi rty1 name rty2) = supp rty1 \<union> supp (Abs {atom name} rty2)"
|
|
69 |
"supp (Const i) = {atom i}"
|
|
70 |
"supp (Var x) = {atom x}"
|
|
71 |
"supp (App M N) = supp M \<union> supp N"
|
|
72 |
"supp rtrm = fv_trm rtrm \<Longrightarrow> supp (Lam rty name rtrm) = supp rty \<union> supp (Abs {atom name} rtrm)"
|
|
73 |
apply(simp_all (no_asm) add: supp_def permute_set_eq atom_eqvt kind_ty_trm_perm)
|
|
74 |
apply(simp_all only: kind_ty_trm_inject Abs_eq_iff alpha_gen)
|
|
75 |
apply(simp_all only: ex_out)
|
|
76 |
apply(simp_all only: eqvts[symmetric])
|
|
77 |
apply(simp_all only: Collect_neg_conj)
|
|
78 |
apply(simp_all only: supp_at_base[simplified supp_def] Un_commute Un_assoc)
|
|
79 |
apply(simp_all add: Collect_imp_eq Collect_neg_eq[symmetric] Un_commute Un_assoc)
|
|
80 |
apply(simp_all add: Un_left_commute)
|
1245
|
81 |
done
|
1002
|
82 |
|
994
333c24bd595d
More in the LF example in the new nominal way, all is clear until support.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
|
83 |
lemma supp_fv:
|
1348
|
84 |
"supp t1 = fv_kind t1 \<and> supp t2 = fv_ty t2 \<and> supp t3 = fv_trm t3"
|
|
85 |
apply(induct rule: kind_ty_trm_induct)
|
|
86 |
apply(simp_all (no_asm) only: supp_eqs kind_ty_trm_fv)
|
1245
|
87 |
apply(simp_all)
|
1348
|
88 |
apply(simp_all add: supp_eqs)
|
1245
|
89 |
apply(simp_all add: supp_Abs)
|
|
90 |
done
|
994
333c24bd595d
More in the LF example in the new nominal way, all is clear until support.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
|
91 |
|
1234
|
92 |
lemma supp_rkind_rty_rtrm:
|
1348
|
93 |
"supp Type = {}"
|
|
94 |
"supp (KPi A x K) = supp A \<union> (supp K - {atom x})"
|
|
95 |
"supp (TConst i) = {atom i}"
|
|
96 |
"supp (TApp A M) = supp A \<union> supp M"
|
|
97 |
"supp (TPi A x B) = supp A \<union> (supp B - {atom x})"
|
|
98 |
"supp (Const i) = {atom i}"
|
|
99 |
"supp (Var x) = {atom x}"
|
|
100 |
"supp (App M N) = supp M \<union> supp N"
|
|
101 |
"supp (Lam A x M) = supp A \<union> (supp M - {atom x})"
|
|
102 |
apply (simp_all add: supp_fv kind_ty_trm_fv)
|
994
333c24bd595d
More in the LF example in the new nominal way, all is clear until support.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
|
103 |
|
985
ef8a2b0b237a
Ported existing part of LF to new permutations and alphas.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
104 |
end
|
ef8a2b0b237a
Ported existing part of LF to new permutations and alphas.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
105 |
|
ef8a2b0b237a
Ported existing part of LF to new permutations and alphas.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
106 |
|
ef8a2b0b237a
Ported existing part of LF to new permutations and alphas.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
107 |
|
ef8a2b0b237a
Ported existing part of LF to new permutations and alphas.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
108 |
|