Example #1
0
        public bool UniversalQuantifierRule(ref DerivationStep s)
        {
            List <Node> temp = s.GetFormulas().ToList();

            foreach (var n in s.GetFormulas())
            {
                if (n is Universal u)
                {
                    Universal newUniversal = FunctionHelper.DeepClone <Universal>(u);
                    if (newUniversal.ReplaceChecked() == true)
                    {
                        continue;
                    }
                    DerivationStep newStep = new DerivationStep(s.GetActiveVariables());
                    newUniversal.SetSubtitution();
                    foreach (var v in newStep.GetActiveVariables())
                    {
                        Node addNode = FunctionHelper.DeepClone <Node>(newUniversal.RightNode);
                        this.ChangeVarHelperUni(addNode, v);
                        newStep.AddFormulas(addNode);
                    }
                    newStep.AddFormulas(newUniversal);
                    newStep.Merge(temp);
                    s.RightNode = newStep;
                    this._branchingPoint.Push(s.RightNode);
                    return(true);
                }
                else if (n is Negation && n.RightNode is Existential e)
                {
                    Existential newExist = FunctionHelper.DeepClone <Existential>(e);
                    if (newExist.ReplaceChecked() == true)
                    {
                        continue;
                    }
                    DerivationStep newStep = new DerivationStep(s.GetActiveVariables());
                    newExist.SetSubtitution();
                    foreach (var v in newStep.GetActiveVariables())
                    {
                        Node addNode = FunctionHelper.DeepClone <Node>(newExist.RightNode);
                        this.ChangeVarHelperUni(addNode, v);
                        newStep.AddFormulas(new Negation("~", addNode));
                    }
                    newStep.AddFormulas(new Negation("~", newExist));
                    newStep.Merge(temp);
                    s.RightNode = newStep;
                    this._branchingPoint.Push(s.RightNode);
                    return(true);
                }
            }
            return(false);
        }