6 public class Termination {
8 Hashtable conjunctionmap;
10 HashSet abstractrepair;
12 HashSet consequencenodes;
15 Hashtable scopesatisfy;
16 Hashtable scopefalsify;
17 Hashtable consequence;
18 Hashtable abstractadd;
19 Hashtable abstractremove;
20 Hashtable conjtonodemap;
25 public Termination(State state) {
27 conjunctions=new HashSet();
28 conjunctionmap=new Hashtable();
29 abstractrepair=new HashSet();
30 scopenodes=new HashSet();
31 scopesatisfy=new Hashtable();
32 scopefalsify=new Hashtable();
33 consequence=new Hashtable();
34 updatenodes=new HashSet();
35 consequencenodes=new HashSet();
36 abstractadd=new Hashtable();
37 abstractremove=new Hashtable();
38 conjtonodemap=new Hashtable();
40 generateconjunctionnodes();
42 generaterepairnodes();
43 generatedatastructureupdatenodes();
44 generatecompensationnodes();
46 generateabstractedges();
48 generateupdateedges();
50 HashSet superset=new HashSet();
51 superset.addAll(conjunctions);
52 //superset.addAll(abstractrepair);
53 //superset.addAll(updatenodes);
54 //superset.addAll(scopenodes);
55 //superset.addAll(consequencenodes);
56 GraphNode.computeclosure(superset,null);
58 GraphNode.DOTVisitor.visit(new FileOutputStream("graph.dot"),superset);
59 } catch (Exception e) {
63 for(Iterator it=updatenodes.iterator();it.hasNext();) {
64 GraphNode gn=(GraphNode)it.next();
65 TermNode tn=(TermNode)gn.getOwner();
66 MultUpdateNode mun=tn.getUpdate();
67 System.out.println(gn.getTextLabel());
68 System.out.println(mun.toString());
70 GraphAnalysis ga=new GraphAnalysis(this);
71 removedset=ga.doAnalysis();
72 System.out.println("Removing:");
73 for(Iterator it=removedset.iterator();it.hasNext();) {
74 GraphNode gn=(GraphNode)it.next();
75 System.out.println(gn.getTextLabel());
79 void generateconjunctionnodes() {
80 Vector constraints=state.vConstraints;
81 for(int i=0;i<constraints.size();i++) {
82 Constraint c=(Constraint)constraints.get(i);
83 DNFConstraint dnf=c.dnfconstraint;
84 for(int j=0;j<dnf.size();j++) {
85 TermNode tn=new TermNode(c,dnf.get(j));
86 GraphNode gn=new GraphNode("Conj"+i+"A"+j,
87 "Conj ("+i+","+j+") "+dnf.get(j).name()
90 if (!conjunctionmap.containsKey(c))
91 conjunctionmap.put(c,new HashSet());
92 ((Set)conjunctionmap.get(c)).add(gn);
93 conjtonodemap.put(dnf.get(j),gn);
98 void generateupdateedges() {
99 for(Iterator updateiterator=updatenodes.iterator();updateiterator.hasNext();) {
100 GraphNode gn=(GraphNode)updateiterator.next();
101 TermNode tn=(TermNode)gn.getOwner();
102 MultUpdateNode mun=tn.getUpdate();
103 /* Cycle through the rules to look for possible conflicts */
104 for(int i=0;i<state.vRules.size();i++) {
105 Rule r=(Rule) state.vRules.get(i);
106 if (ConcreteInterferes.interferes(mun,r,true)) {
107 GraphNode scopenode=(GraphNode)scopesatisfy.get(r);
108 GraphNode.Edge e=new GraphNode.Edge("interferes",scopenode);
111 if (ConcreteInterferes.interferes(mun,r,false)) {
112 GraphNode scopenode=(GraphNode)scopefalsify.get(r);
113 GraphNode.Edge e=new GraphNode.Edge("interferes",scopenode);
120 void generateabstractedges() {
121 for(Iterator absiterator=abstractrepair.iterator();absiterator.hasNext();) {
122 GraphNode gn=(GraphNode)absiterator.next();
123 TermNode tn=(TermNode)gn.getOwner();
124 AbstractRepair ar=(AbstractRepair)tn.getAbstract();
126 for(Iterator conjiterator=conjunctions.iterator();conjiterator.hasNext();) {
127 GraphNode gn2=(GraphNode)conjiterator.next();
128 TermNode tn2=(TermNode)gn2.getOwner();
129 Conjunction conj=tn2.getConjunction();
130 Constraint cons=tn2.getConstraint();
132 for(int i=0;i<conj.size();i++) {
133 DNFPredicate dp=conj.get(i);
134 if (AbstractInterferes.interferes(ar,cons)||
135 AbstractInterferes.interferes(ar,dp)) {
136 GraphNode.Edge e=new GraphNode.Edge("interferes",gn2);
143 for(Iterator scopeiterator=scopenodes.iterator();scopeiterator.hasNext();) {
144 GraphNode gn2=(GraphNode)scopeiterator.next();
145 TermNode tn2=(TermNode)gn2.getOwner();
146 ScopeNode sn2=tn2.getScope();
147 if (AbstractInterferes.interferes(ar,sn2.getRule(),sn2.getSatisfy())) {
148 GraphNode.Edge e=new GraphNode.Edge("interferes",gn2);
155 void generatescopeedges() {
156 for(Iterator scopeiterator=scopenodes.iterator();scopeiterator.hasNext();) {
157 GraphNode gn=(GraphNode)scopeiterator.next();
158 TermNode tn=(TermNode)gn.getOwner();
159 ScopeNode sn=tn.getScope();
161 /* Interference edges with conjunctions */
162 for(Iterator conjiterator=conjunctions.iterator();conjiterator.hasNext();) {
163 GraphNode gn2=(GraphNode)conjiterator.next();
164 TermNode tn2=(TermNode)gn2.getOwner();
165 Conjunction conj=tn2.getConjunction();
166 Constraint constr=tn2.getConstraint();
167 for(int i=0;i<conj.size();i++) {
168 DNFPredicate dp=conj.get(i);
169 if (AbstractInterferes.interferes(sn.getDescriptor(),sn.getSatisfy(),dp)||
170 AbstractInterferes.interferes(sn.getDescriptor(),sn.getSatisfy(),constr)) {
171 GraphNode.Edge e=new GraphNode.Edge("interferes",gn2);
172 GraphNode gnconseq=(GraphNode)consequence.get(sn);
179 /* Now see if this could effect other model defintion rules */
180 for(int i=0;i<state.vRules.size();i++) {
181 Rule r=(Rule) state.vRules.get(i);
182 if (AbstractInterferes.interferes(sn.getDescriptor(),sn.getSatisfy(),r,true)) {
183 GraphNode scopenode=(GraphNode)scopesatisfy.get(r);
184 GraphNode.Edge e=new GraphNode.Edge("interferes",scopenode);
185 GraphNode gnconseq=(GraphNode)consequence.get(sn);
188 if (AbstractInterferes.interferes(sn.getDescriptor(),sn.getSatisfy(),r,false)) {
189 GraphNode scopenode=(GraphNode)scopefalsify.get(r);
190 GraphNode.Edge e=new GraphNode.Edge("interferes",scopenode);
191 GraphNode gnconseq=(GraphNode)consequence.get(sn);
198 /* Generates the abstract repair nodes */
199 void generaterepairnodes() {
200 /* Generate repairs of conjunctions */
201 for(Iterator conjiterator=conjunctions.iterator();conjiterator.hasNext();) {
202 GraphNode gn=(GraphNode)conjiterator.next();
203 TermNode tn=(TermNode)gn.getOwner();
204 Conjunction conj=tn.getConjunction();
205 for(int i=0;i<conj.size();i++) {
206 DNFPredicate dp=conj.get(i);
207 int[] array=dp.getPredicate().getRepairs(dp.isNegated());
208 Descriptor d=dp.getPredicate().getDescriptor();
209 for(int j=0;j<array.length;j++) {
210 AbstractRepair ar=new AbstractRepair(dp,array[j],d);
211 TermNode tn2=new TermNode(ar);
212 GraphNode gn2=new GraphNode(gn.getLabel()+"A"+i+"B"+ar.type(),gn.getTextLabel()+" #"+i+" "+ar.type(),tn2);
213 GraphNode.Edge e=new GraphNode.Edge("abstract",gn2);
215 abstractrepair.add(gn2);
219 /* Generate additional abstract repairs */
220 Vector setdescriptors=state.stSets.getAllDescriptors();
221 for(int i=0;i<setdescriptors.size();i++) {
222 SetDescriptor sd=(SetDescriptor)setdescriptors.get(i);
224 /* XXXXXXX: Not sure what to do here */
225 VarExpr ve=new VarExpr("DUMMY");
226 InclusionPredicate ip=new InclusionPredicate(ve,new SetExpr(sd));
228 DNFPredicate tp=new DNFPredicate(false,ip);
229 AbstractRepair ar=new AbstractRepair(tp, AbstractRepair.ADDTOSET, sd);
230 TermNode tn=new TermNode(ar);
231 GraphNode gn=new GraphNode("AbstractAddSetRule"+i,tn);
232 abstractrepair.add(gn);
233 abstractadd.put(sd,gn);
235 DNFPredicate tp2=new DNFPredicate(true,ip);
236 AbstractRepair ar2=new AbstractRepair(tp2, AbstractRepair.REMOVEFROMSET, sd);
237 TermNode tn2=new TermNode(ar2);
238 GraphNode gn2=new GraphNode("AbstractRemSetRule"+i,tn2);
239 abstractrepair.add(gn2);
240 abstractremove.put(sd,gn2);
243 Vector relationdescriptors=state.stRelations.getAllDescriptors();
244 for(int i=0;i<relationdescriptors.size();i++) {
245 RelationDescriptor rd=(RelationDescriptor)relationdescriptors.get(i);
247 /* XXXXXXX: Not sure what to do here */
248 VarDescriptor vd1=new VarDescriptor("DUMMY1");
249 VarExpr ve2=new VarExpr("DUMMY2");
251 InclusionPredicate ip=new InclusionPredicate(ve2,new ImageSetExpr(vd1, rd));
253 DNFPredicate tp=new DNFPredicate(false,ip);
254 AbstractRepair ar=new AbstractRepair(tp, AbstractRepair.ADDTORELATION, rd);
255 TermNode tn=new TermNode(ar);
256 GraphNode gn=new GraphNode("AbstractAddRelRule"+i,tn);
257 abstractrepair.add(gn);
258 abstractadd.put(rd,gn);
260 DNFPredicate tp2=new DNFPredicate(true,ip);
261 AbstractRepair ar2=new AbstractRepair(tp2, AbstractRepair.REMOVEFROMRELATION, rd);
262 TermNode tn2=new TermNode(ar2);
263 GraphNode gn2=new GraphNode("AbstractRemRelRule"+i,tn2);
264 abstractrepair.add(gn2);
265 abstractremove.put(rd,gn2);
270 int compensationcount=0;
271 void generatecompensationnodes() {
272 for(int i=0;i<state.vRules.size();i++) {
273 Rule r=(Rule) state.vRules.get(i);
274 Vector possiblerules=new Vector();
275 /* Construct bindings */
276 /* No need to construct bindings on remove
277 Vector bindings=new Vector();
278 constructbindings(bindings, r,true);
280 for(int j=0;j<(r.numQuantifiers()+r.getDNFNegGuardExpr().size());j++) {
281 GraphNode gn=(GraphNode)scopesatisfy.get(r);
282 TermNode tn=(TermNode) gn.getOwner();
283 ScopeNode sn=tn.getScope();
284 MultUpdateNode mun=new MultUpdateNode(sn);
285 TermNode tn2=new TermNode(mun);
286 GraphNode gn2=new GraphNode("CompRem"+compensationcount,tn2);
287 UpdateNode un=new UpdateNode(r);
288 // un.addBindings(bindings);
290 if (j<r.numQuantifiers()) {
291 /* Remove quantifier */
292 Quantifier q=r.getQuantifier(j);
293 if (q instanceof RelationQuantifier) {
294 RelationQuantifier rq=(RelationQuantifier)q;
295 TupleOfExpr toe=new TupleOfExpr(new VarExpr(rq.x),new VarExpr(rq.y),rq.relation);
296 toe.td=ReservedTypeDescriptor.INT;
297 Updates u=new Updates(toe,true);
299 if (abstractremove.containsKey(rq.relation)) {
300 GraphNode agn=(GraphNode)abstractremove.get(rq.relation);
301 GraphNode.Edge e=new GraphNode.Edge("requires",agn);
304 continue; /* Abstract repair doesn't exist */
306 } else if (q instanceof SetQuantifier) {
307 SetQuantifier sq=(SetQuantifier)q;
308 ElementOfExpr eoe=new ElementOfExpr(new VarExpr(sq.var),sq.set);
309 eoe.td=ReservedTypeDescriptor.INT;
310 Updates u=new Updates(eoe,true);
312 if (abstractremove.containsKey(sq.set)) {
313 GraphNode agn=(GraphNode)abstractremove.get(sq.set);
314 GraphNode.Edge e=new GraphNode.Edge("requires",agn);
317 continue; /* Abstract repair doesn't exist */
323 int c=j-r.numQuantifiers();
324 if (!processconjunction(un,r.getDNFNegGuardExpr().get(c))) {
328 if (!un.checkupdates()) /* Make sure we have a good update */
333 GraphNode.Edge e=new GraphNode.Edge("abstract"+compensationcount,gn2);
336 updatenodes.add(gn2);
341 void generatedatastructureupdatenodes() {
342 for(Iterator absiterator=abstractrepair.iterator();absiterator.hasNext();) {
343 GraphNode gn=(GraphNode)absiterator.next();
344 TermNode tn=(TermNode) gn.getOwner();
345 AbstractRepair ar=tn.getAbstract();
346 if (ar.getType()==AbstractRepair.ADDTOSET) {
347 generateaddtosetrelation(gn,ar);
348 } else if (ar.getType()==AbstractRepair.REMOVEFROMSET) {
349 generateremovefromsetrelation(gn,ar);
350 } else if (ar.getType()==AbstractRepair.ADDTORELATION) {
351 generateaddtosetrelation(gn,ar);
352 } else if (ar.getType()==AbstractRepair.REMOVEFROMRELATION) {
353 generateremovefromsetrelation(gn,ar);
354 } else if (ar.getType()==AbstractRepair.MODIFYRELATION) {
355 /* Generate remove/add pairs */
356 generateremovefromsetrelation(gn,ar);
357 generateaddtosetrelation(gn,ar);
358 /* Generate atomic modify */
359 generatemodifyrelation(gn,ar);
364 int removefromcount=0;
365 void generateremovefromsetrelation(GraphNode gn,AbstractRepair ar) {
366 Vector possiblerules=new Vector();
367 for(int i=0;i<state.vRules.size();i++) {
368 Rule r=(Rule) state.vRules.get(i);
369 if ((r.getInclusion() instanceof SetInclusion)&&
370 (ar.getDescriptor()==((SetInclusion)r.getInclusion()).getSet()))
371 possiblerules.add(r);
372 if ((r.getInclusion() instanceof RelationInclusion)&&
373 (ar.getDescriptor()==((RelationInclusion)r.getInclusion()).getRelation()))
374 possiblerules.add(r);
376 if (possiblerules.size()==0)
378 int[] count=new int[possiblerules.size()];
379 while(remains(count,possiblerules)) {
380 MultUpdateNode mun=new MultUpdateNode(ar,MultUpdateNode.REMOVE);
381 TermNode tn=new TermNode(mun);
382 GraphNode gn2=new GraphNode("UpdateRem"+removefromcount,tn);
384 boolean goodflag=true;
385 for(int i=0;i<possiblerules.size();i++) {
386 Rule r=(Rule)possiblerules.get(i);
387 UpdateNode un=new UpdateNode(r);
388 /* Construct bindings */
389 /* No Need to construct bindings on remove
390 Vector bindings=new Vector();
391 constructbindings(bindings, r,true);
392 un.addBindings(bindings);*/
393 if (count[i]<r.numQuantifiers()) {
394 /* Remove quantifier */
395 Quantifier q=r.getQuantifier(count[i]);
396 if (q instanceof RelationQuantifier) {
397 RelationQuantifier rq=(RelationQuantifier)q;
398 TupleOfExpr toe=new TupleOfExpr(new VarExpr(rq.x),new VarExpr(rq.y),rq.relation);
399 toe.td=ReservedTypeDescriptor.INT;
400 Updates u=new Updates(toe,true);
402 if (abstractremove.containsKey(rq.relation)) {
403 GraphNode agn=(GraphNode)abstractremove.get(rq.relation);
404 GraphNode.Edge e=new GraphNode.Edge("requires",agn);
407 goodflag=false;break; /* Abstract repair doesn't exist */
409 } else if (q instanceof SetQuantifier) {
410 SetQuantifier sq=(SetQuantifier)q;
411 ElementOfExpr eoe=new ElementOfExpr(new VarExpr(sq.var),sq.set);
412 eoe.td=ReservedTypeDescriptor.INT;
413 Updates u=new Updates(eoe,true);
415 if (abstractremove.containsKey(sq.set)) {
416 GraphNode agn=(GraphNode)abstractremove.get(sq.set);
417 GraphNode.Edge e=new GraphNode.Edge("requires",agn);
420 goodflag=false;break; /* Abstract repair doesn't exist */
422 } else {goodflag=false;break;}
424 int c=count[i]-r.numQuantifiers();
425 if (!processconjunction(un,r.getDNFNegGuardExpr().get(c))) {
426 goodflag=false;break;
429 if (!un.checkupdates()) {
436 GraphNode.Edge e=new GraphNode.Edge("abstract"+removefromcount,gn2);
439 updatenodes.add(gn2);
441 increment(count,possiblerules);
445 static void increment(int count[], Vector rules) {
447 for(int i=0;i<(rules.size()-1);i++) {
448 if (count[i]>=(((Rule)rules.get(i)).numQuantifiers()+(((Rule)rules.get(i)).getDNFNegGuardExpr().size()))) {
455 static boolean remains(int count[], Vector rules) {
456 for(int i=0;i<rules.size();i++) {
457 if (count[i]>=(((Rule)rules.get(i)).numQuantifiers()+(((Rule)rules.get(i)).getDNFNegGuardExpr().size()))) {
464 void generatemodifyrelation(GraphNode gn, AbstractRepair ar) {
468 boolean constructbindings(Vector bindings, Rule r, boolean isremoval) {
469 boolean goodupdate=true;
470 Inclusion inc=r.getInclusion();
471 for(Iterator iterator=r.quantifiers();iterator.hasNext();) {
472 Quantifier q=(Quantifier)iterator.next();
473 if ((q instanceof SetQuantifier)||(q instanceof ForQuantifier)) {
474 VarDescriptor vd=null;
475 SetDescriptor set=null;
476 if (q instanceof SetQuantifier) {
477 vd=((SetQuantifier)q).getVar();
479 vd=((ForQuantifier)q).getVar();
480 if(inc instanceof SetInclusion) {
481 SetInclusion si=(SetInclusion)inc;
482 if ((si.elementexpr instanceof VarExpr)&&
483 (((VarExpr)si.elementexpr).getVar()==vd)) {
484 /* Can solve for v */
485 Binding binding=new Binding(vd,0);
486 bindings.add(binding);
489 } else if (inc instanceof RelationInclusion) {
490 RelationInclusion ri=(RelationInclusion)inc;
493 if ((ri.getLeftExpr() instanceof VarExpr)&&
494 (((VarExpr)ri.getLeftExpr()).getVar()==vd)) {
495 /* Can solve for v */
496 Binding binding=new Binding(vd,0);
497 bindings.add(binding);
499 if ((ri.getRightExpr() instanceof VarExpr)&&
500 (((VarExpr)ri.getRightExpr()).getVar()==vd)) {
501 /* Can solve for v */
502 Binding binding=new Binding(vd,0);
503 bindings.add(binding);
507 } else throw new Error("Inclusion not recognized");
510 Binding binding=new Binding(vd);
511 bindings.add(binding);
515 } else if (q instanceof RelationQuantifier) {
516 RelationQuantifier rq=(RelationQuantifier)q;
517 for(int k=0;k<2;k++) {
518 VarDescriptor vd=(k==0)?rq.x:rq.y;
519 if(inc instanceof SetInclusion) {
520 SetInclusion si=(SetInclusion)inc;
521 if ((si.elementexpr instanceof VarExpr)&&
522 (((VarExpr)si.elementexpr).getVar()==vd)) {
523 /* Can solve for v */
524 Binding binding=new Binding(vd,0);
525 bindings.add(binding);
528 } else if (inc instanceof RelationInclusion) {
529 RelationInclusion ri=(RelationInclusion)inc;
532 if ((ri.getLeftExpr() instanceof VarExpr)&&
533 (((VarExpr)ri.getLeftExpr()).getVar()==vd)) {
534 /* Can solve for v */
535 Binding binding=new Binding(vd,0);
536 bindings.add(binding);
538 if ((ri.getRightExpr() instanceof VarExpr)&&
539 (((VarExpr)ri.getRightExpr()).getVar()==vd)) {
540 /* Can solve for v */
541 Binding binding=new Binding(vd,0);
542 bindings.add(binding);
546 } else throw new Error("Inclusion not recognized");
549 Binding binding=new Binding(vd);
550 bindings.add(binding);
557 } else throw new Error("Quantifier not recognized");
562 static int addtocount=0;
563 void generateaddtosetrelation(GraphNode gn, AbstractRepair ar) {
564 // System.out.println("Attempting to generate add to set");
565 //System.out.println(ar.getPredicate().getPredicate().name());
566 //System.out.println(ar.getPredicate().isNegated());
567 for(int i=0;i<state.vRules.size();i++) {
568 Rule r=(Rule) state.vRules.get(i);
569 /* See if this is a good rule*/
570 //System.out.println(r.getGuardExpr().name());
571 if ((r.getInclusion() instanceof SetInclusion&&
572 ar.getDescriptor()==((SetInclusion)r.getInclusion()).getSet())||
573 (r.getInclusion() instanceof RelationInclusion&&
574 ar.getDescriptor()==((RelationInclusion)r.getInclusion()).getRelation())) {
576 /* First solve for quantifiers */
577 Vector bindings=new Vector();
578 /* Construct bindings */
579 //System.out.println("Attempting to generate add to set: #2");
580 if (!constructbindings(bindings,r,false))
582 //System.out.println("Attempting to generate add to set: #3");
583 //Generate add instruction
584 DNFRule dnfrule=r.getDNFGuardExpr();
585 for(int j=0;j<dnfrule.size();j++) {
586 Inclusion inc=r.getInclusion();
587 UpdateNode un=new UpdateNode(r);
588 un.addBindings(bindings);
589 /* Now build update for tuple/set inclusion condition */
590 if(inc instanceof SetInclusion) {
591 SetInclusion si=(SetInclusion)inc;
592 if (!(si.elementexpr instanceof VarExpr)) {
593 Updates up=new Updates(si.elementexpr,0);
596 VarDescriptor vd=((VarExpr)si.elementexpr).getVar();
597 if (un.getBinding(vd)==null) {
598 Updates up=new Updates(si.elementexpr,0);
602 } else if (inc instanceof RelationInclusion) {
603 RelationInclusion ri=(RelationInclusion)inc;
604 if (!(ri.getLeftExpr() instanceof VarExpr)) {
605 Updates up=new Updates(ri.getLeftExpr(),0);
608 VarDescriptor vd=((VarExpr)ri.getLeftExpr()).getVar();
609 if (un.getBinding(vd)==null) {
610 Updates up=new Updates(ri.getLeftExpr(),0);
614 if (!(ri.getRightExpr() instanceof VarExpr)) {
615 Updates up=new Updates(ri.getRightExpr(),1);
618 VarDescriptor vd=((VarExpr)ri.getRightExpr()).getVar();
619 if (un.getBinding(vd)==null) {
620 Updates up=new Updates(ri.getRightExpr(),1);
625 //Finally build necessary updates to satisfy conjunction
626 RuleConjunction ruleconj=dnfrule.get(j);
627 /* Add in updates for quantifiers */
628 //System.out.println("Attempting to generate add to set #4");
629 MultUpdateNode mun=new MultUpdateNode(ar,MultUpdateNode.ADD);
630 TermNode tn=new TermNode(mun);
631 GraphNode gn2=new GraphNode("UpdateAdd"+addtocount,tn);
633 if (processquantifers(gn2,un, r)&&debugdd()&&
634 processconjunction(un,ruleconj)&&
636 //System.out.println("Attempting to generate add to set #5");
638 GraphNode.Edge e=new GraphNode.Edge("abstract"+addtocount,gn2);
641 updatenodes.add(gn2);}
648 //System.out.println("Attempting to generate add to set DD");
652 boolean processquantifers(GraphNode gn,UpdateNode un, Rule r) {
653 Inclusion inc=r.getInclusion();
654 for(Iterator iterator=r.quantifiers();iterator.hasNext();) {
655 Quantifier q=(Quantifier)iterator.next();
657 /* FIXME: Analysis to determine when this update is necessary */
658 if (q instanceof RelationQuantifier) {
659 RelationQuantifier rq=(RelationQuantifier)q;
660 TupleOfExpr toe=new TupleOfExpr(new VarExpr(rq.x),new VarExpr(rq.y),rq.relation);
661 toe.td=ReservedTypeDescriptor.INT;
662 Updates u=new Updates(toe,false);
664 if (abstractremove.containsKey(rq.relation)) {
665 GraphNode agn=(GraphNode)abstractadd.get(rq.relation);
666 GraphNode.Edge e=new GraphNode.Edge("requires",agn);
672 } else if (q instanceof SetQuantifier) {
673 SetQuantifier sq=(SetQuantifier)q;
674 ElementOfExpr eoe=new ElementOfExpr(new VarExpr(sq.var),sq.set);
675 eoe.td=ReservedTypeDescriptor.INT;
676 Updates u=new Updates(eoe,false);
678 if (abstractremove.containsKey(sq.set)) {
679 GraphNode agn=(GraphNode)abstractadd.get(sq.set);
680 GraphNode.Edge e=new GraphNode.Edge("requires",agn);
690 boolean processconjunction(UpdateNode un,RuleConjunction ruleconj){
692 for(int k=0;k<ruleconj.size();k++) {
693 DNFExpr de=ruleconj.get(k);
695 if (e instanceof OpExpr) {
696 OpExpr ex=(OpExpr)de.getExpr();
697 Opcode op=ex.getOpcode();
698 Updates up=new Updates(ex.left,ex.right,op, de.getNegation());
700 } else if (e instanceof ElementOfExpr) {
701 Updates up=new Updates(e,de.getNegation());
703 } else if (e instanceof TupleOfExpr) {
704 Updates up=new Updates(e,de.getNegation());
706 } else if (e instanceof BooleanLiteralExpr) {
707 boolean truth=((BooleanLiteralExpr)e).getValue();
708 if (de.getNegation())
715 System.out.println(e.getClass().getName());
716 throw new Error("Error #213");
722 void generatescopenodes() {
723 for(int i=0;i<state.vRules.size();i++) {
724 Rule r=(Rule) state.vRules.get(i);
725 ScopeNode satisfy=new ScopeNode(r,true);
726 TermNode tnsatisfy=new TermNode(satisfy);
727 GraphNode gnsatisfy=new GraphNode("SatisfyRule"+i,tnsatisfy);
728 ConsequenceNode cnsatisfy=new ConsequenceNode();
729 TermNode ctnsatisfy=new TermNode(cnsatisfy);
730 GraphNode cgnsatisfy=new GraphNode("ConseqSatisfyRule"+i,ctnsatisfy);
731 consequence.put(satisfy,cgnsatisfy);
732 GraphNode.Edge esat=new GraphNode.Edge("consequencesatisfy"+i,cgnsatisfy);
733 gnsatisfy.addEdge(esat);
734 consequencenodes.add(cgnsatisfy);
735 scopesatisfy.put(r,gnsatisfy);
736 scopenodes.add(gnsatisfy);
738 ScopeNode falsify=new ScopeNode(r,false);
739 TermNode tnfalsify=new TermNode(falsify);
740 GraphNode gnfalsify=new GraphNode("FalsifyRule"+i,tnfalsify);
741 ConsequenceNode cnfalsify=new ConsequenceNode();
742 TermNode ctnfalsify=new TermNode(cnfalsify);
743 GraphNode cgnfalsify=new GraphNode("ConseqFalsifyRule"+i,ctnfalsify);
744 consequence.put(falsify,cgnfalsify);
745 GraphNode.Edge efals=new GraphNode.Edge("consequencefalsify"+i,cgnfalsify);
746 gnfalsify.addEdge(efals);
747 consequencenodes.add(cgnfalsify);
748 scopefalsify.put(r,gnfalsify);
749 scopenodes.add(gnfalsify);