Skip to content

Commit

Permalink
polystat#12 fixed a conjunction with false value
Browse files Browse the repository at this point in the history
  • Loading branch information
mnj2kk committed Jul 14, 2022
1 parent 205776e commit da979f7
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions src/main/java/org/polystat/far/Expr.java
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,18 @@ public Directives find() {
final Solver slv = CTX.mkSolver();
final List<BoolExpr> list = new ArrayList<>(0);
for (final XML obj : this.xml.nodes("o/o")) {
final BoolExpr cur = opts(obj);
list.add(cur);
final String name = obj.xpath("@name").get(0);
BoolExpr equation = CTX.mkNot(
CTX.mkEq(
CTX.mkConst(name, CTX.getStringSort()),
CTX.mkString("NONE")
)
);
final BoolExpr cur = opts(obj, name);
if (!cur.isFalse()) {
equation = CTX.mkAnd(cur, equation);
}
list.add(equation);
}
list.add(this.mkVariables());
slv.add(list.toArray(new BoolExpr[0]));
Expand All @@ -113,11 +123,11 @@ public Directives find() {
/**
* Parse opts tags.
* @param xml Current XML block
* @param name Attr name of current XML block
* @return BoolExpr of current block
*/
private static BoolExpr opts(final XML xml) {
private static BoolExpr opts(final XML xml, final String name) {
BoolExpr result = CTX.mkFalse();
final String name = xml.xpath("@name").get(0);
final List<Map<String, BoolExpr>> obj = new ArrayList<>(0);
for (final XML opts : xml.nodes("opts")) {
obj.add(opt(opts));
Expand All @@ -136,15 +146,6 @@ private static BoolExpr opts(final XML xml) {
);
result = CTX.mkOr(result, cur);
}
result = CTX.mkAnd(
result,
CTX.mkNot(
CTX.mkEq(
CTX.mkConst(name, CTX.getStringSort()),
CTX.mkString("NONE")
)
)
);
return result;
}

Expand All @@ -157,9 +158,8 @@ private static Map<String, BoolExpr> opt(final XML xml) {
final Map<String, BoolExpr> result = new HashMap<>();
for (final XML opt : xml.nodes("opt")) {
final String val = opt.xpath("@x").get(0);
final BoolExpr cur = taus(opt);
final BoolExpr old = result.getOrDefault(val, CTX.mkFalse());
result.put(val, CTX.mkOr(cur, old));
result.put(val, CTX.mkOr(taus(opt), old));
}
return result;
}
Expand Down Expand Up @@ -220,7 +220,7 @@ private BoolExpr mkVariables() {
final String path = String.format("/o/o/opts/opt/tau[@i='%s']/text()", var);
variables.get(name).addAll(this.xml.xpath(path));
}
BoolExpr result = CTX.mkAnd();
BoolExpr result = CTX.mkTrue();
for (final String var : variables.keySet()) {
BoolExpr cur = CTX.mkFalse();
for (final String val : variables.get(var)) {
Expand Down

0 comments on commit da979f7

Please sign in to comment.