Skip to content

Commit e0e5a5c

Browse files
committedJul 11, 2021
Initial commit
0 parents  commit e0e5a5c

24 files changed

+2784
-0
lines changed
 

‎.gitignore

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Agda
2+
*.agdai
3+
4+
# Emacs
5+
\#*#

‎CombinatoryLogic/Equality.agda

+139
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
-- Kapitel 1, Abschnitt D (Die Eigenschaften der Gleichheit)
2+
module CombinatoryLogic.Equality where
3+
4+
open import Algebra.Definitions using (Congruent₂; LeftCongruent; RightCongruent)
5+
open import Data.Vec using (Vec; []; _∷_; foldr₁; lookup)
6+
open import Function using (_$_)
7+
open import Relation.Binary using (IsEquivalence; Setoid)
8+
open import Relation.Binary.PropositionalEquality using (_≡_; refl)
9+
10+
open import CombinatoryLogic.Semantics
11+
open import CombinatoryLogic.Syntax
12+
13+
private
14+
-- A lemma used in the proofs of Propositions 1 and 2.
15+
lemma-CQXX : {X} ⊢ C ∙ Q ∙ X ∙ X
16+
lemma-CQXX {X} =
17+
let s₁ = ⊢ Π ∙ (W ∙ (C ∙ Q)) [ ax Q ]
18+
s₂ = ⊢ W ∙ (C ∙ Q) ∙ X [ Π s₁ ]
19+
s₃ = ⊢ Q ∙ (W ∙ (C ∙ Q) ∙ X) ∙ (C ∙ Q ∙ X ∙ X) [ W ]
20+
s₄ = ⊢ C ∙ Q ∙ X ∙ X [ Q₁ s₂ s₃ ]
21+
in s₄
22+
23+
-- Satz 1
24+
prop₁ : {X} ⊢ Q ∙ X ∙ X
25+
prop₁ {X} = s₆ where
26+
s₄ = ⊢ C ∙ Q ∙ X ∙ X [ lemma-CQXX ]
27+
s₅ = ⊢ Q ∙ (C ∙ Q ∙ X ∙ X) ∙ (Q ∙ X ∙ X) [ C ]
28+
s₆ = ⊢ Q ∙ X ∙ X [ Q₁ s₄ s₅ ]
29+
30+
-- Satz 2
31+
prop₂ : {X Y} ⊢ Q ∙ X ∙ Y ⊢ Q ∙ Y ∙ X
32+
prop₂ {X} {Y} ⊢QXY = s₅ where
33+
s₁ = ⊢ Q ∙ X ∙ Y [ ⊢QXY ]
34+
-- NOTE: Curry's proof contains a mistake: CQXX should be CQXY.
35+
s₂ = ⊢ Q ∙ (C ∙ Q ∙ X ∙ X) ∙ (C ∙ Q ∙ X ∙ Y) [ Q₂ {Z = C ∙ Q ∙ X} s₁ ]
36+
s₃ = ⊢ C ∙ Q ∙ X ∙ X [ lemma-CQXX ]
37+
-- NOTE: Curry's proof uses rule Q, but there is no such rule.
38+
s₄ = ⊢ C ∙ Q ∙ X ∙ Y [ Q₁ s₃ s₂ ]
39+
s₅ = ⊢ Q ∙ Y ∙ X [ Q₁ s₄ C ]
40+
41+
-- Satz 3
42+
prop₃ : {X Y Z} ⊢ Q ∙ X ∙ Y ⊢ Q ∙ Y ∙ Z ⊢ Q ∙ X ∙ Z
43+
prop₃ {X} {Y} {Z} ⊢QXY ⊢QYZ = s₃ where
44+
s₁ = ⊢ Q ∙ Y ∙ Z [ ⊢QYZ ]
45+
s₂ = ⊢ Q ∙ (Q ∙ X ∙ Y) ∙ (Q ∙ X ∙ Z) [ Q₂ {Z = Q ∙ X} s₁ ]
46+
s₃ = ⊢ Q ∙ X ∙ Z [ Q₁ ⊢QXY s₂ ]
47+
48+
-- Satz 4
49+
prop₄ : {X Y Z} ⊢ Q ∙ X ∙ Y ⊢ Q ∙ (X ∙ Z) ∙ (Y ∙ Z)
50+
prop₄ {X} {Y} {Z} Hp = s₅ where
51+
p₁ = λ {X} ⊢ Q ∙ (C ∙ (B ∙ (W ∙ K)) ∙ Z ∙ X) ∙ (B ∙ (W ∙ K) ∙ X ∙ Z) [ C ]
52+
p₂ = λ {X} ⊢ Q ∙ (B ∙ (W ∙ K) ∙ X ∙ Z) ∙ (W ∙ K ∙ (X ∙ Z)) [ B ]
53+
p₃ = λ {X} ⊢ Q ∙ (W ∙ K ∙ (X ∙ Z)) ∙ (K ∙ (X ∙ Z) ∙ (X ∙ Z)) [ W ]
54+
p₄ = λ {X} ⊢ Q ∙ (K ∙ (X ∙ Z) ∙ (X ∙ Z)) ∙ (X ∙ Z) [ K ]
55+
p₅ = λ {X} ⊢ Q ∙ (C ∙ (B ∙ (W ∙ K)) ∙ Z ∙ X) ∙ (X ∙ Z) [ prop₃ p₁ $ prop₃ p₂ $ prop₃ p₃ p₄ ]
56+
s₁ = ⊢ Q ∙ (C ∙ (B ∙ (W ∙ K)) ∙ Z ∙ X) ∙ (C ∙ (B ∙ (W ∙ K)) ∙ Z ∙ Y) [ Q₂ Hp ]
57+
s₂ = ⊢ Q ∙ (C ∙ (B ∙ (W ∙ K)) ∙ Z ∙ X) ∙ (X ∙ Z) [ p₅ ]
58+
s₃ = ⊢ Q ∙ (C ∙ (B ∙ (W ∙ K)) ∙ Z ∙ Y) ∙ (Y ∙ Z) [ p₅ ]
59+
s₄ = ⊢ Q ∙ (X ∙ Z) ∙ (C ∙ (B ∙ (W ∙ K)) ∙ Z ∙ X) [ prop₂ s₂ ]
60+
s₅ = ⊢ Q ∙ (X ∙ Z) ∙ (Y ∙ Z) [ prop₃ s₄ $ prop₃ s₁ s₃ ]
61+
62+
-- Satz 5
63+
prop₅ : {X Y} X ≡ Y ⊢ Q ∙ X ∙ Y
64+
prop₅ {X} {Y} refl = prop₁
65+
66+
-- Satz 6 (first part)
67+
isEquivalence : IsEquivalence _≈_
68+
isEquivalence = record
69+
{ refl = prop₁
70+
; sym = prop₂
71+
; trans = prop₃
72+
}
73+
74+
setoid : Setoid _ _
75+
setoid = record
76+
{ Carrier = Combinator
77+
; _≈_ = _≈_
78+
; isEquivalence = isEquivalence
79+
}
80+
81+
module Reasoning where
82+
module = IsEquivalence isEquivalence
83+
import Relation.Binary.Reasoning.Base.Single _≈_ ≈.refl ≈.trans as Base
84+
open Base using (begin_; _∎) public
85+
86+
infixr 2 _≈⟨⟩_ step-≈ step-≈˘
87+
88+
_≈⟨⟩_ : x {y} x Base.IsRelatedTo y x Base.IsRelatedTo y
89+
_ ≈⟨⟩ x≈y = x≈y
90+
91+
step-≈ = Base.step-∼
92+
syntax step-≈ x y≈z x≈y = x ≈⟨ x≈y ⟩ y≈z
93+
94+
step-≈˘ : x {y z} y Base.IsRelatedTo z y ≈ x x Base.IsRelatedTo z
95+
step-≈˘ x y∼z y≈x = x ≈⟨ ≈.sym y≈x ⟩ y∼z
96+
syntax step-≈˘ x y≈z y≈x = x ≈˘⟨ y≈x ⟩ y≈z
97+
98+
-- Satz 6 (second part)
99+
∙-cong : Congruent₂ _≈_ _∙_
100+
∙-cong {X} {X′} {Y} {Y′} ⊢X==X′ ⊢Y==Y′ = s₃ where
101+
s₁ = ⊢ X ∙ Y == X ∙ Y′ [ Q₂ ⊢Y==Y′ ]
102+
s₂ = ⊢ X ∙ Y′ == X′ ∙ Y′ [ prop₄ ⊢X==X′ ]
103+
s₃ = ⊢ X ∙ Y == X′ ∙ Y′ [ prop₃ s₁ s₂ ]
104+
105+
-- ∙-congˡ and ∙-congʳ follow from ∙-cong, but are also just different names for
106+
-- Q₂ and prop₄, respectively.
107+
∙-congˡ : LeftCongruent _≈_ _∙_
108+
∙-congˡ = Q₂
109+
110+
∙-congʳ : RightCongruent _≈_ _∙_
111+
∙-congʳ = prop₄
112+
113+
-- TODO: Satz 7, 8
114+
115+
prop₉ : {X} ⊢ I ∙ X == X
116+
prop₉ {X} = begin
117+
I ∙ X ≈⟨⟩
118+
W ∙ K ∙ X ≈⟨ W ⟩
119+
K ∙ X ∙ X ≈⟨ K ⟩
120+
X ∎
121+
where open Reasoning
122+
123+
-- Note after the proof of Satz 9.
124+
S : Combinator
125+
S = B ∙ (B ∙ W) ∙ (B ∙ B ∙ C)
126+
127+
prop-S : {X} {Y} {Z} ⊢ S ∙ X ∙ Y ∙ Z == X ∙ Z ∙ (Y ∙ Z)
128+
prop-S {X} {Y} {Z} = begin
129+
S ∙ X ∙ Y ∙ Z ≈⟨⟩
130+
B ∙ (B ∙ W) ∙ (B ∙ B ∙ C) ∙ X ∙ Y ∙ Z ≈⟨ ∙-congʳ $ ∙-congʳ B ⟩
131+
B ∙ W ∙ (B ∙ B ∙ C ∙ X) ∙ Y ∙ Z ≈⟨ ∙-congʳ B ⟩
132+
W ∙ (B ∙ B ∙ C ∙ X ∙ Y) ∙ Z ≈⟨ W ⟩
133+
B ∙ B ∙ C ∙ X ∙ Y ∙ Z ∙ Z ≈⟨ ∙-congʳ $ ∙-congʳ $ ∙-congʳ B ⟩
134+
B ∙ (C ∙ X) ∙ Y ∙ Z ∙ Z ≈⟨ ∙-congʳ B ⟩
135+
C ∙ X ∙ (Y ∙ Z) ∙ Z ≈⟨ C ⟩
136+
X ∙ Z ∙ (Y ∙ Z) ∎
137+
where open Reasoning
138+
139+
-- TODO: ⊢ B == S(KS)K, ⊢ C == S(BBS)(KK), ⊢ W == SS(SK), ⊢ I == SKK

‎CombinatoryLogic/Forest.agda

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
module CombinatoryLogic.Forest where
2+
3+
open import Data.Product using (_,_)
4+
open import Function using (_$_)
5+
open import Mockingbird.Forest using (Forest)
6+
7+
open import CombinatoryLogic.Equality as Equality using (isEquivalence; ∙-cong)
8+
open import CombinatoryLogic.Semantics as ⊢ using (_≈_)
9+
open import CombinatoryLogic.Syntax as Syntax using (Combinator)
10+
11+
forest : Forest
12+
forest = record
13+
{ Bird = Combinator
14+
; _≈_ = _≈_
15+
; _∙_ = Syntax._∙_
16+
; isForest = record
17+
{ isEquivalence = isEquivalence
18+
; ∙-cong = ∙-cong
19+
}
20+
}
21+
22+
open Forest forest
23+
24+
open import Mockingbird.Forest.Birds forest
25+
open import Mockingbird.Forest.Extensionality forest
26+
import Mockingbird.Problems.Chapter11 forest as Chapter₁₁
27+
import Mockingbird.Problems.Chapter12 forest as Chapter₁₂
28+
29+
instance
30+
hasWarbler : HasWarbler
31+
hasWarbler = record
32+
{ W = Syntax.W
33+
; isWarbler = λ _ _ ⊢.W
34+
}
35+
36+
hasKestrel : HasKestrel
37+
hasKestrel = record
38+
{ K = Syntax.K
39+
; isKestrel = λ _ _ ⊢.K
40+
}
41+
42+
hasBluebird : HasBluebird
43+
hasBluebird = record
44+
{ B = Syntax.B
45+
; isBluebird = λ _ _ _ ⊢.B
46+
}
47+
48+
hasIdentity : HasIdentity
49+
hasIdentity = record
50+
{ I = Syntax.I
51+
; isIdentity = λ _ Equality.prop₉
52+
}
53+
54+
hasMockingbird : HasMockingbird
55+
hasMockingbird = Chapter₁₁.problem₁₄
56+
57+
hasLark : HasLark
58+
hasLark = Chapter₁₂.problem₃
59+
60+
hasComposition : HasComposition
61+
hasComposition = Chapter₁₁.problem₁

‎CombinatoryLogic/Semantics.agda

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
module CombinatoryLogic.Semantics where
2+
3+
open import Relation.Binary using (Rel)
4+
5+
open import CombinatoryLogic.Syntax
6+
7+
-- Kapitel 1, Abschnitt C, §5 (Axiome)
8+
data Axiom : Combinator Set where
9+
Q : Axiom (Π ∙ (W ∙ (C ∙ Q)))
10+
B : Axiom (C ∙ (B ∙ B ∙ (B ∙ B ∙ B)) ∙ B == B ∙ (B ∙ B) ∙ B)
11+
C : Axiom (C ∙ (B ∙ B ∙ (B ∙ B ∙ B)) ∙ W ∙ C == B ∙ (B ∙ C) ∙ (B ∙ B ∙ B))
12+
W : Axiom (C ∙ (B ∙ B ∙ B) ∙ W == B ∙ (B ∙ W) ∙ (B ∙ B ∙ B))
13+
-- NOTE (Curry): this axiom can be proved from the others.
14+
I₁ : Axiom (C ∙ (B ∙ B ∙ B) ∙ K == B ∙ (B ∙ K) ∙ I)
15+
BC : Axiom (B ∙ B ∙ C == B ∙ (B ∙ (B ∙ C) ∙ C) ∙ (B ∙ B))
16+
BW : Axiom (B ∙ B ∙ W == B ∙ (B ∙ (B ∙ (B ∙ (B ∙ W) ∙ W) ∙ (B ∙ C)) ∙ B ∙ (B ∙ B)) ∙ B)
17+
BK : Axiom (B ∙ B ∙ K == B ∙ K ∙ K)
18+
CC₁ : Axiom (B ∙ C ∙ C ∙ B ∙ (B ∙ I))
19+
CC₂ : Axiom (B ∙ (B ∙ (B ∙ C) ∙ C) ∙ (B ∙ C) == B ∙ (B ∙ C ∙ (B ∙ C)) ∙ C)
20+
CW : Axiom (B ∙ C ∙ W == B ∙ (B ∙ (B ∙ W) ∙ C) ∙ (B ∙ C))
21+
CK : Axiom (B ∙ C ∙ K == B ∙ K)
22+
WC : Axiom (B ∙ W ∙ C == W)
23+
WW : Axiom (B ∙ W ∙ W == B ∙ W ∙ (B ∙ W))
24+
WK : Axiom (B ∙ W ∙ K == B ∙ I)
25+
I₂ : Axiom (B ∙ I == I)
26+
27+
-- TODO: fixity definition
28+
infix 4 ⊢_
29+
30+
-- Kapitel 1, Abschnitt C, §4 (Symbolische Festsetzungen), Festsetzung 1
31+
data ⊢_ : Combinator Set where
32+
ax : {X} Axiom X ⊢ X
33+
34+
-- Kapitel 1, Abschnitt C, §6 (Regeln)
35+
Q₁ : {X Y} ⊢ X ⊢ X == Y ⊢ Y
36+
Q₂ : {X Y Z} ⊢ X == Y ⊢ Z ∙ X == Z ∙ Y
37+
Π : {X Y} ⊢ Π ∙ X ⊢ X ∙ Y
38+
B : {X Y Z} ⊢ B ∙ X ∙ Y ∙ Z == X ∙ (Y ∙ Z)
39+
C : {X Y Z} ⊢ C ∙ X ∙ Y ∙ Z == X ∙ Z ∙ Y
40+
W : {X Y} ⊢ W ∙ X ∙ Y == X ∙ Y ∙ Y
41+
K : {X Y} ⊢ K ∙ X ∙ Y == X
42+
P : {X Y} ⊢ X ⊢ P ∙ X ∙ Y ⊢ Y
43+
: {X Y} ⊢ X ⊢ Y ⊢ ∧ ∙ X ∙ Y
44+
45+
-- We introduce convenience notation for the equality defined in Kapitel 1,
46+
-- Abschnitt C, §4 (Symbolische Festsetzungen), Festsetzung 3 (Gleichheit).
47+
_≈_ : Rel Combinator _
48+
X ≈ Y = ⊢ X == Y
49+
50+
infix 0 _[_]
51+
52+
-- An operator that helps write proofs in the style of Curry. Where Curry writes
53+
-- ⟨statement⟩ (⟨rule⟩)
54+
-- we write
55+
-- ⟨statement⟩ [ ⟨rule⟩ ]
56+
--
57+
-- Later, we can also use the Agda standard library's reasoning combinators
58+
-- (e.g. _≈⟨_⟩_) for proving equalities, but not before it is shown that the
59+
-- equality _≈_ is an equivalence relation, which Curry does in propositions 1,
60+
-- 2 and 3 of Kapitel 1, Abschnitt D (Die Eigenschaften der Gleichheit).
61+
_[_] : {a} (A : Set a) (x : A) A
62+
_ [ x ] = x

‎CombinatoryLogic/Syntax.agda

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
module CombinatoryLogic.Syntax where
2+
3+
open import Data.String using (String; _++_)
4+
open import Relation.Binary.PropositionalEquality using (_≡_; refl)
5+
6+
-- Kapitel 1, Abschnitt C, §4 (Symbolische Festsetzungen), Def. 1
7+
infixl 6 _∙_
8+
9+
data Combinator : Set where
10+
-- Kapitel 1, Abschnitt C, §3 (Die formalen Grundbegriffe)
11+
B C W K Q Π P ∧ : Combinator
12+
-- Kapitel 1, Abschnitt C, §2, c (Anwendung)
13+
_∙_ : (X Y : Combinator) Combinator
14+
15+
-- NOTE: for the (intensional) equality defined by Kapitel 1, Abschnitt C, §4
16+
-- (Symbolische Festsetzungen), Festsetzung 2, we use the propositional equality
17+
-- _≡_.
18+
19+
toString : Combinator String
20+
toString (X ∙ Y@(_ ∙ _)) = toString X ++ "(" ++ toString Y ++ ")"
21+
toString (X ∙ Y) = toString X ++ toString Y
22+
toString B = "B"
23+
toString C = "C"
24+
toString W = "W"
25+
toString K = "K"
26+
toString Q = "Q"
27+
toString Π = "Π"
28+
toString P = "P"
29+
toString ∧ = "∧"
30+
31+
_ : toString (K ∙ Q ∙ (W ∙ C)) ≡ "KQ(WC)"
32+
_ = refl
33+
34+
_ : toString (K ∙ ∧ ∙ (Q ∙ Π) ∙ (W ∙ C)) ≡ "K∧(QΠ)(WC)"
35+
_ = refl
36+
37+
_ : toString (K ∙ ∧ ∙ ((Q ∙ Π) ∙ (W ∙ C))) ≡ "K∧(QΠ(WC))"
38+
_ = refl
39+
40+
_ : toString (K ∙ K ∙ K) ≡ "KKK"
41+
_ = refl
42+
43+
infix 5 _==_
44+
45+
-- Kapitel 1, Abschnitt C, §4 (Symbolische Festsetzungen), Def. 2
46+
_==_ : (X Y : Combinator) Combinator
47+
X == Y = Q ∙ X ∙ Y
48+
49+
-- Kapitel 1, Abschnitt C, §4 (Symbolische Festsetzungen), Def. 3
50+
I : Combinator
51+
I = W ∙ K

‎LICENCE

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Copyright © 2021 Splinter Suidman
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4+
5+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6+
7+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

‎Mockingbird/Forest.agda

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module Mockingbird.Forest where
2+
3+
open import Mockingbird.Forest.Base public

‎Mockingbird/Forest/Base.agda

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
module Mockingbird.Forest.Base where
2+
3+
open import Algebra using (Op₂; Congruent₂; LeftCongruent; RightCongruent)
4+
open import Level using (_⊔_) renaming (suc to lsuc)
5+
open import Relation.Binary using (Rel; IsEquivalence; Setoid)
6+
open import Relation.Nullary using (¬_)
7+
8+
record IsForest {b ℓ} (Bird : Set b) (_≈_ : Rel Bird ℓ) (_∙_ : Op₂ Bird) : Set (b ⊔ ℓ) where
9+
field
10+
isEquivalence : IsEquivalence _≈_
11+
∙-cong : Congruent₂ _≈_ _∙_
12+
13+
open IsEquivalence isEquivalence public
14+
15+
setoid : Setoid b ℓ
16+
setoid = record { isEquivalence = isEquivalence }
17+
18+
∙-congˡ : LeftCongruent _≈_ _∙_
19+
∙-congˡ A≈B = ∙-cong refl A≈B
20+
21+
∙-congʳ : RightCongruent _≈_ _∙_
22+
∙-congʳ A≈B = ∙-cong A≈B refl
23+
24+
record Forest {b ℓ} : Set (lsuc (b ⊔ ℓ)) where
25+
infix 4 _≈_
26+
infixl 6 _∙_
27+
28+
field
29+
Bird : Set b
30+
_≈_ : Rel Bird ℓ
31+
_∙_ : Op₂ Bird
32+
isForest : IsForest Bird _≈_ _∙_
33+
34+
_≉_ : Rel Bird ℓ
35+
x ≉ y = ¬ (x ≈ y)
36+
37+
open IsForest isForest public
38+
39+
import Relation.Binary.Reasoning.Base.Single _≈_ refl trans as Base
40+
open Base using (begin_; _∎) public
41+
42+
infixr 2 _≈⟨⟩_ step-≈ step-≈˘
43+
44+
_≈⟨⟩_ : x {y} x Base.IsRelatedTo y x Base.IsRelatedTo y
45+
_ ≈⟨⟩ x≈y = x≈y
46+
47+
step-≈ = Base.step-∼
48+
syntax step-≈ x y≈z x≈y = x ≈⟨ x≈y ⟩ y≈z
49+
50+
step-≈˘ : x {y z} y Base.IsRelatedTo z y ≈ x x Base.IsRelatedTo z
51+
step-≈˘ x y∼z y≈x = x ≈⟨ sym y≈x ⟩ y∼z
52+
syntax step-≈˘ x y≈z y≈x = x ≈˘⟨ y≈x ⟩ y≈z

‎Mockingbird/Forest/Birds.agda

+504
Large diffs are not rendered by default.

‎Mockingbird/Forest/Combination.agda

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
open import Mockingbird.Forest using (Forest)
2+
3+
module Mockingbird.Forest.Combination {b ℓ} (forest : Forest {b} {ℓ}) where
4+
5+
open import Mockingbird.Forest.Combination.Base public
+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
open import Mockingbird.Forest using (Forest)
2+
3+
module Mockingbird.Forest.Combination.Base {b ℓ} (forest : Forest {b} {ℓ}) where
4+
5+
open import Level using (Level; _⊔_)
6+
open import Relation.Unary using (Pred; _∈_)
7+
8+
open Forest forest
9+
10+
private
11+
variable
12+
p : Level
13+
x y z : Bird
14+
P : Pred Bird p
15+
16+
-- If P is a set of birds, we can think of ⟨ P ⟩ as the set of birds ‘generated
17+
-- by’ P.
18+
data ⟨_⟩ (P : Pred Bird p) : Bird Set (p ⊔ b ⊔ ℓ) where
19+
[_] : (x∈P : x ∈ P) x ∈ ⟨ P ⟩
20+
21+
_⟨∙⟩_∣_ :
22+
(x∈⟨P⟩ : x ∈ ⟨ P ⟩)
23+
(y∈⟨P⟩ : y ∈ ⟨ P ⟩)
24+
(xy≈z : x ∙ y ≈ z)
25+
z ∈ ⟨ P ⟩
26+
27+
infixl 6 _⟨∙⟩_
28+
_⟨∙⟩_ : x ∈ ⟨ P ⟩ y ∈ ⟨ P ⟩ x ∙ y ∈ ⟨ P ⟩
29+
_⟨∙⟩_ = _⟨∙⟩_∣ refl
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
open import Mockingbird.Forest using (Forest)
2+
3+
module Mockingbird.Forest.Combination.Properties {b ℓ} (forest : Forest {b} {ℓ}) where
4+
5+
open import Data.Product using (_×_; _,_)
6+
open import Relation.Binary using (_Respects_)
7+
open import Relation.Unary using (Pred; _∈_; _⊆_; ∅; _∩_)
8+
open import Level using (Level; _⊔_)
9+
10+
open Forest forest
11+
12+
open import Mockingbird.Forest.Combination.Base forest
13+
14+
private
15+
variable
16+
x y z : Bird
17+
p : Level
18+
P Q : Pred Bird p
19+
20+
subst : P Respects _≈_ x ≈ y x ∈ ⟨ P ⟩ y ∈ ⟨ P ⟩
21+
subst respects x≈y [ x∈P ] = [ respects x≈y x∈P ]
22+
subst respects x≈y (x₁∈⟨P⟩ ⟨∙⟩ x₂∈⟨P⟩ ∣ x₁x₂≈x) = x₁∈⟨P⟩ ⟨∙⟩ x₂∈⟨P⟩ ∣ trans x₁x₂≈x x≈y
23+
24+
subst′ : P Respects _≈_ y ≈ x x ∈ ⟨ P ⟩ y ∈ ⟨ P ⟩
25+
subst′ respects y≈x = subst respects (sym y≈x)
26+
27+
-- TODO: maybe lift ∅ to an arbitrary level p
28+
⟨∅⟩ : ⟨ ∅ ⟩ ⊆ ∅
29+
⟨∅⟩ (X ⟨∙⟩ Y ∣ xy≈z) = ⟨∅⟩ X
30+
31+
⟨_⟩⊆⟨_⟩ : {p} (P Q : Pred Bird p) P ⊆ Q ⟨ P ⟩ ⊆ ⟨ Q ⟩
32+
⟨ P ⟩⊆⟨ Q ⟩ P⊆Q [ x∈P ] = [ P⊆Q x∈P ]
33+
⟨ P ⟩⊆⟨ Q ⟩ P⊆Q (x∈⟨P⟩ ⟨∙⟩ y∈⟨P⟩ ∣ xy≈z) = ⟨ P ⟩⊆⟨ Q ⟩ P⊆Q x∈⟨P⟩ ⟨∙⟩ ⟨ P ⟩⊆⟨ Q ⟩ P⊆Q y∈⟨P⟩ ∣ xy≈z
34+
35+
⟨_∩_⟩ : {p} (P Q : Pred Bird p) ⟨ (P ∩ Q) ⟩ ⊆ ⟨ P ⟩ ∩ ⟨ Q ⟩
36+
⟨ P ∩ Q ⟩ [ (x∈P , x∈Q) ] = ([ x∈P ] , [ x∈Q ])
37+
⟨ P ∩ Q ⟩ (_⟨∙⟩_∣_ {x} {y} {z} x∈⟨P∩Q⟩ y∈⟨P∩Q⟩ xy≈z) =
38+
let (x∈⟨P⟩ , x∈⟨Q⟩) = ⟨_∩_⟩ P Q x∈⟨P∩Q⟩
39+
(y∈⟨P⟩ , y∈⟨Q⟩) = ⟨_∩_⟩ P Q y∈⟨P∩Q⟩
40+
in (x∈⟨P⟩ ⟨∙⟩ y∈⟨P⟩ ∣ xy≈z , x∈⟨Q⟩ ⟨∙⟩ y∈⟨Q⟩ ∣ xy≈z)
41+
42+
-- NOTE: the inclusion ⟨P⟩ ∩ ⟨Q⟩ ⊆ ⟨P ∩ Q⟩ does not hold for alle P and Q; let
43+
-- for example P = {S, K}, Q = {I}, then SKK = I ∈ ⟨P⟩ ∩ ⟨Q⟩, but P ∩ Q = ∅, and
44+
-- hence SKK = I ∉ P ∩ Q.
45+
-- TODO: formalise
+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
open import Mockingbird.Forest using (Forest)
2+
3+
module Mockingbird.Forest.Combination.Vec {b ℓ} (forest : Forest {b} {ℓ}) where
4+
5+
open import Mockingbird.Forest.Combination.Vec.Base forest public
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
open import Mockingbird.Forest using (Forest)
2+
3+
module Mockingbird.Forest.Combination.Vec.Base {b ℓ} (forest : Forest {b} {ℓ}) where
4+
5+
open import Data.Fin using (Fin; zero; suc; #_)
6+
open import Data.Nat using (ℕ; zero; suc)
7+
open import Data.Nat.Properties using (_≤?_)
8+
open import Data.Vec as Vec using (Vec; _∷_)
9+
open import Data.Vec.Relation.Unary.Any using (here; there) public
10+
open import Level using (_⊔_)
11+
open import Relation.Nullary.Decidable.Core using (True)
12+
open import Relation.Unary using (Pred; _∈_)
13+
14+
open Forest forest
15+
16+
import Mockingbird.Forest.Combination.Base forest as Base
17+
import Mockingbird.Forest.Combination.Properties forest as Combinationₚ
18+
open import Mockingbird.Forest.Combination.Base forest using ([_]; _⟨∙⟩_∣_; _⟨∙⟩_) public
19+
open import Data.Vec.Membership.Setoid setoid using () renaming (_∈_ to _∈′_)
20+
21+
⟨_⟩ : {n} Vec Bird n Pred Bird (b ⊔ ℓ)
22+
⟨ bs ⟩ = Base.⟨ _∈′ bs ⟩
23+
where
24+
25+
[_]′ : {n} {bs : Vec Bird n} (i : Fin n) Vec.lookup bs i ∈ ⟨ bs ⟩
26+
[_]′ {suc n} {x ∷ bs} zero = [ here refl ]
27+
[_]′ {suc n} {x ∷ bs} (suc i) = Combinationₚ.⟨ _ ⟩⊆⟨ _ ⟩ there [ i ]′
28+
29+
[#_] : m {n} {m<n : True (suc m ≤? n)} {bs : Vec Bird n}
30+
Vec.lookup bs (#_ m {m<n = m<n}) ∈ ⟨ bs ⟩
31+
[# m ] = [ # m ]′
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
open import Mockingbird.Forest using (Forest)
2+
3+
module Mockingbird.Forest.Combination.Vec.Properties {b ℓ} (forest : Forest {b} {ℓ}) where
4+
5+
open import Data.Vec as Vec using (Vec; []; _∷_)
6+
import Data.Vec.Relation.Unary.Any as Any
7+
open import Function using (_$_; flip)
8+
open import Relation.Unary using (Pred; _∈_; _⊆_; ∅)
9+
10+
open Forest forest
11+
12+
open import Mockingbird.Forest.Combination.Vec.Base forest
13+
import Mockingbird.Forest.Combination.Properties forest as Combinationₚ
14+
15+
subst : {n x y} {bs : Vec Bird n} x ≈ y x ∈ ⟨ bs ⟩ y ∈ ⟨ bs ⟩
16+
subst = Combinationₚ.subst λ x≈y Any.map (trans (sym x≈y))
17+
18+
subst′ : {n x y} {bs : Vec Bird n} y ≈ x x ∈ ⟨ bs ⟩ y ∈ ⟨ bs ⟩
19+
subst′ y≈x = subst (sym y≈x)
20+
21+
⟨[]⟩ : ⟨ [] ⟩ ⊆ ∅
22+
⟨[]⟩ (X ⟨∙⟩ Y ∣ xy≈z) = ⟨[]⟩ X
23+
24+
open import Mockingbird.Forest.Birds forest
25+
open import Mockingbird.Forest.Extensionality forest
26+
module _ ⦃ _ : Extensional ⦄ ⦃ _ : HasCardinal ⦄ ⦃ _ : HasIdentity ⦄
27+
⦃ _ : HasThrush ⦄ ⦃ _ : HasKestrel ⦄ ⦃ _ : HasStarling ⦄ where
28+
private
29+
CI≈T : C ∙ I ≈ T
30+
CI≈T = ext $ λ x ext $ λ y begin
31+
C ∙ I ∙ x ∙ y ≈⟨ isCardinal I x y ⟩
32+
I ∙ y ∙ x ≈⟨ ∙-congʳ $ isIdentity y ⟩
33+
y ∙ x ≈˘⟨ isThrush x y ⟩
34+
T ∙ x ∙ y ∎
35+
36+
_ : T ∈ ⟨ C ∷ I ∷ [] ⟩
37+
_ = subst CI≈T $ [# 0 ] ⟨∙⟩ [# 1 ]
38+
39+
_ : I ∈ ⟨ S ∷ K ∷ [] ⟩
40+
_ = flip subst ([# 0 ] ⟨∙⟩ [# 1 ] ⟨∙⟩ [# 1 ]) $ ext $ λ x begin
41+
S ∙ K ∙ K ∙ x ≈⟨ isStarling K K x ⟩
42+
K ∙ x ∙ (K ∙ x) ≈⟨ isKestrel x (K ∙ x) ⟩
43+
x ≈˘⟨ isIdentity x ⟩
44+
I ∙ x ∎
+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
open import Mockingbird.Forest using (Forest)
2+
3+
module Mockingbird.Forest.Extensionality {b ℓ} (forest : Forest {b} {ℓ}) where
4+
5+
open import Algebra using (RightCongruent)
6+
open import Relation.Binary using (Rel; IsEquivalence; Setoid)
7+
open import Level using (_⊔_)
8+
9+
open Forest forest
10+
11+
-- TODO: if the arguments to the predicates is{Mockingbird,Thrush,Cardinal,...}
12+
-- are made implicit, then x can be implicit too.
13+
Similar : Rel Bird (b ⊔ ℓ)
14+
Similar A₁ A₂ = x A₁ ∙ x ≈ A₂ ∙ x
15+
16+
infix 4 _≋_
17+
_≋_ = Similar
18+
19+
-- A forest is called extensional if similarity implies equality.
20+
IsExtensional : Set (b ⊔ ℓ)
21+
IsExtensional = {A₁ A₂} A₁ ≋ A₂ A₁ ≈ A₂
22+
23+
-- A record to be used as an instance argument.
24+
record Extensional : Set (b ⊔ ℓ) where
25+
field
26+
ext : IsExtensional
27+
28+
open Extensional ⦃ ... ⦄ public
29+
30+
ext′ : ⦃ _ : Extensional ⦄ {A₁ A₂} ( {x} A₁ ∙ x ≈ A₂ ∙ x) A₁ ≈ A₂
31+
ext′ A₁≋A₂ = ext λ _ A₁≋A₂
32+
33+
-- Similarity is an equivalence relation.
34+
≋-isEquivalence : IsEquivalence _≋_
35+
≋-isEquivalence = record
36+
{ refl = λ _ refl
37+
; sym = λ x≋y z sym (x≋y z)
38+
; trans = λ x≋y y≋z w trans (x≋y w) (y≋z w)
39+
}
40+
41+
≋-∙-congʳ : RightCongruent _≋_ _∙_
42+
≋-∙-congʳ {w} {x} {y} x≋y = λ _ ∙-congʳ (x≋y w)

‎Mockingbird/Problems/Chapter09.agda

+326
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,326 @@
1+
open import Mockingbird.Forest using (Forest)
2+
3+
-- To Mock a Mockingbird
4+
module Mockingbird.Problems.Chapter09 {b ℓ} (forest : Forest {b} {ℓ}) where
5+
6+
open import Data.Product using (_,_; proj₁; proj₂; ∃-syntax)
7+
open import Function using (_$_)
8+
open import Level using (_⊔_)
9+
open import Relation.Nullary using (¬_)
10+
11+
open import Mockingbird.Forest.Birds forest
12+
13+
open Forest forest
14+
15+
module _ ⦃ _ : HasComposition ⦄ ⦃ _ : HasMockingbird ⦄ where
16+
problem₁ : A ∃[ B ] A IsFondOf B
17+
problem₁ A =
18+
let C = A ∘ M
19+
20+
isFond : A IsFondOf (C ∙ C)
21+
isFond = sym $ begin
22+
C ∙ C ≈⟨ isComposition A M C ⟩
23+
A ∙ (M ∙ C) ≈⟨ ∙-congˡ (isMockingbird C) ⟩
24+
A ∙ (C ∙ C) ∎
25+
26+
in (C ∙ C , isFond)
27+
28+
module _ ⦃ _ : HasComposition ⦄ ⦃ _ : HasMockingbird ⦄ where
29+
problem₂ : ∃[ E ] IsEgocentric E
30+
problem₂ =
31+
let (E , isFond) = problem₁ M
32+
33+
isEgocentric : IsEgocentric E
34+
isEgocentric = begin
35+
E ∙ E ≈˘⟨ isMockingbird E ⟩
36+
M ∙ E ≈⟨ isFond ⟩
37+
E ∎
38+
39+
in (E , isEgocentric)
40+
41+
module _ ⦃ _ : HasComposition ⦄ (hasAgreeable : ∃[ A ] IsAgreeable A) where
42+
A = proj₁ hasAgreeable
43+
isAgreeable = proj₂ hasAgreeable
44+
45+
problem₃ : B ∃[ C ] B IsFondOf C
46+
problem₃ B =
47+
let D = B ∘ A
48+
(x , Ax≈Dx) = isAgreeable D
49+
50+
isFond : B IsFondOf (A ∙ x)
51+
isFond = begin
52+
B ∙ (A ∙ x) ≈˘⟨ isComposition B A x ⟩
53+
D ∙ x ≈˘⟨ Ax≈Dx ⟩
54+
A ∙ x ∎
55+
56+
in (A ∙ x , isFond)
57+
58+
-- Bonus question of Problem 3.
59+
C₂→HasAgreeable : ⦃ _ : HasMockingbird ⦄ ∃[ A ] IsAgreeable A
60+
C₂→HasAgreeable = (M , λ B (B , isMockingbird B))
61+
62+
module _ ⦃ _ : HasComposition ⦄ (A B C : Bird) (Cx≈A[Bx] : IsComposition A B C) where
63+
problem₄ : IsAgreeable C IsAgreeable A
64+
problem₄ C-isAgreeable D =
65+
let E = D ∘ B
66+
(x , Cx≈Ex) = C-isAgreeable E
67+
68+
agree : Agree A D (B ∙ x)
69+
agree = begin
70+
A ∙ (B ∙ x) ≈˘⟨ Cx≈A[Bx] x ⟩
71+
C ∙ x ≈⟨ Cx≈Ex ⟩
72+
E ∙ x ≈⟨ isComposition D B x ⟩
73+
D ∙ (B ∙ x) ∎
74+
75+
in (B ∙ x , agree)
76+
77+
module _ ⦃ _ : HasComposition ⦄ where
78+
problem₅ : A B C ∃[ D ] ( x D ∙ x ≈ A ∙ (B ∙ (C ∙ x)))
79+
problem₅ A B C =
80+
let E = B ∘ C
81+
D = A ∘ E
82+
in (D , λ x trans (isComposition A E x) $ ∙-congˡ (isComposition B C x))
83+
84+
module _ ⦃ _ : HasComposition ⦄ ⦃ _ : HasMockingbird ⦄ where
85+
problem₆ : A B Compatible A B
86+
problem₆ A B =
87+
let C = A ∘ B
88+
(y , Cy≈y) = problem₁ C
89+
x = B ∙ y
90+
in (x , y , trans (sym (isComposition A B y)) Cy≈y , refl)
91+
92+
problem₇ : A ∃[ B ] A IsFondOf B IsHappy A
93+
problem₇ A (B , AB≈B) = (B , B , AB≈B , AB≈B)
94+
-- problem₇ : ∀ A → IsNormal A → IsHappy A
95+
96+
module _ ⦃ _ : HasComposition ⦄ where
97+
problem₈ : ∃[ H ] IsHappy H ∃[ N ] IsNormal N
98+
problem₈ (H , x , y , Hx≈y , Hy≈x) =
99+
let N = H ∘ H
100+
101+
isFond : N IsFondOf x
102+
isFond = begin
103+
N ∙ x ≈⟨ isComposition H H x ⟩
104+
H ∙ (H ∙ x) ≈⟨ ∙-congˡ Hx≈y ⟩
105+
H ∙ y ≈⟨ Hy≈x ⟩
106+
x ∎
107+
108+
in (N , x , isFond)
109+
110+
module _ ⦃ _ : HasComposition ⦄ ⦃ _ : HasMockingbird ⦄ ⦃ _ : HasKestrel ⦄ where
111+
problem₉ : ∃[ A ] IsHopelesslyEgocentric A
112+
problem₉ =
113+
let (A , KA≈A) = problem₁ K
114+
115+
isHopelesslyEgocentric : IsHopelesslyEgocentric A
116+
isHopelesslyEgocentric x = begin
117+
A ∙ x ≈˘⟨ ∙-congʳ KA≈A ⟩
118+
(K ∙ A) ∙ x ≈⟨ isKestrel A x ⟩
119+
A ∎
120+
121+
in (A , isHopelesslyEgocentric)
122+
123+
problem₁₀ : x y x IsFixatedOn y x IsFondOf y
124+
problem₁₀ x y xz≈y = xz≈y y
125+
126+
problem₁₁ : K IsKestrel K IsEgocentric K IsHopelesslyEgocentric K
127+
problem₁₁ K isKestrel KK≈K x = begin
128+
K ∙ x ≈˘⟨ ∙-congʳ KK≈K ⟩
129+
(K ∙ K) ∙ x ≈⟨ isKestrel K x ⟩
130+
K ∎
131+
132+
problem₁₂ : ⦃ _ : HasKestrel ⦄ x IsEgocentric (K ∙ x) K IsFondOf x
133+
problem₁₂ x [Kx][Kx]≈Kx = begin
134+
K ∙ x ≈˘⟨ [Kx][Kx]≈Kx ⟩
135+
(K ∙ x) ∙ (K ∙ x) ≈⟨ isKestrel x (K ∙ x) ⟩
136+
x ∎
137+
138+
problem₁₃ : A x y IsHopelesslyEgocentric A A ∙ x ≈ A ∙ y
139+
problem₁₃ A x y Az≈A = begin
140+
A ∙ x ≈⟨ Az≈A x ⟩
141+
A ≈˘⟨ Az≈A y ⟩
142+
A ∙ y ∎
143+
144+
problem₁₄ : A x y IsHopelesslyEgocentric A (A ∙ x) ∙ y ≈ A
145+
problem₁₄ A x y Az≈A = begin
146+
(A ∙ x) ∙ y ≈⟨ ∙-congʳ (Az≈A x) ⟩
147+
A ∙ y ≈⟨ Az≈A y ⟩
148+
A ∎
149+
150+
problem₁₅ : A x IsHopelesslyEgocentric A IsHopelesslyEgocentric (A ∙ x)
151+
problem₁₅ A x Az≈A y = begin
152+
(A ∙ x) ∙ y ≈⟨ ∙-congʳ (Az≈A x) ⟩
153+
A ∙ y ≈⟨ Az≈A y ⟩
154+
A ≈˘⟨ Az≈A x ⟩
155+
A ∙ x ∎
156+
157+
problem₁₆ : K IsKestrel K x y K ∙ x ≈ K ∙ y x ≈ y
158+
problem₁₆ K isKestrel x y Kx≈Ky = begin
159+
x ≈˘⟨ isKestrel x K ⟩
160+
-- NOTE: for the right-most kestrel, we can choose any bird. (Since we know
161+
-- only of three birds to exist here, the only option is a combination of
162+
-- {K, x, y}).
163+
(K ∙ x) ∙ K ≈⟨ ∙-congʳ Kx≈Ky ⟩
164+
(K ∙ y) ∙ K ≈⟨ isKestrel y K ⟩
165+
y ∎
166+
167+
problem₁₇ : A x y A IsFixatedOn x A IsFixatedOn y x ≈ y
168+
problem₁₇ A x y Az≈x Az≈y = begin
169+
x ≈˘⟨ Az≈x A ⟩
170+
-- NOTE: for the right-most A, we can choose any bird. (In this case a
171+
-- combination of {A, B, C}).
172+
A ∙ A ≈⟨ Az≈y A ⟩
173+
y ∎
174+
175+
problem₁₈ : ⦃ _ : HasKestrel ⦄ x K IsFondOf K ∙ x K IsFondOf x
176+
problem₁₈ x K[Kx]≈Kx = begin
177+
K ∙ x ≈˘⟨ isKestrel (K ∙ x) x ⟩
178+
-- NOTE: for the right-most x, we can choose any bird.
179+
(K ∙ (K ∙ x)) ∙ x ≈⟨ ∙-congʳ K[Kx]≈Kx ⟩
180+
(K ∙ x) ∙ x ≈⟨ isKestrel x x ⟩
181+
x ∎
182+
183+
-- In the circumstances of Problem 19, the only bird in the forest is the
184+
-- kestrel.
185+
problem₁₉ : K IsKestrel K IsEgocentric K x x ≈ K
186+
problem₁₉ K isKestrel KK≈K x = begin
187+
x ≈⟨ lemma x x ⟩
188+
K ∙ x ≈˘⟨ ∙-congʳ KK≈K ⟩
189+
(K ∙ K) ∙ x ≈⟨ isKestrel K x ⟩
190+
K ∎
191+
where
192+
lemma : y z y ≈ K ∙ z
193+
lemma y z = begin
194+
y ≈˘⟨ isKestrel y z ⟩
195+
(K ∙ y) ∙ z ≈˘⟨ ∙-congʳ (∙-congʳ KK≈K) ⟩
196+
((K ∙ K) ∙ y) ∙ z ≈⟨ ∙-congʳ (isKestrel K y) ⟩
197+
K ∙ z ∎
198+
199+
module _ ⦃ _ : HasIdentity ⦄ where
200+
problem₂₀ : IsAgreeable I A ∃[ B ] A IsFondOf B
201+
problem₂₀ isAgreeable A =
202+
let (B , IB≈AB) = isAgreeable A
203+
204+
isFond : A IsFondOf B
205+
isFond = begin
206+
A ∙ B ≈˘⟨ IB≈AB ⟩
207+
I ∙ B ≈⟨ isIdentity B ⟩
208+
B ∎
209+
210+
in (B , isFond)
211+
212+
problem₂₁ : ( A ∃[ B ] A IsFondOf B) IsAgreeable I
213+
problem₂₁ isFond A =
214+
let (B , AB≈B) = isFond A
215+
216+
agree : I ∙ B ≈ A ∙ B
217+
agree = begin
218+
I ∙ B ≈⟨ isIdentity B ⟩
219+
B ≈˘⟨ AB≈B ⟩
220+
A ∙ B ∎
221+
222+
in (B , agree)
223+
224+
problem₂₂-1 : ( A B Compatible A B) A IsNormal A
225+
problem₂₂-1 compatible A =
226+
let (x , y , Ix≈y , Ay≈x) = compatible I A
227+
228+
isFond : A IsFondOf y
229+
isFond = begin
230+
A ∙ y ≈⟨ Ay≈x ⟩
231+
x ≈˘⟨ isIdentity x ⟩
232+
I ∙ x ≈⟨ Ix≈y ⟩
233+
y ∎
234+
in (y , isFond)
235+
236+
problem₂₂-2 : ( A B Compatible A B) IsAgreeable I
237+
problem₂₂-2 compatible A =
238+
let (x , y , Ix≈y , Ay≈x) = compatible I A
239+
240+
agree : Agree I A y
241+
agree = begin
242+
I ∙ y ≈⟨ isIdentity y ⟩
243+
y ≈˘⟨ Ix≈y ⟩
244+
I ∙ x ≈⟨ isIdentity x ⟩
245+
x ≈˘⟨ Ay≈x ⟩
246+
A ∙ y ∎
247+
248+
in (y , agree)
249+
250+
problem₂₃ : IsHopelesslyEgocentric I x I ≈ x
251+
problem₂₃ isHopelesslyEgocentric x = begin
252+
I ≈˘⟨ isHopelesslyEgocentric x ⟩
253+
I ∙ x ≈⟨ isIdentity x ⟩
254+
x ∎
255+
256+
module _ ⦃ _ : HasLark ⦄ ⦃ _ : HasIdentity ⦄ where
257+
problem₂₄ : HasMockingbird
258+
problem₂₄ = record
259+
{ M = L ∙ I
260+
; isMockingbird = λ x begin
261+
(L ∙ I) ∙ x ≈⟨ isLark I x ⟩
262+
I ∙ (x ∙ x) ≈⟨ isIdentity (x ∙ x) ⟩
263+
x ∙ x ∎
264+
}
265+
266+
module _ ⦃ _ : HasLark ⦄ where
267+
problem₂₅ : x IsNormal x
268+
problem₂₅ x =
269+
let isFond : x IsFondOf (L ∙ x) ∙ (L ∙ x)
270+
isFond = begin
271+
x ∙ ((L ∙ x) ∙ (L ∙ x)) ≈˘⟨ isLark x (L ∙ x) ⟩
272+
(L ∙ x) ∙ (L ∙ x) ∎
273+
in ((L ∙ x) ∙ (L ∙ x) , isFond)
274+
275+
problem₂₆ : IsHopelesslyEgocentric L x x IsFondOf L
276+
problem₂₆ isHopelesslyEgocentric x = begin
277+
x ∙ L ≈˘⟨ ∙-congˡ $ isHopelesslyEgocentric L ⟩
278+
x ∙ (L ∙ L) ≈˘⟨ isLark x L ⟩
279+
(L ∙ x) ∙ L ≈⟨ ∙-congʳ $ isHopelesslyEgocentric x ⟩
280+
L ∙ L ≈⟨ isHopelesslyEgocentric L ⟩
281+
L ∎
282+
283+
module _ ⦃ _ : HasLark ⦄ ⦃ _ : HasKestrel ⦄ where
284+
problem₂₇ : L ≉ K ¬ L IsFondOf K
285+
problem₂₇ L≉K isFond =
286+
let K-fondOf-KK : K IsFondOf K ∙ K
287+
K-fondOf-KK = begin
288+
K ∙ (K ∙ K) ≈˘⟨ ∙-congʳ isFond ⟩
289+
(L ∙ K) ∙ (K ∙ K) ≈⟨ isLark K (K ∙ K) ⟩
290+
K ∙ ((K ∙ K) ∙ (K ∙ K)) ≈⟨ ∙-congˡ $ isKestrel K (K ∙ K) ⟩
291+
K ∙ K ∎
292+
293+
isEgocentric : IsEgocentric K
294+
isEgocentric = problem₁₈ K K-fondOf-KK
295+
296+
L≈K : L ≈ K
297+
L≈K = problem₁₉ K isKestrel isEgocentric L
298+
299+
in L≉K L≈K
300+
301+
problem₂₈ : K IsFondOf L x x IsFondOf L
302+
problem₂₈ KL≈L =
303+
let isHopelesslyEgocentric : IsHopelesslyEgocentric L
304+
isHopelesslyEgocentric y = begin
305+
L ∙ y ≈˘⟨ ∙-congʳ KL≈L ⟩
306+
(K ∙ L) ∙ y ≈⟨ isKestrel L y ⟩
307+
L ∎
308+
in problem₂₆ isHopelesslyEgocentric
309+
310+
module _ ⦃ _ : HasLark ⦄ where
311+
problem₂₉ : ∃[ x ] IsEgocentric x
312+
problem₂₉ =
313+
let (y , [LL]y≈y) = problem₂₅ (L ∙ L)
314+
315+
isEgocentric : IsEgocentric (y ∙ y)
316+
isEgocentric = begin
317+
(y ∙ y) ∙ (y ∙ y) ≈˘⟨ isLark (y ∙ y) y ⟩
318+
(L ∙ (y ∙ y)) ∙ y ≈˘⟨ ∙-congʳ (isLark L y) ⟩
319+
((L ∙ L) ∙ y) ∙ y ≈⟨ ∙-congʳ [LL]y≈y ⟩
320+
y ∙ y ∎
321+
322+
-- The expression of yy in terms of L and brackets.
323+
_ : y ∙ y ≈ ((L ∙ (L ∙ L)) ∙ (L ∙ (L ∙ L))) ∙ ((L ∙ (L ∙ L)) ∙ (L ∙ (L ∙ L)))
324+
_ = refl
325+
326+
in (y ∙ y , isEgocentric)

‎Mockingbird/Problems/Chapter10.agda

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
open import Mockingbird.Forest using (Forest)
2+
3+
-- Is There a Sage Bird?
4+
module Mockingbird.Problems.Chapter10 {b ℓ} (forest : Forest {b} {ℓ}) where
5+
6+
open import Data.Product using (_,_; proj₁; proj₂; ∃-syntax)
7+
open import Function using (_$_)
8+
9+
open import Mockingbird.Forest.Birds forest
10+
11+
open Forest forest
12+
13+
module _ ⦃ _ : HasComposition ⦄ ⦃ _ : HasMockingbird ⦄ ⦃ _ : HasLark ⦄ where
14+
private
15+
hasMockingbirdComposer : ∃[ A ] ( x y A ∙ x ∙ y ≈ x ∙ (M ∙ y))
16+
hasMockingbirdComposer = (L , isMockingbirdComposer)
17+
where
18+
isMockingbirdComposer = λ x y begin
19+
L ∙ x ∙ y ≈⟨ isLark x y ⟩
20+
x ∙ (y ∙ y) ≈˘⟨ ∙-congˡ $ isMockingbird y ⟩
21+
x ∙ (M ∙ y) ∎
22+
23+
hasSageBird : HasSageBird
24+
hasSageBird = record
25+
{ Θ = M ∘ L
26+
; isSageBird = λ x begin
27+
x ∙ ((M ∘ L) ∙ x) ≈⟨ ∙-congˡ $ isComposition M L x ⟩
28+
x ∙ (M ∙ (L ∙ x)) ≈⟨ ∙-congˡ $ isMockingbird (L ∙ x) ⟩
29+
x ∙ ((L ∙ x) ∙ (L ∙ x)) ≈˘⟨ isLark x (L ∙ x) ⟩
30+
(L ∙ x) ∙ (L ∙ x) ≈˘⟨ isMockingbird (L ∙ x) ⟩
31+
M ∙ (L ∙ x) ≈˘⟨ isComposition M L x ⟩
32+
(M ∘ L) ∙ x ∎
33+
}
34+
35+
module _ ⦃ _ : HasComposition ⦄ ⦃ _ : HasMockingbird ⦄
36+
(hasMockingbirdComposer : ∃[ A ] ( x y A ∙ x ∙ y ≈ x ∙ (M ∙ y))) where
37+
38+
private
39+
A = proj₁ hasMockingbirdComposer
40+
[Ax]y≈x[My] = proj₂ hasMockingbirdComposer
41+
42+
instance
43+
hasLark : HasLark
44+
hasLark = record
45+
{ L = A
46+
; isLark = λ x y begin
47+
(A ∙ x) ∙ y ≈⟨ [Ax]y≈x[My] x y ⟩
48+
x ∙ (M ∙ y) ≈⟨ ∙-congˡ $ isMockingbird y ⟩
49+
x ∙ (y ∙ y) ∎
50+
}
51+
52+
hasSageBird′ : HasSageBird
53+
hasSageBird′ = hasSageBird

‎Mockingbird/Problems/Chapter11.agda

+642
Large diffs are not rendered by default.

‎Mockingbird/Problems/Chapter12.agda

+413
Large diffs are not rendered by default.

‎Mockingbird/Problems/Chapter13.agda

+225
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,225 @@
1+
open import Mockingbird.Forest using (Forest)
2+
3+
-- A Gallery of Sage Birds
4+
module Mockingbird.Problems.Chapter13 {b ℓ} (forest : Forest {b} {ℓ}) where
5+
6+
open import Function using (_$_)
7+
open import Data.Product using (proj₂)
8+
9+
open import Mockingbird.Forest.Birds forest
10+
import Mockingbird.Problems.Chapter09 forest as Chapter₉
11+
import Mockingbird.Problems.Chapter10 forest as Chapter₁₀
12+
import Mockingbird.Problems.Chapter11 forest as Chapter₁₁
13+
import Mockingbird.Problems.Chapter12 forest as Chapter₁₂
14+
15+
open Forest forest
16+
17+
problem₁ : ⦃ _ : HasBluebird ⦄ ⦃ _ : HasMockingbird ⦄ ⦃ _ : HasRobin ⦄ HasSageBird
18+
problem₁ = record
19+
{ Θ = B ∙ M ∙ (R ∙ M ∙ B)
20+
; isSageBird = λ x begin
21+
x ∙ (B ∙ M ∙ (R ∙ M ∙ B) ∙ x) ≈⟨ ∙-congˡ lemma ⟩
22+
x ∙ (M ∙ (B ∙ x ∙ M)) ≈⟨ isFond ⟩
23+
M ∙ (B ∙ x ∙ M) ≈˘⟨ lemma ⟩
24+
B ∙ M ∙ (R ∙ M ∙ B) ∙ x ∎
25+
} where
26+
isFond = λ {x} proj₂ (Chapter₁₁.problem₂ x)
27+
28+
lemma : {x} B ∙ M ∙ (R ∙ M ∙ B) ∙ x ≈ M ∙ (B ∙ x ∙ M)
29+
lemma {x} = begin
30+
B ∙ M ∙ (R ∙ M ∙ B) ∙ x ≈⟨ isBluebird M (R ∙ M ∙ B) x ⟩
31+
M ∙ (R ∙ M ∙ B ∙ x) ≈⟨ ∙-congˡ $ isRobin M B x ⟩
32+
M ∙ (B ∙ x ∙ M) ∎
33+
34+
problem₂ : ⦃ _ : HasBluebird ⦄ ⦃ _ : HasMockingbird ⦄ ⦃ _ : HasCardinal ⦄ HasSageBird
35+
problem₂ = record
36+
{ Θ = B ∙ M ∙ (C ∙ B ∙ M)
37+
; isSageBird = λ x begin
38+
x ∙ (B ∙ M ∙ (C ∙ B ∙ M) ∙ x) ≈⟨ ∙-congˡ lemma ⟩
39+
x ∙ (M ∙ (B ∙ x ∙ M)) ≈⟨ isFond ⟩
40+
M ∙ (B ∙ x ∙ M) ≈˘⟨ lemma ⟩
41+
B ∙ M ∙ (C ∙ B ∙ M) ∙ x ∎
42+
} where
43+
isFond = λ {x} proj₂ (Chapter₁₁.problem₂ x)
44+
45+
lemma : {x} B ∙ M ∙ (C ∙ B ∙ M) ∙ x ≈ M ∙ (B ∙ x ∙ M)
46+
lemma {x} = begin
47+
B ∙ M ∙ (C ∙ B ∙ M) ∙ x ≈⟨ isBluebird M (C ∙ B ∙ M) x ⟩
48+
M ∙ (C ∙ B ∙ M ∙ x) ≈⟨ ∙-congˡ $ isCardinal B M x ⟩
49+
M ∙ (B ∙ x ∙ M) ∎
50+
51+
problem₃ : ⦃ _ : HasMockingbird ⦄ ⦃ _ : HasBluebird ⦄ ⦃ _ : HasLark ⦄ HasSageBird
52+
problem₃ = record
53+
{ Θ = B ∙ M ∙ L
54+
; isSageBird = isSageBird ⦃ Chapter₁₀.hasSageBird ⦄
55+
} where instance hasComposition = Chapter₁₁.problem₁
56+
57+
problem₄ : ⦃ _ : HasMockingbird ⦄ ⦃ _ : HasBluebird ⦄ ⦃ _ : HasWarbler ⦄ HasSageBird
58+
problem₄ = record
59+
{ Θ = B ∙ M ∙ (B ∙ W ∙ B)
60+
; isSageBird = isSageBird ⦃ problem₃ ⦄
61+
} where instance hasLark = Chapter₁₂.problem₃
62+
63+
problem₆ : ⦃ _ : HasQueerBird ⦄ ⦃ _ : HasLark ⦄ ⦃ _ : HasWarbler ⦄ HasSageBird
64+
problem₆ = record
65+
{ Θ = W ∙ (Q ∙ L ∙ (Q ∙ L))
66+
; isSageBird = λ x begin
67+
x ∙ (W ∙ (Q ∙ L ∙ (Q ∙ L)) ∙ x) ≈⟨ ∙-congˡ lemma ⟩
68+
x ∙ (L ∙ x ∙ (L ∙ x)) ≈⟨ isFond ⟩
69+
L ∙ x ∙ (L ∙ x) ≈˘⟨ lemma ⟩
70+
W ∙ (Q ∙ L ∙ (Q ∙ L)) ∙ x ∎
71+
} where
72+
isFond = λ {x} proj₂ (Chapter₉.problem₂₅ x)
73+
74+
lemma : {x} W ∙ (Q ∙ L ∙ (Q ∙ L)) ∙ x ≈ L ∙ x ∙ (L ∙ x)
75+
lemma {x} = begin
76+
W ∙ (Q ∙ L ∙ (Q ∙ L)) ∙ x ≈⟨ isWarbler (Q ∙ L ∙ (Q ∙ L)) x ⟩
77+
Q ∙ L ∙ (Q ∙ L) ∙ x ∙ x ≈⟨ ∙-congʳ $ isQueerBird L (Q ∙ L) x ⟩
78+
Q ∙ L ∙ (L ∙ x) ∙ x ≈⟨ isQueerBird L (L ∙ x) x ⟩
79+
L ∙ x ∙ (L ∙ x) ∎
80+
81+
82+
problem₅ : ⦃ _ : HasBluebird ⦄ ⦃ _ : HasCardinal ⦄ ⦃ _ : HasWarbler ⦄ HasSageBird
83+
problem₅ = problem₆
84+
where
85+
instance
86+
hasQueerBird = Chapter₁₁.problem₃₇′
87+
hasLark = Chapter₁₂.problem₃
88+
89+
problem₇ = problem₅
90+
91+
problem₈ : ⦃ _ : HasMockingbird ⦄ ⦃ _ : HasQueerBird ⦄ HasSageBird
92+
problem₈ = record
93+
{ Θ = Q ∙ (Q ∙ M) ∙ M
94+
; isSageBird = λ x sym $ begin
95+
Q ∙ (Q ∙ M) ∙ M ∙ x ≈⟨ isQueerBird (Q ∙ M) M x ⟩
96+
M ∙ (Q ∙ M ∙ x) ≈⟨ isMockingbird (Q ∙ M ∙ x) ⟩
97+
Q ∙ M ∙ x ∙ (Q ∙ M ∙ x) ≈⟨ isQueerBird M x (Q ∙ M ∙ x) ⟩
98+
x ∙ (M ∙ (Q ∙ M ∙ x)) ≈˘⟨ ∙-congˡ $ isQueerBird (Q ∙ M) M x ⟩
99+
x ∙ (Q ∙ (Q ∙ M) ∙ M ∙ x) ∎
100+
}
101+
102+
-- TODO: formalise regularity.
103+
104+
problem₉ : ⦃ _ : HasStarling ⦄ ⦃ _ : HasLark ⦄ HasSageBird
105+
problem₉ = record
106+
{ Θ = S ∙ L ∙ L
107+
; isSageBird = λ x begin
108+
x ∙ (S ∙ L ∙ L ∙ x) ≈⟨ ∙-congˡ $ isStarling L L x ⟩
109+
x ∙ (L ∙ x ∙ (L ∙ x)) ≈⟨ isFond ⟩
110+
L ∙ x ∙ (L ∙ x) ≈˘⟨ isStarling L L x ⟩
111+
S ∙ L ∙ L ∙ x ∎
112+
} where
113+
isFond = λ {x} proj₂ (Chapter₉.problem₂₅ x)
114+
115+
problem₁₀ : ⦃ _ : HasBluebird ⦄ ⦃ _ : HasWarbler ⦄ ⦃ _ : HasStarling ⦄ HasSageBird
116+
problem₁₀ = record
117+
{ Θ = W ∙ S ∙ (B ∙ W ∙ B)
118+
; isSageBird = λ x begin
119+
x ∙ (W ∙ S ∙ (B ∙ W ∙ B) ∙ x) ≈⟨⟩
120+
x ∙ (W ∙ S ∙ L ∙ x) ≈⟨ ∙-congˡ $ ∙-congʳ $ isWarbler S L ⟩
121+
x ∙ (S ∙ L ∙ L ∙ x) ≈⟨ isSageBird ⦃ problem₉ ⦄ x ⟩
122+
S ∙ L ∙ L ∙ x ≈˘⟨ ∙-congʳ $ isWarbler S L ⟩
123+
W ∙ S ∙ L ∙ x ≈⟨⟩
124+
W ∙ S ∙ (B ∙ W ∙ B) ∙ x ∎
125+
} where instance hasLark = Chapter₁₂.problem₃
126+
127+
problem₁₁ : ⦃ _ : HasBluebird ⦄ ⦃ _ : HasMockingbird ⦄ ⦃ _ : HasThrush ⦄ HasTuringBird
128+
problem₁₁ = record
129+
{ U = B ∙ (B ∙ W ∙ (C ∙ B)) ∙ M
130+
; isTuringBird = λ x y begin
131+
B ∙ (B ∙ W ∙ (C ∙ B)) ∙ M ∙ x ∙ y ≈⟨ ∙-congʳ $ isBluebird (B ∙ W ∙ (C ∙ B)) M x ⟩
132+
B ∙ W ∙ (C ∙ B) ∙ (M ∙ x) ∙ y ≈⟨ ∙-congʳ $ isBluebird W (C ∙ B) (M ∙ x) ⟩
133+
W ∙ (C ∙ B ∙ (M ∙ x)) ∙ y ≈⟨ isWarbler (C ∙ B ∙ (M ∙ x)) y ⟩
134+
C ∙ B ∙ (M ∙ x) ∙ y ∙ y ≈⟨ ∙-congʳ $ isCardinal B (M ∙ x) y ⟩
135+
B ∙ y ∙ (M ∙ x) ∙ y ≈⟨ isBluebird y (M ∙ x) y ⟩
136+
y ∙ (M ∙ x ∙ y) ≈⟨ ∙-congˡ $ ∙-congʳ $ isMockingbird x ⟩
137+
y ∙ (x ∙ x ∙ y) ∎
138+
} where
139+
instance
140+
hasCardinal = Chapter₁₁.problem₂₁′
141+
hasLark = Chapter₁₂.problem₇
142+
143+
problem₁₂ : ⦃ _ : HasTuringBird ⦄ HasSageBird
144+
problem₁₂ = record
145+
{ Θ = U ∙ U
146+
; isSageBird = λ x sym $ isTuringBird U x
147+
}
148+
149+
problem₁₃ : ⦃ _ : HasQueerBird ⦄ ⦃ _ : HasWarbler ⦄ HasOwl
150+
problem₁₃ = record
151+
{ O = Q ∙ Q ∙ W
152+
; isOwl = λ x y begin
153+
Q ∙ Q ∙ W ∙ x ∙ y ≈⟨ ∙-congʳ $ isQueerBird Q W x ⟩
154+
W ∙ (Q ∙ x) ∙ y ≈⟨ isWarbler (Q ∙ x) y ⟩
155+
Q ∙ x ∙ y ∙ y ≈⟨ isQueerBird x y y ⟩
156+
y ∙ (x ∙ y) ∎
157+
}
158+
159+
problem₁₄ : ⦃ _ : HasOwl ⦄ ⦃ _ : HasLark ⦄ HasTuringBird
160+
problem₁₄ = record
161+
{ U = L ∙ O
162+
; isTuringBird = λ x y begin
163+
L ∙ O ∙ x ∙ y ≈⟨ ∙-congʳ $ isLark O x ⟩
164+
O ∙ (x ∙ x) ∙ y ≈⟨ isOwl (x ∙ x) y ⟩
165+
y ∙ (x ∙ x ∙ y) ∎
166+
}
167+
168+
problem₁₅ : ⦃ _ : HasOwl ⦄ ⦃ _ : HasIdentity ⦄ HasMockingbird
169+
problem₁₅ = record
170+
{ M = O ∙ I
171+
; isMockingbird = λ x begin
172+
O ∙ I ∙ x ≈⟨ isOwl I x ⟩
173+
x ∙ (I ∙ x) ≈⟨ ∙-congˡ $ isIdentity x ⟩
174+
x ∙ x ∎
175+
}
176+
177+
problem₁₆ : ⦃ _ : HasStarling ⦄ ⦃ _ : HasIdentity ⦄ HasOwl
178+
problem₁₆ = record
179+
{ O = S ∙ I
180+
; isOwl = λ x y begin
181+
S ∙ I ∙ x ∙ y ≈⟨ isStarling I x y ⟩
182+
I ∙ y ∙ (x ∙ y) ≈⟨ ∙-congʳ $ isIdentity y ⟩
183+
y ∙ (x ∙ y) ∎
184+
}
185+
186+
problem₁₇ : x y x IsFondOf y x IsFondOf x ∙ y
187+
problem₁₇ x y xy≈y = begin
188+
x ∙ (x ∙ y) ≈⟨ ∙-congˡ xy≈y ⟩
189+
x ∙ y ∎
190+
191+
problem₁₈ : ⦃ _ : HasOwl ⦄ ⦃ _ : HasSageBird ⦄ IsSageBird (O ∙ Θ)
192+
problem₁₈ x = begin
193+
x ∙ (O ∙ Θ ∙ x) ≈⟨ ∙-congˡ $ isOwl Θ x ⟩
194+
x ∙ (x ∙ (Θ ∙ x)) ≈⟨ isFond ⟩
195+
x ∙ (Θ ∙ x) ≈˘⟨ isOwl Θ x ⟩
196+
O ∙ Θ ∙ x ∎
197+
where
198+
isFond : x IsFondOf (x ∙ (Θ ∙ x))
199+
isFond = problem₁₇ x (Θ ∙ x) (isSageBird x)
200+
201+
problem₁₉ : ⦃ _ : HasOwl ⦄ ⦃ _ : HasSageBird ⦄ IsSageBird (Θ ∙ O)
202+
problem₁₉ x = sym $ begin
203+
Θ ∙ O ∙ x ≈˘⟨ ∙-congʳ $ isSageBird O ⟩
204+
O ∙ (Θ ∙ O) ∙ x ≈⟨ isOwl (Θ ∙ O) x ⟩
205+
x ∙ (Θ ∙ O ∙ x) ∎
206+
207+
problem₂₀ : ⦃ _ : HasOwl ⦄ A O IsFondOf A IsSageBird A
208+
problem₂₀ A OA≈A x = begin
209+
x ∙ (A ∙ x) ≈˘⟨ isOwl A x ⟩
210+
O ∙ A ∙ x ≈⟨ ∙-congʳ OA≈A ⟩
211+
A ∙ x ∎
212+
213+
problem₂₁ : ⦃ _ : HasSageBird ⦄ A IsChoosy A IsSageBird (Θ ∙ A)
214+
problem₂₁ A isChoosy = isChoosy (Θ ∙ A) $ isSageBird A
215+
216+
open import Mockingbird.Forest.Extensionality forest
217+
218+
problem₂₂ : ⦃ _ : HasOwl ⦄ ⦃ _ : HasSageBird ⦄ O ∙ Θ ≋ Θ
219+
problem₂₂ x = begin
220+
O ∙ Θ ∙ x ≈⟨ isOwl Θ x ⟩
221+
x ∙ (Θ ∙ x) ≈⟨ isSageBird x ⟩
222+
Θ ∙ x ∎
223+
224+
problem₂₃ : ⦃ _ : Extensional ⦄ ⦃ _ : HasOwl ⦄ ⦃ _ : HasSageBird ⦄ O IsFondOf Θ
225+
problem₂₃ = ext problem₂₂

‎README.md

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Explorations in combinatory logic with Agda
2+
3+
Contents:
4+
- A formalisation in [Agda](https://wiki.portal.chalmers.se/agda/Main/HomePage) of the
5+
theory and problems of *To Mock a Mockingbird* by Raymond Smullyan.
6+
- A formalisation in Agda of [Haskell Curry's](https://en.wikipedia.org/wiki/Haskell_Curry)
7+
thesis *Grundlagen der Kombinatorischen Logik*. See [part 1](https://www.jstor.org/stable/2370619)
8+
and [part 2](https://www.jstor.org/stable/2370716).
9+
10+
Both are work in progress.

‎combinatory-logic.agda-lib

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
name: combinatory-logic
2+
include: .
3+
depend: standard-library

‎index.agda

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
module index where
2+
3+
-- A formalisation of Haskell B. Curry’s thesis Grundlagen der Kombinatorischen
4+
-- Logik. See <https://www.jstor.org/stable/2370619> (part 1) and
5+
-- <https://www.jstor.org/stable/2370716> (part 2).
6+
import CombinatoryLogic.Equality
7+
import CombinatoryLogic.Forest
8+
import CombinatoryLogic.Semantics
9+
import CombinatoryLogic.Syntax
10+
11+
-- A formalisation of the theory and problems presented in To Mock a Mockingbird
12+
-- by Raymond Smullyan.
13+
import Mockingbird.Forest
14+
import Mockingbird.Forest.Base
15+
import Mockingbird.Forest.Birds
16+
import Mockingbird.Forest.Combination
17+
import Mockingbird.Forest.Combination.Base
18+
import Mockingbird.Forest.Combination.Properties
19+
import Mockingbird.Forest.Combination.Vec
20+
import Mockingbird.Forest.Combination.Vec.Base
21+
import Mockingbird.Forest.Combination.Vec.Properties
22+
import Mockingbird.Forest.Extensionality
23+
import Mockingbird.Problems.Chapter09
24+
import Mockingbird.Problems.Chapter10
25+
import Mockingbird.Problems.Chapter11
26+
import Mockingbird.Problems.Chapter12
27+
import Mockingbird.Problems.Chapter13

0 commit comments

Comments
 (0)
Please sign in to comment.