Esempio n. 1
0
        public void Test4()
        {
            ObjectVariableTerm x = new ObjectVariable('x');

            IndividualConstantTerm <RationalNumber> half =
                (IndividualConstant <RationalNumber>)(new RationalNumber(1, 2));

            IndividualConstantTerm <RationalNumber>
            one = (IndividualConstant <RationalNumber>)(new RationalNumber(1, 1));

            var pr1 = new PredicateFormula(Predicates.More, x, half);
            var pr2 = new PredicateFormula(Predicates.Less, x, one);

            var f1 = new PropositionalConnectiveFormula(Conjunction.GetInstance(), pr1, pr2);
            var f2 = new QuantifierFormula(ExistentialQuantifier.GetInstance(), x, f1);


            IndividualConstantTerm <int> two = new IndividualConstant <int>(2);
            var xSqr = new FunctionTerm(Functions.Pow, x, two);

            var pr3 = new PredicateFormula(Predicates.MoreZero, xSqr);
            var pr4 = new PredicateFormula(Predicates.EqualZero, x);

            var f3 = new PropositionalConnectiveFormula(Disjunction.GetInstance(), pr3, pr4);

            var f      = new PropositionalConnectiveFormula(Conjunction.GetInstance(), f2, f3);
            var actual = SimpleTarskiAlgorithm.QuantifiersElimination(f);

            Formula expected  = f3;
            Formula expected1 = new PropositionalConnectiveFormula(Disjunction.GetInstance(), pr4, pr3);

            Assert.IsTrue(expected.Equals(actual) || expected1.Equals(actual));
        }
Esempio n. 2
0
        private static Symbol SpecialSymbol(string str, ref int index)
        {
            ++index;
            if (index >= str.Length)
            {
                throw new ArgumentException(
                          $"a tag was expected, but there is no tag before the symbol \\ with the number {index - 1}");
            }

            var tag = GetTag(str, ref index);

            if (tag.Length == 0)
            {
                throw new ArgumentException(
                          $"a tag was expected, but there is no tag before the symbol \\ with the number {index - 1}");
            }

            return(tag switch
            {
                "lnot" => Negation.GetInstance(),
                "lor" => Disjunction.GetInstance(),
                "land" => Conjunction.GetInstance(),
                "to" => Implication.GetInstance(),
                "forall" => UniversalQuantifier.GetInstance(),
                "exists" => ExistentialQuantifier.GetInstance(),
                "over" => Division.GetInstance(),
                "func" => GetFunction(str, ref index), // \func{name arity}
                "pr" => GetPredicate(str, ref index),  // \pr{name arity}
                _ => throw new ArgumentException($"unknown tag {tag} before the symbol with the number {index}")
            });
Esempio n. 3
0
        public void Test2()
        {
            ObjectVariableTerm x = new ObjectVariable('x');

            IndividualConstantTerm <RationalNumber> half =
                (IndividualConstant <RationalNumber>)(new RationalNumber(1, 2));

            IndividualConstantTerm <RationalNumber> one = (IndividualConstant <RationalNumber>) new RationalNumber(1, 1);

            var pr1 = new PredicateFormula(Predicates.More, x, half);

            var pr2 = new PredicateFormula(Predicates.Less, x, one);

            var f1 = new PropositionalConnectiveFormula(Conjunction.GetInstance(), pr1, pr2);

            var f2 = new QuantifierFormula(ExistentialQuantifier.GetInstance(), x, f1);

            var actual = SimpleTarskiAlgorithm.QuantifiersElimination(f2);

            var expected = new PredicateFormula(True.GetInstance());

            Assert.AreEqual(expected, actual);
        }
Esempio n. 4
0
 public ConjunctionRemovingRight(SequentFormula first, int firstNumber)
 {
     _first       = first;
     _firstNumber = firstNumber;
     IsValid      = _first.Consequent != null && _first.Consequent.TopConnective.Equals(Conjunction.GetInstance());
 }