public static VarTerm CreateVar(bool negated, string functor) { VarTerm v = new VarTerm(functor); v.SetNegated(negated); return(v); }
public override bool HasVar(VarTerm t, Unifier u) { if (base.HasVar(t, u)) { return(true); } return(body.HasVar(t, u)); }
public static VarTerm ParseVar(string sVar) { as2j parser = new as2j(new StringReader(sVar)); VarTerm v = parser.Var(Literal.DefaultNS); if (parser.getNextToken().kind != as2jConstants.EOF) { throw new ParseException("Expected <EOF> after " + v + " for parameter '" + sVar + "'"); } return(v); }
public override Literal MakeVarsAnnon(Unifier u) { base.MakeVarsAnnon(u); VarTerm v = u.Deref(cyclicVar); if (v != null) { cyclicVar = v; } return(this); }
public override bool HasVar(VarTerm t, Unifier u) { int size = GetArity(); for (int i = 0; i < size; i++) { if (GetTerm(i).HasVar(t, u)) { return(true); } } return(false); }
public override bool Equals(object t) { if (t == null) { return(false); } if (t == this) { return(true); } if (t.GetType() == typeof(VarTerm)) { VarTerm tAsVT = t as VarTerm; //This should be const but c# doesn't allow it return(GetFunctor().Equals(tAsVT.GetFunctor())); } return(false); }
public override bool HasVar(VarTerm t, Unifier u) { if (base.HasVar(t, u)) { return(true); } if (annotations != null) { foreach (ITerm v in annotations) { if (v.HasVar(t, u)) { return(true); } } } return(false); }
public VarTerm VarToReplace(ITerm t, Unifier u) { VarTerm v = (VarTerm)t; VarTerm deref = u.Deref(v); if (deref.Equals(v)) { Atom a = v.GetNS(); if (a.IsVar()) { a = VarToReplace(a, u); } //UnnamedVar uv = useShortUnnamedVars ? new UnnamedVar(a) : UnnamedVar.Create(a, t.ToString()); UnnamedVar uv = UnnamedVar.Create(a, t.ToString()); if (deref.HasAnnot()) { uv.SetAnnots(deref.GetAnnots().CloneLT()); uv.MakeVarsAnnon(u); } u.Bind(deref, v); return(v); } else { Atom a = v.GetNS(); if (a.IsVar()) { a = VarToReplace(a, u); } deref = (VarTerm)deref.CloneNS(a); if (v.HasAnnot() && !deref.HasAnnot()) { deref.SetAnnots(v.GetAnnots().CloneLT()); deref.MakeVarsAnnon(u); } return(deref); } }
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); }
public void SetTail(VarTerm v) { }
/****** Checks *******/ /* * Returns true only if this term contains the variable t (or unifies with the variable term t?). * t - The variable term * u - The unifier */ public virtual bool HasVar(VarTerm t, Unifier u) { return(false); }
public CyclicTerm(Literal t, VarTerm v, Unifier u) : base(t, u) { cyclicVar = v; }
public CyclicTerm(Literal t, VarTerm v) : base(t) { cyclicVar = v; }
public override bool HasSubsetAnnot(Literal p, Unifier u) { if (annotations == null) { return(true); } if (!p.HasAnnot()) { return(false); } ITerm thisTail = null; IListTerm pAnnots = p.GetAnnots().CloneLTShallow(); VarTerm pTail = pAnnots.GetTail(); ITerm pAnnot = null; IListTerm pAnnotsTail = null; IEnumerator <ITerm> en = pAnnots.ListTermIterator(); bool enReset = false; IEnumerator <IListTerm> en2 = annotations.ListTermIterator(); // use this iterator to get the tail of the list while (en2.MoveNext()) { IListTerm lt = en2.Current; ITerm annot = lt.GetTerm(); if (annot == null) { break; } if (lt.IsTail()) { thisTail = lt.GetTail(); } if (annotations.IsVar() && !enReset) { enReset = true; en = pAnnots.ListTermIterator(); pAnnot = null; } bool ok = false; while (true) { if (pAnnot != null && u.UnifiesNoUndo(annotations, pAnnot)) { ok = true; en.Dispose(); pAnnot = en.Current; break; } else if (pAnnot != null && pAnnot.CompareTo(annot) > 0) { break; } else if (en.MoveNext()) { pAnnot = en.Current; } else { break; } } if (!ok && pTail != null) { if (pAnnotsTail == null) { pAnnotsTail = (IListTerm)u.Get(pTail); if (pAnnotsTail == null) { pAnnotsTail = new ListTermImpl(); u.Unifies(pTail, pAnnotsTail); pAnnotsTail = (IListTerm)u.Get(pTail); } } pAnnotsTail.Add((ITerm)annot.Clone()); // Como uso el Clone de C# lo que clono son object que luego hay que castear... ok = true; } if (!ok) { return(false); } } if (thisTail != null) { u.Unifies(thisTail, pAnnots); } return(true); }
public override bool HasVar(VarTerm t, Unifier u) { throw new NotImplementedException(); }