Search code examples
coqproofdependent-typeproof-of-correctnesschurch-encoding

Coq doesn't recognize equality of dependent list


I made a question before, but i think that question was bad formalized so... I am facing some problems with this specific definition to prove their properties:

I have a definition of a list :

Inductive list (A : Type) (f : A -> A -> A) : A -> Type :=
  |Acons : forall {x : A} (y' : A) (cons' : list f x), list f (f x y')
  |Anil : forall (x: A) (y : A), list f (f x y).

And that's definitions :

Definition t_list (T : Type) := (T -> T -> T) -> T -> T.
Definition nil {A : Type} (f : A -> A -> A) (d : A) := d.
Definition cons {A : Type} (v' : A) (c_cons : t_list _) (f : A -> A -> A) (v'' : A) :=
  f (c_cons f v'') v'.

Fixpoint list_correspodence (A : Type) (v' : A) (z : A -> A -> A) (xs : list func v'):=
  let fix curry_list {y : A} {z' : A -> A -> A} (l : list z' y) := 
      match l with
        |Acons x y => cons x (curry_list y)
        |Anil _ _ y  => cons y nil
      end in (@curry_list _ _ xs) z (let fix minimal_case {y' : A} {functor : A -> A -> A} (a : list functor y') {struct a} :=
                                    match a with
                                      |Acons x y => minimal_case y
                                      |Anil _ x _ => x
                                    end in minimal_case xs).

Theorem z_next_list_coorresp : forall {A} (z : A -> A -> A) (x y' : A) (x' : list z x), z (list_correspodence x') y' = list_correspodence (Acons y' x').
intros.
generalize (Acons y' x').
intros.
unfold list_correspodence.
(*reflexivity should works ?*)
Qed.

z_next_list_coorres is actually a lemma i need to prove a goal in another theory (v'_list x = (list_correspodence x)).

I have been trying with some limited scopes to prove list_correspodence and works well, seems that definitions are equal, but for coq not.


Solution

  • Here list_correspondence is a spurious Fixpoint (i.e., fix) (it makes no recursive calls), and this gets in the way of reduction.

    You can force reduction of a fix by destructing its decreasing argument:

    destruct x'.
    - reflexivity.
    - reflexivity.
    

    Or you can avoid using Fixpoint in the first place. Use Definition instead.

    You may run into a strange bug here with implicit arguments, which is avoided by adding a type signature (as below), or by not marking implicit the arguments of the local function curry_list:

    Definition list_correspodence (A : Type) (v' : A) (func : A -> A -> A) (xs : list func v')
      : A :=
     (* ^ add this *)