Re: [klee-dev] Building constraints with Expr

2016-12-16 Thread Dan Liew
Hi,


> I am interested to build an Expr constraint given (in the simplest case)
> something like “x == 0”, how would I do that?

I presume that `x` refers to a symbolic variable here.

KLEE's Expr language works on Arrays rather than plain variables so in
order construct the expression you want you first need to find the
Array corresponding to it and create the appropriate read from that
Array. This usually a concatenation (ConcatExpr) of byte reads
(ReadExpr). Take a look at `Executor::executeMakeSymbolic()` to see
how the Array gets created and how it is stored.

Once you have the `Array*` you can easily create the read (assuming
you want to read the whole array from offset 0) using
`Expr::createTempRead()`. Once you have that then you could do
something like

```
ref tempRead = Expr::createTempRead(array, width);
ref xEqualsZero = EqExpr::create(tempRead, ConstantExpr::alloc(0, width));
```

> I have been looking at the code in include/klee/Expr.h but it doesn’t seem
> intuitive to me how to proceed.
>
>
>
> My goal is to express some constraints with Expr and subsequently query the
> solver with the getValue() function to check whether my constraints are
> satisfiable on a particular state under evaluation.
>
> If you can think any other way of achieving that without building an Expr
> please feel free to suggest it.

Creating the appropriate the `Expr` is the only sane way to do this.
Once you have the expression you will need to query the solver. BEWARE
for historical reasons KLEE's solver interface generally works in
terms of validity rather than satisfiability which is incredibly
confusing so you need to carefully construct the query.

For satisfiability you can try using solver->mayBeTrue(). Read
`Solver.h` for more detail.

Dan.

___
klee-dev mailing list
klee-dev@imperial.ac.uk
https://mailman.ic.ac.uk/mailman/listinfo/klee-dev


[klee-dev] Building constraints with Expr

2016-12-16 Thread Papapanagiotakis-Bousy, Iason
Hello everyone,

I have a question regarding how to build constraints with the Expr class.
The question has been asked a while ago here: 
https://www.mail-archive.com/klee-dev@imperial.ac.uk/msg01513.html

I am interested to build an Expr constraint given (in the simplest case) 
something like "x == 0", how would I do that?
I have been looking at the code in include/klee/Expr.h but it doesn't seem 
intuitive to me how to proceed.

My goal is to express some constraints with Expr and subsequently query the 
solver with the getValue() function to check whether my constraints are 
satisfiable on a particular state under evaluation.
If you can think any other way of achieving that without building an Expr 
please feel free to suggest it.

Thank you in advance.

Regards,
Jason


___
klee-dev mailing list
klee-dev@imperial.ac.uk
https://mailman.ic.ac.uk/mailman/listinfo/klee-dev