Skip to content

Commit 90e65eb

Browse files
committed
extend results on ceil 'for free'
This opaquely defines ceil from floor so all results on ceil apply to floor and don't need copied. We still start copying them.
1 parent 10ebb3a commit 90e65eb

1 file changed

Lines changed: 13 additions & 3 deletions

File tree

theories/datatypes/Real.ec

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -218,12 +218,16 @@ instance field with real
218218

219219
(* -------------------------------------------------------------------- *)
220220
op floor : real -> int.
221-
op ceil : real -> int.
221+
op [opaque] ceil : real -> int = fun (x : real)=> -(floor (Self.([-]) x)).
222222

223223
axiom floor_bound (x:real) : x - 1%r < (floor x)%r <= x.
224-
axiom ceil_bound (x:real) : x <= (ceil x)%r < x + 1%r.
225224
axiom from_int_floor n : floor n%r = n.
226-
axiom from_int_ceil n : ceil n%r = n.
225+
226+
lemma ceil_bound (x:real) : x <= (ceil x)%r < x + 1%r.
227+
proof. by rewrite /ceil; smt(floor_bound). qed.
228+
229+
lemma from_int_ceil n : ceil n%r = n.
230+
proof. by rewrite /ceil -fromintN from_int_floor oppzK. qed.
227231

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

253+
lemma from_int_ceil_addl n x : ceil (n%r + x) = n + ceil x.
254+
proof. smt(ceil_bound). qed.
255+
256+
lemma from_int_ceil_addr n x : ceil (x + n%r) = ceil x + n.
257+
proof. smt(ceil_bound). qed.
258+
249259
lemma floor_mono (x y : real) : x <= y => floor x <= floor y.
250260
proof. smt(floor_bound). qed.
251261

0 commit comments

Comments
 (0)