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.
The variable definition used by the bitblaster.
Equations
Equations
All supported binary operations on BVExpr
.
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 = "%ᵤ"
Equations
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
All supported unary operators on BVExpr
.
Equations
Equations
- Std.Tactic.BVDecide.BVUnOp.not.toString = "~"
- (Std.Tactic.BVDecide.BVUnOp.rotateLeft a).toString = toString "rotL " ++ toString a ++ toString ""
- (Std.Tactic.BVDecide.BVUnOp.rotateRight a).toString = toString "rotR " ++ toString a ++ toString ""
- (Std.Tactic.BVDecide.BVUnOp.arithShiftRightConst a).toString = toString ">>a " ++ toString a ++ toString ""
- Std.Tactic.BVDecide.BVUnOp.reverse.toString = "rev"
- Std.Tactic.BVDecide.BVUnOp.clz.toString = "clz"
Equations
The semantics for BVUnOp
.
Equations
- Std.Tactic.BVDecide.BVUnOp.not.eval = fun (x : BitVec w) => ~~~x
- (Std.Tactic.BVDecide.BVUnOp.rotateLeft a).eval = fun (x : BitVec w) => x.rotateLeft a
- (Std.Tactic.BVDecide.BVUnOp.rotateRight a).eval = fun (x : BitVec w) => x.rotateRight a
- (Std.Tactic.BVDecide.BVUnOp.arithShiftRightConst a).eval = fun (x : BitVec w) => x.sshiftRight a
- Std.Tactic.BVDecide.BVUnOp.reverse.eval = BitVec.reverse
- Std.Tactic.BVDecide.BVUnOp.clz.eval = BitVec.clz
All supported expressions involving BitVec
and operations on them.
- var
{w : Nat}
(idx : Nat)
: BVExpr w
A
BitVec
variable, referred to through an index. - const
{w : Nat}
(val : BitVec w)
: BVExpr w
A constant
BitVec
value. - extract
{w : Nat}
(start len : Nat)
(expr : BVExpr w)
: BVExpr len
Extract a slice from a
BitVec
. - bin
{w : Nat}
(lhs : BVExpr w)
(op : BVBinOp)
(rhs : BVExpr w)
: BVExpr w
A binary operation on two
BVExpr
. - un
{w : Nat}
(op : BVUnOp)
(operand : BVExpr w)
: BVExpr w
A unary operation on two
BVExpr
. - append
{l r w : Nat}
(lhs : BVExpr l)
(rhs : BVExpr r)
(h : w = l + r)
: BVExpr w
Concatenate two bitvectors.
- replicate
{w w' : Nat}
(n : Nat)
(expr : BVExpr w)
(h : w' = w * n)
: BVExpr w'
Concatenate a bitvector with itself
n
times. - shiftLeft
{m n : Nat}
(lhs : BVExpr m)
(rhs : BVExpr n)
: BVExpr m
shift left by another BitVec expression. For constant shifts there exists a
BVUnop
. - shiftRight
{m n : Nat}
(lhs : BVExpr m)
(rhs : BVExpr n)
: BVExpr m
shift right by another BitVec expression. For constant shifts there exists a
BVUnop
. - arithShiftRight
{m n : Nat}
(lhs : BVExpr m)
(rhs : BVExpr n)
: BVExpr m
shift right arithmetically by another BitVec expression. For constant shifts there exists a
BVUnop
.
Equations
- One or more equations did not get rendered due to their size.
- Std.Tactic.BVDecide.BVExpr.hashCode x✝ (Std.Tactic.BVDecide.BVExpr.var idx) = mixHash 5 (mixHash (hash x✝) (hash idx))
- Std.Tactic.BVDecide.BVExpr.hashCode x✝ (Std.Tactic.BVDecide.BVExpr.const val) = mixHash 7 (mixHash (hash x✝) (hash val))
- Std.Tactic.BVDecide.BVExpr.hashCode x✝ (Std.Tactic.BVDecide.BVExpr.extract start x✝ expr) = mixHash 11 (mixHash (hash start) (mixHash (hash x✝) (Std.Tactic.BVDecide.BVExpr.hashCode w_1 expr)))
- Std.Tactic.BVDecide.BVExpr.hashCode x✝ (Std.Tactic.BVDecide.BVExpr.un op operand) = mixHash 17 (mixHash (hash x✝) (mixHash (hash op) (Std.Tactic.BVDecide.BVExpr.hashCode x✝ operand)))
- Std.Tactic.BVDecide.BVExpr.hashCode x✝ (Std.Tactic.BVDecide.BVExpr.replicate n expr h) = mixHash 23 (mixHash (hash x✝) (mixHash (hash n) (Std.Tactic.BVDecide.BVExpr.hashCode w_1 expr)))
Equations
- Std.Tactic.BVDecide.BVExpr.instHashable = { hash := fun (expr : Std.Tactic.BVDecide.BVExpr w) => Std.Tactic.BVDecide.BVExpr.hashCode w expr }
Equations
- One or more equations did not get rendered due to their size.
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.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 h).toString = toString "(" ++ toString lhs.toString ++ toString " ++ " ++ toString rhs.toString ++ toString ")"
- (Std.Tactic.BVDecide.BVExpr.replicate n expr h).toString = toString "(replicate " ++ toString n ++ 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 ")"
Equations
The notion of variable assignments for BVExpr
.
Get the value of a BVExpr.var
from an Assignment
.
Equations
- assign.get idx = Lean.RArray.get assign idx
The semantics for BVExpr
.
Equations
- Std.Tactic.BVDecide.BVExpr.eval assign (Std.Tactic.BVDecide.BVExpr.var idx) = if h : (assign.get idx).w = w then h ▸ (assign.get idx).bv else BitVec.truncate w (assign.get idx).bv
- Std.Tactic.BVDecide.BVExpr.eval assign (Std.Tactic.BVDecide.BVExpr.const val) = val
- 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 h) = ⋯ ▸ (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 h) = ⋯ ▸ BitVec.replicate n (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)
Supported binary predicates on BVExpr
.
Equations
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
Supported predicates on BVExpr
.
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
Boolean substructure of problems involving predicates on BitVec as atoms.
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
Equations
- x.Sat assign = (Std.Tactic.BVDecide.BVLogicalExpr.eval assign x = true)