public Frame unify(RBTerm other, Frame f) { // System.err.println("** entering unify " + this + " to: " + other); if (other instanceof RBIgnoredVariable) return f; RBTerm val = f.get(this); if (val == null) { other = other.substitute(f); if (equals(other)) return f; else if (other.freefor(this)) { return bind(other, f); } else return null; } else return val.unify(other, f); }
public Frame unify(RBTerm other, Frame f) { if (!(other instanceof RBCompoundTerm)) { if ((other instanceof RBVariable)) { return other.unify(this, f); } return null; } RBCompoundTerm cother = (RBCompoundTerm) other; if (!cother.getConstructorType().equals(getConstructorType())) { return null; } return getArg().unify(cother.getArg(), f); }
protected boolean sameForm(RBTerm other, Frame lr, Frame rl) { if (!(other.getClass() == this.getClass())) return false; else { RBVariable binding = (RBVariable) lr.get(this); if (binding == null) { lr.put(this, other); } else if (!binding.equals(other)) { return false; } binding = (RBVariable) rl.get(other); if (binding == null) { rl.put(other, this); return true; } else { return this.equals(binding); } } }