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
7
votes
2 answers

How do you look up where identifiers are defined in Coq efficiently?

In most IDEs or text editors, you can right-click a term and it takes you to the file where that term is defined. CoqIDE doesn't seem to have that, so I've been doing coqdoc myfile.v --html, then going to the generated HTML docs. But the only…
Lance
  • 75,200
  • 93
  • 289
  • 503
7
votes
1 answer

CoqIDE loadpath error for ssreflect

I am a Coq newbie and therefore to improve my understanding of proof checking I am trying to use the Ssreflect library. I have installed Ssreflect v 1.5 on a Mac OS v 10.10.3 ( Yosemite ) which runs at the Terminal. However when I tried to load…
David
  • 439
  • 1
  • 4
  • 15
7
votes
2 answers

How to destruct pair equivalence in Coq?

I'm trying to destruct a pair equivalence hypothesis in proof when using Coq. But I didn't find the tactic for me. The case is: a, b, a', b' : nat H0 : (a, b) = (a', b') I want to destruct the pairs in H0 to generate H1 : a = a' H2 : b = b' How…
xywang
  • 941
  • 8
  • 24
7
votes
1 answer

How to match a "match" expression?

I am trying to write a rule for hypotheses, formulated with a help of match construction: Goal forall x:nat, (match x with | 1 => 5 | _ => 10 end = 5 -> x = 1)%nat. intros. x : nat H : match x with | 0%nat => 10%nat | 1%nat => 5%nat | S…
Necto
  • 2,594
  • 1
  • 20
  • 45
7
votes
3 answers

Rewriting a match in Coq

In Coq, suppose I have a fixpoint function f whose matching definition on (g x), and I want to use a hypothesis in the form (g x = ...) in a proof. The following is a minimal working example (in reality f, g would be more complicated): Definition g…
holdenlee
  • 969
  • 1
  • 8
  • 21
7
votes
1 answer

Coq: keeping information in a match statement

I'm building a recursive function that does a match on a list l. In the cons branch I need to use the information that l = cons a l' in order to prove that the recursive function terminates. However, when I use match l the information gets…
larsr
  • 5,447
  • 19
  • 38
7
votes
1 answer

Apply a function to both sides of an equality in Coq?

I'm in Coq trying to prove that Theorem evenb_n__oddb_Sn : ∀n : nat, evenb n = negb (evenb (S n)). I'm using induction on n. The base case is trivial, so I'm at the inductive case and my goal looks like: k : nat IHk : evenb k = negb (evenb (S…
limp_chimp
  • 13,475
  • 17
  • 66
  • 105
7
votes
2 answers

How to "flip" an equality proposition in Coq?

If I'm in Coq and I find myself in a situation with a goal like so: ================== x = y -> y = x Is there a tactic that can can take care of this in one swoop? As it is, I'm writing intros H. rewrite -> H. reflexivity. But it's a bit…
limp_chimp
  • 13,475
  • 17
  • 66
  • 105
7
votes
1 answer

Coq tactic for record equality?

In Coq, when attempting to prove equality of records, is there a tactic that will decompose that into equality of all of its fields? For example, Record R := {x:nat;y:nat}. Variables a b c d : nat. Lemma eqr : {|x:=a;y:=b|} = {|x:=c;y:=d|}. Is…
Ashley Yakeley
  • 664
  • 4
  • 11
7
votes
1 answer

With Coq Proof General, Emacs executes on every period. How do I stop it?

I'm using Proof General in Emacs on Aquamacs and every time I write a period (".") everything is executed (up to that period). It seems like an electric behavior but it's not. All other keys behave normally. I know that this is some mode that…
Skuge
  • 1,010
  • 2
  • 11
  • 28
7
votes
1 answer

Coq -- understanding `forall` syntax

I'm learning Coq by reading the book "Certified Programming with Dependent Types" and I'm having trouble udnerstanding forall syntax. As an example let's think this mutually inductive data type: (code is from the book) Inductive even_list : Set := |…
sinan
  • 6,809
  • 6
  • 38
  • 67
7
votes
1 answer

Concoqtion (Coq + MetaOCaml) - why abandoned?

Before bugging people on the OCaml mailing list, I thought I might post my question here. I just discovered this beauty (link to Concoqtion website). Concoqtion is an extension of MetaOCaml which allows indexed types (and perhaps a lot more). With…
Olle Härstedt
  • 3,799
  • 1
  • 24
  • 57
7
votes
1 answer

__ in Ocaml extracted from Coq

Ocaml code extracted from Coq includes (in some cases) a type __ and a function __ defined as follows: type __ = Obj.t let __ = let rec f _ = Obj.repr f in Obj.repr f The documentation says that in the past, such type was defined as unit (and thus…
David Monniaux
  • 1,948
  • 12
  • 23
7
votes
1 answer

Limitations of Fixpoint in Coq?

I am fooling around with Coq. Specifically, I am trying to implement mergesort and then prove that it works. My attempt at an implementation was: Fixpoint sort ls := match ls with | nil => nil | cons x nil => cons x nil | xs => let (left, right)…
mushroom
  • 6,201
  • 5
  • 36
  • 63
7
votes
2 answers

How to use rewrite on a subexpression of the current goal

In coq, is it somehow possible to apply a lemma or hypothesis to a subexpression of the current goal? For example I would like to apply the fact that plus is commutative in order to swap 3 and 4 in this example. Require Import…