Skip to content

Expressing invariant of a an array used to index into another array #900

Answered by W95Psp
ROMemories asked this question in Q&A
Discussion options

You must be logged in to vote

Hi!

Indeed, here, the invariant is a bit verbose.
Instead of having the invariant on the level of the struct Foo, I think that here, putting the invariant on the items of the array would be nicer.

hax provides a way of creating newtype-style refinement types: here you want to have a wrapper around u8 that guarantees the property you need.

You probably wants something like the following:
https://hax-playground.cryspen.com/#fstar/latest-main/gist=9a358635fb2712c9484c3f99effdc99a

We should document that better however. It is documented in the library here: https://hacspec.org/hax/frontend/hax_lib/attr.refinement_type.html, but we should have a chapter in the book that describes that.

Do you …

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@ROMemories
Comment options

Answer selected by ROMemories
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants