public static object GetRandomBooleanFormula(int countVariables, int depthBound, int sizeBound)
        {
            BooleanFormula booleanFormula = BooleanFormula.RandomFormula(countVariables, sizeBound, depthBound);

            BooleanFunction booleanFunction = new BooleanFunction(1, 1);
            booleanFunction.SetNewBooleanFormula(booleanFormula);

            return  CheckLatex(booleanFormula.ToLaTeXString());
        }
        public static object GetRandomBooleanFormulaWithParams(int countVariables, int depthBound, int sizeBound, bool isByLatex)
        {
            BooleanFormula booleanFormula = BooleanFormula.RandomFormula(countVariables, sizeBound, depthBound);

            BooleanFunction booleanFunction = new BooleanFunction(1, 1);
            booleanFunction.SetNewBooleanFormula(booleanFormula);

            var data = new
            {
                result = isByLatex ? booleanFormula.ToLaTeXString() : CheckLatex(booleanFormula.ToLaTeXString()),

                isMonotone = booleanFunction.IsMonotone(),
                isBalanced = booleanFunction.IsBalanced(),
                isLinear = booleanFunction.IsLinear(),

                isSelfAdjoint = booleanFunction.IsSelfAdjoint(),// Самосопряженная
                isComplete = booleanFunction.IsComplete(),
                isBasis = booleanFunction.IsBasis()
            };

            return data;
        }
        // Генерируем и возвращаем изображение // Генерируется задача в зависимости от присланного номера
        public string CheckBooleanFormulaInput(string formula, int operation)
        {
            formula = formula.Replace("{", "(!(");
            formula = formula.Replace("}", "))");
            formula = formula.Trim();

            try
            {
                if (operation == 0)
                {

                    List<BooleanVariable> variables = new List<BooleanVariable>();
                    BooleanFormula booleanFormula = BooleanFormulaParser.Parse(formula, variables);

                    return booleanFormula.ToLaTeXString();
                } else if (operation == 1)
                {

                    List<BooleanVariable> variables = new List<BooleanVariable>();
                    BooleanFormula booleanFormula = BooleanFormulaParser.Parse(formula, variables);

                    return BooleanFormulaService.CheckLatex(booleanFormula.ToLaTeXString());
                } else if (operation == 2)
                {

                    List<BooleanVariable> variables = new List<BooleanVariable>();
                    BooleanFormula booleanFormula = BooleanFormulaParser.Parse(formula, variables);

                    return BooleanFormulaService.CheckLatex(booleanFormula.GetZhegalkinPolynomial().ToLaTeXString());
                }
                else if (operation == 3)
                {

                    List<BooleanVariable> variables = new List<BooleanVariable>();
                    BooleanFormula booleanFormula = BooleanFormulaParser.Parse(formula, variables);

                    return BooleanFormulaService.CheckLatex(BooleanFormula.PerfectCNF(booleanFormula).ToLaTeXString());
                }else if (operation == 4)
                {

                    List<BooleanVariable> variables = new List<BooleanVariable>();
                    BooleanFormula booleanFormula = BooleanFormulaParser.Parse(formula, variables);

                    return BooleanFormulaService.CheckLatex(BooleanFormula.PerfectDNF(booleanFormula).ToLaTeXString());
                }
                else if (operation == 5)
                {

                    List<BooleanVariable> variables = new List<BooleanVariable>();

                    BooleanFunction booleanFunction = new BooleanFunction(1,1);
                    booleanFunction.SetNewBooleanFormula(BooleanFormulaParser.Parse(formula, variables));

                    return BooleanFormulaService.CheckLatex(booleanFunction.ToLaTeXBooleanTable());
                }
                else
                {
                    return BooleanFormulaService.CheckLatex("Not_selected_operation");
                }
            }
            catch (Exception e)
            {
                return BooleanFormulaService.CheckLatex("Error_in_formule!"); ;
            }
        }