public override ITerm CApply(Unifier u) { ITerm v = u.Get(cyclicVar); u.Remove(cyclicVar); ITerm r = new CyclicTerm(this, cyclicVar.Clone() as VarTerm, u); if (v != null) { u.Bind(cyclicVar, v); } return(r); }
public override ITerm CApply(Unifier u) { if (u != null) { ITerm vl = u.Get(this); if (vl != null) { if (!vl.IsCyclicTerm() && vl.HasVar(this, u)) { u.Remove(this); ITerm tempVl = vl.CApply(u); u.Bind(this, vl); CyclicTerm ct = new CyclicTerm(tempVl as Literal, this); Unifier renamedVars = new Unifier(); ct.MakeVarsAnnon(renamedVars); renamedVars.Remove(this); u.Compose(renamedVars); vl = ct; } vl = vl.CApply(u); if (vl.IsLiteral()) { if (GetNS() != Literal.DefaultNS) { vl = (vl.CloneNS(GetNS().CApply(u) as Atom) as Literal); } if (Negated()) { ((Literal)vl).SetNegated(Literal.LNeg); } } if (vl.IsLiteral() && this.HasAnnot()) { vl = ((Literal)vl).ForceFullLiteralImpl().AddAnnots((IListTerm)this.GetAnnots().CApply(u)); } return(vl); } } return((ITerm)Clone()); // Como uso el Clone de C# lo que clono son object que luego hay que castear... }
public override bool HasVar(VarTerm t, Unifier u) { if (Equals(t)) { return(true); } if (u != null) { ITerm vl = u.Get(this); if (vl != null) { try { u.Remove(this); return(vl.HasVar(t, u)); } finally { u.Bind(this, vl); } } } return(false); }