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 Vector bindings=new Vector();
277 constructbindings(bindings, r,true);
279 for(int j=0;j<(r.numQuantifiers()+r.getDNFNegGuardExpr().size());j++) {
280 GraphNode gn=(GraphNode)scopesatisfy.get(r);
281 TermNode tn=(TermNode) gn.getOwner();
282 ScopeNode sn=tn.getScope();
283 MultUpdateNode mun=new MultUpdateNode(sn);
284 TermNode tn2=new TermNode(mun);
285 GraphNode gn2=new GraphNode("CompRem"+compensationcount,tn2);
286 UpdateNode un=new UpdateNode(r);
287 un.addBindings(bindings);
288 if (j<r.numQuantifiers()) {
289 /* Remove quantifier */
290 Quantifier q=r.getQuantifier(j);
291 if (q instanceof RelationQuantifier) {
292 RelationQuantifier rq=(RelationQuantifier)q;
293 TupleOfExpr toe=new TupleOfExpr(new VarExpr(rq.x),new VarExpr(rq.y),rq.relation);
294 toe.td=ReservedTypeDescriptor.INT;
295 Updates u=new Updates(toe,true);
297 if (abstractremove.containsKey(rq.relation)) {
298 GraphNode agn=(GraphNode)abstractremove.get(rq.relation);
299 GraphNode.Edge e=new GraphNode.Edge("requires",agn);
302 continue; /* Abstract repair doesn't exist */
304 } else if (q instanceof SetQuantifier) {
305 SetQuantifier sq=(SetQuantifier)q;
306 ElementOfExpr eoe=new ElementOfExpr(new VarExpr(sq.var),sq.set);
307 eoe.td=ReservedTypeDescriptor.INT;
308 Updates u=new Updates(eoe,true);
310 if (abstractremove.containsKey(sq.set)) {
311 GraphNode agn=(GraphNode)abstractremove.get(sq.set);
312 GraphNode.Edge e=new GraphNode.Edge("requires",agn);
315 continue; /* Abstract repair doesn't exist */
321 int c=j-r.numQuantifiers();
322 if (!processconjunction(un,r.getDNFNegGuardExpr().get(c))) {
326 if (!un.checkupdates()) /* Make sure we have a good update */
331 GraphNode.Edge e=new GraphNode.Edge("abstract"+compensationcount,gn2);
334 updatenodes.add(gn2);
339 void generatedatastructureupdatenodes() {
340 for(Iterator absiterator=abstractrepair.iterator();absiterator.hasNext();) {
341 GraphNode gn=(GraphNode)absiterator.next();
342 TermNode tn=(TermNode) gn.getOwner();
343 AbstractRepair ar=tn.getAbstract();
344 if (ar.getType()==AbstractRepair.ADDTOSET) {
345 generateaddtosetrelation(gn,ar);
346 } else if (ar.getType()==AbstractRepair.REMOVEFROMSET) {
347 generateremovefromsetrelation(gn,ar);
348 } else if (ar.getType()==AbstractRepair.ADDTORELATION) {
349 generateaddtosetrelation(gn,ar);
350 } else if (ar.getType()==AbstractRepair.REMOVEFROMRELATION) {
351 generateremovefromsetrelation(gn,ar);
352 } else if (ar.getType()==AbstractRepair.MODIFYRELATION) {
353 /* Generate remove/add pairs */
354 generateremovefromsetrelation(gn,ar);
355 generateaddtosetrelation(gn,ar);
356 /* Generate atomic modify */
357 generatemodifyrelation(gn,ar);
362 int removefromcount=0;
363 void generateremovefromsetrelation(GraphNode gn,AbstractRepair ar) {
364 Vector possiblerules=new Vector();
365 for(int i=0;i<state.vRules.size();i++) {
366 Rule r=(Rule) state.vRules.get(i);
367 if ((r.getInclusion() instanceof SetInclusion)&&
368 (ar.getDescriptor()==((SetInclusion)r.getInclusion()).getSet()))
369 possiblerules.add(r);
370 if ((r.getInclusion() instanceof RelationInclusion)&&
371 (ar.getDescriptor()==((RelationInclusion)r.getInclusion()).getRelation()))
372 possiblerules.add(r);
374 if (possiblerules.size()==0)
376 int[] count=new int[possiblerules.size()];
377 while(remains(count,possiblerules)) {
378 MultUpdateNode mun=new MultUpdateNode(ar,MultUpdateNode.REMOVE);
379 TermNode tn=new TermNode(mun);
380 GraphNode gn2=new GraphNode("UpdateRem"+removefromcount,tn);
382 boolean goodflag=true;
383 for(int i=0;i<possiblerules.size();i++) {
384 Rule r=(Rule)possiblerules.get(i);
385 UpdateNode un=new UpdateNode(r);
386 /* Construct bindings */
387 Vector bindings=new Vector();
388 constructbindings(bindings, r,true);
389 un.addBindings(bindings);
390 if (count[i]<r.numQuantifiers()) {
391 /* Remove quantifier */
392 Quantifier q=r.getQuantifier(count[i]);
393 if (q instanceof RelationQuantifier) {
394 RelationQuantifier rq=(RelationQuantifier)q;
395 TupleOfExpr toe=new TupleOfExpr(new VarExpr(rq.x),new VarExpr(rq.y),rq.relation);
396 toe.td=ReservedTypeDescriptor.INT;
397 Updates u=new Updates(toe,true);
399 if (abstractremove.containsKey(rq.relation)) {
400 GraphNode agn=(GraphNode)abstractremove.get(rq.relation);
401 GraphNode.Edge e=new GraphNode.Edge("requires",agn);
404 goodflag=false;break; /* Abstract repair doesn't exist */
406 } else if (q instanceof SetQuantifier) {
407 SetQuantifier sq=(SetQuantifier)q;
408 ElementOfExpr eoe=new ElementOfExpr(new VarExpr(sq.var),sq.set);
409 eoe.td=ReservedTypeDescriptor.INT;
410 Updates u=new Updates(eoe,true);
412 if (abstractremove.containsKey(sq.set)) {
413 GraphNode agn=(GraphNode)abstractremove.get(sq.set);
414 GraphNode.Edge e=new GraphNode.Edge("requires",agn);
417 goodflag=false;break; /* Abstract repair doesn't exist */
419 } else {goodflag=false;break;}
421 int c=count[i]-r.numQuantifiers();
422 if (!processconjunction(un,r.getDNFNegGuardExpr().get(c))) {
423 goodflag=false;break;
426 if (!un.checkupdates()) {
433 GraphNode.Edge e=new GraphNode.Edge("abstract"+removefromcount,gn2);
436 updatenodes.add(gn2);
438 increment(count,possiblerules);
442 static void increment(int count[], Vector rules) {
444 for(int i=0;i<(rules.size()-1);i++) {
445 if (count[i]>=(((Rule)rules.get(i)).numQuantifiers()+(((Rule)rules.get(i)).getDNFNegGuardExpr().size()))) {
452 static boolean remains(int count[], Vector rules) {
453 for(int i=0;i<rules.size();i++) {
454 if (count[i]>=(((Rule)rules.get(i)).numQuantifiers()+(((Rule)rules.get(i)).getDNFNegGuardExpr().size()))) {
461 void generatemodifyrelation(GraphNode gn, AbstractRepair ar) {
465 boolean constructbindings(Vector bindings, Rule r, boolean isremoval) {
466 boolean goodupdate=true;
467 Inclusion inc=r.getInclusion();
468 for(Iterator iterator=r.quantifiers();iterator.hasNext();) {
469 Quantifier q=(Quantifier)iterator.next();
470 if ((q instanceof SetQuantifier)||(q instanceof ForQuantifier)) {
471 VarDescriptor vd=null;
472 SetDescriptor set=null;
473 if (q instanceof SetQuantifier) {
474 vd=((SetQuantifier)q).getVar();
476 vd=((ForQuantifier)q).getVar();
477 if(inc instanceof SetInclusion) {
478 SetInclusion si=(SetInclusion)inc;
479 if ((si.elementexpr instanceof VarExpr)&&
480 (((VarExpr)si.elementexpr).getVar()==vd)) {
481 /* Can solve for v */
482 Binding binding=new Binding(vd,0);
483 bindings.add(binding);
486 } else if (inc instanceof RelationInclusion) {
487 RelationInclusion ri=(RelationInclusion)inc;
490 if ((ri.getLeftExpr() instanceof VarExpr)&&
491 (((VarExpr)ri.getLeftExpr()).getVar()==vd)) {
492 /* Can solve for v */
493 Binding binding=new Binding(vd,0);
494 bindings.add(binding);
496 if ((ri.getRightExpr() instanceof VarExpr)&&
497 (((VarExpr)ri.getRightExpr()).getVar()==vd)) {
498 /* Can solve for v */
499 Binding binding=new Binding(vd,0);
500 bindings.add(binding);
504 } else throw new Error("Inclusion not recognized");
507 Binding binding=new Binding(vd);
508 bindings.add(binding);
512 } else if (q instanceof RelationQuantifier) {
513 RelationQuantifier rq=(RelationQuantifier)q;
514 for(int k=0;k<2;k++) {
515 VarDescriptor vd=(k==0)?rq.x:rq.y;
516 if(inc instanceof SetInclusion) {
517 SetInclusion si=(SetInclusion)inc;
518 if ((si.elementexpr instanceof VarExpr)&&
519 (((VarExpr)si.elementexpr).getVar()==vd)) {
520 /* Can solve for v */
521 Binding binding=new Binding(vd,0);
522 bindings.add(binding);
525 } else if (inc instanceof RelationInclusion) {
526 RelationInclusion ri=(RelationInclusion)inc;
529 if ((ri.getLeftExpr() instanceof VarExpr)&&
530 (((VarExpr)ri.getLeftExpr()).getVar()==vd)) {
531 /* Can solve for v */
532 Binding binding=new Binding(vd,0);
533 bindings.add(binding);
535 if ((ri.getRightExpr() instanceof VarExpr)&&
536 (((VarExpr)ri.getRightExpr()).getVar()==vd)) {
537 /* Can solve for v */
538 Binding binding=new Binding(vd,0);
539 bindings.add(binding);
543 } else throw new Error("Inclusion not recognized");
546 Binding binding=new Binding(vd);
547 bindings.add(binding);
554 } else throw new Error("Quantifier not recognized");
559 static int addtocount=0;
560 void generateaddtosetrelation(GraphNode gn, AbstractRepair ar) {
561 // System.out.println("Attempting to generate add to set");
562 //System.out.println(ar.getPredicate().getPredicate().name());
563 //System.out.println(ar.getPredicate().isNegated());
564 for(int i=0;i<state.vRules.size();i++) {
565 Rule r=(Rule) state.vRules.get(i);
566 /* See if this is a good rule*/
567 //System.out.println(r.getGuardExpr().name());
568 if ((r.getInclusion() instanceof SetInclusion&&
569 ar.getDescriptor()==((SetInclusion)r.getInclusion()).getSet())||
570 (r.getInclusion() instanceof RelationInclusion&&
571 ar.getDescriptor()==((RelationInclusion)r.getInclusion()).getRelation())) {
573 /* First solve for quantifiers */
574 Vector bindings=new Vector();
575 /* Construct bindings */
576 //System.out.println("Attempting to generate add to set: #2");
577 if (!constructbindings(bindings,r,false))
579 //System.out.println("Attempting to generate add to set: #3");
580 //Generate add instruction
581 DNFRule dnfrule=r.getDNFGuardExpr();
582 for(int j=0;j<dnfrule.size();j++) {
583 Inclusion inc=r.getInclusion();
584 UpdateNode un=new UpdateNode(r);
585 un.addBindings(bindings);
586 /* Now build update for tuple/set inclusion condition */
587 if(inc instanceof SetInclusion) {
588 SetInclusion si=(SetInclusion)inc;
589 if (!(si.elementexpr instanceof VarExpr)) {
590 Updates up=new Updates(si.elementexpr,0);
593 VarDescriptor vd=((VarExpr)si.elementexpr).getVar();
594 if (un.getBinding(vd)==null) {
595 Updates up=new Updates(si.elementexpr,0);
599 } else if (inc instanceof RelationInclusion) {
600 RelationInclusion ri=(RelationInclusion)inc;
601 if (!(ri.getLeftExpr() instanceof VarExpr)) {
602 Updates up=new Updates(ri.getLeftExpr(),0);
605 VarDescriptor vd=((VarExpr)ri.getLeftExpr()).getVar();
606 if (un.getBinding(vd)==null) {
607 Updates up=new Updates(ri.getLeftExpr(),0);
611 if (!(ri.getRightExpr() instanceof VarExpr)) {
612 Updates up=new Updates(ri.getRightExpr(),1);
615 VarDescriptor vd=((VarExpr)ri.getRightExpr()).getVar();
616 if (un.getBinding(vd)==null) {
617 Updates up=new Updates(ri.getRightExpr(),1);
622 //Finally build necessary updates to satisfy conjunction
623 RuleConjunction ruleconj=dnfrule.get(j);
624 /* Add in updates for quantifiers */
625 //System.out.println("Attempting to generate add to set #4");
626 MultUpdateNode mun=new MultUpdateNode(ar,MultUpdateNode.ADD);
627 TermNode tn=new TermNode(mun);
628 GraphNode gn2=new GraphNode("UpdateAdd"+addtocount,tn);
630 if (processquantifers(gn2,un, r)&&debugdd()&&
631 processconjunction(un,ruleconj)&&
633 //System.out.println("Attempting to generate add to set #5");
635 GraphNode.Edge e=new GraphNode.Edge("abstract"+addtocount,gn2);
638 updatenodes.add(gn2);}
645 //System.out.println("Attempting to generate add to set DD");
649 boolean processquantifers(GraphNode gn,UpdateNode un, Rule r) {
650 Inclusion inc=r.getInclusion();
651 for(Iterator iterator=r.quantifiers();iterator.hasNext();) {
652 Quantifier q=(Quantifier)iterator.next();
654 /* FIXME: Analysis to determine when this update is necessary */
655 if (q instanceof RelationQuantifier) {
656 RelationQuantifier rq=(RelationQuantifier)q;
657 TupleOfExpr toe=new TupleOfExpr(new VarExpr(rq.x),new VarExpr(rq.y),rq.relation);
658 toe.td=ReservedTypeDescriptor.INT;
659 Updates u=new Updates(toe,false);
661 if (abstractremove.containsKey(rq.relation)) {
662 GraphNode agn=(GraphNode)abstractadd.get(rq.relation);
663 GraphNode.Edge e=new GraphNode.Edge("requires",agn);
669 } else if (q instanceof SetQuantifier) {
670 SetQuantifier sq=(SetQuantifier)q;
671 ElementOfExpr eoe=new ElementOfExpr(new VarExpr(sq.var),sq.set);
672 eoe.td=ReservedTypeDescriptor.INT;
673 Updates u=new Updates(eoe,false);
675 if (abstractremove.containsKey(sq.set)) {
676 GraphNode agn=(GraphNode)abstractadd.get(sq.set);
677 GraphNode.Edge e=new GraphNode.Edge("requires",agn);
687 boolean processconjunction(UpdateNode un,RuleConjunction ruleconj){
689 for(int k=0;k<ruleconj.size();k++) {
690 DNFExpr de=ruleconj.get(k);
692 if (e instanceof OpExpr) {
693 OpExpr ex=(OpExpr)de.getExpr();
694 Opcode op=ex.getOpcode();
695 Updates up=new Updates(ex.left,ex.right,op, de.getNegation());
697 } else if (e instanceof ElementOfExpr) {
698 Updates up=new Updates(e,de.getNegation());
700 } else if (e instanceof TupleOfExpr) {
701 Updates up=new Updates(e,de.getNegation());
703 } else if (e instanceof BooleanLiteralExpr) {
704 boolean truth=((BooleanLiteralExpr)e).getValue();
705 if (de.getNegation())
712 System.out.println(e.getClass().getName());
713 throw new Error("Error #213");
719 void generatescopenodes() {
720 for(int i=0;i<state.vRules.size();i++) {
721 Rule r=(Rule) state.vRules.get(i);
722 ScopeNode satisfy=new ScopeNode(r,true);
723 TermNode tnsatisfy=new TermNode(satisfy);
724 GraphNode gnsatisfy=new GraphNode("SatisfyRule"+i,tnsatisfy);
725 ConsequenceNode cnsatisfy=new ConsequenceNode();
726 TermNode ctnsatisfy=new TermNode(cnsatisfy);
727 GraphNode cgnsatisfy=new GraphNode("ConseqSatisfyRule"+i,ctnsatisfy);
728 consequence.put(satisfy,cgnsatisfy);
729 GraphNode.Edge esat=new GraphNode.Edge("consequencesatisfy"+i,cgnsatisfy);
730 gnsatisfy.addEdge(esat);
731 consequencenodes.add(cgnsatisfy);
732 scopesatisfy.put(r,gnsatisfy);
733 scopenodes.add(gnsatisfy);
735 ScopeNode falsify=new ScopeNode(r,false);
736 TermNode tnfalsify=new TermNode(falsify);
737 GraphNode gnfalsify=new GraphNode("FalsifyRule"+i,tnfalsify);
738 ConsequenceNode cnfalsify=new ConsequenceNode();
739 TermNode ctnfalsify=new TermNode(cnfalsify);
740 GraphNode cgnfalsify=new GraphNode("ConseqFalsifyRule"+i,ctnfalsify);
741 consequence.put(falsify,cgnfalsify);
742 GraphNode.Edge efals=new GraphNode.Edge("consequencefalsify"+i,cgnfalsify);
743 gnfalsify.addEdge(efals);
744 consequencenodes.add(cgnfalsify);
745 scopefalsify.put(r,gnfalsify);
746 scopenodes.add(gnfalsify);