Skip to content

Commit a435344

Browse files
committed
fixed bug on var one sigs' bounds
1 parent 2032198 commit a435344

File tree

4 files changed

+17
-4
lines changed

4 files changed

+17
-4
lines changed

electrum/src/main/java/edu/mit/csail/sdg/alloy4compiler/ast/Expr.java

+9
Original file line numberDiff line numberDiff line change
@@ -734,4 +734,13 @@ public final Decl setOf(String label) throws Err {
734734
* <p> this must be an integer expression
735735
*/
736736
public final Expr cast2sigint() { return ExprUnary.Op.CAST2SIGINT.make(span(), this); }
737+
738+
// [HASLab]
739+
public final Expr always() { return ExprUnary.Op.ALWAYS.make(span(), this); }
740+
public final Expr eventually() { return ExprUnary.Op.EVENTUALLY.make(span(), this); }
741+
public final Expr after() { return ExprUnary.Op.AFTER.make(span(), this); }
742+
public final Expr previous() { return ExprUnary.Op.PREVIOUS.make(span(), this); }
743+
public final Expr historically() { return ExprUnary.Op.HISTORICALLY.make(span(), this); }
744+
public final Expr once() { return ExprUnary.Op.ONCE.make(span(), this); }
745+
737746
}

electrum/src/main/java/edu/mit/csail/sdg/alloy4compiler/translator/A4Solution.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -454,11 +454,11 @@ Relation addRel(String label, TupleSet lower, TupleSet upper, Expr expr) throws
454454
if (solved) throw new ErrorFatal("Cannot add a Kodkod relation since solve() has completed.");
455455
Relation rel;
456456
if (expr instanceof Field){
457-
if (((Field) expr).isVariable != null){rel = VarRelation.nary(label, upper.arity());}
457+
if (((Field) expr).isVariable != null){rel = VarRelation.nary(label, upper.arity());} // [HASLab]
458458
else{rel = Relation.nary(label, upper.arity());}
459459
} else {
460460
if (expr instanceof Sig){
461-
if (((Sig) expr).isVariable != null){rel = VarRelation.nary(label, upper.arity());}
461+
if (((Sig) expr).isVariable != null){rel = VarRelation.nary(label, upper.arity());} // [HASLab]
462462
else{rel = Relation.nary(label, upper.arity());}
463463
}else{
464464
rel = Relation.nary(label, upper.arity());

electrum/src/main/java/edu/mit/csail/sdg/alloy4compiler/translator/BoundsComputer.java

+2
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,8 @@ private Expression allocatePrimSig(PrimSig sig) throws Err {
143143
Expression relation = sol.addRel(sig.label+" remainder", lower, upper, sig);
144144
sum = sum.union(relation);
145145
}
146+
if (sig.isOne != null) // [HASLab]
147+
sol.addFormula(sum.one().always(), sig.isOne);
146148
sol.addSig(sig, sum);
147149
return sum;
148150
}

electrum/src/main/java/edu/mit/csail/sdg/alloy4compiler/translator/ScopeComputer.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -308,8 +308,10 @@ private ScopeComputer(A4Reporter rep, Iterable<Sig> sigs, Command cmd) throws Er
308308
if (exact) makeExact(cmd.pos, s);
309309
}
310310
// Force "one" sigs to be exactly one, and "lone" to be at most one
311-
for(Sig s:sigs) if (s instanceof PrimSig) {
312-
if (s.isOne!=null) { makeExact(cmd.pos, s); sig2scope(s,1); } else if (s.isLone!=null && sig2scope(s)!=0) sig2scope(s,1);
311+
for(Sig s:sigs) if (s instanceof PrimSig) { // [HASLab]
312+
if (s.isOne!=null && s.isVariable==null) { makeExact(cmd.pos, s); sig2scope(s,1); }
313+
if (s.isOne!=null && s.isVariable!=null) { sig2scope(s,1); }
314+
else if (s.isLone!=null && sig2scope(s)!=0) sig2scope(s,1);
313315
}
314316
// Derive the implicit scopes
315317
while(true) {

0 commit comments

Comments
 (0)