import java.util.*;
import java.io.*;
+
+////////////////////////////////////////////////
+//
+// important note! The static operations in this class that take
+// canonicals and produce a canonical result sometimes need a
+// "working copy" that IS NOT CANONICAL. So, even though it isn't
+// perfectly clean, Canonical constructors have been changed from
+// private to protected and they may be used in this file--however,
+// only use a constructor for an object that will mutate during the
+// calculation--use the factory method to obtain everything else!
+// This is CRITICAL!
+//
+// What this boils down to is that the only normally constructed
+// object in a canonical operation should be the result out.
+//
+////////////////////////////////////////////////
+
+
abstract public class Canonical {
// for generating unique canonical values
}
- public ReachState union( ReachState rs1,
- ReachState rs2 ) {
+ public static ReachState union( ReachState rs1,
+ ReachState rs2 ) {
assert rs1 != null;
assert rs2 != null;
assert rs1.isCanonical();
}
// otherwise, no cached result...
- ReachState out = ReachState.factory();
+ ReachState out = new ReachState();
out.reachTuples.addAll( rs1.reachTuples );
out.reachTuples.addAll( rs2.reachTuples );
}
// otherwise, no cached result...
- ReachState out = ReachState.factory();
+ ReachState out = new ReachState();
out.reachTuples.addAll( rs.reachTuples );
out.reachTuples.add( rt );
}
// otherwise, no cached result...
- ReachState out = ReachState.factory();
+ ReachState out = new ReachState();
Iterator<ReachTuple> rtItr = rs1.iterator();
while( rtItr.hasNext() ) {
}
// otherwise, no cached result...
- ReachState out = ReachState.factory();
+ ReachState out = new ReachState();
out.reachTuples.addAll( rs.reachTuples );
out.reachTuples.remove( rt );
}
// otherwise, no cached result...
- ReachState out = ReachState.factory();
+ ReachState out = new ReachState();
ReachTuple rtSummary = null;
ReachTuple rtOldest = null;
}
// otherwise, no cached result...
- ReachSet out = ReachSet.factory();
+ ReachSet out = new ReachSet();
out.reachStates.addAll( rs1.reachStates );
out.reachStates.addAll( rs2.reachStates );
}
// otherwise, no cached result...
- ReachSet out = ReachSet.factory();
+ ReachSet out = new ReachSet();
out.reachStates.addAll( rs.reachStates );
out.reachStates.add( state );
}
// otherwise, no cached result...
- ReachSet out = ReachSet.factory();
+ ReachSet out = new ReachSet();
Iterator<ReachState> itr = rs1.iterator();
while( itr.hasNext() ) {
ReachState state = (ReachState) itr.next();
}
// otherwise, no cached result...
- ReachSet out = ReachSet.factory();
+ ReachSet out = new ReachSet();
out.reachStates.addAll( rs.reachStates );
out.reachStates.remove( state );
}
// otherwise, no cached result...
- ReachSet out = ReachSet.factory();
+ ReachSet out = new ReachSet();
Iterator<ReachState> stateItr = rs.iterator();
while( stateItr.hasNext() ) {
}
// otherwise, no cached result...
- ChangeSet out = ChangeSet.factory();
+ ChangeSet out = new ChangeSet();
Iterator<ReachState> itrO = rsO.iterator();
while( itrO.hasNext() ) {
}
// otherwise, no cached result...
- ReachSet out = ReachSet.factory();
+ ReachSet out = new ReachSet();
Iterator<ReachState> itrS = rs.iterator();
while( itrS.hasNext() ) {
}
// otherwise, no cached result...
- ReachSet out = ReachSet.factory();
+ ReachSet out = new ReachSet();
Iterator<ReachState> itrO = rsO.iterator();
while( itrO.hasNext() ) {
}
// otherwise, no cached result...
- ChangeSet out = ChangeSet.factory();
+ ChangeSet out = new ChangeSet();
out.changeTuples.addAll( cs1.changeTuples );
out.changeTuples.addAll( cs2.changeTuples );
}
// otherwise, no cached result...
- ChangeSet out = ChangeSet.factory();
+ ChangeSet out = new ChangeSet();
out.changeTuples.addAll( cs.changeTuples );
out.changeTuples.add( ct );
}
// otherwise, no cached result...
- ExistPredSet out = ExistPredSet.factory();
+ ExistPredSet out = new ExistPredSet();
out.preds.addAll( eps1.preds );
out.preds.addAll( eps2.preds );
}
// otherwise, no cached result...
- ExistPredSet out = ExistPredSet.factory();
+ ExistPredSet out = new ExistPredSet();
out.preds.addAll( eps.preds );
out.preds.add( ep );
}
void t1() {
- ReachTuple rt11a = ReachTuple.factory( 11, true, ReachTuple.ARITY_ONE );
- ReachTuple rt11b = ReachTuple.factory( 11, true, ReachTuple.ARITY_ONE );
- ReachTuple rt12 = ReachTuple.factory( 12, true, ReachTuple.ARITY_ONE );
- ReachTuple rt12z = ReachTuple.factory( 12, true, ReachTuple.ARITY_ZEROORMORE );
+ ReachTuple rt11a = ReachTuple.factory( 11, true, ReachTuple.ARITY_ONE );
+ ReachTuple rt11b = ReachTuple.factory( 11, true, ReachTuple.ARITY_ONE );
+ ReachTuple rt12 = ReachTuple.factory( 12, true, ReachTuple.ARITY_ONE );
+ ReachTuple rt12z = ReachTuple.factory( 12, true, ReachTuple.ARITY_ZEROORMORE );
ReachTuple rt13 = ReachTuple.factory( 13, false, ReachTuple.ARITY_ONE );
assert rt11a.equals( rt11b );
}
void t2() {
-
+ ReachTuple rt14 = ReachTuple.factory( 14, false, ReachTuple.ARITY_ONE );
+ ReachTuple rt15 = ReachTuple.factory( 15, true, ReachTuple.ARITY_ZEROORMORE );
+
+ ReachState s1 = ReachState.factory();
+ ReachState s2 = Canonical.union( s1, rt14 );
+
+ ReachState s3 = ReachState.factory();
+ ReachState s4 = Canonical.union( s3, rt15 );
+
+ ReachState s5 = ReachState.factory( rt14 );
+
+ ReachState s6 = ReachState.factory( rt15 );
+
+ ReachState s7 = Canonical.union( s2, s4 );
+ ReachState s8 = Canonical.union( s5, s6 );
+
+ assert s1 == s3;
+ assert s2 == s5;
+ assert s4 == s6;
+ assert s7 == s8;
+ assert !s1.equals( s7 );
+ assert !s8.equals( s5 );
}
}