bookshelf/Bookshelf/Combinator/Aviary.lean

249 lines
4.6 KiB
Plaintext
Raw Normal View History

2023-05-04 22:37:54 +00:00
/-! # Bookshelf.Combinator.Aviary
A collection of combinator birds representable in Lean. Certain duplicators,
e.g. mockingbirds, are not directly expressible since they would require
encoding a signature in which an argument has types `α` *and* `αα`.
Duplicators that are included, e.g. the warbler, are not exactly correct
considering they still have the same limitation described above during actual
use. Their inclusion here serves more as pseudo-documentation than anything.
[^1]: Smullyan, Raymond M. To Mock a Mockingbird: And Other Logic Puzzles
Including an Amazing Adventure in Combinatory Logic. Oxford: Oxford
university press, 2000.
-/
2023-05-07 16:40:20 +00:00
/-- #### Bald Eagle
`E'xy₁y₂y₃z₁z₂z₃ = x(y₁y₂y₃)(z₁z₂z₃)`
-/
def E' (x : α → β → γ)
(y₁ : δ → ε → α) (y₂ : δ) (y₃ : ε)
(z₁ : ζ → η → β) (z₂ : ζ) (z₃ : η) := x (y₁ y₂ y₃) (z₁ z₂ z₃)
2023-05-07 16:40:20 +00:00
/-- #### Becard
`B₃xyzw = x(y(zw))`
-/
def B₃ (x : α → ε) (y : β → α) (z : γ → β) (w : γ) := x (y (z w))
2023-05-07 16:40:20 +00:00
/-- #### Blackbird
`B₁xyzw = x(yzw)`
-/
def B₁ (x : α → ε) (y : β → γα) (z : β) (w : γ) := x (y z w)
2023-05-07 16:40:20 +00:00
/-- #### Bluebird
`Bxyz = x(yz)`
-/
def B (x : αγ) (y : β → α) (z : β) := x (y z)
2023-05-07 16:40:20 +00:00
/-- #### Bunting
`B₂xyzwv = x(yzwv)`
-/
def B₂ (x : α → ζ) (y : β → γ → ε → α) (z : β) (w : γ) (v : ε) := x (y z w v)
2023-05-07 16:40:20 +00:00
/-- #### Cardinal Once Removed
`C*xyzw = xywz`
-/
def C_star (x : α → β → γ → δ) (y : α) (z : γ) (w : β) := x y w z
notation "C*" => C_star
2023-05-07 16:40:20 +00:00
/-- #### Cardinal
`Cxyz = xzy`
-/
def C (x : α → β → δ) (y : β) (z : α) := x z y
2023-05-07 16:40:20 +00:00
/-- #### Converse Warbler
`W'xy = yxx`
-/
def W' (x : α) (y : αα → β) := y x x
2023-05-07 16:40:20 +00:00
/-- #### Dickcissel
`D₁xyzwv = xyz(wv)`
-/
def D₁ (x : α → β → δ → ε) (y : α) (z : β) (w : γ → δ) (v : γ) := x y z (w v)
2023-05-07 16:40:20 +00:00
/-! #### Double Mockingbird
`M₂xy = xy(xy)`
-/
/-- #### Dove
`Dxyzw = xy(zw)`
-/
def D (x : αγ → δ) (y : α) (z : β → γ) (w : β) := x y (z w)
2023-05-07 16:40:20 +00:00
/-- #### Dovekie
`D₂xyzwv = x(yz)(wv)`
-/
def D₂ (x : α → δ → ε) (y : β → α) (z : β) (w : γ → δ) (v : γ) := x (y z) (w v)
2023-05-07 16:40:20 +00:00
/-- #### Eagle
`Exyzwv = xy(zwv)`
-/
def E (x : α → δ → ε) (y : α) (z : β → γ → δ) (w : β) (v : γ) := x y (z w v)
2023-05-07 16:40:20 +00:00
/-- #### Finch Once Removed
`F*xyzw = xwzy`
-/
def F_star (x : α → β → γ → δ) (y : γ) (z : β) (w : α) := x w z y
notation "F*" => F_star
2023-05-07 16:40:20 +00:00
/-- #### Finch
`Fxyz = zyx`
-/
def F (x : α) (y : β) (z : β → αγ) := z y x
2023-05-07 16:40:20 +00:00
/-- #### Goldfinch
`Gxyzw = xw(yz)`
-/
def G (x : αγ → δ) (y : β → γ) (z : β) (w : α) := x w (y z)
2023-05-07 16:40:20 +00:00
/-- #### Hummingbird
`Hxyz = xyzy`
-/
def H (x : α → β → αγ) (y : α) (z : β) := x y z y
2023-05-07 16:40:20 +00:00
/-- #### Identity Bird
`Ix = x`
-/
def I (x : α) : α := x
2023-05-07 16:40:20 +00:00
/-- #### Kestrel
`Kxy = x`
-/
def K (x : α) (_ : β) := x
2023-05-07 16:40:20 +00:00
/-! #### Lark
`Lxy = x(yy)`
-/
/-! #### Mockingbird
`Mx = xx`
-/
/-- #### Owl
`Oxy = y(xy)`
-/
def O (x : (α → β) → α) (y : α → β) := y (x y)
2023-05-07 16:40:20 +00:00
/-- #### Phoenix
`Φxyzw = x(yw)(zw)`
-/
def Φ (x : β → γ → δ) (y : α → β) (z : αγ) (w : α) := x (y w) (z w)
2023-05-07 16:40:20 +00:00
/-- #### Psi Bird
`Ψxyzw = x(yz)(yw)`
-/
def Ψ (x : ααγ) (y : β → α) (z : β) (w : β) := x (y z) (y w)
2023-05-07 16:40:20 +00:00
/-- #### Quacky Bird
`Q₄xyz = z(yx)`
-/
def Q₄ (x : α) (y : α → β) (z : β → γ) := z (y x)
2023-05-07 16:40:20 +00:00
/-- #### Queer Bird
`Qxyz = y(xz)`
-/
def Q (x : α → β) (y : β → γ) (z : α) := y (x z)
2023-05-07 16:40:20 +00:00
/-- #### Quirky Bird
`Q₃xyz = z(xy)`
-/
def Q₃ (x : α → β) (y : α) (z : β → γ) := z (x y)
2023-05-07 16:40:20 +00:00
/-- #### Quixotic Bird
`Q₁xyz = x(zy)`
-/
def Q₁ (x : αγ) (y : β) (z : β → α) := x (z y)
2023-05-07 16:40:20 +00:00
/-- #### Quizzical Bird
`Q₂xyz = y(zx)`
-/
def Q₂ (x : α) (y : β → γ) (z : α → β) := y (z x)
2023-05-07 16:40:20 +00:00
/-- #### Robin Once Removed
`R*xyzw = xzwy`
-/
def R_star (x : α → β → γ → δ) (y : γ) (z : α) (w : β) := x z w y
notation "R*" => R_star
2023-05-07 16:40:20 +00:00
/-- #### Robin
`Rxyz = yzx`
-/
def R (x : α) (y : β → αγ) (z : β) := y z x
2023-05-07 16:40:20 +00:00
/-- #### Sage Bird
`Θx = x(Θx)`
-/
partial def Θ [Inhabited α] (x : αα) := x (Θ x)
2023-05-07 16:40:20 +00:00
/-- #### Starling
`Sxyz = xz(yz)`
-/
def S (x : α → β → γ) (y : α → β) (z : α) := x z (y z)
2023-05-07 16:40:20 +00:00
/-- #### Thrush
`Txy = yx`
-/
def T (x : α) (y : α → β) := y x
2023-05-07 16:40:20 +00:00
/-! #### Turing Bird
`Uxy = y(xxy)`
-/
/-- #### Vireo Once Removed
`V*xyzw = xwyz`
-/
def V_star (x : α → β → γ → δ) (y : β) (z : γ) (w : α) := x w y z
notation "V*" => V_star
2023-05-07 16:40:20 +00:00
/-- #### Vireo
`Vxyz = zxy`
-/
def V (x : α) (y : β) (z : α → β → γ) := z x y
2023-05-07 16:40:20 +00:00
/-- #### Warbler
`Wxy = xyy`
-/
def W (x : αα → β) (y : α) := x y y