Пример #1
0
    public HashSet<GeneratorNode> spawn(FOExists op)
    {
        HashSet<GeneratorNode> outSet = new HashSet<GeneratorNode>();
        Atom x = op.getQuantifiedVariable();
        string qualifier = op.getQualifier();

        if (m_encounteredQualifiers.Contains(qualifier))
        {
            // We add something along a path where a ForAll has already
          		// been evaluated: soundness is no longer guaranteed for this node
            m_sound = false;
        }

        if (op.isAnOPlus())
        {
            // This is an OPlus; return a node with op transferred to the OPlus set
            GeneratorNode wn = new GeneratorNode(this);

            if (!wn.addToOPluses(op.toOPlus()))
            {
                // We can't add this OPlus to the current set. Contradiction! Return the empty set
                return new HashSet<GeneratorNode>();
            }

            return wn.spawn();
        }

        if (op.isPathAssertion())
        {
            GeneratorNode wn = new GeneratorNode();
            OPlus opl = new OPlus();

            opl.setQualifier(op.getQualifier());
            opl.setOperand(Operator.m_trueAtom);

            if (!wn.addToOPluses(opl))
            {
                // We can't add this OPlus to the current set. Contradiction! Return the empty set
                return new HashSet<GeneratorNode>();
            }

            return wn.spawn();
        }

        // Iterate over domain
        //HashSet<Constant> oplus_domain = getOPlusDomain(qualifier);
        HashSet<Constant> domain = op.getDomain();
        SubsetIterator<Constant> it = new SubsetIterator<Constant>(domain); //,oplus_domain

        while (it.hasNext())
        {
            GeneratorNode wn = new GeneratorNode(this);
            HashSet<Constant> subset = it.next();

            foreach (Atom v in subset)
            {
                Operator o2 = op .getOperand();
                Operator o3 = o2.evaluate(x, v);

                if (!op.isPathAssertion())
                {
                    wn.addToGamma(o3);
                }

                OPlus opl = new OPlus(qualifier, v);

                if (!wn.addToOPluses(opl))
                {
                    // We can't add this OPlus to the current set. Contradiction! Skip that branch
                    continue;
                }
            }

            HashSet<GeneratorNode> spawnedSet = wn.spawn();

            if (spawnedSet != null)
            {
                foreach (GeneratorNode gn in spawnedSet)
                {
                    outSet.Add(gn);
                }
            }
        }

        return outSet;
    }