Replies: 1 comment 1 reply
-
First, it's really exciting to see CrossHair in action here! Comments follow, some of which I've broken into other discussions/bugs, in no particular order:
|
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi Phillip,
I'm trying to formally verify simple functions that are time sensitive using CrossHair. The goal is to find path(s) of a given function that verifies a property p and the symbolic values of the returned variables. This is a quite similar to issue #142 .
Here's an example:
Property p is : there exists a
t
greater than 5 such thata
is true.Context:
I use this in SVSHI, an open-source smart-home hub that runs applications in Python that are formally verified to avoid conflicts between two applications.
These applications are short and run periodically.
Each application has its own properties and we use CrossHair to check if these properties are satisfied.
The next step to enhance the verification is to manage time sensitive properties.
We provide an API to give time to the developer, by using multiples variables for the seconds, minutes, hour etc.. to avoid using non-linear arithmetic.
Then we can create properties that are time-sensitive using these variables. Example : Every two days
a
(where a is a physical switch) is True for two minutes. Here we can suppose thatt
is a variable that represent a minute, where0<=t<=59
However, when using CrossHair we couldn't have a "memory" a previous execution and this always lead to counterexamples.
A solution I found is to modify slightly the cover function to return the solver at the end of run_iteration and get the return values from the function to symbolic values.
Then I recreate a function in Z3 using all the output of crosshair and then use Z3's solver to verify the property.
Details of the modifications:
Getting the symbolic variables in
path_cover
here by getting the "var" attribute (thanks to @lmontand !)Getting the paths constraints from the
StateSpace
object after detaching the pathIt's is copied and put into a list with the return values.
Then I run the path_cover function to get everything from a specific function.
To get back to the example of the function, CrossHair will output these paths [[Not(10 < t_2), Not(a_3)], {'ret': True}]
[[10 < t_2], {'ret': a_3}]
[[Not(10 < t_2), a_3], {'ret': False}]
Then they are converted to Z3 expression and I can use this to verify any properties.
Something I haven't figured out yet is when you have a boolean variable with
not
as a return, it seems to realize (hence the two 'paths' when t<10). But it is still working as intended, which is the most important!Let me know if you have any suggestions, improvements or seeing any limitations.
Also a big thank you for providing this tool, it's very helpful and it doing very well for the symbolic execution :)
Cheers,
Aymeri
Beta Was this translation helpful? Give feedback.
All reactions