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

Proofs' role in Coq extractions

I'm trying to understand what is the role of proofs in Coq extractions. I have the following example of floor integer division by two taken from here. For my first try I used the Admitted keyword: (*********************) (* div_2_even_number…
OrenIshShalom
  • 5,974
  • 9
  • 37
  • 87
7
votes
1 answer

Coq: Notation not importing from List

The title is pretty self-explanatory. I want to use the standard [] and ++ notations for lists. But they go unrecognized even after importing. See the following code. Require Import List. Check [1]. This results in the following error…
user11102091
7
votes
2 answers

How does one inspect what more complicated tactics do in Coq step-by-step?

I was trying to go through the famous and wonderful software foundations book but I got to an example where simpl. and reflexivity. just do to much under the covers and are hindering my learning & understanding. I was going through the following…
Charlie Parker
  • 5,884
  • 57
  • 198
  • 323
7
votes
1 answer

Is it possible to remove/override an existing coercion?

I have imported a Coq module which defines a coercion, but it does not fit my needs. Is there any way to remove or (locally) override it? To be specific, say the module I imported defines a coercion Coercion bool_to_nat (b:bool) := match b with…
Tony Beta Lambda
  • 529
  • 3
  • 18
7
votes
1 answer

Why does Coq.Init.Logic define the notation "A -> B"?

The Coq Standard Library file Coq.Init.Logic, which can be found here, contains the statement Notation "A -> B" := (forall (_ : A), B) : type_scope. I don't understand how this is possible, given that the symbol -> already has a built-in meaning. Is…
Stefan
  • 185
  • 4
7
votes
0 answers

Is it possible to normalize affine λ-calculus terms using PHOAS in Agda?

In Agda, one can conveniently represent λ-terms using PHOAS: data Term (V : Set) : Set where var : V → Term V abs : (V → Term V) → Term V app : Term V → Term V → Term V That approach has several benefits over Bruijn indices, as explained in…
MaiaVictor
  • 51,090
  • 44
  • 144
  • 286
7
votes
1 answer

The Coq :> symbol

This is probably super trivial, but I can't find any information about what the ':>' symbol means in Coq. What is the difference between: U : Type and W :> Type ?
Yasmine Shaorda
  • 383
  • 1
  • 7
7
votes
1 answer

Is there a type theory in which the equivalence of identically shaped inductive datatypes is representable?

Say I have two inductively defined datatypes: Inductive list1 (A : Type) : Type := | nil1 : list1 A | cons1 : A -> list1 A -> list1 A. and Inductive list2 (A : Type) : Type := | nil2 : list2 A | cons2 : A -> list2 A -> list2 A. For any P…
LogicChains
  • 4,332
  • 2
  • 18
  • 27
7
votes
1 answer

What is eq_rect and where is it defined in Coq?

From what I have read, eq_rect and equality seem deeply interlinked. Weirdly, I'm not able to find a definition on the manual for it. Where does it come from, and what does it state?
Siddharth Bhat
  • 823
  • 5
  • 15
7
votes
1 answer

Dealing with let-in expressions in current goal

I got stuck while doing some coq proofs around the state monad. Concretely, I've simplified the situation to this proof: Definition my_call {A B C} (f : A -> B * C) (a : A) : B * C := let (b, c) := f a in (b, c). Lemma mycall_is_call : forall {A…
neutropolis
  • 1,884
  • 15
  • 34
7
votes
3 answers

Is it possible to derive induction for the church-encoded Nat?

I was just wondering if it is possible to derive induction for the church-encoded Nat type on Idris, Agda, Coq and similar. Notice this is a different issue from doing it on CoC (which is known to be impossible) because we have much more…
MaiaVictor
  • 51,090
  • 44
  • 144
  • 286
7
votes
1 answer

Coq equality implementation

I'm writing a toy language where nodes in the AST can have any number of children (Num has 0, Arrow has 2, etc). You might call these operators. Additionally, exactly one node in the AST might be "focused". We index the data type with Z if it has a…
Joel Burget
  • 1,328
  • 8
  • 17
7
votes
1 answer

How to set the module name when extracting Coq to Haskell

When I extract/compile Coq to Haskell using Extraction Language Haskell. in the Coq file and running coqtop -compile mymodule.v > MyModule.hs, I get a Haskell module which starts with module Main where. Is there an option to set the resulting…
yairchu
  • 23,680
  • 7
  • 69
  • 109
7
votes
3 answers

How to do induction on the length of a list in Coq?

When reasoning on paper, I often use arguments by induction on the length of some list. I want to formalized these arguments in Coq, but there doesn't seem to be any built in way to do induction on the length of a list. How should I perform such an…
kainwen
  • 356
  • 1
  • 12
7
votes
1 answer

Canonical structures in ssreflect

I'm trying to deal with canonical structures in ssreflect. There are 2 pieces of code that I took from here. I will bring pieces for the bool and the option types. Section BoolFinType. Lemma bool_enumP : Finite.axiom [:: true; false]. Proof. by…