feat: stricter word ram model - #90
Open
Shreyas4991 wants to merge 4 commits into
Open
Shreyas4991 wants to merge 4 commits into
Shreyas4991 wants to merge 4 commits into
Conversation
Shreyas4991
marked this pull request as ready for review
September 14, 2026 21:57
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The goal of this PR was initially to experiment with a stricter version of the WordRAM model previously introduced in #88. The problem there is one can extract Bitvecs, perform computations in
pureand put them back in memory. This is always an issue with monadic models, but here we had a chance to do something stronger. We could force the syntax to specify registers and returnUnit.unit. The contents of the registers should remain inaccessible, so there is nogetoperation. Thus it's basically impossible to work on bitvectors in pure computations, because in theProgsyntax, once can never access them in the first place. OTOH, this suggested some design changes.Note:
Once the set of accessed memory addresses is hidden in the model's state monad, costing it for space complexity separately became tedious. So we merged
evalMandcostMinModelMinto a singlerunwhich returns anAddWriterTvalue. This also changes how the mvcgen setup works. Note we could just use the old setup and treatcostas a dummy field, but that's pretty suggestive that we really ought to just return a single AddWriterT computation instead of two separate functions for running and costing.On the other hand, keeping evaluation and costs separate has its benefits. It keeps the correctness and complexity proofs separate and simpler, without relying on monadic verification machinery. I have not touched Model itself for now because it is incredibly convenient to not rely on mvcgen for algorithmic proofs where we can avoid it. It is also unclear how the random quick sort PRs Add randomized quicksort and prove correctness #82 and explore: random quicksort variant 2 #87 are affected by this change. It might turn out that there we benefit from the simplicity of not getting into monad transformers.
For now this is an experiment. So I'll leave this a draft PR.