コード例 #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);
        }
コード例 #2
0
        public bool ExistentialQuantifierRule(ref DerivationStep s)
        {
            List <Node> temp = s.GetFormulas().ToList();

            foreach (var n in s.GetFormulas())
            {
                int index = s.GetFormulas().IndexOf(n);
                if (n is Existential e)
                {
                    Existential newExist = FunctionHelper.DeepClone <Existential>(e);
                    temp.RemoveAt(index);
                    DerivationStep newStep = new DerivationStep(s.GetActiveVariables());
                    newStep.AddActiveVariable();
                    string checkVar = newExist.GetVariable().ToString();
                    this.ChangeVarHelperExist(newExist.RightNode, newStep.GetLastVar(), checkVar);
                    newStep.AddFormulas(newExist.RightNode);
                    newStep.Merge(temp);
                    s.RightNode = newStep;
                    this._branchingPoint.Push(s.RightNode);
                    return(true);
                }
                else if (n is Negation && n.RightNode is Universal u)
                {
                    Universal newUni = FunctionHelper.DeepClone <Universal>(u);
                    temp.RemoveAt(index);
                    DerivationStep newStep = new DerivationStep(s.GetActiveVariables());
                    newStep.AddActiveVariable();
                    string checkVar = newUni.GetVariable().ToString();
                    this.ChangeVarHelperExist(newUni.RightNode, newStep.GetLastVar(), checkVar);
                    newStep.AddFormulas(new Negation("~", newUni.RightNode));
                    newStep.Merge(temp);
                    s.RightNode = newStep;
                    this._branchingPoint.Push(s.RightNode);
                    return(true);
                }
            }
            return(false);
        }