Skip to content

extend results on ceil 'for free' #781

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions theories/datatypes/Real.ec
Original file line number Diff line number Diff line change
Expand Up @@ -218,12 +218,16 @@ instance field with real

(* -------------------------------------------------------------------- *)
op floor : real -> int.
op ceil : real -> int.
op [opaque] ceil : real -> int = fun (x : real)=> -(floor (Self.([-]) x)).

axiom floor_bound (x:real) : x - 1%r < (floor x)%r <= x.
axiom ceil_bound (x:real) : x <= (ceil x)%r < x + 1%r.
axiom from_int_floor n : floor n%r = n.
axiom from_int_ceil n : ceil n%r = n.

lemma ceil_bound (x:real) : x <= (ceil x)%r < x + 1%r.
proof. by rewrite /ceil; smt(floor_bound). qed.

lemma from_int_ceil n : ceil n%r = n.
proof. by rewrite /ceil -fromintN from_int_floor oppzK. qed.

lemma floor_gt x : x - 1%r < (floor x)%r.
proof. by case: (floor_bound x). qed.
Expand All @@ -246,6 +250,12 @@ proof. smt(floor_bound). qed.
lemma from_int_floor_addr n x : floor (x + n%r) = floor x + n.
proof. smt(floor_bound). qed.

lemma from_int_ceil_addl n x : ceil (n%r + x) = n + ceil x.
proof. smt(ceil_bound). qed.

lemma from_int_ceil_addr n x : ceil (x + n%r) = ceil x + n.
proof. smt(ceil_bound). qed.

lemma floor_mono (x y : real) : x <= y => floor x <= floor y.
proof. smt(floor_bound). qed.

Expand Down
Loading