getContrapositives() public méthode

public getContrapositives ( ) : List
Résultat List
Exemple #1
0
        public void testContrapositives()
        {
            List<Chain> conts;
            Literal p = new Literal(new Predicate("P", new List<Term>()));
            Literal notq = new Literal(new Predicate("Q", new List<Term>()),
                    true);
            Literal notr = new Literal(new Predicate("R", new List<Term>()),
                    true);

            Chain c = new Chain();

            conts = c.getContrapositives();
            Assert.AreEqual(0, conts.Count);

            c.addLiteral(p);
            conts = c.getContrapositives();
            Assert.AreEqual(0, conts.Count);

            c.addLiteral(notq);
            conts = c.getContrapositives();
            Assert.AreEqual(1, conts.Count);
            Assert.AreEqual("<~Q(),P()>", conts[0].ToString());

            c.addLiteral(notr);
            conts = c.getContrapositives();
            Assert.AreEqual(2, conts.Count);
            Assert.AreEqual("<~Q(),P(),~R()>", conts[0].ToString());
            Assert.AreEqual("<~R(),P(),~Q()>", conts[1].ToString());
        }
        // END-InferenceProcedure
        //

        //
        // PRIVATE METHODS
        //
        public List<Chain> createChainsFromClauses(List<Clause> clauses)
        {
            List<Chain> chains = new List<Chain>();

            foreach (Clause c in clauses)
            {
                Chain chn = new Chain(c.getLiterals());
                chn.setProofStep(new ProofStepChainFromClause(chn, c));
                chains.Add(chn);
                chains.AddRange(chn.getContrapositives());
            }

            return chains;
        }