Skip to content
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

Move NUM_FLOOR/NUM_CEILING to realaxTheory #1256

Merged
merged 3 commits into from
Jun 17, 2024
Merged
Show file tree
Hide file tree
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
8 changes: 4 additions & 4 deletions examples/probability/large_numberScript.sml
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ val _ = hide "W";
val _ = intLib.deprecate_int ();
val _ = ratLib.deprecate_rat ();

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

(* ------------------------------------------------------------------------- *)
(* Definitions *)
Expand Down
2 changes: 1 addition & 1 deletion src/real/realLib.sig
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ sig
val REAL_ARITH : term -> thm
val REAL_ASM_ARITH_TAC : tactic

val real_ss : simpLib.simpset
(* Incorporates simpsets for bool, pair, and arithmetic *)
val real_ss : simpLib.simpset

(* syntax *)
val prefer_real : unit -> unit
Expand Down
13 changes: 3 additions & 10 deletions src/real/realScript.sml
Original file line number Diff line number Diff line change
Expand Up @@ -3797,19 +3797,12 @@ val lt_int = store_thm(
Q.EXISTS_TAC `0` THEN SRW_TAC [][REAL_NEG_LE0]
]);


(*---------------------------------------------------------------------------*)
(* Floor and ceiling (nums) *)
(* Floor and ceiling (nums) (NOTE: Their definitions are moved to realax) *)
(*---------------------------------------------------------------------------*)

val NUM_FLOOR_def = zDefine`
NUM_FLOOR (x:real) = LEAST (n:num). real_of_num (n+1) > x`;

val NUM_CEILING_def = zDefine`
NUM_CEILING (x:real) = LEAST (n:num). x <= real_of_num n`;

val _ = overload_on ("flr",``NUM_FLOOR``);
val _ = overload_on ("clg",``NUM_CEILING``);
Theorem NUM_FLOOR_def = NUM_FLOOR_def
Theorem NUM_CEILING_def = NUM_CEILING_def

val lem = SIMP_RULE arith_ss [REAL_POS,REAL_ADD_RID]
(Q.SPECL[`y`,`&n`,`0r`,`1r`] REAL_LTE_ADD2);
Expand Down
2 changes: 2 additions & 0 deletions src/real/realSyntax.sig
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ sig
val negate_tm : term
val real_injection : term (* the injection from :num -> :real *)
val inv_tm : term
val NUM_FLOOR_tm : term
val NUM_CEILING_tm : term

(* binary operators *)
val div_tm : term
Expand Down
12 changes: 8 additions & 4 deletions src/real/realSyntax.sml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
structure realSyntax :> realSyntax =
struct

local open realaxTheory in end;
open HolKernel Abbrev;

local open realaxTheory numSyntax in end;

val ERR = mk_HOL_ERR "realSyntax";

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

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

val zero_tm = mk_comb(real_injection, numSyntax.zero_tm)
val one_tm = mk_comb(real_injection, numSyntax.mk_numeral (Arbnum.fromInt 1))
Expand All @@ -23,7 +24,7 @@ struct
val minus_tm = mk_raconst("real_sub", bop_ty)
val mult_tm = mk_raconst("real_mul", bop_ty)
val div_tm = mk_raconst("/", bop_ty)
val exp_tm = mk_raconst("pow", real_ty --> numSyntax.num --> real_ty)
val exp_tm = mk_raconst("pow", real_ty --> num_ty --> real_ty)

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

val NUM_FLOOR_tm = mk_raconst("NUM_FLOOR", real_ty --> num_ty);
val NUM_CEILING_tm = mk_raconst("NUM_CEILING", real_ty --> num_ty);

(* Functions *)

fun dest1 c fnm nm t = let
Expand Down
12 changes: 12 additions & 0 deletions src/real/realaxScript.sml
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,18 @@ Proof
end
QED

(* Floor and ceiling (nums) *)
Definition NUM_FLOOR_def[nocompute] :
NUM_FLOOR (x:real) = LEAST (n:num). real_of_num (n+1) > x
End

Definition NUM_CEILING_def[nocompute] :
NUM_CEILING (x:real) = LEAST (n:num). x <= real_of_num n
End

Overload flr = “NUM_FLOOR”
Overload clg = “NUM_CEILING”

(* ------------------------------------------------------------------------- *)
(* Some elementary "bootstrapping" lemmas needed by RealArith.sml *)
(* *)
Expand Down