src/main/java/org/thegalactic/rule/ImplicationalSystem.java
public int makeCompact() {
        ImplicationalSystem save = new ImplicationalSystem(this);
        int before = this.sigma.size();
        this.sigma = new TreeSet();

        while (save.sigma.size() > 0) {
            Rule rule1 = save.sigma.first();
            ComparableSet newConc = new ComparableSet();
            Iterator<Rule> it2 = save.sigma.iterator();
            while (it2.hasNext()) {
                Rule rule2 = it2.next();
                if (!rule1.equals(rule2) && rule1.getPremise().equals(rule2.getPremise())) {
                    newConc.addAll(rule2.getConclusion());
                    it2.remove();
                }
            }
            if (newConc.size() > 0) {
                newConc.addAll(rule1.getConclusion());
                Rule newR = new Rule(rule1.getPremise(), newConc);
                this.addRule(newR);
            } else {
                this.addRule(rule1);
            }
            save.removeRule(rule1);
        }
        return before - this.sigma.size();
    }
/**
     * Replaces rules of same premise by only one rule.
     *
     * This treatment is performed in O(|sigma|^2|S|)
     *
     * @return the difference between the number of rules of this component
     *         before and after this treatment
     */
Replaces rules of same premise by only one rule.
This treatment is performed in O(|sigma|^2|S|)

@return the difference between the number of rules of this component
before and after this treatment
Replaces rules of same premise by only one rule . This treatment is performed in O ( |sigma|^2|S| ) @return the difference between the number of rules of this component before and after this treatment
public int makeCompact() {
        ImplicationalSystem save = new ImplicationalSystem(this);
        int before = this.sigma.size();
        this.sigma = new TreeSet();
        while (save.sigma.size() > 0) {
            Rule rule1 = save.sigma.first();
            ComparableSet newConc = new ComparableSet();
            Iterator<Rule> it2 = save.sigma.iterator();
            while (it2.hasNext()) {
                Rule rule2 = it2.next();
                if (!rule1.equals(rule2) && rule1.getPremise().equals(rule2.getPremise())) {
                    newConc.addAll(rule2.getConclusion());
                    it2.remove();
                }
            }
            if (newConc.size() > 0) {
                newConc.addAll(rule1.getConclusion());
                Rule newR = new Rule(rule1.getPremise(), newConc);
                this.addRule(newR);
            } else {
                this.addRule(rule1);
            }
            save.removeRule(rule1);
        }
        return before - this.sigma.size();
    }
public int makeCompact ( ) { ImplicationalSystem save = new ImplicationalSystem ( this ) ; int before = this . sigma . size ( ) ; this . sigma = new TreeSet ( ) ; while ( save . sigma . size ( ) > 0 ) { Rule rule1 = save . sigma . first ( ) ; ComparableSet newConc = new ComparableSet ( ) ; Iterator < Rule > it2 = save . sigma . iterator ( ) ; while ( it2 . hasNext ( ) ) { Rule rule2 = it2 . next ( ) ; if ( ! rule1 . equals ( rule2 ) && rule1 . getPremise ( ) . equals ( rule2 . getPremise ( ) ) ) { newConc . addAll ( rule2 . getConclusion ( ) ) ; it2 . remove ( ) ; } } if ( newConc . size ( ) > 0 ) { newConc . addAll ( rule1 . getConclusion ( ) ) ; Rule newR = new Rule ( rule1 . getPremise ( ) , newConc ) ; this . addRule ( newR ) ; } else { this . addRule ( rule1 ) ; } save . removeRule ( rule1 ) ; } return before - this . sigma . size ( ) ; }
Replaces rules of same premise by only one rule.
Replaces rules of same premise by only one rule .