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

Unfolding recursive operators #67

Closed
konnov opened this issue Nov 1, 2019 · 2 comments
Closed

Unfolding recursive operators #67

konnov opened this issue Nov 1, 2019 · 2 comments
Assignees
Labels
new New issue to be triaged.
Milestone

Comments

@konnov
Copy link
Collaborator

konnov commented Nov 1, 2019

Unfold definitions of recursive operators by using an upper bound on the number of calls.

Consider the following TLA+ code:

RECURSIVE Sum(_)
Sum(S) ==
  IF S = {}
  THEN 0
  ELSE LET n = CHOOSE x \in S: TRUE IN
    n + Sum(S \ {n})

\* an upper bound on the number of unfoldings
Sum_unfold_count == 3

\* a failure expression to be used when the upper bound has been exceeded
Sum_unfold_fail ==
  CHOOSE x \in {}: TRUE \* the expression should be type-compatible

Test == Sum({3, 4})

As a result of rewriting, Test should be rewritten as:

Test == Sum3({3, 4})

Sum3(S3) ==
  IF S3 = {}
  THEN 0
  ELSE LET n3 = CHOOSE x3 \in S3: TRUE IN
    n3 + Sum2(S3 \in {n3})

Sum2(S2) ==
  IF S2 = {}
  THEN 0
  ELSE LET n2 = CHOOSE x2 \in S2: TRUE IN
    n2 + Sum1(S2 \in {n2})

Sum1(S1) ==
  IF S1 = {}
  THEN 0
  ELSE LET n1 = CHOOSE x1 \in S1: TRUE IN
    n1 + Sum0(S1 \in {n1})

Sum0(S0) == CHOOSE x \in {}: TRUE
@konnov konnov added the new New issue to be triaged. label Nov 1, 2019
@konnov konnov added this to the BMCMT-0.9-release-ux milestone Nov 1, 2019
@konnov konnov self-assigned this Nov 1, 2019
@konnov konnov modified the milestones: v1.0-release-ux, v0.8.5-dev-encoding Apr 7, 2020
@konnov
Copy link
Collaborator Author

konnov commented Apr 7, 2020

The approach we take is documented in the manual. The implementation is quite unstable yet. It will be fixed in several days.

@Kukovec
Copy link
Collaborator

Kukovec commented Apr 17, 2020

Addressed in #127.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new New issue to be triaged.
Projects
None yet
Development

No branches or pull requests

2 participants