Skip to Content.
Sympa Menu

maude-help - [[maude-help] ] Reusing intermediate results

maude-help AT lists.cs.illinois.edu

Subject: Maude-help mailing list

List archive

Chronological Thread  
  • From: Raghu Ranganathan <rraghu.11502 AT gmail.com>
  • To: maude-help AT lists.cs.illinois.edu
  • Subject: [[maude-help] ] Reusing intermediate results
  • Date: Mon, 4 Dec 2023 14:51:33 +0800

I would like to be able to assign local variables (or something similar to a local variable) to reuse intermediate values instead of creating potentially 3-4 ops for a single purpose.

Taking a pseudocode example:

a=1
b=F(2,a,3,a)
c=F(b,2,a,2)
F(x,y,z,u)=x+y+z+u

my attempt at translating this to an object module is:
omod LOCALS is
  pr NAT .
  class R | a : Nat, b : Nat, c : Nat .
  var X Y Z U : Nat .
  var O : Oid .
  var Atts : AttributeSet .

  op f : Nat Nat Nat Nat -> Nat .
  eq f(X,Y,Z,U) = X + Y + Z + U .
 
  rl < O : R | Atts > => < O : R | a : 1 , Atts > .
  rl < O : R | a : X , Atts > => < O : R | b : f(2,X,3,X), Atts > .
  rl < O : R | a : X, b : Y, Atts > => < O : R | c : f(Y,2,X,2), Atts > .
endom

This strategy doesn't seem to work when i try to rewrite it:

Maude> rew < O : R | > .
rewrite in LOCALS : < O : R | none > .
rewrites: 0 in 0ms cpu (0ms real) (~ rewrites/second)
result Object: < O : R | none >

But even if it worked, this is equally as verbose if not more verbose than simply creating new ops. I am wondering if there is a simpler way to store values for later use, or a better way to reuse state in an operator.



Archive powered by MHonArc 2.6.24.

Top of Page