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

no error with assert (goal) but error with cut (goal)

I'm confused as to why assert and cut are behaving differently in this case. I am trying to prove this lemma with the ssreflect seq library. Lemma subseq_add_both: forall{A: eqType} (L1 L2: seq A) (a: A), subseq L1 L2 -> subseq (a:: L1) (a ::…
push33n
  • 398
  • 4
  • 12
1
vote
1 answer

Under what circumstances is equality of equalities decidable?

Consider the following goals: Goal forall (x y: I = I), x = y. Proof. Abort. Goal forall (x y: tt = tt), x = y. Proof. Abort. Both I and tt are members of singleton types. The former lives in Prop, the latter in Set. These are very uncomplicated…
Carl Patenaude Poulin
  • 6,238
  • 5
  • 24
  • 46
1
vote
1 answer

Simple syntax for terms of decidable subset types

I have a type BoundedNat n, representing natural numbers smaller than n. My current implementation is as follows: Definition BoundedNat n := {x : nat | x < n}. Manipulating elements of type BoundedNat n is relatively heavyweight. I constantly need…
Carl Patenaude Poulin
  • 6,238
  • 5
  • 24
  • 46
1
vote
1 answer

Does Gallina have an equivalent of Haskell's `$` or Ocaml's `@@`

Does the Gallina language in Coq have a predefined operator that helps avoid parentheses like Haskell's $ or OCaml's @@? If not, is there a conventional one that people define using Notation?
Max Heiber
  • 14,346
  • 12
  • 59
  • 97
1
vote
1 answer

How to make an inverse function in coq

I have a following code. I didn't write the full code, but this should work. Definition in_domain {X Y : Set} (f : X -> option Y) x := match (f x) with | Some y => True | None => False end. Definition injective {X Y : Set} (f : X -> option Y) :=…
user5876164
  • 471
  • 3
  • 15
1
vote
1 answer

tactical for introducing a hypothesis and then immediately doing another tactic on it

When my proof state is of the form H -> goal I often use the pattern intros H. *some tactic* H. where some tactic could be "inversion" or "apply _ in", etc. It would be nice if there was some tactical which combined these two steps, ie, something…
push33n
  • 398
  • 4
  • 12
1
vote
2 answers

How to prove that (0 = 2) -> false in Coq?

In a proof of one lemma I eventually reached a state, where I have a premise H : 0 = 2 and I have to prove false. Question: how to infer that the premise H is false to conclude the proof?
mercury0114
  • 1,341
  • 2
  • 15
  • 29
1
vote
0 answers

Looking for some help understanding where I'm going from (Software Foundations, Binom.v)

I am working through Software Foundations and am a bit stuck. Here is a link for reference: https://softwarefoundations.cis.upenn.edu/vfa-current/Binom.html I am stuck on the proof "abs_perm," reproduced here. Theorem abs_perm: forall p al bl, …
A Question Asker
  • 3,339
  • 7
  • 31
  • 39
1
vote
0 answers

Coq proof automation not working like I expect

I'm currently working on RedBlack from software foundations...I'm up to "ins_is_redblack" (you can find it here https://softwarefoundations.cis.upenn.edu/vfa-current/Redblack.html). I'm struggling to figure out why my match goal isn't working. The…
A Question Asker
  • 3,339
  • 7
  • 31
  • 39
1
vote
2 answers

Why can't Coq unify goal and hypothesis?

After some work on an exercise, I've reached the following proof state: (tail1 is a nat list pattern generator, lng is generalized) 1 subgoal n' : nat IH_n' : forall lng : nat, lng > n' -> nth n' (update (tail1 lng) 0 1) 9 = 1 lng : nat H : S lng >…
Attila Karoly
  • 951
  • 5
  • 13
1
vote
2 answers

Can't prove trivial lemma about function with non-standard recursion

I'm having a great difficulty trying to prove even very simple lemmas about a function I defined. This is my definition: Require Import List. Require Export Omega. Require Export FunInd. Require Export Recdef. Notation "A :: B" := (cons A…
bfbonatto
  • 21
  • 3
1
vote
1 answer

How to use de-morgan law in Coq to replace "not forall" by "exists"?

I am learning the Coq language and trying to prove the following statement: Lemma ex4: forall (X : Set) (P : X -> Prop), ~(forall x, ~ (P x)) -> (exists x, (P x)). In the beginning of my proof: Proof. intros X P A. I arrive at the point where I…
mercury0114
  • 1,341
  • 2
  • 15
  • 29
1
vote
2 answers

strictly positive vs ill-formed regular expressions in Coq

We are a few people learning Coq and we are trying to define an Inductive predicate for the denotation of regular expressions, which represents a set of sequences. This seems to run into the strictly positive limitation, since we allow not as an…
1
vote
2 answers

Define basic inductive types in coq

Very basic question about coq. How do I define the following two inductive types? Type 1 containing: o fo, ffo, fffo... k, sk, ssk, sssk... Note that the f here could alternatively be characterized as the natural number index for o. Type 2…
Tony
  • 343
  • 1
  • 6
  • 15
1
vote
1 answer

How proof functions prove?

It'd help my understanding the 'programs/proofs' parallelism if somebody was kind enough to explain me how the proof function is used in the following simple case: Theorem ex1: forall n:nat, 7*5 < n -> 6*6 <= n. Proof. intros. …
Attila Karoly
  • 951
  • 5
  • 13