All Downloads are FREE. Search and download functionalities are using the official Maven repository.

astra.reasoner.unifier.FormulaVariableUnifier Maven / Gradle / Ivy

There is a newer version: 1.4.2
Show newest version
package astra.reasoner.unifier;

import java.util.Map;

import astra.core.Agent;
import astra.formula.Formula;
import astra.formula.FormulaVariable;
import astra.reasoner.FormulaUnifier;
import astra.term.FormulaTerm;
import astra.term.Term;
import astra.term.Variable;

public class FormulaVariableUnifier implements FormulaUnifier {

	@Override
	public boolean isApplicable(Formula source, Formula target) {
		return (source instanceof FormulaVariable) || (target instanceof FormulaVariable);
	}

	@Override
	public Map unify(Formula source, Formula target, Map bindings, Agent agent) {
		if (source instanceof FormulaVariable) {
			Variable variable = ((FormulaVariable) source).variable();
			bindings.put(variable.id(), new FormulaTerm(target));
			return bindings;
		} else if (target instanceof FormulaVariable) {
			Variable variable = ((FormulaVariable) target).variable();
			bindings.put(variable.id(), new FormulaTerm(source));
			return bindings;
        }
		return null;
	}
    
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy