/** This tries a particular solution against the formula. */
private static Solution trial (A4Reporter rep, TupleFactory fac, Solver solver, Iterable<Sig> sigs, Formula f, A4Solution frame, Object[] t) {
try {
frame.kr2typeCLEAR();
Bounds b = null;
TupleSet ts = null;
for(int i=1; i<t.length; i++) {
Object x=t[i];
if (x==null) return null;
if (x instanceof String && ((String)x).length()>0) { // This means it's a unary Tuple containing the given atom
Tuple xx = fac.tuple((String)x);
if (ts==null) ts=fac.noneOf(1);
ts.add(xx);
continue;
}
if (x instanceof Tuple) { // This means it's a Tuple
Tuple xx=(Tuple)x;
if (ts==null) ts=fac.noneOf(xx.arity());
ts.add(xx);
continue;
}
if (x instanceof String) { // The empty string means the sig name follows here
i++;
if (i>=t.length-1 || !(t[i] instanceof String) || !(t[i+1] instanceof String)) return null;
String sigName = (String)(t[i]);
i++;
String fieldName = (String)(t[i]);
Sig first = hasSig(sigs,sigName);
if (first==null) return null;
Expression expr = null;
if (fieldName.length()==0) {
expr=frame.a2k(first);
} else {
for(Field field:first.getFields()) if (field.label.equals(fieldName)) {
expr=frame.a2k(field);
while(expr instanceof BinaryExpression) expr=((BinaryExpression)expr).right();
break;
}
}
if (!(expr instanceof Relation)) return null;
if (b==null) b = frame.getBounds(); // We delay the expansive Bounds.clone() until we really find a possible match
if (ts==null) ts = fac.noneOf(expr.arity());
if (!ts.containsAll(b.lowerBound((Relation)expr))) return null; // Sanity check
if (!b.upperBound((Relation)expr).containsAll(ts)) return null; // Sanity check
b.boundExactly((Relation)expr, ts);
ts=null;
continue;
}
}
SATFactory sat = solver.options().solver();