From 2bad0dfb94fcdfc04e3c5725177803e7158158b0 Mon Sep 17 00:00:00 2001 From: bdemsky Date: Tue, 3 Aug 2004 19:43:51 +0000 Subject: [PATCH] ... --- Repair/RepairCompiler/MCC/IR/AbstractRepair.java | 15 ++++++++++++++- .../MCC/IR/ConstraintDependence.java | 14 ++++++++++++-- Repair/RepairCompiler/MCC/IR/RepairGenerator.java | 3 +-- 3 files changed, 27 insertions(+), 5 deletions(-) diff --git a/Repair/RepairCompiler/MCC/IR/AbstractRepair.java b/Repair/RepairCompiler/MCC/IR/AbstractRepair.java index 153677f..1d32666 100755 --- a/Repair/RepairCompiler/MCC/IR/AbstractRepair.java +++ b/Repair/RepairCompiler/MCC/IR/AbstractRepair.java @@ -152,7 +152,7 @@ class AbstractRepair { } - /** Thie method tells whether the repair needs to remove objects * + /** This method tells whether the repair needs to remove objects * * from the relation, or whether the model definition rules make * the remove unnecessary.*/ @@ -162,6 +162,19 @@ class AbstractRepair { return !ConstraintDependence.rulesensurefunction(state,(RelationDescriptor)getDescriptor(), sd, getPredicate().getPredicate().inverted(), true); } + /** This method tells whether the repair needs to force the + * relation to be function-like. */ + + public boolean mayNeedFunctionEnforcement(State state) { + assert type==MODIFYRELATION; + SetDescriptor sd=getPredicate().getPredicate().inverted()?getRangeSet():getDomainSet(); + if (ConstraintDependence.rulesensurefunction(state,(RelationDescriptor)getDescriptor(), sd, getPredicate().getPredicate().inverted(), false)) + return false; + if (ConstraintDependence.constraintsensurefunction(state,(RelationDescriptor)getDescriptor(), sd, getPredicate().getPredicate().inverted())) + return false; + return true; + } + public AbstractRepair(DNFPredicate dp,int typ, Descriptor d, Sources s) { torepair=dp; type=typ; diff --git a/Repair/RepairCompiler/MCC/IR/ConstraintDependence.java b/Repair/RepairCompiler/MCC/IR/ConstraintDependence.java index ae1ac7a..c36d913 100755 --- a/Repair/RepairCompiler/MCC/IR/ConstraintDependence.java +++ b/Repair/RepairCompiler/MCC/IR/ConstraintDependence.java @@ -159,7 +159,7 @@ public class ConstraintDependence { if (rulesensurefunction(state,f,false)) continue; //no constraint needed to ensure - Set s=providesfunction(f); + Set s=providesfunction(state,f); if (s.size()==0) { System.out.println("Warning: No constraint ensures that [forall v in "+f.getSet()+"], size(v."+(f.isInverse()?"~":"")+f.getRelation()+")=1"); continue; @@ -216,7 +216,7 @@ public class ConstraintDependence { return foundrule; } - private Set providesfunction(Function f) { + static private Set providesfunction(State state, Function f) { HashSet set=new HashSet(); for(int i=0;i