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

Rewrite for set membership of the powerset of a record where the record has infinite co-domains. #2946

Merged
merged 1 commit into from
Aug 17, 2024

Conversation

lemmy
Copy link
Contributor

@lemmy lemmy commented Aug 16, 2024

Simplified real-world scenario:

EXTENDS Integers

VARIABLE
  \* @type: Set({ p: (Int) });
  v

TypeOK ==
  v \in SUBSET [ p: Int ]

Init ==
  v = { [p |-> 42] }

Next ==
  UNCHANGED v

Apalache Error:

$ apalache-mc check --inv=TypeOK APARecSub.tla
[...]
Input error (see the manual): Found a set map over an infinite set of CellTFrom(Int). Not supported.

Rewrite:

S \in SUBSET [a : T] ~~> \A r \in S: DOMAIN r = { "a" } /\ r.a \in T

Related commits, issues, PRs:

PR hygiene

  • Tests added for any new code
  • Ran make fmt-fix (or had formatting run automatically on all files edited)

@lemmy

This comment was marked as resolved.

Copy link
Collaborator

@konnov konnov left a comment

Choose a reason for hiding this comment

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

Looks good to me. Thanks you for the contribution! Could you add a release note like this one, so your contribution would be visible in the next release.

…rd has infinite co-domains.

Simplified real-world scenario:
```tla
EXTENDS Integers

VARIABLE
  \* @type: Set({ p: (Int) });
  v

TypeOK ==
  v \in SUBSET [ p: Int ]

Init ==
  v = { [p |-> 42] }

Next ==
  UNCHANGED v
```

Apalache Error:
```sh
$ apalache-mc check --inv=TypeOK APARecSub.tla
[...]
Input error (see the manual): Found a set map over an infinite set of CellTFrom(Int). Not supported.
```

Rewrite:
```tla
S \in SUBSET [a : T] ~~> \A r \in S: DOMAIN r = { "a" } /\ r.a \in T
```

Related commits, issues, PRs:
* 625a164
* 785e269

* apalache-mc#723
* apalache-mc#1627
* apalache-mc#2762

* apalache-mc#1453
* apalache-mc#1629

Signed-off-by: Markus Alexander Kuppe <[email protected]>
@lemmy
Copy link
Contributor Author

lemmy commented Aug 16, 2024

Looks good to me. Thanks you for the contribution! Could you add a release note like this one, so your contribution would be visible in the next release.

Done

@lemmy lemmy marked this pull request as ready for review August 16, 2024 21:06
@lemmy lemmy requested a review from Kukovec as a code owner August 16, 2024 21:06
@konnov konnov enabled auto-merge August 17, 2024 08:25
@konnov konnov merged commit f55f57c into apalache-mc:main Aug 17, 2024
10 checks passed
@lemmy lemmy deleted the mku-SubsetRecordInf branch August 17, 2024 10:39
@lemmy
Copy link
Contributor Author

lemmy commented Aug 17, 2024

May I assume that you won't be releasing a new minor release with this change because of the move to the independent github org anytime soon?

@konnov
Copy link
Collaborator

konnov commented Aug 17, 2024

May I assume that you won't be releasing a new minor release with this change because of the move to the independent github org anytime soon?

I have started a job on cutting 0.45.0. It should be fairly easy to do.

@konnov
Copy link
Collaborator

konnov commented Aug 17, 2024

The last step of the release did not work. I will have a look into it: #2951

@lemmy
Copy link
Contributor Author

lemmy commented Aug 18, 2024

Blast, I've found that it rewrites APARecSub but not APARecRecSub:

------------------------- MODULE APARecSub ------------------------------           
EXTENDS Integers

VARIABLE
    \* @type: Set({ p: Int });
    v

TypeOK ==
    v \in SUBSET [ p: Int ]

Init ==
    v = { [p |-> 42] }

Next ==
    UNCHANGED v
========================================================================== 
------------------------- MODULE APARecRecSub -------------------------
EXTENDS Integers

VARIABLE
    \* @type: { p : Set ({ t : Int }) };
    v

TypeOK ==
    v \in [ p : SUBSET [t : Int] ]  

Init ==
    v = [ p |-> [t : Int] ]

Next ==
    UNCHANGED v
========================================================================== 

Will investigate...

@lemmy
Copy link
Contributor Author

lemmy commented Aug 19, 2024

Blast, I've found that it rewrites APARecSub but not APARecRecSub:

------------------------- MODULE APARecSub ------------------------------           
EXTENDS Integers

VARIABLE
    \* @type: Set({ p: Int });
    v

TypeOK ==
    v \in SUBSET [ p: Nat \ {0} ]

Init ==
    v = { [p |-> 42] }

Next ==
    UNCHANGED v
========================================================================== 
------------------------- MODULE APARecRecSub -------------------------
EXTENDS Integers

VARIABLE
    \* @type: { p : Set ({ t : Int }) };
    v

TypeOK ==
    v \in [ p : SUBSET [t : Int] ]  

Init ==
    v = [ p |-> [t : Int] ]

Next ==
    UNCHANGED v
========================================================================== 

Will investigate...

The rewrite works correctly and Apalache successfully handles a finite domain as in heidihoward/pbft-tlaplus#5. I presume another rewrite is able to handle the simpler ∀t_4 ∈ v: ((DOMAIN t_4 = {"p"}) ∧ t_4["p"] ∈ Int) but fails to handle ∀t_9 ∈ v["p"]: ((DOMAIN t_9 = {"t"}) ∧ t_9["t"] ∈ Int).

@konnov
Copy link
Collaborator

konnov commented Aug 19, 2024

We have the release 0.45.1 cut, which includes your PR: https://github.com/apalache-mc/apalache/actions/runs/10452011929

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