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

Rewrite tactic fails to find term occurrence within pattern matching

In Coq, I'm having problems with applying the rewrite tactic in the following situation: Section Test. Hypothesis s t : nat -> nat. Hypothesis s_ext_eq_t : forall (x : nat), s x = t x. Definition dummy_s : nat -> nat := fun n => match n…
Hanno
  • 549
  • 3
  • 10
9
votes
1 answer

Coqide Error: Compiled library Basics.vo makes inconsistent assumptions over library

i'm using CoqIDE_8.4pl5 on mac os X. This error message pops up when CoqIDE forwards to this command: Require Import Basics. Error: Compiled library Basics.vo makes inconsistent assumptions over library Coq.Init.Notations I didn't get this problem…
pheonixkid
  • 101
  • 1
  • 5
9
votes
2 answers

Why Coq doesn't allow inversion, destruct, etc. when the goal is a Type?

When refineing a program, I tried to end proof by inversion on a False hypothesis when the goal was a Type. Here is a reduced version of the proof I tried to do. Lemma strange1: forall T:Type, 0>0 -> T. intros T H. inversion H. (* Coq refuses…
larsr
  • 5,447
  • 19
  • 38
9
votes
1 answer

Unicode glyphs for keywords and operators in Coq/Proof General under Emacs

This question has to do with configuring the Coq mode within Proof General, in Emacs. I'm trying to have Emacs automatically replace keywords and notation in Coq with the corresponding Unicode glyphs. I managed to define fun to be the Greek…
Mayer Goldberg
  • 1,378
  • 11
  • 23
8
votes
0 answers

Which axioms may be safely added to Coq?

This question is a request for references or explanation. The main idea is: What if I add every axiom from standard library of Coq? Will it raise a contradiction or they are well-adjusted to each other? What are other reliable sources of information…
ged
  • 687
  • 7
  • 19
8
votes
0 answers

Definitional vs propositional equality in Coq lemma statements

When writing highly automated proofs in Coq (CPDT-style) proofs, building on extensive use of eauto N, I must often modify my lemma statements to allow eauto to use them easily. In particular, I must replace statements of form (1) forall vars, P (f…
Blaisorblade
  • 6,438
  • 1
  • 43
  • 76
8
votes
1 answer

Subset parameter

I have a set as a parameter: Parameter Q:Set. Now I want to define another parameter that is a subset of Q. Something like: Parameter F: subset Q. How I can define that? I guess I can add the restriction later as an axiom, but seems more natural…
GClaramunt
  • 3,148
  • 1
  • 21
  • 35
8
votes
1 answer

Can you automatically add Haskell import statements when extracting from Coq?

I'm doing an extraction from Coq to Haskell that requires importing a couple of modules on the Haskell end. Is there any Coq extraction feature that allows you to do this automatically? I know I could just write a script to do this but I'd prefer…
tlon
  • 413
  • 2
  • 6
8
votes
3 answers

Rigorous proof of the following C++ code's property?

Take the following C++14 code snippet: unsigned int f(unsigned int a, unsigned int b){ if(a>b)return a; return b; } Statement: the function f returns the maximum of its arguments. Now, the statement is "obviously" true, yet I failed to…
Adam
  • 1,342
  • 7
  • 15
8
votes
2 answers

Is it possible to write C programs using Coq?

I know that one can extract Coq programs into Haskell and OCaml programs. Is there a way to do this with C? I am imagining a library that models the C language. Maybe such a library would contain a collection of axioms about how C constructs…
Mark
  • 5,286
  • 5
  • 42
  • 73
8
votes
1 answer

What is difference between `destruct` and `case_eq` tactics in Coq?

I understood destruct as it breaks an inductive definition into its constructors. I recently saw case_eq and I couldn't understand what it does differently? 1 subgoals n : nat k : nat m : M.t nat H : match M.find (elt:=nat) n m with | Some _ =>…
abhishek
  • 850
  • 6
  • 14
8
votes
1 answer

Overloading notation for different types in Coq

I would like to be able to define the same Coq notations for different inductive definitions, and distinguish the notations based on the types of their arguments. Here is a minimal example: Inductive type : Type := | TBool : type. Inductive term1…
amaurremi
  • 777
  • 1
  • 5
  • 11
8
votes
1 answer

How to express "there exists a unique X" in Coq?

I was wondering if there is a succinct way of writing that there exists a unique something (i.e. write unique existential quantifier) in Coq? For example, to say that there exists an x s.t. 2 + x = 4: Goal exists x, 2 + x = 4. How can I write that…
thor
  • 21,418
  • 31
  • 87
  • 173
8
votes
2 answers

How do I read the definition of ex_intro?

I'm reading Mike Nahas's introductory Coq tutorial, which says: The arguments to "ex_intro" are: the predicate the witness a proof of the predicated called with the witness I looked at the definition: Inductive ex (A:Type) (P:A -> Prop) : Prop…
Chris Martin
  • 30,334
  • 10
  • 78
  • 137
8
votes
1 answer

Purpose of maximal vs non-maximal implicit arguments

I have just discovered the existence of maximal and non-maximal arguments (see documentation). But is there some motivation to use one over the other? Is one more recent than the other? Maximal implicit arguments simply need {} to be created,…
eponier
  • 3,062
  • 9
  • 20