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 to solve goals with invalid type equalities in Coq?

My proof scripts are giving me stupid type equalities like nat = bool or nat = list unit which I need to use to solve contradictory goals. In normal math, this would be trivial. Given sets bool := { true, false } and nat := { 0, 1, 2, ... } I know…
nobody
  • 4,074
  • 1
  • 23
  • 33
7
votes
2 answers

Unable to provide long (1024+ character) inputs to the OCaml toplevel and coqtop (and Proof General)

Edit 4: It turns out that this is actually just a limitation of TTY input in general; there's nothing specific about OCaml, Coq, or Emacs which is causing the problem. I'm working on a Coq program using Proof General in Emacs, and I've found a bug…
Antal Spector-Zabusky
  • 36,191
  • 7
  • 77
  • 140
7
votes
3 answers

How can I prove propositional extensionality in Coq?

I'm trying to prove a substitution theorem about Prop, and I'm failing miserably. Can the following theorem be proven in coq, and if not, why not. Theorem prop_subst: forall (f : Prop -> Prop) (P Q : Prop), (P <-> Q) -> ((f P) <-> (f…
Mayer Goldberg
  • 1,378
  • 11
  • 23
6
votes
1 answer

Destructing on the result of applying a predicate function

I'm new to Coq and have a quick question about the destruct tactic. Suppose I have a count function that counts the number of occurrences of a given natural number in a list of natural numbers: Fixpoint count (v : nat) (xs : natlist) : nat := …
Alan O'Donnell
  • 1,276
  • 9
  • 17
6
votes
0 answers

How does one automatically make a `COQ_PROJ.opam` install script automatically from a Coq Project/Package?

I have a very long list of coq projects I want to automatically install with opam pin/install. I'd like to install them with opam because I am using this python tool (PyCoq) that uses opam pin/install. How can I automatically create a COQ_PROJ.opam…
Charlie Parker
  • 5,884
  • 57
  • 198
  • 323
6
votes
2 answers

Avoid duplicating code for applying tactics in both hypothesis and goal

I find my self (sort of) duplicating code because I want to the same tactics in the goal and in a hypothesis when they match. For example: match goal with | H : PATTERN |- _ => simpl in H; rewrite X in H; ... ; other_tactic in H | |- PATTERN …
Kristian
  • 1,667
  • 2
  • 15
  • 20
6
votes
2 answers

How to define Xor in Coq and prove its properties

This should be an easy question. I'm new with Coq. I want to define the exclusive or in Coq (which to the best of my knowledge is not predefined). The important part is to allow for multiple propositions (e.g. Xor A B C D). I also need the two…
Skuge
  • 1,010
  • 2
  • 11
  • 28
6
votes
2 answers

Pattern matching not specialising types

I'm playing around in Coq, trying to create a sorted list. I just wanted a function that takes a list [1,2,3,2,4] and would return something like Sorted [1,2,3,4] - i.e. taking out the bad parts, but not actually sorting the entire list. I thought I…
Amos Robinson
  • 729
  • 5
  • 10
6
votes
1 answer

How to temporarily disable notations in Coq

Notations are convenient when you're familiar with a project but can be confusing when you're just starting with a code base. I know you can turn off all notations with the vernacular Set Printing All. However, I want to keep some printing off, such…
sdpoll
  • 426
  • 2
  • 12
6
votes
1 answer

How to step through semicolons separated tactics sequence in coqide?

when constructing proof in coqide, I didn't find a way to step though T1; T2; T3; ...; Tn. one tactic by one tactic. So it became very difficult to construct correct proof like the code above. So my question is Is there a way to step through the…
lambda
  • 63
  • 3
6
votes
1 answer

Infinite recursive types in Coq (for Bananas and Lenses)

I'd like to see a Coq version of the Bananas, Lenses, etc. They are built up in the excellent series of blog posts at sumtypeofway Introduction to Recursion schemes However, the blog post is in Haskell, which permits infinite non-terminating…
larsr
  • 5,447
  • 19
  • 38
6
votes
4 answers

Defining recursive function over product type

I'm trying to formalize each integer as an equivalence class of pairs of natural numbers, where the first component is the positive part, and the second component is the negative part. Definition integer : Type := prod nat nat. I want to define a…
Mark
  • 5,286
  • 5
  • 42
  • 73
6
votes
2 answers

Induction on evidence for the "less than" relation in coq

I am working on the proof of the following theorem Sn_le_Sm__n_le_m in IndProp.v of Software Foundations (Vol 1: Logical Foundations). Theorem Sn_le_Sm__n_le_m : ∀n m, S n ≤ S m → n ≤ m. Proof. intros n m HS. induction HS as [ | m' Hm' IHm']. …
hengxin
  • 1,867
  • 2
  • 21
  • 42
6
votes
1 answer

Prove that the powerset of a finite set is finite using Coq

While trying to prove some things, I encountered an innocent looking claim that I failed to prove in Coq. The claim is that for a given Finite Ensemble, the powerset is also finite. The statement is given in the Coq code below. I looked through the…
Herman Bergwerf
  • 143
  • 1
  • 5
6
votes
1 answer

Shorter notation for matching hypotheses in Coq?

I find myself often wanting to refer to hypotheses by their type rather than by their name; especially in proofs with inversions on semantic rules, i.e., rules with several cases each of which may have multiple antecedents. I know how to do this…
tbrk
  • 1,290
  • 1
  • 13
  • 20