public override Literal MakeVarsAnnon(Unifier u) { base.MakeVarsAnnon(u); VarTerm v = u.Deref(cyclicVar); if (v != null) { cyclicVar = v; } return(this); }
public void DerefTest() { un.function.Add(new VarTerm("key"), new VarTerm("value")); VarTerm v = new VarTerm("key"); VarTerm funcion = un.Deref(v); bool resultado = un.function.ContainsKey(v); Assert.AreEqual(true, resultado); }
private static void UseDerefVars(ITerm p, Unifier un) { if (p.GetType() == typeof(Literal)) { Literal l = p as Literal; for (int i = 0; i < l.GetArity(); i++) { ITerm t = l.GetTerm(i); if (t.IsVar()) { l.SetTerm(i, un.Deref(t as VarTerm)); } else { UseDerefVars(t, un); } } } }
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); } }