5 Vector ruleconjunctions;
7 public DNFRule(Expr e) {
8 ruleconjunctions=new Vector();
9 ruleconjunctions.add(new RuleConjunction(new DNFExpr(false,e)));
12 public DNFRule(DNFExpr de) {
13 ruleconjunctions=new Vector();
14 ruleconjunctions.add(new RuleConjunction(de));
17 public DNFRule(RuleConjunction conj) {
18 ruleconjunctions=new Vector();
19 ruleconjunctions.add(conj);
22 public DNFRule(Vector conj) {
23 ruleconjunctions=conj;
27 ruleconjunctions=new Vector();
31 return ruleconjunctions.size();
34 RuleConjunction get(int i) {
35 return (RuleConjunction)ruleconjunctions.get(i);
38 void add(RuleConjunction c) {
39 ruleconjunctions.add(c);
42 public DNFRule copy() {
43 Vector vector=new Vector();
44 for (int i=0;i<size();i++) {
45 vector.add(get(i).copy());
47 return new DNFRule(vector);
50 public DNFRule and(DNFRule c) {
51 DNFRule newdnf=new DNFRule();
52 for(int i=0;i<size();i++) {
53 for(int j=0;j<c.size();j++) {
54 newdnf.add(get(i).append(c.get(j))); //Cross product
60 public DNFRule or(DNFRule c) {
62 for(int i=0;i<c.size();i++) {
63 copy.add(c.get(i).copy()); //Add in other conjunctions
68 public DNFRule not() {
71 for (int i=0;i<size();i++) {
72 RuleConjunction conj=copy.get(i);
74 for (int j=0;j<conj.size();j++) {
75 DNFExpr dp=conj.get(j);
78 newrule=new DNFRule(dp);
80 newrule=newrule.or(new DNFRule(dp));
85 notrule=notrule.and(newrule);