Questions tagged [coq]

Coq is a formal proof management system, semi-interactive theorem prover and functional programming language. Coq is used for software verification, the formalization of programming languages, the formalization of mathematical theorems, teaching, and more. Due to the interactive nature of Coq, we recommend questions to link to executable examples at https://x80.org/collacoq/ if deemed appropriate.

Coq is an interactive theorem prover based on the calculus of inductive constructions.

Resources

2862 questions
8
votes
1 answer

Abstracting over the term ... leads to a term ... which is ill-typed

Here is what I am trying to prove: A : Type i : nat index_f : nat → nat n : nat ip : n < i partial_index_f : nat → option nat L : partial_index_f (index_f n) ≡ Some n V : ∀ i0 : nat, i0 < i → option A l : ∀ z : nat, partial_index_f…
krokodil
  • 1,326
  • 10
  • 18
8
votes
1 answer

Is there a minimal complete set of tactics in Coq?

I have seen a lot of Coq tactics that are overlapping each other in function. For example, when you have the exact conclusion in the hypothesis, you can use assumption, apply, exact, trivial, and maybe others. Other examples include destruct and…
thor
  • 21,418
  • 31
  • 87
  • 173
8
votes
3 answers

Coq: manage LoadPath in project with subdirectories

I have a Coq project with its libraries organised into subdirectories, something like: …/MyProj/Auxiliary/Aux.v …/MyProj/Main/Main.v (imports Auxiliary/Aux.v) When I compile the files, I expect to do so from working directory MyProj (via a…
PLL
  • 1,572
  • 1
  • 13
  • 21
8
votes
1 answer

Handling let in hypothesis

As an exercise in Coq, I'm trying to prove that the following function returns a pair of lists of equal length. Require Import List. Fixpoint split (A B:Set)(x:list (A*B)) : (list A)*(list B) := match x with |nil => (nil, nil) |cons (a,b) x1 => let…
kjam
  • 809
  • 1
  • 7
  • 17
8
votes
1 answer

How do I write tactics that behave like "destruct ... as"?

In coq, the destruct tactic has a variant accepting an "conjunctive disjunctive introduction pattern" that allows the user to assign names to introduced variables, even when unpacking complex inductive types. The Ltac language in coq allows the user…
phs
  • 10,687
  • 4
  • 58
  • 84
8
votes
1 answer

A good way to formalize groups in Coq

I try to formalize groups in Coq. I want to be as general as possible. I try to do something, but I'm not really happy with it. I found different implementations and I don't know which one to choose. For example I found this :…
Saroupille
  • 609
  • 8
  • 14
8
votes
3 answers

How to prove False from obviously contradictory assumptions

Suppose I want to prove following Theorem: Theorem succ_neq_zero : forall n m: nat, S n = m -> 0 = m -> False. This one is trivial since m cannot be both successor and zero, as assumed. However I found it quite tricky to prove it, and I don't know…
Michal Seweryn
  • 363
  • 2
  • 8
8
votes
2 answers

How to forbid simpl tactic to unfold arithmetic expressions?

The simpl tactic unfolds expressions like 2 + a to "match trees" which doesn't seem simple at all. For example: Goal forall i:Z, ((fun x => x + i) 3 = i + 3). simpl. Leads to: forall i : Z, match i with | 0 => 3 | Z.pos y' => Z.pos match…
Necto
  • 2,594
  • 1
  • 20
  • 45
8
votes
1 answer

How or is that possible to prove or falsify `forall (P Q : Prop), (P -> Q) -> (Q -> P) -> P = Q.` in Coq?

I want to prove or falsify forall (P Q : Prop), (P -> Q) -> (Q -> P) -> P = Q. in Coq. Here is my approach. Inductive True2 : Prop := | One : True2 | Two : True2. Lemma True_has_one : forall (t0 t1 : True), t0 = t1. Proof. intros. destruct…
TorosFanny
  • 1,702
  • 1
  • 16
  • 25
8
votes
1 answer

Inversion produces unexpected existT in Coq

Here is an inductive type pc that I am using in a mathematical theorem. Inductive pc ( n : nat ) : Type := | pcs : forall ( m : nat ), m < n -> pc n | pcm : pc n -> pc n -> pc n. And another inductive type pc_tree, which is basically a binary…
user287393
  • 1,221
  • 8
  • 13
8
votes
1 answer

Coq: Ltac definitions over variable argument lists?

While trying to create an Ltac definition that loops over a variable-length argument list, I encountered the following unexpected behavior on Coq 8.4pl2. Can anyone explain it to me? Ltac ltac_loop X := match X with | 0 => idtac "done" | _ =>…
Kevin Hamlen
  • 185
  • 3
8
votes
1 answer

Coq: adding a "strong induction" tactic

"Strong" (or "complete") induction on the natural number means that when proving the induction step on n, you can assume the property holds for any k Theorem strong_induction: forall P : nat -> Prop, (forall n : nat, (forall k : nat, (k < n -> P…
Gadi A
  • 3,449
  • 8
  • 36
  • 54
8
votes
1 answer

Coq - use Prop (True | False) in if ... then ... else

I'm kind of new to Coq. I'm trying to implement a generic version of insertion sort. I'm implementing is as a module that takes a Comparator as a parameter. This Comparator implements comparison operators (such as is_eq, is_le, is_neq, etc.). In…
feet
  • 103
  • 1
  • 8
7
votes
5 answers

How to prove (forall x, P x /\ Q x) -> (forall x, P x)

How does one prove (forall x, P x /\ Q x) -> (forall x, P x) in Coq? Been trying for hours and can't figure out how to break down the antecedent to something that Coq can digest. (I'm a newb, obviously :)
Farley Knight
  • 1,795
  • 1
  • 13
  • 17
7
votes
1 answer

Is it possible to turn unification errors into goals in Coq?

I've been working on a formalization for a process calculus in Coq (repository here), and constantly find myself trying to apply a function which fails because of equivalent, but syntactically different, subterms. This often happens because of…
paulotorrens
  • 2,286
  • 20
  • 30