示例#1
0
        public override PrologObject Dereference()
        {
            if (this.value == null || this.value == this)
            {
                return(this);
            }

            return(value.Dereference());
        }
示例#2
0
        public virtual bool Unify(PrologObject po)
        {
            PrologObject po0;

            po0 = this.Dereference();
            if (!(po0 == this))
            {
                return(po0.Unify(po));
            }
            po = po.Dereference();
            if (po is Variable)
            {
                return(po.Unify(this));
            }
            return(Equals(po));
        }
示例#3
0
 public bool Unify(PrologObject po1, PrologObject po2)
 {
     po1 = po1.Dereference();
     po2 = po2.Dereference();
     if (po1.Equals(po2))
     {
         return(true);
     }
     if (po1 is Variable)
     {
         ((Variable)(po1)).Bind(po2);
         return(true);
     }
     if (po2 is Variable)
     {
         ((Variable)(po2)).Bind(po1);
         return(true);
     }
     if (po1 is StructureObject && po2 is StructureObject)
     {
         StructureObject st1 = ((StructureObject)(po1));
         StructureObject st2 = ((StructureObject)(po2));
         if (!(Unify(st1.Functor, st2.Functor)))
         {
             return(false);
         }
         if (!(st1.Arity == st2.Arity))
         {
             return(false);
         }
         for (int k = 0; k <= st1.Arity - 1; k++)
         {
             if (!(Unify(st1.Parameters[k], st2.Parameters[k])))
             {
                 return(false);
             }
         }
         return(true);
     }
     return(false);
 }