Package stanfordlogic.prover

Examples of stanfordlogic.prover.GroundFact


        addFacts(succs);
       
        AbstractReasoner r = new BasicReasoner(kb_, new ArrayList<Implication>(), parser_ );
       
        // Make sure we can prove all of our ground facts!
        GroundFact answer1 = getAnAnswer( r, new GroundFact(symbolTable_, "succ", "1", "2") );
        GroundFact answer2 = getAnAnswer( r, new GroundFact(symbolTable_, "succ", "2", "3") );
        GroundFact answer3 = getAnAnswer( r, new GroundFact(symbolTable_, "succ", "3", "4") );
       
        assertEquals( new GroundFact(symbolTable_, "succ", "1", "2"), answer1 );
        assertEquals( new GroundFact(symbolTable_, "succ", "2", "3"), answer2 );
        assertEquals( new GroundFact(symbolTable_, "succ", "3", "4"), answer3 );
    }
View Full Code Here


       
        // See if we can get just one answer
        GdlList questionList = parser_.parse("succ ?x 2");
        Fact question = VariableFact.fromList(questionList);
       
        GroundFact answer = getAnAnswer( r, question );
        assertEquals( new GroundFact(symbolTable_, "succ", "1", "2"), answer);
       
        questionList = parser_.parse("succ ?x 2");
        question = VariableFact.fromList(questionList);
       
        answer = getAnAnswer( r, question );
        assertNotNull(answer);
        assertEquals( new GroundFact(symbolTable_, "succ", "1", "2"), answer);
    }
View Full Code Here

        Fact question = VariableFact.fromList(questionList);
       
        List<GroundFact> answers = getAllAnswers( r,question);
        assertEquals( 3, answers.size() );
       
        assertEquals( new GroundFact(symbolTable_, "succ", "1", "2"), answers.get(0) );
        assertEquals( new GroundFact(symbolTable_, "succ", "2", "3"), answers.get(1) );
        assertEquals( new GroundFact(symbolTable_, "succ", "3", "4"), answers.get(2) );
    }
View Full Code Here

        rules.add(rule);
       
        AbstractReasoner r = new BasicReasoner(kb_, rules, parser_ );
       
        // Make sure we can prove all of our ground facts!
        GroundFact answer1 = getAnAnswer( r, new GroundFact(symbolTable_, "gt", "2", "1") );
       
        assertEquals( new GroundFact(symbolTable_, "gt", "2", "1"), answer1 );
    }
View Full Code Here

        rules.add(rule);
       
        AbstractReasoner r = new BasicReasoner(kb_, rules, parser_ );
       
        // Make sure we can prove all of our ground facts!
        GroundFact answer1 = getAnAnswer( r, new GroundFact(symbolTable_, "gt", "2", "1") );
       
        assertEquals( new GroundFact(symbolTable_, "gt", "2", "1"), answer1 );
       
        // Do it again just for good measure
        answer1 = getAnAnswer( r, new GroundFact(symbolTable_, "gt", "2", "1") );
       
        assertEquals( new GroundFact(symbolTable_, "gt", "2", "1"), answer1 );
    }
View Full Code Here

       
        GdlList facts = parser_.parse("(true (cell 1 1 x))(true (cell 1 2 o))(true (cell 1 3 x))(true (cell 2 1 o))(true (cell 2 2 x))(true (cell 2 3 b))(true (cell 3 1 b))(true (cell 3 2 b))(true (cell 3 3 b))(true (control oplayer))");
        addFacts(facts);
       
        // Get all next facts
        GroundFact does = GroundFact.fromExpression( parser_.parse("does xplayer noop") );
        GroundFact does2 = GroundFact.fromExpression( parser_.parse("does oplayer (mark 2 3)") );
        Fact question = VariableFact.fromExpression( parser_.parse("next ?x") );
       
        KnowledgeBase kb = new BasicKB();
       
        kb.setTrue(does);
View Full Code Here

        // Is the game terminal?
        assertNull( reasoner.getAnAnswer( makeFact( "terminal" ), context ) );

        // Make some move
        GroundFact does1 = (GroundFact) makeFact( "does white (move wk c 1 c 2)" );
        GroundFact does2 = (GroundFact) makeFact( "does black noop" );

        volatileKb.setTrue( does1 );
        volatileKb.setTrue( does2 );

        // Find the next state.
View Full Code Here

  /* (non-Javadoc)
   * @see tud.gamecontroller.game.jocular.ReasonerInterface#getSuccessorState(tud.gamecontroller.game.jocular.State, tud.gamecontroller.game.JointMove)
   */
  public synchronized ProofContext getSuccessorState(ProofContext state, JointMoveInterface<Term> jointMove) {
    for(Entry<? extends RoleInterface<Term>, ? extends MoveInterface<Term>> entry:jointMove.entrySet()){
      GroundFact moveFact=new GroundFact(parser.TOK_DOES, entry.getKey().getTerm().getExpr(), entry.getValue().getTerm().getExpr());
          state.getVolatileKb().setTrue(moveFact);
        }
    Iterable<GroundFact> nextFacts=stanfordlogicReasoner.getAllAnswersIterable(queryNext, state);
        KnowledgeBase kb = new BasicKB();
        for (GroundFact fact : nextFacts) {
View Full Code Here

  /* (non-Javadoc)
   * @see tud.gamecontroller.game.jocular.ReasonerInterface#GetGoalValue(tud.gamecontroller.game.jocular.State, tud.gamecontroller.game.Role)
   */
  public synchronized int getGoalValue(ProofContext state, RoleInterface<Term> role) {
    GroundFact f=stanfordlogicReasoner.getAnAnswer(new VariableFact(parser.TOK_GOAL, role.getTerm().getExpr(), TermVariable.makeTermVariable()), state);
    return Integer.parseInt(f.getTerm(1).toString(parser.getSymbolTable()));
  }
View Full Code Here

        RelationNameProcessor trueProcessor = new RelationNameProcessor(parser.TOK_TRUE);
       
        Iterable<GroundFact> inits = reasoner.getAllAnswersIterable(ProofContext.makeDummy(parser), "init", "?x");
        for (GroundFact initFact : inits)
        {
            GroundFact trueFact = trueProcessor.processFact(initFact);
            facts.add(trueFact);
        }
    }
View Full Code Here

TOP

Related Classes of stanfordlogic.prover.GroundFact

Copyright © 2018 www.massapicom. 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.