}
/** Does performing the AbstractRepair ar satisfy (or falsify if satisfy=false)
- * Rule r */
- static public boolean interferes(AbstractRepair ar, Rule r, boolean satisfy) {
+ * Rule r. */
+
+ static public boolean interfereswithrule(AbstractRepair ar, Rule r, boolean satisfy) {
boolean mayadd=false;
boolean mayremove=false;
switch (ar.getType()) {
/** Does performing the AbstractRepair ar falsify the predicate dp */
- public boolean interferes(AbstractRepair ar, DNFPredicate dp) {
+ public boolean interfereswithpredicate(AbstractRepair ar, DNFPredicate dp) {
if ((ar.getDescriptor()!=dp.getPredicate().getDescriptor()) &&
((ar.getDescriptor() instanceof SetDescriptor)||
!dp.getPredicate().usesDescriptor((RelationDescriptor)ar.getDescriptor())))
return false;
}
-
-
/* Translate the opcodes */
op1=Opcode.translateOpcode(neg1,op1);
op2=Opcode.translateOpcode(neg2,op2);
return true;
}
- /** Does the increase (or decrease) in scope of a model defintion rule represented by sn
- * falsify the predicate dp */
+ /** Does the increase (or decrease) in scope of a model defintion
+ * rule represented by sn falsify the predicate dp. */
- public boolean interferes(ScopeNode sn, DNFPredicate dp) {
+ public boolean scopeinterfereswithpredicate(ScopeNode sn, DNFPredicate dp) {
if (!sn.getSatisfy()&&(sn.getDescriptor() instanceof SetDescriptor)) {
Rule r=sn.getRule();
Set target=r.getInclusion().getTargetDescriptors();
return interferes(sn.getDescriptor(), sn.getSatisfy(),dp);
}
- /** Does increasing (or decreasing if satisfy=false) the size of the set or relation des
- * falsify the predicate dp */
+ /** Does increasing (or decreasing if satisfy=false) the size of
+ * the set or relation des falsify the predicate dp. */
- public boolean interferes(Descriptor des, boolean satisfy, DNFPredicate dp) {
+ private boolean interferes(Descriptor des, boolean satisfy, DNFPredicate dp) {
if ((des!=dp.getPredicate().getDescriptor()) &&
((des instanceof SetDescriptor)||
!dp.getPredicate().usesDescriptor((RelationDescriptor)des)))
return true;
}
- static public boolean interferesquantifier(Descriptor des, boolean satisfy, Quantifiers r, boolean satisfyrule) {
+ /** This method test whether satisfying (or falsifying depending
+ * on the flag satisfy) a rule that adds an object(or tuple) to
+ * the set(or relation) descriptor may increase (or decrease
+ * depending on the flag satisfyrule) the scope of a constraint or
+ * model defintion rule r. */
+
+ static private boolean interferesquantifier(Descriptor des, boolean satisfy, Quantifiers r, boolean satisfyrule) {
for(int i=0;i<r.numQuantifiers();i++) {
Quantifier q=r.getQuantifier(i);
if (q instanceof RelationQuantifier||q instanceof SetQuantifier) {
return false;
}
- static public boolean interferes(AbstractRepair ar, Quantifiers q) {
+ static public boolean interferesquantifier(AbstractRepair ar, Quantifiers q) {
if (ar.getType()==AbstractRepair.ADDTOSET||ar.getType()==AbstractRepair.ADDTORELATION)
return interferesquantifier(ar.getDescriptor(),true,q,true);
return false;
}
- static public boolean interferes(Descriptor des, boolean satisfy, Quantifiers q) {
+ static public boolean interfereswithquantifier(Descriptor des, boolean satisfy, Quantifiers q) {
return interferesquantifier(des, satisfy, q,true);
}
- static public boolean interferes(Descriptor des, boolean satisfy, Rule r, boolean satisfyrule) {
+ static public boolean interfereswithrule(Descriptor des, boolean satisfy, Rule r, boolean satisfyrule) {
if (interferesquantifier(des,satisfy,r,satisfyrule))
return true;
/* Scan DNF form */
case ExprPredicate.COMPARISON:
{
RelationExpr re=((RelationExpr)((OpExpr)ep.expr).left);
- return ep.expr.getSet();
+ return re.expr.getSet();
}
default:
throw new Error("");
case ExprPredicate.COMPARISON:
{
RelationExpr re=((RelationExpr)((OpExpr)ep.expr).left);
- return ep.expr.getSet();
+ return re.expr.getSet();
}
default:
throw new Error("");
}
public int getsize(SetDescriptor sd) {
- if (sizemap.containsKey(sd))
- return ((Integer)sizemap.get(sd)).intValue();
+ SizeObject so=new SizeObject(sd);
+ if (sizemap.containsKey(so))
+ return ((Integer)sizemap.get(so)).intValue();
else
return -1;
}
public Constraint getConstraint(SetDescriptor sd) {
- return (Constraint)constraintmap.get(sd);
+ SizeObject so=new SizeObject(sd);
+ return (Constraint)constraintmap.get(so);
}
private void computesizes() {
}
if (matches) {
System.out.println("Set "+sd.toString()+" has size "+oldsize);
- sizemap.put(sd,new Integer(oldsize));
- constraintmap.put(sd,c);
+ SizeObject so=new SizeObject(sd);
+ sizemap.put(so,new Integer(oldsize));
+ constraintmap.put(so,c);
}
}
}
public SetDescriptor getSet() {
if (inverse)
- return relation.domain;
+ return relation.getDomain();
else
- return relation.range;
+ return relation.getRange();
}
public RelationExpr(Expr expr, RelationDescriptor relation, boolean inverse) {
--- /dev/null
+package MCC.IR;
+
+class SizeObject {
+ Descriptor setorrelation;
+ boolean isRelation;
+ SetDescriptor set;
+ boolean isInverted;
+
+ public SizeObject(SetDescriptor sd) {
+ this.setorrelation=sd;
+ this.isRelation=false;
+ }
+
+ public SizeObject(RelationDescriptor rd, SetDescriptor sd,boolean inverted) {
+ this.isRelation=true;
+ this.setorrelation=rd;
+ this.set=sd;
+ this.isInverted=inverted;
+ }
+
+ public int hashCode() {
+ int hashcode=setorrelation.hashCode();
+ if (set!=null)
+ hashcode^=set.hashCode();
+ return hashcode;
+ }
+ public boolean equals(java.lang.Object o) {
+ if (!(o instanceof SizeObject))
+ return false;
+ SizeObject so=(SizeObject)o;
+ if (so.setorrelation!=setorrelation)
+ return false;
+ if (so.isRelation!=isRelation)
+ throw new Error("");
+ if (isRelation) {
+ if (so.set!=set)
+ return false;
+ if (so.isInverted!=isInverted)
+ return false;
+ }
+ return true;
+ }
+}
for(int i=0;i<conj.size();i++) {
DNFPredicate dp=conj.get(i);
- if (AbstractInterferes.interferes(ar,cons)||
- abstractinterferes.interferes(ar,dp)) {
+ if (AbstractInterferes.interferesquantifier(ar,cons)||
+ abstractinterferes.interfereswithpredicate(ar,dp)) {
GraphNode.Edge e=new GraphNode.Edge("interferes",gn2);
gn.addEdge(e);
break;
GraphNode gn2=(GraphNode)scopeiterator.next();
TermNode tn2=(TermNode)gn2.getOwner();
ScopeNode sn2=tn2.getScope();
- if (AbstractInterferes.interferes(ar,sn2.getRule(),sn2.getSatisfy())) {
+ if (AbstractInterferes.interfereswithrule(ar,sn2.getRule(),sn2.getSatisfy())) {
GraphNode.Edge e=new GraphNode.Edge("interferes",gn2);
gn.addEdge(e);
}
Constraint constr=tn2.getConstraint();
for(int i=0;i<conj.size();i++) {
DNFPredicate dp=conj.get(i);
- if (abstractinterferes.interferes(sn,dp)||
- AbstractInterferes.interferes(sn.getDescriptor(),sn.getSatisfy(),constr)) {
+ if (abstractinterferes.scopeinterfereswithpredicate(sn,dp)||
+ AbstractInterferes.interfereswithquantifier(sn.getDescriptor(),sn.getSatisfy(),constr)) {
GraphNode.Edge e=new GraphNode.Edge("interferes",gn2);
GraphNode gnconseq=(GraphNode)consequence.get(sn);
gnconseq.addEdge(e);
/* Now see if this could effect other model defintion rules */
for(int i=0;i<state.vRules.size();i++) {
Rule r=(Rule) state.vRules.get(i);
- if (AbstractInterferes.interferes(sn.getDescriptor(),sn.getSatisfy(),r,true)) {
+ if (AbstractInterferes.interfereswithrule(sn.getDescriptor(),sn.getSatisfy(),r,true)) {
GraphNode scopenode=(GraphNode)scopesatisfy.get(r);
GraphNode.Edge e=new GraphNode.Edge("interferes",scopenode);
GraphNode gnconseq=(GraphNode)consequence.get(sn);
gnconseq.addEdge(e);
}
- if (AbstractInterferes.interferes(sn.getDescriptor(),sn.getSatisfy(),r,false)) {
+ if (AbstractInterferes.interfereswithrule(sn.getDescriptor(),sn.getSatisfy(),r,false)) {
GraphNode scopenode=(GraphNode)scopefalsify.get(r);
GraphNode.Edge e=new GraphNode.Edge("interferes",scopenode);
GraphNode gnconseq=(GraphNode)consequence.get(sn);
}
}
}
-
}
boolean debugmsg(String st) {
} else {
return false;
}
-
} else if (q instanceof SetQuantifier) {
SetQuantifier sq=(SetQuantifier)q;
if (un.getBinding(sq.var).getType()==Binding.SEARCH) {