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); }
public bool UnBranchingRules(ref DerivationStep s) { List <Node> temp = s.GetFormulas().ToList(); foreach (var n in s.GetFormulas()) { int index = s.GetFormulas().IndexOf(n); if (n is Negation && n.RightNode is OrOperator o) { temp.RemoveAt(index); s.RightNode = new DerivationStep(s.GetActiveVariables()); s.RightNode.AddFormulas(new Negation("~", o.LeftNode)); s.RightNode.AddFormulas(new Negation("~", o.RightNode)); s.RightNode.Merge(temp); this._branchingPoint.Push(s.RightNode); return(true); } else if (n is Negation && n.RightNode is Negation n1) { temp.RemoveAt(index); s.RightNode = new DerivationStep(s.GetActiveVariables()); s.RightNode.AddFormulas(n1.RightNode); s.RightNode.Merge(temp); this._branchingPoint.Push(s.RightNode); return(true); } else if (n is Negation && n.RightNode is Implication i) { temp.RemoveAt(index); s.RightNode = new DerivationStep(s.GetActiveVariables()); s.RightNode.AddFormulas(i.LeftNode); s.RightNode.AddFormulas(new Negation("~", i.RightNode)); s.RightNode.Merge(temp); this._branchingPoint.Push(s.RightNode); return(true); } else if (n is AndOperator a) { temp.RemoveAt(index); s.RightNode = new DerivationStep(s.GetActiveVariables()); s.RightNode.AddFormulas(a.LeftNode); s.RightNode.AddFormulas(a.RightNode); s.RightNode.Merge(temp); this._branchingPoint.Push(s.RightNode); return(true); } } return(false); }
public void CreateProofTree() { this._root.AddFormulas(new Negation("~", _treeRoot)); this._branchingPoint.Push(this._root); while (this._branchingPoint.Count > 0) { DerivationStep s = (DerivationStep)this._branchingPoint.Pop(); if (FunctionHelper.IsClosed(s.GetFormulas())) { s.RightNode = new DerivationStep(); s.RightNode.AddFormulas(new Node("X")); } else { if (this.UnBranchingRules(ref s) || this.ExistentialQuantifierRule(ref s) || this.BranchingRules(ref s) || this.UniversalQuantifierRule(ref s)) { continue; } } } }
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); }
public SemanticTableaux(Node treeRoot) { this._branchingPoint = new Stack <Node>(); this._root = new DerivationStep(); this._treeRoot = treeRoot; }