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

Opaque function annotation #474

Merged
merged 5 commits into from
Nov 24, 2023
Merged

Opaque function annotation #474

merged 5 commits into from
Nov 24, 2023

Conversation

marcoeilers
Copy link
Contributor

Adds the ability to annotate functions as @opaque(), which will result in the function body not being known by default. The precondition of the function will still aways be checked, and the postcondition of the function is always known.
Individual function applications can then be annotated with @reveal() to reveal the function definition for that specific usage.

Example:

@opaque()
function isGreaterOne(i: Int): Bool
{ i > 1 }

method mDef(j: Int)
    requires j > -50
{
    assume isGreaterOne(j)
    assert j > 1 // fails
}

method mDef2(j: Int)
    requires j > -50
{
    assume @reveal() isGreaterOne(j)
    assert j > 1 // succeeds
}

Internally, applications of opaque functions are encoded using the existing limited version of the function. @reveal() forces the use of the normal version of the function that triggers the definitional axiom.
The equivalent Silicon PR is here: viperproject/silicon#767

Copy link
Contributor

@gauravpartha gauravpartha left a comment

Choose a reason for hiding this comment

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

Looks good to me. I just added one comment about adding some more comments to the code.

@marcoeilers marcoeilers merged commit 4a695ff into master Nov 24, 2023
1 check passed
@marcoeilers marcoeilers deleted the meilers_opaque_functions branch November 24, 2023 16:44
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.

None yet

2 participants