aboutsummaryrefslogtreecommitdiffhomepage
path: root/readme.md
blob: c64fd84ea2b65dc824d0e8e2946a22837ce07f23 (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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# Birb

Birb is an *advanced* programming language that only consists of bird
emojis ๐Ÿฃ. Each emoji gets substituted by a [*combinator
bird*](https://www.angelfire.com/tx4/cus/combinator/birds.html) of pure
lambda calculus.

## Birbs

Unfortunately, the Unicode standard does not yet have many
(single-character) birds. These are the ones currently mapped/supported:

| emoji | animal         | combinator   | bruijn              | term                               |
|:-----:|----------------|--------------|---------------------|------------------------------------|
|  ๐Ÿฆ‰   | owl            | owl          | `[[0(10)]]`         | $\lambda ab.b(ab)$                 |
|  ๐Ÿฆ…   | eagle          | eagle        | `[[[[[43(210)]]]]]` | $\lambda abcde.ab(cde)$            |
|  ๐Ÿชฝ   | wing           | phoenix      | `[[[[3(20)(10)]]]]` | $\lambda abcd.a(bd)(cd)$           |
|  ๐Ÿ•Š๏ธ   | dove           | dove         | `[[[[32(10)]]]]`    | $\lambda abcd.ab(cd)$              |
|  ๐Ÿฆœ   | parrot         | mockingbird  | `[00]`              | $\lambda a.aa$                     |
|  ๐Ÿฆ†   | duck           | quacky       | `[[[0(12)]]]`       | $\lambda abc.c(ba)$                |
|  ๐Ÿค   | touring chick  | turing       | `[[0(110)]]`        | $\lambda ab.b(aab)$                |
|  ๐Ÿฅ   | kool chick     | kestrel      | `[[1]]`             | $\lambda ab.a$                     |
|  ๐Ÿฃ   | hatching chick | quirky       | `[[[0(21)]]]`       | $\lambda abc.c(ab)$                |
|  ๐Ÿฆ   | simple bird    | identity     | `[0]`               | $\lambda a.a$                      |
|  ๐Ÿฆš   | peacock        | queer        | `[[[1(20)]]]`       | $\lambda abc.b(ac)$                |
|  ๐Ÿฆค   | dodo           | sage         | `[[0(11)][0(11)]]`  | $\lambda ab.b(aa)\lambda ab.b(aa)$ |
|  ๐Ÿง   | penguin        | blackbird    | `[[[2(10)]]]`       | $\lambda abc.a(bc)$                |
|  ๐Ÿฆข   | swan           | substitution | `[[[20(10)]]]`      | $\lambda abc.ac(bc)$               |
|  ๐Ÿฆฉ   | flamingo       | cardinal     | `[[[201]]]`         | $\lambda abc.acb$                  |

Lonely/unmatched birbs: ๐Ÿ”๐Ÿฆƒ๐Ÿ“

# Syntax

- `[birb]+`: Birb
- everything else: Comment

# Semantics

Birbs stagger as they walk: they are reduced in alternating associative
order, starting with birb index $\lfloor\frac{\texttt{len}}{2}\rfloor$:

    ๐Ÿฆ๐Ÿฆ -> (๐Ÿฆ๐Ÿฆ)
    ๐Ÿฆ๐Ÿฆ๐Ÿฆ -> ((๐Ÿฆ๐Ÿฆ)๐Ÿฆ)
    ๐Ÿฆ๐Ÿฆ๐Ÿฆ๐Ÿฆ -> (๐Ÿฆ((๐Ÿฆ๐Ÿฆ)๐Ÿฆ))
    ๐Ÿฆ๐Ÿฆ๐Ÿฆ๐Ÿฆ๐Ÿฆ -> ((๐Ÿฆ((๐Ÿฆ๐Ÿฆ)๐Ÿฆ))๐Ÿฆ)
    ๐Ÿฆ๐Ÿฆ๐Ÿฆ๐Ÿฆ๐Ÿฆ๐Ÿฆ -> (๐Ÿฆ((๐Ÿฆ((๐Ÿฆ๐Ÿฆ)๐Ÿฆ))๐Ÿฆ))
    ๐Ÿฆ๐Ÿฆ๐Ÿฆ๐Ÿฆ๐Ÿฆ๐Ÿฆ๐Ÿฆ -> ((๐Ÿฆ((๐Ÿฆ((๐Ÿฆ๐Ÿฆ)๐Ÿฆ))๐Ÿฆ))๐Ÿฆ)

# Examples

You can find more examples in the `samples/` directory.

## Relationships

- ๐Ÿฆ‰๐Ÿฆ $\rightsquigarrow$ ๐Ÿฆœ
- ๐Ÿฆข๐Ÿฆ $\rightsquigarrow$ ๐Ÿฆ‰
- ๐Ÿง๐Ÿง $\rightsquigarrow$ ๐Ÿ•Š๏ธ
- ๐Ÿฆฉ๐Ÿง $\rightsquigarrow$ ๐Ÿฆš
- ๐Ÿฆฉ๐Ÿฆš $\rightsquigarrow$ ๐Ÿง

One can only imagine what happens if two parrots repeat each other: ๐Ÿฆœ๐Ÿฆœ
$\rightsquigarrow$ ๐Ÿ’ฅ

## Arithmetic

For this example I use the Church numerals. Zero would then be encoded
as ๐Ÿฅ๐Ÿฆ. The successor function can be written as ๐Ÿฆข๐Ÿง:

- ๐Ÿฆ๐Ÿง๐Ÿฆ๐Ÿฆข๐Ÿง๐Ÿฅ๐Ÿฆ $\rightsquigarrow$ ฮปฮป(10) โ€“ (Church numeral 1)
- ๐Ÿฆ๐Ÿง๐Ÿฆ๐Ÿง๐Ÿ•Š๏ธ๐Ÿฆข๐Ÿง๐Ÿฆข๐Ÿง๐Ÿฅ๐Ÿฆ $\rightsquigarrow$ ฮปฮป(1(10)) โ€“ (Church numeral
  2)  

Similarly, one can very obviously translate the Church addition function
to ๐Ÿง๐Ÿฆข๐Ÿฅ๐Ÿฆข๐Ÿ•Š๏ธ. Now, to calculate $1+2$ based on their increments from
zero:

- ๐Ÿฆข๐Ÿง๐Ÿฆข๐Ÿง๐Ÿฅ๐Ÿฆ

Also: ๐Ÿง is $a\cdot b$, ๐Ÿฆœ is $n^n$ and ๐Ÿฆš๐Ÿฆ $a^b$.

Note that there are many alternative ways to do arithmetic. Try writing
the functions above with other birbs!

## Busy ~~beavers~~ birbs

- The touring eagle: ๐Ÿฆ๐Ÿฆ๐Ÿฆ๐Ÿฆ…๐Ÿค๐Ÿฆ…๐Ÿค๐Ÿฆ…๐Ÿค (~20M BLC bits)
- more? PR!

# Usage

Install [Haskellโ€™s
stack](https://docs.haskellstack.org/en/stable/install_and_upgrade/).
Then,

- `stack run -- file.birb` or `stack run <(echo ๐Ÿง๐Ÿง)`
- `stack install` so you can enjoy `birb` from anywhere

If the output cannot be translated to birbs, the raw lambda calculus
term (with De Bruijn indices) is printed. For the examples above I
sometimes manually converted the term back to birbs.

# Turing-completeness

The language is probably Turing complete. If the language supported
left- *and* right-associativity, ๐Ÿง would be enough to prove its
completeness.

------------------------------------------------------------------------

The idea of the language was originally proposed in 2021 by an
unknown(?) author on [Esolang](https://esolangs.org/wiki/Birb).