This module contains the definition of the BitVec
fragment that bv_decide
internally operates
on as BVLogicalExpr
. The preprocessing steps of bv_decide
reduce all supported BitVec
operations to the ones provided in this file. For verification purposes BVLogicalExpr.Sat
and
BVLogicalExpr.Unsat
are provided.
Equations
- Std.Tactic.BVDecide.instReprBVBit = { reprPrec := Std.Tactic.BVDecide.reprBVBit✝ }
Equations
- Std.Tactic.BVDecide.instInhabitedBVBit = { default := Std.Tactic.BVDecide.BVBit.mk 0 0 }
All supported binary operations on BVExpr
.
- and : Std.Tactic.BVDecide.BVBinOp
Bitwise and.
- or : Std.Tactic.BVDecide.BVBinOp
Bitwise or.
- xor : Std.Tactic.BVDecide.BVBinOp
Bitwise xor.
- add : Std.Tactic.BVDecide.BVBinOp
Addition.
- mul : Std.Tactic.BVDecide.BVBinOp
Multiplication.
- udiv : Std.Tactic.BVDecide.BVBinOp
Unsigned division.
- umod : Std.Tactic.BVDecide.BVBinOp
Unsigned modulo.
Instances For
Equations
- Std.Tactic.BVDecide.BVBinOp.and.toString = "&&"
- Std.Tactic.BVDecide.BVBinOp.or.toString = "||"
- Std.Tactic.BVDecide.BVBinOp.xor.toString = "^"
- Std.Tactic.BVDecide.BVBinOp.add.toString = "+"
- Std.Tactic.BVDecide.BVBinOp.mul.toString = "*"
- Std.Tactic.BVDecide.BVBinOp.udiv.toString = "/ᵤ"
- Std.Tactic.BVDecide.BVBinOp.umod.toString = "%ᵤ"
Instances For
The semantics for BVBinOp
.
Equations
- Std.Tactic.BVDecide.BVBinOp.and.eval = fun (x1 x2 : BitVec w) => x1 &&& x2
- Std.Tactic.BVDecide.BVBinOp.or.eval = fun (x1 x2 : BitVec w) => x1 ||| x2
- Std.Tactic.BVDecide.BVBinOp.xor.eval = fun (x1 x2 : BitVec w) => x1 ^^^ x2
- Std.Tactic.BVDecide.BVBinOp.add.eval = fun (x1 x2 : BitVec w) => x1 + x2
- Std.Tactic.BVDecide.BVBinOp.mul.eval = fun (x1 x2 : BitVec w) => x1 * x2
- Std.Tactic.BVDecide.BVBinOp.udiv.eval = fun (x1 x2 : BitVec w) => x1 / x2
- Std.Tactic.BVDecide.BVBinOp.umod.eval = fun (x1 x2 : BitVec w) => x1 % x2
Instances For
All supported unary operators on BVExpr
.
- not : Std.Tactic.BVDecide.BVUnOp
Bitwise not.
- shiftLeftConst (n : Nat) : Std.Tactic.BVDecide.BVUnOp
- shiftRightConst (n : Nat) : Std.Tactic.BVDecide.BVUnOp
- rotateLeft
(n : Nat)
: Std.Tactic.BVDecide.BVUnOp
Rotating left by a constant value.
- rotateRight
(n : Nat)
: Std.Tactic.BVDecide.BVUnOp
Rotating right by a constant value.
- arithShiftRightConst (n : Nat) : Std.Tactic.BVDecide.BVUnOp
Instances For
Equations
- Std.Tactic.BVDecide.BVUnOp.not.toString = "~"
- (Std.Tactic.BVDecide.BVUnOp.shiftLeftConst n).toString = toString "<< " ++ toString n ++ toString ""
- (Std.Tactic.BVDecide.BVUnOp.shiftRightConst n).toString = toString ">> " ++ toString n ++ toString ""
- (Std.Tactic.BVDecide.BVUnOp.rotateLeft n).toString = toString "rotL " ++ toString n ++ toString ""
- (Std.Tactic.BVDecide.BVUnOp.rotateRight n).toString = toString "rotR " ++ toString n ++ toString ""
- (Std.Tactic.BVDecide.BVUnOp.arithShiftRightConst n).toString = toString ">>a " ++ toString n ++ toString ""
Instances For
Equations
The semantics for BVUnOp
.
Equations
- Std.Tactic.BVDecide.BVUnOp.not.eval = fun (x : BitVec w) => ~~~x
- (Std.Tactic.BVDecide.BVUnOp.shiftLeftConst n).eval = fun (x : BitVec w) => x <<< n
- (Std.Tactic.BVDecide.BVUnOp.shiftRightConst n).eval = fun (x : BitVec w) => x >>> n
- (Std.Tactic.BVDecide.BVUnOp.rotateLeft n).eval = fun (x : BitVec w) => x.rotateLeft n
- (Std.Tactic.BVDecide.BVUnOp.rotateRight n).eval = fun (x : BitVec w) => x.rotateRight n
- (Std.Tactic.BVDecide.BVUnOp.arithShiftRightConst n).eval = fun (x : BitVec w) => x.sshiftRight n
Instances For
All supported expressions involving BitVec
and operations on them.
- var
{w : Nat}
(idx : Nat)
: Std.Tactic.BVDecide.BVExpr w
A
BitVec
variable, referred to through an index. - const
{w : Nat}
(val : BitVec w)
: Std.Tactic.BVDecide.BVExpr w
A constant
BitVec
value. - zeroExtend
{w : Nat}
(v : Nat)
(expr : Std.Tactic.BVDecide.BVExpr w)
: Std.Tactic.BVDecide.BVExpr v
zero extend a
BitVec
by some constant amount. - extract
{w : Nat}
(start len : Nat)
(expr : Std.Tactic.BVDecide.BVExpr w)
: Std.Tactic.BVDecide.BVExpr len
Extract a slice from a
BitVec
. - bin
{w : Nat}
(lhs : Std.Tactic.BVDecide.BVExpr w)
(op : Std.Tactic.BVDecide.BVBinOp)
(rhs : Std.Tactic.BVDecide.BVExpr w)
: Std.Tactic.BVDecide.BVExpr w
A binary operation on two
BVExpr
. - un
{w : Nat}
(op : Std.Tactic.BVDecide.BVUnOp)
(operand : Std.Tactic.BVDecide.BVExpr w)
: Std.Tactic.BVDecide.BVExpr w
A unary operation on two
BVExpr
. - append
{l r : Nat}
(lhs : Std.Tactic.BVDecide.BVExpr l)
(rhs : Std.Tactic.BVDecide.BVExpr r)
: Std.Tactic.BVDecide.BVExpr (l + r)
Concatenate two bit vectors.
- replicate
{w : Nat}
(n : Nat)
(expr : Std.Tactic.BVDecide.BVExpr w)
: Std.Tactic.BVDecide.BVExpr (w * n)
Concatenate a bit vector with itself
n
times. - signExtend
{w : Nat}
(v : Nat)
(expr : Std.Tactic.BVDecide.BVExpr w)
: Std.Tactic.BVDecide.BVExpr v
sign extend a
BitVec
by some constant amount. - shiftLeft
{m n : Nat}
(lhs : Std.Tactic.BVDecide.BVExpr m)
(rhs : Std.Tactic.BVDecide.BVExpr n)
: Std.Tactic.BVDecide.BVExpr m
shift left by another BitVec expression. For constant shifts there exists a
BVUnop
. - shiftRight
{m n : Nat}
(lhs : Std.Tactic.BVDecide.BVExpr m)
(rhs : Std.Tactic.BVDecide.BVExpr n)
: Std.Tactic.BVDecide.BVExpr m
shift right by another BitVec expression. For constant shifts there exists a
BVUnop
. - arithShiftRight
{m n : Nat}
(lhs : Std.Tactic.BVDecide.BVExpr m)
(rhs : Std.Tactic.BVDecide.BVExpr n)
: Std.Tactic.BVDecide.BVExpr m
shift right arithmetically by another BitVec expression. For constant shifts there exists a
BVUnop
.
Instances For
Equations
- (Std.Tactic.BVDecide.BVExpr.var idx).toString = toString "var" ++ toString idx ++ toString ""
- (Std.Tactic.BVDecide.BVExpr.const val).toString = toString val
- (Std.Tactic.BVDecide.BVExpr.zeroExtend w expr).toString = toString "(zext " ++ toString w ++ toString " " ++ toString expr.toString ++ toString ")"
- (Std.Tactic.BVDecide.BVExpr.extract start w expr).toString = toString "" ++ toString expr.toString ++ toString "[" ++ toString start ++ toString ", " ++ toString w ++ toString "]"
- (lhs.bin op rhs).toString = toString "(" ++ toString lhs.toString ++ toString " " ++ toString op.toString ++ toString " " ++ toString rhs.toString ++ toString ")"
- (Std.Tactic.BVDecide.BVExpr.un op operand).toString = toString "(" ++ toString op.toString ++ toString " " ++ toString operand.toString ++ toString ")"
- (lhs.append rhs).toString = toString "(" ++ toString lhs.toString ++ toString " ++ " ++ toString rhs.toString ++ toString ")"
- (Std.Tactic.BVDecide.BVExpr.replicate n expr).toString = toString "(replicate " ++ toString n ++ toString " " ++ toString expr.toString ++ toString ")"
- (Std.Tactic.BVDecide.BVExpr.signExtend w expr).toString = toString "(sext " ++ toString w ++ toString " " ++ toString expr.toString ++ toString ")"
- (lhs.shiftLeft rhs).toString = toString "(" ++ toString lhs.toString ++ toString " << " ++ toString rhs.toString ++ toString ")"
- (lhs.shiftRight rhs).toString = toString "(" ++ toString lhs.toString ++ toString " >> " ++ toString rhs.toString ++ toString ")"
- (lhs.arithShiftRight rhs).toString = toString "(" ++ toString lhs.toString ++ toString " >>a " ++ toString rhs.toString ++ toString ")"
Instances For
Equations
- Std.Tactic.BVDecide.BVExpr.instToString = { toString := Std.Tactic.BVDecide.BVExpr.toString }
Get the value of a BVExpr.var
from an Assignment
.
Equations
- assign.getD idx = List.getD assign idx (Std.Tactic.BVDecide.BVExpr.PackedBitVec.mk (BitVec.zero 0))
Instances For
The semantics for BVExpr
.
Equations
- Std.Tactic.BVDecide.BVExpr.eval assign (Std.Tactic.BVDecide.BVExpr.var idx) = match assign.getD idx with | Std.Tactic.BVDecide.BVExpr.PackedBitVec.mk bv => BitVec.truncate w bv
- Std.Tactic.BVDecide.BVExpr.eval assign (Std.Tactic.BVDecide.BVExpr.const val) = val
- Std.Tactic.BVDecide.BVExpr.eval assign (Std.Tactic.BVDecide.BVExpr.zeroExtend w expr) = BitVec.zeroExtend w (Std.Tactic.BVDecide.BVExpr.eval assign expr)
- Std.Tactic.BVDecide.BVExpr.eval assign (Std.Tactic.BVDecide.BVExpr.extract start w expr) = BitVec.extractLsb' start w (Std.Tactic.BVDecide.BVExpr.eval assign expr)
- Std.Tactic.BVDecide.BVExpr.eval assign (lhs.bin op rhs) = op.eval (Std.Tactic.BVDecide.BVExpr.eval assign lhs) (Std.Tactic.BVDecide.BVExpr.eval assign rhs)
- Std.Tactic.BVDecide.BVExpr.eval assign (Std.Tactic.BVDecide.BVExpr.un op operand) = op.eval (Std.Tactic.BVDecide.BVExpr.eval assign operand)
- Std.Tactic.BVDecide.BVExpr.eval assign (lhs.append rhs) = Std.Tactic.BVDecide.BVExpr.eval assign lhs ++ Std.Tactic.BVDecide.BVExpr.eval assign rhs
- Std.Tactic.BVDecide.BVExpr.eval assign (Std.Tactic.BVDecide.BVExpr.replicate n expr) = BitVec.replicate n (Std.Tactic.BVDecide.BVExpr.eval assign expr)
- Std.Tactic.BVDecide.BVExpr.eval assign (Std.Tactic.BVDecide.BVExpr.signExtend w expr) = BitVec.signExtend w (Std.Tactic.BVDecide.BVExpr.eval assign expr)
- Std.Tactic.BVDecide.BVExpr.eval assign (lhs.shiftLeft rhs) = Std.Tactic.BVDecide.BVExpr.eval assign lhs <<< Std.Tactic.BVDecide.BVExpr.eval assign rhs
- Std.Tactic.BVDecide.BVExpr.eval assign (lhs.shiftRight rhs) = Std.Tactic.BVDecide.BVExpr.eval assign lhs >>> Std.Tactic.BVDecide.BVExpr.eval assign rhs
- Std.Tactic.BVDecide.BVExpr.eval assign (lhs.arithShiftRight rhs) = (Std.Tactic.BVDecide.BVExpr.eval assign lhs).sshiftRight' (Std.Tactic.BVDecide.BVExpr.eval assign rhs)
Instances For
Supported binary predicates on BVExpr
.
- eq : Std.Tactic.BVDecide.BVBinPred
Equality.
- ult : Std.Tactic.BVDecide.BVBinPred
Unsigned Less Than
Instances For
Equations
- Std.Tactic.BVDecide.BVBinPred.eq.toString = "=="
- Std.Tactic.BVDecide.BVBinPred.ult.toString = "<u"
Instances For
The semantics for BVBinPred
.
Equations
- Std.Tactic.BVDecide.BVBinPred.eq.eval = fun (x1 x2 : BitVec w) => x1 == x2
- Std.Tactic.BVDecide.BVBinPred.ult.eval = BitVec.ult
Instances For
Supported predicates on BVExpr
.
- bin
{w : Nat}
(lhs : Std.Tactic.BVDecide.BVExpr w)
(op : Std.Tactic.BVDecide.BVBinPred)
(rhs : Std.Tactic.BVDecide.BVExpr w)
: Std.Tactic.BVDecide.BVPred
A binary predicate on
BVExpr
. - getLsbD
{w : Nat}
(expr : Std.Tactic.BVDecide.BVExpr w)
(idx : Nat)
: Std.Tactic.BVDecide.BVPred
Getting a constant LSB from a
BitVec
.
Instances For
Pack two BVExpr
of equivalent width into one parameter-less structure.
- w : Nat
- lhs : Std.Tactic.BVDecide.BVExpr self.w
- rhs : Std.Tactic.BVDecide.BVExpr self.w
Instances For
Equations
Instances For
Equations
The semantics for BVPred
.
Equations
- Std.Tactic.BVDecide.BVPred.eval assign (Std.Tactic.BVDecide.BVPred.bin lhs op rhs) = op.eval (Std.Tactic.BVDecide.BVExpr.eval assign lhs) (Std.Tactic.BVDecide.BVExpr.eval assign rhs)
- Std.Tactic.BVDecide.BVPred.eval assign (Std.Tactic.BVDecide.BVPred.getLsbD expr idx) = (Std.Tactic.BVDecide.BVExpr.eval assign expr).getLsbD idx
Instances For
Boolean substructure of problems involving predicates on BitVec as atoms.
Equations
Instances For
The semantics of boolean problems involving BitVec predicates as atoms.
Equations
- Std.Tactic.BVDecide.BVLogicalExpr.eval assign expr = Std.Tactic.BVDecide.BoolExpr.eval (fun (x : Std.Tactic.BVDecide.BVPred) => Std.Tactic.BVDecide.BVPred.eval assign x) expr
Instances For
Equations
- x.Sat assign = (Std.Tactic.BVDecide.BVLogicalExpr.eval assign x = true)
Instances For
Equations
- x.Unsat = ∀ (f : Std.Tactic.BVDecide.BVExpr.Assignment), Std.Tactic.BVDecide.BVLogicalExpr.eval f x = false