Skip to content

Commit 25dad8e

Browse files
committed
Add general requirements for case to typing rule
1 parent b6c52e0 commit 25dad8e

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed

Defs.thy

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,35 @@ proof goal_cases
4242
qed (auto simp: eqvt_def head_ctor_graph_aux_def)
4343
nominal_termination (eqvt) by lexicographic_order
4444

45+
nominal_function head_data :: "\<tau> \<Rightarrow> data_name option" where
46+
"head_data (TyVar _) = None"
47+
| "head_data (TyData T) = Some T"
48+
| "head_data TyArrow = None"
49+
| "head_data (TyApp (TyData T) _) = Some T"
50+
| "head_data (TyApp (TyVar _) _) = None"
51+
| "head_data (TyApp TyArrow _) = None"
52+
| "head_data (TyApp (TyApp _ _) _) = None"
53+
| "head_data (TyApp (TyForall _ _ _) _) = None"
54+
| "head_data (TyForall _ _ _) = None"
55+
proof goal_cases
56+
case (3 P x)
57+
then show ?case
58+
proof (cases x rule: \<tau>.exhaust)
59+
case (TyApp \<tau>1 \<tau>2)
60+
then show ?thesis using 3 by (cases \<tau>1 rule: \<tau>.exhaust) auto
61+
qed
62+
qed (auto simp: eqvt_def head_data_graph_aux_def)
63+
nominal_termination (eqvt) by lexicographic_order
64+
65+
nominal_function set_alt_list :: "alt_list \<Rightarrow> alt set" where
66+
"set_alt_list ANil = {}"
67+
| "set_alt_list (ACons alt alts) = insert alt (set_alt_list alts)"
68+
proof goal_cases
69+
case (3 P x)
70+
then show ?case by (cases x rule: term_alt_list_alt.exhaust(2))
71+
qed (auto simp: eqvt_def set_alt_list_graph_aux_def)
72+
nominal_termination (eqvt) by lexicographic_order
73+
4574
nominal_function ctor_data_app :: "\<tau> \<Rightarrow> (data_name * tyvar list) option" where
4675
"ctor_data_app (TyVar _) = None"
4776
| "ctor_data_app (TyData T) = Some (T, [])"
@@ -163,6 +192,14 @@ next
163192
qed auto
164193
nominal_termination (eqvt) by lexicographic_order
165194

195+
abbreviation exhaustive :: "alt_list \<Rightarrow> \<Delta> \<Rightarrow> data_name \<Rightarrow> bool" where
196+
"exhaustive alts \<Delta> T \<equiv>
197+
(\<nexists>x e. MatchVar x e \<in> set_alt_list alts) \<longrightarrow>
198+
(\<forall>D \<tau>.
199+
(AxCtor D \<tau> \<in> set \<Delta> \<and> ctor_type \<tau> = Some T) \<longrightarrow>
200+
(\<exists>tys vals e. MatchCtor D tys vals e \<in> set_alt_list alts)
201+
)"
202+
166203
nominal_function is_value :: "term => bool" where
167204
"is_value (Var x) = False"
168205
| "is_value (\<lambda> x : \<tau> . e) = True"

Typing.thy

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ inductive Tm :: "\<Gamma> \<Rightarrow> \<Delta> \<Rightarrow> term \<Rightarrow
5151

5252
| Tm_Let: "\<lbrakk> \<Gamma> , \<Delta> \<turnstile> e1 : \<tau>1 ; BVar x \<tau>1 # \<Gamma> , \<Delta> \<turnstile> e2 : \<tau>2 \<rbrakk> \<Longrightarrow> \<Gamma> , \<Delta> \<turnstile> Let x \<tau>1 e1 e2 : \<tau>2"
5353

54+
| Tm_Case: "\<lbrakk> \<Gamma> , \<Delta> \<turnstile> e : \<tau>1 ; head_data \<tau>1 = Some T ; \<Gamma> , \<Delta> \<turnstile>\<^sub>t\<^sub>y \<tau> : \<star> ; exhaustive alts \<Delta> T ;
55+
\<forall>m\<in>set_alt_list alts. True
56+
\<rbrakk> \<Longrightarrow> \<Gamma> , \<Delta> \<turnstile> Case e alts : \<tau>"
57+
5458
equivariance Tm
5559

5660
lemmas Ax_intros = Ax_Ctx_Ty.intros(1-3)

0 commit comments

Comments
 (0)