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
14
votes
1 answer

What's the difference between Program Fixpoint and Function in Coq?

They seem to serve similar purposes. The one difference I've noticed so far is that while Program Fixpoint will accept a compound measure like {measure (length l1 + length l2) }, Function seems to reject this and will only allow {measure length…
LogicChains
  • 4,332
  • 2
  • 18
  • 27
14
votes
1 answer

Why are logical connectives and booleans separate in Coq?

I come from a JavaScript/Ruby programming background and am used to this being how true/false works (in JS): !true // false !false // true Then you can use those true/false values with && like var a = true, b = false; a && !b; So and and not (and…
Lance
  • 75,200
  • 93
  • 289
  • 503
14
votes
3 answers

Formalizing computability theory in Coq

I'm trying to teach myself Coq by formalizing formalize a mathematical theorem I'm familiar with: the undecidability of the halting problem various theorems in computability theory. Since I'm not interested in formalizing the details of…
Pteromys
  • 1,441
  • 2
  • 12
  • 29
14
votes
1 answer

Is there a way to prove properties about my C++ programs?

I understand how languages like Coq and Idris can be used to prove properties of programs written in those languages (judging by my little experience in the subject.), but I wonder if there's an approachable way to do the same externally, on an…
Jakub Arnold
  • 85,596
  • 89
  • 230
  • 327
14
votes
2 answers

Replicating the 'Taint mode' from 'Fortify static checking tool' in Haskell

I've read some documentation of the Fortify static checking tool. One of the concepts used by this tool are called taints. Some sources, such as web requests, provide data that is tainted in one or more ways and some sinks, such as web responses,…
aleator
  • 4,436
  • 20
  • 31
14
votes
3 answers

Error in defining Ackermann in Coq

I am trying to define the Ackermann-Peters function in Coq, and I'm getting an error message that I don't understand. As you can see, I'm packaging the arguments a, b of Ackermann in a pair ab; I provide an ordering defining an ordering function for…
Mayer Goldberg
  • 1,378
  • 11
  • 23
13
votes
2 answers

How do I import modules in Coq?

I'm having trouble importing definitions from modules in Coq. I'm new to Coq, but couldn't solve the problem using the language's reference manual or online tutorial. I have a module that defines a signature and axioms for finite sets, which I…
emi
  • 5,380
  • 1
  • 27
  • 45
13
votes
2 answers

Can I tell Coq to do induction from n to n+2?

I'm trying to see if it's possible to prove evenb n = true <-> exists k, n = double k from https://softwarefoundations.cis.upenn.edu/lf-current/Logic.html without involving odd numbers at all. I tried something like the following: Theorem…
Max Ng
  • 449
  • 1
  • 4
  • 10
13
votes
2 answers

Why are the real numbers axiomatized in Coq?

I was wondering whether Coq defined the real numbers as Cauchy sequences or Dedekind cuts, so I checked Coq.Reals.Raxioms and... none of these two. The real numbers are axiomatized, along with their operations (as Parameters and Axioms). Why is it…
V. Semeria
  • 3,128
  • 1
  • 10
  • 25
13
votes
2 answers

How do I provide implicit arguments explicitly in Coq?

Suppose I have a definition f : x -> y -> z where x can be easily inferred. I therefore choose to make x an implicit argument using Arguments. Consider the following example: Definition id : forall (S : Set), S -> S := fun S s => s. Arguments id…
Tobia Tesan
  • 1,938
  • 17
  • 29
13
votes
1 answer

Coq simpl for Program Fixpoint

is there anything like the tactic simpl for Program Fixpoints? In particular, how can one proof the following trivial statement? Program Fixpoint bla (n:nat) {measure n} := match n with | 0 => 0 | S n' => S (bla n') end. Lemma obvious: forall n,…
ouler
  • 133
  • 6
13
votes
3 answers

How to duplicate a hypothesis in Coq?

During a proof, I encountered an hypothesis H. I have lemmas: H -> A and H -> B. How can I duplicate H in order to deduce two hypotheses A and B ? edited: More precisely, I have: lemma l1: X -> A. lemma l2: X -> B. 1 subgoals, subgoal 1 (ID:…
Necto
  • 2,594
  • 1
  • 20
  • 45
13
votes
2 answers

How to unfold a recursive function just once in Coq

Here is a recursive function all_zero that checks whether all members of a list of natural numbers are zero: Require Import Lists.List. Require Import Basics. Fixpoint all_zero ( l : list nat ) : bool := match l with | nil => true | n :: l'…
user287393
  • 1,221
  • 8
  • 13
13
votes
1 answer

Converting Coq to Idris

What would be some useful guidelines for converting Coq source to Idris (e.g. how similar are their type systems and what can be made of translating the proofs)? From what I gather, Idris' built-in library of tactics is minimal yet extendable, so I…
Arets Paeglis
  • 3,856
  • 4
  • 35
  • 44
13
votes
4 answers

Proving f (f bool) = bool

How can I in coq, prove that a function f that accepts a bool true|false and returns a bool true|false (shown below), when applied twice to a single bool true|false would always return that same value true|false: (f:bool -> bool) For example the…
Marcus Whybrow
  • 19,578
  • 9
  • 70
  • 90