Skip to content

Commit

Permalink
Add general requirements for case to typing rule
Browse files Browse the repository at this point in the history
  • Loading branch information
jvanbruegge committed Mar 3, 2021
1 parent f4f5929 commit e24abcf
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
37 changes: 37 additions & 0 deletions Defs.thy
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,35 @@ proof goal_cases
qed (auto simp: eqvt_def head_ctor_graph_aux_def)
nominal_termination (eqvt) by lexicographic_order

nominal_function head_data :: "\<tau> \<Rightarrow> data_name option" where
"head_data (TyVar _) = None"
| "head_data (TyData T) = Some T"
| "head_data TyArrow = None"
| "head_data (TyApp (TyData T) _) = Some T"
| "head_data (TyApp (TyVar _) _) = None"
| "head_data (TyApp TyArrow _) = None"
| "head_data (TyApp (TyApp _ _) _) = None"
| "head_data (TyApp (TyForall _ _ _) _) = None"
| "head_data (TyForall _ _ _) = None"
proof goal_cases
case (3 P x)
then show ?case
proof (cases x rule: \<tau>.exhaust)
case (TyApp \<tau>1 \<tau>2)
then show ?thesis using 3 by (cases \<tau>1 rule: \<tau>.exhaust) auto
qed
qed (auto simp: eqvt_def head_data_graph_aux_def)
nominal_termination (eqvt) by lexicographic_order

nominal_function set_alt_list :: "alt_list \<Rightarrow> alt set" where
"set_alt_list ANil = {}"
| "set_alt_list (ACons alt alts) = insert alt (set_alt_list alts)"
proof goal_cases
case (3 P x)
then show ?case by (cases x rule: term_alt_list_alt.exhaust(2))
qed (auto simp: eqvt_def set_alt_list_graph_aux_def)
nominal_termination (eqvt) by lexicographic_order

nominal_function ctor_data_app :: "\<tau> \<Rightarrow> (data_name * tyvar list) option" where
"ctor_data_app (TyVar _) = None"
| "ctor_data_app (TyData T) = Some (T, [])"
Expand Down Expand Up @@ -163,6 +192,14 @@ next
qed auto
nominal_termination (eqvt) by lexicographic_order

abbreviation exhaustive :: "alt_list \<Rightarrow> \<Delta> \<Rightarrow> data_name \<Rightarrow> bool" where
"exhaustive alts \<Delta> T \<equiv>
(\<nexists>x e. MatchVar x e \<in> set_alt_list alts) \<longrightarrow>
(\<forall>D \<tau>.
(AxCtor D \<tau> \<in> set \<Delta> \<and> ctor_type \<tau> = Some T) \<longrightarrow>
(\<exists>tys vals e. MatchCtor D tys vals e \<in> set_alt_list alts)
)"

nominal_function is_value :: "term => bool" where
"is_value (Var x) = False"
| "is_value (\<lambda> x : \<tau> . e) = True"
Expand Down
4 changes: 4 additions & 0 deletions Typing.thy
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ inductive Tm :: "\<Gamma> \<Rightarrow> \<Delta> \<Rightarrow> term \<Rightarrow

| 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"

| 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 ;
\<forall>m\<in>set_alt_list alts. True
\<rbrakk> \<Longrightarrow> \<Gamma> , \<Delta> \<turnstile> Case e alts : \<tau>"

equivariance Tm

lemmas Ax_intros = Ax_Ctx_Ty.intros(1-3)
Expand Down

0 comments on commit e24abcf

Please sign in to comment.