
package uk.ac.man.cs.lethe.internal.forgetting.scan

import uk.ac.man.cs.lethe.internal.fol.datatypes.Clause
import uk.ac.man.cs.lethe.internal.fol.unification.Unifier
import uk.ac.man.cs.lethe.internal.resolution._
import uk.ac.man.cs.lethe.internal.resolution.constraintResolution._
import uk.ac.man.cs.lethe.internal.resolution.simplifications._


import com.typesafe.scalalogging.Logger

object ConstraintResolutionForgetter extends SimpleScanForgetter { 
  //implicit val (logger, formatter, appender) = ZeroLoggerFactory.newLogger(SimpleScanForgetterSingleton)

  val logger = Logger(ConstraintResolutionForgetter.getClass)

  override def setClauses(clauses: Set[Clause]) = { 
    super.setClauses(clauses.map(x => Unifier.makeVarsUnique(x)._2))
  }

  override def setRuleGetter() = { 
    ruleGetter = new CombinedRuleGetter(List(new RestrictedRuleGetter(new CombinedRuleGetter(List(CResolutionRuleGetter,
												  CFactoringRuleGetter)),
								      nonBaseSymbols),
					     FactoringRuleGetter))
  }

  override val simplificationRule = new CombinedSimplification(List(//ConstraintElimination,
								    TautologyDeletion,
								    SubsumptionDeletion,
								    SubsumptionFactoring,
								    IdentitySimplification))
  override def resolve() = { 
    super.resolve()
    
    logger.trace("Constraint elimination... ")
    result = ConstraintElimination.simplify(result)
    result = simplificationRule.simplify(result)
  }
}
