-
Notifications
You must be signed in to change notification settings - Fork 3
/
SubtypeMatch.v
74 lines (67 loc) · 2.07 KB
/
SubtypeMatch.v
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
Require Export SystemFR.ScalaDepSugar.
Require Export SystemFR.SubtypeExists.
Require Export SystemFR.ReducibilitySubtype.
Opaque reducible_values.
Lemma subtype_union_left:
forall ρ T1 T2 T,
[ ρ ⊨ T1 <: T ] ->
[ ρ ⊨ T2 <: T ] ->
[ ρ ⊨ T_union T1 T2 <: T ].
Proof.
repeat step || simp_red.
Qed.
Lemma open_subtype_union_left:
forall Θ Γ T1 T2 T,
[ Θ; Γ ⊨ T1 <: T ] ->
[ Θ; Γ ⊨ T2 <: T ] ->
[ Θ; Γ ⊨ T_union T1 T2 <: T ].
Proof.
unfold open_subtype; repeat step; eauto using subtype_union_left.
Qed.
Opaque List.
Lemma open_submatch_helper:
forall Θ Γ t1 T2 T3 S x y,
x <> y ->
~x ∈ fv S ->
~x ∈ fv t1 ->
~x ∈ fv T3 ->
~x ∈ pfv_context Γ term_var ->
~y ∈ fv S ->
~y ∈ fv t1 ->
~y ∈ fv T3 ->
~y ∈ pfv_context Γ term_var ->
wf t1 0 ->
[ Θ; Γ ⊨ t1 : List ] ->
[ Θ; Γ ⊨ T2 <: S ] ->
[ Θ; (y, List) :: (x, T_top) :: Γ ⊨ open 0 (open 1 T3 (fvar x term_var)) (fvar y term_var) <: S ] ->
[ Θ; Γ ⊨ List_Match t1 T2 T3 <: S ].
Proof.
unfold List_Match; intros; apply open_subtype_union_left; steps.
- unfold open_subtype; repeat step || simp_red_top_level_hyp.
unfold open_subtype in H2; eauto using subtype_reducible_values.
- apply open_sub_exists_left_helper with x; repeat step || list_utils.
apply open_sub_exists_left_helper with y;
repeat step || list_utils || fv_open || open_none.
rewrite (open_none t1) by eauto with wf.
unfold open_subtype in H11.
unfold open_subtype; repeat step || simp_red_top_level_hyp.
Qed.
Lemma open_submatch:
forall Γ t1 T2 T3 S x y,
x <> y ->
~x ∈ fv S ->
~x ∈ fv t1 ->
~x ∈ fv T3 ->
~x ∈ pfv_context Γ term_var ->
~y ∈ fv S ->
~y ∈ fv t1 ->
~y ∈ fv T3 ->
~y ∈ pfv_context Γ term_var ->
wf t1 0 ->
[ Γ ⊫ t1 : List ] ->
[ Γ ⊫ T2 <: S ] ->
[ (y, List) :: (x, T_top) :: Γ ⊫ open 0 (open 1 T3 (fvar x term_var)) (fvar y term_var) <: S ] ->
[ Γ ⊫ List_Match t1 T2 T3 <: S ].
Proof.
eauto using open_submatch_helper.
Qed.