aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrhiannon morris2022-10-24 06:48:36 +0000
committerrhiannon morris2022-10-24 06:48:55 +0000
commitdcf99fd7ebf54474ea6d81ced6e00c28fba614fa (patch)
tree9c97ee122a3a9931ca6e74083212fea5e448151c
parentca09b8229ba680d5e5400ed72b121e8302990dab (diff)
add maude & ATS
-rw-r--r--entries/lizard-business/fib.dats25
-rw-r--r--entries/lizard-business/fib.maude27
-rw-r--r--people.json15
3 files changed, 67 insertions, 0 deletions
diff --git a/entries/lizard-business/fib.dats b/entries/lizard-business/fib.dats
new file mode 100644
index 0000000..f6bd5a1
--- /dev/null
+++ b/entries/lizard-business/fib.dats
@@ -0,0 +1,25 @@
+#include "share/atspre_define.hats"
+#include "share/atspre_staload.hats"
+
+dataprop is_fib(int, int) =
+| F0(0, 0) | F1(1, 1)
+| {i, m, n : nat} Fplus(i + 2, m + n) of (is_fib(i, m), is_fib(i + 1, n))
+
+typedef fib(i : int) = [n : nat] (is_fib(i, n) | int(n))
+
+
+fun fib {t : nat} .<>. (t : int(t)) :<> fib(t) =
+let
+ fun go {m, n, i : nat | i <= t} .<t - i>.
+ (M : is_fib(i, m), N : is_fib(i + 1, n) |
+ m : int(m), n : int(n), i : int(i)) :<>
+ fib(t) =
+ if i = t then (M | m)
+ else go(N, Fplus(M, N) | n, m + n, i + 1)
+in
+ go(F0, F1 | 0, 1, 0)
+end
+
+fun fib_(i : Nat) : Nat = let val (_ | res) = fib(i) in res end
+
+implement main0 () = println!("fib(15) = ", fib_(15))
diff --git a/entries/lizard-business/fib.maude b/entries/lizard-business/fib.maude
new file mode 100644
index 0000000..20bc428
--- /dev/null
+++ b/entries/lizard-business/fib.maude
@@ -0,0 +1,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)
+)
diff --git a/people.json b/people.json
index cc5e8e3..526da06 100644
--- a/people.json
+++ b/people.json
@@ -71,6 +71,21 @@
]
},
{
+ "github": "lizard-business",
+ "name": "rhiannon morris",
+ "title": "amateur type system liker",
+ "entries": [
+ {
+ "name": "maude",
+ "link": "./entries/lizard-business/fib.maude"
+ },
+ {
+ "name": "ats",
+ "link": "./entries/lizard-business/fib.dats"
+ }
+ ]
+ },
+ {
"github": "margoseltzer",
"name": "Margo Seltzer",
"title": "Professor of Computer Science, UBC",