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

Real numbers in Coq

In https://www.cs.umd.edu/~rrand/vqc/Real.html#lab1 one can read: Coq's standard library takes a very different approach to the real numbers: An axiomatic approach. and one can find the following axiom: Axiom completeness : ∀E:R → Prop, …
Bruno
  • 95
  • 3
9
votes
1 answer

Equal indexed inductive types implies equal indices

Let's have an inductive type foo indexed by x : X. Parameter X : Type. Inductive foo : X -> Type := | constr : forall (x : X), foo x. I'm curious, if foo x = foo y implies x = y. I'm out of ideas how to prove this. Lemma…
tom
  • 1,520
  • 1
  • 12
  • 26
9
votes
1 answer

"Non strictly positive occurrence of ..."

I try to define the following type Inductive t : Type -> Type := | I : t nat | F : forall A, (t nat -> t A) -> t A. and I get the following error: Non strictly positive occurrence of "t" in "forall A : Type, (t nat -> t A) -> t A". What does…
Nicolás
  • 303
  • 2
  • 6
9
votes
2 answers

What is a constructor in Coq?

I am having trouble understanding the principles of what a constructor is and how it works. For example, in Coq, we have been taught to define the natural numbers like this: Inductive nat : Type := | O : nat | S : nat -> nat. And have been…
Jerome
  • 275
  • 2
  • 7
9
votes
2 answers

Extensible tactic in Coq

Let’s say I have a fancy tactic that solves lemmas of a certain kind: Ltac solveFancy := some_preparation; repeat (first [important_step1 | important_step2]; some_cleanup); solve_basecase. Now I use this tactic to prove further…
Joachim Breitner
  • 25,395
  • 6
  • 78
  • 139
9
votes
1 answer

What can Coq do while Agda/Idris can't do?

Coq is a proof assistant, while Agda/Idris are programming languages (although they can be called proof assistants). I was exploring these languages and I wonder if Agda/Idris are sufficient to do everything that Coq can do. So, is there some…
ice1000
  • 6,406
  • 4
  • 39
  • 85
9
votes
3 answers

Nested recursion and `Program Fixpoint` or `Function`

I’d like to define the following function using Program Fixpoint or Function in Coq: Require Import Coq.Lists.List. Import ListNotations. Require Import Coq.Program.Wf. Require Import Recdef. Inductive Tree := Node : nat -> list Tree ->…
Joachim Breitner
  • 25,395
  • 6
  • 78
  • 139
9
votes
2 answers

How to call proof asistant Coq from external software

How to call proof assistant Coq from external software? Does Coq have some API? Is Coq command line interface rich enough to pass arguments in file and receive response in file? I am interested in Java or C++ bridges. This is legitimate question.…
TomR
  • 2,696
  • 6
  • 34
  • 87
9
votes
0 answers

How to extract the second element of Sigma on the Calculus of Constructions?

I'm attempting to do that as follows: λ (A : *) -> λ (B : (A -> *)) -> λ (t : (∀ (r : *) -> (∀ (x : a) -> (B x) -> r)) -> r) -> (t (B (t A (λ (x : A) -> λ (y : (B x)) -> x))) (λ (x : A) -> λ (y : (B x)) -> y)) Notice that, since the value…
MaiaVictor
  • 51,090
  • 44
  • 144
  • 286
9
votes
1 answer

How can I rewrite "+ 1" (plus one) to "S" (succ) in Coq?

I have the following Lemma with an incomplete proof: Lemma s_is_plus_one : forall n:nat, S n = n + 1. Proof. intros. reflexivity. Qed. This proof fails with Unable to unify "n + 1" with "S n". It seems like eq_S would be the way to prove this,…
Langston
  • 1,083
  • 10
  • 26
9
votes
3 answers

can I force Coq to print parentheses?

I'm new to Coq, working on set-theoretic proof writing. I realized that parentheses are omitted, and it makes difficult for me to read the formula. For example, 1 subgoal A, B : {set T} H : B \subset A ______________________________________(1/1) A…
Pengin
  • 771
  • 1
  • 10
  • 16
9
votes
2 answers

What's the difference between revert and generalize tactics in Coq?

From the Coq reference manual (8.5p1), my impression is that revert is the inverse of intro, but so is generalize to a certain extent. For example, revert and generalize dependent below seem to be the same. Goal forall x y: nat, 1 + x = 2 + y -> 1 +…
thor
  • 21,418
  • 31
  • 87
  • 173
9
votes
0 answers

Idris type system properties

Is it theoretically possible to convert any Coq proof to Idris or there are any limitations? More abstract question: Where does Idris type system fall on the lambda cube? The reason for these questions is that I'm trying to understand how (and if)…
svetlana
  • 308
  • 2
  • 8
9
votes
1 answer

Coq execution difference between semicolon ";" and period "."

Given a valid Coq proof using the ; tactical, is there a general formula for converting it to a valid equivalent proof with . substituted for ;? Many Coq proofs use the ; or tactic sequencing tactical. As a beginner, I want to watch the individual…
9
votes
1 answer

Proving False with negative inductive types in Coq

The third chapter of CPDT briefly discusses why negative inductive types are forbidden in Coq. If we had Inductive term : Set := | App : term -> term -> term | Abs : (term -> term) -> term. then we could easily define a function Definition uhoh (t…
user287393
  • 1,221
  • 8
  • 13