Skip to content

Smt

smt

NonFuncSMTType: TypeAlias = BoolType | BitVectorType module-attribute

NonFuncSMTTypeConstr = irdl_to_attr_constraint(NonFuncSMTType) module-attribute

SMTType: TypeAlias = NonFuncSMTType | FuncType module-attribute

SMTTypeConstr = irdl_to_attr_constraint(SMTType) module-attribute

SMT = Dialect('smt', [DeclareFunOp, ApplyFuncOp, ConstantBoolOp, NotOp, AndOp, OrOp, XOrOp, ImpliesOp, DistinctOp, EqOp, IteOp, ExistsOp, ForallOp, YieldOp, AssertOp, BvConstantOp, BVNegOp, BVNotOp, BVAndOp, BVOrOp, BVXOrOp, BVAddOp, BVMulOp, BVUDivOp, BVSDivOp, BVURemOp, BVSRemOp, BVSModOp, BVShlOp, BVLShrOp, BVAShrOp], [BoolType, BitVectorType, FuncType, BitVectorAttr]) module-attribute

BoolType dataclass

Bases: ParametrizedAttribute, TypeAttribute

A boolean.

Source code in xdsl/dialects/smt.py
@irdl_attr_definition
class BoolType(ParametrizedAttribute, TypeAttribute):
    """A boolean."""

    name = "smt.bool"

name = 'smt.bool' class-attribute instance-attribute

BitVectorType

Bases: ParametrizedAttribute, TypeAttribute

This type represents the (_ BitVec width) sort as described in the SMT bitvector theory. The bit-width must be strictly greater than zero.

Source code in xdsl/dialects/smt.py
@irdl_attr_definition
class BitVectorType(ParametrizedAttribute, TypeAttribute):
    """
    This type represents the (_ BitVec width) sort as described in the SMT bitvector theory.
    The bit-width must be strictly greater than zero.
    """

    name = "smt.bv"

    width: IntAttr

    def __init__(self, width: int | IntAttr):
        if isinstance(width, int):
            width = IntAttr(width)
        super().__init__(width)

    @classmethod
    def parse_parameters(cls, parser: AttrParser) -> Sequence[Attribute]:
        with parser.in_angle_brackets():
            width = parser.parse_integer(allow_boolean=False, allow_negative=False)

        return (IntAttr(width),)

    def print_parameters(self, printer: Printer) -> None:
        printer.print_string(f"<{self.width.data}>")

    def verify(self) -> None:
        super().verify()
        if self.width.data <= 0:
            raise VerifyException(
                "BitVectorType width must be strictly greater "
                f"than zero, got {self.width.data}"
            )

    def value_range(self) -> tuple[int, int]:
        """
        The range of values that this bitvector can represent.
        The maximum value is exclusive.
        """
        return (0, 1 << self.width.data)

name = 'smt.bv' class-attribute instance-attribute

width: IntAttr instance-attribute

__init__(width: int | IntAttr)

Source code in xdsl/dialects/smt.py
def __init__(self, width: int | IntAttr):
    if isinstance(width, int):
        width = IntAttr(width)
    super().__init__(width)

parse_parameters(parser: AttrParser) -> Sequence[Attribute] classmethod

Source code in xdsl/dialects/smt.py
@classmethod
def parse_parameters(cls, parser: AttrParser) -> Sequence[Attribute]:
    with parser.in_angle_brackets():
        width = parser.parse_integer(allow_boolean=False, allow_negative=False)

    return (IntAttr(width),)

print_parameters(printer: Printer) -> None

Source code in xdsl/dialects/smt.py
def print_parameters(self, printer: Printer) -> None:
    printer.print_string(f"<{self.width.data}>")

verify() -> None

Source code in xdsl/dialects/smt.py
def verify(self) -> None:
    super().verify()
    if self.width.data <= 0:
        raise VerifyException(
            "BitVectorType width must be strictly greater "
            f"than zero, got {self.width.data}"
        )

value_range() -> tuple[int, int]

The range of values that this bitvector can represent. The maximum value is exclusive.

Source code in xdsl/dialects/smt.py
def value_range(self) -> tuple[int, int]:
    """
    The range of values that this bitvector can represent.
    The maximum value is exclusive.
    """
    return (0, 1 << self.width.data)

FuncType

Bases: ParametrizedAttribute, TypeAttribute

A function type.

Source code in xdsl/dialects/smt.py
@irdl_attr_definition
class FuncType(ParametrizedAttribute, TypeAttribute):
    """A function type."""

    name = "smt.func"

    domain_types: ArrayAttr[NonFuncSMTType]
    """The types of the function arguments."""

    range_type: NonFuncSMTType
    """The type of the function result."""

    def __init__(
        self, domain_types: Sequence[NonFuncSMTType], range_type: NonFuncSMTType
    ):
        super().__init__(ArrayAttr[NonFuncSMTType](domain_types), range_type)

    @classmethod
    def parse_parameters(cls, parser: AttrParser) -> Sequence[Attribute]:
        with parser.in_angle_brackets():
            domain_types = parser.parse_comma_separated_list(
                parser.Delimiter.PAREN, parser.parse_type
            )
            range_type = parser.parse_type()

        return (ArrayAttr(domain_types), range_type)

    def print_parameters(self, printer: Printer) -> None:
        printer.print_string("<(")
        printer.print_list(self.domain_types, printer.print_attribute)
        printer.print_string(") ")
        printer.print_attribute(self.range_type)
        printer.print_string(">")

    @staticmethod
    def constr(
        domain: RangeConstraint[NonFuncSMTType],
        range: AttrConstraint[NonFuncSMTType],
    ) -> AttrConstraint[FuncType]:
        return ParamAttrConstraint(FuncType, (ArrayAttr.constr(domain), range))

name = 'smt.func' class-attribute instance-attribute

domain_types: ArrayAttr[NonFuncSMTType] instance-attribute

The types of the function arguments.

range_type: NonFuncSMTType instance-attribute

The type of the function result.

__init__(domain_types: Sequence[NonFuncSMTType], range_type: NonFuncSMTType)

Source code in xdsl/dialects/smt.py
def __init__(
    self, domain_types: Sequence[NonFuncSMTType], range_type: NonFuncSMTType
):
    super().__init__(ArrayAttr[NonFuncSMTType](domain_types), range_type)

parse_parameters(parser: AttrParser) -> Sequence[Attribute] classmethod

Source code in xdsl/dialects/smt.py
@classmethod
def parse_parameters(cls, parser: AttrParser) -> Sequence[Attribute]:
    with parser.in_angle_brackets():
        domain_types = parser.parse_comma_separated_list(
            parser.Delimiter.PAREN, parser.parse_type
        )
        range_type = parser.parse_type()

    return (ArrayAttr(domain_types), range_type)

print_parameters(printer: Printer) -> None

Source code in xdsl/dialects/smt.py
def print_parameters(self, printer: Printer) -> None:
    printer.print_string("<(")
    printer.print_list(self.domain_types, printer.print_attribute)
    printer.print_string(") ")
    printer.print_attribute(self.range_type)
    printer.print_string(">")

constr(domain: RangeConstraint[NonFuncSMTType], range: AttrConstraint[NonFuncSMTType]) -> AttrConstraint[FuncType] staticmethod

Source code in xdsl/dialects/smt.py
@staticmethod
def constr(
    domain: RangeConstraint[NonFuncSMTType],
    range: AttrConstraint[NonFuncSMTType],
) -> AttrConstraint[FuncType]:
    return ParamAttrConstraint(FuncType, (ArrayAttr.constr(domain), range))

BitVectorAttr

Bases: TypedAttribute

Source code in xdsl/dialects/smt.py
@irdl_attr_definition
class BitVectorAttr(TypedAttribute):
    name = "smt.bv"

    value: IntAttr
    type: BitVectorType

    def __init__(self, value: int | IntAttr, type: BitVectorType | int):
        if isinstance(value, int):
            value = IntAttr(value)
        if isinstance(type, int):
            type = BitVectorType(type)
        super().__init__(value, type)

    def verify(self) -> None:
        super().verify()
        (min_value, max_value) = self.type.value_range()
        if not (min_value <= self.value.data < max_value):
            raise VerifyException(
                f"BitVectorAttr value {self.value.data} is out of range "
                f"[{min_value}, {max_value}) for type {self.type}"
            )

    @staticmethod
    def constr(
        type: AttrConstraint[BitVectorType],
    ) -> AttrConstraint[BitVectorAttr]:
        return ParamAttrConstraint(
            BitVectorAttr,
            (
                AnyAttr(),
                type,
            ),
        )

    @classmethod
    def get_type_index(cls) -> int:
        return 1

    @classmethod
    def parse_parameters(cls, parser: AttrParser) -> Sequence[Attribute]:
        with parser.in_angle_brackets():
            value = parser.parse_integer(allow_boolean=False, allow_negative=False)
        parser.parse_punctuation(":")
        type = parser.parse_type()
        return [IntAttr(value), type]

    def print_parameters(self, printer: Printer) -> None:
        printer.print_string(f"<{self.value.data}> : {self.type}")

    @staticmethod
    def parse_with_type(
        parser: AttrParser,
        type: Attribute,
    ) -> TypedAttribute:
        with parser.in_angle_brackets():
            value = parser.parse_integer(allow_boolean=False, allow_negative=False)
        return BitVectorAttr.new([IntAttr(value), type])

    def print_without_type(self, printer: Printer) -> None:
        printer.print_string(f"<{self.value.data}>")

name = 'smt.bv' class-attribute instance-attribute

value: IntAttr instance-attribute

type: BitVectorType instance-attribute

__init__(value: int | IntAttr, type: BitVectorType | int)

Source code in xdsl/dialects/smt.py
def __init__(self, value: int | IntAttr, type: BitVectorType | int):
    if isinstance(value, int):
        value = IntAttr(value)
    if isinstance(type, int):
        type = BitVectorType(type)
    super().__init__(value, type)

verify() -> None

Source code in xdsl/dialects/smt.py
def verify(self) -> None:
    super().verify()
    (min_value, max_value) = self.type.value_range()
    if not (min_value <= self.value.data < max_value):
        raise VerifyException(
            f"BitVectorAttr value {self.value.data} is out of range "
            f"[{min_value}, {max_value}) for type {self.type}"
        )

constr(type: AttrConstraint[BitVectorType]) -> AttrConstraint[BitVectorAttr] staticmethod

Source code in xdsl/dialects/smt.py
@staticmethod
def constr(
    type: AttrConstraint[BitVectorType],
) -> AttrConstraint[BitVectorAttr]:
    return ParamAttrConstraint(
        BitVectorAttr,
        (
            AnyAttr(),
            type,
        ),
    )

get_type_index() -> int classmethod

Source code in xdsl/dialects/smt.py
@classmethod
def get_type_index(cls) -> int:
    return 1

parse_parameters(parser: AttrParser) -> Sequence[Attribute] classmethod

Source code in xdsl/dialects/smt.py
@classmethod
def parse_parameters(cls, parser: AttrParser) -> Sequence[Attribute]:
    with parser.in_angle_brackets():
        value = parser.parse_integer(allow_boolean=False, allow_negative=False)
    parser.parse_punctuation(":")
    type = parser.parse_type()
    return [IntAttr(value), type]

print_parameters(printer: Printer) -> None

Source code in xdsl/dialects/smt.py
def print_parameters(self, printer: Printer) -> None:
    printer.print_string(f"<{self.value.data}> : {self.type}")

parse_with_type(parser: AttrParser, type: Attribute) -> TypedAttribute staticmethod

Source code in xdsl/dialects/smt.py
@staticmethod
def parse_with_type(
    parser: AttrParser,
    type: Attribute,
) -> TypedAttribute:
    with parser.in_angle_brackets():
        value = parser.parse_integer(allow_boolean=False, allow_negative=False)
    return BitVectorAttr.new([IntAttr(value), type])

print_without_type(printer: Printer) -> None

Source code in xdsl/dialects/smt.py
def print_without_type(self, printer: Printer) -> None:
    printer.print_string(f"<{self.value.data}>")

DeclareFunOp

Bases: IRDLOperation

This operation declares a symbolic value just as the declare-const and declare-fun statements in SMT-LIB 2.7. The result type determines the SMT sort of the symbolic value. The returned value can then be used to refer to the symbolic value instead of using the identifier like in SMT-LIB.

The optionally provided string will be used as a prefix for the newly generated identifier (useful for easier readability when exporting to SMT-LIB). Each declare will always provide a unique new symbolic value even if the identifier strings are the same.

Source code in xdsl/dialects/smt.py
@irdl_op_definition
class DeclareFunOp(IRDLOperation):
    """
    This operation declares a symbolic value just as the declare-const and declare-fun
    statements in SMT-LIB 2.7. The result type determines the SMT sort of the symbolic
    value. The returned value can then be used to refer to the symbolic value instead
    of using the identifier like in SMT-LIB.

    The optionally provided string will be used as a prefix for the newly generated
    identifier (useful for easier readability when exporting to SMT-LIB). Each declare
    will always provide a unique new symbolic value even if the identifier strings are
    the same.
    """

    name = "smt.declare_fun"

    name_prefix = opt_prop_def(StringAttr, prop_name="namePrefix")
    result = result_def(SMTType)

    assembly_format = "($namePrefix^)? attr-dict `:` type($result)"

    def __init__(
        self, result_type: SMTType, name_prefix: StringAttr | str | None = None
    ):
        if isinstance(name_prefix, str):
            name_prefix = StringAttr(name_prefix)
        super().__init__(
            result_types=[result_type], properties={"namePrefix": name_prefix}
        )

name = 'smt.declare_fun' class-attribute instance-attribute

name_prefix = opt_prop_def(StringAttr, prop_name='namePrefix') class-attribute instance-attribute

result = result_def(SMTType) class-attribute instance-attribute

assembly_format = '($namePrefix^)? attr-dict `:` type($result)' class-attribute instance-attribute

__init__(result_type: SMTType, name_prefix: StringAttr | str | None = None)

Source code in xdsl/dialects/smt.py
def __init__(
    self, result_type: SMTType, name_prefix: StringAttr | str | None = None
):
    if isinstance(name_prefix, str):
        name_prefix = StringAttr(name_prefix)
    super().__init__(
        result_types=[result_type], properties={"namePrefix": name_prefix}
    )

ApplyFuncOp

Bases: IRDLOperation

This operation performs a function application as described in the SMT-LIB 2.7 standard. It is part of the SMT-LIB core theory.

Source code in xdsl/dialects/smt.py
@irdl_op_definition
class ApplyFuncOp(IRDLOperation):
    """
    This operation performs a function application as described in the SMT-LIB
    2.7 standard. It is part of the SMT-LIB core theory.
    """

    name = "smt.apply_func"

    DOMAIN: ClassVar = RangeVarConstraint("DOMAIN", RangeOf(NonFuncSMTTypeConstr))
    RANGE: ClassVar = VarConstraint("RANGE", NonFuncSMTTypeConstr)

    func = operand_def(FuncType.constr(DOMAIN, RANGE))
    args = var_operand_def(DOMAIN)

    result = result_def(RANGE)

    assembly_format = "$func `(` $args `)` attr-dict `:` qualified(type($func))"

    def __init__(self, func: SSAValue[FuncType], *args: SSAValue):
        super().__init__(
            operands=[func, tuple(args)], result_types=[func.type.range_type]
        )

name = 'smt.apply_func' class-attribute instance-attribute

DOMAIN: ClassVar = RangeVarConstraint('DOMAIN', RangeOf(NonFuncSMTTypeConstr)) class-attribute instance-attribute

RANGE: ClassVar = VarConstraint('RANGE', NonFuncSMTTypeConstr) class-attribute instance-attribute

func = operand_def(FuncType.constr(DOMAIN, RANGE)) class-attribute instance-attribute

args = var_operand_def(DOMAIN) class-attribute instance-attribute

result = result_def(RANGE) class-attribute instance-attribute

assembly_format = '$func `(` $args `)` attr-dict `:` qualified(type($func))' class-attribute instance-attribute

__init__(func: SSAValue[FuncType], *args: SSAValue)

Source code in xdsl/dialects/smt.py
def __init__(self, func: SSAValue[FuncType], *args: SSAValue):
    super().__init__(
        operands=[func, tuple(args)], result_types=[func.type.range_type]
    )

ConstantBoolOp

Bases: IRDLOperation, HasFolderInterface

This operation represents a constant boolean value. The semantics are equivalent to the true and false keywords in the Core theory of the SMT-LIB Standard 2.7.

Source code in xdsl/dialects/smt.py
@irdl_op_definition
class ConstantBoolOp(IRDLOperation, HasFolderInterface):
    """
    This operation represents a constant boolean value. The semantics are
    equivalent to the `true` and `false` keywords in the Core theory of the
    SMT-LIB Standard 2.7.
    """

    name = "smt.constant"

    value_attr = prop_def(BoolAttr, prop_name="value")
    result = result_def(BoolType())

    traits = traits_def(Pure(), ConstantLike())

    assembly_format = "qualified($value) attr-dict"

    def __init__(self, value: bool):
        value_attr = BoolAttr.from_bool(value)
        super().__init__(properties={"value": value_attr}, result_types=[BoolType()])

    @property
    def value(self) -> bool:
        return bool(self.value_attr)

    def fold(self) -> tuple[BoolAttr]:
        return (self.value_attr,)

name = 'smt.constant' class-attribute instance-attribute

value_attr = prop_def(BoolAttr, prop_name='value') class-attribute instance-attribute

result = result_def(BoolType()) class-attribute instance-attribute

traits = traits_def(Pure(), ConstantLike()) class-attribute instance-attribute

assembly_format = 'qualified($value) attr-dict' class-attribute instance-attribute

value: bool property

__init__(value: bool)

Source code in xdsl/dialects/smt.py
def __init__(self, value: bool):
    value_attr = BoolAttr.from_bool(value)
    super().__init__(properties={"value": value_attr}, result_types=[BoolType()])

fold() -> tuple[BoolAttr]

Source code in xdsl/dialects/smt.py
def fold(self) -> tuple[BoolAttr]:
    return (self.value_attr,)

NotOp

Bases: IRDLOperation

This operation performs a boolean negation. The semantics are equivalent to the not operator in the Core theory of the SMT-LIB Standard 2.7.

Source code in xdsl/dialects/smt.py
@irdl_op_definition
class NotOp(IRDLOperation):
    """
    This operation performs a boolean negation. The semantics are equivalent
    to the `not` operator in the Core theory of the SMT-LIB Standard 2.7.
    """

    name = "smt.not"

    input = operand_def(BoolType)
    result = result_def(BoolType)

    assembly_format = "$input attr-dict"

    traits = traits_def(Pure())

    def __init__(self, input: SSAValue):
        super().__init__(operands=[input], result_types=[BoolType()])

name = 'smt.not' class-attribute instance-attribute

input = operand_def(BoolType) class-attribute instance-attribute

result = result_def(BoolType) class-attribute instance-attribute

assembly_format = '$input attr-dict' class-attribute instance-attribute

traits = traits_def(Pure()) class-attribute instance-attribute

__init__(input: SSAValue)

Source code in xdsl/dialects/smt.py
def __init__(self, input: SSAValue):
    super().__init__(operands=[input], result_types=[BoolType()])

VariadicBoolOp

Bases: IRDLOperation

A variadic operation on boolean. It has a variadic number of operands, but requires at least two.

Source code in xdsl/dialects/smt.py
class VariadicBoolOp(IRDLOperation):
    """
    A variadic operation on boolean. It has a variadic number of operands, but
    requires at least two.
    """

    inputs = var_operand_def(RangeOf.get(BoolType).of_length(AtLeast(2)))
    result = result_def(BoolType())

    traits = traits_def(Pure())

    assembly_format = "$inputs attr-dict"

    def __init__(self, *operands: SSAValue):
        super().__init__(operands=[operands], result_types=[BoolType()])

inputs = var_operand_def(RangeOf.get(BoolType).of_length(AtLeast(2))) class-attribute instance-attribute

result = result_def(BoolType()) class-attribute instance-attribute

traits = traits_def(Pure()) class-attribute instance-attribute

assembly_format = '$inputs attr-dict' class-attribute instance-attribute

__init__(*operands: SSAValue)

Source code in xdsl/dialects/smt.py
def __init__(self, *operands: SSAValue):
    super().__init__(operands=[operands], result_types=[BoolType()])

AndOp dataclass

Bases: VariadicBoolOp

This operation performs a boolean conjunction. The semantics are equivalent to the and operator in the Core theory of the SMT-LIB Standard 2.7.

It supports a variadic number of operands, but requires at least two.

Source code in xdsl/dialects/smt.py
@irdl_op_definition
class AndOp(VariadicBoolOp):
    """
    This operation performs a boolean conjunction. The semantics are equivalent
    to the `and` operator in the Core theory of the SMT-LIB Standard 2.7.

    It supports a variadic number of operands, but requires at least two.
    """

    name = "smt.and"

name = 'smt.and' class-attribute instance-attribute

OrOp dataclass

Bases: VariadicBoolOp

This operation performs a boolean disjunction. The semantics are equivalent to the or operator in the Core theory of the SMT-LIB Standard 2.7.

It supports a variadic number of operands, but requires at least two.

Source code in xdsl/dialects/smt.py
@irdl_op_definition
class OrOp(VariadicBoolOp):
    """
    This operation performs a boolean disjunction. The semantics are equivalent
    to the `or` operator in the Core theory of the SMT-LIB Standard 2.7.

    It supports a variadic number of operands, but requires at least two.
    """

    name = "smt.or"

name = 'smt.or' class-attribute instance-attribute

XOrOp dataclass

Bases: VariadicBoolOp

This operation performs a boolean exclusive or. The semantics are equivalent to the xor operator in the Core theory of the SMT-LIB Standard 2.7.

It supports a variadic number of operands, but requires at least two.

Source code in xdsl/dialects/smt.py
@irdl_op_definition
class XOrOp(VariadicBoolOp):
    """
    This operation performs a boolean exclusive or. The semantics are equivalent
    to the `xor` operator in the Core theory of the SMT-LIB Standard 2.7.

    It supports a variadic number of operands, but requires at least two.
    """

    name = "smt.xor"

name = 'smt.xor' class-attribute instance-attribute

ImpliesOp

Bases: IRDLOperation

This operation performs a boolean implication. The semantics are equivalent to the => operator in the Core theory of the SMT-LIB Standard 2.7.

Source code in xdsl/dialects/smt.py
@irdl_op_definition
class ImpliesOp(IRDLOperation):
    """
    This operation performs a boolean implication. The semantics are equivalent
    to the `=>` operator in the Core theory of the SMT-LIB Standard 2.7.
    """

    name = "smt.implies"

    lhs = operand_def(BoolType)
    rhs = operand_def(BoolType)
    result = result_def(BoolType)

    traits = traits_def(Pure())

    assembly_format = "$lhs `,` $rhs attr-dict"

    def __init__(self, lhs: SSAValue, rhs: SSAValue):
        super().__init__(operands=[lhs, rhs], result_types=[BoolType()])

name = 'smt.implies' class-attribute instance-attribute

lhs = operand_def(BoolType) class-attribute instance-attribute

rhs = operand_def(BoolType) class-attribute instance-attribute

result = result_def(BoolType) class-attribute instance-attribute

traits = traits_def(Pure()) class-attribute instance-attribute

assembly_format = '$lhs `,` $rhs attr-dict' class-attribute instance-attribute

__init__(lhs: SSAValue, rhs: SSAValue)

Source code in xdsl/dialects/smt.py
def __init__(self, lhs: SSAValue, rhs: SSAValue):
    super().__init__(operands=[lhs, rhs], result_types=[BoolType()])

VariadicPredicateOp

Bases: IRDLOperation, ABC

A predicate with a variadic number (but at least 2) operands.

Source code in xdsl/dialects/smt.py
class VariadicPredicateOp(IRDLOperation, ABC):
    """
    A predicate with a variadic number (but at least 2) operands.
    """

    T: ClassVar = VarConstraint("T", NonFuncSMTTypeConstr)

    inputs = var_operand_def(RangeOf(T).of_length(AtLeast(2)))
    result = result_def(BoolType())

    traits = traits_def(Pure())

    @classmethod
    def parse(cls: type[Self], parser: Parser) -> Self:
        operands, attr_dict = _parse_same_operand_type_variadic_to_bool_op(parser)
        op = cls(*operands)
        op.attributes = attr_dict
        return op

    def print(self, printer: Printer):
        _print_same_operand_type_variadic_to_bool_op(
            printer, self.inputs, self.attributes
        )

    def __init__(self, *operands: SSAValue):
        super().__init__(operands=[operands], result_types=[BoolType()])

T: ClassVar = VarConstraint('T', NonFuncSMTTypeConstr) class-attribute instance-attribute

inputs = var_operand_def(RangeOf(T).of_length(AtLeast(2))) class-attribute instance-attribute

result = result_def(BoolType()) class-attribute instance-attribute

traits = traits_def(Pure()) class-attribute instance-attribute

parse(parser: Parser) -> Self classmethod

Source code in xdsl/dialects/smt.py
@classmethod
def parse(cls: type[Self], parser: Parser) -> Self:
    operands, attr_dict = _parse_same_operand_type_variadic_to_bool_op(parser)
    op = cls(*operands)
    op.attributes = attr_dict
    return op

print(printer: Printer)

Source code in xdsl/dialects/smt.py
def print(self, printer: Printer):
    _print_same_operand_type_variadic_to_bool_op(
        printer, self.inputs, self.attributes
    )

__init__(*operands: SSAValue)

Source code in xdsl/dialects/smt.py
def __init__(self, *operands: SSAValue):
    super().__init__(operands=[operands], result_types=[BoolType()])

DistinctOp dataclass

Bases: VariadicPredicateOp

This operation compares the operands and returns true iff all operands are not identical to any of the other operands. The semantics are equivalent to the distinct operator defined in the SMT-LIB Standard 2.7 in the Core theory.

Any SMT sort/type is allowed for the operands and it supports a variadic number of operands, but requires at least two. This is because the distinct operator is annotated with :pairwise which means that distinct a b c d is equivalent to

and (distinct a b) (distinct a c) (distinct a d)
    (distinct b c) (distinct b d) (distinct c d)
Source code in xdsl/dialects/smt.py
@irdl_op_definition
class DistinctOp(VariadicPredicateOp):
    """
    This operation compares the operands and returns true iff all operands are not
    identical to any of the other operands. The semantics are equivalent to the
    `distinct` operator defined in the SMT-LIB Standard 2.7 in the Core theory.

    Any SMT sort/type is allowed for the operands and it supports a variadic
    number of operands, but requires at least two. This is because the `distinct`
    operator is annotated with `:pairwise` which means that `distinct a b c d` is
    equivalent to

    ```
    and (distinct a b) (distinct a c) (distinct a d)
        (distinct b c) (distinct b d) (distinct c d)
    ```
    """

    name = "smt.distinct"

name = 'smt.distinct' class-attribute instance-attribute

EqOp dataclass

Bases: VariadicPredicateOp

This operation compares the operands and returns true iff all operands are identical. The semantics are equivalent to the = operator defined in the SMT-LIB Standard 2.7 in the Core theory.

Any SMT sort/type is allowed for the operands and it supports a variadic number of operands, but requires at least two. This is because the = operator is annotated with :chainable which means that = a b c d is equivalent to and (= a b) (= b c) (= c d) where and is annotated :left-assoc, i.e., it can be further rewritten to and (and (= a b) (= b c)) (= c d).

Source code in xdsl/dialects/smt.py
@irdl_op_definition
class EqOp(VariadicPredicateOp):
    """
    This operation compares the operands and returns true iff all operands are
    identical. The semantics are equivalent to the `=` operator defined in the
    SMT-LIB Standard 2.7 in the Core theory.

    Any SMT sort/type is allowed for the operands and it supports a variadic number of
    operands, but requires at least two. This is because the `=` operator is annotated
    with `:chainable` which means that `= a b c d` is equivalent to
    `and (= a b) (= b c) (= c d)` where and is annotated `:left-assoc`, i.e., it can
    be further rewritten to `and (and (= a b) (= b c)) (= c d)`.
    """

    name = "smt.eq"

name = 'smt.eq' class-attribute instance-attribute

IteOp

Bases: IRDLOperation

This operation returns its second operand or its third operand depending on whether its first operand is true or not. The semantics are equivalent to the ite operator defined in the Core theory of the SMT-LIB 2.7 standard.

Source code in xdsl/dialects/smt.py
@irdl_op_definition
class IteOp(IRDLOperation):
    """
    This operation returns its second operand or its third operand depending on
    whether its first operand is true or not. The semantics are equivalent to the
    ite operator defined in the Core theory of the SMT-LIB 2.7 standard.
    """

    name = "smt.ite"

    T: ClassVar = VarConstraint("T", NonFuncSMTTypeConstr)

    cond = operand_def(BoolType)
    then_value = operand_def(T)
    else_value = operand_def(T)

    result = result_def(T)

    assembly_format = (
        "$cond `,` $then_value `,` $else_value attr-dict `:` type($result)"
    )

    traits = traits_def(Pure())

    def __init__(self, cond: SSAValue, then_value: SSAValue, else_value: SSAValue):
        super().__init__(
            operands=[cond, then_value, else_value],
            result_types=[then_value.type],
        )

name = 'smt.ite' class-attribute instance-attribute

T: ClassVar = VarConstraint('T', NonFuncSMTTypeConstr) class-attribute instance-attribute

cond = operand_def(BoolType) class-attribute instance-attribute

then_value = operand_def(T) class-attribute instance-attribute

else_value = operand_def(T) class-attribute instance-attribute

result = result_def(T) class-attribute instance-attribute

assembly_format = '$cond `,` $then_value `,` $else_value attr-dict `:` type($result)' class-attribute instance-attribute

traits = traits_def(Pure()) class-attribute instance-attribute

__init__(cond: SSAValue, then_value: SSAValue, else_value: SSAValue)

Source code in xdsl/dialects/smt.py
def __init__(self, cond: SSAValue, then_value: SSAValue, else_value: SSAValue):
    super().__init__(
        operands=[cond, then_value, else_value],
        result_types=[then_value.type],
    )

QuantifierOp

Bases: IRDLOperation, ABC

Source code in xdsl/dialects/smt.py
class QuantifierOp(IRDLOperation, ABC):
    result = result_def(BoolType)
    body = region_def("single_block")

    traits = traits_def(Pure())

    assembly_format = "attr-dict-with-keyword $body"

    def __init__(self, body: Region) -> None:
        super().__init__(result_types=[BoolType()], regions=[body])

    def verify_(self) -> None:
        if not isinstance(yield_op := self.body.block.last_op, YieldOp):
            raise VerifyException("region expects an `smt.yield` terminator")
        if tuple(yield_op.operand_types) != (BoolType(),):
            raise VerifyException(
                "region yield terminator must have a single boolean operand, "
                f"got {tuple(str(type) for type in yield_op.operand_types)}"
            )

    @property
    def returned_value(self) -> SSAValue[BoolType]:
        """
        The value returned by the quantifier. This is the value that is passed
        to the `smt.yield` terminator of the operation region.
        This function will asserts if the region is not correctly terminated by
        an `smt.yield` operation with a single boolean operand.
        """
        yield_op = self.body.block.last_op
        assert isinstance(yield_op, YieldOp)
        ret_value = yield_op.values[0]
        assert isa(ret_value, SSAValue[BoolType])
        return ret_value

result = result_def(BoolType) class-attribute instance-attribute

body = region_def('single_block') class-attribute instance-attribute

traits = traits_def(Pure()) class-attribute instance-attribute

assembly_format = 'attr-dict-with-keyword $body' class-attribute instance-attribute

returned_value: SSAValue[BoolType] property

The value returned by the quantifier. This is the value that is passed to the smt.yield terminator of the operation region. This function will asserts if the region is not correctly terminated by an smt.yield operation with a single boolean operand.

__init__(body: Region) -> None

Source code in xdsl/dialects/smt.py
def __init__(self, body: Region) -> None:
    super().__init__(result_types=[BoolType()], regions=[body])

verify_() -> None

Source code in xdsl/dialects/smt.py
def verify_(self) -> None:
    if not isinstance(yield_op := self.body.block.last_op, YieldOp):
        raise VerifyException("region expects an `smt.yield` terminator")
    if tuple(yield_op.operand_types) != (BoolType(),):
        raise VerifyException(
            "region yield terminator must have a single boolean operand, "
            f"got {tuple(str(type) for type in yield_op.operand_types)}"
        )

ExistsOp dataclass

Bases: QuantifierOp

This operation represents the exists quantifier as described in the SMT-LIB 2.7 standard. It is part of the language itself rather than a theory or logic.

Source code in xdsl/dialects/smt.py
@irdl_op_definition
class ExistsOp(QuantifierOp):
    """
    This operation represents the `exists` quantifier as described in the SMT-LIB 2.7
    standard. It is part of the language itself rather than a theory or logic.
    """

    name = "smt.exists"

name = 'smt.exists' class-attribute instance-attribute

ForallOp dataclass

Bases: QuantifierOp

This operation represents the forall quantifier as described in the SMT-LIB 2.7 standard. It is part of the language itself rather than a theory or logic.

Source code in xdsl/dialects/smt.py
@irdl_op_definition
class ForallOp(QuantifierOp):
    """
    This operation represents the `forall` quantifier as described in the SMT-LIB 2.7
    standard. It is part of the language itself rather than a theory or logic.
    """

    name = "smt.forall"

name = 'smt.forall' class-attribute instance-attribute

YieldOp

Bases: IRDLOperation

Source code in xdsl/dialects/smt.py
@irdl_op_definition
class YieldOp(IRDLOperation):
    name = "smt.yield"

    values = var_operand_def(NonFuncSMTType)

    assembly_format = "($values^ `:` type($values))? attr-dict"

    traits = traits_def(IsTerminator(), HasParent(ExistsOp, ForallOp))

    def __init__(self, *values: SSAValue):
        super().__init__(operands=[values], result_types=[])

name = 'smt.yield' class-attribute instance-attribute

values = var_operand_def(NonFuncSMTType) class-attribute instance-attribute

assembly_format = '($values^ `:` type($values))? attr-dict' class-attribute instance-attribute

traits = traits_def(IsTerminator(), HasParent(ExistsOp, ForallOp)) class-attribute instance-attribute

__init__(*values: SSAValue)

Source code in xdsl/dialects/smt.py
def __init__(self, *values: SSAValue):
    super().__init__(operands=[values], result_types=[])

AssertOp

Bases: IRDLOperation

Assert that a boolean expression holds.

Source code in xdsl/dialects/smt.py
@irdl_op_definition
class AssertOp(IRDLOperation):
    """Assert that a boolean expression holds."""

    name = "smt.assert"

    input = operand_def(BoolType)

    assembly_format = "$input attr-dict"

    def __init__(self, input: SSAValue):
        super().__init__(operands=[input])

name = 'smt.assert' class-attribute instance-attribute

input = operand_def(BoolType) class-attribute instance-attribute

assembly_format = '$input attr-dict' class-attribute instance-attribute

__init__(input: SSAValue)

Source code in xdsl/dialects/smt.py
def __init__(self, input: SSAValue):
    super().__init__(operands=[input])

BvConstantOp

Bases: IRDLOperation, HasFolderInterface

This operation produces an SSA value equal to the bitvector constant specified by the value attribute.

Source code in xdsl/dialects/smt.py
@irdl_op_definition
class BvConstantOp(IRDLOperation, HasFolderInterface):
    """
    This operation produces an SSA value equal to the bitvector constant specified
    by the `value` attribute.
    """

    name = "smt.bv.constant"

    T: ClassVar = VarConstraint.get("T", BitVectorType)

    value = prop_def(BitVectorAttr.constr(T))
    result = result_def(T)

    assembly_format = "qualified($value) attr-dict"

    traits = traits_def(Pure(), ConstantLike())

    @overload
    def __init__(self, value: BitVectorAttr) -> None: ...

    @overload
    def __init__(self, value: int, type: BitVectorType | int) -> None: ...

    def __init__(
        self, value: BitVectorAttr | int, type: int | BitVectorType | None = None
    ):
        """
        Create a new `BvConstantOp` from a value and a bitvector width.
        """
        if not isinstance(value, BitVectorAttr):
            if isinstance(type, int):
                type = BitVectorType(type)
            assert isinstance(type, BitVectorType)
            value = BitVectorAttr(value, type)
        super().__init__(properties={"value": value}, result_types=[value.type])

    def fold(self) -> tuple[Attribute]:
        return (self.value,)

name = 'smt.bv.constant' class-attribute instance-attribute

T: ClassVar = VarConstraint.get('T', BitVectorType) class-attribute instance-attribute

value = prop_def(BitVectorAttr.constr(T)) class-attribute instance-attribute

result = result_def(T) class-attribute instance-attribute

assembly_format = 'qualified($value) attr-dict' class-attribute instance-attribute

traits = traits_def(Pure(), ConstantLike()) class-attribute instance-attribute

__init__(value: BitVectorAttr | int, type: int | BitVectorType | None = None)

__init__(value: BitVectorAttr) -> None
__init__(value: int, type: BitVectorType | int) -> None

Create a new BvConstantOp from a value and a bitvector width.

Source code in xdsl/dialects/smt.py
def __init__(
    self, value: BitVectorAttr | int, type: int | BitVectorType | None = None
):
    """
    Create a new `BvConstantOp` from a value and a bitvector width.
    """
    if not isinstance(value, BitVectorAttr):
        if isinstance(type, int):
            type = BitVectorType(type)
        assert isinstance(type, BitVectorType)
        value = BitVectorAttr(value, type)
    super().__init__(properties={"value": value}, result_types=[value.type])

fold() -> tuple[Attribute]

Source code in xdsl/dialects/smt.py
def fold(self) -> tuple[Attribute]:
    return (self.value,)

UnaryBVOp

Bases: IRDLOperation, ABC

A unary bitvector operation. It has one operand and one result of the same bitvector type.

Source code in xdsl/dialects/smt.py
class UnaryBVOp(IRDLOperation, ABC):
    """
    A unary bitvector operation.
    It has one operand and one result of the same bitvector type.
    """

    T: ClassVar = VarConstraint.get("T", BitVectorType)

    input = operand_def(T)
    result = result_def(T)

    assembly_format = "$input attr-dict `:` qualified(type($result))"

    traits = traits_def(Pure())

    def __init__(self, input: SSAValue[BitVectorType]):
        super().__init__(operands=[input], result_types=[input.type])

T: ClassVar = VarConstraint.get('T', BitVectorType) class-attribute instance-attribute

input = operand_def(T) class-attribute instance-attribute

result = result_def(T) class-attribute instance-attribute

assembly_format = '$input attr-dict `:` qualified(type($result))' class-attribute instance-attribute

traits = traits_def(Pure()) class-attribute instance-attribute

__init__(input: SSAValue[BitVectorType])

Source code in xdsl/dialects/smt.py
def __init__(self, input: SSAValue[BitVectorType]):
    super().__init__(operands=[input], result_types=[input.type])

BVNotOp dataclass

Bases: UnaryBVOp

A unary bitwise not operation for bitvectors. It corresponds to the 'not' operation in SMT-LIB.

Source code in xdsl/dialects/smt.py
@irdl_op_definition
class BVNotOp(UnaryBVOp):
    """
    A unary bitwise not operation for bitvectors.
    It corresponds to the 'not' operation in SMT-LIB.
    """

    name = "smt.bv.not"

name = 'smt.bv.not' class-attribute instance-attribute

BVNegOp dataclass

Bases: UnaryBVOp

A unary negation operation for bitvectors. It corresponds to the 'neg' operation in SMT-LIB.

Source code in xdsl/dialects/smt.py
@irdl_op_definition
class BVNegOp(UnaryBVOp):
    """
    A unary negation operation for bitvectors.
    It corresponds to the 'neg' operation in SMT-LIB.
    """

    name = "smt.bv.neg"

name = 'smt.bv.neg' class-attribute instance-attribute

BinaryBVOp

Bases: IRDLOperation, ABC

A binary bitvector operation. It has two operands and one result of the same bitvector type.

Source code in xdsl/dialects/smt.py
class BinaryBVOp(IRDLOperation, ABC):
    """
    A binary bitvector operation.
    It has two operands and one result of the same bitvector type.
    """

    T: ClassVar = VarConstraint.get("T", BitVectorType)

    lhs = operand_def(T)
    rhs = operand_def(T)
    result = result_def(T)

    assembly_format = "$lhs `,` $rhs attr-dict `:` qualified(type($result))"

    traits = traits_def(Pure())

    def __init__(self, lhs: SSAValue[BitVectorType], rhs: SSAValue[BitVectorType]):
        super().__init__(operands=[lhs, rhs], result_types=[lhs.type])

T: ClassVar = VarConstraint.get('T', BitVectorType) class-attribute instance-attribute

lhs = operand_def(T) class-attribute instance-attribute

rhs = operand_def(T) class-attribute instance-attribute

result = result_def(T) class-attribute instance-attribute

assembly_format = '$lhs `,` $rhs attr-dict `:` qualified(type($result))' class-attribute instance-attribute

traits = traits_def(Pure()) class-attribute instance-attribute

__init__(lhs: SSAValue[BitVectorType], rhs: SSAValue[BitVectorType])

Source code in xdsl/dialects/smt.py
def __init__(self, lhs: SSAValue[BitVectorType], rhs: SSAValue[BitVectorType]):
    super().__init__(operands=[lhs, rhs], result_types=[lhs.type])

BVAndOp dataclass

Bases: BinaryBVOp

A bitwise AND operation for bitvectors. It corresponds to the 'bvand' operation in SMT-LIB.

Source code in xdsl/dialects/smt.py
@irdl_op_definition
class BVAndOp(BinaryBVOp):
    """
    A bitwise AND operation for bitvectors.
    It corresponds to the 'bvand' operation in SMT-LIB.
    """

    name = "smt.bv.and"

name = 'smt.bv.and' class-attribute instance-attribute

BVOrOp dataclass

Bases: BinaryBVOp

A bitwise OR operation for bitvectors. It corresponds to the 'bvor' operation in SMT-LIB.

Source code in xdsl/dialects/smt.py
@irdl_op_definition
class BVOrOp(BinaryBVOp):
    """
    A bitwise OR operation for bitvectors.
    It corresponds to the 'bvor' operation in SMT-LIB.
    """

    name = "smt.bv.or"

name = 'smt.bv.or' class-attribute instance-attribute

BVXOrOp dataclass

Bases: BinaryBVOp

A bitwise XOR operation for bitvectors. It corresponds to the 'bvxor' operation in SMT-LIB.

Source code in xdsl/dialects/smt.py
@irdl_op_definition
class BVXOrOp(BinaryBVOp):
    """
    A bitwise XOR operation for bitvectors.
    It corresponds to the 'bvxor' operation in SMT-LIB.
    """

    name = "smt.bv.xor"

name = 'smt.bv.xor' class-attribute instance-attribute

BVAddOp dataclass

Bases: BinaryBVOp

An addition operation for bitvectors. It corresponds to the 'bvadd' operation in SMT-LIB.

Source code in xdsl/dialects/smt.py
@irdl_op_definition
class BVAddOp(BinaryBVOp):
    """
    An addition operation for bitvectors.
    It corresponds to the 'bvadd' operation in SMT-LIB.
    """

    name = "smt.bv.add"

name = 'smt.bv.add' class-attribute instance-attribute

BVMulOp dataclass

Bases: BinaryBVOp

A multiplication operation for bitvectors. It corresponds to the 'bvmul' operation in SMT-LIB.

Source code in xdsl/dialects/smt.py
@irdl_op_definition
class BVMulOp(BinaryBVOp):
    """
    A multiplication operation for bitvectors.
    It corresponds to the 'bvmul' operation in SMT-LIB.
    """

    name = "smt.bv.mul"

name = 'smt.bv.mul' class-attribute instance-attribute

BVUDivOp dataclass

Bases: BinaryBVOp

An unsigned division operation (rounded towards zero) for bitvectors. It corresponds to the 'bvudiv' operation in SMT-LIB.

Source code in xdsl/dialects/smt.py
@irdl_op_definition
class BVUDivOp(BinaryBVOp):
    """
    An unsigned division operation (rounded towards zero) for bitvectors.
    It corresponds to the 'bvudiv' operation in SMT-LIB.
    """

    name = "smt.bv.udiv"

name = 'smt.bv.udiv' class-attribute instance-attribute

BVSDivOp dataclass

Bases: BinaryBVOp

A two's complement signed division operation (rounded towards zero) for bitvectors. It corresponds to the 'bvsdiv' operation in SMT-LIB.

Source code in xdsl/dialects/smt.py
@irdl_op_definition
class BVSDivOp(BinaryBVOp):
    """
    A two's complement signed division operation (rounded towards zero) for bitvectors.
    It corresponds to the 'bvsdiv' operation in SMT-LIB.
    """

    name = "smt.bv.sdiv"

name = 'smt.bv.sdiv' class-attribute instance-attribute

BVURemOp dataclass

Bases: BinaryBVOp

An unsigned remainder for bitvectors. It corresponds to the 'bvurem' operation in SMT-LIB.

Source code in xdsl/dialects/smt.py
@irdl_op_definition
class BVURemOp(BinaryBVOp):
    """
    An unsigned remainder for bitvectors.
    It corresponds to the 'bvurem' operation in SMT-LIB.
    """

    name = "smt.bv.urem"

name = 'smt.bv.urem' class-attribute instance-attribute

BVSRemOp dataclass

Bases: BinaryBVOp

A two's complement signed remainder (sign follows dividend) for bitvectors. It corresponds to the 'bvsrem' operation in SMT-LIB.

Source code in xdsl/dialects/smt.py
@irdl_op_definition
class BVSRemOp(BinaryBVOp):
    """
    A two's complement signed remainder (sign follows dividend) for bitvectors.
    It corresponds to the 'bvsrem' operation in SMT-LIB.
    """

    name = "smt.bv.srem"

name = 'smt.bv.srem' class-attribute instance-attribute

BVSModOp dataclass

Bases: BinaryBVOp

A two's complement signed remainder (sign follows divisor) for bitvectors. It corresponds to the 'bvsmod' operation in SMT-LIB.

Source code in xdsl/dialects/smt.py
@irdl_op_definition
class BVSModOp(BinaryBVOp):
    """
    A two's complement signed remainder (sign follows divisor) for bitvectors.
    It corresponds to the 'bvsmod' operation in SMT-LIB.
    """

    name = "smt.bv.smod"

name = 'smt.bv.smod' class-attribute instance-attribute

BVShlOp dataclass

Bases: BinaryBVOp

A shift left for bitvectors. It corresponds to the 'bvshl' operation in SMT-LIB.

Source code in xdsl/dialects/smt.py
@irdl_op_definition
class BVShlOp(BinaryBVOp):
    """
    A shift left for bitvectors.
    It corresponds to the 'bvshl' operation in SMT-LIB.
    """

    name = "smt.bv.shl"

name = 'smt.bv.shl' class-attribute instance-attribute

BVLShrOp dataclass

Bases: BinaryBVOp

A logical shift right for bitvectors. It corresponds to the 'bvlshr' operation in SMT-LIB.

Source code in xdsl/dialects/smt.py
@irdl_op_definition
class BVLShrOp(BinaryBVOp):
    """
    A logical shift right for bitvectors.
    It corresponds to the 'bvlshr' operation in SMT-LIB.
    """

    name = "smt.bv.lshr"

name = 'smt.bv.lshr' class-attribute instance-attribute

BVAShrOp dataclass

Bases: BinaryBVOp

An arithmetic shift right for bitvectors. It corresponds to the 'bvashr' operation in SMT-LIB.

Source code in xdsl/dialects/smt.py
@irdl_op_definition
class BVAShrOp(BinaryBVOp):
    """
    An arithmetic shift right for bitvectors.
    It corresponds to the 'bvashr' operation in SMT-LIB.
    """

    name = "smt.bv.ashr"

name = 'smt.bv.ashr' class-attribute instance-attribute