Example #1
0
        public Body(Body another)
        {
            Atom refAtom = null;
            And refAnd = null;
            Or refOr = null;

            try
            {
                if (another.And != null)
                {
                    refAnd = (And)another.And.Clone();
                }

                if (another.Atom != null)
                {
                    refAtom = (Atom)another.Atom.Clone();
                }

                if (another.Or != null)
                {
                    refOr = (Or)another.Or.Clone();
                }
            }
            catch (Exception e)
            {
                e.ToString();
            }

            cf = another.cf;
            or = refOr;
            and = refAnd;
            atom = refAtom;
        }
Example #2
0
        public AndOrFormula(AndOrFormula another)
        {
            Atom refAtom = null;
            And refAnd = null;
            Or refOr = null;

            try
            {
                if (another.Atom != null)
                {
                    refAtom = (Atom)another.Atom.Clone();
                }

                if (another.InnerAnd != null)
                {
                    refAnd = (And)another.InnerAnd.Clone();
                }

                if (another.InnerOr != null)
                {
                    refOr = (Or)another.InnerOr.Clone();
                }
            }
            catch (Exception e)
            {
                e.ToString();
            }

            atom = refAtom;
            and = refAnd;
            or = refOr;
        }
Example #3
0
        public Integrity(Integrity another)
        {
            Oid refOid = null;
            Atom refAtom = null;
            Or refOr = null;
            And refAnd = null;
            AndOrFormula refFormula = null;

            try
            {
                if (another.Oid != null)
                {
                    refOid = (Oid)another.Oid.Clone();
                }

                if (another.Atom != null)
                {
                    refAtom = (Atom)another.Atom.Clone();
                }

                if (another.InnerOr != null)
                {
                    refOr = (Or)another.InnerOr.Clone();
                }

                if (another.InnerAnd != null)
                {
                    refAnd = (And)another.InnerAnd.Clone();
                }

                if (another.Formula != null)
                {
                    refFormula = (AndOrFormula)another.Formula.Clone();
                }
            }
            catch (Exception e)
            {
                e.ToString();
            }

            oid = refOid;
            and = refAnd;
            or = refOr;
            formula = refFormula;
            atom = refAtom;
        }
Example #4
0
        public Torso(Torso another)
        {
            Atom refAtom = null;

            try
            {
                if (another.Atom != null)
                {
                    refAtom = (Atom)another.Atom.Clone();
                }
            }
            catch (Exception e)
            {
                e.ToString();
            }

            atom = refAtom;
        }
Example #5
0
        public Head(Head another)
        {
            Atom refAtom = null;

            try
            {
                if (another.Atom != null)
                {
                    refAtom = (Atom)another.Atom.Clone();
                }
            }
            catch (Exception e)
            {
                e.ToString();
            }

            atom = refAtom;
            atom.initialIndividuals();
        }
Example #6
0
        public ForAllFormula(ForAllFormula another)
        {
            Atom refAtom = null;
            ForAll refForall = null;
            Implies refImplies = null;
            Equivalent refEquivalent = null;

            try
            {
                if (another.Atom != null)
                {
                    refAtom = (Atom)another.Atom.Clone();
                }

                if (another.Equivalent != null)
                {
                    refEquivalent = (Equivalent)another.Equivalent.Clone();
                }

                if (another.Implies != null)
                {
                    refImplies = (Implies)another.Implies.Clone();
                }

                if (another.InnerForAll != null)
                {
                    refForall = (ForAll)another.InnerForAll.Clone();
                }
            }
            catch (Exception e)
            {
                e.ToString();
            }

            atom = refAtom;
            imp = refImplies;
            forall = refForall;
            eq = refEquivalent;
        }
Example #7
0
        public QueryFormula(QueryFormula another)
        {
            formula = new ArrayList();
            Atom refAtom = null;
            Exist refExist = null;

            try
            {
                if (another.Atom != null)
                {
                    refAtom = (Atom)another.Atom.Clone();
                }

                if (another.Exist != null)
                {
                    refExist = (Exist)another.Exist.Clone();
                }

                if (another.Formula != null)
                {
                    AndOrFormula[] items = (AndOrFormula[])another.Formula.Clone();
                    formula.Clear();
                    foreach (AndOrFormula item in items)
                    {
                        formula.Add(new AndOrFormula(item));
                    }
                }
            }
            catch (Exception e)
            {
                e.ToString();
            }

            atom = refAtom;
            Exist = refExist;
        }
Example #8
0
        public Atom(Atom another)
        {
            Oid refOid = null;
            individual = new ArrayList();
            variable = new ArrayList();
            slot = new ArrayList();
            data = new ArrayList();
            variableNames = new ArrayList();
            variableValues = new ArrayList();
            Degree refDegree = null;
            Operator refOperator = null;

            try
            {
                if (another.Oid != null)
                {
                    refOid = (Oid)another.Oid.Clone();
                }

                if (another.Degree != null)
                {
                    refDegree = (Degree)another.Degree.Clone();
                }

                if (another.Operator != null)
                {
                    refOperator = (Operator)another.Operator.Clone();
                }

                if (another.Data != null)
                {
                    string[] items = (string[])another.Data.Clone();
                    foreach (string item in items)
                    {
                        data.Add(new string(item.ToCharArray()));
                    }
                }

                if (another.Individual != null)
                {
                    string[] items = (string[])another.Individual.Clone();
                    foreach (string item in items)
                    {
                        individual.Add(new string(item.ToCharArray()));
                    }
                }

                if (another.Variable != null)
                {
                    string[] items = (string[])another.Variable.Clone();
                    foreach (string item in items)
                    {
                        variable.Add(new string(item.ToCharArray()));
                    }
                }

                if (another.Slot != null)
                {
                    Slot[] items = (Slot[])another.Slot.Clone();
                    foreach (Slot item in items)
                    {
                        slot.Add(new Slot(item));
                    }
                }

                if (another.VariableNames != null)
                {
                    string[] items = (string[])another.VariableNames.Clone();
                    foreach (string item in items)
                    {
                        variableNames.Add(new string(item.ToCharArray()));
                    }
                }

                if (another.VariableValues != null)
                {
                    string[] items = (string[])another.VariableValues.Clone();
                    foreach (string item in items)
                    {
                        variableValues.Add(new string(item.ToCharArray()));
                    }
                }
            }
            catch (Exception e)
            {
                e.ToString();
            }

            oid = refOid;
            degree = refDegree;
            Operator = refOperator;
            fixedInd = another.FixedIndCount;
            assignedVariableCount = another.assignedVariableCount;
            variablesAssigned = another.variablesAssigned;
            index = -1;
        }
Example #9
0
        public override bool Equals(object o)
        {
            if (o == null || GetType() != o.GetType())
            {
                return false;
            }

            Atom other = new Atom((Atom)o);

            if (this.oid != null)
            {
                if (!this.Oid.Equals(other.Oid))
                {
                    return false;
                }
            }

            if (this.Operator != null)
            {
                if (!this.Operator.Equals(other.Operator))
                {
                    return false;
                }
            }

            /*
             * if (this.Degree != null)
             * {
             *  if (!this.Degree.Equals(other.Degree))
             * {
             * return false;
             * }
             * }
             */

            if (this.Individual.Length != other.Individual.Length)
            {
                return false;
            }

            for (int i = 0; i < Individual.Length; i++)
            {
                if (!Individual[i].Equals(other.Individual[i]))
                {
                    return false;
                }
            }

            if (this.Data.Length != other.Data.Length)
            {
                return false;
            }

            for (int i = 0; i < Data.Length; i++)
            {
                if (!Data[i].Equals(other.Data[i]))
                {
                    return false;
                }
            }

            if (this.Variable.Length != other.Variable.Length)
            {
                return false;
            }

            for (int i = 0; i < Variable.Length; i++)
            {
                if (!Variable[i].Equals(other.Variable[i]))
                {
                    return false;
                }
            }

            if (this.Slot.Length != other.Slot.Length)
            {
                return false;
            }

            for (int i = 0; i < Slot.Length; i++)
            {
                if (!Slot[i].Equals(other.Slot[i]))
                {
                    return false;
                }
            }

            return true;
        }
Example #10
0
        public int CompareTo(object o)
        {
            Atom another = new Atom((Atom)o);

            if (another.Degree != null && degree != null)
            {
                double thiscf = double.Parse(degree.Data.ToString());
                double anothercf = double.Parse(another.Degree.Data.ToString());

                if (thiscf > anothercf)
                {
                    return -1;
                }
                else if (thiscf == anothercf)
                {
                    return 0;
                }
                else
                {
                    return 1;
                }
            }
            else if (another.Degree != null)
            {
                return 1;
            }
            else if (degree != null)
            {
                return -1;
            }

            return 0;
        }