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
1
vote
0 answers

I know of two ways to define the finite number type. Is there words to distinguish between the two?

I know of two ways to define the finite number type: (* The conditions are described in the type definition. *) Inductive fin (n : nat) := | O_fin : fin (S O) | S_fin : forall n : nat, fin n -> fin (S n). (* The conditions are defined by an…
Hexirp
  • 410
  • 2
  • 11
1
vote
1 answer

Why can I use the constructor tactic to prove reflexivity?

The constructor tactic allows you to discharge a goal which is an inductive datatype by automatically applying constructors. However, definitional equality is not an inductive product in Coq. Then why does Coq accept this proof? Example zeqz : 0 =…
NJay
  • 130
  • 8
1
vote
0 answers

How does one display an arbitrary programming language (e.g. Isabelle/Isar) in latex in their native display in *.pdf format?

I want to display the Isabelle/Isar and Coq languages in Latex, e.g. when I do coding format in a *.pdf format (for an academic paper). How do I do this? (I hope this generalizes to other languages like Python and Coq, so that is useful to…
Charlie Parker
  • 5,884
  • 57
  • 198
  • 323
1
vote
1 answer

Recursive function definition in coq with limit on set of possible inputs

I need to define a recursive function with no easily measurable argument. I keep a list of used arguments to ensure that each one is used at most once, and the input space is finite. Using a measure (inpspacesize - (length l)) works mostly, but I…
nobody
  • 4,074
  • 1
  • 23
  • 33
1
vote
1 answer

Programming c-like classes to run in Coq

I'm trying to come up with a syntax and semantics for a simple c-like program in coq. This is for a uni course I'm taking on the principles of programming languages. I have checked the site for similar questions and only found two threads that got…
1
vote
0 answers

How to print 'forall' as 'Π' in a one-time setting in coqdoc?

I was able to get coqdoc to print forall as Π, using (** printing forall %Π% #Π# *). However, it is a pain to add the description to all the files. Is it possible to do that for all files with just one setting? Note that I have to use -utf8, because…
Hexirp
  • 410
  • 2
  • 11
1
vote
1 answer

How to debug tactic failure in a match goal branch?

Let's say I have some complex tactics in the body of a match goal branch that can easily go wrong in a way I might need to debug. Is there a way to get the "real" error message from the branch if some tactic fails, rather than simply getting "Error:…
blaineh
  • 2,263
  • 3
  • 28
  • 46
1
vote
3 answers

What is the name of the programming style enabled by dependent types (think Coq or Agda)?

There is a programming "style" (or maybe paradigm, i'm not sure what to call it) which is as follows: First, you write a specification: a formal description of what your (whole, or part of) program is to do. This is done within the programming…
1
vote
1 answer

Effect of non zero term

I am new to Coq, I have f1 & f2 two functions whose input and output arguments are natural number.I want to ask that what ever be the output value of f1 and f2. Result should not be zero due to addition of non zero number.Therefore it should be…
zeesha huq
  • 17
  • 2
1
vote
0 answers

Counting of natural number

I have natural number list. Want to count number(a) in the list while a is not zero. I want to write a lambda that counts a in the list and gives some natural number at the output.Secondly if I have information that greatest element in the list is…
1
vote
2 answers

Defining functions inside proof scope

I'm trying to prove that injective functions are left invertible in Coq. I've reached a point in my proof where my goal is an "exists" proposition. I want to define a function that uses terms from proof scope (types and functions I've intro'ed…
1
vote
1 answer

Record Subtyping in Coq, questions and references requested

I've been looking for references discussing subtyping in Coq with respect to records, but have come up dry. I'm specifically wondering what the Record _ : _ := { _ :> * } syntax means, and how it behaves. Especially am confused when a Record has a…
user5775230
1
vote
1 answer

is there a tactic (other than inversion) that extracts implications from hypotheses?

say I have the following goal: To the human eye, it should be obvious that the only way H ends up being true is if n is either 7 or 21. I want to prove this using something like "Since H necessitates that n is either 7 or 21, the goal must be…
Blueper
  • 31
  • 3
1
vote
1 answer

VecUtil: take nth element of processed vector by two slightly different way

I want to prove trivial_request and think we need request_eq to prove trivial_request. Lemma request_eq : forall (n k:nat)(a b:Euc (S n))(H:(S k < S n)%nat), Vnth (request (λ _ : Euc 0, id) Vnil a b) H = Vnth (request (λ _ : Euc 0, id) Vnil (Vtail…
Daisuke Sugawara
  • 311
  • 4
  • 20
1
vote
1 answer

How do I write a proof for a switch statement with VST/ coq?

I had a question regarding the use of VST and switch statements. I am having trouble writing a proof that steps through the switch statement when there is a matching case for the switch variable. For example: I CAN write a proof for something like…
R2D2
  • 11
  • 1