Skip to content

Commit 32af6b4

Browse files
committed
example
1 parent 98157e3 commit 32af6b4

2 files changed

Lines changed: 3 additions & 11 deletions

File tree

DatapathVerification/BitHeap/BitHeap.lean

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ namespace BitHeap
1515
open Circuit
1616
open Column
1717

18+
def empty : BitHeap := ⟨Std.HashMap.emptyWithCapacity 0
19+
1820
/--
1921
Evaluate 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
/--
4040
Add 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 :=
4747
def 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-
5850
structure AdderResult where
5951
heap : BitHeap
6052
sumIndex : Index

DatapathVerification/BitHeap/Column.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def empty : Column := ⟨[]⟩
1717

1818
def 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

2323
def eval (col : Column) (env : BitEnv) : Nat :=

0 commit comments

Comments
 (0)