Common — library colibrilib.q — module Real

The logic on the real numbers shared by the interfaces of the numbers (Q_intf, A_intf): the integer parts and the divisions

374
module Real
375
use real.RealInfix
376
use int.Int
377
use real.FromInt
378
use real.Truncate
379
380
predicate
is_integer
(a:real) = (exists z. a = from_int z)
381
382
function
div_e
(a:real) (b:real) : int =
383
let d = a /. b in
384
if b <. 0. then (ceil d) else (floor d)
385
function
mod_e
(a:real) (b:real) : real =
386
a -. b *. (from_int (div_e a b))
387
388
function
div_t
(a:real) (b:real) : int = truncate (a /. b)
389
function
mod_t
(a:real) (b:real) : real = a -. b *. (from_int (div_t a b))
390
391
function
div_f
(a:real) (b:real) : int = floor (a /. b)
392
function
mod_f
(a:real) (b:real) : real = a -. b *. (from_int (div_f a b))

The integer of an integer real: a witness of is_integer (ghost code, it replaces a skolemization)

  Valid (20ms) (colibri2)
396
let ghost
int_of
(x:real) : int
397
requires { is_integer x }
398
ensures { x = from_int result }
399
= any int ensures { x = from_int result }
400
end