i might submit these here, if i can be bothered to get a new github account.
maude
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)
ats
#include "share/atspre_define.hats"
#include "share/atspre_staload.hats"
// is_fib(i, n): n is the i-th fibonacci number
dataprop is_fib(int, int) =
0, 0) | F1(1, 1)
| F0(: nat} Fplus(i + 2, m + n) of (is_fib(i, m), is_fib(i + 1, n))
| {i, m, n
typedef fib(i : int) = [n : nat] (is_fib(i, n) | int(n))
fun fib {t : nat} .<>. (t : int(t)) :<> fib(t) =
let
// m, n : accs
// i : index of m
// t : target index
fun go {m, n, i, t : nat | i <= t} .<t - i>.
: is_fib(i, m), N : is_fib(i + 1, n) |
(M : int(m), n : int(n), i : int(i), t : int(t)) :<>
m =
fib(t) if i = t then
(M | m)else
1, t)
go(N, Fplus(M, N) | n, m + n, i + in
0, 1, 0, t)
go(F0, F1 | end
fun fib_(i : Nat) : Nat = let val (_ | res) = fib(i) in res end
implement main0() = println!("fib(15) = ", fib_(15))
$ make fib
$ ./fib
fib(15) = 610
same makefile as last time.