File tree Expand file tree Collapse file tree
DatapathVerification/BitHeap Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -15,6 +15,8 @@ namespace BitHeap
1515open Circuit
1616open Column
1717
18+ def empty : BitHeap := ⟨Std.HashMap.emptyWithCapacity 0 ⟩
19+
1820/--
1921Evaluate a bit-heap, to compute the final sum of all the bits in the heap.
2022-/
@@ -34,8 +36,6 @@ def get (h : BitHeap) (i : Index) : Circuit :=
3436 | none => Circuit.const false
3537 | some col => (col.getD i.index (Circuit.const false ))
3638
37- def empty : BitHeap := ⟨Std.HashMap.emptyWithCapacity 0 ⟩
38-
3939/--
4040Add a bit into the bit heap, returning a new bit heap, and an index to the added bit.
4141-/
@@ -47,14 +47,6 @@ def addBit (h : BitHeap) (c : Circuit) (w : Nat) : BitHeap × Index :=
4747def removeBit (h : BitHeap) (i : Index) : BitHeap :=
4848 ⟨h.columns.modify i.column (fun col => ⟨col.elems.eraseIdx i.index⟩)⟩
4949
50- def addBitsExample : BitHeap :=
51- let h := BitHeap.empty
52- let (h, _) := h.addBit (Circuit.bit 0 ) 0 -- add a bit in column 0
53- let (h, _) := h.addBit (Circuit.bit 1 ) 1 -- add a bit in column 1
54- let (h, _) := h.addBit (Circuit.bit 1 ) 1 -- add another bit in column 1
55- let h := h.removeBit (Index.mk 0 0 ) -- remove the bit in column 0
56- h
57-
5850structure AdderResult where
5951 heap : BitHeap
6052 sumIndex : Index
Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ def empty : Column := ⟨[]⟩
1717
1818def insert (col : Column) (c : Circuit): Column × Nat :=
1919 let newIndex := col.elems.length
20- let col := ⟨c :: col.elems⟩
20+ let col := ⟨col.elems ++ [c] ⟩
2121 (col, newIndex)
2222
2323def eval (col : Column) (env : BitEnv) : Nat :=
You can’t perform that action at this time.
0 commit comments