public override Formula Clone()
        {
            var clone = (QuantifierFormula)MemberwiseClone();

            clone.Formula    = Formula.Clone();
            clone.WorldIndex = WorldIndex.Clone();
            clone.ChangeWorldIndex(clone.WorldIndex);
            return(clone);
        }
Example #2
0
        public WorldIndex(WorldSymbol symbol)
        {
            Symbols.Add(symbol);

            if (symbol.ParentSymbol != null)
            {
                ParentIndex = new WorldIndex(symbol.ParentSymbol);
                Symbols.AddRange(ParentIndex.Symbols);
            }
        }
 public void AddWorldIndex(WorldIndex worldIndex)
 {
     foreach (var symbol in worldIndex.Symbols)
     {
         if (symbol.ParentSymbol != null)
         {
             AddRelation(symbol.ParentSymbol, symbol);
         }
     }
 }
Example #4
0
        public Substitution WorldUnify(AccessibilityRelation relation, WorldIndex i, WorldIndex j)
        {
            //2b -> one is ground and the other world variable
            if (i.EndSymbol.IsGround || j.EndSymbol.IsGround)
            {
                //Need to verify if n is accessible from the parent of w
                var n = i.EndSymbol.IsGround ? i.EndSymbol : j.EndSymbol;
                var w = !i.EndSymbol.IsGround ? i.EndSymbol : j.EndSymbol;

                if (relation.Contains(w.ParentSymbol, n))
                {
                    var sub = new Substitution();
                    sub.Add(n, w);
                    return(sub);
                }

                return(null);
            }
            //2c -> both are world variables
            else
            {
                //(i)
                if (relation.Contains(i.EndSymbol.ParentSymbol, j.EndSymbol) || relation.Contains(j.EndSymbol.ParentSymbol, i.EndSymbol))
                {
                    return(new Substitution(i.EndSymbol, j.EndSymbol));
                }
                //(ii)
                else
                {
                    var parentUnification = relation.WorldUnify(i.ParentIndex, j.ParentIndex);
                    if (parentUnification == null)
                    {
                        return(null);
                    }
                    else
                    {
                        new Substitution(i.EndSymbol, j.EndSymbol).Compose(parentUnification);
                        return(parentUnification);
                    }
                }
            }
        }
        public Substitution WorldUnify(WorldIndex i, WorldIndex j)
        {
            //By convention "0" is the actual world
            if (i.StartSymbol.Equals(BaseWorld) || j.StartSymbol.Equals(BaseWorld))
            {
                return(null);
            }

            if (i.EndSymbol.IsGround && j.EndSymbol.IsGround)
            {
                if (i.EndSymbol == j.EndSymbol)
                {
                    return(new Substitution());
                }
                else
                {
                    return(null);
                }
            }

            //return AbstractWorldUnify(i, j);

            var unifications = new List <Substitution>();

            foreach (var property in properties)
            {
                var unification = property.WorldUnify(this, i, j);
                if (unification != null)
                {
                    unifications.Add(unification);
                }
            }

            if (unifications.Count == 0)
            {
                return(null);
            }
            else
            {
                return(unifications[0]);
            }
        }
Example #6
0
 public void AddSymbol(WorldSymbol symbol)
 {
     symbol.ParentSymbol = EndSymbol;
     Symbols.Add(symbol);
     ParentIndex = new WorldIndex(symbol.ParentSymbol);
 }
Example #7
0
 public Substitution WorldUnify(AccessibilityRelation relation, WorldIndex i, WorldIndex j)
 {
     return(null);
 }
 public override void ChangeWorldIndex(WorldIndex value)
 {
     WorldIndex = value;
     Formula.ChangeWorldIndex(value);
 }
 public QuantifierFormula(Formula formula, VariableTerminal variable, string quantifier, WorldIndex index) : base(index)
 {
     Formula    = formula;
     Variable   = variable;
     Quantifier = quantifier;
 }
Example #10
0
 public string ToWorldString()
 {
     return("|" + ToString() + "|" + WorldIndex.ToString());
 }
Example #11
0
 public Formula(WorldIndex index)
 {
     WorldIndex = index;
 }
Example #12
0
 public abstract void ChangeWorldIndex(WorldIndex value);