public SymbolValuePair findPureSymbolValuePair(List<Sentence> clauseList,
Model model, List<Symbol> symbols)
{
List<Sentence> _clausesWithNonTrueValues = clausesWithNonTrueValues(clauseList,
model);
Sentence nonTrueClauses = LogicUtils.chainWith("AND",
_clausesWithNonTrueValues);
// System.Console.WriteLine("Unsatisfied clauses = "
// + clausesWithNonTrueValues.Count);
List<Symbol> symbolsAlreadyAssigned = new List<Symbol>( model.getAssignedSymbols());
// debug
// List symList = asList(symbolsAlreadyAssigned);
//
// System.Console.WriteLine(" assignedSymbols = " + symList.Count);
// if (symList.Count == 52) {
// System.Console.WriteLine("untrue clauses = " + clausesWithNonTrueValues);
// System.Console.WriteLine("model= " + model);
// }
// debug
List<Symbol> purePositiveSymbols = SetOps
.difference(new SymbolClassifier()
.getPurePositiveSymbolsIn(nonTrueClauses),
symbolsAlreadyAssigned);
List<Symbol> pureNegativeSymbols = SetOps
.difference(new SymbolClassifier()
.getPureNegativeSymbolsIn(nonTrueClauses),
symbolsAlreadyAssigned);
// if none found return "not found
if ((purePositiveSymbols.Count == 0)
&& (pureNegativeSymbols.Count == 0))
{
return new SymbolValuePair();// automatically set to null values
}
else
{
if (purePositiveSymbols.Count > 0)
{
Symbol symbol =purePositiveSymbols[0];
if (pureNegativeSymbols.Contains(symbol))
{
throw new ApplicationException("Symbol " + symbol.getValue()
+ "misclassified");
}
return new SymbolValuePair(symbol, true);
}
else
{
Symbol symbol = new Symbol((pureNegativeSymbols[0])
.getValue());
if (purePositiveSymbols.Contains(symbol))
{
throw new ApplicationException("Symbol " + symbol.getValue()
+ "misclassified");
}
return new SymbolValuePair(symbol, false);
}
}
}