public void addClause(Clause c, ISet<Clause> sos, ISet<Clause> usable) { // Perform forward subsumption elimination bool addToSOS = true; for (int i = this.minNoLiterals; i < c.GetNumberLiterals(); i++) { var fs = this.clausesGroupedBySize[i]; if (null != fs) { addToSOS = fs.All(s => !s.Subsumes(c)); } if (!addToSOS) { break; } } if (addToSOS) { sos.Add(c); lightestClauseHeuristic.AddedClauseToSOS(c); this.IndexClause(c); // Have added clause, therefore // perform backward subsumption elimination ISet<Clause> subsumed = new HashedSet<Clause>(); for (var i = c.GetNumberLiterals() + 1; i <= this.maxNoLiterals; i++) { subsumed.Clear(); var bs = this.clausesGroupedBySize[i]; if (null == bs) { continue; } foreach (var s in bs.Where(c.Subsumes)) { subsumed.Add(s); if (sos.Contains(s)) { sos.Remove(s); this.lightestClauseHeuristic.RemovedClauseFromSOS(s); } usable.Remove(s); } bs.ExceptWith(subsumed); } } }
public bool IsCheckForUnitRefutation(Clause clause) { if (this.IsLookingForAnswerLiteral()) { if (2 == clause.GetNumberLiterals()) { return clause.GetLiterals().Any(t => t.AtomicSentence.GetSymbolicName().Equals(this.answerLiteral.AtomicSentence.GetSymbolicName())); } } else { return clause.IsUnitClause(); } return false; }
private void IndexClause(Clause c) { int size = c.GetNumberLiterals(); if (size < this.minNoLiterals) { this.minNoLiterals = size; } if (size > this.maxNoLiterals) { this.maxNoLiterals = size; } var cforsize = this.clausesGroupedBySize[size]; if (null == cforsize) { cforsize = new HashedSet<Clause>(); this.clausesGroupedBySize[size] = cforsize; } cforsize.Add(c); }