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 @@ -29,11 +29,7 @@ structure AdderResult where
2929 carry : Circuit
3030
3131def 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/--
3935Add 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.
Original file line number Diff line number Diff line change @@ -14,17 +14,21 @@ deriving Inhabited, Repr
1414
1515namespace Column
1616
17+ def contains (col : Column) (c : Circuit) : Bool :=
18+ col.elems.contains c
19+
1720def 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+
1925def 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
2933end Column
3034
You can’t perform that action at this time.
0 commit comments