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 rules containing mappings #1663

Open
twillems opened this issue Dec 10, 2021 · 2 comments
Open

Rewrite rules containing mappings #1663

twillems opened this issue Dec 10, 2021 · 2 comments
Assignees
Labels
bug Something isn't working long term Issue serves as a reminder

Comments

@twillems
Copy link
Collaborator

There might be an issue with pattern matching when using mappings as an argument of other mappings, as the following specification, derived from an example by Myrthe Spronck, suggests:

map N:Nat;
    modify: Nat # List(Nat) -> List(Nat);
var l:List(Nat);
eqn N = 10;
    modify(N,l) = l;

act a;
proc P(l:List(Nat)) = a. P(modify(N,l));
init P([0,1]);

Replacing the mapping N in the rule for modify by the value 10 resolves the issue and leads to a finite state space. The example as it is currently generates an infinite number of states.

Steps to reproduce: glue the specification in mcrl2IDE and try generating a state space.

@twillems twillems added the bug Something isn't working label Dec 10, 2021
@tneele
Copy link
Member

tneele commented Dec 10, 2021

To make the issue more clear, consider the following. Load the specification above into a file a.mcrl2 and execute:

mcrl22lps a.mcrl2 a.lps
mcrl2i a.lps

In the prompt of mcrl2i, enter the following:

mCRL2 interpreter (type h for help)
? e modify(N, [])
modify(10, [])

According to @twillems, the expected result is [], while the actual result is modify(10, []).

@jgroote
Copy link
Member

jgroote commented Dec 11, 2021

I think this is expected behaviour.

Within the context of the rewrite rules:

eqn N = 10;
modify(N,l) = l;

the expression modify(N,[]) rewrites to modify(10,[]). This does not match with modify(N,l), because 10 does not match with N.

Hence, it does not rewrite.

This problem occurs in more contexts and is in my opinion a real disadvantage of using rewrite rules.
Question is should we change this, and then the question is what is the correct way, and how to implement
this. A suggestion could be to rewrite the lhs of the rewrite rules to normal form, before generating a rewrite
system. But should we do this until we reach a fixed point in the form of the lhs's?

@mlaveaux mlaveaux added the long term Issue serves as a reminder label Apr 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working long term Issue serves as a reminder
Projects
None yet
Development

No branches or pull requests

4 participants