/* Check if we reached a fixpoint. That is, if there are no states in <largeSet>
         * which are absent from <smallSet>.
         */
        private bool IsFixpoint(FormulaNode largeSet, FormulaNode smallSet, SymbolicState v)
        {
            FormulaNode notNew       = new FormulaNode(LogicOperator.NOT, smallSet, null);
            FormulaNode stateRemoved = new FormulaNode(LogicOperator.AND, largeSet, notNew);

            stateRemoved = v.Quantify(LogicOperator.EXISTS, stateRemoved);
            return(!FormulaCNF.QBFSAT(stateRemoved));
        }
        public bool Check()
        {
            SymbolicState v = new SymbolicState(elementary, "v");

            // initially, all possible states belong to the structure
            FormulaNode states = new FormulaNode(FormulaNode.TRUE_LITERAL);
            FormulaNode oldStates;

            while (true)
            {
                iterations++;
#if DEBUG
                Console.WriteLine("Iteration " + iterations.ToString());
#endif
                oldStates = states;
                FormulaNode succ = GenSucc(states, v);
                FormulaNode lc1  = GenLC1(states, v);
                FormulaNode e    = GenE(states, v);
                FormulaNode a    = GenA(states, v);

                states = new FormulaNode(LogicOperator.AND, states, succ);
                states = new FormulaNode(LogicOperator.AND, states, lc1);
                states = new FormulaNode(LogicOperator.AND, states, e);
                states = new FormulaNode(LogicOperator.AND, states, a);
                if (IsFixpoint(oldStates, states, v))
                {
                    break;
                }
            }
#if DEBUG
            Console.WriteLine("Reached fixpoint. Checking for satisfying state");
#endif
            FormulaNode formulaValue    = v.ValueOf(normalized);
            FormulaNode formulaAndValid = new FormulaNode(LogicOperator.AND, states, formulaValue);
            FormulaNode sat             = v.Quantify(LogicOperator.EXISTS, formulaAndValid);
            return(FormulaCNF.QBFSAT(sat));
        }