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

[DMS-22] motoko-san: loop invariants #3

Merged
merged 1 commit into from
Apr 15, 2024
Merged

Conversation

int-index
Copy link
Member

New features:

  • invariants in while-loops

New test cases:

  • test/viper/loop-invariant.mo
while (i < n) {
      assert:loop:invariant (i * 2 == j);
      assert:loop:invariant (j - i == i);
      i := i + 1;
      j := j + 2;
    };

@int-index int-index requested a review from GoPavel April 14, 2024 19:13
@int-index int-index force-pushed the motoko-san/loop-invariant branch from 3af963b to 065005c Compare April 14, 2024 19:52
| WhileS (exp, _, s) -> (* TODO: Invariant *)
fprintf ppf "@[<v 2>while (%a) {@ %a}@]"
| WhileS (exp, invs, s) ->
fprintf ppf "@[<v 2>while (%a) @[<v 0>%a@] {@ %a}@]"
Copy link

Choose a reason for hiding this comment

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

Suggested change
fprintf ppf "@[<v 2>while (%a) @[<v 0>%a@] {@ %a}@]"
fprintf ppf "@[<v 2>while (%a)@;@[<v 0>%a@]@;%a@]"

This removes spare brackets and move invariants on next line

Copy link
Member Author

Choose a reason for hiding this comment

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

Thank you, yes, this makes the output cleaner

@GoPavel
Copy link

GoPavel commented Apr 15, 2024

Others LGTM

New features:
* invariants in while-loops

New test cases:
* test/viper/loop-invariant.mo
@int-index int-index force-pushed the motoko-san/loop-invariant branch from 065005c to 921a119 Compare April 15, 2024 17:01
@int-index int-index merged commit af3e765 into master Apr 15, 2024
3 of 5 checks passed
@delete-merged-branch delete-merged-branch bot deleted the motoko-san/loop-invariant branch April 15, 2024 18:21
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