Skip to content

Commit c6a0460

Browse files
committed
WIP: resolve more admitted cases
1 parent 0026516 commit c6a0460

1 file changed

Lines changed: 49 additions & 21 deletions

File tree

theories/SimplyTypedLambdaCalculus/StrongNormalisation.v

Lines changed: 49 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
From FormArith.SimplyTypedLambdaCalculus Require Import Definitions.
1+
From FormArith.SimplyTypedLambdaCalculus Require Import Definitions ChurchRosser.
22
Import List.ListNotations.
33

44

@@ -103,7 +103,7 @@ Fixpoint nested_app t l :=
103103
| cons t' l' => App (nested_app t l') t'
104104
end.
105105

106-
Lemma atomic_step t s : atomic' t -> t ->β s -> atomic' s.
106+
Lemma atomic_step t s : atomic' t -> t ~> s -> atomic' s.
107107
Proof.
108108
induction t in s |- *; cbn.
109109
- inversion 2.
@@ -131,8 +131,8 @@ Proof.
131131
+ apply H2. 1: assumption. assumption.
132132
Qed.
133133

134-
Lemma SN_ind_pair (P : term -> term -> Prop):
135-
(forall t u, (forall t' u', ((t = t' /\ u ->β u') \/ (t ->β t' /\ u = u')) -> P t' u') -> P t u)
134+
Lemma SNaa_ind_pair (P : term -> term -> Prop):
135+
(forall t u, (forall t' u', ((t = t' /\ u ~> u') \/ (t ~> t' /\ u = u')) -> P t' u') -> P t u)
136136
-> forall t u, SN t -> SN u -> P t u.
137137
Proof.
138138
intros IH ? ? Hsnt.
@@ -169,7 +169,7 @@ Fixpoint enumerate_steps (t : term) : list term :=
169169
(*
170170
enumerate_steps is sound and complete:
171171
*)
172-
Lemma enumerate_steps_spec t: forall t', List.In t' (enumerate_steps t) <-> t ->β t'.
172+
Lemma enumerate_steps_spec t: forall t', List.In t' (enumerate_steps t) <-> t ~> t'.
173173
Proof.
174174
induction t as [x | s IHs t IHt | s IHs].
175175
- intros u; cbn. split.
@@ -206,7 +206,7 @@ Qed.
206206
(*
207207
This version is slightly nicer to use in the following proof:
208208
*)
209-
Lemma enumerate_Forall_beta t : List.Forall (fun t' => t ->β t') (enumerate_steps t).
209+
Lemma enumerate_Forall_beta t : List.Forall (fun t' => t ~> t') (enumerate_steps t).
210210
Proof.
211211
apply List.Forall_forall.
212212
apply enumerate_steps_spec.
@@ -220,7 +220,7 @@ Fixpoint reduction_sequence (l : list term) : Prop :=
220220
match l with
221221
| nil => True
222222
| cons t nil => True
223-
| cons s (cons t l' as ll) => s ->β t /\ reduction_sequence ll
223+
| cons s (cons t l' as ll) => s ~> t /\ reduction_sequence ll
224224
end.
225225

226226
Require Import Lia.
@@ -238,15 +238,15 @@ Proof.
238238
(*The proof is by induction on SN, which is also why we can't (easily) state this as a function.*)
239239
intros Hsn. induction Hsn as [t Hsn IH].
240240
(*First, we apply the induction hypothesis to all terms in `enumerate_steps` (i.e. all the terms t can reduce to).*)
241-
assert (List.Forall (fun t' => t ->β t' /\ exists n, forall l, reduction_sequence (t' :: l) -> length l <= n) (enumerate_steps t)) as H.
241+
assert (List.Forall (fun t' => t ~> t' /\ exists n, forall l, reduction_sequence (t' :: l) -> length l <= n) (enumerate_steps t)) as H.
242242
+ pose proof (enumerate_Forall_beta t) as H.
243243
induction H.
244244
* constructor.
245245
* constructor. 2: assumption.
246246
firstorder.
247247
+ (*Unfortunately, the maximal lengths for all t' are currently hidden underneath existential quantifiers, and not easily accessible.
248248
We begin by moving them into an existentially quantified list.*)
249-
assert (exists l', length l' = length (enumerate_steps t) /\ List.Forall (fun (p : term * nat) => let (t', n) := p in forall l, reduction_sequence (t' :: l) -> length l <= n) (List.combine (enumerate_steps t) l')) as [l' [Hlen Hl']].
249+
assert (exists l', length l' = length (enumerate_steps t) /\ List.Forall (fun (p : prod term nat) => let (t', n) := p in forall l, reduction_sequence (t' :: l) -> length l <= n) (List.combine (enumerate_steps t) l')) as [l' [Hlen Hl']].
250250
* induction H as [|t' l Ht' HForall IHForall].
251251
-- exists nil. firstorder.
252252
-- destruct Ht' as [_ [n Hn]].
@@ -317,14 +317,35 @@ Proof.
317317
* subst. now apply IHn.
318318
Qed.
319319

320+
Lemma subst_steps t u u': u ~> u' -> t.[u/] ~>* t.[u'/].
321+
Proof.
322+
intros Hstep.
323+
apply par_red_to_beta_star.
324+
apply par_red_subst_par_red.
325+
2: apply par_red_refl.
326+
intros [| v].
327+
- asimpl. now apply beta_to_par_red.
328+
- asimpl. apply par_red_refl.
329+
Qed.
330+
331+
Lemma SN_inverted_star t t': SN t -> t ~>* t' -> SN t'.
332+
Proof.
333+
intros Hsn Hsteps.
334+
induction Hsteps.
335+
- eapply SN_inverted; eassumption.
336+
- assumption.
337+
- firstorder.
338+
Qed.
339+
340+
320341
Lemma nested_app_app t inner outer : (nested_app (nested_app t inner) outer) = nested_app t (outer ++ inner).
321342
Proof.
322343
induction outer as [| t' outer IH].
323344
- reflexivity.
324345
- cbn. rewrite IH. reflexivity.
325346
Qed.
326347

327-
Lemma max_steps_decr t n: (forall l, reduction_sequence (t :: l) -> length l <= n) -> forall t', t ->β t' -> forall l, reduction_sequence (t' :: l) -> length l <= pred n.
348+
Lemma max_steps_decr t n: (forall l, reduction_sequence (t :: l) -> length l <= n) -> forall t', t ~> t' -> forall l, reduction_sequence (t' :: l) -> length l <= pred n.
328349
Proof.
329350
intros Hmax t' Hstep.
330351
destruct n.
@@ -341,34 +362,34 @@ Proof.
341362
split; assumption.
342363
Qed.
343364

344-
Lemma max_steps_nonzero t t' n: (t ->β t') -> (forall l, reduction_sequence (t :: l) -> length l <= n) -> n > 0.
365+
Lemma max_steps_nonzero t t' n: (t ~> t') -> (forall l, reduction_sequence (t :: l) -> length l <= n) -> n > 0.
345366
Proof.
346367
intros Hstep Hlen.
347368
specialize (Hlen [t']%list).
348369
cbn in Hlen. firstorder.
349370
Qed.
350371

351372
Lemma max_steps_list_decr t1 t2 l l' outer :
352-
t1 ->β t2 ->
373+
t1 ~> t2 ->
353374
length l' = length (outer ++ t1 :: l) ->
354375
List.Forall
355-
(fun p : term * nat =>
376+
(fun p : prod term nat =>
356377
let (t, n) := p in
357378
forall l : list term,
358379
match l with
359380
| []%list => True
360-
| (t0 :: _)%list => t ->β t0 /\ reduction_sequence l
381+
| (t0 :: _)%list => t ~> t0 /\ reduction_sequence l
361382
end -> length l <= n) (List.combine (outer ++ t1 :: l) l') ->
362383
exists l'',
363384
List.list_sum l'' < List.list_sum l'
364385
/\ length l'' = length (outer ++ t1 :: l)
365386
/\ List.Forall
366-
(fun p : term * nat =>
387+
(fun p : prod term nat =>
367388
let (t0, n) := p in
368389
forall l0 : list term,
369390
match l0 with
370391
| []%list => True
371-
| (t2 :: _)%list => t0 ->β t2 /\ reduction_sequence l0
392+
| (t2 :: _)%list => t0 ~> t2 /\ reduction_sequence l0
372393
end -> length l0 <= n) (List.combine (outer ++ t1 :: l) l'').
373394
Proof.
374395
intros Hstep Hlen Hl'.
@@ -404,7 +425,7 @@ Admitted.
404425
The current attempt uses the maximal numbers of steps (as determined by max_steps),
405426
but is stuck at destructing the actual reduction step. Presumably, induction is needed, but I have not yet found a version that yields suitable induction hypotheses.
406427
*)
407-
Lemma base_case t u l : SN (nested_app t.[u/] l) -> SN u -> forall t', nested_app (App (Lam t) u) l ->β t' -> SN t'.
428+
Lemma base_case t u l : SN (nested_app t.[u/] l) -> SN u -> forall t', nested_app (App (Lam t) u) l ~> t' -> SN t'.
408429
Proof.
409430
intros Hsn Hsnu.
410431
(*determine the maximum number of steps for t*)
@@ -422,7 +443,7 @@ Proof.
422443
assert (exists nu, forall l, reduction_sequence (u :: l) -> length l <= nu) as [nu Hnu].
423444
{ apply max_steps. assumption. }
424445
(*determine the maximum number of steps for all terms in l*)
425-
assert (exists l', length l' = length l /\ List.Forall (fun (p : term * nat) => let (t, n) := p in forall l, reduction_sequence (t :: l) -> length l <= n) (List.combine l l')) as [l' Hl'].
446+
assert (exists l', length l' = length l /\ List.Forall (fun (p : prod term nat) => let (t, n) := p in forall l, reduction_sequence (t :: l) -> length l <= n) (List.combine l l')) as [l' Hl'].
426447
{ induction l.
427448
- exists nil; firstorder.
428449
- cbn in Hsn.
@@ -496,7 +517,14 @@ Proof.
496517
1: apply (max_steps_nonzero u _ nu) in Hstep.
497518
1: lia.
498519
1: assumption.
499-
admit. (* requires (u ->β u') -> (t.[u/] ->β* t.[u'/]), which we have not yet shown *)
520+
clear - Hsn Hsnu Hstep.
521+
eapply SN_inverted_star. 1: exact Hsn.
522+
induction outer as [| a outer IHouter].
523+
* cbn. now apply subst_steps.
524+
* cbn. apply beta_star_app. 2: apply beta_star_refl.
525+
apply IHouter.
526+
eapply SN_sub_term. 1: exact Hsn.
527+
cbn. constructor.
500528
+ inversion Heqtrm; subst.
501529
change (SN (nested_app (nested_app (App (Lam t) u) (t' :: l)) outer)).
502530
rewrite (nested_app_app).
@@ -514,7 +542,7 @@ Proof.
514542
2: exact Hl''.
515543
lia.
516544
- destruct l; cbn in Heqtrm; congruence.
517-
Admitted.
545+
Qed.
518546

519547
(*Lemma 3.2.1 of the lecture notes.*)
520548
Lemma reducible_is_SN_variant_1 (A : type):
@@ -703,4 +731,4 @@ Proof.
703731
intros.
704732
apply reducible_var with Γ.
705733
now apply Typing_Var.
706-
Qed.
734+
Qed

0 commit comments

Comments
 (0)