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

ExprOptimizer: Rewrite S \in SUBSET T when it occurs in subexpressions #2975

Merged
merged 1 commit into from
Aug 29, 2024

Conversation

lemmy
Copy link
Contributor

@lemmy lemmy commented Aug 28, 2024

----- MODULE ljasf -----
EXTENDS Integers

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

TypeOK ==
        m \in [ v : SUBSET [ p : SUBSET [ v: SUBSET {1,2,3,4,5}] ] ]

Init ==
    m = [ v |-> {[p |-> {[v |-> {1}]} ]} ]

Next ==
    UNCHANGED m
====
input:
m["v"] ∈ SUBSET ({["p" ↦ t_5$1] : t_5$1 ∈ SUBSET ({["v" ↦ t_4$1] : t_4$1 ∈ SUBSET {1, 2, 3, 4, 5}})})

old output:
∀t_a ∈ m["v"]: ((DOMAIN t_a = {"p"}) ∧ (∀t_b ∈ t_a["p"]: ((DOMAIN t_b = {"v"}) ∧ t_b["v"] ∈ SUBSET {1, 2, 3, 4, 5})))

new output:
∀t_a ∈ m["v"]: ((DOMAIN t_a = {"p"}) ∧ (∀t_b ∈ t_a["p"]: ((DOMAIN t_b = {"v"}) ∧ (∀t_c ∈ t_b["v"]: t_c ∈ {1, 2, 3, 4, 5}))))
  • Tests added for any new code
  • Ran make fmt-fix (or had formatting run automatically on all files edited)
  • Documentation added for any new functionality (nothing to document)
  • [Entries added to ./unreleased/][changelog format] for any new functionality

@lemmy lemmy requested a review from Kukovec as a code owner August 28, 2024 22:28
@lemmy lemmy changed the title ExprOptimizer: Eliminate SUBSET operator when it occurs in subexpressions ExprOptimizer: Rewrite SUBSET operator when it occurs in subexpressions Aug 28, 2024
@lemmy lemmy changed the title ExprOptimizer: Rewrite SUBSET operator when it occurs in subexpressions ExprOptimizer: Rewrite S \in SUBSET T when it occurs in subexpressions Aug 28, 2024
…ssions:

```tla
----- MODULE ljasf -----
EXTENDS Integers

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

TypeOK ==
        m \in [ v : SUBSET [ p : SUBSET [ v: SUBSET {1,2,3,4,5}] ] ]

Init ==
    m = [ v |-> {[p |-> {[v |-> {1}]} ]} ]

Next ==
    UNCHANGED m
====
```

```
input:
m["v"] ∈ SUBSET ({["p" ↦ t_5$1] : t_5$1 ∈ SUBSET ({["v" ↦ t_4$1] : t_4$1 ∈ SUBSET {1, 2, 3, 4, 5}})})

old:
∀t_a ∈ m["v"]: ((DOMAIN t_a = {"p"}) ∧ (∀t_b ∈ t_a["p"]: ((DOMAIN t_b = {"v"}) ∧ t_b["v"] ∈ SUBSET {1, 2, 3, 4, 5})))

new:
∀t_a ∈ m["v"]: ((DOMAIN t_a = {"p"}) ∧ (∀t_b ∈ t_a["p"]: ((DOMAIN t_b = {"v"}) ∧ (∀t_c ∈ t_b["v"]: t_c ∈ {1, 2, 3, 4, 5}))))
```
@lemmy
Copy link
Contributor Author

lemmy commented Aug 29, 2024

@konnov This is a follow-up of #2946.

Just a heads-up: GitHub automatically assigns Kukovec as the PR reviewer for me every time. I'm not sure if that's intentional.

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.

This makes sense to me. Thanks for fixing this issue!

@konnov konnov merged commit c6f015b into apalache-mc:main Aug 29, 2024
10 checks passed
@lemmy lemmy deleted the mku-ExprOptimizerSubset branch September 1, 2024 23:33
@lemmy
Copy link
Contributor Author

lemmy commented Sep 2, 2024

Thanks for merging.

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