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

fix(arith): Do not expose unnormalized intervals in only_borne_XXX #1081

Merged
merged 1 commit into from
Mar 29, 2024

Conversation

bclement-ocp
Copy link
Collaborator

The only_borne_sup and only_borne_inf functions have been introduced in 0968433 and are intended to only take in consideration upper and lower bounds of an interval, respectively.

These functions work by replacing the lower (resp. upper) bound of each interval in an union by negative (resp. positive) infinities, leading to bogus and non-normalized representations; for instance, computing only_borne_inf on the union (which we will assume is normalized, i.e. a < b < c < d):

[a, b] U [c, d]

returns

[a, +oo[ U [c, +oo[

which should be just

[a, +oo[

This does not cause issues currently because we always ultimately call borne_sup (resp. borne_inf) on these, but these functions should not return such bogus intervals in the first place.

This patch changes functions only_borne_sup and only_borne_inf to only return the last (resp. first) interval in the union, ensuring that their result is always a single normalized interval without change of semantics.

The `only_borne_sup` and `only_borne_inf` functions have been introduced
in 0968433 and are intended to only
take in consideration upper and lower bounds of an interval,
respectively.

These functions work by replacing the lower (resp. upper) bound of
each interval in an union by negative (resp. positive) infinities,
leading to bogus and non-normalized representations; for instance,
computing `only_borne_inf` on the union (which we will assume is
normalized, i.e. a < b < c < d):

  [a, b] U [c, d]

returns

  [a, +oo[ U [c, +oo[

which should be just

  [a, +oo[

This does not cause issues currently because we always ultimately call
`borne_sup` (resp. `borne_inf`) on these, but these functions should not
return such bogus intervals in the first place.

This patch changes functions `only_borne_sup` and `only_borne_inf` to
only return the last (resp. first) interval in the union, ensuring that
their result is always a single normalized interval without change of
semantics.
@bclement-ocp bclement-ocp requested a review from Gbury March 29, 2024 15:15
Copy link
Collaborator

@Gbury Gbury left a comment

Choose a reason for hiding this comment

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

I agree that it is better to keep intervals normalized.

In the future, maybe we could re-write the code that calls only_borne_inf and only_borne_sup to not use intervals (since such code does not actually care about intervals but only computing some inf/sup bound).

@bclement-ocp
Copy link
Collaborator Author

In the future, maybe we could re-write the code that calls only_borne_inf and only_borne_sup to not use intervals (since such code does not actually care about intervals but only computing some inf/sup bound).

Agreed, although I do not understand the IntervalCalculus module well enough to make this change confidently yet.

@bclement-ocp bclement-ocp merged commit 95ff902 into OCamlPro:next Mar 29, 2024
15 checks passed
@bclement-ocp bclement-ocp deleted the only-borne branch March 29, 2024 16:38
Halbaroth pushed a commit to Halbaroth/alt-ergo that referenced this pull request Apr 2, 2024
…CamlPro#1081)

The `only_borne_sup` and `only_borne_inf` functions have been introduced
in 0968433 and are intended to only
take in consideration upper and lower bounds of an interval,
respectively.

These functions work by replacing the lower (resp. upper) bound of
each interval in an union by negative (resp. positive) infinities,
leading to bogus and non-normalized representations; for instance,
computing `only_borne_inf` on the union (which we will assume is
normalized, i.e. a < b < c < d):

  [a, b] U [c, d]

returns

  [a, +oo[ U [c, +oo[

which should be just

  [a, +oo[

This does not cause issues currently because we always ultimately call
`borne_sup` (resp. `borne_inf`) on these, but these functions should not
return such bogus intervals in the first place.

This patch changes functions `only_borne_sup` and `only_borne_inf` to
only return the last (resp. first) interval in the union, ensuring that
their result is always a single normalized interval without change of
semantics.
@bclement-ocp bclement-ocp added this to the 2.6.0 milestone Jul 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants