forked from aptos-labs/aptos-core
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[move-prover] create a choice boogie function on unique ExpData
The choice operator is currently implemented with a property that if the same choice operator is referred multiple times, the chosen evidence should stay the same. This semantics is captured in the newly added `// Semantics when the same-choice operator is referred` section in the `choice.move` test case. This property is implemented by converting a choice operator into an uninterpreted function in Boogie followed by an axiom to constrain this uninterpreted function. However, in this translation process, there is an implicit assumption that one choice operator will only be called with a one and only one set of variables (e.g., function arguments/locals, free vars, and memories). This assumption is valid in the verification of DPN given the limited uses of the choice operator, but there are violations. Once case is documented in the following example: ```move struct S has drop { x: u64 } fun test_less_than_1(x: u64): u64 { x - 1 } fun test_less_than_2(s: S): u64 { s.x - 1 } spec test_less_than_1 { include EnsuresLessThan; } spec test_less_than_2 { include EnsuresLessThan { x: s.x }; } spec schema EnsuresLessThan { x: u64; result: u64; ensures result != (choose i: u64 where i >= x); } ``` This choice operator is referred to in two contexts: - in `test_less_than_1`, it is called with an argument `$t0` of type `u64` - in `test_less_than_2`, it is called with an argument `$t0` of type `S` Before this commit, the translation will produce a Boogie type error, which is due to the fact that the choice operator is only translated once with `$t0: u64` as its first argument. Changes in this commit is simple in concept but might not be obvious from the code: Before this commit, we are already creating different functions for the same choice operator if they are specialized with different types. This is evident in `lifted_choice_infos: Rc<RefCell<BTreeMap<NodeId, LiftedChoiceInfo>>>` as `NodeId` being the key. The change is: `lifted_choice_infos: Rc<RefCell<HashMap<ExpData, LiftedChoiceInfo>>>`. So, instead of just using `NodeId`, we use the whole `ExpData`, which includes the `NodeId` but also the range and body `Exp` as well. If two choice expressions share exactly the same `Exp` for range and body, (i.e., their ASTs are exactly the same). We point them to the same uninterpreted function in Boogie. Otherwise, we create a new uninterpreted function for each reference to the same choice operator. Closes: aptos-labs#9772
- Loading branch information
1 parent
a992689
commit 566a655
Showing
5 changed files
with
247 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters