Skip to content

Commit b97a996

Browse files
committed
clean
1 parent f9e54f7 commit b97a996

2 files changed

Lines changed: 10 additions & 10 deletions

File tree

DatapathVerification/BitHeap/BitHeap.lean

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,7 @@ structure AdderResult where
2929
carry : Circuit
3030

3131
def removeBit (column : Nat) (c : Circuit) (h : BitHeap) : BitHeap :=
32-
⟨h.columns.modify column (fun col => ⟨col.elems.erase c⟩)⟩
33-
34-
def columnsWithFrom (column : Nat) (c : Circuit) (h : BitHeap) : Nat :=
35-
h.columns.fold (fun acc k col =>
36-
if k ≥ column && col.contains c then acc + 1 else acc) 0
32+
⟨h.columns.modify column (fun col => col.erase c)⟩
3733

3834
/--
3935
Add a bit into the bit heap, returning a new bit heap. If the bit already exists in the column, remove it and add it to the next column.

DatapathVerification/BitHeap/Column.lean

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,21 @@ deriving Inhabited, Repr
1414

1515
namespace Column
1616

17+
def contains (col : Column) (c : Circuit) : Bool :=
18+
col.elems.contains c
19+
1720
def empty : Column := ⟨Std.HashSet.emptyWithCapacity 0
1821

22+
def eval (col : Column) (env : BitEnv) : Nat :=
23+
(col.elems.fold (init := 0) (fun acc (c : Circuit) => acc + (c.eval env).toNat))
24+
1925
def insert (col : Column) (c : Circuit) : Column :=
2026
let col := ⟨col.elems.insert c⟩
2127
col
2228

23-
def contains (col : Column) (c : Circuit) : Bool :=
24-
col.elems.contains c
25-
26-
def eval (col : Column) (env : BitEnv) : Nat :=
27-
(col.elems.fold (init := 0) (fun acc (c : Circuit) => acc + (c.eval env).toNat))
29+
def erase (col : Column) (c : Circuit) : Column :=
30+
let col := ⟨col.elems.erase c⟩
31+
col
2832

2933
end Column
3034

0 commit comments

Comments
 (0)