├── .gitignore ├── Liar.agda ├── LICENSE ├── Yablo.agda ├── README.md ├── Russell-TypeIndexedSets.agda ├── Hypergame.agda └── BuraliForti-Chains.agda /.gitignore: -------------------------------------------------------------------------------- 1 | *.agda~ 2 | *.agdai 3 | MAlonzo/** 4 | -------------------------------------------------------------------------------- /Liar.agda: -------------------------------------------------------------------------------- 1 | {- 2 | The liar paradox, showing that the positivity check is required to maintain consistency 3 | in the presence of inductive types. 4 | -} 5 | 6 | {-# OPTIONS --no-positivity-check #-} 7 | 8 | module Liar where 9 | 10 | open import Data.Empty 11 | 12 | {- 13 | The liar sentence says "the Liar sentence is false". 14 | -} 15 | 16 | record Liar : Set where 17 | inductive 18 | field 19 | Liar-fails : Liar → ⊥ 20 | open Liar 21 | 22 | {- 23 | Assume that the liar sentence holds. It then fails, a contradiction. Therefore, our assumption 24 | must have been faulty, and the liar sentence does not hold. 25 | -} 26 | 27 | not-liar : Liar → ⊥ 28 | not-liar liar = Liar-fails liar liar 29 | 30 | {- 31 | We just proved that the liar sentence fails. But it says precisely this, so it must hold. 32 | -} 33 | 34 | liar : Liar 35 | liar = record { Liar-fails = not-liar } 36 | 37 | {- 38 | We managed to prove that the liar sentence both holds and fails, a contradiction. 39 | -} 40 | 41 | paradox : ⊥ 42 | paradox = not-liar liar 43 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | BSD 3-Clause License 2 | 3 | Copyright (c) 2020, Zoltan A. Kocsis 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | 1. Redistributions of source code must retain the above copyright notice, this 10 | list of conditions and the following disclaimer. 11 | 12 | 2. Redistributions in binary form must reproduce the above copyright notice, 13 | this list of conditions and the following disclaimer in the documentation 14 | and/or other materials provided with the distribution. 15 | 16 | 3. Neither the name of the copyright holder nor the names of its 17 | contributors may be used to endorse or promote products derived from 18 | this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 24 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 27 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | -------------------------------------------------------------------------------- /Yablo.agda: -------------------------------------------------------------------------------- 1 | {- 2 | A Yabloesque paradox, showing that the positivity check is required to maintain consistency 3 | in the presence of inductive types, and it cannot be weakened for parametric families. 4 | -} 5 | 6 | {-# OPTIONS --no-positivity-check #-} 7 | 8 | module Yablo where 9 | 10 | open import Data.Nat 11 | open import Data.Empty 12 | 13 | {- 14 | Consider a natural number n. The nth Yablo sentence says that the (n+1)st, (n+2)nd, (n+3)rd and so 15 | on Yablo sentences are all false. 16 | -} 17 | 18 | record Yablo (n : ℕ) : Set where 19 | inductive 20 | field 21 | subsequent-Yablo-false : ∀ k → n < k → Yablo k → ⊥ 22 | open Yablo 23 | 24 | {- 25 | If the nth Yablo sentence holds, then all subsequent ones fail. In particular, the (n+2)nd, (n+3)rd, 26 | (n+4)th and so on Yablo sentences all fail. But the (n+1)st Yablo sentence says precisely that these 27 | all fail, so the (n+1)st Yablo sentence must hold. 28 | -} 29 | 30 | Yablo-n-implies-Yablo-n+1 : ∀ n → Yablo n → Yablo (suc n) 31 | Yablo-n-implies-Yablo-n+1 n yablo-n = 32 | record { 33 | subsequent-Yablo-false = λ k sn 4 > 3 > 2 > 1 > 0 30 | 31 | -} 32 | 33 | record Chain {ℓ₁ ℓ₂ : Level} {A : Set ℓ₁} (R : A → A → Set ℓ₂) : Set (ℓ₁ ⊔ ℓ₂) where 34 | field 35 | _at_ : ℕ → A 36 | is-chain : ∀ n → R (_at_ (suc n)) (_at_ n) 37 | open Chain 38 | 39 | {- 40 | We call a relation _transitive_ if whenever it relates some x to y and y to z, then it also relates x to z. 41 | 42 | The usual order relation "less than" is transitive: if x is less than y, and y is less than 43 | z, then we can safely conclude that x itself is less than z. 44 | 45 | An example of a non-transitive relation would be fatherhood: if x is the father of y, and y is the father 46 | of z, then x is usually _not_ the father of z. 47 | 48 | In what follows, we will consider a set P equipped with a transitive relation ≺. 49 | If there are no ≺-chains, then we will call that the structure (P,≺) a _django_ (since it is _unchained_). 50 | 51 | For example, the natural numbers equipped with the usual order relation < ("less than") form a django. 52 | However, the integers (positive, negative, and zero) do not form a django when equipped with the same 53 | order relation, since they contain e.g. the chain 54 | 55 | ... < -16 < -8 < -4 < -2 < -1 for indices 56 | ... > 4 > 3 > 2 > 1 > 0 57 | 58 | Exercise: convince yourself that ℕ does not contain any such chain. 59 | -} 60 | 61 | record IsDjango {ℓ₁ ℓ₂ : Level} (A : Set ℓ₁) (R : A → A → Set ℓ₂) : Set (ℓ₁ ⊔ ℓ₂) where 62 | field 63 | Django-is-transitive : ∀ {x y z} → R x y → R y z → R x z 64 | Django-is-unchained : Chain R → ⊥ 65 | 66 | record Django {ℓ₁ ℓ₂ : Level} : Set (lsuc (ℓ₁ ⊔ ℓ₂)) where 67 | field 68 | Carrier : Set ℓ₁ 69 | order : Carrier → Carrier → Set ℓ₂ 70 | is-Django : IsDjango Carrier order 71 | open IsDjango is-Django public 72 | open Django 73 | 74 | {- 75 | Given a django (P,≺), and an element t ∈ P, the "lower set" P↓t = {x ∈ P | x ≺ t} inherits the 76 | django structure: if the relation ≺ is transitive on all of P, then of course it is transitive on the 77 | subset P↓t as well. Moreover, P↓t cannot contain any ≺-chains. 78 | 79 | In our previous example, we would have ℕ↓5 = {4,3,2,1}. 80 | 81 | We call djangoes of the form (P↓t,≺) the _prefixes_ of the django (P,≺). You can think of P↓t 82 | as the structure you get from P by removing everything "above" the element t ∈ P. 83 | -} 84 | 85 | record LowerSet {ℓ₁} {ℓ₂} (P : Django {ℓ₁} {ℓ₂}) (t : Carrier P) : Set (ℓ₁ ⊔ ℓ₂) where 86 | constructor _suchThat_ 87 | field 88 | element : Carrier P 89 | proof : order P element t 90 | 91 | LowerSet-inherited-order : 92 | {ℓ₁ ℓ₂ : Level} → (P : Django {ℓ₁} {ℓ₂}) (t : Carrier P) → 93 | LowerSet P t → LowerSet P t → Set ℓ₂ 94 | LowerSet-inherited-order P t (x suchThat x-below-t) (y suchThat y-below-t) = order P x y 95 | 96 | Prefix : {ℓ₁ : Level} → (P : Django {ℓ₁} {ℓ₁}) → Carrier P → Django {ℓ₁} {ℓ₁} 97 | Prefix {ℓ₁} P t = record 98 | { Carrier = LowerSet P t 99 | ; order = LowerSet-inherited-order P t 100 | ; is-Django = record 101 | { Django-is-transitive = λ {x y z} → F(4) ---> F(3) ---> F(2) ---> F(1) ---> F(0), for 245 | ... > 4 > 3 > 2 > 1 > 0 246 | 247 | where the bₙ ∈ F(n) are bounds, and the arrows fₙ are django homomorphisms embedding the django F(n+1) 248 | into the django F(n)↓bₙ, a prefix of F(n). 249 | 250 | Since the subprefix relation is transitive, each element of my chain is in fact a subprefix of F(0), via 251 | the "collapse" homomorphism cₙ = fₙ ∘ fₙ₋₁ ∘ ... ∘ f₀ : F(n+1) → F(0). 252 | 253 | Moreover, since fₙ(bₙ₊₁) < bₙ always holds, a simple diagonalization allows us to construct the chain 254 | 255 | ... R c₃(b₄) R c₂(b₃) R c₁(b₂) R c₀(b₁) R b₀, for indices 256 | ... > 4 > 3 > 2 > 1 > 0 257 | 258 | inside F(0). But that is impossible: F(0) is a django, so it is unchained! Since we could construct a 259 | chain inside F(0) using a chain F as above, we can conclude that such chains F cannot exist. 260 | -} 261 | 262 | subpr-is-unchained : Chain _subpr_ → ⊥ 263 | subpr-is-unchained F = AllDjangoes subpr AllDjangoes subpr AllDjangoes subpr AllDjangoes, for 340 | ... > 3 > 2 > 1 > 0 341 | 342 | -} 343 | 344 | AllDjangoes-is-chained : Chain _subpr_ 345 | AllDjangoes-is-chained = record 346 | { _at_ = λ n → AllDjangoes 347 | ; is-chain = λ n → AllDjangoes-subpr-AllDjangoes 348 | } 349 | 350 | {- 351 | This contradicts the non-existence of subpr-chains established earlier. 352 | -} 353 | 354 | paradox : ⊥ 355 | paradox = Django-is-unchained AllDjangoes AllDjangoes-is-chained 356 | --------------------------------------------------------------------------------