private void DfsPush(Formula formula) { if (Contains(formula)) { return; } if (Hypotheses != null && Hypotheses.Contains(formula)) { Add(formula); return; } if (Axioms.Contains(formula)) { Add(formula); return; } if (formula is MpFormula mpFormula) { DfsPush(mpFormula.A); DfsPush(mpFormula.B); Add(formula); return; } throw new Exception(); }
public bool Push(Formula formula) { if (Contains(formula)) { return(false); } if (Hypotheses != null && Hypotheses.Contains(formula)) { Add(formula); return(true); } if (Axioms.Contains(formula)) { Add(formula); return(true); } var mpFormula = FindMpPair(formula); if (mpFormula != null) { Add(mpFormula); return(true); } return(false); }
public override string ToString() { var ret = new string[Length]; foreach (var f in _inferenceSet.Keys) { var line = new StringBuilder(); line.Append($"{_inferenceSet[f]}. "); line.Append(f); if (Hypotheses != null && Hypotheses.Contains(f)) { line.Append(StringConstants.IsHypothesis); } else if (Axioms.Contains(f)) { line.Append("; "); line.Append(Axioms.FindAppropriateAxiom(f).Name); } else if (f is MpFormula mpF) { line.Append(StringConstants.IsMpFormula); var indA = _inferenceSet[mpF.A]; var indB = _inferenceSet[mpF.B]; line.Append(indA + ", " + indB); } else { throw new Exception(); } ret[_inferenceSet[f]] = line.ToString(); } return(string.Join(StringConstants.LineEnd, ret)); }