k-legacy icon indicating copy to clipboard operation
k-legacy copied to clipboard

Substitution as an argument of a function

Open omarzd opened this issue 8 years ago • 4 comments

Before K4.0, using the substitution module, I could do something like this:

rule prep(A, Body, B) => prep(Body[A / B])

Now the substitution inside prep upsets the parser. So how should I do that?

omarzd avatar Feb 17 '17 23:02 omarzd

Do you have more details about the error message? A simple test and version of K could suffice in this case.

radumereuta avatar Feb 23 '17 14:02 radumereuta

I tried to make a minimal example. I modified lesson2/lambda.k. This example doesn't make much sense, but it produces the same error I'm getting.

require "substitution.k"
module TEST
  imports SUBSTITUTION

  syntax Exp ::= Id
               | Exp "{" Id Id "}"              [left]
               | "(" Exp ")"          [bracket]
  syntax KVariable ::= Id
  
  syntax Exp ::= prep(Exp) [function]

  rule E:Exp {I1:Id I2:Id} => prep(E[I1 / I2])
endmodule

omarzd avatar Feb 25 '17 19:02 omarzd

@radumereuta Oh and I'm using the latest master!

omarzd avatar Mar 01 '17 09:03 omarzd

The relation between K and the user defined sorts in the definition has changed. So now at the top there is K, and at the bottom there is KBot. Changing the prep production to something like:

syntax Exp ::= prep(K) [function]

avoids your error.

radumereuta avatar Mar 07 '17 12:03 radumereuta