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

Annotations with multiline LET-INs #1961

Open
konnov opened this issue Jul 12, 2022 · 1 comment
Open

Annotations with multiline LET-INs #1961

konnov opened this issue Jul 12, 2022 · 1 comment
Labels
bug effort-hard Will take 5 or more days (probably requires issue refactor) impact-low Easy workaround exists | doesn't help objectives meaingfully | saves hardly any time product-owner-triage This should be triaged by the product owner

Comments

@konnov
Copy link
Collaborator

konnov commented Jul 12, 2022

Following the bug report in #1946, type annotations in multiple-line LET-IN definitions do not work:

---- MODULE Apalache_M0 ----

EXTENDS Naturals, FiniteSets

\* @type: (Set(a), Set(b)) => Set(a -> b);
FSets(D, R) ==
    LET
        \* @type: Int -> Set(a -> b);
        F[n \in 0..Cardinality(D)] ==
            IF n = 0
            THEN {<<>>}
            ELSE
                LET
                    \* @type: Set(a -> b);
                    F0 == F[n - 1]
                    \* All functions in F0 have the same domain, choose any one
                    \* @type: a -> b;
                    f0 == CHOOSE f \in F0 : TRUE
                    \* @type: Set(a);
                    D_smaller == DOMAIN f0
                    \* @type: a;
                    d1 == CHOOSE d \in (D \ D_smaller) : TRUE
                    \* @type: Set(a);
                    D_bigger == D_smaller \union {d1}
                IN
                    {
                        [d \in D_bigger |-> IF d \in DOMAIN f THEN f[d] ELSE r]
                        : f \in F0, r \in R
                    }
    IN
        F[Cardinality(D)]

ASSUME 
    \A d \in SUBSET (0..3) :
    \A r \in SUBSET (4..5) :
        [d -> r] = FSets(d, r)

====

We should figure out, whether this problem arises from SANY, or we translate the SANY representation incorrectly.

@konnov
Copy link
Collaborator Author

konnov commented Jul 12, 2022

For the multiline LET-IN definitions, there is an easy workaround, e.g., we can rewrite the above example as:

                LET \* @type: Set(a -> b);
                    F0 == F[n - 1]
                IN
                LET   \* @type: a -> b;
                    f0 == CHOOSE f \in F0 : TRUE
                IN
                LET    \* @type: Set(a);
                    D_smaller == DOMAIN f0
                IN
                LET \* @type: a;
                    d1 == CHOOSE d \in (D \ D_smaller) : TRUE
                IN
                LET \* @type: Set(a);
                    D_bigger == D_smaller \union {d1}
                IN
...

@konnov konnov changed the title Annotations with multiple-line LET-INs Annotations with multiline LET-INs Jul 12, 2022
@konnov konnov added the product-owner-triage This should be triaged by the product owner label Jul 15, 2022
@konnov konnov added effort-hard Will take 5 or more days (probably requires issue refactor) impact-low Easy workaround exists | doesn't help objectives meaingfully | saves hardly any time labels Sep 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug effort-hard Will take 5 or more days (probably requires issue refactor) impact-low Easy workaround exists | doesn't help objectives meaingfully | saves hardly any time product-owner-triage This should be triaged by the product owner
Projects
None yet
Development

No branches or pull requests

2 participants