specs to still work.
return false;
}
}
-
if (ar.getDescriptor()==dp.getPredicate().getDescriptor()&&
(ar.getType()==AbstractRepair.ADDTOSET||ar.getType()==AbstractRepair.ADDTORELATION)&&
(dp.getPredicate() instanceof ExprPredicate)&&
(op2==Opcode.GT))
return false;
}
-
if (ar.getDescriptor()==dp.getPredicate().getDescriptor()&&
(ar.getType()==AbstractRepair.MODIFYRELATION)&&
(dp.getPredicate() instanceof ExprPredicate)&&
(dp.getPredicate().inverted()==ar.getPredicate().getPredicate().inverted())&&
(((ExprPredicate)dp.getPredicate()).getType()==ExprPredicate.COMPARISON)) {
-
+
boolean neg1=ar.getPredicate().isNegated();
Opcode op1=((ExprPredicate)ar.getPredicate().getPredicate()).getOp();
boolean isInt1=((ExprPredicate)ar.getPredicate().getPredicate()).isRightInt();
Opcode op2=((ExprPredicate)dp.getPredicate()).getOp();
boolean isInt2=((ExprPredicate)dp.getPredicate()).isRightInt();
int size2=isInt2?((ExprPredicate)dp.getPredicate()).rightSize():0;
- Expr expr2=((OpExpr)((ExprPredicate)ar.getPredicate().getPredicate()).expr).right;
+ Expr expr2=((OpExpr)((ExprPredicate)dp.getPredicate()).expr).right;
+
+ {
+ Expr lexpr1=((RelationExpr)((OpExpr)((ExprPredicate)ar.getPredicate().getPredicate()).expr).getLeftExpr()).getExpr();
+ Expr lexpr2=((RelationExpr)((OpExpr)((ExprPredicate)dp.getPredicate()).expr).getLeftExpr()).getExpr();
+ SetDescriptor sd1=lexpr1.getSet();
+ SetDescriptor sd2=lexpr2.getSet();
+ if (termination.mutuallyexclusive(sd1,sd2))
+ return false;
+ }
+
+
/* Translate the opcodes */
op1=Opcode.translateOpcode(neg1,op1);
((op2==Opcode.GT)||
(op2==Opcode.GE)))
return false;
-
if (((op1==Opcode.LT)||
(op1==Opcode.LE))&&
((op2==Opcode.LT)||
(op2==Opcode.LE)))
return false;
-
if (((op1==Opcode.EQ)||(op1==Opcode.GE)||(op1==Opcode.LE))&&
((op2==Opcode.EQ)||(op2==Opcode.GE)||(op2==Opcode.LE))&&
expr1.equals(null,expr2)) {
return false;
}
-
if (isInt1&&isInt2) {
if (((op1==Opcode.EQ)||(op1==Opcode.GE)||(op1==Opcode.LE))&&
((op2==Opcode.EQ)||(op2==Opcode.GE)||(op2==Opcode.LE))&&
size2a++;
if (op2==Opcode.LT)
size2a--;
-
if (((op1==Opcode.GE)||(op1==Opcode.GT))&&
((op2==Opcode.LE)||(op2==Opcode.EQ)||(op2==Opcode.LT))&&
(size1a<=size2a))
return false;
-
if (((op1==Opcode.LE)||(op1==Opcode.LT))&&
((op2==Opcode.GE)||(op2==Opcode.EQ)||(op2==Opcode.GT))&&
(size1a>=size2a))
return false;
-
if ((op1==Opcode.EQ)&&(op2==Opcode.EQ)&&
(size1a==size2a))
return false;
-
if ((op1==Opcode.EQ)&&
((op2==Opcode.LE)||(op2==Opcode.LT))&&
(size1a<=size2a))
return false;
-
if ((op1==Opcode.EQ)&&
((op2==Opcode.GE)||(op2==Opcode.GT))&&
(size1a>=size2a))
return false;
-
if (op2==Opcode.NE) /*FLAGNE this is current behavior for NE repairs */
if (size1a!=size2)
return false;
-
if ((op1==Opcode.NE)&&
(op2==Opcode.EQ)&&
(size1!=size2))
return false;
-
if ((op1==Opcode.NE)&& /* FLAGNE relies on increasing or decreasing by 1 */
((op2==Opcode.GT)||(op2==Opcode.GE))&&
(size1!=size2a))
return false;
-
if ((op1==Opcode.NE)&& /* FLAGNE relies on increasing or decreasing by 1 */
((op2==Opcode.LT)||(op2==Opcode.LE))&&
(size1!=size2a))
return false;
}
}
-
/* This handles all the c comparisons in the paper */
if (ar.getDescriptor()==dp.getPredicate().getDescriptor()&&
(ar.getType()==AbstractRepair.REMOVEFROMSET||ar.getType()==AbstractRepair.REMOVEFROMRELATION)&&
(op2==Opcode.LE)||
(op2==Opcode.LT))
return false;
-
}
if ((ar.getDescriptor()==dp.getPredicate().getDescriptor())&&
(ar.getType()==AbstractRepair.ADDTOSET||ar.getType()==AbstractRepair.ADDTORELATION)&&
(dp.getPredicate() instanceof InclusionPredicate)&&
(dp.isNegated()==true))
return false; /* Could only satisfy this predicate */
-
return true;
}
private void generateEdge(Rule r1,Rule r2) {
Descriptor d=(Descriptor) r1.getInclusion().getTargetDescriptors().iterator().next();
int dep=checkBody(d,r2.getDNFGuardExpr());
- if (dep==NODEPENDENCY)
- dep=checkQuantifiers(d,r2);
+ if (dep==NODEPENDENCY) {
+ SetDescriptor bsd=null;
+ if (d instanceof SetDescriptor) {
+ SetInclusion si=(SetInclusion)r1.getInclusion();
+ if (si.getExpr() instanceof VarExpr) {
+ VarDescriptor vd=((VarExpr)si.getExpr()).getVar();
+ bsd=vd.getSet();
+ }
+ }
+ dep=checkQuantifiers(bsd,d,r2);
+ }
if (dep==NODEPENDENCY)
return;
GraphNode gn1=(GraphNode) ruletonode.get(r1);
return NODEPENDENCY;
}
- private int checkQuantifiers(Descriptor d, Quantifiers qs) {
+ private int checkQuantifiers(SetDescriptor bsd, Descriptor d, Quantifiers qs) {
for (int i=0;i<qs.numQuantifiers();i++) {
Quantifier q=qs.getQuantifier(i);
- if (q.getRequiredDescriptors().contains(d))
+ if (q instanceof SetQuantifier&&
+ d instanceof SetDescriptor) {
+ SetQuantifier sq=(SetQuantifier)q;
+ SetDescriptor sd=(SetDescriptor)d;
+ if (sq.getSet().isSubset(sd)&&
+ ((bsd==null)||!bsd.isSubset(sq.getSet())))
+ return NORMDEPENDENCY;
+ } else if (q.getRequiredDescriptors().contains(d))
return NORMDEPENDENCY;
}
return NODEPENDENCY;
public Set getfunctions() {
Set leftfunctions=left.getfunctions();
- Set rightfunctions=right.getfunctions();
+ Set rightfunctions=null;
+ if (right!=null) rightfunctions=right.getfunctions();
if (leftfunctions!=null&&rightfunctions!=null) {
HashSet functions=new HashSet();
functions.addAll(leftfunctions);
for(int i=0;i<conj.size();i++) {
DNFPredicate dp=conj.get(i);
+ System.out.println("Checking "+gn.getTextLabel()+" --> "+gn2.getTextLabel());
if (AbstractInterferes.interferes(ar,cons)||
abstractinterferes.interferes(ar,dp)) {
GraphNode.Edge e=new GraphNode.Edge("interferes",gn2);
}
return true;
}
+
+ public boolean mutuallyexclusive(SetDescriptor sd1, SetDescriptor sd2) {
+ if (mutualexclusive(sd1,sd2)||
+ mutualexclusive(sd2,sd1))
+ return true;
+ else
+ return false;
+ }
+
+ private boolean mutualexclusive(SetDescriptor sd1, SetDescriptor sd2) {
+ Vector rules=state.vRules;
+ for(int i=0;i<rules.size();i++) {
+ Rule r=(Rule)rules.get(i);
+ if (r.getInclusion().getTargetDescriptors().contains(sd1)) {
+ /* Rule may add items to sd1 */
+ SetInclusion si=(SetInclusion)r.getInclusion();
+ Expr ve=si.getExpr();
+ DNFRule drule=r.getDNFGuardExpr();
+ for(int j=0;j<drule.size();j++) {
+ RuleConjunction rconj=drule.get(j);
+ boolean containsexclusion=false;
+ for (int k=0;k<rconj.size();k++) {
+ DNFExpr dexpr=rconj.get(k);
+ if (dexpr.getNegation()&&
+ dexpr.getExpr() instanceof ElementOfExpr&&
+ ((ElementOfExpr)dexpr.getExpr()).element.equals(null,ve)) {
+ SetDescriptor sd=((ElementOfExpr)dexpr.getExpr()).set;
+ if (sd.isSubset(sd2))
+ containsexclusion=true;
+ }
+ }
+ if (!containsexclusion)
+ return false;
+ }
+ }
+ }
+ return true;
+ }
}