hexsha
stringlengths 40
40
| size
int64 3
1.05M
| ext
stringclasses 163
values | lang
stringclasses 53
values | max_stars_repo_path
stringlengths 3
945
| max_stars_repo_name
stringlengths 4
112
| max_stars_repo_head_hexsha
stringlengths 40
78
| max_stars_repo_licenses
listlengths 1
10
| max_stars_count
float64 1
191k
⌀ | max_stars_repo_stars_event_min_datetime
stringlengths 24
24
⌀ | max_stars_repo_stars_event_max_datetime
stringlengths 24
24
⌀ | max_issues_repo_path
stringlengths 3
945
| max_issues_repo_name
stringlengths 4
113
| max_issues_repo_head_hexsha
stringlengths 40
78
| max_issues_repo_licenses
listlengths 1
10
| max_issues_count
float64 1
116k
⌀ | max_issues_repo_issues_event_min_datetime
stringlengths 24
24
⌀ | max_issues_repo_issues_event_max_datetime
stringlengths 24
24
⌀ | max_forks_repo_path
stringlengths 3
945
| max_forks_repo_name
stringlengths 4
113
| max_forks_repo_head_hexsha
stringlengths 40
78
| max_forks_repo_licenses
listlengths 1
10
| max_forks_count
float64 1
105k
⌀ | max_forks_repo_forks_event_min_datetime
stringlengths 24
24
⌀ | max_forks_repo_forks_event_max_datetime
stringlengths 24
24
⌀ | content
stringlengths 3
1.05M
| avg_line_length
float64 1
966k
| max_line_length
int64 1
977k
| alphanum_fraction
float64 0
1
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
38820211215289f92bffeb663c691f961d4b1369
| 346
|
agda
|
Agda
|
Cubical/Data/List/FinData.agda
|
guilhermehas/cubical
|
ce3120d3f8d692847b2744162bcd7a01f0b687eb
|
[
"MIT"
] | 1
|
2021-10-31T17:32:49.000Z
|
2021-10-31T17:32:49.000Z
|
Cubical/Data/List/FinData.agda
|
guilhermehas/cubical
|
ce3120d3f8d692847b2744162bcd7a01f0b687eb
|
[
"MIT"
] | null | null | null |
Cubical/Data/List/FinData.agda
|
guilhermehas/cubical
|
ce3120d3f8d692847b2744162bcd7a01f0b687eb
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --safe #-}
module Cubical.Data.List.FinData where
open import Cubical.Foundations.Prelude
open import Cubical.Data.List
open import Cubical.Data.FinData
variable
ℓ : Level
A : Type ℓ
-- copy-paste from agda-stdlib
lookup : ∀ (xs : List A) → Fin (length xs) → A
lookup (x ∷ xs) zero = x
lookup (x ∷ xs) (suc i) = lookup xs i
| 21.625
| 46
| 0.682081
|
8b6a80e358e539d8c29a3a17d275872bec7707db
| 8,244
|
agda
|
Agda
|
lib/Explore/Universe/FromE.agda
|
crypto-agda/explore
|
16bc8333503ff9c00d47d56f4ec6113b9269a43e
|
[
"BSD-3-Clause"
] | 2
|
2016-06-05T09:25:32.000Z
|
2017-06-28T19:19:29.000Z
|
lib/Explore/Universe/FromE.agda
|
crypto-agda/explore
|
16bc8333503ff9c00d47d56f4ec6113b9269a43e
|
[
"BSD-3-Clause"
] | 1
|
2019-03-16T14:24:04.000Z
|
2019-03-16T14:24:04.000Z
|
lib/Explore/Universe/FromE.agda
|
crypto-agda/explore
|
16bc8333503ff9c00d47d56f4ec6113b9269a43e
|
[
"BSD-3-Clause"
] | null | null | null |
{-# OPTIONS --without-K #-}
open import Type using (Type₀; Type_)
open import Type.Identities
open import Function.NP using (Π; _∘_; const)
open import Function.Extensionality using (FunExt)
open import Data.One using (0₁)
open import Data.Two.Base using (0₂; 1₂)
open import Data.Product.NP using (_,_; fst)
open import Data.Sum.NP using (inl; inr)
open import Relation.Binary.PropositionalEquality.NP using (_≡_; idp; ap; !_; _∙_; tr)
open import HoTT using (ua; UA; module Equivalences)
open Equivalences using (_≃_)
open import Explore.Core
open import Explore.Zero
open import Explore.One
open import Explore.Two
open import Explore.Product
open Explore.Product.Operators
open import Explore.Sum
open import Explore.Properties
open import Explore.Explorable
open import Explore.Isomorphism
import Explore.Universe.Type
module Explore.Universe.FromE
(X : Type₀) (Xᵉ : ∀ {ℓ} → Explore ℓ X) where
open Explore.Universe.Type {X}
explore : ∀ {ℓ} u → Explore ℓ (El u)
explore 𝟘ᵁ = 𝟘ᵉ
explore 𝟙ᵁ = 𝟙ᵉ
explore 𝟚ᵁ = 𝟚ᵉ
explore (u₀ ×ᵁ u₁) = explore u₀ ×ᵉ explore u₁
explore (u₀ ⊎ᵁ u₁) = explore u₀ ⊎ᵉ explore u₁
explore (Σᵁ u f) = exploreΣ (explore u) λ {x} → explore (f x)
explore Xᵁ = Xᵉ
explore (≃ᵁ u A e) = explore-iso e (explore u)
module FromXⁱ (Xⁱ : ∀ {ℓ p} → ExploreInd p (Xᵉ {ℓ})) where
explore-ind : ∀ {ℓ p} u → ExploreInd {ℓ} p (explore u)
explore-ind 𝟘ᵁ = 𝟘ⁱ
explore-ind 𝟙ᵁ = 𝟙ⁱ
explore-ind 𝟚ᵁ = 𝟚ⁱ
explore-ind (u₀ ×ᵁ u₁) = explore-ind u₀ ×ⁱ explore-ind u₁
explore-ind (u₀ ⊎ᵁ u₁) = explore-ind u₀ ⊎ⁱ explore-ind u₁
explore-ind (Σᵁ u f) = exploreΣ-ind (explore-ind u) λ {x} → explore-ind (f x)
explore-ind Xᵁ = Xⁱ
explore-ind (≃ᵁ u A e) = explore-iso-ind e (explore-ind u)
module _ (u : U) where
private
uᵉ : ∀ {ℓ} → Explore ℓ (El u)
uᵉ = explore u
uⁱ : ∀ {ℓ p} → ExploreInd {ℓ} p uᵉ
uⁱ = explore-ind u
open FromExploreInd uⁱ public hiding (⟦explore⟧)
ΣᵉU : ∀ {ℓ} → (El u → Type ℓ) → Type ℓ
ΣᵉU = Σᵉ uᵉ
ΠᵉU : ∀ {ℓ} → (El u → Type ℓ) → Type ℓ
ΠᵉU = Πᵉ uᵉ
module Xᴱ = FromExploreInd Xⁱ
ΣᵉX : ∀ {ℓ} → (X → Type ℓ) → Type ℓ
ΣᵉX = Σᵉ Xᵉ
ΠᵉX : ∀ {ℓ} → (X → Type ℓ) → Type ℓ
ΠᵉX = Πᵉ Xᵉ
open Adequacy _≡_
module FromXˢ-ok (Xˢ-ok : Adequate-sum Xᴱ.sum){{_ : UA}}{{_ : FunExt}} where
adequate-sum : ∀ u → Adequate-sum (sum u)
adequate-sum 𝟘ᵁ = 𝟘ˢ-ok
adequate-sum 𝟙ᵁ = 𝟙ˢ-ok
adequate-sum 𝟚ᵁ = 𝟚ˢ-ok
adequate-sum (u₀ ×ᵁ u₁) = adequate-sumΣ (adequate-sum u₀) (adequate-sum u₁)
adequate-sum (u₀ ⊎ᵁ u₁) = adequate-sum⊎ (adequate-sum u₀) (adequate-sum u₁)
adequate-sum (Σᵁ u f) = adequate-sumΣ (adequate-sum u) (λ {x} → adequate-sum (f x))
adequate-sum Xᵁ = Xˢ-ok
adequate-sum (≃ᵁ u A e) = sum-iso-ok e (adequate-sum u)
module FromXˡ (Xˡ : ∀ {ℓ} → Lookup {ℓ} Xᵉ) where
lookup : ∀ {ℓ} u → Lookup {ℓ} (explore u)
lookup 𝟘ᵁ = 𝟘ˡ
lookup 𝟙ᵁ = 𝟙ˡ
lookup 𝟚ᵁ = 𝟚ˡ
lookup (u₀ ×ᵁ u₁) = lookup× {eᴬ = explore u₀} {eᴮ = explore u₁} (lookup u₀) (lookup u₁)
lookup (u₀ ⊎ᵁ u₁) = lookup⊎ {eᴬ = explore u₀} {eᴮ = explore u₁} (lookup u₀) (lookup u₁)
lookup (Σᵁ u f) = lookupΣ {eᴬ = explore u} {eᴮ = λ {x} → explore (f x)} (lookup u) (λ {x} → lookup (f x))
lookup Xᵁ = Xˡ
lookup (≃ᵁ u A e) = lookup-iso e {Aᵉ = explore u} (lookup u)
module FromXᶠ (Xᶠ : ∀ {ℓ} → Focus {ℓ} Xᵉ) where
focus : ∀ {ℓ} u → Focus {ℓ} (explore u)
focus 𝟘ᵁ = 𝟘ᶠ
focus 𝟙ᵁ = 𝟙ᶠ
focus 𝟚ᵁ = 𝟚ᶠ
focus (u₀ ×ᵁ u₁) = focus× {eᴬ = explore u₀} {eᴮ = explore u₁} (focus u₀) (focus u₁)
focus (u₀ ⊎ᵁ u₁) = focus⊎ {eᴬ = explore u₀} {eᴮ = explore u₁} (focus u₀) (focus u₁)
focus (Σᵁ u f) = focusΣ {eᴬ = explore u} {eᴮ = λ {x} → explore (f x)} (focus u) (λ {x} → focus (f x))
focus Xᵁ = Xᶠ
focus (≃ᵁ u A e) = focus-iso e {Aᵉ = explore u} (focus u)
module FromΣᵉX-ok (ΣᵉX-ok : ∀ {ℓ} → Adequate-Σ {ℓ} ΣᵉX){{_ : UA}}{{_ : FunExt}} where
Σᵉ-ok : ∀ {ℓ} u → Adequate-Σ {ℓ} (ΣᵉU u)
Σᵉ-ok 𝟘ᵁ = Σᵉ𝟘-ok
Σᵉ-ok 𝟙ᵁ = Σᵉ𝟙-ok
Σᵉ-ok 𝟚ᵁ = Σᵉ𝟚-ok
Σᵉ-ok (u₀ ×ᵁ u) = Σᵉ×-ok {eᴬ = explore u₀} {eᴮ = explore u} (Σᵉ-ok u₀) (Σᵉ-ok u)
Σᵉ-ok (u₀ ⊎ᵁ u) = Σᵉ⊎-ok {eᴬ = explore u₀} {eᴮ = explore u} (Σᵉ-ok u₀) (Σᵉ-ok u)
Σᵉ-ok (Σᵁ u f) = ΣᵉΣ-ok {eᴬ = explore u} {eᴮ = λ {x} → explore (f x)} (Σᵉ-ok u) (λ {x} → Σᵉ-ok (f x))
Σᵉ-ok Xᵁ = ΣᵉX-ok
Σᵉ-ok (≃ᵁ u A e) = Σ-iso-ok e {Aᵉ = explore u} (Σᵉ-ok u)
module FromΠᵉX-ok (ΠᵉX-ok : ∀ {ℓ} → Adequate-Π {ℓ} ΠᵉX){{_ : UA}}{{_ : FunExt}} where
Πᵉ-ok : ∀ {ℓ} u → Adequate-Π {ℓ} (ΠᵉU u)
Πᵉ-ok 𝟘ᵁ = Πᵉ𝟘-ok
Πᵉ-ok 𝟙ᵁ = Πᵉ𝟙-ok
Πᵉ-ok 𝟚ᵁ = Πᵉ𝟚-ok
Πᵉ-ok (u₀ ×ᵁ u) = Πᵉ×-ok {eᴬ = explore u₀} {eᴮ = explore u} (Πᵉ-ok u₀) (Πᵉ-ok u)
Πᵉ-ok (u₀ ⊎ᵁ u) = Πᵉ⊎-ok {eᴬ = explore u₀} {eᴮ = explore u} (Πᵉ-ok u₀) (Πᵉ-ok u)
Πᵉ-ok (Σᵁ u f) = ΠᵉΣ-ok {eᴬ = explore u} {eᴮ = λ {x} → explore (f x)} (Πᵉ-ok u) (λ {x} → Πᵉ-ok (f x))
Πᵉ-ok Xᵁ = ΠᵉX-ok
Πᵉ-ok (≃ᵁ u A e) = Π-iso-ok e {Aᵉ = explore u} (Πᵉ-ok u)
module From⟦Xᵉ⟧≡ (⟦Xᵉ⟧≡ : ∀ {ℓ₀ ℓ₁} ℓᵣ → ⟦Explore⟧ {ℓ₀} {ℓ₁} ℓᵣ _≡_ Xᵉ Xᵉ) {ℓ₀ ℓ₁} ℓᵣ where
⟦explore⟧≡ : ∀ u → ⟦Explore⟧ {ℓ₀} {ℓ₁} ℓᵣ _≡_ (explore u) (explore u)
⟦explore⟧≡ 𝟘ᵁ = ⟦𝟘ᵉ⟧ {ℓᵣ = ℓᵣ}
⟦explore⟧≡ 𝟙ᵁ = ⟦𝟙ᵉ⟧ {ℓᵣ = ℓᵣ} {_≡_} {idp}
⟦explore⟧≡ 𝟚ᵁ = ⟦𝟚ᵉ⟧ {ℓᵣ = ℓᵣ} {_≡_} {idp} {idp}
⟦explore⟧≡ (u₀ ×ᵁ u₁) = ⟦explore×⟧≡ {ℓᵣ = ℓᵣ} (⟦explore⟧≡ u₀) (⟦explore⟧≡ u₁)
⟦explore⟧≡ (u₀ ⊎ᵁ u₁) = ⟦explore⊎⟧≡ {ℓᵣ = ℓᵣ} (⟦explore⟧≡ u₀) (⟦explore⟧≡ u₁)
⟦explore⟧≡ (Σᵁ u F) = ⟦exploreΣ⟧≡ {ℓᵣ = ℓᵣ} (⟦explore⟧≡ u) (λ x → ⟦explore⟧≡ (F x))
⟦explore⟧≡ Xᵁ = ⟦Xᵉ⟧≡ ℓᵣ
⟦explore⟧≡ (≃ᵁ u A e) = ⟦explore-iso⟧ e {ℓᵣ = ℓᵣ} (ap (fst e)) (⟦explore⟧≡ u)
module FromΠX (ΠX : (X → U) → U) where
Πᵁ : (u : U) (v : El u → U) → U
Πᵁ 𝟘ᵁ v = 𝟙ᵁ
Πᵁ 𝟙ᵁ v = v _
Πᵁ 𝟚ᵁ v = v 0₂ ×ᵁ v 1₂
Πᵁ (u ×ᵁ u₁) v = Πᵁ u λ x → Πᵁ u₁ λ y → v (x , y)
Πᵁ (u ⊎ᵁ u₁) v = (Πᵁ u (v ∘ inl)) ×ᵁ (Πᵁ u₁ (v ∘ inr))
Πᵁ (Σᵁ u f) v = Πᵁ u λ x → Πᵁ (f x) (v ∘ _,_ x)
Πᵁ Xᵁ v = ΠX v
Πᵁ (≃ᵁ u A e)v = Πᵁ u (v ∘ fst e)
_→ᵁ_ : (u : U) (v : U) → U
u →ᵁ v = Πᵁ u (const v)
module FromΠX≃ (ΠX≃ : ∀ v → El (ΠX v) ≃ Π X (El ∘ v)) where
private
module ΠX≃ {v} = Equivalences.Equiv (ΠX≃ v)
module _ {{_ : FunExt}}{{_ : UA}} where
Πᵁ-Π : ∀ u v → El (Πᵁ u v) ≡ Π (El u) (El ∘ v)
Πᵁ-Π 𝟘ᵁ v = ! Π𝟘-uniq₀ _
Πᵁ-Π 𝟙ᵁ v = ! Π𝟙-uniq _
Πᵁ-Π 𝟚ᵁ v = ! Π𝟚-×
Πᵁ-Π (u ×ᵁ u₁) v = Πᵁ-Π u (λ x → Πᵁ u₁ (v ∘ _,_ x)) ∙ Π=′ _ (λ _ → Πᵁ-Π u₁ _) ∙ ! ΠΣ-curry
Πᵁ-Π (u ⊎ᵁ u₁) v = ×= (Πᵁ-Π u (v ∘ inl)) (Πᵁ-Π u₁ (v ∘ inr)) ∙ ! dist-×-Π
Πᵁ-Π (Σᵁ u f) v = Πᵁ-Π u (λ x → Πᵁ (f _) (v ∘ _,_ x)) ∙ Π=′ _ (λ _ → Πᵁ-Π (f _) _) ∙ ! ΠΣ-curry
Πᵁ-Π Xᵁ v = ua (ΠX≃ v)
Πᵁ-Π (≃ᵁ u A e)v = Πᵁ-Π u (v ∘ fst e) ∙ Π≃ e λ _ → idp
→ᵁ-→ : ∀ u v → El (u →ᵁ v) ≡ (El u → El v)
→ᵁ-→ u v = Πᵁ-Π u (const v)
Πᵁ→Π : ∀ u v → El (Πᵁ u v) → Π (El u) (El ∘ v)
Πᵁ→Π 𝟘ᵁ v x₂ ()
Πᵁ→Π 𝟙ᵁ v x₂ x₃ = x₂
Πᵁ→Π 𝟚ᵁ v (x , y) 0₂ = x
Πᵁ→Π 𝟚ᵁ v (x , y) 1₂ = y
Πᵁ→Π (u ×ᵁ u₁) v x (z , t) = Πᵁ→Π u₁ (v ∘ _,_ z) (Πᵁ→Π u (λ x → Πᵁ u₁ (v ∘ _,_ x)) x z) t
Πᵁ→Π (u ⊎ᵁ _) v (x , _) (inl y) = Πᵁ→Π u (v ∘ inl) x y
Πᵁ→Π (_ ⊎ᵁ u) v (_ , x) (inr y) = Πᵁ→Π u (v ∘ inr) x y
Πᵁ→Π (Σᵁ u f) v x (y , z) = Πᵁ→Π (f _) (v ∘ _,_ y) (Πᵁ→Π u (λ x → Πᵁ (f _) (v ∘ _,_ x)) x y) z
Πᵁ→Π Xᵁ v = ΠX≃.·→
Πᵁ→Π (≃ᵁ u A e) v f x = tr (El ∘ v) (·←-inv-r x) (Πᵁ→Π u (v ∘ ·→) f (·← x))
where open Equivalences.Equiv e
Π→Πᵁ : ∀ u v → Π (El u) (El ∘ v) → El (Πᵁ u v)
Π→Πᵁ 𝟘ᵁ v f = 0₁
Π→Πᵁ 𝟙ᵁ v f = f 0₁
Π→Πᵁ 𝟚ᵁ v f = f 0₂ , f 1₂
Π→Πᵁ (u ×ᵁ u₁) v f = Π→Πᵁ u (λ x → Πᵁ u₁ (v ∘ _,_ x))
(λ x → Π→Πᵁ u₁ (v ∘ _,_ x) (f ∘ _,_ x))
Π→Πᵁ (u ⊎ᵁ u₁) v f = Π→Πᵁ u (v ∘ inl) (f ∘ inl) ,
Π→Πᵁ u₁ (v ∘ inr) (f ∘ inr)
Π→Πᵁ (Σᵁ u F) v f = Π→Πᵁ u (λ x → Πᵁ (F x) (v ∘ _,_ x))
(λ x → Π→Πᵁ (F x) (v ∘ _,_ x) (f ∘ _,_ x))
Π→Πᵁ Xᵁ v = ΠX≃.·←
Π→Πᵁ (≃ᵁ u A e) v f = Π→Πᵁ u (v ∘ ·→) (f ∘ ·→)
where open Equivalences.Equiv e
→ᵁ→→ : ∀ u v → El (u →ᵁ v) → (El u → El v)
→ᵁ→→ u v = Πᵁ→Π u (const v)
→→→ᵁ : ∀ u v → (El u → El v) → El (u →ᵁ v)
→→→ᵁ u v = Π→Πᵁ u (const v)
| 40.610837
| 109
| 0.513222
|
3df87eec09adbde9903af55126972876b6924daf
| 890
|
agda
|
Agda
|
src/Web/Semantic/DL/FOL/Model.agda
|
agda/agda-web-semantic
|
8ddbe83965a616bff6fc7a237191fa261fa78bab
|
[
"MIT"
] | 9
|
2015-09-13T17:46:41.000Z
|
2020-03-14T14:21:08.000Z
|
src/Web/Semantic/DL/FOL/Model.agda
|
bblfish/agda-web-semantic
|
38fbc3af7062ba5c3d7d289b2b4bcfb995d99057
|
[
"MIT"
] | 4
|
2018-11-14T02:32:28.000Z
|
2021-01-04T20:57:19.000Z
|
src/Web/Semantic/DL/FOL/Model.agda
|
bblfish/agda-web-semantic
|
38fbc3af7062ba5c3d7d289b2b4bcfb995d99057
|
[
"MIT"
] | 3
|
2017-12-03T14:52:09.000Z
|
2022-03-12T11:40:03.000Z
|
open import Data.Product using ( _×_ ; _,_ )
open import Data.Sum using ( _⊎_ )
open import Relation.Unary using ( _∈_ ; _∉_ )
open import Web.Semantic.DL.FOL using ( Formula ; true ; false ; _∧_ ; _∈₁_ ; _∈₁_⇒_ ; _∈₂_ ; _∈₂_⇒_ ; _∼_ ; _∼_⇒_ ; ∀₁ )
open import Web.Semantic.DL.Signature using ( Signature )
open import Web.Semantic.DL.TBox.Interp using ( Interp ; Δ ; _⊨_≈_ ; con ; rol )
open import Web.Semantic.Util using ( True ; False )
module Web.Semantic.DL.FOL.Model {Σ : Signature} where
_⊨f_ : (I : Interp Σ) → Formula Σ (Δ I) → Set
I ⊨f true = True
I ⊨f false = False
I ⊨f (F ∧ G) = (I ⊨f F) × (I ⊨f G)
I ⊨f (x ∈₁ c) = x ∈ (con I c)
I ⊨f (x ∈₁ c ⇒ F) = (x ∈ (con I c)) → (I ⊨f F)
I ⊨f ((x , y) ∈₂ r) = (x , y) ∈ (rol I r)
I ⊨f ((x , y) ∈₂ r ⇒ F) = ((x , y) ∈ (rol I r)) → (I ⊨f F)
I ⊨f (x ∼ y) = I ⊨ x ≈ y
I ⊨f (x ∼ y ⇒ F) = (I ⊨ x ≈ y) → (I ⊨f F)
I ⊨f ∀₁ F = ∀ x → (I ⊨f F x)
| 40.454545
| 122
| 0.533708
|
237bc90c8807ba958ed8d5a29390b7c2318c4d8b
| 1,323
|
agda
|
Agda
|
TypeTheory/Common/SumProperties.agda
|
hbasold/Sandbox
|
8fc7a6cd878f37f9595124ee8dea62258da28aa4
|
[
"MIT"
] | null | null | null |
TypeTheory/Common/SumProperties.agda
|
hbasold/Sandbox
|
8fc7a6cd878f37f9595124ee8dea62258da28aa4
|
[
"MIT"
] | null | null | null |
TypeTheory/Common/SumProperties.agda
|
hbasold/Sandbox
|
8fc7a6cd878f37f9595124ee8dea62258da28aa4
|
[
"MIT"
] | null | null | null |
module Common.SumProperties where
open import Function as Fun
open import Data.Sum as Sum
open import Relation.Binary.PropositionalEquality as PE hiding ([_])
open ≡-Reasoning
copair-elimˡ : {A B C : Set} {f : A → C} {g : B → C} (x : A) →
([ f , g ]′ ) (inj₁ x) ≡ f x
copair-elimˡ x = refl
copair-elimʳ : {A B C : Set} {f : A → C} {g : B → C} (x : B) →
([ f , g ]′ ) (inj₂ x) ≡ g x
copair-elimʳ x = refl
copair-sum-map-merge : {A A' B B' C : Set}
{f₁ : A → A'} {f₂ : B → B'} {g₁ : A' → C} {g₂ : B' → C}
(x : A ⊎ B) →
([ g₁ , g₂ ]′ ∘ Sum.map f₁ f₂) x ≡ [ g₁ ∘ f₁ , g₂ ∘ f₂ ]′ x
copair-sum-map-merge (inj₁ x) = refl
copair-sum-map-merge (inj₂ y) = refl
copair-cong : {A B C : Set} {f f' : A → C} {g : B → C}
(p : (x : A) → f x ≡ f' x) →
(x : A ⊎ B) →
[ f , g ]′ x ≡ [ f' , g ]′ x
copair-cong {A} {B} {C} {f} {f'} {g} p (inj₁ x) =
begin
([ f , g ]′ (inj₁ x))
≡⟨ refl ⟩
f x
≡⟨ p x ⟩
f' x
≡⟨ refl ⟩
[ f' , g ]′ (inj₁ x)
∎
copair-cong p (inj₂ y) = refl
copair-distr : {A B C D : Set} {f : A → C} {g : B → C} {h : C → D}
(x : A ⊎ B) →
[ h ∘ f , h ∘ g ]′ x ≡ (h ∘ [ f , g ]′) x
copair-distr (inj₁ x) = refl
copair-distr (inj₂ y) = refl
| 30.068182
| 80
| 0.421013
|
41aa225f0cedd1e559d4ad3b87d31caf8ca5e6e5
| 1,568
|
agda
|
Agda
|
test/Succeed/TerminationRecordPatternCoerce.agda
|
vlopezj/agda
|
ff4d89e75970cf27599fb9f572bd43c9455cbb56
|
[
"BSD-3-Clause"
] | 2
|
2019-10-29T09:40:30.000Z
|
2020-09-20T00:28:57.000Z
|
test/Succeed/TerminationRecordPatternCoerce.agda
|
vikfret/agda
|
49ad0b3f0d39c01bc35123478b857e702b29fb9d
|
[
"BSD-3-Clause"
] | 3
|
2018-11-14T15:31:44.000Z
|
2019-04-01T19:39:26.000Z
|
test/Succeed/TerminationRecordPatternCoerce.agda
|
vikfret/agda
|
49ad0b3f0d39c01bc35123478b857e702b29fb9d
|
[
"BSD-3-Clause"
] | 1
|
2015-09-15T14:36:15.000Z
|
2015-09-15T14:36:15.000Z
|
-- 2010-10-05 Andreas
module TerminationRecordPatternCoerce where
data Empty : Set where
record Unit : Set where
constructor unit
data Bool : Set where
true false : Bool
T : Bool -> Set
T true = Unit
T false = Empty
data _==_ {A : Set}(a : A) : A -> Set where
refl : a == a
subst : forall {A a b} -> a == b -> {P : A -> Set} -> P a -> P b
subst refl x = x
-- Thorsten suggests on the Agda list thread "Coinductive families"
-- to encode lists as records
record List (A : Set) : Set where
inductive
constructor list
field
isCons : Bool
head : T isCons -> A
tail : T isCons -> List A
open List public
-- However, we have to be careful to preserve termination
-- in the presence of a lie
postulate
lie : {b : Bool} -> T b
-- if the record constructor list was counted as structural increase
-- this function would not be rejected
f : {A : Set} -> (b : Bool) -> (l : List A) -> b == isCons l -> Unit
f .false (list false h t) refl = unit
f .true (list true h t) refl = f (isCons tl) tl refl
where tl : List _
tl = t unit
{- dot patterns inside of record patterns not supported!
f true (list .true h t) refl = f (isCons tl) tl refl
where tl : List _
tl = t unit
-}
-- however, it is almost like the following
f' : {A : Set} -> (b : Bool) -> (l : List A) -> b == isCons l -> Unit
f' false l p = unit
f' true (list b' h t) p = f' (isCons tl) tl refl
where tl : List _
tl = t (subst p {T} unit)
-- UPDATE: both of these are fine, since non-eta records patterns are not
-- translated to projections.
| 24.888889
| 73
| 0.627551
|
1ede1968ee02968ea84858b0162f60ef74fe6757
| 702
|
agda
|
Agda
|
Cubical/Homotopy/Loopspace.agda
|
ryanorendorff/cubical
|
c67854d2e11aafa5677e25a09087e176fafd3e43
|
[
"MIT"
] | 1
|
2020-03-23T23:52:11.000Z
|
2020-03-23T23:52:11.000Z
|
Cubical/Homotopy/Loopspace.agda
|
ryanorendorff/cubical
|
c67854d2e11aafa5677e25a09087e176fafd3e43
|
[
"MIT"
] | null | null | null |
Cubical/Homotopy/Loopspace.agda
|
ryanorendorff/cubical
|
c67854d2e11aafa5677e25a09087e176fafd3e43
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --cubical --safe #-}
module Cubical.Homotopy.Loopspace where
open import Cubical.Core.Everything
open import Cubical.Data.Nat
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Pointed
open import Cubical.Foundations.GroupoidLaws
{- loop space of a pointed type -}
Ω : {ℓ : Level} → Pointed ℓ → Pointed ℓ
Ω (_ , a) = ((a ≡ a) , refl)
{- n-fold loop space of a pointed type -}
Ω^_ : ∀ {ℓ} → ℕ → Pointed ℓ → Pointed ℓ
(Ω^ 0) p = p
(Ω^ (suc n)) p = Ω ((Ω^ n) p)
{- loop space map -}
Ω→ : ∀ {ℓA ℓB} {A : Pointed ℓA} {B : Pointed ℓB} (f : A →∙ B) → (Ω A →∙ Ω B)
Ω→ (f , f∙) = (λ p → (sym f∙ ∙ cong f p) ∙ f∙) , cong (λ q → q ∙ f∙) (sym (rUnit (sym f∙))) ∙ lCancel f∙
| 28.08
| 104
| 0.602564
|
5985960f8bac16cbda93156720667d5ebe80b6b9
| 763
|
agda
|
Agda
|
test/Succeed/Issue5007.agda
|
cagix/agda
|
cc026a6a97a3e517bb94bafa9d49233b067c7559
|
[
"BSD-2-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
test/Succeed/Issue5007.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
test/Succeed/Issue5007.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
record R₁ : Set₂ where
field
_≡_ : {A : Set₁} → A → A → Set
postulate
A B : Set
record R₂ (r₁ : R₁) : Set₂ where
open R₁ r₁
field
cong : (A : Set₁) (x y : A) (F : A → Set) → x ≡ y → F x ≡ F y
subst : (P : Set → Set₁) → A ≡ B → P A → P B
postulate
_≡_ : {A : Set₁} → A → A → Set
r₁ : R₁
r₁ .R₁._≡_ = _≡_
postulate
r₂ : ∀ r₁ → R₂ r₁
open R₂ (r₂ r₁)
record R₃ (@0 A : Set₁) : Set₁ where
constructor [_]
field
f : A
postulate
r₃ : R₃ Set
push-subst-[] :
(P : Set → Set₁) (p : P A) (eq : A ≡ B) →
subst (λ A → R₃ (P A)) eq [ p ] ≡ [ subst P eq p ]
_ :
(eq : A ≡ B) →
(subst (λ _ → R₃ Set) eq r₃ ≡ r₃) ≡
([ subst (λ _ → Set) eq (r₃ .R₃.f) ] ≡ r₃)
_ = λ eq → cong _ _ _ (_≡ _) (push-subst-[] _ _ _)
| 18.609756
| 66
| 0.466579
|
8b644cd0c5275b3e95239ab5d6c99f0bde3af3d0
| 2,550
|
agda
|
Agda
|
Definition/Typed/Consequences/Reduction.agda
|
CoqHott/logrel-mltt
|
e0eeebc4aa5ed791ce3e7c0dc9531bd113dfcc04
|
[
"MIT"
] | 2
|
2018-06-21T08:39:01.000Z
|
2022-01-17T16:13:53.000Z
|
Definition/Typed/Consequences/Reduction.agda
|
CoqHott/logrel-mltt
|
e0eeebc4aa5ed791ce3e7c0dc9531bd113dfcc04
|
[
"MIT"
] | null | null | null |
Definition/Typed/Consequences/Reduction.agda
|
CoqHott/logrel-mltt
|
e0eeebc4aa5ed791ce3e7c0dc9531bd113dfcc04
|
[
"MIT"
] | 2
|
2022-01-26T14:55:51.000Z
|
2022-02-15T19:42:19.000Z
|
{-# OPTIONS --safe #-}
module Definition.Typed.Consequences.Reduction where
open import Definition.Untyped
open import Definition.Typed
open import Definition.Typed.Properties
open import Definition.Typed.EqRelInstance
open import Definition.LogicalRelation
open import Definition.LogicalRelation.Properties
open import Definition.LogicalRelation.Fundamental.Reducibility
import Tools.PropositionalEquality as PE
open import Tools.Product
-- Helper function where all reducible types can be reduced to WHNF.
whNorm′ : ∀ {A rA Γ l} ([A] : Γ ⊩⟨ l ⟩ A ^ rA)
→ ∃ λ B → Whnf B × Γ ⊢ A :⇒*: B ^ rA
whNorm′ (Uᵣ′ _ _ r l _ e d) = Univ r l , Uₙ , PE.subst (λ ll → _ ⊢ _ :⇒*: Univ r l ^ [ ! , ll ]) e d
whNorm′ (ℕᵣ D) = ℕ , ℕₙ , D
whNorm′ (Emptyᵣ {l = l} D) = Empty l , Emptyₙ , D
whNorm′ (ne′ K D neK K≡K) = K , ne neK , D
whNorm′ (Πᵣ {l = l} (Πᵣ rF lF lG lF≤ lG≤ F G D ⊢F ⊢G A≡A [F] [G] G-ext)) = Π F ^ rF ° lF ▹ G ° lG ° l , Πₙ , D
whNorm′ (∃ᵣ′ F G D ⊢F ⊢G A≡A [F] [G] G-ext) = ∃ F ▹ G , ∃ₙ , D
whNorm′ (emb emb< [A]) = whNorm′ [A]
whNorm′ (emb ∞< [A]) = whNorm′ [A]
-- Well-formed types can all be reduced to WHNF.
whNorm : ∀ {A rA Γ} → Γ ⊢ A ^ rA → ∃ λ B → Whnf B × Γ ⊢ A :⇒*: B ^ rA
whNorm A = whNorm′ (reducible A)
-- whNorm-conv : ∀ {A rA Γ} → Γ ⊢ A ≡ B ^ rA → ∃ λ B → Whnf B × Γ ⊢ A :⇒*: B ^ rA
-- whNorm-conv A = whNorm′ (reducible A)
-- Helper function where reducible all terms can be reduced to WHNF.
whNormTerm′ : ∀ {a A Γ l lA} ([A] : Γ ⊩⟨ l ⟩ A ^ [ ! , lA ]) → Γ ⊩⟨ l ⟩ a ∷ A ^ [ ! , lA ] / [A]
→ ∃ λ b → Whnf b × Γ ⊢ a :⇒*: b ∷ A ^ lA
whNormTerm′ (Uᵣ′ _ _ r l _ e dU) (Uₜ A d typeA A≡A [t]) = A , typeWhnf typeA ,
conv:⇒*: (PE.subst (λ ll → _ ⊢ _ :⇒*: _ ∷ _ ^ ll) e d)
(sym (subset* (red (PE.subst (λ ll → _ ⊢ _ :⇒*: Univ r l ^ [ ! , ll ]) e dU))))
whNormTerm′ (ℕᵣ x) (ℕₜ n d n≡n prop) =
let natN = natural prop
in n , naturalWhnf natN , convRed:*: d (sym (subset* (red x)))
whNormTerm′ (ne (ne K D neK K≡K)) (neₜ k d (neNfₜ neK₁ ⊢k k≡k)) =
k , ne neK₁ , convRed:*: d (sym (subset* (red D)))
whNormTerm′ (Πᵣ′ rF lF lG lF≤ lG≤ F G D ⊢F ⊢G A≡A [F] [G] G-ext) (Πₜ f d funcF f≡f [f] [f]₁) =
f , functionWhnf funcF , convRed:*: d (sym (subset* (red D)))
whNormTerm′ (emb emb< [A]) [a] = whNormTerm′ [A] [a]
whNormTerm′ (emb ∞< [A]) [a] = whNormTerm′ [A] [a]
-- Well-formed terms can all be reduced to WHNF.
whNormTerm : ∀ {a A Γ lA} → Γ ⊢ a ∷ A ^ [ ! , lA ] → ∃ λ b → Whnf b × Γ ⊢ a :⇒*: b ∷ A ^ lA
whNormTerm {a} {A} ⊢a =
let [A] , [a] = reducibleTerm ⊢a
in whNormTerm′ [A] [a]
| 42.5
| 110
| 0.559608
|
dffac9f183a2c1ac7b5307e3d4f4c1613c475d72
| 296
|
agda
|
Agda
|
notes/README/Test.agda
|
asr/apia
|
a66c5ddca2ab470539fd68c42c4fbd45f720d682
|
[
"MIT"
] | 10
|
2015-09-03T20:54:16.000Z
|
2019-12-03T13:44:25.000Z
|
notes/README/Test.agda
|
asr/apia
|
a66c5ddca2ab470539fd68c42c4fbd45f720d682
|
[
"MIT"
] | 121
|
2015-01-25T13:22:12.000Z
|
2018-04-22T06:01:44.000Z
|
notes/README/Test.agda
|
asr/apia
|
a66c5ddca2ab470539fd68c42c4fbd45f720d682
|
[
"MIT"
] | 4
|
2016-05-10T23:06:19.000Z
|
2016-08-03T03:54:55.000Z
|
{-# OPTIONS --exact-split #-}
{-# OPTIONS --no-universe-polymorphism #-}
{-# OPTIONS --without-K #-}
module Test where
data _∨_ (A B : Set) : Set where
inj₁ : A → A ∨ B
inj₂ : B → A ∨ B
postulate
A B : Set
∨-comm : A ∨ B → B ∨ A
{-# ATP prove ∨-comm #-}
| 19.733333
| 42
| 0.483108
|
fb9ed4e58b5068b38723aa921a36ba53bb3fa5b6
| 986
|
agda
|
Agda
|
src/Categories/Category/Instance/Cartesians.agda
|
turion/agda-categories
|
ad0f94b6cf18d8a448b844b021aeda58e833d152
|
[
"MIT"
] | 5
|
2020-10-07T12:07:53.000Z
|
2020-10-10T21:41:32.000Z
|
src/Categories/Category/Instance/Cartesians.agda
|
turion/agda-categories
|
ad0f94b6cf18d8a448b844b021aeda58e833d152
|
[
"MIT"
] | null | null | null |
src/Categories/Category/Instance/Cartesians.agda
|
turion/agda-categories
|
ad0f94b6cf18d8a448b844b021aeda58e833d152
|
[
"MIT"
] | 1
|
2021-11-04T06:54:45.000Z
|
2021-11-04T06:54:45.000Z
|
{-# OPTIONS --without-K --safe #-}
module Categories.Category.Instance.Cartesians where
open import Level
open import Categories.Category
open import Categories.Category.Helper
open import Categories.Category.Cartesian.Structure
open import Categories.Functor.Cartesian
open import Categories.Functor.Cartesian.Properties
open import Categories.NaturalTransformation.NaturalIsomorphism
module _ o ℓ e where
Cartesians : Category (suc (o ⊔ ℓ ⊔ e)) (o ⊔ ℓ ⊔ e) (o ⊔ ℓ ⊔ e)
Cartesians = categoryHelper record
{ Obj = CartesianCategory o ℓ e
; _⇒_ = CartesianF
; _≈_ = λ F G → CF.F F ≃ CF.F G
; id = idF-CartesianF _
; _∘_ = ∘-CartesianF
; assoc = λ {_ _ _ _ F G H} → associator (CF.F F) (CF.F G) (CF.F H)
; identityˡ = unitorˡ
; identityʳ = unitorʳ
; equiv = record
{ refl = ≃.refl
; sym = ≃.sym
; trans = ≃.trans
}
; ∘-resp-≈ = _ⓘₕ_
}
where module CF = CartesianF
| 29
| 75
| 0.621704
|
a0b484e32f40554d0d2c3c746fb349809d1eb5b7
| 3,414
|
agda
|
Agda
|
src/Categories/Category/Core.agda
|
bond15/agda-categories
|
6cbfdf3f1be15ef513435e3b85faae92cb1ac36f
|
[
"MIT"
] | null | null | null |
src/Categories/Category/Core.agda
|
bond15/agda-categories
|
6cbfdf3f1be15ef513435e3b85faae92cb1ac36f
|
[
"MIT"
] | null | null | null |
src/Categories/Category/Core.agda
|
bond15/agda-categories
|
6cbfdf3f1be15ef513435e3b85faae92cb1ac36f
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --without-K --safe #-}
module Categories.Category.Core where
open import Level
open import Function.Base using (flip)
open import Relation.Binary using (Rel; IsEquivalence; Setoid)
import Relation.Binary.Reasoning.Setoid as SetoidR
-- Basic definition of a |Category| with a Hom setoid.
-- Also comes with some reasoning combinators (see HomReasoning)
record Category (o ℓ e : Level) : Set (suc (o ⊔ ℓ ⊔ e)) where
eta-equality
infix 4 _≈_ _⇒_
infixr 9 _∘_
field
Obj : Set o
_⇒_ : Rel Obj ℓ
_≈_ : ∀ {A B} → Rel (A ⇒ B) e
id : ∀ {A} → (A ⇒ A)
_∘_ : ∀ {A B C} → (B ⇒ C) → (A ⇒ B) → (A ⇒ C)
field
assoc : ∀ {A B C D} {f : A ⇒ B} {g : B ⇒ C} {h : C ⇒ D} → (h ∘ g) ∘ f ≈ h ∘ (g ∘ f)
-- We add a symmetric proof of associativity so that the opposite category of the
-- opposite category is definitionally equal to the original category. See how
-- `op` is implemented.
sym-assoc : ∀ {A B C D} {f : A ⇒ B} {g : B ⇒ C} {h : C ⇒ D} → h ∘ (g ∘ f) ≈ (h ∘ g) ∘ f
identityˡ : ∀ {A B} {f : A ⇒ B} → id ∘ f ≈ f
identityʳ : ∀ {A B} {f : A ⇒ B} → f ∘ id ≈ f
-- We add a proof of "neutral" identity proof, in order to ensure the opposite of
-- constant functor is definitionally equal to itself.
identity² : ∀ {A} → id ∘ id {A} ≈ id {A}
equiv : ∀ {A B} → IsEquivalence (_≈_ {A} {B})
∘-resp-≈ : ∀ {A B C} {f h : B ⇒ C} {g i : A ⇒ B} → f ≈ h → g ≈ i → f ∘ g ≈ h ∘ i
module Equiv {A B : Obj} = IsEquivalence (equiv {A} {B})
open Equiv
∘-resp-≈ˡ : ∀ {A B C} {f h : B ⇒ C} {g : A ⇒ B} → f ≈ h → f ∘ g ≈ h ∘ g
∘-resp-≈ˡ pf = ∘-resp-≈ pf refl
∘-resp-≈ʳ : ∀ {A B C} {f h : A ⇒ B} {g : B ⇒ C} → f ≈ h → g ∘ f ≈ g ∘ h
∘-resp-≈ʳ pf = ∘-resp-≈ refl pf
hom-setoid : ∀ {A B} → Setoid _ _
hom-setoid {A} {B} = record
{ Carrier = A ⇒ B
; _≈_ = _≈_
; isEquivalence = equiv
}
-- When a category is quatified, it is convenient to refer to the levels from a module,
-- so we do not have to explicitly quantify over a category when universe levels do not
-- play a big part in a proof (which is the case probably all the time).
o-level : Level
o-level = o
ℓ-level : Level
ℓ-level = ℓ
e-level : Level
e-level = e
-- Reasoning combinators. _≈⟨_⟩_ and _≈˘⟨_⟩_ from SetoidR.
-- Also some useful combinators for doing reasoning on _∘_ chains
module HomReasoning {A B : Obj} where
open SetoidR (hom-setoid {A} {B}) public
-- open Equiv {A = A} {B = B} public
infixr 4 _⟩∘⟨_ refl⟩∘⟨_
infixl 5 _⟩∘⟨refl
_⟩∘⟨_ : ∀ {M} {f h : M ⇒ B} {g i : A ⇒ M} → f ≈ h → g ≈ i → f ∘ g ≈ h ∘ i
_⟩∘⟨_ = ∘-resp-≈
refl⟩∘⟨_ : ∀ {M} {f : M ⇒ B} {g i : A ⇒ M} → g ≈ i → f ∘ g ≈ f ∘ i
refl⟩∘⟨_ = Equiv.refl ⟩∘⟨_
_⟩∘⟨refl : ∀ {M} {f h : M ⇒ B} {g : A ⇒ M} → f ≈ h → f ∘ g ≈ h ∘ g
_⟩∘⟨refl = _⟩∘⟨ Equiv.refl
-- convenient inline versions
infix 2 ⟺
infixr 3 _○_
⟺ : {f g : A ⇒ B} → f ≈ g → g ≈ f
⟺ = Equiv.sym
_○_ : {f g h : A ⇒ B} → f ≈ g → g ≈ h → f ≈ h
_○_ = Equiv.trans
op : Category o ℓ e
op = record
{ Obj = Obj
; _⇒_ = flip _⇒_
; _≈_ = _≈_
; _∘_ = flip _∘_
; id = id
; assoc = sym-assoc
; sym-assoc = assoc
; identityˡ = identityʳ
; identityʳ = identityˡ
; identity² = identity²
; equiv = equiv
; ∘-resp-≈ = flip ∘-resp-≈
}
| 31.611111
| 91
| 0.513474
|
13a8987cae39eb3cc889da0280f8307519e32f8d
| 868
|
agda
|
Agda
|
Cubical/HITs/S1/Properties.agda
|
knrafto/cubical
|
f6771617374bfe65a7043d00731fed5a673aa729
|
[
"MIT"
] | null | null | null |
Cubical/HITs/S1/Properties.agda
|
knrafto/cubical
|
f6771617374bfe65a7043d00731fed5a673aa729
|
[
"MIT"
] | 1
|
2022-01-27T02:07:48.000Z
|
2022-01-27T02:07:48.000Z
|
Cubical/HITs/S1/Properties.agda
|
knrafto/cubical
|
f6771617374bfe65a7043d00731fed5a673aa729
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --cubical --no-import-sorts --safe #-}
module Cubical.HITs.S1.Properties where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.GroupoidLaws
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.HLevels
open import Cubical.Foundations.Isomorphism
open import Cubical.Foundations.Univalence
open import Cubical.HITs.S1.Base
open import Cubical.HITs.PropositionalTruncation as PropTrunc
isConnectedS¹ : (s : S¹) → ∥ base ≡ s ∥
isConnectedS¹ base = ∣ refl ∣
isConnectedS¹ (loop i) =
squash ∣ (λ j → loop (i ∧ j)) ∣ ∣ (λ j → loop (i ∨ ~ j)) ∣ i
isGroupoidS¹ : isGroupoid S¹
isGroupoidS¹ s t =
PropTrunc.rec isPropIsSet
(λ p →
subst (λ s → isSet (s ≡ t)) p
(PropTrunc.rec isPropIsSet
(λ q → subst (λ t → isSet (base ≡ t)) q isSetΩS¹)
(isConnectedS¹ t)))
(isConnectedS¹ s)
| 31
| 62
| 0.699309
|
1eeb4c85e88ba64c6dd3012551890426d85cbb86
| 733
|
agda
|
Agda
|
Cubical/Data/Universe/Properties.agda
|
Rotsor/cubical
|
d55cd4834ca1f171f58b4a0c46b804ea6d18191f
|
[
"MIT"
] | null | null | null |
Cubical/Data/Universe/Properties.agda
|
Rotsor/cubical
|
d55cd4834ca1f171f58b4a0c46b804ea6d18191f
|
[
"MIT"
] | null | null | null |
Cubical/Data/Universe/Properties.agda
|
Rotsor/cubical
|
d55cd4834ca1f171f58b4a0c46b804ea6d18191f
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --cubical --safe #-}
module Cubical.Data.Universe.Properties where
open import Cubical.Core.Everything
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.HLevels
open import Cubical.Foundations.Univalence
isInjectiveTransport : ∀ {ℓ : Level} {A B : Type ℓ} {p q : A ≡ B}
→ transport p ≡ transport q → p ≡ q
isInjectiveTransport {p = p} {q} α i =
hcomp
(λ j → λ
{ (i = i0) → secEq univalence p j
; (i = i1) → secEq univalence q j
})
(invEq univalence ((λ a → α i a) , t i))
where
t : PathP (λ i → isEquiv (λ a → α i a)) (pathToEquiv p .snd) (pathToEquiv q .snd)
t = isProp→isContrPathP isPropIsEquiv (λ i a → α i a) _ _ .fst
| 33.318182
| 83
| 0.657572
|
9a4b76265f8e944169ba6b9f93d5614078b79580
| 18,649
|
agda
|
Agda
|
a1b.agda
|
felixwellen/adventOfCode
|
834bc9e291a76bdbcd58cbff9805161f1b1cfe71
|
[
"MIT"
] | null | null | null |
a1b.agda
|
felixwellen/adventOfCode
|
834bc9e291a76bdbcd58cbff9805161f1b1cfe71
|
[
"MIT"
] | null | null | null |
a1b.agda
|
felixwellen/adventOfCode
|
834bc9e291a76bdbcd58cbff9805161f1b1cfe71
|
[
"MIT"
] | null | null | null |
{-
Day 1, 2nd task of https://adventofcode.com/
-}
module a1b where
open import Agda.Builtin.IO using (IO)
open import Agda.Builtin.Unit using (⊤)
open import Agda.Builtin.String using (String; primShowNat)
open import Data.Nat
open import Data.Bool using (if_then_else_)
open import Data.List
postulate putStrLn : String → IO ⊤
{-# FOREIGN GHC import qualified Data.Text as T #-}
{-# COMPILE GHC putStrLn = putStrLn . T.unpack #-}
doTask1 : (list : List ℕ) → ℕ
doTask1 [] = 0
doTask1 (x ∷ []) = 0
doTask1 (x ∷ x₁ ∷ xs) =
if x <ᵇ x₁
then 1 + doTask1 (x₁ ∷ xs)
else doTask1 (x₁ ∷ xs)
doTask2 : (list : List ℕ) → ℕ
doTask2 list = doTask1 (sumSlidingWindow list)
where sumSlidingWindow : (list : List ℕ) → List ℕ
sumSlidingWindow (x₁ ∷ x₂ ∷ x₃ ∷ list) =
x₁ + x₂ + x₃ ∷ sumSlidingWindow (x₂ ∷ x₃ ∷ list)
sumSlidingWindow tooShortList = []
input =
104 ∷
105 ∷
109 ∷
120 ∷
124 ∷
113 ∷
120 ∷
121 ∷
122 ∷
123 ∷
134 ∷
133 ∷
134 ∷
150 ∷
160 ∷
165 ∷
179 ∷
178 ∷
180 ∷
178 ∷
196 ∷
197 ∷
198 ∷
204 ∷
197 ∷
213 ∷
206 ∷
207 ∷
209 ∷
210 ∷
211 ∷
223 ∷
212 ∷
224 ∷
228 ∷
238 ∷
237 ∷
238 ∷
242 ∷
245 ∷
249 ∷
250 ∷
253 ∷
248 ∷
261 ∷
265 ∷
274 ∷
276 ∷
274 ∷
275 ∷
278 ∷
275 ∷
276 ∷
267 ∷
266 ∷
272 ∷
275 ∷
279 ∷
280 ∷
286 ∷
282 ∷
292 ∷
308 ∷
323 ∷
324 ∷
319 ∷
310 ∷
304 ∷
309 ∷
310 ∷
320 ∷
326 ∷
322 ∷
340 ∷
341 ∷
340 ∷
339 ∷
344 ∷
346 ∷
342 ∷
353 ∷
352 ∷
353 ∷
349 ∷
346 ∷
330 ∷
342 ∷
343 ∷
344 ∷
329 ∷
348 ∷
346 ∷
367 ∷
373 ∷
379 ∷
384 ∷
388 ∷
398 ∷
387 ∷
392 ∷
391 ∷
385 ∷
409 ∷
411 ∷
416 ∷
419 ∷
420 ∷
423 ∷
422 ∷
420 ∷
421 ∷
422 ∷
421 ∷
422 ∷
441 ∷
438 ∷
428 ∷
431 ∷
443 ∷
427 ∷
433 ∷
434 ∷
432 ∷
421 ∷
429 ∷
432 ∷
434 ∷
439 ∷
437 ∷
445 ∷
456 ∷
462 ∷
464 ∷
472 ∷
474 ∷
460 ∷
433 ∷
439 ∷
433 ∷
444 ∷
456 ∷
457 ∷
452 ∷
454 ∷
455 ∷
465 ∷
474 ∷
475 ∷
486 ∷
489 ∷
490 ∷
491 ∷
472 ∷
477 ∷
475 ∷
493 ∷
497 ∷
495 ∷
496 ∷
488 ∷
500 ∷
501 ∷
504 ∷
505 ∷
524 ∷
525 ∷
522 ∷
530 ∷
548 ∷
545 ∷
562 ∷
570 ∷
582 ∷
583 ∷
584 ∷
586 ∷
585 ∷
604 ∷
606 ∷
610 ∷
617 ∷
619 ∷
621 ∷
623 ∷
620 ∷
622 ∷
624 ∷
625 ∷
633 ∷
627 ∷
623 ∷
638 ∷
639 ∷
644 ∷
643 ∷
644 ∷
648 ∷
663 ∷
695 ∷
681 ∷
682 ∷
686 ∷
692 ∷
708 ∷
712 ∷
720 ∷
736 ∷
737 ∷
738 ∷
739 ∷
738 ∷
741 ∷
742 ∷
741 ∷
746 ∷
748 ∷
751 ∷
750 ∷
782 ∷
788 ∷
793 ∷
799 ∷
790 ∷
834 ∷
852 ∷
860 ∷
848 ∷
856 ∷
857 ∷
859 ∷
860 ∷
863 ∷
849 ∷
844 ∷
854 ∷
860 ∷
862 ∷
865 ∷
864 ∷
866 ∷
887 ∷
878 ∷
899 ∷
893 ∷
895 ∷
896 ∷
897 ∷
876 ∷
877 ∷
886 ∷
887 ∷
898 ∷
905 ∷
906 ∷
907 ∷
875 ∷
877 ∷
875 ∷
894 ∷
893 ∷
871 ∷
878 ∷
879 ∷
872 ∷
868 ∷
873 ∷
884 ∷
900 ∷
899 ∷
886 ∷
896 ∷
903 ∷
909 ∷
928 ∷
932 ∷
935 ∷
928 ∷
913 ∷
917 ∷
919 ∷
920 ∷
912 ∷
917 ∷
923 ∷
926 ∷
927 ∷
932 ∷
936 ∷
944 ∷
942 ∷
961 ∷
960 ∷
961 ∷
956 ∷
951 ∷
971 ∷
980 ∷
990 ∷
999 ∷
1005 ∷
1008 ∷
1010 ∷
1011 ∷
1032 ∷
1034 ∷
1041 ∷
1066 ∷
1067 ∷
1064 ∷
1066 ∷
1070 ∷
1068 ∷
1079 ∷
1100 ∷
1122 ∷
1118 ∷
1111 ∷
1113 ∷
1141 ∷
1145 ∷
1170 ∷
1171 ∷
1170 ∷
1167 ∷
1170 ∷
1171 ∷
1178 ∷
1183 ∷
1186 ∷
1189 ∷
1190 ∷
1198 ∷
1200 ∷
1202 ∷
1204 ∷
1207 ∷
1226 ∷
1243 ∷
1245 ∷
1246 ∷
1247 ∷
1273 ∷
1267 ∷
1274 ∷
1276 ∷
1298 ∷
1293 ∷
1313 ∷
1315 ∷
1298 ∷
1301 ∷
1316 ∷
1322 ∷
1282 ∷
1256 ∷
1257 ∷
1263 ∷
1271 ∷
1294 ∷
1313 ∷
1322 ∷
1323 ∷
1322 ∷
1324 ∷
1309 ∷
1320 ∷
1325 ∷
1321 ∷
1327 ∷
1335 ∷
1334 ∷
1335 ∷
1346 ∷
1382 ∷
1388 ∷
1393 ∷
1395 ∷
1403 ∷
1417 ∷
1424 ∷
1426 ∷
1427 ∷
1428 ∷
1429 ∷
1432 ∷
1431 ∷
1430 ∷
1411 ∷
1439 ∷
1440 ∷
1441 ∷
1458 ∷
1461 ∷
1466 ∷
1471 ∷
1481 ∷
1483 ∷
1486 ∷
1488 ∷
1494 ∷
1490 ∷
1492 ∷
1489 ∷
1533 ∷
1560 ∷
1577 ∷
1582 ∷
1583 ∷
1592 ∷
1594 ∷
1593 ∷
1594 ∷
1599 ∷
1605 ∷
1616 ∷
1619 ∷
1621 ∷
1627 ∷
1651 ∷
1655 ∷
1656 ∷
1655 ∷
1653 ∷
1651 ∷
1652 ∷
1653 ∷
1657 ∷
1658 ∷
1660 ∷
1674 ∷
1680 ∷
1694 ∷
1700 ∷
1698 ∷
1676 ∷
1648 ∷
1644 ∷
1643 ∷
1645 ∷
1652 ∷
1653 ∷
1654 ∷
1660 ∷
1663 ∷
1664 ∷
1668 ∷
1671 ∷
1681 ∷
1687 ∷
1699 ∷
1702 ∷
1705 ∷
1707 ∷
1712 ∷
1739 ∷
1750 ∷
1753 ∷
1755 ∷
1779 ∷
1769 ∷
1792 ∷
1793 ∷
1798 ∷
1828 ∷
1832 ∷
1811 ∷
1844 ∷
1845 ∷
1846 ∷
1848 ∷
1854 ∷
1857 ∷
1859 ∷
1863 ∷
1866 ∷
1862 ∷
1894 ∷
1898 ∷
1875 ∷
1878 ∷
1879 ∷
1884 ∷
1897 ∷
1883 ∷
1894 ∷
1889 ∷
1890 ∷
1889 ∷
1907 ∷
1924 ∷
1926 ∷
1936 ∷
1940 ∷
1949 ∷
1950 ∷
1968 ∷
1973 ∷
1974 ∷
1971 ∷
1982 ∷
1989 ∷
2004 ∷
2005 ∷
2007 ∷
2018 ∷
2032 ∷
2037 ∷
2039 ∷
2040 ∷
2042 ∷
2046 ∷
2056 ∷
2053 ∷
2054 ∷
2057 ∷
2059 ∷
2063 ∷
2067 ∷
2065 ∷
2059 ∷
2049 ∷
2052 ∷
2045 ∷
2053 ∷
2057 ∷
2063 ∷
2066 ∷
2061 ∷
2068 ∷
2063 ∷
2058 ∷
2060 ∷
2061 ∷
2066 ∷
2065 ∷
2093 ∷
2094 ∷
2126 ∷
2135 ∷
2136 ∷
2119 ∷
2121 ∷
2134 ∷
2135 ∷
2137 ∷
2138 ∷
2143 ∷
2144 ∷
2152 ∷
2159 ∷
2154 ∷
2159 ∷
2162 ∷
2164 ∷
2158 ∷
2163 ∷
2162 ∷
2159 ∷
2165 ∷
2166 ∷
2167 ∷
2165 ∷
2169 ∷
2172 ∷
2182 ∷
2188 ∷
2173 ∷
2182 ∷
2175 ∷
2182 ∷
2203 ∷
2205 ∷
2206 ∷
2212 ∷
2213 ∷
2218 ∷
2229 ∷
2226 ∷
2233 ∷
2235 ∷
2233 ∷
2257 ∷
2258 ∷
2284 ∷
2280 ∷
2282 ∷
2285 ∷
2279 ∷
2280 ∷
2291 ∷
2292 ∷
2293 ∷
2294 ∷
2291 ∷
2292 ∷
2293 ∷
2300 ∷
2308 ∷
2303 ∷
2308 ∷
2312 ∷
2311 ∷
2320 ∷
2315 ∷
2326 ∷
2328 ∷
2330 ∷
2352 ∷
2349 ∷
2352 ∷
2357 ∷
2346 ∷
2360 ∷
2375 ∷
2374 ∷
2375 ∷
2377 ∷
2385 ∷
2392 ∷
2383 ∷
2386 ∷
2388 ∷
2403 ∷
2411 ∷
2400 ∷
2401 ∷
2402 ∷
2399 ∷
2400 ∷
2401 ∷
2397 ∷
2417 ∷
2419 ∷
2431 ∷
2430 ∷
2429 ∷
2421 ∷
2429 ∷
2427 ∷
2428 ∷
2429 ∷
2424 ∷
2425 ∷
2426 ∷
2432 ∷
2433 ∷
2435 ∷
2436 ∷
2441 ∷
2454 ∷
2455 ∷
2456 ∷
2464 ∷
2462 ∷
2463 ∷
2465 ∷
2475 ∷
2489 ∷
2495 ∷
2497 ∷
2467 ∷
2484 ∷
2486 ∷
2487 ∷
2502 ∷
2509 ∷
2504 ∷
2503 ∷
2496 ∷
2515 ∷
2516 ∷
2542 ∷
2550 ∷
2552 ∷
2554 ∷
2557 ∷
2559 ∷
2565 ∷
2563 ∷
2552 ∷
2553 ∷
2555 ∷
2552 ∷
2559 ∷
2564 ∷
2565 ∷
2548 ∷
2546 ∷
2536 ∷
2540 ∷
2542 ∷
2543 ∷
2544 ∷
2561 ∷
2550 ∷
2551 ∷
2552 ∷
2556 ∷
2562 ∷
2559 ∷
2596 ∷
2583 ∷
2586 ∷
2584 ∷
2585 ∷
2590 ∷
2592 ∷
2590 ∷
2591 ∷
2599 ∷
2615 ∷
2617 ∷
2595 ∷
2599 ∷
2607 ∷
2605 ∷
2600 ∷
2612 ∷
2611 ∷
2591 ∷
2611 ∷
2590 ∷
2599 ∷
2597 ∷
2604 ∷
2612 ∷
2613 ∷
2620 ∷
2603 ∷
2592 ∷
2604 ∷
2606 ∷
2588 ∷
2591 ∷
2577 ∷
2576 ∷
2606 ∷
2605 ∷
2614 ∷
2618 ∷
2622 ∷
2633 ∷
2636 ∷
2648 ∷
2649 ∷
2638 ∷
2637 ∷
2644 ∷
2651 ∷
2650 ∷
2651 ∷
2658 ∷
2657 ∷
2659 ∷
2661 ∷
2660 ∷
2658 ∷
2669 ∷
2676 ∷
2688 ∷
2691 ∷
2693 ∷
2697 ∷
2698 ∷
2702 ∷
2699 ∷
2706 ∷
2707 ∷
2710 ∷
2698 ∷
2697 ∷
2705 ∷
2717 ∷
2718 ∷
2720 ∷
2721 ∷
2731 ∷
2749 ∷
2757 ∷
2765 ∷
2767 ∷
2759 ∷
2776 ∷
2780 ∷
2784 ∷
2778 ∷
2779 ∷
2783 ∷
2788 ∷
2789 ∷
2825 ∷
2826 ∷
2820 ∷
2825 ∷
2852 ∷
2871 ∷
2870 ∷
2872 ∷
2873 ∷
2878 ∷
2882 ∷
2900 ∷
2906 ∷
2908 ∷
2907 ∷
2917 ∷
2931 ∷
2933 ∷
2931 ∷
2952 ∷
2953 ∷
2954 ∷
2962 ∷
2971 ∷
2973 ∷
2960 ∷
2965 ∷
2967 ∷
2968 ∷
2982 ∷
2983 ∷
2994 ∷
2997 ∷
3014 ∷
3026 ∷
3028 ∷
3040 ∷
3057 ∷
3063 ∷
3064 ∷
3065 ∷
3066 ∷
3073 ∷
3056 ∷
3052 ∷
3067 ∷
3070 ∷
3071 ∷
3072 ∷
3073 ∷
3077 ∷
3078 ∷
3074 ∷
3083 ∷
3082 ∷
3079 ∷
3080 ∷
3081 ∷
3073 ∷
3069 ∷
3072 ∷
3081 ∷
3111 ∷
3109 ∷
3112 ∷
3126 ∷
3127 ∷
3128 ∷
3129 ∷
3135 ∷
3146 ∷
3147 ∷
3149 ∷
3142 ∷
3148 ∷
3152 ∷
3165 ∷
3173 ∷
3201 ∷
3216 ∷
3217 ∷
3218 ∷
3217 ∷
3235 ∷
3236 ∷
3241 ∷
3247 ∷
3248 ∷
3249 ∷
3251 ∷
3252 ∷
3251 ∷
3250 ∷
3252 ∷
3260 ∷
3261 ∷
3259 ∷
3255 ∷
3256 ∷
3257 ∷
3258 ∷
3259 ∷
3264 ∷
3299 ∷
3300 ∷
3304 ∷
3313 ∷
3326 ∷
3324 ∷
3326 ∷
3331 ∷
3340 ∷
3341 ∷
3343 ∷
3348 ∷
3342 ∷
3380 ∷
3381 ∷
3370 ∷
3374 ∷
3390 ∷
3379 ∷
3382 ∷
3383 ∷
3386 ∷
3388 ∷
3382 ∷
3386 ∷
3402 ∷
3400 ∷
3406 ∷
3408 ∷
3407 ∷
3409 ∷
3411 ∷
3412 ∷
3411 ∷
3412 ∷
3422 ∷
3441 ∷
3446 ∷
3451 ∷
3449 ∷
3451 ∷
3480 ∷
3500 ∷
3511 ∷
3520 ∷
3521 ∷
3525 ∷
3548 ∷
3557 ∷
3558 ∷
3560 ∷
3561 ∷
3562 ∷
3570 ∷
3571 ∷
3575 ∷
3571 ∷
3570 ∷
3574 ∷
3576 ∷
3583 ∷
3587 ∷
3594 ∷
3615 ∷
3619 ∷
3620 ∷
3622 ∷
3607 ∷
3599 ∷
3602 ∷
3604 ∷
3607 ∷
3617 ∷
3618 ∷
3623 ∷
3626 ∷
3632 ∷
3637 ∷
3635 ∷
3640 ∷
3641 ∷
3642 ∷
3654 ∷
3668 ∷
3669 ∷
3675 ∷
3670 ∷
3672 ∷
3675 ∷
3684 ∷
3688 ∷
3701 ∷
3699 ∷
3705 ∷
3704 ∷
3718 ∷
3724 ∷
3717 ∷
3734 ∷
3736 ∷
3741 ∷
3729 ∷
3730 ∷
3731 ∷
3722 ∷
3717 ∷
3718 ∷
3711 ∷
3708 ∷
3719 ∷
3737 ∷
3738 ∷
3734 ∷
3740 ∷
3747 ∷
3749 ∷
3740 ∷
3752 ∷
3758 ∷
3784 ∷
3787 ∷
3792 ∷
3800 ∷
3802 ∷
3803 ∷
3805 ∷
3814 ∷
3815 ∷
3813 ∷
3816 ∷
3812 ∷
3815 ∷
3816 ∷
3803 ∷
3799 ∷
3805 ∷
3806 ∷
3809 ∷
3788 ∷
3781 ∷
3783 ∷
3779 ∷
3780 ∷
3786 ∷
3776 ∷
3780 ∷
3790 ∷
3802 ∷
3806 ∷
3789 ∷
3790 ∷
3791 ∷
3804 ∷
3801 ∷
3797 ∷
3823 ∷
3826 ∷
3828 ∷
3831 ∷
3834 ∷
3843 ∷
3867 ∷
3870 ∷
3879 ∷
3883 ∷
3893 ∷
3909 ∷
3934 ∷
3932 ∷
3955 ∷
3961 ∷
3963 ∷
3968 ∷
3994 ∷
4001 ∷
4002 ∷
3999 ∷
4008 ∷
4003 ∷
4006 ∷
3997 ∷
3990 ∷
4020 ∷
4021 ∷
4027 ∷
4031 ∷
4038 ∷
4039 ∷
4043 ∷
4040 ∷
4036 ∷
4049 ∷
4050 ∷
4075 ∷
4077 ∷
4079 ∷
4061 ∷
4060 ∷
4062 ∷
4059 ∷
4050 ∷
4052 ∷
4053 ∷
4094 ∷
4097 ∷
4106 ∷
4107 ∷
4108 ∷
4112 ∷
4118 ∷
4122 ∷
4125 ∷
4124 ∷
4126 ∷
4127 ∷
4129 ∷
4130 ∷
4131 ∷
4139 ∷
4163 ∷
4164 ∷
4169 ∷
4168 ∷
4176 ∷
4177 ∷
4175 ∷
4177 ∷
4183 ∷
4186 ∷
4188 ∷
4194 ∷
4173 ∷
4163 ∷
4168 ∷
4198 ∷
4201 ∷
4202 ∷
4205 ∷
4177 ∷
4178 ∷
4181 ∷
4180 ∷
4211 ∷
4214 ∷
4215 ∷
4218 ∷
4219 ∷
4218 ∷
4215 ∷
4220 ∷
4230 ∷
4231 ∷
4232 ∷
4276 ∷
4281 ∷
4288 ∷
4289 ∷
4291 ∷
4293 ∷
4297 ∷
4304 ∷
4319 ∷
4330 ∷
4337 ∷
4343 ∷
4353 ∷
4360 ∷
4361 ∷
4377 ∷
4402 ∷
4401 ∷
4424 ∷
4429 ∷
4445 ∷
4452 ∷
4456 ∷
4460 ∷
4457 ∷
4434 ∷
4436 ∷
4438 ∷
4441 ∷
4442 ∷
4437 ∷
4439 ∷
4446 ∷
4447 ∷
4457 ∷
4456 ∷
4454 ∷
4455 ∷
4456 ∷
4461 ∷
4473 ∷
4471 ∷
4473 ∷
4481 ∷
4495 ∷
4498 ∷
4504 ∷
4511 ∷
4520 ∷
4541 ∷
4540 ∷
4561 ∷
4572 ∷
4577 ∷
4578 ∷
4577 ∷
4572 ∷
4575 ∷
4582 ∷
4608 ∷
4617 ∷
4623 ∷
4625 ∷
4635 ∷
4640 ∷
4673 ∷
4675 ∷
4676 ∷
4692 ∷
4687 ∷
4688 ∷
4692 ∷
4703 ∷
4685 ∷
4674 ∷
4693 ∷
4708 ∷
4703 ∷
4693 ∷
4681 ∷
4682 ∷
4696 ∷
4722 ∷
4729 ∷
4732 ∷
4739 ∷
4740 ∷
4744 ∷
4750 ∷
4751 ∷
4752 ∷
4751 ∷
4744 ∷
4746 ∷
4749 ∷
4754 ∷
4758 ∷
4748 ∷
4749 ∷
4760 ∷
4759 ∷
4761 ∷
4757 ∷
4767 ∷
4779 ∷
4771 ∷
4772 ∷
4774 ∷
4773 ∷
4791 ∷
4792 ∷
4790 ∷
4797 ∷
4790 ∷
4800 ∷
4810 ∷
4836 ∷
4830 ∷
4826 ∷
4828 ∷
4838 ∷
4836 ∷
4840 ∷
4846 ∷
4848 ∷
4863 ∷
4865 ∷
4867 ∷
4880 ∷
4883 ∷
4892 ∷
4908 ∷
4905 ∷
4909 ∷
4890 ∷
4891 ∷
4882 ∷
4889 ∷
4898 ∷
4900 ∷
4903 ∷
4909 ∷
4913 ∷
4919 ∷
4920 ∷
4922 ∷
4915 ∷
4922 ∷
4923 ∷
4944 ∷
4960 ∷
4978 ∷
4979 ∷
4983 ∷
5006 ∷
5009 ∷
5012 ∷
5011 ∷
5023 ∷
5045 ∷
5010 ∷
5026 ∷
5027 ∷
5030 ∷
5049 ∷
5055 ∷
5053 ∷
5068 ∷
5069 ∷
5077 ∷
5083 ∷
5084 ∷
5087 ∷
5094 ∷
5093 ∷
5101 ∷
5108 ∷
5110 ∷
5111 ∷
5116 ∷
5118 ∷
5121 ∷
5153 ∷
5155 ∷
5156 ∷
5157 ∷
5150 ∷
5171 ∷
5172 ∷
5180 ∷
5191 ∷
5185 ∷
5194 ∷
5218 ∷
5221 ∷
5216 ∷
5224 ∷
5225 ∷
5226 ∷
5225 ∷
5231 ∷
5227 ∷
5228 ∷
5223 ∷
5247 ∷
5245 ∷
5246 ∷
5260 ∷
5287 ∷
5281 ∷
5285 ∷
5287 ∷
5291 ∷
5302 ∷
5303 ∷
5304 ∷
5302 ∷
5310 ∷
5321 ∷
5317 ∷
5326 ∷
5327 ∷
5329 ∷
5307 ∷
5310 ∷
5313 ∷
5336 ∷
5358 ∷
5367 ∷
5369 ∷
5375 ∷
5379 ∷
5368 ∷
5370 ∷
5371 ∷
5372 ∷
5377 ∷
5383 ∷
5384 ∷
5389 ∷
5402 ∷
5404 ∷
5397 ∷
5400 ∷
5402 ∷
5403 ∷
5396 ∷
5400 ∷
5391 ∷
5394 ∷
5400 ∷
5386 ∷
5382 ∷
5389 ∷
5385 ∷
5386 ∷
5388 ∷
5390 ∷
5391 ∷
5397 ∷
5401 ∷
5403 ∷
5405 ∷
5409 ∷
5412 ∷
5431 ∷
5435 ∷
5440 ∷
5457 ∷
5454 ∷
5422 ∷
5423 ∷
5424 ∷
5423 ∷
5426 ∷
5417 ∷
5420 ∷
5424 ∷
5422 ∷
5447 ∷
5446 ∷
5455 ∷
5460 ∷
5472 ∷
5475 ∷
5482 ∷
5483 ∷
5485 ∷
5493 ∷
5494 ∷
5500 ∷
5512 ∷
5519 ∷
5539 ∷
5550 ∷
5554 ∷
5561 ∷
5571 ∷
5597 ∷
5598 ∷
5579 ∷
5584 ∷
5589 ∷
5591 ∷
5592 ∷
5593 ∷
5594 ∷
5616 ∷
5618 ∷
5628 ∷
5630 ∷
5617 ∷
5625 ∷
5626 ∷
5655 ∷
5654 ∷
5663 ∷
5673 ∷
5670 ∷
5669 ∷
5661 ∷
5660 ∷
5665 ∷
5669 ∷
5667 ∷
5675 ∷
5677 ∷
5679 ∷
5680 ∷
5703 ∷
5709 ∷
5710 ∷
5708 ∷
5710 ∷
5711 ∷
5713 ∷
5714 ∷
5715 ∷
5709 ∷
5738 ∷
5714 ∷
5718 ∷
5734 ∷
5735 ∷
5743 ∷
5738 ∷
5739 ∷
5740 ∷
5749 ∷
5752 ∷
5768 ∷
5757 ∷
5753 ∷
5752 ∷
5753 ∷
5754 ∷
5755 ∷
5758 ∷
5770 ∷
5769 ∷
5768 ∷
5781 ∷
5789 ∷
5798 ∷
5799 ∷
5814 ∷
5815 ∷
5824 ∷
5828 ∷
5829 ∷
5830 ∷
5831 ∷
5837 ∷
5835 ∷
5836 ∷
5832 ∷
5820 ∷
5821 ∷
5822 ∷
5814 ∷
5817 ∷
5818 ∷
5821 ∷
5818 ∷
5811 ∷
5814 ∷
5842 ∷
5844 ∷
5863 ∷
5874 ∷
5870 ∷
5883 ∷
5878 ∷
5890 ∷
5891 ∷
5900 ∷
5896 ∷
5895 ∷
5863 ∷
5860 ∷
5861 ∷
5859 ∷
5861 ∷
5865 ∷
5862 ∷
5864 ∷
5870 ∷
5890 ∷
5884 ∷
5889 ∷
5893 ∷
5898 ∷
5902 ∷
5922 ∷
5924 ∷
5926 ∷
5907 ∷
5909 ∷
5915 ∷
5914 ∷
5923 ∷
5925 ∷
5930 ∷
5932 ∷
5934 ∷
5946 ∷
5947 ∷
5950 ∷
5945 ∷
5957 ∷
5965 ∷
5966 ∷
5971 ∷
5967 ∷
5973 ∷
5974 ∷
5977 ∷
5979 ∷
5984 ∷
5991 ∷
5992 ∷
5994 ∷
6002 ∷
6005 ∷
6006 ∷
6011 ∷
6012 ∷
6014 ∷
6000 ∷
6019 ∷
6034 ∷
6053 ∷
6035 ∷
6036 ∷
6042 ∷
6047 ∷
6048 ∷
6050 ∷
6054 ∷
6074 ∷
6075 ∷
6077 ∷
6046 ∷
6055 ∷
6058 ∷
6060 ∷
6061 ∷
6062 ∷
6073 ∷
6081 ∷
6086 ∷
6088 ∷
6096 ∷
6097 ∷
6098 ∷
6099 ∷
6096 ∷
6110 ∷
6112 ∷
6113 ∷
6112 ∷
6111 ∷
6132 ∷
6115 ∷
6118 ∷
6127 ∷
6124 ∷
6128 ∷
6139 ∷
6145 ∷
6156 ∷
6155 ∷
6153 ∷
6152 ∷
6153 ∷
6157 ∷
6164 ∷
6176 ∷
6186 ∷
6187 ∷
6188 ∷
6190 ∷
6192 ∷
6185 ∷
6190 ∷
6191 ∷
6192 ∷
6191 ∷
6198 ∷
6200 ∷
6213 ∷
6214 ∷
6222 ∷
6242 ∷
6236 ∷
6246 ∷
6256 ∷
6257 ∷
6256 ∷
6257 ∷
6258 ∷
6259 ∷
6284 ∷
6285 ∷
6286 ∷
6290 ∷
6291 ∷
6287 ∷
6294 ∷
6298 ∷
6311 ∷
6301 ∷
6309 ∷
6312 ∷
6315 ∷
6318 ∷
6323 ∷
6325 ∷
6334 ∷
6323 ∷
6322 ∷
6323 ∷
6334 ∷
6335 ∷
6332 ∷
6343 ∷
6344 ∷
6348 ∷
6352 ∷
6358 ∷
6361 ∷
6362 ∷
6367 ∷
6381 ∷
6395 ∷
6412 ∷
6411 ∷
6410 ∷
6426 ∷
6444 ∷
6455 ∷
6461 ∷
6470 ∷
6449 ∷
6456 ∷
6455 ∷
6464 ∷
6463 ∷
6468 ∷
6474 ∷
6478 ∷
6477 ∷
6474 ∷
6473 ∷
6468 ∷
6474 ∷
6476 ∷
6501 ∷
6513 ∷
6516 ∷
6517 ∷
6518 ∷
6513 ∷
6515 ∷
6519 ∷
6515 ∷
6531 ∷
6537 ∷
6538 ∷
6531 ∷
6545 ∷
6553 ∷
6554 ∷
6560 ∷
6559 ∷
6562 ∷
6551 ∷
6563 ∷
6559 ∷
6557 ∷
6562 ∷
6564 ∷
6562 ∷
6564 ∷
6563 ∷
6568 ∷
6572 ∷
6573 ∷
6572 ∷
6583 ∷
6591 ∷
6595 ∷
6587 ∷
6589 ∷
6590 ∷
6581 ∷
6583 ∷
6593 ∷
6592 ∷
6616 ∷
6627 ∷
6654 ∷
6657 ∷
6667 ∷
6668 ∷
6680 ∷
6695 ∷
6682 ∷
6685 ∷
6691 ∷
6708 ∷
6720 ∷
6722 ∷
6723 ∷
6721 ∷
6750 ∷
6759 ∷
6760 ∷
6759 ∷
6760 ∷
6769 ∷
6772 ∷
6780 ∷
6774 ∷
6782 ∷
6774 ∷
6777 ∷
6778 ∷
6777 ∷
6786 ∷
6787 ∷
6792 ∷
6796 ∷
6802 ∷
6814 ∷
6816 ∷
6813 ∷
6814 ∷
6823 ∷
6807 ∷
6805 ∷
6804 ∷
6805 ∷
6806 ∷
6807 ∷
6801 ∷
6803 ∷
6806 ∷
6807 ∷
6799 ∷
6812 ∷
6832 ∷
6858 ∷
6846 ∷
6856 ∷
6857 ∷
6865 ∷
6867 ∷
6876 ∷
6877 ∷
6887 ∷
6889 ∷
6895 ∷
6896 ∷
6900 ∷
6901 ∷
6881 ∷
6874 ∷
6873 ∷
6876 ∷
6883 ∷
6888 ∷
6898 ∷
6899 ∷
6910 ∷
6913 ∷
6934 ∷
6932 ∷
6939 ∷
6940 ∷
6943 ∷
6968 ∷
6974 ∷
6978 ∷
6975 ∷
6956 ∷
6971 ∷
6953 ∷
6976 ∷
6983 ∷
6980 ∷
6986 ∷
6987 ∷
6988 ∷
6989 ∷
6992 ∷
7003 ∷
7004 ∷
7005 ∷
7004 ∷
7011 ∷
7017 ∷
7019 ∷
7030 ∷
7033 ∷
7037 ∷
7043 ∷
7053 ∷
7058 ∷
7062 ∷
7076 ∷
7078 ∷
7080 ∷
7093 ∷
7094 ∷
7095 ∷
7107 ∷
7106 ∷
7109 ∷
7110 ∷
7111 ∷
7112 ∷
7113 ∷
7116 ∷
7117 ∷
7119 ∷
7118 ∷
7119 ∷
7120 ∷
7122 ∷
7134 ∷
7145 ∷
7142 ∷
7174 ∷
7175 ∷
7185 ∷
7189 ∷
7190 ∷
7191 ∷
7214 ∷
7228 ∷
7236 ∷
7252 ∷
7267 ∷
7296 ∷
7302 ∷
7303 ∷
7322 ∷
7321 ∷
7323 ∷
7327 ∷
7331 ∷
7333 ∷
7337 ∷
7334 ∷
7343 ∷
7344 ∷
7352 ∷
7361 ∷
7369 ∷
7381 ∷
7384 ∷
7385 ∷
7384 ∷
7389 ∷
7393 ∷
7394 ∷
7395 ∷
7403 ∷
7425 ∷
7430 ∷
7431 ∷
7433 ∷
7441 ∷
7440 ∷
7424 ∷
7427 ∷
7419 ∷
7430 ∷
7432 ∷
7436 ∷
7437 ∷
7450 ∷
7451 ∷
7457 ∷
7477 ∷
7485 ∷
7490 ∷
7496 ∷
7503 ∷
7504 ∷
7508 ∷
7509 ∷
7485 ∷
7490 ∷
7501 ∷
7502 ∷
7506 ∷
7512 ∷
7513 ∷
7514 ∷
7515 ∷
7513 ∷
7528 ∷
7545 ∷
7554 ∷
7563 ∷
7569 ∷
7570 ∷
7573 ∷
7574 ∷
7586 ∷
7589 ∷
7605 ∷
7618 ∷
7620 ∷
7621 ∷
7624 ∷
7645 ∷
7658 ∷
7669 ∷
7672 ∷
7670 ∷
7671 ∷
7678 ∷
7680 ∷
7692 ∷
7712 ∷
7724 ∷
7730 ∷
7736 ∷
7737 ∷
7746 ∷
7759 ∷ []
main : IO ⊤
main = putStrLn (primShowNat (doTask2 input))
| 9.150638
| 59
| 0.446405
|
13bb69319fc814e8e4c35969b95fe0b41ce35856
| 2,484
|
agda
|
Agda
|
Function/Isomorphism.agda
|
oisdk/agda-playground
|
97a3aab1282b2337c5f43e2cfa3fa969a94c11b7
|
[
"MIT"
] | 6
|
2020-09-11T17:45:41.000Z
|
2021-11-16T08:11:34.000Z
|
Function/Isomorphism.agda
|
oisdk/agda-playground
|
97a3aab1282b2337c5f43e2cfa3fa969a94c11b7
|
[
"MIT"
] | null | null | null |
Function/Isomorphism.agda
|
oisdk/agda-playground
|
97a3aab1282b2337c5f43e2cfa3fa969a94c11b7
|
[
"MIT"
] | 1
|
2021-11-11T12:30:21.000Z
|
2021-11-11T12:30:21.000Z
|
{-# OPTIONS --cubical --safe --postfix-projections #-}
module Function.Isomorphism where
open import Cubical.Foundations.Isomorphism using (Iso; section; retract; isoToPath; iso; isoToEquiv) public
open import Level
open import Path
open import Function
open import Data.Sigma
open import Relation.Binary
open Iso public
infix 4 _⇔_
_⇔_ = Iso
sym-⇔ : (A ⇔ B) → (B ⇔ A)
fun (sym-⇔ A⇔B) = inv A⇔B
inv (sym-⇔ A⇔B) = fun A⇔B
leftInv (sym-⇔ A⇔B) = rightInv A⇔B
rightInv (sym-⇔ A⇔B) = leftInv A⇔B
sym-sym-iso : (s : A ⇔ B) → sym-⇔ (sym-⇔ s) ≡ s
sym-sym-iso s i .fun = s .fun
sym-sym-iso s i .inv = s .inv
sym-sym-iso s i .rightInv = s .rightInv
sym-sym-iso s i .leftInv = s .leftInv
refl-⇔ : A ⇔ A
fun refl-⇔ x = x
inv refl-⇔ x = x
leftInv refl-⇔ x = refl
rightInv refl-⇔ x = refl
trans-⇔ : A ⇔ B → B ⇔ C → A ⇔ C
fun (trans-⇔ A⇔B B⇔C) = fun B⇔C ∘ fun A⇔B
inv (trans-⇔ A⇔B B⇔C) = inv A⇔B ∘ inv B⇔C
leftInv (trans-⇔ A⇔B B⇔C) x = cong (inv A⇔B) (leftInv B⇔C _) ; leftInv A⇔B _
rightInv (trans-⇔ A⇔B B⇔C) x = cong (fun B⇔C) (rightInv A⇔B _) ; rightInv B⇔C _
iso-Σ : {B : A → Type b} {C : A → Type c} → (∀ x → B x ⇔ C x) → Σ A B ⇔ Σ A C
iso-Σ B⇔C .fun (x , xs) = x , B⇔C x .fun xs
iso-Σ B⇔C .inv (x , xs) = x , B⇔C x .inv xs
iso-Σ B⇔C .rightInv (x , xs) i .fst = x
iso-Σ B⇔C .rightInv (x , xs) i .snd = B⇔C x .rightInv xs i
iso-Σ B⇔C .leftInv (x , xs) i .fst = x
iso-Σ B⇔C .leftInv (x , xs) i .snd = B⇔C x .leftInv xs i
⇔-equiv : Equivalence (Type a) a
Equivalence._≋_ ⇔-equiv = _⇔_
Equivalence.sym ⇔-equiv = sym-⇔
Equivalence.refl ⇔-equiv = refl-⇔
Equivalence.trans ⇔-equiv = trans-⇔
open import HLevels
open import Equiv
iso⇔equiv : isSet A → (A ⇔ B) ⇔ (A ≃ B)
iso⇔equiv isSetA .fun = isoToEquiv
iso⇔equiv isSetA .inv = equivToIso
iso⇔equiv isSetA .rightInv x i .fst = x .fst
iso⇔equiv isSetA .rightInv x i .snd = isPropIsEquiv (x .fst) (isoToEquiv (equivToIso x) .snd) (x .snd) i
iso⇔equiv isSetA .leftInv x i .fun = x .fun
iso⇔equiv isSetA .leftInv x i .inv = x .inv
iso⇔equiv isSetA .leftInv x i .rightInv = x .rightInv
iso⇔equiv isSetA .leftInv x i .leftInv y = isSetA _ y (equivToIso (isoToEquiv x) .leftInv y) (x .leftInv y) i
open import Function.Surjective
open import Function.Injective
surj×inj⇒iso : (f : A → B) → SplitSurjective f → Injective f → A ⇔ B
surj×inj⇒iso f surj inj .fun = f
surj×inj⇒iso f surj inj .inv = fst ∘ surj
surj×inj⇒iso f surj inj .rightInv = snd ∘ surj
surj×inj⇒iso f surj inj .leftInv x = inj (fst (surj (f x))) x (surj (f x) .snd)
| 32.684211
| 109
| 0.633655
|
04ae706e698eaa36a7f58aa7ccc88fa4c7106b48
| 1,528
|
agda
|
Agda
|
test/fail/Issue882a.agda
|
masondesu/agda
|
70c8a575c46f6a568c7518150a1a64fcd03aa437
|
[
"MIT"
] | 1
|
2018-10-10T17:08:44.000Z
|
2018-10-10T17:08:44.000Z
|
test/fail/Issue882a.agda
|
masondesu/agda
|
70c8a575c46f6a568c7518150a1a64fcd03aa437
|
[
"MIT"
] | null | null | null |
test/fail/Issue882a.agda
|
masondesu/agda
|
70c8a575c46f6a568c7518150a1a64fcd03aa437
|
[
"MIT"
] | null | null | null |
{-# OPTIONS -v impossible:100 #-}
module Issue882a where
open import Common.Level
open import Common.Equality
private
primitive
primTrustMe : ∀ {a} {A : Set a} {x y : A} → x ≡ y
-- trustMe {x = x} {y = y} evaluates to refl if x and y are
-- definitionally equal.
--
-- For an example of the use of trustMe, see Data.String._≟_.
trustMe : ∀ {a} {A : Set a} {x y : A} → x ≡ y
trustMe = primTrustMe
postulate
S : Set
B : Set
b : B
M : Set
M = B -> S
out : M -> M
out m = o
where
s : S
s = m b
postulate
mko : (mm : S) -> s ≡ mm -> M
o : M
o n = mko (m b) trustMe n
postulate
unfold : (M -> M) -> M
inn : M
inn = unfold out
postulate
n : B
iso1 : inn ≡ inn
iso1 rewrite refl {x = n} = {!!}
-- iso1 rewrite (refl {a = lzero}{A = B}{x = n}) = {!!}
{- Error
OLD:
An internal error has occurred. Please report this as a bug.
Location of the error: src/full/Agda/TypeChecking/Conversion.hs:636
NEW:
Some vomit about Setω not equal to Level when checking well-formedness
of with type.
NEWER (2013-11-30):
Cannot instantiate the metavariable _48 to solution m b since it
contains the variable m which is not in scope of the metavariable
or irrelevant in the metavariable but relevant in the solution
when checking that the type
B →
(w : _x_48 ≡ _x_48) →
unfold (λ m → _.mko m (m b) w) ≡ unfold (λ m → _.mko m (m b) w)
of the generated with function is well-formed
NOW (2014-05-17):
Rewriting with refl is a no-op, so no error is triggered any more.
Just an unresolved meta now.
-}
| 19.1
| 70
| 0.645288
|
13a0e5f26f96ebc422c4ee7c37c2b8a6e5982760
| 5,308
|
agda
|
Agda
|
Dave/Algebra/Naturals/Multiplication.agda
|
DavidStahl97/formal-proofs
|
05213fb6ab1f51f770f9858b61526ba950e06232
|
[
"MIT"
] | null | null | null |
Dave/Algebra/Naturals/Multiplication.agda
|
DavidStahl97/formal-proofs
|
05213fb6ab1f51f770f9858b61526ba950e06232
|
[
"MIT"
] | null | null | null |
Dave/Algebra/Naturals/Multiplication.agda
|
DavidStahl97/formal-proofs
|
05213fb6ab1f51f770f9858b61526ba950e06232
|
[
"MIT"
] | null | null | null |
module Dave.Algebra.Naturals.Multiplication where
open import Dave.Algebra.Naturals.Addition public
_*_ : ℕ → ℕ → ℕ
zero * b = zero
suc a * b = (a * b) + b
infixl 7 _*_
*-zero : ∀ (m : ℕ) → m * zero ≡ zero
*-zero zero = refl
*-zero (suc m) = begin
suc m * zero ≡⟨⟩
m * zero + zero ≡⟨ +-right-identity (m * zero) ⟩
m * zero ≡⟨ *-zero m ⟩
zero ∎
{- Identity -}
ℕ-*-right-identity : ∀ (m : ℕ) → m * 1 ≡ m
ℕ-*-right-identity zero = refl
ℕ-*-right-identity (suc m) = begin
suc m * 1 ≡⟨⟩
m * 1 + 1 ≡⟨ cong (λ a → a + 1) (ℕ-*-right-identity m) ⟩
m + 1 ≡⟨ +-add1ᵣ m ⟩
suc m ∎
ℕ-*-left-identity : ∀ (m : ℕ) → 1 * m ≡ m
ℕ-*-left-identity m = refl
ℕ-*-HasIdentity : Identity _*_ 1
Identity.left ℕ-*-HasIdentity = ℕ-*-left-identity
Identity.right ℕ-*-HasIdentity = ℕ-*-right-identity
{- Distributivity -}
*-distrib-+ᵣ : ∀ (m n p : ℕ) → (m + n) * p ≡ m * p + n * p
*-distrib-+ᵣ zero n p = refl
*-distrib-+ᵣ (suc m) n p = begin
(suc m + n) * p ≡⟨⟩
suc (m + n) * p ≡⟨⟩
(m + n) * p + p ≡⟨ cong (λ a → a + p) (*-distrib-+ᵣ m n p) ⟩
m * p + n * p + p ≡⟨ IsCommutativeMonoid.swap021 ℕ-+-IsCommutativeMonoid (m * p) (n * p) p ⟩
m * p + p + n * p ≡⟨ cong (λ a → m * p + a + n * p) (ℕ-*-left-identity p) ⟩
m * p + 1 * p + n * p ≡⟨ cong (λ a → a + n * p) (sym (*-distrib-+ᵣ m 1 p)) ⟩
(m + 1) * p + n * p ≡⟨ cong (λ a → a * p + n * p) (+-add1ᵣ m) ⟩
suc m * p + n * p ∎
*-distrib1ᵣ-+ᵣ : ∀ (m p : ℕ) → (m + 1) * p ≡ m * p + p
*-distrib1ᵣ-+ᵣ m p = begin
(m + 1) * p ≡⟨ *-distrib-+ᵣ m 1 p ⟩
m * p + 1 * p ≡⟨⟩
m * p + p ∎
*-distrib1ₗ-+ᵣ : ∀ (m p : ℕ) → (1 + m) * p ≡ p + m * p
*-distrib1ₗ-+ᵣ m p = begin
(1 + m) * p ≡⟨ *-distrib-+ᵣ 1 m p ⟩
1 * p + m * p ≡⟨⟩
p + m * p ∎
*-distrib-+ₗ : ∀ (m n p : ℕ) → m * (n + p) ≡ m * n + m * p
*-distrib-+ₗ zero n p = refl
*-distrib-+ₗ (suc m) n p = begin
suc m * (n + p) ≡⟨⟩
m * (n + p) + (n + p) ≡⟨ cong (λ a → a + (n + p)) (*-distrib-+ₗ m n p) ⟩
m * n + m * p + (n + p) ≡⟨ IsCommutativeMonoid.swap021 ℕ-+-IsCommutativeMonoid (m * n) (m * p) (n + p) ⟩
m * n + (n + p) + m * p ≡⟨ cong (λ a → a + m * p) (sym (IsSemigroup.assoc ℕ-+-IsSemigroup (m * n) n p)) ⟩
m * n + n + p + m * p ≡⟨ IsCommutativeMonoid.swap021 ℕ-+-IsCommutativeMonoid (m * n + n) p (m * p) ⟩
m * n + n + m * p + p ≡⟨⟩
m * n + 1 * n + m * p + 1 * p ≡⟨ cong (λ a → a + m * p + 1 * p) (sym (*-distrib-+ᵣ m 1 n)) ⟩
(m + 1) * n + m * p + 1 * p ≡⟨ IsSemigroup.assoc ℕ-+-IsSemigroup ((m + 1) * n) (m * p) (1 * p) ⟩
(m + 1) * n + (m * p + 1 * p) ≡⟨ cong (λ a → (m + 1) * n + a) (sym (*-distrib-+ᵣ m 1 p)) ⟩
(m + 1) * n + (m + 1) * p ≡⟨ cong (λ a → a * n + (m + 1) * p) (+-add1ᵣ m) ⟩
suc m * n + (m + 1) * p ≡⟨ cong (λ a → suc m * n + a * p) (+-add1ᵣ m) ⟩
suc m * n + suc m * p ∎
{- Semigroup -}
*-assoc : associative _*_
*-assoc zero n p = refl
*-assoc (suc m) n p = begin
(suc m * n) * p ≡⟨⟩
(m * n + n) * p ≡⟨ *-distrib-+ᵣ (m * n) n p ⟩
m * n * p + n * p ≡⟨⟩
m * n * p + 1 * (n * p) ≡⟨ cong (λ a → a + 1 * (n * p)) (*-assoc m n p) ⟩
m * (n * p) + 1 * (n * p) ≡⟨ sym (*-distrib-+ᵣ m 1 (n * p)) ⟩
(m + 1) * (n * p) ≡⟨ cong (λ a → a * (n * p)) (+-add1ᵣ m) ⟩
suc m * (n * p) ∎
ℕ-*-IsSemigroup : IsSemigroup _*_
IsSemigroup.assoc ℕ-*-IsSemigroup = *-assoc
ℕ-*-Semigroup : Semigroup
Semigroup.Carrier ℕ-*-Semigroup = ℕ
Semigroup._·_ ℕ-*-Semigroup = _*_
Semigroup.isSemigroup ℕ-*-Semigroup = ℕ-*-IsSemigroup
{- Monoid -}
ℕ-*-IsMonoid : IsMonoid _*_ 1
IsMonoid.semigroup ℕ-*-IsMonoid = ℕ-*-IsSemigroup
IsMonoid.identity ℕ-*-IsMonoid = ℕ-*-HasIdentity
ℕ-*-Monoid : Monoid
Monoid.Carrier ℕ-*-Monoid = ℕ
Monoid._·_ ℕ-*-Monoid = _*_
Monoid.e ℕ-*-Monoid = 1
Monoid.isMonoid ℕ-*-Monoid = ℕ-*-IsMonoid
{- Commutative Monoid -}
ℕ-*-comm : commutative _*_
ℕ-*-comm zero n = begin
zero * n ≡⟨⟩
zero ≡⟨ sym (*-zero n) ⟩
n * zero ∎
ℕ-*-comm (suc m) n = begin
suc m * n ≡⟨⟩
m * n + n ≡⟨ +-comm (m * n) n ⟩
n + m * n ≡⟨ sym (cong (λ a → a + m * n) (ℕ-*-right-identity n)) ⟩
n * 1 + m * n ≡⟨ cong (λ a → n * 1 + a) (ℕ-*-comm m n) ⟩
n * 1 + n * m ≡⟨ sym (*-distrib-+ₗ n 1 m) ⟩
n * (1 + m) ≡⟨⟩
n * suc m ∎
ℕ-*-IsCommutativeMonoid : IsCommutativeMonoid _*_ 1
IsCommutativeMonoid.isSemigroup ℕ-*-IsCommutativeMonoid = ℕ-*-IsSemigroup
IsCommutativeMonoid.leftIdentity ℕ-*-IsCommutativeMonoid = ℕ-*-left-identity
IsCommutativeMonoid.comm ℕ-*-IsCommutativeMonoid = ℕ-*-comm
ℕ-*-CommutativeMonoid : CommutativeMonoid
CommutativeMonoid.Carrier ℕ-*-CommutativeMonoid = ℕ
CommutativeMonoid._·_ ℕ-*-CommutativeMonoid = _*_
CommutativeMonoid.e ℕ-*-CommutativeMonoid = 1
CommutativeMonoid.isCommutativeMonoid ℕ-*-CommutativeMonoid = ℕ-*-IsCommutativeMonoid
*-distrib1ᵣ-+ₗ : ∀ (m p : ℕ) → m * (p + 1) ≡ m * p + m
*-distrib1ᵣ-+ₗ m p = begin
m * (p + 1) ≡⟨ ℕ-*-comm m (p + 1) ⟩
(p + 1) * m ≡⟨ *-distrib1ᵣ-+ᵣ p m ⟩
p * m + m ≡⟨ cong (λ a → a + m) (ℕ-*-comm p m) ⟩
m * p + m ∎
*-distrib1ₗ-+ₗ : ∀ (m p : ℕ) → m * (1 + p) ≡ m + m * p
*-distrib1ₗ-+ₗ m p = begin
m * (1 + p) ≡⟨ ℕ-*-comm m (1 + p) ⟩
(1 + p) * m ≡⟨ *-distrib1ₗ-+ᵣ p m ⟩
m + p * m ≡⟨ cong (λ a → m + a) (ℕ-*-comm p m) ⟩
m + m * p ∎
| 36.606897
| 109
| 0.480972
|
1e40acdb1a115bbc26058f50a2804839d534fd36
| 19,436
|
agda
|
Agda
|
theorems/homotopy/SmashFmapConn.agda
|
AntoineAllioux/HoTT-Agda
|
1037d82edcf29b620677a311dcfd4fc2ade2faa6
|
[
"MIT"
] | 294
|
2015-01-09T16:23:23.000Z
|
2022-03-20T13:54:45.000Z
|
theorems/homotopy/SmashFmapConn.agda
|
AntoineAllioux/HoTT-Agda
|
1037d82edcf29b620677a311dcfd4fc2ade2faa6
|
[
"MIT"
] | 31
|
2015-03-05T20:09:00.000Z
|
2021-10-03T19:15:25.000Z
|
theorems/homotopy/SmashFmapConn.agda
|
AntoineAllioux/HoTT-Agda
|
1037d82edcf29b620677a311dcfd4fc2ade2faa6
|
[
"MIT"
] | 50
|
2015-01-10T01:48:08.000Z
|
2022-02-14T03:03:25.000Z
|
{-# OPTIONS --without-K --rewriting #-}
open import HoTT
module homotopy.SmashFmapConn where
module _ {i} {j} {A : Type i} (B : A → Type j) where
custom-assoc : {a₀ a₁ a₂ a₃ : A}
{b₀ : B a₀} {b₁ b₁' b₁'' : B a₁} {b₂ : B a₂} {b₃ : B a₃}
{p : a₀ == a₁} (p' : b₀ == b₁ [ B ↓ p ])
(q' : b₁ == b₁')
(r' : b₁' == b₁'')
{s : a₁ == a₂} (s' : b₁'' == b₂ [ B ↓ s ])
{t : a₂ == a₃} (t' : b₂ == b₃ [ B ↓ t ])
→ p' ∙ᵈ (((q' ∙ r') ◃ s') ∙ᵈ t')
==
((p' ▹ q') ▹ r') ∙ᵈ s' ∙ᵈ t'
custom-assoc {p = idp} p'@idp q'@idp r'@idp {s = idp} s'@idp {t = idp} t' = idp
transp-over : {a₀ a₁ : A} (p : a₀ == a₁) (b₀ : B a₀)
→ b₀ == transport B p b₀ [ B ↓ p ]
transp-over p b₀ = from-transp B p (idp {a = transport B p b₀})
transp-over-naturality : ∀ {a₀ a₁ : A} (p : a₀ == a₁)
{b₀ b₀' : B a₀} (q : b₀ == b₀')
→ q ◃ transp-over p b₀'
==
transp-over p b₀ ▹ ap (transport B p) q
transp-over-naturality p@idp q@idp = idp
to-transp-over : {a₀ a₁ : A} {p : a₀ == a₁}
{b₀ : B a₀} {b₁ : B a₁} (q : b₀ == b₁ [ B ↓ p ])
→ q ▹ ! (to-transp q) == transp-over p b₀
to-transp-over {p = idp} q@idp = idp
module _ {i} {j} {S* : Type i} (P* : S* → Type j) where
-- cpa = custom path algebra
cpa₁ : {s₁ s₂ t : S*} (p* : P* s₂) (p₁ : s₁ == t) (p₂ : s₂ == t)
→ transport P* (! (p₁ ∙ ! p₂)) p* == transport P* p₂ p* [ P* ↓ p₁ ]
cpa₁ p* p₁@idp p₂@idp = idp
-- cpac = custom path algebra coherence
cpac₁ : ∀ {k} {C : Type k} (f : C → S*)
{c₁ c₂ : C} (q : c₁ == c₂)
(d : Π C (P* ∘ f))
{t : S*} (p₁ : f c₁ == t) (p₂ : f c₂ == t)
(r : ap f q == p₁ ∙' ! p₂)
{u : P* (f c₂)} (v : u == transport P* (! (p₂ ∙ ! p₂)) (d c₂))
{u' : P* (f c₁)} (v' : u' == transport P* (! (p₁ ∙ ! p₂)) (d c₂))
→ (v' ∙
ap (λ pp → transport P* pp (d c₂)) (ap ! (! (r ∙ ∙'=∙ p₁ (! p₂))) ∙ !-ap f q) ∙
to-transp {B = P*} {p = ap f (! q)}
(↓-ap-in P* f (apd d (! q)))) ◃
apd d q
==
↓-ap-out= P* f q (r ∙ ∙'=∙ p₁ (! p₂))
((v' ◃ cpa₁ (d c₂) p₁ p₂) ∙ᵈ !ᵈ (v ◃ cpa₁ (d c₂) p₂ p₂)) ▹
(v ∙ ap (λ pp → transport P* (! pp) (d c₂)) (!-inv-r p₂))
cpac₁ f q@idp d p₁@.idp p₂@idp r@idp v@idp v'@idp = idp
cpa₂ : ∀ {k} {C : Type k} (f : C → S*)
{c₁ c₂ : C} (q : c₁ == c₂)
(d : Π C (P* ∘ f))
{s t : S*} (p : f c₁ == s) (r : s == t) (u : f c₂ == t)
(h : ap f q == p ∙' (r ∙ ! u))
→ transport P* p (d c₁)
==
transport P* u (d c₂)
[ P* ↓ r ]
cpa₂ f q@idp d p@.idp r@idp u@idp h@idp = idp
cpac₂ : ∀ {k} {C : Type k} (f : C → S*)
{c₁ c₂ c₃ : C} (q : c₁ == c₂) (q' : c₃ == c₂)
(d : Π C (P* ∘ f))
{s t : S*} (p : f c₁ == s) (p' : f c₃ == f c₂) (r : s == t) (u : f c₂ == t)
(h : ap f q == p ∙' (r ∙ ! u))
(h' : ap f q' == p' ∙' u ∙ ! u)
{x : P* (f c₂)} (x' : x == transport P* p' (d c₃))
{y : P* (f c₁)} (y' : y == d c₁)
→ ↓-ap-out=
P*
f
q
(h ∙ ∙'=∙ p (r ∙ ! u))
((y' ◃ transp-over P* p (d c₁)) ∙ᵈ cpa₂ f q d p r u h ∙ᵈ !ᵈ (x' ◃ cpa₂ f q' d p' u u h')) ▹
(x' ∙
ap (λ pp → transport P* pp (d c₃))
(! (∙-unit-r p') ∙
ap (p' ∙_) (! (!-inv-r u)) ∙
! (h' ∙ ∙'=∙ p' (u ∙ ! u))) ∙
to-transp (↓-ap-in P* f (apd d q')))
==
y' ◃ apd d q
cpac₂ f q@idp q'@idp d p@.idp p'@.idp r@idp u@idp h@idp h'@idp x'@idp y'@idp = idp
module _ {i} {j} {k} {A : Ptd i} {A' : Ptd j} (f : A ⊙→ A') (B : Ptd k)
{m n : ℕ₋₂}
(f-is-m-conn : has-conn-fibers m (fst f))
(B-is-Sn-conn : is-connected (S n) (de⊙ B)) where
private
a₀ = pt A
a₀' = pt A'
b₀ = pt B
module ConnIn (P : A' ∧ B → (n +2+ m) -Type (lmax i (lmax j k)))
(d : ∀ (ab : A ∧ B) → fst (P (∧-fmap f (⊙idf B) ab))) where
h : ∀ (b : de⊙ B)
→ (∀ (a' : de⊙ A') → fst (P (smin a' b)))
→ (∀ (a : de⊙ A) → fst (P (smin (fst f a) b)))
h b s = s ∘ fst f
Q : de⊙ B → n -Type (lmax i (lmax j k))
Q b = Q' , Q'-level
where
Q' : Type (lmax i (lmax j k))
Q' = hfiber (h b) (λ a → d (smin a b))
Q'-level : has-level n Q'
Q'-level =
conn-extend-general
{n = m} {k = n}
f-is-m-conn
(λ a → P (smin a b))
(λ a → d (smin a b))
s₀ : ∀ (a' : de⊙ A') → fst (P (smin a' b₀))
s₀ a' = transport (fst ∘ P) (! (∧-norm-l a')) (d smbasel)
∧-fmap-smgluel-β-∙' : ∀ (a : de⊙ A) →
ap (∧-fmap f (⊙idf B)) (smgluel a)
==
smgluel (fst f a) ∙' ! (smgluel a₀')
∧-fmap-smgluel-β-∙' a =
∧-fmap-smgluel-β' f (⊙idf B) a ∙
∙=∙' (smgluel (fst f a)) (! (smgluel a₀'))
∧-fmap-smgluel-β-∙ : ∀ (a : de⊙ A) →
ap (∧-fmap f (⊙idf B)) (smgluel a)
==
smgluel (fst f a) ∙ ! (smgluel a₀')
∧-fmap-smgluel-β-∙ a =
∧-fmap-smgluel-β-∙' a ∙
∙'=∙ (smgluel (fst f a)) (! (smgluel a₀'))
∧-fmap-smgluer-β-∙' : ∀ (b : de⊙ B) →
ap (∧-fmap f (⊙idf B)) (smgluer b)
==
ap (λ a' → smin a' b) (snd f) ∙' ∧-norm-r b
∧-fmap-smgluer-β-∙' b =
∧-fmap-smgluer-β' f (⊙idf B) b ∙
∙=∙' (ap (λ a' → smin a' b) (snd f)) (∧-norm-r b)
∧-fmap-smgluer-β-∙ : ∀ (b : de⊙ B) →
ap (∧-fmap f (⊙idf B)) (smgluer b)
==
ap (λ a' → smin a' b) (snd f) ∙ ∧-norm-r b
∧-fmap-smgluer-β-∙ b =
∧-fmap-smgluer-β-∙' b ∙
∙'=∙ (ap (λ a' → smin a' b) (snd f)) (∧-norm-r b)
s₀-f : ∀ (a : de⊙ A) → s₀ (fst f a) == d (smin a b₀)
s₀-f a =
ap (λ p → transport (λ a'b → fst (P a'b)) p (d smbasel)) q ∙
to-transp {B = fst ∘ P}
{p = ap (∧-fmap f (⊙idf B)) (! (smgluel a))}
(↓-ap-in (fst ∘ P)
(∧-fmap f (⊙idf B))
(apd d (! (smgluel a))))
where
q : ! (∧-norm-l (fst f a)) == ap (∧-fmap f (⊙idf B)) (! (smgluel a))
q = ap ! (! (∧-fmap-smgluel-β-∙ a)) ∙ !-ap (∧-fmap f (⊙idf B)) (smgluel a)
q₀ : fst (Q b₀)
q₀ = s₀ , s₀-lies-over-pt
where
s₀-lies-over-pt : h b₀ s₀ == (λ a → d (smin a b₀))
s₀-lies-over-pt = λ= s₀-f
q : ∀ (b : de⊙ B) → fst (Q b)
q = conn-extend {n = n} {h = cst b₀}
(pointed-conn-out (de⊙ B) b₀ {{B-is-Sn-conn}})
Q
(λ _ → q₀)
q-f : q b₀ == q₀
q-f = conn-extend-β {n = n} {h = cst b₀}
(pointed-conn-out (de⊙ B) b₀ {{B-is-Sn-conn}})
Q
(λ _ → q₀)
unit
s : ∀ (a' : de⊙ A') (b : de⊙ B) → fst (P (smin a' b))
s a' b = fst (q b) a'
s-b₀ : ∀ (a' : de⊙ A') → s a' b₀ == s₀ a'
s-b₀ a' = ap (λ u → fst u a') q-f
s-f : ∀ (a : de⊙ A) (b : de⊙ B)
→ s (fst f a) b == d (smin a b)
s-f a b = app= (snd (q b)) a
s-f-b₀ : ∀ (a : de⊙ A)
→ s-f a b₀ == s-b₀ (fst f a) ∙ s₀-f a
s-f-b₀ a =
app= (snd (q b₀)) a
=⟨ ↓-app=cst-out' (apd (λ u → app= (snd u) a) q-f) ⟩
s-b₀ (fst f a) ∙' app= (snd q₀) a
=⟨ ap (s-b₀ (fst f a) ∙'_) (app=-β s₀-f a) ⟩
s-b₀ (fst f a) ∙' s₀-f a
=⟨ ∙'=∙ (s-b₀ (fst f a)) (s₀-f a) ⟩
s-b₀ (fst f a) ∙ s₀-f a =∎
s-a₀' : ∀ (b : de⊙ B) →
s a₀' b
==
transport (fst ∘ P) (ap (λ a' → smin a' b) (snd f)) (d (smin a₀ b))
s-a₀' b = ↯ $
s a₀' b
=⟪ ! (to-transp (↓-ap-in (fst ∘ P) (λ a' → smin a' b) (apd (λ a' → s a' b) (snd f)))) ⟫
transport (fst ∘ P) (ap (λ a' → smin a' b) (snd f)) (s (fst f a₀) b)
=⟪ ap (transport (fst ∘ P) (ap (λ a' → smin a' b) (snd f)))
(s-f a₀ b) ⟫
transport (fst ∘ P) (ap (λ a' → smin a' b) (snd f)) (d (smin a₀ b)) ∎∎
section-smbasel : fst (P smbasel)
section-smbasel = transport (fst ∘ P) (smgluel a₀') (d smbasel)
section-smbaser : fst (P smbaser)
section-smbaser = transport (fst ∘ P) (smgluer b₀) (d smbaser)
section-smgluel' : ∀ (a' : de⊙ A') → s₀ a' == section-smbasel [ fst ∘ P ↓ smgluel a' ]
section-smgluel' a' = cpa₁ (fst ∘ P) (d smbasel) (smgluel a') (smgluel a₀')
section-smgluel : ∀ (a' : de⊙ A') → s a' b₀ == section-smbasel [ fst ∘ P ↓ smgluel a' ]
section-smgluel a' = s-b₀ a' ◃ section-smgluel' a'
section-smgluer' : ∀ (b : de⊙ B) →
transport (fst ∘ P) (ap (λ a' → smin a' b) (snd f)) (d (smin a₀ b))
==
section-smbaser
[ fst ∘ P ↓ smgluer b ]
section-smgluer' b =
cpa₂
(fst ∘ P)
(∧-fmap f (⊙idf B))
(smgluer b)
d
(ap (λ a' → smin a' b) (snd f))
(smgluer b)
(smgluer b₀)
(∧-fmap-smgluer-β-∙' b)
section-smgluer : ∀ (b : de⊙ B) → s a₀' b == section-smbaser [ fst ∘ P ↓ smgluer b ]
section-smgluer b = s-a₀' b ◃ section-smgluer' b
module Section =
SmashElim
{P = fst ∘ P}
s
section-smbasel
section-smbaser
section-smgluel
section-smgluer
section : Π (A' ∧ B) (fst ∘ P)
section = Section.f
is-section-smbasel : s a₀' b₀ == d smbasel
is-section-smbasel = ↯ $
s a₀' b₀
=⟪ s-b₀ a₀' ⟫
s₀ a₀'
=⟪idp⟫
transport (fst ∘ P) (! (∧-norm-l a₀')) (d smbasel)
=⟪ ap (λ p → transport (fst ∘ P) (! p) (d smbasel))
(!-inv-r (smgluel a₀')) ⟫
d smbasel ∎∎
is-section-smgluel : ∀ (a : de⊙ A) →
s-f a b₀ ◃ apd d (smgluel a)
==
apd (section ∘ ∧-fmap f (⊙idf B)) (smgluel a) ▹
is-section-smbasel
is-section-smgluel a =
s-f a b₀ ◃ apd d (smgluel a)
=⟨ ap (_◃ apd d (smgluel a)) (s-f-b₀ a) ⟩
(s-b₀ (fst f a) ∙ s₀-f a) ◃ apd d (smgluel a)
=⟨ cpac₁
(fst ∘ P)
(∧-fmap f (⊙idf B))
(smgluel a)
d
(smgluel (fst f a))
(smgluel a₀')
(∧-fmap-smgluel-β-∙' a)
(s-b₀ a₀')
(s-b₀ (fst f a)) ⟩
↓-ap-out= (fst ∘ P)
(∧-fmap f (⊙idf B))
(smgluel a)
(∧-fmap-smgluel-β-∙ a)
(section-smgluel (fst f a) ∙ᵈ !ᵈ (section-smgluel a₀')) ▹
is-section-smbasel
=⟨ ! $ ap (_▹ is-section-smbasel) $
ap (↓-ap-out= (fst ∘ P)
(∧-fmap f (⊙idf B))
(smgluel a)
(∧-fmap-smgluel-β-∙ a)) $
apd-section-norm-l (fst f a) ⟩
↓-ap-out= (fst ∘ P)
(∧-fmap f (⊙idf B))
(smgluel a)
(∧-fmap-smgluel-β-∙ a)
(apd section (∧-norm-l (fst f a))) ▹
is-section-smbasel
=⟨ ! $ ap (_▹ is-section-smbasel) $
apd-∘'' section
(∧-fmap f (⊙idf B))
(smgluel a)
(∧-fmap-smgluel-β-∙ a) ⟩
apd (section ∘ ∧-fmap f (⊙idf B)) (smgluel a) ▹
is-section-smbasel =∎
where
apd-section-norm-l : ∀ (a' : de⊙ A') →
apd section (∧-norm-l a')
==
section-smgluel a' ∙ᵈ !ᵈ (section-smgluel a₀')
apd-section-norm-l a' =
apd section (∧-norm-l a')
=⟨ apd-∙ section (smgluel a') (! (smgluel a₀')) ⟩
apd section (smgluel a') ∙ᵈ apd section (! (smgluel a₀'))
=⟨ ap2 _∙ᵈ_ (Section.smgluel-β a')
(apd-! section (smgluel a₀') ∙
ap !ᵈ (Section.smgluel-β a₀')) ⟩
section-smgluel a' ∙ᵈ !ᵈ (section-smgluel a₀') =∎
is-section-smbaser : s a₀' b₀ == d smbaser
is-section-smbaser = ↯ $
s a₀' b₀
=⟪ s-a₀' b₀ ⟫
transport (fst ∘ P) (ap (λ a' → smin a' b₀) (snd f)) (d (smin a₀ b₀))
=⟪ ap (λ p → transport (fst ∘ P) p (d (smin a₀ b₀))) (↯ r) ⟫
transport (fst ∘ P) (ap (∧-fmap f (⊙idf B)) (smgluer b₀)) (d (smin a₀ b₀))
=⟪ to-transp (↓-ap-in (fst ∘ P) (∧-fmap f (⊙idf B)) (apd d (smgluer b₀))) ⟫
d smbaser ∎∎
where
r : ap (λ a' → smin a' b₀) (snd f) =-= ap (∧-fmap f (⊙idf B)) (smgluer b₀)
r =
ap (λ a' → smin a' b₀) (snd f)
=⟪ ! (∙-unit-r _) ⟫
ap (λ a' → smin a' b₀) (snd f) ∙ idp
=⟪ ap (ap (λ a' → smin a' b₀) (snd f) ∙_)
(! (!-inv-r (smgluer b₀))) ⟫
ap (λ a' → smin a' b₀) (snd f) ∙ ∧-norm-r b₀
=⟪ ! (∧-fmap-smgluer-β-∙ b₀) ⟫
ap (∧-fmap f (⊙idf B)) (smgluer b₀) ∎∎
is-section-smgluer : ∀ (b : de⊙ B) →
s-f a₀ b ◃
apd d (smgluer b)
==
apd (section ∘ ∧-fmap f (⊙idf B)) (smgluer b) ▹
is-section-smbaser
is-section-smgluer b = ! $
apd (section ∘ ∧-fmap f (⊙idf B)) (smgluer b) ▹
is-section-smbaser
=⟨ ap (_▹ is-section-smbaser) $
apd-∘'' section
(∧-fmap f (⊙idf B))
(smgluer b)
(∧-fmap-smgluer-β-∙ b) ⟩
↓-ap-out= (fst ∘ P)
(∧-fmap f (⊙idf B))
(smgluer b)
(∧-fmap-smgluer-β-∙ b)
(apd section (ap (λ a' → smin a' b) (snd f) ∙ ∧-norm-r b)) ▹
is-section-smbaser
=⟨ ap (_▹ is-section-smbaser) $
ap (↓-ap-out= (fst ∘ P)
(∧-fmap f (⊙idf B))
(smgluer b)
(∧-fmap-smgluer-β-∙ b)) $
apd-section-helper ⟩
↓-ap-out= (fst ∘ P)
(∧-fmap f (⊙idf B))
(smgluer b)
(∧-fmap-smgluer-β-∙ b)
((s-f a₀ b ◃ transp-over (fst ∘ P) (ap (λ a' → smin a' b) (snd f)) (d (smin a₀ b))) ∙ᵈ
section-smgluer' b ∙ᵈ !ᵈ (section-smgluer b₀)) ▹
is-section-smbaser
=⟨ cpac₂
(fst ∘ P)
(∧-fmap f (⊙idf B))
(smgluer b)
(smgluer b₀)
d
(ap (λ a' → smin a' b) (snd f))
(ap (λ a' → smin a' b₀) (snd f))
(smgluer b)
(smgluer b₀)
(∧-fmap-smgluer-β-∙' b)
(∧-fmap-smgluer-β-∙' b₀)
(s-a₀' b₀)
(s-f a₀ b) ⟩
s-f a₀ b ◃
apd d (smgluer b) =∎
where
apd-section-helper :
apd section (ap (λ a' → smin a' b) (snd f) ∙ ∧-norm-r b)
==
(s-f a₀ b ◃ transp-over (fst ∘ P) (ap (λ a' → smin a' b) (snd f)) (d (smin a₀ b))) ∙ᵈ
section-smgluer' b ∙ᵈ !ᵈ (section-smgluer b₀)
apd-section-helper =
apd section (ap (λ a' → smin a' b) (snd f) ∙ ∧-norm-r b)
=⟨ apd-∙ section (ap (λ a' → smin a' b) (snd f)) (∧-norm-r b) ⟩
apd section (ap (λ a' → smin a' b) (snd f)) ∙ᵈ
apd section (∧-norm-r b)
=⟨ ap2 _∙ᵈ_
(apd-∘''' section (λ a' → smin a' b) (snd f))
(apd-∙ section (smgluer b) (! (smgluer b₀))) ⟩
↓-ap-in (fst ∘ P) (λ a' → smin a' b) (apd (λ a' → s a' b) (snd f)) ∙ᵈ
apd section (smgluer b) ∙ᵈ apd section (! (smgluer b₀))
=⟨ ap (↓-ap-in (fst ∘ P) (λ a' → smin a' b) (apd (λ a' → s a' b) (snd f)) ∙ᵈ_) $
ap2 _∙ᵈ_
(Section.smgluer-β b)
(apd-! section (smgluer b₀) ∙
ap !ᵈ (Section.smgluer-β b₀)) ⟩
↓-ap-in (fst ∘ P) (λ a' → smin a' b) (apd (λ a' → s a' b) (snd f)) ∙ᵈ
section-smgluer b ∙ᵈ !ᵈ (section-smgluer b₀)
=⟨ custom-assoc (fst ∘ P)
(↓-ap-in (fst ∘ P) (λ a' → smin a' b) (apd (λ a' → s a' b) (snd f)))
(! (to-transp (↓-ap-in (fst ∘ P) (λ a' → smin a' b) (apd (λ a' → s a' b) (snd f)))))
(ap (transport (fst ∘ P) (ap (λ a' → smin a' b) (snd f))) (s-f a₀ b))
(section-smgluer' b)
(!ᵈ (section-smgluer b₀)) ⟩
((↓-ap-in (fst ∘ P) (λ a' → smin a' b) (apd (λ a' → s a' b) (snd f)) ▹
! (to-transp (↓-ap-in (fst ∘ P) (λ a' → smin a' b) (apd (λ a' → s a' b) (snd f))))) ▹
ap (transport (fst ∘ P) (ap (λ a' → smin a' b) (snd f))) (s-f a₀ b)) ∙ᵈ
section-smgluer' b ∙ᵈ !ᵈ (section-smgluer b₀)
=⟨ ap (λ u → (u ▹ ap (transport (fst ∘ P) (ap (λ a' → smin a' b) (snd f))) (s-f a₀ b)) ∙ᵈ
section-smgluer' b ∙ᵈ !ᵈ (section-smgluer b₀)) $
to-transp-over (fst ∘ P) $
↓-ap-in (fst ∘ P) (λ a' → smin a' b) (apd (λ a' → s a' b) (snd f)) ⟩
(transp-over (fst ∘ P) (ap (λ a' → smin a' b) (snd f)) (s (fst f a₀) b) ▹
ap (transport (fst ∘ P) (ap (λ a' → smin a' b) (snd f))) (s-f a₀ b)) ∙ᵈ
section-smgluer' b ∙ᵈ !ᵈ (section-smgluer b₀)
=⟨ ! $ ap (_∙ᵈ section-smgluer' b ∙ᵈ !ᵈ (section-smgluer b₀)) $
transp-over-naturality (fst ∘ P)
(ap (λ a' → smin a' b) (snd f))
(s-f a₀ b) ⟩
(s-f a₀ b ◃ transp-over (fst ∘ P) (ap (λ a' → smin a' b) (snd f)) (d (smin a₀ b))) ∙ᵈ
section-smgluer' b ∙ᵈ !ᵈ (section-smgluer b₀) =∎
is-section : section ∘ ∧-fmap f (⊙idf B) ∼ d
is-section =
Smash-PathOver-elim
{P = λ ab → fst (P (∧-fmap f (⊙idf B) ab))}
(section ∘ ∧-fmap f (⊙idf B))
d
s-f
is-section-smbasel
is-section-smbaser
is-section-smgluel
is-section-smgluer
{- Proposition 4.3.2 in Guillaume Brunerie's thesis -}
∧-fmap-conn-l : has-conn-fibers (n +2+ m) (∧-fmap f (⊙idf B))
∧-fmap-conn-l = conn-in (λ P → ConnIn.section P , ConnIn.is-section P)
private
∧-swap-conn : ∀ {i} {j} (X : Ptd i) (Y : Ptd j) (n : ℕ₋₂)
→ has-conn-fibers n (∧-swap X Y)
∧-swap-conn X Y n yx =
Trunc-preserves-level {n = -2} n $
equiv-is-contr-map (∧-swap-is-equiv X Y) yx
∧-fmap-conn-r : ∀ {i} {j} {k}
(A : Ptd i) {B : Ptd j} {B' : Ptd k} (g : B ⊙→ B')
{k l : ℕ₋₂}
→ is-connected (S k) (de⊙ A)
→ has-conn-fibers l (fst g)
→ has-conn-fibers (k +2+ l) (∧-fmap (⊙idf A) g)
∧-fmap-conn-r A {B} {B'} g {k} {l} A-is-Sk-conn g-is-l-conn =
transport
(has-conn-fibers (k +2+ l))
(λ= (∧-swap-fmap (⊙idf A) g)) $
∘-conn (∧-swap A B)
(∧-swap B' A ∘ ∧-fmap g (⊙idf A))
(∧-swap-conn A B _) $
∘-conn (∧-fmap g (⊙idf A))
(∧-swap B' A)
(∧-fmap-conn-l g A g-is-l-conn A-is-Sk-conn)
(∧-swap-conn B' A _)
private
∘-conn' : ∀ {i j k} {A : Type i} {B : Type j} {C : Type k}
{n m : ℕ₋₂} (g : B → C) (f : A → B)
→ has-conn-fibers m g
→ has-conn-fibers n f
→ has-conn-fibers (minT n m) (g ∘ f)
∘-conn' {n = n} {m = m} g f g-conn f-conn =
∘-conn f g
(λ b → connected-≤T (minT≤l n m) {{f-conn b}})
(λ c → connected-≤T (minT≤r n m) {{g-conn c}})
{- Proposition 4.3.5 in Guillaume Brunerie's thesis -}
∧-fmap-conn : ∀ {i i' j j'}
{A : Ptd i} {A' : Ptd i'} (f : A ⊙→ A')
{B : Ptd j} {B' : Ptd j'} (g : B ⊙→ B')
{m n k l : ℕ₋₂}
→ is-connected (S k) (de⊙ A')
→ is-connected (S n) (de⊙ B)
→ has-conn-fibers m (fst f)
→ has-conn-fibers l (fst g)
→ has-conn-fibers (minT (n +2+ m) (k +2+ l)) (∧-fmap f g)
∧-fmap-conn {A = A} {A'} f {B} {B'} g {m} {n} {k} {l}
A'-is-Sk-conn B-is-Sn-conn f-is-m-conn g-is-l-conn =
transport (has-conn-fibers (minT (n +2+ m) (k +2+ l))) p $
∘-conn' (∧-fmap (⊙idf A') g)
(∧-fmap f (⊙idf B))
(∧-fmap-conn-r A' g A'-is-Sk-conn g-is-l-conn)
(∧-fmap-conn-l f B f-is-m-conn B-is-Sn-conn)
where
p : ∧-fmap (⊙idf A') g ∘ ∧-fmap f (⊙idf B) == ∧-fmap f g
p =
∧-fmap (⊙idf A') g ∘ ∧-fmap f (⊙idf B)
=⟨ ! (λ= (∧-fmap-comp f (⊙idf A') (⊙idf B) g)) ⟩
∧-fmap (⊙idf A' ⊙∘ f) (g ⊙∘ ⊙idf B)
=⟨ ap (λ h → ∧-fmap h g) (⊙λ= (⊙∘-unit-l f)) ⟩
∧-fmap f g =∎
| 36.397004
| 102
| 0.41454
|
22fdbe0b4dec6f5b7bd1c6fc1d49cf234effe479
| 44,570
|
agda
|
Agda
|
Cubical/Homotopy/Group/Pi4S3/DirectProof.agda
|
thomas-lamiaux/cubical
|
58c0b83bb0fed0dc683f3d29b1709effe51c1689
|
[
"MIT"
] | null | null | null |
Cubical/Homotopy/Group/Pi4S3/DirectProof.agda
|
thomas-lamiaux/cubical
|
58c0b83bb0fed0dc683f3d29b1709effe51c1689
|
[
"MIT"
] | null | null | null |
Cubical/Homotopy/Group/Pi4S3/DirectProof.agda
|
thomas-lamiaux/cubical
|
58c0b83bb0fed0dc683f3d29b1709effe51c1689
|
[
"MIT"
] | null | null | null |
{-
This file contains a direct proof that the Brunerie number (the number
n s.t. π₄(S³)≅ℤ/nℤ) is 2, not relying on any of the more advanced
constructions in chapters 4-6 in Brunerie's thesis (but still using
chapters 1-3 for the construction). The Brunerie number is defined via
S³ ≃ S¹ * S¹ -ᵂ→ S² ∨ S² -ᶠᵒˡᵈ→ S²
where * denotes the join, ∨ denotes the wedge sum, W is the Whitehead
map (see joinTo⋁ in Cubical.Homotopy.Whitehead) and the final map is
just the folding map. η := ∣ fold ∘ W ∣₀ defines an element of π₃(S²).
The (absolute value) of the Brunerie number is given by the absolute
value of ϕ(η) for any iso π₃(S²)≅ℤ. The reason it's hard to prove
ϕ(η) = ± 2 directly is mainly because the equivalence S³ ≃ S¹ * S¹
complicates things. In this file, we try to work around this problem.
The proof goes as follows.
1. Define π₃*(A) := ∥ S¹ * S¹ →∙ A ∥₀ and define explicitly an
addition on this type. Prove that the equivalence π₃(A) ≃ π₃*(A) is
structure preserving, thereby giving a group structure on π₃*(A) and a
group iso π₃*(A) ≅ π₃(A)
2. Under this iso, η gets mapped to η₁ (by construction) defined by
S¹ * S¹ -ᵂ→ S² ∨ S² -ᶠᵒˡᵈ→ S²
which is much easier to work with.
3. Define a sequence of equivalences
π₃*(S²) ≅ π₃*(S¹ * S¹) ≅ π₃*(S³) ≅ π₃(S³) ≅ ℤ
and trace η₁ in each step, proving that it ends up at -2. It turns out
that that the iso S³ ≃ S¹ * S¹, which has been relatively explicitly
defined in Cubical.HITs.Sphere.Properties, kills off a good deal of
``annoying'' terms on the way, making the proof rather straightforward.
4. Conclude that π₄(S³) ≅ ℤ/2ℤ.
-------------- Part 2:
The file also contains a second approach: showing η₃ : π₃*(S³) ↦ -2 by
computation. This is done by very carefully choosing the equivalences
involved. In fact, one has to be so careful that it almost requires
more work than just proving η₃ : ↦ -2 by hand. But at least, we can do
it!
-}
{-# OPTIONS --safe --experimental-lossy-unification #-}
module Cubical.Homotopy.Group.Pi4S3.DirectProof where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Pointed
open import Cubical.Foundations.HLevels
open import Cubical.Foundations.GroupoidLaws renaming (assoc to ∙assoc)
open import Cubical.Foundations.Pointed.Homogeneous
open import Cubical.Foundations.Path
open import Cubical.Foundations.Equiv.HalfAdjoint
open import Cubical.Foundations.Isomorphism
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.Function
open import Cubical.Homotopy.Loopspace
open import Cubical.Homotopy.Group.Base
open import Cubical.Homotopy.Group.Pi3S2
open import Cubical.Homotopy.Group.PinSn
open import Cubical.Homotopy.Hopf
open import Cubical.Homotopy.Whitehead using (joinTo⋁)
open import Cubical.Homotopy.Connected
open import Cubical.Homotopy.HopfInvariant.HopfMap using (hopfMap≡HopfMap')
-- Only imports a simple equality of two constructions of the Hopf map.
open import Cubical.Homotopy.Group.Pi4S3.BrunerieNumber
using (fold∘W ; coFib-fold∘W∙ ; π₄S³≅π₃coFib-fold∘W∙ ; S³→S²→Pushout→Unit)
-- Only imports definitions/proofs from chapter 1-3 in Brunerie's thesis
open import Cubical.Homotopy.Group.Pi4S3.BrunerieExperiments
using (K₂ ; f7' ; S¹∙ ; encodeTruncS²)
-- For computation (alternative proof)
open import Cubical.Data.Sigma
open import Cubical.Data.Nat
open import Cubical.Data.Int
renaming (ℤ to Z ; _·_ to _·Z_ ; _+_ to _+Z_)
open import Cubical.HITs.S1 as S1 renaming (_·_ to _*_)
open import Cubical.HITs.S2 renaming (S¹×S¹→S² to S¹×S¹→S²')
open import Cubical.HITs.Sn
open import Cubical.HITs.Susp renaming (toSusp to σ)
open import Cubical.HITs.Join hiding (joinS¹S¹→S³)
open import Cubical.HITs.Wedge
open import Cubical.HITs.Pushout
open import Cubical.HITs.SetTruncation
renaming (rec2 to sRec2 ; elim to sElim ; elim2 to sElim2 ; map to sMap)
open import Cubical.HITs.Truncation as Trunc renaming (rec to trRec)
open import Cubical.HITs.PropositionalTruncation as PropTrunc
open import Cubical.HITs.GroupoidTruncation as GroupoidTrunc
open import Cubical.HITs.2GroupoidTruncation as 2GroupoidTrunc
open import Cubical.Algebra.Group
open import Cubical.Algebra.Group.Exact
open import Cubical.Algebra.Group.ZAction
open import Cubical.Algebra.Group.Instances.IntMod
open import Cubical.Algebra.Group.GroupPath
open import Cubical.Algebra.Group.Morphisms
open import Cubical.Algebra.Group.MorphismProperties
open import Cubical.Algebra.Group.Instances.Int
-- For computation (alternative proof)
open import Cubical.ZCohomology.Base
open import Cubical.ZCohomology.Properties
open import Cubical.ZCohomology.GroupStructure
open S¹Hopf
open Iso
open GroupStr
private
variable
ℓ : Level
A B : Pointed ℓ
-- Some abbreviations and simple lemmas
private
σ₁ = σ (S₊∙ 1)
σ₂ = σ (S₊∙ 2)
σ-filler : ∀ {ℓ} {A : Type ℓ} (x y : A) (i j : I) → Susp A
σ-filler x y i j = compPath-filler (merid x) (sym (merid y)) i j
to3ConnectedId : {f g : A →∙ B}
→ (isConnected 3 (typ B)) → fst f ≡ fst g → ∣ f ∣₂ ≡ ∣ g ∣₂
to3ConnectedId {f = f} {g = g} con p =
trRec (squash₂ _ _)
(λ q → cong ∣_∣₂ (ΣPathP (p , q)))
(fst (isConnectedPathP 1 (isConnectedPath 2 con _ _) (snd f) (snd g)))
connS³ : isConnected 3 (S₊ 3)
connS³ =
isConnectedSubtr 3 1 (sphereConnected 3)
con-joinS¹S¹ : isConnected 3 (join S¹ S¹)
con-joinS¹S¹ =
(isConnectedRetractFromIso 3
(IsoSphereJoin 1 1)
(isConnectedSubtr 3 1 (sphereConnected 3)))
-- Key goal: prove that the following element of π₃(S²) gets mapped to -2
η : π' 3 (S₊∙ 2)
η = fst (π'∘∙Hom 2 (fold∘W , refl)) ∣ id∙ (S₊∙ 3) ∣₂
{- Step 1. Define an addition on π₃*(A) := ∥ S¹ * S¹ →∙ A ∥₀ -}
-- On the underlying function spaces.
_+join_ : (f g : (join S¹ S¹ , inl base) →∙ A)
→ (join S¹ S¹ , inl base) →∙ A
fst (f +join g) (inl x) = fst f (inl x)
fst (f +join g) (inr x) = fst g (inr x)
fst (f +join g) (push a b i) =
(cong (fst f) (push a b ∙ sym (push base b))
∙∙ snd f ∙ sym (snd g)
∙∙ cong (fst g) (push base base ∙∙ sym (push a base) ∙∙ push a b)) i
snd (f +join g) = snd f
-- Homotopy group version
_π₃*+_ : (f g : ∥ (join S¹ S¹ , inl base) →∙ S₊∙ 2 ∥₂)
→ ∥ (join S¹ S¹ , inl base) →∙ S₊∙ 2 ∥₂
_π₃*+_ = sRec2 squash₂ λ x y → ∣ x +join y ∣₂
-- transferring between π₃ and π₃*
-- (homotopy groups defined in terms of S¹ * S¹)
joinify : S₊∙ 3 →∙ A → (join S¹ S¹ , inl base) →∙ A
fst (joinify f) x = fst f (joinS¹S¹→S³ x)
snd (joinify f) = snd f
disjoin : (join S¹ S¹ , inl base) →∙ A → S₊∙ 3 →∙ A
fst (disjoin f) = λ x → fst f (Iso.inv (IsoSphereJoin 1 1) x)
snd (disjoin f) = snd f
-- joinify is structure preserving
+join≡∙Π : (f g : S₊∙ 3 →∙ A)
→ joinify (∙Π f g)
≡ (joinify f +join joinify g)
+join≡∙Π f' g' =
ΣPathP ((funExt (λ { (inl x) → sym fp
; (inr x) → sym gp ∙ cong g (merid north)
; (push a b i) j → main a b j i}))
, λ i j → fp (j ∨ ~ i))
where
f = fst f'
g = fst g'
fp = snd f'
gp = snd g'
path-lem : ∀ {ℓ} {A : Type ℓ} {x y z w u : A}
(p : x ≡ y) (q : y ≡ z) (r : z ≡ w) (s : w ≡ u)
→ (refl ∙∙ p ∙∙ q) ∙ (r ∙∙ s ∙∙ refl)
≡ (p ∙∙ (q ∙ r) ∙∙ s)
path-lem p q r s =
cong ((p ∙ q) ∙_) (sym (compPath≡compPath' r s))
∙∙ sym (∙assoc p q (r ∙ s))
∙∙ cong (p ∙_) (∙assoc q r s)
∙ sym (doubleCompPath≡compPath p (q ∙ r) s)
main-helper : (a b : S¹)
→ Square ((refl ∙∙ cong f (σ₂ (S¹×S¹→S² a b)) ∙∙ fp)
∙ (sym gp ∙∙ cong g (σ₂ (S¹×S¹→S² a b)) ∙∙ refl))
((cong f (merid (S¹×S¹→S² a b))
∙ sym (cong f (merid north)))
∙∙ (fp ∙ sym gp)
∙∙ cong g (merid (S¹×S¹→S² a b)))
(λ _ → f north)
(cong g (merid north))
main-helper a b =
path-lem (cong f (σ₂ (S¹×S¹→S² a b))) fp (sym gp)
(cong g (σ₂ (S¹×S¹→S² a b)))
◁ lem
where
lem : PathP (λ i → f north ≡ cong g (merid north) i)
((λ i → f (σ₂ (S¹×S¹→S² a b) i))
∙∙ fp ∙ (sym gp) ∙∙
(cong g (σ₂ (S¹×S¹→S² a b))))
((cong f (merid (S¹×S¹→S² a b)) ∙ sym (cong f (merid north)))
∙∙ fp ∙ sym gp
∙∙ cong g (merid (S¹×S¹→S² a b)))
lem i j =
hcomp (λ k → λ { (i = i0) →
(cong-∙ f (merid (S¹×S¹→S² a b))
(sym (merid north)) (~ k)
∙∙ fp ∙ sym gp
∙∙ (λ i → g (σ-filler (S¹×S¹→S² a b) north k i))) j
; (i = i1) → ((cong f (merid (S¹×S¹→S² a b))
∙ sym (cong f (merid north)))
∙∙ (fp ∙ sym gp)
∙∙ cong g (merid (S¹×S¹→S² a b))) j
; (j = i0) → f north
; (j = i1) → g (merid north (~ k ∨ i))})
(((cong f (merid (S¹×S¹→S² a b)) ∙ sym (cong f (merid north)))
∙∙ (fp ∙ sym gp)
∙∙ cong g (merid (S¹×S¹→S² a b))) j)
main-helper₂ : (a b : S¹)
→ cong (fst (joinify g')) (push base base ∙∙ sym (push a base) ∙∙ push a b)
≡ cong g (merid (S¹×S¹→S² a b))
main-helper₂ a b = cong-∙∙ (fst (joinify g'))
(push base base) (sym (push a base)) (push a b)
∙ cong (cong g (merid north) ∙∙_∙∙ cong g (merid (S¹×S¹→S² a b)))
(cong (cong g) (cong sym (cong merid (S¹×S¹→S²rUnit a))))
∙ ((λ i → (cong g (λ j → merid north (j ∧ ~ i)))
∙∙ (cong g (λ j → merid north (~ j ∧ ~ i)))
∙∙ cong g (merid (S¹×S¹→S² a b)))
∙ sym (lUnit (cong g (merid (S¹×S¹→S² a b)))))
main : (a b : S¹)
→ PathP (λ i → fp (~ i) ≡ (sym gp ∙ cong g (merid north)) i)
((sym fp ∙∙ cong f (σ₂ (S¹×S¹→S² a b)) ∙∙ fp)
∙ (sym gp ∙∙ cong g (σ₂ (S¹×S¹→S² a b)) ∙∙ gp))
((cong (fst (joinify f')) (push a b ∙ sym (push base b))
∙∙ fp ∙ sym gp
∙∙ cong (fst (joinify g'))
(push base base ∙∙ sym (push a base) ∙∙ push a b)))
main a b =
((λ i j → hcomp (λ k → λ {(i = i0) → (((λ j → fp (~ j ∧ k))
∙∙ cong f (σ₂ (S¹×S¹→S² a b))
∙∙ fp)
∙ (sym gp
∙∙ cong g (σ₂ (S¹×S¹→S² a b))
∙∙ λ j → gp (j ∧ k))) j
; (i = i1) → ((cong f (merid (S¹×S¹→S² a b))
∙ sym (cong f (merid north)))
∙∙ fp ∙ sym gp
∙∙ cong g (merid (S¹×S¹→S² a b))) j
; (j = i0) → fp (~ i ∧ k)
; (j = i1) → compPath-filler'
(sym gp) (cong g (merid north)) k i})
(main-helper a b i j)))
▷ λ i →
cong-∙ (fst (joinify f')) (push a b) (sym (push base b)) (~ i)
∙∙ fp ∙ sym gp
∙∙ main-helper₂ a b (~ i)
-- Group structure on π₃*
-- todo: remove connectivity assumption
module _ (A : Pointed ℓ) (con : (isConnected 3 (typ A))) where
π₃*Iso : Iso (typ (π'Gr 2 A)) ∥ (join S¹ S¹ , inl base) →∙ A ∥₂
fun π₃*Iso = sMap joinify
inv π₃*Iso = sMap disjoin
rightInv π₃*Iso =
sElim (λ _ → isSetPathImplicit)
λ f → to3ConnectedId
con (funExt λ x → cong (fst f) (Iso.leftInv (IsoSphereJoin 1 1) x))
leftInv π₃*Iso =
sElim (λ _ → isSetPathImplicit)
λ f → to3ConnectedId
con (funExt (λ x → cong (fst f) (Iso.rightInv (IsoSphereJoin 1 1) x)))
π₃* : Group ℓ
π₃* = InducedGroupFromPres·
(π'Gr 2 A)
(sRec2 squash₂ (λ x y → ∣ x +join y ∣₂))
(isoToEquiv π₃*Iso)
(sElim2 (λ _ _ → isSetPathImplicit) (λ f g → cong ∣_∣₂ (+join≡∙Π f g)))
π₃≅π₃* : GroupEquiv (π'Gr 2 A) π₃*
π₃≅π₃* =
InducedGroupEquivFromPres· (π'Gr 2 A) (sRec2 squash₂ (λ x y → ∣ x +join y ∣₂))
(isoToEquiv π₃*Iso)
(sElim2 (λ _ _ → isSetPathImplicit) (λ f g → cong ∣_∣₂ (+join≡∙Π f g)))
-- Induced homomorphisms (A →∙ B) → (π₃*(A) → π₃*(B))
-- todo: remove connectivity assumptions
module _ (conA : (isConnected 3 (typ A))) (conB : (isConnected 3 (typ B)))
(f : A →∙ B) where
postCompπ₃* : GroupHom (π₃* A conA) (π₃* B conB)
fst postCompπ₃* = sMap (f ∘∙_)
snd postCompπ₃* =
makeIsGroupHom
(sElim2 (λ _ _ → isSetPathImplicit)
λ h g → to3ConnectedId conB
(funExt λ { (inl x) → refl
; (inr x) → refl
; (push a b i) j →
(cong-∙∙ (fst f)
(cong (fst h) ((push a b ∙ (sym (push base b)))))
(snd h ∙ (sym (snd g)))
(cong (fst g) ((push base base
∙∙ (sym (push a base))
∙∙ push a b)))
∙ cong (cong (fst f)
(cong (fst h) (push a b ∙ (sym (push base b))))
∙∙_∙∙
cong (fst f ∘ fst g)
((push base base ∙∙ (sym (push a base)) ∙∙ push a b)))
(cong-∙ (fst f) (snd h) (sym (snd g))
∙ λ j → compPath-filler (cong (fst f) (snd h)) (snd f) j
∙ sym (compPath-filler
(cong (fst f) (snd g)) (snd f) j))) j i}))
-- Induced iso (A ≃∙ B) → π₃*(A) ≅ π₃*(B)
-- todo: remove connectivity assumptions
module _ (conA : (isConnected 3 (typ A))) (conB : (isConnected 3 (typ B)))
(f : A ≃∙ B) where
postCompπ₃*Equiv : GroupEquiv (π₃* A conA) (π₃* B conB)
fst postCompπ₃*Equiv = isoToEquiv h
where
h : Iso (π₃* A conA .fst) (π₃* B conB .fst)
fun h = fst (postCompπ₃* conA conB (≃∙map f))
inv h = fst (postCompπ₃* conB conA (≃∙map (invEquiv∙ f)))
rightInv h =
sElim (λ _ → isSetPathImplicit)
λ g → to3ConnectedId conB (funExt λ x → secEq (fst f) (fst g x))
leftInv h =
sElim (λ _ → isSetPathImplicit)
λ g → to3ConnectedId conA (funExt λ x → retEq (fst f) (fst g x))
snd postCompπ₃*Equiv = snd (postCompπ₃* conA conB (≃∙map f))
-- The relevant groups (in order of the iso π₃(S²) ≅ ℤ)
π₃S² = π'Gr 2 (S₊∙ 2)
π₃*S² = π₃* (S₊∙ 2) (sphereConnected 2)
π₃*joinS¹S¹ = π₃* (join S¹ S¹ , inl base) con-joinS¹S¹
π₃*S³ = π₃* (S₊∙ 3) connS³
π₃S³ = π'Gr 2 (S₊∙ 3)
{- Goal now: Show that
(η : π₃(S²))
↦ (η₁ : π₃*(S²))
↦ (η₂ : π₃*(S¹ * S¹))
↦ (η₃ : π₃*(S³))
↦ (η₄ : π₃(S³))
↦ (-2 : ℤ)
for some terms η₁ ... η₄ by a sequence of isomorphisms
π₃(S²) ≅ π₃*(S²) ≅ π₃*(S¹ * S¹) ≅ π₃*(S³) ≅ π₃(S³) ≅ ℤ
Hence, there is an is an iso π₃(S²) ≅ ℤ taking η to
-2, from which we can conclude π₄(S³) ≅ ℤ/2ℤ.
-}
-- Underlying functions of (some of) the ηs
η₁-raw : (join S¹ S¹ , inl base) →∙ S₊∙ 2
fst η₁-raw (inl x) = north
fst η₁-raw (inr x) = north
fst η₁-raw (push a b i) = (σ₁ b ∙ σ₁ a) i
snd η₁-raw = refl
η₂-raw : (join S¹ S¹ , inl base) →∙ (join S¹ S¹ , inl base)
fst η₂-raw (inl x) = inr (invLooper x)
fst η₂-raw (inr x) = inr x
fst η₂-raw (push a b i) =
(sym (push (b * invLooper a) (invLooper a))
∙ push (b * invLooper a) b) i
snd η₂-raw = sym (push base base)
η₃-raw : (join S¹ S¹ , inl base) →∙ S₊∙ 3
fst η₃-raw (inl x) = north
fst η₃-raw (inr x) = north
fst η₃-raw (push a b i) =
(sym (σ₂ (S¹×S¹→S² a b)) ∙ sym (σ₂ (S¹×S¹→S² a b))) i
snd η₃-raw = refl
-- Homotopy group versions
η₁ : fst π₃*S²
η₁ = ∣ η₁-raw ∣₂
η₂ : fst (π₃*joinS¹S¹)
η₂ = ∣ η₂-raw ∣₂
η₃ : π₃*S³ .fst
η₃ = ∣ η₃-raw ∣₂
η₄ : fst π₃S³
η₄ = ·π' 2 (-π' 2 ∣ idfun∙ (S₊∙ 3) ∣₂) (-π' 2 ∣ idfun∙ (S₊∙ 3) ∣₂)
-- π₃S²≅π₃*S²
π₃S²→π₃*S² : GroupEquiv π₃S² π₃*S²
π₃S²→π₃*S² = π₃≅π₃* (S₊∙ 2) (sphereConnected 2)
-- Time for π₃*(S¹ * S¹) ≅ π₃*S².
-- We have this iso already, but slightly differently stated,
-- so the following proof becomes a bit technical.
-- We define it in terms a slight variation of the Hopf map
Hopfσ : join S¹ S¹ → S₊ 2
Hopfσ (inl x) = north
Hopfσ (inr x) = north
Hopfσ (push a b i) = σ₁ (invLooper a * b) i
π₃*joinS¹S¹→π₃*S² : GroupHom π₃*joinS¹S¹ π₃*S²
π₃*joinS¹S¹→π₃*S² =
postCompπ₃* con-joinS¹S¹ (sphereConnected 2)
(Hopfσ , refl)
π₃*joinS¹S¹≅π₃*S² : GroupEquiv π₃*joinS¹S¹ π₃*S²
fst (fst π₃*joinS¹S¹≅π₃*S²) = fst π₃*joinS¹S¹→π₃*S²
snd (fst π₃*joinS¹S¹≅π₃*S²) =
subst isEquiv idLem isEquivπ₃*joinS¹S¹→π₃*S²'
where
π₃*joinS¹S¹→π₃*S²' : GroupHom π₃*joinS¹S¹ π₃*S²
π₃*joinS¹S¹→π₃*S²' =
postCompπ₃* con-joinS¹S¹ (sphereConnected 2)
(fst ∘ JoinS¹S¹→TotalHopf , refl)
isEquivπ₃*joinS¹S¹→π₃*S²' : isEquiv (fst π₃*joinS¹S¹→π₃*S²')
isEquivπ₃*joinS¹S¹→π₃*S²' =
transport (λ i → isEquiv (fst (help (~ i))))
(snd (fst GrEq))
where
GrEq = compGroupEquiv (πS³≅πTotalHopf 2) π'₃S²≅π'₃TotalHopf
help : PathP
(λ i → GroupHom
(GroupPath π₃*joinS¹S¹ π₃S³ .fst
(compGroupEquiv
(invGroupEquiv (π₃≅π₃* (join S¹ S¹ , inl base) con-joinS¹S¹))
(π'Iso 2 (isoToEquiv (IsoSphereJoin 1 1) , refl))) i)
(GroupPath π₃*S² π₃S² .fst
(invGroupEquiv (π₃≅π₃* (S₊∙ 2) (sphereConnected 2))) i))
π₃*joinS¹S¹→π₃*S²'
(fst (fst GrEq) , snd GrEq)
help =
toPathP (Σ≡Prop (λ _ → isPropIsGroupHom _ _)
(funExt
λ f → (λ i
→ transportRefl
((invGroupEquiv (π₃≅π₃* (S₊∙ 2) (sphereConnected 2))) .fst .fst
(fst π₃*joinS¹S¹→π₃*S²' (
((fst (fst (π₃≅π₃* (join S¹ S¹ , inl base) con-joinS¹S¹)))
(invEq (fst (π'Iso 2 (isoToEquiv (IsoSphereJoin 1 1) , refl)))
(transportRefl f i)))))) i)
∙ main f))
where
main : (f : _) → invEquiv (fst (π₃≅π₃* (S₊∙ 2) (sphereConnected 2))) .fst
(fst π₃*joinS¹S¹→π₃*S²'
(invEq
(invEquiv (fst (π₃≅π₃* (join S¹ S¹ , inl base) con-joinS¹S¹)))
(invEq (fst (π'Iso 2 (isoToEquiv Iso-joinS¹S¹-S³ , (λ _ → north))))
f)))
≡ fst GrEq .fst f
main = sElim (λ _ → isSetPathImplicit)
λ f → to3ConnectedId (sphereConnected 2)
(funExt λ x
→ (λ i → fst (JoinS¹S¹→TotalHopf (Iso.inv (IsoSphereJoin 1 1)
(fst f (Iso.rightInv (IsoSphereJoin 1 1) x i)))))
∙ sym (funExt⁻ (sym (cong fst hopfMap≡HopfMap'))
(fst f x)))
idLem : fst π₃*joinS¹S¹→π₃*S²' ≡ fst π₃*joinS¹S¹→π₃*S²
idLem =
funExt (sElim (λ _ → isSetPathImplicit)
λ f → to3ConnectedId (sphereConnected 2)
(funExt λ x → lem (fst f x)))
where
lem : (x : _) → fst (JoinS¹S¹→TotalHopf x) ≡ Hopfσ x
lem (inl x) = refl
lem (inr x) = sym (merid base)
lem (push a b i) j =
compPath-filler (merid (invLooper a * b)) (sym (merid base)) j i
snd π₃*joinS¹S¹≅π₃*S² = snd π₃*joinS¹S¹→π₃*S²
-- π₃*(S³) ≅ π₃*(S¹ * S¹)
π₃*S³≅π₃*joinS¹S¹ : GroupEquiv π₃*S³ π₃*joinS¹S¹
π₃*S³≅π₃*joinS¹S¹ =
postCompπ₃*Equiv
connS³ con-joinS¹S¹
(isoToEquiv (invIso (IsoSphereJoin 1 1)) , refl)
-- π₃(S³)≅π₃*(S³)
π₃S³≅π₃*S³ : GroupEquiv π₃S³ π₃*S³
π₃S³≅π₃*S³ = π₃≅π₃* (S₊∙ 3) connS³
η↦η₁ : fst (fst π₃S²→π₃*S²) η ≡ η₁
η↦η₁ = to3ConnectedId (sphereConnected 2)
(funExt λ x → (funExt⁻ lem₁ x) ∙ sym (lem₂ x))
where
lem₁ : fold∘W ∘ joinS¹S¹→S³ ≡ fold⋁ ∘ (joinTo⋁ {A = S₊∙ 1} {B = S₊∙ 1})
lem₁ = funExt λ x
→ cong (fold⋁ ∘ (joinTo⋁ {A = S₊∙ 1} {B = S₊∙ 1}))
(leftInv (IsoSphereJoin 1 1) x)
lem₂ : (x : join S¹ S¹) → fst η₁-raw x ≡ (fold⋁ ∘ joinTo⋁) x
lem₂ (inl x) = refl
lem₂ (inr x) = refl
lem₂ (push a b i) j = help j i
where
help : (σ₁ b ∙ σ₁ a) ≡ cong (fold⋁ ∘ joinTo⋁) (push a b)
help = sym (cong-∙∙ fold⋁ (λ j → inr (σ₁ b j))
(sym (push tt)) (λ j → inl (σ₁ a j))
∙ λ i → (λ j → σ₁ b (j ∧ ~ i))
∙∙ (λ j → σ₁ b (j ∨ ~ i))
∙∙ σ₁ a)
-- We show that η₂ ↦ η₁ (this is easier than η₁ ↦ η₂)
η₂↦η₁ : fst (fst π₃*joinS¹S¹≅π₃*S²) η₂ ≡ η₁
η₂↦η₁ =
to3ConnectedId (sphereConnected 2)
(funExt λ { (inl x) → refl
; (inr x) → refl
; (push a b i) j → main a b j i})
where
lem : (a b : S¹)
→ (sym (σ₁ (invLooper (b * invLooper a) * invLooper a)) ≡ σ₁ b)
× (σ₁ (invLooper (b * invLooper a) * b) ≡ σ₁ a)
fst (lem a b) =
cong sym (cong σ₁ (sym (invLooperDistr (b * invLooper a) a))
∙ σ-invSphere 0 (b * invLooper a * a))
∙ cong σ₁ (sym (assocS¹ b (invLooper a) a)
∙ cong (b *_) (commS¹ _ _ ∙ sym (rCancelS¹ a))
∙ rUnitS¹ b)
snd (lem a b) =
cong σ₁ (cong (_* b) (invLooperDistr b (invLooper a)
∙ cong (invLooper b *_) (invSphere² 1 a)
∙ commS¹ (invLooper b) a)
∙ sym (assocS¹ a (invLooper b) b)
∙ cong (a *_) (commS¹ _ _ ∙ sym (rCancelS¹ b))
∙ rUnitS¹ a)
main : (a b : S¹)
→ cong Hopfσ ((sym (push (b * invLooper a) (invLooper a))
∙ push (b * invLooper a) b))
≡ σ₁ b ∙ σ₁ a
main a b =
cong-∙ Hopfσ (sym (push (b * invLooper a) (invLooper a)))
(push (b * invLooper a) b)
∙ cong₂ _∙_ (fst (lem a b)) (snd (lem a b))
-- We show that η₂ ↦ η₃
η₂↦η₃ : invEq (fst π₃*S³≅π₃*joinS¹S¹) η₂ ≡ η₃
η₂↦η₃ =
to3ConnectedId connS³
(funExt λ x → sym (joinS¹S¹→S³σ≡ (fst η₂-raw x))
∙ lem x)
where
joinS¹S¹→S³σ : join S¹ S¹ → S₊ 3
joinS¹S¹→S³σ (inl x) = north
joinS¹S¹→S³σ (inr x) = north
joinS¹S¹→S³σ (push a b i) = σ₂ (S¹×S¹→S² a b) i
joinS¹S¹→S³σ≡ : (x : _) → joinS¹S¹→S³σ x ≡ joinS¹S¹→S³ x
joinS¹S¹→S³σ≡ (inl x) = refl
joinS¹S¹→S³σ≡ (inr x) = merid north
joinS¹S¹→S³σ≡ (push a b i) j =
compPath-filler (merid (S¹×S¹→S² a b)) (sym (merid north)) (~ j) i
lem : (x : _) → joinS¹S¹→S³σ (fst η₂-raw x) ≡ fst η₃-raw x
lem (inl x) = refl
lem (inr x) = refl
lem (push a b i) j = main j i
where
left-lem : σ₂ (S¹×S¹→S² (b * invLooper a) (invLooper a))
≡ σ₂ (S¹×S¹→S² a b)
left-lem = cong σ₂ (S¹×S¹→S²-Distr b (invLooper a)
∙ sym (S¹×S¹→S²-antiComm a b))
right-lem : σ₂ (S¹×S¹→S² (b * invLooper a) b) ≡ sym (σ₂ (S¹×S¹→S² a b))
right-lem =
cong σ₂ ((cong (λ x → S¹×S¹→S² x b) (commS¹ b (invLooper a))
∙ S¹×S¹→S²-Distr (invLooper a) b)
∙∙ S¹×S¹→S²-antiComm (invLooper a) b
∙∙ invSusp∘S¹×S¹→S² b (invLooper a))
∙∙ σ-invSphere 1 (S¹×S¹→S² b (invLooper a))
∙∙ cong (sym ∘ σ₂) (sym (S¹×S¹→S²-antiComm a b))
main : cong (joinS¹S¹→S³σ ∘ fst η₂-raw) (push a b)
≡ sym (σ₂ (S¹×S¹→S² a b)) ∙ sym (σ₂ (S¹×S¹→S² a b))
main = cong-∙ joinS¹S¹→S³σ
(sym (push (b * invLooper a) (invLooper a)))
(push (b * invLooper a) b)
∙ cong₂ _∙_ (cong sym left-lem) right-lem
-- We show that η₄ ↦ η₃ (this is easier than η₃ ↦ η₄)
η₄↦η₃ : fst (fst π₃S³≅π₃*S³) η₄ ≡ η₃
η₄↦η₃ = IsGroupHom.pres· (snd π₃S³≅π₃*S³)
(-π' 2 ∣ idfun∙ (S₊∙ 3) ∣₂) (-π' 2 ∣ idfun∙ (S₊∙ 3) ∣₂)
∙ cong₂ _+π₃*_ gen↦η₃/2 gen↦η₃/2
∙ η₃/2+η₃/2≡η₃
where
_+π₃*_ : fst π₃*S³ → fst π₃*S³ → fst π₃*S³
_+π₃*_ = GroupStr._·_ (snd π₃*S³)
η₃-raw/2 : (join S¹ S¹ , inl base) →∙ S₊∙ 3
fst η₃-raw/2 (inl x) = north
fst η₃-raw/2 (inr x) = north
fst η₃-raw/2 (push a b i) = σ₂ (S¹×S¹→S² a b) (~ i)
snd η₃-raw/2 = refl
η₃/2 : π₃*S³ .fst
η₃/2 = ∣ η₃-raw/2 ∣₂
gen↦η₃/2 : fst (fst π₃S³≅π₃*S³) (-π' 2 ∣ idfun∙ (S₊∙ 3) ∣₂) ≡ η₃/2
gen↦η₃/2 =
to3ConnectedId connS³
(funExt λ { (inl x) → refl
; (inr x) → refl
; (push a b i) → refl})
η₃/2+η₃/2≡η₃ : η₃/2 +π₃* η₃/2 ≡ η₃
η₃/2+η₃/2≡η₃ =
to3ConnectedId connS³
(funExt λ { (inl x) → refl
; (inr x) → refl
; (push a b i) → λ j → lem a b j i})
where
lem : (a b : S¹) → cong (fst (η₃-raw/2 +join η₃-raw/2)) (push a b)
≡ cong (fst η₃-raw) (push a b)
lem a b = (λ i → cong-∙ (fst η₃-raw/2) (push a b) (sym (push base b)) i
∙∙ rUnit refl (~ i)
∙∙ cong-∙∙ (fst η₃-raw/2)
(push base base) (sym (push a base)) (push a b) i)
∙∙ (λ i → (sym (σ₂ (S¹×S¹→S² a b)) ∙ rCancel (merid north) i)
∙∙ refl
∙∙ (sym (rCancel (merid north) i)
∙∙ (cong σ₂ (S¹×S¹→S²rUnit a) ∙ rCancel (merid north)) i
∙∙ sym (σ₂ (S¹×S¹→S² a b))))
∙∙ ((λ i → rUnit (sym (σ₂ (S¹×S¹→S² a b))) (~ i)
∙∙ refl
∙∙ lUnit (sym (σ₂ (S¹×S¹→S² a b))) (~ i))
∙ λ i → (λ j → σ₂ (S¹×S¹→S² a b) (i ∨ ~ j))
∙∙ (λ j → σ₂ (S¹×S¹→S² a b) (i ∧ ~ j))
∙∙ sym (σ₂ (S¹×S¹→S² a b)))
-- Agda is very keen on expanding things, so we make an abstract
-- summary of the main lemmas above
abstract
π₃S²≅π₃*S²-abs : GroupEquiv π₃S² π₃*S²
π₃S²≅π₃*S²-abs = π₃S²→π₃*S²
π₃*S²≅π₃*joinS¹S¹-abs : GroupEquiv π₃*S² π₃*joinS¹S¹
π₃*S²≅π₃*joinS¹S¹-abs = invGroupEquiv π₃*joinS¹S¹≅π₃*S²
π₃*joinS¹S¹≅π₃*S³-abs : GroupEquiv π₃*joinS¹S¹ π₃*S³
π₃*joinS¹S¹≅π₃*S³-abs = invGroupEquiv π₃*S³≅π₃*joinS¹S¹
π₃*S³≅π₃*S³-abs : GroupEquiv π₃*S³ π₃S³
π₃*S³≅π₃*S³-abs = invGroupEquiv π₃S³≅π₃*S³
-- stated in terms of (n : ℕ) to prevent normalisation
π₃'S³≅ℤ-abs : (n : ℕ) → GroupEquiv (π'Gr n (S₊∙ (suc n))) ℤGroup
π₃'S³≅ℤ-abs n = GroupIso→GroupEquiv (πₙ'Sⁿ≅ℤ n)
η↦η₁-abs : fst (fst π₃S²≅π₃*S²-abs) η ≡ η₁
η↦η₁-abs = η↦η₁
η₁↦η₂-abs : fst (fst π₃*S²≅π₃*joinS¹S¹-abs) η₁ ≡ η₂
η₁↦η₂-abs = cong (fst (fst π₃*S²≅π₃*joinS¹S¹-abs)) (sym η₂↦η₁)
∙ secEq (fst π₃*S²≅π₃*joinS¹S¹-abs) η₂
η₂↦η₃-abs : fst (fst π₃*joinS¹S¹≅π₃*S³-abs) η₂ ≡ η₃
η₂↦η₃-abs = η₂↦η₃
η₃↦η₄-abs : fst (fst π₃*S³≅π₃*S³-abs) η₃ ≡ η₄
η₃↦η₄-abs = cong (invEq (fst π₃S³≅π₃*S³)) (sym η₄↦η₃)
∙ retEq (fst π₃S³≅π₃*S³) η₄
gen↦1 : (n : ℕ) → fst (fst (π₃'S³≅ℤ-abs n)) ∣ idfun∙ (S₊∙ (suc n)) ∣₂ ≡ 1
gen↦1 = πₙ'Sⁿ≅ℤ-idfun∙
-- We finally prove that η₄ ↦ -2
abstract
η₄↦-2 : fst (fst (π₃'S³≅ℤ-abs 2)) η₄ ≡ -2
η₄↦-2 = speedUp (∣ idfun∙ (S₊∙ 3) ∣₂) (gen↦1 2)
where
speedUp : (x : _)
→ fst (fst (π₃'S³≅ℤ-abs (suc (suc zero)))) x ≡ (pos (suc zero))
→ (fst (fst (π₃'S³≅ℤ-abs 2))) (·π' 2 (-π' 2 x) (-π' 2 x)) ≡ -2
speedUp x p =
IsGroupHom.pres· (π₃'S³≅ℤ-abs 2 .snd)
(-π' 2 x) (-π' 2 x)
∙ cong (λ x → x +Z x)
(IsGroupHom.presinv (π₃'S³≅ℤ-abs 2 .snd) x ∙ cong (inv (ℤGroup .snd)) p)
-- Puting it all together, we get our group iso π₃(S²) ≅ ℤGroup
π₃'S²≅ℤ : GroupEquiv (π'Gr 2 (S₊∙ 2)) ℤGroup
π₃'S²≅ℤ =
compGroupEquiv
π₃S²≅π₃*S²-abs
(compGroupEquiv
π₃*S²≅π₃*joinS¹S¹-abs
(compGroupEquiv
π₃*joinS¹S¹≅π₃*S³-abs
(compGroupEquiv π₃*S³≅π₃*S³-abs
(π₃'S³≅ℤ-abs 2))))
-- ... which takes η to -2
η↦-2 : fst (fst π₃'S²≅ℤ) η ≡ - 2
η↦-2 =
cong (fst (fst (π₃'S³≅ℤ-abs 2)))
(cong (fst π₃*S³≅π₃*S³-abs .fst)
(cong (fst π₃*joinS¹S¹≅π₃*S³-abs .fst)
(cong (fst (fst π₃*S²≅π₃*joinS¹S¹-abs))
η↦η₁-abs
∙ η₁↦η₂-abs)
∙ η₂↦η₃-abs)
∙ η₃↦η₄-abs)
∙ η₄↦-2
-- We combine this with the rest of the main conclusions of chapters
-- 1-3 in Brunerie's thesis
BrunerieGroupEquiv : GroupEquiv (π'Gr 3 (S₊∙ 3)) (ℤGroup/ 2)
BrunerieGroupEquiv =
compGroupEquiv
(compGroupEquiv π₄S³≅π₃coFib-fold∘W∙
(invGroupEquiv
(GroupEquiv-abstractℤ/abs-gen
(π'Gr 2 (S₊∙ 3)) (π'Gr 2 (S₊∙ 2)) (π'Gr 2 coFib-fold∘W∙)
(invGroupEquiv (π₃'S³≅ℤ-abs 2))
(invGroupEquiv π₃'S²≅ℤ)
(π'∘∙Hom 2 (fold∘W , refl))
_
S³→S²→Pushout→Unit 2
(cong abs (cong (invEq (invEquiv (fst π₃'S²≅ℤ))
∘ sMap (_∘∙_ (fold∘W , refl)))
(sym (cong (invEq (fst (π₃'S³≅ℤ-abs 2))) (gen↦1 2))
∙ retEq (fst (π₃'S³≅ℤ-abs 2)) ∣ idfun∙ (S₊∙ 3) ∣₂))
∙ cong abs η↦-2))))
(abstractℤ/≅ℤ 2)
------------- Part 2: proof (partly) by computation -------------
-- Alternative version of the same proof: proving η₃ ↦ -2 by computation
connS² : isConnected 3 S²
connS² = ∣ base ∣
, Trunc.elim (λ _ → isOfHLevelPath 3 (isOfHLevelTrunc 3) _ _)
(S²ToSetElim (λ _ → isOfHLevelTrunc 3 _ _)
refl)
connSuspS² : isConnected 4 (Susp S²)
fst connSuspS² = ∣ north ∣
snd connSuspS² =
Trunc.elim (λ _ → isOfHLevelPath 4 (isOfHLevelTrunc 4) _ _)
λ { north → refl
; south → cong ∣_∣ₕ (merid base)
; (merid a i) → lem a i}
where
lem : (a : S²)
→ PathP (λ i → ∣ north ∣ₕ ≡ ∣ merid a i ∣ₕ)
refl (cong ∣_∣ₕ (merid base))
lem = S²ToSetElim (λ _ → isOfHLevelPathP' 2 (isOfHLevelTrunc 4 _ _) _ _)
λ i j → ∣ merid base (i ∧ j) ∣ₕ
π₃*S³' : Group₀
π₃*S³' = π₃* (Susp∙ S²) (isConnectedSubtr 3 1 connSuspS²)
-- The version of η₃ we have been able to compute lies in π₃*S³'
η₃'-raw : (join S¹ S¹ , inl base) →∙ (Susp S² , north)
fst η₃'-raw (inl x) = north
fst η₃'-raw (inr x) = north
fst η₃'-raw (push a b i) =
(σ (S² , base) (S¹×S¹→S²' a b) ∙ σ (S² , base) (S¹×S¹→S²' a b)) i
snd η₃'-raw = refl
η₃' : π₃*S³' .fst
η₃' = ∣ η₃'-raw ∣₂
-- We first have to show (manually) that the following iso sends η₃ to η₃'
π₃*S³≅π₃*S³' : GroupEquiv π₃*S³ π₃*S³'
π₃*S³≅π₃*S³' = postCompπ₃*Equiv _ _
(isoToEquiv (congSuspIso (invIso S²IsoSuspS¹))
, refl)
π₃*S³≅π₃*S³'-pres-η₃ : fst (fst π₃*S³≅π₃*S³') η₃ ≡ η₃'
π₃*S³≅π₃*S³'-pres-η₃ =
cong ∣_∣₂
(ΣPathP ((funExt (λ { (inl x) → refl
; (inr x) → refl
; (push a b i) j → lem a b j i}))
, sym (rUnit refl)))
where
lem : (a b : S¹)
→ cong (suspFun SuspS¹→S²)
(sym (σ₂ (S¹×S¹→S² a b)) ∙ sym (σ₂ (S¹×S¹→S² a b)))
≡ (σ (S² , base) (S¹×S¹→S²' a b) ∙ σ (S² , base) (S¹×S¹→S²' a b))
lem a b =
cong-∙ (suspFun SuspS¹→S²)
(sym (σ₂ (S¹×S¹→S² a b))) (sym (σ₂ (S¹×S¹→S² a b)))
∙ cong (λ x → x ∙ x)
(cong sym (cong-∙
(suspFun SuspS¹→S²) (merid (S¹×S¹→S² a b)) (sym (merid north)))
∙ cong sym (cong (σ S²∙) (SuspS¹→S²-S¹×S¹→S² a b))
∙ sym (S¹×S¹→S²-sym a b))
-- After this, we want to establish an iso π₃*S³'≅ℤ which is nice enough to compute.
-- This requires a bit of work and some hacking.
-- First iso: π₃*(Susp S²) ≅ π₁(S¹ →∙ Ω(Susp S²))
private
map← : S₊∙ 1 →∙ (S₊∙ 1 →∙ Ω (Susp∙ S²) ∙)
→ (join S¹ S¹ , inl base) →∙ Susp∙ S²
fst (map← f) (inl x) = north
fst (map← f) (inr x) = north
fst (map← f) (push a b i) = fst f a .fst b i
snd (map← f) = refl
map→ : (join S¹ S¹ , inl base) →∙ Susp∙ S²
→ S₊∙ 1 →∙ (S₊∙ 1 →∙ Ω (Susp∙ S²) ∙)
fst (fst (map→ f) x) y =
sym (snd f)
∙∙ cong (fst f)
((push base base ∙ sym (push x base)) ∙∙ push x y ∙∙ sym (push base y))
∙∙ snd f
snd (fst (map→ f) x) =
cong (sym (snd f) ∙∙_∙∙ snd f)
(cong (cong (fst f))
((λ j → (push base base ∙ (λ i → push x base (~ i ∨ j)))
∙∙ (λ i → push x base (i ∨ j)) ∙∙ sym (push base base))
∙ cong (_∙∙ refl ∙∙ sym (push base base)) (sym (rUnit (push base base)))
∙ ∙∙lCancel (sym (push base base))))
∙ ∙∙lCancel (snd f)
snd (map→ f) = coherence _
λ x → cong (sym (snd f) ∙∙_∙∙ snd f)
(cong (cong (fst f))
(cong (_∙∙ push base x ∙∙ sym (push base x))
(rCancel (push base base))
∙ rCancel (push base x)))
∙ ∙∙lCancel (snd f)
where
abstract
coherence : (f : S₊∙ 1 →∙ Ω (Susp∙ S²))
→ ((x : S¹) → fst f x ≡ refl) → f ≡ ((λ _ → refl) , refl)
coherence f p = →∙Homogeneous≡ (isHomogeneousPath _ _) (funExt p)
-- Iso for underlying type
π₃*S³'≅π₁S¹→∙ΩS³'-raw :
Iso (π₃*S³' .fst) ((π'Gr 0 (S₊∙ 1 →∙ Ω (Susp∙ S²) ∙)) .fst)
fun π₃*S³'≅π₁S¹→∙ΩS³'-raw = sMap map→
inv π₃*S³'≅π₁S¹→∙ΩS³'-raw = sMap map←
rightInv π₃*S³'≅π₁S¹→∙ΩS³'-raw =
sElim (λ _ → isSetPathImplicit)
λ f → cong ∣_∣₂
(→∙Homogeneous≡
(subst isHomogeneous
(ua∙ {A = (Ω^ 2) (Susp∙ S²)} {B = (S₊∙ 1 →∙ Ω (Susp∙ S²) ∙)}
(isoToEquiv (IsoΩSphereMap 1))
(ΣPathP ((funExt (λ { base → refl ; (loop i) → refl})) , refl)))
(isHomogeneousPath _ _))
(funExt λ x → →∙Homogeneous≡ (isHomogeneousPath _ _)
(funExt λ y
→ sym (rUnit
((cong (fst (map← f)))
((push base base
∙ sym (push x base)) ∙∙ push x y ∙∙ sym (push base y))))
∙∙ cong-∙∙ (fst (map← f))
(push base base
∙ sym (push x base)) (push x y) (sym (push base y))
∙∙ (λ i → cong-∙ (fst (map← f))
(push base base) (sym (push x base)) i
∙∙ f .fst x .fst y
∙∙ sym (snd f i .fst y))
∙∙ cong (_∙∙ f .fst x .fst y ∙∙ refl)
(cong₂ _∙_ (fst f base .snd) (cong sym (fst f x .snd))
∙ sym (rUnit refl))
∙∙ sym (rUnit (f .fst x .fst y)))))
leftInv π₃*S³'≅π₁S¹→∙ΩS³'-raw =
sElim (λ _ → isSetPathImplicit)
λ f → cong ∣_∣₂ (ΣPathP
((funExt
(λ { (inl x) → sym (snd f)
∙ cong (fst f) (push base base ∙ sym (push x base))
; (inr x) → sym (snd f)
∙ cong (fst f) (push base x)
; (push a b i) j
→ hcomp (λ k → λ {(i = i0) →
compPath-filler' (sym (snd f)) (cong (fst f)
(push base base ∙ sym (push a base))) k j
; (i = i1) →
compPath-filler' (sym (snd f)) (cong (fst f)
(push base b)) k j
; (j = i1) → fst f (push a b i) })
(fst f (doubleCompPath-filler
(push base base ∙ sym (push a base))
(push a b)
(sym (push base b)) (~ j) i))}))
, help f))
where
help : (f : (join S¹ S¹ , inl base) →∙ Susp∙ S²)
→ PathP (λ i → (sym (snd f)
∙ cong (fst f) (push base base ∙ sym (push base base))) i
≡ north)
refl (snd f)
help f =
flipSquare ((cong (sym (snd f) ∙_)
(cong (cong (fst f))
(rCancel (push base base))) ∙ sym (rUnit (sym (snd f))))
◁ λ i j → snd f (i ∨ ~ j))
-- the iso
π₁S¹→∙ΩS³'≅π₃*S³' : GroupIso (π'Gr 0 (S₊∙ 1 →∙ Ω (Susp∙ S²) ∙)) π₃*S³'
fst π₁S¹→∙ΩS³'≅π₃*S³' = invIso π₃*S³'≅π₁S¹→∙ΩS³'-raw
snd π₁S¹→∙ΩS³'≅π₃*S³' =
makeIsGroupHom
(sElim2 (λ _ _ → isSetPathImplicit)
λ f g → cong ∣_∣₂
(ΣPathP ((funExt (λ { (inl x) → refl
; (inr x) → refl
; (push a b i) j → main f g a b j i}))
, refl)))
where
main : (f g : S₊∙ 1 →∙ (S₊∙ 1 →∙ Ω (Susp∙ S²) ∙)) (a b : S¹)
→ cong (fst (map← (∙Π f g))) (push a b)
≡ cong (fst (map← f +join map← g)) (push a b)
main f g a b = (main-lem a b
∙ (λ i → (λ j → fst f a .fst b (j ∧ i))
∙∙ ((λ j → fst f a .fst b (j ∨ i)))
∙∙ fst g a .fst b))
∙ λ i → (rUnit (fst f a .fst b) ∙ cong (fst f a .fst b ∙_)
(cong sym (sym (funExt⁻ (cong fst (snd f)) b)))
∙ sym (cong-∙ (map← f .fst) (push a b) (sym (push base b)))) i
∙∙ rUnit refl i
∙∙ ((lUnit (fst g a .fst b)
∙ (λ i → fst g base .snd (~ i)
∙∙ sym (fst g a .snd (~ i))
∙∙ cong (map← g .fst) (push a b)))
∙ (sym (cong-∙∙ (map← g .fst)
(push base base) (sym (push a base)) (push a b)))) i
where
JLem : ∀ {ℓ} {A : Type ℓ} (* : A)
(fab : * ≡ *) (fabrefl : refl ≡ fab)
(gab : * ≡ *) (gabrefl : refl ≡ gab)
→ (fl : fab ≡ fab) (gl : gab ≡ gab)
→ PathP (λ i → (rUnit refl ∙ (λ i → fabrefl i ∙ gabrefl i)) i
≡ (rUnit refl ∙ (λ i → fabrefl i ∙ gabrefl i)) i)
((fabrefl ∙∙ fl ∙∙ sym fabrefl)
∙ (gabrefl ∙∙ gl ∙∙ sym gabrefl))
(cong₂ _∙_ fl gl)
JLem * =
J> (J> λ fl gl
→ flipSquare (sym (rUnit (rUnit refl))
◁ ((flipSquare (cong₂ _∙_ (sym (rUnit fl)) (sym (rUnit gl))
◁ ((λ i → (cong (λ x → rUnit x i) fl
∙ cong (λ x → lUnit x i) gl))
▷ sym (cong₂Funct _∙_ fl gl))))
▷ rUnit (rUnit refl))))
pp : (b : S¹) → refl ∙ refl ≡ fst (fst f base) b ∙ fst (fst g base) b
pp b i = fst (snd f (~ i)) b ∙ fst (snd g (~ i)) b
main-lem : (a b : S¹)
→ cong (fst (map← (∙Π f g))) (push a b)
≡ (fst f a .fst b ∙ fst g a .fst b)
main-lem base b = rUnit refl ∙ pp b
main-lem (loop i) b j =
hcomp (λ r → λ {(i = i0) → (rUnit refl ∙ pp b) j
; (i = i1) → (rUnit refl ∙ pp b) j
; (j = i0) → lem (~ r) i
; (j = i1) →
(fst f (loop i) .fst b ∙ fst g (loop i) .fst b)})
(JLem north
(fst f base .fst b) (λ i → fst (snd f (~ i)) b)
(fst g base .fst b) (λ i → fst (snd g (~ i)) b)
(λ i → fst f (loop i) .fst b)
(λ i → fst g (loop i) .fst b) j i)
where
lem : cong (λ l → cong (fst (map← (∙Π f g))) (push l b)) loop
≡ ((λ i → fst (snd f (~ i)) b)
∙∙ funExt⁻ (cong fst (cong (f .fst) loop)) b
∙∙ (λ i → fst (snd f i) b))
∙ ((λ i → fst (snd g (~ i)) b)
∙∙ funExt⁻ (cong fst (cong (g .fst) loop)) b
∙∙ (λ i → fst (snd g i) b))
lem =
(λ i → funExt⁻ (cong-∙ fst
(sym (snd f) ∙∙ cong (f .fst) loop ∙∙ snd f)
(sym (snd g) ∙∙ cong (g .fst) loop ∙∙ snd g) i) b)
∙ λ i → funExt⁻
(cong-∙∙ fst (sym (snd f)) (cong (f .fst) loop) (snd f) i
∙ cong-∙∙ fst (sym (snd g)) (cong (g .fst) loop) (snd g) i) b
-- The goal now is to establish a homomorphism from π₁S¹→∙ΩS³' to ℤ.
-- We can then show that 1 is in its image via computation, establishing that it
-- is an iso (since we already know that π₁S¹→∙ΩS³' ≅ ℤ)
-- We first introduce the following base change map defined via pattern
-- matching for better computational behaviour
ΩK₂-basechange : (x : K₂) → Ω (K₂ , x) →∙ Ω (K₂ , ∣ base ∣₄)
ΩK₂-basechange =
2GroupoidTrunc.elim
(λ _ → isOfHLevelΣ 4
(isOfHLevelΠ 4 (λ _ → isOfHLevelPath 4 squash₄ _ _))
λ _ → isOfHLevelPath 4 (isOfHLevelPath 4 squash₄ _ _) _ _)
λ { base → idfun∙ _
; (surf i j) → coherence i j}
where
K₂≃coHomK2 : Iso K₂ (coHomK 2)
K₂≃coHomK2 = compIso 2GroupoidTruncTrunc4Iso (mapCompIso S²IsoSuspS¹)
ΩK₂≡S¹ : Ω (K₂ , ∣ base ∣₄) ≡ S¹∙
ΩK₂≡S¹ = ua∙ (isoToEquiv (compIso (congIso K₂≃coHomK2)
(compIso
(invIso (Iso-Kn-ΩKn+1 1))
(truncIdempotentIso 3 isGroupoidS¹)))) refl
coherence :
SquareP (λ i j → Ω (K₂ , ∣ surf i j ∣₄) →∙ Ω (K₂ , ∣ base ∣₄))
(λ _ → idfun∙ (Ω (K₂ , ∣ base ∣₄)))
(λ _ → idfun∙ (Ω (K₂ , ∣ base ∣₄)))
(λ _ → idfun∙ (Ω (K₂ , ∣ base ∣₄)))
λ _ → idfun∙ (Ω (K₂ , ∣ base ∣₄))
coherence =
toPathP
(isOfHLevelPath' 1 (subst isSet (λ i → ΩK₂≡S¹ (~ i) →∙ Ω (K₂ , ∣ base ∣₄))
(subst isSet
(isoToPath
(equivToIso (Ω→SphereMap 1 {A = Ω (K₂ , ∣ base ∣₄) }
, isEquiv-Ω→SphereMap 1))) (squash₄ _ _ _ _))) _ _ _ _)
-- The three homomorphisms
π₁S¹→∙ΩS³'→π₁S¹→∙K₂ :
GroupHom (π'Gr 0 (S₊∙ 1 →∙ Ω (Susp∙ S²) ∙))
(π'Gr 0 (S₊∙ 1 →∙ (K₂ , ∣ base ∣₄ ) ∙))
π₁S¹→∙ΩS³'→π₁S¹→∙K₂ =
π'∘∙Hom 0 ((λ f → (λ x → f7' (fst f x)) , (cong f7' (snd f))) , refl)
π₁S¹→∙K₂→π₁S¹ :
GroupHom (π'Gr 0 (S₊∙ 1 →∙ (K₂ , ∣ base ∣₄ ) ∙)) (π'Gr 0 (S₊∙ 1))
π₁S¹→∙K₂→π₁S¹ = π'∘∙Hom 0 mainMap∙
where
mainMap : (S¹ → K₂) → S¹
mainMap f =
GroupoidTrunc.rec isGroupoidS¹ (λ x → x)
(encodeTruncS² (ΩK₂-basechange _ .fst (cong f loop)))
mainMap∙ : ((S₊∙ 1 →∙ (K₂ , ∣ base ∣₄) ∙) →∙ S₊∙ 1)
fst mainMap∙ f = mainMap (fst f)
snd mainMap∙ = refl
π₁S¹→ℤ : GroupHom ((π'Gr 0 (S₊∙ 1))) ℤGroup
π₁S¹→ℤ =
compGroupHom
((sMap (λ f → basechange2⁻ _ (cong (fst f) loop)))
, makeIsGroupHom (sElim2 (λ _ _ → isSetPathImplicit)
λ f g i
→ ∣ (basechange2⁻ (snd f (~ i))
(doubleCompPath-filler
(sym (snd f)) (λ i → fst f (loop i)) (snd f) (~ i))
∙ basechange2⁻ (snd g (~ i))
(doubleCompPath-filler
(sym (snd g)) (λ i → fst g (loop i)) (snd g) (~ i))) ∣₂))
(_ , πₙSⁿ≅ℤ 0 .snd)
-- We combine them into one
computer : GroupHom π₃*S³' ℤGroup
computer = compGroupHom
(GroupEquiv→GroupHom (invGroupEquiv (GroupIso→GroupEquiv π₁S¹→∙ΩS³'≅π₃*S³')))
(compGroupHom (compGroupHom π₁S¹→∙ΩS³'→π₁S¹→∙K₂ π₁S¹→∙K₂→π₁S¹) π₁S¹→ℤ)
-- We show that it's an iso by computation: 1 lies in its image
-- It's witnessed by the following element:
1∈π₃*S³' : π₃*S³' .fst
1∈π₃*S³' =
∣ (λ { (inl x) → north
; (inr x) → north
; (push a b i) → σ S²∙ (S¹×S¹→S²' b a) i}) , refl ∣₂
-- By computation, it maps to 1
1∈π₃*S³'↦1 : fst computer 1∈π₃*S³' ≡ 1
1∈π₃*S³'↦1 = refl
-- This implies that computer indeed is an iso
computerIso : GroupEquiv π₃*S³' ℤGroup
fst (fst computerIso) = fst computer
snd (fst computerIso) =
1∈Im→isEquiv π₃*S³'
(compGroupEquiv
(compGroupEquiv
(invGroupEquiv
(GroupIso→GroupEquiv
(πₙ'Sⁿ≅ℤ 2)))
π₃S³≅π₃*S³)
π₃*S³≅π₃*S³')
computer
∣ 1∈π₃*S³' , 1∈π₃*S³'↦1 ∣₁
snd computerIso = snd computer
-- We now verify via computation that η₃' maps to -2
computerIsoη₃ : fst computer η₃' ≡ -2
computerIsoη₃ = refl
-- Putting this together with the info from the beginning of the file, we have an iso
-- π₃S² ≅ π₃*S³' ≅ ℤ, mapping η ↦ η₃' ↦ -2
BrunerieGroupEquiv' : GroupEquiv (π'Gr 3 (S₊∙ 3)) (ℤGroup/ (abs (fst computer η₃')))
BrunerieGroupEquiv' =
compGroupEquiv
(compGroupEquiv
π₄S³≅π₃coFib-fold∘W∙
(invGroupEquiv
(GroupEquiv-abstractℤ/abs-gen
(π'Gr 2 (S₊∙ 3)) (π'Gr 2 (S₊∙ 2)) (π'Gr 2 coFib-fold∘W∙)
(invGroupEquiv (π₃'S³≅ℤ-abs 2))
(invGroupEquiv
(compGroupEquiv
(compGroupEquiv
(compGroupEquiv
π₃S²≅π₃*S²-abs
π₃*S²≅π₃*joinS¹S¹-abs)
π₃*joinS¹S¹≅π₃*S³-abs)
(fst π₃*S³≅ℤ-abs)))
(π'∘∙Hom 2 (fold∘W , refl))
_
S³→S²→Pushout→Unit
_
(cong abs ((cong (m1 ∘ m2 ∘ m3 ∘ m4)
((cong (sMap (_∘∙_ (fold∘W , refl)))
(sym (cong (invEq (fst (π₃'S³≅ℤ-abs 2))) (gen↦1 2))
∙ retEq (fst (π₃'S³≅ℤ-abs 2)) ∣ idfun∙ (S₊∙ 3) ∣₂))
∙ (λ _ → η)))
∙ cong (m1 ∘ m2 ∘ m3) η↦η₁-abs
∙ cong (m1 ∘ m2) η₁↦η₂-abs
∙ cong m1 η₂↦η₃-abs)
∙ cong abs (snd π₃*S³≅ℤ-abs)))))
(abstractℤ/≅ℤ (abs (fst computer η₃')))
where
abstract
η₃-abs : Σ[ x ∈ _ ] x ≡ η₃
η₃-abs = η₃ , refl
η₃-abs-pres : fst π₃*S³≅π₃*S³' .fst (fst η₃-abs) ≡ ∣ η₃'-raw ∣₂
η₃-abs-pres = π₃*S³≅π₃*S³'-pres-η₃
π₃*S³≅ℤ : GroupEquiv π₃*S³ ℤGroup
π₃*S³≅ℤ = compGroupEquiv π₃*S³≅π₃*S³' computerIso
π₃*S³≅ℤβ≡-2 : fst (fst π₃*S³≅ℤ) η₃ ≡ fst computer η₃'
π₃*S³≅ℤβ≡-2 = (cong (fst (fst π₃*S³≅ℤ)) (sym (snd η₃-abs))
∙ cong (fst computer) η₃-abs-pres)
∙ computerIsoη₃
abstract
π₃*S³≅ℤ-abs : Σ[ f ∈ GroupEquiv π₃*S³ ℤGroup ] (fst (fst f) η₃ ≡ fst computer η₃')
π₃*S³≅ℤ-abs = π₃*S³≅ℤ , π₃*S³≅ℤβ≡-2
m1 = fst (fst (fst π₃*S³≅ℤ-abs))
m2 = fst (fst π₃*joinS¹S¹≅π₃*S³-abs)
m3 = fst (fst π₃*S²≅π₃*joinS¹S¹-abs)
m4 = fst (fst π₃S²≅π₃*S²-abs)
-- We hence get the following by computation:
BrunerieGroupEquiv'' : GroupEquiv (π'Gr 3 (S₊∙ 3)) (ℤGroup/ 2)
BrunerieGroupEquiv'' = BrunerieGroupEquiv'
| 37.453782
| 87
| 0.515392
|
8b8c110d66b49564a2e5beb82c088a7dd4b15dee
| 4,184
|
agda
|
Agda
|
cohomology/FlipPushout.agda
|
UlrikBuchholtz/HoTT-Agda
|
f8fa68bf753d64d7f45556ca09d0da7976709afa
|
[
"MIT"
] | 1
|
2021-06-30T00:17:55.000Z
|
2021-06-30T00:17:55.000Z
|
cohomology/FlipPushout.agda
|
UlrikBuchholtz/HoTT-Agda
|
f8fa68bf753d64d7f45556ca09d0da7976709afa
|
[
"MIT"
] | null | null | null |
cohomology/FlipPushout.agda
|
UlrikBuchholtz/HoTT-Agda
|
f8fa68bf753d64d7f45556ca09d0da7976709afa
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --without-K #-}
open import HoTT
open import cohomology.FunctionOver
{- Flipping the pushout diagram (switching left and right) gives the
- same pushout. -}
module cohomology.FlipPushout where
{- Span-flipping functions -}
flip-span : ∀ {i j k} → Span {i} {j} {k} → Span {j} {i} {k}
flip-span (span A B C f g) = span B A C g f
flip-⊙span : ∀ {i j k} → ⊙Span {i} {j} {k} → ⊙Span {j} {i} {k}
flip-⊙span (⊙span X Y Z f g) = ⊙span Y X Z g f
{- Pushout-flipping function -}
module _ {i j k} {d : Span {i} {j} {k}} where
module FlipPushout = PushoutRec
(right {d = flip-span d})
(left {d = flip-span d})
(λ z → ! (glue {d = flip-span d} z))
flip-pushout : Pushout d → Pushout (flip-span d)
flip-pushout = FlipPushout.f
flip-pushout-involutive : ∀ {i j k} (d : Span {i} {j} {k})
(s : Pushout d) → flip-pushout (flip-pushout s) == s
flip-pushout-involutive d = Pushout-elim
(λ a → idp)
(λ b → idp)
(λ c → ↓-∘=idf-in flip-pushout flip-pushout $
ap flip-pushout (ap flip-pushout (glue c))
=⟨ ap (ap flip-pushout) (FlipPushout.glue-β c) ⟩
ap flip-pushout (! (glue c))
=⟨ ap-! flip-pushout (glue c) ⟩
! (ap flip-pushout (glue c))
=⟨ ap ! (FlipPushout.glue-β c) ⟩
! (! (glue c))
=⟨ !-! (glue c) ⟩
glue c ∎)
{- Equivalence for spans with proofs that the equivalence swaps the
- injections -}
module _ {i j k} (d : Span {i} {j} {k}) where
open Span d
flip-pushout-equiv : Pushout d ≃ Pushout (flip-span d)
flip-pushout-equiv =
equiv flip-pushout flip-pushout
(flip-pushout-involutive (flip-span d))
(flip-pushout-involutive d)
flip-pushout-path : Pushout d == Pushout (flip-span d)
flip-pushout-path = ua flip-pushout-equiv
flip-left : left == right [ (λ D → (A → D)) ↓ flip-pushout-path ]
flip-left = codomain-over-equiv _ _
flip-right : right == left [ (λ D → (B → D)) ↓ flip-pushout-path ]
flip-right = codomain-over-equiv _ _
{- Path for pointed spans with proofs that the path swaps the pointed
- injections -}
module _ {i j k} (ps : ⊙Span {i} {j} {k}) where
open ⊙Span ps
private
s = ⊙span-out ps
preserves : –> (flip-pushout-equiv s) (left (snd X)) == left (snd Y)
preserves = snd (⊙right (flip-⊙span ps))
flip-⊙pushout : fst (⊙Pushout ps ⊙→ ⊙Pushout (flip-⊙span ps))
flip-⊙pushout = (FlipPushout.f , preserves)
flip-⊙pushout-path : ⊙Pushout ps == ⊙Pushout (flip-⊙span ps)
flip-⊙pushout-path = ⊙ua (⊙ify-eq (flip-pushout-equiv s) preserves)
{- action of [flip-pushout] on [snd ⊙right] -}
ap-flip-right : ap flip-pushout (snd (⊙right ps))
== ! (snd (⊙right (flip-⊙span ps)))
ap-flip-right = lemma f g
where
lemma : {X : Ptd i} {Y : Ptd j} {Z : Ptd k}
(f : fst (Z ⊙→ X)) (g : fst (Z ⊙→ Y))
→ ap (flip-pushout {d = ⊙span-out (⊙span X Y Z f g)})
(ap right (! (snd g)) ∙ ! (glue (snd Z)) ∙' ap left (snd f))
== ! (ap right (! (snd f)) ∙ ! (glue (snd Z)) ∙' ap left (snd g))
lemma {Z = Z} (f , idp) (g , idp) =
ap flip-pushout (! (glue (snd Z)))
=⟨ ap-! flip-pushout (glue (snd Z)) ⟩
! (ap flip-pushout (glue (snd Z)))
=⟨ FlipPushout.glue-β (snd Z) |in-ctx ! ⟩
! (! (glue (snd Z))) ∎
flip-⊙left : ⊙left ps == ⊙right (flip-⊙span ps)
[ (λ W → fst (X ⊙→ W)) ↓ flip-⊙pushout-path ]
flip-⊙left = codomain-over-⊙equiv _ _
flip-⊙right : ⊙right ps == ⊙left (flip-⊙span ps)
[ (λ W → fst (Y ⊙→ W)) ↓ flip-⊙pushout-path ]
flip-⊙right =
codomain-over-⊙equiv _ _
▹ pair= idp (ap (λ w → w ∙ preserves) ap-flip-right ∙ !-inv-l preserves)
flip-⊙pushout-involutive : ∀ {i j k} (ps : ⊙Span {i} {j} {k})
→ flip-⊙pushout (flip-⊙span ps) ⊙∘ flip-⊙pushout ps == ⊙idf _
flip-⊙pushout-involutive ps =
⊙λ= (flip-pushout-involutive _) lemma
where
lemma :
ap flip-pushout (snd (⊙right (flip-⊙span ps))) ∙ snd (⊙right ps)
== idp
lemma =
ap flip-pushout (snd (⊙right (flip-⊙span ps))) ∙ snd (⊙right ps)
=⟨ ap-flip-right (flip-⊙span ps)
|in-ctx (λ w → w ∙ snd (⊙right ps)) ⟩
! (snd (⊙right ps)) ∙ snd (⊙right ps)
=⟨ !-inv-l (snd (⊙right ps)) ⟩
idp
| 33.206349
| 76
| 0.564054
|
8b76003155c6355617a2a047262424f9c30e1756
| 52
|
agda
|
Agda
|
agda.agda
|
5R33CH4/lango
|
3227a8a458fc7fd3618106ad054f7f3be62d0513
|
[
"Unlicense"
] | 2
|
2021-10-02T05:34:09.000Z
|
2021-10-03T09:18:09.000Z
|
agda.agda
|
5R33CH4/lango
|
3227a8a458fc7fd3618106ad054f7f3be62d0513
|
[
"Unlicense"
] | 4
|
2021-10-02T01:30:09.000Z
|
2021-10-02T05:38:00.000Z
|
agda.agda
|
5R33CH4/lango
|
3227a8a458fc7fd3618106ad054f7f3be62d0513
|
[
"Unlicense"
] | 7
|
2021-10-01T15:13:01.000Z
|
2021-10-02T05:07:45.000Z
|
open import IO
main = run (putStr "Hacktoberfest")
| 13
| 35
| 0.730769
|
9a135e289e3121a139ea0af1f5b3920067a1bc4c
| 4,265
|
agda
|
Agda
|
Cubical/Data/Sum/Properties.agda
|
L-TChen/cubical
|
60226aacd7b386aef95d43a0c29c4eec996348a8
|
[
"MIT"
] | null | null | null |
Cubical/Data/Sum/Properties.agda
|
L-TChen/cubical
|
60226aacd7b386aef95d43a0c29c4eec996348a8
|
[
"MIT"
] | 1
|
2022-01-27T02:07:48.000Z
|
2022-01-27T02:07:48.000Z
|
Cubical/Data/Sum/Properties.agda
|
L-TChen/cubical
|
60226aacd7b386aef95d43a0c29c4eec996348a8
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --cubical --no-import-sorts --safe #-}
module Cubical.Data.Sum.Properties where
open import Cubical.Core.Everything
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.HLevels
open import Cubical.Functions.Embedding
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.Isomorphism
open import Cubical.Data.Empty
open import Cubical.Data.Nat
open import Cubical.Data.Sum.Base
-- Path space of sum type
module SumPath {ℓ ℓ'} {A : Type ℓ} {B : Type ℓ'} where
Cover : A ⊎ B → A ⊎ B → Type (ℓ-max ℓ ℓ')
Cover (inl a) (inl a') = Lift {j = ℓ-max ℓ ℓ'} (a ≡ a')
Cover (inl _) (inr _) = Lift ⊥
Cover (inr _) (inl _) = Lift ⊥
Cover (inr b) (inr b') = Lift {j = ℓ-max ℓ ℓ'} (b ≡ b')
reflCode : (c : A ⊎ B) → Cover c c
reflCode (inl a) = lift refl
reflCode (inr b) = lift refl
encode : ∀ c c' → c ≡ c' → Cover c c'
encode c _ = J (λ c' _ → Cover c c') (reflCode c)
encodeRefl : ∀ c → encode c c refl ≡ reflCode c
encodeRefl c = JRefl (λ c' _ → Cover c c') (reflCode c)
decode : ∀ c c' → Cover c c' → c ≡ c'
decode (inl a) (inl a') (lift p) = cong inl p
decode (inl a) (inr b') ()
decode (inr b) (inl a') ()
decode (inr b) (inr b') (lift q) = cong inr q
decodeRefl : ∀ c → decode c c (reflCode c) ≡ refl
decodeRefl (inl a) = refl
decodeRefl (inr b) = refl
decodeEncode : ∀ c c' → (p : c ≡ c') → decode c c' (encode c c' p) ≡ p
decodeEncode c _ =
J (λ c' p → decode c c' (encode c c' p) ≡ p)
(cong (decode c c) (encodeRefl c) ∙ decodeRefl c)
encodeDecode : ∀ c c' → (d : Cover c c') → encode c c' (decode c c' d) ≡ d
encodeDecode (inl a) (inl _) (lift d) =
J (λ a' p → encode (inl a) (inl a') (cong inl p) ≡ lift p) (encodeRefl (inl a)) d
encodeDecode (inr a) (inr _) (lift d) =
J (λ a' p → encode (inr a) (inr a') (cong inr p) ≡ lift p) (encodeRefl (inr a)) d
Cover≃Path : ∀ c c' → Cover c c' ≃ (c ≡ c')
Cover≃Path c c' =
isoToEquiv (iso (decode c c') (encode c c') (decodeEncode c c') (encodeDecode c c'))
isOfHLevelCover : (n : HLevel)
→ isOfHLevel (suc (suc n)) A
→ isOfHLevel (suc (suc n)) B
→ ∀ c c' → isOfHLevel (suc n) (Cover c c')
isOfHLevelCover n p q (inl a) (inl a') = isOfHLevelLift (suc n) (p a a')
isOfHLevelCover n p q (inl a) (inr b') =
isOfHLevelLift (suc n) (isProp→isOfHLevelSuc n isProp⊥)
isOfHLevelCover n p q (inr b) (inl a') =
isOfHLevelLift (suc n) (isProp→isOfHLevelSuc n isProp⊥)
isOfHLevelCover n p q (inr b) (inr b') = isOfHLevelLift (suc n) (q b b')
isEmbedding-inl : ∀ {ℓ ℓ'} {A : Type ℓ} {B : Type ℓ'} → isEmbedding (inl {A = A} {B = B})
isEmbedding-inl w z = snd (compEquiv LiftEquiv (SumPath.Cover≃Path (inl w) (inl z)))
isEmbedding-inr : ∀ {ℓ ℓ'} {A : Type ℓ} {B : Type ℓ'} → isEmbedding (inr {A = A} {B = B})
isEmbedding-inr w z = snd (compEquiv LiftEquiv (SumPath.Cover≃Path (inr w) (inr z)))
isOfHLevelSum : ∀ {ℓ ℓ'} (n : HLevel) {A : Type ℓ} {B : Type ℓ'}
→ isOfHLevel (suc (suc n)) A
→ isOfHLevel (suc (suc n)) B
→ isOfHLevel (suc (suc n)) (A ⊎ B)
isOfHLevelSum n lA lB c c' =
isOfHLevelRetract (suc n)
(SumPath.encode c c')
(SumPath.decode c c')
(SumPath.decodeEncode c c')
(SumPath.isOfHLevelCover n lA lB c c')
isSetSum : ∀ {ℓ ℓ'} {A : Type ℓ} {B : Type ℓ'} → isSet A → isSet B → isSet (A ⊎ B)
isSetSum = isOfHLevelSum 0
isGroupoidSum : ∀ {ℓ ℓ'} {A : Type ℓ} {B : Type ℓ'} → isGroupoid A → isGroupoid B → isGroupoid (A ⊎ B)
isGroupoidSum = isOfHLevelSum 1
is2GroupoidSum : ∀ {ℓ ℓ'} {A : Type ℓ} {B : Type ℓ'} → is2Groupoid A → is2Groupoid B → is2Groupoid (A ⊎ B)
is2GroupoidSum = isOfHLevelSum 2
sumIso : ∀ {ℓa ℓb ℓc ℓd} {A : Type ℓa} {B : Type ℓb} {C : Type ℓc} {D : Type ℓd}
→ Iso A C → Iso B D
→ Iso (A ⊎ B) (C ⊎ D)
Iso.fun (sumIso iac ibd) (inl x) = inl (iac .Iso.fun x)
Iso.fun (sumIso iac ibd) (inr x) = inr (ibd .Iso.fun x)
Iso.inv (sumIso iac ibd) (inl x) = inl (iac .Iso.inv x)
Iso.inv (sumIso iac ibd) (inr x) = inr (ibd .Iso.inv x)
Iso.rightInv (sumIso iac ibd) (inl x) = cong inl (iac .Iso.rightInv x)
Iso.rightInv (sumIso iac ibd) (inr x) = cong inr (ibd .Iso.rightInv x)
Iso.leftInv (sumIso iac ibd) (inl x) = cong inl (iac .Iso.leftInv x)
Iso.leftInv (sumIso iac ibd) (inr x) = cong inr (ibd .Iso.leftInv x)
| 39.859813
| 106
| 0.607972
|
2feb1f981ef075ed5b2c66e1908628076c4871d6
| 51
|
agda
|
Agda
|
extra/extra/Rec1.agda
|
krzygorz/plfa.github.io
|
10a3203624f2ea937b3892176db5de825d0c46b4
|
[
"CC-BY-4.0"
] | 1,003
|
2018-07-05T18:15:14.000Z
|
2022-03-27T07:03:28.000Z
|
extra/extra/Rec1.agda
|
krzygorz/plfa.github.io
|
10a3203624f2ea937b3892176db5de825d0c46b4
|
[
"CC-BY-4.0"
] | 323
|
2018-07-05T22:34:34.000Z
|
2022-03-30T07:42:57.000Z
|
extra/extra/Rec1.agda
|
krzygorz/plfa.github.io
|
10a3203624f2ea937b3892176db5de825d0c46b4
|
[
"CC-BY-4.0"
] | 304
|
2018-07-16T18:24:59.000Z
|
2022-03-28T11:35:02.000Z
|
module Rec1 where
import Rec2
y : ℕ
y = x
| 6.375
| 17
| 0.568627
|
1acfcf0137a9cd61f7ff9dcadcd0a354818b0141
| 337
|
agda
|
Agda
|
test/Succeed/Issue418private.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 3
|
2015-03-28T14:51:03.000Z
|
2015-12-07T20:14:00.000Z
|
test/Succeed/Issue418private.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 3
|
2018-11-14T15:31:44.000Z
|
2019-04-01T19:39:26.000Z
|
test/Succeed/Issue418private.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1
|
2019-03-05T20:02:38.000Z
|
2019-03-05T20:02:38.000Z
|
-- Andreas, 2016-07-19 revisiting issue #418
module Issue418private where
open import Common.Equality
abstract
A : Set₁
A = Set
private
works : A ≡ A
works = refl
test : A ≡ _
test = refl
-- Since test is private, abstract definitions are transparent in its type.
-- The meta should be solved (by A or Set).
| 16.047619
| 75
| 0.670623
|
194925b0dc7de5d6f8d7b4a6c6e23e68f20373e0
| 12,824
|
agda
|
Agda
|
src/Categories/Adjoint/Equivalence.agda
|
MirceaS/agda-categories
|
58e5ec015781be5413bdf968f7ec4fdae0ab4b21
|
[
"MIT"
] | null | null | null |
src/Categories/Adjoint/Equivalence.agda
|
MirceaS/agda-categories
|
58e5ec015781be5413bdf968f7ec4fdae0ab4b21
|
[
"MIT"
] | null | null | null |
src/Categories/Adjoint/Equivalence.agda
|
MirceaS/agda-categories
|
58e5ec015781be5413bdf968f7ec4fdae0ab4b21
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --without-K --safe #-}
module Categories.Adjoint.Equivalence where
open import Level
open import Categories.Adjoint
open import Categories.Category
open import Categories.Functor renaming (id to idF)
open import Categories.Functor.Properties
open import Categories.NaturalTransformation using (ntHelper)
open import Categories.NaturalTransformation.NaturalIsomorphism as ≃ using (_≃_; NaturalIsomorphism)
open import Categories.NaturalTransformation.NaturalIsomorphism.Properties
import Categories.Morphism.Reasoning as MR
open import Relation.Binary using (Setoid; IsEquivalence)
private
variable
o ℓ e : Level
o′ ℓ′ e′ : Level
C D E : Category o ℓ e
infix 5 _⊣⊢_
record _⊣⊢_ (L : Functor C D) (R : Functor D C) : Set (levelOfTerm L ⊔ levelOfTerm R) where
field
unit : idF ≃ (R ∘F L)
counit : (L ∘F R) ≃ idF
module unit = NaturalIsomorphism unit
module counit = NaturalIsomorphism counit
private
module C = Category C
module D = Category D
module L = Functor L
module R = Functor R
field
zig : ∀ {A : C.Obj} → counit.⇒.η (L.₀ A) D.∘ L.₁ (unit.⇒.η A) D.≈ D.id
zag : ∀ {B : D.Obj} → R.₁ (counit.⇒.η B) C.∘ unit.⇒.η (R.₀ B) C.≈ C.id
op₁ : R.op ⊣⊢ L.op
op₁ = record
{ unit = counit.op
; counit = unit.op
; zig = zag
; zag = zig
}
zag⁻¹ : {B : D.Obj} → unit.⇐.η (R.F₀ B) C.∘ R.F₁ (counit.⇐.η B) C.≈ C.id
zag⁻¹ {B} = begin
unit.⇐.η (R.₀ B) C.∘ R.₁ (counit.⇐.η B) ≈˘⟨ flip-fromʳ unit.FX≅GX zag ⟩∘⟨refl ⟩
R.₁ (counit.⇒.η B) C.∘ R.₁ (counit.⇐.η B) ≈⟨ [ R ]-resp-∘ (counit.iso.isoʳ B) ⟩
R.₁ D.id ≈⟨ R.identity ⟩
C.id ∎
where open C.HomReasoning
open MR C
zig⁻¹ : {A : C.Obj} → L.F₁ (unit.⇐.η A) D.∘ counit.⇐.η (L.F₀ A) D.≈ D.id
zig⁻¹ {A} = begin
L.₁ (unit.⇐.η A) D.∘ counit.⇐.η (L.₀ A) ≈˘⟨ refl⟩∘⟨ flip-fromˡ counit.FX≅GX zig ⟩
L.₁ (unit.⇐.η A) D.∘ L.₁ (unit.⇒.η A) ≈⟨ [ L ]-resp-∘ (unit.iso.isoˡ A) ⟩
L.₁ C.id ≈⟨ L.identity ⟩
D.id ∎
where open D.HomReasoning
open MR D
op₂ : R ⊣⊢ L
op₂ = record
{ unit = ≃.sym counit
; counit = ≃.sym unit
; zig = zag⁻¹
; zag = zig⁻¹
}
L⊣R : L ⊣ R
L⊣R = record
{ unit = unit.F⇒G
; counit = counit.F⇒G
; zig = zig
; zag = zag
}
module L⊣R = Adjoint L⊣R
open L⊣R hiding (unit; counit; zig; zag; op) public
R⊣L : R ⊣ L
R⊣L = record
{ unit = counit.F⇐G
; counit = unit.F⇐G
; zig = zag⁻¹
; zag = zig⁻¹
}
module R⊣L = Adjoint R⊣L
private
record WithZig (L : Functor C D) (R : Functor D C) : Set (levelOfTerm L ⊔ levelOfTerm R) where
field
unit : idF ≃ (R ∘F L)
counit : (L ∘F R) ≃ idF
module unit = NaturalIsomorphism unit
module counit = NaturalIsomorphism counit
private
module C = Category C
module D = Category D
module L = Functor L
module R = Functor R
module ℱ = Functor
field
zig : ∀ {A : C.Obj} → counit.⇒.η (L.₀ A) D.∘ L.₁ (unit.⇒.η A) D.≈ D.id
zag : ∀ {B : D.Obj} → R.₁ (counit.⇒.η B) C.∘ unit.⇒.η (R.₀ B) C.≈ C.id
zag {B} = F≃id⇒id (≃.sym unit) helper
where open C
open HomReasoning
helper : R.₁ (L.₁ (R.₁ (counit.⇒.η B) ∘ unit.⇒.η (R.₀ B))) ≈ id
helper = begin
R.₁ (L.₁ (R.₁ (counit.⇒.η B) ∘ unit.⇒.η (R.₀ B))) ≈⟨ ℱ.homomorphism (R ∘F L) ⟩
R.₁ (L.₁ (R.₁ (counit.⇒.η B))) ∘ R.₁ (L.₁ (unit.⇒.η (R.₀ B))) ≈˘⟨ R.F-resp-≈ (F≃id-comm₁ counit) ⟩∘⟨refl ⟩
R.₁ (counit.⇒.η (L.₀ (R.₀ B))) ∘ R.₁ (L.₁ (unit.⇒.η (R.₀ B))) ≈⟨ [ R ]-resp-∘ zig ⟩
R.₁ D.id ≈⟨ R.identity ⟩
id ∎
record WithZag (L : Functor C D) (R : Functor D C) : Set (levelOfTerm L ⊔ levelOfTerm R) where
field
unit : idF ≃ (R ∘F L)
counit : (L ∘F R) ≃ idF
module unit = NaturalIsomorphism unit
module counit = NaturalIsomorphism counit
private
module C = Category C
module D = Category D
module L = Functor L
module R = Functor R
module ℱ = Functor
field
zag : ∀ {B : D.Obj} → R.₁ (counit.⇒.η B) C.∘ unit.⇒.η (R.₀ B) C.≈ C.id
zig : ∀ {A : C.Obj} → counit.⇒.η (L.₀ A) D.∘ L.₁ (unit.⇒.η A) D.≈ D.id
zig {A} = F≃id⇒id counit helper
where open D
open HomReasoning
helper : L.₁ (R.₁ (counit.⇒.η (L.₀ A) ∘ L.₁ (unit.⇒.η A))) ≈ id
helper = begin
L.₁ (R.₁ (counit.⇒.η (L.₀ A) ∘ L.₁ (unit.⇒.η A))) ≈⟨ ℱ.homomorphism (L ∘F R) ⟩
(L.₁ (R.₁ (counit.⇒.η (L.₀ A))) ∘ L.₁ (R.₁ (L.₁ (unit.⇒.η A)))) ≈˘⟨ refl⟩∘⟨ L.F-resp-≈ (F≃id-comm₂ (≃.sym unit)) ⟩
L.₁ (R.₁ (counit.⇒.η (L.₀ A))) ∘ L.₁ (unit.⇒.η (R.₀ (L.₀ A))) ≈⟨ [ L ]-resp-∘ zag ⟩
L.₁ C.id ≈⟨ L.identity ⟩
id ∎
module _ {L : Functor C D} {R : Functor D C} where
withZig : WithZig L R → L ⊣⊢ R
withZig LR = record
{ unit = unit
; counit = counit
; zig = zig
; zag = zag
}
where open WithZig LR
withZag : WithZag L R → L ⊣⊢ R
withZag LR = record
{ unit = unit
; counit = counit
; zig = zig
; zag = zag
}
where open WithZag LR
id⊣⊢id : idF {C = C} ⊣⊢ idF
id⊣⊢id {C = C} = record
{ unit = ≃.sym ≃.unitor²
; counit = ≃.unitor²
; zig = identity²
; zag = identity²
}
where open Category C
module _ {L : Functor C D} {R : Functor D C} {L′ : Functor D E} {R′ : Functor E D}
(L⊣⊢R : L ⊣⊢ R) (L′⊣⊢R′ : L′ ⊣⊢ R′) where
private
module C = Category C
module D = Category D
module E = Category E
module L = Functor L
module R = Functor R
module L′ = Functor L′
module R′ = Functor R′
module ⊣⊢₁ = _⊣⊢_ L⊣⊢R
module ⊣⊢₂ = _⊣⊢_ L′⊣⊢R′
unit : idF ≃ (R ∘F R′) ∘F L′ ∘F L
unit = record
{ F⇒G = ntHelper record
{ η = λ c → R.₁ (⊣⊢₂.unit.⇒.η (L.₀ c)) ∘ ⊣⊢₁.unit.⇒.η c
; commute = λ {x} {y} f → begin
(R.₁ (⊣⊢₂.unit.⇒.η (L.₀ y)) ∘ ⊣⊢₁.unit.⇒.η y) ∘ f
≈⟨ pullʳ (⊣⊢₁.unit.⇒.commute f) ⟩
R.₁ (⊣⊢₂.unit.⇒.η (L.₀ y)) ∘ R.₁ (L.₁ f) ∘ ⊣⊢₁.unit.⇒.η x
≈⟨ pullˡ ([ R ]-resp-square (⊣⊢₂.unit.⇒.commute (L.₁ f))) ⟩
(R.₁ (R′.₁ (L′.₁ (L.₁ f))) ∘ R.₁ (⊣⊢₂.unit.⇒.η (L.₀ x))) ∘ ⊣⊢₁.unit.⇒.η x
≈⟨ assoc ⟩
R.₁ (R′.₁ (L′.₁ (L.₁ f))) ∘ R.₁ (⊣⊢₂.unit.⇒.η (L.₀ x)) ∘ ⊣⊢₁.unit.⇒.η x
∎
}
; F⇐G = ntHelper record
{ η = λ c → ⊣⊢₁.unit.⇐.η c ∘ R.₁ (⊣⊢₂.unit.⇐.η (L.₀ c))
; commute = λ {x} {y} f → begin
(⊣⊢₁.unit.⇐.η y ∘ R.₁ (⊣⊢₂.unit.⇐.η (L.₀ y))) ∘ R.₁ (R′.₁ (L′.₁ (L.₁ f)))
≈⟨ pullʳ ([ R ]-resp-square (⊣⊢₂.unit.⇐.commute (L.₁ f))) ⟩
⊣⊢₁.unit.⇐.η y ∘ R.₁ (L.₁ f) ∘ R.₁ (⊣⊢₂.unit.⇐.η (L.₀ x))
≈⟨ pullˡ (⊣⊢₁.unit.⇐.commute f) ⟩
(f ∘ ⊣⊢₁.unit.⇐.η x) ∘ R.₁ (⊣⊢₂.unit.⇐.η (L.₀ x))
≈⟨ assoc ⟩
f ∘ ⊣⊢₁.unit.⇐.η x ∘ R.₁ (⊣⊢₂.unit.⇐.η (L.₀ x))
∎
}
; iso = λ c → record
{ isoˡ = begin
(⊣⊢₁.unit.⇐.η c ∘ R.₁ (⊣⊢₂.unit.⇐.η (L.₀ c))) ∘ R.₁ (⊣⊢₂.unit.⇒.η (L.₀ c)) ∘ ⊣⊢₁.unit.⇒.η c
≈⟨ center ([ R ]-resp-∘ (⊣⊢₂.unit.iso.isoˡ (L.₀ c))) ⟩
⊣⊢₁.unit.⇐.η c ∘ R.₁ D.id ∘ ⊣⊢₁.unit.⇒.η c
≈⟨ refl⟩∘⟨ elimˡ R.identity ⟩
⊣⊢₁.unit.⇐.η c ∘ ⊣⊢₁.unit.⇒.η c
≈⟨ ⊣⊢₁.unit.iso.isoˡ c ⟩
id
∎
; isoʳ = begin
(R.₁ (⊣⊢₂.unit.⇒.η (L.₀ c)) ∘ ⊣⊢₁.unit.⇒.η c) ∘ ⊣⊢₁.unit.⇐.η c ∘ R.₁ (⊣⊢₂.unit.⇐.η (L.₀ c))
≈⟨ center (⊣⊢₁.unit.iso.isoʳ c) ⟩
R.₁ (⊣⊢₂.unit.⇒.η (L.₀ c)) ∘ id ∘ R.₁ (⊣⊢₂.unit.⇐.η (L.₀ c))
≈⟨ refl⟩∘⟨ identityˡ ⟩
R.₁ (⊣⊢₂.unit.⇒.η (L.₀ c)) ∘ R.₁ (⊣⊢₂.unit.⇐.η (L.₀ c))
≈⟨ [ R ]-resp-∘ (⊣⊢₂.unit.iso.isoʳ (L.₀ c)) ⟩
R.₁ D.id
≈⟨ R.identity ⟩
id
∎
}
}
where open C
open HomReasoning
open MR C
module unit = NaturalIsomorphism unit
counit : (L′ ∘F L) ∘F R ∘F R′ ≃ idF
counit = record
{ F⇒G = ntHelper record
{ η = λ e → ⊣⊢₂.counit.⇒.η e ∘ L′.₁ (⊣⊢₁.counit.⇒.η (R′.₀ e))
; commute = λ {x} {y} f → begin
(⊣⊢₂.counit.⇒.η y ∘ L′.₁ (⊣⊢₁.counit.⇒.η (R′.₀ y))) ∘ L′.₁ (L.₁ (R.₁ (R′.₁ f)))
≈⟨ pullʳ ([ L′ ]-resp-square (⊣⊢₁.counit.⇒.commute (R′.₁ f))) ⟩
⊣⊢₂.counit.⇒.η y ∘ L′.₁ (R′.₁ f) ∘ L′.₁ (⊣⊢₁.counit.⇒.η (R′.₀ x))
≈⟨ pullˡ (⊣⊢₂.counit.⇒.commute f) ⟩
(f ∘ ⊣⊢₂.counit.⇒.η x) ∘ L′.₁ (⊣⊢₁.counit.⇒.η (R′.₀ x))
≈⟨ assoc ⟩
f ∘ ⊣⊢₂.counit.⇒.η x ∘ L′.₁ (⊣⊢₁.counit.⇒.η (R′.₀ x))
∎
}
; F⇐G = ntHelper record
{ η = λ e → L′.₁ (⊣⊢₁.counit.⇐.η (R′.₀ e)) ∘ ⊣⊢₂.counit.⇐.η e
; commute = λ {x} {y} f → begin
(L′.₁ (⊣⊢₁.counit.⇐.η (R′.₀ y)) ∘ ⊣⊢₂.counit.⇐.η y) ∘ f
≈⟨ pullʳ (⊣⊢₂.counit.⇐.commute f) ⟩
L′.₁ (⊣⊢₁.counit.⇐.η (R′.₀ y)) ∘ L′.₁ (R′.₁ f) ∘ ⊣⊢₂.counit.⇐.η x
≈⟨ pullˡ ([ L′ ]-resp-square (⊣⊢₁.counit.⇐.commute (R′.₁ f))) ⟩
(L′.₁ (L.₁ (R.₁ (R′.₁ f))) ∘ L′.₁ (⊣⊢₁.counit.⇐.η (R′.₀ x))) ∘ ⊣⊢₂.counit.⇐.η x
≈⟨ assoc ⟩
L′.₁ (L.₁ (R.₁ (R′.₁ f))) ∘ L′.₁ (⊣⊢₁.counit.⇐.η (R′.₀ x)) ∘ ⊣⊢₂.counit.⇐.η x
∎
}
; iso = λ e → record
{ isoˡ = begin
(L′.₁ (⊣⊢₁.counit.⇐.η (R′.₀ e)) ∘ ⊣⊢₂.counit.⇐.η e) ∘ ⊣⊢₂.counit.⇒.η e ∘ L′.₁ (⊣⊢₁.counit.⇒.η (R′.₀ e))
≈⟨ center (⊣⊢₂.counit.iso.isoˡ e) ⟩
L′.₁ (⊣⊢₁.counit.⇐.η (R′.₀ e)) ∘ id ∘ L′.₁ (⊣⊢₁.counit.⇒.η (R′.₀ e))
≈⟨ refl⟩∘⟨ identityˡ ⟩
L′.₁ (⊣⊢₁.counit.⇐.η (R′.₀ e)) ∘ L′.₁ (⊣⊢₁.counit.⇒.η (R′.₀ e))
≈⟨ [ L′ ]-resp-∘ (⊣⊢₁.counit.iso.isoˡ (R′.₀ e)) ⟩
L′.₁ D.id
≈⟨ L′.identity ⟩
id
∎
; isoʳ = begin
(⊣⊢₂.counit.⇒.η e ∘ L′.₁ (⊣⊢₁.counit.⇒.η (R′.₀ e))) ∘ L′.₁ (⊣⊢₁.counit.⇐.η (R′.₀ e)) ∘ ⊣⊢₂.counit.⇐.η e
≈⟨ center ([ L′ ]-resp-∘ (⊣⊢₁.counit.iso.isoʳ (R′.₀ e))) ⟩
⊣⊢₂.counit.⇒.η e ∘ L′.₁ D.id ∘ ⊣⊢₂.counit.⇐.η e
≈⟨ refl⟩∘⟨ elimˡ L′.identity ⟩
⊣⊢₂.counit.⇒.η e ∘ ⊣⊢₂.counit.⇐.η e
≈⟨ ⊣⊢₂.counit.iso.isoʳ e ⟩
id
∎
}
}
where open E
open HomReasoning
open MR E
module counit = NaturalIsomorphism counit
zig : ∀ {c} → counit.⇒.η (L′.₀ (L.₀ c)) E.∘ L′.₁ (L.₁ (unit.⇒.η c)) E.≈ E.id
zig {c} = begin
counit.⇒.η (L′.₀ (L.₀ c)) ∘ L′.₁ (L.₁ (unit.⇒.η c))
≈⟨ refl⟩∘⟨ Functor.homomorphism (L′ ∘F L) ⟩
counit.⇒.η (L′.₀ (L.₀ c)) ∘ L′.₁ (L.₁ (R.₁ (⊣⊢₂.unit.⇒.η (L.₀ c)))) ∘ L′.₁ (L.₁ (⊣⊢₁.unit.⇒.η c))
≈⟨ center ([ L′ ]-resp-square (⊣⊢₁.counit.⇒.commute (⊣⊢₂.unit.⇒.η (L.₀ c)))) ⟩
⊣⊢₂.counit.⇒.η (L′.₀ (L.₀ c)) ∘ (L′.₁ (⊣⊢₂.unit.⇒.η (L.₀ c)) ∘ L′.₁ (⊣⊢₁.counit.⇒.η (L.₀ c))) ∘ L′.₁ (L.₁ (⊣⊢₁.unit.⇒.η c))
≈⟨ pull-first ⊣⊢₂.zig ⟩
id ∘ L′.₁ (⊣⊢₁.counit.⇒.η (L.₀ c)) ∘ L′.₁ (L.₁ (⊣⊢₁.unit.⇒.η c))
≈⟨ elimʳ (([ L′ ]-resp-∘ ⊣⊢₁.zig) ○ L′.identity) ⟩
id
∎
where open E
open HomReasoning
open MR E
_∘⊣⊢_ : (L′ ∘F L) ⊣⊢ (R ∘F R′)
_∘⊣⊢_ = withZig record
{ unit = unit
; counit = counit
; zig = zig
}
record ⊣Equivalence (C : Category o ℓ e) (D : Category o′ ℓ′ e′) : Set (o ⊔ ℓ ⊔ e ⊔ o′ ⊔ ℓ′ ⊔ e′) where
field
L : Functor C D
R : Functor D C
L⊣⊢R : L ⊣⊢ R
module L = Functor L
module R = Functor R
module L⊣⊢R = _⊣⊢_ L⊣⊢R
open L⊣⊢R public
refl : ⊣Equivalence C C
refl = record
{ L = idF
; R = idF
; L⊣⊢R = id⊣⊢id
}
sym : ⊣Equivalence C D → ⊣Equivalence D C
sym e = record
{ L = R
; R = L
; L⊣⊢R = op₂
}
where open ⊣Equivalence e
trans : ⊣Equivalence C D → ⊣Equivalence D E → ⊣Equivalence C E
trans e e′ = record
{ L = e′.L ∘F e.L
; R = e.R ∘F e′.R
; L⊣⊢R = e.L⊣⊢R ∘⊣⊢ e′.L⊣⊢R
}
where module e = ⊣Equivalence e
module e′ = ⊣Equivalence e′
isEquivalence : ∀ {o ℓ e} → IsEquivalence (⊣Equivalence {o} {ℓ} {e})
isEquivalence = record
{ refl = refl
; sym = sym
; trans = trans
}
setoid : ∀ o ℓ e → Setoid _ _
setoid o ℓ e = record
{ Carrier = Category o ℓ e
; _≈_ = ⊣Equivalence
; isEquivalence = isEquivalence
}
| 33.309091
| 129
| 0.438163
|
1dbb3e275400c1c3d392e0d90f277d21a2a05c71
| 8,403
|
agda
|
Agda
|
archive/agda-3/src/Everything.agda
|
m0davis/oscar
|
52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb
|
[
"RSA-MD"
] | null | null | null |
archive/agda-3/src/Everything.agda
|
m0davis/oscar
|
52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb
|
[
"RSA-MD"
] | 1
|
2019-04-29T00:35:04.000Z
|
2019-05-11T23:33:04.000Z
|
archive/agda-3/src/Everything.agda
|
m0davis/oscar
|
52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb
|
[
"RSA-MD"
] | null | null | null |
module Everything where
open import Oscar.Prelude public
-- meta-class
open import Oscar.Class public
-- classes
open import Oscar.Class.Amgu public
open import Oscar.Class.Apply public
open import Oscar.Class.Bind public
open import Oscar.Class.Category public
open import Oscar.Class.Congruity public
open import Oscar.Class.Fmap public
open import Oscar.Class.Functor public
open import Oscar.Class.HasEquivalence public
open import Oscar.Class.Hmap public
open import Oscar.Class.Injectivity public
open import Oscar.Class.IsCategory public
open import Oscar.Class.IsDecidable public
open import Oscar.Class.IsEquivalence public
open import Oscar.Class.IsFunctor public
open import Oscar.Class.IsPrecategory public
open import Oscar.Class.IsPrefunctor public
open import Oscar.Class.Leftstar public
open import Oscar.Class.Leftunit public
open import Oscar.Class.Map public
open import Oscar.Class.Precategory public
open import Oscar.Class.Prefunctor public
open import Oscar.Class.Properthing public
open import Oscar.Class.Pure public
open import Oscar.Class.Quadricity public
open import Oscar.Class.Reflexivity public
open import Oscar.Class.Setoid public
open import Oscar.Class.Similarity public
open import Oscar.Class.SimilarityM public
open import Oscar.Class.SimilaritySingleton public
open import Oscar.Class.Smap public
open import Oscar.Class.Smapoid public
open import Oscar.Class.Successor₀ public
open import Oscar.Class.Successor₁ public
open import Oscar.Class.Surjection public
open import Oscar.Class.Surjextensionality public
open import Oscar.Class.Surjidentity public
open import Oscar.Class.Surjtranscommutativity public
open import Oscar.Class.Symmetrical public
open import Oscar.Class.Symmetry public
open import Oscar.Class.Thickandthin public
open import Oscar.Class.Transassociativity public
open import Oscar.Class.Transextensionality public
open import Oscar.Class.Transitivity public
open import Oscar.Class.Transleftidentity public
open import Oscar.Class.Transrightidentity public
open import Oscar.Class.Unit public
open import Oscar.Class.[ExtensibleType] public
open import Oscar.Class.[IsExtensionB] public
-- individual instances
open import Oscar.Class.Amgu.Term∃SubstitistMaybe public
open import Oscar.Class.Congruity.Proposequality public
open import Oscar.Class.Congruity.Proposextensequality public
open import Oscar.Class.HasEquivalence.ExtensionṖroperty public
open import Oscar.Class.HasEquivalence.Ṗroperty public
open import Oscar.Class.HasEquivalence.Substitunction public
open import Oscar.Class.Hmap.Transleftidentity public
open import Oscar.Class.Injectivity.Vec public
open import Oscar.Class.IsDecidable.Fin public
open import Oscar.Class.IsDecidable.¶ public
open import Oscar.Class.Properthing.ExtensionṖroperty public
open import Oscar.Class.Properthing.Ṗroperty public
open import Oscar.Class.Reflexivity.Function public
open import Oscar.Class.Smap.ExtensionFinExtensionTerm public
open import Oscar.Class.Smap.ExtensionṖroperty public
open import Oscar.Class.Smap.TransitiveExtensionLeftṖroperty public
open import Oscar.Class.Surjection.⋆ public
open import Oscar.Class.Symmetrical.ExtensionalUnifies public
open import Oscar.Class.Symmetrical.Symmetry public
open import Oscar.Class.Symmetrical.Unifies public
open import Oscar.Class.Transextensionality.Proposequality public
open import Oscar.Class.Transitivity.Function public
open import Oscar.Class.[ExtensibleType].Proposequality public
-- instance bundles
open import Oscar.Property.Category.AListProposequality public
open import Oscar.Property.Category.ExtensionProposextensequality public
open import Oscar.Property.Category.Function public
open import Oscar.Property.Functor.SubstitistProposequalitySubstitunctionProposextensequality public
open import Oscar.Property.Functor.SubstitunctionExtensionTerm public
open import Oscar.Property.Monad.Maybe public
open import Oscar.Property.Propergroup.Substitunction public
open import Oscar.Property.Setoid.ProductIndexEquivalence public
open import Oscar.Property.Setoid.Proposequality public
open import Oscar.Property.Setoid.Proposextensequality public
open import Oscar.Property.Setoid.ṖropertyEquivalence public
open import Oscar.Property.Thickandthin.FinFinProposequalityMaybeProposequality public
open import Oscar.Property.Thickandthin.FinTermProposequalityMaybeProposequality public
-- data
open import Oscar.Data.Constraint public
open import Oscar.Data.Decidable public
open import Oscar.Data.Descender public
open import Oscar.Data.ExtensionṖroperty public
open import Oscar.Data.Fin public
open import Oscar.Data.List public
open import Oscar.Data.Maybe public
open import Oscar.Data.ProductIndexEquivalence public
open import Oscar.Data.ProperlyExtensionNothing public
open import Oscar.Data.Proposequality public
open import Oscar.Data.ṖropertyEquivalence public
open import Oscar.Data.Substitist public
open import Oscar.Data.Substitunction public
open import Oscar.Data.Surjcollation public
open import Oscar.Data.Surjextenscollation public
open import Oscar.Data.Term public
open import Oscar.Data.Vec public
open import Oscar.Data.¶ public
open import Oscar.Data.𝟘 public
open import Oscar.Data.𝟙 public
open import Oscar.Data.𝟚 public
-- class derivations
open import Oscar.Class.Leftunit.ToUnit public
open import Oscar.Class.Symmetry.ToSym public
open import Oscar.Class.Transleftidentity.ToLeftunit public
| 66.690476
| 103
| 0.555397
|
8baf4b8398572e7ad2d47123d28aac1585bc23b0
| 10,474
|
agda
|
Agda
|
agda/Text/Greek/SBLGNT/3John.agda
|
scott-fleischman/GreekGrammar
|
915c46c27c7f8aad5907474d8484f2685a4cd6a7
|
[
"MIT"
] | 44
|
2015-05-29T14:48:51.000Z
|
2022-03-06T15:41:57.000Z
|
agda/Text/Greek/SBLGNT/3John.agda
|
scott-fleischman/GreekGrammar
|
915c46c27c7f8aad5907474d8484f2685a4cd6a7
|
[
"MIT"
] | 13
|
2015-05-28T20:04:08.000Z
|
2020-09-07T11:58:38.000Z
|
agda/Text/Greek/SBLGNT/3John.agda
|
scott-fleischman/GreekGrammar
|
915c46c27c7f8aad5907474d8484f2685a4cd6a7
|
[
"MIT"
] | 5
|
2015-02-27T22:34:13.000Z
|
2017-06-11T11:25:09.000Z
|
module Text.Greek.SBLGNT.3John where
open import Data.List
open import Text.Greek.Bible
open import Text.Greek.Script
open import Text.Greek.Script.Unicode
ΙΩΑΝΝΟΥ-Γ : List (Word)
ΙΩΑΝΝΟΥ-Γ =
word (Ὁ ∷ []) "3John.1.1"
∷ word (π ∷ ρ ∷ ε ∷ σ ∷ β ∷ ύ ∷ τ ∷ ε ∷ ρ ∷ ο ∷ ς ∷ []) "3John.1.1"
∷ word (Γ ∷ α ∷ ΐ ∷ ῳ ∷ []) "3John.1.1"
∷ word (τ ∷ ῷ ∷ []) "3John.1.1"
∷ word (ἀ ∷ γ ∷ α ∷ π ∷ η ∷ τ ∷ ῷ ∷ []) "3John.1.1"
∷ word (ὃ ∷ ν ∷ []) "3John.1.1"
∷ word (ἐ ∷ γ ∷ ὼ ∷ []) "3John.1.1"
∷ word (ἀ ∷ γ ∷ α ∷ π ∷ ῶ ∷ []) "3John.1.1"
∷ word (ἐ ∷ ν ∷ []) "3John.1.1"
∷ word (ἀ ∷ ∙λ ∷ η ∷ θ ∷ ε ∷ ί ∷ ᾳ ∷ []) "3John.1.1"
∷ word (Ἀ ∷ γ ∷ α ∷ π ∷ η ∷ τ ∷ έ ∷ []) "3John.1.2"
∷ word (π ∷ ε ∷ ρ ∷ ὶ ∷ []) "3John.1.2"
∷ word (π ∷ ά ∷ ν ∷ τ ∷ ω ∷ ν ∷ []) "3John.1.2"
∷ word (ε ∷ ὔ ∷ χ ∷ ο ∷ μ ∷ α ∷ ί ∷ []) "3John.1.2"
∷ word (σ ∷ ε ∷ []) "3John.1.2"
∷ word (ε ∷ ὐ ∷ ο ∷ δ ∷ ο ∷ ῦ ∷ σ ∷ θ ∷ α ∷ ι ∷ []) "3John.1.2"
∷ word (κ ∷ α ∷ ὶ ∷ []) "3John.1.2"
∷ word (ὑ ∷ γ ∷ ι ∷ α ∷ ί ∷ ν ∷ ε ∷ ι ∷ ν ∷ []) "3John.1.2"
∷ word (κ ∷ α ∷ θ ∷ ὼ ∷ ς ∷ []) "3John.1.2"
∷ word (ε ∷ ὐ ∷ ο ∷ δ ∷ ο ∷ ῦ ∷ τ ∷ α ∷ ί ∷ []) "3John.1.2"
∷ word (σ ∷ ο ∷ υ ∷ []) "3John.1.2"
∷ word (ἡ ∷ []) "3John.1.2"
∷ word (ψ ∷ υ ∷ χ ∷ ή ∷ []) "3John.1.2"
∷ word (ἐ ∷ χ ∷ ά ∷ ρ ∷ η ∷ ν ∷ []) "3John.1.3"
∷ word (γ ∷ ὰ ∷ ρ ∷ []) "3John.1.3"
∷ word (∙λ ∷ ί ∷ α ∷ ν ∷ []) "3John.1.3"
∷ word (ἐ ∷ ρ ∷ χ ∷ ο ∷ μ ∷ έ ∷ ν ∷ ω ∷ ν ∷ []) "3John.1.3"
∷ word (ἀ ∷ δ ∷ ε ∷ ∙λ ∷ φ ∷ ῶ ∷ ν ∷ []) "3John.1.3"
∷ word (κ ∷ α ∷ ὶ ∷ []) "3John.1.3"
∷ word (μ ∷ α ∷ ρ ∷ τ ∷ υ ∷ ρ ∷ ο ∷ ύ ∷ ν ∷ τ ∷ ω ∷ ν ∷ []) "3John.1.3"
∷ word (σ ∷ ο ∷ υ ∷ []) "3John.1.3"
∷ word (τ ∷ ῇ ∷ []) "3John.1.3"
∷ word (ἀ ∷ ∙λ ∷ η ∷ θ ∷ ε ∷ ί ∷ ᾳ ∷ []) "3John.1.3"
∷ word (κ ∷ α ∷ θ ∷ ὼ ∷ ς ∷ []) "3John.1.3"
∷ word (σ ∷ ὺ ∷ []) "3John.1.3"
∷ word (ἐ ∷ ν ∷ []) "3John.1.3"
∷ word (ἀ ∷ ∙λ ∷ η ∷ θ ∷ ε ∷ ί ∷ ᾳ ∷ []) "3John.1.3"
∷ word (π ∷ ε ∷ ρ ∷ ι ∷ π ∷ α ∷ τ ∷ ε ∷ ῖ ∷ ς ∷ []) "3John.1.3"
∷ word (μ ∷ ε ∷ ι ∷ ζ ∷ ο ∷ τ ∷ έ ∷ ρ ∷ α ∷ ν ∷ []) "3John.1.4"
∷ word (τ ∷ ο ∷ ύ ∷ τ ∷ ω ∷ ν ∷ []) "3John.1.4"
∷ word (ο ∷ ὐ ∷ κ ∷ []) "3John.1.4"
∷ word (ἔ ∷ χ ∷ ω ∷ []) "3John.1.4"
∷ word (χ ∷ α ∷ ρ ∷ ά ∷ ν ∷ []) "3John.1.4"
∷ word (ἵ ∷ ν ∷ α ∷ []) "3John.1.4"
∷ word (ἀ ∷ κ ∷ ο ∷ ύ ∷ ω ∷ []) "3John.1.4"
∷ word (τ ∷ ὰ ∷ []) "3John.1.4"
∷ word (ἐ ∷ μ ∷ ὰ ∷ []) "3John.1.4"
∷ word (τ ∷ έ ∷ κ ∷ ν ∷ α ∷ []) "3John.1.4"
∷ word (ἐ ∷ ν ∷ []) "3John.1.4"
∷ word (τ ∷ ῇ ∷ []) "3John.1.4"
∷ word (ἀ ∷ ∙λ ∷ η ∷ θ ∷ ε ∷ ί ∷ ᾳ ∷ []) "3John.1.4"
∷ word (π ∷ ε ∷ ρ ∷ ι ∷ π ∷ α ∷ τ ∷ ο ∷ ῦ ∷ ν ∷ τ ∷ α ∷ []) "3John.1.4"
∷ word (Ἀ ∷ γ ∷ α ∷ π ∷ η ∷ τ ∷ έ ∷ []) "3John.1.5"
∷ word (π ∷ ι ∷ σ ∷ τ ∷ ὸ ∷ ν ∷ []) "3John.1.5"
∷ word (π ∷ ο ∷ ι ∷ ε ∷ ῖ ∷ ς ∷ []) "3John.1.5"
∷ word (ὃ ∷ []) "3John.1.5"
∷ word (ἐ ∷ ὰ ∷ ν ∷ []) "3John.1.5"
∷ word (ἐ ∷ ρ ∷ γ ∷ ά ∷ σ ∷ ῃ ∷ []) "3John.1.5"
∷ word (ε ∷ ἰ ∷ ς ∷ []) "3John.1.5"
∷ word (τ ∷ ο ∷ ὺ ∷ ς ∷ []) "3John.1.5"
∷ word (ἀ ∷ δ ∷ ε ∷ ∙λ ∷ φ ∷ ο ∷ ὺ ∷ ς ∷ []) "3John.1.5"
∷ word (κ ∷ α ∷ ὶ ∷ []) "3John.1.5"
∷ word (τ ∷ ο ∷ ῦ ∷ τ ∷ ο ∷ []) "3John.1.5"
∷ word (ξ ∷ έ ∷ ν ∷ ο ∷ υ ∷ ς ∷ []) "3John.1.5"
∷ word (ο ∷ ἳ ∷ []) "3John.1.6"
∷ word (ἐ ∷ μ ∷ α ∷ ρ ∷ τ ∷ ύ ∷ ρ ∷ η ∷ σ ∷ ά ∷ ν ∷ []) "3John.1.6"
∷ word (σ ∷ ο ∷ υ ∷ []) "3John.1.6"
∷ word (τ ∷ ῇ ∷ []) "3John.1.6"
∷ word (ἀ ∷ γ ∷ ά ∷ π ∷ ῃ ∷ []) "3John.1.6"
∷ word (ἐ ∷ ν ∷ ώ ∷ π ∷ ι ∷ ο ∷ ν ∷ []) "3John.1.6"
∷ word (ἐ ∷ κ ∷ κ ∷ ∙λ ∷ η ∷ σ ∷ ί ∷ α ∷ ς ∷ []) "3John.1.6"
∷ word (ο ∷ ὓ ∷ ς ∷ []) "3John.1.6"
∷ word (κ ∷ α ∷ ∙λ ∷ ῶ ∷ ς ∷ []) "3John.1.6"
∷ word (π ∷ ο ∷ ι ∷ ή ∷ σ ∷ ε ∷ ι ∷ ς ∷ []) "3John.1.6"
∷ word (π ∷ ρ ∷ ο ∷ π ∷ έ ∷ μ ∷ ψ ∷ α ∷ ς ∷ []) "3John.1.6"
∷ word (ἀ ∷ ξ ∷ ί ∷ ω ∷ ς ∷ []) "3John.1.6"
∷ word (τ ∷ ο ∷ ῦ ∷ []) "3John.1.6"
∷ word (θ ∷ ε ∷ ο ∷ ῦ ∷ []) "3John.1.6"
∷ word (ὑ ∷ π ∷ ὲ ∷ ρ ∷ []) "3John.1.7"
∷ word (γ ∷ ὰ ∷ ρ ∷ []) "3John.1.7"
∷ word (τ ∷ ο ∷ ῦ ∷ []) "3John.1.7"
∷ word (ὀ ∷ ν ∷ ό ∷ μ ∷ α ∷ τ ∷ ο ∷ ς ∷ []) "3John.1.7"
∷ word (ἐ ∷ ξ ∷ ῆ ∷ ∙λ ∷ θ ∷ ο ∷ ν ∷ []) "3John.1.7"
∷ word (μ ∷ η ∷ δ ∷ ὲ ∷ ν ∷ []) "3John.1.7"
∷ word (∙λ ∷ α ∷ μ ∷ β ∷ ά ∷ ν ∷ ο ∷ ν ∷ τ ∷ ε ∷ ς ∷ []) "3John.1.7"
∷ word (ἀ ∷ π ∷ ὸ ∷ []) "3John.1.7"
∷ word (τ ∷ ῶ ∷ ν ∷ []) "3John.1.7"
∷ word (ἐ ∷ θ ∷ ν ∷ ι ∷ κ ∷ ῶ ∷ ν ∷ []) "3John.1.7"
∷ word (ἡ ∷ μ ∷ ε ∷ ῖ ∷ ς ∷ []) "3John.1.8"
∷ word (ο ∷ ὖ ∷ ν ∷ []) "3John.1.8"
∷ word (ὀ ∷ φ ∷ ε ∷ ί ∷ ∙λ ∷ ο ∷ μ ∷ ε ∷ ν ∷ []) "3John.1.8"
∷ word (ὑ ∷ π ∷ ο ∷ ∙λ ∷ α ∷ μ ∷ β ∷ ά ∷ ν ∷ ε ∷ ι ∷ ν ∷ []) "3John.1.8"
∷ word (τ ∷ ο ∷ ὺ ∷ ς ∷ []) "3John.1.8"
∷ word (τ ∷ ο ∷ ι ∷ ο ∷ ύ ∷ τ ∷ ο ∷ υ ∷ ς ∷ []) "3John.1.8"
∷ word (ἵ ∷ ν ∷ α ∷ []) "3John.1.8"
∷ word (σ ∷ υ ∷ ν ∷ ε ∷ ρ ∷ γ ∷ ο ∷ ὶ ∷ []) "3John.1.8"
∷ word (γ ∷ ι ∷ ν ∷ ώ ∷ μ ∷ ε ∷ θ ∷ α ∷ []) "3John.1.8"
∷ word (τ ∷ ῇ ∷ []) "3John.1.8"
∷ word (ἀ ∷ ∙λ ∷ η ∷ θ ∷ ε ∷ ί ∷ ᾳ ∷ []) "3John.1.8"
∷ word (Ἔ ∷ γ ∷ ρ ∷ α ∷ ψ ∷ ά ∷ []) "3John.1.9"
∷ word (τ ∷ ι ∷ []) "3John.1.9"
∷ word (τ ∷ ῇ ∷ []) "3John.1.9"
∷ word (ἐ ∷ κ ∷ κ ∷ ∙λ ∷ η ∷ σ ∷ ί ∷ ᾳ ∷ []) "3John.1.9"
∷ word (ἀ ∷ ∙λ ∷ ∙λ ∷ []) "3John.1.9"
∷ word (ὁ ∷ []) "3John.1.9"
∷ word (φ ∷ ι ∷ ∙λ ∷ ο ∷ π ∷ ρ ∷ ω ∷ τ ∷ ε ∷ ύ ∷ ω ∷ ν ∷ []) "3John.1.9"
∷ word (α ∷ ὐ ∷ τ ∷ ῶ ∷ ν ∷ []) "3John.1.9"
∷ word (Δ ∷ ι ∷ ο ∷ τ ∷ ρ ∷ έ ∷ φ ∷ η ∷ ς ∷ []) "3John.1.9"
∷ word (ο ∷ ὐ ∷ κ ∷ []) "3John.1.9"
∷ word (ἐ ∷ π ∷ ι ∷ δ ∷ έ ∷ χ ∷ ε ∷ τ ∷ α ∷ ι ∷ []) "3John.1.9"
∷ word (ἡ ∷ μ ∷ ᾶ ∷ ς ∷ []) "3John.1.9"
∷ word (δ ∷ ι ∷ ὰ ∷ []) "3John.1.10"
∷ word (τ ∷ ο ∷ ῦ ∷ τ ∷ ο ∷ []) "3John.1.10"
∷ word (ἐ ∷ ὰ ∷ ν ∷ []) "3John.1.10"
∷ word (ἔ ∷ ∙λ ∷ θ ∷ ω ∷ []) "3John.1.10"
∷ word (ὑ ∷ π ∷ ο ∷ μ ∷ ν ∷ ή ∷ σ ∷ ω ∷ []) "3John.1.10"
∷ word (α ∷ ὐ ∷ τ ∷ ο ∷ ῦ ∷ []) "3John.1.10"
∷ word (τ ∷ ὰ ∷ []) "3John.1.10"
∷ word (ἔ ∷ ρ ∷ γ ∷ α ∷ []) "3John.1.10"
∷ word (ἃ ∷ []) "3John.1.10"
∷ word (π ∷ ο ∷ ι ∷ ε ∷ ῖ ∷ []) "3John.1.10"
∷ word (∙λ ∷ ό ∷ γ ∷ ο ∷ ι ∷ ς ∷ []) "3John.1.10"
∷ word (π ∷ ο ∷ ν ∷ η ∷ ρ ∷ ο ∷ ῖ ∷ ς ∷ []) "3John.1.10"
∷ word (φ ∷ ∙λ ∷ υ ∷ α ∷ ρ ∷ ῶ ∷ ν ∷ []) "3John.1.10"
∷ word (ἡ ∷ μ ∷ ᾶ ∷ ς ∷ []) "3John.1.10"
∷ word (κ ∷ α ∷ ὶ ∷ []) "3John.1.10"
∷ word (μ ∷ ὴ ∷ []) "3John.1.10"
∷ word (ἀ ∷ ρ ∷ κ ∷ ο ∷ ύ ∷ μ ∷ ε ∷ ν ∷ ο ∷ ς ∷ []) "3John.1.10"
∷ word (ἐ ∷ π ∷ ὶ ∷ []) "3John.1.10"
∷ word (τ ∷ ο ∷ ύ ∷ τ ∷ ο ∷ ι ∷ ς ∷ []) "3John.1.10"
∷ word (ο ∷ ὔ ∷ τ ∷ ε ∷ []) "3John.1.10"
∷ word (α ∷ ὐ ∷ τ ∷ ὸ ∷ ς ∷ []) "3John.1.10"
∷ word (ἐ ∷ π ∷ ι ∷ δ ∷ έ ∷ χ ∷ ε ∷ τ ∷ α ∷ ι ∷ []) "3John.1.10"
∷ word (τ ∷ ο ∷ ὺ ∷ ς ∷ []) "3John.1.10"
∷ word (ἀ ∷ δ ∷ ε ∷ ∙λ ∷ φ ∷ ο ∷ ὺ ∷ ς ∷ []) "3John.1.10"
∷ word (κ ∷ α ∷ ὶ ∷ []) "3John.1.10"
∷ word (τ ∷ ο ∷ ὺ ∷ ς ∷ []) "3John.1.10"
∷ word (β ∷ ο ∷ υ ∷ ∙λ ∷ ο ∷ μ ∷ έ ∷ ν ∷ ο ∷ υ ∷ ς ∷ []) "3John.1.10"
∷ word (κ ∷ ω ∷ ∙λ ∷ ύ ∷ ε ∷ ι ∷ []) "3John.1.10"
∷ word (κ ∷ α ∷ ὶ ∷ []) "3John.1.10"
∷ word (ἐ ∷ κ ∷ []) "3John.1.10"
∷ word (τ ∷ ῆ ∷ ς ∷ []) "3John.1.10"
∷ word (ἐ ∷ κ ∷ κ ∷ ∙λ ∷ η ∷ σ ∷ ί ∷ α ∷ ς ∷ []) "3John.1.10"
∷ word (ἐ ∷ κ ∷ β ∷ ά ∷ ∙λ ∷ ∙λ ∷ ε ∷ ι ∷ []) "3John.1.10"
∷ word (Ἀ ∷ γ ∷ α ∷ π ∷ η ∷ τ ∷ έ ∷ []) "3John.1.11"
∷ word (μ ∷ ὴ ∷ []) "3John.1.11"
∷ word (μ ∷ ι ∷ μ ∷ ο ∷ ῦ ∷ []) "3John.1.11"
∷ word (τ ∷ ὸ ∷ []) "3John.1.11"
∷ word (κ ∷ α ∷ κ ∷ ὸ ∷ ν ∷ []) "3John.1.11"
∷ word (ἀ ∷ ∙λ ∷ ∙λ ∷ ὰ ∷ []) "3John.1.11"
∷ word (τ ∷ ὸ ∷ []) "3John.1.11"
∷ word (ἀ ∷ γ ∷ α ∷ θ ∷ ό ∷ ν ∷ []) "3John.1.11"
∷ word (ὁ ∷ []) "3John.1.11"
∷ word (ἀ ∷ γ ∷ α ∷ θ ∷ ο ∷ π ∷ ο ∷ ι ∷ ῶ ∷ ν ∷ []) "3John.1.11"
∷ word (ἐ ∷ κ ∷ []) "3John.1.11"
∷ word (τ ∷ ο ∷ ῦ ∷ []) "3John.1.11"
∷ word (θ ∷ ε ∷ ο ∷ ῦ ∷ []) "3John.1.11"
∷ word (ἐ ∷ σ ∷ τ ∷ ι ∷ ν ∷ []) "3John.1.11"
∷ word (ὁ ∷ []) "3John.1.11"
∷ word (κ ∷ α ∷ κ ∷ ο ∷ π ∷ ο ∷ ι ∷ ῶ ∷ ν ∷ []) "3John.1.11"
∷ word (ο ∷ ὐ ∷ χ ∷ []) "3John.1.11"
∷ word (ἑ ∷ ώ ∷ ρ ∷ α ∷ κ ∷ ε ∷ ν ∷ []) "3John.1.11"
∷ word (τ ∷ ὸ ∷ ν ∷ []) "3John.1.11"
∷ word (θ ∷ ε ∷ ό ∷ ν ∷ []) "3John.1.11"
∷ word (Δ ∷ η ∷ μ ∷ η ∷ τ ∷ ρ ∷ ί ∷ ῳ ∷ []) "3John.1.12"
∷ word (μ ∷ ε ∷ μ ∷ α ∷ ρ ∷ τ ∷ ύ ∷ ρ ∷ η ∷ τ ∷ α ∷ ι ∷ []) "3John.1.12"
∷ word (ὑ ∷ π ∷ ὸ ∷ []) "3John.1.12"
∷ word (π ∷ ά ∷ ν ∷ τ ∷ ω ∷ ν ∷ []) "3John.1.12"
∷ word (κ ∷ α ∷ ὶ ∷ []) "3John.1.12"
∷ word (ὑ ∷ π ∷ ὸ ∷ []) "3John.1.12"
∷ word (α ∷ ὐ ∷ τ ∷ ῆ ∷ ς ∷ []) "3John.1.12"
∷ word (τ ∷ ῆ ∷ ς ∷ []) "3John.1.12"
∷ word (ἀ ∷ ∙λ ∷ η ∷ θ ∷ ε ∷ ί ∷ α ∷ ς ∷ []) "3John.1.12"
∷ word (κ ∷ α ∷ ὶ ∷ []) "3John.1.12"
∷ word (ἡ ∷ μ ∷ ε ∷ ῖ ∷ ς ∷ []) "3John.1.12"
∷ word (δ ∷ ὲ ∷ []) "3John.1.12"
∷ word (μ ∷ α ∷ ρ ∷ τ ∷ υ ∷ ρ ∷ ο ∷ ῦ ∷ μ ∷ ε ∷ ν ∷ []) "3John.1.12"
∷ word (κ ∷ α ∷ ὶ ∷ []) "3John.1.12"
∷ word (ο ∷ ἶ ∷ δ ∷ α ∷ ς ∷ []) "3John.1.12"
∷ word (ὅ ∷ τ ∷ ι ∷ []) "3John.1.12"
∷ word (ἡ ∷ []) "3John.1.12"
∷ word (μ ∷ α ∷ ρ ∷ τ ∷ υ ∷ ρ ∷ ί ∷ α ∷ []) "3John.1.12"
∷ word (ἡ ∷ μ ∷ ῶ ∷ ν ∷ []) "3John.1.12"
∷ word (ἀ ∷ ∙λ ∷ η ∷ θ ∷ ή ∷ ς ∷ []) "3John.1.12"
∷ word (ἐ ∷ σ ∷ τ ∷ ι ∷ ν ∷ []) "3John.1.12"
∷ word (Π ∷ ο ∷ ∙λ ∷ ∙λ ∷ ὰ ∷ []) "3John.1.13"
∷ word (ε ∷ ἶ ∷ χ ∷ ο ∷ ν ∷ []) "3John.1.13"
∷ word (γ ∷ ρ ∷ ά ∷ ψ ∷ α ∷ ι ∷ []) "3John.1.13"
∷ word (σ ∷ ο ∷ ι ∷ []) "3John.1.13"
∷ word (ἀ ∷ ∙λ ∷ ∙λ ∷ []) "3John.1.13"
∷ word (ο ∷ ὐ ∷ []) "3John.1.13"
∷ word (θ ∷ έ ∷ ∙λ ∷ ω ∷ []) "3John.1.13"
∷ word (δ ∷ ι ∷ ὰ ∷ []) "3John.1.13"
∷ word (μ ∷ έ ∷ ∙λ ∷ α ∷ ν ∷ ο ∷ ς ∷ []) "3John.1.13"
∷ word (κ ∷ α ∷ ὶ ∷ []) "3John.1.13"
∷ word (κ ∷ α ∷ ∙λ ∷ ά ∷ μ ∷ ο ∷ υ ∷ []) "3John.1.13"
∷ word (σ ∷ ο ∷ ι ∷ []) "3John.1.13"
∷ word (γ ∷ ρ ∷ ά ∷ φ ∷ ε ∷ ι ∷ ν ∷ []) "3John.1.13"
∷ word (ἐ ∷ ∙λ ∷ π ∷ ί ∷ ζ ∷ ω ∷ []) "3John.1.14"
∷ word (δ ∷ ὲ ∷ []) "3John.1.14"
∷ word (ε ∷ ὐ ∷ θ ∷ έ ∷ ω ∷ ς ∷ []) "3John.1.14"
∷ word (σ ∷ ε ∷ []) "3John.1.14"
∷ word (ἰ ∷ δ ∷ ε ∷ ῖ ∷ ν ∷ []) "3John.1.14"
∷ word (κ ∷ α ∷ ὶ ∷ []) "3John.1.14"
∷ word (σ ∷ τ ∷ ό ∷ μ ∷ α ∷ []) "3John.1.14"
∷ word (π ∷ ρ ∷ ὸ ∷ ς ∷ []) "3John.1.14"
∷ word (σ ∷ τ ∷ ό ∷ μ ∷ α ∷ []) "3John.1.14"
∷ word (∙λ ∷ α ∷ ∙λ ∷ ή ∷ σ ∷ ο ∷ μ ∷ ε ∷ ν ∷ []) "3John.1.14"
∷ word (Ε ∷ ἰ ∷ ρ ∷ ή ∷ ν ∷ η ∷ []) "3John.1.15"
∷ word (σ ∷ ο ∷ ι ∷ []) "3John.1.15"
∷ word (ἀ ∷ σ ∷ π ∷ ά ∷ ζ ∷ ο ∷ ν ∷ τ ∷ α ∷ ί ∷ []) "3John.1.15"
∷ word (σ ∷ ε ∷ []) "3John.1.15"
∷ word (ο ∷ ἱ ∷ []) "3John.1.15"
∷ word (φ ∷ ί ∷ ∙λ ∷ ο ∷ ι ∷ []) "3John.1.15"
∷ word (ἀ ∷ σ ∷ π ∷ ά ∷ ζ ∷ ο ∷ υ ∷ []) "3John.1.15"
∷ word (τ ∷ ο ∷ ὺ ∷ ς ∷ []) "3John.1.15"
∷ word (φ ∷ ί ∷ ∙λ ∷ ο ∷ υ ∷ ς ∷ []) "3John.1.15"
∷ word (κ ∷ α ∷ τ ∷ []) "3John.1.15"
∷ word (ὄ ∷ ν ∷ ο ∷ μ ∷ α ∷ []) "3John.1.15"
∷ []
| 45.53913
| 74
| 0.360703
|
2f21c9ebcbbd8806c27e4233ce7faa237025bef2
| 5,451
|
agda
|
Agda
|
Basic/Compiler/Machine.agda
|
AndrasKovacs/SemanticsWithApplications
|
05200d60b4a4b2c6fa37806ced9247055d24db94
|
[
"MIT"
] | 8
|
2016-09-12T04:25:39.000Z
|
2020-02-02T10:01:52.000Z
|
Basic/Compiler/Machine.agda
|
AndrasKovacs/SemanticsWithApplications
|
05200d60b4a4b2c6fa37806ced9247055d24db94
|
[
"MIT"
] | null | null | null |
Basic/Compiler/Machine.agda
|
AndrasKovacs/SemanticsWithApplications
|
05200d60b4a4b2c6fa37806ced9247055d24db94
|
[
"MIT"
] | null | null | null |
module Basic.Compiler.Machine where
open import Basic.AST
open import Basic.BigStep
open import Basic.Compiler.Code
open import Utils.Decidable
open import Data.Product
open import Relation.Nullary
open import Relation.Nullary.Decidable
open import Data.List hiding (unfold)
open import Data.Bool
open import Data.Nat
open import Data.Maybe
{-
This is a simple interpreter for the abstract machine code.
There's no corresponding part in the book.
A nice thing about the abstract machine is that each transition is decidable,
so we can tell at each point whether our program is stuck or may continue.
Of course, this doesn't mean that *computation sequences* are decidable! (it's pretty much
just the halting problem).
What we can do is specify how many steps we'd like to compute, and then compute that far.
The "steps" function below only computes the ending configuration, while "trace"
returns a list of all intermediate configurations.
"unfold" returns a computation sequence if the program terminates or gets stuck in
the given number of steps.
-}
step : ∀ {n} (c : Code n) e s → Dec (∃₂ λ c' e' -> ∃ λ s' → ⟨ c , e , s ⟩▷⟨ c' , e' , s' ⟩)
step [] e s = no (λ {(c' , e' , s' , ())})
step (PUSH x ∷ c) e s = yes (c , nat x ∷ e , s , PUSH x)
step (FETCH x ∷ c) e s = yes (c , nat _ ∷ e , s , FETCH x)
step (STORE x ∷ c) [] s = no (λ {(c' , e' , s' , ())})
step (STORE x ∷ c) (nat x₁ ∷ e) s = yes (c , e , _ , STORE x)
step (STORE x ∷ c) (bool x₁ ∷ e) s = no (λ {(c' , e' , s' , ())})
step (ADD ∷ c) [] s = no (λ { (c' , e' , s' , ()) })
step (ADD ∷ c) (nat x ∷ []) s = no (λ { (c' , e' , s' , ()) })
step (ADD ∷ c) (nat x ∷ nat x₁ ∷ e) s = yes (c , nat _ ∷ e , s , ADD x x₁)
step (ADD ∷ c) (nat x ∷ bool x₁ ∷ e) s = no (λ { (c' , e' , s' , ()) })
step (ADD ∷ c) (bool x ∷ e) s = no (λ { (c' , e' , s' , ()) })
step (MUL ∷ c) [] s = no (λ { (c' , e' , s' , ()) })
step (MUL ∷ c) (nat x ∷ []) s = no (λ { (c' , e' , s' , ()) })
step (MUL ∷ c) (nat x ∷ nat x₁ ∷ e) s = yes (c , nat _ ∷ e , s , MUL x x₁)
step (MUL ∷ c) (nat x ∷ bool x₁ ∷ e) s = no (λ { (c' , e' , s' , ()) })
step (MUL ∷ c) (bool x ∷ e) s = no (λ { (c' , e' , s' , ()) })
step (SUB ∷ c) [] s = no (λ { (c' , e' , s' , ()) })
step (SUB ∷ c) (nat x ∷ []) s = no (λ { (c' , e' , s' , ()) })
step (SUB ∷ c) (nat x ∷ nat x₁ ∷ e) s = yes (c , nat _ ∷ e , s , SUB x x₁)
step (SUB ∷ c) (nat x ∷ bool x₁ ∷ e) s = no (λ { (c' , e' , s' , ()) })
step (SUB ∷ c) (bool x ∷ e) s = no (λ { (c' , e' , s' , ()) })
step (TRUE ∷ c) e s = yes (c , bool true ∷ e , s , TRUE)
step (FALSE ∷ c) e s = yes (c , bool false ∷ e , s , FALSE)
step (EQ ∷ c) [] s = no (λ { (c' , e' , s' , ()) })
step (EQ ∷ c) (nat x ∷ []) s = no (λ { (c' , e' , s' , ()) })
step (EQ ∷ c) (nat x ∷ nat x₁ ∷ e) s = yes (c , bool ⌊ x ≡⁇ x₁ ⌋ ∷ e , s , EQ x x₁)
step (EQ ∷ c) (nat x ∷ bool x₁ ∷ e) s = no (λ { (c' , e' , s' , ()) })
step (EQ ∷ c) (bool x ∷ e) s = no (λ { (c' , e' , s' , ()) })
step (LTE ∷ c) [] s = no (λ { (c' , e' , s' , ()) })
step (LTE ∷ c) (nat x ∷ []) s = no (λ { (c' , e' , s' , ()) })
step (LTE ∷ c) (nat x ∷ nat x₁ ∷ e) s = yes (c , bool ⌊ x ≤⁇ x₁ ⌋ ∷ e , s , LTE x x₁)
step (LTE ∷ c) (nat x ∷ bool x₁ ∷ e) s = no (λ { (c' , e' , s' , ()) })
step (LTE ∷ c) (bool x ∷ e) s = no (λ { (c' , e' , s' , ()) })
step (LT ∷ c) [] s = no (λ { (c' , e' , s' , ()) })
step (LT ∷ c) (nat x ∷ []) s = no (λ { (c' , e' , s' , ()) })
step (LT ∷ c) (nat x ∷ nat x₁ ∷ e) s = yes (c , bool ⌊ x <⁇ x₁ ⌋ ∷ e , s , LT x x₁)
step (LT ∷ c) (nat x ∷ bool x₁ ∷ e) s = no (λ { (c' , e' , s' , ()) })
step (LT ∷ c) (bool x ∷ e) s = no (λ { (c' , e' , s' , ()) })
step (AND ∷ c) [] s = no (λ { (c' , e' , s' , ()) })
step (AND ∷ c) (nat x ∷ e) s = no (λ { (c' , e' , s' , ()) })
step (AND ∷ c) (bool x ∷ []) s = no (λ { (c' , e' , s' , ()) })
step (AND ∷ c) (bool x ∷ nat x₁ ∷ e) s = no (λ { (c' , e' , s' , ()) })
step (AND ∷ c) (bool x ∷ bool x₁ ∷ e) s = yes (c , bool (x ∧ x₁) ∷ e , s , AND x x₁)
step (NOT ∷ c) [] s = no (λ { (c' , e' , s' , ()) })
step (NOT ∷ c) (nat x ∷ e) s = no (λ { (c' , e' , s' , ()) })
step (NOT ∷ c) (bool x ∷ e) s = yes (c , bool _ ∷ e , s , NOT x)
step (NOOP ∷ c) e s = yes (c , e , s , NOOP)
step (BRANCH x x₁ ∷ c) [] s = no (λ { (c' , e' , s' , ()) })
step (BRANCH x x₁ ∷ c) (nat x₂ ∷ e) s = no (λ { (c' , e' , s' , ()) })
step (BRANCH x x₁ ∷ c) (bool true ∷ e) s = yes (x ++ c , e , s , BRANCH)
step (BRANCH x x₁ ∷ c) (bool false ∷ e) s = yes (x₁ ++ c , e , s , BRANCH)
step (LOOP x x₁ ∷ c) e s = yes (x ++ BRANCH (x₁ ++ LOOP x x₁ ∷ []) (NOOP ∷ []) ∷ c , e , s , LOOP)
steps : ∀ {n} → Code n → Stack → State n → ℕ → (Code n × Stack × State n)
steps c e s zero = c , e , s
steps c e s (suc n) with step c e s
... | yes (c' , e' , s' , p) = steps c' e' s' n
... | no _ = c , e , s
trace : ∀ {n} → Code n → Stack → State n → ℕ → List (Code n × Stack × State n)
trace c e s zero = []
trace c e s (suc n) with step c e s
... | yes (c' , e' , s' , p) = (c , e , s) ∷ trace c' e' s' n
... | no _ = (c , e , s) ∷ []
unfold :
∀ {n} c e (s : State n) → ℕ → Maybe (∃₂ λ c' e' → ∃ λ s' → ⟨ c , e , s ⟩▷*⟨ c' , e' , s' ⟩)
unfold [] e s n₁ = just ([] , e , s , done)
unfold (x ∷ c) e s zero = nothing
unfold (x ∷ c) e s (suc n) with step (x ∷ c) e s
... | no ¬p = just (x ∷ c , e , s , stuck (λ c' e' s' z → ¬p (c' , e' , s' , z)))
... | yes (c' , e' , s' , p) with unfold c' e' s' n
... | nothing = nothing
... | just (c'' , e'' , s'' , seq) = just (c'' , e'' , s'' , p ∷ seq)
| 43.261905
| 98
| 0.464685
|
8bfd76e5fbe80d160e622fc3d94d078f7077ae3e
| 122
|
agda
|
Agda
|
examples/AIM5/PolyDep/TYPE.agda
|
asr/agda-kanso
|
aa10ae6a29dc79964fe9dec2de07b9df28b61ed5
|
[
"MIT"
] | 1
|
2019-11-27T07:26:06.000Z
|
2019-11-27T07:26:06.000Z
|
examples/AIM5/PolyDep/TYPE.agda
|
np/agda-git-experiment
|
20596e9dd9867166a64470dd24ea68925ff380ce
|
[
"MIT"
] | null | null | null |
examples/AIM5/PolyDep/TYPE.agda
|
np/agda-git-experiment
|
20596e9dd9867166a64470dd24ea68925ff380ce
|
[
"MIT"
] | null | null | null |
module TYPE where
data Pair (a b : Set1) : Set1 where
pair : a -> b -> Pair a b
data Unit : Set1 where
unit : Unit
| 13.555556
| 35
| 0.614754
|
dc86594aeac1fdac1efa42787635d8e42ed693ea
| 951
|
agda
|
Agda
|
test/Succeed/Issue4525.agda
|
googleson78/agda
|
aea2c53340f509c2c67157caeac360400ea6afbc
|
[
"BSD-3-Clause"
] | null | null | null |
test/Succeed/Issue4525.agda
|
googleson78/agda
|
aea2c53340f509c2c67157caeac360400ea6afbc
|
[
"BSD-3-Clause"
] | null | null | null |
test/Succeed/Issue4525.agda
|
googleson78/agda
|
aea2c53340f509c2c67157caeac360400ea6afbc
|
[
"BSD-3-Clause"
] | null | null | null |
open import Agda.Builtin.Bool
open import Agda.Builtin.Equality
open import Agda.Builtin.List
open import Agda.Builtin.Reflection renaming (bindTC to _>>=_)
open import Agda.Builtin.Unit
postulate
@0 A : Set
@0 _ : @0 Set → (Set → Set) → Set
_ = λ @0 where
A G → G A
@0 _ : @0 Set → (Set → Set) → Set
_ = λ @0 { A G → G A }
data ⊥ : Set where
@0 _ : @0 ⊥ → Set
_ = λ @0 { () }
@0 _ : @0 ⊥ → Set
_ = λ @0 where
()
@0 _ : @0 ⊥ → Set
_ =
λ @0
@ω
@erased
@plenty
@(tactic (λ _ → Set))
@irr
@irrelevant
@shirr
@shape-irrelevant
@relevant
@♭
@flat
@notlock
@lock
@tick where
()
F : ⊤ → ⊤
F = λ { tt → tt }
macro
`F : Term → TC ⊤
`F goal = do
F ← withNormalisation true (quoteTC F)
F ← quoteTC F
unify goal F
_ :
`F ≡
pat-lam
(clause []
(arg (arg-info visible relevant) (con (quote tt) []) ∷ [])
(con (quote tt) []) ∷
[])
[]
_ = refl
| 14.630769
| 64
| 0.513144
|
8b6c590c68d845123ec29ff3784b5bbacc6abbe7
| 11,023
|
agda
|
Agda
|
IPC/Syntax/Translation.agda
|
mietek/hilbert-gentzen
|
fcd187db70f0a39b894fe44fad0107f61849405c
|
[
"X11"
] | 29
|
2016-07-03T18:51:56.000Z
|
2022-01-01T10:29:18.000Z
|
IPC/Syntax/Translation.agda
|
mietek/hilbert-gentzen
|
fcd187db70f0a39b894fe44fad0107f61849405c
|
[
"X11"
] | 1
|
2018-06-10T09:11:22.000Z
|
2018-06-10T09:11:22.000Z
|
IPC/Syntax/Translation.agda
|
mietek/hilbert-gentzen
|
fcd187db70f0a39b894fe44fad0107f61849405c
|
[
"X11"
] | null | null | null |
-- Intuitionistic propositional calculus.
-- Translation between different formalisations of syntax.
module IPC.Syntax.Translation where
open import IPC.Syntax.Common public
import IPC.Syntax.ClosedHilbertSequential as CHS
import IPC.Syntax.ClosedHilbert as CH
import IPC.Syntax.HilbertSequential as HS
import IPC.Syntax.Hilbert as H
import IPC.Syntax.Gentzen as G
open HS using () renaming (_⊦⊢_ to HS⟨_⊦⊢_⟩ ; _⊢_ to HS⟨_⊢_⟩) public
open H using () renaming (_⊢_ to H⟨_⊢_⟩) public
open G using () renaming (_⊢_ to G⟨_⊢_⟩) public
-- Available translations.
--
-- ┌─────┬─────┬─────┬─────┬─────┐
-- │ CHS │ CH │ HS │ H │ G │
-- ┌─────┼─────┼─────┼─────┼─────┼─────┤
-- │ CHS │ │ d │ d │ ∘ │ ∘ │
-- ├─────┼─────┼─────┼─────┼─────┼─────┤
-- │ CH │ d │ │ ∘ │ d │ ∘ │
-- ├─────┼─────┼─────┼─────┼─────┼─────┤
-- │ HS │ d │ ∘ │ │ d │ ∘ │
-- ├─────┼─────┼─────┼─────┼─────┼─────┤
-- │ H │ ∘ │ d │ d │ │ d │
-- ├─────┼─────┼─────┼─────┼─────┼─────┤
-- │ G │ ∘ │ ∘ │ ∘ │ d │ │
-- └─────┴─────┴─────┴─────┴─────┴─────┘
--
-- d : Direct translation.
-- ∘ : Composition of translations.
-- Translation from closed Hilbert-style sequential to closed Hilbert-style.
chs→ch : ∀ {A} → CHS.⊢ A → CH.⊢ A
chs→ch (Ξ , ts) = chs⊦→ch ts top
where
chs⊦→ch : ∀ {A Ξ} → CHS.⊦⊢ Ξ → A ∈ Ξ → CH.⊢ A
chs⊦→ch (CHS.mp i j ts) top = CH.app (chs⊦→ch ts i) (chs⊦→ch ts j)
chs⊦→ch (CHS.ci ts) top = CH.ci
chs⊦→ch (CHS.ck ts) top = CH.ck
chs⊦→ch (CHS.cs ts) top = CH.cs
chs⊦→ch (CHS.cpair ts) top = CH.cpair
chs⊦→ch (CHS.cfst ts) top = CH.cfst
chs⊦→ch (CHS.csnd ts) top = CH.csnd
chs⊦→ch (CHS.unit ts) top = CH.unit
chs⊦→ch (CHS.cboom ts) top = CH.cboom
chs⊦→ch (CHS.cinl ts) top = CH.cinl
chs⊦→ch (CHS.cinr ts) top = CH.cinr
chs⊦→ch (CHS.ccase ts) top = CH.ccase
chs⊦→ch (CHS.mp i j ts) (pop k) = chs⊦→ch ts k
chs⊦→ch (CHS.ci ts) (pop k) = chs⊦→ch ts k
chs⊦→ch (CHS.ck ts) (pop k) = chs⊦→ch ts k
chs⊦→ch (CHS.cs ts) (pop k) = chs⊦→ch ts k
chs⊦→ch (CHS.cpair ts) (pop k) = chs⊦→ch ts k
chs⊦→ch (CHS.cfst ts) (pop k) = chs⊦→ch ts k
chs⊦→ch (CHS.csnd ts) (pop k) = chs⊦→ch ts k
chs⊦→ch (CHS.unit ts) (pop k) = chs⊦→ch ts k
chs⊦→ch (CHS.cboom ts) (pop k) = chs⊦→ch ts k
chs⊦→ch (CHS.cinl ts) (pop k) = chs⊦→ch ts k
chs⊦→ch (CHS.cinr ts) (pop k) = chs⊦→ch ts k
chs⊦→ch (CHS.ccase ts) (pop k) = chs⊦→ch ts k
-- Translation from closed Hilbert-style to closed Hilbert-style sequential.
ch→chs : ∀ {A} → CH.⊢ A → CHS.⊢ A
ch→chs (CH.app t u) = CHS.app (ch→chs t) (ch→chs u)
ch→chs CH.ci = ∅ , CHS.ci CHS.nil
ch→chs CH.ck = ∅ , CHS.ck CHS.nil
ch→chs CH.cs = ∅ , CHS.cs CHS.nil
ch→chs CH.cpair = ∅ , CHS.cpair CHS.nil
ch→chs CH.cfst = ∅ , CHS.cfst CHS.nil
ch→chs CH.csnd = ∅ , CHS.csnd CHS.nil
ch→chs CH.unit = ∅ , CHS.unit CHS.nil
ch→chs CH.cboom = ∅ , CHS.cboom CHS.nil
ch→chs CH.cinl = ∅ , CHS.cinl CHS.nil
ch→chs CH.cinr = ∅ , CHS.cinr CHS.nil
ch→chs CH.ccase = ∅ , CHS.ccase CHS.nil
-- Translation from Hilbert-style sequential to Hilbert-style.
hs→h : ∀ {A Γ} → HS⟨ Γ ⊢ A ⟩ → H⟨ Γ ⊢ A ⟩
hs→h (Ξ , ts) = hs⊦→h ts top
where
hs⊦→h : ∀ {A Ξ Γ} → HS⟨ Γ ⊦⊢ Ξ ⟩ → A ∈ Ξ → H⟨ Γ ⊢ A ⟩
hs⊦→h (HS.var i ts) top = H.var i
hs⊦→h (HS.mp i j ts) top = H.app (hs⊦→h ts i) (hs⊦→h ts j)
hs⊦→h (HS.ci ts) top = H.ci
hs⊦→h (HS.ck ts) top = H.ck
hs⊦→h (HS.cs ts) top = H.cs
hs⊦→h (HS.cpair ts) top = H.cpair
hs⊦→h (HS.cfst ts) top = H.cfst
hs⊦→h (HS.csnd ts) top = H.csnd
hs⊦→h (HS.unit ts) top = H.unit
hs⊦→h (HS.cboom ts) top = H.cboom
hs⊦→h (HS.cinl ts) top = H.cinl
hs⊦→h (HS.cinr ts) top = H.cinr
hs⊦→h (HS.ccase ts) top = H.ccase
hs⊦→h (HS.var i ts) (pop k) = hs⊦→h ts k
hs⊦→h (HS.mp i j ts) (pop k) = hs⊦→h ts k
hs⊦→h (HS.ci ts) (pop k) = hs⊦→h ts k
hs⊦→h (HS.ck ts) (pop k) = hs⊦→h ts k
hs⊦→h (HS.cs ts) (pop k) = hs⊦→h ts k
hs⊦→h (HS.cpair ts) (pop k) = hs⊦→h ts k
hs⊦→h (HS.cfst ts) (pop k) = hs⊦→h ts k
hs⊦→h (HS.csnd ts) (pop k) = hs⊦→h ts k
hs⊦→h (HS.unit ts) (pop k) = hs⊦→h ts k
hs⊦→h (HS.cboom ts) (pop k) = hs⊦→h ts k
hs⊦→h (HS.cinl ts) (pop k) = hs⊦→h ts k
hs⊦→h (HS.cinr ts) (pop k) = hs⊦→h ts k
hs⊦→h (HS.ccase ts) (pop k) = hs⊦→h ts k
-- Translation from Hilbert-style to Hilbert-style sequential.
h→hs : ∀ {A Γ} → H⟨ Γ ⊢ A ⟩ → HS⟨ Γ ⊢ A ⟩
h→hs (H.var i) = ∅ , HS.var i HS.nil
h→hs (H.app t u) = HS.app (h→hs t) (h→hs u)
h→hs H.ci = ∅ , HS.ci HS.nil
h→hs H.ck = ∅ , HS.ck HS.nil
h→hs H.cs = ∅ , HS.cs HS.nil
h→hs H.cpair = ∅ , HS.cpair HS.nil
h→hs H.cfst = ∅ , HS.cfst HS.nil
h→hs H.csnd = ∅ , HS.csnd HS.nil
h→hs H.unit = ∅ , HS.unit HS.nil
h→hs H.cboom = ∅ , HS.cboom HS.nil
h→hs H.cinl = ∅ , HS.cinl HS.nil
h→hs H.cinr = ∅ , HS.cinr HS.nil
h→hs H.ccase = ∅ , HS.ccase HS.nil
-- Deduction and detachment theorems for Hilbert-style sequential.
hs-lam : ∀ {A B Γ} → HS⟨ Γ , A ⊢ B ⟩ → HS⟨ Γ ⊢ A ▻ B ⟩
hs-lam = h→hs ∘ H.lam ∘ hs→h
hs-lam⋆₀ : ∀ {A Γ} → HS⟨ Γ ⊢ A ⟩ → HS⟨ ∅ ⊢ Γ ▻⋯▻ A ⟩
hs-lam⋆₀ = h→hs ∘ H.lam⋆₀ ∘ hs→h
hs-det : ∀ {A B Γ} → HS⟨ Γ ⊢ A ▻ B ⟩ → HS⟨ Γ , A ⊢ B ⟩
hs-det = h→hs ∘ H.det ∘ hs→h
hs-det⋆₀ : ∀ {A Γ} → HS⟨ ∅ ⊢ Γ ▻⋯▻ A ⟩ → HS⟨ Γ ⊢ A ⟩
hs-det⋆₀ = h→hs ∘ H.det⋆₀ ∘ hs→h
-- Translation from closed Hilbert-style sequential to Hilbert-style sequential.
chs→hs₀ : ∀ {A} → CHS.⊢ A → HS⟨ ∅ ⊢ A ⟩
chs→hs₀ (Ξ , ts) = Ξ , chs⊦→hs₀⊦ ts
where
chs⊦→hs₀⊦ : ∀ {Ξ} → CHS.⊦⊢ Ξ → HS⟨ ∅ ⊦⊢ Ξ ⟩
chs⊦→hs₀⊦ CHS.nil = HS.nil
chs⊦→hs₀⊦ (CHS.mp i j ts) = HS.mp i j (chs⊦→hs₀⊦ ts)
chs⊦→hs₀⊦ (CHS.ci ts) = HS.ci (chs⊦→hs₀⊦ ts)
chs⊦→hs₀⊦ (CHS.ck ts) = HS.ck (chs⊦→hs₀⊦ ts)
chs⊦→hs₀⊦ (CHS.cs ts) = HS.cs (chs⊦→hs₀⊦ ts)
chs⊦→hs₀⊦ (CHS.cpair ts) = HS.cpair (chs⊦→hs₀⊦ ts)
chs⊦→hs₀⊦ (CHS.cfst ts) = HS.cfst (chs⊦→hs₀⊦ ts)
chs⊦→hs₀⊦ (CHS.csnd ts) = HS.csnd (chs⊦→hs₀⊦ ts)
chs⊦→hs₀⊦ (CHS.unit ts) = HS.unit (chs⊦→hs₀⊦ ts)
chs⊦→hs₀⊦ (CHS.cboom ts) = HS.cboom (chs⊦→hs₀⊦ ts)
chs⊦→hs₀⊦ (CHS.cinl ts) = HS.cinl (chs⊦→hs₀⊦ ts)
chs⊦→hs₀⊦ (CHS.cinr ts) = HS.cinr (chs⊦→hs₀⊦ ts)
chs⊦→hs₀⊦ (CHS.ccase ts) = HS.ccase (chs⊦→hs₀⊦ ts)
chs→hs : ∀ {A Γ} → CHS.⊢ Γ ▻⋯▻ A → HS⟨ Γ ⊢ A ⟩
chs→hs t = hs-det⋆₀ (chs→hs₀ t)
-- Translation from Hilbert-style sequential to closed Hilbert-style sequential.
hs₀→chs : ∀ {A} → HS⟨ ∅ ⊢ A ⟩ → CHS.⊢ A
hs₀→chs (Ξ , ts) = Ξ , hs₀⊦→chs⊦ ts
where
hs₀⊦→chs⊦ : ∀ {Ξ} → HS⟨ ∅ ⊦⊢ Ξ ⟩ → CHS.⊦⊢ Ξ
hs₀⊦→chs⊦ HS.nil = CHS.nil
hs₀⊦→chs⊦ (HS.var () ts)
hs₀⊦→chs⊦ (HS.mp i j ts) = CHS.mp i j (hs₀⊦→chs⊦ ts)
hs₀⊦→chs⊦ (HS.ci ts) = CHS.ci (hs₀⊦→chs⊦ ts)
hs₀⊦→chs⊦ (HS.ck ts) = CHS.ck (hs₀⊦→chs⊦ ts)
hs₀⊦→chs⊦ (HS.cs ts) = CHS.cs (hs₀⊦→chs⊦ ts)
hs₀⊦→chs⊦ (HS.cpair ts) = CHS.cpair (hs₀⊦→chs⊦ ts)
hs₀⊦→chs⊦ (HS.cfst ts) = CHS.cfst (hs₀⊦→chs⊦ ts)
hs₀⊦→chs⊦ (HS.csnd ts) = CHS.csnd (hs₀⊦→chs⊦ ts)
hs₀⊦→chs⊦ (HS.unit ts) = CHS.unit (hs₀⊦→chs⊦ ts)
hs₀⊦→chs⊦ (HS.cboom ts) = CHS.cboom (hs₀⊦→chs⊦ ts)
hs₀⊦→chs⊦ (HS.cinl ts) = CHS.cinl (hs₀⊦→chs⊦ ts)
hs₀⊦→chs⊦ (HS.cinr ts) = CHS.cinr (hs₀⊦→chs⊦ ts)
hs₀⊦→chs⊦ (HS.ccase ts) = CHS.ccase (hs₀⊦→chs⊦ ts)
hs→chs : ∀ {A Γ} → HS⟨ Γ ⊢ A ⟩ → CHS.⊢ Γ ▻⋯▻ A
hs→chs t = hs₀→chs (hs-lam⋆₀ t)
-- Translation from closed Hilbert-style to Hilbert-style.
ch→h₀ : ∀ {A} → CH.⊢ A → H⟨ ∅ ⊢ A ⟩
ch→h₀ (CH.app t u) = H.app (ch→h₀ t) (ch→h₀ u)
ch→h₀ CH.ci = H.ci
ch→h₀ CH.ck = H.ck
ch→h₀ CH.cs = H.cs
ch→h₀ CH.cpair = H.cpair
ch→h₀ CH.cfst = H.cfst
ch→h₀ CH.csnd = H.csnd
ch→h₀ CH.unit = H.unit
ch→h₀ CH.cboom = H.cboom
ch→h₀ CH.cinl = H.cinl
ch→h₀ CH.cinr = H.cinr
ch→h₀ CH.ccase = H.ccase
ch→h : ∀ {A Γ} → CH.⊢ Γ ▻⋯▻ A → H⟨ Γ ⊢ A ⟩
ch→h t = H.det⋆₀ (ch→h₀ t)
-- Translation from Hilbert-style to closed Hilbert-style.
h₀→ch : ∀ {A} → H⟨ ∅ ⊢ A ⟩ → CH.⊢ A
h₀→ch (H.var ())
h₀→ch (H.app t u) = CH.app (h₀→ch t) (h₀→ch u)
h₀→ch H.ci = CH.ci
h₀→ch H.ck = CH.ck
h₀→ch H.cs = CH.cs
h₀→ch H.cpair = CH.cpair
h₀→ch H.cfst = CH.cfst
h₀→ch H.csnd = CH.csnd
h₀→ch H.unit = CH.unit
h₀→ch H.cboom = CH.cboom
h₀→ch H.cinl = CH.cinl
h₀→ch H.cinr = CH.cinr
h₀→ch H.ccase = CH.ccase
h→ch : ∀ {A Γ} → H⟨ Γ ⊢ A ⟩ → CH.⊢ Γ ▻⋯▻ A
h→ch t = h₀→ch (H.lam⋆₀ t)
-- Translation from Hilbert-style to Gentzen-style.
h→g : ∀ {A Γ} → H⟨ Γ ⊢ A ⟩ → G⟨ Γ ⊢ A ⟩
h→g (H.var i) = G.var i
h→g (H.app t u) = G.app (h→g t) (h→g u)
h→g H.ci = G.ci
h→g H.ck = G.ck
h→g H.cs = G.cs
h→g H.cpair = G.cpair
h→g H.cfst = G.cfst
h→g H.csnd = G.csnd
h→g H.unit = G.unit
h→g H.cboom = G.cboom
h→g H.cinl = G.cinl
h→g H.cinr = G.cinr
h→g H.ccase = G.ccase
-- Translation from Gentzen-style to Hilbert-style.
g→h : ∀ {A Γ} → G⟨ Γ ⊢ A ⟩ → H⟨ Γ ⊢ A ⟩
g→h (G.var i) = H.var i
g→h (G.lam t) = H.lam (g→h t)
g→h (G.app t u) = H.app (g→h t) (g→h u)
g→h (G.pair t u) = H.pair (g→h t) (g→h u)
g→h (G.fst t) = H.fst (g→h t)
g→h (G.snd t) = H.snd (g→h t)
g→h G.unit = H.unit
g→h (G.boom t) = H.boom (g→h t)
g→h (G.inl t) = H.inl (g→h t)
g→h (G.inr t) = H.inr (g→h t)
g→h (G.case t u v) = H.case (g→h t) (g→h u) (g→h v)
-- Additional translations from closed Hilbert-style sequential.
chs→h₀ : ∀ {A} → CHS.⊢ A → H⟨ ∅ ⊢ A ⟩
chs→h₀ = ch→h₀ ∘ chs→ch
chs→h : ∀ {A Γ} → CHS.⊢ Γ ▻⋯▻ A → H⟨ Γ ⊢ A ⟩
chs→h = ch→h ∘ chs→ch
chs→g₀ : ∀ {A} → CHS.⊢ A → G⟨ ∅ ⊢ A ⟩
chs→g₀ = h→g ∘ chs→h₀
chs→g : ∀ {A Γ} → CHS.⊢ Γ ▻⋯▻ A → G⟨ Γ ⊢ A ⟩
chs→g = h→g ∘ chs→h
-- Additional translations from closed Hilbert-style.
ch→hs₀ : ∀ {A} → CH.⊢ A → HS⟨ ∅ ⊢ A ⟩
ch→hs₀ = chs→hs₀ ∘ ch→chs
ch→hs : ∀ {A Γ} → CH.⊢ Γ ▻⋯▻ A → HS⟨ Γ ⊢ A ⟩
ch→hs = chs→hs ∘ ch→chs
ch→g₀ : ∀ {A} → CH.⊢ A → G⟨ ∅ ⊢ A ⟩
ch→g₀ = h→g ∘ ch→h₀
ch→g : ∀ {A Γ} → CH.⊢ Γ ▻⋯▻ A → G⟨ Γ ⊢ A ⟩
ch→g = h→g ∘ ch→h
-- Additional translations from Hilbert-style sequential.
hs₀→ch : ∀ {A} → HS⟨ ∅ ⊢ A ⟩ → CH.⊢ A
hs₀→ch = chs→ch ∘ hs₀→chs
hs→ch : ∀ {A Γ} → HS⟨ Γ ⊢ A ⟩ → CH.⊢ Γ ▻⋯▻ A
hs→ch = chs→ch ∘ hs→chs
hs→g : ∀ {A Γ} → HS⟨ Γ ⊢ A ⟩ → G⟨ Γ ⊢ A ⟩
hs→g = h→g ∘ hs→h
-- Additional translations from Hilbert-style.
h₀→chs : ∀ {A} → H⟨ ∅ ⊢ A ⟩ → CHS.⊢ A
h₀→chs = ch→chs ∘ h₀→ch
h→chs : ∀ {A Γ} → H⟨ Γ ⊢ A ⟩ → CHS.⊢ Γ ▻⋯▻ A
h→chs = ch→chs ∘ h→ch
-- Additional translations from Gentzen-style.
g₀→chs : ∀ {A} → G⟨ ∅ ⊢ A ⟩ → CHS.⊢ A
g₀→chs = h₀→chs ∘ g→h
g→chs : ∀ {A Γ} → G⟨ Γ ⊢ A ⟩ → CHS.⊢ Γ ▻⋯▻ A
g→chs = h→chs ∘ g→h
g₀→ch : ∀ {A} → G⟨ ∅ ⊢ A ⟩ → CH.⊢ A
g₀→ch = h₀→ch ∘ g→h
g→ch : ∀ {A Γ} → G⟨ Γ ⊢ A ⟩ → CH.⊢ Γ ▻⋯▻ A
g→ch = h→ch ∘ g→h
g→hs : ∀ {A Γ} → G⟨ Γ ⊢ A ⟩ → HS⟨ Γ ⊢ A ⟩
g→hs = h→hs ∘ g→h
| 31.858382
| 80
| 0.48544
|
9ad7022b36883edfd9379430f807a25bcca3d9db
| 826
|
agda
|
Agda
|
test/Succeed/Issue1153.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
test/Succeed/Issue1153.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
test/Succeed/Issue1153.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
-- Reported by Andrea, 2014-05-xx
-- We cannot prune from a meta if one of its arguments is a lambda.
-- (In some cases we could, but it is hard to get this right,
-- probably needs a flow analysis.)
-- {-# OPTIONS -v tc.meta.assign:25 -v tc.meta.kill:40 #-}
open import Common.Equality
open import Common.Product
postulate
F : Set → Set
A : Set
test : let H : Set
H = _
M : ((Set → Set) → Set) → Set
M = _
in {Z : Set} → H ≡ F (M (\ G → A → G Z))
× F H ≡ F (F (A → A))
× M ≡ \ K → K (\ _ → A)
test = refl
, refl
, refl
#1 : {A : Set} →
let H : Set
H = _
M : (Set → Set) → Set → Set
M = _
in {Z : Set} → H ≡ F (M (\ _ → A) Z)
× M ≡ (\ F X → F X)
#1 = refl , refl
| 23.6
| 67
| 0.445521
|
57147d57961de8e1cd1047de435d7f96edef6b23
| 265
|
agda
|
Agda
|
Cubical/Data/Int.agda
|
FernandoLarrain/cubical
|
9acdecfa6437ec455568be4e5ff04849cc2bc13b
|
[
"MIT"
] | 301
|
2018-10-17T18:00:24.000Z
|
2022-03-24T02:10:47.000Z
|
Cubical/Data/Int.agda
|
FernandoLarrain/cubical
|
9acdecfa6437ec455568be4e5ff04849cc2bc13b
|
[
"MIT"
] | 584
|
2018-10-15T09:49:02.000Z
|
2022-03-30T12:09:17.000Z
|
Cubical/Data/Int.agda
|
FernandoLarrain/cubical
|
9acdecfa6437ec455568be4e5ff04849cc2bc13b
|
[
"MIT"
] | 134
|
2018-11-16T06:11:03.000Z
|
2022-03-23T16:22:13.000Z
|
-- This is the preferred version of the integers in the library. Other
-- versions can be found in the MoreInts directory.
{-# OPTIONS --safe #-}
module Cubical.Data.Int where
open import Cubical.Data.Int.Base public
open import Cubical.Data.Int.Properties public
| 33.125
| 70
| 0.773585
|
19652ee6937dec5b44356358f243a4a52b180b84
| 606
|
agda
|
Agda
|
archive/agda-2/Oscar/Class/Symmetry.agda
|
m0davis/oscar
|
52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb
|
[
"RSA-MD"
] | null | null | null |
archive/agda-2/Oscar/Class/Symmetry.agda
|
m0davis/oscar
|
52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb
|
[
"RSA-MD"
] | 1
|
2019-04-29T00:35:04.000Z
|
2019-05-11T23:33:04.000Z
|
archive/agda-2/Oscar/Class/Symmetry.agda
|
m0davis/oscar
|
52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb
|
[
"RSA-MD"
] | null | null | null |
module Oscar.Class.Symmetry where
open import Oscar.Class.Extensionality
open import Oscar.Function
open import Oscar.Level
record Symmetry {a} {A : Set a} {ℓ} (_≤_ : A → A → Set ℓ) : Set (a ⊔ ℓ) where
field
⦃ ′extensionality ⦄ : Extensionality _≤_ (λ ⋆ → flip _≤_ ⋆) id id
symmetry : ∀ {x y} → x ≤ y → y ≤ x
symmetry = extension (λ ⋆ → flip _≤_ ⋆)
open Symmetry ⦃ … ⦄ public hiding (′extensionality)
instance
Symmetry⋆ : ∀
{a} {A : Set a} {ℓ} {_≤_ : A → A → Set ℓ}
⦃ _ : Extensionality _≤_ (λ ⋆ → flip _≤_ ⋆) id id ⦄
→ Symmetry _≤_
Symmetry.′extensionality Symmetry⋆ = it
| 25.25
| 77
| 0.607261
|
4b82c717d6c632682012fd1bacb85040e2298819
| 3,119
|
agda
|
Agda
|
src/fot/FOTC/Program/Division/CorrectnessProofATP.agda
|
asr/fotc
|
2fc9f2b81052a2e0822669f02036c5750371b72d
|
[
"MIT"
] | 11
|
2015-09-03T20:53:42.000Z
|
2021-09-12T16:09:54.000Z
|
src/fot/FOTC/Program/Division/CorrectnessProofATP.agda
|
asr/fotc
|
2fc9f2b81052a2e0822669f02036c5750371b72d
|
[
"MIT"
] | 2
|
2016-10-12T17:28:16.000Z
|
2017-01-01T14:34:26.000Z
|
src/fot/FOTC/Program/Division/CorrectnessProofATP.agda
|
asr/fotc
|
2fc9f2b81052a2e0822669f02036c5750371b72d
|
[
"MIT"
] | 3
|
2016-09-19T14:18:30.000Z
|
2018-03-14T08:50:00.000Z
|
------------------------------------------------------------------------------
-- The division program is correct
------------------------------------------------------------------------------
{-# OPTIONS --exact-split #-}
{-# OPTIONS --no-sized-types #-}
{-# OPTIONS --no-universe-polymorphism #-}
{-# OPTIONS --without-K #-}
-- N.B This module does not contain combined proofs, but it imports
-- modules which contain combined proofs.
-- This module proves the correctness of the division program using
-- repeated subtraction (Dybjer 1985).
module FOTC.Program.Division.CorrectnessProofATP where
open import FOTC.Base
open import FOTC.Data.Nat
open import FOTC.Data.Nat.Inequalities
open import FOTC.Data.Nat.Inequalities.PropertiesATP
open import FOTC.Data.Nat.PropertiesATP
import FOTC.Data.Nat.Induction.NonAcc.WF-ATP
open module WFInd = FOTC.Data.Nat.Induction.NonAcc.WF-ATP.WFInd
open import FOTC.Program.Division.Division
open import FOTC.Program.Division.ResultATP
open import FOTC.Program.Division.Specification
open import FOTC.Program.Division.TotalityATP
------------------------------------------------------------------------------
-- The division program is correct when the dividend is less than the
-- divisor.
div-x<y-correct : ∀ {i j} → N i → N j → i < j → divSpec i j (div i j)
div-x<y-correct Ni Nj i<j = div-x<y-N i<j , div-x<y-resultCorrect Ni Nj i<j
-- The division program is correct dividend is greater or equal than
-- the divisor.
div-x≮y-correct : ∀ {i j} → N i → N j →
(∀ {i'} → N i' → i' < i → divSpec i' j (div i' j)) →
j > zero →
i ≮ j →
divSpec i j (div i j)
div-x≮y-correct {i} {j} Ni Nj ah j>0 i≮j =
div-x≮y-N ih i≮j , div-x≮y-resultCorrect Ni Nj ih i≮j
where
-- The inductive hypothesis on i ∸ j.
ih : divSpec (i ∸ j) j (div (i ∸ j) j)
ih = ah {i ∸ j}
(∸-N Ni Nj)
(x≥y→y>0→x∸y<x Ni Nj (x≮y→x≥y Ni Nj i≮j) j>0)
------------------------------------------------------------------------------
-- The division program is correct.
-- We do the well-founded induction on i and we keep j fixed.
divCorrect : ∀ {i j} → N i → N j → j > zero → divSpec i j (div i j)
divCorrect {j = j} Ni Nj j>0 = <-wfind A ih Ni
where
A : D → Set
A d = divSpec d j (div d j)
-- The inductive step doesn't use the variable i (nor Ni). To make
-- this clear we write down the inductive step using the variables m
-- and n.
ih : ∀ {n} → N n → (∀ {m} → N m → m < n → A m) → A n
ih {n} Nn ah =
case (div-x<y-correct Nn Nj) (div-x≮y-correct Nn Nj ah j>0) (x<y∨x≮y Nn Nj)
------------------------------------------------------------------------------
-- References
--
-- Dybjer, Peter (1985). Program Verification in a Logical Theory of
-- Constructions. In: Functional Programming Languages and Computer
-- Architecture. Ed. by Jouannaud,
-- Jean-Pierre. Vol. 201. LNCS. Appears in revised form as Programming
-- Methodology Group Report 26, University of Gothenburg and Chalmers
-- University of Technology, June 1986. Springer, pp. 334–349.
| 38.506173
| 79
| 0.567169
|
9abe886d9b728bd1de017467fb08aa129cb0231b
| 539
|
agda
|
Agda
|
agda-stdlib/src/Data/List/Relation/Lex/Strict.agda
|
DreamLinuxer/popl21-artifact
|
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
|
[
"MIT"
] | 5
|
2020-10-07T12:07:53.000Z
|
2020-10-10T21:41:32.000Z
|
agda-stdlib/src/Data/List/Relation/Lex/Strict.agda
|
DreamLinuxer/popl21-artifact
|
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
|
[
"MIT"
] | null | null | null |
agda-stdlib/src/Data/List/Relation/Lex/Strict.agda
|
DreamLinuxer/popl21-artifact
|
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
|
[
"MIT"
] | 1
|
2021-11-04T06:54:45.000Z
|
2021-11-04T06:54:45.000Z
|
------------------------------------------------------------------------
-- The Agda standard library
--
-- This module is DEPRECATED. Please use
-- Data.List.Relation.Binary.Lex.Strict directly.
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
module Data.List.Relation.Lex.Strict where
open import Data.List.Relation.Binary.Lex.Strict public
{-# WARNING_ON_IMPORT
"Data.List.Relation.Lex.Strict was deprecated in v1.0.
Use Data.List.Relation.Binary.Lex.Strict instead."
#-}
| 29.944444
| 72
| 0.54731
|
adecd5911e729fce8fbb9dc353b6bdc1f99df86b
| 589
|
agda
|
Agda
|
test/Common/Product.agda
|
favonia/agda
|
8d433b967567c08afe15d04a5cb63b6f6d8884ee
|
[
"BSD-2-Clause"
] | null | null | null |
test/Common/Product.agda
|
favonia/agda
|
8d433b967567c08afe15d04a5cb63b6f6d8884ee
|
[
"BSD-2-Clause"
] | 6
|
2021-10-18T08:12:24.000Z
|
2021-11-24T08:31:10.000Z
|
test/Common/Product.agda
|
antoinevanmuylder/agda
|
bd59d5b07ffe02a43b28d186d95e1747aac5bc8c
|
[
"BSD-2-Clause"
] | null | null | null |
{-# OPTIONS --cubical-compatible #-}
module Common.Product where
open import Common.Level
infixr 4 _,_ _,′_
infixr 2 _×_
------------------------------------------------------------------------
-- Definition
record Σ {a b} (A : Set a) (B : A → Set b) : Set (a ⊔ b) where
constructor _,_
field
proj₁ : A
proj₂ : B proj₁
open Σ public
syntax Σ A (λ x → B) = Σ[ x ∶ A ] B
∃ : ∀ {a b} {A : Set a} → (A → Set b) → Set (a ⊔ b)
∃ = Σ _
_×_ : ∀ {a b} (A : Set a) (B : Set b) → Set (a ⊔ b)
A × B = Σ[ x ∶ A ] B
_,′_ : ∀ {a b} {A : Set a} {B : Set b} → A → B → A × B
_,′_ = _,_
| 19.633333
| 72
| 0.434635
|
ad5ac8050caf69cc4bc6460625a999133efc420c
| 383
|
agda
|
Agda
|
archive/agda-3/src/Oscar/Data/Descender.agda
|
m0davis/oscar
|
52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb
|
[
"RSA-MD"
] | null | null | null |
archive/agda-3/src/Oscar/Data/Descender.agda
|
m0davis/oscar
|
52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb
|
[
"RSA-MD"
] | 1
|
2019-04-29T00:35:04.000Z
|
2019-05-11T23:33:04.000Z
|
archive/agda-3/src/Oscar/Data/Descender.agda
|
m0davis/oscar
|
52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb
|
[
"RSA-MD"
] | null | null | null |
open import Oscar.Prelude
open import Oscar.Data.¶
module Oscar.Data.Descender where
-- m ≤ n, counting down from n-1 to m
data Descender⟨_⟩ {a} (A : ¶ → Ø a) (m : ¶) : ¶ → Ø a where
∅ : Descender⟨ A ⟩ m m
_,_ : ∀ {n} → A n → Descender⟨ A ⟩ m n → Descender⟨ A ⟩ m (↑ n)
Vec'⟨_⟩ = λ {a} (A : Ø a) N → Descender⟨ (λ _ → A) ⟩ 0 N
⟨_⟩¶⟨_≤_↓⟩ = Descender⟨_⟩
AList⟨_⟩ = ⟨_⟩¶⟨_≤_↓⟩
| 25.533333
| 65
| 0.537859
|
4d7cef3925b47b0bdc0c503bcaf2a6e6b6f7be9a
| 1,573
|
agda
|
Agda
|
demo/agda/FRP/JS/Demo/Calculator/Model.agda
|
agda/agda-frp-js
|
c7ccaca624cb1fa1c982d8a8310c313fb9a7fa72
|
[
"MIT",
"BSD-3-Clause"
] | 63
|
2015-04-20T21:47:00.000Z
|
2022-02-28T09:46:14.000Z
|
demo/agda/FRP/JS/Demo/Calculator/Model.agda
|
agda/agda-frp-js
|
c7ccaca624cb1fa1c982d8a8310c313fb9a7fa72
|
[
"MIT",
"BSD-3-Clause"
] | null | null | null |
demo/agda/FRP/JS/Demo/Calculator/Model.agda
|
agda/agda-frp-js
|
c7ccaca624cb1fa1c982d8a8310c313fb9a7fa72
|
[
"MIT",
"BSD-3-Clause"
] | 7
|
2016-11-07T21:50:58.000Z
|
2022-03-12T11:39:38.000Z
|
open import FRP.JS.Behaviour using ( Beh ; [_] ; map ; accumHoldBy )
open import FRP.JS.Event using ( Evt ; tag )
open import FRP.JS.DOM using ( DOM ; element ; text ; listen ; click ; _++_ ; element+ ; _+++_ )
open import FRP.JS.RSet using ( RSet ; ⟦_⟧ ; ⟨_⟩ ; _⇒_ )
open import FRP.JS.Nat using ( ℕ ; _+_ ; _*_ ; _∸_ ; show )
open import FRP.JS.Time using ( Time )
open import FRP.JS.String using ( String )
open import FRP.JS.Bool using ( Bool ; true ; false )
open import FRP.JS.Product using ( _∧_ ; _,_ )
module FRP.JS.Demo.Calculator.Model where
data Op : Set where
plus minus times eq : Op
data Button : Set where
digit : ℕ → Button
op : Op → Button
clear : Button
data State : Set where
state : ℕ → ℕ → Bool → Op → State
init : State
init = state 0 0 false eq
eval : ℕ → Op → ℕ → ℕ
eval m plus n = m + n
eval m minus n = m ∸ n
eval m times n = m * n
eval m eq n = n
step : State → Button → State
step (state m n true p) (digit d) = state m (n * 10 + d) true p
step (state m n false p) (digit d) = state n d true p
step (state m n true p) (op q) = state n (eval m p n) false q
step (state m n false p) (op q) = state m (eval m p n) false q
step (state m n b p) clear = state 0 0 false eq
button$ : Button → String
button$ (digit d) = show d
button$ (op plus) = "+"
button$ (op minus) = "-"
button$ (op times) = "×"
button$ (op eq) = "="
button$ clear = "C"
state$ : State → String
state$ (state m n b p) = show n
model : ⟦ Evt ⟨ Button ⟩ ⇒ Beh ⟨ State ⟩ ⟧
model = accumHoldBy step init
| 30.25
| 96
| 0.600127
|
a07abe6067a4f4a9698e168ab287bd8aa7e73db2
| 3,781
|
agda
|
Agda
|
benchmark/Syntacticosmos/Term.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
benchmark/Syntacticosmos/Term.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
benchmark/Syntacticosmos/Term.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
module Term (Gnd : Set)(U : Set)(El : U -> Set) where
open import Basics
open import Pr
open import Nom
import Kind
open module KindGUEl = Kind Gnd U El
import Loc
open module LocK = Loc Kind
import Cxt
open module CxtK = Cxt Kind
data Jud : Set where
Term : Kind -> Jud
Args : Kind -> Gnd -> Jud
Head : Jud
data _[_]-_ : Loc -> Jud -> Kind -> Set where
[_] : {C : Kind}{L : Loc}{Z : Gnd} ->
L [ Args C Z ]- C -> L [ Term C ]- Ty Z
fn : {C : Kind}{L : Loc}(A : U){K : El A -> Kind} ->
((x : El A) -> L [ Term C ]- K x) -> L [ Term C ]- Pi A K
\\ : {C : Kind}{L : Loc}{S T : Kind} ->
(L * S) [ Term C ]- T -> L [ Term C ]- (S |> T)
_^_ : {C : Kind}{L : Loc}{Z : Gnd}{A : U}{K : El A -> Kind} ->
(x : El A) -> L [ Args C Z ]- K x -> L [ Args C Z ]- Pi A K
_&_ : {C : Kind}{L : Loc}{S T : Kind}{Z : Gnd} ->
L [ Term C ]- S -> L [ Args C Z ]- T -> L [ Args C Z ]- (S |> T)
nil : {C : Kind}{L : Loc}{Z : Gnd} -> L [ Args C Z ]- Ty Z
_$_ : {C : Kind}{L : Loc}{T : Kind}{Z : Gnd} ->
L [ Head ]- T -> L [ Args C Z ]- T -> L [ Term C ]- Ty Z
` : Nom -> {S : Kind}{L : Loc} -> L [ Head ]- S
# : {L : Loc}{S : Kind} -> L ! S -> L [ Head ]- S
infixr 90 _^_ _&_
infix 40 _[_]-_
Good : Cxt -> {L : Loc}{j : Jud}{T : Kind} -> L [ j ]- T -> Pr
Good G [ c ] = Good G c
Good G (fn A f) = all (El A) \a -> Good G (f a)
Good G (\\ b) = Good G b
Good G (a ^ ss) = Good G ss
Good G (s & ss) = Good G s /\ Good G ss
Good G nil = tt
Good G (x $ ss) = Good G x /\ Good G ss
Good G (` x {S}) = GooN G S x
Good G (# v) = tt
data _[_/_]-_ (G : Cxt)(L : Loc)(j : Jud)(T : Kind) : Set where
_-!_ : (t : L [ j ]- T) -> [| Good G t |] -> G [ L / j ]- T
gtm : {G : Cxt}{L : Loc}{j : Jud}{T : Kind} -> G [ L / j ]- T -> L [ j ]- T
gtm (t -! _) = t
good : {G : Cxt}{L : Loc}{j : Jud}{T : Kind}
(t : G [ L / j ]- T) -> [| Good G (gtm t) |]
good (t -! g) = g
_[!_!]-_ : Cxt -> Kind -> Kind -> Set
G [! C !]- T = G [ EL / Term C ]- T
G[_] : {G : Cxt}{C : Kind}{L : Loc}{Z : Gnd} ->
G [ L / Args C Z ]- C ->
----------------------------
G [ L / Term C ]- Ty Z
G[ c -! cg ] = [ c ] -! cg
Gfn : {G : Cxt}{C : Kind}{L : Loc}(A : U){K : El A -> Kind} ->
((x : El A) -> G [ L / Term C ]- K x) ->
-------------------------------------------
G [ L / Term C ]- Pi A K
Gfn A f = fn A (gtm o f) -! (good o f)
G\\ : {G : Cxt}{C : Kind}{L : Loc}{S T : Kind} ->
G [ L * S / Term C ]- T ->
------------------------------
G [ L / Term C ]- (S |> T)
G\\ (b -! bg) = \\ b -! bg
_G^_ : {G : Cxt}{C : Kind}{L : Loc}{Z : Gnd}{A : U}{K : El A -> Kind} ->
(x : El A) ->
G [ L / Args C Z ]- K x ->
------------------------------
G [ L / Args C Z ]- Pi A K
a G^ (s -! sg) = (a ^ s) -! sg
_G&_ : {G : Cxt}{C : Kind}{L : Loc}{S T : Kind}{Z : Gnd} ->
G [ L / Term C ]- S ->
G [ L / Args C Z ]- T ->
----------------------------------
G [ L / Args C Z ]- (S |> T)
(r -! rg) G& (s -! sg) = (r & s) -! (rg , sg)
Gnil : {G : Cxt}{C : Kind}{L : Loc}{Z : Gnd} ->
-----------------------------
G [ L / Args C Z ]- Ty Z
Gnil = nil -! _
_G$_ : {G : Cxt}{C : Kind}{L : Loc}{T : Kind}{Z : Gnd} ->
G [ L / Head ]- T ->
G [ L / Args C Z ]- T ->
-----------------------------
G [ L / Term C ]- Ty Z
(h -! hg) G$ (s -! sg) = (h $ s) -! (hg , sg)
G` : {G : Cxt}{S : Kind}{L : Loc} -> Nom :- GooN G S ->
------------------------------------------------------
G [ L / Head ]- S
G` [ x / xg ] = ` x -! xg
G# : {G : Cxt}{L : Loc}{S : Kind} -> L ! S ->
--------------------------
G [ L / Head ]- S
G# v = # v -! _
infixr 90 _G^_ _G&_
| 29.310078
| 76
| 0.357842
|
29ef33bb54609d5d2c152ffd8a05e95e2940e7d6
| 492
|
agda
|
Agda
|
test/fail/Issue1015.agda
|
larrytheliquid/agda
|
477c8c37f948e6038b773409358fd8f38395f827
|
[
"MIT"
] | 1
|
2018-10-10T17:08:44.000Z
|
2018-10-10T17:08:44.000Z
|
test/fail/Issue1015.agda
|
masondesu/agda
|
70c8a575c46f6a568c7518150a1a64fcd03aa437
|
[
"MIT"
] | null | null | null |
test/fail/Issue1015.agda
|
masondesu/agda
|
70c8a575c46f6a568c7518150a1a64fcd03aa437
|
[
"MIT"
] | 1
|
2022-03-12T11:35:18.000Z
|
2022-03-12T11:35:18.000Z
|
-- Andreas, 2014-03-27 fixed issue
{-# OPTIONS --copatterns --sized-types #-}
open import Common.Size
mutual
data D (i : Size) : Set where
inn : R i → D i
record R (i : Size) : Set where
-- Note: not coinductive
field
force : (j : Size< i) → D j
open R
inh : (i : Size) → R i
force (inh i) j = inn (inh j)
-- inh should be rejected by termination checker
data ⊥ : Set where
elim : D ∞ → ⊥
elim (inn r) = elim (force r ∞)
absurd : ⊥
absurd = elim (inn (inh ∞))
| 16.4
| 48
| 0.583333
|
1a7e720991d776b984ded657cb7d23495468c150
| 1,203
|
agda
|
Agda
|
theorems/cw/cohomology/ReconstructedCohomologyGroups.agda
|
mikeshulman/HoTT-Agda
|
e7d663b63d89f380ab772ecb8d51c38c26952dbb
|
[
"MIT"
] | null | null | null |
theorems/cw/cohomology/ReconstructedCohomologyGroups.agda
|
mikeshulman/HoTT-Agda
|
e7d663b63d89f380ab772ecb8d51c38c26952dbb
|
[
"MIT"
] | null | null | null |
theorems/cw/cohomology/ReconstructedCohomologyGroups.agda
|
mikeshulman/HoTT-Agda
|
e7d663b63d89f380ab772ecb8d51c38c26952dbb
|
[
"MIT"
] | 1
|
2018-12-26T21:31:57.000Z
|
2018-12-26T21:31:57.000Z
|
{-# OPTIONS --without-K --rewriting #-}
open import HoTT
open import cohomology.ChainComplex
open import cohomology.Theory
open import groups.KernelImage
open import cw.CW
module cw.cohomology.ReconstructedCohomologyGroups {i : ULevel} (OT : OrdinaryTheory i) where
open OrdinaryTheory OT
open import cw.cohomology.Descending OT
open import cw.cohomology.ReconstructedCochainComplex OT
open import cw.cohomology.ReconstructedZerothCohomologyGroup OT
open import cw.cohomology.ReconstructedFirstCohomologyGroup OT
open import cw.cohomology.ReconstructedHigherCohomologyGroups OT
abstract
reconstructed-cohomology-group : ∀ m {n} (⊙skel : ⊙Skeleton {i} n)
→ ⊙has-cells-with-choice 0 ⊙skel i
→ C m ⊙⟦ ⊙skel ⟧ ≃ᴳ cohomology-group (cochain-complex ⊙skel) m
reconstructed-cohomology-group (pos 0) ⊙skel ac =
zeroth-cohomology-group ⊙skel ac
reconstructed-cohomology-group (pos 1) ⊙skel ac =
first-cohomology-group ⊙skel ac
reconstructed-cohomology-group (pos (S (S m))) ⊙skel ac =
higher-cohomology-group m ⊙skel ac
reconstructed-cohomology-group (negsucc m) ⊙skel ac =
lift-iso {j = i} ∘eᴳ trivial-iso-0ᴳ (C-cw-at-negsucc ⊙skel m ac)
| 40.1
| 93
| 0.739817
|
13adbe0d4f9f6eb3628535a033a5b93fbdc4085b
| 1,624
|
agda
|
Agda
|
Cubical/Data/Queue/Finite.agda
|
kiana-S/univalent-foundations
|
8bdb0766260489f9c89a14f4c0f2ad26e5190dec
|
[
"MIT"
] | null | null | null |
Cubical/Data/Queue/Finite.agda
|
kiana-S/univalent-foundations
|
8bdb0766260489f9c89a14f4c0f2ad26e5190dec
|
[
"MIT"
] | 1
|
2022-01-27T02:07:48.000Z
|
2022-01-27T02:07:48.000Z
|
Cubical/Data/Queue/Finite.agda
|
kiana-S/univalent-foundations
|
8bdb0766260489f9c89a14f4c0f2ad26e5190dec
|
[
"MIT"
] | 1
|
2021-11-22T02:02:01.000Z
|
2021-11-22T02:02:01.000Z
|
{-# OPTIONS --cubical --no-import-sorts --no-exact-split --safe #-}
module Cubical.Data.Queue.Finite where
open import Cubical.Foundations.Everything
open import Cubical.Foundations.SIP
open import Cubical.Structures.Queue
open import Cubical.Data.Maybe
open import Cubical.Data.List
open import Cubical.Data.Sigma
open import Cubical.HITs.PropositionalTruncation
open import Cubical.Data.Queue.1List
-- All finite queues are equal to 1List.Finite
private
variable
ℓ : Level
module _ (A : Type ℓ) (Aset : isSet A) where
open Queues-on A Aset
private
module One = 1List A Aset
open One renaming (Q to Q₁; emp to emp₁; enq to enq₁; deq to deq₁)
isContrFiniteQueue : isContr FiniteQueue
isContrFiniteQueue .fst = One.Finite
isContrFiniteQueue .snd (Q , (S@(emp , enq , deq) , _ , deq-emp , deq-enq , _) , fin) =
sip finiteQueueUnivalentStr _ _ ((f , fin) , f∘emp , f∘enq , sym ∘ f∘deq)
where
deq₁-enq₁ = str One.WithLaws .snd .snd .snd .fst
f : Q₁ → Q
f = foldr enq emp
f∘emp : f emp₁ ≡ emp
f∘emp = refl
f∘enq : ∀ a xs → f (enq₁ a xs) ≡ enq a (f xs)
f∘enq _ _ = refl
fA : Q₁ × A → Q × A
fA (q , a) = (f q , a)
f∘returnOrEnq : (x : A) (xsr : Maybe (List A × A)) →
returnOrEnq S x (deqMap f xsr) ≡ fA (returnOrEnq (str One.Raw) x xsr)
f∘returnOrEnq _ nothing = refl
f∘returnOrEnq _ (just _) = refl
f∘deq : ∀ xs → deq (f xs) ≡ deqMap f (deq₁ xs)
f∘deq [] = deq-emp
f∘deq (x ∷ xs) =
deq-enq x (f xs)
∙ cong (just ∘ returnOrEnq S x) (f∘deq xs)
∙ cong just (f∘returnOrEnq x (deq₁ xs))
∙ cong (deqMap f) (sym (deq₁-enq₁ x xs))
| 27.525424
| 88
| 0.64101
|
19a1cd2898cf8da43aba6107e1fb956cd7d97f1f
| 10,162
|
agda
|
Agda
|
Structure/Operator/Properties.agda
|
Lolirofle/stuff-in-agda
|
70f4fba849f2fd779c5aaa5af122ccb6a5b271ba
|
[
"MIT"
] | 6
|
2020-04-07T17:58:13.000Z
|
2022-02-05T06:53:22.000Z
|
Structure/Operator/Properties.agda
|
Lolirofle/stuff-in-agda
|
70f4fba849f2fd779c5aaa5af122ccb6a5b271ba
|
[
"MIT"
] | null | null | null |
Structure/Operator/Properties.agda
|
Lolirofle/stuff-in-agda
|
70f4fba849f2fd779c5aaa5af122ccb6a5b271ba
|
[
"MIT"
] | null | null | null |
module Structure.Operator.Properties where
import Lvl
open import Functional
open import Lang.Instance
open import Logic
open import Logic.Predicate
open import Logic.Propositional
import Structure.Operator.Names as Names
open import Structure.Setoid
open import Syntax.Function
open import Type
private variable ℓ ℓₑ ℓ₁ ℓ₂ ℓ₃ ℓₑ₁ ℓₑ₂ ℓₑ₃ : Lvl.Level
module _ {T₁ : Type{ℓ₁}} {T₂ : Type{ℓ₂}} ⦃ _ : Equiv{ℓₑ₂}(T₂) ⦄ (_▫_ : T₁ → T₁ → T₂) where
record Commutativity : Stmt{Lvl.of(Type.of(_▫_)) Lvl.⊔ ℓₑ₂} where
constructor intro
field proof : Names.Commutativity(_▫_)
commutativity = inst-fn Commutativity.proof
module _ {T₁ : Type{ℓ₁}} {T₂ : Type{ℓ₂}} ⦃ _ : Equiv{ℓₑ₂}(T₂) ⦄ (_▫_ : T₁ → T₂ → T₂) (id : T₁) where
record Identityₗ : Stmt{Lvl.of(Type.of(_▫_)) Lvl.⊔ ℓₑ₂} where
constructor intro
field proof : Names.Identityₗ(_▫_)(id)
identityₗ = inst-fn Identityₗ.proof
module _ {T₁ : Type{ℓ₁}} {T₂ : Type{ℓ₂}} ⦃ _ : Equiv{ℓₑ₂}(T₂) ⦄ (_▫_ : T₁ → T₂ → T₂) (null : T₂) where
record Absorberᵣ : Stmt{Lvl.of(Type.of(_▫_)) Lvl.⊔ ℓₑ₂} where
constructor intro
field proof : Names.Absorberᵣ(_▫_)(null)
absorberᵣ = inst-fn Absorberᵣ.proof
module _ {T₁ : Type{ℓ₁}} ⦃ _ : Equiv{ℓₑ₁}(T₁) ⦄ {T₂ : Type{ℓ₂}} (_▫_ : T₁ → T₂ → T₁) (id : T₂) where
record Identityᵣ : Stmt{Lvl.of(Type.of(_▫_)) Lvl.⊔ ℓₑ₁} where
constructor intro
field proof : Names.Identityᵣ(_▫_)(id)
identityᵣ = inst-fn Identityᵣ.proof
module _ {T₁ : Type{ℓ₁}} ⦃ _ : Equiv{ℓₑ₁}(T₁) ⦄ {T₂ : Type{ℓ₂}} (_▫_ : T₁ → T₂ → T₁) (null : T₁) where
record Absorberₗ : Stmt{Lvl.of(Type.of(_▫_)) Lvl.⊔ ℓₑ₁} where
constructor intro
field proof : Names.Absorberₗ(_▫_)(null)
absorberₗ = inst-fn Absorberₗ.proof
module _{T : Type{ℓ}} ⦃ _ : Equiv{ℓₑ}(T) ⦄ (_▫_ : T → T → T) (id : T) where
record Identity : Stmt{Lvl.of(Type.of(_▫_)) Lvl.⊔ ℓₑ} where
constructor intro
field
instance ⦃ left ⦄ : Identityₗ(_▫_)(id)
instance ⦃ right ⦄ : Identityᵣ(_▫_)(id)
identity-left = inst-fn (Identityₗ.proof ∘ Identity.left)
identity-right = inst-fn (Identityᵣ.proof ∘ Identity.right)
module _{T : Type{ℓ}} ⦃ _ : Equiv{ℓₑ}(T) ⦄ (_▫_ : T → T → T) where
record Idempotence : Stmt{Lvl.of(Type.of(_▫_)) Lvl.⊔ ℓₑ} where
constructor intro
field proof : Names.Idempotence(_▫_)
idempotence = inst-fn Idempotence.proof
module _{T : Type{ℓ}} ⦃ _ : Equiv{ℓₑ}(T) ⦄ (_▫_ : T → T → T) (id : T) where
record Absorber : Stmt{Lvl.of(Type.of(_▫_)) Lvl.⊔ ℓₑ} where
constructor intro
field
instance ⦃ left ⦄ : Absorberₗ(_▫_)(id)
instance ⦃ right ⦄ : Absorberᵣ(_▫_)(id)
absorber-left = inst-fn (Absorberₗ.proof ∘ Absorber.left)
absorber-right = inst-fn (Absorberᵣ.proof ∘ Absorber.right)
module _{T : Type{ℓ}} ⦃ _ : Equiv{ℓₑ}(T) ⦄ (_▫_ : T → T → T) ⦃ identityₗ : ∃(Identityₗ(_▫_)) ⦄ where
module _ (x : T) where
module _ (inv : T) where
record InverseElementₗ : Stmt{Lvl.of(Type.of(_▫_)) Lvl.⊔ ℓₑ} where
constructor intro
field proof : Names.InverseElementₗ(_▫_)([∃]-witness identityₗ)(x)(inv)
inverseElementₗ = inst-fn InverseElementₗ.proof
InvertibleElementₗ = ∃(InverseElementₗ)
module _ (inv : T → T) where
record InverseFunctionₗ : Stmt{Lvl.of(Type.of(_▫_)) Lvl.⊔ ℓₑ} where
constructor intro
field proof : Names.InverseFunctionₗ(_▫_)([∃]-witness identityₗ)(inv)
inverseFunctionₗ = inst-fn InverseFunctionₗ.proof
Invertibleₗ = ∃(InverseFunctionₗ)
module _{T : Type{ℓ}} ⦃ _ : Equiv{ℓₑ}(T) ⦄ (_▫_ : T → T → T) ⦃ identityᵣ : ∃(Identityᵣ(_▫_)) ⦄ where
module _ (x : T) where
module _ (inv : T) where
record InverseElementᵣ : Stmt{Lvl.of(Type.of(_▫_)) Lvl.⊔ ℓₑ} where
constructor intro
field proof : Names.InverseElementᵣ(_▫_)([∃]-witness identityᵣ)(x)(inv)
inverseElementᵣ = inst-fn InverseElementᵣ.proof
InvertibleElementᵣ = ∃(InverseElementᵣ)
module _ (inv : T → T) where
record InverseFunctionᵣ : Stmt{Lvl.of(Type.of(_▫_)) Lvl.⊔ ℓₑ} where
constructor intro
field proof : Names.InverseFunctionᵣ(_▫_)([∃]-witness identityᵣ)(inv)
inverseFunctionᵣ = inst-fn InverseFunctionᵣ.proof
Invertibleᵣ = ∃(InverseFunctionᵣ)
module _{T : Type{ℓ}} ⦃ _ : Equiv{ℓₑ}(T) ⦄ (_▫_ : T → T → T) ⦃ identity : ∃(Identity(_▫_)) ⦄ where
module _ (x : T) where
module _ (inv : T) where
InverseElement : Stmt
InverseElement =
InverseElementₗ(_▫_) ⦃ [∃]-map-proof Identity.left identity ⦄ (x)(inv) ∧
InverseElementᵣ(_▫_) ⦃ [∃]-map-proof Identity.right identity ⦄ (x)(inv)
InvertibleElement = ∃(InverseElement)
module _ (inv : T → T) where
import Logic.IntroInstances
record InverseFunction : Stmt{Lvl.of(Type.of(_▫_)) Lvl.⊔ ℓₑ} where
constructor intro
field
instance ⦃ left ⦄ : InverseFunctionₗ(_▫_) ⦃ [∃]-map-proof Identity.left identity ⦄ (inv)
instance ⦃ right ⦄ : InverseFunctionᵣ(_▫_) ⦃ [∃]-map-proof Identity.right identity ⦄ (inv)
inverseFunction-left = inst-fn (InverseFunctionₗ.proof ∘ InverseFunction.left)
inverseFunction-right = inst-fn (InverseFunctionᵣ.proof ∘ InverseFunction.right)
Invertible = ∃(InverseFunction)
-- TODO: Add some kind of inverse function
module _{T : Type{ℓ}} ⦃ _ : Equiv{ℓₑ}(T) ⦄ (_▫_ : T → T → T) ⦃ absorberₗ : ∃(Absorberₗ(_▫_)) ⦄ where
module _ (opp : T → T) where
record ComplementFunctionₗ : Stmt{Lvl.of(Type.of(_▫_)) Lvl.⊔ ℓₑ} where
constructor intro
field proof : Names.InverseFunctionₗ(_▫_)([∃]-witness absorberₗ)(opp)
oppositeFunctionₗ = inst-fn ComplementFunctionₗ.proof
module _{T : Type{ℓ}} ⦃ _ : Equiv{ℓₑ}(T) ⦄ (_▫_ : T → T → T) ⦃ absorberᵣ : ∃(Absorberᵣ(_▫_)) ⦄ where
module _ (opp : T → T) where
record ComplementFunctionᵣ : Stmt{Lvl.of(Type.of(_▫_)) Lvl.⊔ ℓₑ} where
constructor intro
field proof : Names.InverseFunctionᵣ(_▫_)([∃]-witness absorberᵣ)(opp)
oppositeFunctionᵣ = inst-fn ComplementFunctionᵣ.proof
module _{T : Type{ℓ}} ⦃ _ : Equiv{ℓₑ}(T) ⦄ (_▫_ : T → T → T) ⦃ absorber : ∃(Absorber(_▫_)) ⦄ where
module _ (opp : T → T) where
record ComplementFunction : Stmt{Lvl.of(Type.of(_▫_)) Lvl.⊔ ℓₑ} where
constructor intro
field
instance ⦃ left ⦄ : ComplementFunctionₗ(_▫_) ⦃ [∃]-map-proof Absorber.left absorber ⦄ (opp)
instance ⦃ right ⦄ : ComplementFunctionᵣ(_▫_) ⦃ [∃]-map-proof Absorber.right absorber ⦄ (opp)
module _{T : Type{ℓ}} ⦃ _ : Equiv{ℓₑ}(T) ⦄ (_▫_ : T → T → T) where
record Associativity : Stmt{Lvl.of(Type.of(_▫_)) Lvl.⊔ ℓₑ} where
constructor intro
field proof : Names.Associativity(_▫_)
associativity = inst-fn Associativity.proof
module _ {T₁ : Type{ℓ₁}} {T₂ : Type{ℓ₂}} ⦃ _ : Equiv{ℓₑ₂}(T₂) ⦄ (_▫₁_ : T₁ → T₂ → T₂) (_▫₂_ : T₂ → T₂ → T₂) where
record Distributivityₗ : Stmt{Lvl.of(Type.of(_▫₁_)) Lvl.⊔ Lvl.of(Type.of(_▫₂_)) Lvl.⊔ ℓₑ₂} where
constructor intro
field proof : Names.Distributivityₗ(_▫₁_)(_▫₂_)
distributivityₗ = inst-fn Distributivityₗ.proof
module _ {T₁ : Type{ℓ₁}} {T₂ : Type{ℓ₂}} ⦃ _ : Equiv{ℓₑ₂}(T₂) ⦄ (_▫₁_ : T₂ → T₁ → T₂) (_▫₂_ : T₂ → T₂ → T₂) where
record Distributivityᵣ : Stmt{Lvl.of(Type.of(_▫₁_)) Lvl.⊔ Lvl.of(Type.of(_▫₂_)) Lvl.⊔ ℓₑ₂} where
constructor intro
field proof : Names.Distributivityᵣ(_▫₁_)(_▫₂_)
distributivityᵣ = inst-fn Distributivityᵣ.proof
module _ {T₁ : Type{ℓ₁}} {T₂ : Type{ℓ₂}} ⦃ _ : Equiv{ℓₑ₂}(T₂) ⦄ {T₃ : Type{ℓ₃}} ⦃ _ : Equiv{ℓₑ₃}(T₃) ⦄ (_▫_ : T₁ → T₂ → T₃) where
record Cancellationₗ : Stmt{Lvl.of(Type.of(_▫_)) Lvl.⊔ ℓₑ₂ Lvl.⊔ ℓₑ₃} where
constructor intro
field proof : Names.Cancellationₗ(_▫_)
cancellationₗ = inst-fn Cancellationₗ.proof
module _ {T₁ : Type{ℓ₁}} ⦃ _ : Equiv{ℓₑ₁}(T₁) ⦄ {T₂ : Type{ℓ₂}} {T₃ : Type{ℓ₃}} ⦃ _ : Equiv{ℓₑ₃}(T₃) ⦄ (_▫_ : T₁ → T₂ → T₃) where
record Cancellationᵣ : Stmt{Lvl.of(Type.of(_▫_)) Lvl.⊔ ℓₑ₁ Lvl.⊔ ℓₑ₃} where
constructor intro
field proof : Names.Cancellationᵣ(_▫_)
cancellationᵣ = inst-fn Cancellationᵣ.proof
module _ {T₁ : Type{ℓ₁}} {T₂ : Type{ℓ₂}} {T₃ : Type{ℓ₃}} ⦃ _ : Equiv{ℓₑ₁}(T₁) ⦄ (_▫₁_ : T₁ → T₃ → T₁) (_▫₂_ : T₁ → T₂ → T₃) where
record Absorptionₗ : Stmt{Lvl.of(Type.of(_▫₁_)) Lvl.⊔ Lvl.of(Type.of(_▫₂_)) Lvl.⊔ ℓₑ₁} where
constructor intro
field proof : Names.Absorptionₗ(_▫₁_)(_▫₂_)
absorptionₗ = inst-fn Absorptionₗ.proof
module _ {T₁ : Type{ℓ₁}} {T₂ : Type{ℓ₂}} {T₃ : Type{ℓ₃}} ⦃ _ : Equiv{ℓₑ₂}(T₂) ⦄ (_▫₁_ : T₃ → T₂ → T₂) (_▫₂_ : T₁ → T₂ → T₃) where
record Absorptionᵣ : Stmt{Lvl.of(Type.of(_▫₁_)) Lvl.⊔ Lvl.of(Type.of(_▫₂_)) Lvl.⊔ ℓₑ₂} where
constructor intro
field proof : Names.Absorptionᵣ(_▫₁_)(_▫₂_)
absorptionᵣ = inst-fn Absorptionᵣ.proof
module _ {T₁ : Type{ℓ₁}} {T₂ : Type{ℓ₂}} {T₃ : Type{ℓ₃}} ⦃ _ : Equiv{ℓₑ₂}(T₂) ⦄ (_▫₁_ : T₁ → T₂ → T₃) (_▫₂_ : T₁ → T₃ → T₂) where
record InverseOperatorₗ : Stmt{Lvl.of(Type.of(_▫₁_)) Lvl.⊔ Lvl.of(Type.of(_▫₂_)) Lvl.⊔ ℓₑ₂} where
constructor intro
field proof : Names.InverseOperatorₗ(_▫₁_)(_▫₂_)
inverseOperₗ = inst-fn InverseOperatorₗ.proof
module _ {T₁ : Type{ℓ₁}} {T₂ : Type{ℓ₂}} {T₃ : Type{ℓ₃}} ⦃ _ : Equiv{ℓₑ₁}(T₁) ⦄ (_▫₁_ : T₁ → T₂ → T₃) (_▫₂_ : T₃ → T₂ → T₁) where
record InverseOperatorᵣ : Stmt{Lvl.of(Type.of(_▫₁_)) Lvl.⊔ Lvl.of(Type.of(_▫₂_)) Lvl.⊔ ℓₑ₁} where
constructor intro
field proof : Names.InverseOperatorᵣ(_▫₁_)(_▫₂_)
inverseOperᵣ = inst-fn InverseOperatorᵣ.proof
module _ {T₁ : Type{ℓ₁}} {T₂ : Type{ℓ₂}} ⦃ _ : Equiv{ℓₑ₂}(T₂) ⦄ (_▫_ : T₁ → T₂ → T₂) (inv : T₁ → T₁) where
InversePropertyₗ = InverseOperatorₗ(_▫_)(a ↦ b ↦ inv(a) ▫ b)
module InversePropertyₗ = InverseOperatorₗ{_▫₁_ = _▫_}{_▫₂_ = a ↦ b ↦ inv(a) ▫ b}
inversePropₗ = inverseOperₗ(_▫_)(a ↦ b ↦ inv(a) ▫ b)
module _ {T₁ : Type{ℓ₁}} {T₂ : Type{ℓ₂}} ⦃ _ : Equiv{ℓₑ₂}(T₂) ⦄ (_▫_ : T₂ → T₁ → T₂) (inv : T₁ → T₁) where
InversePropertyᵣ = InverseOperatorᵣ(_▫_)(a ↦ b ↦ a ▫ inv(b))
module InversePropertyᵣ = InverseOperatorᵣ{_▫₁_ = _▫_}{_▫₂_ = a ↦ b ↦ a ▫ inv(b)}
inversePropᵣ = inverseOperᵣ(_▫_)(a ↦ b ↦ a ▫ inv(b))
module _ {T₁ : Type{ℓ₁}} {T₂ : Type{ℓ₂}} ⦃ _ : Equiv{ℓₑ₂}(T₂) ⦄ (_▫_ : T₁ → T₁ → T₂) where
record Central(x : T₁) : Stmt{ℓ₁ Lvl.⊔ ℓₑ₂} where
constructor intro
field proof : ∀{y : T₁} → (x ▫ y ≡ y ▫ x)
| 47.485981
| 129
| 0.637473
|
03a0ffcc8c6324f0a96f486709cb33c86b18413e
| 2,325
|
agda
|
Agda
|
archive/agda-1/UnifyMguF.agda
|
m0davis/oscar
|
52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb
|
[
"RSA-MD"
] | null | null | null |
archive/agda-1/UnifyMguF.agda
|
m0davis/oscar
|
52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb
|
[
"RSA-MD"
] | 1
|
2019-04-29T00:35:04.000Z
|
2019-05-11T23:33:04.000Z
|
archive/agda-1/UnifyMguF.agda
|
m0davis/oscar
|
52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb
|
[
"RSA-MD"
] | null | null | null |
open import Relation.Binary using (IsDecEquivalence)
open import Agda.Builtin.Equality
module UnifyMguF (FunctionName : Set) ⦃ isDecEquivalenceA : IsDecEquivalence (_≡_ {A = FunctionName}) ⦄ where
{-
module UnifyMguF where
postulate
FunctionName : Set
instance isDecEquivalenceA : IsDecEquivalence (_≡_ {A = FunctionName})
-}
open IsDecEquivalence isDecEquivalenceA using () renaming (_≟_ to _≟F_)
open import UnifyTermF FunctionName
open import Data.Product using (∃; _,_)
open import Data.Maybe using (Maybe; just; nothing)
open import Category.Monad using (RawMonad)
import Level
open RawMonad (Data.Maybe.monad {Level.zero})
open import Relation.Nullary using (Dec; yes; no)
open import Data.Nat using (ℕ; _≟_)
open import Function using (flip; _∘_)
open import Data.Vec using (Vec; []; _∷_)
record ⋆amgu (T : ℕ → Set) : Set where
field amgu : ∀ {m} (s t : T m) (acc : ∃ (AList m)) -> Maybe (∃ (AList m))
open ⋆amgu ⦃ … ⦄ public
mutual
instance ⋆amguTerm : ⋆amgu Term
⋆amgu.amgu ⋆amguTerm leaf leaf acc = just acc
⋆amgu.amgu ⋆amguTerm leaf (function _ _) acc = nothing
⋆amgu.amgu ⋆amguTerm leaf (s' fork t') acc = nothing
⋆amgu.amgu ⋆amguTerm (s' fork t') leaf acc = nothing
⋆amgu.amgu ⋆amguTerm (s' fork t') (function _ _) acc = nothing
⋆amgu.amgu ⋆amguTerm (s1 fork s2) (t1 fork t2) acc =
amgu s2 t2 =<< amgu s1 t1 acc
⋆amgu.amgu ⋆amguTerm (function fn₁ ts₁) leaf acc = nothing
⋆amgu.amgu ⋆amguTerm (function fn₁ {n₁} ts₁) (function fn₂ {n₂} ts₂) acc
with fn₁ ≟F fn₂
… | no _ = nothing
… | yes _ with n₁ ≟ n₂
… | no _ = nothing
… | yes refl = amgu ts₁ ts₂ acc
⋆amgu.amgu ⋆amguTerm (function fn₁ ts₁) (_ fork _) acc = nothing
⋆amgu.amgu ⋆amguTerm (i x) (i y) (m , anil) = just (flexFlex x y)
⋆amgu.amgu ⋆amguTerm (i x) t (m , anil) = flexRigid x t
⋆amgu.amgu ⋆amguTerm t (i x) (m , anil) = flexRigid x t
⋆amgu.amgu ⋆amguTerm s t (n , σ asnoc r / z) =
(λ σ -> σ ∃asnoc r / z) <$>
amgu ((r for z) ◃ s) ((r for z) ◃ t) (n , σ)
instance ⋆amguVecTerm : ∀ {N} → ⋆amgu (flip Vec N ∘ Term)
⋆amgu.amgu ⋆amguVecTerm [] [] acc = just acc
⋆amgu.amgu ⋆amguVecTerm (t₁ ∷ t₁s) (t₂ ∷ t₂s) acc = amgu t₁s t₂s =<< amgu t₁ t₂ acc
mgu : ∀ {m} -> (s t : Term m) -> Maybe (∃ (AList m))
mgu {m} s t = amgu s t (m , anil)
| 35.227273
| 109
| 0.637849
|
5829e96324aa243003201bd3daf8060ad4633971
| 69
|
agda
|
Agda
|
setoid-cats/Category/Monoidal.agda
|
heades/AUGL
|
b33c6a59d664aed46cac8ef77d34313e148fecc2
|
[
"MIT"
] | null | null | null |
setoid-cats/Category/Monoidal.agda
|
heades/AUGL
|
b33c6a59d664aed46cac8ef77d34313e148fecc2
|
[
"MIT"
] | null | null | null |
setoid-cats/Category/Monoidal.agda
|
heades/AUGL
|
b33c6a59d664aed46cac8ef77d34313e148fecc2
|
[
"MIT"
] | null | null | null |
module Category.Monoidal where
open import Category.NatIsomorphism
| 13.8
| 35
| 0.855072
|
2e865f5cd9acf803096cfd59165c026e7fd0db7a
| 2,880
|
agda
|
Agda
|
src/Dodo/Binary/Intersection.agda
|
sourcedennis/agda-dodo
|
376f0ccee1e1aa31470890e494bcb534324f598a
|
[
"BSD-3-Clause"
] | null | null | null |
src/Dodo/Binary/Intersection.agda
|
sourcedennis/agda-dodo
|
376f0ccee1e1aa31470890e494bcb534324f598a
|
[
"BSD-3-Clause"
] | null | null | null |
src/Dodo/Binary/Intersection.agda
|
sourcedennis/agda-dodo
|
376f0ccee1e1aa31470890e494bcb534324f598a
|
[
"BSD-3-Clause"
] | null | null | null |
{-# OPTIONS --without-K --safe #-}
module Dodo.Binary.Intersection where
-- Stdlib imports
open import Level using (Level; _⊔_)
open import Data.Product as P
open import Data.Product using (_×_; _,_; swap; proj₁; proj₂)
open import Relation.Binary using (REL)
-- Local imports
open import Dodo.Binary.Equality
-- # Definitions
infixl 30 _∩₂_
_∩₂_ : {a b ℓ₁ ℓ₂ : Level} {A : Set a} {B : Set b}
→ REL A B ℓ₁
→ REL A B ℓ₂
→ REL A B (ℓ₁ ⊔ ℓ₂)
_∩₂_ P Q x y = P x y × Q x y
-- # Properties
module _ {a b ℓ : Level} {A : Set a} {B : Set b} {R : REL A B ℓ} where
∩₂-idem : (R ∩₂ R) ⇔₂ R
∩₂-idem = ⇔: ⊆-proof ⊇-proof
where
⊆-proof : (R ∩₂ R) ⊆₂' R
⊆-proof _ _ = proj₁
⊇-proof : R ⊆₂' (R ∩₂ R)
⊇-proof _ _ Rxy = (Rxy , Rxy)
module _ {a b ℓ₁ ℓ₂ : Level} {A : Set a} {B : Set b}
{P : REL A B ℓ₁} {Q : REL A B ℓ₂} where
∩₂-comm : (P ∩₂ Q) ⇔₂ (Q ∩₂ P)
∩₂-comm = ⇔: (λ _ _ → swap) (λ _ _ → swap)
module _ {a b ℓ₁ ℓ₂ ℓ₃ : Level} {A : Set a} {B : Set b}
{P : REL A B ℓ₁} {Q : REL A B ℓ₂} {R : REL A B ℓ₃} where
∩₂-assoc : P ∩₂ (Q ∩₂ R) ⇔₂ (P ∩₂ Q) ∩₂ R
∩₂-assoc = ⇔: ⊆-proof ⊇-proof
where
⊆-proof : P ∩₂ (Q ∩₂ R) ⊆₂' (P ∩₂ Q) ∩₂ R
⊆-proof _ _ (Pxy , (Qxy , Rxy)) = ((Pxy , Qxy) , Rxy)
⊇-proof : (P ∩₂ Q) ∩₂ R ⊆₂' P ∩₂ (Q ∩₂ R)
⊇-proof _ _ ((Pxy , Qxy) , Rxy) = (Pxy , (Qxy , Rxy))
-- # Operations
-- ## Operations: ⊆₂
module _ {a b ℓ₁ ℓ₂ ℓ₃ : Level} {A : Set a} {B : Set b}
{P : REL A B ℓ₁} {Q : REL A B ℓ₂} {R : REL A B ℓ₃} where
∩₂-combine-⊆₂ : P ⊆₂ Q → P ⊆₂ R → P ⊆₂ (Q ∩₂ R)
∩₂-combine-⊆₂ (⊆: P⊆Q) (⊆: P⊆R) = ⊆: (λ x y Pxy → (P⊆Q x y Pxy , P⊆R x y Pxy))
module _ {a b ℓ₁ ℓ₂ : Level} {A : Set a} {B : Set b}
{P : REL A B ℓ₁} {Q : REL A B ℓ₂} where
∩₂-introˡ-⊆₂ : (P ∩₂ Q) ⊆₂ Q
∩₂-introˡ-⊆₂ = ⊆: λ _ _ → proj₂
∩₂-introʳ-⊆₂ : (P ∩₂ Q) ⊆₂ P
∩₂-introʳ-⊆₂ = ⊆: λ _ _ → proj₁
module _ {a b ℓ₁ ℓ₂ ℓ₃ : Level} {A : Set a} {B : Set b}
{P : REL A B ℓ₁} {Q : REL A B ℓ₂} {R : REL A B ℓ₃} where
∩₂-elimˡ-⊆₂ : P ⊆₂ (Q ∩₂ R) → P ⊆₂ R
∩₂-elimˡ-⊆₂ (⊆: P⊆[Q∩R]) = ⊆: (λ x y Pxy → proj₂ (P⊆[Q∩R] x y Pxy))
∩₂-elimʳ-⊆₂ : P ⊆₂ (Q ∩₂ R) → P ⊆₂ Q
∩₂-elimʳ-⊆₂ (⊆: P⊆[Q∩R]) = ⊆: (λ x y Pxy → proj₁ (P⊆[Q∩R] x y Pxy))
module _ {a b ℓ₁ ℓ₂ ℓ₃ : Level} {A : Set a} {B : Set b}
{P : REL A B ℓ₁} {Q : REL A B ℓ₂} {R : REL A B ℓ₃} where
∩₂-substˡ-⊆₂ : P ⊆₂ Q → (P ∩₂ R) ⊆₂ (Q ∩₂ R)
∩₂-substˡ-⊆₂ (⊆: P⊆Q) = ⊆: (λ x y → P.map₁ (P⊆Q x y))
∩₂-substʳ-⊆₂ : P ⊆₂ Q → (R ∩₂ P) ⊆₂ (R ∩₂ Q)
∩₂-substʳ-⊆₂ (⊆: P⊆Q) = ⊆: (λ x y → P.map₂ (P⊆Q x y))
-- ## Operations: ⇔₂
module _ {a b ℓ₁ ℓ₂ ℓ₃ : Level} {A : Set a} {B : Set b}
{P : REL A B ℓ₁} {Q : REL A B ℓ₂} {R : REL A B ℓ₃} where
∩₂-substˡ : P ⇔₂ Q → (P ∩₂ R) ⇔₂ (Q ∩₂ R)
∩₂-substˡ = ⇔₂-compose ∩₂-substˡ-⊆₂ ∩₂-substˡ-⊆₂
∩₂-substʳ : P ⇔₂ Q → (R ∩₂ P) ⇔₂ (R ∩₂ Q)
∩₂-substʳ = ⇔₂-compose ∩₂-substʳ-⊆₂ ∩₂-substʳ-⊆₂
| 26.666667
| 80
| 0.482639
|
034dadd8482cc54f38605fc8eaec3b45545d8fc3
| 144
|
agda
|
Agda
|
test/Compiler/with-stdlib/HelloWorldPrim.agda
|
ashinkarov/agda
|
154d1c1e3d7a3ed2a965a800c620958ecda8fb1e
|
[
"BSD-3-Clause"
] | null | null | null |
test/Compiler/with-stdlib/HelloWorldPrim.agda
|
ashinkarov/agda
|
154d1c1e3d7a3ed2a965a800c620958ecda8fb1e
|
[
"BSD-3-Clause"
] | null | null | null |
test/Compiler/with-stdlib/HelloWorldPrim.agda
|
ashinkarov/agda
|
154d1c1e3d7a3ed2a965a800c620958ecda8fb1e
|
[
"BSD-3-Clause"
] | null | null | null |
module HelloWorldPrim where
open import IO.Primitive.Infinite
open import Codata.Musical.Costring
main = putStrLn (toCostring "Hello World!")
| 20.571429
| 43
| 0.8125
|
a05534c90196e8da324eacb0a1ea129d141c846d
| 662
|
agda
|
Agda
|
agda/BHeap/Heap.agda
|
bgbianchi/sorting
|
b8d428bccbdd1b13613e8f6ead6c81a8f9298399
|
[
"MIT"
] | 6
|
2015-05-21T12:50:35.000Z
|
2021-08-24T22:11:15.000Z
|
agda/BHeap/Heap.agda
|
bgbianchi/sorting
|
b8d428bccbdd1b13613e8f6ead6c81a8f9298399
|
[
"MIT"
] | null | null | null |
agda/BHeap/Heap.agda
|
bgbianchi/sorting
|
b8d428bccbdd1b13613e8f6ead6c81a8f9298399
|
[
"MIT"
] | null | null | null |
module BHeap.Heap {A : Set}(_≤_ : A → A → Set) where
open import BHeap _≤_
open import Bound.Lower A
open import Bound.Lower.Order _≤_
open import BTree.Heap _≤_
lemma-bheap-heap : {b : Bound}(h : BHeap b) → Heap (forget h)
lemma-bheap-heap lf = leaf
lemma-bheap-heap (nd {x = x} _ lf lf) = single x
lemma-bheap-heap (nd _ (nd (lexy x≤y) l r) lf) = left x≤y (lemma-bheap-heap (nd (lexy x≤y) l r))
lemma-bheap-heap (nd _ lf (nd (lexy x≤y) l r)) = right x≤y (lemma-bheap-heap (nd (lexy x≤y) l r))
lemma-bheap-heap (nd _ (nd (lexy x≤y) l r) (nd (lexy x≤y') l' r')) = both x≤y x≤y' (lemma-bheap-heap (nd (lexy x≤y) l r)) (lemma-bheap-heap (nd (lexy x≤y') l' r'))
| 47.285714
| 163
| 0.629909
|
1cfe0fff815324e65265166488d151576988daef
| 2,412
|
agda
|
Agda
|
LibraBFT/Impl/Consensus/ConsensusTypes/Vote.agda
|
oracle/bft-consensus-agda
|
49f8b1b70823be805d84ffc3157c3b880edb1e92
|
[
"UPL-1.0"
] | 4
|
2020-12-16T19:43:41.000Z
|
2021-12-18T19:24:05.000Z
|
LibraBFT/Impl/Consensus/ConsensusTypes/Vote.agda
|
oracle/bft-consensus-agda
|
49f8b1b70823be805d84ffc3157c3b880edb1e92
|
[
"UPL-1.0"
] | 72
|
2021-02-04T05:04:33.000Z
|
2022-03-25T05:36:11.000Z
|
LibraBFT/Impl/Consensus/ConsensusTypes/Vote.agda
|
oracle/bft-consensus-agda
|
49f8b1b70823be805d84ffc3157c3b880edb1e92
|
[
"UPL-1.0"
] | 6
|
2020-12-16T19:43:52.000Z
|
2022-02-18T01:04:32.000Z
|
{- Byzantine Fault Tolerant Consensus Verification in Agda, version 0.9.
Copyright (c) 2021, Oracle and/or its affiliates.
Licensed under the Universal Permissive License v 1.0 as shown at https://opensource.oracle.com/licenses/upl
-}
open import LibraBFT.Base.PKCS hiding (verify)
open import LibraBFT.Hash
import LibraBFT.Impl.Consensus.ConsensusTypes.VoteData as VoteData
open import LibraBFT.Impl.OBM.Crypto hiding (verify)
open import LibraBFT.Impl.OBM.Logging.Logging
import LibraBFT.Impl.Types.ValidatorVerifier as ValidatorVerifier
open import LibraBFT.ImplShared.Consensus.Types
open import LibraBFT.Prelude
open import Optics.All
------------------------------------------------------------------------------
open import Data.String using (String)
module LibraBFT.Impl.Consensus.ConsensusTypes.Vote where
------------------------------------------------------------------------------
timeout : Vote → Timeout
------------------------------------------------------------------------------
newWithSignature : VoteData → Author → LedgerInfo → Signature → Vote
newWithSignature voteData author ledgerInfo signature =
Vote∙new voteData author ledgerInfo signature nothing
verify : Vote → ValidatorVerifier → Either ErrLog Unit
verify self validator = do
lcheck (self ^∙ vLedgerInfo ∙ liConsensusDataHash == hashVD (self ^∙ vVoteData))
(here' ("Vote's hash mismatch with LedgerInfo" ∷ []))
withErrCtx' (here' ("vote" ∷ []))
(ValidatorVerifier.verify validator (self ^∙ vAuthor) (self ^∙ vLedgerInfo) (self ^∙ vSignature))
case self ^∙ vTimeoutSignature of λ where
nothing → pure unit
(just tos) →
withErrCtx' (here' ("timeout" ∷ []))
(ValidatorVerifier.verify validator (self ^∙ vAuthor) (timeout self) tos)
withErrCtx' (here' ("VoteData" ∷ [])) (VoteData.verify (self ^∙ vVoteData))
where
here' : List String → List String
here' t = "Vote" ∷ "verify" ∷ "failed" {-∷lsV self-} ∷ t
addTimeoutSignature : Vote → Signature → Vote
addTimeoutSignature self sig =
if is-just (self ^∙ vTimeoutSignature)
then self
else self & vTimeoutSignature ?~ sig
timeout v =
Timeout∙new (v ^∙ vVoteData ∙ vdProposed ∙ biEpoch) (v ^∙ vVoteData ∙ vdProposed ∙ biRound)
isTimeout : Vote → Bool
isTimeout v = is-just (v ^∙ vTimeoutSignature)
| 39.540984
| 111
| 0.628939
|
04f58b6b09fc89acf8d0456087800d067d1e81fb
| 3,028
|
agda
|
Agda
|
agda-stdlib-0.9/src/Data/Vec/Equality.agda
|
qwe2/try-agda
|
9d4c43b1609d3f085636376fdca73093481ab882
|
[
"Apache-2.0"
] | 1
|
2016-10-20T15:52:05.000Z
|
2016-10-20T15:52:05.000Z
|
agda-stdlib-0.9/src/Data/Vec/Equality.agda
|
qwe2/try-agda
|
9d4c43b1609d3f085636376fdca73093481ab882
|
[
"Apache-2.0"
] | null | null | null |
agda-stdlib-0.9/src/Data/Vec/Equality.agda
|
qwe2/try-agda
|
9d4c43b1609d3f085636376fdca73093481ab882
|
[
"Apache-2.0"
] | null | null | null |
------------------------------------------------------------------------
-- The Agda standard library
--
-- Semi-heterogeneous vector equality
------------------------------------------------------------------------
module Data.Vec.Equality where
open import Data.Vec
open import Data.Nat using (suc)
open import Function
open import Level using (_⊔_)
open import Relation.Binary
open import Relation.Binary.PropositionalEquality as P using (_≡_)
module Equality {s₁ s₂} (S : Setoid s₁ s₂) where
private
open module SS = Setoid S
using () renaming (_≈_ to _≊_; Carrier to A)
infix 4 _≈_
data _≈_ : ∀ {n¹} → Vec A n¹ →
∀ {n²} → Vec A n² → Set (s₁ ⊔ s₂) where
[]-cong : [] ≈ []
_∷-cong_ : ∀ {x¹ n¹} {xs¹ : Vec A n¹}
{x² n²} {xs² : Vec A n²}
(x¹≈x² : x¹ ≊ x²) (xs¹≈xs² : xs¹ ≈ xs²) →
x¹ ∷ xs¹ ≈ x² ∷ xs²
length-equal : ∀ {n¹} {xs¹ : Vec A n¹}
{n²} {xs² : Vec A n²} →
xs¹ ≈ xs² → n¹ ≡ n²
length-equal []-cong = P.refl
length-equal (_ ∷-cong eq₂) = P.cong suc $ length-equal eq₂
refl : ∀ {n} (xs : Vec A n) → xs ≈ xs
refl [] = []-cong
refl (x ∷ xs) = SS.refl ∷-cong refl xs
sym : ∀ {n m} {xs : Vec A n} {ys : Vec A m} →
xs ≈ ys → ys ≈ xs
sym []-cong = []-cong
sym (x¹≡x² ∷-cong xs¹≈xs²) = SS.sym x¹≡x² ∷-cong sym xs¹≈xs²
trans : ∀ {n m l} {xs : Vec A n} {ys : Vec A m} {zs : Vec A l} →
xs ≈ ys → ys ≈ zs → xs ≈ zs
trans []-cong []-cong = []-cong
trans (x≈y ∷-cong xs≈ys) (y≈z ∷-cong ys≈zs) =
SS.trans x≈y y≈z ∷-cong trans xs≈ys ys≈zs
_++-cong_ : ∀ {n₁¹ n₂¹} {xs₁¹ : Vec A n₁¹} {xs₂¹ : Vec A n₂¹}
{n₁² n₂²} {xs₁² : Vec A n₁²} {xs₂² : Vec A n₂²} →
xs₁¹ ≈ xs₁² → xs₂¹ ≈ xs₂² →
xs₁¹ ++ xs₂¹ ≈ xs₁² ++ xs₂²
[]-cong ++-cong eq₃ = eq₃
(eq₁ ∷-cong eq₂) ++-cong eq₃ = eq₁ ∷-cong (eq₂ ++-cong eq₃)
module DecidableEquality {d₁ d₂} (D : DecSetoid d₁ d₂) where
private module DS = DecSetoid D
open DS using () renaming (_≟_ to _≟′_ ; Carrier to A)
open Equality DS.setoid
open import Relation.Nullary
_≟_ : ∀ {n m} (xs : Vec A n) (ys : Vec A m) → Dec (xs ≈ ys)
_≟_ [] [] = yes []-cong
_≟_ [] (y ∷ ys) = no (λ())
_≟_ (x ∷ xs) [] = no (λ())
_≟_ (x ∷ xs) (y ∷ ys) with xs ≟ ys | x ≟′ y
... | yes xs≈ys | yes x≊y = yes (x≊y ∷-cong xs≈ys)
... | no ¬xs≈ys | _ = no helper
where
helper : ¬ (x ∷ xs ≈ y ∷ ys)
helper (_ ∷-cong xs≈ys) = ¬xs≈ys xs≈ys
... | _ | no ¬x≊y = no helper
where
helper : ¬ (x ∷ xs ≈ y ∷ ys)
helper (x≊y ∷-cong _) = ¬x≊y x≊y
module PropositionalEquality {a} {A : Set a} where
open Equality (P.setoid A) public
to-≡ : ∀ {n} {xs ys : Vec A n} → xs ≈ ys → xs ≡ ys
to-≡ []-cong = P.refl
to-≡ (P.refl ∷-cong xs¹≈xs²) = P.cong (_∷_ _) $ to-≡ xs¹≈xs²
from-≡ : ∀ {n} {xs ys : Vec A n} → xs ≡ ys → xs ≈ ys
from-≡ P.refl = refl _
| 32.913043
| 72
| 0.471598
|
8be896ffb948b498ec4daa67d0ddddb993c23db1
| 9,335
|
agda
|
Agda
|
examples/windController/agdaProof/SafetyProof.agda
|
vehicle-lang/vehicle
|
25842faea65b4f7f0f7b1bb11ea6e4bf3f4a59b0
|
[
"BSD-3-Clause"
] | 9
|
2022-02-10T12:56:42.000Z
|
2022-02-17T18:51:05.000Z
|
examples/windController/agdaProof/SafetyProof.agda
|
vehicle-lang/vehicle
|
25842faea65b4f7f0f7b1bb11ea6e4bf3f4a59b0
|
[
"BSD-3-Clause"
] | 19
|
2022-03-07T14:09:13.000Z
|
2022-03-31T20:49:39.000Z
|
examples/windController/agdaProof/SafetyProof.agda
|
vehicle-lang/vehicle
|
25842faea65b4f7f0f7b1bb11ea6e4bf3f4a59b0
|
[
"BSD-3-Clause"
] | null | null | null |
module SafetyProof where
open import Algebra
import Algebra.Properties.CommutativeSemigroup as CommutativeSemigroupProperties
open import Data.List
open import Data.List.Relation.Unary.All using (All; []; _∷_)
open import Data.Fin.Patterns using (0F; 1F)
open import Data.Nat using (z≤n; s≤s)
open import Data.Integer using (+≤+; +<+; +_)
open import Data.Vec using (_∷_)
import Data.Vec.Functional as Vector
open import Data.Product using (_×_; _,_; uncurry)
open import Data.Sum
open import Level using (0ℓ)
open import Relation.Binary.PropositionalEquality
open import Relation.Nullary using (yes; no)
open import Vehicle.Data.Tensor
open import AbstractRationals
import WindControllerSpec as Vehicle
open ≤-Reasoning
------------------------------------------------------------------------
-- Setup
toTensor : ℚ → ℚ → Tensor ℚ (2 ∷ [])
toTensor x y = Vector.fromList (x ∷ y ∷ [])
roadWidth : ℚ
roadWidth = + 3 / 1
maxWindShift : ℚ
maxWindShift = 1ℚ
maxSensorError : ℚ
maxSensorError = + 1 / 4
roadWidth≥0 : roadWidth ≥ 0ℚ
roadWidth≥0 = *≤* (+≤+ z≤n)
maxWindShift≥0 : maxWindShift ≥ 0ℚ
maxWindShift≥0 = *≤* (+≤+ z≤n)
maxSensorError≥0 : maxSensorError ≥ 0ℚ
maxSensorError≥0 = *≤* (+≤+ z≤n)
------------------------------------------------------------------------
-- Model data
record State : Set where
constructor state
field
windSpeed : ℚ
position : ℚ
velocity : ℚ
sensor : ℚ
open State
record Observation : Set where
constructor observe
field
windShift : ℚ
sensorError : ℚ
open Observation
------------------------------------------------------------------------
-- Model transitions
initialState : State
initialState = record
{ windSpeed = 0ℚ
; position = 0ℚ
; velocity = 0ℚ
; sensor = 0ℚ
}
controller : ℚ → ℚ → ℚ
controller x y = Vehicle.controller (toTensor x y)
nextState : Observation → State → State
nextState o s = record
{ windSpeed = newWindSpeed
; position = newPosition
; velocity = newVelocity
; sensor = newSensor
}
where
newWindSpeed = windSpeed s + windShift o
newPosition = position s + velocity s + newWindSpeed
newSensor = newPosition + sensorError o
newVelocity = velocity s + controller newSensor (sensor s)
finalState : List Observation → State
finalState xs = foldr nextState initialState xs
------------------------------------------------------------------------
-- Definition of correctness
nextPosition-windShift : State → ℚ
nextPosition-windShift s = position s + velocity s + windSpeed s
-- The vehicle is on the road if its position is less than the
-- width of the road.
OnRoad : State → Set
OnRoad s = ∣ position s ∣ ≤ roadWidth
-- The vehicle is in a "safe" state if it's more than the maxWindShift away
-- from the edge of the road.
SafeDistanceFromEdge : State → Set
SafeDistanceFromEdge s = ∣ nextPosition-windShift s ∣ < roadWidth - maxWindShift
-- The vehicle's previous sensor reading is accurate if it is no more than the
-- maximum error away from it's true location.
AccurateSensorReading : State → Set
AccurateSensorReading s = ∣ position s - sensor s ∣ ≤ maxSensorError
-- The vehicle's previous sensor reading was not off the road
SensorReadingNotOffRoad : State → Set
SensorReadingNotOffRoad s = ∣ sensor s ∣ ≤ roadWidth + maxSensorError
-- A state is safe if it both a safe distance from the edge and it's sensor
-- reading is accurate.
SafeState : State → Set
SafeState s = SafeDistanceFromEdge s
× AccurateSensorReading s
× SensorReadingNotOffRoad s
-- An observation is valid if the observed sensor error and the wind shift
-- are less than the expected maximum shifts.
ValidObservation : Observation → Set
ValidObservation o = ∣ sensorError o ∣ ≤ maxSensorError
× ∣ windShift o ∣ ≤ maxWindShift
------------------------------------------------------------------------
-- Proof of correctness
-- Initial state is both a safe distance from the edge and on the road
initialState-onRoad : OnRoad initialState
initialState-onRoad = roadWidth≥0
initialState-safe : SafeState initialState
initialState-safe rewrite +-eq | *-eq | neg-eq =
*<* (+<+ (s≤s z≤n)) ,
*≤* (+≤+ z≤n) ,
*≤* (+≤+ z≤n)
-- Transitions are well-behaved
controller-lem : ∀ x y →
∣ x ∣ ≤ roadWidth + maxSensorError →
∣ y ∣ ≤ roadWidth + maxSensorError →
∣ controller x y + 2ℚ * x - y ∣ < roadWidth - maxWindShift - 3ℚ * maxSensorError
controller-lem x y ∣x∣≤rw+εₘₐₓ ∣y∣≤rw+εₘₐₓ rewrite +-eq | *-eq | neg-eq =
uncurry -p<q<p⇒∣q∣<p (Vehicle.safe (toTensor x y) (λ
{ 0F → ∣p∣≤q⇒-q≤p≤q x ∣x∣≤rw+εₘₐₓ
; 1F → ∣p∣≤q⇒-q≤p≤q y ∣y∣≤rw+εₘₐₓ
}))
valid⇒nextState-accurateSensor : ∀ o → ValidObservation o → ∀ s →
AccurateSensorReading (nextState o s)
valid⇒nextState-accurateSensor o (ε≤εₘₐₓ , _) s = let s' = nextState o s in begin
∣ position s' - sensor s' ∣ ≡⟨⟩
∣ position s' - (position s' + sensorError o) ∣ ≡⟨ cong ∣_∣ (p-[p+q]≡q (position s') (sensorError o)) ⟩
∣ sensorError o ∣ ≤⟨ ε≤εₘₐₓ ⟩
maxSensorError ∎
valid+safe⇒nextState-onRoad : ∀ o → ValidObservation o →
∀ s → SafeState s →
OnRoad (nextState o s)
valid+safe⇒nextState-onRoad o (_ , δw≤δwₘₐₓ) s (safeDist , _ , _) = begin
∣ position s + velocity s + (windSpeed s + windShift o) ∣ ≡˘⟨ cong ∣_∣ (+-assoc (position s + velocity s) (windSpeed s) (windShift o)) ⟩
∣ position s + velocity s + windSpeed s + windShift o ∣ ≤⟨ ∣p+q∣≤∣p∣+∣q∣ _ (windShift o) ⟩
∣ nextPosition-windShift s ∣ + ∣ windShift o ∣ ≤⟨ +-mono-≤ (<⇒≤ safeDist) δw≤δwₘₐₓ ⟩
roadWidth - maxWindShift + maxWindShift ≡⟨ p-q+q≡p roadWidth maxWindShift ⟩
roadWidth ∎
valid+safe⇒nextState-sensorReadingNotOffRoad : ∀ s → SafeState s → ∀ o → ValidObservation o →
SensorReadingNotOffRoad (nextState o s)
valid+safe⇒nextState-sensorReadingNotOffRoad s safe o valid@(ε≤εₘₐₓ , _) = begin
∣ position (nextState o s) + sensorError o ∣ ≤⟨ ∣p+q∣≤∣p∣+∣q∣ (position s + velocity s + (windSpeed s + windShift o)) (sensorError o) ⟩
∣ position (nextState o s) ∣ + ∣ sensorError o ∣ ≤⟨ +-mono-≤ (valid+safe⇒nextState-onRoad o valid s safe) ε≤εₘₐₓ ⟩
roadWidth + maxSensorError ∎
valid+safe⇒nextState-safeDistanceFromEdge : ∀ o → ValidObservation o →
∀ s → SafeState s →
SafeDistanceFromEdge (nextState o s)
valid+safe⇒nextState-safeDistanceFromEdge o valid@(ε-accurate , _) s safe@(safeDist , ε'-accurate , s-notOffRoad) = let
s' = nextState o s
y = position s; y' = position s'
v = velocity s; v' = velocity s'
w = windSpeed s; w' = windSpeed s'
p = sensor s; p' = sensor s'
ε = y - p; ε' = sensorError o
dw = windShift o
dv = controller p' p
∣dv+2p'-p∣ = ∣ dv + 2ℚ * p' - p ∣
s'-notOffRoad = valid+safe⇒nextState-sensorReadingNotOffRoad s safe o valid
in begin-strict
∣ y' + v' + w' ∣ ≡⟨ cong ∣_∣ (sym (p+q-q≡p (y' + v' + w') _)) ⟩
∣ y' + (v + dv) + w' + (y + ε' + ε' - p) - (y + ε' + ε' - p) ∣ ≡⟨ cong ∣_∣ (lem1 y' v dv w' y ε' p) ⟩
∣ dv + (y' + ε' + (y + v + w' + ε')) - p - (ε' + ε' + (y - p)) ∣ ≡⟨⟩
∣ dv + (p' + p') - p - (ε' + ε' + (y - p)) ∣ ≡⟨ cong ∣_∣ (cong₂ (λ a b → dv + a - p - (b + (y - p))) (sym (2*p≡p+p p')) (sym (2*p≡p+p ε'))) ⟩
∣ dv + 2ℚ * p' - p - (2ℚ * ε' + (y - p)) ∣ ≤⟨ ∣p-q∣≤∣p∣+∣q∣ (dv + 2ℚ * p' - p) (2ℚ * ε' + (y - p)) ⟩
∣ dv + 2ℚ * p' - p ∣ + ∣ 2ℚ * ε' + (y - p) ∣ ≤⟨ +-monoʳ-≤ _ (∣p+q∣≤∣p∣+∣q∣ (2ℚ * ε') (y - p)) ⟩
∣ dv + 2ℚ * p' - p ∣ + (∣ 2ℚ * ε' ∣ + ∣ y - p ∣) ≡⟨ cong (λ v → ∣dv+2p'-p∣ + v) (cong (_+ _) (∣p*q∣≡∣p∣*∣q∣ 2ℚ ε')) ⟩
∣ dv + 2ℚ * p' - p ∣ + (2ℚ * ∣ ε' ∣ + ∣ ε ∣) ≤⟨ +-monoʳ-≤ _ (+-mono-≤ (*-monoʳ-≤ 2ℚ _ ε-accurate) ε'-accurate) ⟩
∣ dv + 2ℚ * p' - p ∣ + (2ℚ * maxSensorError + maxSensorError) ≡⟨ cong (λ v → ∣dv+2p'-p∣ + v) (2p+p≡3p maxSensorError) ⟩
∣ dv + 2ℚ * p' - p ∣ + 3ℚ * maxSensorError <⟨ p<r-q⇒p+q<r _ _ _ (controller-lem p' p s'-notOffRoad s-notOffRoad) ⟩
roadWidth - maxWindShift ∎
safe⇒nextState-safe : ∀ s → SafeState s → ∀ o → ValidObservation o → SafeState (nextState o s)
safe⇒nextState-safe s safe o valid =
valid+safe⇒nextState-safeDistanceFromEdge o valid s safe ,
valid⇒nextState-accurateSensor o valid s ,
valid+safe⇒nextState-sensorReadingNotOffRoad s safe o valid
finalState-safe : ∀ xs → All ValidObservation xs → SafeState (finalState xs)
finalState-safe [] [] = initialState-safe
finalState-safe (x ∷ xs) (px ∷ pxs) = safe⇒nextState-safe (finalState xs) (finalState-safe xs pxs) x px
finalState-onRoad : ∀ xs → All ValidObservation xs → OnRoad (finalState xs)
finalState-onRoad [] [] = initialState-onRoad
finalState-onRoad (x ∷ xs) (px ∷ pxs) = valid+safe⇒nextState-onRoad x px (finalState xs) (finalState-safe xs pxs)
| 40.586957
| 164
| 0.570648
|
10f352792f855416f21635744ca67c55dfb4696b
| 209
|
agda
|
Agda
|
test/Succeed/Issue4869.agda
|
LaloHao/agda
|
7de768bb7bc65dbe1efa35c699cfa8b8f9510573
|
[
"BSD-3-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
test/Succeed/Issue4869.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
test/Succeed/Issue4869.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
module Issue4869 where
open import Agda.Builtin.Nat
infix 4 _≤_
data _≤_ : Nat → Nat → Set where
z≤n : ∀ {n} → zero ≤ n
s≤s : ∀ {m n} (m≤n : m ≤ n) → suc m ≤ suc n
foo : 2 ≤ 1 → Nat
foo (s≤s ()) = 123
| 16.076923
| 45
| 0.535885
|
a08b95d83b8f92e217f91ca67ae86ea00531c3c9
| 1,683
|
agda
|
Agda
|
test/Fail/Issue4929.agda
|
AntoineAllioux/agda
|
68ec2312961776e415c99d2839e41a92ffe464db
|
[
"BSD-3-Clause"
] | null | null | null |
test/Fail/Issue4929.agda
|
AntoineAllioux/agda
|
68ec2312961776e415c99d2839e41a92ffe464db
|
[
"BSD-3-Clause"
] | null | null | null |
test/Fail/Issue4929.agda
|
AntoineAllioux/agda
|
68ec2312961776e415c99d2839e41a92ffe464db
|
[
"BSD-3-Clause"
] | null | null | null |
-- {-# OPTIONS --no-forcing #-}
{-# OPTIONS --rewriting #-}
{-# OPTIONS --sized-types #-}
open import Agda.Builtin.Equality
open import Agda.Builtin.Size
{-# BUILTIN REWRITE _≡_ #-}
variable i j : Size
postulate ANY : ∀{A : Set} → A
data Ty : Set where
bool : Ty
variable a b c d : Ty
infixl 5 _∘_
infixr 6 _∷_ _++_
mutual
data Tm (c : Ty) : Set where
tm : ∀{i a} (E : Stack i a c) → Tm c
data Stack (i : Size) : (a c : Ty) → Set where
ε : ∀{c} → Stack i c c
_∷_ : ∀{j : Size< i}{b} (u : Tm b) (E : Stack j b c) → Stack i bool c
variable E E' E′ : Stack i a c
_++_ : ∀{a b c} → Stack ∞ a b → Stack ∞ b c → Stack ∞ a c
ε ++ E′ = E′
(u ∷ E) ++ E′ = u ∷ (E ++ E′)
postulate
_∘_ : ∀{a c} → Tm a → Stack ∞ a c → Tm c
app-app : ∀{i j a b c}{t : Tm a} {E : Stack i a b} {E′ : Stack j b c} → t ∘ E ∘ E′ ≡ t ∘ E ++ E′
{-# REWRITE app-app #-}
infix 4 _↦_ _↦ₛ_
mutual
data _↦_ {c} : (t t′ : Tm c) → Set where
↦E : (r : E ↦ₛ E′) → tm E ↦ tm E′
-- ↦E : ∀{i a} {E E′ : Stack i a c} (r : E ↦ₛ E′) → tm E ↦ tm E′ -- no internal error
data _↦ₛ_ {c} : ∀ {i a} (E E′ : Stack i a c) → Set where
π : ∀{i a u v} {E : Stack i a c} → (u ∷ v ∷ E) ↦ₛ ((u ∘ v ∷ ε) ∷ E)
there : ∀{i a u} {E E′ : Stack i a c} (r : E ↦ₛ E′) → u ∷ E ↦ₛ u ∷ E′
data SN {a} (t : Tm a) : Set where
acc : (h : {t′ : Tm a} (r : t ↦ t′) → SN t′) → SN t
-- {-# TERMINATING #-} -- removes internal error
test : {i : Size} {a c : Ty} {t : Tm a} {E : Stack i a c}
(sntE : SN (t ∘ E))
→ SN (tm (t ∷ E))
test {i = i} {t = t} (acc sntE) = acc
λ { (↦E (there r)) → test (sntE ANY)
; (↦E (π {i = j})) → test {i = j} (acc sntE)
}
| 25.119403
| 98
| 0.456328
|
1e7d2986664a627f370e5122c773cf31b5a2b717
| 545
|
agda
|
Agda
|
test/asset/agda-stdlib-1.0/Data/Unit/Base.agda
|
omega12345/agda-mode
|
0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71
|
[
"MIT"
] | null | null | null |
test/asset/agda-stdlib-1.0/Data/Unit/Base.agda
|
omega12345/agda-mode
|
0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71
|
[
"MIT"
] | null | null | null |
test/asset/agda-stdlib-1.0/Data/Unit/Base.agda
|
omega12345/agda-mode
|
0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71
|
[
"MIT"
] | null | null | null |
------------------------------------------------------------------------
-- The Agda standard library
--
-- The unit type and the total relation on unit
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
module Data.Unit.Base where
------------------------------------------------------------------------
-- A unit type defined as a record type
-- Note that the name of this type is "\top", not T.
open import Agda.Builtin.Unit public using (⊤; tt)
record _≤_ (x y : ⊤) : Set where
| 28.684211
| 72
| 0.401835
|
38ab03b1d54a573dbe12eac1de6edf820fed992d
| 27,492
|
agda
|
Agda
|
Agda/05-identity-types.agda
|
hemangandhi/HoTT-Intro
|
09c710bf9c31ba88be144cc950bd7bc19c22a934
|
[
"CC-BY-4.0"
] | null | null | null |
Agda/05-identity-types.agda
|
hemangandhi/HoTT-Intro
|
09c710bf9c31ba88be144cc950bd7bc19c22a934
|
[
"CC-BY-4.0"
] | null | null | null |
Agda/05-identity-types.agda
|
hemangandhi/HoTT-Intro
|
09c710bf9c31ba88be144cc950bd7bc19c22a934
|
[
"CC-BY-4.0"
] | null | null | null |
{-# OPTIONS --without-K --exact-split #-}
module 05-identity-types where
import 04-inductive-types
open 04-inductive-types public
-- Section 5.1
-- Definition 5.1.1
{- We introduce the identity type. -}
data Id {i : Level} {A : UU i} (x : A) : A → UU i where
refl : Id x x
{- In the following definition we give a construction of path induction.
However, in the development of this library we will mostly use Agda's
built-in methods to give constructions by path induction. -}
ind-Id :
{i j : Level} {A : UU i} (x : A) (B : (y : A) (p : Id x y) → UU j) →
(B x refl) → (y : A) (p : Id x y) → B y p
ind-Id x B b y refl = b
-- Section 5.2 The groupoid structure of types
-- Definition 5.2.1
_∙_ :
{i : Level} {A : UU i} {x y z : A} → Id x y → Id y z → Id x z
refl ∙ q = q
concat :
{i : Level} {A : UU i} {x y : A} → Id x y → (z : A) → Id y z → Id x z
concat p z q = p ∙ q
-- Definition 5.2.2
inv :
{i : Level} {A : UU i} {x y : A} → Id x y → Id y x
inv refl = refl
-- Definition 5.2.3
assoc :
{i : Level} {A : UU i} {x y z w : A} (p : Id x y) (q : Id y z)
(r : Id z w) → Id ((p ∙ q) ∙ r) (p ∙ (q ∙ r))
assoc refl q r = refl
-- Definition 5.2.4
left-unit :
{i : Level} {A : UU i} {x y : A} {p : Id x y} → Id (refl ∙ p) p
left-unit = refl
right-unit :
{i : Level} {A : UU i} {x y : A} {p : Id x y} → Id (p ∙ refl) p
right-unit {p = refl} = refl
-- Definition 5.2.5
left-inv :
{i : Level} {A : UU i} {x y : A} (p : Id x y) →
Id ((inv p) ∙ p) refl
left-inv refl = refl
right-inv :
{i : Level} {A : UU i} {x y : A} (p : Id x y) →
Id (p ∙ (inv p)) refl
right-inv refl = refl
-- Section 5.3 The action on paths of functions
-- Definition 5.3.1
ap :
{i j : Level} {A : UU i} {B : UU j} (f : A → B) {x y : A} (p : Id x y) →
Id (f x) (f y)
ap f refl = refl
ap-id :
{i : Level} {A : UU i} {x y : A} (p : Id x y) → Id (ap id p) p
ap-id refl = refl
ap-comp :
{i j k : Level} {A : UU i} {B : UU j} {C : UU k} (g : B → C)
(f : A → B) {x y : A} (p : Id x y) → Id (ap (g ∘ f) p) (ap g (ap f p))
ap-comp g f refl = refl
-- Definition 5.3.2
ap-refl :
{i j : Level} {A : UU i} {B : UU j} (f : A → B) (x : A) →
Id (ap f (refl {_} {_} {x})) refl
ap-refl f x = refl
ap-concat :
{i j : Level} {A : UU i} {B : UU j} (f : A → B) {x y z : A}
(p : Id x y) (q : Id y z) → Id (ap f (p ∙ q)) ((ap f p) ∙ (ap f q))
ap-concat f refl q = refl
ap-inv :
{i j : Level} {A : UU i} {B : UU j} (f : A → B) {x y : A}
(p : Id x y) → Id (ap f (inv p)) (inv (ap f p))
ap-inv f refl = refl
-- Section 5.4 Transport
-- Definition 5.4.1
tr :
{i j : Level} {A : UU i} (B : A → UU j) {x y : A} (p : Id x y) → B x → B y
tr B refl b = b
-- Definition 5.4.2
apd :
{i j : Level} {A : UU i} {B : A → UU j} (f : (x : A) → B x) {x y : A}
(p : Id x y) → Id (tr B p (f x)) (f y)
apd f refl = refl
path-over :
{i j : Level} {A : UU i} (B : A → UU j) {x x' : A} (p : Id x x') →
B x → B x' → UU j
path-over B p y y' = Id (tr B p y) y'
refl-path-over :
{i j : Level} {A : UU i} (B : A → UU j) (x : A) (y : B x) →
path-over B refl y y
refl-path-over B x y = refl
-- Exercises
-- Exercise 5.1
-- Exercise 5.2
distributive-inv-concat :
{i : Level} {A : UU i} {x y : A} (p : Id x y) {z : A}
(q : Id y z) → Id (inv (p ∙ q)) ((inv q) ∙ (inv p))
distributive-inv-concat refl refl = refl
-- Exercise 5.3
inv-con :
{i : Level} {A : UU i} {x y : A} (p : Id x y) {z : A} (q : Id y z)
(r : Id x z) → (Id (p ∙ q) r) → Id q ((inv p) ∙ r)
inv-con refl q r = id
con-inv :
{i : Level} {A : UU i} {x y : A} (p : Id x y) {z : A} (q : Id y z)
(r : Id x z) → (Id (p ∙ q) r) → Id p (r ∙ (inv q))
con-inv p refl r =
( λ α → α ∙ (inv right-unit)) ∘ (concat (inv right-unit) r)
-- Exercise 5.4
lift :
{i j : Level} {A : UU i} {B : A → UU j} {x y : A} (p : Id x y)
(b : B x) → Id (pair x b) (pair y (tr B p b))
lift refl b = refl
-- Exercise 5.5
-- Exercise 5.5(a)
abstract
right-unit-law-add-ℕ :
(x : ℕ) → Id (add-ℕ x zero-ℕ) x
right-unit-law-add-ℕ x = refl
left-unit-law-add-ℕ :
(x : ℕ) → Id (add-ℕ zero-ℕ x) x
left-unit-law-add-ℕ zero-ℕ = refl
left-unit-law-add-ℕ (succ-ℕ x) = ap succ-ℕ (left-unit-law-add-ℕ x)
left-successor-law-add-ℕ :
(x y : ℕ) → Id (add-ℕ (succ-ℕ x) y) (succ-ℕ (add-ℕ x y))
left-successor-law-add-ℕ x zero-ℕ = refl
left-successor-law-add-ℕ x (succ-ℕ y) =
ap succ-ℕ (left-successor-law-add-ℕ x y)
right-successor-law-add-ℕ :
(x y : ℕ) → Id (add-ℕ x (succ-ℕ y)) (succ-ℕ (add-ℕ x y))
right-successor-law-add-ℕ x y = refl
-- Exercise 5.5(b)
abstract
associative-add-ℕ :
(x y z : ℕ) → Id (add-ℕ (add-ℕ x y) z) (add-ℕ x (add-ℕ y z))
associative-add-ℕ x y zero-ℕ = refl
associative-add-ℕ x y (succ-ℕ z) = ap succ-ℕ (associative-add-ℕ x y z)
abstract
commutative-add-ℕ : (x y : ℕ) → Id (add-ℕ x y) (add-ℕ y x)
commutative-add-ℕ zero-ℕ y = left-unit-law-add-ℕ y
commutative-add-ℕ (succ-ℕ x) y =
(left-successor-law-add-ℕ x y) ∙ (ap succ-ℕ (commutative-add-ℕ x y))
-- Exercise 5.5(c)
abstract
left-zero-law-mul-ℕ :
(x : ℕ) → Id (mul-ℕ zero-ℕ x) zero-ℕ
left-zero-law-mul-ℕ x = refl
right-zero-law-mul-ℕ :
(x : ℕ) → Id (mul-ℕ x zero-ℕ) zero-ℕ
right-zero-law-mul-ℕ zero-ℕ = refl
right-zero-law-mul-ℕ (succ-ℕ x) =
( right-unit-law-add-ℕ (mul-ℕ x zero-ℕ)) ∙ (right-zero-law-mul-ℕ x)
abstract
right-unit-law-mul-ℕ :
(x : ℕ) → Id (mul-ℕ x one-ℕ) x
right-unit-law-mul-ℕ zero-ℕ = refl
right-unit-law-mul-ℕ (succ-ℕ x) = ap succ-ℕ (right-unit-law-mul-ℕ x)
left-unit-law-mul-ℕ :
(x : ℕ) → Id (mul-ℕ one-ℕ x) x
left-unit-law-mul-ℕ zero-ℕ = refl
left-unit-law-mul-ℕ (succ-ℕ x) = ap succ-ℕ (left-unit-law-mul-ℕ x)
abstract
left-successor-law-mul-ℕ :
(x y : ℕ) → Id (mul-ℕ (succ-ℕ x) y) (add-ℕ (mul-ℕ x y) y)
left-successor-law-mul-ℕ x y = refl
right-successor-law-mul-ℕ :
(x y : ℕ) → Id (mul-ℕ x (succ-ℕ y)) (add-ℕ x (mul-ℕ x y))
right-successor-law-mul-ℕ zero-ℕ y = refl
right-successor-law-mul-ℕ (succ-ℕ x) y =
( ( ap (λ t → succ-ℕ (add-ℕ t y)) (right-successor-law-mul-ℕ x y)) ∙
( ap succ-ℕ (associative-add-ℕ x (mul-ℕ x y) y))) ∙
( inv (left-successor-law-add-ℕ x (add-ℕ (mul-ℕ x y) y)))
-- Exercise 5.5(d)
abstract
commutative-mul-ℕ :
(x y : ℕ) → Id (mul-ℕ x y) (mul-ℕ y x)
commutative-mul-ℕ zero-ℕ y = inv (right-zero-law-mul-ℕ y)
commutative-mul-ℕ (succ-ℕ x) y =
( commutative-add-ℕ (mul-ℕ x y) y) ∙
( ( ap (add-ℕ y) (commutative-mul-ℕ x y)) ∙
( inv (right-successor-law-mul-ℕ y x)))
-- Exercise 5.5(e)
abstract
left-distributive-mul-add-ℕ :
(x y z : ℕ) → Id (mul-ℕ x (add-ℕ y z)) (add-ℕ (mul-ℕ x y) (mul-ℕ x z))
left-distributive-mul-add-ℕ zero-ℕ y z = refl
left-distributive-mul-add-ℕ (succ-ℕ x) y z =
( left-successor-law-mul-ℕ x (add-ℕ y z)) ∙
( ( ap (λ t → add-ℕ t (add-ℕ y z)) (left-distributive-mul-add-ℕ x y z)) ∙
( ( associative-add-ℕ (mul-ℕ x y) (mul-ℕ x z) (add-ℕ y z)) ∙
( ( ap ( add-ℕ (mul-ℕ x y))
( ( inv (associative-add-ℕ (mul-ℕ x z) y z)) ∙
( ( ap (λ t → add-ℕ t z) (commutative-add-ℕ (mul-ℕ x z) y)) ∙
( associative-add-ℕ y (mul-ℕ x z) z)))) ∙
( inv (associative-add-ℕ (mul-ℕ x y) y (add-ℕ (mul-ℕ x z) z))))))
abstract
right-distributive-mul-add-ℕ :
(x y z : ℕ) → Id (mul-ℕ (add-ℕ x y) z) (add-ℕ (mul-ℕ x z) (mul-ℕ y z))
right-distributive-mul-add-ℕ x y z =
( commutative-mul-ℕ (add-ℕ x y) z) ∙
( ( left-distributive-mul-add-ℕ z x y) ∙
( ( ap (λ t → add-ℕ t (mul-ℕ z y)) (commutative-mul-ℕ z x)) ∙
( ap (λ t → add-ℕ (mul-ℕ x z) t) (commutative-mul-ℕ z y))))
-- Exercise 5.5(f)
abstract
associative-mul-ℕ :
(x y z : ℕ) → Id (mul-ℕ (mul-ℕ x y) z) (mul-ℕ x (mul-ℕ y z))
associative-mul-ℕ zero-ℕ y z = refl
associative-mul-ℕ (succ-ℕ x) y z =
( right-distributive-mul-add-ℕ (mul-ℕ x y) y z) ∙
( ap (λ t → add-ℕ t (mul-ℕ y z)) (associative-mul-ℕ x y z))
-- Exercise 5.6
Mac-Lane-pentagon :
{i : Level} {A : UU i} {a b c d e : A}
(p : Id a b) (q : Id b c) (r : Id c d) (s : Id d e) →
let α₁ = (ap (λ t → t ∙ s) (assoc p q r))
α₂ = (assoc p (q ∙ r) s)
α₃ = (ap (λ t → p ∙ t) (assoc q r s))
α₄ = (assoc (p ∙ q) r s)
α₅ = (assoc p q (r ∙ s))
in
Id ((α₁ ∙ α₂) ∙ α₃) (α₄ ∙ α₅)
Mac-Lane-pentagon refl refl refl refl = refl
{- The following code is an experiment that shows that constructions in an
abstract environment do remember the specific definitions of previous
definitions in abstract environments. -}
abstract
abstract-concat :
{l : Level} {A : UU l} {x y z : A} → Id x y → Id y z → Id x z
abstract-concat refl q = q
abstract-left-unit-law :
{l : Level} {A : UU l} {x y : A} (q : Id x y) → Id (abstract-concat refl q) q
abstract-left-unit-law q = refl
{- We just make some random definition to make sure that we are not in the
same abstract envirnoment anymore. -}
one : ℕ
one = succ-ℕ zero-ℕ
abstract
abstract-right-unit-law :
{l : Level} {A : UU l} {x y : A} (p : Id x y) →
Id (abstract-concat p refl) p
abstract-right-unit-law refl = refl
{- The term refl should not be accepted if the definition of abstract-concat
were forgotten. A definition that would work under all circumstances is
abstract-left-unit refl. -}
-- The ring axioms for ℤ
abstract
left-inverse-pred-ℤ :
(k : ℤ) → Id (pred-ℤ (succ-ℤ k)) k
left-inverse-pred-ℤ (inl zero-ℕ) = refl
left-inverse-pred-ℤ (inl (succ-ℕ x)) = refl
left-inverse-pred-ℤ (inr (inl star)) = refl
left-inverse-pred-ℤ (inr (inr zero-ℕ)) = refl
left-inverse-pred-ℤ (inr (inr (succ-ℕ x))) = refl
right-inverse-pred-ℤ :
(k : ℤ) → Id (succ-ℤ (pred-ℤ k)) k
right-inverse-pred-ℤ (inl zero-ℕ) = refl
right-inverse-pred-ℤ (inl (succ-ℕ x)) = refl
right-inverse-pred-ℤ (inr (inl star)) = refl
right-inverse-pred-ℤ (inr (inr zero-ℕ)) = refl
right-inverse-pred-ℤ (inr (inr (succ-ℕ x))) = refl
{- Exercise 6.12 (a) simply asks to prove the unit laws. The left unit law
holds by judgmental equality. -}
abstract
left-unit-law-add-ℤ :
(k : ℤ) → Id (add-ℤ zero-ℤ k) k
left-unit-law-add-ℤ k = refl
right-unit-law-add-ℤ :
(k : ℤ) → Id (add-ℤ k zero-ℤ) k
right-unit-law-add-ℤ (inl zero-ℕ) = refl
right-unit-law-add-ℤ (inl (succ-ℕ x)) =
ap pred-ℤ (right-unit-law-add-ℤ (inl x))
right-unit-law-add-ℤ (inr (inl star)) = refl
right-unit-law-add-ℤ (inr (inr zero-ℕ)) = refl
right-unit-law-add-ℤ (inr (inr (succ-ℕ x))) =
ap succ-ℤ (right-unit-law-add-ℤ (inr (inr x)))
{- Exercise 6.12 (b) asks to show the left and right predecessor and successor
laws. These are helpful to give proofs of associativity and commutativity.
-}
abstract
left-predecessor-law-add-ℤ :
(x y : ℤ) → Id (add-ℤ (pred-ℤ x) y) (pred-ℤ (add-ℤ x y))
left-predecessor-law-add-ℤ (inl n) y = refl
left-predecessor-law-add-ℤ (inr (inl star)) y = refl
left-predecessor-law-add-ℤ (inr (inr zero-ℕ)) y =
( ap (λ t → add-ℤ t y) (left-inverse-pred-ℤ zero-ℤ)) ∙
( inv (left-inverse-pred-ℤ y))
left-predecessor-law-add-ℤ (inr (inr (succ-ℕ x))) y =
( ap (λ t → (add-ℤ t y)) (left-inverse-pred-ℤ (inr (inr x)))) ∙
( inv (left-inverse-pred-ℤ (add-ℤ (inr (inr x)) y)))
right-predecessor-law-add-ℤ :
(x y : ℤ) → Id (add-ℤ x (pred-ℤ y)) (pred-ℤ (add-ℤ x y))
right-predecessor-law-add-ℤ (inl zero-ℕ) n = refl
right-predecessor-law-add-ℤ (inl (succ-ℕ m)) n =
ap pred-ℤ (right-predecessor-law-add-ℤ (inl m) n)
right-predecessor-law-add-ℤ (inr (inl star)) n = refl
right-predecessor-law-add-ℤ (inr (inr zero-ℕ)) n =
(right-inverse-pred-ℤ n) ∙ (inv (left-inverse-pred-ℤ n))
right-predecessor-law-add-ℤ (inr (inr (succ-ℕ x))) n =
( ap succ-ℤ (right-predecessor-law-add-ℤ (inr (inr x)) n)) ∙
( ( right-inverse-pred-ℤ (add-ℤ (inr (inr x)) n)) ∙
( inv (left-inverse-pred-ℤ (add-ℤ (inr (inr x)) n))))
abstract
left-successor-law-add-ℤ :
(x y : ℤ) → Id (add-ℤ (succ-ℤ x) y) (succ-ℤ (add-ℤ x y))
left-successor-law-add-ℤ (inl zero-ℕ) y =
( ap (λ t → add-ℤ t y) (right-inverse-pred-ℤ zero-ℤ)) ∙
( inv (right-inverse-pred-ℤ y))
left-successor-law-add-ℤ (inl (succ-ℕ x)) y =
( inv (right-inverse-pred-ℤ (add-ℤ (inl x) y))) ∙
( ap succ-ℤ (inv (left-predecessor-law-add-ℤ (inl x) y)))
left-successor-law-add-ℤ (inr (inl star)) y = refl
left-successor-law-add-ℤ (inr (inr x)) y = refl
right-successor-law-add-ℤ :
(x y : ℤ) → Id (add-ℤ x (succ-ℤ y)) (succ-ℤ (add-ℤ x y))
right-successor-law-add-ℤ (inl zero-ℕ) y =
(left-inverse-pred-ℤ y) ∙ (inv (right-inverse-pred-ℤ y))
right-successor-law-add-ℤ (inl (succ-ℕ x)) y =
( ap pred-ℤ (right-successor-law-add-ℤ (inl x) y)) ∙
( ( left-inverse-pred-ℤ (add-ℤ (inl x) y)) ∙
( inv (right-inverse-pred-ℤ (add-ℤ (inl x) y))))
right-successor-law-add-ℤ (inr (inl star)) y = refl
right-successor-law-add-ℤ (inr (inr zero-ℕ)) y = refl
right-successor-law-add-ℤ (inr (inr (succ-ℕ x))) y =
ap succ-ℤ (right-successor-law-add-ℤ (inr (inr x)) y)
{- Exercise 6.12 (c) asks to prove associativity and commutativity. Note that
we avoid an unwieldy amount of cases by only using induction on the first
argument. The resulting proof term is fairly short, and we don't have to
present ℤ as a certain quotient of ℕ × ℕ. -}
abstract
associative-add-ℤ :
(x y z : ℤ) → Id (add-ℤ (add-ℤ x y) z) (add-ℤ x (add-ℤ y z))
associative-add-ℤ (inl zero-ℕ) y z =
( ap (λ t → add-ℤ t z) (left-predecessor-law-add-ℤ zero-ℤ y)) ∙
( ( left-predecessor-law-add-ℤ y z) ∙
( inv (left-predecessor-law-add-ℤ zero-ℤ (add-ℤ y z))))
associative-add-ℤ (inl (succ-ℕ x)) y z =
( ap (λ t → add-ℤ t z) (left-predecessor-law-add-ℤ (inl x) y)) ∙
( ( left-predecessor-law-add-ℤ (add-ℤ (inl x) y) z) ∙
( ( ap pred-ℤ (associative-add-ℤ (inl x) y z)) ∙
( inv (left-predecessor-law-add-ℤ (inl x) (add-ℤ y z)))))
associative-add-ℤ (inr (inl star)) y z = refl
associative-add-ℤ (inr (inr zero-ℕ)) y z =
( ap (λ t → add-ℤ t z) (left-successor-law-add-ℤ zero-ℤ y)) ∙
( ( left-successor-law-add-ℤ y z) ∙
( inv (left-successor-law-add-ℤ zero-ℤ (add-ℤ y z))))
associative-add-ℤ (inr (inr (succ-ℕ x))) y z =
( ap (λ t → add-ℤ t z) (left-successor-law-add-ℤ (inr (inr x)) y)) ∙
( ( left-successor-law-add-ℤ (add-ℤ (inr (inr x)) y) z) ∙
( ( ap succ-ℤ (associative-add-ℤ (inr (inr x)) y z)) ∙
( inv (left-successor-law-add-ℤ (inr (inr x)) (add-ℤ y z)))))
abstract
commutative-add-ℤ :
(x y : ℤ) → Id (add-ℤ x y) (add-ℤ y x)
commutative-add-ℤ (inl zero-ℕ) y =
( left-predecessor-law-add-ℤ zero-ℤ y) ∙
( inv
( ( right-predecessor-law-add-ℤ y zero-ℤ) ∙
( ap pred-ℤ (right-unit-law-add-ℤ y))))
commutative-add-ℤ (inl (succ-ℕ x)) y =
( ap pred-ℤ (commutative-add-ℤ (inl x) y)) ∙
( inv (right-predecessor-law-add-ℤ y (inl x)))
commutative-add-ℤ (inr (inl star)) y = inv (right-unit-law-add-ℤ y)
commutative-add-ℤ (inr (inr zero-ℕ)) y =
inv
( ( right-successor-law-add-ℤ y zero-ℤ) ∙
( ap succ-ℤ (right-unit-law-add-ℤ y)))
commutative-add-ℤ (inr (inr (succ-ℕ x))) y =
( ap succ-ℤ (commutative-add-ℤ (inr (inr x)) y)) ∙
( inv (right-successor-law-add-ℤ y (inr (inr x))))
{- Exercise 6.12 (d) finally asks to show the inverse laws, completing the
verification of the group laws. Combined with associativity and
commutativity we conclude that (add-ℤ x) and (λ x → add-ℤ x y) are
equivalences, for every x : ℤ and y : ℤ, respectively. -}
abstract
left-inverse-law-add-ℤ :
(x : ℤ) → Id (add-ℤ (neg-ℤ x) x) zero-ℤ
left-inverse-law-add-ℤ (inl zero-ℕ) = refl
left-inverse-law-add-ℤ (inl (succ-ℕ x)) =
( ap succ-ℤ (right-predecessor-law-add-ℤ (inr (inr x)) (inl x))) ∙
( ( right-inverse-pred-ℤ (add-ℤ (inr (inr x)) (inl x))) ∙
( left-inverse-law-add-ℤ (inl x)))
left-inverse-law-add-ℤ (inr (inl star)) = refl
left-inverse-law-add-ℤ (inr (inr x)) =
( commutative-add-ℤ (inl x) (inr (inr x))) ∙
( left-inverse-law-add-ℤ (inl x))
right-inverse-law-add-ℤ :
(x : ℤ) → Id (add-ℤ x (neg-ℤ x)) zero-ℤ
right-inverse-law-add-ℤ x =
( commutative-add-ℤ x (neg-ℤ x)) ∙ (left-inverse-law-add-ℤ x)
-- Similar for multiplication on ℤ
neg-neg-ℤ : (k : ℤ) → Id (neg-ℤ (neg-ℤ k)) k
neg-neg-ℤ (inl n) = refl
neg-neg-ℤ (inr (inl star)) = refl
neg-neg-ℤ (inr (inr n)) = refl
neg-pred-ℤ :
(k : ℤ) → Id (neg-ℤ (pred-ℤ k)) (succ-ℤ (neg-ℤ k))
neg-pred-ℤ (inl x) = refl
neg-pred-ℤ (inr (inl star)) = refl
neg-pred-ℤ (inr (inr zero-ℕ)) = refl
neg-pred-ℤ (inr (inr (succ-ℕ x))) = refl
pred-neg-ℤ :
(k : ℤ) → Id (pred-ℤ (neg-ℤ k)) (neg-ℤ (succ-ℤ k))
pred-neg-ℤ (inl zero-ℕ) = refl
pred-neg-ℤ (inl (succ-ℕ x)) = refl
pred-neg-ℤ (inr (inl star)) = refl
pred-neg-ℤ (inr (inr x)) = refl
right-negative-law-add-ℤ :
(k l : ℤ) → Id (add-ℤ k (neg-ℤ l)) (neg-ℤ (add-ℤ (neg-ℤ k) l))
right-negative-law-add-ℤ (inl zero-ℕ) l =
( left-predecessor-law-add-ℤ zero-ℤ (neg-ℤ l)) ∙
( pred-neg-ℤ l)
right-negative-law-add-ℤ (inl (succ-ℕ x)) l =
( left-predecessor-law-add-ℤ (inl x) (neg-ℤ l)) ∙
( ( ap pred-ℤ (right-negative-law-add-ℤ (inl x) l)) ∙
( pred-neg-ℤ (add-ℤ (inr (inr x)) l)))
right-negative-law-add-ℤ (inr (inl star)) l = refl
right-negative-law-add-ℤ (inr (inr zero-ℕ)) l = inv (neg-pred-ℤ l)
right-negative-law-add-ℤ (inr (inr (succ-ℕ n))) l =
( left-successor-law-add-ℤ (in-pos n) (neg-ℤ l)) ∙
( ( ap succ-ℤ (right-negative-law-add-ℤ (inr (inr n)) l)) ∙
( inv (neg-pred-ℤ (add-ℤ (inl n) l))))
distributive-neg-add-ℤ :
(k l : ℤ) → Id (neg-ℤ (add-ℤ k l)) (add-ℤ (neg-ℤ k) (neg-ℤ l))
distributive-neg-add-ℤ (inl zero-ℕ) l =
( ap neg-ℤ (left-predecessor-law-add-ℤ zero-ℤ l)) ∙
( neg-pred-ℤ l)
distributive-neg-add-ℤ (inl (succ-ℕ n)) l =
( neg-pred-ℤ (add-ℤ (inl n) l)) ∙
( ( ap succ-ℤ (distributive-neg-add-ℤ (inl n) l)) ∙
( ap (λ t → add-ℤ t (neg-ℤ l)) (inv (neg-pred-ℤ (inl n)))))
distributive-neg-add-ℤ (inr (inl star)) l = refl
distributive-neg-add-ℤ (inr (inr zero-ℕ)) l = inv (pred-neg-ℤ l)
distributive-neg-add-ℤ (inr (inr (succ-ℕ n))) l =
( inv (pred-neg-ℤ (add-ℤ (in-pos n) l))) ∙
( ap pred-ℤ (distributive-neg-add-ℤ (inr (inr n)) l))
left-zero-law-mul-ℤ : (k : ℤ) → Id (mul-ℤ zero-ℤ k) zero-ℤ
left-zero-law-mul-ℤ k = refl
right-zero-law-mul-ℤ : (k : ℤ) → Id (mul-ℤ k zero-ℤ) zero-ℤ
right-zero-law-mul-ℤ (inl zero-ℕ) = refl
right-zero-law-mul-ℤ (inl (succ-ℕ n)) =
right-zero-law-mul-ℤ (inl n)
right-zero-law-mul-ℤ (inr (inl star)) = refl
right-zero-law-mul-ℤ (inr (inr zero-ℕ)) = refl
right-zero-law-mul-ℤ (inr (inr (succ-ℕ n))) =
right-zero-law-mul-ℤ (inr (inr n))
left-unit-law-mul-ℤ : (k : ℤ) → Id (mul-ℤ one-ℤ k) k
left-unit-law-mul-ℤ k = refl
right-unit-law-mul-ℤ : (k : ℤ) → Id (mul-ℤ k one-ℤ) k
right-unit-law-mul-ℤ (inl zero-ℕ) = refl
right-unit-law-mul-ℤ (inl (succ-ℕ n)) =
ap (add-ℤ (neg-one-ℤ)) (right-unit-law-mul-ℤ (inl n))
right-unit-law-mul-ℤ (inr (inl star)) = refl
right-unit-law-mul-ℤ (inr (inr zero-ℕ)) = refl
right-unit-law-mul-ℤ (inr (inr (succ-ℕ n))) =
ap (add-ℤ one-ℤ) (right-unit-law-mul-ℤ (inr (inr n)))
left-neg-unit-law-mul-ℤ : (k : ℤ) → Id (mul-ℤ neg-one-ℤ k) (neg-ℤ k)
left-neg-unit-law-mul-ℤ k = refl
right-neg-unit-law-mul-ℤ : (k : ℤ) → Id (mul-ℤ k neg-one-ℤ) (neg-ℤ k)
right-neg-unit-law-mul-ℤ (inl zero-ℕ) = refl
right-neg-unit-law-mul-ℤ (inl (succ-ℕ n)) =
ap (add-ℤ one-ℤ) (right-neg-unit-law-mul-ℤ (inl n))
right-neg-unit-law-mul-ℤ (inr (inl star)) = refl
right-neg-unit-law-mul-ℤ (inr (inr zero-ℕ)) = refl
right-neg-unit-law-mul-ℤ (inr (inr (succ-ℕ n))) =
ap (add-ℤ neg-one-ℤ) (right-neg-unit-law-mul-ℤ (inr (inr n)))
left-successor-law-mul-ℤ :
(k l : ℤ) → Id (mul-ℤ (succ-ℤ k) l) (add-ℤ l (mul-ℤ k l))
left-successor-law-mul-ℤ (inl zero-ℕ) l =
inv (right-inverse-law-add-ℤ l)
left-successor-law-mul-ℤ (inl (succ-ℕ n)) l =
( ( inv (left-unit-law-add-ℤ (mul-ℤ (inl n) l))) ∙
( ap
( λ x → add-ℤ x (mul-ℤ (inl n) l))
( inv (right-inverse-law-add-ℤ l)))) ∙
( associative-add-ℤ l (neg-ℤ l) (mul-ℤ (inl n) l))
left-successor-law-mul-ℤ (inr (inl star)) l =
inv (right-unit-law-add-ℤ l)
left-successor-law-mul-ℤ (inr (inr n)) l = refl
left-predecessor-law-mul-ℤ :
(k l : ℤ) → Id (mul-ℤ (pred-ℤ k) l) (add-ℤ (neg-ℤ l) (mul-ℤ k l))
left-predecessor-law-mul-ℤ (inl n) l = refl
left-predecessor-law-mul-ℤ (inr (inl star)) l =
( left-neg-unit-law-mul-ℤ l) ∙
( inv (right-unit-law-add-ℤ (neg-ℤ l)))
left-predecessor-law-mul-ℤ (inr (inr zero-ℕ)) l =
inv (left-inverse-law-add-ℤ l)
left-predecessor-law-mul-ℤ (inr (inr (succ-ℕ x))) l =
( ap
( λ t → add-ℤ t (mul-ℤ (in-pos x) l))
( inv (left-inverse-law-add-ℤ l))) ∙
( associative-add-ℤ (neg-ℤ l) l (mul-ℤ (in-pos x) l))
right-successor-law-mul-ℤ :
(k l : ℤ) → Id (mul-ℤ k (succ-ℤ l)) (add-ℤ k (mul-ℤ k l))
right-successor-law-mul-ℤ (inl zero-ℕ) l = inv (pred-neg-ℤ l)
right-successor-law-mul-ℤ (inl (succ-ℕ n)) l =
( left-predecessor-law-mul-ℤ (inl n) (succ-ℤ l)) ∙
( ( ap (add-ℤ (neg-ℤ (succ-ℤ l))) (right-successor-law-mul-ℤ (inl n) l)) ∙
( ( inv (associative-add-ℤ (neg-ℤ (succ-ℤ l)) (inl n) (mul-ℤ (inl n) l))) ∙
( ( ap
( λ t → add-ℤ t (mul-ℤ (inl n) l))
{ x = add-ℤ (neg-ℤ (succ-ℤ l)) (inl n)}
{ y = add-ℤ (inl (succ-ℕ n)) (neg-ℤ l)}
( ( right-successor-law-add-ℤ (neg-ℤ (succ-ℤ l)) (inl (succ-ℕ n))) ∙
( ( ap succ-ℤ
( commutative-add-ℤ (neg-ℤ (succ-ℤ l)) (inl (succ-ℕ n)))) ∙
( ( inv
( right-successor-law-add-ℤ
( inl (succ-ℕ n))
( neg-ℤ (succ-ℤ l)))) ∙
( ap
( add-ℤ (inl (succ-ℕ n)))
( ( ap succ-ℤ (inv (pred-neg-ℤ l))) ∙
( right-inverse-pred-ℤ (neg-ℤ l)))))))) ∙
( associative-add-ℤ (inl (succ-ℕ n)) (neg-ℤ l) (mul-ℤ (inl n) l)))))
right-successor-law-mul-ℤ (inr (inl star)) l = refl
right-successor-law-mul-ℤ (inr (inr zero-ℕ)) l = refl
right-successor-law-mul-ℤ (inr (inr (succ-ℕ n))) l =
( left-successor-law-mul-ℤ (in-pos n) (succ-ℤ l)) ∙
( ( ap (add-ℤ (succ-ℤ l)) (right-successor-law-mul-ℤ (inr (inr n)) l)) ∙
( ( inv (associative-add-ℤ (succ-ℤ l) (in-pos n) (mul-ℤ (in-pos n) l))) ∙
( ( ap
( λ t → add-ℤ t (mul-ℤ (in-pos n) l))
{ x = add-ℤ (succ-ℤ l) (in-pos n)}
{ y = add-ℤ (in-pos (succ-ℕ n)) l}
( ( left-successor-law-add-ℤ l (in-pos n)) ∙
( ( ap succ-ℤ (commutative-add-ℤ l (in-pos n))) ∙
( inv (left-successor-law-add-ℤ (in-pos n) l))))) ∙
( associative-add-ℤ (inr (inr (succ-ℕ n))) l (mul-ℤ (inr (inr n)) l)))))
right-predecessor-law-mul-ℤ :
(k l : ℤ) → Id (mul-ℤ k (pred-ℤ l)) (add-ℤ (neg-ℤ k) (mul-ℤ k l))
right-predecessor-law-mul-ℤ (inl zero-ℕ) l =
( left-neg-unit-law-mul-ℤ (pred-ℤ l)) ∙
( neg-pred-ℤ l)
right-predecessor-law-mul-ℤ (inl (succ-ℕ n)) l =
( left-predecessor-law-mul-ℤ (inl n) (pred-ℤ l)) ∙
( ( ap (add-ℤ (neg-ℤ (pred-ℤ l))) (right-predecessor-law-mul-ℤ (inl n) l)) ∙
( ( inv
( associative-add-ℤ (neg-ℤ (pred-ℤ l)) (in-pos n) (mul-ℤ (inl n) l))) ∙
( ( ap
( λ t → add-ℤ t (mul-ℤ (inl n) l))
{ x = add-ℤ (neg-ℤ (pred-ℤ l)) (inr (inr n))}
{ y = add-ℤ (neg-ℤ (inl (succ-ℕ n))) (neg-ℤ l)}
( ( ap (λ t → add-ℤ t (in-pos n)) (neg-pred-ℤ l)) ∙
( ( left-successor-law-add-ℤ (neg-ℤ l) (in-pos n)) ∙
( ( ap succ-ℤ (commutative-add-ℤ (neg-ℤ l) (in-pos n))) ∙
( inv (left-successor-law-add-ℤ (in-pos n) (neg-ℤ l))))))) ∙
( associative-add-ℤ (in-pos (succ-ℕ n)) (neg-ℤ l) (mul-ℤ (inl n) l)))))
right-predecessor-law-mul-ℤ (inr (inl star)) l = refl
right-predecessor-law-mul-ℤ (inr (inr zero-ℕ)) l = refl
right-predecessor-law-mul-ℤ (inr (inr (succ-ℕ n))) l =
( left-successor-law-mul-ℤ (in-pos n) (pred-ℤ l)) ∙
( ( ap (add-ℤ (pred-ℤ l)) (right-predecessor-law-mul-ℤ (inr (inr n)) l)) ∙
( ( inv (associative-add-ℤ (pred-ℤ l) (inl n) (mul-ℤ (inr (inr n)) l))) ∙
( ( ap
( λ t → add-ℤ t (mul-ℤ (in-pos n) l))
{ x = add-ℤ (pred-ℤ l) (inl n)}
{ y = add-ℤ (neg-ℤ (in-pos (succ-ℕ n))) l}
( ( left-predecessor-law-add-ℤ l (inl n)) ∙
( ( ap pred-ℤ (commutative-add-ℤ l (inl n))) ∙
( inv (left-predecessor-law-add-ℤ (inl n) l))))) ∙
( associative-add-ℤ (inl (succ-ℕ n)) l (mul-ℤ (inr (inr n)) l)))))
right-distributive-mul-add-ℤ :
(k l m : ℤ) → Id (mul-ℤ (add-ℤ k l) m) (add-ℤ (mul-ℤ k m) (mul-ℤ l m))
right-distributive-mul-add-ℤ (inl zero-ℕ) l m =
( left-predecessor-law-mul-ℤ l m) ∙
( ap
( λ t → add-ℤ t (mul-ℤ l m))
( inv
( ( left-predecessor-law-mul-ℤ zero-ℤ m) ∙
( right-unit-law-add-ℤ (neg-ℤ m)))))
right-distributive-mul-add-ℤ (inl (succ-ℕ x)) l m =
( left-predecessor-law-mul-ℤ (add-ℤ (inl x) l) m) ∙
( ( ap (add-ℤ (neg-ℤ m)) (right-distributive-mul-add-ℤ (inl x) l m)) ∙
( inv (associative-add-ℤ (neg-ℤ m) (mul-ℤ (inl x) m) (mul-ℤ l m))))
right-distributive-mul-add-ℤ (inr (inl star)) l m = refl
right-distributive-mul-add-ℤ (inr (inr zero-ℕ)) l m =
left-successor-law-mul-ℤ l m
right-distributive-mul-add-ℤ (inr (inr (succ-ℕ n))) l m =
( left-successor-law-mul-ℤ (add-ℤ (in-pos n) l) m) ∙
( ( ap (add-ℤ m) (right-distributive-mul-add-ℤ (inr (inr n)) l m)) ∙
( inv (associative-add-ℤ m (mul-ℤ (in-pos n) m) (mul-ℤ l m))))
left-negative-law-mul-ℤ :
(k l : ℤ) → Id (mul-ℤ (neg-ℤ k) l) (neg-ℤ (mul-ℤ k l))
left-negative-law-mul-ℤ (inl zero-ℕ) l =
( left-unit-law-mul-ℤ l) ∙
( inv (neg-neg-ℤ l))
left-negative-law-mul-ℤ (inl (succ-ℕ n)) l =
( ap (λ t → mul-ℤ t l) (neg-pred-ℤ (inl n))) ∙
( ( left-successor-law-mul-ℤ (neg-ℤ (inl n)) l) ∙
( ( ap (add-ℤ l) (left-negative-law-mul-ℤ (inl n) l)) ∙
( right-negative-law-add-ℤ l (mul-ℤ (inl n) l))))
left-negative-law-mul-ℤ (inr (inl star)) l = refl
left-negative-law-mul-ℤ (inr (inr zero-ℕ)) l = refl
left-negative-law-mul-ℤ (inr (inr (succ-ℕ n))) l =
( left-predecessor-law-mul-ℤ (inl n) l) ∙
( ( ap (add-ℤ (neg-ℤ l)) (left-negative-law-mul-ℤ (inr (inr n)) l)) ∙
( inv (distributive-neg-add-ℤ l (mul-ℤ (in-pos n) l))))
associative-mul-ℤ :
(k l m : ℤ) → Id (mul-ℤ (mul-ℤ k l) m) (mul-ℤ k (mul-ℤ l m))
associative-mul-ℤ (inl zero-ℕ) l m =
left-negative-law-mul-ℤ l m
associative-mul-ℤ (inl (succ-ℕ n)) l m =
( right-distributive-mul-add-ℤ (neg-ℤ l) (mul-ℤ (inl n) l) m) ∙
( ( ap (add-ℤ (mul-ℤ (neg-ℤ l) m)) (associative-mul-ℤ (inl n) l m)) ∙
( ap
( λ t → add-ℤ t (mul-ℤ (inl n) (mul-ℤ l m)))
( left-negative-law-mul-ℤ l m)))
associative-mul-ℤ (inr (inl star)) l m = refl
associative-mul-ℤ (inr (inr zero-ℕ)) l m = refl
associative-mul-ℤ (inr (inr (succ-ℕ n))) l m =
( right-distributive-mul-add-ℤ l (mul-ℤ (in-pos n) l) m) ∙
( ap (add-ℤ (mul-ℤ l m)) (associative-mul-ℤ (inr (inr n)) l m))
commutative-mul-ℤ :
(k l : ℤ) → Id (mul-ℤ k l) (mul-ℤ l k)
commutative-mul-ℤ (inl zero-ℕ) l = inv (right-neg-unit-law-mul-ℤ l)
commutative-mul-ℤ (inl (succ-ℕ n)) l =
( ap (add-ℤ (neg-ℤ l)) (commutative-mul-ℤ (inl n) l)) ∙
( inv (right-predecessor-law-mul-ℤ l (inl n)))
commutative-mul-ℤ (inr (inl star)) l = inv (right-zero-law-mul-ℤ l)
commutative-mul-ℤ (inr (inr zero-ℕ)) l = inv (right-unit-law-mul-ℤ l)
commutative-mul-ℤ (inr (inr (succ-ℕ n))) l =
( ap (add-ℤ l) (commutative-mul-ℤ (inr (inr n)) l)) ∙
( inv (right-successor-law-mul-ℤ l (in-pos n)))
| 37.001346
| 81
| 0.5622
|
9af4653093c23ea0e664946eff02fda660e3bdd4
| 10,551
|
agda
|
Agda
|
Cubical/Foundations/Equiv.agda
|
hyleIndex/cubical
|
ce5c2820ecb2e0fd8dce74fb0247856cdbf034c4
|
[
"MIT"
] | 301
|
2018-10-17T18:00:24.000Z
|
2022-03-24T02:10:47.000Z
|
Cubical/Foundations/Equiv.agda
|
hyleIndex/cubical
|
ce5c2820ecb2e0fd8dce74fb0247856cdbf034c4
|
[
"MIT"
] | 584
|
2018-10-15T09:49:02.000Z
|
2022-03-30T12:09:17.000Z
|
Cubical/Foundations/Equiv.agda
|
hyleIndex/cubical
|
ce5c2820ecb2e0fd8dce74fb0247856cdbf034c4
|
[
"MIT"
] | 134
|
2018-11-16T06:11:03.000Z
|
2022-03-23T16:22:13.000Z
|
{-
Theory about equivalences
Definitions are in Core/Glue.agda but re-exported by this module
- isEquiv is a proposition ([isPropIsEquiv])
- Any isomorphism is an equivalence ([isoToEquiv])
There are more statements about equivalences in Equiv/Properties.agda:
- if f is an equivalence then (cong f) is an equivalence
- if f is an equivalence then precomposition with f is an equivalence
- if f is an equivalence then postcomposition with f is an equivalence
-}
{-# OPTIONS --safe #-}
module Cubical.Foundations.Equiv where
open import Cubical.Foundations.Function
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Isomorphism
open import Cubical.Foundations.GroupoidLaws
open import Cubical.Foundations.Equiv.Base public
open import Cubical.Data.Sigma.Base
private
variable
ℓ ℓ' ℓ'' : Level
A B C D : Type ℓ
equivIsEquiv : (e : A ≃ B) → isEquiv (equivFun e)
equivIsEquiv e = snd e
equivCtr : (e : A ≃ B) (y : B) → fiber (equivFun e) y
equivCtr e y = e .snd .equiv-proof y .fst
equivCtrPath : (e : A ≃ B) (y : B) →
(v : fiber (equivFun e) y) → Path _ (equivCtr e y) v
equivCtrPath e y = e .snd .equiv-proof y .snd
-- Proof using isPropIsContr. This is slow and the direct proof below is better
isPropIsEquiv' : (f : A → B) → isProp (isEquiv f)
equiv-proof (isPropIsEquiv' f u0 u1 i) y =
isPropIsContr (u0 .equiv-proof y) (u1 .equiv-proof y) i
-- Direct proof that computes quite ok (can be optimized further if
-- necessary, see:
-- https://github.com/mortberg/cubicaltt/blob/pi4s3_dimclosures/examples/brunerie2.ctt#L562
isPropIsEquiv : (f : A → B) → isProp (isEquiv f)
equiv-proof (isPropIsEquiv f p q i) y =
let p2 = p .equiv-proof y .snd
q2 = q .equiv-proof y .snd
in p2 (q .equiv-proof y .fst) i
, λ w j → hcomp (λ k → λ { (i = i0) → p2 w j
; (i = i1) → q2 w (j ∨ ~ k)
; (j = i0) → p2 (q2 w (~ k)) i
; (j = i1) → w })
(p2 w (i ∨ j))
equivEq : {e f : A ≃ B} → (h : e .fst ≡ f .fst) → e ≡ f
equivEq {e = e} {f = f} h = λ i → (h i) , isProp→PathP (λ i → isPropIsEquiv (h i)) (e .snd) (f .snd) i
module _ {f : A → B} (equivF : isEquiv f) where
funIsEq : A → B
funIsEq = f
invIsEq : B → A
invIsEq y = equivF .equiv-proof y .fst .fst
secIsEq : section f invIsEq
secIsEq y = equivF .equiv-proof y .fst .snd
retIsEq : retract f invIsEq
retIsEq a i = equivF .equiv-proof (f a) .snd (a , refl) i .fst
commSqIsEq : ∀ a → Square (secIsEq (f a)) refl (cong f (retIsEq a)) refl
commSqIsEq a i = equivF .equiv-proof (f a) .snd (a , refl) i .snd
commPathIsEq : ∀ a → secIsEq (f a) ≡ cong f (retIsEq a)
commPathIsEq a i j =
hcomp
(λ k → λ
{ (i = i0) → secIsEq (f a) j
; (i = i1) → f (retIsEq a (j ∨ ~ k))
; (j = i0) → f (retIsEq a (i ∧ ~ k))
; (j = i1) → f a
})
(commSqIsEq a i j)
module _ (w : A ≃ B) where
invEq : B → A
invEq = invIsEq (snd w)
retEq : retract (w .fst) invEq
retEq = retIsEq (snd w)
secEq : section (w .fst) invEq
secEq = secIsEq (snd w)
open Iso
equivToIso : ∀ {ℓ ℓ'} {A : Type ℓ} {B : Type ℓ'} → A ≃ B → Iso A B
fun (equivToIso e) = e .fst
inv (equivToIso e) = invEq e
rightInv (equivToIso e) = secEq e
leftInv (equivToIso e) = retEq e
-- TODO: there should be a direct proof of this that doesn't use equivToIso
invEquiv : A ≃ B → B ≃ A
invEquiv e = isoToEquiv (invIso (equivToIso e))
invEquivIdEquiv : (A : Type ℓ) → invEquiv (idEquiv A) ≡ idEquiv A
invEquivIdEquiv _ = equivEq refl
compEquiv : A ≃ B → B ≃ C → A ≃ C
compEquiv f g .fst = g .fst ∘ f .fst
compEquiv {A = A} {C = C} f g .snd .equiv-proof c = contr
where
contractG = g .snd .equiv-proof c .snd
secFiller : (a : A) (p : g .fst (f .fst a) ≡ c) → _ {- square in A -}
secFiller a p = compPath-filler (cong (invEq f ∘ fst) (contractG (_ , p))) (retEq f a)
contr : isContr (fiber (g .fst ∘ f .fst) c)
contr .fst .fst = invEq f (invEq g c)
contr .fst .snd = cong (g .fst) (secEq f (invEq g c)) ∙ secEq g c
contr .snd (a , p) i .fst = secFiller a p i1 i
contr .snd (a , p) i .snd j =
hcomp
(λ k → λ
{ (i = i1) → fSquare k
; (j = i0) → g .fst (f .fst (secFiller a p k i))
; (j = i1) → contractG (_ , p) i .snd k
})
(g .fst (secEq f (contractG (_ , p) i .fst) j))
where
fSquare : I → C
fSquare k =
hcomp
(λ l → λ
{ (j = i0) → g .fst (f .fst (retEq f a k))
; (j = i1) → p (k ∧ l)
; (k = i0) → g .fst (secEq f (f .fst a) j)
; (k = i1) → p (j ∧ l)
})
(g .fst (f .snd .equiv-proof (f .fst a) .snd (a , refl) k .snd j))
compEquivIdEquiv : (e : A ≃ B) → compEquiv (idEquiv A) e ≡ e
compEquivIdEquiv e = equivEq refl
compEquivEquivId : (e : A ≃ B) → compEquiv e (idEquiv B) ≡ e
compEquivEquivId e = equivEq refl
invEquiv-is-rinv : (e : A ≃ B) → compEquiv e (invEquiv e) ≡ idEquiv A
invEquiv-is-rinv e = equivEq (funExt (retEq e))
invEquiv-is-linv : (e : A ≃ B) → compEquiv (invEquiv e) e ≡ idEquiv B
invEquiv-is-linv e = equivEq (funExt (secEq e))
compEquiv-assoc : (f : A ≃ B) (g : B ≃ C) (h : C ≃ D)
→ compEquiv f (compEquiv g h) ≡ compEquiv (compEquiv f g) h
compEquiv-assoc f g h = equivEq refl
LiftEquiv : A ≃ Lift {i = ℓ} {j = ℓ'} A
LiftEquiv .fst a .lower = a
LiftEquiv .snd .equiv-proof = strictContrFibers lower
Lift≃Lift : (e : A ≃ B) → Lift {j = ℓ'} A ≃ Lift {j = ℓ''} B
Lift≃Lift e .fst a .lower = e .fst (a .lower)
Lift≃Lift e .snd .equiv-proof b .fst .fst .lower = invEq e (b .lower)
Lift≃Lift e .snd .equiv-proof b .fst .snd i .lower =
e .snd .equiv-proof (b .lower) .fst .snd i
Lift≃Lift e .snd .equiv-proof b .snd (a , p) i .fst .lower =
e .snd .equiv-proof (b .lower) .snd (a .lower , cong lower p) i .fst
Lift≃Lift e .snd .equiv-proof b .snd (a , p) i .snd j .lower =
e .snd .equiv-proof (b .lower) .snd (a .lower , cong lower p) i .snd j
isContr→Equiv : isContr A → isContr B → A ≃ B
isContr→Equiv Actr Bctr = isoToEquiv (isContr→Iso Actr Bctr)
propBiimpl→Equiv : (Aprop : isProp A) (Bprop : isProp B) (f : A → B) (g : B → A) → A ≃ B
propBiimpl→Equiv Aprop Bprop f g = f , hf
where
hf : isEquiv f
hf .equiv-proof y .fst = (g y , Bprop (f (g y)) y)
hf .equiv-proof y .snd h i .fst = Aprop (g y) (h .fst) i
hf .equiv-proof y .snd h i .snd = isProp→isSet' Bprop (Bprop (f (g y)) y) (h .snd)
(cong f (Aprop (g y) (h .fst))) refl i
isEquivPropBiimpl→Equiv : isProp A → isProp B
→ ((A → B) × (B → A)) ≃ (A ≃ B)
isEquivPropBiimpl→Equiv {A = A} {B = B} Aprop Bprop = isoToEquiv isom where
isom : Iso (Σ (A → B) (λ _ → B → A)) (A ≃ B)
isom .fun (f , g) = propBiimpl→Equiv Aprop Bprop f g
isom .inv e = equivFun e , invEq e
isom .rightInv e = equivEq refl
isom .leftInv _ = refl
equivΠCod : ∀ {F : A → Type ℓ} {G : A → Type ℓ'}
→ ((x : A) → F x ≃ G x) → ((x : A) → F x) ≃ ((x : A) → G x)
equivΠCod k .fst f x = k x .fst (f x)
equivΠCod k .snd .equiv-proof f .fst .fst x = equivCtr (k x) (f x) .fst
equivΠCod k .snd .equiv-proof f .fst .snd i x = equivCtr (k x) (f x) .snd i
equivΠCod k .snd .equiv-proof f .snd (g , p) i .fst x =
equivCtrPath (k x) (f x) (g x , λ j → p j x) i .fst
equivΠCod k .snd .equiv-proof f .snd (g , p) i .snd j x =
equivCtrPath (k x) (f x) (g x , λ k → p k x) i .snd j
equivImplicitΠCod : ∀ {F : A → Type ℓ} {G : A → Type ℓ'}
→ ({x : A} → F x ≃ G x) → ({x : A} → F x) ≃ ({x : A} → G x)
equivImplicitΠCod k .fst f {x} = k {x} .fst (f {x})
equivImplicitΠCod k .snd .equiv-proof f .fst .fst {x} = equivCtr (k {x}) (f {x}) .fst
equivImplicitΠCod k .snd .equiv-proof f .fst .snd i {x} = equivCtr (k {x}) (f {x}) .snd i
equivImplicitΠCod k .snd .equiv-proof f .snd (g , p) i .fst {x} =
equivCtrPath (k {x}) (f {x}) (g {x} , λ j → p j {x}) i .fst
equivImplicitΠCod k .snd .equiv-proof f .snd (g , p) i .snd j {x} =
equivCtrPath (k {x}) (f {x}) (g {x} , λ k → p k {x}) i .snd j
equiv→Iso : (A ≃ B) → (C ≃ D) → Iso (A → C) (B → D)
equiv→Iso h k .Iso.fun f b = equivFun k (f (invEq h b))
equiv→Iso h k .Iso.inv g a = invEq k (g (equivFun h a))
equiv→Iso h k .Iso.rightInv g = funExt λ b → secEq k _ ∙ cong g (secEq h b)
equiv→Iso h k .Iso.leftInv f = funExt λ a → retEq k _ ∙ cong f (retEq h a)
equiv→ : (A ≃ B) → (C ≃ D) → (A → C) ≃ (B → D)
equiv→ h k = isoToEquiv (equiv→Iso h k)
equivΠ : ∀ {ℓA ℓA' ℓB ℓB'} {A : Type ℓA} {A' : Type ℓA'}
{B : A → Type ℓB} {B' : A' → Type ℓB'}
(eA : A ≃ A')
(eB : (a : A) → B a ≃ B' (eA .fst a))
→ ((a : A) → B a) ≃ ((a' : A') → B' a')
equivΠ {B' = B'} eA eB = isoToEquiv isom
where
open Iso
isom : Iso _ _
isom .fun f a' =
subst B' (secEq eA a') (eB _ .fst (f (invEq eA a')))
isom .inv f' a =
invEq (eB _) (f' (eA .fst a))
isom .rightInv f' =
funExt λ a' →
cong (subst B' (secEq eA a')) (secEq (eB _) _)
∙ fromPathP (cong f' (secEq eA a'))
isom .leftInv f =
funExt λ a →
invEq (eB a) (subst B' (secEq eA _) (eB _ .fst (f (invEq eA (eA .fst a)))))
≡⟨ cong (λ t → invEq (eB a) (subst B' t (eB _ .fst (f (invEq eA (eA .fst a))))))
(commPathIsEq (snd eA) a) ⟩
invEq (eB a) (subst B' (cong (eA .fst) (retEq eA a)) (eB _ .fst (f (invEq eA (eA .fst a)))))
≡⟨ cong (invEq (eB a)) (fromPathP (λ i → eB _ .fst (f (retEq eA a i)))) ⟩
invEq (eB a) (eB a .fst (f a))
≡⟨ retEq (eB _) (f a) ⟩
f a
∎
equivCompIso : (A ≃ B) → (C ≃ D) → Iso (A ≃ C) (B ≃ D)
equivCompIso h k .Iso.fun f = compEquiv (compEquiv (invEquiv h) f) k
equivCompIso h k .Iso.inv g = compEquiv (compEquiv h g) (invEquiv k)
equivCompIso h k .Iso.rightInv g = equivEq (equiv→Iso h k .Iso.rightInv (equivFun g))
equivCompIso h k .Iso.leftInv f = equivEq (equiv→Iso h k .Iso.leftInv (equivFun f))
equivComp : (A ≃ B) → (C ≃ D) → (A ≃ C) ≃ (B ≃ D)
equivComp h k = isoToEquiv (equivCompIso h k)
-- Some helpful notation:
_≃⟨_⟩_ : (X : Type ℓ) → (X ≃ B) → (B ≃ C) → (X ≃ C)
_ ≃⟨ f ⟩ g = compEquiv f g
_■ : (X : Type ℓ) → (X ≃ X)
_■ = idEquiv
infixr 0 _≃⟨_⟩_
infix 1 _■
composesToId→Equiv : (f : A → B) (g : B → A) → f ∘ g ≡ idfun B → isEquiv f → isEquiv g
composesToId→Equiv f g id iseqf =
isoToIsEquiv
(iso g f
(λ b → (λ i → equiv-proof iseqf (f b) .snd (g (f b) , cong (λ h → h (f b)) id) (~ i) .fst)
∙∙ cong (λ x → equiv-proof iseqf (f b) .fst .fst) id
∙∙ λ i → equiv-proof iseqf (f b) .snd (b , refl) i .fst)
λ a i → id i a)
| 36.382759
| 102
| 0.562222
|
57c8357726617997acf2be34407a927e1525e58d
| 540
|
agda
|
Agda
|
test/fail/Issue691.agda
|
masondesu/agda
|
70c8a575c46f6a568c7518150a1a64fcd03aa437
|
[
"MIT"
] | 1
|
2018-10-10T17:08:44.000Z
|
2018-10-10T17:08:44.000Z
|
test/fail/Issue691.agda
|
np/agda-git-experiment
|
20596e9dd9867166a64470dd24ea68925ff380ce
|
[
"MIT"
] | null | null | null |
test/fail/Issue691.agda
|
np/agda-git-experiment
|
20596e9dd9867166a64470dd24ea68925ff380ce
|
[
"MIT"
] | null | null | null |
-- Andreas, 2012-09-07
-- {-# OPTIONS -v tc.polarity:10 -v tc.conv.irr:20 -v tc.conv.elim:25 -v tc.conv.term:10 #-}
module Issue691 where
open import Common.Equality
data Bool : Set where
true false : Bool
assert : (A : Set) → A → Bool → Bool
assert _ _ true = true
assert _ _ false = false
g : Bool -> Bool -> Bool
g x true = true
g x false = true
unsolved : Bool -> Bool
unsolved y =
let X : Bool
X = _
in assert (g X y ≡ g true y) refl X
-- X should be left unsolved
istrue : (unsolved false) ≡ true
istrue = refl
| 18.62069
| 92
| 0.635185
|
ada976e329647f2da9e4ed4a042bc05f1b3f1e1d
| 2,302
|
agda
|
Agda
|
Experiment/Categories/Solver/Category/Cartesian/Example.agda
|
rei1024/agda-misc
|
37200ea91d34a6603d395d8ac81294068303f577
|
[
"MIT"
] | 3
|
2020-04-07T17:49:42.000Z
|
2020-04-21T00:03:43.000Z
|
Experiment/Categories/Solver/Category/Cartesian/Example.agda
|
rei1024/agda-misc
|
37200ea91d34a6603d395d8ac81294068303f577
|
[
"MIT"
] | null | null | null |
Experiment/Categories/Solver/Category/Cartesian/Example.agda
|
rei1024/agda-misc
|
37200ea91d34a6603d395d8ac81294068303f577
|
[
"MIT"
] | null | null | null |
-- Example usage of solver
{-# OPTIONS --without-K --safe #-}
open import Categories.Category
open import Categories.Category.Cartesian
module Experiment.Categories.Solver.Category.Cartesian.Example
{o ℓ e} {𝒞 : Category o ℓ e} (cartesian : Cartesian 𝒞) where
open import Experiment.Categories.Solver.Category.Cartesian cartesian
open Category 𝒞
open Cartesian cartesian
open HomReasoning
private
variable
A B C D E F : Obj
module _ {f : D ⇒ E} {g : C ⇒ D} {h : B ⇒ C} {i : A ⇒ B} where
_ : (f ∘ g) ∘ id ∘ h ∘ i ≈ f ∘ (g ∘ h) ∘ i
_ = solve ((∥-∥ :∘ ∥-∥) :∘ :id :∘ ∥-∥ :∘ ∥-∥) (∥-∥ :∘ (∥-∥ :∘ ∥-∥) :∘ ∥-∥) refl
swap∘swap≈id :
∀ {A B} → swap {A}{B} ∘ swap {B}{A} ≈ id
swap∘swap≈id {A} {B} =
solve (:swap {∥ A ∥} {∥ B ∥} :∘ :swap)
:id
refl
assocʳ∘assocˡ≈id : ∀ {A B C} → assocʳ {A}{B}{C} ∘ assocˡ {A}{B}{C} ≈ id
assocʳ∘assocˡ≈id = solve (:assocʳ {∥ _ ∥} {∥ _ ∥} {∥ _ ∥} :∘ :assocˡ) :id refl
module _ {f : B ⇒ C} (f′ : A ⇒ B) {g : E ⇒ F} {g′ : D ⇒ E} where
⁂-∘ : (f ⁂ g) ∘ (f′ ⁂ g′) ≈ (f ∘ f′) ⁂ (g ∘ g′)
⁂-∘ = solve lhs rhs refl where
lhs = (∥ f ∥ :⁂ ∥ g ∥) :∘ (∥ f′ ∥ :⁂ ∥ g′ ∥)
rhs = (∥ f ∥ :∘ ∥ f′ ∥) :⁂ (∥ g ∥ :∘ ∥ g′ ∥)
module _ {A B C D} where
pentagon′ : (id ⁂ assocˡ) ∘ assocˡ ∘ (assocˡ ⁂ id) ≈
assocˡ ∘ assocˡ {A × B} {C} {D}
pentagon′ = solve lhs rhs refl where
lhs = (:id :⁂ :assocˡ) :∘ :assocˡ :∘ (:assocˡ :⁂ :id)
rhs = :assocˡ :∘ :assocˡ {∥ A ∥ :× ∥ B ∥} {∥ C ∥} {∥ D ∥}
module _ {A B C} where
hexagon₁′ : (id ⁂ swap) ∘ assocˡ ∘ (swap ⁂ id) ≈
assocˡ ∘ swap ∘ assocˡ {A}{B}{C}
hexagon₁′ = solve lhs rhs refl where
lhs = (:id :⁂ :swap) :∘ :assocˡ :∘ (:swap :⁂ :id)
rhs = :assocˡ :∘ :swap :∘ :assocˡ {∥ A ∥}{∥ B ∥}{∥ C ∥}
module _ {f : A ⇒ B} where
commute : ⟨ ! , id ⟩ ∘ f ≈ ⟨ id ∘ π₁ , f ∘ π₂ ⟩ ∘ ⟨ ! , id ⟩
commute = solve (:⟨ :! , :id ⟩ :∘ ∥ f ∥)
(:⟨ :id :∘ :π₁ , ∥ f ∥ :∘ :π₂ ⟩ :∘ :⟨ :! , :id ⟩)
refl
_ : id {⊤} ≈ !
_ = solve (∥ id !∥) :! refl
_ : π₁ {⊤} {⊤} ≈ π₂
_ = solve (:π₁ {:⊤} {:⊤}) :π₂ refl
module _ {f : A ⇒ B} {g : C ⇒ D} where
first↔second′ : first f ∘ second g ≈ second g ∘ first f
first↔second′ = solve (:first ∥ f ∥ :∘ :second ∥ g ∥)
(:second ∥ g ∥ :∘ :first ∥ f ∥)
refl
| 31.534247
| 81
| 0.454822
|
4be1c937b0e104bf38c97d9916b7afbc25d31386
| 1,011
|
agda
|
Agda
|
test/Succeed/RecordUpdateSyntax.agda
|
pthariensflame/agda
|
222c4c64b2ccf8e0fc2498492731c15e8fef32d4
|
[
"BSD-3-Clause"
] | 3
|
2015-03-28T14:51:03.000Z
|
2015-12-07T20:14:00.000Z
|
test/Succeed/RecordUpdateSyntax.agda
|
Blaisorblade/Agda
|
802a28aa8374f15fe9d011ceb80317fdb1ec0949
|
[
"BSD-3-Clause"
] | null | null | null |
test/Succeed/RecordUpdateSyntax.agda
|
Blaisorblade/Agda
|
802a28aa8374f15fe9d011ceb80317fdb1ec0949
|
[
"BSD-3-Clause"
] | null | null | null |
module RecordUpdateSyntax where
open import Common.Prelude
open import Common.Equality
data Param : Nat → Set where
param : ∀ n → Param (suc n)
record R : Set where
field
{i} : Nat
p : Param i
s : Nat
old : R
old = record { p = param 0; s = 1 }
-- Simple update, it should be able to infer the type and the implicit.
new : _
new = record old { p = param 1 }
new′ : R
new′ = record { i = 2; p = param 1; s = 1 }
-- Here's a needlessly complex update.
upd-p-s : _ → _ → _ → R
upd-p-s zero s r = record r { p = param zero; s = s }
upd-p-s (suc n) s r = record (upd-p-s n 0 r) { p = param n; s = s }
eq₁ : new ≡ new′
eq₁ = refl
eq₂ : upd-p-s zero 1 (record new { s = 0 }) ≡ old
eq₂ = refl
-- Check that instance arguments are handled properly
postulate
T : Nat → Set
instance
t0 : T 0
t1 : T 1
record Instance : Set where
field
n : Nat
{{t}} : T n
r0 : Instance
r0 = record { n = 0 }
r1 : Instance
r1 = record r0 { n = 1 }
check : Instance.t r1 ≡ t1
check = refl
| 18.053571
| 71
| 0.593472
|
0381bcd3202baa6897123c389e8136e3f49c6bf8
| 1,030
|
agda
|
Agda
|
test/Succeed/Issue1227.agda
|
vlopezj/agda
|
ff4d89e75970cf27599fb9f572bd43c9455cbb56
|
[
"BSD-3-Clause"
] | 3
|
2015-03-28T14:51:03.000Z
|
2015-12-07T20:14:00.000Z
|
test/Succeed/Issue1227.agda
|
vikfret/agda
|
49ad0b3f0d39c01bc35123478b857e702b29fb9d
|
[
"BSD-3-Clause"
] | 3
|
2018-11-14T15:31:44.000Z
|
2019-04-01T19:39:26.000Z
|
test/Succeed/Issue1227.agda
|
vikfret/agda
|
49ad0b3f0d39c01bc35123478b857e702b29fb9d
|
[
"BSD-3-Clause"
] | 1
|
2015-09-15T14:36:15.000Z
|
2015-09-15T14:36:15.000Z
|
open import Common.Prelude hiding (pred)
open import Common.Reflection
open import Common.Equality
un-function : Definition → FunDef
un-function (funDef cs) = funDef unknown cs
un-function _ = funDef unknown []
data Is-suc : Nat → Set where
is-suc : ∀ n → Is-suc (suc n)
pred : (n : Nat) → Is-suc n → Nat
pred ._ (is-suc n) = n
pred-def : FunDef
pred-def =
funDef (quoteTerm ((n : Nat) → Is-suc n → Nat))
(clause (vArg dot ∷ vArg (con (quote is-suc) (vArg (var "n") ∷ [])) ∷ [])
(var 0 []) ∷ [])
data Is-zero : Nat → Set where
is-zero : Is-zero zero
f : (n : Nat) → Is-zero n → Nat
f ._ is-zero = zero
f-def : FunDef
f-def =
funDef (quoteTerm ((n : Nat) → Is-zero n → Nat))
(clause (vArg dot ∷ vArg (con (quote is-zero) []) ∷ [])
(con (quote zero) []) ∷ [])
unquoteDecl pred' = define (vArg pred') pred-def
unquoteDecl f' = define (vArg f') f-def
check-pred : pred' 4 (is-suc _) ≡ 3
check-pred = refl
check-f : f' 0 is-zero ≡ 0
check-f = refl
| 24.52381
| 82
| 0.574757
|
58a26aa4b56b4098d8df7d97e504415eb528bab8
| 1,655
|
agda
|
Agda
|
src/Categories/Category/Monoidal/Braided.agda
|
MirceaS/agda-categories
|
58e5ec015781be5413bdf968f7ec4fdae0ab4b21
|
[
"MIT"
] | null | null | null |
src/Categories/Category/Monoidal/Braided.agda
|
MirceaS/agda-categories
|
58e5ec015781be5413bdf968f7ec4fdae0ab4b21
|
[
"MIT"
] | null | null | null |
src/Categories/Category/Monoidal/Braided.agda
|
MirceaS/agda-categories
|
58e5ec015781be5413bdf968f7ec4fdae0ab4b21
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --without-K --safe #-}
open import Categories.Category
open import Categories.Category.Monoidal.Core using (Monoidal)
module Categories.Category.Monoidal.Braided {o ℓ e} {C : Category o ℓ e} (M : Monoidal C) where
open import Level
open import Data.Product using (Σ; _,_)
open import Categories.Functor.Bifunctor
open import Categories.NaturalTransformation.NaturalIsomorphism
open Category C
open Commutation
private
variable
X Y Z : Obj
-- braided monoidal category
-- it has a braiding natural isomorphism has two hexagon identities.
-- these two identities are directly expressed in the morphism level.
record Braided : Set (levelOfTerm M) where
open Monoidal M public
field
braiding : NaturalIsomorphism ⊗ (flip-bifunctor ⊗)
module braiding = NaturalIsomorphism braiding
private
B : ∀ {X Y} → X ⊗₀ Y ⇒ Y ⊗₀ X
B {X} {Y} = braiding.⇒.η (X , Y)
field
hexagon₁ : [ (X ⊗₀ Y) ⊗₀ Z ⇒ Y ⊗₀ Z ⊗₀ X ]⟨
B ⊗₁ id ⇒⟨ (Y ⊗₀ X) ⊗₀ Z ⟩
associator.from ⇒⟨ Y ⊗₀ X ⊗₀ Z ⟩
id ⊗₁ B
≈ associator.from ⇒⟨ X ⊗₀ Y ⊗₀ Z ⟩
B ⇒⟨ (Y ⊗₀ Z) ⊗₀ X ⟩
associator.from
⟩
hexagon₂ : [ X ⊗₀ Y ⊗₀ Z ⇒ (Z ⊗₀ X) ⊗₀ Y ]⟨
id ⊗₁ B ⇒⟨ X ⊗₀ Z ⊗₀ Y ⟩
(associator.to ⇒⟨ (X ⊗₀ Z) ⊗₀ Y ⟩
B ⊗₁ id)
≈ associator.to ⇒⟨ (X ⊗₀ Y) ⊗₀ Z ⟩
(B ⇒⟨ Z ⊗₀ X ⊗₀ Y ⟩
associator.to)
⟩
| 30.648148
| 95
| 0.503927
|
22c02196ad4559723ef4300bc2d674d534cc5f83
| 1,291
|
agda
|
Agda
|
vendor/stdlib/src/Data/Fin/Substitution/List.agda
|
isabella232/Lemmachine
|
8ef786b40e4a9ab274c6103dc697dcb658cf3db3
|
[
"MIT"
] | 56
|
2015-01-20T02:11:42.000Z
|
2021-12-21T17:02:19.000Z
|
vendor/stdlib/src/Data/Fin/Substitution/List.agda
|
larrytheliquid/Lemmachine
|
8ef786b40e4a9ab274c6103dc697dcb658cf3db3
|
[
"MIT"
] | 1
|
2022-03-12T12:17:51.000Z
|
2022-03-12T12:17:51.000Z
|
vendor/stdlib/src/Data/Fin/Substitution/List.agda
|
isabella232/Lemmachine
|
8ef786b40e4a9ab274c6103dc697dcb658cf3db3
|
[
"MIT"
] | 3
|
2015-07-21T16:37:58.000Z
|
2022-03-12T11:54:10.000Z
|
------------------------------------------------------------------------
-- Application of substitutions to lists, along with various lemmas
------------------------------------------------------------------------
-- This module illustrates how Data.Fin.Substitution.Lemmas.AppLemmas
-- can be used.
open import Data.Fin.Substitution.Lemmas
module Data.Fin.Substitution.List {T} (lemmas₄ : Lemmas₄ T) where
open import Data.List
open import Data.List.Properties
open import Data.Fin.Substitution
import Data.Function as Fun
open import Relation.Binary.PropositionalEquality
open ≡-Reasoning
private
open module L = Lemmas₄ lemmas₄ using (_/_; id; _⊙_)
infixl 8 _//_
_//_ : ∀ {m n} → List (T m) → Sub T m n → List (T n)
ts // ρ = map (λ σ → σ / ρ) ts
appLemmas : AppLemmas (λ n → List (T n)) T
appLemmas = record
{ application = record { _/_ = _//_ }
; lemmas₄ = lemmas₄
; id-vanishes = λ ts → begin
ts // id ≡⟨ map-cong L.id-vanishes ts ⟩
map Fun.id ts ≡⟨ map-id ts ⟩
ts ∎
; /-⊙ = λ {_ _ _ ρ₁ ρ₂} ts → begin
ts // ρ₁ ⊙ ρ₂ ≡⟨ map-cong L./-⊙ ts ⟩
map (λ σ → σ / ρ₁ / ρ₂) ts ≡⟨ map-compose ts ⟩
ts // ρ₁ // ρ₂ ∎
}
open AppLemmas appLemmas public
hiding (_/_) renaming (_/✶_ to _//✶_)
| 30.023256
| 72
| 0.540666
|
12d52ea83ffb8797206a738ac3eccaf47611b435
| 882
|
agda
|
Agda
|
Cubical/Data/Nat/Base.agda
|
ryanorendorff/cubical
|
c67854d2e11aafa5677e25a09087e176fafd3e43
|
[
"MIT"
] | 1
|
2020-03-23T23:52:11.000Z
|
2020-03-23T23:52:11.000Z
|
Cubical/Data/Nat/Base.agda
|
ryanorendorff/cubical
|
c67854d2e11aafa5677e25a09087e176fafd3e43
|
[
"MIT"
] | null | null | null |
Cubical/Data/Nat/Base.agda
|
ryanorendorff/cubical
|
c67854d2e11aafa5677e25a09087e176fafd3e43
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --cubical --no-exact-split --safe #-}
module Cubical.Data.Nat.Base where
open import Cubical.Core.Primitives
open import Agda.Builtin.Nat public
using (zero; suc; _+_; _*_)
renaming (Nat to ℕ; _-_ to _∸_)
open import Cubical.Data.Nat.Literals public
predℕ : ℕ → ℕ
predℕ zero = zero
predℕ (suc n) = n
caseNat : ∀ {ℓ} → {A : Type ℓ} → (a0 aS : A) → ℕ → A
caseNat a0 aS zero = a0
caseNat a0 aS (suc n) = aS
doubleℕ : ℕ → ℕ
doubleℕ zero = zero
doubleℕ (suc x) = suc (suc (doubleℕ x))
-- doublesℕ n m = 2^n * m
doublesℕ : ℕ → ℕ → ℕ
doublesℕ zero m = m
doublesℕ (suc n) m = doublesℕ n (doubleℕ m)
-- iterate
iter : ∀ {ℓ} {A : Type ℓ} → ℕ → (A → A) → A → A
iter zero f z = z
iter (suc n) f z = f (iter n f z)
elim : ∀ {ℓ} {A : ℕ → Type ℓ}
→ A zero
→ ((n : ℕ) → A n → A (suc n))
→ (n : ℕ) → A n
elim a₀ _ zero = a₀
elim a₀ f (suc n) = f n (elim a₀ f n)
| 22.05
| 52
| 0.580499
|
2e3bba34d44f53febf0871225ea9fdc81d83dcf3
| 1,306
|
agda
|
Agda
|
demo/agda/FRP/JS/Demo/Calculator/View.agda
|
agda/agda-frp-js
|
c7ccaca624cb1fa1c982d8a8310c313fb9a7fa72
|
[
"MIT",
"BSD-3-Clause"
] | 63
|
2015-04-20T21:47:00.000Z
|
2022-02-28T09:46:14.000Z
|
demo/agda/FRP/JS/Demo/Calculator/View.agda
|
agda/agda-frp-js
|
c7ccaca624cb1fa1c982d8a8310c313fb9a7fa72
|
[
"MIT",
"BSD-3-Clause"
] | null | null | null |
demo/agda/FRP/JS/Demo/Calculator/View.agda
|
agda/agda-frp-js
|
c7ccaca624cb1fa1c982d8a8310c313fb9a7fa72
|
[
"MIT",
"BSD-3-Clause"
] | 7
|
2016-11-07T21:50:58.000Z
|
2022-03-12T11:39:38.000Z
|
open import FRP.JS.Behaviour using ( Beh ; [_] ; map )
open import FRP.JS.Event using ( Evt ; tag )
open import FRP.JS.DOM using
( DOM ; click ; element ; text ; _++_ ; element+ ; text+ ; listen+ ; _+++_ )
open import FRP.JS.RSet using ( RSet ; ⟦_⟧ ; ⟨_⟩ ; _⇒_ )
open import FRP.JS.Product using ( _∧_ ; _,_ )
open import FRP.JS.Demo.Calculator.Model using
( Button ; State ; digit ; op ; clear ; eq ; plus ; minus ; times ; button$ ; state$ ; model )
module FRP.JS.Demo.Calculator.View where
button : ∀ {w} → Button → ⟦ Beh (DOM w) ∧ Evt ⟨ Button ⟩ ⟧
button b = listen+ click (λ _ → b) (element+ "button" (text+ [ button$ b ]))
keypad : ∀ {w} → ⟦ Beh (DOM w) ∧ Evt ⟨ Button ⟩ ⟧
keypad =
element+ "div" (button (digit 7) +++ button (digit 8) +++ button (digit 9) ) +++
element+ "div" (button (digit 4) +++ button (digit 5) +++ button (digit 6) ) +++
element+ "div" (button (digit 1) +++ button (digit 2) +++ button (digit 3) ) +++
element+ "div" (button (op eq) +++ button (digit 0) +++ button clear ) +++
element+ "div" (button (op plus) +++ button (op minus) +++ button (op times))
display : ∀ {w} → ⟦ Beh ⟨ State ⟩ ⇒ Beh (DOM w) ⟧
display σ = element "div" (text (map state$ σ))
view : ∀ {w} → ⟦ Beh (DOM w) ⟧
view with keypad
... | (dom , evt) = display (model evt) ++ dom
| 46.642857
| 96
| 0.579632
|
192c5246872183b9704ff61b8df89584db7b730c
| 746
|
agda
|
Agda
|
test/Succeed/Issue3390.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
test/Succeed/Issue3390.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
test/Succeed/Issue3390.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
{-# OPTIONS --allow-unsolved-metas #-}
module _ where
open import Agda.Builtin.Equality
module Case₀ where
postulate
I : Set
P : I → Set
variable
p : P _
postulate
D : P _ → Set
d : D p
module Case₁ where
postulate
I : Set
P : I → Set
Q : ∀ n → P n → Set
variable
q : Q _ _
postulate
D : ∀ {p} → Q _ p → Set
d : D q
module Case₂ where
postulate
I : Set
P : I → Set
Q : ∀ n → P n → Set
record R n (p : P n) : Set where
constructor c
field
f : Q _ p
variable
q : Q _ _
data D {p} : R _ p → Set where
d : D (c q)
module Case₃ where
variable
A : Set
a : A
record B : Set where
id = λ x → x ≡ x
field
b : id a
| 12.229508
| 38
| 0.504021
|
22953af969acc076bd6e4659d2e37795bd4f98dc
| 30,384
|
agda
|
Agda
|
Cubical/ZCohomology/Properties.agda
|
cangiuli/cubical
|
d103ec455d41cccf9b13a4803e7d3cf462e00067
|
[
"MIT"
] | null | null | null |
Cubical/ZCohomology/Properties.agda
|
cangiuli/cubical
|
d103ec455d41cccf9b13a4803e7d3cf462e00067
|
[
"MIT"
] | null | null | null |
Cubical/ZCohomology/Properties.agda
|
cangiuli/cubical
|
d103ec455d41cccf9b13a4803e7d3cf462e00067
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --cubical --no-import-sorts --safe #-}
module Cubical.ZCohomology.Properties where
open import Cubical.ZCohomology.Base
open import Cubical.HITs.S1
open import Cubical.HITs.Sn
open import Cubical.Foundations.HLevels
open import Cubical.Foundations.Function
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Pointed
open import Cubical.Foundations.Transport
open import Cubical.Foundations.Isomorphism
open import Cubical.Foundations.GroupoidLaws
open import Cubical.Foundations.Univalence
open import Cubical.Data.Empty
open import Cubical.Data.Sigma hiding (_×_)
open import Cubical.HITs.Susp
open import Cubical.HITs.Wedge
open import Cubical.HITs.SetTruncation renaming (rec to sRec ; rec2 to sRec2 ; elim to sElim ; elim2 to sElim2 ; setTruncIsSet to §)
open import Cubical.Data.Int renaming (_+_ to _ℤ+_)
open import Cubical.Data.Nat
open import Cubical.HITs.Truncation renaming (elim to trElim ; map to trMap ; rec to trRec ; elim3 to trElim3)
open import Cubical.Homotopy.Loopspace
open import Cubical.Homotopy.Connected
open import Cubical.Homotopy.Freudenthal
open import Cubical.Algebra.Group
open import Cubical.Algebra.Semigroup
open import Cubical.Algebra.Monoid
open import Cubical.Foundations.Equiv.HalfAdjoint
open import Cubical.Data.NatMinusOne
open import Cubical.HITs.Pushout
open import Cubical.Data.Sum.Base
open import Cubical.Data.HomotopyGroup
open import Cubical.ZCohomology.KcompPrelims
open Iso renaming (inv to inv')
private
variable
ℓ ℓ' : Level
A : Type ℓ
B : Type ℓ'
A' : Pointed ℓ
infixr 34 _+ₖ_
infixr 34 _+ₕ_
is2ConnectedKn : (n : ℕ) → isConnected 2 (coHomK (suc n))
is2ConnectedKn zero = ∣ ∣ base ∣ ∣
, trElim (λ _ → isOfHLevelPath 2 (isOfHLevelTrunc 2) _ _)
(trElim (λ _ → isOfHLevelPath 3 (isOfHLevelSuc 2 (isOfHLevelTrunc 2)) _ _)
(toPropElim (λ _ → isOfHLevelTrunc 2 _ _) refl))
is2ConnectedKn (suc n) = ∣ ∣ north ∣ ∣
, trElim (λ _ → isOfHLevelPath 2 (isOfHLevelTrunc 2) _ _)
(trElim (λ _ → isProp→isOfHLevelSuc (3 + n) (isOfHLevelTrunc 2 _ _))
(suspToPropElim (ptSn (suc n)) (λ _ → isOfHLevelTrunc 2 _ _) refl))
isConnectedKn : (n : ℕ) → isConnected (2 + n) (coHomK (suc n))
isConnectedKn n = isOfHLevelRetractFromIso 0 (invIso (truncOfTruncIso (2 + n) 1)) (sphereConnected (suc n))
-- Induction principles for cohomology groups
-- If we want to show a proposition about some x : Hⁿ(A), it suffices to show it under the
-- assumption that x = ∣f∣₂ and that f is pointed
coHomPointedElim : {A : Type ℓ} (n : ℕ) (a : A) {B : coHom (suc n) A → Type ℓ'}
→ ((x : coHom (suc n) A) → isProp (B x))
→ ((f : A → coHomK (suc n)) → f a ≡ coHom-pt (suc n) → B ∣ f ∣₂)
→ (x : coHom (suc n) A) → B x
coHomPointedElim {ℓ' = ℓ'} {A = A} n a isprop indp =
sElim (λ _ → isOfHLevelSuc 1 (isprop _))
λ f → helper n isprop indp f (f a) refl
where
helper : (n : ℕ) {B : coHom (suc n) A → Type ℓ'}
→ ((x : coHom (suc n) A) → isProp (B x))
→ ((f : A → coHomK (suc n)) → f a ≡ coHom-pt (suc n) → B ∣ f ∣₂)
→ (f : A → coHomK (suc n))
→ (x : coHomK (suc n))
→ f a ≡ x → B ∣ f ∣₂
-- pattern matching a bit extra to avoid isOfHLevelPlus'
helper zero isprop ind f =
trElim (λ _ → isOfHLevelPlus {n = 1} 2 (isPropΠ λ _ → isprop _))
(toPropElim (λ _ → isPropΠ λ _ → isprop _) (ind f))
helper (suc zero) isprop ind f =
trElim (λ _ → isOfHLevelPlus {n = 1} 3 (isPropΠ λ _ → isprop _))
(suspToPropElim base (λ _ → isPropΠ λ _ → isprop _) (ind f))
helper (suc (suc zero)) isprop ind f =
trElim (λ _ → isOfHLevelPlus {n = 1} 4 (isPropΠ λ _ → isprop _))
(suspToPropElim north (λ _ → isPropΠ λ _ → isprop _) (ind f))
helper (suc (suc (suc n))) isprop ind f =
trElim (λ _ → isOfHLevelPlus' {n = 5 + n} 1 (isPropΠ λ _ → isprop _))
(suspToPropElim north (λ _ → isPropΠ λ _ → isprop _) (ind f))
coHomPointedElim2 : {A : Type ℓ} (n : ℕ) (a : A) {B : coHom (suc n) A → coHom (suc n) A → Type ℓ'}
→ ((x y : coHom (suc n) A) → isProp (B x y))
→ ((f g : A → coHomK (suc n)) → f a ≡ coHom-pt (suc n) → g a ≡ coHom-pt (suc n) → B ∣ f ∣₂ ∣ g ∣₂)
→ (x y : coHom (suc n) A) → B x y
coHomPointedElim2 {ℓ' = ℓ'} {A = A} n a isprop indp = sElim2 (λ _ _ → isOfHLevelSuc 1 (isprop _ _))
λ f g → helper n a isprop indp f g (f a) (g a) refl refl
where
helper : (n : ℕ) (a : A) {B : coHom (suc n) A → coHom (suc n) A → Type ℓ'}
→ ((x y : coHom (suc n) A) → isProp (B x y))
→ ((f g : A → coHomK (suc n)) → f a ≡ coHom-pt (suc n) → g a ≡ coHom-pt (suc n) → B ∣ f ∣₂ ∣ g ∣₂)
→ (f g : A → coHomK (suc n))
→ (x y : coHomK (suc n))
→ f a ≡ x → g a ≡ y
→ B ∣ f ∣₂ ∣ g ∣₂
helper zero a isprop indp f g =
elim2 (λ _ _ → isOfHLevelPlus {n = 1} 2 (isPropΠ2 λ _ _ → isprop _ _))
(toPropElim2 (λ _ _ → isPropΠ2 λ _ _ → isprop _ _) (indp f g))
helper (suc zero) a isprop indp f g =
elim2 (λ _ _ → isOfHLevelPlus {n = 1} 3 (isPropΠ2 λ _ _ → isprop _ _))
(suspToPropElim2 base (λ _ _ → isPropΠ2 λ _ _ → isprop _ _) (indp f g))
helper (suc (suc zero)) a isprop indp f g =
elim2 (λ _ _ → isOfHLevelPlus {n = 1} 4 (isPropΠ2 λ _ _ → isprop _ _))
(suspToPropElim2 north (λ _ _ → isPropΠ2 λ _ _ → isprop _ _) (indp f g))
helper (suc (suc (suc n))) a isprop indp f g =
elim2 (λ _ _ → isOfHLevelPlus' {n = 5 + n} 1 (isPropΠ2 λ _ _ → isprop _ _))
(suspToPropElim2 north (λ _ _ → isPropΠ2 λ _ _ → isprop _ _) (indp f g))
{- Equivalence between cohomology of A and reduced cohomology of (A + 1) -}
coHomRed+1Equiv : (n : ℕ) →
(A : Type ℓ) →
(coHom n A) ≡ (coHomRed n ((A ⊎ Unit , inr (tt))))
coHomRed+1Equiv zero A i = ∥ helpLemma {C = (Int , pos 0)} i ∥₂
module coHomRed+1 where
helpLemma : {C : Pointed ℓ} → ( (A → (typ C)) ≡ ((((A ⊎ Unit) , inr (tt)) →∙ C)))
helpLemma {C = C} = isoToPath (iso map1
map2
(λ b → linvPf b)
(λ _ → refl))
where
map1 : (A → typ C) → ((((A ⊎ Unit) , inr (tt)) →∙ C))
map1 f = map1' , refl
module helpmap where
map1' : A ⊎ Unit → fst C
map1' (inl x) = f x
map1' (inr x) = pt C
map2 : ((((A ⊎ Unit) , inr (tt)) →∙ C)) → (A → typ C)
map2 (g , pf) x = g (inl x)
linvPf : (b :((((A ⊎ Unit) , inr (tt)) →∙ C))) → map1 (map2 b) ≡ b
linvPf (f , snd) i = (λ x → helper x i) , λ j → snd ((~ i) ∨ j)
where
helper : (x : A ⊎ Unit) → ((helpmap.map1') (map2 (f , snd)) x) ≡ f x
helper (inl x) = refl
helper (inr tt) = sym snd
coHomRed+1Equiv (suc zero) A i = ∥ coHomRed+1.helpLemma A i {C = (coHomK 1 , ∣ base ∣)} i ∥₂
coHomRed+1Equiv (suc (suc n)) A i = ∥ coHomRed+1.helpLemma A i {C = (coHomK (2 + n) , ∣ north ∣)} i ∥₂
-----------
Kn→ΩKn+1 : (n : ℕ) → coHomK n → typ (Ω (coHomK-ptd (suc n)))
Kn→ΩKn+1 n = Iso.fun (Iso-Kn-ΩKn+1 n)
ΩKn+1→Kn : (n : ℕ) → typ (Ω (coHomK-ptd (suc n))) → coHomK n
ΩKn+1→Kn n = Iso.inv (Iso-Kn-ΩKn+1 n)
Kn≃ΩKn+1 : {n : ℕ} → coHomK n ≃ typ (Ω (coHomK-ptd (suc n)))
Kn≃ΩKn+1 {n = n} = isoToEquiv (Iso-Kn-ΩKn+1 n)
---------- Algebra/Group stuff --------
0ₖ : (n : ℕ) → coHomK n
0ₖ = coHom-pt
_+ₖ_ : {n : ℕ} → coHomK n → coHomK n → coHomK n
_+ₖ_ {n = n} x y = ΩKn+1→Kn n (Kn→ΩKn+1 n x ∙ Kn→ΩKn+1 n y)
-ₖ_ : {n : ℕ} → coHomK n → coHomK n
-ₖ_ {n = n} x = ΩKn+1→Kn n (sym (Kn→ΩKn+1 n x))
-- subtraction as a binary operator
_-ₖ_ : {n : ℕ} → coHomK n → coHomK n → coHomK n
_-ₖ_ {n = n} x y = ΩKn+1→Kn n (Kn→ΩKn+1 n x ∙ sym (Kn→ΩKn+1 n y))
+ₖ-syntax : (n : ℕ) → coHomK n → coHomK n → coHomK n
+ₖ-syntax n = _+ₖ_ {n = n}
-ₖ-syntax : (n : ℕ) → coHomK n → coHomK n
-ₖ-syntax n = -ₖ_ {n = n}
-'ₖ-syntax : (n : ℕ) → coHomK n → coHomK n → coHomK n
-'ₖ-syntax n = _-ₖ_ {n = n}
syntax +ₖ-syntax n x y = x +[ n ]ₖ y
syntax -ₖ-syntax n x = -[ n ]ₖ x
syntax -'ₖ-syntax n x y = x -[ n ]ₖ y
Kn→ΩKn+10ₖ : (n : ℕ) → Kn→ΩKn+1 n (0ₖ n) ≡ refl
Kn→ΩKn+10ₖ zero = sym (rUnit refl)
Kn→ΩKn+10ₖ (suc zero) i j = ∣ (rCancel (merid base) i j) ∣
Kn→ΩKn+10ₖ (suc (suc n)) i j = ∣ (rCancel (merid north) i j) ∣
ΩKn+1→Kn-refl : (n : ℕ) → ΩKn+1→Kn n refl ≡ 0ₖ n
ΩKn+1→Kn-refl zero = refl
ΩKn+1→Kn-refl (suc zero) = refl
ΩKn+1→Kn-refl (suc (suc zero)) = refl
ΩKn+1→Kn-refl (suc (suc (suc zero))) = refl
ΩKn+1→Kn-refl (suc (suc (suc (suc zero)))) = refl
ΩKn+1→Kn-refl (suc (suc (suc (suc (suc n))))) = refl
-0ₖ : {n : ℕ} → -[ n ]ₖ (0ₖ n) ≡ (0ₖ n)
-0ₖ {n = n} = (λ i → ΩKn+1→Kn n (sym (Kn→ΩKn+10ₖ n i)))
∙∙ (λ i → ΩKn+1→Kn n (Kn→ΩKn+10ₖ n (~ i)))
∙∙ Iso.leftInv (Iso-Kn-ΩKn+1 n) (0ₖ n)
+ₖ→∙ : (n : ℕ) (a b : coHomK n) → Kn→ΩKn+1 n (a +[ n ]ₖ b) ≡ Kn→ΩKn+1 n a ∙ Kn→ΩKn+1 n b
+ₖ→∙ n a b = Iso.rightInv (Iso-Kn-ΩKn+1 n) (Kn→ΩKn+1 n a ∙ Kn→ΩKn+1 n b)
lUnitₖ : (n : ℕ) (x : coHomK n) → (0ₖ n) +[ n ]ₖ x ≡ x
lUnitₖ 0 x = Iso.leftInv (Iso-Kn-ΩKn+1 zero) x
lUnitₖ (suc zero) = trElim (λ _ → isOfHLevelPath 3 (isOfHLevelTrunc 3) _ _) λ x → Iso.leftInv (Iso-Kn-ΩKn+1 1) ∣ x ∣
lUnitₖ (suc (suc n)) x =
(λ i → ΩKn+1→Kn (2 + n) (Kn→ΩKn+10ₖ (2 + n) i ∙ Kn→ΩKn+1 (2 + n) x)) ∙∙
(cong (ΩKn+1→Kn (2 + n)) (sym (lUnit (Kn→ΩKn+1 (2 + n) x)))) ∙∙
Iso.leftInv (Iso-Kn-ΩKn+1 (2 + n)) x
rUnitₖ : (n : ℕ) (x : coHomK n) → x +[ n ]ₖ (0ₖ n) ≡ x
rUnitₖ 0 x = Iso.leftInv (Iso-Kn-ΩKn+1 zero) x
rUnitₖ (suc zero) = trElim (λ _ → isOfHLevelPath 3 (isOfHLevelTrunc 3) _ _) λ x → Iso.leftInv (Iso-Kn-ΩKn+1 1) ∣ x ∣
rUnitₖ (suc (suc n)) x =
(λ i → ΩKn+1→Kn (2 + n) (Kn→ΩKn+1 (2 + n) x ∙ Kn→ΩKn+10ₖ (2 + n) i))
∙∙ (cong (ΩKn+1→Kn (2 + n)) (sym (rUnit (Kn→ΩKn+1 (2 + n) x))))
∙∙ Iso.leftInv (Iso-Kn-ΩKn+1 (2 + n)) x
rCancelₖ : (n : ℕ) (x : coHomK n) → x +[ n ]ₖ (-[ n ]ₖ x) ≡ (0ₖ n)
rCancelₖ zero x = (λ i → ΩKn+1→Kn 0 (Kn→ΩKn+1 zero x ∙ Iso.rightInv (Iso-Kn-ΩKn+1 zero) (sym (Kn→ΩKn+1 zero x)) i)) ∙
cong (ΩKn+1→Kn 0) (rCancel (Kn→ΩKn+1 zero x))
rCancelₖ (suc n) x = (λ i → ΩKn+1→Kn (suc n) (Kn→ΩKn+1 (1 + n) x ∙ Iso.rightInv (Iso-Kn-ΩKn+1 (1 + n)) (sym (Kn→ΩKn+1 (1 + n) x)) i)) ∙
cong (ΩKn+1→Kn (suc n)) (rCancel (Kn→ΩKn+1 (1 + n) x)) ∙
(λ i → ΩKn+1→Kn (suc n) (Kn→ΩKn+10ₖ (suc n) (~ i))) ∙
Iso.leftInv (Iso-Kn-ΩKn+1 (suc n)) (0ₖ (suc n))
lCancelₖ : (n : ℕ) (x : coHomK n) → (-[ n ]ₖ x) +[ n ]ₖ x ≡ (0ₖ n)
lCancelₖ 0 x = (λ i → ΩKn+1→Kn 0 (Iso.rightInv (Iso-Kn-ΩKn+1 zero) (sym (Kn→ΩKn+1 zero x)) i ∙ Kn→ΩKn+1 zero x)) ∙
cong (ΩKn+1→Kn 0) (lCancel (Kn→ΩKn+1 zero x))
lCancelₖ (suc n) x = (λ i → ΩKn+1→Kn (suc n) (Iso.rightInv (Iso-Kn-ΩKn+1 (1 + n)) (sym (Kn→ΩKn+1 (1 + n) x)) i ∙ Kn→ΩKn+1 (1 + n) x)) ∙
cong (ΩKn+1→Kn (suc n)) (lCancel (Kn→ΩKn+1 (1 + n) x)) ∙
(λ i → (ΩKn+1→Kn (suc n)) (Kn→ΩKn+10ₖ (suc n) (~ i))) ∙
Iso.leftInv (Iso-Kn-ΩKn+1 (suc n)) (0ₖ (suc n))
assocₖ : (n : ℕ) (x y z : coHomK n) → ((x +[ n ]ₖ y) +[ n ]ₖ z) ≡ (x +[ n ]ₖ (y +[ n ]ₖ z))
assocₖ n x y z = ((λ i → ΩKn+1→Kn n (Kn→ΩKn+1 n (ΩKn+1→Kn n (Kn→ΩKn+1 n x ∙ Kn→ΩKn+1 n y)) ∙ Kn→ΩKn+1 n z)) ∙∙
(λ i → ΩKn+1→Kn n (Iso.rightInv (Iso-Kn-ΩKn+1 n) (Kn→ΩKn+1 n x ∙ Kn→ΩKn+1 n y) i ∙ Kn→ΩKn+1 n z)) ∙∙
(λ i → ΩKn+1→Kn n (assoc (Kn→ΩKn+1 n x) (Kn→ΩKn+1 n y) (Kn→ΩKn+1 n z) (~ i)))) ∙
(λ i → ΩKn+1→Kn n ((Kn→ΩKn+1 n x) ∙ Iso.rightInv (Iso-Kn-ΩKn+1 n) ((Kn→ΩKn+1 n y ∙ Kn→ΩKn+1 n z)) (~ i)))
cancelₖ : (n : ℕ) (x : coHomK n) → x -[ n ]ₖ x ≡ (0ₖ n)
cancelₖ zero x = cong (ΩKn+1→Kn 0) (rCancel (Kn→ΩKn+1 zero x))
cancelₖ (suc zero) x = cong (ΩKn+1→Kn 1) (rCancel (Kn→ΩKn+1 1 x))
cancelₖ (suc (suc zero)) x = cong (ΩKn+1→Kn 2) (rCancel (Kn→ΩKn+1 2 x))
cancelₖ (suc (suc (suc zero))) x = cong (ΩKn+1→Kn 3) (rCancel (Kn→ΩKn+1 3 x))
cancelₖ (suc (suc (suc (suc zero)))) x = cong (ΩKn+1→Kn 4) (rCancel (Kn→ΩKn+1 4 x))
cancelₖ (suc (suc (suc (suc (suc n))))) x = cong (ΩKn+1→Kn (5 + n)) (rCancel (Kn→ΩKn+1 (5 + n) x))
-rUnitₖ : (n : ℕ) (x : coHomK n) → x -[ n ]ₖ 0ₖ n ≡ x
-rUnitₖ zero x = rUnitₖ zero x
-rUnitₖ (suc n) x = cong (λ y → ΩKn+1→Kn (suc n) (Kn→ΩKn+1 (suc n) x ∙ sym y)) (Kn→ΩKn+10ₖ (suc n))
∙∙ cong (ΩKn+1→Kn (suc n)) (sym (rUnit (Kn→ΩKn+1 (suc n) x)))
∙∙ Iso.leftInv (Iso-Kn-ΩKn+1 (suc n)) x
isComm∙ : ∀ {ℓ} (A : Pointed ℓ) → Type ℓ
isComm∙ A = (p q : typ (Ω A)) → p ∙ q ≡ q ∙ p
abstract
isCommA→isCommTrunc : ∀ {ℓ} {A : Pointed ℓ} (n : ℕ) → isComm∙ A → isOfHLevel (suc n) (typ A) → isComm∙ (∥ typ A ∥ (suc n) , ∣ pt A ∣)
isCommA→isCommTrunc {A = (A , a)} n comm hlev p q =
((λ i j → (Iso.leftInv (truncIdempotentIso (suc n) hlev) ((p ∙ q) j) (~ i)))
∙∙ (λ i → cong {B = λ _ → ∥ A ∥ (suc n) } (λ x → ∣ x ∣) (cong (trRec hlev (λ x → x)) (p ∙ q)))
∙∙ (λ i → cong {B = λ _ → ∥ A ∥ (suc n) } (λ x → ∣ x ∣) (congFunct {A = ∥ A ∥ (suc n)} {B = A} (trRec hlev (λ x → x)) p q i)))
∙ ((λ i → cong {B = λ _ → ∥ A ∥ (suc n) } (λ x → ∣ x ∣) (comm (cong (trRec hlev (λ x → x)) p) (cong (trRec hlev (λ x → x)) q) i))
∙∙ (λ i → cong {B = λ _ → ∥ A ∥ (suc n) } (λ x → ∣ x ∣) (congFunct {A = ∥ A ∥ (suc n)} {B = A} (trRec hlev (λ x → x)) q p (~ i)))
∙∙ (λ i j → (Iso.leftInv (truncIdempotentIso (suc n) hlev) ((q ∙ p) j) i)))
isCommΩK1 : (n : ℕ) → isComm∙ ((Ω^ n) (coHomK-ptd 1))
isCommΩK1 zero = isCommA→isCommTrunc 2 comm-ΩS¹ isGroupoidS¹
isCommΩK1 (suc n) = Eckmann-Hilton n
open Iso renaming (inv to inv')
ptdIso→comm : ∀ {ℓ ℓ'} {A : Pointed ℓ} {B : Type ℓ'} (e : Iso (typ A) B) → isComm∙ A → isComm∙ (B , Iso.fun e (pt A))
ptdIso→comm {A = (A , a)} {B = B} e comm p q =
sym (rightInv (congIso e) (p ∙ q))
∙∙ (cong (fun (congIso e)) ((invCongFunct e p q)
∙∙ (comm (inv' (congIso e) p) (inv' (congIso e) q))
∙∙ (sym (invCongFunct e q p))))
∙∙ rightInv (congIso e) (q ∙ p)
isCommΩK : (n : ℕ) → isComm∙ (coHomK-ptd n)
isCommΩK zero p q = isSetInt _ _ (p ∙ q) (q ∙ p)
isCommΩK (suc zero) = isCommA→isCommTrunc 2 comm-ΩS¹ isGroupoidS¹
isCommΩK (suc (suc n)) = subst isComm∙ (λ i → coHomK (2 + n) , ΩKn+1→Kn-refl (2 + n) i) (ptdIso→comm {A = (_ , _)} (invIso (Iso-Kn-ΩKn+1 (2 + n))) (Eckmann-Hilton 0))
commₖ : (n : ℕ) (x y : coHomK n) → (x +[ n ]ₖ y) ≡ (y +[ n ]ₖ x)
commₖ 0 x y i = ΩKn+1→Kn 0 (isCommΩK1 0 (Kn→ΩKn+1 0 x) (Kn→ΩKn+1 0 y) i)
commₖ 1 x y i = ΩKn+1→Kn 1 (ptdIso→comm {A = ((∣ north ∣ ≡ ∣ north ∣) , snd ((Ω^ 1) (coHomK 3 , ∣ north ∣)))}
{B = coHomK 2}
(invIso (Iso-Kn-ΩKn+1 2)) (Eckmann-Hilton 0) (Kn→ΩKn+1 1 x) (Kn→ΩKn+1 1 y) i)
commₖ 2 x y i = ΩKn+1→Kn 2 (ptdIso→comm {A = (∣ north ∣ ≡ ∣ north ∣) , snd ((Ω^ 1) (coHomK 4 , ∣ north ∣))}
{B = coHomK 3}
(invIso (Iso-Kn-ΩKn+1 3)) (Eckmann-Hilton 0) (Kn→ΩKn+1 2 x) (Kn→ΩKn+1 2 y) i)
commₖ 3 x y i = ΩKn+1→Kn 3 (ptdIso→comm {A = (∣ north ∣ ≡ ∣ north ∣) , snd ((Ω^ 1) (coHomK 5 , ∣ north ∣))}
{B = coHomK 4}
(invIso (Iso-Kn-ΩKn+1 4)) (Eckmann-Hilton 0) (Kn→ΩKn+1 3 x) (Kn→ΩKn+1 3 y) i)
commₖ (suc (suc (suc (suc n)))) x y i =
ΩKn+1→Kn (4 + n) (ptdIso→comm {A = (∣ north ∣ ≡ ∣ north ∣) , snd ((Ω^ 1) (coHomK (6 + n) , ∣ north ∣))}
{B = coHomK (5 + n)}
(invIso (Iso-Kn-ΩKn+1 (5 + n))) (Eckmann-Hilton 0) (Kn→ΩKn+1 (4 + n) x) (Kn→ΩKn+1 (4 + n) y) i)
rUnitₖ' : (n : ℕ) (x : coHomK n) → x +[ n ]ₖ (0ₖ n) ≡ x
rUnitₖ' n x = commₖ n x (0ₖ n) ∙ lUnitₖ n x
-distrₖ : (n : ℕ) (x y : coHomK n) → -[ n ]ₖ (x +[ n ]ₖ y) ≡ (-[ n ]ₖ x) +[ n ]ₖ (-[ n ]ₖ y)
-distrₖ n x y = ((λ i → ΩKn+1→Kn n (sym (Kn→ΩKn+1 n (ΩKn+1→Kn n (Kn→ΩKn+1 n x ∙ Kn→ΩKn+1 n y))))) ∙∙
(λ i → ΩKn+1→Kn n (sym (Iso.rightInv (Iso-Kn-ΩKn+1 n) (Kn→ΩKn+1 n x ∙ Kn→ΩKn+1 n y) i))) ∙∙
(λ i → ΩKn+1→Kn n (symDistr (Kn→ΩKn+1 n x) (Kn→ΩKn+1 n y) i))) ∙∙
(λ i → ΩKn+1→Kn n (Iso.rightInv (Iso-Kn-ΩKn+1 n) (sym (Kn→ΩKn+1 n y)) (~ i) ∙ (Iso.rightInv (Iso-Kn-ΩKn+1 n) (sym (Kn→ΩKn+1 n x)) (~ i)))) ∙∙
commₖ n (-[ n ]ₖ y) (-[ n ]ₖ x)
private
rCancelLem : (n : ℕ) (x : coHomK n) → ΩKn+1→Kn n ((Kn→ΩKn+1 n x) ∙ refl) ≡ ΩKn+1→Kn n (Kn→ΩKn+1 n x)
rCancelLem zero x = refl
rCancelLem (suc n) x = cong (ΩKn+1→Kn (suc n)) (sym (rUnit (Kn→ΩKn+1 (suc n) x)))
lCancelLem : (n : ℕ) (x : coHomK n) → ΩKn+1→Kn n (refl ∙ (Kn→ΩKn+1 n x)) ≡ ΩKn+1→Kn n (Kn→ΩKn+1 n x)
lCancelLem zero x = refl
lCancelLem (suc n) x = cong (ΩKn+1→Kn (suc n)) (sym (lUnit (Kn→ΩKn+1 (suc n) x)))
-cancelRₖ : (n : ℕ) (x y : coHomK n) → (y +[ n ]ₖ x) -[ n ]ₖ x ≡ y
-cancelRₖ n x y = (cong (ΩKn+1→Kn n) ((cong (_∙ sym (Kn→ΩKn+1 n x)) (+ₖ→∙ n y x))
∙∙ sym (assoc _ _ _)
∙∙ cong (Kn→ΩKn+1 n y ∙_) (rCancel _)))
∙∙ rCancelLem n y
∙∙ Iso.leftInv (Iso-Kn-ΩKn+1 n) y
-cancelLₖ : (n : ℕ) (x y : coHomK n) → (x +[ n ]ₖ y) -[ n ]ₖ x ≡ y
-cancelLₖ n x y = cong (λ z → z -[ n ]ₖ x) (commₖ n x y) ∙ -cancelRₖ n x y
-+cancelₖ : (n : ℕ) (x y : coHomK n) → (x -[ n ]ₖ y) +[ n ]ₖ y ≡ x
-+cancelₖ n x y = (cong (ΩKn+1→Kn n) ((cong (_∙ (Kn→ΩKn+1 n y)) (Iso.rightInv (Iso-Kn-ΩKn+1 n) (Kn→ΩKn+1 n x ∙ sym (Kn→ΩKn+1 n y))))
∙∙ sym (assoc _ _ _)
∙∙ cong (Kn→ΩKn+1 n x ∙_) (lCancel _)))
∙∙ rCancelLem n x
∙∙ Iso.leftInv (Iso-Kn-ΩKn+1 n) x
---- Group structure of cohomology groups ---
_+ₕ_ : {n : ℕ} → coHom n A → coHom n A → coHom n A
_+ₕ_ {n = n} = sRec2 § λ a b → ∣ (λ x → a x +[ n ]ₖ b x) ∣₂
-ₕ_ : {n : ℕ} → coHom n A → coHom n A
-ₕ_ {n = n} = sRec § λ a → ∣ (λ x → -[ n ]ₖ a x) ∣₂
_-ₕ_ : {n : ℕ} → coHom n A → coHom n A → coHom n A
_-ₕ_ {n = n} = sRec2 § λ a b → ∣ (λ x → a x -[ n ]ₖ b x) ∣₂
+ₕ-syntax : (n : ℕ) → coHom n A → coHom n A → coHom n A
+ₕ-syntax n = _+ₕ_ {n = n}
-ₕ-syntax : (n : ℕ) → coHom n A → coHom n A
-ₕ-syntax n = -ₕ_ {n = n}
-ₕ'-syntax : (n : ℕ) → coHom n A → coHom n A → coHom n A
-ₕ'-syntax n = _-ₕ_ {n = n}
syntax +ₕ-syntax n x y = x +[ n ]ₕ y
syntax -ₕ-syntax n x = -[ n ]ₕ x
syntax -ₕ'-syntax n x y = x -[ n ]ₕ y
0ₕ : (n : ℕ) → coHom n A
0ₕ n = ∣ (λ _ → (0ₖ n)) ∣₂
rUnitₕ : (n : ℕ) (x : coHom n A) → x +[ n ]ₕ (0ₕ n) ≡ x
rUnitₕ n = sElim (λ _ → isOfHLevelPath 1 (§ _ _))
λ a i → ∣ funExt (λ x → rUnitₖ n (a x)) i ∣₂
lUnitₕ : (n : ℕ) (x : coHom n A) → (0ₕ n) +[ n ]ₕ x ≡ x
lUnitₕ n = sElim (λ _ → isOfHLevelPath 1 (§ _ _))
λ a i → ∣ funExt (λ x → lUnitₖ n (a x)) i ∣₂
rCancelₕ : (n : ℕ) (x : coHom n A) → x +[ n ]ₕ (-[ n ]ₕ x) ≡ 0ₕ n
rCancelₕ n = sElim (λ _ → isOfHLevelPath 1 (§ _ _))
λ a i → ∣ funExt (λ x → rCancelₖ n (a x)) i ∣₂
lCancelₕ : (n : ℕ) (x : coHom n A) → (-[ n ]ₕ x) +[ n ]ₕ x ≡ 0ₕ n
lCancelₕ n = sElim (λ _ → isOfHLevelPath 1 (§ _ _))
λ a i → ∣ funExt (λ x → lCancelₖ n (a x)) i ∣₂
assocₕ : (n : ℕ) (x y z : coHom n A) → ((x +[ n ]ₕ y) +[ n ]ₕ z) ≡ (x +[ n ]ₕ (y +[ n ]ₕ z))
assocₕ n = elim3 (λ _ _ _ → isOfHLevelPath 1 (§ _ _))
λ a b c i → ∣ funExt (λ x → assocₖ n (a x) (b x) (c x)) i ∣₂
commₕ : (n : ℕ) (x y : coHom n A) → (x +[ n ]ₕ y) ≡ (y +[ n ]ₕ x)
commₕ n = sElim2 (λ _ _ → isOfHLevelPath 1 (§ _ _))
λ a b i → ∣ funExt (λ x → commₖ n (a x) (b x)) i ∣₂
cancelₕ : (n : ℕ) (x : coHom n A) → x -[ n ]ₕ x ≡ 0ₕ n
cancelₕ n = sElim (λ _ → isOfHLevelPath 1 (§ _ _))
λ a i → ∣ funExt (λ x → cancelₖ n (a x)) i ∣₂
-ₖ-ₖ : (n : ℕ) (x : coHomK n) → (-[ n ]ₖ (-[ n ]ₖ x)) ≡ x
-ₖ-ₖ n x = cong ((ΩKn+1→Kn n) ∘ sym) (Iso.rightInv (Iso-Kn-ΩKn+1 n) (sym (Kn→ΩKn+1 n x))) ∙ Iso.leftInv (Iso-Kn-ΩKn+1 n) x
-- Proof that rUnitₖ and lUnitₖ agree on 0ₖ. Needed for Mayer-Vietoris.
private
rUnitlUnitGen : ∀ {ℓ ℓ'} {A : Type ℓ} {B : Type ℓ'} {b : B} (e : Iso A (b ≡ b))
(0A : A)
(0fun : fun e 0A ≡ refl)
→ Path (inv' e (fun e 0A ∙ fun e 0A) ≡ 0A)
(cong (inv' e) (cong (_∙ fun e 0A) 0fun) ∙∙ cong (inv' e) (sym (lUnit (fun e 0A))) ∙∙ Iso.leftInv e 0A)
(cong (inv' e) (cong (fun e 0A ∙_) 0fun) ∙∙ cong (inv' e) (sym (rUnit (fun e 0A))) ∙∙ Iso.leftInv e 0A)
rUnitlUnitGen e 0A 0fun =
(λ i → cong (inv' e) (cong (_∙ fun e 0A) 0fun) ∙∙ rUnit (cong (inv' e) (sym (lUnit (fun e 0A)))) i ∙∙ Iso.leftInv e 0A)
∙ ((λ i → (λ j → inv' e (0fun (~ i ∧ j) ∙ 0fun (j ∧ i)))
∙∙ ((λ j → inv' e (0fun (~ i ∨ j) ∙ 0fun i))
∙∙ cong (inv' e) (sym (lUnit (0fun i)))
∙∙ λ j → inv' e (0fun (i ∧ (~ j))))
∙∙ Iso.leftInv e 0A)
∙∙ (λ i → (λ j → inv' e (fun e 0A ∙ 0fun j))
∙∙ (λ j → inv' e (0fun (j ∧ ~ i) ∙ refl))
∙∙ cong (inv' e) (sym (rUnit (0fun (~ i))))
∙∙ (λ j → inv' e (0fun (~ i ∧ ~ j)))
∙∙ Iso.leftInv e 0A)
∙∙ λ i → cong (inv' e) (cong (fun e 0A ∙_) 0fun)
∙∙ rUnit (cong (inv' e) (sym (rUnit (fun e 0A)))) (~ i)
∙∙ Iso.leftInv e 0A)
rUnitlUnit0 : (n : ℕ) → rUnitₖ n (0ₖ n) ≡ lUnitₖ n (0ₖ n)
rUnitlUnit0 0 = refl
rUnitlUnit0 (suc zero) = refl
rUnitlUnit0 (suc (suc n)) = sym (rUnitlUnitGen (Iso-Kn-ΩKn+1 (2 + n)) (0ₖ (2 + n)) (Kn→ΩKn+10ₖ (2 + n)))
-cancelLₕ : (n : ℕ) (x y : coHom n A) → (x +[ n ]ₕ y) -[ n ]ₕ x ≡ y
-cancelLₕ n = sElim2 (λ _ _ → isOfHLevelPath 1 (§ _ _))
λ a b i → ∣ (λ x → -cancelLₖ n (a x) (b x) i) ∣₂
-cancelRₕ : (n : ℕ) (x y : coHom n A) → (y +[ n ]ₕ x) -[ n ]ₕ x ≡ y
-cancelRₕ n = sElim2 (λ _ _ → isOfHLevelPath 1 (§ _ _))
λ a b i → ∣ (λ x → -cancelRₖ n (a x) (b x) i) ∣₂
-+cancelₕ : (n : ℕ) (x y : coHom n A) → (x -[ n ]ₕ y) +[ n ]ₕ y ≡ x
-+cancelₕ n = sElim2 (λ _ _ → isOfHLevelPath 1 (§ _ _))
λ a b i → ∣ (λ x → -+cancelₖ n (a x) (b x) i) ∣₂
-- Group structure of reduced cohomology groups (in progress - might need K to compute properly first) ---
+ₕ∙ : {A : Pointed ℓ} (n : ℕ) → coHomRed n A → coHomRed n A → coHomRed n A
+ₕ∙ zero = sRec2 § λ { (a , pa) (b , pb) → ∣ (λ x → a x +[ zero ]ₖ b x) , (λ i → (pa i +[ zero ]ₖ pb i)) ∣₂ }
+ₕ∙ (suc zero) = sRec2 § λ { (a , pa) (b , pb) → ∣ (λ x → a x +[ 1 ]ₖ b x) , (λ i → pa i +[ 1 ]ₖ pb i) ∙ lUnitₖ 1 (0ₖ 1) ∣₂ }
+ₕ∙ (suc (suc n)) = sRec2 § λ { (a , pa) (b , pb) → ∣ (λ x → a x +[ (2 + n) ]ₖ b x) , (λ i → pa i +[ (2 + n) ]ₖ pb i) ∙ lUnitₖ (2 + n) (0ₖ (2 + n)) ∣₂ }
open IsSemigroup
open IsMonoid
open GroupStr
open GroupHom
coHomGr : ∀ {ℓ} (n : ℕ) (A : Type ℓ) → Group {ℓ}
coHomGr n A = coHom n A , coHomGrnA
where
coHomGrnA : GroupStr (coHom n A)
0g coHomGrnA = 0ₕ n
GroupStr._+_ coHomGrnA = λ x y → x +[ n ]ₕ y
- coHomGrnA = λ x → -[ n ]ₕ x
isGroup coHomGrnA = helper
where
abstract
helper : IsGroup (0ₕ n) (λ x y → x +[ n ]ₕ y) (λ x → -[ n ]ₕ x)
helper = makeIsGroup § (λ x y z → sym (assocₕ n x y z)) (rUnitₕ n) (lUnitₕ n) (rCancelₕ n) (lCancelₕ n)
×coHomGr : (n : ℕ) (A : Type ℓ) (B : Type ℓ') → Group
×coHomGr n A B = dirProd (coHomGr n A) (coHomGr n B)
coHomFun : ∀ {ℓ ℓ'} {A : Type ℓ} {B : Type ℓ'} (n : ℕ) (f : A → B) → coHom n B → coHom n A
coHomFun n f = sRec § λ β → ∣ β ∘ f ∣₂
-distrLemma : ∀ {ℓ ℓ'} {A : Type ℓ} {B : Type ℓ'} (n m : ℕ) (f : GroupHom (coHomGr n A) (coHomGr m B))
(x y : coHom n A)
→ fun f (x -[ n ]ₕ y) ≡ fun f x -[ m ]ₕ fun f y
-distrLemma n m f' x y = sym (-cancelRₕ m (f y) (f (x -[ n ]ₕ y)))
∙∙ cong (λ x → x -[ m ]ₕ f y) (sym (isHom f' (x -[ n ]ₕ y) y))
∙∙ cong (λ x → x -[ m ]ₕ f y) ( cong f (-+cancelₕ n _ _))
where
f = fun f'
--- the loopspace of Kₙ is commutative regardless of base
addIso : (n : ℕ) (x : coHomK n) → Iso (coHomK n) (coHomK n)
fun (addIso n x) y = y +[ n ]ₖ x
inv' (addIso n x) y = y -[ n ]ₖ x
rightInv (addIso n x) y = -+cancelₖ n y x
leftInv (addIso n x) y = -cancelRₖ n x y
isCommΩK-based : (n : ℕ) (x : coHomK n) → isComm∙ (coHomK n , x)
isCommΩK-based zero x p q = isSetInt _ _ (p ∙ q) (q ∙ p)
isCommΩK-based (suc zero) x =
subst isComm∙ (λ i → coHomK 1 , lUnitₖ 1 x i)
(ptdIso→comm {A = (_ , 0ₖ 1)} (addIso 1 x)
(isCommΩK 1))
isCommΩK-based (suc (suc n)) x =
subst isComm∙ (λ i → coHomK (suc (suc n)) , lUnitₖ (suc (suc n)) x i)
(ptdIso→comm {A = (_ , 0ₖ (suc (suc n)))} (addIso (suc (suc n)) x)
(isCommΩK (suc (suc n))))
addLemma : (a b : Int) → a +[ 0 ]ₖ b ≡ (a ℤ+ b)
addLemma a b = (cong (ΩKn+1→Kn 0) (sym (congFunct ∣_∣ (intLoop a) (intLoop b))))
∙∙ (λ i → ΩKn+1→Kn 0 (cong ∣_∣ (intLoop-hom a b i)))
∙∙ Iso.leftInv (Iso-Kn-ΩKn+1 0) (a ℤ+ b)
---
-- hidden versions of cohom stuff using the "lock" hack. The locked versions can be used when proving things.
-- Swapping "key" for "tt*" will then give computing functions.
Unit' : Type₀
Unit' = lockUnit {ℓ-zero}
lock : ∀ {ℓ} {A : Type ℓ} → Unit' → A → A
lock unlock = λ x → x
module lockedCohom (key : Unit') where
+K : (n : ℕ) → coHomK n → coHomK n → coHomK n
+K n = lock key (_+ₖ_ {n = n})
-K : (n : ℕ) → coHomK n → coHomK n
-K n = lock key (-ₖ_ {n = n})
-Kbin : (n : ℕ) → coHomK n → coHomK n → coHomK n
-Kbin n = lock key (_-ₖ_ {n = n})
rUnitK : (n : ℕ) (x : coHomK n) → +K n x (0ₖ n) ≡ x
rUnitK n x = pm key
where
pm : (t : Unit') → lock t (_+ₖ_ {n = n}) x (0ₖ n) ≡ x
pm unlock = rUnitₖ n x
lUnitK : (n : ℕ) (x : coHomK n) → +K n (0ₖ n) x ≡ x
lUnitK n x = pm key
where
pm : (t : Unit') → lock t (_+ₖ_ {n = n}) (0ₖ n) x ≡ x
pm unlock = lUnitₖ n x
rCancelK : (n : ℕ) (x : coHomK n) → +K n x (-K n x) ≡ 0ₖ n
rCancelK n x = pm key
where
pm : (t : Unit') → lock t (_+ₖ_ {n = n}) x (lock t (-ₖ_ {n = n}) x) ≡ 0ₖ n
pm unlock = rCancelₖ n x
lCancelK : (n : ℕ) (x : coHomK n) → +K n (-K n x) x ≡ 0ₖ n
lCancelK n x = pm key
where
pm : (t : Unit') → lock t (_+ₖ_ {n = n}) (lock t (-ₖ_ {n = n}) x) x ≡ 0ₖ n
pm unlock = lCancelₖ n x
-cancelRK : (n : ℕ) (x y : coHomK n) → -Kbin n (+K n y x) x ≡ y
-cancelRK n x y = pm key
where
pm : (t : Unit') → lock t (_-ₖ_ {n = n}) (lock t (_+ₖ_ {n = n}) y x) x ≡ y
pm unlock = -cancelRₖ n x y
-cancelLK : (n : ℕ) (x y : coHomK n) → -Kbin n (+K n x y) x ≡ y
-cancelLK n x y = pm key
where
pm : (t : Unit') → lock t (_-ₖ_ {n = n}) (lock t (_+ₖ_ {n = n}) x y) x ≡ y
pm unlock = -cancelLₖ n x y
-+cancelK : (n : ℕ) (x y : coHomK n) → +K n (-Kbin n x y) y ≡ x
-+cancelK n x y = pm key
where
pm : (t : Unit') → lock t (_+ₖ_ {n = n}) (lock t (_-ₖ_ {n = n}) x y) y ≡ x
pm unlock = -+cancelₖ n x y
cancelK : (n : ℕ) (x : coHomK n) → -Kbin n x x ≡ 0ₖ n
cancelK n x = pm key
where
pm : (t : Unit') → (lock t (_-ₖ_ {n = n}) x x) ≡ 0ₖ n
pm unlock = cancelₖ n x
assocK : (n : ℕ) (x y z : coHomK n) → +K n (+K n x y) z ≡ +K n x (+K n y z)
assocK n x y z = pm key
where
pm : (t : Unit') → lock t (_+ₖ_ {n = n}) (lock t (_+ₖ_ {n = n}) x y) z
≡ lock t (_+ₖ_ {n = n}) x (lock t (_+ₖ_ {n = n}) y z)
pm unlock = assocₖ n x y z
commK : (n : ℕ) (x y : coHomK n) → +K n x y ≡ +K n y x
commK n x y = pm key
where
pm : (t : Unit') → lock t (_+ₖ_ {n = n}) x y ≡ lock t (_+ₖ_ {n = n}) y x
pm unlock = commₖ n x y
-- cohom
+H : (n : ℕ) (x y : coHom n A) → coHom n A
+H n = sRec2 § λ a b → ∣ (λ x → +K n (a x) (b x)) ∣₂
-H : (n : ℕ) (x : coHom n A) → coHom n A
-H n = sRec § λ a → ∣ (λ x → -K n (a x)) ∣₂
-Hbin : (n : ℕ) → coHom n A → coHom n A → coHom n A
-Hbin n = sRec2 § λ a b → ∣ (λ x → -Kbin n (a x) (b x)) ∣₂
rUnitH : (n : ℕ) (x : coHom n A) → +H n x (0ₕ n) ≡ x
rUnitH n = sElim (λ _ → isOfHLevelPath 1 (§ _ _))
λ a i → ∣ funExt (λ x → rUnitK n (a x)) i ∣₂
lUnitH : (n : ℕ) (x : coHom n A) → +H n (0ₕ n) x ≡ x
lUnitH n = sElim (λ _ → isOfHLevelPath 1 (§ _ _))
λ a i → ∣ funExt (λ x → lUnitK n (a x)) i ∣₂
rCancelH : (n : ℕ) (x : coHom n A) → +H n x (-H n x) ≡ 0ₕ n
rCancelH n = sElim (λ _ → isOfHLevelPath 1 (§ _ _))
λ a i → ∣ funExt (λ x → rCancelK n (a x)) i ∣₂
lCancelH : (n : ℕ) (x : coHom n A) → +H n (-H n x) x ≡ 0ₕ n
lCancelH n = sElim (λ _ → isOfHLevelPath 1 (§ _ _))
λ a i → ∣ funExt (λ x → lCancelK n (a x)) i ∣₂
assocH : (n : ℕ) (x y z : coHom n A) → (+H n (+H n x y) z) ≡ (+H n x (+H n y z))
assocH n = elim3 (λ _ _ _ → isOfHLevelPath 1 (§ _ _))
λ a b c i → ∣ funExt (λ x → assocK n (a x) (b x) (c x)) i ∣₂
commH : (n : ℕ) (x y : coHom n A) → (+H n x y) ≡ (+H n y x)
commH n = sElim2 (λ _ _ → isOfHLevelPath 1 (§ _ _))
λ a b i → ∣ funExt (λ x → commK n (a x) (b x)) i ∣₂
-cancelRH : (n : ℕ) (x y : coHom n A) → -Hbin n (+H n y x) x ≡ y
-cancelRH n = sElim2 (λ _ _ → isOfHLevelPath 1 (§ _ _))
λ a b i → ∣ (λ x → -cancelRK n (a x) (b x) i) ∣₂
-cancelLH : (n : ℕ) (x y : coHom n A) → -Hbin n (+H n x y) x ≡ y
-cancelLH n = sElim2 (λ _ _ → isOfHLevelPath 1 (§ _ _))
λ a b i → ∣ (λ x → -cancelLK n (a x) (b x) i) ∣₂
-+cancelH : (n : ℕ) (x y : coHom n A) → +H n (-Hbin n x y) y ≡ x
-+cancelH n = sElim2 (λ _ _ → isOfHLevelPath 1 (§ _ _))
λ a b i → ∣ (λ x → -+cancelK n (a x) (b x) i) ∣₂
+K→∙ : (key : Unit') (n : ℕ) (a b : coHomK n) → Kn→ΩKn+1 n (lockedCohom.+K key n a b) ≡ Kn→ΩKn+1 n a ∙ Kn→ΩKn+1 n b
+K→∙ unlock = +ₖ→∙
+H≡+ₕ : (key : Unit') (n : ℕ) → lockedCohom.+H key {A = A} n ≡ _+ₕ_ {n = n}
+H≡+ₕ unlock _ = refl
rUnitlUnit0K : (key : Unit') (n : ℕ) → lockedCohom.rUnitK key n (0ₖ n) ≡ lockedCohom.lUnitK key n (0ₖ n)
rUnitlUnit0K unlock = rUnitlUnit0
| 46.601227
| 168
| 0.493944
|
8bfe688b2f1b88a948a0eedd401033ec9b43d794
| 900
|
agda
|
Agda
|
Cubical/Data/Nat/Base.agda
|
kiana-S/univalent-foundations
|
8bdb0766260489f9c89a14f4c0f2ad26e5190dec
|
[
"MIT"
] | null | null | null |
Cubical/Data/Nat/Base.agda
|
kiana-S/univalent-foundations
|
8bdb0766260489f9c89a14f4c0f2ad26e5190dec
|
[
"MIT"
] | null | null | null |
Cubical/Data/Nat/Base.agda
|
kiana-S/univalent-foundations
|
8bdb0766260489f9c89a14f4c0f2ad26e5190dec
|
[
"MIT"
] | 1
|
2021-11-22T02:02:01.000Z
|
2021-11-22T02:02:01.000Z
|
{-# OPTIONS --cubical --no-import-sorts --no-exact-split --safe #-}
module Cubical.Data.Nat.Base where
open import Cubical.Core.Primitives
open import Agda.Builtin.Nat public
using (zero; suc; _+_; _*_)
renaming (Nat to ℕ; _-_ to _∸_)
open import Cubical.Data.Nat.Literals public
predℕ : ℕ → ℕ
predℕ zero = zero
predℕ (suc n) = n
caseNat : ∀ {ℓ} → {A : Type ℓ} → (a0 aS : A) → ℕ → A
caseNat a0 aS zero = a0
caseNat a0 aS (suc n) = aS
doubleℕ : ℕ → ℕ
doubleℕ zero = zero
doubleℕ (suc x) = suc (suc (doubleℕ x))
-- doublesℕ n m = 2^n * m
doublesℕ : ℕ → ℕ → ℕ
doublesℕ zero m = m
doublesℕ (suc n) m = doublesℕ n (doubleℕ m)
-- iterate
iter : ∀ {ℓ} {A : Type ℓ} → ℕ → (A → A) → A → A
iter zero f z = z
iter (suc n) f z = f (iter n f z)
elim : ∀ {ℓ} {A : ℕ → Type ℓ}
→ A zero
→ ((n : ℕ) → A n → A (suc n))
→ (n : ℕ) → A n
elim a₀ _ zero = a₀
elim a₀ f (suc n) = f n (elim a₀ f n)
| 22.5
| 67
| 0.583333
|
587ea47c39fee4fb78a316fd62cbbd395932153e
| 522
|
agda
|
Agda
|
test/interaction/Issue59.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
test/interaction/Issue59.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
test/interaction/Issue59.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
-- {-# OPTIONS -v term.with.inline:20 -v term.with.call:30 #-}
data Nat : Set where
zero : Nat
suc : Nat → Nat
_+_ : Nat → Nat → Nat
zero + m = m
suc n + m = suc (n + m)
data [_] : Nat → Set where
⟨_⟩ : ∀ n → [ n ]
f : Nat → Nat
g : Nat → Nat
h : ∀ n → [ f n ]
f zero = zero
f (suc n) with f n
f (suc n) | zero = zero
f (suc n) | suc m = f n + m
-- f's with-function should not get inlined into the clauses of g!
g zero = zero
g (suc n) = _ -- f (suc n) | f n
h zero = ⟨ zero ⟩
h (suc n) = ⟨ g (suc n) ⟩
| 17.4
| 66
| 0.517241
|
9add0152db9a764a56179fadb0488f172c489bc5
| 439
|
agda
|
Agda
|
test/asset/agda-stdlib-1.0/Data/List/Relation/Permutation/Inductive.agda
|
omega12345/agda-mode
|
0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71
|
[
"MIT"
] | null | null | null |
test/asset/agda-stdlib-1.0/Data/List/Relation/Permutation/Inductive.agda
|
omega12345/agda-mode
|
0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71
|
[
"MIT"
] | null | null | null |
test/asset/agda-stdlib-1.0/Data/List/Relation/Permutation/Inductive.agda
|
omega12345/agda-mode
|
0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71
|
[
"MIT"
] | null | null | null |
------------------------------------------------------------------------
-- The Agda standard library
--
-- This module is DEPRECATED. Please use
-- Data.List.Relation.Binary.Permutation.Inductive directly.
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
module Data.List.Relation.Permutation.Inductive where
open import Data.List.Relation.Binary.Permutation.Inductive public
| 33.769231
| 72
| 0.517084
|
228cda68ac8ea3ea21f73a89c364e0af1c5c6075
| 1,019
|
agda
|
Agda
|
test/Succeed/Issue1796.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 3
|
2015-03-28T14:51:03.000Z
|
2015-12-07T20:14:00.000Z
|
test/Succeed/Issue1796.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 3
|
2018-11-14T15:31:44.000Z
|
2019-04-01T19:39:26.000Z
|
test/Succeed/Issue1796.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1
|
2015-09-15T14:36:15.000Z
|
2015-09-15T14:36:15.000Z
|
-- Andreas, 2016-01-23, issue 1796
-- Need to run size constraint solver before with-abstraction
-- {-# OPTIONS -v tc.size:100 -v tc.meta.assign:30 #-}
open import Common.Size
postulate
anything : ∀{A : Set} → A
mutual
record IO i : Set where
coinductive
field force : ∀{j : Size< i} → IO' j
data IO' i : Set where
cons : IO i → IO' i
mutual
record All i (s : IO ∞) : Set where
field force : ∀{j : Size< i} → All' j (IO.force s)
data All' i : (s : IO' ∞) → Set where
always : ∀ e → All' i (cons e)
runIO : ∀{i} (s : IO ∞) → IO i
IO.force (runIO s) with IO.force s
... | cons e = cons e
-- With abstraction fails when _ in IO.force s {_}
-- has not been solved to ∞.
test : ∀ i s → All i (runIO s)
All.force (test i s) with IO.force s -- works with {∞} added
All.force (test i s) | cons e = always e
-- cons e != IO.force (runIO {∞} s) {∞} | IO.force s of type IO' ∞
-- when checking that the expression always e has type
-- All' .j (IO.force (runIO {∞} s) {∞} | IO.force s)
| 24.261905
| 66
| 0.589794
|
cb2c43edbf53a1d31ee371a030fefb8b7d1a5f7e
| 9,403
|
agda
|
Agda
|
Numbers/Rationals/Lemmas.agda
|
Smaug123/agdaproofs
|
0f4230011039092f58f673abcad8fb0652e6b562
|
[
"MIT"
] | 4
|
2019-08-08T12:44:19.000Z
|
2022-01-28T06:04:15.000Z
|
Numbers/Rationals/Lemmas.agda
|
Smaug123/agdaproofs
|
0f4230011039092f58f673abcad8fb0652e6b562
|
[
"MIT"
] | 14
|
2019-01-06T21:11:59.000Z
|
2020-04-11T11:03:39.000Z
|
Numbers/Rationals/Lemmas.agda
|
Smaug123/agdaproofs
|
0f4230011039092f58f673abcad8fb0652e6b562
|
[
"MIT"
] | 1
|
2021-11-29T13:23:07.000Z
|
2021-11-29T13:23:07.000Z
|
{-# OPTIONS --safe --warning=error --without-K #-}
open import LogicalFormulae
open import Numbers.Naturals.Semiring
open import Numbers.Naturals.Order
open import Numbers.Naturals.Order.WellFounded
open import Numbers.Naturals.Order.Lemmas
open import Numbers.Integers.Definition
open import Numbers.Integers.Integers
open import Numbers.Integers.Order
open import Groups.Groups
open import Groups.Definition
open import Rings.Definition
open import Rings.Orders.Partial.Definition
open import Rings.Orders.Total.Definition
open import Fields.Fields
open import Numbers.Primes.PrimeNumbers
open import Setoids.Setoids
open import Functions.Definition
open import Sets.EquivalenceRelations
open import Numbers.Rationals.Definition
open import Semirings.Definition
open import Orders.Total.Definition
open import Orders.WellFounded.Induction
open import Setoids.Orders.Total.Definition
module Numbers.Rationals.Lemmas where
open import Semirings.Lemmas ℕSemiring
open PartiallyOrderedRing ℤPOrderedRing
open import Rings.Orders.Total.Lemmas ℤOrderedRing
open import Rings.Orders.Total.AbsoluteValue ℤOrderedRing
open SetoidTotalOrder (totalOrderToSetoidTotalOrder ℤOrder)
evenOrOdd : (a : ℕ) → (Sg ℕ (λ i → i *N 2 ≡ a)) || (Sg ℕ (λ i → succ (i *N 2) ≡ a))
evenOrOdd zero = inl (zero , refl)
evenOrOdd (succ zero) = inr (zero , refl)
evenOrOdd (succ (succ a)) with evenOrOdd a
evenOrOdd (succ (succ a)) | inl (a/2 , even) = inl (succ a/2 , applyEquality (λ i → succ (succ i)) even)
evenOrOdd (succ (succ a)) | inr (a/2-1 , odd) = inr (succ a/2-1 , applyEquality (λ i → succ (succ i)) odd)
parity : (a b : ℕ) → succ (2 *N a) ≡ 2 *N b → False
parity zero (succ b) pr rewrite Semiring.commutative ℕSemiring b (succ (b +N 0)) = bad pr
where
bad : (1 ≡ succ (succ ((b +N 0) +N b))) → False
bad ()
parity (succ a) (succ b) pr rewrite Semiring.commutative ℕSemiring b (succ (b +N 0)) | Semiring.commutative ℕSemiring a (succ (a +N 0)) | Semiring.commutative ℕSemiring (a +N 0) a | Semiring.commutative ℕSemiring (b +N 0) b = parity a b (succInjective (succInjective pr))
sqrt0 : (p : ℕ) → p *N p ≡ 0 → p ≡ 0
sqrt0 zero pr = refl
sqrt0 (succ p) ()
-- So as to give us something easy to induct down, introduce a silly extra variable
evil' : (k : ℕ) → ((a b : ℕ) → (0 <N a) → (pr : k ≡ a +N b) → a *N a ≡ (b *N b) *N 2 → False)
evil' = rec <NWellfounded (λ z → (x x₁ : ℕ) (pr' : 0 <N x) (x₂ : z ≡ x +N x₁) (x₃ : x *N x ≡ (x₁ *N x₁) *N 2) → False) go
where
go : (k : ℕ) (indHyp : (k' : ℕ) (k'<k : k' <N k) (r s : ℕ) (0<r : 0 <N r) (r+s : k' ≡ r +N s) (x₇ : r *N r ≡ (s *N s) *N 2) → False) (a b : ℕ) (0<a : 0 <N a) (a+b : k ≡ a +N b) (pr : a *N a ≡ (b *N b) *N 2) → False
go k indHyp a b 0<a a+b pr = contr
where
open import Semirings.Solver ℕSemiring multiplicationNIsCommutative
aEven : Sg ℕ (λ i → i *N 2 ≡ a)
aEven with evenOrOdd a
aEven | inl x = x
aEven | inr (a/2-1 , odd) rewrite equalityCommutative odd =
-- Derive a pretty mechanical contradiction using the automatic solver.
-- This line looks hellish, but it was almost completely mechanical.
exFalso (parity (a/2-1 +N (a/2-1 *N succ (a/2-1 *N 2))) (b *N b) (transitivity (
-- truly mechanical bit starts here
from (succ (plus (plus (const a/2-1) (times (const a/2-1) (succ (times (const a/2-1) (succ (succ zero)))))) (plus (plus (const a/2-1) (times (const a/2-1) (succ (times (const a/2-1) (succ (succ zero)))))) (times zero (plus (const a/2-1) (times (const a/2-1) (succ (times (const a/2-1) (succ (succ zero))))))))))
to succ (plus (times (const a/2-1) (succ (succ zero))) (times (times (const a/2-1) (succ (succ zero))) (succ (times (const a/2-1) (succ (succ zero))))))
-- truly mechanical bit ends here
by applyEquality (λ i → succ (a/2-1 +N i)) (
-- Grinding out some manipulations
transitivity (equalityCommutative (Semiring.+Associative ℕSemiring a/2-1 _ _)) (applyEquality (a/2-1 +N_) (transitivity (Semiring.commutative ℕSemiring (a/2-1 *N (a/2-1 +N a/2-1)) _) (transitivity (equalityCommutative (Semiring.+Associative ℕSemiring a/2-1 _ _)) (applyEquality (a/2-1 +N_) (transitivity (equalityCommutative (Semiring.+Associative ℕSemiring a/2-1 _ _)) (applyEquality (a/2-1 +N_) (transitivity (equalityCommutative (Semiring.+DistributesOver* ℕSemiring a/2-1 _ _)) (applyEquality (a/2-1 *N_) (equalityCommutative (Semiring.+Associative ℕSemiring a/2-1 _ _))))))))))
)) (transitivity pr (multiplicationNIsCommutative (b *N b) 2))))
next : (underlying aEven *N 2) *N (underlying aEven *N 2) ≡ (b *N b) *N 2
next with aEven
... | a/2 , even rewrite even = pr
next2 : (underlying aEven *N 2) *N underlying aEven ≡ b *N b
next2 = productCancelsRight 2 _ _ (le 1 refl) (transitivity (equalityCommutative (Semiring.*Associative ℕSemiring (underlying aEven *N 2) _ _)) next)
next3 : b *N b ≡ (underlying aEven *N underlying aEven) *N 2
next3 = equalityCommutative (transitivity (transitivity (equalityCommutative (Semiring.*Associative ℕSemiring (underlying aEven) _ _)) (multiplicationNIsCommutative (underlying aEven) _)) next2)
halveDecreased : underlying aEven <N a
halveDecreased with aEven
halveDecreased | zero , even rewrite equalityCommutative even = exFalso (TotalOrder.irreflexive ℕTotalOrder 0<a)
halveDecreased | succ a/2 , even = le a/2 (transitivity (applyEquality succ (transitivity (Semiring.commutative ℕSemiring a/2 _) (applyEquality succ (transitivity (doubleIsAddTwo a/2) (multiplicationNIsCommutative 2 a/2))))) even)
reduced : b +N underlying aEven <N k
reduced with lessRespectsAddition b halveDecreased
... | bl rewrite a+b = identityOfIndiscernablesLeft _<N_ bl (Semiring.commutative ℕSemiring _ b)
0<b : 0 <N b
0<b with TotalOrder.totality ℕTotalOrder 0 b
0<b | inl (inl 0<b) = 0<b
0<b | inl (inr ())
0<b | inr 0=b rewrite equalityCommutative 0=b = exFalso (TotalOrder.irreflexive ℕTotalOrder {0} (identityOfIndiscernablesRight _<N_ 0<a (sqrt0 a pr)))
contr : False
contr = indHyp (b +N underlying aEven) reduced b (underlying aEven) 0<b refl next3
evil : (a b : ℕ) → (0 <N a) → a *N a ≡ (b *N b) *N 2 → False
evil a b 0<a = evil' (a +N b) a b 0<a refl
absNonneg : (x : ℕ) → abs (nonneg x) ≡ nonneg x
absNonneg x with totality (nonneg 0) (nonneg x)
absNonneg x | inl (inl 0<x) = refl
absNonneg x | inr 0=x = refl
absNegsucc : (x : ℕ) → abs (negSucc x) ≡ nonneg (succ x)
absNegsucc x with totality (nonneg 0) (negSucc x)
absNegsucc x | inl (inr _) = refl
toNats : (numerator denominator : ℤ) → .(denominator ≡ nonneg 0 → False) → (abs numerator) *Z (abs numerator) ≡ ((abs denominator) *Z (abs denominator)) *Z nonneg 2 → Sg (ℕ && ℕ) (λ nats → ((_&&_.fst nats *N _&&_.fst nats) ≡ (_&&_.snd nats *N _&&_.snd nats) *N 2) && (_&&_.snd nats ≡ 0 → False))
toNats (nonneg num) (nonneg 0) pr _ = exFalso (pr refl)
toNats (nonneg num) (nonneg (succ denom)) _ pr = (num ,, (succ denom)) , (nonnegInjective (transitivity (transitivity (equalityCommutative (absNonneg (num *N num))) (absRespectsTimes (nonneg num) (nonneg num))) pr) ,, λ ())
toNats (nonneg num) (negSucc denom) _ pr = (num ,, succ denom) , (nonnegInjective (transitivity (transitivity (equalityCommutative (absNonneg (num *N num))) (absRespectsTimes (nonneg num) (nonneg num))) pr) ,, λ ())
toNats (negSucc num) (nonneg (succ denom)) _ pr = (succ num ,, succ denom) , (nonnegInjective pr ,, λ ())
toNats (negSucc num) (negSucc denom) _ pr = (succ num ,, succ denom) , (nonnegInjective pr ,, λ ())
sqrt2Irrational : (a : ℚ) → (a *Q a) =Q (injectionQ (nonneg 2)) → False
sqrt2Irrational (record { num = numerator ; denom = denominator ; denomNonzero = denom!=0 }) pr = bad
where
-- We have in hand `pr`, which is the following (almost by definition):
pr' : (numerator *Z numerator) ≡ (denominator *Z denominator) *Z nonneg 2
pr' = transitivity (equalityCommutative (transitivity (Ring.*Commutative ℤRing) (Ring.identIsIdent ℤRing))) pr
-- Move into the naturals so that we can do nice divisibility things.
lemma1 : abs ((denominator *Z denominator) *Z nonneg 2) ≡ (abs denominator *Z abs denominator) *Z nonneg 2
lemma1 = transitivity (absRespectsTimes (denominator *Z denominator) (nonneg 2)) (applyEquality (_*Z nonneg 2) (absRespectsTimes denominator denominator))
amenableToNaturals : (abs numerator) *Z (abs numerator) ≡ ((abs denominator) *Z (abs denominator)) *Z nonneg 2
amenableToNaturals = transitivity (equalityCommutative (absRespectsTimes numerator numerator)) (transitivity (applyEquality abs pr') lemma1)
naturalsStatement : Sg (ℕ && ℕ) (λ nats → ((_&&_.fst nats *N _&&_.fst nats) ≡ (_&&_.snd nats *N _&&_.snd nats) *N 2) && (_&&_.snd nats ≡ 0 → False))
naturalsStatement = toNats numerator denominator denom!=0 amenableToNaturals
bad : False
bad with naturalsStatement
bad | (num ,, 0) , (pr1 ,, pr2) = exFalso (pr2 refl)
bad | (num ,, succ denom) , (pr1 ,, pr2) = evil num (succ denom) 0<num pr1
where
0<num : 0 <N num
0<num with TotalOrder.totality ℕTotalOrder 0 num
0<num | inl (inl 0<num) = 0<num
0<num | inr 0=num rewrite equalityCommutative 0=num = exFalso (naughtE pr1)
| 62.686667
| 596
| 0.664681
|
1a7a8510aedc9237aa5a4907dcac17c749ab89f8
| 5,627
|
agda
|
Agda
|
nicolai/pseudotruncations/PseudoTruncs.agda
|
nicolaikraus/HoTT-Agda
|
939a2d83e090fcc924f69f7dfa5b65b3b79fe633
|
[
"MIT"
] | 1
|
2021-06-30T00:17:55.000Z
|
2021-06-30T00:17:55.000Z
|
nicolai/pseudotruncations/PseudoTruncs.agda
|
nicolaikraus/HoTT-Agda
|
939a2d83e090fcc924f69f7dfa5b65b3b79fe633
|
[
"MIT"
] | null | null | null |
nicolai/pseudotruncations/PseudoTruncs.agda
|
nicolaikraus/HoTT-Agda
|
939a2d83e090fcc924f69f7dfa5b65b3b79fe633
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --without-K #-}
open import lib.Basics
open import lib.NType2
open import lib.PathFunctor
open import lib.PathGroupoid
open import lib.types.Bool
open import lib.types.IteratedSuspension
open import lib.types.LoopSpace
open import lib.types.Nat
open import lib.types.Paths
open import lib.types.Pi
open import lib.types.Pointed
open import lib.types.Sigma
open import lib.types.Suspension
open import lib.types.TLevel
open import lib.types.Unit
open import nicolai.pseudotruncations.Preliminary-definitions
open import nicolai.pseudotruncations.Liblemmas
open import nicolai.pseudotruncations.SeqColim
open import nicolai.pseudotruncations.wconstSequence
module nicolai.pseudotruncations.PseudoTruncs where
{- Definition of the Pseudo-truncation -}
module _ {i} where
private
data #Pseudotrunc-aux (n : ℕ) (A : Type i) : Type i where
#point : A → #Pseudotrunc-aux n A
#hub : (r : Sphere' n → A) → #Pseudotrunc-aux n A
data #Pseudotrunc (n : ℕ) (A : Type i) : Type i where
#trick-aux : #Pseudotrunc-aux n A → (Unit → Unit) → #Pseudotrunc n A
Pseudo_-1-trunc : (n : ℕ) (A : Type i) → Type i
Pseudo_-1-trunc = #Pseudotrunc
point_-1 : {A : Type i} → (n : ℕ) → A → Pseudo n -1-trunc A
point_-1 {A} n a = #trick-aux (#point a) _
hub_-1 : {A : Type i} (n : ℕ) (r : Sphere' n → A) → Pseudo n -1-trunc A
hub_-1 {A} n r = #trick-aux (#hub r) _
postulate
spoke_-1 : {A : Type i} (n : ℕ) (r : Sphere' n → A) (x : Sphere' n)
→ point n -1 (r x) == hub n -1 r
{- The induction principle -}
module PseudotruncInduction
{A : Type i} (n : ℕ) {j}
{P : Pseudo n -1-trunc A → Type j}
(Point-1 : (a : A) → P (point n -1 a))
(Hub-1 : (r : Sphere' n → A) → P (hub n -1 r))
(Spoke-1 : (r : Sphere' n → A) → (x : Sphere' n)
→ Point-1 (r x) == Hub-1 r [ P ↓ spoke n -1 r x ])
where
f : Π (Pseudo n -1-trunc A) P
f = f-aux phantom where
f-aux : Phantom Spoke-1 → Π (Pseudo n -1-trunc A) P
f-aux phantom (#trick-aux (#point x) _) = Point-1 x
f-aux phantom (#trick-aux (#hub r) _) = Hub-1 r
postulate
pathβ : (r : Sphere' {i} n → A)
→ (x : Sphere' {i} n)
→ apd f (spoke n -1 r x) == Spoke-1 r x
open PseudotruncInduction public renaming
(f to Pseudotrunc-ind ; pathβ to Pseudotrunc-ind-pathβ)
{- We derive the recursion principle from the induction principle -}
module PseudotruncRecursion
{i j} {A : Type i}
{P : Type j} (n : ℕ)
(Point-1 : A → P)
(Hub-1 : (r : Sphere' {i} n → A) → P)
(Spoke-1 : (r : Sphere' n → A) (x : Sphere' n) → Point-1 (r x) == Hub-1 r)
where
rec : Pseudo n -1-trunc A → P
rec = Pseudotrunc-ind n {P = λ _ → P} Point-1 Hub-1
(λ r x → from-transp
(λ _ → P)
(spoke n -1 r x)
((transport (λ _ → P) (spoke n -1 r x) (Point-1 (r x)))
=⟨ transport-const-fam (spoke n -1 r x) (Point-1 (r x)) ⟩
Point-1 (r x)
=⟨ Spoke-1 r x ⟩
Hub-1 r
∎))
open PseudotruncRecursion public renaming (rec to Pseudotrunc-rec)
{- A lemma that will be important later: any map from
the sphere, composed with the points constructor,
is null. -}
open import nicolai.pseudotruncations.pointed-O-Sphere
open import nicolai.pseudotruncations.LoopsAndSpheres
open null
module _ {i} {A : Type i} (n : ℕ) where
from-sphere-null : (g : Sphere' {i} n → A)
→ isNull (point n -1 (g (nor' n))) ((point n -1) ∘ g)
from-sphere-null g x = point n -1 (g x)
=⟨ spoke n -1 g x ⟩
hub n -1 g
=⟨ ! (spoke n -1 g (nor' n)) ⟩
point n -1 (g (nor' n))
∎
module cmp-nll {i} {Â : Ptd i} (n : ℕ) (g : ⊙Sphere' {i} n →̇ Â) where
{- Pointed version of first constructor -}
-- points∙ : Â →̇ (Pseudo n -1-trunc (fst Â) , point n -1 (snd Â))
-- points∙ = point n -1 , idp
from-sphere-null∙ : isNulld ((point n -1 , idp) ⊙∘ g)
from-sphere-null∙ = λ x →
point n -1 ((fst g) x)
=⟨ spoke n -1 (fst g) x ⟩
hub n -1 (fst g)
=⟨ ! (spoke n -1 (fst g) (nor' n)) ⟩
point n -1 ((fst g) (nor' n))
=⟨ ap (point n -1) (snd g) ⟩
point n -1 (snd Â)
∎
{- Unfortunately, we will need this lemma not for maps
g : Sphere' (S n) → A,
but we will need it for maps
g : Susp (Sphere' n) → A,
and Sphere' (S n) is NOT judgmentally equal to Susp (Sphere' n).
We have to give a second proof. -}
module cmp-nll' {i} {Â : Ptd i} (n : ℕ) (g : ⊙Susp (⊙Sphere' {i} n) →̇ Â) where
{- "translate" equivalence -}
tr≃⊙ : ⊙Sphere' {i} (S n) ⊙≃ ⊙Susp (⊙Sphere' {i} n)
tr≃⊙ = coe-equiv∙ (susp'-switch n)
tr≃ : Sphere' {i} (S n) ≃ fst (⊙Susp (⊙Sphere' {i} n))
tr≃ = fst (fst tr≃⊙) , snd tr≃⊙
tr–̇> : (⊙Sphere' {i} (S n)) →̇ ⊙Susp (⊙Sphere' {i} n)
tr–̇> = fst tr≃⊙ -- –> (fst (fst tr-eq) , snd tr-eq) , {!!}
from-sphere-null'∙ : isNulld ((point S n -1 , idp) ⊙∘ g)
from-sphere-null'∙ = λ x →
fst ((point S n -1 , idp) ⊙∘ g) x
=⟨ ap (fst ((point S n -1 , idp) ⊙∘ g)) (! (<–-inv-r tr≃ x)) ⟩
fst ((point S n -1 , idp) ⊙∘ g) (–> tr≃ (<– tr≃ x))
=⟨ cmp-nll.from-sphere-null∙ {i} {Â} (S n) (g ⊙∘ tr–̇>) (<– tr≃ x) ⟩
point S n -1 (snd Â)
∎
| 33.1
| 81
| 0.519815
|
8b9d6a4e3d3d45dc261f82fbd4a52af80aa7a867
| 307
|
agda
|
Agda
|
test/interaction/Issue2609.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
test/interaction/Issue2609.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
test/interaction/Issue2609.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
open import Common.Bool
open import Common.Nat
data cheesy : Bool → Set where
chocolate : cheesy false
cheese : cheesy true
bread : ∀ x → cheesy x
foo : ∀ {x : Bool} → cheesy x → cheesy x → Bool
foo x chocolate = {!!}
foo x cheese = {!!}
foo x (bread false) = {!x!}
foo x (bread true) = {!!}
| 21.928571
| 47
| 0.609121
|
1e46aa46ad9c37c4b4f6d2112404ff1785b3e888
| 4,817
|
agda
|
Agda
|
Base/Change/Sums.agda
|
inc-lc/ilc-agda
|
39bb081c6f192bdb87bd58b4a89291686d2d7d03
|
[
"MIT"
] | 10
|
2015-03-04T06:09:20.000Z
|
2019-07-19T07:06:59.000Z
|
Base/Change/Sums.agda
|
inc-lc/ilc-agda
|
39bb081c6f192bdb87bd58b4a89291686d2d7d03
|
[
"MIT"
] | 6
|
2015-07-01T18:09:31.000Z
|
2017-05-04T13:53:59.000Z
|
Base/Change/Sums.agda
|
inc-lc/ilc-agda
|
39bb081c6f192bdb87bd58b4a89291686d2d7d03
|
[
"MIT"
] | 1
|
2016-02-18T12:26:44.000Z
|
2016-02-18T12:26:44.000Z
|
module Base.Change.Sums where
open import Data.Sum
open import Data.Product
open import Relation.Binary.PropositionalEquality
open import Level
open import Base.Ascription
open import Base.Change.Algebra
open import Base.Change.Equivalence
open import Base.Change.Equivalence.Realizers
open import Postulate.Extensionality
module SumChanges ℓ {X Y : Set ℓ} {{CX : ChangeAlgebra X}} {{CY : ChangeAlgebra Y}} where
open ≡-Reasoning
-- This is an indexed datatype, so it has two constructors per argument. But
-- erasure would probably not be smart enough to notice.
-- Should we rewrite this as two separate datatypes?
data SumChange : X ⊎ Y → Set ℓ where
ch₁ : ∀ {x} → (dx : Δ x) → SumChange (inj₁ x)
rp₁₂ : ∀ {x} → (y : Y) → SumChange (inj₁ x)
ch₂ : ∀ {y} → (dy : Δ y) → SumChange (inj₂ y)
rp₂₁ : ∀ {y} → (x : X) → SumChange (inj₂ y)
_⊕_ : (v : X ⊎ Y) → SumChange v → X ⊎ Y
inj₁ x ⊕ ch₁ dx = inj₁ (x ⊞ dx)
inj₂ y ⊕ ch₂ dy = inj₂ (y ⊞ dy)
inj₁ x ⊕ rp₁₂ y = inj₂ y
inj₂ y ⊕ rp₂₁ x = inj₁ x
_⊝_ : ∀ (v₂ v₁ : X ⊎ Y) → SumChange v₁
inj₁ x₂ ⊝ inj₁ x₁ = ch₁ (x₂ ⊟ x₁)
inj₂ y₂ ⊝ inj₂ y₁ = ch₂ (y₂ ⊟ y₁)
inj₂ y₂ ⊝ inj₁ x₁ = rp₁₂ y₂
inj₁ x₂ ⊝ inj₂ y₁ = rp₂₁ x₂
s-nil : (v : X ⊎ Y) → SumChange v
s-nil (inj₁ x) = ch₁ (nil x)
s-nil (inj₂ y) = ch₂ (nil y)
s-update-diff : ∀ (u v : X ⊎ Y) → v ⊕ (u ⊝ v) ≡ u
s-update-diff (inj₁ x₂) (inj₁ x₁) = cong inj₁ (update-diff x₂ x₁)
s-update-diff (inj₂ y₂) (inj₂ y₁) = cong inj₂ (update-diff y₂ y₁)
s-update-diff (inj₁ x₂) (inj₂ y₁) = refl
s-update-diff (inj₂ y₂) (inj₁ x₁) = refl
s-update-nil : ∀ v → v ⊕ (s-nil v) ≡ v
s-update-nil (inj₁ x) = cong inj₁ (update-nil x)
s-update-nil (inj₂ y) = cong inj₂ (update-nil y)
instance
changeAlgebraSums : ChangeAlgebra (X ⊎ Y)
changeAlgebraSums = record
{ Change = SumChange
; update = _⊕_
; diff = _⊝_
; nil = s-nil
; isChangeAlgebra = record
{ update-diff = s-update-diff
; update-nil = s-update-nil
}
}
inj₁′ : Δ (inj₁ as (X → (X ⊎ Y)))
inj₁′ = nil inj₁
inj₁′-realizer : RawChange (inj₁ as (X → (X ⊎ Y)))
inj₁′-realizer x dx = ch₁ dx
inj₁′Derivative : IsDerivative (inj₁ as (X → (X ⊎ Y))) inj₁′-realizer
inj₁′Derivative x dx = refl
inj₁′-realizer-correct : ∀ a da → apply inj₁′ a da ≙₍ inj₁ a as (X ⊎ Y) ₎ inj₁′-realizer a da
inj₁′-realizer-correct a da = diff-update
inj₁′-faster-w-proof : equiv-raw-change-to-change-ResType inj₁ inj₁′-realizer
inj₁′-faster-w-proof = equiv-raw-change-to-change inj₁ inj₁′ inj₁′-realizer inj₁′-realizer-correct
inj₁′-faster : Δ inj₁
inj₁′-faster = proj₁ inj₁′-faster-w-proof
inj₂′ : Δ (inj₂ as (Y → (X ⊎ Y)))
inj₂′ = nil inj₂
inj₂′-realizer : RawChange (inj₂ as (Y → (X ⊎ Y)))
inj₂′-realizer y dy = ch₂ dy
inj₂′Derivative : IsDerivative (inj₂ as (Y → (X ⊎ Y))) inj₂′-realizer
inj₂′Derivative y dy = refl
inj₂′-realizer-correct : ∀ b db → apply inj₂′ b db ≙₍ inj₂ b as (X ⊎ Y) ₎ inj₂′-realizer b db
inj₂′-realizer-correct b db = diff-update
inj₂′-faster-w-proof : equiv-raw-change-to-change-ResType inj₂ inj₂′-realizer
inj₂′-faster-w-proof = equiv-raw-change-to-change inj₂ inj₂′ inj₂′-realizer inj₂′-realizer-correct
inj₂′-faster : Δ inj₂
inj₂′-faster = proj₁ inj₂′-faster-w-proof
module _ {Z : Set ℓ} {{CZ : ChangeAlgebra Z}} where
-- Elimination form for sums. This is a less dependently-typed version of
-- [_,_].
match : (X → Z) → (Y → Z) → X ⊎ Y → Z
match f g (inj₁ x) = f x
match f g (inj₂ y) = g y
match′ : Δ match
match′ = nil match
match′-realizer : (f : X → Z) → Δ f → (g : Y → Z) → Δ g → (s : X ⊎ Y) → Δ s → Δ (match f g s)
match′-realizer f df g dg (inj₁ x) (ch₁ dx) = apply df x dx
match′-realizer f df g dg (inj₁ x) (rp₁₂ y) = ((g ⊞ dg) y) ⊟ (f x)
match′-realizer f df g dg (inj₂ y) (rp₂₁ x) = ((f ⊞ df) x) ⊟ (g y)
match′-realizer f df g dg (inj₂ y) (ch₂ dy) = apply dg y dy
match′-realizer-correct :
(f : X → Z) → (df : Δ f) → (g : Y → Z) → (dg : Δ g) → (s : X ⊎ Y) → (ds : Δ s) →
apply (apply (apply match′ f df) g dg) s ds ≙₍ match f g s ₎ match′-realizer f df g dg s ds
match′-realizer-correct f df g dg (inj₁ x) (ch₁ dx) = ≙-incrementalization f df x dx
match′-realizer-correct f df g dg (inj₁ x) (rp₁₂ y) = ≙-refl
match′-realizer-correct f df g dg (inj₂ y) (ch₂ dy) = ≙-incrementalization g dg y dy
match′-realizer-correct f df g dg (inj₂ y) (rp₂₁ x) = ≙-refl
-- We need a ternary variant of the lemma here.
match′-faster-w-proof : equiv-raw-change-to-change-ternary-ResType match match′-realizer
match′-faster-w-proof = equiv-raw-change-to-change-ternary match match′ match′-realizer match′-realizer-correct
match′-faster : Δ match
match′-faster = proj₁ match′-faster-w-proof
| 37.053846
| 115
| 0.61366
|
c5d18aae30192775739410458ff518da7619b4f0
| 9,873
|
agda
|
Agda
|
Groups/FreeGroup/Lemmas.agda
|
Smaug123/agdaproofs
|
0f4230011039092f58f673abcad8fb0652e6b562
|
[
"MIT"
] | 4
|
2019-08-08T12:44:19.000Z
|
2022-01-28T06:04:15.000Z
|
Groups/FreeGroup/Lemmas.agda
|
Smaug123/agdaproofs
|
0f4230011039092f58f673abcad8fb0652e6b562
|
[
"MIT"
] | 14
|
2019-01-06T21:11:59.000Z
|
2020-04-11T11:03:39.000Z
|
Groups/FreeGroup/Lemmas.agda
|
Smaug123/agdaproofs
|
0f4230011039092f58f673abcad8fb0652e6b562
|
[
"MIT"
] | 1
|
2021-11-29T13:23:07.000Z
|
2021-11-29T13:23:07.000Z
|
{-# OPTIONS --safe --warning=error #-}
open import Sets.Cardinality.Infinite.Definition
open import Sets.EquivalenceRelations
open import Setoids.Setoids
open import Groups.FreeGroup.Definition
open import Groups.Homomorphisms.Definition
open import Groups.Definition
open import Decidable.Sets
open import Numbers.Naturals.Semiring
open import Numbers.Naturals.Order
open import LogicalFormulae
open import Semirings.Definition
open import Functions.Definition
open import Functions.Lemmas
open import Groups.Isomorphisms.Definition
open import Groups.FreeGroup.Word
open import Groups.FreeGroup.Group
open import Groups.FreeGroup.UniversalProperty
open import Groups.Abelian.Definition
open import Groups.QuotientGroup.Definition
open import Groups.Lemmas
open import Groups.Homomorphisms.Lemmas
module Groups.FreeGroup.Lemmas {a : _} {A : Set a} (decA : DecidableSet A) where
freeGroupNonAbelian : AbelianGroup (freeGroup decA) → (a : A) → Sg (A → True) Bijection
freeGroupNonAbelian record { commutative = commutative } a = (λ _ → record {}) , b
where
b : Bijection (λ _ → record {})
Bijection.inj b {x} {y} _ with decA x y
... | inl pr = pr
... | inr neq = exFalso (neq (ofLetterInjective (prependLetterInjective' decA t)))
where
t : prependLetter {decA = decA} (ofLetter x) (prependLetter (ofLetter y) empty (wordEmpty refl)) (wordEnding (succIsPositive 0) refl) ≡ prependLetter (ofLetter y) (prependLetter (ofLetter x) empty (wordEmpty refl)) (wordEnding (succIsPositive 0) refl)
t = commutative {prependLetter (ofLetter x) empty (wordEmpty refl)} {prependLetter (ofLetter y) empty (wordEmpty refl)}
Bijection.surj b record {} = a , refl
private
iso : {b : _} {B : Set b} (decB : DecidableSet B) → {f : A → B} → Bijection f → ReducedWord decA → ReducedWord decB
iso decB {f} bij = universalPropertyFunction decA (freeGroup decB) λ a → freeEmbedding decB (f a)
isoHom : {b : _} {B : Set b} (decB : DecidableSet B) → {f : A → B} → (bij : Bijection f) → GroupHom (freeGroup decA) (freeGroup decB) (iso decB bij)
isoHom decB {f} bij = universalPropertyHom decA (freeGroup decB) λ a → iso decB bij (freeEmbedding decA a)
iso2 : {b : _} {B : Set b} (decB : DecidableSet B) → {f : A → B} → Bijection f → ReducedWord decB → ReducedWord decA
iso2 decB {f} bij = universalPropertyFunction decB (freeGroup decA) λ b → freeEmbedding decA (Invertible.inverse (bijectionImpliesInvertible bij) b)
iso2Hom : {b : _} {B : Set b} (decB : DecidableSet B) → {f : A → B} → (bij : Bijection f) → GroupHom (freeGroup decB) (freeGroup decA) (iso2 decB bij)
iso2Hom decB {f} bij = universalPropertyHom decB (freeGroup decA) λ b → iso2 decB bij (freeEmbedding decB b)
fixesF : {b : _} {B : Set b} (decB : DecidableSet B) → {f : A → B} → (bij : Bijection f) → (x : A) → iso2 decB bij (iso decB bij (freeEmbedding decA x)) ≡ freeEmbedding decA x
fixesF decB {f} bij x with Bijection.surj bij (f x)
... | _ , pr rewrite Bijection.inj bij pr = refl
fixesF' : {b : _} {B : Set b} (decB : DecidableSet B) → {f : A → B} → (bij : Bijection f) → (x : B) → iso decB bij (iso2 decB bij (freeEmbedding decB x)) ≡ freeEmbedding decB x
fixesF' decB {f} bij x with Bijection.surj bij x
... | _ , pr rewrite pr = refl
uniq : {b : _} {B : Set b} (decB : DecidableSet B) → {f : A → B} → (bij : Bijection f) → (x : ReducedWord decA) → x ≡ universalPropertyFunction decA (freeGroup decA) (λ x → iso2 decB bij (iso decB bij (freeEmbedding decA x))) x
uniq decB {f} bij x = universalPropertyUniqueness decA (freeGroup decA) (λ x → iso2 decB bij (iso decB bij (freeEmbedding decA x))) {id} (record { wellDefined = id ; groupHom = refl }) (fixesF decB bij) x
uniqLemm : {b : _} {B : Set b} (decB : DecidableSet B) → {f : A → B} → (bij : Bijection f) → (x : ReducedWord decA) → iso2 decB bij (iso decB bij x) ≡ universalPropertyFunction decA (freeGroup decA) (λ x → iso2 decB bij (iso decB bij (freeEmbedding decA x))) x
uniqLemm decB {f} bij x = universalPropertyUniqueness decA (freeGroup decA) (λ i → freeEmbedding decA (underlying (Bijection.surj bij (f i)))) {λ i → iso2 decB bij (iso decB bij i)} (groupHomsCompose (isoHom decB bij) (iso2Hom decB bij)) (λ _ → refl) x
uniq! : {b : _} {B : Set b} (decB : DecidableSet B) → {f : A → B} → (bij : Bijection f) → (x : ReducedWord decA) → iso2 decB bij (iso decB bij x) ≡ x
uniq! decB bij x = transitivity (uniqLemm decB bij x) (equalityCommutative (uniq decB bij x))
uniq' : {b : _} {B : Set b} (decB : DecidableSet B) → {f : A → B} → (bij : Bijection f) → (x : ReducedWord decB) → x ≡ universalPropertyFunction decB (freeGroup decB) (λ x → iso decB bij (iso2 decB bij (freeEmbedding decB x))) x
uniq' decB {f} bij x = universalPropertyUniqueness decB (freeGroup decB) (λ x → iso decB bij (iso2 decB bij (freeEmbedding decB x))) {id} (record { wellDefined = id ; groupHom = refl }) (fixesF' decB bij) x
uniq'Lemm : {b : _} {B : Set b} (decB : DecidableSet B) → {f : A → B} → (bij : Bijection f) → (x : ReducedWord decB) → iso decB bij (iso2 decB bij x) ≡ universalPropertyFunction decB (freeGroup decB) (λ x → iso decB bij (iso2 decB bij (freeEmbedding decB x))) x
uniq'Lemm decB {f} bij x = universalPropertyUniqueness decB (freeGroup decB) (λ i → freeEmbedding decB (f (Invertible.inverse (bijectionImpliesInvertible bij) i))) {λ i → iso decB bij (iso2 decB bij i)} (groupHomsCompose (iso2Hom decB bij) (isoHom decB bij)) (λ _ → refl) x
uniq'! : {b : _} {B : Set b} (decB : DecidableSet B) → {f : A → B} → (bij : Bijection f) → (x : ReducedWord decB) → iso decB bij (iso2 decB bij x) ≡ x
uniq'! decB bij x = transitivity (uniq'Lemm decB bij x) (equalityCommutative (uniq' decB bij x))
inBijection : {b : _} {B : Set b} (decB : DecidableSet B) {f : A → B} (bij : Bijection f) → Bijection (iso decB bij)
inBijection decB bij = invertibleImpliesBijection (record { inverse = iso2 decB bij ; isLeft = uniq'! decB bij ; isRight = uniq! decB bij })
freeGroupFunctorWellDefined : {b : _} {B : Set b} (decB : DecidableSet B) → {f : A → B} → Bijection f → GroupsIsomorphic (freeGroup decA) (freeGroup decB)
GroupsIsomorphic.isomorphism (freeGroupFunctorWellDefined decB {f} bij) = iso decB bij
GroupIso.groupHom (GroupsIsomorphic.proof (freeGroupFunctorWellDefined decB {f} bij)) = universalPropertyHom decA (freeGroup decB) λ a → freeEmbedding decB (f a)
SetoidInjection.wellDefined (SetoidBijection.inj (GroupIso.bij (GroupsIsomorphic.proof (freeGroupFunctorWellDefined decB {f} bij)))) refl = refl
SetoidInjection.injective (SetoidBijection.inj (GroupIso.bij (GroupsIsomorphic.proof (freeGroupFunctorWellDefined decB {f} bij)))) {x} {y} pr = Bijection.inj (inBijection decB bij) pr
SetoidSurjection.wellDefined (SetoidBijection.surj (GroupIso.bij (GroupsIsomorphic.proof (freeGroupFunctorWellDefined decB {f} bij)))) refl = refl
SetoidSurjection.surjective (SetoidBijection.surj (GroupIso.bij (GroupsIsomorphic.proof (freeGroupFunctorWellDefined decB {f} bij)))) {x} = Bijection.surj (inBijection decB bij) x
{-
freeGroupFunctorInjective : {b : _} {B : Set b} (decB : DecidableSet B) → GroupsIsomorphic (freeGroup decA) (freeGroup decB) → Sg (A → B) (λ f → Bijection f)
freeGroupFunctorInjective decB iso = {!!}
everyGroupQuotientOfFreeGroup : {b : _} → (S : Setoid {a} {b} A) → {_+_ : A → A → A} → (G : Group S _+_) → GroupsIsomorphic G (quotientGroupByHom (freeGroup decA) (universalPropertyHom decA {!!} {!!}))
everyGroupQuotientOfFreeGroup = {!!}
everyFGGroupQuotientOfFGFreeGroup : {!!}
everyFGGroupQuotientOfFGFreeGroup = {!!}
freeGroupTorsionFree : {!!}
freeGroupTorsionFree = {!!}
-}
private
mapNToGrp : (a : A) → (n : ℕ) → ReducedWord decA
mapNToGrpLen : (a : A) → (n : ℕ) → wordLength decA (mapNToGrp a n) ≡ n
mapNToGrpFirstLetter : (a : A) → (n : ℕ) → .(pr : 0 <N wordLength decA (mapNToGrp a (succ n))) → firstLetter decA (mapNToGrp a (succ n)) pr ≡ (ofLetter a)
lemma : (a : A) → (n : ℕ) → .(pr : 0 <N wordLength decA (mapNToGrp a (succ n))) → ofLetter a ≡ freeInverse (firstLetter decA (mapNToGrp a (succ n)) pr) → False
lemma a zero _ ()
lemma a (succ n) _ ()
mapNToGrp a zero = empty
mapNToGrp a 1 = prependLetter (ofLetter a) empty (wordEmpty refl)
mapNToGrp a (succ (succ n)) = prependLetter (ofLetter a) (mapNToGrp a (succ n)) (wordEnding (identityOfIndiscernablesRight _<N_ (succIsPositive n) (equalityCommutative (mapNToGrpLen a (succ n)))) (freeCompletionEqualFalse decA λ p → lemma a n ((identityOfIndiscernablesRight _<N_ (succIsPositive n) (equalityCommutative (mapNToGrpLen a (succ n))))) p))
mapNToGrpFirstLetter a zero pr = refl
mapNToGrpFirstLetter a (succ n) pr = refl
mapNToGrpLen a zero = refl
mapNToGrpLen a (succ zero) = refl
mapNToGrpLen a (succ (succ n)) = applyEquality succ (mapNToGrpLen a (succ n))
mapNToGrpInj : (a : A) → (x y : ℕ) → mapNToGrp a x ≡ mapNToGrp a y → x ≡ y
mapNToGrpInj a zero zero pr = refl
mapNToGrpInj a zero (succ zero) ()
mapNToGrpInj a zero (succ (succ y)) ()
mapNToGrpInj a (succ zero) zero ()
mapNToGrpInj a (succ (succ x)) zero ()
mapNToGrpInj a (succ zero) (succ zero) pr = refl
mapNToGrpInj a (succ zero) (succ (succ y)) pr = exFalso (naughtE (transitivity (applyEquality (wordLength decA) (prependLetterInjective decA pr)) (mapNToGrpLen a (succ y))))
mapNToGrpInj a (succ (succ x)) (succ 0) pr = exFalso (naughtE (transitivity (equalityCommutative (applyEquality (wordLength decA) (prependLetterInjective decA pr))) (mapNToGrpLen a (succ x))))
mapNToGrpInj a (succ (succ x)) (succ (succ y)) pr = applyEquality succ (mapNToGrpInj a (succ x) (succ y) (prependLetterInjective decA pr))
freeGroupInfinite : (nonempty : A) → DedekindInfiniteSet (ReducedWord decA)
DedekindInfiniteSet.inj (freeGroupInfinite nonempty) = mapNToGrp nonempty
DedekindInfiniteSet.isInjection (freeGroupInfinite nonempty) {x} {y} = mapNToGrpInj nonempty x y
| 74.233083
| 354
| 0.701307
|
19e9b2e52a7dbd4c2854bdcea2e86ecbdc66abfa
| 8,816
|
agda
|
Agda
|
Cubical/Functions/Logic.agda
|
guilhermehas/cubical
|
ce3120d3f8d692847b2744162bcd7a01f0b687eb
|
[
"MIT"
] | 1
|
2021-10-31T17:32:49.000Z
|
2021-10-31T17:32:49.000Z
|
Cubical/Functions/Logic.agda
|
guilhermehas/cubical
|
ce3120d3f8d692847b2744162bcd7a01f0b687eb
|
[
"MIT"
] | null | null | null |
Cubical/Functions/Logic.agda
|
guilhermehas/cubical
|
ce3120d3f8d692847b2744162bcd7a01f0b687eb
|
[
"MIT"
] | null | null | null |
-- Various functions for manipulating hProps.
--
-- This file used to be part of Foundations, but it turned out to be
-- not very useful so moved here. Feel free to upstream content.
--
-- Note that it is often a bad idea to use hProp instead of having the
-- isProp proof separate. The reason is that Agda can rarely infer
-- isProp proofs making it easier to just give them explicitly instead
-- of having them bundled up with the type.
--
{-# OPTIONS --safe #-}
module Cubical.Functions.Logic where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.HLevels
open import Cubical.Foundations.Isomorphism
open import Cubical.Foundations.Structure
open import Cubical.Foundations.Function
open import Cubical.Foundations.Univalence using (hPropExt)
import Cubical.Data.Empty as ⊥
open import Cubical.Data.Sum as ⊎ using (_⊎_)
open import Cubical.Data.Unit
open import Cubical.Data.Sigma
open import Cubical.HITs.PropositionalTruncation as PropTrunc
open import Cubical.Relation.Nullary hiding (¬_)
--------------------------------------------------------------------------------
-- The type hProp of mere propositions
-- the definition hProp is given in Foundations.HLevels
-- hProp ℓ = Σ (Type ℓ) isProp
private
variable
ℓ ℓ' ℓ'' : Level
P Q R : hProp ℓ
A B C : Type ℓ
infix 10 ¬_
infixr 8 _⊔_
infixr 8 _⊔′_
infixr 8 _⊓_
infixr 8 _⊓′_
infixr 6 _⇒_
infixr 4 _⇔_
infix 30 _≡ₚ_
infix 30 _≢ₚ_
infix 2 ∃[]-syntax
infix 2 ∃[∶]-syntax
infix 2 ∀[∶]-syntax
infix 2 ∀[]-syntax
infix 2 ⇒∶_⇐∶_
infix 2 ⇐∶_⇒∶_
∥_∥ₚ : Type ℓ → hProp ℓ
∥ A ∥ₚ = ∥ A ∥₁ , isPropPropTrunc
_≡ₚ_ : (x y : A) → hProp _
x ≡ₚ y = ∥ x ≡ y ∥ₚ
hProp≡ : ⟨ P ⟩ ≡ ⟨ Q ⟩ → P ≡ Q
hProp≡ = TypeOfHLevel≡ 1
isProp⟨⟩ : (A : hProp ℓ) → isProp ⟨ A ⟩
isProp⟨⟩ = snd
--------------------------------------------------------------------------------
-- Logical implication of mere propositions
_⇒_ : (A : hProp ℓ) → (B : hProp ℓ') → hProp _
A ⇒ B = (⟨ A ⟩ → ⟨ B ⟩) , isPropΠ λ _ → isProp⟨⟩ B
⇔toPath : ⟨ P ⇒ Q ⟩ → ⟨ Q ⇒ P ⟩ → P ≡ Q
⇔toPath {P = P} {Q = Q} P⇒Q Q⇒P = hProp≡ (hPropExt (isProp⟨⟩ P) (isProp⟨⟩ Q) P⇒Q Q⇒P)
pathTo⇒ : P ≡ Q → ⟨ P ⇒ Q ⟩
pathTo⇒ p x = subst fst p x
pathTo⇐ : P ≡ Q → ⟨ Q ⇒ P ⟩
pathTo⇐ p x = subst fst (sym p) x
substₚ : {x y : A} (B : A → hProp ℓ) → ⟨ x ≡ₚ y ⇒ B x ⇒ B y ⟩
substₚ {x = x} {y = y} B = PropTrunc.elim (λ _ → isPropΠ λ _ → isProp⟨⟩ (B y)) (subst (fst ∘ B))
--------------------------------------------------------------------------------
-- Mixfix notations for ⇔-toPath
-- see ⊔-identityˡ and ⊔-identityʳ for the difference
⇒∶_⇐∶_ : ⟨ P ⇒ Q ⟩ → ⟨ Q ⇒ P ⟩ → P ≡ Q
⇒∶_⇐∶_ = ⇔toPath
⇐∶_⇒∶_ : ⟨ Q ⇒ P ⟩ → ⟨ P ⇒ Q ⟩ → P ≡ Q
⇐∶ g ⇒∶ f = ⇔toPath f g
--------------------------------------------------------------------------------
-- False and True
⊥ : hProp _
⊥ = ⊥.⊥ , λ ()
⊤ : ∀ {ℓ} → hProp ℓ
⊤ = Unit* , (λ _ _ _ → tt*)
--------------------------------------------------------------------------------
-- Pseudo-complement of mere propositions
¬_ : hProp ℓ → hProp _
¬ A = (⟨ A ⟩ → ⊥.⊥) , isPropΠ λ _ → ⊥.isProp⊥
_≢ₚ_ : (x y : A) → hProp _
x ≢ₚ y = ¬ x ≡ₚ y
--------------------------------------------------------------------------------
-- Disjunction of mere propositions
_⊔′_ : Type ℓ → Type ℓ' → Type _
A ⊔′ B = ∥ A ⊎ B ∥₁
_⊔_ : hProp ℓ → hProp ℓ' → hProp _
P ⊔ Q = ∥ ⟨ P ⟩ ⊎ ⟨ Q ⟩ ∥ₚ
inl : A → A ⊔′ B
inl x = ∣ ⊎.inl x ∣₁
inr : B → A ⊔′ B
inr x = ∣ ⊎.inr x ∣₁
⊔-elim : (P : hProp ℓ) (Q : hProp ℓ') (R : ⟨ P ⊔ Q ⟩ → hProp ℓ'')
→ (∀ x → ⟨ R (inl x) ⟩) → (∀ y → ⟨ R (inr y) ⟩) → (∀ z → ⟨ R z ⟩)
⊔-elim _ _ R P⇒R Q⇒R = PropTrunc.elim (snd ∘ R) (⊎.elim P⇒R Q⇒R)
--------------------------------------------------------------------------------
-- Conjunction of mere propositions
_⊓′_ : Type ℓ → Type ℓ' → Type _
A ⊓′ B = A × B
_⊓_ : hProp ℓ → hProp ℓ' → hProp _
A ⊓ B = ⟨ A ⟩ ⊓′ ⟨ B ⟩ , isOfHLevelΣ 1 (isProp⟨⟩ A) (\ _ → isProp⟨⟩ B)
⊓-intro : (P : hProp ℓ) (Q : ⟨ P ⟩ → hProp ℓ') (R : ⟨ P ⟩ → hProp ℓ'')
→ (∀ a → ⟨ Q a ⟩) → (∀ a → ⟨ R a ⟩) → (∀ (a : ⟨ P ⟩) → ⟨ Q a ⊓ R a ⟩ )
⊓-intro _ _ _ = \ f g a → f a , g a
--------------------------------------------------------------------------------
-- Logical bi-implication of mere propositions
_⇔_ : hProp ℓ → hProp ℓ' → hProp _
A ⇔ B = (A ⇒ B) ⊓ (B ⇒ A)
⇔-id : (P : hProp ℓ) → ⟨ P ⇔ P ⟩
⇔-id P = (idfun ⟨ P ⟩) , (idfun ⟨ P ⟩)
--------------------------------------------------------------------------------
-- Universal Quantifier
∀[∶]-syntax : (A → hProp ℓ) → hProp _
∀[∶]-syntax {A = A} P = (∀ x → ⟨ P x ⟩) , isPropΠ (isProp⟨⟩ ∘ P)
∀[]-syntax : (A → hProp ℓ) → hProp _
∀[]-syntax {A = A} P = (∀ x → ⟨ P x ⟩) , isPropΠ (isProp⟨⟩ ∘ P)
syntax ∀[∶]-syntax {A = A} (λ a → P) = ∀[ a ∶ A ] P
syntax ∀[]-syntax (λ a → P) = ∀[ a ] P
--------------------------------------------------------------------------------
-- Existential Quantifier
∃[]-syntax : (A → hProp ℓ) → hProp _
∃[]-syntax {A = A} P = ∥ Σ A (⟨_⟩ ∘ P) ∥ₚ
∃[∶]-syntax : (A → hProp ℓ) → hProp _
∃[∶]-syntax {A = A} P = ∥ Σ A (⟨_⟩ ∘ P) ∥ₚ
syntax ∃[∶]-syntax {A = A} (λ x → P) = ∃[ x ∶ A ] P
syntax ∃[]-syntax (λ x → P) = ∃[ x ] P
--------------------------------------------------------------------------------
-- Decidable mere proposition
Decₚ : (P : hProp ℓ) → hProp ℓ
Decₚ P = Dec ⟨ P ⟩ , isPropDec (isProp⟨⟩ P)
--------------------------------------------------------------------------------
-- Negation commutes with truncation
∥¬A∥≡¬∥A∥ : (A : Type ℓ) → ∥ (A → ⊥.⊥) ∥ₚ ≡ (¬ ∥ A ∥ₚ)
∥¬A∥≡¬∥A∥ _ =
⇒∶ (λ ¬A A → PropTrunc.elim (λ _ → ⊥.isProp⊥)
(PropTrunc.elim (λ _ → isPropΠ λ _ → ⊥.isProp⊥) (λ ¬p p → ¬p p) ¬A) A)
⇐∶ λ ¬p → ∣ (λ p → ¬p ∣ p ∣₁) ∣₁
--------------------------------------------------------------------------------
-- (hProp, ⊔, ⊥) is a bounded ⊔-semilattice
⊔-assoc : (P : hProp ℓ) (Q : hProp ℓ') (R : hProp ℓ'')
→ P ⊔ (Q ⊔ R) ≡ (P ⊔ Q) ⊔ R
⊔-assoc P Q R =
⇒∶ ⊔-elim P (Q ⊔ R) (λ _ → (P ⊔ Q) ⊔ R)
(inl ∘ inl)
(⊔-elim Q R (λ _ → (P ⊔ Q) ⊔ R) (inl ∘ inr) inr)
⇐∶ assoc2
where
assoc2 : (A ⊔′ B) ⊔′ C → A ⊔′ (B ⊔′ C)
assoc2 ∣ ⊎.inr a ∣₁ = ∣ ⊎.inr ∣ ⊎.inr a ∣₁ ∣₁
assoc2 ∣ ⊎.inl ∣ ⊎.inr b ∣₁ ∣₁ = ∣ ⊎.inr ∣ ⊎.inl b ∣₁ ∣₁
assoc2 ∣ ⊎.inl ∣ ⊎.inl c ∣₁ ∣₁ = ∣ ⊎.inl c ∣₁
assoc2 ∣ ⊎.inl (squash₁ x y i) ∣₁ = isPropPropTrunc (assoc2 ∣ ⊎.inl x ∣₁) (assoc2 ∣ ⊎.inl y ∣₁) i
assoc2 (squash₁ x y i) = isPropPropTrunc (assoc2 x) (assoc2 y) i
⊔-idem : (P : hProp ℓ) → P ⊔ P ≡ P
⊔-idem P =
⇒∶ (⊔-elim P P (\ _ → P) (\ x → x) (\ x → x))
⇐∶ inl
⊔-comm : (P : hProp ℓ) (Q : hProp ℓ') → P ⊔ Q ≡ Q ⊔ P
⊔-comm P Q =
⇒∶ (⊔-elim P Q (\ _ → (Q ⊔ P)) inr inl)
⇐∶ (⊔-elim Q P (\ _ → (P ⊔ Q)) inr inl)
⊔-identityˡ : (P : hProp ℓ) → ⊥ ⊔ P ≡ P
⊔-identityˡ P =
⇒∶ (⊔-elim ⊥ P (λ _ → P) (λ ()) (λ x → x))
⇐∶ inr
⊔-identityʳ : (P : hProp ℓ) → P ⊔ ⊥ ≡ P
⊔-identityʳ P = ⇔toPath (⊔-elim P ⊥ (λ _ → P) (λ x → x) λ ()) inl
--------------------------------------------------------------------------------
-- (hProp, ⊓, ⊤) is a bounded ⊓-lattice
⊓-assoc : (P : hProp ℓ) (Q : hProp ℓ') (R : hProp ℓ'')
→ P ⊓ Q ⊓ R ≡ (P ⊓ Q) ⊓ R
⊓-assoc _ _ _ =
⇒∶ (λ {(x , (y , z)) → (x , y) , z})
⇐∶ (λ {((x , y) , z) → x , (y , z) })
⊓-comm : (P : hProp ℓ) (Q : hProp ℓ') → P ⊓ Q ≡ Q ⊓ P
⊓-comm _ _ = ⇔toPath (\ p → p .snd , p .fst) (\ p → p .snd , p .fst)
⊓-idem : (P : hProp ℓ) → P ⊓ P ≡ P
⊓-idem _ = ⇔toPath fst (λ x → x , x)
⊓-identityˡ : (P : hProp ℓ) → ⊤ {ℓ} ⊓ P ≡ P
⊓-identityˡ _ = ⇔toPath snd λ x → tt* , x
⊓-identityʳ : (P : hProp ℓ) → P ⊓ ⊤ {ℓ} ≡ P
⊓-identityʳ _ = ⇔toPath fst λ x → x , tt*
--------------------------------------------------------------------------------
-- Distributive laws
⇒-⊓-distrib : (P : hProp ℓ) (Q : hProp ℓ')(R : hProp ℓ'')
→ P ⇒ (Q ⊓ R) ≡ (P ⇒ Q) ⊓ (P ⇒ R)
⇒-⊓-distrib _ _ _ =
⇒∶ (λ f → (fst ∘ f) , (snd ∘ f))
⇐∶ (λ { (f , g) x → f x , g x})
⊓-⊔-distribˡ : (P : hProp ℓ) (Q : hProp ℓ')(R : hProp ℓ'')
→ P ⊓ (Q ⊔ R) ≡ (P ⊓ Q) ⊔ (P ⊓ R)
⊓-⊔-distribˡ P Q R =
⇒∶ (λ { (x , a) → ⊔-elim Q R (λ _ → (P ⊓ Q) ⊔ (P ⊓ R))
(λ y → ∣ ⊎.inl (x , y) ∣₁ )
(λ z → ∣ ⊎.inr (x , z) ∣₁ ) a })
⇐∶ ⊔-elim (P ⊓ Q) (P ⊓ R) (λ _ → P ⊓ Q ⊔ R)
(λ y → fst y , inl (snd y))
(λ z → fst z , inr (snd z))
⊔-⊓-distribˡ : (P : hProp ℓ) (Q : hProp ℓ')(R : hProp ℓ'')
→ P ⊔ (Q ⊓ R) ≡ (P ⊔ Q) ⊓ (P ⊔ R)
⊔-⊓-distribˡ P Q R =
⇒∶ ⊔-elim P (Q ⊓ R) (λ _ → (P ⊔ Q) ⊓ (P ⊔ R) )
(\ x → inl x , inl x) (\ p → inr (p .fst) , inr (p .snd))
⇐∶ (λ { (x , y) → ⊔-elim P R (λ _ → P ⊔ Q ⊓ R) inl
(λ z → ⊔-elim P Q (λ _ → P ⊔ Q ⊓ R) inl (λ y → inr (y , z)) x) y })
⊓-∀-distrib : (P : A → hProp ℓ) (Q : A → hProp ℓ')
→ (∀[ a ∶ A ] P a) ⊓ (∀[ a ∶ A ] Q a) ≡ (∀[ a ∶ A ] (P a ⊓ Q a))
⊓-∀-distrib P Q =
⇒∶ (λ {(p , q) a → p a , q a})
⇐∶ λ pq → (fst ∘ pq ) , (snd ∘ pq)
| 30.295533
| 101
| 0.420599
|
1daec78cc4875922e4f3782aed83abc252804464
| 5,528
|
agda
|
Agda
|
Structure/Sets/ZFC/Classical.agda
|
Lolirofle/stuff-in-agda
|
70f4fba849f2fd779c5aaa5af122ccb6a5b271ba
|
[
"MIT"
] | 6
|
2020-04-07T17:58:13.000Z
|
2022-02-05T06:53:22.000Z
|
Structure/Sets/ZFC/Classical.agda
|
Lolirofle/stuff-in-agda
|
70f4fba849f2fd779c5aaa5af122ccb6a5b271ba
|
[
"MIT"
] | null | null | null |
Structure/Sets/ZFC/Classical.agda
|
Lolirofle/stuff-in-agda
|
70f4fba849f2fd779c5aaa5af122ccb6a5b271ba
|
[
"MIT"
] | null | null | null |
open import Type
open import Structure.Relator
open import Structure.Setoid renaming (_≡_ to _≡ₑ_)
module Structure.Sets.ZFC.Classical {ℓₛ ℓₗ ℓₑ} {S : Type{ℓₛ}} ⦃ equiv : Equiv{ℓₑ}(S) ⦄ (_∈_ : S → S → Type{ℓₗ}) ⦃ [∈]-binaryRelator : BinaryRelator(_∈_) ⦄ where
open import Data.Either as Either using ()
open import Functional
open import Logic.Classical
open import Logic.Predicate
open import Logic.Propositional
open import Logic.Propositional.Theorems
import Lvl
open import Structure.Operator
open import Structure.Relator.Proofs
open import Structure.Relator.Properties
import Structure.Sets.Names
open Structure.Sets.Names.From-[∈] (_∈_)
open Structure.Sets.Names.Relations (_∈_)
open import Structure.Sets.ZFC(_∈_) ⦃ [∈]-binaryRelator ⦄
open import Syntax.Function
open import Syntax.Implication
open import Syntax.Transitivity
private variable ℓ : Lvl.Level
private variable T A B : Type{ℓ}
private variable x : S
module _ ⦃ zfc : ZFC ⦄ where
open ZFC(zfc)
-- ZFC implies excluded middle.
-- Note that this only requires the following set related axioms:
-- • Set extensionality (Not really neccessary if every equality is replaced with set equality instead).
-- • Axiom of choice (TODO: Is this really neccessary? The proof only uses the choice function on finite sets? Further investigation on choice functions for finite sets would clear this up).
-- • Choice functions are functions.
-- • Restricted set comprehension.
-- • Existence of at least two different sets (In this proof, ∅ and {∅} (𝑇 and 𝐹) is used).
-- • Existence of a set containing the two different sets, and the existence of all subsets of this set.
-- Also called: Diaconescu's theorem, Goodman–Myhill theorem.
excluded-middle-by-choice : ∀{P : Type{ℓ}} → Classical(P)
excluded-middle-by-choice{P = P} = intro $ᵢₙₛₜ
let
instance
pos-rel : UnaryRelator(x ↦ P ∨ (x ≡ 𝑇))
pos-rel = [∨]-unaryRelator ⦃ rel-Q = binary-unaryRelatorᵣ ⦄
instance
neg-rel : UnaryRelator(x ↦ P ∨ (x ≡ 𝐹))
neg-rel = [∨]-unaryRelator ⦃ rel-Q = binary-unaryRelatorᵣ ⦄
pos = filter (x ↦ P ∨ (x ≡ 𝑇)) BoolSet
neg = filter (x ↦ P ∨ (x ≡ 𝐹)) BoolSet
-- The contents of pos by definition. A subset of BoolSet which is equal to BoolSet when P, {𝑇} otherwise.
pos-containment : (x ∈ pos) ↔ (x ∈ BoolSet) ∧ (P ∨ (x ≡ 𝑇))
pos-containment = restricted-comprehension
-- The contents of neg by definition. A subset of BoolSet which is equal to BoolSet when P, {𝐹} otherwise.
neg-containment : (x ∈ neg) ↔ (x ∈ BoolSet) ∧ (P ∨ (x ≡ 𝐹))
neg-containment = restricted-comprehension
-- pos is non-empty because it should at least contain 𝑇 from filtering BoolSet.
instance
ne-pos : NonEmpty(pos)
ne-pos = [↔]-to-[←] (nonEmpty-filter) ([∃]-intro 𝑇 ⦃ [∧]-intro 𝑇-in-BoolSet ([∨]-introᵣ (\{_} → [↔]-reflexivity)) ⦄)
-- neg is non-empty because it should at least contain 𝐹 from filtering BoolSet.
instance
ne-neg : NonEmpty(neg)
ne-neg = [↔]-to-[←] (nonEmpty-filter) ([∃]-intro 𝐹 ⦃ [∧]-intro 𝐹-in-BoolSet ([∨]-introᵣ (\{_} → [↔]-reflexivity)) ⦄)
-- Chooses an element in respective sets pos and neg.
pos-choose = choose (pair pos neg) pos
neg-choose = choose (pair pos neg) neg
-- By definition of pos, either P holds or pos-choose have to be 𝑇.
pos-choice : P ∨ (pos-choose ≡ 𝑇)
pos-choice = [∧]-elimᵣ ([↔]-to-[→] pos-containment (choice {pair pos neg} {pos} ⦃ ne-pos ⦄ ⦃ pair-contains-left ⦄))
-- By definition of neg, either P holds or neg-choose have to be 𝐹.
neg-choice : P ∨ (neg-choose ≡ 𝐹)
neg-choice = [∧]-elimᵣ ([↔]-to-[→] neg-containment (choice {pair pos neg} {neg} ⦃ ne-neg ⦄ ⦃ pair-contains-right ⦄))
in
• ( -- Contrapositive of the argument below states that if pos-choose and neg-choose is inequal, then (¬ P)
(_⇒ -- When P holds, both pos and neg is BoolSet, so they are equal. The pos-choose and neg-choose is the choice function applied to the equal sets pos and neg respectively, and because choose is a function (it respects equality, specifically set equality), pos-choose and neg-choose is also equal.
P ⇒-[ (\p {x} → [↔]-transitivity (pos-containment {x}) ([↔]-transitivity ([∧]-mapᵣ-[↔] ([↔]-intro (const([∨]-introₗ p)) (const([∨]-introₗ p)))) ([↔]-symmetry (neg-containment {x})))) ]
(pos ≡ neg) ⇒-[ [↔]-to-[←] set-extensionality ]
(pos ≡ₑ neg) ⇒-[ congruence₂(choose) (reflexivity(_≡ₑ_)) ]
(pos-choose ≡ₑ neg-choose) ⇒-end
) ⇒
(P → (pos-choose ≡ₑ neg-choose)) ⇒-[ contrapositiveᵣ ]
((¬ P) ← (pos-choose ≢ neg-choose)) ⇒-end
)
• ( -- The case other than P is that pos and neg only contains 𝑇 and 𝐹 respectively. This forces pos-choose and neg-choose to be 𝑇 and 𝐹 respectively, which means that they are inequal.
• pos-choice
• neg-choice
⇒₂-[ [∧]-intro ]
(P ∨ (pos-choose ≡ 𝑇)) ∧ (P ∨ (neg-choose ≡ 𝐹)) ⇒-[ [↔]-to-[←] [∨][∧]-distributivityₗ ]
P ∨ ((pos-choose ≡ 𝑇) ∧ (neg-choose ≡ 𝐹)) ⇒-[ Either.mapRight (\{([∧]-intro p0 n1) → [≡][≢]-semitransitivityᵣ([≡][≢]-semitransitivityₗ ([↔]-to-[←] set-extensionality p0) zero-one-ineq) (symmetry(_≡ₑ_) ([↔]-to-[←] set-extensionality n1))}) ]
P ∨ (pos-choose ≢ neg-choose) ⇒-end
)
⇒₂-[ Either.mapRight ]
(P ∨ (¬ P)) ⇒-end
| 52.647619
| 306
| 0.624819
|
134367bbfc51f3e9acaa5136a5fbcf628f06a338
| 37
|
agda
|
Agda
|
Structure/Sets/Relators.agda
|
Lolirofle/stuff-in-agda
|
70f4fba849f2fd779c5aaa5af122ccb6a5b271ba
|
[
"MIT"
] | 6
|
2020-04-07T17:58:13.000Z
|
2022-02-05T06:53:22.000Z
|
Structure/Sets/Relators.agda
|
Lolirofle/stuff-in-agda
|
70f4fba849f2fd779c5aaa5af122ccb6a5b271ba
|
[
"MIT"
] | null | null | null |
Structure/Sets/Relators.agda
|
Lolirofle/stuff-in-agda
|
70f4fba849f2fd779c5aaa5af122ccb6a5b271ba
|
[
"MIT"
] | null | null | null |
module Structure.Sets.Relators where
| 18.5
| 36
| 0.864865
|
1ea299f203b68cfe8591f0e955040582cdff5334
| 15,847
|
agda
|
Agda
|
theorems/stash/modalities/gbm/CoherenceData.agda
|
AntoineAllioux/HoTT-Agda
|
1037d82edcf29b620677a311dcfd4fc2ade2faa6
|
[
"MIT"
] | 294
|
2015-01-09T16:23:23.000Z
|
2022-03-20T13:54:45.000Z
|
theorems/stash/modalities/gbm/CoherenceData.agda
|
AntoineAllioux/HoTT-Agda
|
1037d82edcf29b620677a311dcfd4fc2ade2faa6
|
[
"MIT"
] | 31
|
2015-03-05T20:09:00.000Z
|
2021-10-03T19:15:25.000Z
|
theorems/stash/modalities/gbm/CoherenceData.agda
|
AntoineAllioux/HoTT-Agda
|
1037d82edcf29b620677a311dcfd4fc2ade2faa6
|
[
"MIT"
] | 50
|
2015-01-10T01:48:08.000Z
|
2022-02-14T03:03:25.000Z
|
{-# OPTIONS --without-K --rewriting #-}
open import HoTT hiding (left; right)
import homotopy.ModalWedgeExtension
module stash.modalities.gbm.CoherenceData {ℓ} (M : Modality ℓ)
{A : Type ℓ} {B : Type ℓ} (Q : A → B → Type ℓ)
(H : {a₀ : A} {b₀ : B} (q₀ : Q a₀ b₀)
{a₁ : A} (q₁ : Q a₁ b₀)
{b₁ : B} (q₂ : Q a₀ b₁) →
Modality.is-◯-connected M (((a₀ , q₀) == (a₁ , q₁)) * ((b₀ , q₀) == (b₁ , q₂))))
where
open Modality M
module WedgeExt {A} {a₀} {B} {b₀} =
homotopy.ModalWedgeExtension M {A} {a₀} {B} {b₀}
open import stash.modalities.gbm.Pushout Q
-- {- goal :
-- ◯ (hfiber (λ q₁₀ → bmglue q₀₀ ∙' ! (bmglue q₁₀) ∙' bmglue q₁₁) r)
-- ≃ ◯ (hfiber bmglue r)
-- -}
α₁=α₁α₂⁻¹α₂ : ∀ {p₁ p₂ p₃ : BMPushout} (α₁ : p₁ == p₂) (α₂ : p₃ == p₂)
→ α₁ == α₁ ∙' ! α₂ ∙' α₂
α₁=α₁α₂⁻¹α₂ _ idp = idp
α₁=α₂α₂⁻¹α₁ : ∀ {p₁ p₂ p₃ : BMPushout} (α₁ : p₁ == p₂) (α₂ : p₁ == p₃)
→ α₁ == α₂ ∙' ! α₂ ∙' α₁
α₁=α₂α₂⁻¹α₁ idp α₂ = ! (!-inv'-r α₂)
private
path-lemma₁ : ∀ {a₀ a₁ b} (q₀ : Q a₀ b) (q₁ : Q a₁ b)
→ bmglue q₀ == bmglue q₀ ∙' ! (bmglue q₁) ∙' bmglue q₁
path-lemma₁ q₀ q₁ = α₁=α₁α₂⁻¹α₂ (bmglue q₀) (bmglue q₁)
path-lemma₂ : ∀ {a b₀ b₁} (q₀ : Q a b₀) (q₁ : Q a b₁)
→ bmglue q₀ == bmglue q₁ ∙' ! (bmglue q₁) ∙' bmglue q₀
path-lemma₂ q₀ q₁ = α₁=α₂α₂⁻¹α₁ (bmglue q₀) (bmglue q₁)
abstract
path-coherence : ∀ {a b} (q : Q a b)
→ path-lemma₁ q q == path-lemma₂ q q
path-coherence q = lemma (bmglue q) where
lemma : ∀ {p₀ p₁ : BMPushout} (path : p₀ == p₁)
→ α₁=α₁α₂⁻¹α₂ path path == α₁=α₂α₂⁻¹α₁ path path
lemma idp = idp
module To {a₁ b₀} (q₁₀ : Q a₁ b₀) where
U = Σ A λ a → Q a b₀
u₀ : U
u₀ = (a₁ , q₁₀)
V = Σ B λ b → Q a₁ b
v₀ : V
v₀ = (b₀ , q₁₀)
P : U → V → Type ℓ
P u v = (r : bmleft (fst u) == bmright (fst v))
→ bmglue (snd u) ∙' ! (bmglue q₁₀) ∙' bmglue (snd v) == r
→ ◯ (hfiber bmglue r)
template : ∀ (u : U) (v : V)
→ (r : bmleft (fst u) == bmright (fst v))
→ (shift : bmglue (snd u) ∙' ! (bmglue q₁₀) ∙' bmglue (snd v) == r)
→ ∀ q₀₁ → bmglue q₀₁ == bmglue (snd u) ∙' ! (bmglue q₁₀) ∙' bmglue (snd v)
→ ◯ (hfiber bmglue r)
template u v r shift q₀₁ path = η (q₀₁ , path ∙' shift)
f = λ u r shift → template u v₀ r shift (snd u) (path-lemma₁ (snd u) q₁₀)
g = λ v r shift → template u₀ v r shift (snd v) (path-lemma₂ (snd v) q₁₀)
p' = λ r shift → ap (template u₀ v₀ r shift q₁₀) (path-coherence q₁₀)
p = λ= λ r → λ= λ shift → p' r shift
args : WedgeExt.args {A = U} {a₀ = u₀} {B = V} {b₀ = v₀}
args = record {
join-conn = λ u v → H q₁₀ (snd u) (snd v);
R = λ u v → P u v , Π-is-local λ _ → Π-is-local λ _ → ◯-is-local;
f = f; g = g; p = p}
ext : ∀ u v → P u v
ext = WedgeExt.ext args
β-l : ∀ u r shift → ext u v₀ r shift == f u r shift
β-l u r shift = app= (app= (WedgeExt.β-l u) r) shift
β-r : ∀ v r shift → ext u₀ v r shift == g v r shift
β-r v r shift = app= (app= (WedgeExt.β-r v) r) shift
abstract
coh : ∀ r shift → ! (β-l u₀ r shift) ∙ β-r v₀ r shift == p' r shift
coh r shift =
! (β-l u₀ r shift) ∙ β-r v₀ r shift
=⟨ ap (_∙ β-r v₀ r shift) (!-ap (_$ shift) (app= (WedgeExt.β-l u₀) r))
∙ ∙-ap (_$ shift)
(! (app= (WedgeExt.β-l {r = args} u₀) r))
(app= (WedgeExt.β-r {r = args} v₀) r)
∙ ap (λ p → app= p shift)
( ap (_∙ app= (WedgeExt.β-r {r = args} v₀) r)
(!-ap (_$ r) (WedgeExt.β-l {r = args} u₀))
∙ ∙-ap (_$ r)
(! (WedgeExt.β-l {r = args} u₀))
(WedgeExt.β-r {r = args} v₀)) ⟩
app= (app= (! (WedgeExt.β-l {r = args} u₀) ∙ WedgeExt.β-r {r = args} v₀) r) shift
=⟨ ap (λ p → app= (app= p r) shift) (WedgeExt.coh {r = args}) ⟩
app= (app= (λ= λ r → λ= λ shift → p' r shift) r) shift
=⟨ ap (λ p → app= p shift) (app=-β (λ r → λ= λ shift → p' r shift) r)
∙ app=-β (λ shift → p' r shift) shift ⟩
p' r shift
=∎
to' : ∀ {a₀ a₁ b₀ b₁} (q₀₀ : Q a₀ b₀) (q₁₁ : Q a₁ b₁)
→ (r : bmleft a₀ == bmright b₁)
→ hfiber (λ q₁₀ → bmglue q₀₀ ∙' ! (bmglue q₁₀) ∙' bmglue q₁₁) r
→ ◯ (hfiber bmglue r)
to' q₀₀ q₁₁ r (q₁₀ , shift) = To.ext q₁₀ (_ , q₀₀) (_ , q₁₁) r shift
to : ∀ {a₀ a₁ b₀ b₁} (q₀₀ : Q a₀ b₀) (q₁₁ : Q a₁ b₁)
→ (r : bmleft a₀ == bmright b₁)
→ ◯ (hfiber (λ q₁₀ → bmglue q₀₀ ∙' ! (bmglue q₁₀) ∙' bmglue q₁₁) r)
→ ◯ (hfiber bmglue r)
to q₀₀ q₁₁ r = ◯-rec ◯-is-local (to' q₀₀ q₁₁ r)
to-η-β : ∀ {a₀ a₁ b₀ b₁} (q₀₀ : Q a₀ b₀) (q₁₁ : Q a₁ b₁)
→ (r : bmleft a₀ == bmright b₁)
→ (fiber : hfiber (λ q₁₀ → bmglue q₀₀ ∙' ! (bmglue q₁₀) ∙' bmglue q₁₁) r)
→ to q₀₀ q₁₁ r (η fiber) == to' q₀₀ q₁₁ r fiber
to-η-β q₀₀ q₁₁ r = ◯-rec-β ◯-is-local (to' q₀₀ q₁₁ r)
module From {a₀ b₁} (q₀₁ : Q a₀ b₁) where
U = Σ A λ a → Q a b₁
u₀ : U
u₀ = (a₀ , q₀₁)
V = Σ B λ b → Q a₀ b
v₀ : V
v₀ = (b₁ , q₀₁)
P : U → V → Type ℓ
P u v = (r : bmleft a₀ == bmright b₁)
→ bmglue q₀₁ == r
→ ◯ (hfiber (λ q₁₀ → bmglue (snd v) ∙' ! (bmglue q₁₀) ∙' bmglue (snd u)) r)
template : ∀ (u : U) (v : V)
→ (r : bmleft a₀ == bmright b₁)
→ (shift : bmglue q₀₁ == r)
→ ∀ q₁₀ → bmglue q₀₁ == bmglue (snd v) ∙' ! (bmglue q₁₀) ∙' bmglue (snd u)
→ ◯ (hfiber (λ q₁₀ → bmglue (snd v) ∙' ! (bmglue q₁₀) ∙' bmglue (snd u)) r)
template u v r shift q₁₀ path = η (q₁₀ , ! path ∙' shift)
f = λ u r shift → template u v₀ r shift (snd u) (path-lemma₁ q₀₁ (snd u))
g = λ v r shift → template u₀ v r shift (snd v) (path-lemma₂ q₀₁ (snd v))
p' = λ r shift → ap (template u₀ v₀ r shift q₀₁) (path-coherence q₀₁)
p = λ= λ r → λ= λ shift → p' r shift
args : WedgeExt.args {A = U} {a₀ = u₀} {B = V} {b₀ = v₀}
args = record {
join-conn = λ u v → H q₀₁ (snd u) (snd v);
R = λ u v → P u v , Π-is-local λ _ → Π-is-local λ _ → ◯-is-local;
f = f; g = g; p = p}
ext : ∀ u v → P u v
ext = WedgeExt.ext args
β-l : ∀ u r shift → ext u v₀ r shift == f u r shift
β-l u r shift = app= (app= (WedgeExt.β-l u) r) shift
β-r : ∀ v r shift → ext u₀ v r shift == g v r shift
β-r v r shift = app= (app= (WedgeExt.β-r v) r) shift
abstract
coh : ∀ r shift → ! (β-l u₀ r shift) ∙ β-r v₀ r shift == p' r shift
coh r shift =
! (β-l u₀ r shift) ∙ β-r v₀ r shift
=⟨ ap (_∙ β-r v₀ r shift) (!-ap (_$ shift) (app= β-l' r))
∙ ∙-ap (_$ shift) (! (app= β-l' r)) (app= β-r' r)
∙ ap (λ p → app= p shift)
( ap (_∙ app= β-r' r) (!-ap (_$ r) β-l')
∙ ∙-ap (_$ r) (! β-l') β-r') ⟩
app= (app= (! β-l' ∙ β-r') r) shift
=⟨ ap (λ p → app= (app= p r) shift) (WedgeExt.coh {r = args}) ⟩
app= (app= (λ= λ r → λ= λ shift → p' r shift) r) shift
=⟨ ap (λ p → app= p shift) (app=-β (λ r → λ= λ shift → p' r shift) r)
∙ app=-β (λ shift → p' r shift) shift ⟩
p' r shift
=∎
where β-l' = WedgeExt.β-l {r = args} u₀
β-r' = WedgeExt.β-r {r = args} v₀
from' : ∀ {a₀ a₁ b₀ b₁} (q₀₀ : Q a₀ b₀) (q₁₁ : Q a₁ b₁)
→ (r : bmleft a₀ == bmright b₁)
→ hfiber bmglue r
→ ◯ (hfiber (λ q₁₀ → bmglue q₀₀ ∙' ! (bmglue q₁₀) ∙' bmglue q₁₁) r)
from' q₀₀ q₁₁ r (q₀₁ , shift) = From.ext q₀₁ (_ , q₁₁) (_ , q₀₀) r shift
from : ∀ {a₀ a₁ b₀ b₁} (q₀₀ : Q a₀ b₀) (q₁₁ : Q a₁ b₁)
→ (r : bmleft a₀ == bmright b₁)
→ ◯ (hfiber bmglue r)
→ ◯ (hfiber (λ q₁₀ → bmglue q₀₀ ∙' ! (bmglue q₁₀) ∙' bmglue q₁₁) r)
from q₀₀ q₁₁ r = ◯-rec ◯-is-local (from' q₀₀ q₁₁ r)
from-η-β : ∀ {a₀ a₁ b₀ b₁} (q₀₀ : Q a₀ b₀) (q₁₁ : Q a₁ b₁)
→ (r : bmleft a₀ == bmright b₁)
→ (fiber : hfiber bmglue r)
→ from q₀₀ q₁₁ r (η fiber) == from' q₀₀ q₁₁ r fiber
from-η-β q₀₀ q₁₁ r = ◯-rec-β ◯-is-local (from' q₀₀ q₁₁ r)
-- Equivalence
{-
First step: Pack relevant rules into records.
-}
record βPair {a₀ a₁ b₀ b₁} (q₀₀ : Q a₀ b₀)
(q₁₁ : Q a₁ b₁) (q₀₁ : Q a₀ b₁) (q₁₀ : Q a₁ b₀)
(r : bmleft a₀ == bmright b₁) : Type ℓ where
constructor βpair
field
path : bmglue q₀₁ == bmglue q₀₀ ∙' ! (bmglue q₁₀) ∙' bmglue q₁₁
to-β : ∀ shift → To.ext q₁₀ (_ , q₀₀) (_ , q₁₁) r shift
== To.template q₁₀ (_ , q₀₀) (_ , q₁₁) r shift q₀₁ path
from-β : ∀ shift → From.ext q₀₁ (_ , q₁₁) (_ , q₀₀) r shift
== From.template q₀₁ (_ , q₁₁) (_ , q₀₀) r shift q₁₀ path
βpair-bmleft : ∀ {a₀ a₁ b} (q₀ : Q a₀ b) (q₁ : Q a₁ b) r
→ βPair q₀ q₁ q₀ q₁ r
βpair-bmleft q₀ q₁ r = record
{ path = path-lemma₁ q₀ q₁
; to-β = To.β-l q₁ (_ , q₀) r
; from-β = From.β-l q₀ (_ , q₁) r
}
βpair-bmright : ∀ {a b₀ b₁} (q₀ : Q a b₀) (q₁ : Q a b₁) r
→ βPair q₀ q₁ q₁ q₀ r
βpair-bmright q₀ q₁ r = record
{ path = path-lemma₂ q₁ q₀
; to-β = To.β-r q₀ (_ , q₁) r
; from-β = From.β-r q₁ (_ , q₀) r
}
abstract
βpair= : ∀ {a₀ a₁} {b₀ b₁} (q₀₀ : Q a₀ b₀) (q₁₁ : Q a₁ b₁)
(q₀₁ : Q a₀ b₁) (q₁₀ : Q a₁ b₀) (r : bmleft a₀ == bmright b₁)
{p₁ p₂ : bmglue q₀₁ == bmglue q₀₀ ∙' ! (bmglue q₁₀) ∙' bmglue q₁₁} (p= : p₁ == p₂)
{toβ₁} {toβ₂}
(toβ= : ∀ shift → toβ₁ shift ∙ ap (To.template q₁₀ (_ , q₀₀) (_ , q₁₁) r shift q₀₁) p=
== toβ₂ shift)
{fromβ₁} {fromβ₂}
(fromβ= : ∀ shift → fromβ₁ shift ∙ ap (From.template q₀₁ (_ , q₁₁) (_ , q₀₀) r shift q₁₀) p=
== fromβ₂ shift)
→ βpair p₁ toβ₁ fromβ₁ == βpair p₂ toβ₂ fromβ₂
βpair= q₀₀ q₁₁ q₀₁ q₁₀ r {p} idp toβ= fromβ= = lemma
(λ= λ shift → ! (∙-unit-r _) ∙ toβ= shift)
(λ= λ shift → ! (∙-unit-r _) ∙ fromβ= shift)
where
lemma : ∀ {toβ₁} {toβ₂} (toβ= : toβ₁ == toβ₂) {fromβ₁} {fromβ₂} (fromβ= : fromβ₁ == fromβ₂)
→ βpair p toβ₁ fromβ₁ == βpair p toβ₂ fromβ₂
lemma idp idp = idp
abstract
βpair-glue : ∀ {a} {b} (q : Q a b) r
→ βpair-bmleft q q r == βpair-bmright q q r
βpair-glue q r = βpair= q q q q r
(path-coherence q)
(λ shift →
To.β-l q (_ , q) r shift ∙ To.p' q r shift
=⟨ ! $ ap (To.β-l q (_ , q) r shift ∙_) (To.coh q r shift) ⟩
To.β-l q (_ , q) r shift ∙ ! (To.β-l q (_ , q) r shift) ∙ To.β-r q (_ , q) r shift
=⟨ ! (∙-assoc (To.β-l q (_ , q) r shift) (! (To.β-l q (_ , q) r shift)) (To.β-r q (_ , q) r shift))
∙ ap (_∙ To.β-r q (_ , q) r shift) (!-inv-r (To.β-l q (_ , q) r shift)) ⟩
To.β-r q (_ , q) r shift
∎)
(λ shift →
From.β-l q (_ , q) r shift ∙ From.p' q r shift
=⟨ ! $ ap (From.β-l q (_ , q) r shift ∙_) (From.coh q r shift) ⟩
From.β-l q (_ , q) r shift ∙ ! (From.β-l q (_ , q) r shift) ∙ From.β-r q (_ , q) r shift
=⟨ ! (∙-assoc (From.β-l q (_ , q) r shift) (! (From.β-l q (_ , q) r shift)) (From.β-r q (_ , q) r shift))
∙ ap (_∙ From.β-r q (_ , q) r shift) (!-inv-r (From.β-l q (_ , q) r shift)) ⟩
From.β-r q (_ , q) r shift
∎)
-- Lemmas
private
abstract
to-from-template : ∀ {a₀ a₁ b₀ b₁} {q₀₀ : Q a₀ b₀}
{q₁₁ : Q a₁ b₁} {q₀₁ : Q a₀ b₁} {q₁₀ : Q a₁ b₀} {r}
(params : βPair q₀₀ q₁₁ q₀₁ q₁₀ r) shift
→ to q₀₀ q₁₁ r (from q₀₀ q₁₁ r (η (q₀₁ , shift ))) == η (q₀₁ , shift)
to-from-template {q₀₀ = q₀₀} {q₁₁} {q₀₁} {q₁₀} {r} params shift =
to q₀₀ q₁₁ r (from q₀₀ q₁₁ r (η (q₀₁ , shift)))
=⟨ ap (to q₀₀ q₁₁ r) $ from-η-β q₀₀ q₁₁ r (q₀₁ , shift) ∙ from-β shift ⟩
to q₀₀ q₁₁ r (η (q₁₀ , ! path ∙' shift))
=⟨ to-η-β q₀₀ q₁₁ r (q₁₀ , ! path ∙' shift) ∙ to-β (! path ∙' shift) ⟩
η (q₀₁ , path ∙' ! path ∙' shift)
=⟨ ap (λ p → η (q₀₁ , p)) $ ! (∙'-assoc path (! path) shift) ∙ ap (_∙' shift) (!-inv'-r path) ∙ ∙'-unit-l shift ⟩
η (q₀₁ , shift)
=∎
where open βPair params
module FromTo {a₁ b₀} (q₁₀ : Q a₁ b₀) where
-- upper
U = To.U q₁₀
u₀ = To.u₀ q₁₀
-- lower
V = To.V q₁₀
v₀ = To.v₀ q₁₀
P : U → V → Type ℓ
P u v = (r : bmleft (fst u) == bmright (fst v))
→ (shift : bmglue (snd u) ∙' ! (bmglue q₁₀) ∙' bmglue (snd v) == r)
→ from (snd u) (snd v) r (to (snd u) (snd v) r (η (q₁₀ , shift))) == η (q₁₀ , shift)
abstract
template : ∀ (u : U) (v : V) r shift q₀₁
→ βPair (snd u) (snd v) q₀₁ q₁₀ r
→ from (snd u) (snd v) r (to (snd u) (snd v) r (η (q₁₀ , shift))) == η (q₁₀ , shift)
template (_ , q₀₀) (_ , q₁₁) r shift q₀₁ params =
from q₀₀ q₁₁ r (to q₀₀ q₁₁ r (η (q₁₀ , shift)))
=⟨ ap (from q₀₀ q₁₁ r) $ to-η-β q₀₀ q₁₁ r (q₁₀ , shift) ∙ to-β shift ⟩
from q₀₀ q₁₁ r (η (q₀₁ , path ∙' shift))
=⟨ from-η-β q₀₀ q₁₁ r (q₀₁ , path ∙' shift) ∙ from-β (path ∙' shift) ⟩
η (q₁₀ , ! path ∙' path ∙' shift)
=⟨ ap (λ p → η (q₁₀ , p)) $ ! (∙'-assoc (! path) path shift) ∙ ap (_∙' shift) (!-inv'-l path) ∙ ∙'-unit-l shift ⟩
η (q₁₀ , shift)
=∎
where open βPair params
f = λ u r shift → template u v₀ r shift (snd u) (βpair-bmleft (snd u) q₁₀ r)
g = λ v r shift → template u₀ v r shift (snd v) (βpair-bmright q₁₀ (snd v) r)
abstract
p : f u₀ == g v₀
p = λ= λ r → λ= λ shift → ap (template u₀ v₀ r shift q₁₀) (βpair-glue q₁₀ r)
args : WedgeExt.args {A = U} {a₀ = u₀} {B = V} {b₀ = v₀}
args = record {
join-conn = λ u v → H q₁₀ (snd u) (snd v);
R = λ u v → P u v , Π-is-local λ _ → Π-is-local λ _ → ◯-=-is-local _ _;
f = f; g = g; p = p}
abstract
ext : ∀ u v → P u v
ext = WedgeExt.ext args
abstract
from-to' : ∀ {a₀ a₁ b₀ b₁} (q₀₀ : Q a₀ b₀) (q₁₁ : Q a₁ b₁) r fiber
→ from q₀₀ q₁₁ r (to q₀₀ q₁₁ r (η fiber)) == η fiber
from-to' q₀₀ q₁₁ r (q₁₀ , shift) = FromTo.ext q₁₀ (_ , q₀₀) (_ , q₁₁) r shift
from-to : ∀ {a₀ a₁ b₀ b₁} (q₀₀ : Q a₀ b₀) (q₁₁ : Q a₁ b₁) r fiber
→ from q₀₀ q₁₁ r (to q₀₀ q₁₁ r fiber) == fiber
from-to q₀₀ q₁₁ r = ◯-elim (λ _ → ◯-=-is-local _ _) (from-to' q₀₀ q₁₁ r)
module ToFrom {a₀ b₁} (q₀₁ : Q a₀ b₁) where
-- upper
U = From.U q₀₁
u₀ = From.u₀ q₀₁
-- lower
V = From.V q₀₁
v₀ = From.v₀ q₀₁
P : U → V → Type ℓ
P u v = (r : bmleft a₀ == bmright b₁)
→ (shift : bmglue q₀₁ == r)
→ to (snd v) (snd u) r (from (snd v) (snd u) r (η (q₀₁ , shift))) == η (q₀₁ , shift)
abstract
template : ∀ (u : U) (v : V) r shift q₁₀
→ βPair (snd v) (snd u) q₀₁ q₁₀ r
→ to (snd v) (snd u) r (from (snd v) (snd u) r (η (q₀₁ , shift))) == η (q₀₁ , shift)
template (_ , q₁₁) (_ , q₀₀) r shift q₁₀ params =
to q₀₀ q₁₁ r (from q₀₀ q₁₁ r (η (q₀₁ , shift)))
=⟨ ap (to q₀₀ q₁₁ r) $ from-η-β q₀₀ q₁₁ r (q₀₁ , shift) ∙ from-β shift ⟩
to q₀₀ q₁₁ r (η (q₁₀ , ! path ∙' shift))
=⟨ to-η-β q₀₀ q₁₁ r (q₁₀ , ! path ∙' shift) ∙ to-β (! path ∙' shift) ⟩
η (q₀₁ , path ∙' ! path ∙' shift)
=⟨ ap (λ p → η (q₀₁ , p)) $ ! (∙'-assoc path (! path) shift) ∙ ap (_∙' shift) (!-inv'-r path) ∙ ∙'-unit-l shift ⟩
η (q₀₁ , shift)
=∎
where open βPair params
f = λ u r shift → template u v₀ r shift (snd u) (βpair-bmleft q₀₁ (snd u) r)
g = λ v r shift → template u₀ v r shift (snd v) (βpair-bmright (snd v) q₀₁ r)
abstract
p : f u₀ == g v₀
p = λ= λ r → λ= λ shift → ap (template u₀ v₀ r shift q₀₁) (βpair-glue q₀₁ r)
args : WedgeExt.args {A = U} {a₀ = u₀} {B = V} {b₀ = v₀}
args = record {
join-conn = λ u v → H q₀₁ (snd u) (snd v);
R = λ u v → P u v , Π-is-local λ _ → Π-is-local λ _ → ◯-=-is-local _ _;
f = f; g = g; p = p}
abstract
ext : ∀ u v → P u v
ext = WedgeExt.ext args
abstract
to-from' : ∀ {a₀ a₁ b₀ b₁} (q₀₀ : Q a₀ b₀) (q₁₁ : Q a₁ b₁) r fiber
→ to q₀₀ q₁₁ r (from q₀₀ q₁₁ r (η fiber)) == η fiber
to-from' q₀₀ q₁₁ r (q₀₁ , shift) = ToFrom.ext q₀₁ (_ , q₁₁) (_ , q₀₀) r shift
to-from : ∀ {a₀ a₁ b₀ b₁} (q₀₀ : Q a₀ b₀) (q₁₁ : Q a₁ b₁) r fiber
→ to q₀₀ q₁₁ r (from q₀₀ q₁₁ r fiber) == fiber
to-from q₀₀ q₁₁ r = ◯-elim (λ _ → ◯-=-is-local _ _) (to-from' q₀₀ q₁₁ r)
eqv : ∀ {a₀ a₁ b₀ b₁} (q₀₀ : Q a₀ b₀) (q₁₁ : Q a₁ b₁) r
→ ◯ (hfiber (λ q₁₀ → bmglue q₀₀ ∙' ! (bmglue q₁₀) ∙' bmglue q₁₁) r)
≃ ◯ (hfiber bmglue r)
eqv q₀₀ q₁₁ r = equiv (to q₀₀ q₁₁ r) (from q₀₀ q₁₁ r) (to-from q₀₀ q₁₁ r) (from-to q₀₀ q₁₁ r)
| 38.277778
| 121
| 0.50691
|
fb6679891bb9fb2a9b3df0b14fc72c5c0e2d19a1
| 469
|
agda
|
Agda
|
Sets/Cardinality/Infinite/Definition.agda
|
Smaug123/agdaproofs
|
0f4230011039092f58f673abcad8fb0652e6b562
|
[
"MIT"
] | 4
|
2019-08-08T12:44:19.000Z
|
2022-01-28T06:04:15.000Z
|
Sets/Cardinality/Infinite/Definition.agda
|
Smaug123/agdaproofs
|
0f4230011039092f58f673abcad8fb0652e6b562
|
[
"MIT"
] | 14
|
2019-01-06T21:11:59.000Z
|
2020-04-11T11:03:39.000Z
|
Sets/Cardinality/Infinite/Definition.agda
|
Smaug123/agdaproofs
|
0f4230011039092f58f673abcad8fb0652e6b562
|
[
"MIT"
] | 1
|
2021-11-29T13:23:07.000Z
|
2021-11-29T13:23:07.000Z
|
{-# OPTIONS --safe --warning=error --without-K #-}
open import Functions.Definition
open import LogicalFormulae
open import Numbers.Naturals.Definition
open import Sets.FinSet.Definition
module Sets.Cardinality.Infinite.Definition where
InfiniteSet : {a : _} (A : Set a) → Set a
InfiniteSet A = (n : ℕ) → (f : FinSet n → A) → (Bijection f) → False
record DedekindInfiniteSet {a : _} (A : Set a) : Set a where
field
inj : ℕ → A
isInjection : Injection inj
| 27.588235
| 68
| 0.69936
|
18a798bc9d9a243ea3d9fa7e6ebf5235cad9a238
| 281
|
agda
|
Agda
|
test/Fail/SplitOnIrrelevant.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
test/Fail/SplitOnIrrelevant.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
test/Fail/SplitOnIrrelevant.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
-- 2010-09-07 Andreas
-- 2011-10-04 may not work even in the presence of experimental irr.
{-# OPTIONS --experimental-irrelevance #-}
module SplitOnIrrelevant where
data Bool : Set where
true false : Bool
not : .Bool -> Bool
not true = false -- needs to fail
not false = true
| 23.416667
| 68
| 0.711744
|
58da8e2c7e084dd658e93be97dea28546118e275
| 173
|
agda
|
Agda
|
Cubical/HITs/Join.agda
|
kiana-S/univalent-foundations
|
8bdb0766260489f9c89a14f4c0f2ad26e5190dec
|
[
"MIT"
] | null | null | null |
Cubical/HITs/Join.agda
|
kiana-S/univalent-foundations
|
8bdb0766260489f9c89a14f4c0f2ad26e5190dec
|
[
"MIT"
] | 1
|
2022-01-27T02:07:48.000Z
|
2022-01-27T02:07:48.000Z
|
Cubical/HITs/Join.agda
|
kiana-S/univalent-foundations
|
8bdb0766260489f9c89a14f4c0f2ad26e5190dec
|
[
"MIT"
] | 1
|
2021-11-22T02:02:01.000Z
|
2021-11-22T02:02:01.000Z
|
{-# OPTIONS --cubical --no-import-sorts --safe #-}
module Cubical.HITs.Join where
open import Cubical.HITs.Join.Base public
open import Cubical.HITs.Join.Properties public
| 28.833333
| 50
| 0.768786
|
1e5f0c124dc78f53c35e72cf80abba7265f0f4fa
| 1,420
|
agda
|
Agda
|
test/Fail/Issue738.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
test/Fail/Issue738.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
test/Fail/Issue738.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
-- {-# OPTIONS -v tc.lhs.unify:100 #-}
-- Reported by project member adamgundry, 2012-10-26
-- I was trying to extend Conor's KIPLING technique (Outrageous but
-- Meaningful Coincidences, WGP 2010) which depends on indexing a
-- syntax by functions, when I hit this problem:
module Issue738 where
open import Common.Equality
data U : Set where
a : U
b : U
-- works, with explicit equality:
module Param where
data D (f : U → U) : Set where
da : (f ≡ λ x → a) → D f
db : (f ≡ λ x → b) → D f
app : ∀ {A B : Set}{f g : A → B} → f ≡ g → ∀ x → f x ≡ g x
app refl x = refl
fu : D (λ x → a) → Set
fu (da refl) = U
fu (db p) with app p a
... | ()
-- original formulation:
module Index where
data Foo : (U -> U) -> Set where
mka : Foo (\ x -> a)
mkb : Foo (\ x -> b)
foo : Foo (\ x -> a) -> Set
foo mka = ?
-- This gives the error message:
-- -- Cannot decide whether there should be a case for the constructor
-- -- mkb, since the unification gets stuck on unifying the inferred
-- -- indices
-- -- [λ x → b]
-- -- with the expected indices
-- -- [λ x → a]
-- -- when checking the definition of foo
-- But these indices cannot be unified (a and b are constants) so it
-- should be possible to exclude this case. Could we improve the
-- unifier to notice this?
-- Andreas, 2012-10-29 No, because if the domain type is empty,
-- these two lambdas cannot be disunified
| 24.067797
| 70
| 0.61831
|
cb97159919fc130035d110dfc633edeb9a812887
| 12,851
|
agda
|
Agda
|
04-cubical-type-theory/material/Part1.agda
|
tomdjong/EPIT-2020
|
54b18e4adf890b3533bbefda373912423be7f490
|
[
"MIT"
] | null | null | null |
04-cubical-type-theory/material/Part1.agda
|
tomdjong/EPIT-2020
|
54b18e4adf890b3533bbefda373912423be7f490
|
[
"MIT"
] | null | null | null |
04-cubical-type-theory/material/Part1.agda
|
tomdjong/EPIT-2020
|
54b18e4adf890b3533bbefda373912423be7f490
|
[
"MIT"
] | null | null | null |
{-
Part 1: The interval and path types
• The interval in Cubical Agda
• Path and PathP types
• Function extensionality
• Equality in Σ-types
-}
-- To make Agda cubical add the following options
{-# OPTIONS --cubical #-}
module Part1 where
-- To load an Agda file type "C-c C-l" in emacs (the notation "C-c"
-- means that one should hold "CTRL" and press "c", for general
-- documentation about emacs keybindings see:
-- https://www.gnu.org/software/emacs/manual/html_node/efaq/Basic-keys.html)
-- The "Core" package of the agda/cubical library sets things for us
open import Cubical.Core.Primitives public
-- The "Foundations" package of agda/cubical contains a lot of
-- important results (in particular the univalence theorem). As we
-- will develop many things from scratch we don't import it here, but
-- a typical file in the library would import the relevant files from
-- Foundations which it uses. To get everything in Foundations write:
--
-- open import Cubical.Foundations.Everything
-- To search for something among the imported files press C-s C-z and
-- then write what you want to search for.
-- Documentation of the Cubical Agda mode can be found at:
-- https://agda.readthedocs.io/en/v2.6.1.3/language/cubical.html
------------------------------------------------------------------------------
-- Agda Basic --
------------------------------------------------------------------------------
-- We parametrize everything by some universe levels (as opposed to
-- Coq we always have to give these explicitly unless we work with the
-- lowest universe)
variable
ℓ ℓ' ℓ'' : Level
-- Universes in Agda are called "Set", but in order to avoid confusion
-- with h-sets we rename them to "Type".
-- Functions in Agda are written using equations:
id : {A : Type ℓ} → A → A
id x = x
-- The {A : Type} notation says that A is an implicit argument of Type ℓ.
-- The notation (x : A) → B and {x : A} → B introduces a dependent
-- function (so B might mention B), in other words an element of a
-- Π-type.
-- We could also write this using a λ-abstraction:
id' : {A : Type ℓ} → A → A
id' = λ x → x
-- To input a nice symbol for the lambda write "\lambda". Agda support
-- Unicode symbols natively:
-- https://agda.readthedocs.io/en/latest/tools/emacs-mode.html#unicode-input
-- To input the "ℓ" write "\ell"
-- We can build Agda terms interactively in emacs by writing a ? as RHS:
--
-- id'' : {A : Type ℓ} → A → A
-- id'' = ?
--
-- Try uncommenting this and pressing "C-c C-l". This will give us a
-- hole and by entering it with the cursor we can get information
-- about what Agda expects us to provide and get help from Agda in
-- providing this.
--
-- By pressing "C-c C-," while having the cursor in the goal Agda
-- shows us the current context and goal. As we're trying to write a
-- function we can press "C-c C-r" (for refine) to have Agda write the
-- λ-abstraction "λ x → ?" automatically for us. If one presses "C-c C-,"
-- in the hole again "x : A" will now be in the context. If we type
-- "x" in the hole and press "C-c C-." Agda will show us that we have
-- an A, which is exactly what we want to provide to fill the goal. By
-- pressing "C-c C-SPACE" Agda will then fill the hole with "x" for us.
--
-- Agda has lots of handy commands like this for manipulating goals:
-- https://agda.readthedocs.io/en/latest/tools/emacs-mode.html#commands-in-context-of-a-goal
-- A good resource to get start with Agda is the documentation:
-- https://agda.readthedocs.io/en/latest/getting-started/index.html
------------------------------------------------------------------------------
-- The interval and path types --
------------------------------------------------------------------------------
-- The interval in Cubical Agda is written I and the endpoints are
--
-- i0 : I
-- i1 : I
--
-- These stand for "interval 0" and "interval 1".
-- We can apply a function out of the interval to an endpoint just
-- like we would apply any Agda function:
apply0 : (A : Type ℓ) (p : I → A) → A
apply0 A p = p i0
-- The equality type _≡_ is not inductively defined in Cubical Agda,
-- instead it's a builtin primitive. An element of x ≡ y consists of a
-- function p : I → A such that p i0 is definitionally x and p i1 is
-- definitionally y. The check that the endpoints are correct when we
-- provide a p : I → A is automatically checked by Agda during
-- typechecking, so introducing an element of x ≡ y is done just like
-- how we introduce elements of I → A but Agda will check the side
-- conditions.
--
-- So we can write paths using λ-abstraction:
path1 : {A : Type ℓ} (x : A) → x ≡ x
path1 x = λ i → x
--
-- As explained above Agda checks that whatever we write as definition
-- matches the path that we have written (so the endpoints have to be
-- correct). In this case everything is fine and path1 can be thought
-- of as a proof reflexivity. Let's give it a nicer name and more
-- implicit arguments:
--
refl : {A : Type ℓ} {x : A} → x ≡ x
refl {x = x} = λ i → x
--
-- The notation {x = x} lets us access the implicit argument x (the x
-- in the LHS) and rename it to x (the x in the RHS) in the body of refl.
-- We could just as well have written:
--
-- refl : {A : Type ℓ} {x : A} → x ≡ x
-- refl {x = y} = λ i → y
-- Note that we cannot pattern-match on interval variables as I is not
-- inductively defined:
--
-- foo : {A : Type} → I → A
-- foo r = {!r!} -- Try typing C-c C-c
-- It often gets tiring to write {A : Type ℓ} everywhere, so let's
-- assume that we have some types:
variable
A B : Type ℓ
-- This will make A and B elements of different universes (all
-- arguments is maximally generalized) and all definitions that use
-- them will have them as implicit arguments.
-- We can now implement some basic operations on _≡_. Let's start with
-- cong (called "ap" in the HoTT book):
cong : (f : A → B) {x y : A} → x ≡ y → f x ≡ f y
cong f p i = f (p i)
-- Note that the definition differs from the HoTT definition in that
-- it is not defined by J or pattern-matching on p, but rather it's
-- just a direct definition as a composition fo functions. Agda treats
-- p : x ≡ y as a function, so we can just apply it to i to get an
-- element of A which at i0 is x and at i1 is y. By applying f to this
-- element we hence get an element of B which at i0 is f x and at i1
-- is f y.
-- As this is just function composition it satisfies lots of nice
-- definitional equalities, see the Warmup.agda file. Some of these
-- are not satisfied by the HoTT definition of cong/ap.
-- In HoTT function extensionality is proved as a consequence of
-- univalence using a rather ingenious proof due to Voevodsky, but in
-- cubical systems it has a much more direct proof. As paths are just
-- functions we can get it by just swapping the arguments to p:
funExt : {f g : A → B} (p : (x : A) → f x ≡ g x) → f ≡ g
funExt p i x = p x i
-- To see that this has the correct type not that when i is i0 we have
-- "p x i0 = f x" and when i is i1 we have "p x i1 = g x", so by η for
-- functions we have a path f ≡ g as desired.
-- The interval has additional operations:
--
-- Minimum: _∧_ : I → I → I
-- Maximum: _∨_ : I → I → I
-- Symmetry: ~_ : I → I
-- These satisfy the equations of a De Morgan algebra (i.e. a
-- distributive lattice (_∧_ , _∨_ , i0 , i1) with an involution
-- ~). So we have the following kinds of equations definitionally:
--
-- i0 ∨ i = i
-- i ∨ i1 = i1
-- i ∨ j = j ∨ i
-- i0 ∧ i = i0
-- i1 ∧ i = i
-- i ∧ j = j ∧ i
-- ~ (~ i) = i
-- i0 = ~ i1
-- ~ (i ∨ j) = ~ i ∧ ~ j
-- ~ (i ∧ j) = ~ i ∨ ~ j
-- These operations are very useful as they let us define even more
-- things directly. For example symmetry of paths is easily defined
-- using ~:
sym : {x y : A} → x ≡ y → y ≡ x
sym p i = p (~ i)
-- The operations _∧_ and _∨_ are called "connections" and lets us
-- build higher dimensional cubes from lower dimensional ones, for
-- example if we have a path p : x ≡ y then
--
-- sq i j = p (i ∧ j)
--
-- is a square (as we've parametrized by i and j) with the following
-- boundary:
--
-- sq i0 j = p (i0 ∧ j) = p i0 = x
-- sq i1 j = p (i1 ∧ j) = p j
-- sq i i0 = p (i ∧ i0) = p i0 = x
-- sq i i1 = p (i ∧ i1) = p i
--
-- So if we draw this we get:
--
-- p
-- x --------> y
-- ^ ^
-- ¦ ¦
-- refl ¦ sq ¦ p
-- ¦ ¦
-- ¦ ¦
-- x --------> x
-- refl
--
-- These operations are very useful, for example let's prove that
-- singletons are contractible (aka based path induction).
--
-- We first need the notion of contractible types. For this we need
-- to use a Σ-type:
isContr : Type ℓ → Type ℓ
isContr A = Σ[ x ∈ A ] ((y : A) → x ≡ y)
-- Σ-types are introduced in the file Agda.Builtin.Sigma as the record
-- (modulo some renaming):
--
-- record Σ {ℓ ℓ'} (A : Type ℓ) (B : A → Type ℓ') : Type (ℓ-max ℓ ℓ') where
-- constructor _,_
-- field
-- fst : A
-- snd : B fst
--
-- So the projections are fst/snd and the constructor is _,_. We
-- also define non-dependent product as a special case of Σ-types in
-- Cubical.Data.Sigma.Base as:
--
-- _×_ : ∀ {ℓ ℓ'} (A : Type ℓ) (B : Type ℓ') → Type (ℓ-max ℓ ℓ')
-- A × B = Σ A (λ _ → B)
--
-- The notation ∀ {ℓ ℓ'} lets us omit the type of ℓ and ℓ' in the
-- definition.
-- We define the type of singletons as follows
singl : {A : Type ℓ} (a : A) → Type ℓ
singl {A = A} a = Σ[ x ∈ A ] a ≡ x
-- To show that this type is contractible we need to provide a center
-- of contraction and the fact that any element of it is path-equal to
-- the center
isContrSingl : (x : A) → isContr (singl x)
isContrSingl x = ctr , prf
where
-- The center is just a pair with x and refl
ctr : singl x
ctr = x , refl
-- We then need to prove that ctr is equal to any element s : singl x.
-- This is an equality in a Σ-type, so the first component is a path
-- and the second is a path over the path we pick as first argument,
-- so the second component is a square. In fact, we need a square
-- relating refl and pax, so we can use an _∧_ connection.
prf : (s : singl x) → ctr ≡ s
prf (y , pax) i = (pax i) , λ j → pax (i ∧ j)
-- As we saw in the second component of prf we often need squares when
-- proving things. In fact, pax (i ∧ j) is a path relating refl to pax
-- *over* another path "λ j → x ≡ pax j". This notion of path over a
-- path is very useful when working in HoTT as well as cubically. In
-- HoTT these are called path-overs and are defined using transport,
-- but in Cubical Agda they are a primitive notion called PathP ("Path
-- of a Path"). In general PathP A x y has
--
-- A : I → Type ℓ
-- x : A i0
-- y : A i1
--
-- So PathP lets us natively define heteorgeneous paths, i.e. paths
-- where the endpoints lie in different types. This lets us specify
-- the type of the second component of prf:
prf' : (x : A) (s : singl x) → (x , refl) ≡ s
prf' x (y , pax) i = (pax i) , λ j → goal i j
where
goal : PathP (λ j → x ≡ pax j) refl pax
goal i j = pax (i ∧ j)
-- Just like _×_ is a special case of Σ-types we have that _≡_ is a
-- special case of PathP. In fact, x ≡ y is just short for PathP (λ _ → A) x y:
reflP : {x : A} → PathP (λ _ → A) x x
reflP {x = x} = λ _ → x
-- Having the primitive notion of equality be heterogeneous is an
-- easily overlooked, but very important, strength of cubical type
-- theory. This allows us to work directly with equality in Σ-types
-- without using transport:
module _ {A : Type ℓ} {B : A → Type ℓ'} {x y : Σ A B} where
ΣPathP : Σ[ p ∈ fst x ≡ fst y ] PathP (λ i → B (p i)) (snd x) (snd y)
→ x ≡ y
ΣPathP eq i = fst eq i , snd eq i
PathPΣ : x ≡ y
→ Σ[ p ∈ fst x ≡ fst y ] PathP (λ i → B (p i)) (snd x) (snd y)
PathPΣ eq = (λ i → fst (eq i)) , (λ i → snd (eq i))
-- The fact that these cancel is proved by refl
-- If one looks carefully the proof of prf uses ΣPathP inlined, in
-- fact this is used all over the place when working cubically and
-- simplifies many proofs which in HoTT requires long complicated
-- reasoning about transport.
isContrΠ : {B : A → Type ℓ'} (h : (x : A) → isContr (B x))
→ isContr ((x : A) → B x)
isContrΠ h = (λ x → fst (h x)) , (λ f i x → snd (h x) (f x) i)
-- Let us end this session with defining propositions and sets
isProp : Type ℓ → Type ℓ
isProp A = (x y : A) → x ≡ y
isSet : Type ℓ → Type ℓ
isSet A = (x y : A) → isProp (x ≡ y)
-- In the agda/cubical library we call these h-levels following
-- Voevodsky instead of n-types and index by natural numbers instead
-- of ℕ₋₂. So isContr is h-level 0, isProp is h-level 1, isSet is
-- h-level 2, etc. For details see Cubical/Foundations/HLevels.agda
| 35.997199
| 92
| 0.62571
|
1d025dabede913ffacb172151beda179d6c3bc05
| 20,699
|
agda
|
Agda
|
src/lc/LC.agda
|
kcaliban/ldlc
|
a87fb6402639c3d2bb393cc5466426c28e7a0398
|
[
"BSD-3-Clause"
] | null | null | null |
src/lc/LC.agda
|
kcaliban/ldlc
|
a87fb6402639c3d2bb393cc5466426c28e7a0398
|
[
"BSD-3-Clause"
] | null | null | null |
src/lc/LC.agda
|
kcaliban/ldlc
|
a87fb6402639c3d2bb393cc5466426c28e7a0398
|
[
"BSD-3-Clause"
] | 1
|
2019-03-14T17:52:29.000Z
|
2019-03-14T17:52:29.000Z
|
-- simply-typed λ-calculus w/ DeBruijn indices
module LC where
open import Agda.Primitive
open import Agda.Builtin.Bool
open import Data.Bool.Properties hiding (≤-trans ; <-trans ; ≤-refl ; <-irrefl)
open import Data.Empty
open import Data.Nat renaming (_+_ to _+ᴺ_ ; _≤_ to _≤ᴺ_ ; _≥_ to _≥ᴺ_ ; _<_ to _<ᴺ_ ; _>_ to _>ᴺ_)
open import Data.Nat.Properties renaming (_<?_ to _<ᴺ?_)
open import Data.Integer renaming (_+_ to _+ᶻ_ ; _≤_ to _≤ᶻ_ ; _≥_ to _≥ᶻ_ ; _<_ to _<ᶻ_ ; _>_ to _>ᶻ_)
open import Data.Integer.Properties using (⊖-≥ ; 0≤n⇒+∣n∣≡n ; +-monoˡ-≤)
open import Data.List
open import Data.List.Relation.Unary.All
open import Relation.Binary.PropositionalEquality
open import Relation.Nullary
open import Relation.Nullary.Decidable
open import Relation.Nullary.Negation
open import Auxiliary
module defs where
data Exp : Set where
Var : ℕ → Exp
Abs : Exp → Exp
App : Exp → Exp → Exp
data Ty : Set where
Fun : Ty → Ty → Ty
-- typing
Env = List Ty
data _∶_∈_ : ℕ → Ty → Env → Set where
here : {T : Ty} {Γ : Env} → 0 ∶ T ∈ (T ∷ Γ)
there : {n : ℕ} {T₁ T₂ : Ty} {Γ : Env} → n ∶ T₁ ∈ Γ → (ℕ.suc n) ∶ T₁ ∈ (T₂ ∷ Γ)
data _⊢_∶_ : Env → Exp → Ty → Set where
TVar : {n : ℕ} {Γ : Env} {T : Ty} → n ∶ T ∈ Γ → Γ ⊢ (Var n) ∶ T
TAbs : {Γ : Env} {T₁ T₂ : Ty} {e : Exp} → (T₁ ∷ Γ) ⊢ e ∶ T₂ → Γ ⊢ (Abs e) ∶ (Fun T₁ T₂)
TApp : {Γ : Env} {T₁ T₂ : Ty} {e₁ e₂ : Exp} → Γ ⊢ e₁ ∶ (Fun T₁ T₂) → Γ ⊢ e₂ ∶ T₁ → Γ ⊢ (App e₁ e₂) ∶ T₂
-- denotational semantics
module denotational where
open defs
Valᵈ : Ty → Set
Valᵈ (Fun Ty₁ Ty₂) = (Valᵈ Ty₁) → (Valᵈ Ty₂)
access : {n : ℕ} {Γ : Env} {T : Ty} → n ∶ T ∈ Γ → All Valᵈ Γ → Valᵈ T
access here (V ∷ Γ) = V
access (there J) (V ∷ Γ) = access J Γ
eval : {Γ : Env} {T : Ty} {e : Exp} → Γ ⊢ e ∶ T → All Valᵈ Γ → Valᵈ T
eval (TVar c) Val-Γ = access c Val-Γ
eval (TAbs TJ) Val-Γ = λ V → eval TJ (V ∷ Val-Γ)
eval (TApp TJ TJ₁) Val-Γ = (eval TJ Val-Γ) (eval TJ₁ Val-Γ)
-- operational semantics (call-by-value)
module operational where
open defs
-- shifting, required to avoid variable-capturing in substitution
-- see Pierce 2002, pg. 78/79
↑_,_[_] : ℤ → ℕ → Exp → Exp
↑ d , c [ Var x ]
with (x <ᴺ? c)
... | yes p = Var x
... | no ¬p = Var (∣ (ℤ.pos x) +ᶻ d ∣) -- should always be positive anyway
↑ d , c [ Abs t ] = Abs (↑ d , (ℕ.suc c) [ t ])
↑ d , c [ App t t₁ ] = App (↑ d , c [ t ]) (↑ d , c [ t₁ ])
-- shifting in range [n, m]; by def. m < n implies no shift
↑[_,_]_[_] : ℕ → ℕ → ℤ → Exp → Exp
↑[ n , m ] d [ Var x ]
with (x <ᴺ? n)
... | yes p = Var x
... | no ¬p
with (m <ᴺ? x)
... | yes p' = Var x
... | no ¬p' = Var (∣ (ℤ.pos x) +ᶻ d ∣)
↑[ n , m ] d [ Abs e ] = Abs (↑[ ℕ.suc n , ℕ.suc m ] d [ e ])
↑[ n , m ] d [ App e e₁ ] = App (↑[ n , m ] d [ e ]) (↑[ n , m ] d [ e₁ ])
-- shorthands
↑¹[_] : Exp → Exp
↑¹[ e ] = ↑ (ℤ.pos 1) , 0 [ e ]
↑⁻¹[_] : Exp → Exp
↑⁻¹[ e ] = ↑ (ℤ.negsuc 0) , 0 [ e ]
-- substitution
-- see Pierce 2002, pg. 80
[_↦_]_ : ℕ → Exp → Exp → Exp
[ k ↦ s ] Var x
with (Data.Nat._≟_ x k)
... | yes p = s
... | no ¬p = Var x
[ k ↦ s ] Abs t = Abs ([ ℕ.suc k ↦ ↑¹[ s ] ] t)
[ k ↦ s ] App t t₁ = App ([ k ↦ s ] t) ([ k ↦ s ] t₁)
data Val : Exp → Set where
VFun : {e : Exp} → Val (Abs e)
-- reduction relation
data _⇒_ : Exp → Exp → Set where
ξ-App1 : {e₁ e₁' e₂ : Exp} → e₁ ⇒ e₁' → App e₁ e₂ ⇒ App e₁' e₂
ξ-App2 : {e e' v : Exp} → Val v → e ⇒ e' → App v e ⇒ App v e'
β-App : {e v : Exp} → Val v → (App (Abs e) v) ⇒ (↑⁻¹[ ([ 0 ↦ ↑¹[ v ] ] e) ])
---- properties & lemmas
--- properties of shifting
↑-var-refl : {d : ℤ} {c : ℕ} {x : ℕ} {le : ℕ.suc x ≤ᴺ c} → ↑ d , c [ Var x ] ≡ Var x
↑-var-refl {d} {c} {x} {le}
with (x <ᴺ? c)
... | no ¬p = contradiction le ¬p
... | yes p = refl
↑[]-var-refl-< : {n m x : ℕ} {d : ℤ} {le : x <ᴺ n} → ↑[ n , m ] d [ Var x ] ≡ Var x
↑[]-var-refl-< {n} {m} {x} {d} {le}
with (x <ᴺ? n)
... | yes p = refl
... | no ¬p = contradiction le ¬p
↑[]-var-refl-> : {n m x : ℕ} {d : ℤ} {le : m <ᴺ x} → ↑[ n , m ] d [ Var x ] ≡ Var x
↑[]-var-refl-> {n} {m} {x} {d} {le}
with (x <ᴺ? n)
... | yes p = refl
... | no p
with (m <ᴺ? x)
... | no ¬q = contradiction le ¬q
... | yes q = refl
↑[]-var-shift : {n m x : ℕ} {d : ℤ} (le1 : n ≤ᴺ x) (le2 : x ≤ᴺ m) → ↑[ n , m ] d [ Var x ] ≡ Var (∣ (ℤ.pos x) +ᶻ d ∣)
↑[]-var-shift {n} {m} {x} {d} le1 le2
with x <ᴺ? n
... | yes p = contradiction p (<⇒≱ (s≤s le1))
... | no ¬p
with m <ᴺ? x
... | yes p' = contradiction p' (<⇒≱ (s≤s le2))
... | no ¬p' = refl
↑¹-var : {x : ℕ} → ↑¹[ Var x ] ≡ Var (ℕ.suc x)
↑¹-var {zero} = refl
↑¹-var {ℕ.suc x}
rewrite (sym (n+1≡sucn{x +ᴺ 1}))
| (sym (n+1≡sucn{x}))
= cong ↑¹[_] (↑¹-var{x})
↑⁻¹ₖ[↑¹ₖ[s]]≡s : {e : Exp} {k : ℕ} → ↑ -[1+ 0 ] , k [ ↑ + 1 , k [ e ] ] ≡ e
↑⁻¹ₖ[↑¹ₖ[s]]≡s {Var x} {k}
with (x <ᴺ? k)
-- x < k
-- => ↑⁻¹ₖ(↑¹ₖ(Var n)) = ↑⁻¹ₖ(Var n) = Var n
... | yes p = ↑-var-refl{ -[1+ 0 ]}{k}{x}{p}
-- x ≥ k
-- => ↑⁻¹ₖ(↑¹ₖ(Var n)) = ↑⁻¹ₖ(Var |n + 1|) = Var (||n + 1| - 1|) = Var n
... | no ¬p
with (¬[x≤k]⇒¬[sucx≤k] ¬p)
... | ¬p'
with (x +ᴺ 1) <ᴺ? k
... | yes pp = contradiction pp ¬p'
... | no ¬pp
rewrite (∣nℕ+1⊖1∣≡n{x})
= refl
↑⁻¹ₖ[↑¹ₖ[s]]≡s {Abs e} {k} = cong Abs ↑⁻¹ₖ[↑¹ₖ[s]]≡s
↑⁻¹ₖ[↑¹ₖ[s]]≡s {App e e₁} = cong₂ App ↑⁻¹ₖ[↑¹ₖ[s]]≡s ↑⁻¹ₖ[↑¹ₖ[s]]≡s
↑ᵏ[↑ˡ[s]]≡↑ᵏ⁺ˡ[s] : {k l : ℤ} {c : ℕ} {s : Exp} → l ≥ᶻ +0 → ↑ k , c [ ↑ l , c [ s ] ] ≡ ↑ (l +ᶻ k) , c [ s ]
↑ᵏ[↑ˡ[s]]≡↑ᵏ⁺ˡ[s] {k} {l} {c} {Var x} ge
with x <ᴺ? c
↑ᵏ[↑ˡ[s]]≡↑ᵏ⁺ˡ[s] {k} {l} {c} {Var x} ge | no ¬p
with ∣ + x +ᶻ l ∣ <ᴺ? c
... | yes q = contradiction q (<⇒≱ (n≤m⇒n<sucm (≤-trans (≮⇒≥ ¬p) (m≥0⇒∣n+m∣≥n ge))))
... | no ¬q
rewrite (0≤n⇒+∣n∣≡n{+ x +ᶻ l} (m≥0⇒n+m≥0 ge))
| (Data.Integer.Properties.+-assoc (+_ x) l k)
= refl
↑ᵏ[↑ˡ[s]]≡↑ᵏ⁺ˡ[s] {k} {l} {c} {Var x} ge | yes p
with x <ᴺ? c
... | yes p' = refl
... | no ¬p' = contradiction p ¬p'
↑ᵏ[↑ˡ[s]]≡↑ᵏ⁺ˡ[s] {k} {l} {c} {Abs s} le = cong Abs (↑ᵏ[↑ˡ[s]]≡↑ᵏ⁺ˡ[s]{k}{l}{ℕ.suc c}{s} le)
↑ᵏ[↑ˡ[s]]≡↑ᵏ⁺ˡ[s] {k} {l} {c} {App s s₁} le = cong₂ App (↑ᵏ[↑ˡ[s]]≡↑ᵏ⁺ˡ[s]{k}{l}{c}{s} le) (↑ᵏ[↑ˡ[s]]≡↑ᵏ⁺ˡ[s]{k}{l}{c}{s₁} le)
↑k,q[↑l,c[s]]≡↑l+k,c[s] : {k l : ℤ} {q c : ℕ} {s : Exp} → + q ≤ᶻ + c +ᶻ l → c ≤ᴺ q → ↑ k , q [ ↑ l , c [ s ] ] ≡ ↑ (l +ᶻ k) , c [ s ]
↑k,q[↑l,c[s]]≡↑l+k,c[s] {k} {l} {q} {c} {Var x} ge₁ ge₂
with x <ᴺ? c
... | yes p
with x <ᴺ? q
... | yes p' = refl
... | no ¬p' = contradiction (≤-trans p ge₂) ¬p'
↑k,q[↑l,c[s]]≡↑l+k,c[s] {k} {l} {q} {c} {Var x} ge₁ ge₂
| no ¬p
with ∣ + x +ᶻ l ∣ <ᴺ? q
... | yes p' = contradiction p' (≤⇒≯ (+a≤b⇒a≤∣b∣{q}{+ x +ᶻ l} (Data.Integer.Properties.≤-trans ge₁ ((Data.Integer.Properties.+-monoˡ-≤ l (+≤+ (≮⇒≥ ¬p)))))))
... | no ¬p'
rewrite (0≤n⇒+∣n∣≡n{+ x +ᶻ l} (Data.Integer.Properties.≤-trans (+≤+ z≤n) ((Data.Integer.Properties.≤-trans ge₁ ((Data.Integer.Properties.+-monoˡ-≤ l (+≤+ (≮⇒≥ ¬p))))))))
| (Data.Integer.Properties.+-assoc (+_ x) l k)
= refl
↑k,q[↑l,c[s]]≡↑l+k,c[s] {k} {l} {q} {c} {Abs s} ge₁ ge₂ = cong Abs (↑k,q[↑l,c[s]]≡↑l+k,c[s] {k} {l} {ℕ.suc q} {ℕ.suc c} {s} (+q≤+c+l⇒+1q≤+1c+l{q}{c}{l} ge₁) (s≤s ge₂))
↑k,q[↑l,c[s]]≡↑l+k,c[s] {k} {l} {q} {c} {App s s₁} ge₁ ge₂ = cong₂ App (↑k,q[↑l,c[s]]≡↑l+k,c[s] {k} {l} {q} {c} {s} ge₁ ge₂) (↑k,q[↑l,c[s]]≡↑l+k,c[s] {k} {l} {q} {c} {s₁} ge₁ ge₂)
--- properties of substitution
subst-trivial : {x : ℕ} {s : Exp} → [ x ↦ s ] Var x ≡ s
subst-trivial {x} {s}
with x Data.Nat.≟ x
... | no ¬p = contradiction refl ¬p
... | yes p = refl
var-subst-refl : {n m : ℕ} {neq : n ≢ m} {e : Exp} → [ n ↦ e ] (Var m) ≡ (Var m)
var-subst-refl {n} {m} {neq} {e}
with Data.Nat._≟_ n m
| map′ (≡ᵇ⇒≡ m n) (≡⇒≡ᵇ m n) (Data.Bool.Properties.T? (m ≡ᵇ n))
... | yes p | _ = contradiction p neq
... | no ¬p | yes q = contradiction q (≢-sym ¬p)
... | no ¬p | no ¬q = refl
--- properties and manipulation of environments
var-env-< : {Γ : Env} {T : Ty} {n : ℕ} (j : n ∶ T ∈ Γ) → n <ᴺ (length Γ)
var-env-< {.(T ∷ _)} {T} {.0} here = s≤s z≤n
var-env-< {.(_ ∷ _)} {T} {.(ℕ.suc _)} (there j) = s≤s (var-env-< j)
-- type to determine whether var type judgement in env. (Δ ++ Γ) is in Δ or Γ
data extract-env-or {Δ Γ : Env} {T : Ty} {x : ℕ} : Set where
in-Δ : x ∶ T ∈ Δ → extract-env-or
-- x ≥ length Δ makes sure that x really is in Γ; e.g.
-- x = 1, Δ = (S ∷ T), Γ = (T ∷ Γ'); here 1 ∶ T ∈ Δ as well as (1 ∸ 2) ≡ 0 ∶ T ∈ Γ
in-Γ : (x ≥ᴺ length Δ) → (x ∸ length Δ) ∶ T ∈ Γ → extract-env-or
extract : {Δ Γ : Env} {T : Ty} {x : ℕ} (j : x ∶ T ∈ (Δ ++ Γ)) → extract-env-or{Δ}{Γ}{T}{x}
extract {[]} {Γ} {T} {x} j = in-Γ z≤n j
extract {x₁ ∷ Δ} {Γ} {.x₁} {.0} here = in-Δ here
extract {x₁ ∷ Δ} {Γ} {T} {ℕ.suc x} (there j)
with extract {Δ} {Γ} {T} {x} j
... | in-Δ j' = in-Δ (there j')
... | in-Γ ge j'' = in-Γ (s≤s ge) j''
ext-behind : {Δ Γ : Env} {T : Ty} {x : ℕ} → x ∶ T ∈ Δ → x ∶ T ∈ (Δ ++ Γ)
ext-behind here = here
ext-behind (there j) = there (ext-behind j)
ext-front : {n : ℕ} {Γ Δ : Env} {S : Ty} → n ∶ S ∈ Γ → (n +ᴺ (length Δ)) ∶ S ∈ (Δ ++ Γ)
ext-front {n} {Γ} {[]} {S} j
rewrite (n+length[]≡n{A = Ty}{n = n})
= j
ext-front {n} {Γ} {T ∷ Δ} {S} j
rewrite (+-suc n (foldr (λ _ → ℕ.suc) 0 Δ))
= there (ext-front j)
swap-env-behind : {Γ Δ : Env} {T : Ty} → 0 ∶ T ∈ (T ∷ Γ) → 0 ∶ T ∈ (T ∷ Δ)
swap-env-behind {Γ} {Δ} {T} j = here
swap-type : {Δ ∇ Γ : Env} {T : Ty} → (length Δ) ∶ T ∈ (Δ ++ T ∷ ∇ ++ Γ) → (length Δ +ᴺ length ∇) ∶ T ∈ (Δ ++ ∇ ++ T ∷ Γ)
swap-type {Δ} {∇} {Γ} {T} j
with extract{Δ}{T ∷ ∇ ++ Γ} j
... | in-Δ x = contradiction (var-env-< {Δ} {T} x) (<-irrefl refl)
... | in-Γ le j'
with extract{T ∷ ∇}{Γ} j'
... | in-Δ j''
rewrite (n∸n≡0 (length Δ))
| (sym (length[A++B]≡length[A]+length[B]{lzero}{Ty}{Δ}{∇}))
| (sym (++-assoc{lzero}{Ty}{Δ}{∇}{T ∷ Γ}))
= ext-front{0}{T ∷ Γ}{Δ ++ ∇}{T} (swap-env-behind{∇}{Γ}{T} j'')
... | in-Γ le' j''
rewrite (length[A∷B]≡suc[length[B]]{lzero}{Ty}{T}{∇})
| (n∸n≡0 (length Δ))
= contradiction le' (<⇒≱ (s≤s z≤n))
env-pred : {Γ : Env} {S T : Ty} {y : ℕ} {gt : y ≢ 0} → y ∶ T ∈ (S ∷ Γ) → ∣ y ⊖ 1 ∣ ∶ T ∈ Γ
env-pred {Γ} {S} {.S} {.0} {gt} here = contradiction refl gt
env-pred {Γ} {S} {T} {.(ℕ.suc _)} {gt} (there j) = j
env-type-equiv-here : {Γ : Env} {S T : Ty} → 0 ∶ T ∈ (S ∷ Γ) → T ≡ S
env-type-equiv-here {Γ} {S} {.S} here = refl
env-type-equiv : {Δ ∇ : Env} {S T : Ty} → length Δ ∶ T ∈ (Δ ++ S ∷ ∇) → T ≡ S
env-type-equiv {Δ} {∇} {S} {T} j
with extract{Δ}{S ∷ ∇} j
... | in-Δ x = contradiction (var-env-< x) (≤⇒≯ ≤-refl)
... | in-Γ x j'
rewrite (n∸n≡0 (length Δ))
= env-type-equiv-here {∇} {S} {T} j'
env-type-equiv-j : {Γ : Env} {S T : Ty} {n : ℕ} → T ≡ S → n ∶ T ∈ Γ → n ∶ S ∈ Γ
env-type-equiv-j {Γ} {S} {T} {n} eq j
rewrite eq
= j
-- extension of environment
ext : {Γ Δ ∇ : Env} {S : Ty} {s : Exp} → (∇ ++ Γ) ⊢ s ∶ S → (∇ ++ Δ ++ Γ) ⊢ ↑ (ℤ.pos (length Δ)) , length ∇ [ s ] ∶ S
ext {Γ} {Δ} {∇} (TVar {n} x)
with extract{∇}{Γ} x
... | in-Δ x₁
with n <ᴺ? length ∇
... | yes p = TVar (ext-behind x₁)
... | no ¬p = contradiction (var-env-< x₁) ¬p
ext {Γ} {Δ} {∇} (TVar {n} x)
| in-Γ x₁ x₂
with n <ᴺ? length ∇
... | yes p = contradiction x₁ (<⇒≱ p)
... | no ¬p
with (ext-front{n ∸ length ∇}{Γ}{∇ ++ Δ} x₂)
... | w
rewrite (length[A++B]≡length[A]+length[B]{lzero}{Ty}{∇}{Δ})
| (sym (+-assoc (n ∸ length ∇) (length ∇) (length Δ)))
| (m∸n+n≡m{n}{length ∇} (≮⇒≥ ¬p))
| (++-assoc{lzero}{Ty}{∇}{Δ}{Γ})
= TVar w
ext {Γ} {Δ} {∇} {Fun T₁ T₂} {Abs e} (TAbs j) = TAbs (ext{Γ}{Δ}{T₁ ∷ ∇} j)
ext {Γ} {Δ} {∇} {S} {App s₁ s₂} (TApp{T₁ = T₁} j₁ j₂) = TApp (ext{Γ}{Δ}{∇}{Fun T₁ S} j₁) (ext{Γ}{Δ}{∇}{T₁} j₂)
---- progress and preservation
-- progress theorem, i.e. a well-typed closed expression is either a value
-- or can be reduced further
data Progress (e : Exp) {T : Ty} {j : [] ⊢ e ∶ T} : Set where
step : {e' : Exp} → e ⇒ e' → Progress e
value : Val e → Progress e
progress : (e : Exp) {T : Ty} {j : [] ⊢ e ∶ T} → Progress e {T} {j}
progress (Var x) {T} {TVar ()}
progress (Abs e) = value VFun
progress (App e e₁) {T} {TApp{T₁ = T₁}{T₂ = .T} j j₁} with progress e {Fun T₁ T} {j}
... | step x = step (ξ-App1 x)
... | value VFun with progress e₁ {T₁} {j₁}
... | step x₁ = step (ξ-App2 VFun x₁)
... | value x₁ = step (β-App x₁)
---
-- preservation under substitution
preserve-subst : {T S : Ty} {Γ Δ : Env} {e s : Exp} (j : (Δ ++ (S ∷ Γ)) ⊢ e ∶ T) (j' : Γ ⊢ s ∶ S) → (Δ ++ Γ) ⊢ ↑ -[1+ 0 ] , length Δ [ [ length Δ ↦ ↑ (ℤ.pos (ℕ.suc (length Δ))) , 0 [ s ] ] e ] ∶ T
preserve-subst {T} {S} {Γ} {Δ} {e} {s} (TVar{n} x) j'
with extract{Δ}{S ∷ Γ}{T}{n} x
... | in-Δ x₁
with n Data.Nat.≟ length Δ
... | yes p = contradiction p (<⇒≢ (var-env-< x₁))
... | no ¬p
with n <ᴺ? length Δ
... | yes q = TVar (ext-behind{Δ}{Γ} x₁)
... | no ¬q = contradiction (var-env-< x₁) ¬q
preserve-subst {T} {S} {Γ} {Δ} {e} {s} (TVar{n} x) j'
| in-Γ x₁ x₂
with n Data.Nat.≟ length Δ
... | yes p
rewrite (↑k,q[↑l,c[s]]≡↑l+k,c[s]{ -[1+ 0 ]}{+[1+ length Δ ]}{length Δ}{0}{s} (+≤+ n≤sucn) z≤n)
| p
| (env-type-equiv x)
= ext{Γ}{Δ}{[]} j'
... | no ¬p
with n <ᴺ? length Δ
... | yes q = contradiction x₁ (<⇒≱ q)
... | no ¬q rewrite (sym (minus-1{n}{length Δ}{≤∧≢⇒< x₁ (≢-sym ¬p)}))
= TVar (ext-front{Δ = Δ} (env-pred{Γ}{S}{T}{gt = ≢-sym (<⇒≢ (m>n⇒m∸n≥1 (≤∧≢⇒< x₁ (≢-sym ¬p))))} x₂))
preserve-subst {T} {S} {Γ} {Δ} {Abs e'} {s} (TAbs{T₁ = T₁}{T₂} j) j'
with preserve-subst{T₂}{S}{Γ}{T₁ ∷ Δ}{e'}{s} j j'
... | w
rewrite (↑ᵏ[↑ˡ[s]]≡↑ᵏ⁺ˡ[s]{+ 1}{+[1+ length Δ ]}{0}{s} (+≤+ z≤n))
| (length[A∷B]≡suc[length[B]]{lzero}{Ty}{T₁}{Δ})
| (n+1≡sucn{length Δ})
= TAbs w
preserve-subst (TApp j j₁) j' = TApp (preserve-subst j j') (preserve-subst j₁ j')
-- preservation theorem, i.e. a well-typed expression reduces to a well-typed expression
preserve : {T : Ty} {Γ : Env} (e e' : Exp) (j : Γ ⊢ e ∶ T) (r : e ⇒ e') → Γ ⊢ e' ∶ T
preserve (App s₁ s₂) .(App _ s₂) (TApp j j') (ξ-App1{e₁' = s₁'} r) = TApp (preserve s₁ s₁' j r) j' -- IH on inner reduction
preserve (App s₁ s₂) .(App s₁ _) (TApp j j') (ξ-App2{e' = s₂'} x r) = TApp j (preserve s₂ s₂' j' r)
preserve (App (Abs e) s') .(↑⁻¹[ [ 0 ↦ ↑¹[ s' ] ] e ]) (TApp (TAbs j) j') (β-App x) = preserve-subst{Δ = []} j j'
-----------------------------------------------------------------------------------------------------------
-- swap-subst lemma: swap the position of a type in an environment (did not need this after all)
-- aux. calculations
length-≡ : {Δ ∇ Γ : Env} {S : Ty} → ℕ.suc (length Δ +ᴺ (length Γ +ᴺ length ∇)) ≡ length (Δ ++ S ∷ ∇ ++ Γ)
length-≡ {Δ} {∇} {Γ} {S}
rewrite (length[A++B]≡length[A]+length[B]{lzero}{Ty}{Δ}{S ∷ ∇ ++ Γ})
| (length[A++B]≡length[A]+length[B]{lzero}{Ty}{∇}{Γ})
| (+-suc (length Δ) (length ∇ +ᴺ length Γ))
| (+-comm (length ∇) (length Γ))
= refl
length-≡' : {Δ ∇ : Env} {S : Ty} → length (Δ ++ ∇ ++ S ∷ []) ≡ length Δ +ᴺ ℕ.suc (length ∇)
length-≡' {Δ} {∇} {S}
rewrite (length[A++B]≡length[A]+length[B]{lzero}{Ty}{Δ}{∇ ++ S ∷ []})
| (length[A++B]≡length[A]+length[B]{lzero}{Ty}{∇}{S ∷ []})
| (+-suc (length ∇) (0))
| (+-identityʳ (length ∇))
= refl
length-≡'' : {Δ ∇ : Env} {S : Ty} → length (Δ ++ ∇ ++ S ∷ []) ≡ ℕ.suc (length ∇ +ᴺ length Δ)
length-≡'' {Δ} {∇} {S}
rewrite (cong (ℕ.suc) (+-comm (length ∇) (length Δ)))
| (sym (+-suc (length Δ) (length ∇)))
= length-≡'{Δ}{∇}{S}
--- why the "r"? we have to "remember" where S was
--- cannot substitute its position for zero, since ↑ would increase that
--- cannot do ↑ and then subtitute its position for zero, since (position - 1) would be affected aswell
--- fix: cache in unreachable variable r
swap-subst : {T S : Ty} {Γ Δ ∇ : Env} {e : Exp} {r : ℕ} {gt : r >ᴺ ℕ.suc (length Δ +ᴺ (length Γ +ᴺ length ∇))}
→ (Δ ++ (S ∷ ∇) ++ Γ) ⊢ e ∶ T
→ (Δ ++ ∇ ++ (S ∷ Γ)) ⊢ [ r ↦ Var (length Δ +ᴺ length ∇) ] ↑[ ℕ.suc (length Δ) , length Δ +ᴺ length ∇ ] -[1+ 0 ] [ [ length Δ ↦ Var r ] e ] ∶ T
swap-subst {(Fun T₁ T₂)} {S} {Γ} {Δ} {∇} {(Abs e)} {r} {gt} (TAbs j)
rewrite (↑¹-var{length Δ +ᴺ length ∇})
| (n+1≡sucn{r})
= TAbs (swap-subst{T₂}{S}{Γ}{T₁ ∷ Δ}{∇}{e}{ℕ.suc r}{s≤s gt} j)
swap-subst {T} {S} {Γ} {Δ} {∇} {(App e e₁)} {r} {gt} (TApp{T₁ = T₁}{T₂} j j₁) = TApp (swap-subst{Fun T₁ T₂}{S}{Γ}{Δ}{∇}{e}{r}{gt} j) (swap-subst{T₁}{S}{Γ}{Δ}{∇}{e₁}{r}{gt} j₁)
swap-subst {T} {S} {Γ} {Δ} {∇} {Var y} {r} {gt} (TVar j)
with extract{Δ} {(S ∷ ∇) ++ Γ} {T} {y} j
| y <ᴺ? (foldr (λ _ → ℕ.suc) 0 Δ)
| Data.Nat._≟_ y (length Δ)
-- y ∈ Δ
... | in-Δ x | yes p | yes q = contradiction q (<⇒≢ p)
... | in-Δ x | yes p | no ¬q
rewrite (↑[]-var-refl-<{ℕ.suc (length Δ)}{length Δ +ᴺ length ∇}{y}{ -[1+ 0 ] }{[k<x]⇒[k<sucx] p})
| (var-subst-refl{r}{y}{≢-sym (<⇒≢ (a<b≤c⇒a<c p (≤-trans (n≤m⇒n≤sucm (m≤m+n (length Δ) (length Γ +ᴺ length ∇))) (<-trans (s≤s ≤-refl) gt))) )}
{Var (foldr (λ _ → ℕ.suc) 0 Δ +ᴺ foldr (λ _ → ℕ.suc) 0 ∇)})
= TVar (ext-behind x)
... | in-Δ x | no ¬p | _ = contradiction (var-env-< x) ¬p
-- y ∈ (S ∷ ∇ ++ Γ)
... | in-Γ ge x | p | q
with extract{S ∷ ∇} {Γ} {T} {y ∸ length Δ} x
--- y ∈ (S ∷ ∇)
---- y @ S
swap-subst {T} {S} {Γ} {Δ} {∇} {Var y} {r} {gt} (TVar j) | in-Γ ge x | p | yes q' | in-Δ x'
rewrite (↑[]-var-refl->{ℕ.suc (length Δ)}{length Δ +ᴺ length ∇}{r}{ -[1+ 0 ] }{<-trans (s≤s (n+m≤n+q+m {length Δ} {length ∇} {length Γ})) gt})
| (subst-trivial{r} {Var (length Δ +ᴺ length ∇)})
| q'
| (env-type-equiv j)
= TVar (swap-type{Δ}{∇}{Γ}{S} (env-type-equiv-j (env-type-equiv j) j))
---- y ∈ ∇
swap-subst {T} {S} {Γ} {Δ} {∇} {Var y} {r} {gt} (TVar j) | in-Γ ge x | p | no ¬q' | in-Δ x'
rewrite (↑[]-var-shift{ℕ.suc (length Δ)}{length Δ +ᴺ length ∇}{y}{ -[1+ 0 ]} (≤∧≢⇒< ge (≢-sym ¬q')) (≤-trans (≤-pred (m≤n∧m≡q⇒q≤n (m≤n⇒m+o≤n+o{o = length Δ} (var-env-< x'))
(cong ℕ.suc (m∸n+n≡m ge)))) (≤-refl-+-comm{length ∇}{length Δ})))
| length-≡ {Δ} {∇} {Γ} {S}
| (var-subst-refl {r} {∣ y ⊖ 1 ∣} {≢-sym (<⇒≢ (<-trans (n>0⇒n>∣n⊖1∣ (≤-trans (s≤s z≤n) ((≤∧≢⇒< ge (≢-sym ¬q'))))) (<-trans (var-env-< j) gt)))} {Var (length Δ +ᴺ length ∇)})
| sym (minus-1{y}{length Δ}{≤∧≢⇒< ge (≢-sym ¬q')} )
= TVar (ext-front{Δ = Δ}(ext-behind{∇}{S ∷ Γ}{T} (env-pred{gt = ≢-sym (<⇒≢ (m>n⇒m∸n≥1{y}{length Δ} ((≤∧≢⇒< ge (≢-sym ¬q')))))} x')))
--- y ∈ Γ
swap-subst {T} {S} {Γ} {Δ} {∇} {Var y} {r} {gt} (TVar j) | in-Γ ge x | no ¬p | yes q | in-Γ ge' x'
= contradiction q (≢-sym (<⇒≢ (m∸n≢0⇒n<m{y}{length Δ} (≢-sym (<⇒≢ (a<b≤c⇒a<c (s≤s z≤n) (≤-trans (length[A∷B]≥1{lzero}{Ty}{S}{∇}) ge')))))))
swap-subst {T} {S} {Γ} {Δ} {∇} {Var y} {r} {gt} (TVar j) | in-Γ ge x | yes p | yes q | in-Γ ge' x' = contradiction q (<⇒≢ p)
swap-subst {T} {S} {Γ} {Δ} {∇} {Var y} {r} {gt} (TVar j) | in-Γ ge x | p | no ¬q' | in-Γ ge' x'
rewrite (↑[]-var-refl->{ℕ.suc (length Δ)}{length Δ +ᴺ length ∇}{y}{ -[1+ 0 ]}{a<b≤c⇒a<c (s≤s (≤-refl-+-comm{length Δ}{length ∇})) (m≤n∧n≡q⇒m≤q (m≤n⇒m+o≤n+o{o = length Δ} ge') (m∸n+n≡m ge))})
| (var-subst-refl{r}{y}{≢-sym (<⇒≢ (<-trans (var-env-< j) (m≤n∧m≡q⇒q≤n gt (cong ℕ.suc (length-≡{Δ}{∇}{Γ}{S})))))}{ Var (foldr (λ _ → ℕ.suc) 0 Δ +ᴺ foldr (λ _ → ℕ.suc) 0 ∇)})
with ext-front{((y ∸ (length Δ)) ∸ ℕ.suc (length ∇))}{Γ}{Δ ++ ∇ ++ (S ∷ [])}{T}
... | w rewrite (∸-+-assoc y (length Δ) (ℕ.suc (length ∇)))
| (sym (length-≡'{Δ}{∇}{S}))
| (m∸n+n≡m{y}{length (Δ ++ ∇ ++ S ∷ [])} (m≤n∧m≡q⇒q≤n (m≤n∧n≡q⇒m≤q (m≤n⇒m+o≤n+o{o = length Δ} ge') (m∸n+n≡m ge)) (sym (length-≡''{Δ}{∇}{S}))))
| (A++B++D∷[]++C≡A++B++D∷C{lzero}{Ty}{Δ}{∇}{Γ}{S})
= TVar (w x')
| 44.513978
| 199
| 0.441905
|
291da66f49ad32ab1c3bd193766cfc0a7fa7e243
| 8,624
|
agda
|
Agda
|
src/Basics/Reasoning.agda
|
jstolarek/dep-typed-wbl-heaps
|
57db566cb840dc70331c29eb7bf3a0c849f8b27e
|
[
"BSD-3-Clause"
] | 1
|
2018-05-02T21:48:43.000Z
|
2018-05-02T21:48:43.000Z
|
src/Basics/Reasoning.agda
|
jstolarek/dep-typed-wbl-heaps
|
57db566cb840dc70331c29eb7bf3a0c849f8b27e
|
[
"BSD-3-Clause"
] | null | null | null |
src/Basics/Reasoning.agda
|
jstolarek/dep-typed-wbl-heaps
|
57db566cb840dc70331c29eb7bf3a0c849f8b27e
|
[
"BSD-3-Clause"
] | null | null | null |
----------------------------------------------------------------------
-- Copyright: 2013, Jan Stolarek, Lodz University of Technology --
-- --
-- License: See LICENSE file in root of the repo --
-- Repo address: https://github.com/jstolarek/dep-typed-wbl-heaps --
-- --
-- Refl datatype and functions required for equational reasoning. --
----------------------------------------------------------------------
module Basics.Reasoning where
open import Basics.Nat hiding (_≥_)
open import Basics.Ordering
-- Basic definition we will need in our proofs is propositional
-- equality (known as refl). Unlike refl definition provided by Agda's
-- standard library the definition below is not universe
-- polymorphic. It works only on Set, but not on Set1 and higher Sets
-- - this will be perfectly sufficient for our purposes. This datatype
-- allows to express equality between types belonging to Set.
data _≡_ {S : Set} (s : S) : S → Set where
refl : s ≡ s
infixl 1 _≡_
-- Below we prove basic properties of relations: symmetry,
-- transitivity, congruence and substitution. If these proofs are not
-- familiar I encourage to take a look at tutorials on Agda Wiki. The
-- most useful source in my opinion are the online lecture notes for
-- the Computer Aided Formal Reasoning course by Thorsten Altenkirch:
--
-- http://www.cs.nott.ac.uk/~txa/g53cfr/
sym : {A : Set} → {a b : A} → a ≡ b → b ≡ a
sym refl = refl
trans : {A : Set}{a b c : A} → a ≡ b → b ≡ c → a ≡ c
trans refl refl = refl
cong : {A B : Set} (f : A → B) → ∀ {a b} → a ≡ b → f a ≡ f b
cong f refl = refl
subst : {A : Set}(P : A → Set) → {a b : A} → a ≡ b → P a → P b
subst prp refl p = p
-- We prove some basic properties of addition that we will need later
-- in more complex proofs. I assume that you had previous exposure to
-- these basic proofs, but nevertheless I provide extensive
-- explanations. Make sure you understand how these proofs work before
-- proceeding with rest of the paper.
-- Note [0 is right identity of addition]
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
--
-- The fact that 0 is left identity of addition (ie. 0 + a ≡ a)
-- follows directly from our definition of _+_:
--
-- _+_ : Nat → Nat → Nat
-- zero + m = m
-- suc n + m = suc (n + m)
--
-- But we need a separate proof that 0 is also right identity of
-- addition, ie. a + 0 ≡ a. Proof proceeds by induction on a. If a is
-- zero then we have:
--
-- 0 + 0 = 0
--
-- And the proof follows from the definition of addition - hence we
-- use refl. In a recursive case we have:
--
-- (suc a) + zero ≡ (suc a)
--
-- Applying definition of addition to LHS we have:
--
-- suc (a + zero) ≡ suc a
--
-- Since we have suc on both sides of the equality, we use
-- congruence. This leaves us with a proof that equality holds for the
-- parameters of suc:
--
-- a + zero ≡ a
--
-- But that happens to be the equality we are proving at the
-- moment. We therefore make a recursive call to (+0 a), which is
-- equivalent of applying inductive hypothesis in an inductive proof.
--
-- ∎
+0 : (a : Nat) → a + zero ≡ a -- See Note [0 is right identity of addition]
+0 zero = refl
+0 (suc a) = cong suc (+0 a)
-- Note [1 + (a + b) equals a + (1 + b)]
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
--
-- We will need this property surprisingly often. We proceed by
-- inductive proof on a. In the base case, when a = 0, we have:
--
-- suc (0 + b) ≡ 0 + (suc b)
--
-- Applying definition of + to both sides of equality we get:
--
-- suc b ≡ suc b
--
-- Which is true by definition, hence we use refl. In the recursive
-- case we have:
--
-- suc ((suc a) + b) ≡ (suc a) + (suc b)
--
-- We apply definition of + to both sides and get:
--
-- suc (suc (a + b)) ≡ suc (a + (suc b))
--
-- Again, since we have suc on both sides we use congruence and are
-- left with a proof:
--
-- suc (a + b) ≡ a + (suc b)
--
-- Which again is the equality we are proving. We appeal to inductive
-- hypothesis by making a recursive call.
--
-- ∎
+suc : (a b : Nat) → suc (a + b) ≡ a + (suc b)
+suc zero b = refl
+suc (suc a) b = cong suc (+suc a b)
-- Note [Commutativity of addition]
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
--
-- Everyone knows that a + b ≡ b + a. But Agda won't take our word and
-- requires a formal proof. Let's proceed by induction on second
-- argument. In the base case we have:
--
-- a + 0 ≡ 0 + a
--
-- Right side reduces by the definition of + which leaves us with
--
-- a + 0 ≡ a
--
-- We proved that earlier so we appeal to already existing proof. In
-- the inductive case we have:
--
-- a + suc b ≡ (suc b) + a [1]
--
-- Right hand side reduces by definition of + giving us:
--
-- a + suc b ≡ suc (b + a) [2]
--
-- [2] is therefore the equality we have to prove. From +suc we know
-- that
--
-- suc (a + b) ≡ a + (suc b) [3]
--
-- And we can use that to transform left hand side of [1]. Note
-- however that in order to apply [3] to left hand side of [1] we need
-- to reverse sides of the equality [3]:
--
-- a + (suc b) ≡ suc (a + b) [4]
--
-- We achieve this by using symmetry.
--
-- Looking at right hand sides of [2] and [4] we see they differ by
-- the order of arguments to +. We can prove them equal by using
-- congruence on suc and appealing to our inductive hypothesis of
-- commutativity of addition. This means we have proven two things:
--
-- a + (suc b) ≡ suc (a + b) [4, repeated], from symmetry of +suc
-- suc (a + b) ≡ suc (b + a) [5], from congruence on suc and
-- inductive hypothesis
--
-- Combining [4] and [5] using transitivity yields the proof of [2].
--
-- ∎
--
-- Here is a diagram, showing how code relates to the proof:
--
-- a + b ≡ b + a
-- ____|____
-- / \
-- trans (sym (+suc a b)) (cong suc (+comm a b))
-- ̲\_____________/ \__________________/
-- | |
-- a + (suc b) ≡ suc (a + b) |
-- suc (a + b) ≡ suc (b + a)
+comm : (a b : Nat) → a + b ≡ b + a
+comm a zero = +0 a
+comm a (suc b) = trans (sym (+suc a b)) (cong suc (+comm a b))
-- Note [Associativity of addition]
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
--
-- We proceed by induction on the first parameter. In the base case we
-- have a = 0:
--
-- 0 + (b + c) ≡ (0 + b) + c
--
-- Both sides can be normalized using the definition of + giving us
--
-- b + c ≡ b + c
--
-- Since this is true by definition we use refl. In the inductive case
-- we have to prove:
--
-- suc a + (b + c) ≡ (suc a + b) + c
--
-- Again, Agda normalizes each side using definition of + :
--
-- LHS: suc a + (b + c) ≡ suc (a + (b + c))
-- RHS: (suc a + b) + c ≡ suc (a + b) + c ≡ suc ((a + b) + c)
--
-- This means we have to prove:
--
-- suc (a + (b + c)) ≡ suc ((a + b) + c)
--
-- We can use congruence to remove the outer suc on both sides which
-- leaves us with a proof of:
--
-- a + (b + c) ̄≡ (a + b) + c
--
-- Which happens to be our inductive hypothesis - hence a recursive
-- call to +assoc.
--
-- ∎
+assoc : (a b c : Nat) → a + (b + c) ≡ (a + b) + c
+assoc zero b c = refl
+assoc (suc a) b c = cong suc (+assoc a b c)
-- Note [If numbers are equal they are in the greater-equal relation]
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
--
-- Finally, we need a proof that if a = b then a ≥ b. This property is
-- specific to our task, so you most likely haven't seen it other
-- tutorials. There are three interesting things in this proof:
--
-- 1) a value of type m ≥ n proves that m is greater-equal than n. We
-- therefore need to construct the value of this type.
--
-- 2) since refl is the only constructor of type ≡ we always use refl
-- when pattern matching on a value of ≡. We also always pass refl
-- as a value of ≡ in calls.
--
-- 3) we need to match on implicit parameters to construct a
-- proof. Note that although type signature specifies Nats m and
-- n, in the proof we require that these are always equal. This
-- requirement comes from the fact that m ≡ n, i.e. that m and n
-- are equal.
--
-- In the base case we need to construct a proof that 0 ≥ 0, which we
-- do by using ge0. Inductive case simply applies geS to result of
-- recursive call to ≥sym.
≥sym : {m n : Nat} → m ≡ n → m ≥ n
≥sym {zero} {zero} refl = ge0
≥sym {.(suc n)} {(suc n)} refl = geS (≥sym {n} {n} refl)
| 33.55642
| 75
| 0.57166
|
8bd5212e13cd032b14ab376637ea16433290559d
| 10,574
|
agda
|
Agda
|
Cubical/Foundations/Path.agda
|
Schippmunk/cubical
|
c345dc0c49d3950dc57f53ca5f7099bb53a4dc3a
|
[
"MIT"
] | null | null | null |
Cubical/Foundations/Path.agda
|
Schippmunk/cubical
|
c345dc0c49d3950dc57f53ca5f7099bb53a4dc3a
|
[
"MIT"
] | null | null | null |
Cubical/Foundations/Path.agda
|
Schippmunk/cubical
|
c345dc0c49d3950dc57f53ca5f7099bb53a4dc3a
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --cubical --no-import-sorts --safe #-}
module Cubical.Foundations.Path where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.GroupoidLaws
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.Isomorphism
open import Cubical.Foundations.Transport
open import Cubical.Foundations.Univalence
private
variable
ℓ ℓ' : Level
A : Type ℓ
-- Less polymorphic version of `cong`, to avoid some unresolved metas
cong′ : ∀ {B : Type ℓ'} (f : A → B) {x y : A} (p : x ≡ y)
→ Path B (f x) (f y)
cong′ f = cong f
{-# INLINE cong′ #-}
PathP≡Path : ∀ (P : I → Type ℓ) (p : P i0) (q : P i1) →
PathP P p q ≡ Path (P i1) (transport (λ i → P i) p) q
PathP≡Path P p q i = PathP (λ j → P (i ∨ j)) (transport-filler (λ j → P j) p i) q
PathP≡Path⁻ : ∀ (P : I → Type ℓ) (p : P i0) (q : P i1) →
PathP P p q ≡ Path (P i0) p (transport⁻ (λ i → P i) q)
PathP≡Path⁻ P p q i = PathP (λ j → P (~ i ∧ j)) p (transport⁻-filler (λ j → P j) q i)
PathP≃Path : ∀ (P : I → Type ℓ) (p : P i0) (q : P i1) →
PathP P p q ≃ Path (P i1) (transport (λ i → P i) p) q
PathP≃Path P p q = transportEquiv (PathP≡Path P p q)
-- Alternative more unfolded proof
toPathP-isEquiv : ∀ (A : I → Type ℓ) {x y} → isEquiv (toPathP {A = A} {x} {y})
toPathP-isEquiv A {x} {y} = isoToIsEquiv (iso toPathP fromPathP to-from from-to)
where
to-from : ∀ (p : PathP A x y) → toPathP (fromPathP p) ≡ p
to-from p h i = outS (hcomp-unique (λ { j (i = i0) → x ; j (i = i1) → fromPathP p j })
(inS (transp (λ j → A (i ∧ j)) (~ i) x))
\ h → inS (sq1 h i))
h
where
sq1 : (\ h → A [ x ≡ transp (\ j → A (h ∨ j)) h (p h) ]) [ (\ i → transp (λ j → A (i ∧ j)) (~ i) x) ≡ p ]
sq1 = \ h i → comp (\ z → (hcomp (\ w →
\ { (z = i1) → A (i ∧ (w ∨ h))
; (z = i0) → A (i ∧ h)
; (i = i0) → A i0
; (i = i1) → A (h ∨ (w ∧ z))
; (h = i0) → A (i ∧ (w ∧ z))
; (h = i1) → A i})
((A (i ∧ h)))))
(\ z → \ { (i = i0) → x
; (i = i1) → transp (\ j → A (h ∨ (z ∧ j))) (h ∨ ~ z) (p h)
; (h = i0) → transp (λ j → A ((i ∧ z) ∧ j)) (~ (i ∧ z)) x
; (h = i1) → p i })
(p (i ∧ h))
from-to : ∀ (q : transp (\ i → A i) i0 x ≡ y) → fromPathP (toPathP {A = A} q) ≡ q
from-to q = (\ h i → outS (transp-hcomp i {A' = A i1} (\ j → inS (A (i ∨ j)))
((λ { j (i = i0) → x ; j (i = i1) → q j }))
(inS ((transp (λ j → A (i ∧ j)) (~ i) x))))
h)
∙ (\ h i → outS (hcomp-unique {A = A i1} ((λ { j (i = i0) → transp (\ i → A i) i0 x ; j (i = i1) → q j }))
(inS ((transp (λ j → A (i ∨ j)) i (transp (λ j → A (i ∧ j)) (~ i) x))))
\ h → inS (sq2 h i))
h)
∙ sym (lUnit q)
where
sq2 : (\ h → transp (\ i → A i) i0 x ≡ q h) [ (\ i → transp (\ j → A (i ∨ j)) i (transp (\ j → A (i ∧ j)) (~ i) x)) ≡ refl ∙ q ]
sq2 = \ h i → comp (\ z → hcomp (\ w → \ { (i = i1) → A i1
; (i = i0) → A (h ∨ (w ∧ z))
; (h = i0) → A (i ∨ (w ∧ z))
; (h = i1) → A i1
; (z = i0) → A (i ∨ h)
; (z = i1) → A ((i ∨ h) ∨ w) })
(A (i ∨ h)))
(\ z → \ { (i = i0) → transp (λ j → A ((z ∨ h) ∧ j)) (~ z ∧ ~ h) x
; (i = i1) → q (z ∧ h)
; (h = i1) → compPath-filler refl q z i
; (h = i0) → transp (\ j → A (i ∨ (z ∧ j))) (i ∨ ~ z) (transp (\ j → A (i ∧ j)) (~ i) x)
})
(transp (\ j → A ((i ∨ h) ∧ j)) (~ (i ∨ h)) x)
PathP≡compPath : ∀ {A : Type ℓ} {x y z : A} (p : x ≡ y) (q : y ≡ z) (r : x ≡ z)
→ (PathP (λ i → x ≡ q i) p r) ≡ (p ∙ q ≡ r)
PathP≡compPath p q r k = PathP (λ i → p i0 ≡ q (i ∨ k)) (λ j → compPath-filler p q k j) r
PathP≡doubleCompPathˡ : ∀ {A : Type ℓ} {w x y z : A} (p : w ≡ y) (q : w ≡ x) (r : y ≡ z) (s : x ≡ z)
→ (PathP (λ i → p i ≡ s i) q r) ≡ (p ⁻¹ ∙∙ q ∙∙ s ≡ r)
PathP≡doubleCompPathˡ p q r s k = PathP (λ i → p (i ∨ k) ≡ s (i ∨ k))
(λ j → doubleCompPath-filler (p ⁻¹) q s k j) r
PathP≡doubleCompPathʳ : ∀ {A : Type ℓ} {w x y z : A} (p : w ≡ y) (q : w ≡ x) (r : y ≡ z) (s : x ≡ z)
→ (PathP (λ i → p i ≡ s i) q r) ≡ (q ≡ p ∙∙ r ∙∙ s ⁻¹)
PathP≡doubleCompPathʳ p q r s k = PathP (λ i → p (i ∧ (~ k)) ≡ s (i ∧ (~ k)))
q (λ j → doubleCompPath-filler p r (s ⁻¹) k j)
compPathl-cancel : ∀ {ℓ} {A : Type ℓ} {x y z : A} (p : x ≡ y) (q : x ≡ z) → p ∙ (sym p ∙ q) ≡ q
compPathl-cancel p q = p ∙ (sym p ∙ q) ≡⟨ assoc p (sym p) q ⟩
(p ∙ sym p) ∙ q ≡⟨ cong (_∙ q) (rCancel p) ⟩
refl ∙ q ≡⟨ sym (lUnit q) ⟩
q ∎
compPathr-cancel : ∀ {ℓ} {A : Type ℓ} {x y z : A} (p : z ≡ y) (q : x ≡ y) → (q ∙ sym p) ∙ p ≡ q
compPathr-cancel {x = x} p q i j =
hcomp-equivFiller (doubleComp-faces (λ _ → x) (sym p) j) (inS (q j)) (~ i)
compPathl-isEquiv : {x y z : A} (p : x ≡ y) → isEquiv (λ (q : y ≡ z) → p ∙ q)
compPathl-isEquiv p = isoToIsEquiv (iso (p ∙_) (sym p ∙_) (compPathl-cancel p) (compPathl-cancel (sym p)))
compPathlEquiv : {x y z : A} (p : x ≡ y) → (y ≡ z) ≃ (x ≡ z)
compPathlEquiv p = (p ∙_) , compPathl-isEquiv p
compPathr-isEquiv : {x y z : A} (p : y ≡ z) → isEquiv (λ (q : x ≡ y) → q ∙ p)
compPathr-isEquiv p = isoToIsEquiv (iso (_∙ p) (_∙ sym p) (compPathr-cancel p) (compPathr-cancel (sym p)))
compPathrEquiv : {x y z : A} (p : y ≡ z) → (x ≡ y) ≃ (x ≡ z)
compPathrEquiv p = (_∙ p) , compPathr-isEquiv p
-- Variations of isProp→isSet for PathP
isProp→SquareP : ∀ {B : I → I → Type ℓ} → ((i j : I) → isProp (B i j))
→ {a : B i0 i0} {b : B i0 i1} {c : B i1 i0} {d : B i1 i1}
→ (r : PathP (λ j → B j i0) a c) (s : PathP (λ j → B j i1) b d)
→ (t : PathP (λ j → B i0 j) a b) (u : PathP (λ j → B i1 j) c d)
→ SquareP B t u r s
isProp→SquareP {B = B} isPropB {a = a} r s t u i j =
hcomp (λ { k (i = i0) → isPropB i0 j (base i0 j) (t j) k
; k (i = i1) → isPropB i1 j (base i1 j) (u j) k
; k (j = i0) → isPropB i i0 (base i i0) (r i) k
; k (j = i1) → isPropB i i1 (base i i1) (s i) k
}) (base i j) where
base : (i j : I) → B i j
base i j = transport (λ k → B (i ∧ k) (j ∧ k)) a
isProp→isPropPathP : ∀ {ℓ} {B : I → Type ℓ} → ((i : I) → isProp (B i))
→ (b0 : B i0) (b1 : B i1)
→ isProp (PathP (λ i → B i) b0 b1)
isProp→isPropPathP {B = B} hB b0 b1 = isProp→SquareP (λ _ → hB) refl refl
isProp→isContrPathP : {A : I → Type ℓ} → (∀ i → isProp (A i))
→ (x : A i0) (y : A i1)
→ isContr (PathP A x y)
isProp→isContrPathP h x y = isProp→PathP h x y , isProp→isPropPathP h x y _
-- Flipping a square along its diagonal
flipSquare :
{a₀₀ a₀₁ : A} {a₀₋ : a₀₀ ≡ a₀₁}
{a₁₀ a₁₁ : A} {a₁₋ : a₁₀ ≡ a₁₁}
{a₋₀ : a₀₀ ≡ a₁₀} {a₋₁ : a₀₁ ≡ a₁₁}
→ Square a₀₋ a₁₋ a₋₀ a₋₁
→ Square a₋₀ a₋₁ a₀₋ a₁₋
flipSquare sq i j = sq j i
flipSquareEquiv :
{a₀₀ a₀₁ : A} {a₀₋ : a₀₀ ≡ a₀₁}
{a₁₀ a₁₁ : A} {a₁₋ : a₁₀ ≡ a₁₁}
{a₋₀ : a₀₀ ≡ a₁₀} {a₋₁ : a₀₁ ≡ a₁₁}
→ Square a₀₋ a₁₋ a₋₀ a₋₁ ≃ Square a₋₀ a₋₁ a₀₋ a₁₋
flipSquareEquiv = isoToEquiv (iso flipSquare flipSquare (λ _ → refl) (λ _ → refl))
flipSquarePath :
{a₀₀ a₀₁ : A} {a₀₋ : a₀₀ ≡ a₀₁}
{a₁₀ a₁₁ : A} {a₁₋ : a₁₀ ≡ a₁₁}
{a₋₀ : a₀₀ ≡ a₁₀} {a₋₁ : a₀₁ ≡ a₁₁}
→ Square a₀₋ a₁₋ a₋₀ a₋₁ ≡ Square a₋₀ a₋₁ a₀₋ a₁₋
flipSquarePath = isoToPath (iso flipSquare flipSquare (λ _ → refl) (λ _ → refl))
module _ {a₀₀ a₁₁ : A} {a₋ : a₀₀ ≡ a₁₁}
{a₁₀ : A} {a₁₋ : a₁₀ ≡ a₁₁} {a₋₀ : a₀₀ ≡ a₁₀} where
slideSquareFaces : (i j k : I) → Partial (i ∨ ~ i ∨ j ∨ ~ j) A
slideSquareFaces i j k (i = i0) = a₋ (j ∧ ~ k)
slideSquareFaces i j k (i = i1) = a₁₋ j
slideSquareFaces i j k (j = i0) = a₋₀ i
slideSquareFaces i j k (j = i1) = a₋ (i ∨ ~ k)
slideSquare : Square a₋ a₁₋ a₋₀ refl → Square refl a₁₋ a₋₀ a₋
slideSquare sq i j = hcomp (slideSquareFaces i j) (sq i j)
slideSquareEquiv : (Square a₋ a₁₋ a₋₀ refl) ≃ (Square refl a₁₋ a₋₀ a₋)
slideSquareEquiv = isoToEquiv (iso slideSquare slideSquareInv fillerTo fillerFrom) where
slideSquareInv : Square refl a₁₋ a₋₀ a₋ → Square a₋ a₁₋ a₋₀ refl
slideSquareInv sq i j = hcomp (λ k → slideSquareFaces i j (~ k)) (sq i j)
fillerTo : ∀ p → slideSquare (slideSquareInv p) ≡ p
fillerTo p k i j = hcomp-equivFiller (λ k → slideSquareFaces i j (~ k)) (inS (p i j)) (~ k)
fillerFrom : ∀ p → slideSquareInv (slideSquare p) ≡ p
fillerFrom p k i j = hcomp-equivFiller (slideSquareFaces i j) (inS (p i j)) (~ k)
-- The type of fillers of a square is equivalent to the double composition identites
Square≃doubleComp : {a₀₀ a₀₁ a₁₀ a₁₁ : A}
(a₀₋ : a₀₀ ≡ a₀₁) (a₁₋ : a₁₀ ≡ a₁₁)
(a₋₀ : a₀₀ ≡ a₁₀) (a₋₁ : a₀₁ ≡ a₁₁)
→ Square a₀₋ a₁₋ a₋₀ a₋₁ ≃ (a₋₀ ⁻¹ ∙∙ a₀₋ ∙∙ a₋₁ ≡ a₁₋)
Square≃doubleComp a₀₋ a₁₋ a₋₀ a₋₁ = transportEquiv (PathP≡doubleCompPathˡ a₋₀ a₀₋ a₁₋ a₋₁)
Square≡doubleComp : {a₀₀ a₀₁ a₁₀ a₁₁ : A}
(a₀₋ : a₀₀ ≡ a₀₁) (a₁₋ : a₁₀ ≡ a₁₁)
(a₋₀ : a₀₀ ≡ a₁₀) (a₋₁ : a₀₁ ≡ a₁₁)
→ Square a₀₋ a₁₋ a₋₀ a₋₁ ≡ (a₋₀ ⁻¹ ∙∙ a₀₋ ∙∙ a₋₁ ≡ a₁₋)
Square≡doubleComp a₀₋ a₁₋ a₋₀ a₋₁ = ua (Square≃doubleComp a₀₋ a₁₋ a₋₀ a₋₁)
-- sym induces an equivalence on identity types of paths
symIso : {a b : A} (p q : a ≡ b) → Iso (p ≡ q) (q ≡ p)
symIso p q = iso sym sym (λ _ → refl) λ _ → refl
| 51.082126
| 135
| 0.424154
|
2e64e746be0839e8c7e329c38b44218b4c7ecc58
| 4,619
|
agda
|
Agda
|
theorems/experimental/JoinAssoc.agda
|
cmknapp/HoTT-Agda
|
bc849346a17b33e2679a5b3f2b8efbe7835dc4b6
|
[
"MIT"
] | null | null | null |
theorems/experimental/JoinAssoc.agda
|
cmknapp/HoTT-Agda
|
bc849346a17b33e2679a5b3f2b8efbe7835dc4b6
|
[
"MIT"
] | null | null | null |
theorems/experimental/JoinAssoc.agda
|
cmknapp/HoTT-Agda
|
bc849346a17b33e2679a5b3f2b8efbe7835dc4b6
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --without-K #-}
open import HoTT
-- Associativity of the join (work in progress)
module experimental.JoinAssoc {i j k} (A : Type i) (B : Type j) (C : Type k) where
{- First map -}
to : (A * B) * C → A * (B * C)
to = To.f module _ where
to-left-glue : (ab : A × B) → left (fst ab) == right (left (snd ab)) :> A * (B * C)
to-left-glue (a , b) = glue (a , left b)
module ToLeft = PushoutRec left (right ∘ left) to-left-glue
to-left : A * B → A * (B * C)
to-left = ToLeft.f
to-glue-left : (c : C) (a : A) → to-left (left a) == right (right c)
to-glue-left c a = glue (a , right c)
to-glue-right : (c : C) (b : B) → to-left (right b) == right (right c)
to-glue-right c b = ap right (glue (b , c))
to-glue-glue : (c : C) (ab : A × B) → to-glue-left c (fst ab) == to-glue-right c (snd ab) [ (λ x → to-left x == right (right c)) ↓ glue ab ]
to-glue-glue c (a , b) = ↓-swap to-left right _ idp
(ToLeft.glue-β (a , b) ◃ apd (λ x → glue (a , x)) (glue (b , c)))
module ToGlue (c : C) = PushoutElim (to-glue-left c) (to-glue-right c) (to-glue-glue c)
to-glue : (ab-c : (A * B) × C) → to-left (fst ab-c) == right (right (snd ab-c))
to-glue (ab , c) = M.f ab where module M = ToGlue c
module To = PushoutRec {d = *-span (A * B) C} to-left (right ∘ right) to-glue
{- Second map -}
from : A * (B * C) → (A * B) * C
from = From.f module MM where
from-right-glue : (bc : B × C) → left (right (fst bc)) == right (snd bc)
from-right-glue (b , c) = glue (right b , c)
module FromRight = PushoutRec (left ∘ right) right from-right-glue
from-right : B * C → (A * B) * C
from-right = FromRight.f
from-glue-left : (a : A) (b : B) → left (left a) == from-right (left b)
from-glue-left a b = ap left (glue (a , b))
from-glue-right : (a : A) (c : C) → left (left a) == from-right (right c)
from-glue-right a c = glue (left a , c)
from-glue-glue : (a : A) (bc : B × C) → from-glue-left a (fst bc) == from-glue-right a (snd bc) [ (λ x → left (left a) == from-right x) ↓ glue bc ]
from-glue-glue a (b , c) = ↓-swap! left from-right _ idp
(apd (λ x → glue (x , c)) (glue (a , b)) ▹! (FromRight.glue-β (b , c)))
module FromGlue (a : A) = PushoutElim (from-glue-left a) (from-glue-right a) (from-glue-glue a)
from-glue : (a-bc : A × (B * C)) → left (left (fst a-bc)) == from-right (snd a-bc)
from-glue (a , bc) = M.f bc where module M = FromGlue a
module From = PushoutRec {d = *-span A (B * C)} (left ∘ left) from-right from-glue
open MM public
{- First composite -}
to-from-right-glue' : (b : B) (c : C) → ap (to ∘ from-right) (glue (b , c)) =-= ap right (glue (b , c))
to-from-right-glue' b c =
ap (λ z → to (from-right z)) (glue (b , c)) =⟪ ap-∘ to from-right (glue (b , c)) ⟫
ap to (ap from-right (glue (b , c))) =⟪ FromRight.glue-β (b , c) |in-ctx ap to ⟫
ap to (glue ((right b , c) :> ((A * B) × C))) =⟪ To.glue-β (right b , c)⟫
ap right (glue (b , c)) ∎∎
to-from-right-glue : (bc : B × C) → idp == idp [ (λ x → to (from (right x)) == right x) ↓ glue bc ]
to-from-right-glue (b , c) = ↓-='-in (! (↯ to-from-right-glue' b c))
module ToFromRight = PushoutElim (λ _ → idp) (λ _ → idp) to-from-right-glue
to-from-right : (bc : B * C) → to (from (right bc)) == right bc
to-from-right = ToFromRight.f
to-from-glue-left' : (a : A) (b : B) → ap to (ap from (glue (a , left b))) =-= glue (a , left b)
to-from-glue-left' a b =
ap to (ap from (glue (a , left b))) =⟪ From.glue-β (a , left b) |in-ctx ap to ⟫
ap to (ap left (glue (a , b))) =⟪ ∘-ap to left (glue (a , b)) ⟫
ap to-left (glue (a , b)) =⟪ ToLeft.glue-β (a , b) ⟫
glue (a , left b) ∎∎
to-from-glue-left : (a : A) (b : B) → idp == to-from-right (left b) [ (λ x → to (from x) == x) ↓ glue (a , left b) ]
to-from-glue-left a b = ↓-∘=idf-in to from (↯ to-from-glue-left' a b)
to-from-glue-right' : (a : A) (c : C) → ap to (ap from (glue (a , right c))) =-= glue (a , right c)
to-from-glue-right' a c =
ap to (ap from (glue (a , right c))) =⟪ From.glue-β (a , right c) |in-ctx ap to ⟫
ap to (glue (left a , c)) =⟪ To.glue-β (left a , c) ⟫
glue (a , right c) ∎∎
to-from-glue-right : (a : A) (c : C) → idp == to-from-right (right c) [ (λ x → to (from x) == x) ↓ glue (a , right c) ]
to-from-glue-right a c = ↓-∘=idf-in to from (↯ to-from-glue-right' a c)
postulate -- Not proved yet. Some of it is being worked on at JoinAssoc2
*-assoc : ((A * B) * C) ≃ (A * (B * C))
| 41.990909
| 151
| 0.52349
|
593d38b102bef48e009ab67303411d40a94a66fd
| 2,565
|
agda
|
Agda
|
examples/outdated-and-incorrect/Alonzo/PrintFloat.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
examples/outdated-and-incorrect/Alonzo/PrintFloat.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
examples/outdated-and-incorrect/Alonzo/PrintFloat.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
module PrintFloat where
import AlonzoPrelude
import PreludeShow
import PreludeList
import PreludeString
import PreludeNat
open AlonzoPrelude
open PreludeShow
open PreludeList, hiding(_++_)
open PreludeString
open PreludeNat
typeS : Char -> Set
typeS 'f' = Float
show : (c : Char) -> (typeS c) -> String
show 'f' f = showFloat f
data Unit : Set where
unit : Unit
data Format : Set where
stringArg : Format
natArg : Format
intArg : Format
floatArg : Format
charArg : Format
litChar : Char -> Format
badFormat : Char -> Format
data BadFormat (c:Char) : Set where
format' : List Char -> List Format
format' ('%' :: 's' :: fmt) = stringArg :: format' fmt
format' ('%' :: 'n' :: fmt) = natArg :: format' fmt
-- format' ('%' :: 'd' :: fmt) = intArg :: format' fmt
format' ('%' :: 'f' :: fmt) = floatArg :: format' fmt
format' ('%' :: 'c' :: fmt) = charArg :: format' fmt
format' ('%' :: '%' :: fmt) = litChar '%' :: format' fmt
format' ('%' :: c :: fmt) = badFormat c :: format' fmt
format' (c :: fmt) = litChar c :: format' fmt
format' [] = []
format : String -> List Format
format s = format' (toList s)
-- Printf1 : Format -> Set
-- Printf1 floatArg = Float
Printf' : List Format -> Set
Printf' (stringArg :: fmt) = String × Printf' fmt
Printf' (natArg :: fmt) = Nat × Printf' fmt
Printf' (intArg :: fmt) = Int × Printf' fmt
Printf' (floatArg :: fmt) = Float × Printf' fmt
Printf' (charArg :: fmt) = Char × Printf' fmt
Printf' (badFormat c :: fmt) = BadFormat c
Printf' (litChar _ :: fmt) = Printf' fmt
Printf' [] = Unit × Unit
Printf : String -> Set
Printf fmt = Printf' (format fmt)
printf' : (fmt : List Format) -> Printf' fmt -> String
printf' (stringArg :: fmt) < s | args > = s ++ printf' fmt args
printf' (natArg :: fmt) < n | args > = showNat n ++ printf' fmt args
printf' (intArg :: fmt) < n | args > = showInt n ++ printf' fmt args
printf' (floatArg :: fmt) < x | args > = showFloat x ++ printf' fmt args
printf' (charArg :: fmt) < c | args > = showChar c ++ printf' fmt args
printf' (litChar c :: fmt) args = fromList (c :: []) ++ printf' fmt args
printf' (badFormat _ :: fmt) ()
printf' [] < unit | unit > = ""
printf : (fmt : String) -> Printf fmt -> String
printf fmt = printf' (format fmt)
-- mainS = show 'f' 3.14
-- mainS = printf' (format "%f") < 3.14 | < unit | unit > >
mainS = printf "pi = %f" < 3.14159 | < unit | unit > >
-- mainS = fromList ( 'p' :: [] )
| 31.280488
| 75
| 0.574659
|
03beb8ee32a1eb92f5158e4da707d457f1cf564a
| 8,326
|
agda
|
Agda
|
Formalization/ClassicalPropositionalLogic/NaturalDeduction/Proofs.agda
|
Lolirofle/stuff-in-agda
|
70f4fba849f2fd779c5aaa5af122ccb6a5b271ba
|
[
"MIT"
] | 6
|
2020-04-07T17:58:13.000Z
|
2022-02-05T06:53:22.000Z
|
Formalization/ClassicalPropositionalLogic/NaturalDeduction/Proofs.agda
|
Lolirofle/stuff-in-agda
|
70f4fba849f2fd779c5aaa5af122ccb6a5b271ba
|
[
"MIT"
] | null | null | null |
Formalization/ClassicalPropositionalLogic/NaturalDeduction/Proofs.agda
|
Lolirofle/stuff-in-agda
|
70f4fba849f2fd779c5aaa5af122ccb6a5b271ba
|
[
"MIT"
] | null | null | null |
module Formalization.ClassicalPropositionalLogic.NaturalDeduction.Proofs where
open import Data.Boolean
open import Data.Either
open import Functional
open import Formalization.ClassicalPropositionalLogic.NaturalDeduction
open import Formalization.ClassicalPropositionalLogic.Place
open import Formalization.ClassicalPropositionalLogic.Syntax
import Lvl
open import Logic
import Logic.Propositional as Meta
open import Relator.Equals
open import Relator.Equals.Proofs.Equiv
open import Sets.PredicateSet using (PredSet ; _∈_ ; _∉_ ; _∪_ ; _∪•_ ; _∖_ ; _⊆_ ; _⊇_ ; ∅ ; [≡]-to-[⊆] ; [≡]-to-[⊇]) renaming (•_ to singleton ; _≡_ to _≡ₛ_)
open import Type
private variable ℓₚ ℓ ℓ₁ ℓ₂ : Lvl.Level
private variable T A B : Type{ℓ}
private variable P : Type{ℓₚ}
private variable φ ψ γ : Formula(P)
private variable Γ : Formulas(P){ℓ}
private variable f : A → B
private variable s e : Bool
private variable p : P
module _ where
[¬]-intro-converse : ((Γ ∪ singleton(φ)) ⊢ ⊥) ← (Γ ⊢ (¬ φ))
[¬]-intro-converse {Γ = Γ}{φ = φ} Γ¬φ = [⊥]-intro (direct (Right [≡]-intro)) (weaken-union Γ¬φ)
excluded-middle : Γ ⊢ (φ ∨ (¬ φ))
excluded-middle =
([¬¬]-elim
([¬]-intro
([⊥]-intro
([∨]-introᵣ
([¬]-intro
([⊥]-intro
([∨]-introₗ (direct (Right [≡]-intro)))
(direct (Left (Right [≡]-intro)))
)
)
)
(direct (Right [≡]-intro))
)
)
)
[→]-disjunctive-form : (Γ ⊢ (φ ⟶ ψ)) Meta.↔ (Γ ⊢ ((¬ φ) ∨ ψ))
[→]-disjunctive-form = Meta.[↔]-intro l r where
l = [∨]-elim
([⟶]-intro ([⊥]-elim ([⊥]-intro
(direct (Right [≡]-intro))
(direct (Left (Right [≡]-intro)))
)))
([⟶]-intro (direct (Left (Right [≡]-intro))))
r = pq ↦
([∨]-elim
([∨]-introᵣ ([⟶]-elim (direct (Right [≡]-intro)) (weaken Left pq)))
([∨]-introₗ (direct (Right [≡]-intro)))
excluded-middle
)
[⟷]-negated : (Γ ⊢ (φ ⟷ ψ)) → (Γ ⊢ ((¬ φ) ⟷ (¬ ψ)))
[⟷]-negated p = [⟷]-intro
([¬]-intro ([⊥]-intro ([⟷]-elimᵣ (direct (Right [≡]-intro)) (weaken (Left ∘ Left) p)) (direct (Left (Right [≡]-intro)))))
(([¬]-intro ([⊥]-intro ([⟷]-elimₗ (direct (Right [≡]-intro)) (weaken (Left ∘ Left) p)) (direct (Left (Right [≡]-intro))))))
[⟷]-conjunction-disjunction-negation : (Γ ⊢ (φ ⟷ ψ)) Meta.↔ (Γ ⊢ ((φ ∧ ψ) ∨ ((¬ φ) ∧ (¬ ψ))))
[⟷]-conjunction-disjunction-negation = Meta.[↔]-intro l r where
l = [∨]-elim
([⟷]-intro
([∧]-elimₗ (direct (Left (Right [≡]-intro))))
([∧]-elimᵣ (direct (Left (Right [≡]-intro))))
)
([⟷]-intro
([⊥]-elim ([⊥]-intro (direct (Right [≡]-intro)) ([∧]-elimᵣ (direct (Left (Right [≡]-intro))))))
([⊥]-elim ([⊥]-intro (direct (Right [≡]-intro)) ([∧]-elimₗ (direct (Left (Right [≡]-intro))))))
)
r = p ↦ [∨]-elim
([∨]-introₗ ([∧]-intro
(direct (Right [≡]-intro))
([⟷]-elimᵣ (direct (Right [≡]-intro)) (weaken Left p))
))
([∨]-introᵣ ([∧]-intro
(direct (Right [≡]-intro))
([⟷]-elimᵣ (direct (Right [≡]-intro)) (weaken Left ([⟷]-negated p)))
))
excluded-middle
-- TODO: The two proofs contain very similar cases (the structure is identical in all cases). Are there any good ways to generalize? Maybe by using the strict variants?
positive-congruence : Positive(P) f → (Γ ⊢ (φ ⟶ ψ) ⟶ (f(φ) ⟶ f(ψ)))
negative-congruence : Negative(P) f → (Γ ⊢ (φ ⟶ ψ) ⟶ (f(φ) ⟵ f(ψ)))
positive-congruence identity = [⟶]-intro ([⟶]-intro ([⟶]-elim (direct (Right [≡]-intro)) (direct (Left (Right [≡]-intro)))))
positive-congruence (conjunctionₗ ctx) =
[⟶]-intro ([⟶]-intro ([∧]-intro
([∧]-elimₗ (direct (Right [≡]-intro)))
([⟶]-elim ([∧]-elimᵣ (direct (Right [≡]-intro))) ([⟶]-elim (direct (Left (Right [≡]-intro))) (positive-congruence ctx)))
))
positive-congruence (conjunctionᵣ ctx) =
[⟶]-intro ([⟶]-intro ([∧]-intro
([⟶]-elim ([∧]-elimₗ (direct (Right [≡]-intro))) ([⟶]-elim (direct (Left (Right [≡]-intro))) (positive-congruence ctx)))
([∧]-elimᵣ (direct (Right [≡]-intro)))
))
positive-congruence (disjunctionₗ ctx) =
[⟶]-intro ([⟶]-intro ([∨]-elim
([∨]-introₗ (direct (Right [≡]-intro)))
([∨]-introᵣ ([⟶]-elim (direct (Right [≡]-intro)) ([⟶]-elim (direct (Left (Left (Right [≡]-intro)))) (positive-congruence ctx))))
(direct (Right [≡]-intro))
))
positive-congruence (disjunctionᵣ ctx) =
[⟶]-intro ([⟶]-intro ([∨]-elim
([∨]-introₗ ([⟶]-elim (direct (Right [≡]-intro)) ([⟶]-elim (direct (Left (Left (Right [≡]-intro)))) (positive-congruence ctx))))
([∨]-introᵣ (direct (Right [≡]-intro)))
(direct (Right [≡]-intro))
))
positive-congruence (implicationₗ ctx) =
[⟶]-intro ([⟶]-intro ([⟶]-intro ([⟶]-elim
([⟶]-elim (direct(Right [≡]-intro)) (direct (Left (Right [≡]-intro))))
([⟶]-elim (direct (Left (Left (Right [≡]-intro)))) (positive-congruence ctx))
)))
positive-congruence (implicationᵣ ctx) =
[⟶]-intro ([⟶]-intro ([⟶]-intro ([⟶]-elim
([⟶]-elim (direct (Right [≡]-intro)) ([⟶]-elim (direct (Left (Left (Right [≡]-intro)))) (negative-congruence ctx)))
(direct (Left (Right [≡]-intro)))
)))
negative-congruence (conjunctionₗ ctx) =
[⟶]-intro ([⟶]-intro ([∧]-intro
([∧]-elimₗ (direct (Right [≡]-intro)))
([⟶]-elim ([∧]-elimᵣ (direct (Right [≡]-intro))) ([⟶]-elim (direct (Left (Right [≡]-intro))) (negative-congruence ctx)))
))
negative-congruence (conjunctionᵣ ctx) =
[⟶]-intro ([⟶]-intro ([∧]-intro
([⟶]-elim ([∧]-elimₗ (direct (Right [≡]-intro))) ([⟶]-elim (direct (Left (Right [≡]-intro))) (negative-congruence ctx)))
([∧]-elimᵣ (direct (Right [≡]-intro)))
))
negative-congruence (disjunctionₗ ctx) =
[⟶]-intro ([⟶]-intro ([∨]-elim
([∨]-introₗ (direct (Right [≡]-intro)))
([∨]-introᵣ ([⟶]-elim (direct (Right [≡]-intro)) ([⟶]-elim (direct (Left (Left (Right [≡]-intro)))) (negative-congruence ctx))))
(direct (Right [≡]-intro))
))
negative-congruence (disjunctionᵣ ctx) =
[⟶]-intro ([⟶]-intro ([∨]-elim
([∨]-introₗ ([⟶]-elim (direct (Right [≡]-intro)) ([⟶]-elim (direct (Left (Left (Right [≡]-intro)))) (negative-congruence ctx))))
([∨]-introᵣ (direct (Right [≡]-intro)))
(direct (Right [≡]-intro))
))
negative-congruence (implicationₗ ctx) =
[⟶]-intro ([⟶]-intro ([⟶]-intro ([⟶]-elim
([⟶]-elim (direct(Right [≡]-intro)) (direct (Left (Right [≡]-intro))))
([⟶]-elim (direct (Left (Left (Right [≡]-intro)))) (negative-congruence ctx))
)))
negative-congruence (implicationᵣ ctx) =
[⟶]-intro ([⟶]-intro ([⟶]-intro ([⟶]-elim
([⟶]-elim (direct (Right [≡]-intro)) ([⟶]-elim (direct (Left (Left (Right [≡]-intro)))) (positive-congruence ctx)))
(direct (Left (Right [≡]-intro)))
)))
-- TODO: Mainly for results in minimal logic
data NegativeFragment {P : Type{ℓₚ}} : Formula(P) → Type{Lvl.of(P)} where
atom : NegativeFragment(¬(• p))
bottom : NegativeFragment(⊥)
top : NegativeFragment(⊤)
neg : NegativeFragment(φ) → NegativeFragment(¬ φ)
and : NegativeFragment(φ) → NegativeFragment(ψ) → NegativeFragment(φ ∧ ψ)
impl : NegativeFragment(φ) → NegativeFragment(ψ) → NegativeFragment(φ ⟶ ψ)
eq : NegativeFragment(φ) → NegativeFragment(ψ) → NegativeFragment(φ ⟷ ψ)
open import Functional
open import Type.Dependent
open import Type.Dependent.Functions
module GGNegativeTranslation where
trans : Formula(P) → Formula(P)
trans (• p) = ¬(¬(• p))
trans ⊤ = ⊤
trans ⊥ = ⊥
trans (¬ φ) = ¬(trans φ)
trans (φ ∧ ψ) = (trans φ) ∧ (trans ψ)
trans (φ ∨ ψ) = ¬((¬(trans φ)) ∧ (¬(trans ψ)))
trans (φ ⟶ ψ) = (trans φ) ⟶ (trans ψ)
trans (φ ⟷ ψ) = (trans φ) ⟷ (trans ψ)
trans-negativeFragment : NegativeFragment(trans(φ))
trans-negativeFragment {φ = • p} = neg atom
trans-negativeFragment {φ = ⊤} = top
trans-negativeFragment {φ = ⊥} = bottom
trans-negativeFragment {φ = ¬ φ} = neg trans-negativeFragment
trans-negativeFragment {φ = φ ∧ ψ} = and trans-negativeFragment trans-negativeFragment
trans-negativeFragment {φ = φ ∨ ψ} = neg(and(neg trans-negativeFragment) (neg trans-negativeFragment))
trans-negativeFragment {φ = φ ⟶ ψ} = impl trans-negativeFragment trans-negativeFragment
trans-negativeFragment {φ = φ ⟷ ψ} = eq trans-negativeFragment trans-negativeFragment
| 42.697436
| 168
| 0.571943
|
03734d2c50fc6c13af1c1247930406c7e5df8440
| 1,688
|
agda
|
Agda
|
Mockingbird/Problems/Chapter10.agda
|
splintah/combinatory-logic
|
df8bf877e60b3059532c54a247a36a3d83cd55b0
|
[
"MIT"
] | 1
|
2022-02-28T23:44:42.000Z
|
2022-02-28T23:44:42.000Z
|
Mockingbird/Problems/Chapter10.agda
|
splintah/combinatory-logic
|
df8bf877e60b3059532c54a247a36a3d83cd55b0
|
[
"MIT"
] | null | null | null |
Mockingbird/Problems/Chapter10.agda
|
splintah/combinatory-logic
|
df8bf877e60b3059532c54a247a36a3d83cd55b0
|
[
"MIT"
] | null | null | null |
open import Mockingbird.Forest using (Forest)
-- Is There a Sage Bird?
module Mockingbird.Problems.Chapter10 {b ℓ} (forest : Forest {b} {ℓ}) where
open import Data.Product using (_,_; proj₁; proj₂; ∃-syntax)
open import Function using (_$_)
open import Mockingbird.Forest.Birds forest
open Forest forest
module _ ⦃ _ : HasComposition ⦄ ⦃ _ : HasMockingbird ⦄ ⦃ _ : HasLark ⦄ where
private
hasMockingbirdComposer : ∃[ A ] (∀ x y → A ∙ x ∙ y ≈ x ∙ (M ∙ y))
hasMockingbirdComposer = (L , isMockingbirdComposer)
where
isMockingbirdComposer = λ x y → begin
L ∙ x ∙ y ≈⟨ isLark x y ⟩
x ∙ (y ∙ y) ≈˘⟨ congˡ $ isMockingbird y ⟩
x ∙ (M ∙ y) ∎
hasSageBird : HasSageBird
hasSageBird = record
{ Θ = M ∘ L
; isSageBird = λ x → begin
x ∙ ((M ∘ L) ∙ x) ≈⟨ congˡ $ isComposition M L x ⟩
x ∙ (M ∙ (L ∙ x)) ≈⟨ congˡ $ isMockingbird (L ∙ x) ⟩
x ∙ ((L ∙ x) ∙ (L ∙ x)) ≈˘⟨ isLark x (L ∙ x) ⟩
(L ∙ x) ∙ (L ∙ x) ≈˘⟨ isMockingbird (L ∙ x) ⟩
M ∙ (L ∙ x) ≈˘⟨ isComposition M L x ⟩
(M ∘ L) ∙ x ∎
}
module _ ⦃ _ : HasComposition ⦄ ⦃ _ : HasMockingbird ⦄
(hasMockingbirdComposer : ∃[ A ] (∀ x y → A ∙ x ∙ y ≈ x ∙ (M ∙ y))) where
private
A = proj₁ hasMockingbirdComposer
[Ax]y≈x[My] = proj₂ hasMockingbirdComposer
instance
hasLark : HasLark
hasLark = record
{ L = A
; isLark = λ x y → begin
(A ∙ x) ∙ y ≈⟨ [Ax]y≈x[My] x y ⟩
x ∙ (M ∙ y) ≈⟨ congˡ $ isMockingbird y ⟩
x ∙ (y ∙ y) ∎
}
hasSageBird′ : HasSageBird
hasSageBird′ = hasSageBird
| 31.259259
| 82
| 0.51481
|
13d1226578752a1674d1d6656fe24b87ea485fa1
| 3,296
|
agda
|
Agda
|
BasicIPC/Metatheory/GentzenSpinalNormalForm-HereditarySubstitution.agda
|
mietek/hilbert-gentzen
|
fcd187db70f0a39b894fe44fad0107f61849405c
|
[
"X11"
] | 29
|
2016-07-03T18:51:56.000Z
|
2022-01-01T10:29:18.000Z
|
BasicIPC/Metatheory/GentzenSpinalNormalForm-HereditarySubstitution.agda
|
mietek/hilbert-gentzen
|
fcd187db70f0a39b894fe44fad0107f61849405c
|
[
"X11"
] | 1
|
2018-06-10T09:11:22.000Z
|
2018-06-10T09:11:22.000Z
|
BasicIPC/Metatheory/GentzenSpinalNormalForm-HereditarySubstitution.agda
|
mietek/hilbert-gentzen
|
fcd187db70f0a39b894fe44fad0107f61849405c
|
[
"X11"
] | null | null | null |
module BasicIPC.Metatheory.GentzenSpinalNormalForm-HereditarySubstitution where
open import BasicIPC.Syntax.GentzenSpinalNormalForm public
-- Hereditary substitution and reduction.
mutual
[_≔_]ⁿᶠ_ : ∀ {A B Γ} → (i : A ∈ Γ) → Γ ∖ i ⊢ⁿᶠ A → Γ ⊢ⁿᶠ B → Γ ∖ i ⊢ⁿᶠ B
[ i ≔ s ]ⁿᶠ neⁿᶠ (spⁿᵉ j xs) with i ≟∈ j
[ i ≔ s ]ⁿᶠ neⁿᶠ (spⁿᵉ .i xs) | same = reduce s ([ i ≔ s ]ˢᵖ xs)
[ i ≔ s ]ⁿᶠ neⁿᶠ (spⁿᵉ ._ xs) | diff j = neⁿᶠ (spⁿᵉ j ([ i ≔ s ]ˢᵖ xs))
[ i ≔ s ]ⁿᶠ lamⁿᶠ t = lamⁿᶠ ([ pop i ≔ mono⊢ⁿᶠ weak⊆ s ]ⁿᶠ t)
[ i ≔ s ]ⁿᶠ pairⁿᶠ t u = pairⁿᶠ ([ i ≔ s ]ⁿᶠ t) ([ i ≔ s ]ⁿᶠ u)
[ i ≔ s ]ⁿᶠ unitⁿᶠ = unitⁿᶠ
[_≔_]ˢᵖ_ : ∀ {A B C Γ} → (i : A ∈ Γ) → Γ ∖ i ⊢ⁿᶠ A → Γ ⊢ˢᵖ B ⦙ C → Γ ∖ i ⊢ˢᵖ B ⦙ C
[ i ≔ s ]ˢᵖ nilˢᵖ = nilˢᵖ
[ i ≔ s ]ˢᵖ appˢᵖ xs u = appˢᵖ ([ i ≔ s ]ˢᵖ xs) ([ i ≔ s ]ⁿᶠ u)
[ i ≔ s ]ˢᵖ fstˢᵖ xs = fstˢᵖ ([ i ≔ s ]ˢᵖ xs)
[ i ≔ s ]ˢᵖ sndˢᵖ xs = sndˢᵖ ([ i ≔ s ]ˢᵖ xs)
reduce : ∀ {A C Γ} → Γ ⊢ⁿᶠ A → Γ ⊢ˢᵖ A ⦙ C → Γ ⊢ⁿᶠ C
reduce t nilˢᵖ = t
reduce (lamⁿᶠ t) (appˢᵖ xs u) = reduce ([ top ≔ u ]ⁿᶠ t) xs
reduce (pairⁿᶠ t u) (fstˢᵖ xs) = reduce t xs
reduce (pairⁿᶠ t u) (sndˢᵖ xs) = reduce u xs
-- Reduction-based normal forms.
appⁿᶠ : ∀ {A B Γ} → Γ ⊢ⁿᶠ A ▻ B → Γ ⊢ⁿᶠ A → Γ ⊢ⁿᶠ B
appⁿᶠ t u = reduce t (appˢᵖ nilˢᵖ u)
fstⁿᶠ : ∀ {A B Γ} → Γ ⊢ⁿᶠ A ∧ B → Γ ⊢ⁿᶠ A
fstⁿᶠ t = reduce t (fstˢᵖ nilˢᵖ)
sndⁿᶠ : ∀ {A B Γ} → Γ ⊢ⁿᶠ A ∧ B → Γ ⊢ⁿᶠ B
sndⁿᶠ t = reduce t (sndˢᵖ nilˢᵖ)
-- Useful equipment for deriving neutrals.
≪appˢᵖ : ∀ {A B C Γ} → Γ ⊢ˢᵖ C ⦙ A ▻ B → Γ ⊢ⁿᶠ A → Γ ⊢ˢᵖ C ⦙ B
≪appˢᵖ nilˢᵖ t = appˢᵖ nilˢᵖ t
≪appˢᵖ (appˢᵖ xs u) t = appˢᵖ (≪appˢᵖ xs t) u
≪appˢᵖ (fstˢᵖ xs) t = fstˢᵖ (≪appˢᵖ xs t)
≪appˢᵖ (sndˢᵖ xs) t = sndˢᵖ (≪appˢᵖ xs t)
≪fstˢᵖ : ∀ {A B C Γ} → Γ ⊢ˢᵖ C ⦙ A ∧ B → Γ ⊢ˢᵖ C ⦙ A
≪fstˢᵖ nilˢᵖ = fstˢᵖ nilˢᵖ
≪fstˢᵖ (appˢᵖ xs u) = appˢᵖ (≪fstˢᵖ xs) u
≪fstˢᵖ (fstˢᵖ xs) = fstˢᵖ (≪fstˢᵖ xs)
≪fstˢᵖ (sndˢᵖ xs) = sndˢᵖ (≪fstˢᵖ xs)
≪sndˢᵖ : ∀ {A B C Γ} → Γ ⊢ˢᵖ C ⦙ A ∧ B → Γ ⊢ˢᵖ C ⦙ B
≪sndˢᵖ nilˢᵖ = sndˢᵖ nilˢᵖ
≪sndˢᵖ (appˢᵖ xs u) = appˢᵖ (≪sndˢᵖ xs) u
≪sndˢᵖ (fstˢᵖ xs) = fstˢᵖ (≪sndˢᵖ xs)
≪sndˢᵖ (sndˢᵖ xs) = sndˢᵖ (≪sndˢᵖ xs)
-- Derived neutrals.
varⁿᵉ : ∀ {A Γ} → A ∈ Γ → Γ ⊢ⁿᵉ A
varⁿᵉ i = spⁿᵉ i nilˢᵖ
appⁿᵉ : ∀ {A B Γ} → Γ ⊢ⁿᵉ A ▻ B → Γ ⊢ⁿᶠ A → Γ ⊢ⁿᵉ B
appⁿᵉ (spⁿᵉ i xs) t = spⁿᵉ i (≪appˢᵖ xs t)
fstⁿᵉ : ∀ {A B Γ} → Γ ⊢ⁿᵉ A ∧ B → Γ ⊢ⁿᵉ A
fstⁿᵉ (spⁿᵉ i xs) = spⁿᵉ i (≪fstˢᵖ xs)
sndⁿᵉ : ∀ {A B Γ} → Γ ⊢ⁿᵉ A ∧ B → Γ ⊢ⁿᵉ B
sndⁿᵉ (spⁿᵉ i xs) = spⁿᵉ i (≪sndˢᵖ xs)
-- Iterated expansion.
expand : ∀ {A Γ} → Γ ⊢ⁿᵉ A → Γ ⊢ⁿᶠ A
expand {α P} t = neⁿᶠ t
expand {A ▻ B} t = lamⁿᶠ (expand (appⁿᵉ (mono⊢ⁿᵉ weak⊆ t) (expand (varⁿᵉ top))))
expand {A ∧ B} t = pairⁿᶠ (expand (fstⁿᵉ t)) (expand (sndⁿᵉ t))
expand {⊤} t = unitⁿᶠ
-- Expansion-based normal forms.
varⁿᶠ : ∀ {A Γ} → A ∈ Γ → Γ ⊢ⁿᶠ A
varⁿᶠ i = expand (varⁿᵉ i)
-- Translation from simple terms to normal forms.
tm→nf : ∀ {A Γ} → Γ ⊢ A → Γ ⊢ⁿᶠ A
tm→nf (var i) = varⁿᶠ i
tm→nf (lam t) = lamⁿᶠ (tm→nf t)
tm→nf (app t u) = appⁿᶠ (tm→nf t) (tm→nf u)
tm→nf (pair t u) = pairⁿᶠ (tm→nf t) (tm→nf u)
tm→nf (fst t) = fstⁿᶠ (tm→nf t)
tm→nf (snd t) = sndⁿᶠ (tm→nf t)
tm→nf unit = unitⁿᶠ
-- Normalisation by hereditary substitution.
norm : ∀ {A Γ} → Γ ⊢ A → Γ ⊢ A
norm = nf→tm ∘ tm→nf
| 30.238532
| 84
| 0.533981
|
57c0f5e2b081d63cfa0e72eceb1dd7394577b770
| 1,238
|
agda
|
Agda
|
src/Selective/Examples/Main-template.agda
|
Zalastax/singly-typed-actors
|
ae541df13d069df4eb1464f29fbaa9804aad439f
|
[
"MIT"
] | 1
|
2019-10-29T09:30:26.000Z
|
2019-10-29T09:30:26.000Z
|
src/Selective/Examples/Main-template.agda
|
Zalastax/singly-typed-actors
|
ae541df13d069df4eb1464f29fbaa9804aad439f
|
[
"MIT"
] | null | null | null |
src/Selective/Examples/Main-template.agda
|
Zalastax/singly-typed-actors
|
ae541df13d069df4eb1464f29fbaa9804aad439f
|
[
"MIT"
] | null | null | null |
module Selective.Examples.Main-generated where
import Selective.Examples.PingPong as PingPong
import Selective.Examples.TestCall as Call
import Selective.Examples.TestCall2 as Call2
import Selective.Examples.Fibonacci as Fib
import Selective.Examples.Chat as Chat
import Selective.Examples.Bookstore as Bookstore
import Selective.Examples.TestAO as TestAO
import Selective.Examples.TestSelectiveReceive as SelectiveReceive
import Selective.Examples.TestSelectiveReceive-calc as SelectiveReceive-calc
open import Selective.Runtime
open import Selective.SimulationEnvironment
open import Selective.ActorMonad
import IO
open ∞ActorM
pingpongEntry = singleton-env (PingPong.spawner .force)
callEntry = singleton-env (Call.calltestActor .force)
call2Entry = singleton-env (Call2.calculator-test-actor .force)
fibEntry = singleton-env (Fib.spawner .force)
chatEntry = singleton-env (Chat.chat-supervisor .force)
bookstoreEntry = singleton-env (Bookstore.bookstore-supervisor .force)
testaoEntry = singleton-env (TestAO.calculator-test-actor .force)
testsrcalcEntry = singleton-env (SelectiveReceive-calc.calculator-test-actor .force)
testsrEntry = singleton-env (SelectiveReceive.receive-42-with-reference)
main = IO.run (run-env __ENTRY__)
| 42.689655
| 84
| 0.837641
|
d0c98786c1806005e461de9cda8ae4cc29d62b00
| 779
|
agda
|
Agda
|
test/Succeed/fol-theorems/PropositionalFunction3.agda
|
asr/apia
|
a66c5ddca2ab470539fd68c42c4fbd45f720d682
|
[
"MIT"
] | 10
|
2015-09-03T20:54:16.000Z
|
2019-12-03T13:44:25.000Z
|
test/Succeed/fol-theorems/PropositionalFunction3.agda
|
asr/apia
|
a66c5ddca2ab470539fd68c42c4fbd45f720d682
|
[
"MIT"
] | 121
|
2015-01-25T13:22:12.000Z
|
2018-04-22T06:01:44.000Z
|
test/Succeed/fol-theorems/PropositionalFunction3.agda
|
asr/apia
|
a66c5ddca2ab470539fd68c42c4fbd45f720d682
|
[
"MIT"
] | 4
|
2016-05-10T23:06:19.000Z
|
2016-08-03T03:54:55.000Z
|
------------------------------------------------------------------------------
-- Testing the translation of the propositional functions
------------------------------------------------------------------------------
{-# OPTIONS --exact-split #-}
{-# OPTIONS --no-sized-types #-}
{-# OPTIONS --no-universe-polymorphism #-}
{-# OPTIONS --without-K #-}
module PropositionalFunction3 where
------------------------------------------------------------------------------
postulate
D : Set
P : D → Set
a : D
_∨_ : Set → Set → Set
-- In this case, the propositional function uses predicates and logical
-- constants, and it is an anonymous function.
postulate foo : (λ x → P x ∨ P x) a → (λ x → P x ∨ P x) a
{-# ATP prove foo #-}
| 32.458333
| 78
| 0.41335
|
59b2767df25dd806f850080bc1f2c115de7af545
| 971
|
agda
|
Agda
|
src/AssocFree/Util.agda
|
agda/agda-assoc-free
|
08337fdb8375137a52cc9b3ade766305191b2394
|
[
"MIT"
] | 3
|
2016-11-22T11:48:31.000Z
|
2020-08-27T20:56:20.000Z
|
src/AssocFree/Util.agda
|
agda/agda-assoc-free
|
08337fdb8375137a52cc9b3ade766305191b2394
|
[
"MIT"
] | null | null | null |
src/AssocFree/Util.agda
|
agda/agda-assoc-free
|
08337fdb8375137a52cc9b3ade766305191b2394
|
[
"MIT"
] | 2
|
2018-03-03T04:39:31.000Z
|
2022-03-12T11:38:44.000Z
|
open import Data.List using ( List ; [] ; _∷_ )
open import Data.Nat using ( ℕ ; zero ; suc )
open import Data.Maybe using ( Maybe ; just ; nothing )
open import Relation.Binary.PropositionalEquality using ( _≡_ ; refl ; subst )
open import Relation.Binary.PropositionalEquality.TrustMe using ( trustMe )
module AssocFree.Util where
≡-relevant : ∀ {α} {A : Set α} {a b : A} → .(a ≡ b) → (a ≡ b)
≡-relevant a≡b = trustMe
δsubst₂ : ∀ {a b p} {A : Set a} {B : A → Set b} (P : ∀ a → B a → Set p)
{x₁ x₂ y₁ y₂} → (x₁≡x₂ : x₁ ≡ x₂) → (subst B x₁≡x₂ y₁ ≡ y₂) → P x₁ y₁ → P x₂ y₂
δsubst₂ P refl refl p = p
subst-natural : ∀ {α β γ} {A : Set α} {B : A → Set β} {C : A → Set γ} {a₁ a₂ : A}
(p : a₁ ≡ a₂) (f : ∀ {a} → B a → C a) (b : B a₁) →
subst C p (f b) ≡ f (subst B p b)
subst-natural refl f b = refl
lookup : ∀ {α} {A : Set α} → List A → ℕ → Maybe A
lookup [] n = nothing
lookup (a ∷ as) zero = just a
lookup (a ∷ as) (suc n) = lookup as n
| 38.84
| 88
| 0.559217
|
1a4fb508e80332c3195be2b67d53abf31ca3c48c
| 152
|
agda
|
Agda
|
examples/simple-lib/Lib/Maybe.agda
|
pthariensflame/agda
|
222c4c64b2ccf8e0fc2498492731c15e8fef32d4
|
[
"BSD-3-Clause"
] | 1
|
2018-10-10T17:08:44.000Z
|
2018-10-10T17:08:44.000Z
|
examples/simple-lib/Lib/Maybe.agda
|
np/agda-git-experiment
|
20596e9dd9867166a64470dd24ea68925ff380ce
|
[
"MIT"
] | null | null | null |
examples/simple-lib/Lib/Maybe.agda
|
np/agda-git-experiment
|
20596e9dd9867166a64470dd24ea68925ff380ce
|
[
"MIT"
] | 1
|
2022-03-12T11:35:18.000Z
|
2022-03-12T11:35:18.000Z
|
module Lib.Maybe where
data Maybe (A : Set) : Set where
nothing : Maybe A
just : A -> Maybe A
{-# COMPILED_DATA Maybe Maybe Nothing Just #-}
| 15.2
| 46
| 0.644737
|
581c08721086347bb37307741f459acaf9d6e06e
| 1,475
|
agda
|
Agda
|
test/succeed/CopatternTrailingImplicit.agda
|
larrytheliquid/agda
|
477c8c37f948e6038b773409358fd8f38395f827
|
[
"MIT"
] | null | null | null |
test/succeed/CopatternTrailingImplicit.agda
|
larrytheliquid/agda
|
477c8c37f948e6038b773409358fd8f38395f827
|
[
"MIT"
] | null | null | null |
test/succeed/CopatternTrailingImplicit.agda
|
larrytheliquid/agda
|
477c8c37f948e6038b773409358fd8f38395f827
|
[
"MIT"
] | 1
|
2022-03-12T11:35:18.000Z
|
2022-03-12T11:35:18.000Z
|
{-# OPTIONS --copatterns --sized-types #-}
-- {-# OPTIONS -v tc.size.solve:30 #-}
-- {-# OPTIONS -v term:40 -v term.proj:60 --show-implicit #-}
-- Andreas, 2013-10-01 Make sure trailing implicit insertion
-- works with copatterns
module CopatternTrailingImplicit where
import Common.Level
open import Common.Size
open import Common.Prelude
-- Sized streams
record Stream (A : Set) {i : Size} : Set where
coinductive
field
head : A
tail : {j : Size< i} → Stream A {j}
open Stream
-- Mapping over streams
map : {A B : Set} (f : A → B) {i : Size} → Stream A {i} → Stream B {i}
tail (map f {i} s) {j} = map f (tail s)
head (map f s) = f (head s)
-- Nats defined using map
nats : {i : Size} → Stream Nat {i}
head nats = 0
tail nats = map suc nats
-- Before this patch, Agda would insert a {_} also in the `head' clause
-- leading to a type error.
-- 2013-10-12 works now also without manual {_} insertion
-- (See TermCheck.introHiddenLambdas.)
nats' : {i : Size} → Stream Nat {i}
head nats' = 0
tail nats' = map suc nats'
-- Before this latest patch, the termination checker would complain
-- since it would not see the type of the hidden {j : Size< i}
-- which is the argument to the recursive call.
-- All this would not be an issue if Agda still eagerly introduced
-- trailing hidden arguments on the LHS, but this has other
-- drawbacks (Q: even with varying arity?): cannot have
-- hidden lambdas on rhs (used to name trailing hiddens in with-clauses).
| 30.102041
| 73
| 0.680678
|
38fc06798144a2be7529dfa347509dcbc1cc5592
| 5,048
|
agda
|
Agda
|
Categories/Category/Monoidal/Closed/IsClosed/L.agda
|
rei1024/agda-categories
|
89d163f72caa7deeac9413f27bc1b4ed7f9e025b
|
[
"MIT"
] | null | null | null |
Categories/Category/Monoidal/Closed/IsClosed/L.agda
|
rei1024/agda-categories
|
89d163f72caa7deeac9413f27bc1b4ed7f9e025b
|
[
"MIT"
] | null | null | null |
Categories/Category/Monoidal/Closed/IsClosed/L.agda
|
rei1024/agda-categories
|
89d163f72caa7deeac9413f27bc1b4ed7f9e025b
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --without-K --safe #-}
open import Categories.Category using (Category)
open import Categories.Category.Monoidal using (Monoidal)
open import Categories.Category.Monoidal.Closed using (Closed)
module Categories.Category.Monoidal.Closed.IsClosed.L
{o ℓ e} {C : Category o ℓ e} {M : Monoidal C} (Cl : Closed M) where
open import Data.Product using (_,_)
open import Function using (_$_) renaming (_∘_ to _∙_)
open import Function.Equality as Π using (Π)
open import Categories.Morphism.Reasoning C
using (pull-last; pull-first; pullˡ; pushˡ; center; center⁻¹; pullʳ)
open import Categories.Functor using (Functor)
open import Categories.Functor.Bifunctor.Properties
open Closed Cl
open Category C
open HomReasoning
private
module ℱ = Functor
α⇒ = associator.from
α⇐ = associator.to
module ⊗ = Functor ⊗
open Π.Π
open adjoint renaming (unit to η; counit to ε; Ladjunct to 𝕃; Ladjunct-comm′ to 𝕃-comm′;
Ladjunct-resp-≈ to 𝕃-resp-≈)
L : (X Y Z : Obj) → [ Y , Z ]₀ ⇒ [ [ X , Y ]₀ , [ X , Z ]₀ ]₀
L X Y Z = 𝕃 (𝕃 (ε.η Z ∘ (id ⊗₁ ε.η Y) ∘ α⇒))
private
[g]₁ : {W Z Z′ : Obj} {g : Z ⇒ Z′} → [ W , Z ]₀ ⇒ [ W , Z′ ]₀
[g]₁ {g = g} = [ id , g ]₁
push-α⇒-right : {X Y Z Z′ : Obj} {g : Z ⇒ Z′} → (ε.η Z′ ∘ (id ⊗₁ ε.η {X} Y) ∘ α⇒) ∘ ([g]₁ ⊗₁ id) ⊗₁ id ≈ (g ∘ ε.η Z) ∘ (id ⊗₁ ε.η Y) ∘ α⇒
push-α⇒-right {X} {Y} {Z} {Z′} {g} = begin
(ε.η Z′ ∘ (id ⊗₁ ε.η {X} Y) ∘ α⇒) ∘ ([g]₁ ⊗₁ id) ⊗₁ id ≈⟨ pull-last assoc-commute-from ⟩
ε.η Z′ ∘ (id ⊗₁ ε.η {X} Y) ∘ ([g]₁ ⊗₁ (id ⊗₁ id)) ∘ α⇒ ≈⟨ refl⟩∘⟨ refl⟩∘⟨ ℱ.F-resp-≈ ⊗ (refl , ⊗.identity) ⟩∘⟨refl ⟩
ε.η Z′ ∘ (id ⊗₁ ε.η Y) ∘ [g]₁ ⊗₁ id ∘ α⇒ ≈⟨ refl⟩∘⟨ pullˡ [ ⊗ ]-commute ⟩
ε.η Z′ ∘ ([g]₁ ⊗₁ id ∘ (id ⊗₁ ε.η Y)) ∘ α⇒ ≈⟨ pull-first (ε.commute g) ⟩
(g ∘ ε.η Z) ∘ (id ⊗₁ ε.η Y) ∘ α⇒ ∎
L-g-swap : {X Y Z Z′ : Obj} {g : Z ⇒ Z′} → L X Y Z′ ∘ [ id , g ]₁ ≈ [ [ id , id ]₁ , [ id , g ]₁ ]₁ ∘ L X Y Z
L-g-swap {X} {Y} {Z} {Z′} {g} = begin
L X Y Z′ ∘ [g]₁ ≈˘⟨ 𝕃-comm′ ⟩
𝕃 (𝕃 (ε.η Z′ ∘ (id ⊗₁ ε.η Y) ∘ α⇒) ∘ [g]₁ ⊗₁ id) ≈˘⟨ 𝕃-resp-≈ 𝕃-comm′ ⟩
𝕃 (𝕃 $ (ε.η Z′ ∘ (id ⊗₁ ε.η Y) ∘ α⇒) ∘ ([g]₁ ⊗₁ id) ⊗₁ id) ≈⟨ 𝕃-resp-≈ $ 𝕃-resp-≈ push-α⇒-right ⟩
𝕃 (𝕃 $ (g ∘ ε.η Z) ∘ (id ⊗₁ ε.η Y) ∘ α⇒) ≈⟨ 𝕃-resp-≈ $ pushˡ $ X-resp-≈ assoc ○ ℱ.homomorphism [ X ,-] ⟩
𝕃 ([ id , g ]₁ ∘ 𝕃 (ε.η Z ∘ (id ⊗₁ ε.η Y) ∘ α⇒)) ≈⟨ pushˡ (ℱ.homomorphism [ XY ,-]) ⟩
[ id , [g]₁ ]₁ ∘ L X Y Z ≈˘⟨ [-,-].F-resp-≈ ([-,-].identity , refl) ⟩∘⟨refl ⟩
[ [ id , id ]₁ , [g]₁ ]₁ ∘ L X Y Z ∎
where
XY = [ X , Y ]₀
X-resp-≈ = ℱ.F-resp-≈ [ X ,-]
L-f-swap : {X Y Y′ Z : Obj} {f : Y′ ⇒ Y} → L X Y′ Z ∘ [ f , id ]₁ ≈ [ [ id , f ]₁ , [ id , id ]₁ ]₁ ∘ L X Y Z
L-f-swap {X} {Y} {Y′} {Z} {f} = begin
L X Y′ Z ∘ [fˡ]₁ ≈˘⟨ 𝕃-comm′ ⟩
𝕃 (𝕃 inner-L ∘ [fˡ]₁ ⊗₁ id) ≈˘⟨ 𝕃-resp-≈ 𝕃-comm′ ⟩
𝕃 (𝕃 (inner-L ∘ ([fˡ]₁ ⊗₁ id) ⊗₁ id)) ≈⟨ 𝕃-resp-≈ $ 𝕃-resp-≈ fˡ⇒fʳ ⟩
𝕃 (𝕃 $ inner-L ∘ (id ⊗₁ [fʳ]₁) ⊗₁ id) ≈⟨ 𝕃-resp-≈ $ ∘-resp-≈ˡ $ ℱ.homomorphism [ X ,-] ⟩
𝕃 (([ id , inner-L ]₁ ∘ [ id , (id ⊗₁ [fʳ]₁) ⊗₁ id ]₁)
∘ η.η (YZ ⊗₀ XY′)) ≈⟨ 𝕃-resp-≈ $ pullʳ (⟺ (η.commute _)) ○ (⟺ assoc) ⟩
𝕃 (𝕃 inner-L ∘ id ⊗₁ [fʳ]₁) ≈⟨ ℱ.homomorphism [ XY′ ,-] ⟩∘⟨refl ⟩
([ id , 𝕃 inner-L ]₁ ∘ [ id , id ⊗₁ [fʳ]₁ ]₁) ∘ η.η YZ ≈⟨ pullʳ (mate.commute₁ [fʳ]₁) ⟩
[ id , 𝕃 inner-L ]₁ ∘ [ [fʳ]₁ , id ]₁ ∘ η.η YZ ≈⟨ pullˡ [ [-,-] ]-commute ○ assoc ○ ∘-resp-≈ˡ ([-,-].F-resp-≈ (refl , ⟺ [-,-].identity)) ⟩
[ [fʳ]₁ , [ id , id ]₁ ]₁ ∘ L X Y Z ∎
where
XY′ = [ X , Y′ ]₀
YZ = [ Y , Z ]₀
[fʳ]₁ : ∀ {W} → [ W , Y′ ]₀ ⇒ [ W , Y ]₀
[fʳ]₁ = [ id , f ]₁
[fˡ]₁ : ∀ {W} → [ Y , W ]₀ ⇒ [ Y′ , W ]₀
[fˡ]₁ = [ f , id ]₁
inner-L : ∀ {W} → ([ W , Z ]₀ ⊗₀ [ X , W ]₀) ⊗₀ X ⇒ Z
inner-L {W} = ε.η Z ∘ id ⊗₁ ε.η {X} W ∘ α⇒
fˡ⇒fʳ : inner-L {Y′} ∘ ([fˡ]₁ ⊗₁ id) ⊗₁ id ≈ inner-L {Y} ∘ (id ⊗₁ [fʳ]₁) ⊗₁ id
fˡ⇒fʳ = begin
inner-L ∘ ([fˡ]₁ ⊗₁ id) ⊗₁ id ≈⟨ pull-last assoc-commute-from ⟩
ε.η Z ∘ (id ⊗₁ ε.η Y′) ∘ [fˡ]₁ ⊗₁ id ⊗₁ id ∘ α⇒ ≈⟨ ∘-resp-≈ʳ $ pullˡ
(∘-resp-≈ʳ (ℱ.F-resp-≈ ⊗ (refl , ⊗.identity)) ○ [ ⊗ ]-commute) ⟩
ε.η Z ∘ ([fˡ]₁ ⊗₁ id ∘ id ⊗₁ ε.η Y′) ∘ α⇒ ≈⟨ pull-first (mate.commute₂ f) ⟩
(ε.η Z ∘ id ⊗₁ f) ∘ id ⊗₁ ε.η Y′ ∘ α⇒ ≈⟨ center $ ⟺ (ℱ.homomorphism (YZ ⊗-)) ⟩
ε.η Z ∘ id ⊗₁ (f ∘ ε.η Y′) ∘ α⇒ ≈⟨ ∘-resp-≈ʳ $ ∘-resp-≈ˡ $ ℱ.F-resp-≈ (YZ ⊗-) $ ⟺ (ε.commute f) ⟩
ε.η Z ∘ id ⊗₁ (ε.η Y ∘ [fʳ]₁ ⊗₁ id) ∘ α⇒ ≈⟨ ∘-resp-≈ʳ $ ∘-resp-≈ˡ $ ℱ.homomorphism (YZ ⊗-) ⟩
ε.η Z ∘ (id ⊗₁ ε.η Y ∘ id ⊗₁ [fʳ]₁ ⊗₁ id) ∘ α⇒ ≈⟨ (center⁻¹ refl (⟺ assoc-commute-from)) ○ pullˡ assoc ⟩
inner-L ∘ (id ⊗₁ [fʳ]₁) ⊗₁ id ∎
| 53.702128
| 149
| 0.417987
|
a0c973623a96e11509362b262594d514c467d462
| 1,791
|
agda
|
Agda
|
Example.agda
|
fangyi-zhou/mpst-in-agda
|
3d12eed9d340207d242d70f43c6b34e01d3620de
|
[
"MIT"
] | 1
|
2021-08-14T17:36:53.000Z
|
2021-08-14T17:36:53.000Z
|
Example.agda
|
fangyi-zhou/mpst-in-agda
|
3d12eed9d340207d242d70f43c6b34e01d3620de
|
[
"MIT"
] | 1
|
2021-08-31T10:15:38.000Z
|
2021-11-24T11:30:17.000Z
|
Example.agda
|
fangyi-zhou/mpst-in-agda
|
3d12eed9d340207d242d70f43c6b34e01d3620de
|
[
"MIT"
] | null | null | null |
open import Common
open import Global
open import Projection
open import Local
open import Data.Fin
open import Data.Product
open import Data.Vec
open import Relation.Binary.PropositionalEquality
n = 4
Role = Fin n
p : Role
p = zero
q : Role
q = suc zero
r : Role
r = suc (suc zero)
s : Role
s = suc (suc (suc zero))
l : Label
l = 0
l′ : Label
l′ = 1
g₁ : Global n
g₁ = msgSingle′ p q l endG
lp : Local n
lp = sendSingle q l endL
g₁-proj-p-is-lp : project g₁ p ≡ lp
g₁-proj-p-is-lp = refl
lq : Local n
lq = recvSingle p l endL
g₁-proj-q-is-lq : project g₁ q ≡ lq
g₁-proj-q-is-lq = refl
p→q : Action n
p→q = action′ p q l
r→s : Action n
r→s = action′ r s l′
g₂ : Global n
g₂ = msgSingle′ r s l′ g₁
g₂′ : Global n
g₂′ = msgSingle′ r s l′ endG
g₁→end : g₁ - p→q →g endG
g₁→end = →g-prefix
g₂→g₁ : g₂ - r→s →g g₁
g₂→g₁ = →g-prefix
g₂→g₂′ : g₂ - p→q →g g₂′
g₂→g₂′ = →g-cont g₁→end (λ ()) (λ ()) (λ ()) (λ ())
g₁-proj-p→end : (p , project g₁ p) - p→q →l (p , endL)
g₁-proj-p→end = →l-send p refl λ ()
g₁-proj-q→end : (q , project g₁ q) - p→q →l (q , endL)
g₁-proj-q→end = →l-recv q refl λ ()
g₂-proj-p→g₂′-proj-p : (p , project g₂ p) - p→q →l (p , project g₂′ p)
g₂-proj-p→g₂′-proj-p = →l-send p refl λ ()
g₂-proj-q→g₂′-proj-q : (q , project g₂ q) - p→q →l (q , project g₂′ q)
g₂-proj-q→g₂′-proj-q = →l-recv q refl λ ()
c₁ : Configuration n
c₁ = lp ∷ lq ∷ endL ∷ endL ∷ []
cEnd : Configuration n
cEnd = endL ∷ endL ∷ endL ∷ endL ∷ []
c₁→cEnd : c₁ - p→q →c cEnd
c₁→cEnd = →c-comm c₁ (λ ()) refl refl refl g₁-proj-p→end g₁-proj-q→end
g₁↔c₁ : g₁ ↔ c₁
g₁↔c₁ = record { isProj = refls }
where
refls : (p : Fin n) -> lookup c₁ p ≡ project g₁ p
refls zero = refl
refls (suc zero) = refl
refls (suc (suc zero)) = refl
refls (suc (suc (suc zero))) = refl
| 18.27551
| 70
| 0.59464
|
Subsets and Splits
HTML Code Excluding Scripts
The query retrieves a limited set of HTML content entries that are longer than 8 characters and do not contain script tags, offering only basic filtering with minimal analytical value.