예제 #1
0
        private static Matrix AllAre(IEnumerable <Variable> aVariables, UnaryPredicate aPredicate)
        {
            Matrix lMatrix = Predication(aPredicate, aVariables.First());

            foreach (Variable lVariable in aVariables.Skip(1))
            {
                lMatrix = And(lMatrix, Predication(aPredicate, lVariable));
            }
            return(lMatrix);
        }
예제 #2
0
        public UnaryPredicate AddUnaryPredicate(char aSymbol)
        {
            if (mUnaryPredicates.ContainsKey(aSymbol))
            {
                return(mUnaryPredicates[aSymbol]);
            }
            else
            {
                UnaryPredicate aPredicate = Factory.UnaryPredicate(aSymbol);

                mUnaryPredicates.Add(aSymbol, aPredicate);

                return(aPredicate);
            }
        }
예제 #3
0
        public Matrix AddUnaryPredication(UnaryPredicate aPredicate, Variable aVariable)
        {
            Matrix lPredication = Factory.Predication(aPredicate, aVariable);

            if (mPredications.ContainsKey(lPredication))
            {
                return(mPredications[lPredication]);
            }
            else
            {
                mPredications.Add(lPredication, lPredication);

                return(lPredication);
            }
        }
예제 #4
0
        public void Test_Bits_Needed_Modal()
        {
            NullPredicate[]  lNullPredicates  = new NullPredicate[34];
            UnaryPredicate[] lUnaryPredicates = new UnaryPredicate[7];
            bool[ , , ] lMap = new bool[lNullPredicates.Length + 2, lUnaryPredicates.Length + 2, 19];

            for (int n = lNullPredicates.Length; n >= 0; n--)
            {
                for (int u = lUnaryPredicates.Length; u >= 0; u--)
                {
                    for (int i = 17; i >= 1 || (i == 0 && u == 0); i--)
                    {
                        try
                        {
                            new Predicates(lNullPredicates.Take(n), lUnaryPredicates.Take(u), i, true, 0);
                            lMap[n, u, i] = true;
                        }
                        catch (EngineException)
                        {
                        }
                    }
                }
            }

            for (int n = lNullPredicates.Length; n >= 0; n--)
            {
                for (int u = lUnaryPredicates.Length; u >= 0; u--)
                {
                    for (int i = 17; i >= 1 || (i == 0 && u == 0); i--)
                    {
                        if (lMap[n, u, i] && !lMap[n + 1, u, i] && !lMap[n, u + 1, i] && !lMap[n, u, i + 1])
                        {
                            //Console.WriteLine( "n = {0}, u = {1}, i = {2}, t = {3}", n, u, i, t );
                            Console.WriteLine("  <tr><td>{0}</td><td>{1}</td><td>{2}</td></tr>", n, u, i);
                        }
                    }
                }
            }

            new Predicates(lNullPredicates.Take(32), lUnaryPredicates.Take(0), 0, false, 0);
        }
예제 #5
0
        public static Matrix ThereAreThisManyOfThese(uint aNumber, UnaryPredicate aPredicate)
        {
            Variable[] lVariables = MakeNVariables(Math.Max(aNumber, 1));
            switch (aNumber)
            {
            case 0:
                return(ForAll(lVariables[0], Not(Predication(aPredicate, lVariables[0]))));

            case 1:
                return(The(lVariables[0], Predication(aPredicate, lVariables[0])));

            default:
                Variable lVariable = Variable('x');
                return(Bind(
                           lVariables,
                           And(
                               AllAre(lVariables, aPredicate),
                               AreDistinct(lVariables),
                               ForAll(lVariable, OnlyIf(Predication(aPredicate, lVariable), Disjoin(lVariables.Select(fVariable => TheSame(lVariable, fVariable)))))),
                           ThereExists));
            }
        }
예제 #6
0
 public bool Denies(UnaryPredicate aPredicate)
 {
     return(mPredicates.ContainsKey(aPredicate) ? !mPredicates[aPredicate] : false);
 }
예제 #7
0
 public bool Affirms(UnaryPredicate aPredicate)
 {
     return(mPredicates.ContainsKey(aPredicate) ? mPredicates[aPredicate] : false);
 }
예제 #8
0
 /// <summary>
 /// Create a predication on a single variable.
 /// </summary>
 /// <param name="aPredicate">a predicate</param>
 /// <param name="aVariable">a variable</param>
 /// <returns>a new predication</returns>
 public static Matrix Predication(UnaryPredicate aPredicate, Variable aVariable)
 {
     return(new UnaryPredication(aPredicate, aVariable));
 }
예제 #9
0
 /// <summary>
 /// Create a term.
 /// </summary>
 /// <param name="aPredicate">a unary predicate</param>
 /// <param name="aIsNegative">true if the term contains all and only objects which verify the predicate,
 /// false if the term contains all and only objects which falsify the predicate</param>
 /// <returns>a term</returns>
 public static Term AllAndOnly(UnaryPredicate aPredicate, bool aIsNegative)
 {
     return(new Term(aPredicate, aIsNegative));
 }
 internal UnaryPredication(UnaryPredicate aPredicate, Variable aVariable)
 {
     mPredicate = aPredicate;
     mVariable  = aVariable;
 }