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

Add knowledge about floor/ceil bounds #718

Merged
merged 1 commit into from
Jul 7, 2023
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
28 changes: 28 additions & 0 deletions src/preludes/ria.ae
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,34 @@ theory Real_of_Int extends RIA =
{i <= real_of_int(x)}.
k <= x

(* floor(x) ≤ i iff x < i + 1 *)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess you meant floor(x) <= i implies x < i+1 instead of floor(x) <= i iff x < i+1.
Besides, I don't understand why you need to use the semantic trigger not_theory_constant here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

floor(x) <= i iff x < i + 1 is correct, unless I am mistaken? Even though we only implement the implication.

not_theory_constant is here to avoid adding useless axioms, e.g. 3 < 4 if we know that floor(3.5) <= 3

axiom int_floor_ub:
forall x, y : real, i : int
[ int_floor(x), not_theory_constant(x), int_floor(x) in ]?, i], y |-> real_of_int(i + 1) ]
{ int_floor(x) <= i }.
x < y

(* i <= floor(x) iff i <= x *)
axiom int_floor_lb:
forall x, y : real, i : int
[ int_floor(x), not_theory_constant(x), int_floor(x) in [i, ?[, y |-> real_of_int(i) ]
{ i <= int_floor(x) }.
y <= x

(* ceil(x) ≤ i iff x ≤ i *)
axiom int_ceil_ub:
forall x, y : real, i : int
[ int_ceil(x), not_theory_constant(x), int_ceil(x) in ]?, i], y |-> real_of_int(i) ]
{ int_ceil(x) <= i }.
x <= y

(* i <= ceil(x) iff i - 1 < x *)
axiom int_ceil_lb:
forall x, y : real, i : int
[ int_ceil(x), not_theory_constant(x), int_ceil(x) in [i, ?[, y |-> real_of_int(i - 1) ]
{ i <= int_ceil(x) }.
y < x

(* can add other axioms on strict ineqs on rationals ? *)

end
Expand Down
2 changes: 2 additions & 0 deletions tests/arith/ceil_floor_propagate.ae
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
logic x: real
goal g: int_ceil(x) = 0 and int_floor(x) = 0 -> x = 0.
2 changes: 2 additions & 0 deletions tests/arith/ceil_floor_propagate.expected
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

unknown
Loading