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

Coq: how to apply one hypothesis to another

Assume I have two hypotheses in the context, a_b : A -> B and a : A. I should be able to apply a_b to a to gain a further hypothesis, b : B. That is, given the following state: 1 subgoal A : Prop B : Prop C : Prop a_b : A -> B a :…
jameshfisher
  • 34,029
  • 31
  • 121
  • 167
10
votes
1 answer

Building a class hierarchy in Coq?

I can naively construct a hierarchy of algebraic structures in Coq using type classes. I'm having some trouble finding resources on Coq's syntax and semantics for type classes. However, I believe the following is a correct implementation of…
emi
  • 5,380
  • 1
  • 27
  • 45
10
votes
2 answers

How to do cases with an inductive type in Coq

I wan to use the destruct tactic to prove a statement by cases. I have read a couple of examples online and I'm confused. Could someone explain it better? Here is a small example (there are other ways to solve it but try using destruct): Inductive…
Skuge
  • 1,010
  • 2
  • 11
  • 28
10
votes
2 answers

How to map Type to Value in Idris/Agda/Coq?

I'm trying to define a function named byteWidth, which captures the usage about "get byte width of specific atomic type". My 1st trial: byteWidth : Type -> Int byteWidth Int = 8 byteWidth Char = 1 And the Idris compiler complains: "When checking…
luochen1990
  • 3,689
  • 1
  • 22
  • 37
10
votes
2 answers

How is Coq's parser implemented?

I was entirely amazed by how Coq's parser is implemented. e.g. https://softwarefoundations.cis.upenn.edu/lf-current/Imp.html#lab347 It's so crazy that the parser seems ok to take any lexeme by giving notation command and subsequent parser is able to…
Jason Hu
  • 6,239
  • 1
  • 20
  • 41
10
votes
2 answers

Agda-like programming in Coq/Proof General?

Unlike Agda, Coq tends to separate proofs from functions. The tactics Coq gives are great for writing proofs, but I'm wondering if there is a way to replicate some Agda-mode functionality. Specifically, I'd like: Some equivalent of Agda's ? or…
jmite
  • 8,171
  • 6
  • 40
  • 81
10
votes
1 answer

Coq can't find subterm when using rewrite tactic

I'm trying to do a modified proof of compile_correct from the first chapter of Certified Programming with Dependent Types. In my version, I try to make use of the fact that progDenote is a fold, and use a weaker inductive hypothesis in the proof of…
Kester Tong
  • 191
  • 8
10
votes
2 answers

How to disable my custom notation in Coq?

I've defined a notation to simulate imperative style programming by Notation "a >> b" := (b a) (at level 50). However after that, all function-application expression are represented as '>>' style. For example, in proof mode of Coq Toplevel, I can…
xywang
  • 941
  • 8
  • 24
10
votes
1 answer

What is the difference between "Qed" and "Defined"?

In the interactive theorem prover Coq, any interactive proof or definition can be terminated with either Qed or Defined. There is some concept of "opacity" which Qed enforces but Defined does not. For instance, the book Certified Programming with…
Lily Chung
  • 2,919
  • 1
  • 25
  • 42
10
votes
1 answer

coq error when trying to use Case. Example from Software Foundations book

I am trying to learn Coq by working through the online Software Foundations book: http://www.cis.upenn.edu/~bcpierce/sf/ I'm using the interactive command line Coq interpreter coqtop. In the induction chapter…
John
  • 2,012
  • 2
  • 21
  • 33
10
votes
1 answer

Consistent formulations of sets in Coq?

I'm quite new at Coq and trying to develop a framework based on my research. My work is quite definition-heavy and I'm having trouble encoding it because of how Coq seems to treat sets. There are Type and Set, which they call 'sorts', and I can use…
mhelvens
  • 4,225
  • 4
  • 31
  • 55
10
votes
1 answer

Finite map example

For my application, I need to use and reason about finite maps in Coq. Googling around I've found about FMapAVL which seems to be a perfect fit for my needs. The problem is that the documentation is scarce, and I haven't figured out how I am…
Juan A. Navarro
  • 10,595
  • 6
  • 48
  • 52
10
votes
1 answer

existential instantiation and generalization in coq

Can someone please give me a simple example of existential instantiation and existential generalization in Coq? When I want to prove exists x, P, where P is some Prop that uses x, I often want to name x (as x0 or some such), and manipulate P. Can…
Mayer Goldberg
  • 1,378
  • 11
  • 23
9
votes
1 answer

recursively invert hypotheses in coq

I am having trouble defining a tactic to recursively invert hypotheses in a proof context. For instance, suppose I have a proof context containing a hypothesis like: H1 : search_tree (node a (node b ll lr) (node c rl rr)) and would like to…
emi
  • 5,380
  • 1
  • 27
  • 45
9
votes
6 answers

Interactive math proof system

I'm looking for a tool (GUI preferred but CLI would work) that allows me to input math expressions and then perform manipulations of them but restricts me to only mathematically valid operations. Also, the tool must be able to save a session and…
BCS
  • 75,627
  • 68
  • 187
  • 294