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

Duplicate comm simplification rules #2754

Merged
merged 9 commits into from
Aug 4, 2022
Merged

Duplicate comm simplification rules #2754

merged 9 commits into from
Aug 4, 2022

Conversation

radumereuta
Copy link
Contributor

Fixes: #2587

@radumereuta
Copy link
Contributor Author

Failing with this message. Coming from the java backend: https://github.com/runtimeverification/k/blob/master/java-backend/src/main/java/org/kframework/backend/java/kil/Definition.java#L176

     [exec] [Error] Critical: Unexpected combination of assoc, comm, idem attributes found.
     [exec] Currently only sets, maps, and lists are supported: syntax {Sort1, Sort2} Sort2
     [exec] ::= "{" Sort1 "#Equals" Sort1 "}" [comm, format(%1%i%n%2%d%n%3%i%n%4%d%n%5),
     [exec] klabel(#Equals), mlEquals, mlOp, symbol]
     [exec] 	Source(/home/jenkins-runner/workspace/K_PR-2754/k-distribution/target/release/k/include/kframework/builtin/kast.md)
     [exec] 	Location(148,35,148,148)
     [exec] 	148 |	                                | "{" Sort1 "#Equals" Sort1 "}" [klabel(#Equals), symbol, mlOp, mlEquals, comm, format(%1%i%n%2%d%n%3%i%n%4%d%n%5)]

@radumereuta
Copy link
Contributor Author

radumereuta commented Jul 28, 2022

Hack the Java backend to remove the comm attribute in Definition.java.
Only if there is no assoc or idem present.
If we find issues with the LLVM backend we should talk again.
We should test it with some larger semantics as well.

Comment on lines +51 to +59
public K genCommRule(K body, Module m) {
return new RewriteAwareTransformer(true) {
@Override
public K apply(KApply k) {
if (k.klabel().name().equals("#withConfig")) {
super.apply(k);
return k;
}
if ((isRHS() && !isLHS()) || k.klabel() instanceof KVariable || !m.attributesFor().contains(k.klabel())) {
Copy link
Member

@ehildenb ehildenb Jul 30, 2022

Choose a reason for hiding this comment

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

Is this only swapping at the top-most position of the LHS, or at every position with a comm symbol? We should only swap at the top-most position.

For example, if we have:

    rule { 1 +Int 2 #Equals 3 } => #Top [comm, simplification]

It should generate rule:

    rule { 3 #Equals 1 +Int 2 } => #Top

But not rule:

    rule { 3 #Equals 2 +Int 1 } => #Top

Copy link
Member

Choose a reason for hiding this comment

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

Maybe this could be added as a test somehow.

Copy link
Collaborator

@dwightguth dwightguth left a comment

Choose a reason for hiding this comment

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

I'd definitely like to see tests for this.

Not working because comm is interpreted by the haskell backend
@radumereuta
Copy link
Contributor Author

Try to remove the comm attribute from the rules generated by this step.

@radumereuta radumereuta requested a review from dwightguth August 4, 2022 15:58
@radumereuta
Copy link
Contributor Author

I need to test it to see what happens if I add comm to more productions since the backend generates extra axioms for each.

Copy link
Collaborator

@dwightguth dwightguth left a comment

Choose a reason for hiding this comment

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

looks fine. Adding the commutativity axioms to the kore definition shouldn't affect anything though since both backends appear to be ignoring them.

@ehildenb
Copy link
Member

ehildenb commented Aug 4, 2022

Please add an issue to identify what's going on with the backend, so we can get that fixed too. The backends should not have to have the comm attribute stripped.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[KIP] - comm attribute on simplification rules
4 participants