コード例 #1
0
        public static SequentFormula Apply(SequentFormula first, SequentFormula second, SequentFormula third)
        {
            if (Disjunction.GetInstance().Equals(first.Consequent.TopConnective) == false)
            {
                return(null);
            }
            if (second.Consequent == null || third.Consequent == null)
            {
                return(null);
            }
            if (second.Consequent.Equals(third.Consequent) == false)
            {
                return(null);
            }

            var newAntecedents = new HashSet <Formula>();

            foreach (var antecedent in first)
            {
                newAntecedents.Add(antecedent);
            }
            foreach (var antecedent in second)
            {
                newAntecedents.Add(antecedent);
            }
            foreach (var antecedent in third)
            {
                newAntecedents.Add(antecedent);
            }

            var newConsequent = second.Consequent;

            return(new SequentFormula(newAntecedents, newConsequent));
        }
コード例 #2
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));
        }
コード例 #3
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}")
            });