Skip to content
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

Add attributes #[skip] and refinement attributes #211

Merged
merged 12 commits into from
Aug 21, 2023
Merged

Add attributes #[skip] and refinement attributes #211

merged 12 commits into from
Aug 21, 2023

Conversation

W95Psp
Copy link
Collaborator

@W95Psp W95Psp commented Aug 10, 2023

Example:

use hax_lib_macros::*;

#[skip]
pub fn skip_me() {}

#[hax]
pub struct Hello {
    pub x: u32,
    #[refine(y > 3)]
    pub y: u32,
    #[refine(y + x + z > 3)]
    pub z: u32,
}

Translates into the following F*:

module Attributes
#set-options "--fuel 0 --ifuel 1 --z3rlimit 15"
open Core

let v___: Prims.unit = ()

let refinement_under___ (x y: u32) : bool = y >. 3ul

let v___1: Prims.unit = ()

let refinement_under___1 (x y z: u32) : bool = ((y +. x <: u32) +. z <: u32) >. 3ul

type t_Hello = {
  f_x:u32;
  f_y:f_y: u32{f_y >. 3ul};
  f_z:f_z: u32{((f_y +. f_x <: u32) +. f_z <: u32) >. 3ul}
}

I need to add more attributes and clean up the refinement_under__* things

TODO (follow up PRs):

  • a #[hax::late_skip] (internal thing: translate to the backend, but don't print)
  • refinements on functions inputs & outputs (follow up PR)
  • pre/post on functions, contract style
  • #[refine(...)] on enum fields
  • #[hax::lemma] for marking a function and express that this function is a lemma statement we want to prove on the proof assistant side
  • please comment if other ideas

@W95Psp W95Psp marked this pull request as draft August 10, 2023 14:49
@W95Psp W95Psp marked this pull request as ready for review August 17, 2023 11:39
Copy link
Member

@franziskuskiefer franziskuskiefer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I think there's enough good stuff in here to get it in.

Did you remove the hax attribute again? We should have it at some point. But skip is more important for now I think.

@W95Psp
Copy link
Collaborator Author

W95Psp commented Aug 18, 2023

I just renamed that hax attribute to hax_attributes: when an item is marked with this attribute, anything below it can use the refine attribute (where it's allowed --for now only on struct fields).

@franziskuskiefer
Copy link
Member

I just renamed that hax attribute to hax_attributes: when an item is marked with this attribute, anything below it can use the refine attribute (where it's allowed --for now only on struct fields).

Right, but we want a hax attribute that disables everything in a crate except for the annotated functions to extract code from large crates. But that's not urgent yet. Can you file a follow up for it?

@W95Psp
Copy link
Collaborator Author

W95Psp commented Aug 21, 2023

Oh, right! Sure, filed #223 :)

@W95Psp W95Psp enabled auto-merge August 21, 2023 06:47
@W95Psp W95Psp added this pull request to the merge queue Aug 21, 2023
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to a conflict with the base branch Aug 21, 2023
@franziskuskiefer
Copy link
Member

@W95Psp this needs manual conflict resolution

@W95Psp W95Psp added this pull request to the merge queue Aug 21, 2023
Merged via the queue into main with commit 5855782 Aug 21, 2023
@W95Psp W95Psp deleted the attributes branch August 21, 2023 11:21
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.

2 participants