aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorXavier Leroy <xavier.leroy@college-de-france.fr>2021-06-07 11:27:44 +0200
committerXavier Leroy <xavier.leroy@college-de-france.fr>2021-07-26 16:01:48 +0200
commit88589fa168a0b73f7d82c4ad2dcf9fde9d17f439 (patch)
treef347f9fd738d5d5c4995b2a46e61620c275a71b2 /lib
parentfd68e9d37164871cdcb4ee83ab649c5054b0f1cc (diff)
downloadcompcert-kvx-88589fa168a0b73f7d82c4ad2dcf9fde9d17f439.tar.gz
compcert-kvx-88589fa168a0b73f7d82c4ad2dcf9fde9d17f439.zip
More lemmas about `align`
Diffstat (limited to 'lib')
-rw-r--r--lib/Coqlib.v17
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/Coqlib.v b/lib/Coqlib.v
index 361ae924..706a5d49 100644
--- a/lib/Coqlib.v
+++ b/lib/Coqlib.v
@@ -525,6 +525,23 @@ Proof.
intros. unfold align. apply Z.divide_factor_r.
Qed.
+Lemma align_lt: forall x y, y > 0 -> align x y < x + y.
+Proof.
+ intros. unfold align.
+ generalize (Z_div_mod_eq (x + y - 1) y H); intro.
+ generalize (Z_mod_lt (x + y - 1) y H); intro.
+ lia.
+Qed.
+
+Lemma align_same:
+ forall x y, y > 0 -> (y | x) -> align x y = x.
+Proof.
+ unfold align; intros. destruct H0 as [k E].
+ replace (x + y - 1) with (x + (y - 1)) by lia.
+ rewrite E, Z.div_add_l, Z.div_small by lia.
+ lia.
+Qed.
+
(** * Definitions and theorems on the data types [option], [sum] and [list] *)
Set Implicit Arguments.