library colibrilib.generic_divrem_rewrite — module RoundRounding of an integer plus a fraction (for the clones of Gen)
module Round301use int.Int302use real.RealInfix303use real.FromInt304use real.Truncate as Truncate305Valid (23ms) (colibri2)306let lemma floor_shift (d:int) (f:real)307requires { 0. <=. f <. 1. }308ensures { Truncate.floor (from_int d +. f) = d }309= let z = Truncate.floor (from_int d +. f) in310assert { from_int z <=. from_int d +. f <. from_int (z + 1) };311assert { from_int z <. from_int (d + 1) };312assert { from_int d <. from_int (z + 1) }313Valid (24ms) (colibri2)314let lemma ceil_shift (d:int) (f:real)315requires { -. 1. <. f <=. 0. }316ensures { Truncate.ceil (from_int d +. f) = d }317= let z = Truncate.ceil (from_int d +. f) in318assert { from_int (z - 1) <. from_int d +. f <=. from_int z };319assert { from_int (z - 1) <. from_int d };320assert { from_int (d - 1) <. from_int z }321end322