SetDescriptor sd=isdomain?rd.getDomain():rd.getRange();
if (sd instanceof ReservedSetDescriptor)
return false;
+
+ /* See if there is a rule that adds the corresponding range or domain
+ of the relation to the correct set */
for(int i=0;i<rules.size();i++) {
Rule r=(Rule)rules.get(i);
if ((r.numQuantifiers()==1)&&
return false;
}
}
-
-
for(int i=0;i<rules.size();i++) {
Rule r=(Rule)rules.get(i);
Inclusion inc=r.getInclusion();
boolean good=false;
RelationInclusion rinc=(RelationInclusion)inc;
Expr expr=isdomain?rinc.getLeftExpr():rinc.getRightExpr();
+ /* Check for varexpr's and quantification over */
if (expr instanceof VarExpr) {
VarDescriptor vd=((VarExpr)expr).getVar();
assert vd!=null;
+ /* See if the var is from an appropriate quantifier */
for (int j=0;j<r.numQuantifiers();j++) {
Quantifier q=r.getQuantifier(j);
if ((q instanceof SetQuantifier)&&
good=true;
break;
}
-
}
if (good)
- continue; /* Proved for this case */
+ continue; /* Checked for this case */
}
+ if (checkguard(r,isdomain))
+ continue;
for(int j=0;j<rules.size();j++) {
Rule r2=(Rule)rules.get(j);
Inclusion inc2=r2.getInclusion();
-
if (checkimplication(r,r2,isdomain)) {
good=true;
break;
if (good)
continue;
- return true; /* Couldn't prove we didn't need */
+ return true; /* Couldn't verify we didn't need */
}
}
return false;
}
+ boolean checkguard(Rule r,boolean isdomain) {
+ RelationInclusion inc=(RelationInclusion) r.getInclusion();
+ RelationDescriptor rd=inc.getRelation();
+ SetDescriptor sd=isdomain?rd.getDomain():rd.getRange();
+ Expr expr=isdomain?inc.getLeftExpr():inc.getRightExpr();
+ DNFRule dnfGuard=r.getDNFGuardExpr();
+ for(int i=0;i<dnfGuard.size();i++) {
+ RuleConjunction rconj=dnfGuard.get(i);
+ boolean foundcheck=false;
+ for(int j=0;j<rconj.size();j++) {
+ DNFExpr dexpr=rconj.get(j);
+ if (!dexpr.getNegation()&&
+ dexpr.getExpr() instanceof ElementOfExpr) {
+ ElementOfExpr eoe=(ElementOfExpr)dexpr.getExpr();
+
+ if (eoe.set==sd&&
+ eoe.element.equals(null,expr)) {
+ foundcheck=true;
+ break;
+ }
+ }
+ }
+ if (!foundcheck) {
+ return false;
+ }
+ }
+ return true;
+ }
+
boolean checkimplication(Rule r1, Rule r2, boolean isdomain) {
/* r1 is the relation */
/* See if this rule guarantees relation */