A categorical programming language
修订版 | c4d2e50723df88e4003105ab3e422a92a637778a (tree) |
---|---|
时间 | 2021-09-16 13:35:45 |
作者 | Corbin <cds@corb...> |
Commiter | Corbin |
movelist: Use 1 and 2 for the unit and Boolean types.
@@ -12,25 +12,25 @@ | ||
12 | 12 | ; constructors before trivial constructors. |
13 | 13 | (conde |
14 | 14 | ; Literal s and t. |
15 | - ((== expr 'conj) (== s (list 'pair 'truth 'truth)) (== t 'truth)) | |
16 | - ((== expr 'disj) (== s (list 'pair 'truth 'truth)) (== t 'truth)) | |
15 | + ((== expr 'conj) (== s (list 'pair '2 '2)) (== t '2)) | |
16 | + ((== expr 'disj) (== s (list 'pair '2 '2)) (== t '2)) | |
17 | 17 | ((== expr 'f-add) (== s (list 'pair 'F 'F)) (== t 'F)) |
18 | 18 | ((== expr 'f-mul) (== s (list 'pair 'F 'F)) (== t 'F)) |
19 | 19 | ; Compound before trivial. |
20 | 20 | ((== expr 'succ) (== s 'N) (== t 'N)) |
21 | - ((== expr 'zero) (== s 'unit) (== t 'N)) | |
22 | - ((== expr 't) (== s 'unit) (== t 'truth)) | |
23 | - ((== expr 'f) (== s 'unit) (== t 'truth)) | |
24 | - ((== expr 'not) (== s 'truth) (== t 'truth)) | |
25 | - ((== expr 'f-zero) (== s 'unit) (== t 'F)) | |
26 | - ((== expr 'f-one) (== s 'unit) (== t 'F)) | |
21 | + ((== expr 'zero) (== s '1) (== t 'N)) | |
22 | + ((== expr 't) (== s '1) (== t '2)) | |
23 | + ((== expr 'f) (== s '1) (== t '2)) | |
24 | + ((== expr 'not) (== s '2) (== t '2)) | |
25 | + ((== expr 'f-zero) (== s '1) (== t 'F)) | |
26 | + ((== expr 'f-one) (== s '1) (== t 'F)) | |
27 | 27 | ((== expr 'f-negate) (== s 'F) (== t 'F)) |
28 | - ((== expr 'f-sqrt) (== s 'F) (== t (list 'sum 'F 'unit))) | |
28 | + ((== expr 'f-sqrt) (== s 'F) (== t (list 'sum 'F '1))) | |
29 | 29 | ; Literal s, recursive t. |
30 | 30 | ((fresh (f x y) (== expr (list 'name f)) |
31 | - (== s 'unit) (== t (list 'hom x y)) (cammyo f x y))) | |
31 | + (== s '1) (== t (list 'hom x y)) (cammyo f x y))) | |
32 | 32 | ((fresh (x f) (== expr (list 'pr x f)) |
33 | - (== s 'N) (cammyo x 'unit t) (cammyo f t t))) | |
33 | + (== s 'N) (cammyo x '1 t) (cammyo f t t))) | |
34 | 34 | ; Parametric polymorphism with structural recursion on both sides. |
35 | 35 | ((== expr 'swap) (fresh (x y) (== s (list 'pair x y)) (== t (list 'pair y x)))) |
36 | 36 | ((== expr 'assl) |
@@ -39,18 +39,18 @@ | ||
39 | 39 | (fresh (x y z) (== s (list 'pair (list 'pair x y) z)) (== t (list 'pair x (list 'pair y z))))) |
40 | 40 | ; Compound before trivial. |
41 | 41 | ((== expr 'cons) (fresh (l) (== s (list 'pair l t)) (== t (list 'list l)))) |
42 | - ((== expr 'nil) (== s 'unit) (fresh (l) (== t (list 'list l)))) | |
42 | + ((== expr 'nil) (== s '1) (fresh (l) (== t (list 'list l)))) | |
43 | 43 | ((fresh (f y z) (== expr (list 'curry f)) |
44 | 44 | (== t (list 'hom y z)) (cammyo f (list 'pair s y) z))) |
45 | 45 | ((fresh (f x y) (== expr (list 'uncurry f)) |
46 | 46 | (== s (list 'pair x y)) (cammyo f x (list 'hom y t)))) |
47 | 47 | ((fresh (x f l) (== expr (list 'fold x f)) |
48 | - (== s (list 'list l)) (cammyo x 'unit t) (cammyo f (list 'pair l t) t))) | |
48 | + (== s (list 'list l)) (cammyo x '1 t) (cammyo f (list 'pair l t) t))) | |
49 | 49 | ((fresh (f x y) (== expr (list 'map f)) |
50 | 50 | (== s (list 'list x)) (== t (list 'list y)) (cammyo f x y))) |
51 | 51 | ; Literal t. But this is too easy of an answer, so we don't want it at the |
52 | 52 | ; top of the list. |
53 | - ((== expr 'ignore) (== t 'unit)) | |
53 | + ((== expr 'ignore) (== t '1)) | |
54 | 54 | ; Parametric polymorphism on both sides, but one side recurses. |
55 | 55 | ((== expr 'fst) (fresh (x) (== s (list 'pair t x)))) |
56 | 56 | ((== expr 'snd) (fresh (x) (== s (list 'pair x t)))) |