Examples of Substitution


Examples of stanfordlogic.prover.Substitution

   
    public void testIdenticalVariables()
    {
        GdlList l1, l2;
        Fact f1, f2;
        Substitution sigma;
       
        l1 = parser_.parse("foo ?x ?x");
        l2 = parser_.parse("foo ?x ?x");
        f1 = VariableFact.fromList(l1);
        f2 = (VariableFact) VariableFact.fromList(l2).uniquefy();
       
        sigma = Unifier.mgu(f1,f2);
        assertNotNull(sigma);
        assertEquals(1, sigma.numMappings());
    }
View Full Code Here

Examples of stanfordlogic.prover.Substitution

   
    public void testIdenticalVariableNames()
    {
        GdlList l1, l2;
        Fact f1, f2;
        Substitution sigma;
       
        l1 = parser_.parse("foo ?x ?y");
        l2 = parser_.parse("foo ?y ?y");
        f1 = VariableFact.fromList(l1);
        f2 = (VariableFact) VariableFact.fromList(l2).uniquefy();
       
        sigma = Unifier.mgu(f1,f2);
        assertNotNull(sigma);
        assertEquals(2, sigma.numMappings());
    }
View Full Code Here

Examples of stanfordlogic.prover.Substitution

   
    public void testRecursiveSub()
    {
        GdlList l1, l2;
        Fact f1, f2;
        Substitution sigma;
       
        l1 = parser_.parse("foo ?x ?x ?z");
        l2 = parser_.parse("foo  a ?y ?y");
        f1 = VariableFact.fromList(l1);
        f2 = VariableFact.fromList(l2);
       
        sigma = Unifier.mgu(f1,f2);
        assertNotNull(sigma);
        assertTrue(sigma.numMappings() == 3);
    }
View Full Code Here

Examples of stanfordlogic.prover.Substitution

        parser_ = GameManager.getParser();
    }

    public void testSubstitution()
    {
        Substitution s = new Substitution();
       
        TermVariable v1 = TermVariable.makeTermVariable();
        TermVariable v2 = TermVariable.makeTermVariable();
        TermObject t = TermObject.makeTermObject(256);
       
        s.addMapping( v1, v2 );
        s.addMapping( v2, t );
       
        assertEquals(2, s.numMappings() );
        assertEquals(t, s.getMapping(v1) );
        assertEquals(t, s.getMapping(v2) );
    }
View Full Code Here

Examples of stanfordlogic.prover.Substitution

       
        TermVariable varX = getVariable("?x");
        TermVariable varY = getVariable("?y");
        TermVariable varZ = getVariable("?z");
       
        Substitution s = new Substitution();
        s.addMapping(varX, tf);
        s.addMapping(varY, getTermObject("1"));
        s.addMapping(varZ, getTermObject("2"));
       
       
        Fact result = (Fact) f1.applySubstitution(s);
       
        assertEquals( makeFact("legal (mark 1 2)"), result );
View Full Code Here

Examples of stanfordlogic.prover.Substitution

               
                if(nFact.getArity() > 0 && nFact.getTerm(0) instanceof TermFunction)
                {
                    if(((TermFunction) nFact.getTerm(0)).functionName_ == ((TermFunction) fact.getTerm(0)).functionName_)
                    {
                        Substitution s = fact.unify(nFact);
                        if ( s != null )
                            result.add(s);
                    }
                }
            }
        }
        else
        {
            for(GroundFact nFact : facts)
            {
                Substitution s = fact.unify(nFact);
                if ( s != null )
                    result.add( s );
            }
        }
        return result;
View Full Code Here

Examples of stanfordlogic.prover.Substitution

    {
        long startTime = System.nanoTime();
       
        logger_.fine(" ---------- Beginning new proof request (single) ----------");
       
        Substitution s = proveOne(f, context);

        GameManager.addTime(GameManager.TIME_GET_AN_ANSWER, System.nanoTime() - startTime);
       
        // No proof?
        if (s == null)
View Full Code Here

Examples of stanfordlogic.prover.Substitution

        for ( Implication rule : rules )
        {
            rule = rule.uniquefy();

            Substitution unification = f.unify(rule.getConsequent());

            // Stop if unification fails.
            if ( unification == null )
                continue;

            context.reportRuleHead(rule.getConsequent(), unification);

            Conjunction conjuncts =
                    (Conjunction) rule.getAntecedents().applySubstitution(unification);

            List<Substitution> ruleResults = proveConjunction(conjuncts, context, proveAll);

            if ( ruleResults != null )
            {
                for (Substitution sub: ruleResults)
                {
                    Substitution s = unification.copy(sub);

                    results.add(s);
                   
                    if (!proveAll) {
                        // we can just stop here.
View Full Code Here

Examples of stanfordlogic.prover.Substitution

   
    private List<Substitution> proveNegation(Negation s, ProofContext context, boolean proveAll)
    {
        context.enterProof(s, proveAll);
       
        Substitution result = proveOne(s.getNegated(), context);
       
        // Make sure we *failed* the proof.
        if ( result == null ) {
            List<Substitution> res = new ArrayList<Substitution>(1);
            res.add(EMPTY_SUB);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.