// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
include "../../libraries/src/Wrappers.dfy"
include "../../libraries/src/Collections/Sequences/Seq.dfy"
module Actions {
import opened Wrappers
import opened Seq
datatype ActionInvoke = ActionInvoke(input: A, output: R)
/*
* A trait that can execute arbitrary actions on input type A
* and return results of type R.
*/
trait {:termination false} Action
{
/*
* Contains the implementation of the given action
*/
method Invoke(a: A, ghost attemptsState: seq>)
returns (r: R)
requires Invariant()
modifies Modifies
decreases Modifies
ensures Invariant()
ensures Ensures(a, r, attemptsState)
predicate Invariant()
reads Modifies
decreases Modifies
/*
* Contains the assertions that should be true upon return of the Invoke method
*/
predicate Ensures(
a: A,
r: R,
attemptsState: seq>
)
reads Modifies
decreases Modifies
/*
* Contains the set of fields that may be modified during `Invoke`
*/
ghost const Modifies: set