Equations
Instances For
@[instance_reducible]
@[reducible, inline]
Equations
Instances For
Equations
- Serializer.empty = { bytes := ∅, curByte := 0, bitMask := 1 }
Instances For
@[instance_reducible]
Equations
- Serializer.instEmptyCollection = { emptyCollection := Serializer.empty }
Equations
- Serializer.flush' = modify fun (s : Serializer) => { bytes := s.bytes.push s.curByte, curByte := 0, bitMask := 1 }
Instances For
Equations
- Serializer.flush = do let __do_lift ← get bif __do_lift.bitMask != 0 then pure () else Serializer.flush'
Instances For
Equations
- Serializer.finish = do let __do_lift ← get bif __do_lift.bitMask == 1 then pure () else Serializer.flush'
Instances For
Equations
Instances For
Equations
Instances For
Equations
- Serializer.getOutput = do Serializer.finish gets fun (x : Serializer) => x.bytes
Instances For
Equations
- Serializer.ofBits bs = (StateT.run (Serializer.writeBits bs) ∅).2
Instances For
@[simp]
@[simp]
@[simp]
@[simp]
theorem
Serializer.writeBit_eq_of_lt
{s : Serializer}
{b : Bit}
(n : ℕ)
(h₁ : s.bitMask = 1 <<< UInt8.ofNat n)
(h₂ : n ≤ 6)
:
StateT.run (writeBit b) s = ((), { bytes := s.bytes, curByte := s.curByte ||| UInt8.ofBit b <<< UInt8.ofNat n,
bitMask := 1 <<< UInt8.ofNat (n + 1) })
theorem
Serializer.writeBits_eq_of_lt
{s : Serializer}
{bs : List Bit}
(n : ℕ)
(h₁ : s.bitMask = 1 <<< UInt8.ofNat n)
(h₂ : n + bs.length ≤ 7)
:
StateT.run (writeBits bs) s = ((), { bytes := s.bytes, curByte := s.curByte ||| UInt8.ofBits bs <<< UInt8.ofNat n,
bitMask := 1 <<< UInt8.ofNat (n + bs.length) })