【问题标题】:Coq doesn't recognize equality of dependent listCoq 不承认依赖列表的相等性
【发布时间】:2019-03-05 21:14:43
【问题描述】:

我之前提出过一个问题,但我认为这个问题形式化不好,所以...... 我在使用这个特定定义来证明它们的属性时遇到了一些问题:

我有一个列表的定义:

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 却不是。

【问题讨论】:

  • 由于某种原因,将变量A 重用为类型和列表,这让我很难理解这个程序。将curry_listminimal_case 提升为顶级Fixpoint 也有助于提高可读性,而不是像这里那样使它们成为本地函数。

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


【解决方案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 *)

【讨论】:

  • 这不是我第一次遇到类型签名泄漏的问题,我认为我不应该再使用类型推断了。而我只是忘记了把它拿掉的固定点。非常感谢你。感谢您的奉献精神。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2017-02-14
  • 1970-01-01
  • 2018-06-07
  • 1970-01-01
  • 2013-04-01
  • 1970-01-01
  • 2013-01-05
相关资源
最近更新 更多