Implementation of std::result functions - #250
Open
jonasmittun wants to merge 17 commits into
Open
Conversation
…thod names corrected where applicable. Addition of subsections to better organise the result methods.
…theorem file work with multiple contracts passing functions as arguments.
…d to ensure that every part makes logical sense.
…p as_ref, as_mut, as_deref and as_deref_mut sections with regards to consistency in variable names, text blocks and isar style proofs rather than apply style.
…nto_err and into_ok. Text snippets missing.
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.
Issue #17 :
Implementing std::result
Description of changes:
Restructured file with sections/subsections for ease of use with sidekick, every function has its own subsection.
Added preamble section intended for content reused across functions. Currently contains
declare lift_pure_to_contract_def [crush_contracts]anducincl_auto lift_pure_to_contractwhich are reused in all implementations taking a function as an argument.Added 24 missing functions:
All the following functions are implemented to be as faithful as possible to the Rust docs and are complete with function, contract and proof.
Changed 9 existing functions:
General changes include: Renaming definitions to include a "result_" prefix to keep the namespace consistent and to avoid collisions. Refactoring variable names and HOL type names for consistency across functions. Proofs generally rewritten to use
split:rather thansplit!:.Implemented contract and proof.
Function definition refactored. Implemented contract and proof.
Refactored contract and simplified proof, proof is now using
by-form rather than apply style. Removedadhoc_overloading store_update_const ⇌ update_funas it appeared to be unused, thestore_updateoverloading isn't exercised here.Proof rewritten to use
by-form rather than apply style.Added 5 unimplemented function subsections:
The following functions generally aren't functionally distinct in µRust and are therefore left unimplemented, please advise if this is the best approach, if an alias would be better or if you would prefer that these be handled in some other way.
Identical to cloned in µRust, no optimized execution available.
Default values not implemented in µRust.
Unchecked (unsafe) execution not supported in µRust.
Items requiring extra review attention
Comparing unwrap and unwrap_err we find a difference in how the internal expect/expect_err function is called due to the latter not being implemented in the Core_Syntax.thy consts. I'm unsure what the intention is here for the future so I've left it as is, but perhaps this could be made into a new issue aiming to make StdLib functions callable in the way expect is?
micro_rust_notationandadhoc_overloadingare used in a mixed fashion and depend on functions being added to other files. As these were recently changed and left mixed, I didn't want to make a call as to standardising the file to one or the other. I noticed that adhoc was left specifically in the places where the name is shared with one in Option, unsure if coincidence or not, but I want to point it out so you're aware. Furthermore, I felt it was easier for both me and the reviewer if my changes were isolated to just the one file. Perhaps this could be a new issue?Regarding naming changes (appending
result_to definitions), I'm worried that this could break other proofs that depend on the existing implementations. Unsure how to handle this if that's the case, please advise.I want to be transparent and admit that the as_deref, as_deref_mut, as_mut and as_ref functions were difficult to implement and I have some doubts if I've done this correctly. My biggest specific concern is regarding the optics/focus components used, e.g.
ro_ref_from_ref,focus_focused,unsafe_ref_from_ro_ref. Please be careful to review these in case I have made some mistake.AI Disclosure:
I've used Claude (Opus 4.8) to assist in both understanding the AutoCorrode codebase and writing certain contracts/proofs. I do my best not to use any AI input that I don't understand myself to a reasonable degree and strive to write most code/text by hand to force myself to check my output.
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.