Coq无法识别依赖列表的相等性

时间:2019-03-05 21:14:44

标签: coq proof dependent-type proof-of-correctness church-encoding

我之前提过一个问题,但是我认为这个问题很难正式化,所以... 我在使用此特定定义来证明其特性时遇到了一些问题:

我有一个列表的定义:

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).

这就是定义:

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实际上是一个引理,我需要用另一种理论证明目标(v'_list x =(list_correspodence x))。

我一直在尝试用有限的范围来证明list_correspodence并能很好地工作,似乎定义是相等的,但是对于coq来说不是。

1 个答案:

答案 0 :(得分:1)

这里list_correspondence是伪造的Fixpoint(即fix)(它不进行递归调用),这会减少约数。

您可以通过破坏fix的递减参数来强制减少它:

destruct x'.
- reflexivity.
- reflexivity.

或者您可以避免首先使用Fixpoint。请改用Definition

您可能会在此处遇到带有隐式参数的奇怪错误,可以通过添加类型签名(如下所示)或不标记隐式局部函数curry_list的参数来避免这种错误:

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