Debian Codegraph @

src/Util/ZUtil/Divide/Bool.v

raw
1 From Coq Require Import Lia.
2 From Coq Require Import ZArith.
3 Require Import Crypto.Util.Bool.Reflect.
4 Require Import Crypto.Util.ZUtil.Definitions.
5 Require Import Crypto.Util.Tactics.DestructHead.
6 Require Import Crypto.Util.Tactics.SpecializeBy.
7 Local Open Scope Z_scope.
8
9 Module Z.
10 Lemma divideb_divide x y : Z.divideb x y = true <-> Z.divide x y.
11 Proof.
12 cbv [Z.divideb].
13 pose proof (Z.mod_divide y x).
14 destruct (x =? 0) eqn:H'; intuition repeat (lia || reflect_hyps || subst || rewrite Z.eqb_eq || auto).
15 all: cbv [Z.divide] in *.
16 { exists 0; reflexivity. }
17 { destruct_head'_ex; lia. }
18 Qed.
19
20 #[global] Instance divideb_spec : reflect_rel Z.divide Z.divideb | 10.
21 Proof.
22 intros x y; pose proof (divideb_divide x y); destruct Z.divideb; constructor.
23 all: intuition congruence.
24 Qed.
25 End Z.