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

bound_texpr could be more precise for non-linear expressions #96

Open
rmonat opened this issue Dec 5, 2023 · 0 comments
Open

bound_texpr could be more precise for non-linear expressions #96

rmonat opened this issue Dec 5, 2023 · 0 comments
Labels
enhancement New feature or request

Comments

@rmonat
Copy link
Contributor

rmonat commented Dec 5, 2023

Following a discussion with @jboillot in the Mopsa static analyzer, I believe bound_texpr could be more precise. Consider the case where x >= y and z >= 0. Currently, bound_texpr on (x-y)*z returns [-oo,+oo], while it could return [0, +oo].

I tried bound_texpr on x-y, the result is precise. I also tried bounding x*y when x >= 0, y >= 0, and got a precise result.

Code to reproduce the issue:

open Apron

let man = Polka.manager_alloc_loose ()
let env = Environment.make (Array.map Var.of_string [|"x"; "y"; "z"|]) [||]
let top = Abstract1.top man env
let tv s = Texpr1.var env (Var.of_string s)
let cons1 = Tcons1.make (tv "z") SUPEQ
let cons2 = Tcons1.make (Texpr1.binop Sub
                           (tv "x")
                           (tv "y")
                           Int Rnd) SUPEQ
let cons = Tcons1.array_make env 2
let () = Tcons1.array_set cons 0 cons1
let () = Tcons1.array_set cons 1 cons2
let a = Abstract1.meet_tcons_array man top cons
let () = Tcons1.array_print Format.std_formatter (Abstract1.to_tcons_array man a)
let xmy = Texpr1.binop Sub (tv "x") (tv "y") Int Rnd
let e = Texpr1.binop Mul xmy (tv "z") Int Rnd
let itv = Abstract1.bound_texpr man a e
let () = Format.printf "@.%a in %a@." Texpr1.print e Interval.print itv 

Tried with apron 0.9.13, 0.9.14, using either the Polka or Octagon domain.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants