Equations
- bitvec.one n.succ = (vector.repeat bool.ff n).append (bool.tt :: vector.nil)
- bitvec.one 0 = vector.nil
Equations
- bitvec.cong h ⟨x, p⟩ = ⟨x, _⟩
Equations
Equations
- x.shl i = bitvec.cong _ ((vector.drop i x).append (vector.repeat bool.ff (min n i)))
Equations
- x.fill_shr i fill = bitvec.cong _ ((vector.repeat fill (min n i)).append (vector.take (n - i) x))
Equations
- x.sshr i = vector.head x :: bitvec.fill_shr (vector.tail x) i (vector.head x)
- _x.sshr _x_1 = vector.nil
Equations
Equations
Equations
@[instance]
Equations
- bitvec.has_zero = {zero := bitvec.zero n}
@[instance]
Equations
- bitvec.has_one = {one := bitvec.one n}
@[instance]
Equations
- bitvec.has_add = {add := bitvec.add n}
@[instance]
Equations
- bitvec.has_sub = {sub := bitvec.sub n}
@[instance]
Equations
- bitvec.has_neg = {neg := bitvec.neg n}
@[instance]
Equations
- bitvec.has_mul = {mul := bitvec.mul n}
Equations
- x.sborrow y = bitvec.sborrow._match_1 n x y (vector.head x, vector.head y)
- _x.sborrow _x_1 = bool.ff
- bitvec.sborrow._match_1 n x y (bool.tt, bool.tt) = bitvec.uborrow (vector.tail x) (vector.tail y)
- bitvec.sborrow._match_1 n x y (bool.tt, bool.ff) = bool.tt
- bitvec.sborrow._match_1 n x y (bool.ff, bool.tt) = bool.ff
- bitvec.sborrow._match_1 n x y (bool.ff, bool.ff) = bitvec.uborrow (vector.tail x) (vector.tail y)
Equations
- bitvec.of_nat n.succ x = vector.append (bitvec.of_nat n (x / 2)) (decidable.to_bool (x % 2 = 1) :: vector.nil)
- bitvec.of_nat 0 x = vector.nil
Equations
- bitvec.of_int n -[1+ m] = bool.tt :: (bitvec.of_nat n m).not
- bitvec.of_int n (int.of_nat m) = bool.ff :: bitvec.of_nat n m
Equations
Equations
theorem
bitvec.to_nat_append
{m : ℕ}
(xs : bitvec m)
(b : bool) :
bitvec.to_nat (vector.append xs (b :: vector.nil)) = xs.to_nat * 2 + bitvec.to_nat (b :: vector.nil)
theorem
bitvec.bits_to_nat_to_bool
(n : ℕ) :
bitvec.to_nat (decidable.to_bool (n % 2 = 1) :: vector.nil) = n % 2
theorem
bitvec.of_nat_succ
{k n : ℕ} :
bitvec.of_nat k.succ n = vector.append (bitvec.of_nat k (n / 2)) (decidable.to_bool (n % 2 = 1) :: vector.nil)
Equations
- v.to_int = cond (vector.head v) -[1+ (bitvec.not (vector.tail v)).to_nat] (int.of_nat (bitvec.to_nat (vector.tail v)))
- _x.to_int = 0
@[instance]
Equations
- bitvec.has_repr n = {repr := repr n}
@[instance]
Equations
@[instance]