FStarLang / pulse

The Pulse separation logic DSL for F*
Apache License 2.0
6 stars 7 forks source link

A model for Rust slices (and C array pointers) #225

Closed tahina-pro closed 1 month ago

tahina-pro commented 1 month ago

This PR proposes:

Since Pulse.Lib.Slice is implemented on top of Pulse.Lib.ArrayPtr, slices can extract to C, with their lengths becoming explicit.

Pulse.Lib.Slice.fsti is meant to model the following slice operations:

I intend those operations to be extracted by adding rules in Pulse2Rust (which is why they are not marked inline_for_extraction, thus C extraction will produce explicit functions monomorphized by Karamel.) However, at this point, I have no idea how to do that, so this PR does not provide anything to extract slices to Rust. If anyone has any idea, please rise up! Thanks in advance!

NOTE: Currently, this PR is done on top of Pulse commit c003b9733b1f11b6cc895e9c8681f0483cb193ea, corresponding to the last known good Everest at project-everest/everest@064cc2165b8f5b3af33ed279ad4cacded9abd963

gebner commented 1 month ago

I have added support for slices in pulse2rust and added test cases too.

@tahina-pro There are some small changes in the API:

Unless somebody complains, I'll merge this by tomorrow.

tahina-pro commented 1 month ago

Thanks a lot Gabriel! Your changes greatly improved my initial proposal! And, last but not least, many thanks also for adding Rust extraction support!