If I were using nuXmv
for this task, I would write the following model
MODULE main
VAR
a : boolean;
b : boolean;
c : boolean;
CTLSPEC ((a & b) = (a & b & c));
and then incrementally remove from the state space all those states for which the property is falsified. For example, given this:
nuXmv > reset; read_model -i test.smv ; go ; check_property
-- specification (a & b) = ((a & b) & c) is false
-- as demonstrated by the following execution sequence
Trace Description: CTL Counterexample
Trace Type: Counterexample
-> State: 1.1 <-
a = TRUE
b = TRUE
c = FALSE
I would then write this (because c
is the only watched variable):
MODULE main
VAR
a : boolean;
b : boolean;
c : boolean;
INVAR
c != FALSE;
CTLSPEC ((a & b) = (a & b & c));
which would actually allow for the iterative-refinement search to stop because now the property is true under all possible evaluations of a
and b
:
nuXmv > reset; read_model -i test.smv ; go ; check_property
-- specification (a & b) = ((a & b) & c) is true
Now, this does not appear to be the ideal solution because it requires parsing the output of nuXmv
and correspondingly modify the original file. Compared to your approach, that checks all possible assignments of values, this method enumerates only those assignments which make the formula unsatisfiable. Still, there could be exponentially many counter-examples so it is not that much of an improvement.
One alternative is to use SMT with universal quantification over an EUF formula including the definitions of f1
and f2
, where the only free variable is c
:
(define-fun f1 ((a Bool) (b Bool)) Bool
(and a b)
)
(define-fun f2 ((a Bool) (b Bool) (c Bool)) Bool
(and a b c)
)
(declare-fun c () Bool)
(assert (forall
((a Bool) (b Bool))
(=
(f1 a b)
(f2 a b c)
)
))
(check-sat)
(get-model)
This gives you the following model with the SMT solver z3
:
~$ z3 test3.smt2
sat
(model
(define-fun c () Bool
true)
)
If you would like to know all possible values of c
for which f1 = f2
, then your best shot is to implement an incremental allsat search on top of z3
(see: plenty of Q/A here on stackoverflow on the topic).