package domain

import com.microsoft.z3._

class BitVectorSetDomain(ctx: Context) extends PrimitiveDomain {

  override type Element = ArrayExpr

  private val size: Int = 32
  private val bv: BitVecSort = ctx.mkBitVecSort(size)
  private val bvSet: SetSort = ctx.mkSetSort(ctx.mkBitVecSort(size))

  override def sort: Sort = bvSet

  override def top: Element = ctx.mkFullSet(bv)

  override def bottom: Element = ctx.mkEmptySet(bv)

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

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

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

  override def toElement(n: Long): Element =
    ctx.mkSetAdd(
      ctx.mkEmptySet(bv),
      ctx.mkBV(n, size)
    )

  override def toElement(n: Double): ArrayExpr =
    ctx.mkSetAdd(
      ctx.mkEmptySet(bv),
      ctx.mkFPToIEEEBV(
        ctx.mkFP(n, ctx.mkFPSort32())
      )
    )

  override def sum(e1: ArrayExpr, e2: ArrayExpr): ArrayExpr =
    top

  override def neg(e: ArrayExpr): ArrayExpr =
    top

  override def div(e1: ArrayExpr, e2: ArrayExpr): ArrayExpr =
    top

  override def mult(e1: ArrayExpr, e2: ArrayExpr): ArrayExpr =
    top

  override def rem(e1: ArrayExpr, e2: ArrayExpr): ArrayExpr =
    top
}
