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

Updated snapshot injectivity axiom. #1475

Merged

Conversation

zgrannan
Copy link
Collaborator

The snapshot domain axioms do not currently ensure that a snapshot for a variant must correspond to a constructor invocation. As a consequence, given snapshots s1 and s2 that return the same values for all field access functions, we cannot prove s1 == s2 (see the included test).

This PR introduces a new injectivity axiom, asserting that each variant snapshot corresponds to a constructor invocation:

forall this: Variant :: 
  {field1(this), field2(this), ...}
  this == cons(field1(this), field2(this), ...)

The replaces the current injectivity axiom:

forall _l_args..., _r_args... :: {cons(_l_args...), cons(_r_args)}
    cons(_l_args...) == cons(_r_args) ==> _l_args... == _r_args...

The trigger on field access axioms is also made more permissive. This is necessary because the new injectivity axiom is only triggered on field access (and not on snapshot construction).

Previous: forall args... :: {field(cons(arg_field, other_args...))} field(cons(arg_field, other_args...)) == arg_field
New: forall args... :: {cons(arg_field, other_args...)} field(cons(arg_field, other_args...)) == arg_field

Finally, DefinitionCollector is updated to ensure that functions used in the triggers of domain axioms are always preserved.

@zgrannan zgrannan force-pushed the zgrannan/snapshot-injectivity branch from c0d5298 to d234cd5 Compare December 5, 2023 21:49
@zgrannan zgrannan force-pushed the zgrannan/snapshot-injectivity branch from d234cd5 to 3916dd3 Compare December 6, 2023 17:09
@zgrannan zgrannan merged commit 26c999b into viperproject:master Dec 7, 2023
19 checks passed
@zgrannan zgrannan deleted the zgrannan/snapshot-injectivity branch December 7, 2023 00:03
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.

1 participant