package ec.gp.syntactic.simplification.numeric;

import ec.gp.GPNode;
import ec.gp.semantic.func.SimpleNodeBase;
import ec.gp.syntactic.simplification.GenericSimplifier;
import ec.gp.syntactic.simplification.IRule;

public class NumericSimplifier extends GenericSimplifier {

	public NumericSimplifier() {
		super(new IRule[] {
				new ConstRule(),
				new DivOneRule(),
				new DivPowPowRule(),
				//new DivSameRule(), // doesn't work for division by values close to 0
				new DivZeroRule(),
				new DivZero2Rule(),
				//new ExpLogRule(), // do not add this rule, it's not consistent with our definition of protected logarithm
				new LogExpRule(),
				new MulExpExpRule(),
				new MulMulRule(),
				new MulOneRule(),
				new MulPowConstRule(),
				new MulPowPowRule(),
				new MulSameRule(),
				new MulSqrtSqrtRule(),
				new MulZeroRule(),
				new OneCosSqRule(),
				new OneSinSqRule(),
				new PowDivLogLogRule(),
				new PowOneRule(),
				new PowPowConstConstRule(),
				new PowZeroRule(),
				new SubMulMulRule(),
				new SubNegativeRule(),
				new SubSameRule(),
				new SubSubTwoConstRule(),
				new SubSumRule(),
				new SubZeroRule(),
				new SumLogLogRule(),
				new SumMulMulRule(),
				new SumNegativeRule(),
				new SumSameRule(),
				new SumSubRule(),
				new SumSubZeroRule(),
				new SumSumSameRule(),
				new SumSumSumSameRule(),
				new SumZeroRule()
		});

	}

	@Override
	public void simplify(GPNode node) {
		super.simplify(node);
		// however there should be no difference in behavior, we'd better reset the semantics due to possible floating point errors
		//((SimpleNodeBase<?>) node).resetSemanticsRecursive();
	}

}
