com.thesett.aima.logic.fol.prolog.builtins.ResolutionState Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of prolog Show documentation
Show all versions of prolog Show documentation
Implementation of a Prolog interpreter that works directly over the abstract syntax tree.
/*
* Copyright The Sett Ltd, 2005 to 2014.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.thesett.aima.logic.fol.prolog.builtins;
import java.util.Queue;
import com.thesett.aima.logic.fol.Clause;
import com.thesett.aima.logic.fol.Functor;
import com.thesett.aima.logic.fol.Variable;
import com.thesett.aima.logic.fol.VariableAndFunctorInterner;
import com.thesett.aima.search.util.backtracking.ReTraversable;
import com.thesett.common.util.Function;
import com.thesett.common.util.SimpleQueue;
import com.thesett.common.util.Sink;
/**
* ResolutionState forms a state corresponding to a step of a proof in a resolution, where each step of the proof
* corresponds exactly with one goal functor to be proved in that step. New disjunctive choice points will always
* correspond to new resolution states, as will sequences of conjunctive steps.
*
* This interface is exposed mainly to provide a clean interface to implement {@link BuiltIn}s against the proof
* search engine. It provides access to the goal stack, the variable bindings, the current clause-as-choice-point, a
* unifier to perform unifications as required, and a method to create subsequent steps in the proof.
*
* The goal stack and variable binding sink provided by this interface should be self-undoing. That is if a
* {@link BuiltIn} adds goals or variable bindings to them, but is later required to be back-tracked over, the built in
* does not have to explicitly undo its additions. The state implementation is clever enough to be able to handle
* back-tracking on its own.
*
*
CRC Card
* Responsibilities
* Provide a stack of outstanding goals to be proved.
* Provide a sink to insert new variable bindings onto.
* Provide the current query choice-point being resolved over.
* Provide a unifier to perform unifications with.
* Provide an interner to translate interned symbols with.
* Create a new resolution state as a choice point for a clause.
*
*
* @author Rupert Smith
*/
public interface ResolutionState extends ReTraversable