src/main/java/org/thegalactic/rule/ImplicationalSystem.java
public TreeMap<Comparable, TreeSet<Comparable>> reduction() {
        // compute the reducible elements
        TreeMap red = this.getReducibleElements();
        // collect elements implied by nothing
        TreeSet<Comparable> truth = this.closure(new TreeSet<Comparable>());
        // modify each rule
        for (Object x : red.keySet()) {
            TreeSet<Rule> rules = this.sigma;
            rules = (TreeSet<Rule>) rules.clone();
            for (Rule rule : rules) {
                Rule rule2 = new Rule();
                boolean modif = false;
                // replace the reducible element by its equivalent in the premise
                TreeSet premise = rule.getPremise();
                premise = (TreeSet) premise.clone();
                if (premise.contains(x)) {
                    premise.remove(x);
                    premise.addAll((TreeSet) red.get(x));
                    rule2.addAllToPremise(premise);
                    modif = true;
                } else {
                    rule2.addAllToPremise(premise);
                }
                // replace the reducible element by its equivalent in the conclusion
                TreeSet conclusion = rule.getConclusion();
                conclusion = (TreeSet) conclusion.clone();
                if (conclusion.contains(x)) {
                    conclusion.remove(x);
                    conclusion.addAll((TreeSet) red.get(x));
                    rule2.addAllToConclusion(conclusion);
                    modif = true;
                } else {
                    rule2.addAllToConclusion(conclusion);
                }
                // replace the rule if modified
                if (modif) {
                    if (truth.containsAll(rule2.getConclusion())) {
                        this.removeRule(rule); // Conclusions of this rule are always true, thus the rule is useless
                    } else {
                        this.replaceRule(rule, rule2);
                    }
                } else if (truth.containsAll(rule.getConclusion())) {
                    this.removeRule(rule); // Conclusions of this rule are always true, thus the rule is useless
                }
            }
            // remove the reducible elements from the elements set
            this.deleteElement((Comparable) x);
        }
        return red;
    }
/**
     * Removes from this component reducible elements.
     *
     * Reducible elements are elements equivalent by closure to others elements.
     * They are computed by `getReducibleElements` of `ClosureSystem` in
     * O(O(|Sigma||S|^2)
     *
     * @return the set of reducibles removed elements, with their equivalent
     *         elements
     */
Removes from this component reducible elements.
Reducible elements are elements equivalent by closure to others elements.
They are computed by `getReducibleElements` of `ClosureSystem` in
O(O(|Sigma||S|^2)

@return the set of reducibles removed elements, with their equivalent
elements
Removes from this component reducible elements . Reducible elements are elements equivalent by closure to others elements . They are computed by ` getReducibleElements ` of ` ClosureSystem ` in O ( O ( |Sigma||S|^2 ) @return the set of reducibles removed elements with their equivalent elements
public TreeMap<Comparable, TreeSet<Comparable>> reduction() {
        TreeMap red = this.getReducibleElements();
        TreeSet<Comparable> truth = this.closure(new TreeSet<Comparable>());
        for (Object x : red.keySet()) {
            TreeSet<Rule> rules = this.sigma;
            rules = (TreeSet<Rule>) rules.clone();
            for (Rule rule : rules) {
                Rule rule2 = new Rule();
                boolean modif = false;
                TreeSet premise = rule.getPremise();
                premise = (TreeSet) premise.clone();
                if (premise.contains(x)) {
                    premise.remove(x);
                    premise.addAll((TreeSet) red.get(x));
                    rule2.addAllToPremise(premise);
                    modif = true;
                } else {
                    rule2.addAllToPremise(premise);
                }
                TreeSet conclusion = rule.getConclusion();
                conclusion = (TreeSet) conclusion.clone();
                if (conclusion.contains(x)) {
                    conclusion.remove(x);
                    conclusion.addAll((TreeSet) red.get(x));
                    rule2.addAllToConclusion(conclusion);
                    modif = true;
                } else {
                    rule2.addAllToConclusion(conclusion);
                }
                if (modif) {
                    if (truth.containsAll(rule2.getConclusion())) {
                        this.removeRule(rule); 
                    } else {
                        this.replaceRule(rule, rule2);
                    }
                } else if (truth.containsAll(rule.getConclusion())) {
                    this.removeRule(rule); 
                }
            }
            this.deleteElement((Comparable) x);
        }
        return red;
    }
public TreeMap < Comparable , TreeSet < Comparable > > reduction ( ) { TreeMap red = this . getReducibleElements ( ) ; TreeSet < Comparable > truth = this . closure ( new TreeSet < Comparable > ( ) ) ; for ( Object x : red . keySet ( ) ) { TreeSet < Rule > rules = this . sigma ; rules = ( TreeSet < Rule > ) rules . clone ( ) ; for ( Rule rule : rules ) { Rule rule2 = new Rule ( ) ; boolean modif = false ; TreeSet premise = rule . getPremise ( ) ; premise = ( TreeSet ) premise . clone ( ) ; if ( premise . contains ( x ) ) { premise . remove ( x ) ; premise . addAll ( ( TreeSet ) red . get ( x ) ) ; rule2 . addAllToPremise ( premise ) ; modif = true ; } else { rule2 . addAllToPremise ( premise ) ; } TreeSet conclusion = rule . getConclusion ( ) ; conclusion = ( TreeSet ) conclusion . clone ( ) ; if ( conclusion . contains ( x ) ) { conclusion . remove ( x ) ; conclusion . addAll ( ( TreeSet ) red . get ( x ) ) ; rule2 . addAllToConclusion ( conclusion ) ; modif = true ; } else { rule2 . addAllToConclusion ( conclusion ) ; } if ( modif ) { if ( truth . containsAll ( rule2 . getConclusion ( ) ) ) { this . removeRule ( rule ) ; } else { this . replaceRule ( rule , rule2 ) ; } } else if ( truth . containsAll ( rule . getConclusion ( ) ) ) { this . removeRule ( rule ) ; } } this . deleteElement ( ( Comparable ) x ) ; } return red ; }
Removes from this component reducible elements.
Removes from this component reducible elements .
// compute the reducible elements // collect elements implied by nothing // modify each rule // replace the reducible element by its equivalent in the premise // replace the reducible element by its equivalent in the conclusion // replace the rule if modified // Conclusions of this rule are always true, thus the rule is useless // Conclusions of this rule are always true, thus the rule is useless // remove the reducible elements from the elements set