library colibrilib.dv — module RealSetsSets of reals (as set.Set) and the sets built by an operation on the reals: the concrete semantics that the specifications of the domains compare with.
module RealSets162use real.RealInfix163use set.Set as S164use map.MapExt165
Two sets with the same elements are equal
Valid (21ms) (cvc5)let ghost set_ext (s1 s2: S.set 'a) : unit168requires { forall x. S.mem x s1 <-> S.mem x s2 }169ensures { s1 = s2 }170= {proof…} assert { s1 == s2 };171MapExt.extensionality s1 s2 {qed}172
The image of s by f
function image (f: 'a -> 'b) (s: S.set 'a) : S.set 'b =175fun y -> exists x. S.mem x s /\ y = f x176
The values of f x y for x in s1 and y in s2
function map2 (f: 'a -> 'b -> 'c) (s1: S.set 'a) (s2: S.set 'b) : S.set 'c =179fun z -> exists x y. S.mem x s1 /\ S.mem y s2 /\ z = f x y180
The same, for y different from zero
function map2nz (f: real -> real -> real) (s1 s2: S.set real) : S.set real =183fun z -> exists x y. S.mem x s1 /\ S.mem y s2 /\ y <> 0.0 /\ z = f x y184
The y such that f y is in s
function preimage (f: 'a -> 'b) (s: S.set 'b) : S.set 'a =187fun y -> S.mem (f y) s188
The x such that x * y is in sr for a y in sb
function pre_mul (sb sr: S.set real) : S.set real =191fun x -> exists y. S.mem y sb /\ S.mem (x *. y) sr192
t is the image of s by f when f maps s into t and has an inverse g that maps t into s
Valid (36ms) (colibri2)let ghost image_bij (f g: 'a -> 'a) (s t: S.set 'a) : unit196requires { forall y. S.mem y s -> S.mem (f y) t }197requires { forall x. S.mem x t -> S.mem (g x) s }198requires { forall x. f (g x) = x }199ensures { t = image f s }200= {proof…} let lemma pw (x: 'a) : unit201ensures { S.mem x t <-> S.mem x (image f s) }202= () in203set_ext t (image f s) {qed}204Valid (18ms) (colibri2)205let ghost image_sound (f: 'a -> 'b) (s: S.set 'a) (t: S.set 'b) : unit206requires { forall x. S.mem x s -> S.mem (f x) t }207ensures { S.subset (image f s) t }208= ()209Valid (21ms) (colibri2)210let ghost map2_sound (f: 'a -> 'b -> 'c) (s1: S.set 'a) (s2: S.set 'b) (t: S.set 'c) : unit211requires { forall x y. S.mem x s1 -> S.mem y s2 -> S.mem (f x y) t }212ensures { S.subset (map2 f s1 s2) t }213= ()214Valid (22ms) (colibri2)215let ghost map2nz_sound (f: real -> real -> real) (s1 s2 t: S.set real) : unit216requires { forall x y. S.mem x s1 -> S.mem y s2 -> y <> 0.0 -> S.mem (f x y) t }217ensures { S.subset (map2nz f s1 s2) t }218= ()219end220