Skip to content

Commit 04f56f8

Browse files
authored
Move NUM_FLOOR/NUM_CEILING to realaxTheory (#1256)
* Add realLib.prefer_num_floor * Move NUM_FLOOR and NUM_CEILING to realaxTheory * Canceled prefer_num_floor(), using (redefined) Overload instead
1 parent 212343b commit 04f56f8

File tree

6 files changed

+30
-19
lines changed

6 files changed

+30
-19
lines changed

examples/probability/large_numberScript.sml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,11 @@ val _ = hide "W";
4242
val _ = intLib.deprecate_int ();
4343
val _ = ratLib.deprecate_rat ();
4444

45-
(* NOTE: The above deprecate settings do not cover "flr" and "clg", which
46-
are overloaded again in intrealTheory.
45+
(* Prefer NUM_FLOOR and NUM_CEILING (over INT_FLOOR/INT_CEILING) by redefining
46+
their overloads.
4747
*)
48-
val _ = bring_to_front_overload "flr" {Name = "NUM_FLOOR", Thy = "real"};
49-
val _ = bring_to_front_overload "clg" {Name = "NUM_CEILING", Thy = "real"};
48+
Overload flr = “realax$NUM_FLOOR
49+
Overload clg = “realax$NUM_CEILING
5050

5151
(* ------------------------------------------------------------------------- *)
5252
(* Definitions *)

src/real/realLib.sig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ sig
1111
val REAL_ARITH : term -> thm
1212
val REAL_ASM_ARITH_TAC : tactic
1313

14-
val real_ss : simpLib.simpset
1514
(* Incorporates simpsets for bool, pair, and arithmetic *)
15+
val real_ss : simpLib.simpset
1616

1717
(* syntax *)
1818
val prefer_real : unit -> unit

src/real/realScript.sml

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3797,19 +3797,12 @@ val lt_int = store_thm(
37973797
Q.EXISTS_TAC `0` THEN SRW_TAC [][REAL_NEG_LE0]
37983798
]);
37993799

3800-
38013800
(*---------------------------------------------------------------------------*)
3802-
(* Floor and ceiling (nums) *)
3801+
(* Floor and ceiling (nums) (NOTE: Their definitions are moved to realax) *)
38033802
(*---------------------------------------------------------------------------*)
38043803

3805-
val NUM_FLOOR_def = zDefine`
3806-
NUM_FLOOR (x:real) = LEAST (n:num). real_of_num (n+1) > x`;
3807-
3808-
val NUM_CEILING_def = zDefine`
3809-
NUM_CEILING (x:real) = LEAST (n:num). x <= real_of_num n`;
3810-
3811-
val _ = overload_on ("flr",``NUM_FLOOR``);
3812-
val _ = overload_on ("clg",``NUM_CEILING``);
3804+
Theorem NUM_FLOOR_def = NUM_FLOOR_def
3805+
Theorem NUM_CEILING_def = NUM_CEILING_def
38133806

38143807
val lem = SIMP_RULE arith_ss [REAL_POS,REAL_ADD_RID]
38153808
(Q.SPECL[`y`,`&n`,`0r`,`1r`] REAL_LTE_ADD2);

src/real/realSyntax.sig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ sig
1212
val negate_tm : term
1313
val real_injection : term (* the injection from :num -> :real *)
1414
val inv_tm : term
15+
val NUM_FLOOR_tm : term
16+
val NUM_CEILING_tm : term
1517

1618
(* binary operators *)
1719
val div_tm : term

src/real/realSyntax.sml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
structure realSyntax :> realSyntax =
22
struct
3-
4-
local open realaxTheory in end;
53
open HolKernel Abbrev;
64

5+
local open realaxTheory numSyntax in end;
6+
77
val ERR = mk_HOL_ERR "realSyntax";
88

99
(* Fundamental terms, mainly constants *)
@@ -12,8 +12,9 @@ struct
1212
val real_ty = mk_thy_type {Thy = "realax", Tyop = "real", Args = []}
1313
val bop_ty = real_ty --> real_ty --> real_ty
1414
val rel_ty = real_ty --> real_ty --> bool
15+
val num_ty = numSyntax.num
1516

16-
val real_injection = mk_raconst("real_of_num", numSyntax.num --> real_ty)
17+
val real_injection = mk_raconst("real_of_num", num_ty --> real_ty)
1718

1819
val zero_tm = mk_comb(real_injection, numSyntax.zero_tm)
1920
val one_tm = mk_comb(real_injection, numSyntax.mk_numeral (Arbnum.fromInt 1))
@@ -23,7 +24,7 @@ struct
2324
val minus_tm = mk_raconst("real_sub", bop_ty)
2425
val mult_tm = mk_raconst("real_mul", bop_ty)
2526
val div_tm = mk_raconst("/", bop_ty)
26-
val exp_tm = mk_raconst("pow", real_ty --> numSyntax.num --> real_ty)
27+
val exp_tm = mk_raconst("pow", real_ty --> num_ty --> real_ty)
2728

2829
val real_eq_tm = mk_thy_const { Thy = "min", Name = "=", Ty = rel_ty}
2930
val less_tm = mk_raconst("real_lt", rel_ty)
@@ -34,6 +35,9 @@ struct
3435
val min_tm = mk_raconst("min", bop_ty)
3536
val max_tm = mk_raconst("max", bop_ty)
3637

38+
val NUM_FLOOR_tm = mk_raconst("NUM_FLOOR", real_ty --> num_ty);
39+
val NUM_CEILING_tm = mk_raconst("NUM_CEILING", real_ty --> num_ty);
40+
3741
(* Functions *)
3842

3943
fun dest1 c fnm nm t = let

src/real/realaxScript.sml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,18 @@ Proof
284284
end
285285
QED
286286

287+
(* Floor and ceiling (nums) *)
288+
Definition NUM_FLOOR_def[nocompute] :
289+
NUM_FLOOR (x:real) = LEAST (n:num). real_of_num (n+1) > x
290+
End
291+
292+
Definition NUM_CEILING_def[nocompute] :
293+
NUM_CEILING (x:real) = LEAST (n:num). x <= real_of_num n
294+
End
295+
296+
Overload flr = “NUM_FLOOR”
297+
Overload clg = “NUM_CEILING”
298+
287299
(* ------------------------------------------------------------------------- *)
288300
(* Some elementary "bootstrapping" lemmas needed by RealArith.sml *)
289301
(* *)

0 commit comments

Comments
 (0)