Search code examples
coqproof

Termination implies existence of normal form


I would like to prove that termination implies existence of normal form. These are my definitions:

Section Forms.
  Require Import Classical_Prop.
  Require Import Classical_Pred_Type.
  Context {A : Type}
  Variable R : A -> A -> Prop.

  Definition Inverse (Rel : A -> A -> Prop) := fun x y => Rel y x.  

  Inductive ReflexiveTransitiveClosure : Relation A A :=
  | rtc_into (x y : A) : R x y -> ReflexiveTransitiveClosure x y
  | rtc_trans (x y z : A) : R x y -> ReflexiveTransitiveClosure y z ->
                            ReflexiveTransitiveClosure x z
  | rtc_refl (x y : A) : x = y -> ReflexiveTransitiveClosure x y.

  Definition redc (x : A) := exists y, R x y.
  Definition nf (x : A) := ~(redc x).
  Definition nfo (x y : A) := ReflexiveTransitiveClosure R x y /\ nf y.
  Definition terminating := forall x, Acc (Inverse R) x.
  Definition normalizing := forall x, (exists y, nfo x y).
End Forms.

I'd like to prove:

Lemma terminating_impl_normalizing (T : terminating):
  normalizing.

I have been banging my head against the wall for a couple of hours now, and I've made almost no progress. I can show:

Lemma terminating_not_inf_forall (T : terminating) :
  forall f : nat -> A, ~ (forall n, R (f n) (f (S n))).

which I believe should help (this is also true without classic).


Solution

  • Here is a proof using the excluded middle. I reformulated the problem to replace custom definitions by standard ones (note by the way that in your definition of the closure, the rtc_into is redundant with the other ones). I also reformulated terminating using well_founded.

    Require Import Classical_Prop.
    Require Import Relations.
    
    Section Forms.
      Context {A : Type} (R:relation A).
    
      Definition inverse := fun x y => R y x.
    
      Definition redc (x : A) := exists y, R x y.
      Definition nf (x : A) := ~(redc x).
      Definition nfo (x y : A) := clos_refl_trans _ R x y /\ nf y.
      Definition terminating := well_founded inverse. (* forall x, Acc inverse x. *)
      Definition normalizing := forall x, (exists y, nfo x y).
    
      Lemma terminating_impl_normalizing (T : terminating):
        normalizing.
      Proof.
        unfold normalizing.
        apply (well_founded_ind T). intros.
        destruct (classic (redc x)).
        - destruct H0 as [y H0]. pose proof (H _ H0).
          destruct H1 as [y' H1]. exists y'. unfold nfo.
          destruct H1.
          split.
          + apply rt_trans with (y:=y). apply rt_step. assumption. assumption.
          + assumption.
        - exists x. unfold nfo. split. apply rt_refl. assumption.
    Qed.
    
    End Forms.
    

    The proof is not very complicated but here are the main ideas:

    • use well founded induction
    • thanks to the excluded middle principle, separate the case where x is not in normal form and the case where it is
    • if x is not in normal form, use the induction hypothesis and use the transitivity of the closure to conclude
    • if x is already in normal form, we are done