From a0a7e93f41239e9aa128e3441c3e71ffe2f47a3c Mon Sep 17 00:00:00 2001 From: bdemsky Date: Mon, 8 Nov 2004 01:48:32 +0000 Subject: [PATCH 1/1] Improved termination analysis so that daikon generated specifications won't have problems. --- .../MCC/IR/AbstractInterferes.java | 161 ++++++++++++++++-- Repair/RepairCompiler/MCC/IR/Constraint.java | 17 +- .../RepairCompiler/MCC/IR/DNFConstraint.java | 10 ++ Repair/RepairCompiler/MCC/IR/Termination.java | 109 +++++++----- 4 files changed, 232 insertions(+), 65 deletions(-) diff --git a/Repair/RepairCompiler/MCC/IR/AbstractInterferes.java b/Repair/RepairCompiler/MCC/IR/AbstractInterferes.java index 68ed221..df03933 100755 --- a/Repair/RepairCompiler/MCC/IR/AbstractInterferes.java +++ b/Repair/RepairCompiler/MCC/IR/AbstractInterferes.java @@ -8,6 +8,7 @@ class AbstractInterferes { termination=t; } + /** Does performing the AbstractRepair ar satisfy (or falsify if satisfy=false) * Rule r. */ @@ -43,7 +44,7 @@ class AbstractInterferes { drule=r.getDNFGuardExpr(); else drule=r.getDNFNegGuardExpr(); - + for(int i=0;i in R], a in S1 and b in S2; */ + public boolean checkrelationconstraint(AbstractRepair ar, Constraint c) { if (c.numQuantifiers()==1&& (c.getQuantifier(0) instanceof RelationQuantifier)) { @@ -99,6 +104,137 @@ class AbstractInterferes { return false; } + + /** Check to see if performing the repair ar on repair_c does not + * inferere with interfere_c. Returns true if there is no + * interference. */ + + public boolean interferemodifies(AbstractRepair ar, Constraint repair_c, DNFPredicate interfere_pred, Constraint interfere_c) { + DNFConstraint precondition=repair_c.getDNFConstraint().not(); + if (repair_c.numQuantifiers()!=1|| + interfere_c.numQuantifiers()!=1|| + !(repair_c.getQuantifier(0) instanceof SetQuantifier)|| + !(interfere_c.getQuantifier(0) instanceof SetQuantifier)|| + ((SetQuantifier)repair_c.getQuantifier(0)).getSet()!=((SetQuantifier)interfere_c.getQuantifier(0)).getSet()) + return false; + + Hashtable mapping=new Hashtable(); + mapping.put(((SetQuantifier)repair_c.getQuantifier(0)).getVar(), + ((SetQuantifier)interfere_c.getQuantifier(0)).getVar()); + + if (ar.getType()!=AbstractRepair.MODIFYRELATION|| + !(ar.getPredicate().getPredicate() instanceof ExprPredicate)|| + !(interfere_pred.getPredicate() instanceof ExprPredicate)) + return false; + Expr e=((ExprPredicate)interfere_pred.getPredicate()).expr; + Expr leftside=((OpExpr)((ExprPredicate)ar.getPredicate().getPredicate()).expr).left; + Set relationset=e.useDescriptor(ar.getDescriptor()); + for(Iterator relit=relationset.iterator();relit.hasNext();) { + Expr e2=(Expr)relit.next(); + if (!leftside.equals(mapping,e2)) + return false; + } + /* Prune precondition using any ar's in the same conjunction */ + adjustcondition(precondition, ar); + Conjunction conj=findConjunction(repair_c.getDNFConstraint(),ar.getPredicate()); + for(int i=0;i=size2))|| @@ -309,7 +446,7 @@ class AbstractInterferes { (dp.getPredicate() instanceof ExprPredicate)&& (dp.getPredicate().inverted()==ar.getPredicate().getPredicate().inverted())&& (((ExprPredicate)dp.getPredicate()).getType()==ExprPredicate.COMPARISON)) { - + boolean neg1=ar.getPredicate().isNegated(); Opcode op1=((ExprPredicate)ar.getPredicate().getPredicate()).getOp(); boolean isInt1=((ExprPredicate)ar.getPredicate().getPredicate()).isRightInt(); @@ -323,7 +460,7 @@ class AbstractInterferes { int size2=isInt2?((ExprPredicate)dp.getPredicate()).rightSize():0; Expr expr2=((OpExpr)((ExprPredicate)dp.getPredicate()).expr).right; - + /* If the left sides of the comparisons are both from different sets, the update is orthogonal to the expr dp */ { @@ -338,7 +475,7 @@ class AbstractInterferes { /* Translate the opcodes */ op1=Opcode.translateOpcode(neg1,op1); op2=Opcode.translateOpcode(neg2,op2); - + /* Obvious cases which can't interfere */ if (((op1==Opcode.GT)|| (op1==Opcode.GE))&& @@ -367,7 +504,7 @@ class AbstractInterferes { size1a--; if (op1==Opcode.NE) size1a++; /*FLAGNE this is current behavior for NE repairs */ - + if (op2==Opcode.GT) size2a++; if (op2==Opcode.LT) @@ -584,7 +721,7 @@ class AbstractInterferes { (op2==Opcode.LE)|| (op2==Opcode.LT)) return false; - } + } } if ((des==dp.getPredicate().getDescriptor())&& satisfy&& diff --git a/Repair/RepairCompiler/MCC/IR/Constraint.java b/Repair/RepairCompiler/MCC/IR/Constraint.java index a506b03..c15d749 100755 --- a/Repair/RepairCompiler/MCC/IR/Constraint.java +++ b/Repair/RepairCompiler/MCC/IR/Constraint.java @@ -3,13 +3,13 @@ package MCC.IR; import java.util.*; public class Constraint implements Quantifiers { - + private static int count = 1; String label = null; boolean crash = false; SymbolTable st = new SymbolTable(); - Vector quantifiers = new Vector(); + Vector quantifiers = new Vector(); LogicStatement logicstatement = null; DNFConstraint dnfconstraint; int num; @@ -19,6 +19,10 @@ public class Constraint implements Quantifiers { label = new String("c" + count++); } + public DNFConstraint getDNFConstraint() { + return dnfconstraint; + } + public String toString() { String name=""; for(int i=0;i=0;i--) { if (e==null) e=lexpr; - else + else e=((DotExpr)e).getExpr(); while (e instanceof CastExpr) @@ -1035,7 +1052,7 @@ public class Termination { return false; e=ce.getExpr(); } - + if ((e instanceof VarExpr)&& (((VarExpr)e).getVar()==vd)) { /* Can solve for v */ @@ -1059,7 +1076,7 @@ public class Termination { return false; e=ce.getExpr(); } - + if ((e instanceof VarExpr)&& (((VarExpr)e).getVar()==vd)) { /* Can solve for v */ @@ -1080,7 +1097,7 @@ public class Termination { return false; e=ce.getExpr(); } - + if ((e instanceof VarExpr)&& (((VarExpr)e).getVar()==vd)) { /* Can solve for v */ @@ -1118,7 +1135,7 @@ public class Termination { SetInclusion si=(SetInclusion)inc; Expr e=si.elementexpr; - + while(e instanceof CastExpr) { CastExpr ce=(CastExpr)e; if (ce.getType()!=td) @@ -1143,7 +1160,7 @@ public class Termination { Expr e=ri.getLeftExpr(); - + while(e instanceof CastExpr) { CastExpr ce=(CastExpr)e; if (ce.getType()!=ri.getRelation().getDomain().getType()) @@ -1163,7 +1180,7 @@ public class Termination { e=ri.getRightExpr(); - + while(e instanceof CastExpr) { CastExpr ce=(CastExpr)e; if (ce.getType()!=ri.getRelation().getRange().getType()) @@ -1198,10 +1215,10 @@ public class Termination { } return goodupdate; } - + /** Adds updates that add an item to the appropriate set or * relation quantified over by the model definition rule.. */ - + boolean processquantifiers(GraphNode gn,UpdateNode un, Rule r,Hashtable setmapping) { Inclusion inc=r.getInclusion(); for(Iterator iterator=r.quantifiers();iterator.hasNext();) { @@ -1284,7 +1301,7 @@ public class Termination { } else if (e instanceof TupleOfExpr) { Updates up=new Updates(e,de.getNegation()); un.addUpdate(up); - } else if (e instanceof BooleanLiteralExpr) { + } else if (e instanceof BooleanLiteralExpr) { boolean truth=((BooleanLiteralExpr)e).getValue(); if (de.getNegation()) truth=!truth; -- 2.34.1