3

In the following:

Lemma test:
  forall n j  (jn : j < n)  (ln : j + 0 < n) (P:  forall {x} {y}, (x<y) -> nat),
    P ln = P jn.

Types ln an jn seems to be convertible to each other (from arithmetics point of view). How can I use that fact to prove the lemma above? I can easily prove assert(JL: j < n -> j + 0 < n) by auto. but I fail to see how to apply this to types.

krokodil
  • 1,326
  • 10
  • 18

2 Answers2

2

The types are not convertible to each other, because of the way addition on the natural numbers is defined in Coq (i.e., by recursion on the first argument). As a matter of fact, the only reason your lemma can be typed in Coq at all is that the first implicit argument of P is instantiated to j + 0 on the right-hand side.

Unfortunately, even if these types were convertible, it would not be possible to prove this lemma without additional assumptions, because it requires the axiom of propositional extensionality (see here, for instance).

Community
  • 1
  • 1
Arthur Azevedo De Amorim
  • 23,012
  • 3
  • 33
  • 39
2

The lemma is not provable. Try intros. remember (j+0) as Q. rewrite <- plus_n_O in HeqQ. subst Q. It will get rid of the + 0. Your goal is now

P j n ln = P j n jn

Both sides are of type nat. But now you need to prove that these two nats are equal, without knowing anything else about them...

EDIT:

Actually I was a little too quick... The value of the function P cannot depend on ln and jn since they are Props, . But to prove that, you need proof irrelevance.

If you do Require Import ProofIrrelevance. you get the axiom

Axiom proof_irrelevance : forall (P:Prop) (p1 p2:P), p1 = p2.

It is not a consequence of Coq's logic, but it is consistent with it (and often is just what we mean with a proof - two formally correct arguments are equally true even if they differ in the details).

Now you just do

rewrite (proof_irrelevance _ ln jn). reflexivity. Qed.
larsr
  • 5,447
  • 19
  • 38