@@ -263,6 +263,13 @@ Local Ltac interp_good_t_step_arith :=
263263 => cbv [Z.ltz];
264264 apply unfold_is_bounded_by_bool in Hx;
265265 apply unfold_is_bounded_by_bool in Hy
266+ | [ H : is_bounded_by_bool _ (ZRange.normalize r[0 ~> 1]) = true |- _ ]
267+ => change (ZRange.normalize r[0 ~> 1]) with r[0 ~> 1]%zrange in *;
268+ cbv [is_bounded_by_bool] in H; cbn [upper lower] in H
269+ | [ H : ?x <> ?a, H' : ?a <= ?x |- _ ] => assert (a < x) by lia; clear H H'
270+ | [ H : 0 < ?x, H' : ?x <= 1 |- _ ] => assert (x = 1) by lia; clear H H'
271+ | [ H : ?x <= 1, H' : 0 <= ?x |- _ ] => assert (x = 0 \/ x = 1) by lia; clear H H'
272+ | [ H : ?x = Z.neg _ |- context[?x] ] => rewrite H
266273 | [ |- context[ident.cast r[0~>0] ?v] ]
267274 => rewrite (ident.platform_specific_cast_0_is_mod 0 v) by reflexivity
268275 | [ H : ?x = Z.ones _ |- context [Z.land _ ?x] ] => rewrite H
@@ -288,6 +295,7 @@ Local Ltac interp_good_t_step_arith :=
288295 | progress destruct_head'_and
289296 | progress Z.ltb_to_lt
290297 | progress split_andb
298+ | progress change (0 - 1) with (-1) in *
291299 | match goal with
292300 | [ |- ?a mod ?b = ?a' mod ?b ] => apply f_equal2; lia
293301 | [ |- ?a / ?b = ?a' / ?b ] => apply f_equal2; lia
@@ -399,6 +407,9 @@ Local Ltac interp_good_t_step_arith :=
399407 => tryif constr_eq x x' then fail else replace x with x' by lia
400408 | [ |- _ = _ :> BinInt.Z ] => progress autorewrite with zsimplify_fast
401409 end
410+ | match goal with
411+ | [ |- context[(- _) mod _] ] => rewrite Z.mod_opp_small by lia
412+ end
402413 | saturate_add_sub_bounds_step ].
403414
404415Local Ltac remove_casts :=
0 commit comments