Documentation

Std.Data.BitVec.Bitblast

Bitblasting of bitvectors #

This module provides theorems for showing the equivalence between BitVec operations using the Fin 2^n representation and Boolean vectors. It is still under development, but intended to provide a path for converting SAT and SMT solver proofs about BitVectors as vectors of bits into proofs about Lean BitVec values.

The module is named for the bit-blasting operation in an SMT solver that converts bitvector expressions into expressions about individual bits in each vector.

Main results #

Future work #

All other operations are to be PR'ed later and are already proved in https://github.com/mhk119/lean-smt/blob/bitvec/Smt/Data/BitVec.lean.

Preliminaries #

Addition #

def Std.BitVec.carry (w : Nat) (x : Nat) (y : Nat) (c : Bool) :

carry w x y c returns true if the w carry bit is true when computing x + y + c.

Equations
Instances For
    @[simp]
    theorem Std.BitVec.carry_zero {x : Nat} {y : Nat} {c : Bool} :
    def Std.BitVec.adcb (x : Bool) (y : Bool) (c : Bool) :

    Carry function for bitwise addition.

    Equations
    Instances For
      def Std.BitVec.adc {w : Nat} (x : Std.BitVec w) (y : Std.BitVec w) :

      Bitwise addition implemented via a ripple carry adder.

      Equations
      Instances For
        theorem Std.BitVec.adc_overflow_limit (x : Nat) (y : Nat) (i : Nat) (c : Bool) :
        x % 2 ^ i + (y % 2 ^ i + Bool.toNat c) < 2 ^ (i + 1)
        theorem Std.BitVec.add_as_adc (w : Nat) (x : Std.BitVec w) (y : Std.BitVec w) :
        x + y = (Std.BitVec.adc x y false).snd