2

I am a beginner at Coq and I'm stuck at a problem in Coq, I am not able to simplify this further. It would be great if anyone had any tips on how to break the problem down into smaller steps. The lemma is this:

forall (n : N) (n0 : N),

((1 + 2 * n + (2 * N.pos (2 ^ 32) - 1 - (0 + 2 * n0)))
 mod (2 * N.pos (2 ^ 32)) / (2 * 1)) mod N.pos (2 ^ 32) =
(((n + (N.pos (2 ^ 32) - 1 - n0)) mod N.pos (2 ^ 32) + 1 mod N.pos (2 ^ 32))
 mod N.pos (2 ^ 32) / 1) mod N.pos (2 ^ 32)
  • How can I just prove something like this: 1 + (2 * N.pos (2 ^ 32) - 1 - 0 - 2 * n0) = 1 + 2 * N.pos (2 ^ 32) - 1 - 0 - 2 * n0. Reflexivity doesn't work. – Vaishnavi Lakkalkatti ee17b065 Oct 28 '21 at 11:23
  • They are not equal: if `n0` is large enough (so that `1 + 2*N.pos(2^32) - (2*n0 + 1)) = 0`, for instance `N.pos(2^33)`), the left hand side is equal to `1` while the right hand side is equal to `0`. – Meven Lennon-Bertrand Oct 28 '21 at 12:21

1 Answers1

2

As such, your goal is not provable, you can try:

Goal exists (n : N) (n0 : N),
  ((1 + 2 * n + (2 * N.pos (2 ^ 32) - 1 - (0 + 2 * n0)))
  mod (2 * N.pos (2 ^ 32)) / (2 * 1)) mod N.pos (2 ^ 32) <>
  (((n + (N.pos (2 ^ 32) - 1 - n0)) mod N.pos (2 ^ 32) + 1 mod N.pos (2 ^ 32))
  mod N.pos (2 ^ 32) / 1) mod N.pos (2 ^ 32).
Proof.
  now exists 0, (N.pos 2^33).
Qed.

The issue comes from subtraction between positive numbers, which returns 0 when its second argument is larger, so that it is not injective.