Fix formatting

pull/885/head
Dimitar Bounov 6 years ago
parent 4c1ddb9fbe
commit cfc4746291
  1. 407
      mypy-stubs/z3/__init__.pyi
  2. 1
      mypy-stubs/z3/z3core.pyi
  3. 13
      mypy-stubs/z3/z3types.pyi
  4. 36
      mythril/laser/smt/__init__.py
  5. 1
      mythril/laser/smt/array.py
  6. 6
      mythril/laser/smt/expression.py
  7. 2
      mythril/laser/smt/solver.py

@ -1,283 +1,262 @@
from typing import overload, Tuple, Any, List, Iterable, Iterator, Optional, TypeVar, Union from typing import (
overload,
Tuple,
Any,
List,
Iterable,
Iterator,
Optional,
TypeVar,
Union,
)
from .z3types import Ast, ContextObj from .z3types import Ast, ContextObj
class Context: class Context: ...
... class Z3PPObject: ...
class Z3PPObject:
...
class AstRef(Z3PPObject): class AstRef(Z3PPObject):
@overload @overload
def __init__(self, ast: Ast, ctx: Context) -> None: def __init__(self, ast: Ast, ctx: Context) -> None:
self.ast: Ast = ... self.ast: Ast = ...
self.ctx: Context= ... self.ctx: Context = ...
@overload
@overload def __init__(self, ast: Ast) -> None:
def __init__(self, ast: Ast) -> None: self.ast: Ast = ...
self.ast: Ast = ... self.ctx: Context = ...
self.ctx: Context= ... def ctx_ref(self) -> ContextObj: ...
def ctx_ref(self) -> ContextObj: ... def as_ast(self) -> Ast: ...
def as_ast(self) -> Ast: ... def children(self) -> List[AstRef]: ...
def children(self) -> List[AstRef]: ... def eq(self, other: AstRef) -> bool: ...
def eq(self, other: AstRef) -> bool: ... # TODO: Cannot add __eq__ currently: mypy complains conflict with
# TODO: Cannot add __eq__ currently: mypy complains conflict with # object.__eq__ signature
# object.__eq__ signature # def __eq__(self, other: object) -> ArithRef: ...
#def __eq__(self, other: object) -> ArithRef: ...
class SortRef(AstRef): ...
class SortRef(AstRef):
...
class FuncDeclRef(AstRef): class FuncDeclRef(AstRef):
def arity(self) -> int: ... def arity(self) -> int: ...
def name(self) -> str: ... def name(self) -> str: ...
def __call__(self, *args: ExprRef) -> ExprRef: ... def __call__(self, *args: ExprRef) -> ExprRef: ...
class ExprRef(AstRef): class ExprRef(AstRef):
def sort(self) -> SortRef: ... def sort(self) -> SortRef: ...
def decl(self) -> FuncDeclRef: ... def decl(self) -> FuncDeclRef: ...
class BoolSortRef(SortRef):
...
class ArraySortRef(SortRef):
...
class BoolRef(ExprRef): class BoolSortRef(SortRef): ...
... class ArraySortRef(SortRef): ...
class BoolRef(ExprRef): ...
def is_true(a: BoolRef) -> bool: ...
def is_true(a: BoolRef) -> bool: ... def is_false(a: BoolRef) -> bool: ...
def is_false(a: BoolRef) -> bool: ... def is_int_value(a: AstRef) -> bool: ...
def is_int_value(a: AstRef) -> bool: ...
def substitute(a: AstRef, *m: Tuple[AstRef, AstRef]) -> AstRef: ... def substitute(a: AstRef, *m: Tuple[AstRef, AstRef]) -> AstRef: ...
def simplify(a: AstRef, *args: Any, **kwargs: Any) -> AstRef: ... def simplify(a: AstRef, *args: Any, **kwargs: Any) -> AstRef: ...
class ArithSortRef(SortRef): ...
class ArithSortRef(SortRef):
...
class ArithRef(ExprRef): class ArithRef(ExprRef):
def __neg__(self) -> ExprRef: ... def __neg__(self) -> ExprRef: ...
def __le__(self, other: ArithRef) -> BoolRef: ... def __le__(self, other: ArithRef) -> BoolRef: ...
def __lt__(self, other: ArithRef) -> BoolRef: ... def __lt__(self, other: ArithRef) -> BoolRef: ...
def __ge__(self, other: ArithRef) -> BoolRef: ... def __ge__(self, other: ArithRef) -> BoolRef: ...
def __gt__(self, other: ArithRef) -> BoolRef: ... def __gt__(self, other: ArithRef) -> BoolRef: ...
def __add__(self, other: ArithRef) -> ArithRef: ... def __add__(self, other: ArithRef) -> ArithRef: ...
def __sub__(self, other: ArithRef) -> ArithRef: ... def __sub__(self, other: ArithRef) -> ArithRef: ...
def __mul__(self, other: ArithRef) -> ArithRef: ... def __mul__(self, other: ArithRef) -> ArithRef: ...
def __div__(self, other: ArithRef) -> ArithRef: ... def __div__(self, other: ArithRef) -> ArithRef: ...
def __truediv__(self, other: ArithRef) -> ArithRef: ... def __truediv__(self, other: ArithRef) -> ArithRef: ...
def __mod__(self, other: ArithRef) -> ArithRef: ... def __mod__(self, other: ArithRef) -> ArithRef: ...
class BitVecSortRef(SortRef): class BitVecSortRef(SortRef): ...
...
class BitVecRef(ExprRef): class BitVecRef(ExprRef):
def size(self) -> int: ... def size(self) -> int: ...
def __add__(self, other: Union[BitVecRef, int]) -> BitVecRef: ... def __add__(self, other: Union[BitVecRef, int]) -> BitVecRef: ...
def __radd__(self, other: Union[BitVecRef, int]) -> BitVecRef: ... def __radd__(self, other: Union[BitVecRef, int]) -> BitVecRef: ...
def __mul__(self, other: Union[BitVecRef, int]) -> BitVecRef: ... def __mul__(self, other: Union[BitVecRef, int]) -> BitVecRef: ...
def __rmul__(self, other: Union[BitVecRef, int]) -> BitVecRef: ... def __rmul__(self, other: Union[BitVecRef, int]) -> BitVecRef: ...
def __sub__(self, other: Union[BitVecRef, int]) -> BitVecRef: ... def __sub__(self, other: Union[BitVecRef, int]) -> BitVecRef: ...
def __rsub__(self, other: Union[BitVecRef, int]) -> BitVecRef: ... def __rsub__(self, other: Union[BitVecRef, int]) -> BitVecRef: ...
def __or__(self, other: Union[BitVecRef, int]) -> BitVecRef: ...
def __or__(self, other: Union[BitVecRef, int]) -> BitVecRef: ... def __ror__(self, other: Union[BitVecRef, int]) -> BitVecRef: ...
def __ror__(self, other: Union[BitVecRef, int]) -> BitVecRef: ... def __and__(self, other: Union[BitVecRef, int]) -> BitVecRef: ...
def __and__(self, other: Union[BitVecRef, int]) -> BitVecRef: ... def __rand__(self, other: Union[BitVecRef, int]) -> BitVecRef: ...
def __rand__(self, other: Union[BitVecRef, int]) -> BitVecRef: ... def __xor__(self, other: Union[BitVecRef, int]) -> BitVecRef: ...
def __xor__(self, other: Union[BitVecRef, int]) -> BitVecRef: ... def __rxor__(self, other: Union[BitVecRef, int]) -> BitVecRef: ...
def __rxor__(self, other: Union[BitVecRef, int]) -> BitVecRef: ... def __pos__(self) -> BitVecRef: ...
def __pos__(self) -> BitVecRef: ... def __neg__(self) -> BitVecRef: ...
def __neg__(self) -> BitVecRef: ... def __invert__(self) -> BitVecRef: ...
def __invert__(self) -> BitVecRef: ... def __div__(self, other: BitVecRef) -> BitVecRef: ...
def __div__(self, other: BitVecRef) -> BitVecRef: ... def __rdiv__(self, other: BitVecRef) -> BitVecRef: ...
def __rdiv__(self, other: BitVecRef) -> BitVecRef: ... def __truediv__(self, other: BitVecRef) -> BitVecRef: ...
def __truediv__(self, other: BitVecRef) -> BitVecRef: ... def __rtruediv__(self, other: BitVecRef) -> BitVecRef: ...
def __rtruediv__(self, other: BitVecRef) -> BitVecRef: ... def __mod__(self, other: BitVecRef) -> BitVecRef: ...
def __mod__(self, other: BitVecRef) -> BitVecRef: ... def __rmod__(self, other: BitVecRef) -> BitVecRef: ...
def __rmod__(self, other: BitVecRef) -> BitVecRef: ... def __le__(self, other: BitVecRef) -> BoolRef: ...
def __lt__(self, other: BitVecRef) -> BoolRef: ...
def __le__(self, other: BitVecRef) -> BoolRef: ... def __ge__(self, other: BitVecRef) -> BoolRef: ...
def __lt__(self, other: BitVecRef) -> BoolRef: ... def __gt__(self, other: BitVecRef) -> BoolRef: ...
def __ge__(self, other: BitVecRef) -> BoolRef: ... def __rshift__(self, other: BitVecRef) -> BitVecRef: ...
def __gt__(self, other: BitVecRef) -> BoolRef: ... def __lshift__(self, other: BitVecRef) -> BitVecRef: ...
def __rrshift__(self, other: BitVecRef) -> BitVecRef: ...
def __rlshift__(self, other: BitVecRef) -> BitVecRef: ...
def __rshift__(self, other: BitVecRef) -> BitVecRef: ...
def __lshift__(self, other: BitVecRef) -> BitVecRef: ...
def __rrshift__(self, other: BitVecRef) -> BitVecRef: ...
def __rlshift__(self, other: BitVecRef) -> BitVecRef: ...
class BitVecNumRef(BitVecRef): class BitVecNumRef(BitVecRef):
def as_long(self) -> int: ... def as_long(self) -> int: ...
def as_signed_long(self) -> int: ... def as_signed_long(self) -> int: ...
def as_string(self) -> str: ... def as_string(self) -> str: ...
class IntNumRef(ArithRef): class IntNumRef(ArithRef):
def as_long(self) -> int: ... def as_long(self) -> int: ...
def as_string(self) -> str: ... def as_string(self) -> str: ...
class SeqSortRef(ExprRef): class SeqSortRef(ExprRef): ...
... class SeqRef(ExprRef): ...
class ReSortRef(ExprRef): ...
class SeqRef(ExprRef): class ReRef(ExprRef): ...
... class ArrayRef(ExprRef): ...
class ReSortRef(ExprRef):
...
class ReRef(ExprRef):
...
class ArrayRef(ExprRef):
...
class CheckSatResult: ... class CheckSatResult: ...
class ModelRef(Z3PPObject): class ModelRef(Z3PPObject):
def __getitem__(self, k: FuncDeclRef) -> IntNumRef: ... def __getitem__(self, k: FuncDeclRef) -> IntNumRef: ...
def decls(self) -> Iterable[FuncDeclRef]: ... def decls(self) -> Iterable[FuncDeclRef]: ...
def __iter__(self) -> Iterator[FuncDeclRef]: ... def __iter__(self) -> Iterator[FuncDeclRef]: ...
class FuncEntry: class FuncEntry:
def num_args(self) -> int: ... def num_args(self) -> int: ...
def arg_value(self, idx: int) -> ExprRef: ... def arg_value(self, idx: int) -> ExprRef: ...
def value(self) -> ExprRef: ... def value(self) -> ExprRef: ...
class FuncInterp(Z3PPObject): class FuncInterp(Z3PPObject):
def else_value(self) -> ExprRef: ... def else_value(self) -> ExprRef: ...
def num_entries(self) -> int: ... def num_entries(self) -> int: ...
def arity(self) -> int: ... def arity(self) -> int: ...
def entry(self, idx: int) -> FuncEntry: ... def entry(self, idx: int) -> FuncEntry: ...
class Goal(Z3PPObject): class Goal(Z3PPObject): ...
...
class Solver(Z3PPObject): class Solver(Z3PPObject):
ctx: Context ctx: Context
def __init__(self, ctx:Optional[Context] = None) -> None: ... def __init__(self, ctx: Optional[Context] = None) -> None: ...
def to_smt2(self) -> str: ...
def to_smt2(self) -> str: ... def check(self) -> CheckSatResult: ...
def check(self) -> CheckSatResult: ... def push(self) -> None: ...
def push(self) -> None: ... def pop(self, num: Optional[int] = 1) -> None: ...
def pop(self, num: Optional[int] = 1) -> None: ... def model(self) -> ModelRef: ...
def model(self) -> ModelRef: ... def set(self, *args: Any, **kwargs: Any) -> None: ...
def set(self, *args: Any, **kwargs: Any) -> None: ... @overload
@overload def add(self, *args: Union[BoolRef, Goal]) -> None: ...
def add(self, *args: Union[BoolRef, Goal]) -> None: ... @overload
@overload def add(self, args: List[Union[BoolRef, Goal]]) -> None: ...
def add(self, args: List[Union[BoolRef, Goal]]) -> None: ... def reset(self) -> None: ...
def reset(self) -> None: ...
class Optimize(Z3PPObject): class Optimize(Z3PPObject):
ctx: Context ctx: Context
def __init__(self, ctx:Optional[Context] = None) -> None: ... def __init__(self, ctx: Optional[Context] = None) -> None: ...
def check(self) -> CheckSatResult: ...
def check(self) -> CheckSatResult: ... def push(self) -> None: ...
def push(self) -> None: ... def pop(self) -> None: ...
def pop(self) -> None: ... def model(self) -> ModelRef: ...
def model(self) -> ModelRef: ... def set(self, *args: Any, **kwargs: Any) -> None: ...
def set(self, *args: Any, **kwargs: Any) -> None: ... @overload
@overload def add(self, *args: Union[BoolRef, Goal]) -> None: ...
def add(self, *args: Union[BoolRef, Goal]) -> None: ... @overload
@overload def add(self, args: List[Union[BoolRef, Goal]]) -> None: ...
def add(self, args: List[Union[BoolRef, Goal]]) -> None: ... def minimize(self, element: ExprRef) -> None: ...
def minimize(self, element: ExprRef) -> None: ... def maximize(self, element: ExprRef) -> None: ...
def maximize(self, element: ExprRef) -> None: ...
sat: CheckSatResult = ... sat: CheckSatResult = ...
unsat: CheckSatResult = ... unsat: CheckSatResult = ...
@overload @overload
def Int(name: str) -> ArithRef: ... def Int(name: str) -> ArithRef: ...
@overload @overload
def Int(name: str, ctx: Context) -> ArithRef: ... def Int(name: str, ctx: Context) -> ArithRef: ...
@overload @overload
def Bool(name: str) -> BoolRef: ... def Bool(name: str) -> BoolRef: ...
@overload @overload
def Bool(name: str, ctx: Context) -> BoolRef: ... def Bool(name: str, ctx: Context) -> BoolRef: ...
@overload @overload
def parse_smt2_string(s: str) -> ExprRef: ... def parse_smt2_string(s: str) -> ExprRef: ...
@overload @overload
def parse_smt2_string(s: str, ctx: Context) -> ExprRef: ... def parse_smt2_string(s: str, ctx: Context) -> ExprRef: ...
def Array(name: str, domain: SortRef, range: SortRef) -> ArrayRef: ...
def Array(name: str, domain: SortRef, range: SortRef) -> ArrayRef: ... def K(domain: SortRef, v: Union[ExprRef, int, bool, str]) -> ArrayRef: ...
def K(domain: SortRef, v: Union[ExprRef, int, bool, str]) -> ArrayRef: ...
# Can't give more precise types here since func signature is # Can't give more precise types here since func signature is
# a vararg list of ExprRef optionally followed by a Context # a vararg list of ExprRef optionally followed by a Context
def Or(*args: Any) -> BoolRef: ... def Or(*args: Any) -> BoolRef: ...
def And(*args: Any) -> BoolRef: ... def And(*args: Any) -> BoolRef: ...
def Not(p: BoolRef, ctx: Optional[Context] = None) -> BoolRef: ... def Not(p: BoolRef, ctx: Optional[Context] = None) -> BoolRef: ...
def Implies(a: BoolRef, b: BoolRef, ctx:Context) -> BoolRef: ... def Implies(a: BoolRef, b: BoolRef, ctx: Context) -> BoolRef: ...
T=TypeVar("T", bound=ExprRef) T = TypeVar("T", bound=ExprRef)
def If(a: BoolRef, b: T, c: T, ctx: Optional[Context] = None) -> T: ...
def ULE(a: T, b: T) -> BoolRef: ...
def ULT(a: T, b: T) -> BoolRef: ...
def UGE(a: T, b: T) -> BoolRef: ...
def UGT(a: T, b: T) -> BoolRef: ...
def UDiv(a: T, b: T) -> T: ...
def URem(a: T, b: T) -> T: ...
def SRem(a: T, b: T) -> T: ...
def LShR(a: T, b: T) -> T: ...
def RotateLeft(a: T, b: T) -> T: ...
def RotateRight(a: T, b: T) -> T: ...
def SignExt(n: int, a: BitVecRef) -> BitVecRef: ...
def ZeroExt(n: int, a: BitVecRef) -> BitVecRef: ...
def If(a: BoolRef, b: T, c: T, ctx: Optional[Context] = None) -> T: ...
def ULE(a: T, b: T) -> BoolRef: ...
def ULT(a: T, b: T) -> BoolRef: ...
def UGE(a: T, b: T) -> BoolRef: ...
def UGT(a: T, b: T) -> BoolRef: ...
def UDiv(a: T, b: T) -> T: ...
def URem(a: T, b: T) -> T: ...
def SRem(a: T, b: T) -> T: ...
def LShR(a: T, b: T) -> T: ...
def RotateLeft(a: T, b: T) -> T: ...
def RotateRight(a: T, b: T) -> T: ...
def SignExt(n: int, a: BitVecRef) -> BitVecRef: ...
def ZeroExt(n: int, a: BitVecRef) -> BitVecRef: ...
@overload @overload
def Concat(args: List[Union[SeqRef, str]]) -> SeqRef: ... def Concat(args: List[Union[SeqRef, str]]) -> SeqRef: ...
@overload @overload
def Concat(*args: Union[SeqRef, str]) -> SeqRef: ... def Concat(*args: Union[SeqRef, str]) -> SeqRef: ...
@overload @overload
def Concat(args: List[ReRef]) -> ReRef: ... def Concat(args: List[ReRef]) -> ReRef: ...
@overload @overload
def Concat(*args: ReRef) -> ReRef: ... def Concat(*args: ReRef) -> ReRef: ...
@overload @overload
def Concat(args: List[BitVecRef]) -> BitVecRef: ... def Concat(args: List[BitVecRef]) -> BitVecRef: ...
@overload @overload
def Concat(*args: BitVecRef) -> BitVecRef: ... def Concat(*args: BitVecRef) -> BitVecRef: ...
@overload @overload
def Extract(high: Union[SeqRef], lo: Union[int, ArithRef], a: Union[int, ArithRef]) -> SeqRef: ... def Extract(
high: Union[SeqRef], lo: Union[int, ArithRef], a: Union[int, ArithRef]
) -> SeqRef: ...
@overload @overload
def Extract(high: Union[int, ArithRef], lo: Union[int, ArithRef], a: BitVecRef) -> BitVecRef: ... def Extract(
high: Union[int, ArithRef], lo: Union[int, ArithRef], a: BitVecRef
) -> BitVecRef: ...
@overload @overload
def Sum(arg: BitVecRef, *args: Union[BitVecRef, int]) -> BitVecRef: ... def Sum(arg: BitVecRef, *args: Union[BitVecRef, int]) -> BitVecRef: ...
@overload @overload
def Sum(arg: Union[List[BitVecRef], int]) -> BitVecRef: ... def Sum(arg: Union[List[BitVecRef], int]) -> BitVecRef: ...
@overload @overload
def Sum(arg: ArithRef, *args: Union[ArithRef, int]) -> ArithRef: ... def Sum(arg: ArithRef, *args: Union[ArithRef, int]) -> ArithRef: ...
# Can't include this overload as it overlaps with the second overload.
#@overload
#def Sum(arg: Union[List[ArithRef], int]) -> ArithRef: ...
def Function(name: str, *sig: SortRef) -> FuncDeclRef: ...
def IntVal(val: int, ctx: Optional[Context] = None) -> IntNumRef: ...
def BoolVal(val: bool, ctx: Optional[Context] = None) -> BoolRef: ...
def BitVecVal(val: int, bv: Union[int, BitVecSortRef], ctx: Optional[Context] = None) -> BitVecRef: ...
def BitVec(val: str, bv: Union[int, BitVecSortRef], ctx: Optional[Context] = None) -> BitVecRef: ...
def IntSort(ctx: Optional[Context] = None) -> ArithSortRef: ...
def BoolSort(ctx:Optional[Context] = None) -> BoolSortRef: ...
def ArraySort(domain: SortRef, range: SortRef) -> ArraySortRef: ...
def BitVecSort(domain: int, ctx:Optional[Context] = None) -> BoolSortRef: ...
# Can't include this overload as it overlaps with the second overload.
# @overload
# def Sum(arg: Union[List[ArithRef], int]) -> ArithRef: ...
def Function(name: str, *sig: SortRef) -> FuncDeclRef: ...
def IntVal(val: int, ctx: Optional[Context] = None) -> IntNumRef: ...
def BoolVal(val: bool, ctx: Optional[Context] = None) -> BoolRef: ...
def BitVecVal(
val: int, bv: Union[int, BitVecSortRef], ctx: Optional[Context] = None
) -> BitVecRef: ...
def BitVec(
val: str, bv: Union[int, BitVecSortRef], ctx: Optional[Context] = None
) -> BitVecRef: ...
def IntSort(ctx: Optional[Context] = None) -> ArithSortRef: ...
def BoolSort(ctx: Optional[Context] = None) -> BoolSortRef: ...
def ArraySort(domain: SortRef, range: SortRef) -> ArraySortRef: ...
def BitVecSort(domain: int, ctx: Optional[Context] = None) -> BoolSortRef: ...
def ForAll(vs: List[ExprRef], expr: ExprRef) -> ExprRef: ... def ForAll(vs: List[ExprRef], expr: ExprRef) -> ExprRef: ...
def Select(arr: ExprRef, ind: ExprRef) -> ExprRef: ... def Select(arr: ExprRef, ind: ExprRef) -> ExprRef: ...
def Update(arr: ArrayRef, ind: ExprRef, newVal: ExprRef) -> ArrayRef: ... def Update(arr: ArrayRef, ind: ExprRef, newVal: ExprRef) -> ArrayRef: ...
def Store(arr: ArrayRef, ind: ExprRef, newVal: ExprRef) -> ArrayRef: ... def Store(arr: ArrayRef, ind: ExprRef, newVal: ExprRef) -> ArrayRef: ...
def BVAddNoOverflow(a: BitVecRef, b: BitVecRef, signed: bool) -> BoolRef: ...
def BVAddNoOverflow(a: BitVecRef, b: BitVecRef, signed: bool) -> BoolRef: ... def BVAddNoUnderflow(a: BitVecRef, b: BitVecRef) -> BoolRef: ...
def BVAddNoUnderflow(a: BitVecRef, b: BitVecRef) -> BoolRef: ... def BVSubNoOverflow(a: BitVecRef, b: BitVecRef) -> BoolRef: ...
def BVSubNoOverflow(a: BitVecRef, b: BitVecRef) -> BoolRef: ... def BVSubNoUnderflow(a: BitVecRef, b: BitVecRef, signed: bool) -> BoolRef: ...
def BVSubNoUnderflow(a: BitVecRef, b: BitVecRef, signed: bool) -> BoolRef: ... def BVSDivNoOverflow(a: BitVecRef, b: BitVecRef) -> BoolRef: ...
def BVSDivNoOverflow(a: BitVecRef, b: BitVecRef) -> BoolRef: ... def BVSNegNoOverflow(a: BitVecRef) -> BoolRef: ...
def BVSNegNoOverflow(a: BitVecRef) -> BoolRef: ... def BVMulNoOverflow(a: BitVecRef, b: BitVecRef, signed: bool) -> BoolRef: ...
def BVMulNoOverflow(a: BitVecRef, b: BitVecRef, signed: bool) -> BoolRef: ... def BVMulNoUnderflow(a: BitVecRef, b: BitVecRef) -> BoolRef: ...
def BVMulNoUnderflow(a: BitVecRef, b: BitVecRef) -> BoolRef: ...

@ -1,3 +1,4 @@
from .z3types import Ast, ContextObj from .z3types import Ast, ContextObj
def Z3_mk_eq(ctx: ContextObj, a: Ast, b: Ast) -> Ast: ... def Z3_mk_eq(ctx: ContextObj, a: Ast, b: Ast) -> Ast: ...
def Z3_mk_div(ctx: ContextObj, a: Ast, b: Ast) -> Ast: ... def Z3_mk_div(ctx: ContextObj, a: Ast, b: Ast) -> Ast: ...

@ -1,12 +1,9 @@
from typing import Any from typing import Any
class Z3Exception(Exception): class Z3Exception(Exception):
def __init__(self, a: Any) -> None: def __init__(self, a: Any) -> None:
self.value = a self.value = a
... ...
class ContextObj: class ContextObj: ...
... class Ast: ...
class Ast:
...

@ -30,7 +30,9 @@ class SymbolFactory:
"""A symbol factory provides a default interface for all the components of mythril to create symbols""" """A symbol factory provides a default interface for all the components of mythril to create symbols"""
@staticmethod @staticmethod
def Bool(value: __builtins__.bool, annotations: Annotations=None) -> Union[bool.Bool, z3.BoolRef]: def Bool(
value: __builtins__.bool, annotations: Annotations = None
) -> Union[bool.Bool, z3.BoolRef]:
""" """
Creates a Bool with concrete value Creates a Bool with concrete value
:param value: The boolean value :param value: The boolean value
@ -40,7 +42,9 @@ class SymbolFactory:
raise NotImplementedError raise NotImplementedError
@staticmethod @staticmethod
def BitVecVal(value: int, size: int, annotations: Annotations=None) -> Union[BitVec, z3.BitVecRef]: def BitVecVal(
value: int, size: int, annotations: Annotations = None
) -> Union[BitVec, z3.BitVecRef]:
"""Creates a new bit vector with a concrete value. """Creates a new bit vector with a concrete value.
:param value: The concrete value to set the bit vector to :param value: The concrete value to set the bit vector to
@ -51,7 +55,9 @@ class SymbolFactory:
raise NotImplementedError() raise NotImplementedError()
@staticmethod @staticmethod
def BitVecSym(name: str, size: int, annotations: Annotations=None) -> Union[BitVec, z3.BitVecRef]: def BitVecSym(
name: str, size: int, annotations: Annotations = None
) -> Union[BitVec, z3.BitVecRef]:
"""Creates a new bit vector with a symbolic value. """Creates a new bit vector with a symbolic value.
:param name: The name of the symbolic bit vector :param name: The name of the symbolic bit vector
@ -69,7 +75,9 @@ class _SmtSymbolFactory(SymbolFactory):
""" """
@staticmethod @staticmethod
def Bool(value: __builtins__.bool, annotations: Annotations=None) -> Union[bool.Bool, z3.BoolRef]: def Bool(
value: __builtins__.bool, annotations: Annotations = None
) -> Union[bool.Bool, z3.BoolRef]:
""" """
Creates a Bool with concrete value Creates a Bool with concrete value
:param value: The boolean value :param value: The boolean value
@ -80,13 +88,17 @@ class _SmtSymbolFactory(SymbolFactory):
return Bool(raw, annotations) return Bool(raw, annotations)
@staticmethod @staticmethod
def BitVecVal(value: int, size: int, annotations: Annotations=None) -> Union[BitVec, z3.BitVecRef]: def BitVecVal(
value: int, size: int, annotations: Annotations = None
) -> Union[BitVec, z3.BitVecRef]:
"""Creates a new bit vector with a concrete value.""" """Creates a new bit vector with a concrete value."""
raw = z3.BitVecVal(value, size) raw = z3.BitVecVal(value, size)
return BitVec(raw, annotations) return BitVec(raw, annotations)
@staticmethod @staticmethod
def BitVecSym(name: str, size: int, annotations: Annotations=None) -> Union[BitVec, z3.BitVecRef]: def BitVecSym(
name: str, size: int, annotations: Annotations = None
) -> Union[BitVec, z3.BitVecRef]:
"""Creates a new bit vector with a symbolic value.""" """Creates a new bit vector with a symbolic value."""
raw = z3.BitVec(name, size) raw = z3.BitVec(name, size)
return BitVec(raw, annotations) return BitVec(raw, annotations)
@ -99,17 +111,23 @@ class _Z3SymbolFactory(SymbolFactory):
""" """
@staticmethod @staticmethod
def Bool(value: __builtins__.bool, annotations: Annotations=None) -> Union[bool.Bool, z3.BoolRef]: def Bool(
value: __builtins__.bool, annotations: Annotations = None
) -> Union[bool.Bool, z3.BoolRef]:
""" Creates a new bit vector with a concrete value """ """ Creates a new bit vector with a concrete value """
return z3.BoolVal(value) return z3.BoolVal(value)
@staticmethod @staticmethod
def BitVecVal(value: int, size: int, annotations: Annotations=None) -> Union[BitVec, z3.BitVecRef]: def BitVecVal(
value: int, size: int, annotations: Annotations = None
) -> Union[BitVec, z3.BitVecRef]:
"""Creates a new bit vector with a concrete value.""" """Creates a new bit vector with a concrete value."""
return z3.BitVecVal(value, size) return z3.BitVecVal(value, size)
@staticmethod @staticmethod
def BitVecSym(name: str, size: int, annotations: Annotations=None) -> Union[BitVec, z3.BitVecRef]: def BitVecSym(
name: str, size: int, annotations: Annotations = None
) -> Union[BitVec, z3.BitVecRef]:
"""Creates a new bit vector with a symbolic value.""" """Creates a new bit vector with a symbolic value."""
return z3.BitVec(name, size) return z3.BitVec(name, size)

@ -13,6 +13,7 @@ from mythril.laser.smt.bitvec import BitVec
class BaseArray: class BaseArray:
"""Base array type, which implements basic store and set operations.""" """Base array type, which implements basic store and set operations."""
domain: z3.SortRef domain: z3.SortRef
range: z3.SortRef range: z3.SortRef
raw: z3.ArrayRef raw: z3.ArrayRef

@ -3,15 +3,15 @@ from typing import Optional, List, Any, TypeVar, Generic, cast
import z3 import z3
Annotations=List[Any] Annotations = List[Any]
T = TypeVar('T', bound=z3.ExprRef) T = TypeVar("T", bound=z3.ExprRef)
class Expression(Generic[T]): class Expression(Generic[T]):
"""This is the base symbol class and maintains functionality for """This is the base symbol class and maintains functionality for
simplification and annotations.""" simplification and annotations."""
def __init__(self, raw: T, annotations: Optional[Annotations]=None): def __init__(self, raw: T, annotations: Optional[Annotations] = None):
""" """
:param raw: :param raw:

@ -10,7 +10,7 @@ class Solver:
def __init__(self) -> None: def __init__(self) -> None:
"""""" """"""
self.raw = z3.Solver() # type: Union[z3.Solver, z3.Optimize] self.raw = z3.Solver() # type: Union[z3.Solver, z3.Optimize]
def set_timeout(self, timeout: int) -> None: def set_timeout(self, timeout: int) -> None:
"""Sets the timeout that will be used by this solver, timeout is in """Sets the timeout that will be used by this solver, timeout is in

Loading…
Cancel
Save