如何在Coq语句中证明给定集合

时间:2015-12-19 19:39:01

标签: coq dependent-type induction

COQ中的一个证明陈述如下所示。

Require Import Vector.
Import VectorNotations.
Require Import Fin.

Definition v:=[1;2;3;4;5;6;7;8].
Lemma L: forall (x: Fin.t 8), (nth v x) > 0.

或者,假设您有一个给定的数字列表,并且您想要证明该列表中没有数字出现两次。

也许必须编写一个以引理作为其类型的算法。但我不知道如何做到这一点。

顺便说一下,这不是一个家庭作业。

1 个答案:

答案 0 :(得分:1)

让我建议使用math-comp库的解决方案:

From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat seq.
From mathcomp Require Import fintype tuple.

Definition v := [tuple of [:: 1;2;3;4;5;6;7;8]].

Lemma L : forall x, tnth v x > 0.
Proof. exact/all_tnthP. Qed.

all_tnthP引理将通过其可计算版本替换您的谓词,这反过来将使Coq检查元组中的所有元素都大于0,从而得出证据。