Search in sources :

Example 1 with VariableNormalization

use of nars.term.transform.VariableNormalization in project narchy by automenta.

the class Compound method normalize.

@Override
@Nullable
default Term normalize(byte varOffset) {
    if (varOffset == 0 && this.isNormalized())
        return this;
    int vars = this.vars();
    int pVars = this.varPattern();
    int totalVars = vars + pVars;
    assert (totalVars > 0);
    Term y = transform(((vars == 1) && (pVars == 0) && varOffset == 0) ? // special case for efficiency
    VariableNormalization.singleVariableNormalization : new VariableNormalization(totalVars, /* estimate */
    varOffset));
    if (varOffset == 0 && y instanceof Compound) {
        if (!(y instanceof UnitCompound)) {
            Subterms st = y.subterms();
            st.setNormalized();
        }
    }
    return y;
}
Also used : Subterms(nars.subterm.Subterms) VariableNormalization(nars.term.transform.VariableNormalization) UnitCompound(nars.term.compound.UnitCompound) UnitCompound(nars.term.compound.UnitCompound) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

Subterms (nars.subterm.Subterms)1 UnitCompound (nars.term.compound.UnitCompound)1 VariableNormalization (nars.term.transform.VariableNormalization)1 Nullable (org.jetbrains.annotations.Nullable)1