Beispiel #1
0
        /**
         * Generate all valuations of the abstract state space
         * Used for explicit state model checking output (e.g., PHAVer)
         */
        private void makeAbstractStateValuations()
        {
            foreach (AbstractState a in this._states)
            {
                for (UInt64 i = 0; i < Math.Pow(4, a.EnvironmentStates.Count); i++) // todo: change 4 to: cardinality of {None, All, AllButOne, One, \ldots, Cutoff}
                {
                    Expr          p  = Controller.Instance.Z3.MkTrue();
                    AbstractState ac = ((AbstractState)a.Clone());

                    for (int j = 0; j < a.EnvironmentStates.Count; j++)
                    {
                        switch (i % 4)
                        {
                        case 0:
                            ac.EnvironmentStates.ElementAt(j).Count = Counter.None;
                            break;

                        case 1:
                            ac.EnvironmentStates.ElementAt(j).Count = Counter.One;
                            break;

                        case 2:
                            ac.EnvironmentStates.ElementAt(j).Count = Counter.AllButOne;
                            break;

                        case 3:
                            ac.EnvironmentStates.ElementAt(j).Count = Counter.All;
                            break;

                        default:
                            break;
                        }

                        // convert integer to boolean representation by bit-shifting
                        //if (((i >> j) & 0x01) == 0)
                        //{
                        //ac.EnvironmentStates.ElementAt(j).State = true; // todo: set value if need to generate all valuations
                        p = Controller.Instance.Z3.MkAnd(p, ac.EnvironmentStates.ElementAt(j).EnvironmentPredicate);
                        //}
                        //else
                        //{
                        //  ac.EnvironmentStates.ElementAt(j).State = false; // todo: set value if need to generate all valuations

                        //    p = Controller.Instance.Z3.MkAnd(p, Controller.Instance.Z3.MkNot(ac.EnvironmentStates.ElementAt(j).EnvironmentPredicate));
                        //}
                    }

                    // prune infeasible state space: if combined predicate can be satisfied, add it
                    // todo: need proof of soundness while doing such pruning
                    //       note that this prevents the environment process from being in two locations simultaneously---is this okay? seems like we might allow this
                    //       if this is okay, then just use the intra-predicate predicate (.predicate) and not the environment predicate (.envpred) (doing this for now for testing)
                    Model  m = null;
                    Expr[] core;
                    if (Controller.Instance.Z3.checkTerm(p, out m, out core) && !ac.Concretization().ToString().Equals("false"))
                    {
                        this._valuations.Add(ac);
                    }
                    else
                    {
                        ac.Dispose();
                    }
                }
            }
        }