Skip to content

Commit f87b8c8

Browse files
committed
Move NUM_FLOOR and NUM_CEILING to realaxTheory
1 parent e45b488 commit f87b8c8

File tree

4 files changed

+25
-14
lines changed

4 files changed

+25
-14
lines changed

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)