Skip to Content.
Sympa Menu

coq-club - [Coq-Club] Inside a branch of a match block, how do I use the assertion that the matched expression is equal to the branch's data constructor expression?

coq-club AT inria.fr

Subject: The Coq mailing list

List archive

[Coq-Club] Inside a branch of a match block, how do I use the assertion that the matched expression is equal to the branch's data constructor expression?


Chronological Thread 
  • From: <abc.deaf.xyz AT gmail.com>
  • To: coq-club AT inria.fr
  • Subject: [Coq-Club] Inside a branch of a match block, how do I use the assertion that the matched expression is equal to the branch's data constructor expression?
  • Date: Sat, 29 Dec 2012 20:37:39 +0100 (CET)

I am trying to develop a programming style that is based on preventing bad
input as soon as possible. For example, instead of the following plausible
definition for the predecessor function on the natural numbers:

Definition pred1 n :=
match n with
| O => None
| S n => Some n
end.

I want to write it as follows:

Theorem nope n (p : n = O) (q : n <> O) : False.
contradict q.
exact p.
Qed.

Definition pred2 n (q : n <> O) :=
match n with
| S n => n
| O =>
let p := _ in
match nope n p q with end
end.

My problem is... what do I fill in the hole in the let clause? My intuition
suggests me that every clause of a `match` block must introduce an assumption
that the matched expression (in this case, `n`) is equal to the clause's data
constructor (in this case, `O`). In short, there must be some `assumption : n
= O`. Does Coq indeed introduce such an assumption? If so, what is its name?



Archive powered by MHonArc 2.6.18.

Top of Page