aboutsummaryrefslogtreecommitdiff
path: root/entries/lizard-business/fib.maude
blob: 20bc428c4adf6f36ff44d49440f08292e6a6aca3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
smod FIB is
  pr LIST{Nat} .

  vars M N : Nat .
  var  Ns  : List{Nat} .

  rl [start]: nil => 0 1 .
  rl [next]:  Ns M N => Ns M N (M + N) .
  rl [drop] : Ns N => N .

  strats fib fibgo : Nat @ List{Nat} .
  sd fib(N)      := start ; fibgo(N) .
  sd fibgo(0)    := top(drop) .
  sd fibgo(s(N)) := top(next) ; fibgo(N) .
endsm

***(
  Maude> srew nil using fib(10) .
  srewrite in FIB : nil using fib(10) .

  Solution 1
  rewrites: 8330 in 12ms cpu (12ms real) (694166 rewrites/second)
  result NzNat: 89

  No more solutions.
  rewrites: 8469 in 12ms cpu (13ms real) (705750 rewrites/second)
)