Skip to content

Arrays with non-constant lengths - #1325

Draft
eponier wants to merge 29 commits into
mainfrom
array_unknown_size2
Draft

Arrays with non-constant lengths#1325
eponier wants to merge 29 commits into
mainfrom
array_unknown_size2

Conversation

@eponier

@eponier eponier commented Nov 19, 2025

Copy link
Copy Markdown
Contributor

I open this to get some feedback. This is still early draft, in particular no proof has been tried.

The length of an array is no longer an integer, but a simple arithmetic expression (with additions and multiplications).

This change is used to implement some kind of templating for functions (cf. tests/template) as a POC.

@eponier

eponier commented Nov 19, 2025

Copy link
Copy Markdown
Contributor Author

Comments:

  • this should allow to get rid of (part of?) insert_copy_and_fix_length.ml, this has not been done yet
  • the template feature is a POC, we should discuss if this is a reasonable feature to expose complementary to the module system we may want to have, or if we should get rid of it in favour of a module system
  • the concrete syntax is horrible and has to be changed
  • would it make sense to have fn f(reg u64 a[]) with unspecified length?
  • there is nearly no check in the current implementation that the template arguments are used correctly; if a template arg is used at a wrong place, this will trigger an error in the middle of a pass
  • maybe this is an opportunity to remove all uses of int as lengths of arrays on the OCaml side (use Z.t instead)
  • the fact that lengths of arrays are positive on the Rocq side is sometimes painful, it would be good to explore whether we can use Z instead

@eponier

eponier commented Nov 19, 2025

Copy link
Copy Markdown
Contributor Author

Also the feature was added on top of the param/subst machinery. I don't know if we want to remove it and get rid of the polymorphism on the type of length of arrays. What is done in this PR is not as expressive, though.

@eponier
eponier force-pushed the array_unknown_size2 branch from e6b4ea9 to 5e0cdf4 Compare January 28, 2026 15:00
@eponier
eponier force-pushed the array_unknown_size2 branch from 5e0cdf4 to 36fd5e2 Compare February 16, 2026 09:57
@eponier
eponier force-pushed the array_unknown_size2 branch 2 times, most recently from 14579db to 6a14aec Compare February 25, 2026 22:40
@eponier
eponier force-pushed the array_unknown_size2 branch from 6a14aec to 987d5a5 Compare March 24, 2026 14:42
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.

1 participant