Skip to content

Conversation

@lefterislazar
Copy link
Collaborator

This PR modifies the Rocq translation to include the postconditions and invariants provided in the Act specifiaction. There is also some restructuring in the Rocq generation code.

Postconditions

For every postcondition of the constructor and of every case of every behaviour, a Prop is generated, which expresses that said postcondition holds after a valid transition.
The postconditions are kept separate to allow the user to omit proving any that they do not need, or trust that the SMT solver has validated.

Invariants

The invariants provided in the Act specification are merged into a conjuction in the invariants term.
Three other generated terms are of interest:

  • invariantInit: Given a property P, claims that P holds after a valid constructor execution.
  • invariantStep: Given a property P, claims that if P holds in the prestate of a step transition, then it holds
    in the poststate.
  • invariantReachable: Given a property P and proofs of invariantInit P and invariantStep P, asserts and proves that P is true for any state reachable from an initial state.

The above can also be used to prove any invariant, not just those generated from the specification.

Miscellaneous

  • Added an Amm test where all exported postconditions are proven.
  • Rewrote the proofs in Exponent/Theory.v to make use of the generated invariant theorem.
  • Updated the library imports to fix some warnings.

@lefterislazar lefterislazar requested a review from zoep October 14, 2025 13:59
@@ -0,0 +1,323 @@
constructor of Token
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we have to inline Token or can we use the json config to point at a different file?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The implementation for reading the json config was created with the HEVM equivalence checking requirements in mind, and, while not difficult, porting it to other modes of Act would require some adjustments. It will be implemented in the future.

Copy link
Collaborator

@zoep zoep left a comment

Choose a reason for hiding this comment

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

Nice work!

Just a small nit about removing duplicate conditions.

parens (T.pack name <+> envVar <+> arguments i) <+> stateVar

-- | definition of constructor preconditions
initPrecs :: Constructor -> T.Text
Copy link
Collaborator

Choose a reason for hiding this comment

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

It seems that there are some duplicates in the preconditions for constructors and behaviors. Can we apply a deduplication pass? I'm not sure if this should happen here or earlier when we generate bounds.


creates

Token token0 := create Token(200)
Copy link
Collaborator

Choose a reason for hiding this comment

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

When we handle pointers in the Rocq backend, let's use the real AMM here that does casting.

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