+ /* Generate additional abstract repairs */
+ Vector setdescriptors=state.stSets.getAllDescriptors();
+ for(int i=0;i<setdescriptors.size();i++) {
+ SetDescriptor sd=(SetDescriptor)setdescriptors.get(i);
+
+ /* XXXXXXX: Not sure what to do here */
+ VarExpr ve=new VarExpr("DUMMY");
+ InclusionPredicate ip=new InclusionPredicate(ve,new SetExpr(sd));
+
+ DNFPredicate tp=new DNFPredicate(false,ip);
+ AbstractRepair ar=new AbstractRepair(tp, AbstractRepair.ADDTOSET, sd);
+ TermNode tn=new TermNode(ar);
+ GraphNode gn=new GraphNode("AbstractAddSetRule"+i,tn);
+ abstractrepair.add(gn);
+ abstractadd.put(sd,gn);
+
+ DNFPredicate tp2=new DNFPredicate(true,ip);
+ AbstractRepair ar2=new AbstractRepair(tp2, AbstractRepair.REMOVEFROMSET, sd);
+ TermNode tn2=new TermNode(ar2);
+ GraphNode gn2=new GraphNode("AbstractRemSetRule"+i,tn2);
+ abstractrepair.add(gn2);
+ abstractremove.put(sd,gn2);
+ }
+
+ Vector relationdescriptors=state.stRelations.getAllDescriptors();
+ for(int i=0;i<relationdescriptors.size();i++) {
+ RelationDescriptor rd=(RelationDescriptor)relationdescriptors.get(i);
+
+ /* XXXXXXX: Not sure what to do here */
+ VarDescriptor vd1=new VarDescriptor("DUMMY1");
+ VarExpr ve2=new VarExpr("DUMMY2");
+
+ InclusionPredicate ip=new InclusionPredicate(ve2,new ImageSetExpr(vd1, rd));
+
+ DNFPredicate tp=new DNFPredicate(false,ip);
+ AbstractRepair ar=new AbstractRepair(tp, AbstractRepair.ADDTORELATION, rd);
+ TermNode tn=new TermNode(ar);
+ GraphNode gn=new GraphNode("AbstractAddRelRule"+i,tn);
+ abstractrepair.add(gn);
+ abstractadd.put(rd,gn);
+
+ DNFPredicate tp2=new DNFPredicate(true,ip);
+ AbstractRepair ar2=new AbstractRepair(tp2, AbstractRepair.REMOVEFROMRELATION, rd);
+ TermNode tn2=new TermNode(ar2);
+ GraphNode gn2=new GraphNode("AbstractRemRelRule"+i,tn2);
+ abstractrepair.add(gn2);
+ abstractremove.put(rd,gn2);
+ }
+
+ }
+
+ int compensationcount=0;
+ void generatecompensationnodes() {
+ for(int i=0;i<state.vRules.size();i++) {
+ Rule r=(Rule) state.vRules.get(i);
+ Vector possiblerules=new Vector();
+ /* Construct bindings */
+ /* No need to construct bindings on remove
+ Vector bindings=new Vector();
+ constructbindings(bindings, r,true);
+ */
+ for(int j=0;j<(r.numQuantifiers()+r.getDNFNegGuardExpr().size());j++) {
+ GraphNode gn=(GraphNode)scopesatisfy.get(r);
+ TermNode tn=(TermNode) gn.getOwner();
+ ScopeNode sn=tn.getScope();
+ MultUpdateNode mun=new MultUpdateNode(sn);
+ TermNode tn2=new TermNode(mun);
+ GraphNode gn2=new GraphNode("CompRem"+compensationcount,tn2);
+ UpdateNode un=new UpdateNode(r);
+ // un.addBindings(bindings);
+ // Not necessary
+ if (j<r.numQuantifiers()) {
+ /* Remove quantifier */
+ Quantifier q=r.getQuantifier(j);
+ if (q instanceof RelationQuantifier) {
+ RelationQuantifier rq=(RelationQuantifier)q;
+ TupleOfExpr toe=new TupleOfExpr(new VarExpr(rq.x),new VarExpr(rq.y),rq.relation);
+ toe.td=ReservedTypeDescriptor.INT;
+ Updates u=new Updates(toe,true);
+ un.addUpdate(u);
+ if (abstractremove.containsKey(rq.relation)) {
+ GraphNode agn=(GraphNode)abstractremove.get(rq.relation);
+ GraphNode.Edge e=new GraphNode.Edge("requires",agn);
+ gn2.addEdge(e);
+ } else {
+ continue; /* Abstract repair doesn't exist */
+ }
+ } else if (q instanceof SetQuantifier) {
+ SetQuantifier sq=(SetQuantifier)q;
+ ElementOfExpr eoe=new ElementOfExpr(new VarExpr(sq.var),sq.set);
+ eoe.td=ReservedTypeDescriptor.INT;
+ Updates u=new Updates(eoe,true);
+ un.addUpdate(u);
+ if (abstractremove.containsKey(sq.set)) {
+ GraphNode agn=(GraphNode)abstractremove.get(sq.set);
+ GraphNode.Edge e=new GraphNode.Edge("requires",agn);
+ gn2.addEdge(e);
+ } else {
+ continue; /* Abstract repair doesn't exist */
+ }
+ } else {
+ continue;
+ }
+ } else {
+ int c=j-r.numQuantifiers();
+ if (!processconjunction(un,r.getDNFNegGuardExpr().get(c))) {
+ continue;
+ }
+ }
+ if (!un.checkupdates()) /* Make sure we have a good update */
+ continue;
+
+ mun.addUpdate(un);
+
+ GraphNode.Edge e=new GraphNode.Edge("abstract"+compensationcount,gn2);
+ compensationcount++;
+ gn.addEdge(e);
+ updatenodes.add(gn2);
+ }
+ }