Skip to content

feat: Use hashmap in bit heap#11

Merged
osmanyasar05 merged 11 commits into
mainfrom
hashmap
May 11, 2026
Merged

feat: Use hashmap in bit heap#11
osmanyasar05 merged 11 commits into
mainfrom
hashmap

Conversation

@osmanyasar05
Copy link
Copy Markdown
Collaborator

This PR modifies the bit heap structure so that it now uses hash maps, instead of holding a list of lists.

For now, the columns still hold a List, but we might also change those to use hashsets/arrays.

Comment thread DatapathVerification/BitheapWithCircuit.lean Outdated
Comment thread DatapathVerification/BitheapWithCircuit.lean Outdated
Comment thread DatapathVerification/BitheapWithCircuit.lean Outdated
Copy link
Copy Markdown

@bollu bollu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good so far! I requested changes to (a) fix the asymptotics of insert, and (b) use Circuit.const false as a default value, and (c) to make remove robust to the index not existing. This should help make the library API feel nicer to use.

Comment thread DatapathVerification/BitheapWithCircuit.lean Outdated
Copy link
Copy Markdown

@bollu bollu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're getting there. I request a more idiomatic way of writing get and removeBit so that they'll be easier to prove.

Comment thread DatapathVerification/BitheapWithCircuit.lean Outdated
Comment thread DatapathVerification/BitheapWithCircuit.lean Outdated
Comment thread DatapathVerification/BitheapWithCircuit.lean Outdated
Comment thread DatapathVerification/BitheapWithCircuit.lean Outdated
Copy link
Copy Markdown

@bollu bollu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Almost! I requested a change to addBit where I noticed that we don't compute a index uniquely for a column. I'm happy with everything else

Comment thread DatapathVerification/BitheapWithCircuit.lean Outdated
@bollu bollu self-requested a review May 8, 2026 15:31
Comment thread DatapathVerification/BitheapWithCircuit.lean Outdated
Comment thread DatapathVerification/BitheapWithCircuit.lean Outdated
@bollu
Copy link
Copy Markdown

bollu commented May 8, 2026

Great, can you now split this into multiple files? Example, BitHeap/Basic.lean, BitHeap/FullAdder.lean, BitHeap/Examples.lean, and a toplevel BitHeap.lean that imports all of these, so that running a lake build builds everything? Follow veir style

Comment thread DatapathVerification/BitHeap/BitHeap.lean Outdated
Comment thread DatapathVerification/BitHeap/BitHeap.lean Outdated
Comment thread DatapathVerification/BitHeap/Column.lean Outdated
@bollu
Copy link
Copy Markdown

bollu commented May 11, 2026

@osmanyasar05 when we change from List to HashSet, the API will no longer have an index associated to each column. So, maybe we should anticipate this, and change our API to make use of List.insert and List.erase? Then, addBit will have type addBit (column : Nat) (c : Circuit) (h : BitHeap) : BitHeap := ... and similarly, eraseBit (column : Nat) (c : Circuit) := .... Does that make sense to you?

@bollu
Copy link
Copy Markdown

bollu commented May 11, 2026

LGTM, let's merge it, and perform the refactor in the next patch as suggested by @osmanyasar05 . the eventual goal should be to have all of this sorry-free!

@bollu
Copy link
Copy Markdown

bollu commented May 11, 2026

BTW, for the imports, what one would do is to have a file called DatapathVerification/BitHeap.lean that imports everything inside the subfolder.

@osmanyasar05
Copy link
Copy Markdown
Collaborator Author

BTW, for the imports, what one would do is to have a file called DatapathVerification/BitHeap.lean that imports everything inside the subfolder.

I was using the Basic.lean for that purpose, if that's what you mean?

@osmanyasar05 osmanyasar05 merged commit 63635c9 into main May 11, 2026
2 checks passed
@osmanyasar05 osmanyasar05 deleted the hashmap branch May 11, 2026 14:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants