-
Notifications
You must be signed in to change notification settings - Fork 108
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: statically sized Vector type #793
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Looking forward to having that. I wonder how soon we'd like to have it (or a private copy) in core. I certainly wrote code there where I thought it would be easier with this…
I noticed that not all operations are backed by Array operations; at least not all that could be. It seems like it should be the case, shouldn't it?
Can we also get nice #[a,b,c]
syntax for terms and patterns? Especially in patterns its nice if that is then a complete pattern.
Changing all operations to array operations is my next goal. This causes quite a bit of proof breakage that will have to be fixed. It doesn't make sense to turn operations like head and cons into array operations I suppose? |
|
(also I should mention that I'm just offering unsolicited opinions here, the maintainers have authority here) |
I have started porting the large Array API under |
This latest commit also adds a number of docstrings, which should be reviewed |
I would like to merge this PR after taking care of any new reviews in order to avoid putting too many things together. Subsequent PRs will:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First pass on Vector.Basic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review Vector.Lemmas.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ready for community review.
awaiting-review |
Batteries/Data/Vector/Basic.lean
Outdated
/-- | ||
`Vector α n` is an `Array α` whose size is statically fixed to `n` | ||
-/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you explicitly indicate in the docstrings the cost of each operation? See List.map
for what I mean.
We maintained those complexity annotations where the corresponding Array docstring stated the complexity. For the rest, at some point, we just agreed that predicting whether an operation is an in-place edit is not trivial. |
…jective, made vector parameters implicit in theorems toArray_injective and ext
This PR adds a static vector type to batteries akin to
Mathlib.Data.Vector
with a key difference: It is based onArray
instead ofList
and is designed for efficient operations with while offering a static size .The PR attempts to make the API ofBatteries.Data.Vector
isomorphic toMathlib.Data.Vector
to the maximum possible extent.EDIT: This PR also extends all the Array API to Vector
For discussion see this Zulip thread
EDIT: After consideration of the magnitude of the task, I limit this PR itself to porting non-monadic functions from Init.Data.Array.Basic and some surrounding API, as well as the extension theorem. I will create further PRs for adapting monadic functions, relevant theorems, and elements of the Array API already present in Batteries and Init
Depends on