package domain

import com.microsoft.z3._

/**
  * Domain to track taint information.
  */
class TaintDomain(ctx: Context) extends AbstractDomain {

  override type Element = BoolExpr

  override def sort: Sort = ctx.mkBoolSort()

  override def top: Element = ctx.mkTrue()

  override def bottom: Element = ctx.mkFalse()

  override def meet(e1: Element, e2: Element): Element =
    ctx.mkNot(
      ctx.mkXor(e1, e2)
    )

  override def join(e1: Element, e2: Element): Element =
    ctx.mkNot(
      ctx.mkXor(e1, e2)
    )

  override def approx(e1: Element, e2: Element): BoolExpr =
    ctx.mkOr(
      ctx.mkNot(e1),
      e2
    )

}
