library colibrilib.q — module RealThe logic on the real numbers shared by the interfaces of the numbers (Q_intf, A_intf): the integer parts and the divisions
module Real374use real.RealInfix375use int.Int376use real.FromInt377use real.Truncate378379predicate is_integer (a:real) = (exists z. a = from_int z)380381function div_e (a:real) (b:real) : int =382let d = a /. b in383if b <. 0. then (ceil d) else (floor d)384function mod_e (a:real) (b:real) : real =385a -. b *. (from_int (div_e a b))386387function div_t (a:real) (b:real) : int = truncate (a /. b)388function mod_t (a:real) (b:real) : real = a -. b *. (from_int (div_t a b))389390function div_f (a:real) (b:real) : int = floor (a /. b)391function mod_f (a:real) (b:real) : real = a -. b *. (from_int (div_f a b))392
The integer of an integer real: a witness of is_integer (ghost code, it replaces a skolemization)
Valid (20ms) (colibri2)let ghost int_of (x:real) : int396requires { is_integer x }397ensures { x = from_int result }398= any int ensures { x = from_int result }399end400