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

[FEATURE] Use types to simplify TypeOK #723

Closed
7 tasks done
konnov opened this issue Apr 10, 2021 · 8 comments · Fixed by #2570
Closed
7 tasks done

[FEATURE] Use types to simplify TypeOK #723

konnov opened this issue Apr 10, 2021 · 8 comments · Fixed by #2570
Assignees
Labels
Fprepro Feature: TLA+ preprocessor product-owner-triage This should be triaged by the product owner

Comments

@konnov
Copy link
Collaborator

konnov commented Apr 10, 2021

Blocked by #401 Precise type checking for records

We should use type information to simplify membership tests such as x \in BOOLEAN, x \in Int, x \in STRING, x \in Seq(...). By knowing the types, we could write a preprocessing pass that rewrites the above tests to TRUE, if the types are matching the tests.

@konnov konnov added usability UX improvements Alpha Centauri The first public alpha release labels Apr 10, 2021
@konnov konnov self-assigned this Apr 10, 2021
@konnov konnov removed their assignment Oct 12, 2021
@konnov konnov added Fprepro Feature: TLA+ preprocessor and removed usability UX improvements Alpha Centauri The first public alpha release labels Nov 8, 2021
@konnov konnov removed this from the July iteration milestone Nov 18, 2021
@thpani
Copy link
Collaborator

thpani commented Feb 22, 2022

@konnov What's a good place to implement this? ExprOptimizer or a separate transformation in OptimizationPass or ...?

@thpani thpani self-assigned this Feb 22, 2022
@konnov
Copy link
Collaborator Author

konnov commented Feb 22, 2022

I would implement a separate transformation similar to ExprOptimizer.

@thpani
Copy link
Collaborator

thpani commented Apr 15, 2022

We should revisit this based on #1629

@konnov
Copy link
Collaborator Author

konnov commented Apr 15, 2022

Do we handle the case seq \in Seq(S), when S is a finite set, not Int, Nat, or BOOLEAN? I guess, we could translate it to \A x \in DOMAIN seq: seq[x] \in S.

@thpani thpani added the blocked Issue blocked by another (for filtering) label May 3, 2022
@konnov konnov added the product-owner-triage This should be triaged by the product owner label Jul 13, 2022
@konnov
Copy link
Collaborator Author

konnov commented Jul 13, 2022

Simplification for records should be unblocked now, since #401 is closed. Shall we revisit this issue any time soon?

@thpani
Copy link
Collaborator

thpani commented Jul 13, 2022

Simplification for records should be unblocked now, since #401 is closed. Shall we revisit this issue any time soon?

Does it make sense to follow up on this after we enable TypeSystem 1.2 by default in #1943?

@konnov
Copy link
Collaborator Author

konnov commented Jul 13, 2022

Yes, we can do it after the switch, though nothing prevents us from implementing this transformation right now.

@konnov konnov removed the blocked Issue blocked by another (for filtering) label Dec 21, 2022
@konnov
Copy link
Collaborator Author

konnov commented Dec 21, 2022

Just labelled this one as unblocked.

@thpani thpani mentioned this issue May 26, 2023
4 tasks
lemmy added a commit to lemmy/apalache that referenced this issue Aug 16, 2024
…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 <github.com@lemmster.de>
lemmy added a commit to lemmy/apalache that referenced this issue Aug 16, 2024
…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 <github.com@lemmster.de>
lemmy added a commit to lemmy/apalache that referenced this issue Aug 16, 2024
…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 <github.com@lemmster.de>
lemmy added a commit to lemmy/apalache that referenced this issue Aug 16, 2024
…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 <github.com@lemmster.de>
lemmy added a commit to lemmy/apalache that referenced this issue Aug 16, 2024
…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 <github.com@lemmster.de>
lemmy added a commit to lemmy/apalache that referenced this issue Aug 16, 2024
…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 <github.com@lemmster.de>
lemmy added a commit to lemmy/apalache that referenced this issue Aug 16, 2024
…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 <github.com@lemmster.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Fprepro Feature: TLA+ preprocessor product-owner-triage This should be triaged by the product owner
Projects
None yet
3 participants