简体   繁体   中英

How to proof in Coq statements about given sets

How does one proof statements like the following one in 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.

Or, let's say you have a given list of numbers and you want to proof that no number appears twice in that list.

Maybe one has to write an algorithm with the Lemma as its type. But I have no clue how to do this.

BTW, its not a homework exercise.

Here is a quick-and-dirty proof:

Proof.
Require Import Program.
dependent destruction x.
auto.
dependent destruction x.
compute.
auto.
dependent destruction x.
compute.
auto.
dependent destruction x.
compute.
auto.
dependent destruction x.
compute.
auto.
dependent destruction x.
compute.
auto 10.
dependent destruction x.
compute.
auto 10.
dependent destruction x.
compute.
auto 10.
dependent destruction x.
Qed.

We use the dependent destruction tactic from the Program module. This relies on the JMeq axiom, but that shouldn't be a problem.

Let me suggest a solution using the math-comp library:

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.

The all_tnthP lemma will replace your predicate by its computable version, which in turn will make Coq check that all the elements in the tuple are greater than 0, concluding the proof.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM