| Version 2 (modified by , 12 years ago) ( diff ) |
|---|
Comparison
Here is a sketch of combining ASTs of a spec and impl in order to form a composite program. In compare mode, CIVL will take two programs as arguments. We treat the first program as the "spec" and the second as the "impl."
- Parse individual programs
- Examine input variables, check that spec inputs are a subset of impl inputs.
- It's ok for the impl to have extra inputs.
- Examine output variables, check that sets of spec and input output variables are the same.
- Rename output variables in both programs. (maybe we should just do this in the spec? e.g. for $output int x;, have $output int x_spec; and $output int x; ?)
- We're going to need to compare output variables, and so will need the outputs for each program moved to the new artificial "file" scope.
- Check that assumptions are consistent in spec and impl. (Is it sufficient to check assumptions in the file scope only?)
- Need to check that assumptions in the impl don't prevent any of the valid inputs to the spec from occurring. e.g. suppose spec inputs are
x,yand impl inputs arex,y,z. Ifx=0,y=1is a legal input for the spec, then there must exist some valuez_0ofzsuch thatx=0,y=1,z=z_0is a legal input to the impl. - Let
Xbe the set of inputs to the spec andYbe the set of inputs in the impl not corresponding to inputs in the spec (i.e.XandYare disjoint andXunionYis the full set of inputs to the impl). - Let
p(X)be the conjunction of assumptions in the spec andq(X,Y)be the conjunction of assumptions in the impl. - Check that
p(X)implies there exists an assignment to all variables inYsuch thatq(X,Y)is valid. - If the prover can't answer, provide a warning.
- If assumptions involving input variables are located outside of the file scope, provide a warning.
- Need to check that assumptions in the impl don't prevent any of the valid inputs to the spec from occurring. e.g. suppose spec inputs are
- Create functions for the spec and impl that wrap the sequence of nodes at the file scopes.
- Create a new sequence node. Add the following to it:
- The union of the set of input variables. Remove inputs from spec and impl
- All (renamed) output variables. Remove outputs from spec and impl
- The functions for spec and impl
- One copy of each of the civlc.h functions (remove from spec and impl)
- Spawn statements for spec and impl
- Wait statements for spec and impl
- Assertions checking equality of each pair of output variables. e.g. suppose
xis an output variable. If the variables are renamedx_specandx_impl, an assertion$assert(x_spec==x_impl);will be added. Maybe we need to have a flag indicating that this assertion is special and can read output variables without error? Or, make a system function for comparing output variables that doesn't have this restriction and can directly compare symbolic expressions for arrays, etc.
Note:
See TracWiki
for help on using the wiki.
