4 public class DNFConstraint {
7 public DNFConstraint(Predicate p) {
8 conjunctions=new Vector();
9 conjunctions.add(new Conjunction(new DNFPredicate(false,p)));
12 public DNFConstraint(Conjunction conj) {
13 conjunctions=new Vector();
14 conjunctions.add(conj);
17 public DNFConstraint(Vector conj) {
22 conjunctions=new Vector();
26 return conjunctions.size();
29 Conjunction get(int i) {
30 return (Conjunction)conjunctions.get(i);
33 void add(Conjunction c) {
37 public DNFConstraint copy() {
38 Vector vector=new Vector();
39 for (int i=0;i<size();i++) {
40 vector.add(get(i).copy());
42 return new DNFConstraint(vector);
45 public DNFConstraint and(DNFConstraint c) {
46 DNFConstraint newdnf=new DNFConstraint();
47 for(int i=0;i<size();i++) {
48 for(int j=0;j<c.size();j++) {
49 newdnf.add(get(i).append(c.get(j))); //Cross product
55 public DNFConstraint or(DNFConstraint c) {
56 DNFConstraint copy=copy();
57 for(int i=0;i<c.size();i++) {
58 copy.add(c.get(i).copy()); //Add in other conjunctions
63 public DNFConstraint not() {
64 DNFConstraint copy=copy();
65 for (int i=0;i<size();i++) {
66 Conjunction conj=copy.get(i);
67 for (int j=0;j<conj.size();j++) {
68 DNFPredicate dp=conj.get(j);