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;
23 public Termination(State state) {
25 conjunctions=new HashSet();
26 conjunctionmap=new Hashtable();
27 abstractrepair=new HashSet();
28 scopenodes=new HashSet();
29 scopesatisfy=new Hashtable();
30 scopefalsify=new Hashtable();
31 consequence=new Hashtable();
32 updatenodes=new HashSet();
33 consequencenodes=new HashSet();
34 abstractadd=new Hashtable();
35 abstractremove=new Hashtable();
38 generateconjunctionnodes();
40 generaterepairnodes();
41 generatedatastructureupdatenodes();
42 generatecompensationnodes();
44 generateabstractedges();
46 generateupdateedges();
48 HashSet superset=new HashSet();
49 superset.addAll(conjunctions);
50 //superset.addAll(abstractrepair);
51 //superset.addAll(updatenodes);
52 //superset.addAll(scopenodes);
53 //superset.addAll(consequencenodes);
54 GraphNode.computeclosure(superset,null);
56 GraphNode.DOTVisitor.visit(new FileOutputStream("graph.dot"),superset);
57 } catch (Exception e) {
61 for(Iterator it=updatenodes.iterator();it.hasNext();) {
62 GraphNode gn=(GraphNode)it.next();
63 TermNode tn=(TermNode)gn.getOwner();
64 MultUpdateNode mun=tn.getUpdate();
65 System.out.println(gn.getTextLabel());
66 System.out.println(mun.toString());
68 GraphAnalysis ga=new GraphAnalysis(this);
71 void generateconjunctionnodes() {
72 Vector constraints=state.vConstraints;
73 for(int i=0;i<constraints.size();i++) {
74 Constraint c=(Constraint)constraints.get(i);
75 DNFConstraint dnf=c.dnfconstraint;
76 for(int j=0;j<dnf.size();j++) {
77 TermNode tn=new TermNode(c,dnf.get(j));
78 GraphNode gn=new GraphNode("Conj"+i+"A"+j,
79 "Conj ("+i+","+j+") "+dnf.get(j).name()
82 if (!conjunctionmap.containsKey(c))
83 conjunctionmap.put(c,new HashSet());
84 ((Set)conjunctionmap.get(c)).add(gn);
89 void generateupdateedges() {
90 for(Iterator updateiterator=updatenodes.iterator();updateiterator.hasNext();) {
91 GraphNode gn=(GraphNode)updateiterator.next();
92 TermNode tn=(TermNode)gn.getOwner();
93 MultUpdateNode mun=tn.getUpdate();
94 /* Cycle through the rules to look for possible conflicts */
95 for(int i=0;i<state.vRules.size();i++) {
96 Rule r=(Rule) state.vRules.get(i);
97 if (ConcreteInterferes.interferes(mun,r,true)) {
98 GraphNode scopenode=(GraphNode)scopesatisfy.get(r);
99 GraphNode.Edge e=new GraphNode.Edge("interferes",scopenode);
102 if (ConcreteInterferes.interferes(mun,r,false)) {
103 GraphNode scopenode=(GraphNode)scopefalsify.get(r);
104 GraphNode.Edge e=new GraphNode.Edge("interferes",scopenode);
111 void generateabstractedges() {
112 for(Iterator absiterator=abstractrepair.iterator();absiterator.hasNext();) {
113 GraphNode gn=(GraphNode)absiterator.next();
114 TermNode tn=(TermNode)gn.getOwner();
115 AbstractRepair ar=(AbstractRepair)tn.getAbstract();
117 for(Iterator conjiterator=conjunctions.iterator();conjiterator.hasNext();) {
118 GraphNode gn2=(GraphNode)conjiterator.next();
119 TermNode tn2=(TermNode)gn2.getOwner();
120 Conjunction conj=tn2.getConjunction();
121 Constraint cons=tn2.getConstraint();
123 for(int i=0;i<conj.size();i++) {
124 DNFPredicate dp=conj.get(i);
125 if (AbstractInterferes.interferes(ar,cons)||
126 AbstractInterferes.interferes(ar,dp)) {
127 GraphNode.Edge e=new GraphNode.Edge("interferes",gn2);
134 for(Iterator scopeiterator=scopenodes.iterator();scopeiterator.hasNext();) {
135 GraphNode gn2=(GraphNode)scopeiterator.next();
136 TermNode tn2=(TermNode)gn2.getOwner();
137 ScopeNode sn2=tn2.getScope();
138 if (AbstractInterferes.interferes(ar,sn2.getRule(),sn2.getSatisfy())) {
139 GraphNode.Edge e=new GraphNode.Edge("interferes",gn2);
146 void generatescopeedges() {
147 for(Iterator scopeiterator=scopenodes.iterator();scopeiterator.hasNext();) {
148 GraphNode gn=(GraphNode)scopeiterator.next();
149 TermNode tn=(TermNode)gn.getOwner();
150 ScopeNode sn=tn.getScope();
152 /* Interference edges with conjunctions */
153 for(Iterator conjiterator=conjunctions.iterator();conjiterator.hasNext();) {
154 GraphNode gn2=(GraphNode)conjiterator.next();
155 TermNode tn2=(TermNode)gn2.getOwner();
156 Conjunction conj=tn2.getConjunction();
157 Constraint constr=tn2.getConstraint();
158 for(int i=0;i<conj.size();i++) {
159 DNFPredicate dp=conj.get(i);
160 if (AbstractInterferes.interferes(sn.getDescriptor(),sn.getSatisfy(),dp)||
161 AbstractInterferes.interferes(sn.getDescriptor(),sn.getSatisfy(),constr)) {
162 GraphNode.Edge e=new GraphNode.Edge("interferes",gn2);
163 GraphNode gnconseq=(GraphNode)consequence.get(sn);
170 /* Now see if this could effect other model defintion rules */
171 for(int i=0;i<state.vRules.size();i++) {
172 Rule r=(Rule) state.vRules.get(i);
173 if (AbstractInterferes.interferes(sn.getDescriptor(),sn.getSatisfy(),r,true)) {
174 GraphNode scopenode=(GraphNode)scopesatisfy.get(r);
175 GraphNode.Edge e=new GraphNode.Edge("interferes",scopenode);
176 GraphNode gnconseq=(GraphNode)consequence.get(sn);
179 if (AbstractInterferes.interferes(sn.getDescriptor(),sn.getSatisfy(),r,false)) {
180 GraphNode scopenode=(GraphNode)scopefalsify.get(r);
181 GraphNode.Edge e=new GraphNode.Edge("interferes",scopenode);
182 GraphNode gnconseq=(GraphNode)consequence.get(sn);
189 /* Generates the abstract repair nodes */
190 void generaterepairnodes() {
191 /* Generate repairs of conjunctions */
192 for(Iterator conjiterator=conjunctions.iterator();conjiterator.hasNext();) {
193 GraphNode gn=(GraphNode)conjiterator.next();
194 TermNode tn=(TermNode)gn.getOwner();
195 Conjunction conj=tn.getConjunction();
196 for(int i=0;i<conj.size();i++) {
197 DNFPredicate dp=conj.get(i);
198 int[] array=dp.getPredicate().getRepairs(dp.isNegated());
199 Descriptor d=dp.getPredicate().getDescriptor();
200 for(int j=0;j<array.length;j++) {
201 AbstractRepair ar=new AbstractRepair(dp,array[j],d);
202 TermNode tn2=new TermNode(ar);
203 GraphNode gn2=new GraphNode(gn.getLabel()+"A"+i+"B"+ar.type(),gn.getTextLabel()+" #"+i+" "+ar.type(),tn2);
204 GraphNode.Edge e=new GraphNode.Edge("abstract",gn2);
206 abstractrepair.add(gn2);
210 /* Generate additional abstract repairs */
211 Vector setdescriptors=state.stSets.getAllDescriptors();
212 for(int i=0;i<setdescriptors.size();i++) {
213 SetDescriptor sd=(SetDescriptor)setdescriptors.get(i);
215 /* XXXXXXX: Not sure what to do here */
216 VarExpr ve=new VarExpr("DUMMY");
217 InclusionPredicate ip=new InclusionPredicate(ve,new SetExpr(sd));
219 DNFPredicate tp=new DNFPredicate(false,ip);
220 AbstractRepair ar=new AbstractRepair(tp, AbstractRepair.ADDTOSET, sd);
221 TermNode tn=new TermNode(ar);
222 GraphNode gn=new GraphNode("AbstractAddSetRule"+i,tn);
223 abstractrepair.add(gn);
224 abstractadd.put(sd,gn);
226 DNFPredicate tp2=new DNFPredicate(true,ip);
227 AbstractRepair ar2=new AbstractRepair(tp2, AbstractRepair.REMOVEFROMSET, sd);
228 TermNode tn2=new TermNode(ar2);
229 GraphNode gn2=new GraphNode("AbstractRemSetRule"+i,tn2);
230 abstractrepair.add(gn2);
231 abstractremove.put(sd,gn2);
234 Vector relationdescriptors=state.stRelations.getAllDescriptors();
235 for(int i=0;i<relationdescriptors.size();i++) {
236 RelationDescriptor rd=(RelationDescriptor)relationdescriptors.get(i);
238 /* XXXXXXX: Not sure what to do here */
239 VarDescriptor vd1=new VarDescriptor("DUMMY1");
240 VarExpr ve2=new VarExpr("DUMMY2");
242 InclusionPredicate ip=new InclusionPredicate(ve2,new ImageSetExpr(vd1, rd));
244 DNFPredicate tp=new DNFPredicate(false,ip);
245 AbstractRepair ar=new AbstractRepair(tp, AbstractRepair.ADDTORELATION, rd);
246 TermNode tn=new TermNode(ar);
247 GraphNode gn=new GraphNode("AbstractAddRelRule"+i,tn);
248 abstractrepair.add(gn);
249 abstractadd.put(rd,gn);
251 DNFPredicate tp2=new DNFPredicate(true,ip);
252 AbstractRepair ar2=new AbstractRepair(tp2, AbstractRepair.REMOVEFROMRELATION, rd);
253 TermNode tn2=new TermNode(ar2);
254 GraphNode gn2=new GraphNode("AbstractRemRelRule"+i,tn2);
255 abstractrepair.add(gn2);
256 abstractremove.put(rd,gn2);
261 int compensationcount=0;
262 void generatecompensationnodes() {
263 for(int i=0;i<state.vRules.size();i++) {
264 Rule r=(Rule) state.vRules.get(i);
265 Vector possiblerules=new Vector();
266 /* Construct bindings */
267 Vector bindings=new Vector();
268 constructbindings(bindings, r,true);
270 for(int j=0;j<(r.numQuantifiers()+r.getDNFNegGuardExpr().size());j++) {
271 GraphNode gn=(GraphNode)scopesatisfy.get(r);
272 TermNode tn=(TermNode) gn.getOwner();
273 ScopeNode sn=tn.getScope();
274 MultUpdateNode mun=new MultUpdateNode(sn);
275 TermNode tn2=new TermNode(mun);
276 GraphNode gn2=new GraphNode("CompRem"+compensationcount,tn2);
277 UpdateNode un=new UpdateNode(r);
278 un.addBindings(bindings);
279 if (j<r.numQuantifiers()) {
280 /* Remove quantifier */
281 Quantifier q=r.getQuantifier(j);
282 if (q instanceof RelationQuantifier) {
283 RelationQuantifier rq=(RelationQuantifier)q;
284 TupleOfExpr toe=new TupleOfExpr(new VarExpr(rq.x),new VarExpr(rq.y),rq.relation);
285 toe.td=ReservedTypeDescriptor.INT;
286 Updates u=new Updates(toe,true);
288 if (abstractremove.containsKey(rq.relation)) {
289 GraphNode agn=(GraphNode)abstractremove.get(rq.relation);
290 GraphNode.Edge e=new GraphNode.Edge("requires",agn);
293 continue; /* Abstract repair doesn't exist */
295 } else if (q instanceof SetQuantifier) {
296 SetQuantifier sq=(SetQuantifier)q;
297 ElementOfExpr eoe=new ElementOfExpr(new VarExpr(sq.var),sq.set);
298 eoe.td=ReservedTypeDescriptor.INT;
299 Updates u=new Updates(eoe,true);
301 if (abstractremove.containsKey(sq.set)) {
302 GraphNode agn=(GraphNode)abstractremove.get(sq.set);
303 GraphNode.Edge e=new GraphNode.Edge("requires",agn);
306 continue; /* Abstract repair doesn't exist */
312 int c=j-r.numQuantifiers();
313 if (!processconjunction(un,r.getDNFNegGuardExpr().get(c))) {
317 if (!un.checkupdates()) /* Make sure we have a good update */
322 GraphNode.Edge e=new GraphNode.Edge("abstract"+compensationcount,gn2);
325 updatenodes.add(gn2);
330 void generatedatastructureupdatenodes() {
331 for(Iterator absiterator=abstractrepair.iterator();absiterator.hasNext();) {
332 GraphNode gn=(GraphNode)absiterator.next();
333 TermNode tn=(TermNode) gn.getOwner();
334 AbstractRepair ar=tn.getAbstract();
335 if (ar.getType()==AbstractRepair.ADDTOSET) {
336 generateaddtosetrelation(gn,ar);
337 } else if (ar.getType()==AbstractRepair.REMOVEFROMSET) {
338 generateremovefromsetrelation(gn,ar);
339 } else if (ar.getType()==AbstractRepair.ADDTORELATION) {
340 generateaddtosetrelation(gn,ar);
341 } else if (ar.getType()==AbstractRepair.REMOVEFROMRELATION) {
342 generateremovefromsetrelation(gn,ar);
343 } else if (ar.getType()==AbstractRepair.MODIFYRELATION) {
344 /* Generate remove/add pairs */
345 generateremovefromsetrelation(gn,ar);
346 generateaddtosetrelation(gn,ar);
347 /* Generate atomic modify */
348 generatemodifyrelation(gn,ar);
353 int removefromcount=0;
354 void generateremovefromsetrelation(GraphNode gn,AbstractRepair ar) {
355 Vector possiblerules=new Vector();
356 for(int i=0;i<state.vRules.size();i++) {
357 Rule r=(Rule) state.vRules.get(i);
358 if ((r.getInclusion() instanceof SetInclusion)&&
359 (ar.getDescriptor()==((SetInclusion)r.getInclusion()).getSet()))
360 possiblerules.add(r);
361 if ((r.getInclusion() instanceof RelationInclusion)&&
362 (ar.getDescriptor()==((RelationInclusion)r.getInclusion()).getRelation()))
363 possiblerules.add(r);
365 if (possiblerules.size()==0)
367 int[] count=new int[possiblerules.size()];
368 while(remains(count,possiblerules)) {
369 MultUpdateNode mun=new MultUpdateNode(ar,MultUpdateNode.REMOVE);
370 TermNode tn=new TermNode(mun);
371 GraphNode gn2=new GraphNode("UpdateRem"+removefromcount,tn);
373 boolean goodflag=true;
374 for(int i=0;i<possiblerules.size();i++) {
375 Rule r=(Rule)possiblerules.get(i);
376 UpdateNode un=new UpdateNode(r);
377 /* Construct bindings */
378 Vector bindings=new Vector();
379 constructbindings(bindings, r,true);
380 un.addBindings(bindings);
381 if (count[i]<r.numQuantifiers()) {
382 /* Remove quantifier */
383 Quantifier q=r.getQuantifier(count[i]);
384 if (q instanceof RelationQuantifier) {
385 RelationQuantifier rq=(RelationQuantifier)q;
386 TupleOfExpr toe=new TupleOfExpr(new VarExpr(rq.x),new VarExpr(rq.y),rq.relation);
387 toe.td=ReservedTypeDescriptor.INT;
388 Updates u=new Updates(toe,true);
390 if (abstractremove.containsKey(rq.relation)) {
391 GraphNode agn=(GraphNode)abstractremove.get(rq.relation);
392 GraphNode.Edge e=new GraphNode.Edge("requires",agn);
395 goodflag=false;break; /* Abstract repair doesn't exist */
397 } else if (q instanceof SetQuantifier) {
398 SetQuantifier sq=(SetQuantifier)q;
399 ElementOfExpr eoe=new ElementOfExpr(new VarExpr(sq.var),sq.set);
400 eoe.td=ReservedTypeDescriptor.INT;
401 Updates u=new Updates(eoe,true);
403 if (abstractremove.containsKey(sq.set)) {
404 GraphNode agn=(GraphNode)abstractremove.get(sq.set);
405 GraphNode.Edge e=new GraphNode.Edge("requires",agn);
408 goodflag=false;break; /* Abstract repair doesn't exist */
410 } else {goodflag=false;break;}
412 int c=count[i]-r.numQuantifiers();
413 if (!processconjunction(un,r.getDNFNegGuardExpr().get(c))) {
414 goodflag=false;break;
417 if (!un.checkupdates()) {
424 GraphNode.Edge e=new GraphNode.Edge("abstract"+removefromcount,gn2);
427 updatenodes.add(gn2);
429 increment(count,possiblerules);
433 static void increment(int count[], Vector rules) {
435 for(int i=0;i<(rules.size()-1);i++) {
436 if (count[i]>=(((Rule)rules.get(i)).numQuantifiers()+(((Rule)rules.get(i)).getDNFNegGuardExpr().size()))) {
443 static boolean remains(int count[], Vector rules) {
444 for(int i=0;i<rules.size();i++) {
445 if (count[i]>=(((Rule)rules.get(i)).numQuantifiers()+(((Rule)rules.get(i)).getDNFNegGuardExpr().size()))) {
452 void generatemodifyrelation(GraphNode gn, AbstractRepair ar) {
456 boolean constructbindings(Vector bindings, Rule r, boolean isremoval) {
457 boolean goodupdate=true;
458 Inclusion inc=r.getInclusion();
459 for(Iterator iterator=r.quantifiers();iterator.hasNext();) {
460 Quantifier q=(Quantifier)iterator.next();
461 if ((q instanceof SetQuantifier)||(q instanceof ForQuantifier)) {
462 VarDescriptor vd=null;
463 SetDescriptor set=null;
464 if (q instanceof SetQuantifier) {
465 vd=((SetQuantifier)q).getVar();
467 vd=((ForQuantifier)q).getVar();
468 if(inc instanceof SetInclusion) {
469 SetInclusion si=(SetInclusion)inc;
470 if ((si.elementexpr instanceof VarExpr)&&
471 (((VarExpr)si.elementexpr).getVar()==vd)) {
472 /* Can solve for v */
473 Binding binding=new Binding(vd,0);
474 bindings.add(binding);
477 } else if (inc instanceof RelationInclusion) {
478 RelationInclusion ri=(RelationInclusion)inc;
481 if ((ri.getLeftExpr() instanceof VarExpr)&&
482 (((VarExpr)ri.getLeftExpr()).getVar()==vd)) {
483 /* Can solve for v */
484 Binding binding=new Binding(vd,0);
485 bindings.add(binding);
487 if ((ri.getRightExpr() instanceof VarExpr)&&
488 (((VarExpr)ri.getRightExpr()).getVar()==vd)) {
489 /* Can solve for v */
490 Binding binding=new Binding(vd,0);
491 bindings.add(binding);
495 } else throw new Error("Inclusion not recognized");
498 Binding binding=new Binding(vd);
499 bindings.add(binding);
503 } else if (q instanceof RelationQuantifier) {
504 RelationQuantifier rq=(RelationQuantifier)q;
505 for(int k=0;k<2;k++) {
506 VarDescriptor vd=(k==0)?rq.x:rq.y;
507 if(inc instanceof SetInclusion) {
508 SetInclusion si=(SetInclusion)inc;
509 if ((si.elementexpr instanceof VarExpr)&&
510 (((VarExpr)si.elementexpr).getVar()==vd)) {
511 /* Can solve for v */
512 Binding binding=new Binding(vd,0);
513 bindings.add(binding);
516 } else if (inc instanceof RelationInclusion) {
517 RelationInclusion ri=(RelationInclusion)inc;
520 if ((ri.getLeftExpr() instanceof VarExpr)&&
521 (((VarExpr)ri.getLeftExpr()).getVar()==vd)) {
522 /* Can solve for v */
523 Binding binding=new Binding(vd,0);
524 bindings.add(binding);
526 if ((ri.getRightExpr() instanceof VarExpr)&&
527 (((VarExpr)ri.getRightExpr()).getVar()==vd)) {
528 /* Can solve for v */
529 Binding binding=new Binding(vd,0);
530 bindings.add(binding);
534 } else throw new Error("Inclusion not recognized");
537 Binding binding=new Binding(vd);
538 bindings.add(binding);
545 } else throw new Error("Quantifier not recognized");
550 static int addtocount=0;
551 void generateaddtosetrelation(GraphNode gn, AbstractRepair ar) {
552 // System.out.println("Attempting to generate add to set");
553 //System.out.println(ar.getPredicate().getPredicate().name());
554 //System.out.println(ar.getPredicate().isNegated());
555 for(int i=0;i<state.vRules.size();i++) {
556 Rule r=(Rule) state.vRules.get(i);
557 /* See if this is a good rule*/
558 //System.out.println(r.getGuardExpr().name());
559 if ((r.getInclusion() instanceof SetInclusion&&
560 ar.getDescriptor()==((SetInclusion)r.getInclusion()).getSet())||
561 (r.getInclusion() instanceof RelationInclusion&&
562 ar.getDescriptor()==((RelationInclusion)r.getInclusion()).getRelation())) {
564 /* First solve for quantifiers */
565 Vector bindings=new Vector();
566 /* Construct bindings */
567 //System.out.println("Attempting to generate add to set: #2");
568 if (!constructbindings(bindings,r,false))
570 //System.out.println("Attempting to generate add to set: #3");
571 //Generate add instruction
572 DNFRule dnfrule=r.getDNFGuardExpr();
573 for(int j=0;j<dnfrule.size();j++) {
574 Inclusion inc=r.getInclusion();
575 UpdateNode un=new UpdateNode(r);
576 un.addBindings(bindings);
577 /* Now build update for tuple/set inclusion condition */
578 if(inc instanceof SetInclusion) {
579 SetInclusion si=(SetInclusion)inc;
580 if (!(si.elementexpr instanceof VarExpr)) {
581 Updates up=new Updates(si.elementexpr,0);
584 VarDescriptor vd=((VarExpr)si.elementexpr).getVar();
585 if (un.getBinding(vd)==null) {
586 Updates up=new Updates(si.elementexpr,0);
590 } else if (inc instanceof RelationInclusion) {
591 RelationInclusion ri=(RelationInclusion)inc;
592 if (!(ri.getLeftExpr() instanceof VarExpr)) {
593 Updates up=new Updates(ri.getLeftExpr(),0);
596 VarDescriptor vd=((VarExpr)ri.getLeftExpr()).getVar();
597 if (un.getBinding(vd)==null) {
598 Updates up=new Updates(ri.getLeftExpr(),0);
602 if (!(ri.getRightExpr() instanceof VarExpr)) {
603 Updates up=new Updates(ri.getRightExpr(),1);
606 VarDescriptor vd=((VarExpr)ri.getRightExpr()).getVar();
607 if (un.getBinding(vd)==null) {
608 Updates up=new Updates(ri.getRightExpr(),1);
613 //Finally build necessary updates to satisfy conjunction
614 RuleConjunction ruleconj=dnfrule.get(j);
615 /* Add in updates for quantifiers */
616 //System.out.println("Attempting to generate add to set #4");
617 MultUpdateNode mun=new MultUpdateNode(ar,MultUpdateNode.ADD);
618 TermNode tn=new TermNode(mun);
619 GraphNode gn2=new GraphNode("UpdateAdd"+addtocount,tn);
621 if (processquantifers(gn2,un, r)&&debugdd()&&
622 processconjunction(un,ruleconj)&&
624 //System.out.println("Attempting to generate add to set #5");
626 GraphNode.Edge e=new GraphNode.Edge("abstract"+addtocount,gn2);
629 updatenodes.add(gn2);}
636 //System.out.println("Attempting to generate add to set DD");
640 boolean processquantifers(GraphNode gn,UpdateNode un, Rule r) {
641 Inclusion inc=r.getInclusion();
642 for(Iterator iterator=r.quantifiers();iterator.hasNext();) {
643 Quantifier q=(Quantifier)iterator.next();
645 /* FIXME: Analysis to determine when this update is necessary */
646 if (q instanceof RelationQuantifier) {
647 RelationQuantifier rq=(RelationQuantifier)q;
648 TupleOfExpr toe=new TupleOfExpr(new VarExpr(rq.x),new VarExpr(rq.y),rq.relation);
649 toe.td=ReservedTypeDescriptor.INT;
650 Updates u=new Updates(toe,false);
652 if (abstractremove.containsKey(rq.relation)) {
653 GraphNode agn=(GraphNode)abstractadd.get(rq.relation);
654 GraphNode.Edge e=new GraphNode.Edge("requires",agn);
660 } else if (q instanceof SetQuantifier) {
661 SetQuantifier sq=(SetQuantifier)q;
662 ElementOfExpr eoe=new ElementOfExpr(new VarExpr(sq.var),sq.set);
663 eoe.td=ReservedTypeDescriptor.INT;
664 Updates u=new Updates(eoe,false);
666 if (abstractremove.containsKey(sq.set)) {
667 GraphNode agn=(GraphNode)abstractadd.get(sq.set);
668 GraphNode.Edge e=new GraphNode.Edge("requires",agn);
678 boolean processconjunction(UpdateNode un,RuleConjunction ruleconj){
680 for(int k=0;k<ruleconj.size();k++) {
681 DNFExpr de=ruleconj.get(k);
683 if (e instanceof OpExpr) {
684 OpExpr ex=(OpExpr)de.getExpr();
685 Opcode op=ex.getOpcode();
686 Updates up=new Updates(ex.left,ex.right,op, de.getNegation());
688 } else if (e instanceof ElementOfExpr) {
689 Updates up=new Updates(e,de.getNegation());
691 } else if (e instanceof TupleOfExpr) {
692 Updates up=new Updates(e,de.getNegation());
694 } else if (e instanceof BooleanLiteralExpr) {
695 boolean truth=((BooleanLiteralExpr)e).getValue();
696 if (de.getNegation())
703 System.out.println(e.getClass().getName());
704 throw new Error("Error #213");
710 void generatescopenodes() {
711 for(int i=0;i<state.vRules.size();i++) {
712 Rule r=(Rule) state.vRules.get(i);
713 ScopeNode satisfy=new ScopeNode(r,true);
714 TermNode tnsatisfy=new TermNode(satisfy);
715 GraphNode gnsatisfy=new GraphNode("SatisfyRule"+i,tnsatisfy);
716 ConsequenceNode cnsatisfy=new ConsequenceNode();
717 TermNode ctnsatisfy=new TermNode(cnsatisfy);
718 GraphNode cgnsatisfy=new GraphNode("ConseqSatisfyRule"+i,ctnsatisfy);
719 consequence.put(satisfy,cgnsatisfy);
720 GraphNode.Edge esat=new GraphNode.Edge("consequencesatisfy"+i,cgnsatisfy);
721 gnsatisfy.addEdge(esat);
722 consequencenodes.add(cgnsatisfy);
723 scopesatisfy.put(r,gnsatisfy);
724 scopenodes.add(gnsatisfy);
726 ScopeNode falsify=new ScopeNode(r,false);
727 TermNode tnfalsify=new TermNode(falsify);
728 GraphNode gnfalsify=new GraphNode("FalsifyRule"+i,tnfalsify);
729 ConsequenceNode cnfalsify=new ConsequenceNode();
730 TermNode ctnfalsify=new TermNode(cnfalsify);
731 GraphNode cgnfalsify=new GraphNode("ConseqFalsifyRule"+i,ctnfalsify);
732 consequence.put(falsify,cgnfalsify);
733 GraphNode.Edge efals=new GraphNode.Edge("consequencefalsify"+i,cgnfalsify);
734 gnfalsify.addEdge(efals);
735 consequencenodes.add(cgnfalsify);
736 scopefalsify.put(r,gnfalsify);
737 scopenodes.add(gnfalsify);