Exemplo n.º 1
0
 public override string ToString()
 {
     if (Function is ArithmeticBinaryFunction)
     {
         return($"{LeftBracket.GetInstance()}{_terms[0]}{Function}{_terms[1]}{RightBracket.GetInstance()}");
     }
     return($"{Function}{LeftBracket.GetInstance()}{string.Join<Term>(Comma.GetInstance().ToString(), _terms)}{RightBracket.GetInstance()}");
 }
 public override string ToString()
 {
     return($"{LeftBracket.GetInstance()}{Quantifier}{ObjectVariable}{RightBracket.GetInstance()}{SubFormula}");
 }
Exemplo n.º 3
0
        public override string ToString()
        {
            if (Predicate is ArithmeticPredicate)
            {
                return($"{LeftBracket.GetInstance()}{_terms[0]}{Predicate}{_terms[1]}{RightBracket.GetInstance()}");
            }

            return($"{Predicate}{LeftBracket.GetInstance()}{string.Join<Term>(Comma.GetInstance().ToString(), _terms)}{RightBracket.GetInstance()}");
        }
Exemplo n.º 4
0
 public override string ToString()
 {
     return(Connective switch
     {
         UnaryPropositionalConnective _ => $"{LeftBracket.GetInstance()}{Connective}{_formulas[0]}{RightBracket.GetInstance()}",
         BinaryPropositionalConnective _ => $"{LeftBracket.GetInstance()}{_formulas[0]}{Connective}{_formulas[1]}{RightBracket.GetInstance()}",
         _ => throw new NotSupportedException("Connective must be unary or binary")
     });
Exemplo n.º 5
0
        private static IEnumerable <Symbol> ToSymbols(string str)
        {
            var index = 0;
            var isLastForUnaryMinus = true;

            while (index < str.Length)
            {
                switch (str[index])
                {
                case ' ':
                    ++index;
                    continue;

                case '(':
                    yield return(LeftBracket.GetInstance());

                    isLastForUnaryMinus = true;
                    ++index;
                    continue;

                case ')':
                    yield return(RightBracket.GetInstance());

                    isLastForUnaryMinus = false;
                    ++index;
                    continue;

                case ',':
                    yield return(Comma.GetInstance());

                    isLastForUnaryMinus = true;
                    ++index;
                    continue;

                case '\\':
                    yield return(SpecialSymbol(str, ref index));

                    isLastForUnaryMinus = true;
                    continue;
                }

                if (char.IsLetter(str[index]))
                {
                    yield return(LetterSymbol(str, ref index));

                    isLastForUnaryMinus = false;
                    continue;
                }

                if (char.IsDigit(str[index]))
                {
                    yield return(DigitSymbol(str, ref index));

                    isLastForUnaryMinus = false;
                    continue;
                }

                if (IsArithmeticPredicate(str[index]))
                {
                    yield return(ArithmeticPredicateSymbol(str, ref index));

                    isLastForUnaryMinus = true;
                    continue;
                }

                if (str[index] == '-')
                {
                    if (isLastForUnaryMinus)
                    {
                        yield return(UnaryMinus.GetInstance());

                        ++index;
                        continue;
                    }
                }

                if (IsArithmeticBinaryFunction(str[index]))
                {
                    yield return(ArithmeticBinaryFunctionSymbol(str, ref index));

                    isLastForUnaryMinus = true;
                    continue;
                }

                throw new ArgumentException($"the symbol {str[index]} with the number {index} is unexpected");
            }
        }