Skip to content

Commit 907723f

Browse files
JasonGrossyforster
authored andcommitted
Add union and inter checker flags (#957)
This will allow programatically combining checker flags from multiple constants in Gallina quotation.
1 parent c3c5051 commit 907723f

File tree

1 file changed

+72
-0
lines changed

1 file changed

+72
-0
lines changed

common/theories/config.v

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,3 +71,75 @@ Qed.
7171
impl_refl impl_crefl
7272
impl_trans impl_ctrans
7373
| 100.
74+
75+
Definition laxest_checker_flags : checker_flags := {|
76+
check_univs := false ;
77+
prop_sub_type := true;
78+
indices_matter := false;
79+
lets_in_constructor_types := true
80+
|}.
81+
82+
Definition strictest_checker_flags : checker_flags := {|
83+
check_univs := true ;
84+
prop_sub_type := false;
85+
indices_matter := true;
86+
lets_in_constructor_types := false
87+
|}.
88+
89+
Lemma laxest_checker_flags_laxest : forall cf, impl cf laxest_checker_flags.
90+
Proof.
91+
intro cf; cbv; destruct cf.
92+
repeat match goal with
93+
| [ |- context[match ?x with _ => _ end] ] => case_eq x
94+
end; try reflexivity; congruence.
95+
Qed.
96+
97+
Lemma strictest_checker_flags_strictest : forall cf, impl strictest_checker_flags cf.
98+
Proof.
99+
intro cf; cbv; destruct cf.
100+
repeat match goal with
101+
| [ |- context[match ?x with _ => _ end] ] => case_eq x
102+
end; try reflexivity; congruence.
103+
Qed.
104+
105+
(** can check everything that either one can check *)
106+
Definition union_checker_flags (cf1 cf2 : checker_flags) : checker_flags
107+
:= {| check_univs := andb cf2.(@check_univs) cf1.(@check_univs)
108+
; prop_sub_type := orb cf1.(@prop_sub_type) cf2.(@prop_sub_type)
109+
; indices_matter := andb cf2.(@indices_matter) cf1.(@indices_matter)
110+
; lets_in_constructor_types := orb cf1.(@lets_in_constructor_types) cf2.(@lets_in_constructor_types) |}.
111+
112+
(** can check everything that both can check *)
113+
Definition inter_checker_flags (cf1 cf2 : checker_flags) : checker_flags
114+
:= {| check_univs := orb cf2.(@check_univs) cf1.(@check_univs)
115+
; prop_sub_type := andb cf1.(@prop_sub_type) cf2.(@prop_sub_type)
116+
; indices_matter := orb cf2.(@indices_matter) cf1.(@indices_matter)
117+
; lets_in_constructor_types := andb cf1.(@lets_in_constructor_types) cf2.(@lets_in_constructor_types) |}.
118+
119+
Lemma union_checker_flags_spec cf1 cf2 (cf' := union_checker_flags cf1 cf2)
120+
: impl cf1 cf' /\ impl cf2 cf' /\ (forall cf'', impl cf1 cf'' -> impl cf2 cf'' -> impl cf' cf'').
121+
Proof.
122+
destruct cf1, cf2; subst cf'.
123+
cbv.
124+
repeat split.
125+
3: intro cf''; destruct cf''.
126+
all: repeat first [ match goal with
127+
| [ |- context[match ?x with _ => _ end] ] => is_var x; destruct x
128+
end
129+
| reflexivity
130+
| congruence ].
131+
Qed.
132+
133+
Lemma inter_checker_flags_spec cf1 cf2 (cf' := inter_checker_flags cf1 cf2)
134+
: impl cf' cf1 /\ impl cf' cf2 /\ (forall cf'', impl cf'' cf1 -> impl cf'' cf2 -> impl cf'' cf').
135+
Proof.
136+
destruct cf1, cf2; subst cf'.
137+
cbv.
138+
repeat split.
139+
3: intro cf''; destruct cf''.
140+
all: repeat first [ match goal with
141+
| [ |- context[match ?x with _ => _ end] ] => is_var x; destruct x
142+
end
143+
| reflexivity
144+
| congruence ].
145+
Qed.

0 commit comments

Comments
 (0)