Skip to content
This repository has been archived by the owner on Aug 22, 2024. It is now read-only.

Interval domain: unsound transfer functions for div and mul #1159

Closed
caballa opened this issue Jun 28, 2022 · 2 comments
Closed

Interval domain: unsound transfer functions for div and mul #1159

caballa opened this issue Jun 28, 2022 · 2 comments

Comments

@caballa
Copy link

caballa commented Jun 28, 2022

Issue

The transfer functions for div and mul seem wrong.

Steps to reproduce

I was reading the code and found two issues:

  1. div (https://github.com/facebookexperimental/MIRAI/blob/main/checker/src/interval_domain.rs#L126)
    The use of saturating.add seems a typo

  2. mul (https://github.com/facebookexperimental/MIRAI/blob/main/checker/src/interval_domain.rs#L332)
    gives wrong results if negative intervals.

   [-4, -2]*[5, 10] = [-20, -20] which is clearly wrong since it doesn't include e.g. -4 * 10 = -40

A sound transfer function would be

  [x,y] * [a,b] = [min(x*a, x*b, y*a, y*b), max(x*a, x*b, y*a, y*b)]

  [-4, -2]*[5, 10] = [min(-4*5,-4*10,-2*5,-2*10), max(-4*5,-4*10,-2*5,-2*10)] = [-40, -10] 
@hermanventer
Copy link
Contributor

Thanks for reading carefully and being kind enough to report your findings. I've put up a fix for in in https://github.com/hermanventer/MIRAI/pull/7. Since no-one at Meta seems interested to facilitate merges to this repo, the current source of truth for MIRAI is now https://github.com/hermanventer/MIRAI.

@caballa
Copy link
Author

caballa commented Jul 2, 2022

This is a really nice project. Thanks for all the effort!

@caballa caballa closed this as completed Jul 2, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants