Skip to content

Opaque function annotation#474

Merged
marcoeilers merged 5 commits into
masterfrom
meilers_opaque_functions
Nov 24, 2023
Merged

Opaque function annotation#474
marcoeilers merged 5 commits into
masterfrom
meilers_opaque_functions

Conversation

@marcoeilers

Copy link
Copy Markdown
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

@gauravpartha gauravpartha left a comment

Copy link
Copy Markdown
Contributor

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
@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.

2 participants