From c22b3c9726aa1c052fd44bcaf0ced8fb30970206 Mon Sep 17 00:00:00 2001 From: Jason Gross Date: Mon, 13 Aug 2018 18:46:52 -0400 Subject: Fix split_bounds, prove it correct --- src/Util/ZRange/BasicLemmas.v | 9 +++++++++ src/Util/ZRange/Operations.v | 9 ++++++++- src/Util/ZUtil/Div.v | 4 ++++ src/Util/ZUtil/Modulo.v | 5 +++++ 4 files changed, 26 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/Util/ZRange/BasicLemmas.v b/src/Util/ZRange/BasicLemmas.v index 8da5e69d7..6b5a430c4 100644 --- a/src/Util/ZRange/BasicLemmas.v +++ b/src/Util/ZRange/BasicLemmas.v @@ -8,6 +8,7 @@ Require Import Crypto.Util.ZUtil.Tactics.LtbToLt. Require Import Crypto.Util.ZUtil.Tactics.SplitMinMax. Require Import Crypto.Util.Tactics.SpecializeBy. Require Import Crypto.Util.Tactics.SpecializeAllWays. +Require Import Crypto.Util.Tactics.BreakMatch. Require Import Crypto.Util.Notations. Require Import Crypto.Util.Tactics.DestructHead. @@ -97,4 +98,12 @@ Module ZRange. intros; Bool.split_andb; rewrite Bool.andb_true_iff; split; Z.ltb_to_lt; cbn [lower upper] in *; split_min_max. all: lia. Qed. + + Lemma is_bounded_by_bool_opp x r : is_bounded_by_bool (Z.opp x) (ZRange.opp r) = is_bounded_by_bool x r. + Proof. + cbv [is_bounded_by_bool andb opp]; cbn [lower upper]; break_match; Z.ltb_to_lt; break_match; Z.ltb_to_lt; + try (symmetry; progress Z.ltb_to_lt); + try reflexivity; + try lia. + Qed. End ZRange. diff --git a/src/Util/ZRange/Operations.v b/src/Util/ZRange/Operations.v index 07e330a4a..95f32869c 100644 --- a/src/Util/ZRange/Operations.v +++ b/src/Util/ZRange/Operations.v @@ -102,7 +102,7 @@ Module ZRange. Definition land_bounds : zrange -> zrange -> zrange := land_lor_bounds Z.land. Definition lor_bounds : zrange -> zrange -> zrange := land_lor_bounds Z.lor. - Definition split_bounds (r : zrange) (split_at : BinInt.Z) : zrange * zrange := + Definition split_bounds_pos (r : zrange) (split_at : BinInt.Z) : zrange * zrange := if upper r