* v = abs(r.literal) and
* no r': log.records | r'.node = r.node && log.replay.r' > log.replay.r }
* </pre>
*/
public static IntSet rootVars(TranslationLog log) {
final IntSet rootVars = new IntTreeSet();
final Set<Formula> roots = log.roots();
final Map<Formula,int[]> maxRootVar = new LinkedHashMap<Formula,int[]>(roots.size());
final RecordFilter filter = new RecordFilter() {
public boolean accept(Node node, Formula translated, int literal, Map<Variable, TupleSet> env) {
return roots.contains(translated) && env.isEmpty();
}
};
for(Iterator<TranslationRecord> itr = log.replay(filter); itr.hasNext();) {
TranslationRecord record = itr.next();
int[] var = maxRootVar.get(record.translated());
if (var==null) {
var = new int[1];
maxRootVar.put(record.translated(), var);
}
var[0] = StrictMath.abs(record.literal());
}
for(int[] var : maxRootVar.values()) {
int topVar = var[0];
if (topVar != Integer.MAX_VALUE) // formula simplified to TRUE
rootVars.add(var[0]);
}
// for(Map.Entry<Formula,int[]> entry : maxRootVar.entrySet()) {
// final int topVar = entry.getValue()[0];
// if (topVar != Integer.MAX_VALUE) // formula simplified to TRUE