0

How to deal with with the division in a goal? Because I have a goal which is clearly true... However I cannot use lia and I think that this is related to the division.

2 ^ k / 2 ≤ 2 ^ k

Bellow is my COQ screen:

enter image description here

Breno
  • 135
  • 8
  • `lia` is a tactic for linear goals, so it can't reason about division. You can try [`nia`](https://coq.inria.fr/refman/addendum/micromega.html?highlight=nia#coq:tacn.nia), but it might not work either. In these cases, the best that can be done is to prove it like you would on paper. Use `Search` to look for relevant lemmas. – Ana Borges Apr 30 '22 at 20:11

2 Answers2

1

There is no automation for division on naturals - they don't even form a field. But the corresponding lemmas are not hard to find with Search:

Require Import Lia.

Goal forall k:N, 2 ^ k / 2 <= 2 ^ k.
Proof.
  intros k.
  Search (?a/?b <= ?a/?c).
  Search (_/1).
  rewrite <- N.div_1_r.
  apply N.div_le_compat_l.
  lia.
Qed.

If you have really complicated terms, you can embed the goal into reals using floor (a/b) for integer a/b and then use coq-interval. The embedding is easy to automate and coq-interval is quite powerful for proving real inequalities, but it might choke if you have more than a few floors. You can combine it with coq-gappa then to get rid of the floors. It gets quite involved then, but still fully automated. But be aware that it might not be able to prove very tight inequalities, since it uses real analysis.

Nia (Require Import Psatz), as suggested by Ana, can't solve this (and I honestly stopped trying it).

M Soegtrop
  • 1,268
  • 2
  • 8
  • P.S.: The embedding into reals is easier to automate for `Z` than for `N`, so if you work in N you might want to use the `zify` tactic first to get from `N` to `Z`. – M Soegtrop May 01 '22 at 08:33
0

Division on natural numbers is not as easy to manage as on rationals or reals (think 1 / 3). One way out of this could be to try to reframe your constraints with multiplication instead; for instance, n < m / p can sometimes be handled as n * p < m. Otherwise, using a library for rationals could be a solution.

Pierre Jouvelot
  • 901
  • 3
  • 13