RelationDescriptor relation;
boolean inverse;
+ public Set getfunctions() {
+ HashSet functions=new HashSet();
+ Set exprfunctions=expr.getfunctions();
+ if (exprfunctions!=null)
+ functions.addAll(exprfunctions);
+ functions.add(new ConstraintDependence.Function(relation,expr.getSet(),inverse));
+
+ return functions;
+ }
+
+ public SetDescriptor getSet() {
+ if (inverse)
+ return relation.domain;
+ else
+ return relation.range;
+ }
+
public RelationExpr(Expr expr, RelationDescriptor relation, boolean inverse) {
this.expr = expr;
this.relation = relation;
this.inverse = inverse;
}
+ public Set freeVars() {
+ return expr.freeVars();
+ }
+
+ public String name() {
+ String name=expr.name()+".";
+ if (inverse)
+ name+="~";
+ name+=relation.toString();
+ return name;
+ }
+
public Expr getExpr() {
return expr;
}
- public boolean usesDescriptor(RelationDescriptor rd) {
+ public boolean equals(Map remap, Expr e) {
+ if (e==null||!(e instanceof RelationExpr))
+ return false;
+ RelationExpr re=(RelationExpr)e;
+ if (re.relation!=relation)
+ return false;
+ if (!expr.equals(remap,re.expr))
+ return false;
+ if (inverse!=re.inverse)
+ return false;
+ return true;
+ }
+
+ public boolean usesDescriptor(Descriptor rd) {
if (rd==relation)
return true;
else
return expr.usesDescriptor(rd);
}
+
+ public Set useDescriptor(Descriptor rd) {
+ HashSet newset=new HashSet();
+ if (rd==relation)
+ newset.add(this);
+ newset.addAll(expr.useDescriptor(rd));
+ return newset;
+ }
public RelationDescriptor getRelation() {
return relation;