Comments (9)
Probably the best way is to split the else branch into two more
branches so the disjunction is handled directly by the join abstract
operator. So what I'm suggesting is to apply the abstract operations
for this equivalent code:
if (y > 10 && y < 20) {
w=1;
} else if (y <= 10) {
w=2;
} else if (y >= 20) {
w=2;
}
Crab has also abstract operations for boolean operations that you can
use them to encode the disjunction of the else branch. So you can also do:
abs_val.assign_cst(b1, y <= 10); // b1 := (y <=10);
abs_val.assign_cst(b2, y >= 10); // b2 := (y >=20);
abs_val.apply_binary_bool(crab::OP_BOR, b3, b1, b2); // b3 := b1 or b2;
abs_val.assume_bool(b3, false /*meaning that b3 is not negated*/);
where b1
, b2
, and b3
are declared as boolean variables:
z_var b1(vfac["b1"], crab::BOOL_TYPE, 1);
z_var b2(vfac["b2"], crab::BOOL_TYPE, 1);
z_var b3(vfac["b3"], crab::BOOL_TYPE, 1);
The problem is that there is no way to get around disjunctions. Most
of the domains will ignore the third abstract operation (i.e., the OR abstract operator).
So if you are using the powerset domain, follow the first approach. If you are ok with non-wrapped intervals, then you can use the boxes domain that represents precisely boolean combinations of interval constraints, and thus, it should be precise with boolean operations, included OR operations.
from crab.
Ah, okay, I would have never thought about doing that!
I guess for the case when it is a conjunction, you can just create the permutation of possibilities (excluding the true case), and then create a "duplicate branch" for each false evaluation. For disjunction, you could try to enumerate all true/false solutions using something like an ALLSAT solver, and then encode all of these with the corresponding true/false outcome. It would probably be enough just to encode a proposition skeleton to the solver, and then let crab
tell you it is bottom if the outcome is "impossible".
I tried to play around with assign_cst
, but this seems to work in neither of master
or dev
:(
from crab.
Did you tried assign_cst
with the boxes domain? The wrapped interval domain completely ignores boolean operations. In crab, there is a reduced product (a pair of domains) of a simple domain for booleans (called flat_boolean_domain
) with an arbitrary numerical domain. It's called flat_boolean_numerical_domain
. That one does something but nothing really with boolean ORs.
from crab.
Maybe I'm crazy, but I couldn't even find a definition of that method:
[avj@tempvm master]$ pwd
/home/avj/clones/crab/master
[avj@tempvm master]$ ag "assign_cst\("
include/crab/cfg/cfg.hpp
311: bool is_bool_assign_cst() const { return (m_stmt_code == BOOL_ASSIGN_CST); }
1527: bool_assign_cst(variable_t lhs, linear_constraint_t rhs)
from crab.
(also, I think because I have a "domain" then what's in the cfg
namespace won't work for me -- maybe I missed the point 😬 )
from crab.
Sorry I meant bool_assign_cst
.
from crab.
Do you expect bool_assign_cst
to work with:
using z_wrapped_interval_domain = wrapped_interval_domain<z_number, varname_t>;
using powerset_of_z_wrapped_intervals =
powerset_domain<z_wrapped_interval_domain>;
?
from crab.
Btw, I didn't ignore:
So if you are using the powerset domain, follow the first approach.
I had just presumed it would work just not with disjunction ...
from crab.
Do you expect
bool_assign_cst
to work with:using z_wrapped_interval_domain = wrapped_interval_domain<z_number, varname_t>; using powerset_of_z_wrapped_intervals = powerset_domain<z_wrapped_interval_domain>;
?
Only flat_boolean_numerical_domain
and boxes
will do something with bool_assign_cst
.
So you can do powerset_domain<flat_boolean_numerical_domain<z_wrapped_interval_domain>>
from crab.
Related Issues (20)
- Make generic weights of adaptative sparse graph
- More precise bitwise AND HOT 1
- Valgrind warnings HOT 1
- none-optional dereference on array-expansion domain with elina-pk HOT 3
- Elina does not compile on mac: `'stdlib.h' file not found` HOT 4
- Enhance top-down inter-procedural analysis HOT 1
- CMake Options
- Does crab support running on MacOS? HOT 8
- Reaching Definitions Analysis HOT 5
- Question: "range of intervals" HOT 14
- Compiler warning with `dev` HOT 1
- "compress" `powerset_domain` domain after projection HOT 4
- General question on "backward_assign_operations" HOT 1
- Question regarding the CFG input encoding for the analysis HOT 7
- Create tree expressions and adapt abstract domains to use them
- Question regarding "cyclic" encoding and propagation of analysis results HOT 9
- What is the difference between the wrapped_interval implemented in crab and the one implemented in TOPLAS15 paper? HOT 2
- Should we add the bitwise complement (~) operation in Crab? HOT 2
- Bug in flat_boolean_domain HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from crab.