@@ -27,13 +27,13 @@ Local Ltac inv H := inversion H; subst.
2727
2828(** ** Big step version of weak cbv beta-zeta-iota-fix-delta reduction. *)
2929
30- Definition atom t :=
30+ Definition atom Σ t :=
3131 match t with
3232 | tBox
33- | tConstruct _ _
3433 | tCoFix _ _
3534 | tLambda _ _
3635 | tFix _ _ => true
36+ | tConstruct ind c => isSome (lookup_constructor Σ ind c)
3737 | _ => false
3838 end .
3939
@@ -47,7 +47,7 @@ Definition isStuckFix t (args : list term) :=
4747 | _ => false
4848 end .
4949
50- Lemma atom_mkApps f l : atom (mkApps f l) -> (l = []) /\ atom f.
50+ Lemma atom_mkApps Σ f l : atom Σ (mkApps f l) -> (l = []) /\ atom Σ f.
5151Proof .
5252 revert f; induction l using rev_ind. simpl. intuition auto.
5353 simpl. intros. now rewrite mkApps_app in H.
@@ -197,7 +197,7 @@ Section Wcbv.
197197
198198
199199 (** Atoms are values (includes abstractions, cofixpoints and constructors) *)
200- | eval_atom t : atom t -> eval t t.
200+ | eval_atom t : atom Σ t -> eval t t.
201201
202202 Hint Constructors eval : core.
203203 Derive Signature for eval.
@@ -227,7 +227,7 @@ Section Wcbv.
227227 Derive Signature NoConfusion for value_head.
228228
229229 Inductive value : term -> Type :=
230- | value_atom t : atom t -> value t
230+ | value_atom t : atom Σ t -> value t
231231 | value_app_nonnil f args : value_head #|args| f -> args <> [] -> All value args -> value (mkApps f args).
232232 Derive Signature for value.
233233
@@ -245,12 +245,12 @@ Section Wcbv.
245245 Lemma value_app f args : value_head #|args| f -> All value args -> value (mkApps f args).
246246 Proof .
247247 destruct args.
248- - intros [] hv; now constructor .
248+ - intros [] hv; constructor; try easy. cbn [atom mkApps]. now rewrite e .
249249 - intros vh av. eapply value_app_nonnil => //.
250250 Qed .
251251
252252 Lemma value_values_ind : forall P : term -> Type,
253- (forall t, atom t -> P t) ->
253+ (forall t, atom Σ t -> P t) ->
254254 (forall f args, value_head #|args| f -> args <> [] -> All value args -> All P args -> P (mkApps f args)) ->
255255 forall t : term, value t -> P t.
256256 Proof .
@@ -270,14 +270,14 @@ Section Wcbv.
270270 Proof . destruct t; auto. Qed .
271271 Hint Resolve isStuckfix_nApp : core.
272272
273- Lemma atom_nApp {t} : atom t -> ~~ isApp t.
273+ Lemma atom_nApp {t} : atom Σ t -> ~~ isApp t.
274274 Proof . destruct t; auto. Qed .
275275 Hint Resolve atom_nApp : core.
276276
277277 Lemma value_mkApps_inv t l :
278278 ~~ isApp t ->
279279 value (mkApps t l) ->
280- ((l = []) /\ atom t) + ([× l <> [], value_head #|l| t & All value l]).
280+ ((l = []) /\ atom Σ t) + ([× l <> [], value_head #|l| t & All value l]).
281281 Proof .
282282 intros H H'. generalize_eq x (mkApps t l).
283283 revert x H' t H. apply: value_values_ind.
@@ -353,7 +353,7 @@ Section Wcbv.
353353 value_head n t -> eval t t.
354354 Proof .
355355 destruct 1.
356- - now constructor .
356+ - constructor; try easy. now cbn [atom]; rewrite e .
357357 - now eapply eval_atom.
358358 - now eapply eval_atom.
359359 Qed .
@@ -362,9 +362,9 @@ Section Wcbv.
362362 (* It means no redex can remain at the head of an evaluated term. *)
363363
364364 Lemma value_head_spec' n t :
365- value_head n t -> (~~ (isLambda t || isBox t)) && atom t.
365+ value_head n t -> (~~ (isLambda t || isBox t)) && atom Σ t.
366366 Proof .
367- induction 1; cbn => //.
367+ induction 1; auto. cbn [atom]; rewrite e //.
368368 Qed .
369369
370370
@@ -953,7 +953,9 @@ Section WcbvEnv.
953953 induction ev; try solve [econstructor;
954954 eauto using (extends_lookup_constructor wf ex), (extends_constructor_isprop_pars_decl wf ex), (extends_is_propositional wf ex)].
955955 econstructor; eauto.
956- red in isdecl |- *. eauto using extends_lookup.
956+ red in isdecl |- *. eauto using extends_lookup. constructor.
957+ destruct t => //. cbn [atom] in i. destruct lookup_constructor eqn:hl => //.
958+ eapply (extends_lookup_constructor wf ex) in hl. now cbn [atom].
957959 Qed .
958960
959961End WcbvEnv.
@@ -1359,7 +1361,7 @@ Qed.
13591361
13601362Lemma eval_mkApps_Construct_inv {fl : WcbvFlags} Σ kn c args e :
13611363 eval Σ (mkApps (tConstruct kn c) args) e ->
1362- ∑ args', ( e = mkApps (tConstruct kn c) args') × All2 (eval Σ) args args'.
1364+ ∑ args', [× isSome (lookup_constructor Σ kn c), ( e = mkApps (tConstruct kn c) args') & All2 (eval Σ) args args'] .
13631365Proof .
13641366 revert e; induction args using rev_ind; intros e.
13651367 - intros ev. depelim ev. exists []=> //.
@@ -1472,18 +1474,18 @@ Lemma eval_mkApps_Construct_size {wfl : WcbvFlags} {Σ ind c args v} :
14721474Proof .
14731475 intros ev.
14741476 destruct (eval_mkApps_inv_size ev) as [f'' [args' [? []]]].
1475- exists args'.
1476- exists (eval_atom _ (tConstruct ind c) eq_refl).
1477+ exists args'.
1478+ destruct (eval_mkApps_Construct_inv _ _ _ _ _ ev) as [? []]. subst v.
1479+ exists (eval_atom _ (tConstruct ind c) i).
14771480 cbn. split => //. destruct ev; cbn => //; auto with arith.
14781481 clear l.
1479- destruct (eval_mkApps_Construct_inv _ _ _ _ _ ev) as [? []]. subst v.
14801482 eapply (eval_mkApps_Construct_inv _ _ _ []) in x as [? []]. subst f''. depelim a1.
14811483 f_equal.
14821484 eapply eval_deterministic_all; tea.
14831485 eapply All2_impl; tea; cbn; eauto. now intros x y [].
14841486Qed .
14851487
1486- Lemma eval_construct_size {fl : WcbvFlags} [Σ kn c args e] :
1488+ Lemma eval_construct_size {fl : WcbvFlags} [Σ kn c args e] :
14871489 forall (ev : eval Σ (mkApps (tConstruct kn c) args) e),
14881490 ∑ args', (e = mkApps (tConstruct kn c) args') ×
14891491 All2 (fun x y => ∑ ev' : eval Σ x y, eval_depth ev' < eval_depth ev) args args'.
0 commit comments