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
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
2e1ad682f6e7bd17e316f0c45e921fd71093321d
| 5,246
|
agda
|
Agda
|
UniDB/Subst/Core.agda
|
skeuchel/unidb-agda
|
7ae52205db44ad4f463882ba7e5082120fb76349
|
[
"MIT"
] | null | null | null |
UniDB/Subst/Core.agda
|
skeuchel/unidb-agda
|
7ae52205db44ad4f463882ba7e5082120fb76349
|
[
"MIT"
] | null | null | null |
UniDB/Subst/Core.agda
|
skeuchel/unidb-agda
|
7ae52205db44ad4f463882ba7e5082120fb76349
|
[
"MIT"
] | null | null | null |
module UniDB.Subst.Core where
open import UniDB.Spec public
open import UniDB.Morph.Unit
record Ap (T X : STX) : Set₁ where
field
ap : {Ξ : MOR} {{lkTΞ : Lk T Ξ}} {{upΞ : Up Ξ}}
{γ₁ γ₂ : Dom} (ξ : Ξ γ₁ γ₂) (x : X γ₁) → X γ₂
open Ap {{...}} public
record ApVr (T : STX) {{vrT : Vr T}} {{apTT : Ap T T}} : Set₁ where
field
ap-vr :
{Ξ : MOR} {{lkTΞ : Lk T Ξ}} {{upΞ : Up Ξ}}
{γ₁ γ₂ : Dom} (ξ : Ξ γ₁ γ₂) →
(i : Ix γ₁) → ap {T} ξ (vr i) ≡ lk {T} ξ i
open ApVr {{...}} public
record LkCompAp
(T : STX) {{vrT : Vr T}} {{apTT : Ap T T}}
(Ξ : MOR) {{lkTΞ : Lk T Ξ}} {{upΞ : Up Ξ}} {{compΞ : Comp Ξ}} : Set₁ where
field
lk-⊙-ap : {γ₁ γ₂ γ₃ : Dom} (ξ₁ : Ξ γ₁ γ₂) (ξ₂ : Ξ γ₂ γ₃)
(i : Ix γ₁) → lk {T} (ξ₁ ⊙ ξ₂) i ≡ ap {T} ξ₂ (lk ξ₁ i)
open LkCompAp {{...}} public
record ApIdm
(T : STX) {{vrT : Vr T}}
(X : STX) {{apTX : Ap T X}} : Set₁ where
field
ap-idm :
{Ξ : MOR} {{lkTΞ : Lk T Ξ}} {{upΞ : Up Ξ}} {{idmΞ : Idm Ξ}}
{{lkIdmTΞ : LkIdm T Ξ}} {{upIdmΞ : UpIdm Ξ}}
{γ : Dom} (x : X γ) →
ap {T} (idm {Ξ} γ) x ≡ x
open ApIdm {{...}} public
record ApRel
(T : STX) {{vrT : Vr T}}
(X : STX) {{apTX : Ap T X}} : Set₁ where
field
ap-rel≅ :
{Ξ : MOR} {{lkTΞ : Lk T Ξ}} {{upΞ : Up Ξ}}
{Ζ : MOR} {{lkTΖ : Lk T Ζ}} {{upΖ : Up Ζ}}
{γ₁ γ₂ : Dom} {ξ : Ξ γ₁ γ₂} {ζ : Ζ γ₁ γ₂} (hyp : [ T ] ξ ≅ ζ)
(x : X γ₁) → ap {T} ξ x ≡ ap {T} ζ x
ap-rel≃ : {{wkT : Wk T}}
{Ξ : MOR} {{lkTΞ : Lk T Ξ}} {{upΞ : Up Ξ}} {{lkUpTΞ : LkUp T Ξ}}
{Ζ : MOR} {{lkTΖ : Lk T Ζ}} {{upΖ : Up Ζ}} {{lkUpTΖ : LkUp T Ζ}}
{γ₁ γ₂ : Dom} {ξ : Ξ γ₁ γ₂} {ζ : Ζ γ₁ γ₂} (hyp : [ T ] ξ ≃ ζ)
(x : X γ₁) → ap {T} ξ x ≡ ap {T} ζ x
ap-rel≃ hyp = ap-rel≅ (≃-to-≅` (≃-↑ hyp))
open ApRel {{...}} public
module _
(T : STX) {{vrT : Vr T}} {{wkT : Wk T}}
(X : STX) {{wkX : Wk X}} {{apTX : Ap T X}}
where
record ApWkmWk : Set₁ where
field
ap-wkm-wk₁ :
{Ξ : MOR} {{lkTΞ : Lk T Ξ}} {{upΞ : Up Ξ}} {{wkmΞ : Wkm Ξ}}
{{lkUpTΞ : LkUp T Ξ}} {{lkWkmTΞ : LkWkm T Ξ}}
{γ : Dom} (x : X γ) →
ap {T} (wkm {Ξ} 1) x ≡ wk₁ x
ap-wkm-wk :
{Ξ : MOR} {{lkTΞ : Lk T Ξ}} {{upΞ : Up Ξ}} {{wkmΞ : Wkm Ξ}}
{{lkUpTΞ : LkUp T Ξ}} {{lkWkmTΞ : LkWkm T Ξ}}
{γ : Dom} (δ : Dom) (x : X γ) →
ap {T} (wkm {Ξ} δ) x ≡ wk δ x
open ApWkmWk {{...}} public
module _
(T : STX) {{vrT : Vr T}} {{wkT : Wk T}}
(X : STX) {{wkX : Wk X}} {{apTX : Ap T X}}
where
record ApWk : Set₁ where
field
ap-wk₁ :
{Ξ : MOR} {{lkTΞ : Lk T Ξ}} {{upΞ : Up Ξ}}
{{lkUpTΞ : LkUp T Ξ}}
{γ₁ γ₂ : Dom} (ξ : Ξ γ₁ γ₂) (x : X γ₁) →
ap {T} (ξ ↑₁) (wk₁ x) ≡ wk₁ (ap {T} ξ x)
open ApWk {{...}} public
module _
(T : STX) {{vrT : Vr T}} {{wkT : Wk T}} {{apTT : Ap T T}}
(X : STX) {{apTX : Ap T X}}
where
record ApComp : Set₁ where
field
ap-⊙ :
{Ξ : MOR} {{lkTΞ : Lk T Ξ}} {{upΞ : Up Ξ}} {{compΞ : Comp Ξ}}
{{upCompΞ : UpComp Ξ}} {{lkCompTΞ : LkCompAp T Ξ}}
{γ₁ γ₂ γ₃ : Dom} (ξ₁ : Ξ γ₁ γ₂) (ξ₂ : Ξ γ₂ γ₃) →
(x : X γ₁) → ap {T} (ξ₁ ⊙ ξ₂) x ≡ ap {T} ξ₂ (ap {T} ξ₁ x)
open ApComp {{...}} public
instance
iApIx : Ap Ix Ix
ap {{iApIx}} = lk
iApVrIx : ApVr Ix
ap-vr {{iApVrIx}} ξ i = refl
iApIdmIxIx : ApIdm Ix Ix
ap-idm {{iApIdmIxIx}} {Ξ} = lk-idm {Ix} {Ξ}
iApWkmWkIxIx : ApWkmWk Ix Ix
ap-wkm-wk₁ {{iApWkmWkIxIx}} {Ξ} = lk-wkm {Ix} {Ξ} 1
ap-wkm-wk {{iApWkmWkIxIx}} {Ξ} = lk-wkm {Ix} {Ξ}
iApRelIxIx : ApRel Ix Ix
ap-rel≅ {{iApRelIxIx}} = lk≃ ∘ ≅-to-≃
iApWkIxIx : ApWk Ix Ix
ap-wk₁ {{iApWkIxIx}} {Ξ} ξ i = lk-↑₁-suc {Ix} {Ξ} ξ i
-- TODO: Remove
module _
(T : STX) {{vrT : Vr T}} {{apTT : Ap T T}}
(Ξ : MOR) {{lkTΞ : Lk T Ξ}} {{upΞ : Up Ξ}}
(Ζ : MOR) {{lkTΖ : Lk T Ζ}} {{upΖ : Up Ζ}}
(Θ : MOR) {{lkTΘ : Lk T Θ}} {{upΘ : Up Θ}}
{{hcompΞΖΘ : HComp Ξ Ζ Θ}}
where
record LkHCompAp : Set₁ where
field
lk-⊡-ap : {γ₁ γ₂ γ₃ : Dom} (ξ : Ξ γ₁ γ₂) (ζ : Ζ γ₂ γ₃)
(i : Ix γ₁) → lk {T} {Θ} (ξ ⊡ ζ) i ≡ ap {T} ζ (lk ξ i)
open LkHCompAp {{...}} public
-- TODO: Remove
module _
(T : STX) {{vrT : Vr T}} {{wkT : Wk T}} {{apTT : Ap T T}}
(X : STX) {{apTX : Ap T X}}
where
record ApHComp : Set₁ where
field
ap-⊡ :
{Ξ : MOR} {{lkTΞ : Lk T Ξ}} {{upΞ : Up Ξ}}
{Ζ : MOR} {{lkTΖ : Lk T Ζ}} {{upΖ : Up Ζ}}
{Θ : MOR} {{lkTΘ : Lk T Θ}} {{upΘ : Up Θ}}
{{hcompΞΖΘ : HComp Ξ Ζ Θ}} {{upHCompΞ : UpHComp Ξ Ζ Θ}}
{{lkHCompTΞΖΘ : LkHCompAp T Ξ Ζ Θ}}
{γ₁ γ₂ γ₃ : Dom} (ξ : Ξ γ₁ γ₂) (ζ : Ζ γ₂ γ₃) →
(x : X γ₁) → ap {T} {X} {Θ} (ξ ⊡ ζ) x ≡ ap {T} ζ (ap {T} ξ x)
open ApHComp {{...}} public
-- TODO: Move
module _
{T : STX} {{vrT : Vr T}} {{wkT : Wk T}} {{wkVrT : WkVr T}}
{X : STX} {{wkX : Wk X}} {{apTX : Ap T X}} {{apRelTX : ApRel T X}} {{apIdmTX : ApIdm T X}}
{Ξ : MOR} {{lkTΞ : Lk T Ξ}} {{upΞ : Up Ξ}} {{idmΞ : Idm Ξ}} {{lkIdmTΞ : LkIdm T Ξ}}
{{lkUpTΞ : LkUp T Ξ}}
where
ap-idm` : {γ : Dom} (x : X γ) → ap {T} (idm {Ξ} γ) x ≡ x
ap-idm` {γ} x = begin
ap {T} (idm {Ξ} γ) x ≡⟨ ap-rel≃ {T} lem x ⟩
ap {T} (idm {Unit} γ) x ≡⟨ ap-idm {T} x ⟩
x ∎
where
lem : [ T ] idm {Ξ} γ ≃ unit
lk≃ lem = lk-idm {T} {Ξ}
| 29.977143
| 92
| 0.454823
|
1e8ee9f27cc98fba05a352fa5b08851ae71a63ad
| 2,323
|
agda
|
Agda
|
theorems/homotopy/elims/Lemmas.agda
|
AntoineAllioux/HoTT-Agda
|
1037d82edcf29b620677a311dcfd4fc2ade2faa6
|
[
"MIT"
] | 294
|
2015-01-09T16:23:23.000Z
|
2022-03-20T13:54:45.000Z
|
theorems/homotopy/elims/Lemmas.agda
|
AntoineAllioux/HoTT-Agda
|
1037d82edcf29b620677a311dcfd4fc2ade2faa6
|
[
"MIT"
] | 31
|
2015-03-05T20:09:00.000Z
|
2021-10-03T19:15:25.000Z
|
theorems/homotopy/elims/Lemmas.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.elims.Lemmas where
fill-upper-right : ∀ {i j} {A : Type i} {B : A → Type j}
{a₀₀ a₀₁ a₁₀ a₁₁ : A}
{p₀₋ : a₀₀ == a₀₁} {p₋₀ : a₀₀ == a₁₀} {p₋₁ : a₀₁ == a₁₁} {p₁₋ : a₁₀ == a₁₁}
(sq : Square p₀₋ p₋₀ p₋₁ p₁₋)
{b₀₀ : B a₀₀} {b₀₁ : B a₀₁} {b₁₀ b₁₀' : B a₁₀} {b₁₁ : B a₁₁}
(q₀₋ : b₀₀ == b₀₁ [ B ↓ p₀₋ ]) (q₋₀ : b₀₀ == b₁₀ [ B ↓ p₋₀ ])
(q₋₁ : b₀₁ == b₁₁ [ B ↓ p₋₁ ]) (q₁₋ : b₁₀' == b₁₁ [ B ↓ p₁₋ ])
→ Σ (b₁₀ == b₁₀')
(λ r → SquareOver B sq q₀₋ q₋₀ q₋₁ (r ◃ q₁₋))
fill-upper-right ids idp idp idp idp = (idp , ids)
fill-upper-right-unique : ∀ {i j} {A : Type i} {B : A → Type j}
{a₀₀ a₀₁ a₁₀ a₁₁ : A}
{p₀₋ : a₀₀ == a₀₁} {p₋₀ : a₀₀ == a₁₀} {p₋₁ : a₀₁ == a₁₁} {p₁₋ : a₁₀ == a₁₁}
(sq : Square p₀₋ p₋₀ p₋₁ p₁₋)
{b₀₀ : B a₀₀} {b₀₁ : B a₀₁} {b₁₀ b₁₀' : B a₁₀} {b₁₁ : B a₁₁}
(q₀₋ : b₀₀ == b₀₁ [ B ↓ p₀₋ ]) (q₋₀ : b₀₀ == b₁₀ [ B ↓ p₋₀ ])
(q₋₁ : b₀₁ == b₁₁ [ B ↓ p₋₁ ]) (q₁₋ : b₁₀' == b₁₁ [ B ↓ p₁₋ ])
(r : b₁₀ == b₁₀')
→ SquareOver B sq q₀₋ q₋₀ q₋₁ (r ◃ q₁₋)
→ r == fst (fill-upper-right sq q₀₋ q₋₀ q₋₁ q₁₋)
fill-upper-right-unique {B = B} ids idp idp idp idp r sq' =
! (◃idp {B = B} r) ∙ ! (horiz-degen-path sq')
fill-upper-left : ∀ {i j} {A : Type i} {B : A → Type j}
{a₀₀ a₀₁ a₁₀ a₁₁ : A}
{p₀₋ : a₀₀ == a₀₁} {p₋₀ : a₀₀ == a₁₀} {p₋₁ : a₀₁ == a₁₁} {p₁₋ : a₁₀ == a₁₁}
(sq : Square p₀₋ p₋₀ p₋₁ p₁₋)
{b₀₀ b₀₀' : B a₀₀} {b₀₁ : B a₀₁} {b₁₀ : B a₁₀} {b₁₁ : B a₁₁}
(q₀₋ : b₀₀' == b₀₁ [ B ↓ p₀₋ ]) (q₋₀ : b₀₀ == b₁₀ [ B ↓ p₋₀ ])
(q₋₁ : b₀₁ == b₁₁ [ B ↓ p₋₁ ]) (q₁₋ : b₁₀ == b₁₁ [ B ↓ p₁₋ ])
→ Σ (b₀₀ == b₀₀')
(λ r → SquareOver B sq (r ◃ q₀₋) q₋₀ q₋₁ q₁₋)
fill-upper-left ids idp idp idp idp = (idp , ids)
fill-upper-left-unique : ∀ {i j} {A : Type i} {B : A → Type j}
{a₀₀ a₀₁ a₁₀ a₁₁ : A}
{p₀₋ : a₀₀ == a₀₁} {p₋₀ : a₀₀ == a₁₀} {p₋₁ : a₀₁ == a₁₁} {p₁₋ : a₁₀ == a₁₁}
(sq : Square p₀₋ p₋₀ p₋₁ p₁₋)
{b₀₀ b₀₀' : B a₀₀} {b₀₁ : B a₀₁} {b₁₀ : B a₁₀} {b₁₁ : B a₁₁}
(q₀₋ : b₀₀' == b₀₁ [ B ↓ p₀₋ ]) (q₋₀ : b₀₀ == b₁₀ [ B ↓ p₋₀ ])
(q₋₁ : b₀₁ == b₁₁ [ B ↓ p₋₁ ]) (q₁₋ : b₁₀ == b₁₁ [ B ↓ p₁₋ ])
(r : b₀₀ == b₀₀')
→ SquareOver B sq (r ◃ q₀₋) q₋₀ q₋₁ q₁₋
→ r == fst (fill-upper-left sq q₀₋ q₋₀ q₋₁ q₁₋)
fill-upper-left-unique {B = B} ids idp idp idp idp r sq' =
! (◃idp {B = B} r) ∙ horiz-degen-path sq'
| 43.018519
| 77
| 0.475678
|
1cf1eeb474ab642b7bbe0caf050eee112b3ccf39
| 8,057
|
agda
|
Agda
|
core/lib/types/Suspension/IteratedTrunc.agda
|
AntoineAllioux/HoTT-Agda
|
1037d82edcf29b620677a311dcfd4fc2ade2faa6
|
[
"MIT"
] | 294
|
2015-01-09T16:23:23.000Z
|
2022-03-20T13:54:45.000Z
|
core/lib/types/Suspension/IteratedTrunc.agda
|
AntoineAllioux/HoTT-Agda
|
1037d82edcf29b620677a311dcfd4fc2ade2faa6
|
[
"MIT"
] | 31
|
2015-03-05T20:09:00.000Z
|
2021-10-03T19:15:25.000Z
|
core/lib/types/Suspension/IteratedTrunc.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 lib.Basics
open import lib.types.Bool
open import lib.types.FunctionSeq
open import lib.types.Pointed
open import lib.types.Suspension.Core
open import lib.types.Suspension.Iterated
open import lib.types.Suspension.Trunc
open import lib.types.TLevel
open import lib.types.Truncation
module lib.types.Suspension.IteratedTrunc where
module _ {i} (A : Type i) (m : ℕ₋₂) where
Susp^-Trunc-swap : ∀ (n : ℕ)
→ Susp^ n (Trunc m A)
→ Trunc (⟨ n ⟩₋₂ +2+ m) (Susp^ n A)
Susp^-Trunc-swap O = idf _
Susp^-Trunc-swap (S n) =
Susp-Trunc-swap (Susp^ n A) (⟨ n ⟩₋₂ +2+ m) ∘
Susp-fmap (Susp^-Trunc-swap n)
private
to : ∀ n → Trunc (⟨ n ⟩₋₂ +2+ m) (Susp^ n (Trunc m A)) → Trunc (⟨ n ⟩₋₂ +2+ m) (Susp^ n A)
to n = Trunc-rec {{Trunc-level}} (Susp^-Trunc-swap n)
from : ∀ n → Trunc (⟨ n ⟩₋₂ +2+ m) (Susp^ n A) → Trunc (⟨ n ⟩₋₂ +2+ m) (Susp^ n (Trunc m A))
from n = Trunc-fmap (Susp^-fmap n [_])
abstract
from-Susp^-Trunc-swap : ∀ n → from n ∘ Susp^-Trunc-swap n ∼ [_]
from-Susp^-Trunc-swap O =
Trunc-elim
{P = λ s → from 0 (Susp^-Trunc-swap 0 s) == [ s ]}
{{λ s → =-preserves-level Trunc-level}}
(λ a → idp)
from-Susp^-Trunc-swap (S n) x =
(from (S n) $
Susp-Trunc-swap (Susp^ n A) (⟨ n ⟩₋₂ +2+ m) $
Susp-fmap (Susp^-Trunc-swap n) x)
=⟨ ! $ Susp-Trunc-swap-natural (Susp^-fmap n [_]) (⟨ n ⟩₋₂ +2+ m) $
Susp-fmap (Susp^-Trunc-swap n) x ⟩
(Susp-Trunc-swap (Susp^ n (Trunc m A)) (⟨ n ⟩₋₂ +2+ m) $
Susp-fmap (Trunc-fmap (Susp^-fmap n [_])) $
Susp-fmap (Susp^-Trunc-swap n) x)
=⟨ ap (Susp-Trunc-swap (Susp^ n (Trunc m A)) (⟨ n ⟩₋₂ +2+ m)) $
! $ Susp-fmap-∘ (Trunc-fmap (Susp^-fmap n [_])) (Susp^-Trunc-swap n) x ⟩
(Susp-Trunc-swap (Susp^ n (Trunc m A)) (⟨ n ⟩₋₂ +2+ m) $
Susp-fmap (from n ∘ Susp^-Trunc-swap n) x)
=⟨ ap (Susp-Trunc-swap (Susp^ n (Trunc m A)) (⟨ n ⟩₋₂ +2+ m)) $
ap (λ f → Susp-fmap f x) (λ= (from-Susp^-Trunc-swap n)) ⟩
Susp-Trunc-swap (Susp^ n (Trunc m A)) (⟨ n ⟩₋₂ +2+ m) (Susp-fmap [_] x)
=⟨ Susp-Trunc-swap-Susp-fmap-trunc (Susp^ n (Trunc m A)) (⟨ n ⟩₋₂ +2+ m) x ⟩
[ x ] =∎
from-to : ∀ n → from n ∘ to n ∼ idf _
from-to n =
Trunc-elim
{P = λ t → from n (to n t) == t}
{{λ t → =-preserves-level Trunc-level}}
(from-Susp^-Trunc-swap n)
Susp^-Trunc-swap-Susp^-fmap-trunc : ∀ n →
Susp^-Trunc-swap n ∘ Susp^-fmap n [_] ∼ [_]
Susp^-Trunc-swap-Susp^-fmap-trunc 0 s = idp
Susp^-Trunc-swap-Susp^-fmap-trunc (S n) s =
(Susp-Trunc-swap (Susp^ n A) (⟨ n ⟩₋₂ +2+ m) $
Susp-fmap (Susp^-Trunc-swap n) $
Susp^-fmap (S n) [_] s)
=⟨ ap (Susp-Trunc-swap (Susp^ n A) (⟨ n ⟩₋₂ +2+ m)) $
! $ Susp-fmap-∘ (Susp^-Trunc-swap n) (Susp^-fmap n [_]) s ⟩
(Susp-Trunc-swap (Susp^ n A) (⟨ n ⟩₋₂ +2+ m) $
Susp-fmap (Susp^-Trunc-swap n ∘ Susp^-fmap n [_]) s)
=⟨ ap (Susp-Trunc-swap (Susp^ n A) (⟨ n ⟩₋₂ +2+ m)) $
app= (ap Susp-fmap (λ= (Susp^-Trunc-swap-Susp^-fmap-trunc n))) s ⟩
Susp-Trunc-swap (Susp^ n A) (⟨ n ⟩₋₂ +2+ m) (Susp-fmap [_] s)
=⟨ Susp-Trunc-swap-Susp-fmap-trunc (Susp^ n A) (⟨ n ⟩₋₂ +2+ m) s ⟩
[ s ] =∎
to-from : ∀ n → to n ∘ from n ∼ idf _
to-from n = Trunc-elim {{λ t → =-preserves-level Trunc-level}}
(Susp^-Trunc-swap-Susp^-fmap-trunc n)
Susp^-Trunc-equiv : ∀ (n : ℕ)
→ Trunc (⟨ n ⟩₋₂ +2+ m) (Susp^ n (Trunc m A)) ≃ Trunc (⟨ n ⟩₋₂ +2+ m) (Susp^ n A)
Susp^-Trunc-equiv n = equiv (to n) (from n) (to-from n) (from-to n)
module _ {i} (X : Ptd i) (m : ℕ₋₂) where
Susp^-Trunc-swap-pt : ∀ (n : ℕ)
→ Susp^-Trunc-swap (de⊙ X) m n (pt (⊙Susp^ n (⊙Trunc m X))) ==
pt (⊙Trunc (⟨ n ⟩₋₂ +2+ m) (⊙Susp^ n X))
Susp^-Trunc-swap-pt O = idp
Susp^-Trunc-swap-pt (S n) = idp
⊙Susp^-Trunc-swap : ∀ (n : ℕ)
→ ⊙Susp^ n (⊙Trunc m X) ⊙→ ⊙Trunc (⟨ n ⟩₋₂ +2+ m) (⊙Susp^ n X)
⊙Susp^-Trunc-swap n = Susp^-Trunc-swap (de⊙ X) m n , Susp^-Trunc-swap-pt n
⊙Susp^-⊙Trunc-equiv : ∀ (n : ℕ)
→ ⊙Trunc (⟨ n ⟩₋₂ +2+ m) (⊙Susp^ n (⊙Trunc m X)) ⊙≃ ⊙Trunc (⟨ n ⟩₋₂ +2+ m) (⊙Susp^ n X)
⊙Susp^-⊙Trunc-equiv n =
⊙to , snd (Susp^-Trunc-equiv (de⊙ X) m n)
where
⊙to : ⊙Trunc (⟨ n ⟩₋₂ +2+ m) (⊙Susp^ n (⊙Trunc m X))
⊙→ ⊙Trunc (⟨ n ⟩₋₂ +2+ m) (⊙Susp^ n X)
⊙to = ⊙Trunc-rec {{Trunc-level}} (⊙Susp^-Trunc-swap n)
module _ {i} {X Y : Ptd i} (f : X ⊙→ Y) (m : ℕ₋₂) where
⊙Susp^-Trunc-swap-natural : ∀ (n : ℕ)
→ ⊙Susp^-Trunc-swap Y m n ◃⊙∘
⊙Susp^-fmap n (⊙Trunc-fmap f) ◃⊙idf
=⊙∘
⊙Trunc-fmap (⊙Susp^-fmap n f) ◃⊙∘
⊙Susp^-Trunc-swap X m n ◃⊙idf
⊙Susp^-Trunc-swap-natural O = =⊙∘-in (⊙λ= (⊙∘-unit-l _))
⊙Susp^-Trunc-swap-natural (S n) =
⊙Susp^-Trunc-swap Y m (S n) ◃⊙∘
⊙Susp^-fmap (S n) (⊙Trunc-fmap f) ◃⊙idf
=⊙∘⟨ 0 & 1 & ⊙expand $
⊙Susp-Trunc-swap (Susp^ n (de⊙ Y)) (⟨ n ⟩₋₂ +2+ m) ◃⊙∘
⊙Susp-fmap (Susp^-Trunc-swap (de⊙ Y) m n) ◃⊙idf ⟩
⊙Susp-Trunc-swap (Susp^ n (de⊙ Y)) (⟨ n ⟩₋₂ +2+ m) ◃⊙∘
⊙Susp-fmap (Susp^-Trunc-swap (de⊙ Y) m n) ◃⊙∘
⊙Susp^-fmap (S n) (⊙Trunc-fmap f) ◃⊙idf
=⊙∘⟨ 1 & 2 & ⊙Susp-fmap-seq-=⊙∘ $
de⊙-seq-=⊙∘ $ ⊙Susp^-Trunc-swap-natural n ⟩
⊙Susp-Trunc-swap (Susp^ n (de⊙ Y)) (⟨ n ⟩₋₂ +2+ m) ◃⊙∘
⊙Susp-fmap (Trunc-fmap (Susp^-fmap n (fst f))) ◃⊙∘
⊙Susp-fmap (Susp^-Trunc-swap (de⊙ X) m n) ◃⊙idf
=⊙∘⟨ 0 & 2 & =⊙∘-in
{gs = ⊙Trunc-fmap (⊙Susp-fmap (Susp^-fmap n (fst f))) ◃⊙∘
⊙Susp-Trunc-swap (Susp^ n (de⊙ X)) (⟨ n ⟩₋₂ +2+ m) ◃⊙idf} $
⊙Susp-Trunc-swap-natural (Susp^-fmap n (fst f)) (⟨ n ⟩₋₂ +2+ m) ⟩
⊙Trunc-fmap (⊙Susp-fmap (Susp^-fmap n (fst f))) ◃⊙∘
⊙Susp-Trunc-swap (Susp^ n (de⊙ X)) (⟨ n ⟩₋₂ +2+ m) ◃⊙∘
⊙Susp-fmap (Susp^-Trunc-swap (de⊙ X) m n) ◃⊙idf
=⊙∘⟨ 1 & 2 & ⊙contract ⟩
⊙Trunc-fmap (⊙Susp^-fmap (S n) f) ◃⊙∘
⊙Susp^-Trunc-swap X m (S n) ◃⊙idf ∎⊙∘
⊙Susp^-⊙Trunc-equiv-natural : ∀ (n : ℕ)
→ ⊙–> (⊙Susp^-⊙Trunc-equiv Y m n) ◃⊙∘
⊙Trunc-fmap (⊙Susp^-fmap n (⊙Trunc-fmap f)) ◃⊙idf
=⊙∘
⊙Trunc-fmap (⊙Susp^-fmap n f) ◃⊙∘
⊙–> (⊙Susp^-⊙Trunc-equiv X m n) ◃⊙idf
⊙Susp^-⊙Trunc-equiv-natural n = =⊙∘-in $
⊙–> (⊙Susp^-⊙Trunc-equiv Y m n) ⊙∘
⊙Trunc-fmap (⊙Susp^-fmap n (⊙Trunc-fmap f))
=⟨ ⊙Trunc-rec-⊙Trunc-fmap {{Trunc-level}}
(⊙Susp^-Trunc-swap Y m n)
(⊙Susp^-fmap n (⊙Trunc-fmap f)) ⟩
⊙Trunc-rec {{Trunc-level}} (⊙Susp^-Trunc-swap Y m n ⊙∘ ⊙Susp^-fmap n (⊙Trunc-fmap f))
=⟨ ap (⊙Trunc-rec {{Trunc-level}}) $
=⊙∘-out $ ⊙Susp^-Trunc-swap-natural n ⟩
⊙Trunc-rec {{Trunc-level}} (⊙Trunc-fmap (⊙Susp^-fmap n f) ⊙∘ ⊙Susp^-Trunc-swap X m n)
=⟨ ⊙Trunc-rec-post-⊙∘ {{Trunc-level}} {{Trunc-level}}
(⊙Trunc-fmap (⊙Susp^-fmap n f))
(⊙Susp^-Trunc-swap X m n) ⟩
⊙Trunc-fmap (⊙Susp^-fmap n f) ⊙∘ ⊙–> (⊙Susp^-⊙Trunc-equiv X m n) =∎
⊙Susp^-⊙Trunc-equiv-natural' : ∀ (n : ℕ)
→ ⊙<– (⊙Susp^-⊙Trunc-equiv Y m n) ◃⊙∘
⊙Trunc-fmap (⊙Susp^-fmap n f) ◃⊙idf
=⊙∘
⊙Trunc-fmap (⊙Susp^-fmap n (⊙Trunc-fmap f)) ◃⊙∘
⊙<– (⊙Susp^-⊙Trunc-equiv X m n) ◃⊙idf
⊙Susp^-⊙Trunc-equiv-natural' n =
⊙<– (⊙Susp^-⊙Trunc-equiv Y m n) ◃⊙∘
⊙Trunc-fmap (⊙Susp^-fmap n f) ◃⊙idf
=⊙∘⟨ 2 & 0 & !⊙∘ $ ⊙<–-inv-r-=⊙∘ (⊙Susp^-⊙Trunc-equiv X m n) ⟩
⊙<– (⊙Susp^-⊙Trunc-equiv Y m n) ◃⊙∘
⊙Trunc-fmap (⊙Susp^-fmap n f) ◃⊙∘
⊙–> (⊙Susp^-⊙Trunc-equiv X m n) ◃⊙∘
⊙<– (⊙Susp^-⊙Trunc-equiv X m n) ◃⊙idf
=⊙∘⟨ 1 & 2 & !⊙∘ $ ⊙Susp^-⊙Trunc-equiv-natural n ⟩
⊙<– (⊙Susp^-⊙Trunc-equiv Y m n) ◃⊙∘
⊙–> (⊙Susp^-⊙Trunc-equiv Y m n) ◃⊙∘
⊙Trunc-fmap (⊙Susp^-fmap n (⊙Trunc-fmap f)) ◃⊙∘
⊙<– (⊙Susp^-⊙Trunc-equiv X m n) ◃⊙idf
=⊙∘⟨ 0 & 2 & ⊙<–-inv-l-=⊙∘ (⊙Susp^-⊙Trunc-equiv Y m n) ⟩
⊙Trunc-fmap (⊙Susp^-fmap n (⊙Trunc-fmap f)) ◃⊙∘
⊙<– (⊙Susp^-⊙Trunc-equiv X m n) ◃⊙idf ∎⊙∘
| 42.856383
| 96
| 0.48914
|
1e927dca48e9ea6b6b2d06784b58bdb668cc1033
| 3,825
|
agda
|
Agda
|
src/Examples/TreeSum.agda
|
jonsterling/agda-calf
|
e51606f9ca18d8b4cf9a63c2d6caa2efc5516146
|
[
"Apache-2.0"
] | 29
|
2021-07-14T03:18:28.000Z
|
2022-03-22T20:35:11.000Z
|
src/Examples/TreeSum.agda
|
jonsterling/agda-calf
|
e51606f9ca18d8b4cf9a63c2d6caa2efc5516146
|
[
"Apache-2.0"
] | null | null | null |
src/Examples/TreeSum.agda
|
jonsterling/agda-calf
|
e51606f9ca18d8b4cf9a63c2d6caa2efc5516146
|
[
"Apache-2.0"
] | 2
|
2021-10-06T10:28:24.000Z
|
2022-01-29T08:12:01.000Z
|
{-# OPTIONS --prop --rewriting #-}
module Examples.TreeSum where
open import Calf.CostMonoid
open import Calf.CostMonoids using (ℕ²-ParCostMonoid)
parCostMonoid = ℕ²-ParCostMonoid
open ParCostMonoid parCostMonoid
open import Calf costMonoid
open import Calf.ParMetalanguage parCostMonoid
open import Calf.Types.Nat
open import Calf.Types.Bounded costMonoid
open import Relation.Binary.PropositionalEquality as Eq using (_≡_; refl; _≢_; module ≡-Reasoning)
open import Data.Nat as Nat using (_+_; _⊔_)
open import Data.Nat.Properties as N using ()
open import Data.Product
add : cmp (Π nat λ _ → Π nat λ _ → F nat)
add m n = step (F nat) (1 , 1) (ret (m + n))
add/cost : cmp (Π nat λ _ → Π nat λ _ → cost)
add/cost m n = (1 , 1) ⊕ 𝟘
add/cost/closed : cmp (Π nat λ _ → Π nat λ _ → cost)
add/cost/closed m n = (1 , 1)
add/cost≤add/cost/closed : ∀ m n → ◯ (add/cost m n ≤ add/cost/closed m n)
add/cost≤add/cost/closed m n u = ≤-reflexive (⊕-identityʳ (1 , 1))
add≤add/cost : ∀ m n → IsBounded nat (add m n) (add/cost m n)
add≤add/cost m n = bound/step (1 , 1) _ bound/ret
add≤add/cost/closed : ∀ m n → IsBounded nat (add m n) (add/cost/closed m n)
add≤add/cost/closed m n = bound/relax (add/cost≤add/cost/closed m n) (add≤add/cost m n)
data Tree : Set where
leaf : val nat → Tree
node : Tree → Tree → Tree
tree : tp pos
tree = U (meta Tree)
sum : cmp (Π tree λ _ → F nat)
sum (leaf x) = ret x
sum (node t₁ t₂) =
bind (F nat) (sum t₁ & sum t₂) λ (n₁ , n₂) →
add n₁ n₂
sum/total : ∀ t → ◯ (∃ λ n → sum t ≡ ret n)
sum/total (leaf x) u = x , refl
sum/total (node t₁ t₂) u =
let (n₁ , ≡₁) = sum/total t₁ u
(n₂ , ≡₂) = sum/total t₂ u
in
n₁ + n₂ , (
let open ≡-Reasoning in
begin
(bind (F nat) (sum t₁ & sum t₂) λ (n₁ , n₂) →
add n₁ n₂)
≡⟨ Eq.cong₂ (λ e₁ e₂ → bind (F nat) (e₁ & e₂) _) ≡₁ ≡₂ ⟩
add n₁ n₂
≡⟨⟩
step (F nat) (1 , 1) (ret (n₁ + n₂))
≡⟨ step/ext (F nat) _ (1 , 1) u ⟩
ret (n₁ + n₂)
∎
)
sum/cost : cmp (Π tree λ _ → cost)
sum/cost (leaf x) = 𝟘
sum/cost (node t₁ t₂) =
bind cost (sum t₁ & sum t₂) λ (n₁ , n₂) → (sum/cost t₁ ⊗ sum/cost t₂) ⊕
add/cost/closed n₁ n₂
size : val tree → val nat
size (leaf x) = 0
size (node t₁ t₂) = suc (size t₁ + size t₂)
depth : val tree → val nat
depth (leaf x) = 0
depth (node t₁ t₂) = suc (depth t₁ ⊔ depth t₂)
sum/cost/closed : cmp (Π tree λ _ → cost)
sum/cost/closed t = size t , depth t
sum/cost≤sum/cost/closed : ∀ t → ◯ (sum/cost t ≤ sum/cost/closed t)
sum/cost≤sum/cost/closed (leaf x) u = ≤-refl
sum/cost≤sum/cost/closed (node t₁ t₂) u =
let (_ , ≡₁) = sum/total t₁ u
(_ , ≡₂) = sum/total t₂ u
in
begin
sum/cost (node t₁ t₂)
≡⟨⟩
(bind cost (sum t₁ & sum t₂) λ (n₁ , n₂) → (sum/cost t₁ ⊗ sum/cost t₂) ⊕
add/cost/closed n₁ n₂)
≡⟨ Eq.cong₂ (λ e₁ e₂ → bind cost (e₁ & e₂) λ (n₁ , n₂) → (sum/cost t₁ ⊗ sum/cost t₂) ⊕ _) ≡₁ ≡₂ ⟩
sum/cost t₁ ⊗ sum/cost t₂ ⊕ (1 , 1)
≤⟨ ⊕-monoˡ-≤ (1 , 1) (⊗-mono-≤ (sum/cost≤sum/cost/closed t₁ u) (sum/cost≤sum/cost/closed t₂ u)) ⟩
sum/cost/closed t₁ ⊗ sum/cost/closed t₂ ⊕ (1 , 1)
≡⟨⟩
(size t₁ , depth t₁) ⊗ (size t₂ , depth t₂) ⊕ (1 , 1)
≡⟨⟩
size t₁ + size t₂ + 1 , depth t₁ ⊔ depth t₂ + 1
≡⟨ Eq.cong₂ _,_ (N.+-comm _ 1) (N.+-comm _ 1) ⟩
suc (size t₁ + size t₂) , suc (depth t₁ ⊔ depth t₂)
≡⟨⟩
sum/cost/closed (node t₁ t₂)
∎
where open ≤-Reasoning
sum≤sum/cost : ∀ t → IsBounded nat (sum t) (sum/cost t)
sum≤sum/cost (leaf x) = bound/ret
sum≤sum/cost (node t₁ t₂) =
bound/bind (sum/cost t₁ ⊗ sum/cost t₂) _ (bound/par (sum≤sum/cost t₁) (sum≤sum/cost t₂)) λ (n₁ , n₂) →
add≤add/cost/closed n₁ n₂
sum≤sum/cost/closed : ∀ t → IsBounded nat (sum t) (sum/cost/closed t)
sum≤sum/cost/closed t = bound/relax (sum/cost≤sum/cost/closed t) (sum≤sum/cost t)
| 30.846774
| 104
| 0.595033
|
1e7a6ee7e0e427ccb1c197b3f761f3e1912f2eac
| 4,916
|
agda
|
Agda
|
src/LibraBFT/Impl/Storage/DiemDB/LedgerStore/LedgerStore.agda
|
LaudateCorpus1/bft-consensus-agda
|
a4674fc473f2457fd3fe5123af48253cfb2404ef
|
[
"UPL-1.0"
] | null | null | null |
src/LibraBFT/Impl/Storage/DiemDB/LedgerStore/LedgerStore.agda
|
LaudateCorpus1/bft-consensus-agda
|
a4674fc473f2457fd3fe5123af48253cfb2404ef
|
[
"UPL-1.0"
] | null | null | null |
src/LibraBFT/Impl/Storage/DiemDB/LedgerStore/LedgerStore.agda
|
LaudateCorpus1/bft-consensus-agda
|
a4674fc473f2457fd3fe5123af48253cfb2404ef
|
[
"UPL-1.0"
] | null | null | null |
{- 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.Types
open import LibraBFT.Impl.OBM.Logging.Logging
open import LibraBFT.ImplShared.Consensus.Types hiding (getEpoch)
open import Optics.All
import Util.KVMap as Map
open import Util.Prelude
------------------------------------------------------------------------------
open import Data.String using (String)
module LibraBFT.Impl.Storage.DiemDB.LedgerStore.LedgerStore where
record EpochEndingLedgerInfoIter : Set where
constructor EpochEndingLedgerInfoIter∙new
field
_eeliiObmLIWS : List LedgerInfoWithSignatures
open EpochEndingLedgerInfoIter public
new : LedgerStore
new = mkLedgerStore Map.empty Map.empty nothing
-- OBM-LBFT-DIFF : the entire Haskell impl file is VERY different from the Rust code.
-- The Agda below mirrors Haskell.
getEpoch : LedgerStore → Version → Either ErrLog Epoch
getEpoch self version =
maybeS (Map.lookup version (self ^∙ lsObmVersionToEpoch))
-- COMMENT FROM RUST CODE:
-- There should be a genesis LedgerInfo at version 0.
-- This normally doesn't happen.
-- This part of impl does not need to rely on this assumption.
(pure 0)
pure
getEpochEndingLedgerInfo : LedgerStore → Version → Either ErrLog LedgerInfoWithSignatures
getEpochEndingLedgerInfo self version = do
epoch ← getEpoch self version
case Map.lookup epoch (self ^∙ lsObmEpochToLIWS) of λ where
nothing → Left fakeErr -- ["DiemDbError::NotFound", "LedgerInfo for epoch", lsE epoch]
(just li) →
grd‖ li ^∙ liwsLedgerInfo ∙ liVersion /= version ≔
Left fakeErr --["epoch did not end at version", lsE epoch, lsVersion version]
‖ is-nothing (li ^∙ liwsLedgerInfo ∙ liNextEpochState) ≔
Left fakeErr -- ["not an epoch change at version", lsVersion version]
‖ otherwise≔
pure li
--where
-- here t = "LedgerStore":"getEpochEndingLedgerInfo":t
getEpochState : LedgerStore → Epoch → Either ErrLog EpochState
getEpochState self epoch = do
lcheck (epoch >? 0) (here' ("EpochState only queryable for epoch >= 1" {-∷ lsE epoch-} ∷ []))
case Map.lookup (epoch ∸ 1) (self ^∙ lsObmEpochToLIWS) of λ where
nothing → Left fakeErr --[ "DiemDbError::NotFound"
--, "last LedgerInfo of epoch", lsE (epoch - 1) ]))
(just ledgerInfoWithSigs) →
maybeS (ledgerInfoWithSigs ^∙ liwsNextEpochState)
(Left fakeErr) --[ "last LedgerInfo in epoch must carry nextEpochState"
--, lsE epoch, lsLI (ledgerInfoWithSigs^.liwsLedgerInfo) ]
pure
where
here' : List String → List String
here' t = "LedgerStore" ∷ "getEPochState" ∷ t
-- iterator that yields epoch ending ledger infos
-- starting from `start_epoch`
-- ends at the one before `end_epoch`
getEpochEndingLedgerInfoIter
: LedgerStore → Epoch → Epoch
→ Either ErrLog EpochEndingLedgerInfoIter
getEpochEndingLedgerInfoIter self startEpoch endEpoch =
-- TODO-2: prove endEpoch > 0
-- Use of monus in context where it is not clear that endEpoch > 0.
-- If not, Agda and Haskell code would behave differently.
-- TODO-2: IMPL-DIFF: Haskell uses a list comprehension; Agda uses homegrown 'fromToList'
-- The combination of monus and fromToList risks misunderstanding/misuse of fromToList later.
-- Ranges would differ in Haskell and Agda if, say, startEpoch were negative and endEpoch was 0.
-- It could be correct and verified in Agda, but wrong in Haskell
-- (e.g., if the Haskell code accidentally calculates a negative epoch).
EpochEndingLedgerInfoIter∙new <$> (foldM) go [] (fromToList startEpoch (endEpoch ∸ 1))
where
go : List LedgerInfoWithSignatures → Epoch → Either ErrLog (List LedgerInfoWithSignatures)
go acc e = maybeS (Map.lookup e (self ^∙ lsObmEpochToLIWS))
(Left fakeErr) --[ "LedgerStore", "getEpochEndingLedgerInfoIter"
--, "no LIWS for epoch", lsE e ]
(λ x → Right (acc ++ (x ∷ []))) -- TODO
putLedgerInfo : LedgerStore → LedgerInfoWithSignatures → Either ErrLog LedgerStore
putLedgerInfo self ledgerInfoWithSigs =
let ledgerInfo = ledgerInfoWithSigs ^∙ liwsLedgerInfo
in pure
$ mkLedgerStore
((if ledgerInfo ^∙ liEndsEpoch
then Map.insert (ledgerInfo ^∙ liVersion) (ledgerInfo ^∙ liEpoch)
else identity)
(self ^∙ lsObmVersionToEpoch))
(Map.insert (ledgerInfo ^∙ liEpoch) ledgerInfoWithSigs
(self ^∙ lsObmEpochToLIWS))
(self ^∙ lsLatestLedgerInfo)
obmEELIICollect : EpochEndingLedgerInfoIter → List LedgerInfoWithSignatures
obmEELIICollect = _eeliiObmLIWS
| 45.943925
| 111
| 0.68572
|
04061c9f92aa3df636b4a963f13a67e151e6acdc
| 885
|
agda
|
Agda
|
test/succeed/Issue553c.agda
|
asr/agda-kanso
|
aa10ae6a29dc79964fe9dec2de07b9df28b61ed5
|
[
"MIT"
] | 1
|
2018-10-10T17:08:44.000Z
|
2018-10-10T17:08:44.000Z
|
test/succeed/Issue553c.agda
|
np/agda-git-experiment
|
20596e9dd9867166a64470dd24ea68925ff380ce
|
[
"MIT"
] | null | null | null |
test/succeed/Issue553c.agda
|
np/agda-git-experiment
|
20596e9dd9867166a64470dd24ea68925ff380ce
|
[
"MIT"
] | null | null | null |
-- Andreas, 2012-01-17
-- {-# OPTIONS -v tc.proj.like:50 #-}
-- {-# OPTIONS -v tc.conv.atom:50 #-}
module Issue553c where
postulate
A : Set
a : A
data Bool : Set where
true false : Bool
data WrapBool (C : Set) : Set where
wrap : Bool -> WrapBool C
-- a projection-like function (must not be constructor-headed!)
-- the dummy C is to make Agda accept f as projection like
f : {C : Set} -> WrapBool C -> A
f (wrap true) = a
f (wrap false) = a
data _≡_ {A : Set}(a : A) : A -> Set where
refl : a ≡ a
-- it is important that f does not reduce, in order to enter compareAtom
test : (b : Bool) -> f {C = A} (wrap b) ≡ f (wrap b)
test b = refl
-- An internal error has occurred. Please report this as a bug.
-- Location of the error: src/full/Agda/TypeChecking/Conversion.hs:335
-- the problem is fixed now, since f is no longer projection-like
-- because of deep matching
| 27.65625
| 72
| 0.654237
|
4be7cb29ed3cefe94f434c45a13a9405f63c0d76
| 604
|
agda
|
Agda
|
test/Succeed/Issue2168b.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
test/Succeed/Issue2168b.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
test/Succeed/Issue2168b.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
-- Andreas, 2016-09-19, issue #2168, reported by Nisse
-- {-# OPTIONS -v tc.cover:10 #-}
-- {-# OPTIONS -v tc.cover.splittree:30 -v tc.cc:40 -v tc.cover.split.con:30 #-}
open import Common.Equality
data Three : Set where
one two three : Three
data Bool : Set where
true false : Bool
P : Bool → Bool → Three
P z false = one
P false = λ _ → two -- This caused internal error during clause compilation.
P z true = three
test-one : ∀ x → P x false ≡ one
test-one true = refl
test-one false = refl
test-two : P false true ≡ two
test-two = refl
test-three : P true true ≡ three
test-three = refl
| 21.571429
| 80
| 0.663907
|
1ee9d99af0b2fb32ef3ef52d2ad0c8d66e0910cc
| 2,933
|
agda
|
Agda
|
src/fot/LTC-PCF/Data/Nat/Divisibility/By0/Properties.agda
|
asr/fotc
|
2fc9f2b81052a2e0822669f02036c5750371b72d
|
[
"MIT"
] | 11
|
2015-09-03T20:53:42.000Z
|
2021-09-12T16:09:54.000Z
|
src/fot/LTC-PCF/Data/Nat/Divisibility/By0/Properties.agda
|
asr/fotc
|
2fc9f2b81052a2e0822669f02036c5750371b72d
|
[
"MIT"
] | 2
|
2016-10-12T17:28:16.000Z
|
2017-01-01T14:34:26.000Z
|
src/fot/LTC-PCF/Data/Nat/Divisibility/By0/Properties.agda
|
asr/fotc
|
2fc9f2b81052a2e0822669f02036c5750371b72d
|
[
"MIT"
] | 3
|
2016-09-19T14:18:30.000Z
|
2018-03-14T08:50:00.000Z
|
------------------------------------------------------------------------------
-- Properties of the divisibility relation
------------------------------------------------------------------------------
{-# OPTIONS --exact-split #-}
{-# OPTIONS --no-sized-types #-}
{-# OPTIONS --no-universe-polymorphism #-}
{-# OPTIONS --without-K #-}
module LTC-PCF.Data.Nat.Divisibility.By0.Properties where
open import Common.FOL.Relation.Binary.EqReasoning
open import LTC-PCF.Base
open import LTC-PCF.Base.Properties
open import LTC-PCF.Data.Nat
open import LTC-PCF.Data.Nat.Properties
open import LTC-PCF.Data.Nat.Divisibility.By0
open import LTC-PCF.Data.Nat.Inequalities
open import LTC-PCF.Data.Nat.Inequalities.Properties
open import LTC-PCF.Data.Nat.Properties
open import LTC-PCF.Data.Nat.UnaryNumbers
open import LTC-PCF.Data.Nat.UnaryNumbers.Totality
------------------------------------------------------------------------------
-- Any positive number divides 0.
S∣0 : ∀ {n} → N n → succ₁ n ∣ zero
S∣0 {n} Nn = zero , nzero , sym (*-leftZero (succ₁ n))
-- 0 divides 0.
0∣0 : zero ∣ zero
0∣0 = zero , nzero , sym (*-leftZero zero)
-- The divisibility relation is reflexive.
∣-refl : ∀ {n} → N n → n ∣ n
∣-refl {n} Nn = [1] , 1-N , sym (*-leftIdentity Nn)
-- If x divides y and z then x divides y ∸ z.
x∣y→x∣z→x∣y∸z-helper : ∀ {m n o k k'} → N m → N k → N k' →
n ≡ k * m →
o ≡ k' * m →
n ∸ o ≡ (k ∸ k') * m
x∣y→x∣z→x∣y∸z-helper Nm Nk Nk' refl refl = sym (*∸-leftDistributive Nk Nk' Nm)
x∣y→x∣z→x∣y∸z : ∀ {m n o} → N m → N n → N o → m ∣ n → m ∣ o → m ∣ n ∸ o
x∣y→x∣z→x∣y∸z Nm Nn No (k , Nk , h₁) (k' , Nk' , h₂) =
k ∸ k' , ∸-N Nk Nk' , x∣y→x∣z→x∣y∸z-helper Nm Nk Nk' h₁ h₂
-- If x divides y and z then x divides y + z.
x∣y→x∣z→x∣y+z-helper : ∀ {m n o k k'} → N m → N k → N k' →
n ≡ k * m →
o ≡ k' * m →
n + o ≡ (k + k') * m
x∣y→x∣z→x∣y+z-helper Nm Nk Nk' refl refl = sym (*+-leftDistributive Nk Nk' Nm)
x∣y→x∣z→x∣y+z : ∀ {m n o} → N m → N n → N o → m ∣ n → m ∣ o → m ∣ n + o
x∣y→x∣z→x∣y+z Nm Nn No (k , Nk , h₁) (k' , Nk' , h₂) =
k + k' , +-N Nk Nk' , x∣y→x∣z→x∣y+z-helper Nm Nk Nk' h₁ h₂
-- If x divides y and y is positive, then x ≤ y.
x∣S→x≤S : ∀ {m n} → N m → N n → m ∣ (succ₁ n) → m ≤ succ₁ n
x∣S→x≤S {m} Nm Nn (.zero , nzero , Sn≡0*m) =
⊥-elim (0≢S (trans (sym (*-leftZero m)) (sym Sn≡0*m)))
x∣S→x≤S {m} Nm Nn (.(succ₁ k) , nsucc {k} Nk , Sn≡Sk*m) =
subst (λ t₁ → m ≤ t₁)
(sym Sn≡Sk*m)
(subst (λ t₂ → m ≤ t₂)
(sym (*-Sx k m))
(x≤x+y Nm (*-N Nk Nm)))
0∣x→x≡0 : ∀ {m} → N m → zero ∣ m → m ≡ zero
0∣x→x≡0 nzero _ = refl
0∣x→x≡0 (nsucc {m} Nm) (k , Nk , Sm≡k*0) =
⊥-elim (0≢S (trans (sym (*-leftZero k))
(trans (*-comm nzero Nk) (sym Sm≡k*0))))
| 38.592105
| 78
| 0.474258
|
a0a10d2b66ae547767635384756ab914fe7f16cd
| 508
|
agda
|
Agda
|
test/Fail/errors-shelltestrunner/Issue62/NoTheorem.agda
|
asr/apia
|
a66c5ddca2ab470539fd68c42c4fbd45f720d682
|
[
"MIT"
] | 10
|
2015-09-03T20:54:16.000Z
|
2019-12-03T13:44:25.000Z
|
test/Fail/errors-shelltestrunner/Issue62/NoTheorem.agda
|
asr/apia
|
a66c5ddca2ab470539fd68c42c4fbd45f720d682
|
[
"MIT"
] | 121
|
2015-01-25T13:22:12.000Z
|
2018-04-22T06:01:44.000Z
|
test/Fail/errors-shelltestrunner/Issue62/NoTheorem.agda
|
asr/apia
|
a66c5ddca2ab470539fd68c42c4fbd45f720d682
|
[
"MIT"
] | 4
|
2016-05-10T23:06:19.000Z
|
2016-08-03T03:54:55.000Z
|
------------------------------------------------------------------------------
-- No theorem used by the shelltestrunner test
------------------------------------------------------------------------------
{-# OPTIONS --exact-split #-}
{-# OPTIONS --no-sized-types #-}
{-# OPTIONS --no-universe-polymorphism #-}
{-# OPTIONS --without-K #-}
module Issue62.NoTheorem where
postulate
D : Set
_≡_ : D → D → Set
a b : D
postulate foo : a ≡ b
{-# ATP prove foo #-}
| 26.736842
| 78
| 0.377953
|
a05ce34f3c47eff397f67f7a8be5cc24ac5ff094
| 6,760
|
agda
|
Agda
|
Groups/FreeProduct/Setoid.agda
|
Smaug123/agdaproofs
|
0f4230011039092f58f673abcad8fb0652e6b562
|
[
"MIT"
] | 4
|
2019-08-08T12:44:19.000Z
|
2022-01-28T06:04:15.000Z
|
Groups/FreeProduct/Setoid.agda
|
Smaug123/agdaproofs
|
0f4230011039092f58f673abcad8fb0652e6b562
|
[
"MIT"
] | 14
|
2019-01-06T21:11:59.000Z
|
2020-04-11T11:03:39.000Z
|
Groups/FreeProduct/Setoid.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.EquivalenceRelations
open import Functions.Definition
open import Agda.Primitive using (Level; lzero; lsuc; _⊔_; Setω)
open import Setoids.Setoids
open import Groups.Definition
open import LogicalFormulae
open import Orders.WellFounded.Definition
open import Numbers.Naturals.Semiring
open import Groups.Lemmas
module Groups.FreeProduct.Setoid {i : _} {I : Set i} (decidableIndex : (x y : I) → ((x ≡ y) || ((x ≡ y) → False))) {a b : _} {A : I → Set a} {S : (i : I) → Setoid {a} {b} (A i)} {_+_ : (i : I) → (A i) → (A i) → A i} (decidableGroups : (i : I) → (x y : A i) → ((Setoid._∼_ (S i) x y)) || ((Setoid._∼_ (S i) x y) → False)) (G : (i : I) → Group (S i) (_+_ i)) where
open import Groups.FreeProduct.Definition decidableIndex decidableGroups G
=RP' : {m n : _} (s1 : ReducedSequenceBeginningWith m) (s2 : ReducedSequenceBeginningWith n) → Set b
=RP' (ofEmpty i g nonZero) (ofEmpty j h nonZero₁) with decidableIndex i j
=RP' (ofEmpty i g nonZero) (ofEmpty .i h nonZero₁) | inl refl = Setoid._∼_ (S i) g h
=RP' (ofEmpty i g nonZero) (ofEmpty j h nonZero₁) | inr x = False'
=RP' (ofEmpty i g nonZero) (prependLetter i₁ g₁ nonZero₁ s2 x) = False'
=RP' (prependLetter i g nonZero s1 x) (ofEmpty i₁ g₁ nonZero₁) = False'
=RP' (prependLetter i g nonZero s1 x) (prependLetter j h nonZero₁ s2 x₁) with decidableIndex i j
=RP' (prependLetter i g nonZero s1 x) (prependLetter .i h nonZero₁ s2 x₁) | inl refl = Setoid._∼_ (S i) g h && =RP' s1 s2
=RP' (prependLetter i g nonZero s1 x) (prependLetter j h nonZero₁ s2 x₁) | inr x₂ = False'
_=RP_ : Rel ReducedSequence
empty =RP empty = True'
empty =RP nonempty i x = False'
nonempty i x =RP empty = False'
nonempty i x =RP nonempty j y = =RP' x y
=RP'reflex : {i : _} (x : ReducedSequenceBeginningWith i) → =RP' x x
=RP'reflex (ofEmpty i g nonZero) with decidableIndex i i
=RP'reflex (ofEmpty i g nonZero) | inl refl = Equivalence.reflexive (Setoid.eq (S i))
=RP'reflex (ofEmpty i g nonZero) | inr x = exFalso (x refl)
=RP'reflex (prependLetter i g nonZero x x₁) with decidableIndex i i
=RP'reflex (prependLetter i g nonZero x x₁) | inl refl = Equivalence.reflexive (Setoid.eq (S i)) ,, =RP'reflex x
=RP'reflex (prependLetter i g nonZero x x₁) | inr bad = exFalso (bad refl)
private
reflex : Reflexive _=RP_
reflex {empty} = record {}
reflex {nonempty i (ofEmpty .i g nonZero)} with decidableIndex i i
reflex {nonempty i (ofEmpty .i g nonZero)} | inl refl = Equivalence.reflexive (Setoid.eq (S i))
... | inr bad = exFalso (bad refl)
reflex {nonempty i (prependLetter .i g nonZero x x₁)} with decidableIndex i i
reflex {nonempty i (prependLetter .i g nonZero x x₁)} | inl refl = Equivalence.reflexive (Setoid.eq (S i)) ,, =RP'reflex x
reflex {nonempty i (prependLetter .i g nonZero x x₁)} | inr bad = exFalso (bad refl)
=RP'symm : {i j : _} (x : ReducedSequenceBeginningWith i) (y : ReducedSequenceBeginningWith j) → =RP' x y → =RP' y x
=RP'symm (ofEmpty i g nonZero) (ofEmpty j h nonZero2) with decidableIndex i j
=RP'symm (ofEmpty i g nonZero) (ofEmpty j h nonZero2) | inl pr with decidableIndex j i
=RP'symm (ofEmpty .j g nonZero) (ofEmpty j h nonZero2) | inl refl | inl refl = Equivalence.symmetric (Setoid.eq (S j)) {g} {h}
=RP'symm (ofEmpty i g nonZero) (ofEmpty j h nonZero2) | inl pr | inr x = exFalso (x (equalityCommutative pr))
=RP'symm (ofEmpty i g nonZero) (ofEmpty j h nonZero2) | inr x with decidableIndex j i
=RP'symm (ofEmpty i g nonZero) (ofEmpty j h nonZero2) | inr x | inl pr = exFalso (x (equalityCommutative pr))
=RP'symm (ofEmpty i g nonZero) (ofEmpty j h nonZero2) | inr x | inr _ = id
=RP'symm (ofEmpty i g nonZero) (prependLetter i₁ g₁ nonZero₁ y x) = id
=RP'symm (prependLetter i g nonZero x x₁) (ofEmpty i₁ g₁ nonZero₁) = id
=RP'symm (prependLetter i g nonZero x x₁) (prependLetter j h nonZero2 y pr2) pr with decidableIndex i j
=RP'symm (prependLetter .j g nonZero x x₁) (prependLetter j h nonZero2 y pr2) pr | inl refl with decidableIndex j j
=RP'symm (prependLetter .j g nonZero x x₁) (prependLetter j h nonZero2 y pr2) (fst ,, snd) | inl refl | inl refl = Equivalence.symmetric (Setoid.eq (S j)) fst ,, =RP'symm x y snd
=RP'symm (prependLetter .j g nonZero x x₁) (prependLetter j h nonZero2 y pr2) pr | inl refl | inr bad = exFalso (bad refl)
=RP'symm (prependLetter i g nonZero x x₁) (prependLetter j h nonZero2 y pr2) () | inr i!=j
private
symm : Symmetric _=RP_
symm {empty} {empty} x = record {}
symm {nonempty i m} {nonempty i₁ n} x = =RP'symm m n x
=RP'trans : {i j k : _} (x : ReducedSequenceBeginningWith i) (y : ReducedSequenceBeginningWith j) (z : ReducedSequenceBeginningWith k) → =RP' x y → =RP' y z → =RP' x z
=RP'trans (ofEmpty i g nonZero) (ofEmpty j g₁ nonZero₁) (ofEmpty k g₂ nonZero₂) x=y y=z with decidableIndex i j
=RP'trans (ofEmpty .j g nonZero) (ofEmpty j g₁ nonZero₁) (ofEmpty k g₂ nonZero₂) x=y y=z | inl refl with decidableIndex j k
=RP'trans (ofEmpty .j g nonZero) (ofEmpty j g₁ nonZero₁) (ofEmpty .j g₂ nonZero₂) x=y y=z | inl refl | inl refl = Equivalence.transitive (Setoid.eq (S j)) x=y y=z
=RP'trans (prependLetter i g nonZero x x₁) (prependLetter j g₁ nonZero₁ y x₂) (prependLetter k g₂ nonZero₂ z x₃) x=y y=z with decidableIndex i j
=RP'trans (prependLetter .j g nonZero x x₁) (prependLetter j g₁ nonZero₁ y x₂) (prependLetter k g₂ nonZero₂ z x₃) x=y y=z | inl refl with decidableIndex j k
=RP'trans (prependLetter .j g nonZero x x₁) (prependLetter j g₁ nonZero₁ y x₂) (prependLetter .j g₂ nonZero₂ z x₃) (fst1 ,, snd1) (fst2 ,, snd2) | inl refl | inl refl = Equivalence.transitive (Setoid.eq (S j)) fst1 fst2 ,, =RP'trans x y z snd1 snd2
private
trans : (x y z : ReducedSequence) → x =RP y → y =RP z → x =RP z
trans empty empty empty x=y y=z = record {}
trans (nonempty i x) (nonempty i₁ y) (nonempty i₂ z) x=y y=z = =RP'trans x y z x=y y=z
notEqualIfStartDifferent : {j1 j2 : I} (neq : (j1 ≡ j2) → False) → (x1 : ReducedSequenceBeginningWith j1) (x2 : ReducedSequenceBeginningWith j2) → =RP' x1 x2 → False
notEqualIfStartDifferent neq (ofEmpty i g nonZero) (ofEmpty j g₁ nonZero₁) eq with decidableIndex i j
notEqualIfStartDifferent neq (ofEmpty i g nonZero) (ofEmpty j g₁ nonZero₁) eq | inl i=j = neq i=j
notEqualIfStartDifferent neq (prependLetter i g nonZero x1 x) (prependLetter j g₁ nonZero₁ x2 x₁) eq with decidableIndex i j
notEqualIfStartDifferent neq (prependLetter i g nonZero x1 x) (prependLetter j g₁ nonZero₁ x2 x₁) eq | inl eq' = neq eq'
freeProductSetoid : Setoid ReducedSequence
Setoid._∼_ freeProductSetoid = _=RP_
Equivalence.reflexive (Setoid.eq freeProductSetoid) {x} = reflex {x}
Equivalence.symmetric (Setoid.eq freeProductSetoid) {a} {b} = symm {a} {b}
Equivalence.transitive (Setoid.eq freeProductSetoid) {x} {y} {z} = trans x y z
| 69.690722
| 362
| 0.70074
|
ada21654d68355a2e75f39555392b669c1a413e0
| 15,963
|
agda
|
Agda
|
Agda/subuniverses.agda
|
tmoux/HoTT-Intro
|
22023fd35023cb6804424ce12cd10d252b80fd29
|
[
"CC-BY-4.0"
] | null | null | null |
Agda/subuniverses.agda
|
tmoux/HoTT-Intro
|
22023fd35023cb6804424ce12cd10d252b80fd29
|
[
"CC-BY-4.0"
] | null | null | null |
Agda/subuniverses.agda
|
tmoux/HoTT-Intro
|
22023fd35023cb6804424ce12cd10d252b80fd29
|
[
"CC-BY-4.0"
] | null | null | null |
{-# OPTIONS --without-K --allow-unsolved-metas #-}
module subuniverses where
import 14-univalence
open 14-univalence public
{-
is-local :
{l1 l2 l3 l4 : Level}
{I : UU l1} {A : I → UU l2} {B : I → UU l3} (f : (i : I) → A i → B i)
(X : UU l4) → UU (l1 ⊔ (l2 ⊔ (l3 ⊔ l4)))
is-local {I = I} {B = B} f X =
(i : I) → is-equiv (λ (h : B i → X) → h ∘ (f i))
is-subuniverse-is-local :
{l1 l2 l3 l4 : Level}
{I : UU l1} {A : I → UU l2} {B : I → UU l3} (f : (i : I) → A i → B i) →
is-subuniverse (is-local {l4 = l4} f)
is-subuniverse-is-local f X = is-prop-Π (λ i → is-subtype-is-equiv _)
-}
universal-property-localization :
{l1 l2 : Level} (P : subuniverse l1 l2)
(X : UU l1) (Y : total-subuniverse P) (l : X → pr1 Y) →
UU ((lsuc l1) ⊔ l2)
universal-property-localization {l1} (pair P H) X (pair Y p) l =
(Z : UU l1) (q : P Z) → is-equiv (λ (h : Y → Z) → h ∘ l)
universal-property-localization' :
(l : Level) (α : Level → Level) (P : (l : Level) → subuniverse l (α l))
(g : (l1 l2 : Level) → is-global-subuniverse α P l1 l2)
{l1 l2 : Level} (X : UU l1) (Y : total-subuniverse (P l2)) (f : X → pr1 Y) →
UU ((lsuc l) ⊔ ((α l) ⊔ (l1 ⊔ l2)))
universal-property-localization' l α P g X Y f =
(Z : total-subuniverse (P l)) → is-equiv (λ (h : (pr1 Y) → (pr1 Z)) → h ∘ f)
is-prop-universal-property-localization :
{l1 l2 : Level} (P : subuniverse l1 l2) (X : UU l1)
(Y : total-subuniverse P) (l : X → pr1 Y) →
is-prop (universal-property-localization P X Y l)
is-prop-universal-property-localization (pair P H) X (pair Y p) l =
is-prop-Π (λ Z → is-prop-Π (λ q → is-subtype-is-equiv _))
has-localization :
{l1 l2 : Level} (P : subuniverse l1 l2) (X : UU l1) →
UU ((lsuc l1) ⊔ l2)
has-localization {l1} P X =
Σ ( total-subuniverse P)
( λ Y → Σ (X → pr1 Y) (universal-property-localization P X Y))
Eq-localizations :
{l1 l2 : Level} (P : subuniverse l1 l2) (X : UU l1) →
( s t : has-localization P X) → UU l1
Eq-localizations (pair P H) X
(pair (pair Y p) (pair l up)) t =
let Y' = pr1 (pr1 t)
p' = pr1 (pr1 t)
l' = pr1 (pr2 t)
up' = pr2 (pr2 t)
in
Σ ( Y ≃ Y')
( λ e → ((map-equiv e) ∘ l) ~ l' )
reflexive-Eq-localizations :
{l1 l2 : Level} (P : subuniverse l1 l2) (X : UU l1) →
(s : has-localization P X) → Eq-localizations P X s s
reflexive-Eq-localizations (pair P H) X (pair (pair Y p) (pair l up)) =
pair (equiv-id Y) (htpy-refl l)
Eq-localizations-eq :
{l1 l2 : Level} (P : subuniverse l1 l2) (X : UU l1) →
( s t : has-localization P X) → Id s t → Eq-localizations P X s t
Eq-localizations-eq P X s s refl = reflexive-Eq-localizations P X s
is-contr-total-Eq-localizations :
{l1 l2 : Level} (P : subuniverse l1 l2) (X : UU l1)
(s : has-localization P X) →
is-contr (Σ (has-localization P X) (Eq-localizations P X s))
is-contr-total-Eq-localizations
(pair P H) X (pair (pair Y p) (pair l up)) =
is-contr-total-Eq-structure
( λ Y' l' e → ((map-equiv e) ∘ l) ~ (pr1 l'))
( is-contr-total-Eq-total-subuniverse (pair P H) (pair Y p))
( pair (pair Y p) (equiv-id Y))
( is-contr-total-Eq-substructure
( is-contr-total-htpy l)
( is-prop-universal-property-localization (pair P H) X (pair Y p))
( l)
( htpy-refl _)
( up))
is-equiv-Eq-localizations-eq :
{l1 l2 : Level} (P : subuniverse l1 l2) (X : UU l1) →
( s t : has-localization P X) → is-equiv (Eq-localizations-eq P X s t)
is-equiv-Eq-localizations-eq P X s =
fundamental-theorem-id s
( reflexive-Eq-localizations P X s)
( is-contr-total-Eq-localizations P X s)
( Eq-localizations-eq P X s)
eq-Eq-localizations :
{l1 l2 : Level} (P : subuniverse l1 l2) (X : UU l1)
( s t : has-localization P X) → (Eq-localizations P X s t) → Id s t
eq-Eq-localizations P X s t =
inv-is-equiv (is-equiv-Eq-localizations-eq P X s t)
uniqueness-localizations :
{l1 l2 : Level} (P : subuniverse l1 l2) (X : UU l1) →
( s t : has-localization P X) → Eq-localizations P X s t
uniqueness-localizations (pair P H) X
(pair (pair Y p) (pair l up)) (pair (pair Y' p') (pair l' up')) =
pair
( pair
( inv-is-equiv (up Y' p') l')
( is-equiv-has-inverse
( pair
( inv-is-equiv (up' Y p) l)
( pair
( htpy-eq
( ap
( pr1 {B = λ h → Id (h ∘ l') l'})
( center
( is-prop-is-contr
( is-contr-map-is-equiv (up' Y' p') l')
( pair
( ( inv-is-equiv (up Y' p') l') ∘
( inv-is-equiv (up' Y p) l))
( ( ap
( λ t → (inv-is-equiv (up Y' p') l') ∘ t)
( issec-inv-is-equiv (up' Y p) l)) ∙
( issec-inv-is-equiv (up Y' p') l')))
( pair id refl)))))
( htpy-eq
( ap
( pr1 {B = λ h → Id (h ∘ l) l})
( center
( is-prop-is-contr
( is-contr-map-is-equiv (up Y p) l)
( pair
( ( inv-is-equiv (up' Y p) l) ∘
( inv-is-equiv (up Y' p') l'))
( ( ap
( λ t → (inv-is-equiv (up' Y p) l) ∘ t)
( issec-inv-is-equiv (up Y' p') l')) ∙
issec-inv-is-equiv (up' Y p) l))
( pair id refl)))))))))
( htpy-eq (issec-inv-is-equiv (up Y' p') l'))
is-prop-localizations :
{l1 l2 : Level} (P : subuniverse l1 l2) (X : UU l1) →
is-prop (has-localization P X)
is-prop-localizations P X =
is-prop-is-prop'
( λ Y Y' → eq-Eq-localizations P X Y Y'
( uniqueness-localizations P X Y Y'))
universal-property-localization-equiv-is-local :
{l1 l2 : Level} (P : subuniverse l1 l2) (X : UU l1) →
(Y : UU l1) (p : (pr1 P) Y) (l : X → Y) →
is-equiv l → universal-property-localization P X (pair Y p) l
universal-property-localization-equiv-is-local
(pair P H) X Y p l is-equiv-l Z q =
is-equiv-precomp-is-equiv l is-equiv-l Z
universal-property-localization-id-is-local :
{l1 l2 : Level} (P : subuniverse l1 l2) (X : UU l1) (q : (pr1 P) X) →
universal-property-localization P X (pair X q) id
universal-property-localization-id-is-local P X q =
universal-property-localization-equiv-is-local P X X q id (is-equiv-id X)
is-equiv-localization-is-local :
{l1 l2 : Level} (P : subuniverse l1 l2) (X : UU l1) →
( Y : has-localization P X) → (pr1 P) X → is-equiv (pr1 (pr2 Y))
is-equiv-localization-is-local
(pair P H) X (pair (pair Y p) (pair l up)) q =
is-equiv-right-factor
( id)
( inv-is-equiv (up X q) id)
( l)
( htpy-eq (inv (issec-inv-is-equiv (up X q) id)))
( pr2
( pr1
( uniqueness-localizations (pair P H) X
( pair (pair Y p) (pair l up))
( pair
( pair X q)
( pair id
( universal-property-localization-id-is-local
(pair P H) X q))))))
( is-equiv-id X)
is-local-is-equiv-localization :
{l1 l2 : Level} (P : subuniverse l1 l2) (X : UU l1) →
( Y : has-localization P X) → is-equiv (pr1 (pr2 Y)) → (pr1 P) X
is-local-is-equiv-localization
(pair P H) X (pair (pair Y p) (pair l up)) is-equiv-l =
in-subuniverse-equiv' P (pair l is-equiv-l) p
strong-retraction-property-localization :
{l1 l2 : Level} (P : subuniverse l1 l2) (X : UU l1) →
(Y : total-subuniverse P) (l : X → pr1 Y) → UU l1
strong-retraction-property-localization (pair P H) X (pair Y p) l =
is-equiv (λ (h : Y → X) → h ∘ l)
retraction-property-localization :
{l1 l2 : Level} (P : subuniverse l1 l2) (X : UU l1) →
(Y : total-subuniverse P) (l : X → pr1 Y) → UU l1
retraction-property-localization (pair P H) X (pair Y p) l =
retr l
strong-retraction-property-localization-is-equiv-localization :
{l1 l2 : Level} (P : subuniverse l1 l2) (X : UU l1) →
(Y : total-subuniverse P) (l : X → pr1 Y) →
is-equiv l → strong-retraction-property-localization P X Y l
strong-retraction-property-localization-is-equiv-localization
(pair P H) X (pair Y p) l is-equiv-l =
is-equiv-precomp-is-equiv l is-equiv-l X
retraction-property-localization-strong-retraction-property-localization :
{l1 l2 : Level} (P : subuniverse l1 l2) (X : UU l1) →
(Y : total-subuniverse P) (l : X → pr1 Y) →
strong-retraction-property-localization P X Y l →
retraction-property-localization P X Y l
retraction-property-localization-strong-retraction-property-localization
(pair P H) X (pair Y p) l s =
tot (λ h → htpy-eq) (center (is-contr-map-is-equiv s id))
is-equiv-localization-retraction-property-localization :
{l1 l2 : Level} (P : subuniverse l1 l2) (X : UU l1) →
(Y : has-localization P X) →
retraction-property-localization P X (pr1 Y) (pr1 (pr2 Y)) →
is-equiv (pr1 (pr2 Y))
is-equiv-localization-retraction-property-localization
(pair P H) X (pair (pair Y p) (pair l up)) (pair g isretr-g) =
is-equiv-has-inverse
( pair g
( pair
( htpy-eq
( ap
( pr1 {B = λ (h : Y → Y) → Id (h ∘ l) l})
( center
( is-prop-is-contr
( is-contr-map-is-equiv (up Y p) l)
( pair (l ∘ g) (ap (λ t → l ∘ t) (eq-htpy isretr-g)))
( pair id refl)))))
( isretr-g)))
is-local-retraction-property-localization :
{l1 l2 : Level} (P : subuniverse l1 l2) (X : UU l1) →
(Y : has-localization P X) →
retraction-property-localization P X (pr1 Y) (pr1 (pr2 Y)) →
(pr1 P) X
is-local-retraction-property-localization P X Y r =
is-local-is-equiv-localization P X Y
( is-equiv-localization-retraction-property-localization P X Y r)
is-local-has-localization-is-contr :
{l1 l2 : Level} (P : subuniverse l1 l2) (X : UU l1) →
is-contr X → has-localization P X → (pr1 P) X
is-local-has-localization-is-contr
(pair P H) X is-contr-X (pair (pair Y p) (pair l up)) =
is-local-retraction-property-localization (pair P H) X
( pair (pair Y p) (pair l up))
( pair
( λ _ → center is-contr-X)
( contraction is-contr-X))
has-localization-is-local-is-contr :
{l1 l2 : Level} (P : subuniverse l1 l2) (X : UU l1) →
is-contr X → (pr1 P) X → has-localization P X
has-localization-is-local-is-contr (pair P H) X is-contr-X p =
pair
( pair X p)
( pair id (universal-property-localization-id-is-local (pair P H) X p))
is-contr-raise-unit :
(l : Level) → is-contr (raise l unit)
is-contr-raise-unit l =
is-contr-is-equiv' unit
( map-raise l unit)
( is-equiv-map-raise l unit)
( is-contr-unit)
is-local-unit-localization-unit :
{l1 l2 : Level} (P : subuniverse l1 l2) →
(Y : has-localization P (raise l1 unit)) →
(pr1 P) (raise l1 unit)
is-local-unit-localization-unit P Y =
is-local-has-localization-is-contr P (raise _ unit) (is-contr-raise-unit _) Y
toto-dependent-elimination-localization :
{l1 l2 : Level} (P : subuniverse l1 l2) (X : UU l1) →
(has-loc-X : has-localization P X) →
let Y = pr1 (pr1 has-loc-X)
l = pr1 (pr2 has-loc-X)
in
(Z : Y → UU l1) →
Σ (Y → Y) (λ h → (y : Y) → Z (h y)) →
Σ (X → Y) (λ h → (x : X) → Z (h x))
toto-dependent-elimination-localization (pair P H) X
(pair (pair Y p) (pair l up)) Z =
toto
( λ (h : X → Y) → (x : X) → Z (h x))
( λ h → h ∘ l)
( λ h h' x → h' (l x))
square-dependent-elimination-localization :
{l1 l2 : Level} (P : subuniverse l1 l2) (X : UU l1) →
(has-loc-X : has-localization P X) →
let Y = pr1 (pr1 has-loc-X)
l = pr1 (pr2 has-loc-X)
in
(Z : Y → UU l1) (q : (pr1 P) (Σ _ Z)) →
( ( λ (h : Y → Σ Y Z) → h ∘ l) ∘
( inv-choice-∞)) ~
( ( inv-choice-∞) ∘
( toto-dependent-elimination-localization P X has-loc-X Z))
square-dependent-elimination-localization
(pair P H) X (pair (pair Y p) (pair l up)) Z q =
htpy-refl
is-equiv-toto-dependent-elimination-localization :
{l1 l2 : Level} (P : subuniverse l1 l2) (X : UU l1) →
(has-loc-X : has-localization P X)
(Z : pr1 (pr1 has-loc-X) → UU l1) (q : (pr1 P) (Σ _ Z)) →
is-equiv (toto-dependent-elimination-localization P X has-loc-X Z)
is-equiv-toto-dependent-elimination-localization
(pair P H) X (pair (pair Y p) (pair l up)) Z q =
is-equiv-top-is-equiv-bottom-square
( inv-choice-∞)
( inv-choice-∞)
( toto-dependent-elimination-localization
(pair P H) X (pair (pair Y p) (pair l up)) Z)
( λ h → h ∘ l)
( square-dependent-elimination-localization
(pair P H) X (pair (pair Y p) (pair l up)) Z q)
( is-equiv-inv-choice-∞)
( is-equiv-inv-choice-∞)
( up (Σ Y Z) q)
dependent-elimination-localization :
{l1 l2 : Level} (P : subuniverse l1 l2) →
(X : UU l1) (Y : has-localization P X) →
(Z : (pr1 (pr1 Y)) → UU l1) (q : (pr1 P) (Σ _ Z)) →
is-equiv (λ (h : (y : (pr1 (pr1 Y))) → (Z y)) → λ x → h (pr1 (pr2 Y) x))
dependent-elimination-localization (pair P H) X (pair (pair Y p) (pair l up)) Z q =
is-fiberwise-equiv-is-equiv-toto-is-equiv-base-map
( λ (h : X → Y) → (x : X) → Z (h x))
( λ (h : Y → Y) → h ∘ l)
( λ (h : Y → Y) (h' : (y : Y) → Z (h y)) (x : X) → h' (l x))
( up Y p)
( is-equiv-toto-dependent-elimination-localization
(pair P H) X (pair (pair Y p) (pair l up)) Z q)
( id)
is-reflective-subuniverse :
{l1 l2 : Level} (P : subuniverse l1 l2) → UU ((lsuc l1) ⊔ l2)
is-reflective-subuniverse {l1} P = (X : UU l1) → has-localization P X
reflective-subuniverse :
(l1 l2 : Level) → UU ((lsuc l1) ⊔ (lsuc l2))
reflective-subuniverse l1 l2 = Σ (subuniverse l1 l2) is-reflective-subuniverse
is-local :
{l1 l2 : Level} (L : reflective-subuniverse l1 l2) →
UU l1 → UU l2
is-local L = pr1 (pr1 L)
is-prop-is-local :
{l1 l2 : Level} (L : reflective-subuniverse l1 l2) →
(X : UU l1) → is-prop (is-local L X)
is-prop-is-local L = pr2 (pr1 L)
total-reflective-subuniverse :
{l1 l2 : Level} (L : reflective-subuniverse l1 l2) → UU ((lsuc l1) ⊔ l2)
total-reflective-subuniverse L = total-subuniverse (pr1 L)
local-type-localization :
{l1 l2 : Level} (L : reflective-subuniverse l1 l2)
(X : UU l1) → total-reflective-subuniverse L
local-type-localization L X = pr1 ((pr2 L) X)
type-localization :
{l1 l2 : Level} (L : reflective-subuniverse l1 l2) →
UU l1 → UU l1
type-localization L X = pr1 (local-type-localization L X)
is-local-type-localization :
{l1 l2 : Level} (L : reflective-subuniverse l1 l2)
(X : UU l1) → is-local L (type-localization L X)
is-local-type-localization L X = pr2 (local-type-localization L X)
universal-map-localization :
{l1 l2 : Level} (L : reflective-subuniverse l1 l2) (X : UU l1) →
Σ ( X → type-localization L X)
( universal-property-localization (pr1 L) X (local-type-localization L X))
universal-map-localization L X = pr2 ((pr2 L) X)
unit-localization :
{l1 l2 : Level} (L : reflective-subuniverse l1 l2)
(X : UU l1) → X → type-localization L X
unit-localization L X = pr1 (universal-map-localization L X)
universal-property-map-localization :
{l1 l2 : Level} (L : reflective-subuniverse l1 l2) (X : UU l1) →
universal-property-localization (pr1 L) X
( local-type-localization L X)
( unit-localization L X)
universal-property-map-localization L X = pr2 (universal-map-localization L X)
dependent-elimination-reflective-subuniverse :
{l1 l2 : Level} (L : reflective-subuniverse l1 l2) (X : UU l1) →
(Y : type-localization L X → UU l1)
(is-loc-total-Y : is-local L (Σ _ Y)) →
is-equiv
( λ (h : (x' : type-localization L X) → Y x') x → h (unit-localization L X x))
dependent-elimination-reflective-subuniverse L X =
dependent-elimination-localization (pr1 L) X ((pr2 L) X)
is-contr-square-localization :
{l1 l2 : Level} (L : reflective-subuniverse l1 l2) {X Y : UU l1} (f : X → Y) →
is-contr
( Σ (type-localization L X → type-localization L Y)
( λ Lf → coherence-square (unit-localization L X) f Lf (unit-localization L Y)))
is-contr-square-localization L f = {!!}
| 37.384075
| 86
| 0.58291
|
4b6c41778a872294af7045ab155277c4cf432779
| 273
|
agda
|
Agda
|
slides/Background.agda
|
larrytheliquid/generic-elim
|
832383d7adf37aa2364213fb0aeb67e9f61a248f
|
[
"MIT"
] | 11
|
2015-06-02T14:05:20.000Z
|
2021-09-09T08:46:42.000Z
|
slides/Background.agda
|
larrytheliquid/generic-elim
|
832383d7adf37aa2364213fb0aeb67e9f61a248f
|
[
"MIT"
] | null | null | null |
slides/Background.agda
|
larrytheliquid/generic-elim
|
832383d7adf37aa2364213fb0aeb67e9f61a248f
|
[
"MIT"
] | 2
|
2016-05-02T08:56:15.000Z
|
2022-03-12T11:31:22.000Z
|
module Background where
postulate Bits : Set
module Open where
data U : Set where
postulate
El : U → Set
marshal : (u : U) → El u → Bits
module Closed where
data Desc : Set where
postulate
μ : Desc → Set
marshal : (D : Desc) → μ D → Bits
| 13.65
| 37
| 0.600733
|
2ea530bbb3071c193e62d0e37f7f954524d36635
| 1,334
|
agda
|
Agda
|
Cubical/Relation/Nullary/Base.agda
|
kiana-S/univalent-foundations
|
8bdb0766260489f9c89a14f4c0f2ad26e5190dec
|
[
"MIT"
] | null | null | null |
Cubical/Relation/Nullary/Base.agda
|
kiana-S/univalent-foundations
|
8bdb0766260489f9c89a14f4c0f2ad26e5190dec
|
[
"MIT"
] | null | null | null |
Cubical/Relation/Nullary/Base.agda
|
kiana-S/univalent-foundations
|
8bdb0766260489f9c89a14f4c0f2ad26e5190dec
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --cubical --no-import-sorts --safe #-}
module Cubical.Relation.Nullary.Base where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Function
open import Cubical.Data.Empty as ⊥
open import Cubical.HITs.PropositionalTruncation.Base
open import Cubical.Functions.Fixpoint
open import Cubical.Relation.Nullary.Decidable public
private
variable
ℓ : Level
A : Type ℓ
toWitness : {Q : Dec A} → IsYes Q → A
toWitness {Q = yes x} isYes = x
NonEmpty : Type ℓ → Type ℓ
NonEmpty A = ¬ ¬ A
Stable : Type ℓ → Type ℓ
Stable A = NonEmpty A → A
-- reexport propositional truncation for uniformity
open Cubical.HITs.PropositionalTruncation.Base
using (∥_∥) public
SplitSupport : Type ℓ → Type ℓ
SplitSupport A = ∥ A ∥ → A
Collapsible : Type ℓ → Type ℓ
Collapsible A = Σ[ f ∈ (A → A) ] 2-Constant f
Populated ⟪_⟫ : Type ℓ → Type ℓ
Populated A = (f : Collapsible A) → Fixpoint (f .fst)
⟪_⟫ = Populated
PStable : Type ℓ → Type ℓ
PStable A = ⟪ A ⟫ → A
onAllPaths : (Type ℓ → Type ℓ) → Type ℓ → Type ℓ
onAllPaths S A = (x y : A) → S (x ≡ y)
Separated : Type ℓ → Type ℓ
Separated = onAllPaths Stable
HSeparated : Type ℓ → Type ℓ
HSeparated = onAllPaths SplitSupport
PStable≡ : Type ℓ → Type ℓ
PStable≡ = onAllPaths PStable
Collapsible≡ : Type ℓ → Type ℓ
Collapsible≡ = onAllPaths Collapsible
| 23
| 53
| 0.702399
|
0401ce367792165a644f613408acae8cbedd10b5
| 1,623
|
agda
|
Agda
|
core/lib/groups/CommutingSquare.agda
|
mikeshulman/HoTT-Agda
|
e7d663b63d89f380ab772ecb8d51c38c26952dbb
|
[
"MIT"
] | null | null | null |
core/lib/groups/CommutingSquare.agda
|
mikeshulman/HoTT-Agda
|
e7d663b63d89f380ab772ecb8d51c38c26952dbb
|
[
"MIT"
] | null | null | null |
core/lib/groups/CommutingSquare.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 lib.Basics
open import lib.types.Group
open import lib.types.CommutingSquare
open import lib.groups.Homomorphism
open import lib.groups.Isomorphism
module lib.groups.CommutingSquare where
-- A new type to keep the parameters.
record CommSquareᴳ {i₀ i₁ j₀ j₁}
{G₀ : Group i₀} {G₁ : Group i₁} {H₀ : Group j₀} {H₁ : Group j₁}
(φ₀ : G₀ →ᴳ H₀) (φ₁ : G₁ →ᴳ H₁) (ξG : G₀ →ᴳ G₁) (ξH : H₀ →ᴳ H₁)
: Type (lmax (lmax i₀ i₁) (lmax j₀ j₁)) where
constructor comm-sqrᴳ
field
commutesᴳ : ∀ g₀ → GroupHom.f (ξH ∘ᴳ φ₀) g₀ == GroupHom.f (φ₁ ∘ᴳ ξG) g₀
infix 0 _□$ᴳ_
_□$ᴳ_ = CommSquareᴳ.commutesᴳ
CommSquareᴳ-∘v : ∀ {i₀ i₁ i₂ j₀ j₁ j₂}
{G₀ : Group i₀} {G₁ : Group i₁} {G₂ : Group i₂}
{H₀ : Group j₀} {H₁ : Group j₁} {H₂ : Group j₂}
{φ : G₀ →ᴳ H₀} {ψ : G₁ →ᴳ H₁} {χ : G₂ →ᴳ H₂}
{ξG : G₀ →ᴳ G₁} {ξH : H₀ →ᴳ H₁}
{μA : G₁ →ᴳ G₂} {μB : H₁ →ᴳ H₂}
→ CommSquareᴳ ψ χ μA μB
→ CommSquareᴳ φ ψ ξG ξH
→ CommSquareᴳ φ χ (μA ∘ᴳ ξG) (μB ∘ᴳ ξH)
CommSquareᴳ-∘v {ξG = ξG} {μB = μB} (comm-sqrᴳ □₁₂) (comm-sqrᴳ □₀₁) =
comm-sqrᴳ λ g₀ → ap (GroupHom.f μB) (□₀₁ g₀) ∙ □₁₂ (GroupHom.f ξG g₀)
CommSquareᴳ-inverse-v : ∀ {i₀ i₁ j₀ j₁}
{G₀ : Group i₀} {G₁ : Group i₁} {H₀ : Group j₀} {H₁ : Group j₁}
{φ₀ : G₀ →ᴳ H₀} {φ₁ : G₁ →ᴳ H₁} {ξG : G₀ →ᴳ G₁} {ξH : H₀ →ᴳ H₁}
→ CommSquareᴳ φ₀ φ₁ ξG ξH
→ (ξG-ise : is-equiv (GroupHom.f ξG)) (ξH-ise : is-equiv (GroupHom.f ξH))
→ CommSquareᴳ φ₁ φ₀ (GroupIso.g-hom (ξG , ξG-ise)) (GroupIso.g-hom (ξH , ξH-ise))
CommSquareᴳ-inverse-v (comm-sqrᴳ □) ξG-ise ξH-ise =
comm-sqrᴳ (commutes (CommSquare-inverse-v (comm-sqr □) ξG-ise ξH-ise))
| 37.744186
| 83
| 0.616143
|
adf68ce6285d47bd5b8424f3ee8b9b965263be4c
| 2,090
|
agda
|
Agda
|
test/interaction/Auto/Prelude.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
test/interaction/Auto/Prelude.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
test/interaction/Auto/Prelude.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
module Auto.Prelude where
open import Agda.Primitive public
using (Level)
data ⊥ : Set where
¬ : Set → Set
¬ A = A → ⊥
⊥-e : (A : Set) → ⊥ → A
⊥-e A ()
record ⊤ : Set where
record _∧_ (A B : Set) : Set where
constructor ∧-i
field fst : A
snd : B
data _∨_ (A B : Set) : Set where
∨-i₁ : A → A ∨ B
∨-i₂ : B → A ∨ B
∨-e : (A B C : Set) → A ∨ B → (A → C) → (B → C) → C
∨-e A B C (∨-i₁ x) h₁ h₂ = h₁ x
∨-e A B C (∨-i₂ x) h₁ h₂ = h₂ x
data Π (A : Set) (F : A → Set) : Set where
fun : ((a : A) → F a) → Π A F
record Σ (X : Set) (P : X → Set) : Set where
constructor Σ-i
field wit : X
prf : P wit
data ℕ : Set where
zero : ℕ
succ : ℕ → ℕ
_+_ : ℕ → ℕ → ℕ
zero + n = n
succ m + n = succ (m + n)
data Fin : ℕ → Set where
zero : ∀ {n} → Fin (succ n)
suc : ∀ {n} → Fin n → Fin (succ n)
data List (X : Set) : Set where
[] : List X
_∷_ : X → List X → List X
_++_ : {X : Set} → List X → List X → List X
[] ++ ys = ys
(x ∷ xs) ++ ys = x ∷ (xs ++ ys)
data Vec (X : Set) : ℕ → Set where
[] : Vec X zero
_∷_ : ∀ {n} → X → Vec X n → Vec X (succ n)
-- -----------------------------------
data _≡_ {a} {A : Set a} (x : A) : A → Set where
refl : x ≡ x
subst : {i j : Level} {X : Set i} → (P : X → Set j) → (x y : X) → y ≡ x → P x → P y
subst P x .x refl h = h
trans : ∀ {a} {A : Set a} → {x y z : A} → x ≡ y → y ≡ z → x ≡ z
trans refl refl = refl
sym : ∀ {a} {A : Set a} → {x y : A} → x ≡ y → y ≡ x
sym refl = refl
cong : ∀ {a b} {A : Set a} {B : Set b}
(f : A → B) {x y} → x ≡ y → f x ≡ f y
cong f refl = refl
data _IsRelatedTo_ {a : Level} {Carrier : Set a} (x y : Carrier) : Set a where
relTo : (x∼y : x ≡ y) → x IsRelatedTo y
begin_ : {a : Level} {Carrier : Set a} → {x y : Carrier} → x IsRelatedTo y → x ≡ y
begin relTo x∼y = x∼y
_∎ : {a : Level} {Carrier : Set a} → (x : Carrier) → x IsRelatedTo x
_∎ _ = relTo refl
_≡⟨_⟩_ : {a : Level} {Carrier : Set a} → (x : Carrier) {y z : Carrier} → x ≡ y → y IsRelatedTo z → x IsRelatedTo z
_ ≡⟨ x∼y ⟩ relTo y∼z = relTo (trans x∼y y∼z)
-- -----------------------------------
| 20.693069
| 114
| 0.464115
|
ad7ee2c8d4911597360fde81f08e2aabbc4e0769
| 155
|
agda
|
Agda
|
test/Fail/CoinductiveBuiltinNatural.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 3
|
2015-03-28T14:51:03.000Z
|
2015-12-07T20:14:00.000Z
|
test/Fail/CoinductiveBuiltinNatural.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 3
|
2018-11-14T15:31:44.000Z
|
2019-04-01T19:39:26.000Z
|
test/Fail/CoinductiveBuiltinNatural.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1
|
2021-06-14T11:07:38.000Z
|
2021-06-14T11:07:38.000Z
|
module CoinductiveBuiltinNatural where
open import Common.Coinduction
data ℕ : Set where
zero : ℕ
suc : (n : ∞ ℕ) → ℕ
{-# BUILTIN NATURAL ℕ #-}
| 15.5
| 38
| 0.658065
|
3d6a1e1df3bf3c614d3eedecf11a7f5e74c94f8d
| 494
|
agda
|
Agda
|
test/Fail/Issue4012UnquotePrivate.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
test/Fail/Issue4012UnquotePrivate.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
test/Fail/Issue4012UnquotePrivate.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
-- Andreas, 2019-08-20, issue #4012
-- unquoteDef and unquoteDecl should respect `private`
open import Agda.Builtin.Reflection renaming (bindTC to _>>=_)
open import Agda.Builtin.List
data D : Set where
c : D
module M where
private
unquoteDecl g = do
ty ← quoteTC D
_ ← declareDef (arg (arg-info visible relevant) g) ty
qc ← quoteTC c
defineFun g (clause [] qc ∷ [])
open M
test = g
-- Expect failure.
-- g is private in M, thus, should not be in scope
| 19
| 62
| 0.657895
|
1e7a2d44a897d892b0ea9c60e78878c282f5aeb6
| 469
|
agda
|
Agda
|
test/Fail/Issue3604.agda
|
MxmUrw/agda
|
6ede01fa854c5472e54f7d1799ca2c08ed316129
|
[
"BSD-2-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
test/Fail/Issue3604.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
test/Fail/Issue3604.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
{-# OPTIONS --guardedness #-}
data Maybe (A : Set) : Set where
just : A → Maybe A
nothing : Maybe A
data Is-nothing {A} : Maybe A → Set where
nothing : Is-nothing nothing
record ℕ∞ : Set where
coinductive
field
prd∞ : Maybe ℕ∞
open ℕ∞
f : ℕ∞ → ℕ∞
prd∞ (f m) with prd∞ m
prd∞ (f m) | just pm with f pm
prd∞ (f m) | just pm | x = prd∞ x
prd∞ (f m) | nothing = nothing
inf∞ : ℕ∞
prd∞ inf∞ = just inf∞
test : Is-nothing (prd∞ (f inf∞))
test = nothing
| 16.75
| 41
| 0.588486
|
4d039a7b344b824c02d86e2cd4b92467e44b0133
| 186
|
agda
|
Agda
|
test/Fail/Issue3064.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
test/Fail/Issue3064.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
test/Fail/Issue3064.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
open import Agda.Builtin.Char
open import Agda.Builtin.Sigma
CC = Σ Char λ _ → Char
Test : (c : Char) → Set
Test 'a' = CC
Test _ = CC
test : (c : Char) → Test c
test 'a' .fst = 'a'
| 15.5
| 30
| 0.607527
|
a049162fc68e42c1be2d4c971cf4c241bc0dbf76
| 22
|
agda
|
Agda
|
test/Fail/customised/Issue4671.agda
|
cagix/agda
|
cc026a6a97a3e517bb94bafa9d49233b067c7559
|
[
"BSD-2-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
test/Fail/customised/Issue4671.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
test/Fail/customised/Issue4671.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
import Agda.PRIMITIVE
| 11
| 21
| 0.863636
|
291eb77f0946ee9c4be4c39257461d1ad09c4b3b
| 578
|
agda
|
Agda
|
test/Fail/Issue4752.agda
|
zliu41/agda
|
73405f70bced057d24dd4bf122d53f9548544aba
|
[
"BSD-3-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
test/Fail/Issue4752.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
test/Fail/Issue4752.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
-- Andreas, 2020-06-16, issue #4752
-- Disallow @-patterns in pattern synonyms.
--
-- Agda 2.5.2 implemented @-patterns and accidentially
-- allowed them in pattern synonyms.
-- However they just lead to a panic when used.
data Nat : Set where
suc : Nat → Nat
pattern ss x = suc x@(suc _)
-- EXPECTED:
--
-- @-patterns are not allowed in pattern synonyms
-- when scope checking the declaration
-- pattern ss x = suc x@(suc _)
test : Nat → Set
test (ss x) = test x
-- WAS (from 2.5.2):
--
-- Panic: unbound variable x
-- when checking that the expression x has type Nat
| 22.230769
| 54
| 0.678201
|
2233117c212bc3dc03e7ab6324f83d685b9acd43
| 579
|
agda
|
Agda
|
examples/simple-lib/Lib/Prelude.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
examples/simple-lib/Lib/Prelude.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
examples/simple-lib/Lib/Prelude.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
module Lib.Prelude where
infixr 90 _∘_
infixr 1 _,_
id : {A : Set} -> A -> A
id x = x
_∘_ : {A : Set}{B : A -> Set}{C : {x : A} -> B x -> Set}
(f : {x : A}(y : B x) -> C y)(g : (x : A) -> B x)(x : A) ->
C (g x)
(f ∘ g) x = f (g x)
data Unit : Set where
unit : Unit
{-# COMPILE GHC Unit = data () (()) #-}
postulate String : Set
{-# BUILTIN STRING String #-}
data _×_ (A B : Set) : Set where
_,_ : A -> B -> A × B
{-# COMPILE GHC _×_ = data (,) ((,)) #-}
fst : {A B : Set} -> A × B -> A
fst (x , y) = x
snd : {A B : Set} -> A × B -> B
snd (x , y) = y
| 16.542857
| 65
| 0.430052
|
045a83fe39a9f38b7a84dcee87250c9226e1e82e
| 4,533
|
agda
|
Agda
|
src/Algebra/Dioid/Bool/Theorems.agda
|
algebraic-graphs/alga-theory
|
0fdb96c0233d9be83eba637f0434d0fd22aefb1d
|
[
"MIT"
] | 60
|
2017-12-27T14:57:04.000Z
|
2022-03-22T23:05:29.000Z
|
src/Algebra/Dioid/Bool/Theorems.agda
|
algebraic-graphs/alga-theory
|
0fdb96c0233d9be83eba637f0434d0fd22aefb1d
|
[
"MIT"
] | 3
|
2018-04-12T16:25:13.000Z
|
2018-06-23T13:54:02.000Z
|
src/Algebra/Dioid/Bool/Theorems.agda
|
algebraic-graphs/alga-theory
|
0fdb96c0233d9be83eba637f0434d0fd22aefb1d
|
[
"MIT"
] | 6
|
2017-12-17T20:48:20.000Z
|
2019-05-09T23:53:28.000Z
|
module Algebra.Dioid.Bool.Theorems where
open import Algebra.Dioid
open import Algebra.Dioid.Bool
or-left-congruence : ∀ {b c d : Bool} -> b ≡ c -> (b or d) ≡ (c or d)
or-left-congruence {b} {.b} {d} reflexivity = reflexivity
or-left-congruence {b} {c} {d} (symmetry eq) = symmetry (or-left-congruence eq)
or-left-congruence {b} {c} {d} (transitivity eq eq₁) = transitivity (or-left-congruence eq) (or-left-congruence eq₁)
or-right-congruence : ∀ {b c d : Bool} -> c ≡ d -> (b or c) ≡ (b or d)
or-right-congruence {b} {c} {.c} reflexivity = reflexivity
or-right-congruence {b} {c} {d} (symmetry eq) = symmetry (or-right-congruence eq)
or-right-congruence {b} {c} {d} (transitivity eq eq₁) = transitivity (or-right-congruence eq) (or-right-congruence eq₁)
and-left-congruence : ∀ {b c d : Bool} -> b ≡ c -> (b and d) ≡ (c and d)
and-left-congruence {b} {.b} {d} reflexivity = reflexivity
and-left-congruence {b} {c} {d} (symmetry eq) = symmetry (and-left-congruence eq)
and-left-congruence {b} {c} {d} (transitivity eq eq₁) = transitivity (and-left-congruence eq) (and-left-congruence eq₁)
and-right-congruence : ∀ {b c d : Bool} -> c ≡ d -> (b and c) ≡ (b and d)
and-right-congruence {b} {c} {.c} reflexivity = reflexivity
and-right-congruence {b} {c} {d} (symmetry eq) = symmetry (and-right-congruence eq)
and-right-congruence {b} {c} {d} (transitivity eq eq₁) = transitivity (and-right-congruence eq) (and-right-congruence eq₁)
or-idempotence : ∀ {b : Bool} -> (b or b) ≡ b
or-idempotence {true} = reflexivity
or-idempotence {false} = reflexivity
or-commutativity : ∀ {b c : Bool} -> (b or c) ≡ (c or b)
or-commutativity {true} {true} = reflexivity
or-commutativity {true} {false} = reflexivity
or-commutativity {false} {true} = reflexivity
or-commutativity {false} {false} = reflexivity
or-associativity : ∀ {b c d : Bool} -> (b or (c or d)) ≡ ((b or c) or d)
or-associativity {true} {c} {d} = reflexivity
or-associativity {false} {true} {d} = reflexivity
or-associativity {false} {false} {true} = reflexivity
or-associativity {false} {false} {false} = reflexivity
or-false-identity : ∀ {b : Bool} -> (b or false) ≡ b
or-false-identity {true} = reflexivity
or-false-identity {false} = reflexivity
and-associativity : ∀ {b c d : Bool} -> (b and (c and d)) ≡ ((b and c) and d)
and-associativity {true} {true} {true} = reflexivity
and-associativity {true} {true} {false} = reflexivity
and-associativity {true} {false} {d} = reflexivity
and-associativity {false} {c} {d} = reflexivity
and-left-false : ∀ {b : Bool} -> (false and b) ≡ false
and-left-false {b} = reflexivity
and-right-false : ∀ {b : Bool} -> (b and false) ≡ false
and-right-false {true} = reflexivity
and-right-false {false} = reflexivity
and-left-true : ∀ {b : Bool} -> (true and b) ≡ b
and-left-true {true} = reflexivity
and-left-true {false} = reflexivity
and-right-true : ∀ {b : Bool} -> (b and true) ≡ b
and-right-true {true} = reflexivity
and-right-true {false} = reflexivity
left-distributivity : ∀ {b c d : Bool} -> (b and (c or d)) ≡ ((b and c) or (b and d))
left-distributivity {true} {true} {d} = reflexivity
left-distributivity {true} {false} {true} = reflexivity
left-distributivity {true} {false} {false} = reflexivity
left-distributivity {false} {c} {d} = reflexivity
right-distributivity : ∀ {b c d : Bool} -> ((b or c) and d) ≡ ((b and d) or (c and d))
right-distributivity {true} {true} {true} = reflexivity
right-distributivity {true} {true} {false} = reflexivity
right-distributivity {true} {false} {true} = reflexivity
right-distributivity {true} {false} {false} = reflexivity
right-distributivity {false} {true} {true} = reflexivity
right-distributivity {false} {true} {false} = reflexivity
right-distributivity {false} {false} {d} = reflexivity
bool-dioid : Dioid Bool _≡_
bool-dioid = record
{ zero = false
; one = true
; _+_ = _or_
; _*_ = _and_
; reflexivity = reflexivity
; symmetry = symmetry
; transitivity = transitivity
; +left-congruence = or-left-congruence
; *left-congruence = and-left-congruence
; *right-congruence = and-right-congruence
; +idempotence = or-idempotence
; +commutativity = or-commutativity
; +associativity = or-associativity
; +zero-identity = or-false-identity
; *associativity = and-associativity
; *left-zero = λ {r} → reflexivity
; *right-zero = and-right-false
; *left-identity = and-left-true
; *right-identity = and-right-true
; left-distributivity = left-distributivity
; right-distributivity = right-distributivity
}
| 41.209091
| 122
| 0.67505
|
a015af22a24cda271156fbe021a59b96d211d334
| 6,597
|
agda
|
Agda
|
Data/Bag.agda
|
oisdk/agda-playground
|
97a3aab1282b2337c5f43e2cfa3fa969a94c11b7
|
[
"MIT"
] | 6
|
2020-09-11T17:45:41.000Z
|
2021-11-16T08:11:34.000Z
|
Data/Bag.agda
|
oisdk/agda-playground
|
97a3aab1282b2337c5f43e2cfa3fa969a94c11b7
|
[
"MIT"
] | null | null | null |
Data/Bag.agda
|
oisdk/agda-playground
|
97a3aab1282b2337c5f43e2cfa3fa969a94c11b7
|
[
"MIT"
] | 1
|
2021-11-11T12:30:21.000Z
|
2021-11-11T12:30:21.000Z
|
{-# OPTIONS --cubical --safe #-}
module Data.Bag where
open import Prelude
open import Algebra
open import Path.Reasoning
infixr 5 _∷_
data ⟅_⟆ (A : Type a) : Type a where
[] : ⟅ A ⟆
_∷_ : A → ⟅ A ⟆ → ⟅ A ⟆
com : ∀ x y xs → x ∷ y ∷ xs ≡ y ∷ x ∷ xs
trunc : isSet ⟅ A ⟆
record Elim {a ℓ}
(A : Type a)
(P : ⟅ A ⟆ → Type ℓ)
: Type (a ℓ⊔ ℓ) where
constructor elim
field
⟅_⟆-set : ∀ {xs} → isSet (P xs)
⟅_⟆[] : P []
⟅_⟆_∷_⟨_⟩ : ∀ x xs → P xs → P (x ∷ xs)
private z = ⟅_⟆[]; f = ⟅_⟆_∷_⟨_⟩
field
⟅_⟆-com : (∀ x y xs pxs →
PathP (λ i → P (com x y xs i))
(f x (y ∷ xs) (f y xs pxs))
(f y (x ∷ xs) (f x xs pxs)))
⟅_⟆⇓ : (xs : ⟅ A ⟆) → P xs
⟅ [] ⟆⇓ = z
⟅ x ∷ xs ⟆⇓ = f x xs ⟅ xs ⟆⇓
⟅ com x y xs i ⟆⇓ = ⟅_⟆-com x y xs ⟅ xs ⟆⇓ i
⟅ trunc xs ys x y i j ⟆⇓ =
isOfHLevel→isOfHLevelDep 2
(λ xs → ⟅_⟆-set {xs})
⟅ xs ⟆⇓ ⟅ ys ⟆⇓
(cong ⟅_⟆⇓ x) (cong ⟅_⟆⇓ y)
(trunc xs ys x y)
i j
open Elim
infixr 0 elim-syntax
elim-syntax : ∀ {a ℓ}
→ (A : Type a)
→ (⟅ A ⟆ → Type ℓ)
→ Type (a ℓ⊔ ℓ)
elim-syntax = Elim
syntax elim-syntax A (λ xs → Pxs) = xs ⦂⟅ A ⟆→ Pxs
record ElimProp {a ℓ} (A : Type a) (P : ⟅ A ⟆ → Type ℓ) : Type (a ℓ⊔ ℓ) where
constructor elim-prop
field
⟦_⟧-prop : ∀ {xs} → isProp (P xs)
⟦_⟧[] : P []
⟦_⟧_∷_⟨_⟩ : ∀ x xs → P xs → P (x ∷ xs)
private z = ⟦_⟧[]; f = ⟦_⟧_∷_⟨_⟩
⟦_⟧⇑ = elim
(isProp→isSet ⟦_⟧-prop)
z f
(λ x y xs pxs → toPathP (⟦_⟧-prop (transp (λ i → P (com x y xs i)) i0
(f x (y ∷ xs) (f y xs pxs))) (f y (x ∷ xs) (f x xs pxs))))
⟦_⟧⇓ = ⟅ ⟦_⟧⇑ ⟆⇓
open ElimProp
infixr 0 elim-prop-syntax
elim-prop-syntax : ∀ {a ℓ} → (A : Type a) → (⟅ A ⟆ → Type ℓ) → Type (a ℓ⊔ ℓ)
elim-prop-syntax = ElimProp
syntax elim-prop-syntax A (λ xs → Pxs) = xs ⦂⟅ A ⟆→∥ Pxs ∥
record [⟅_⟆→_] {a b} (A : Type a) (B : Type b) : Type (a ℓ⊔ b) where
constructor rec
field
[_]-set : isSet B
[_]_∷_ : A → B → B
[_][] : B
private f = [_]_∷_; z = [_][]
field
[_]-com : ∀ x y xs → f x (f y xs) ≡ f y (f x xs)
[_]⇑ = elim [_]-set z (λ x _ → f x) (λ x y _ → [_]-com x y)
[_]↓ = ⟅ [_]⇑ ⟆⇓
open [⟅_⟆→_]
infixr 5 _∪_
_∪_ : ⟅ A ⟆ → ⟅ A ⟆ → ⟅ A ⟆
_∪_ = λ xs ys → [ ys ∪′ ]↓ xs
where
_∪′ : ⟅ A ⟆ → [⟅ A ⟆→ ⟅ A ⟆ ]
[ ys ∪′ ]-set = trunc
[ ys ∪′ ] x ∷ xs = x ∷ xs
[ ys ∪′ ][] = ys
[ ys ∪′ ]-com = com
∪-assoc : (xs ys zs : ⟅ A ⟆) →
(xs ∪ ys) ∪ zs ≡ xs ∪ (ys ∪ zs)
∪-assoc = λ xs ys zs → ⟦ ∪-assoc′ ys zs ⟧⇓ xs
where
∪-assoc′ : ∀ ys zs →
xs ⦂⟅ A ⟆→∥ (xs ∪ ys) ∪ zs ≡ xs ∪ (ys ∪ zs) ∥
⟦ ∪-assoc′ ys zs ⟧-prop = trunc _ _
⟦ ∪-assoc′ ys zs ⟧[] = refl
⟦ ∪-assoc′ ys zs ⟧ x ∷ xs ⟨ P ⟩ = cong (x ∷_) P
∪-cons : ∀ (x : A) xs ys
→ (x ∷ xs) ∪ ys ≡ xs ∪ (x ∷ ys)
∪-cons = λ x xs ys → ⟦ ∪-cons′ x ys ⟧⇓ xs
where
∪-cons′ : ∀ x ys →
xs ⦂⟅ A ⟆→∥ (x ∷ xs) ∪ ys ≡ xs ∪ (x ∷ ys) ∥
⟦ ∪-cons′ x ys ⟧-prop = trunc _ _
⟦ ∪-cons′ x ys ⟧[] = refl
⟦ ∪-cons′ x ys ⟧ y ∷ xs ⟨ P ⟩ = cong (_∪ ys) (com x y xs) ; cong (y ∷_) P
∪-idʳ : (xs : ⟅ A ⟆) → xs ∪ [] ≡ xs
∪-idʳ = ⟦ ∪-idʳ′ ⟧⇓
where
∪-idʳ′ : xs ⦂⟅ A ⟆→∥ xs ∪ [] ≡ xs ∥
⟦ ∪-idʳ′ ⟧-prop = trunc _ _
⟦ ∪-idʳ′ ⟧[] = refl
⟦ ∪-idʳ′ ⟧ x ∷ xs ⟨ P ⟩ = cong (x ∷_) P
∪-comm : (xs ys : ⟅ A ⟆) → xs ∪ ys ≡ ys ∪ xs
∪-comm {A = A} = λ xs ys → ⟦ ∪-comm′ ys ⟧⇓ xs
where
∪-comm′ : (ys : ⟅ A ⟆) →
xs ⦂⟅ A ⟆→∥ xs ∪ ys ≡ ys ∪ xs ∥
⟦ ∪-comm′ ys ⟧-prop = trunc _ _
⟦ ∪-comm′ ys ⟧[] = sym (∪-idʳ ys)
⟦ ∪-comm′ ys ⟧ x ∷ xs ⟨ P ⟩ =
(x ∷ xs) ∪ ys ≡⟨ cong (x ∷_) P ⟩
(x ∷ ys) ∪ xs ≡⟨ ∪-cons x ys xs ⟩
ys ∪ x ∷ xs ∎
⟅⟆-commutative-monoid : ∀ {a} (A : Type a) → CommutativeMonoid _
Monoid.𝑆 (CommutativeMonoid.monoid (⟅⟆-commutative-monoid A)) = ⟅ A ⟆
Monoid._∙_ (CommutativeMonoid.monoid (⟅⟆-commutative-monoid A)) = _∪_
Monoid.ε (CommutativeMonoid.monoid (⟅⟆-commutative-monoid A)) = []
Monoid.assoc (CommutativeMonoid.monoid (⟅⟆-commutative-monoid A)) = ∪-assoc
Monoid.ε∙ (CommutativeMonoid.monoid (⟅⟆-commutative-monoid A)) _ = refl
Monoid.∙ε (CommutativeMonoid.monoid (⟅⟆-commutative-monoid A)) = ∪-idʳ
CommutativeMonoid.comm (⟅⟆-commutative-monoid A) = ∪-comm
module _ {ℓ} (mon : CommutativeMonoid ℓ) (sIsSet : isSet (CommutativeMonoid.𝑆 mon)) where
open CommutativeMonoid mon
⟦_⟧ : (A → 𝑆) → ⟅ A ⟆ → 𝑆
⟦_⟧ = λ h → [ ⟦ h ⟧′ ]↓
where
⟦_⟧′ : (A → 𝑆) → [⟅ A ⟆→ 𝑆 ]
[ ⟦ h ⟧′ ] x ∷ xs = h x ∙ xs
[ ⟦ h ⟧′ ][] = ε
[ ⟦ h ⟧′ ]-com x y xs =
h x ∙ (h y ∙ xs)
≡˘⟨ assoc _ _ _ ⟩
(h x ∙ h y) ∙ xs
≡⟨ cong (_∙ xs) (comm _ _) ⟩
(h y ∙ h x) ∙ xs
≡⟨ assoc _ _ _ ⟩
h y ∙ (h x ∙ xs) ∎
[ ⟦ h ⟧′ ]-set = sIsSet
record ⟦_≡_⟧ {a b} {A : Type a} {B : Type b}
(h : ⟅ A ⟆ → B)
(xf : [⟅ A ⟆→ B ])
: Type (a ℓ⊔ b) where
constructor elim-univ
field
⟦_≡⟧_∷_ : ∀ x xs → h (x ∷ xs) ≡ [ xf ] x ∷ h xs
⟦_≡⟧[] : h [] ≡ [ xf ][]
⟦_≡⟧⇓ : ∀ xs → h xs ≡ [ xf ]↓ xs
⟦_≡⟧⇓ = ⟦ ≡⇓′ ⟧⇓
where
≡⇓′ : xs ⦂⟅ A ⟆→∥ h xs ≡ [ xf ]↓ xs ∥
⟦ ≡⇓′ ⟧-prop = [ xf ]-set _ _
⟦ ≡⇓′ ⟧[] = ⟦_≡⟧[]
⟦ ≡⇓′ ⟧ x ∷ xs ⟨ P ⟩ = ⟦_≡⟧_∷_ x _ ; cong ([ xf ] x ∷_) P
open ⟦_≡_⟧
record ⟦_⊚_≡_⟧ {a b c} {A : Type a} {B : Type b} {C : Type c}
(h : B → C)
(xf : [⟅ A ⟆→ B ])
(yf : [⟅ A ⟆→ C ])
: Type (a ℓ⊔ b ℓ⊔ c)
where
constructor elim-fuse
field
⟦_∘≡⟧_∷_ : ∀ x xs → h ([ xf ] x ∷ xs) ≡ [ yf ] x ∷ h xs
⟦_∘≡⟧[] : h [ xf ][] ≡ [ yf ][]
⟦_∘≡⟧⇓ : ∀ xs → h ([ xf ]↓ xs) ≡ [ yf ]↓ xs
⟦_∘≡⟧⇓ = ⟦ ≡⇓′ ⟧⇓
where
≡⇓′ : xs ⦂⟅ A ⟆→∥ h ([ xf ]↓ xs) ≡ [ yf ]↓ xs ∥
⟦ ≡⇓′ ⟧-prop = [ yf ]-set _ _
⟦ ≡⇓′ ⟧[] = ⟦_∘≡⟧[]
⟦ ≡⇓′ ⟧ x ∷ xs ⟨ P ⟩ = ⟦_∘≡⟧_∷_ x _ ; cong ([ yf ] x ∷_) P
open ⟦_⊚_≡_⟧
map-alg : (A → B) → [⟅ A ⟆→ ⟅ B ⟆ ]
[ map-alg f ]-set = trunc
[ map-alg f ][] = []
[ map-alg f ] x ∷ xs = f x ∷ xs
[ map-alg f ]-com x y = com (f x) (f y)
map : (A → B) → ⟅ A ⟆ → ⟅ B ⟆
map f = [ map-alg f ]↓
[_]∘_ : [⟅ B ⟆→ C ] → (A → B) → [⟅ A ⟆→ C ]
[ [ g ]∘ f ]-set = [ g ]-set
[ [ g ]∘ f ][] = [ g ][]
[ [ g ]∘ f ] x ∷ xs = [ g ] f x ∷ xs
[ [ g ]∘ f ]-com x y = [ g ]-com (f x) (f y)
map-fuse : ∀ (g : [⟅ B ⟆→ C ]) (f : A → B)
→ [ g ]↓ ∘ map f ≡ [ [ g ]∘ f ]↓
map-fuse g f = funExt ⟦ map-fuse′ g f ∘≡⟧⇓
where
map-fuse′ : (g : [⟅ B ⟆→ C ]) (f : A → B)
→ ⟦ [ g ]↓ ⊚ map-alg f ≡ [ g ]∘ f ⟧
⟦ map-fuse′ g f ∘≡⟧ x ∷ xs = refl
⟦ map-fuse′ g f ∘≡⟧[] = refl
bind : ⟅ A ⟆ → (A → ⟅ B ⟆) → ⟅ B ⟆
bind xs f = ⟦ ⟅⟆-commutative-monoid _ ⟧ trunc f xs
| 28.80786
| 89
| 0.405033
|
0480c257a4bc839469d67e66f03570ce6c1c8595
| 145
|
agda
|
Agda
|
data/expression/Lam.agda
|
msuperdock/agda-unused
|
f327f9aab8dcb07022b857736d8201906bba02e9
|
[
"MIT"
] | 6
|
2020-10-29T09:38:43.000Z
|
2022-03-01T16:38:05.000Z
|
data/expression/Lam.agda
|
msuperdock/agda-unused
|
f327f9aab8dcb07022b857736d8201906bba02e9
|
[
"MIT"
] | null | null | null |
data/expression/Lam.agda
|
msuperdock/agda-unused
|
f327f9aab8dcb07022b857736d8201906bba02e9
|
[
"MIT"
] | 1
|
2022-03-01T16:38:14.000Z
|
2022-03-01T16:38:14.000Z
|
module Lam where
f
: {A : Set}
→ A
→ A
f x
= (λ y z → z) x x
g
: {A : Set}
→ A
→ A
g {A = A} x
= (λ (y' : A) (z : A) → z) x x
| 8.529412
| 32
| 0.331034
|
296616c5a5165f3a1ce24c2f4182f096c80fa623
| 6,219
|
agda
|
Agda
|
src/Categories/Category/Cartesian/Monoidal.agda
|
yourboynico/agda-categories
|
6a087c592dbe58fc4bd9d02e1be9b94a9e138aca
|
[
"MIT"
] | 279
|
2019-06-01T14:36:40.000Z
|
2022-03-22T00:40:14.000Z
|
src/Categories/Category/Cartesian/Monoidal.agda
|
seanpm2001/agda-categories
|
d9e4f578b126313058d105c61707d8c8ae987fa8
|
[
"MIT"
] | 236
|
2019-06-01T14:53:54.000Z
|
2022-03-28T14:31:43.000Z
|
src/Categories/Category/Cartesian/Monoidal.agda
|
seanpm2001/agda-categories
|
d9e4f578b126313058d105c61707d8c8ae987fa8
|
[
"MIT"
] | 64
|
2019-06-02T16:58:15.000Z
|
2022-03-14T02:00:59.000Z
|
{-# OPTIONS --without-K --safe #-}
open import Categories.Category using (Category; module Commutation)
-- Defines the induced Monoidal structure of a Cartesian Category
module Categories.Category.Cartesian.Monoidal {o ℓ e} {𝒞 : Category o ℓ e} where
open Category 𝒞
open HomReasoning
open import Categories.Category.BinaryProducts 𝒞 using (BinaryProducts; module BinaryProducts)
open import Categories.Category.Cartesian using (Cartesian)
open import Categories.Object.Terminal 𝒞 using (Terminal)
open import Categories.Object.Product.Core 𝒞 using (module Product)
open import Categories.Morphism 𝒞 using (_≅_; module ≅)
open import Categories.Morphism.Reasoning 𝒞 using (cancelˡ; pullʳ; pullˡ)
open import Categories.Category.Monoidal using (Monoidal)
open import Categories.Functor using (Functor) renaming (id to idF)
open import Categories.NaturalTransformation using (ntHelper)
open import Categories.NaturalTransformation.NaturalIsomorphism using (NaturalIsomorphism)
private
variable
A B C D W X Y Z : Obj
f f′ g g′ h i : A ⇒ B
-- The cartesian structure induces a monoidal one: 𝒞 is cartesian monoidal.
module CartesianMonoidal (cartesian : Cartesian 𝒞) where
open Commutation 𝒞
open Terminal (Cartesian.terminal cartesian) using (⊤; !; !-unique; !-unique₂)
open BinaryProducts (Cartesian.products cartesian) using (π₁; π₂; ⟨_,_⟩; _×_; _⁂_;
_×-; -×_; ⟨⟩∘; ⟨⟩-cong₂; -×-; ×-assoc; assocˡ∘⁂; assocʳ∘⁂; ⁂∘⟨⟩;
first∘⟨⟩; second∘⟨⟩; ⟨⟩-congˡ; ⟨⟩-congʳ; π₁∘⁂; π₂∘⁂; assocˡ∘⟨⟩;
assocˡ; assocʳ;
η; unique; project₁; project₂)
⊤×A≅A : ⊤ × A ≅ A
⊤×A≅A = record
{ from = π₂
; to = ⟨ ! , id ⟩
; iso = record
{ isoˡ = begin
⟨ ! , id ⟩ ∘ π₂ ≈˘⟨ unique !-unique₂ (cancelˡ project₂) ⟩
⟨ π₁ , π₂ ⟩ ≈⟨ η ⟩
id ∎
; isoʳ = project₂
}
}
A×⊤≅A : A × ⊤ ≅ A
A×⊤≅A = record
{ from = π₁
; to = ⟨ id , ! ⟩
; iso = record
{ isoˡ = begin
⟨ id , ! ⟩ ∘ π₁ ≈˘⟨ unique (cancelˡ project₁) !-unique₂ ⟩
⟨ π₁ , π₂ ⟩ ≈⟨ η ⟩
id ∎
; isoʳ = project₁
}
}
⊤×--id : NaturalIsomorphism (⊤ ×-) idF
⊤×--id = record
{ F⇒G = ntHelper record
{ η = λ _ → π₂
; commute = λ _ → project₂
}
; F⇐G = ntHelper record
{ η = λ _ → ⟨ ! , id ⟩
; commute = λ f → begin
⟨ ! , id ⟩ ∘ f ≈⟨ ⟨⟩∘ ⟩
⟨ ! ∘ f , id ∘ f ⟩ ≈⟨ ⟨⟩-cong₂ (⟺ (!-unique _)) identityˡ ⟩
⟨ ! , f ⟩ ≈˘⟨ ⟨⟩-cong₂ identityˡ identityʳ ⟩
⟨ id ∘ ! , f ∘ id ⟩ ≈˘⟨ ⟨⟩-cong₂ (pullʳ project₁) (pullʳ project₂) ⟩
⟨ (id ∘ π₁) ∘ ⟨ ! , id ⟩ , (f ∘ π₂) ∘ ⟨ ! , id ⟩ ⟩ ≈˘⟨ ⟨⟩∘ ⟩
⟨ id ∘ π₁ , f ∘ π₂ ⟩ ∘ ⟨ ! , id ⟩ ∎
}
; iso = λ _ → _≅_.iso ⊤×A≅A
}
-×⊤-id : NaturalIsomorphism (-× ⊤) idF
-×⊤-id = record
{ F⇒G = ntHelper record
{ η = λ _ → π₁
; commute = λ _ → project₁
}
; F⇐G = ntHelper record
{ η = λ _ → ⟨ id , ! ⟩
; commute = λ f → begin
⟨ id , ! ⟩ ∘ f ≈⟨ ⟨⟩∘ ⟩
⟨ id ∘ f , ! ∘ f ⟩ ≈⟨ ⟨⟩-cong₂ identityˡ (⟺ (!-unique _)) ⟩
⟨ f , ! ⟩ ≈˘⟨ ⟨⟩-cong₂ identityʳ identityˡ ⟩
⟨ f ∘ id , id ∘ ! ⟩ ≈˘⟨ ⟨⟩-cong₂ (pullʳ project₁) (pullʳ project₂) ⟩
⟨ (f ∘ π₁) ∘ ⟨ id , ! ⟩ , (id ∘ π₂) ∘ ⟨ id , ! ⟩ ⟩ ≈˘⟨ ⟨⟩∘ ⟩
⟨ f ∘ π₁ , id ∘ π₂ ⟩ ∘ ⟨ id , ! ⟩ ∎
}
; iso = λ _ → _≅_.iso A×⊤≅A
}
private
infixr 7 _⊗₀_
infixr 8 _⊗₁_
_⊗₀_ = _×_
_⊗₁_ = _⁂_
α⇒ = assocˡ
private
pentagon : [ ((X ⊗₀ Y) ⊗₀ Z) ⊗₀ W ⇒ X ⊗₀ Y ⊗₀ Z ⊗₀ W ]⟨
α⇒ ⊗₁ id ⇒⟨ (X ⊗₀ Y ⊗₀ Z) ⊗₀ W ⟩
α⇒ ⇒⟨ X ⊗₀ (Y ⊗₀ Z) ⊗₀ W ⟩
id ⊗₁ α⇒
≈ α⇒ ⇒⟨ (X ⊗₀ Y) ⊗₀ Z ⊗₀ W ⟩
α⇒
⟩
pentagon = begin
(id ⁂ α⇒) ∘ α⇒ ∘ (α⇒ ⁂ id) ≈⟨ pullˡ second∘⟨⟩ ⟩
⟨ π₁ ∘ π₁ , α⇒ ∘ ⟨ π₂ ∘ π₁ , π₂ ⟩ ⟩ ∘ (α⇒ ⁂ id) ≈⟨ ⟨⟩∘ ⟩
⟨ (π₁ ∘ π₁) ∘ (α⇒ ⁂ id) , (α⇒ ∘ ⟨ π₂ ∘ π₁ , π₂ ⟩) ∘ (α⇒ ⁂ id) ⟩ ≈⟨ ⟨⟩-cong₂ (pullʳ π₁∘⁂) (pullʳ ⟨⟩∘) ⟩
⟨ π₁ ∘ α⇒ ∘ π₁ , α⇒ ∘ ⟨ (π₂ ∘ π₁) ∘ (α⇒ ⁂ id) , π₂ ∘ (α⇒ ⁂ id) ⟩ ⟩ ≈⟨ ⟨⟩-cong₂ (pullˡ project₁) ( refl⟩∘⟨ ⟨⟩-cong₂ (pullʳ π₁∘⁂) π₂∘⁂) ⟩
⟨ (π₁ ∘ π₁) ∘ π₁ , α⇒ ∘ ⟨ π₂ ∘ α⇒ ∘ π₁ , id ∘ π₂ ⟩ ⟩ ≈⟨ ⟨⟩-cong₂ assoc (refl⟩∘⟨ ⟨⟩-cong₂ (pullˡ project₂) identityˡ) ⟩
⟨ π₁₁₁ , α⇒ ∘ ⟨ ⟨ π₂ ∘ π₁ , π₂ ⟩ ∘ π₁ , π₂ ⟩ ⟩ ≈⟨ ⟨⟩-congˡ (refl⟩∘⟨ ⟨⟩-congʳ ⟨⟩∘) ⟩
⟨ π₁₁₁ , α⇒ ∘ ⟨ ⟨ (π₂ ∘ π₁) ∘ π₁ , π₂ ∘ π₁ ⟩ , π₂ ⟩ ⟩ ≈⟨ ⟨⟩-congˡ assocˡ∘⟨⟩ ⟩
⟨ π₁₁₁ , ⟨ (π₂ ∘ π₁) ∘ π₁ , ⟨ π₂ ∘ π₁ , π₂ ⟩ ⟩ ⟩ ≈˘⟨ ⟨⟩-congˡ (⟨⟩-cong₂ (Equiv.trans (pullʳ project₁) sym-assoc) project₂) ⟩
⟨ π₁₁₁ , ⟨ (π₂ ∘ π₁) ∘ α⇒ , π₂ ∘ α⇒ ⟩ ⟩ ≈˘⟨ ⟨⟩-cong₂ (pullʳ project₁) ⟨⟩∘ ⟩
⟨ (π₁ ∘ π₁) ∘ α⇒ , ⟨ π₂ ∘ π₁ , π₂ ⟩ ∘ α⇒ ⟩ ≈˘⟨ ⟨⟩∘ ⟩
α⇒ ∘ α⇒ ∎
where
π₁₁₁ = π₁ ∘ π₁ ∘ π₁
monoidal : Monoidal 𝒞
monoidal = record
{ ⊗ = -×-
; unit = ⊤
; unitorˡ = ⊤×A≅A
; unitorʳ = A×⊤≅A
; associator = ≅.sym ×-assoc
; unitorˡ-commute-from = project₂
; unitorˡ-commute-to = let open NaturalIsomorphism ⊤×--id in ⇐.commute _
; unitorʳ-commute-from = project₁
; unitorʳ-commute-to = let open NaturalIsomorphism -×⊤-id in ⇐.commute _
; assoc-commute-from = assocˡ∘⁂
; assoc-commute-to = assocʳ∘⁂
; triangle = begin
(id ⁂ π₂) ∘ assocˡ ≈⟨ ⁂∘⟨⟩ ⟩
⟨ id ∘ π₁ ∘ π₁ , π₂ ∘ ⟨ π₂ ∘ π₁ , π₂ ⟩ ⟩ ≈⟨ ⟨⟩-cong₂ (pullˡ identityˡ) (project₂ ○ (⟺ identityˡ)) ⟩
π₁ ⁂ id ∎
; pentagon = pentagon
}
| 40.647059
| 151
| 0.423058
|
2eca80d5b5d669ab8e2069b589f364a4d5a25750
| 1,884
|
agda
|
Agda
|
Examples/Identifier-list.agda
|
nad/pretty
|
b956803ba90b6c5f57bbbaab01bb18485d948492
|
[
"MIT"
] | null | null | null |
Examples/Identifier-list.agda
|
nad/pretty
|
b956803ba90b6c5f57bbbaab01bb18485d948492
|
[
"MIT"
] | null | null | null |
Examples/Identifier-list.agda
|
nad/pretty
|
b956803ba90b6c5f57bbbaab01bb18485d948492
|
[
"MIT"
] | null | null | null |
------------------------------------------------------------------------
-- Lists of identifiers
------------------------------------------------------------------------
-- This example is based on one in Swierstra and Chitil's "Linear,
-- bounded, functional pretty-printing".
{-# OPTIONS --guardedness #-}
module Examples.Identifier-list where
open import Codata.Musical.Notation
open import Data.List
import Data.List.NonEmpty as List⁺
open import Relation.Binary.PropositionalEquality using (_≡_; refl)
open import Examples.Identifier
open import Grammar.Infinite as Grammar
using (Grammar) hiding (module Grammar)
open import Pretty using (Pretty-printer)
open import Renderer
open import Utilities
identifier-list-body : Grammar (List Identifier)
identifier-list-body =
return []
∣ List⁺.toList <$> (identifier-w sep-by symbol′ ",")
where open Grammar
identifier-list : Grammar (List Identifier)
identifier-list = symbol′ "[" ⊛> identifier-list-body <⊛ symbol′ "]"
where open Grammar
open Pretty
identifier-list-printer : Pretty-printer identifier-list
identifier-list-printer ns = symbol ⊛> body ns <⊛ symbol
where
body : Pretty-printer identifier-list-body
body [] = left nil
body (n ∷ ns) =
right (<$> (<$> identifier-w-printer n
⊛
map⋆ (λ n → group symbol-line ⊛>
identifier-w-printer n)
ns))
identifiers : List Identifier
identifiers = str⁺ "aaa" ∷ str⁺ "bbbbb" ∷ str⁺ "ccc" ∷
str⁺ "dd" ∷ str⁺ "eee" ∷ []
test₁ : render 80 (identifier-list-printer identifiers) ≡
"[aaa, bbbbb, ccc, dd, eee]"
test₁ = refl
test₂ : render 11 (identifier-list-printer identifiers) ≡
"[aaa,\nbbbbb, ccc,\ndd, eee]"
test₂ = refl
test₃ : render 8 (identifier-list-printer identifiers) ≡
"[aaa,\nbbbbb,\nccc, dd,\neee]"
test₃ = refl
| 29.904762
| 72
| 0.613588
|
297d3a2ac080286b9d9035aa29d6caf8187b3694
| 1,122
|
agda
|
Agda
|
lib/groups/Unit.agda
|
danbornside/HoTT-Agda
|
1695a7f3dc60177457855ae846bbd86fcd96983e
|
[
"MIT"
] | 1
|
2021-06-30T00:17:55.000Z
|
2021-06-30T00:17:55.000Z
|
lib/groups/Unit.agda
|
danbornside/HoTT-Agda
|
1695a7f3dc60177457855ae846bbd86fcd96983e
|
[
"MIT"
] | null | null | null |
lib/groups/Unit.agda
|
danbornside/HoTT-Agda
|
1695a7f3dc60177457855ae846bbd86fcd96983e
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --without-K #-}
open import lib.Basics
open import lib.types.Group
open import lib.types.Unit
open import lib.groups.Homomorphisms
open import lib.groups.Lift
module lib.groups.Unit where
Unit-group-structure : GroupStructure Unit
Unit-group-structure = record
{ ident = unit
; inv = λ _ → unit
; comp = λ _ _ → unit
; unitl = λ _ → idp
; unitr = λ _ → idp
; assoc = λ _ _ _ → idp
; invr = λ _ → idp
; invl = λ _ → idp
}
Unit-Group : Group lzero
Unit-Group = group _ Unit-is-set Unit-group-structure
LiftUnit-Group : ∀ {i} → Group i
LiftUnit-Group = Lift-Group Unit-Group
0ᴳ = LiftUnit-Group
contr-is-0ᴳ : ∀ {i} (G : Group i) → is-contr (Group.El G) → G == 0ᴳ
contr-is-0ᴳ G pA = group-ua
(group-hom (λ _ → lift unit) (λ _ _ → idp) , snd (contr-equiv-LiftUnit pA))
0ᴳ-hom-out-level : ∀ {i j} {G : Group i}
→ is-contr (0ᴳ {j} →ᴳ G)
0ᴳ-hom-out-level {G = G} =
(cst-hom ,
λ φ → hom= _ _ (λ= (λ {(lift unit) → ! (GroupHom.pres-ident φ)})))
0ᴳ-hom-in-level : ∀ {i j} {G : Group i}
→ is-contr (G →ᴳ 0ᴳ {j})
0ᴳ-hom-in-level {G = G} =
(cst-hom , λ φ → hom= _ _ (λ= (λ _ → idp)))
| 24.933333
| 77
| 0.606952
|
c757cd254a50a642ef0a76dba21e607cadac36e5
| 64
|
agda
|
Agda
|
test/api/Issue1168.agda
|
pthariensflame/agda
|
222c4c64b2ccf8e0fc2498492731c15e8fef32d4
|
[
"BSD-3-Clause"
] | null | null | null |
test/api/Issue1168.agda
|
pthariensflame/agda
|
222c4c64b2ccf8e0fc2498492731c15e8fef32d4
|
[
"BSD-3-Clause"
] | null | null | null |
test/api/Issue1168.agda
|
pthariensflame/agda
|
222c4c64b2ccf8e0fc2498492731c15e8fef32d4
|
[
"BSD-3-Clause"
] | null | null | null |
module Issue1168 where
id : {A : Set} → A → A
id {A = A} a = a
| 12.8
| 22
| 0.53125
|
a0db2e6a25850c8eab204567f0e94b71ccdc8fc1
| 5,543
|
agda
|
Agda
|
Categories/Category/Core.agda
|
rei1024/agda-categories
|
89d163f72caa7deeac9413f27bc1b4ed7f9e025b
|
[
"MIT"
] | null | null | null |
Categories/Category/Core.agda
|
rei1024/agda-categories
|
89d163f72caa7deeac9413f27bc1b4ed7f9e025b
|
[
"MIT"
] | null | null | null |
Categories/Category/Core.agda
|
rei1024/agda-categories
|
89d163f72caa7deeac9413f27bc1b4ed7f9e025b
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --without-K --safe #-}
module Categories.Category.Core where
open import Level
open import Function using (flip)
open import Relation.Binary hiding (_⇒_)
import Relation.Binary.PropositionalEquality as ≡
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
dom : ∀ {A B} → (A ⇒ B) → Obj
dom {A} _ = A
cod : ∀ {A B} → (A ⇒ B) → Obj
cod {B = B} _ = B
∘-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
}
-- 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
-- for reasoning in the Strict cases
≡⇒≈ : {f g : A ⇒ B} → f ≡.≡ g → f ≈ g
≡⇒≈ ≡.refl = Equiv.refl
subst₂≈ : {C D : Obj} {f g : A ⇒ B} → f ≈ g → (eq₁ : A ≡.≡ C) (eq₂ : B ≡.≡ D) →
≡.subst₂ (_⇒_) eq₁ eq₂ f ≈ ≡.subst₂ (_⇒_) eq₁ eq₂ g
subst₂≈ f≈g ≡.refl ≡.refl = f≈g
-- Combinators for commutative diagram
-- The idea is to use the combinators to write commutations in a more readable way.
-- It starts with [_⇒_]⟨_≈_⟩, and within the third and fourth places, use _⇒⟨_⟩_ to
-- connect morphisms with the intermediate object specified.
module Commutation where
infix 1 [_⇒_]⟨_≈_⟩
[_⇒_]⟨_≈_⟩ : ∀ (A B : Obj) → A ⇒ B → A ⇒ B → Set _
[ A ⇒ B ]⟨ f ≈ g ⟩ = f ≈ g
infixl 2 connect
connect : ∀ {A C : Obj} (B : Obj) → A ⇒ B → B ⇒ C → A ⇒ C
connect B f g = g ∘ f
syntax connect B f g = f ⇒⟨ B ⟩ g
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-≈
}
-- Q: Should this really be defined here?
CommutativeSquare : ∀ {A B C D} → (f : A ⇒ B) (g : A ⇒ C) (h : B ⇒ D) (i : C ⇒ D) → Set _
CommutativeSquare f g h i = h ∘ f ≈ i ∘ g
-- Since we add extra proofs in the definition of `Category` (i.e. `sym-assoc` and
-- `identity²`), we might still want to construct a `Category` in its originally
-- easier manner. Thus, this redundant definition is here to ease the construction.
record CategoryHelper (o ℓ e : Level) : Set (suc (o ⊔ ℓ ⊔ e)) where
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)
identityˡ : ∀ {A B} {f : A ⇒ B} → id ∘ f ≈ f
identityʳ : ∀ {A B} {f : A ⇒ B} → f ∘ id ≈ f
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
categoryHelper : ∀ {o ℓ e} → CategoryHelper o ℓ e → Category o ℓ e
categoryHelper C = record
{ Obj = Obj
; _⇒_ = _⇒_
; _≈_ = _≈_
; id = id
; _∘_ = _∘_
; assoc = assoc
; sym-assoc = sym assoc
; identityˡ = identityˡ
; identityʳ = identityʳ
; identity² = identityˡ
; equiv = equiv
; ∘-resp-≈ = ∘-resp-≈
}
where open CategoryHelper C
module _ {A B} where
open IsEquivalence (equiv {A} {B}) public
| 32.415205
| 91
| 0.498647
|
380f1b3006d9bc4a770fea5f76fd33fb76706638
| 5,421
|
agda
|
Agda
|
Cubical/Algebra/CommRingSolver/HornerEval.agda
|
guilhermehas/cubical
|
ce3120d3f8d692847b2744162bcd7a01f0b687eb
|
[
"MIT"
] | 1
|
2021-10-31T17:32:49.000Z
|
2021-10-31T17:32:49.000Z
|
Cubical/Algebra/CommRingSolver/HornerEval.agda
|
guilhermehas/cubical
|
ce3120d3f8d692847b2744162bcd7a01f0b687eb
|
[
"MIT"
] | null | null | null |
Cubical/Algebra/CommRingSolver/HornerEval.agda
|
guilhermehas/cubical
|
ce3120d3f8d692847b2744162bcd7a01f0b687eb
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --safe #-}
module Cubical.Algebra.CommRingSolver.HornerEval where
open import Cubical.Foundations.Prelude
open import Cubical.Data.Nat using (ℕ)
open import Cubical.Data.Int hiding (_+_ ; _·_ ; -_)
open import Cubical.Data.Vec
open import Cubical.Data.Bool
open import Cubical.Relation.Nullary.Base using (¬_; yes; no)
open import Cubical.Algebra.CommRingSolver.Utility
open import Cubical.Algebra.CommRingSolver.RawAlgebra
open import Cubical.Algebra.CommRingSolver.IntAsRawRing
open import Cubical.Algebra.CommRingSolver.HornerForms
open import Cubical.Algebra.CommRing
open import Cubical.Algebra.Ring
private
variable
ℓ ℓ' : Level
eval : {A : RawAlgebra ℤAsRawRing ℓ'}
{n : ℕ} (P : IteratedHornerForms A n)
→ Vec ⟨ A ⟩ n → ⟨ A ⟩
eval {A = A} (const r) [] = RawAlgebra.scalar A r
eval {A = A} 0H (_ ∷ _) = RawAlgebra.0r A
eval {A = A} (P ·X+ Q) (x ∷ xs) =
let open RawAlgebra A
P' = (eval P (x ∷ xs))
Q' = eval Q xs
in if (isZero A P)
then Q'
else P' · x + Q'
module _ (R : CommRing ℓ) where
private
νR = CommRing→RawℤAlgebra R
open CommRingStr (snd R)
open RingTheory (CommRing→Ring R)
open IteratedHornerOperations νR
someCalculation : {x : fst R} → _ ≡ _
someCalculation {x = x} =
0r ≡⟨ sym (+Rid 0r) ⟩
0r + 0r ≡[ i ]⟨ 0LeftAnnihilates x (~ i) + 0r ⟩
0r · x + 0r ∎
evalIsZero : {n : ℕ} (P : IteratedHornerForms νR n)
→ (l : Vec (fst R) n)
→ isZero νR P ≡ true
→ eval P l ≡ 0r
evalIsZero (const (pos ℕ.zero)) [] isZeroP = refl
evalIsZero (const (pos (ℕ.suc n))) [] isZeroP = byBoolAbsurdity isZeroP
evalIsZero (const (negsuc _)) [] isZeroP = byBoolAbsurdity isZeroP
evalIsZero 0H (x ∷ xs) _ = refl
evalIsZero {n = ℕ.suc n} (P ·X+ Q) (x ∷ xs) isZeroPandQ with isZero νR P
... | true = eval Q xs ≡⟨ evalIsZero Q xs isZeroQ ⟩
0r ∎
where isZeroQ = snd (extractFromAnd _ _ isZeroPandQ)
... | false = byBoolAbsurdity isZeroP
where isZeroP = fst (extractFromAnd _ _ isZeroPandQ)
computeEvalSummandIsZero :
{n : ℕ}
(P : IteratedHornerForms νR (ℕ.suc n))
(Q : IteratedHornerForms νR n)
→ (xs : Vec (fst R) n)
→ (x : (fst R))
→ isZero νR P ≡ true
→ eval (P ·X+ Q) (x ∷ xs) ≡ eval Q xs
computeEvalSummandIsZero P Q xs x isZeroP with isZero νR P
... | true = refl
... | false = byBoolAbsurdity isZeroP
computeEvalNotZero :
{n : ℕ}
(P : IteratedHornerForms νR (ℕ.suc n))
(Q : IteratedHornerForms νR n)
→ (xs : Vec (fst R) n)
→ (x : (fst R))
→ ¬ (isZero νR P ≡ true)
→ eval (P ·X+ Q) (x ∷ xs) ≡ (eval P (x ∷ xs)) · x + eval Q xs
computeEvalNotZero P Q xs x notZeroP with isZero νR P
... | true = byBoolAbsurdity (sym (¬true→false true notZeroP))
... | false = refl
combineCasesEval :
{n : ℕ} (P : IteratedHornerForms νR (ℕ.suc n)) (Q : IteratedHornerForms νR n)
(x : (fst R)) (xs : Vec (fst R) n)
→ eval (P ·X+ Q) (x ∷ xs)
≡ (eval P (x ∷ xs)) · x + eval Q xs
combineCasesEval P Q x xs with isZero νR P ≟ true
... | yes p =
eval (P ·X+ Q) (x ∷ xs) ≡⟨ computeEvalSummandIsZero P Q xs x p ⟩
eval Q xs ≡⟨ sym (+Lid _) ⟩
0r + eval Q xs ≡[ i ]⟨ 0LeftAnnihilates x (~ i) + eval Q xs ⟩
0r · x + eval Q xs ≡[ i ]⟨ (evalIsZero P (x ∷ xs) p (~ i)) · x + eval Q xs ⟩
(eval P (x ∷ xs)) · x + eval Q xs ∎
... | no p = computeEvalNotZero P Q xs x p
compute+ₕEvalBothZero :
(n : ℕ) (P Q : IteratedHornerForms νR (ℕ.suc n))
(r s : IteratedHornerForms νR n)
(x : (fst R)) (xs : Vec (fst R) n)
→ (isZero νR (P +ₕ Q) and isZero νR (r +ₕ s)) ≡ true
→ eval ((P ·X+ r) +ₕ (Q ·X+ s)) (x ∷ xs) ≡ eval ((P +ₕ Q) ·X+ (r +ₕ s)) (x ∷ xs)
compute+ₕEvalBothZero n P Q r s x xs bothZero with isZero νR (P +ₕ Q) and isZero νR (r +ₕ s) | bothZero
... | true | p =
eval {A = νR} 0H (x ∷ xs) ≡⟨ refl ⟩
0r ≡⟨ someCalculation ⟩
0r · x + 0r ≡⟨ step1 ⟩
(eval (P +ₕ Q) (x ∷ xs)) · x + eval (r +ₕ s) xs ≡⟨ step2 ⟩
eval ((P +ₕ Q) ·X+ (r +ₕ s)) (x ∷ xs) ∎
where step1 : 0r · x + 0r ≡ (eval (P +ₕ Q) (x ∷ xs)) · x + eval (r +ₕ s) xs
step1 i = (evalIsZero (P +ₕ Q) (x ∷ xs) (fst (extractFromAnd _ _ (bothZero))) (~ i)) · x
+ (evalIsZero (r +ₕ s) xs (snd (extractFromAnd _ _ (bothZero))) (~ i))
step2 = sym (combineCasesEval (P +ₕ Q) (r +ₕ s) x xs)
... | false | p = byBoolAbsurdity p
compute+ₕEvalNotBothZero :
(n : ℕ) (P Q : IteratedHornerForms νR (ℕ.suc n))
(r s : IteratedHornerForms νR n)
(x : (fst R)) (xs : Vec (fst R) n)
→ (isZero νR (P +ₕ Q) and isZero νR (r +ₕ s)) ≡ false
→ eval ((P ·X+ r) +ₕ (Q ·X+ s)) (x ∷ xs) ≡ eval ((P +ₕ Q) ·X+ (r +ₕ s)) (x ∷ xs)
compute+ₕEvalNotBothZero n P Q r s _ _ notBothZero
with isZero νR (P +ₕ Q) and isZero νR (r +ₕ s) | notBothZero
... | true | p = byBoolAbsurdity (sym p)
... | false | p = refl
| 40.455224
| 106
| 0.521306
|
04ef333d30e179f6c0c7ee80169fcb0ca39b49e1
| 562
|
agda
|
Agda
|
test/Succeed/Issue2150.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
test/Succeed/Issue2150.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
test/Succeed/Issue2150.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
open import Agda.Primitive
postulate
X : Set
Id : Set → Set
module Generic1HIT (S : Set) where
module RecType k (C : Set k) (Necc : Set) where
postulate P : Set
module Flattening k (F : Set → Set) (C : Set k) (Necc : Set) where
-- order f before C matters!
module W = Generic1HIT (F X) -- use of F matters, application of F matters
module M = W.RecType k C X -- k matters
module S¹RecType i (A : Set i) where
module FlatteningS¹ = Flattening i Id A X -- i matters here
module HopfJunior = S¹RecType _ Set -- meta variable matters
| 26.761905
| 77
| 0.66548
|
22f266cf5df1086cda99d274685ff6a54b130af9
| 982
|
agda
|
Agda
|
Cubical/Algebra/MonoidSolver/Examples.agda
|
guilhermehas/cubical
|
ce3120d3f8d692847b2744162bcd7a01f0b687eb
|
[
"MIT"
] | 1
|
2021-10-31T17:32:49.000Z
|
2021-10-31T17:32:49.000Z
|
Cubical/Algebra/MonoidSolver/Examples.agda
|
guilhermehas/cubical
|
ce3120d3f8d692847b2744162bcd7a01f0b687eb
|
[
"MIT"
] | null | null | null |
Cubical/Algebra/MonoidSolver/Examples.agda
|
guilhermehas/cubical
|
ce3120d3f8d692847b2744162bcd7a01f0b687eb
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --safe #-}
module Cubical.Algebra.MonoidSolver.Examples where
open import Cubical.Foundations.Prelude
open import Cubical.Algebra.Monoid.Base
open import Cubical.Algebra.CommMonoid.Base
open import Cubical.Algebra.MonoidSolver.Reflection
private
variable
ℓ : Level
module ExamplesMonoid (M : Monoid ℓ) where
open MonoidStr (snd M)
_ : ε ≡ ε
_ = solveMonoid M
_ : ε · ε · ε ≡ ε
_ = solveMonoid M
_ : ∀ x → ε · x ≡ x
_ = solveMonoid M
_ : ∀ x y z → (x · y) · z ≡ x · (y · z)
_ = solveMonoid M
_ : ∀ x y z → z · (x · y) · ε · z ≡ z · x · (y · z)
_ = solveMonoid M
module ExamplesCommMonoid (M : CommMonoid ℓ) where
open CommMonoidStr (snd M)
_ : ε ≡ ε
_ = solveCommMonoid M
_ : ε · ε · ε ≡ ε
_ = solveCommMonoid M
_ : ∀ x → ε · x ≡ x
_ = solveCommMonoid M
_ : ∀ x y z → (x · z) · y ≡ x · (y · z)
_ = solveCommMonoid M
_ : ∀ x y → (x · y) · y · x · (x · y) ≡ x · x · x · (y · y · y)
_ = solveCommMonoid M
| 19.64
| 66
| 0.576375
|
1e5f3c0e4fe7348cd59e48c1781253f299dd4cfb
| 787
|
agda
|
Agda
|
test/succeed/NewWithoutK.agda
|
masondesu/agda
|
70c8a575c46f6a568c7518150a1a64fcd03aa437
|
[
"MIT"
] | 1
|
2018-10-10T17:08:44.000Z
|
2018-10-10T17:08:44.000Z
|
test/succeed/NewWithoutK.agda
|
masondesu/agda
|
70c8a575c46f6a568c7518150a1a64fcd03aa437
|
[
"MIT"
] | null | null | null |
test/succeed/NewWithoutK.agda
|
masondesu/agda
|
70c8a575c46f6a568c7518150a1a64fcd03aa437
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --without-K #-}
module NewWithoutK where
data ℕ : Set where
zero : ℕ
suc : ℕ → ℕ
infixl 20 _+_
_+_ : ℕ → ℕ → ℕ
zero + n = n
(suc m) + n = suc (m + n)
infixl 30 _*_
_*_ : ℕ → ℕ → ℕ
zero * n = zero
(suc m) * n = n + (m * n)
infixl 5 _⊎_
data _⊎_ (A B : Set) : Set where
inj₁ : A → A ⊎ B
inj₂ : B → A ⊎ B
infixl 10 _≡_
data _≡_ {A : Set} (a : A) : A → Set where
refl : a ≡ a
data _≤_ : ℕ → ℕ → Set where
z≤n : {n : ℕ} → zero ≤ n
s≤s : {m n : ℕ} → m ≤ n → suc m ≤ suc n
foo : (k l m : ℕ) → k ≡ l + m → ℕ
foo .(l + m) l m refl = zero
bar : (n : ℕ) → n ≤ n → ℕ
bar .zero z≤n = zero
bar .(suc m) (s≤s {m} p) = zero
baz : ∀ m n → m * n ≡ zero → m ≡ zero ⊎ n ≡ zero
baz zero n h = inj₁ refl
baz (suc m) zero h = inj₂ refl
baz (suc x) (suc x₁) ()
| 18.302326
| 48
| 0.475222
|
387460c9b1335587386c0d3133bf165077469bb0
| 529
|
agda
|
Agda
|
benchmark/ac/Nat.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
benchmark/ac/Nat.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
benchmark/ac/Nat.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
module Nat where
import Bool
open Bool
data Nat : Set where
zero : Nat
suc : Nat -> Nat
infixr 25 _+_
_+_ : Nat -> Nat -> Nat
zero + m = m
suc n + m = suc (n + m)
infix 10 _==_ _<_
_==_ : Nat -> Nat -> Bool
zero == zero = true
suc n == zero = false
zero == suc m = false
suc n == suc m = n == m
_<_ : Nat -> Nat -> Bool
n < zero = false
zero < suc m = true
suc n < suc m = n < m
{-# BUILTIN NATURAL Nat #-}
-- {-# BUILTIN NATPLUS _+_ #-}
-- {-# BUILTIN NATEQUALS _==_ #-}
-- {-# BUILTIN NATLESS _<_ #-}
| 15.114286
| 33
| 0.533081
|
2edcbecd537dea0c8536015ce14f5cebf75614a0
| 2,847
|
agda
|
Agda
|
src/cedille-options.agda
|
ice1000/cedille
|
bf62d3d338809a30bc21a1affed07936b1ac60ac
|
[
"MIT"
] | null | null | null |
src/cedille-options.agda
|
ice1000/cedille
|
bf62d3d338809a30bc21a1affed07936b1ac60ac
|
[
"MIT"
] | null | null | null |
src/cedille-options.agda
|
ice1000/cedille
|
bf62d3d338809a30bc21a1affed07936b1ac60ac
|
[
"MIT"
] | null | null | null |
module cedille-options where
open import general-util
open import options-types public
open import cedille-types
record options : Set where
constructor mk-options
field include-path : 𝕃 string × stringset
use-cede-files : 𝔹
make-rkt-files : 𝔹
generate-logs : 𝔹
show-qualified-vars : 𝔹
erase-types : 𝔹
datatype-encoding : maybe (filepath × maybe file)
pretty-print-columns : ℕ
-- Internal use only
during-elaboration : 𝔹
pretty-print : 𝔹
show-progress-updates : 𝔹
default-options : options
default-options = record {
include-path = [] , empty-stringset;
use-cede-files = tt;
make-rkt-files = ff;
generate-logs = ff;
show-qualified-vars = ff;
erase-types = tt;
datatype-encoding = nothing;
pretty-print-columns = 80;
during-elaboration = ff;
pretty-print = ff ;
show-progress-updates = ff}
include-path-insert : string → 𝕃 string × stringset → 𝕃 string × stringset
include-path-insert s (l , ss) =
if stringset-contains ss s
then l , ss
else s :: l , stringset-insert ss s
options-to-rope : options → rope
options-to-rope ops =
comment "Cedille Options File" ⊹⊹ [[ "\n" ]] ⊹⊹
comment "List of directories to search for imported files in" ⊹⊹
comment "Each directory should be space-delimited and inside double quotes" ⊹⊹
comment "The current file's directory is automatically searched first, before import-directories" ⊹⊹
comment "If a filepath is relative, it is considered relative to this options file" ⊹⊹
option "import-directories"
(𝕃-to-string (λ fp → "\"" ^ fp ^ "\"") " " (fst (options.include-path ops))) ⊹⊹
comment "Cache navigation spans for performance" ⊹⊹
option "use-cede-files" (𝔹-s options.use-cede-files) ⊹⊹
-- comment "Compile Cedille files to Racket after they are checked"⊹⊹
-- option "make-rkt-files" (𝔹-s options.make-rkt-files) ⊹⊹
comment "Write logs to ~/.cedille/log" ⊹⊹
option "generate-logs" (𝔹-s options.generate-logs) ⊹⊹
comment "Print variables fully qualified" ⊹⊹
option "show-qualified-vars" (𝔹-s options.show-qualified-vars) ⊹⊹
comment "Print types erased" ⊹⊹
option "erase-types" (𝔹-s options.erase-types) ⊹⊹
comment "Preferred number of columns to pretty print elaborated files with" ⊹⊹
option "pretty-print-columns" (ℕ-to-string (options.pretty-print-columns ops)) ⊹⊹
comment "Encoding to use when elaborating datatypes to Cedille Core" ⊹⊹
option "datatype-encoding" (maybe-else' (options.datatype-encoding ops) "" λ fp → "\"" ^ fst fp ^ "\"")
where
𝔹-s : (options → 𝔹) → string
𝔹-s f = if f ops then "true" else "false"
comment : string → rope
comment s = [[ "-- " ]] ⊹⊹ [[ s ]] ⊹⊹ [[ "\n" ]]
option : (name : string) → (value : string) → rope
option name value = [[ name ]] ⊹⊹ [[ " = " ]] ⊹⊹ [[ value ]] ⊹⊹ [[ ".\n\n" ]]
| 37.96
| 106
| 0.656832
|
4b47020ddc6666d6bf5c58c46a764fa60ba86296
| 5,871
|
agda
|
Agda
|
agda/DivModAlt.agda
|
halfaya/MusicTools
|
04896c61b603d46011b7d718fcb47dd756e66021
|
[
"MIT"
] | 28
|
2017-04-21T09:08:52.000Z
|
2022-03-04T18:04:07.000Z
|
agda/DivModAlt.agda
|
halfaya/MusicTools
|
04896c61b603d46011b7d718fcb47dd756e66021
|
[
"MIT"
] | 1
|
2020-11-13T01:26:20.000Z
|
2020-11-17T00:58:55.000Z
|
agda/DivModAlt.agda
|
halfaya/MusicTools
|
04896c61b603d46011b7d718fcb47dd756e66021
|
[
"MIT"
] | 3
|
2019-01-12T17:02:36.000Z
|
2020-11-10T04:04:40.000Z
|
{-# OPTIONS --cubical --safe #-}
module DivModAlt where
open import Cubical.Core.Everything using (_≡_; Level; Type; Σ; _,_; fst; snd; _≃_; ~_)
open import Cubical.Foundations.Prelude using (refl; sym; _∙_; cong; transport; subst; funExt; transp; I; i0; i1; hcomp; primPOr; _∨_)
open import Cubical.Foundations.Function using (_∘_)
open import Cubical.Foundations.Isomorphism using (iso; Iso; isoToPath; section; retract; isoToEquiv)
open import Data.Empty using (⊥)
open import Data.Fin using (Fin; toℕ; fromℕ<; #_; _≟_) renaming (zero to fz; suc to fs)
open import Data.Nat using (ℕ; zero; suc; _+_; _*_; _≤_ ; _>_; _<_; _≥_; z≤n; s≤s; NonZero)
open import Data.Product using (_×_)
open import Data.Sum using (_⊎_; inj₁; inj₂)
open import Data.Unit using (⊤; tt)
open import Fin
+-assoc : (m n o : ℕ) → (m + n) + o ≡ m + (n + o)
+-assoc zero _ _ = refl
+-assoc (suc m) n o = cong suc (+-assoc m n o)
≤-refl : {n : ℕ} → n ≤ n
≤-refl {zero} = z≤n
≤-refl {suc n} = s≤s (≤-refl {n})
≤-trans : {m n o : ℕ} → m ≤ n → n ≤ o → m ≤ o
≤-trans z≤n _ = z≤n
≤-trans (s≤s x) (s≤s y) = s≤s (≤-trans x y)
≤-step : {m n : ℕ} → m ≤ n → m ≤ 1 + n
≤-step z≤n = z≤n
≤-step (s≤s m≤n) = s≤s (≤-step m≤n)
n≤1+n : (n : ℕ) → n ≤ 1 + n
n≤1+n _ = ≤-step ≤-refl
≤-pred : {m n : ℕ} → suc m ≤ suc n → m ≤ n
≤-pred (s≤s m≤n) = m≤n
_-_ : (n m : ℕ) → {m ≤ n} → ℕ
(n - zero) {z≤n} = n
(suc n - suc m) {s≤s p} = _-_ n m {p}
<-∨-≥ : (m n : ℕ) → m < n ⊎ m ≥ n
<-∨-≥ zero zero = inj₂ z≤n
<-∨-≥ zero (suc n) = inj₁ (s≤s z≤n)
<-∨-≥ (suc m) zero = inj₂ z≤n
<-∨-≥ (suc m) (suc n) with <-∨-≥ m n
... | inj₁ m<n = inj₁ (s≤s m<n)
... | inj₂ m≥n = inj₂ (s≤s m≥n)
sucn-1 : (n : ℕ) → (suc n - 1) {s≤s z≤n} ≡ n
sucn-1 n = refl
-decreasing : (n m : ℕ) → (m≤n : suc m ≤ n) → ((n - suc m) {m≤n}) < n
-decreasing (suc n) zero (s≤s z≤n) = ≤-refl
-decreasing (suc n) (suc m) (s≤s m≤n) = ≤-trans (-decreasing n m m≤n) (n≤1+n n)
-decreasing1 : (c n m : ℕ) → (m≤n : suc m ≤ n) → (n ≤ suc c) → ((n - suc m) {m≤n}) ≤ c
-decreasing1 c (suc n) m (s≤s m≤n) (s≤s n≤c) = ≤-trans (≤-pred (-decreasing (suc n) m (s≤s m≤n))) n≤c
lemma1 : (n m : ℕ) → {m≤n : m ≤ n} → m + ((n - m) {m≤n}) ≡ n
lemma1 n zero {z≤n} = refl
lemma1 (suc n) (suc m) {s≤s p} = cong suc (lemma1 n m {p})
lemma2 : (n m a : ℕ) → {m≤n : m ≤ n} → (n - m) {m≤n} ≡ a → n ≡ m + a
lemma2 n m a {m≤n} x = subst (λ y → y ≡ m + a) (lemma1 n m {m≤n} ) (cong (m +_) x)
lemma3 : (n m d r : ℕ) → {m≤n : m ≤ n} → (n - m) {m≤n} ≡ d * m + r → n ≡ (suc d) * m + r
lemma3 n m d r {m≤n} x = lemma2 n m (d * m + r) x ∙ sym (+-assoc m (d * m) r)
--infixl 7 _div_ _mod_ _mod'_
record DivMod (n m : ℕ) : Type where
constructor divMod
field
q : ℕ
r : Fin m
n=q*m+r : n ≡ q * m + toℕ r
record DivMod0 (n m : ℕ) : Type where
constructor divMod0
field
q : ℕ
r : ℕ
r<m : r < m
n=q*m+r : n ≡ q * m + r
record DivMod1 (n m : ℕ) : Type where
constructor divMod1
field
q : ℕ
r : Fin1 m
n=q*m+r : n ≡ q * m + Fin1.r r
divmod1 : (c n m : ℕ) → (n ≤ c) → {m > 0} → DivMod n m
divmod1 zero zero (suc m) z≤n = divMod 0 (# 0) refl
divmod1 (suc c) n (suc m) n≤c with <-∨-≥ n (suc m)
... | inj₁ n<m = divMod 0 (fromℕ< n<m) (sym (toℕ-fromℕ< n<m))
... | inj₂ n≥m =
let (divMod q r n-m≡q*m+r) = divmod1 c ((n - (suc m)) {n≥m}) (suc m) (-decreasing1 c n m n≥m n≤c ) {s≤s z≤n}
in divMod (suc q) r (lemma3 n (suc m) q (toℕ r) n-m≡q*m+r)
divmod : (n m : ℕ) → {m > 0} → DivMod n m
divmod n (suc m) = divmod1 n n (suc m) ≤-refl {s≤s z≤n}
-- NOTE: We can't use {m > 0} here because Agda can't figure out
-- the implicit proof (even for constants), so use {NonZero m} instead.
_div_ : (n m : ℕ) → {NonZero m} → ℕ
n div (suc m) = DivMod.q (divmod n (suc m) {s≤s z≤n})
_mod_ : (n m : ℕ) → {NonZero m} → Fin m
n mod (suc m) = DivMod.r (divmod n (suc m) {s≤s z≤n})
_mod'_ : (n m : ℕ) → {NonZero m} → ℕ
n mod' (suc m) = toℕ (n mod (suc m))
---------
dm0→dm1 : {m n : ℕ} → DivMod0 n m → DivMod1 n m
dm0→dm1 {m} {n} (divMod0 q r r<m n=q*m+r) =
divMod1 q (fin1 r r<m) n=q*m+r
dm1→dm0 : {m n : ℕ} → DivMod1 n m → DivMod0 n m
dm1→dm0 (divMod1 q r n=q*m+r) = divMod0 q (Fin1.r r) (Fin1.r<n r) n=q*m+r
dm0→dm1→dm0 : {m n : ℕ} → (dm0 : DivMod0 n m) → (dm1→dm0 ∘ dm0→dm1) dm0 ≡ dm0
dm0→dm1→dm0 _ = refl
dm1→dm0→dm1 : {m n : ℕ} → (dm1 : DivMod1 n m) → (dm0→dm1 ∘ dm1→dm0) dm1 ≡ dm1
dm1→dm0→dm1 _ = refl
dm0≃dm1 : {n m : ℕ} → Iso (DivMod0 n m) (DivMod1 n m)
dm0≃dm1 = iso dm0→dm1 dm1→dm0 dm1→dm0→dm1 dm0→dm1→dm0
dm0≡dm1 : {n m : ℕ} → DivMod0 n m ≡ DivMod1 n m
dm0≡dm1 = isoToPath dm0≃dm1
---------
dm1→dm : {m n : ℕ} → DivMod1 n m → DivMod n m
dm1→dm {m} {n} (divMod1 q r n=q*m+r) =
divMod q (fin1→fin r) (subst (λ x → n ≡ q * m + x) (sym (Fin1r≡toℕ1 r)) n=q*m+r)
dm→dm1 : {m n : ℕ} → DivMod n m → DivMod1 n m
dm→dm1 {m} {n} (divMod q r n=q*m+r) = divMod1 q (fin→fin1 r) (subst (λ x → n ≡ q * m + x) (toℕ≡Fin1r1 r) n=q*m+r)
dm1→dm→dm1 : {m n : ℕ} → (dm1 : DivMod1 n m) → (dm→dm1 ∘ dm1→dm) dm1 ≡ dm1
dm1→dm→dm1 {m} {n} (divMod1 q r n=q*m+r) i = divMod1 q (fin1→fin→fin1 r i) {!!}
dm→dm1→dm : {m n : ℕ} → (dm : DivMod n m) → (dm1→dm ∘ dm→dm1) dm ≡ dm
dm→dm1→dm (divMod q r n=q*m+r) i = divMod q (fin→fin1→fin r i)
(λ j → {!n=q*m+r j!})
dm1≃dm : {n m : ℕ} → Iso (DivMod1 n m) (DivMod n m)
dm1≃dm = iso dm1→dm dm→dm1 dm→dm1→dm dm1→dm→dm1
dm1≡dm : {n m : ℕ} → DivMod1 n m ≡ DivMod n m
dm1≡dm = isoToPath dm1≃dm
---------
dm0≡dm : {n m : ℕ} → DivMod0 n m ≡ DivMod n m
dm0≡dm = dm0≡dm1 ∙ dm1≡dm
---------
n%m<m : (n m : ℕ) {m≠0 : NonZero m} → toℕ ((n mod m) {m≠0}) < m
n%m<m n (suc m) = toℕ<n (DivMod.r (divmod n (suc m) {s≤s z≤n}))
n≡divmod : (n m : ℕ) {m≠0 : NonZero m} → n ≡ ((n div m) {m≠0}) * m + toℕ ((n mod m) {m≠0})
n≡divmod n (suc m) = DivMod.n=q*m+r (divmod n (suc m) {s≤s z≤n})
| 33.357955
| 138
| 0.512519
|
4bed8fc67385a11db50395a6b5339a5e395ff724
| 3,720
|
agda
|
Agda
|
test/asset/Test.agda
|
erydo/agda-mode
|
67d4db3b1050e6acfbdfdc05f8a656fd4c1f0b07
|
[
"MIT"
] | 58
|
2015-01-10T10:24:09.000Z
|
2021-06-11T01:42:34.000Z
|
test/asset/Test.agda
|
erydo/agda-mode
|
67d4db3b1050e6acfbdfdc05f8a656fd4c1f0b07
|
[
"MIT"
] | 126
|
2015-02-02T05:47:54.000Z
|
2020-12-23T23:00:13.000Z
|
test/asset/Test.agda
|
erydo/agda-mode
|
67d4db3b1050e6acfbdfdc05f8a656fd4c1f0b07
|
[
"MIT"
] | 18
|
2015-05-24T04:15:44.000Z
|
2019-11-21T10:12:31.000Z
|
{-# OPTIONS --without-K #-}
module Test where
open import Level
infixl 4 _≡_
data _≡_ {a} {A : Set a} (x : A) : A → Set a where
refl : x ≡ x
J : {a b : Level} (A : Set a) (C : (x y : A) → x ≡ y → Set b)
→ ((x : A) → C x x refl)
→ (x y : A) (P : x ≡ y)
→ C x y P
J A C b x .x refl = b x
-- K : (A : Set) (x : A) (C : x ≡ x → Set)
-- → C refl
-- → (loop : x ≡ x)
-- → C loop
-- K A x C b p = {! p !}
-- Lemma 2.1.1 (inversion of paths)
infix 6 ¬_
¬_ : {a : Level} {A : Set a} {x y : A} → x ≡ y → y ≡ x
¬_ {a} {A} {x} {y} p = J A D d x y p
where
D : (x y : A) (p : x ≡ y) → Set a
D x y p = y ≡ x
d : (x : A) → D x x refl
d x = refl
-- Lemma 2.1.2 (concatenation of paths)
infixl 5 _∙_
_∙_ : {a : Level} {A : Set a} {x y z : A} → x ≡ y → y ≡ z → x ≡ z
_∙_ {a} {A} {x} {y} {z} p q = J {a} {a} A D d x y p z q
where
-- the predicate
D : (x y : A) (p : x ≡ y) → Set a
D x y p = (z : A) (q : y ≡ z) → x ≡ z
-- base case
d : (x : A) → D x x refl
d x z q = J A E e x z q
where
-- the predicate
E : (x z : A) (q : x ≡ z) → Set a
E x z q = x ≡ z
-- base case
e : (x : A) → E x x refl
e x = refl
-- Lemma 2.1.4.i (identity of path concatenation)
∙-identityʳ : {a : Level} {A : Set a} {x y : A} (p : x ≡ y) → p ≡ p ∙ refl
∙-identityʳ {a} {A} {x} {y} p = J A D d x y p
where
-- the predicate
D : (x y : A) (p : x ≡ y) → Set a
D x y p = p ≡ p ∙ refl
-- base case
d : (x : A) → D x x refl
d x = refl
∙-identityˡ : {a : Level} {A : Set a} {x y : A} (p : x ≡ y) → p ≡ refl ∙ p
∙-identityˡ {a} {A} {x} {y} p = J A D d x y p
where
-- the predicate
D : (x y : A) (p : x ≡ y) → Set a
D x y p = p ≡ refl ∙ p
-- base case
d : (x : A) → D x x refl
d x = refl
-- Lemma 2.1.4.ii (identity of path inversion)
¬-identityʳ : {a : Level} {A : Set a} {x y : A} (p : x ≡ y) → ¬ p ∙ p ≡ refl
¬-identityʳ {a} {A} {x} {y} p = J A D d x y p
where
-- the predicate
D : (x y : A) (p : x ≡ y) → Set a
D x y p = ¬ p ∙ p ≡ refl
-- base case
d : (x : A) → D x x refl
d x = refl
¬-identityˡ : {a : Level} {A : Set a} {x y : A} (p : x ≡ y) → p ∙ ¬ p ≡ refl
¬-identityˡ {a} {A} {x} {y} p = J A D d x y p
where
-- the predicate
D : (x y : A) (p : x ≡ y) → Set a
D x y p = p ∙ ¬ p ≡ refl
-- base case
d : (x : A) → D x x refl
d x = refl
-- Lemma 2.1.4.iii (involution of path inversion)
involution : {A : Set} {x y : A} (p : x ≡ y) → ¬ ¬ p ≡ p
involution {A} {x} {y} p = J A D d x y p
where
-- the predicate
D : (x y : A) (p : x ≡ y) → Set
D x y p = ¬ ¬ p ≡ p
-- base case
d : (x : A) → D x x refl
d x = refl
-- Lemma 2.1.4.iv (associativity of path concatenation)
∙-assoc : {a : Level} {A : Set a} {w x y z : A}
→ (p : w ≡ x) (q : x ≡ y) (r : y ≡ z)
→ p ∙ (q ∙ r) ≡ (p ∙ q) ∙ r
∙-assoc {a} {A} {w} {x} {y} {z} p q r = J A D d w x p y q z r
where
-- the predicate
D : (w x : A) (p : w ≡ x) → Set a
D w x p = (y : A) (q : x ≡ y)
→ (z : A) (r : y ≡ z)
→ p ∙ (q ∙ r) ≡ (p ∙ q) ∙ r
-- base case
d : (x : A) → D x x refl
d x y q z r = J A E e x y q z r
where
-- the predicate
E : (x y : A) (q : x ≡ y) → Set a
E x y q = (z : A) (r : y ≡ z)
→ refl ∙ (q ∙ r) ≡ refl ∙ q ∙ r
-- base case
e : (x : A) → E x x refl
e x z r = J A F f x z r
where
-- the predicate
F : (y z : A) (r : y ≡ z) → Set a
F y z r = refl ∙ (refl ∙ r) ≡ refl ∙ refl ∙ r
-- base case
f : (x : A) → F x x refl
f x = {! !}
| 24.635762
| 76
| 0.397312
|
a0a65543b5fa08ad7fa234224d55a8fde2d3e285
| 1,952
|
agda
|
Agda
|
proglangs-learning/Agda/sv20/assign2/SetTheory/Logic.agda
|
helq/old_code
|
a432faf1b340cb379190a2f2b11b997b02d1cd8d
|
[
"CC0-1.0"
] | null | null | null |
proglangs-learning/Agda/sv20/assign2/SetTheory/Logic.agda
|
helq/old_code
|
a432faf1b340cb379190a2f2b11b997b02d1cd8d
|
[
"CC0-1.0"
] | 4
|
2020-03-10T19:20:21.000Z
|
2021-06-07T15:39:48.000Z
|
proglangs-learning/Agda/sv20/assign2/SetTheory/Logic.agda
|
helq/old_code
|
a432faf1b340cb379190a2f2b11b997b02d1cd8d
|
[
"CC0-1.0"
] | null | null | null |
-----------------------------------
-- First order logic
-----------------------------------
module sv20.assign2.SetTheory.Logic where
infix 4 _,_
infix 3 ¬_
infix 1 _∧_
infix 1 _∨_
infix 0 _⇔_
-- Some First order logic I need.
-- ∧ data type (conjunction).
data _∧_ (A B : Set) : Set where
_,_ : A → B → A ∧ B
∧-proj₁ : ∀ {A B} → A ∧ B → A
∧-proj₁ (a , _) = a
∧-proj₂ : ∀ {A B} → A ∧ B → B
∧-proj₂ (_ , b) = b
-- ∨ data type (disjunction), with many useful properties.
data _∨_ (A B : Set) : Set where
inj₁ : A → A ∨ B
inj₂ : B → A ∨ B
∨-e : (A B C : Set) → A ∨ B → (A → C) → (B → C) → C
∨-e A B C (inj₁ a) i₁ i₂ = i₁ a
∨-e A B C (inj₂ b) i₁ i₂ = i₂ b
∨-sym : (A B : Set) → A ∨ B → B ∨ A
∨-sym A B (inj₁ a) = inj₂ a
∨-sym A B (inj₂ b) = inj₁ b
trivial : (A : Set) → A → A
trivial _ A = A
∨-idem : (A : Set) → A ∨ A → A
∨-idem A (inj₁ a) = a
∨-idem A (inj₂ a) = a
∨-prop₁ : {A B C : Set} → (A ∨ B → C) → A → C
∨-prop₁ i a = i (inj₁ a)
∨-prop₂ : {A B C : Set} → (A ∨ B → C) → B → C
∨-prop₂ i b = i (inj₂ b)
∨-prop₃ : {A B C : Set} → A ∨ B → (A → C) → C ∨ B
∨-prop₃ (inj₁ x) i = inj₁ (i x)
∨-prop₃ (inj₂ x) i = inj₂ x
∨-prop₄ : {A B C : Set} → A ∨ B → (B → C) → A ∨ C
∨-prop₄ (inj₁ x) x₁ = inj₁ x
∨-prop₄ (inj₂ x) x₁ = inj₂ (x₁ x)
∨-prop₅ : {A B C D : Set} → A ∨ B → (A → C) → (B → D) → C ∨ D
∨-prop₅ (inj₁ a) a→c b→d = inj₁ (a→c a)
∨-prop₅ (inj₂ b) a→c b→d = inj₂ (b→d b)
∨-∧ : {A B : Set} → (A ∧ B) ∨ (B ∧ A) → A ∧ B
∨-∧ (inj₁ (a , b)) = a , b
∨-∧ (inj₂ (b , a)) = a , b
-- Bi-implication.
_⇔_ : Set → Set → Set
A ⇔ B = (A → B) ∧ (B → A)
⇔-p : (A B C : Set) → A ⇔ (B ∧ C) → (C → B) → A ⇔ C
⇔-p A B C (h₁ , h₂) h₃ = prf₁ , prf₂
where
prf₁ : A → C
prf₁ A = ∧-proj₂ (h₁ A)
prf₂ : C → A
prf₂ C = h₂ ((h₃ C) , C)
-- Empty data type.
data ⊥ : Set where
⊥-elim : {A : Set} → ⊥ → A
⊥-elim ()
data ⊤ : Set where
tt : ⊤
-- Negation
¬_ : Set → Set
¬ A = A → ⊥
cont : (A : Set) → A ∧ ¬ A → ⊥
cont _ (x , ¬x) = ¬x x
| 19.52
| 61
| 0.438012
|
598381959c948e7e2c1596f5d482f52e562b4896
| 970
|
agda
|
Agda
|
vendor/stdlib/src/Relation/Binary/OrderMorphism.agda
|
isabella232/Lemmachine
|
8ef786b40e4a9ab274c6103dc697dcb658cf3db3
|
[
"MIT"
] | 56
|
2015-01-20T02:11:42.000Z
|
2021-12-21T17:02:19.000Z
|
vendor/stdlib/src/Relation/Binary/OrderMorphism.agda
|
larrytheliquid/Lemmachine
|
8ef786b40e4a9ab274c6103dc697dcb658cf3db3
|
[
"MIT"
] | 1
|
2022-03-12T12:17:51.000Z
|
2022-03-12T12:17:51.000Z
|
vendor/stdlib/src/Relation/Binary/OrderMorphism.agda
|
isabella232/Lemmachine
|
8ef786b40e4a9ab274c6103dc697dcb658cf3db3
|
[
"MIT"
] | 3
|
2015-07-21T16:37:58.000Z
|
2022-03-12T11:54:10.000Z
|
------------------------------------------------------------------------
-- Order morphisms
------------------------------------------------------------------------
module Relation.Binary.OrderMorphism where
open import Relation.Binary
open Poset
import Data.Function as F
record _⇒-Poset_ (po₁ po₂ : Poset) : Set where
field
fun : carrier po₁ → carrier po₂
monotone : _≤_ po₁ =[ fun ]⇒ _≤_ po₂
_⇒-DTO_ : (dto₁ dto₂ : DecTotalOrder) → Set
dto₁ ⇒-DTO dto₂ = poset dto₁ ⇒-Poset poset dto₂
where open DecTotalOrder
open _⇒-Poset_
id : ∀ {po} → po ⇒-Poset po
id = record
{ fun = F.id
; monotone = F.id
}
_∘_ : ∀ {po₁ po₂ po₃} →
po₂ ⇒-Poset po₃ → po₁ ⇒-Poset po₂ → po₁ ⇒-Poset po₃
f ∘ g = record
{ fun = F._∘_ (fun f) (fun g)
; monotone = F._∘_ (monotone f) (monotone g)
}
const : ∀ {po₁ po₂} → carrier po₂ → po₁ ⇒-Poset po₂
const {po₂ = po₂} x = record
{ fun = F.const x
; monotone = F.const (refl po₂)
}
| 24.25
| 72
| 0.512371
|
a167a3a1e784dc3a3f61f6810945f52db09976e6
| 1,141
|
agda
|
Agda
|
Cats/Category/Lift.agda
|
alessio-b-zak/cats
|
a3b69911c4c6ec380ddf6a0f4510d3a755734b86
|
[
"MIT"
] | null | null | null |
Cats/Category/Lift.agda
|
alessio-b-zak/cats
|
a3b69911c4c6ec380ddf6a0f4510d3a755734b86
|
[
"MIT"
] | null | null | null |
Cats/Category/Lift.agda
|
alessio-b-zak/cats
|
a3b69911c4c6ec380ddf6a0f4510d3a755734b86
|
[
"MIT"
] | null | null | null |
module Cats.Category.Lift where
open import Relation.Binary using (IsEquivalence)
open import Level as L using (Level ; suc ; _⊔_ ; lift ; lower)
open import Cats.Category.Base
open IsEquivalence
LCategory : (l : Level) → Set (suc l)
LCategory l = Category l l l
Lift : ∀ {lo la l≈ lo′ la′ l≈′} → Category lo la l≈
→ Category (lo ⊔ lo′) (la ⊔ la′) (l≈ ⊔ l≈′)
Lift {lo′ = lo′} {la′} {l≈′} C = record
{ Obj = L.Lift lo′ C.Obj
; _⇒_ = λ A B → L.Lift la′ (lower A C.⇒ lower B)
; _≈_ = λ f g → L.Lift l≈′ (lower f C.≈ lower g)
; id = lift C.id
; _∘_ = λ f g → lift (lower f C.∘ lower g)
; equiv = record
{ refl = lift (refl C.equiv)
; sym = λ eq → lift (sym C.equiv (lower eq))
; trans = λ eq₁ eq₂ → lift (trans C.equiv (lower eq₁) (lower eq₂))
}
; ∘-resp = λ eq₁ eq₂ → lift (C.∘-resp (lower eq₁) (lower eq₂))
; id-r = lift C.id-r
; id-l = lift C.id-l
; assoc = lift C.assoc
}
where
module C = Category C
LiftEq : ∀ {lo la l≈} → Category lo la l≈
→ LCategory (lo ⊔ la ⊔ l≈)
LiftEq {lo} {la} {l≈} = Lift {lo′ = la ⊔ l≈} {la′ = lo ⊔ l≈} {l≈′ = lo ⊔ la}
| 28.525
| 76
| 0.538124
|
06331551b39d7a061634aa53ce19c927e3fe523c
| 2,781
|
agda
|
Agda
|
src/Pts/Typing/Progress.agda
|
asr/pts-agda
|
d701c2688e4a88eb81bdd9d458f9a2fcf81d5a43
|
[
"BSD-3-Clause"
] | 21
|
2016-05-13T12:11:10.000Z
|
2021-08-31T10:47:57.000Z
|
src/Pts/Typing/Progress.agda
|
asr/pts-agda
|
d701c2688e4a88eb81bdd9d458f9a2fcf81d5a43
|
[
"BSD-3-Clause"
] | 1
|
2017-08-21T14:48:09.000Z
|
2017-08-21T16:01:50.000Z
|
src/Pts/Typing/Progress.agda
|
asr/pts-agda
|
d701c2688e4a88eb81bdd9d458f9a2fcf81d5a43
|
[
"BSD-3-Clause"
] | 4
|
2017-08-20T10:29:44.000Z
|
2019-08-11T23:28:33.000Z
|
------------------------------------------------------------------------
-- Progress of CBV reductions in pure type systems (PTS)
------------------------------------------------------------------------
-- This module contains a variant of the "progress" theorem for PTS.
-- Progress says roughly that well-typed terms do not get stuck.
-- I.e. a well-typed term is either a value or it can take a CBV
-- reduction step. Together with the subject reduction (aka
-- "preservation") theorem from Pts.Typing, progress ensures type
-- soundness. For detials, see e.g.
--
-- * B. C. Pierce, TAPL (2002), pp. 95.
--
-- * A. Wright and M. Felleisen, "A Syntactic Approach to Type
-- Soundness" (1994).
module Pts.Typing.Progress where
open import Data.Product using (_,_; ∃; _×_)
open import Data.Sum using (_⊎_; inj₁; inj₂)
open import Relation.Binary.PropositionalEquality
open import Relation.Nullary using (¬_)
open import Relation.Nullary.Negation using (contradiction)
open import Pts.Typing
open import Pts.Reduction.Cbv
open import Pts.Reduction.Full
-- Definitions and lemmas are parametrized by a given PTS instance.
module _ {pts} where
open PTS pts
open Syntax
open Ctx
open Substitution using (_[_])
open Typing pts
-- A helper lemma: sorts are not product types.
Π≢sort : ∀ {n s} {a : Term n} {b} → ¬ (Π a b ≡β sort s)
Π≢sort Πab≡s =
let _ , Πab→*c , s→*c = ≡β⇒→β* Πab≡s
_ , _ , _ , _ , Πa′b′≡c = Π-→β* Πab→*c
in contradiction Πa′b′≡c (sort⇒¬Π (sort-→β* s→*c))
where
sort⇒¬Π : ∀ {n s a b} {c : Term n} → sort s ≡ c → ¬ (Π a b ≡ c)
sort⇒¬Π refl ()
-- A canonical forms lemma for dependent product values: closed
-- values of product type are abstractions.
Π-can : ∀ {f a b} → Val f → [] ⊢ f ∈ Π a b → ∃ λ a′ → ∃ λ t → f ≡ ƛ a′ t
Π-can (sort s) s∈Πab =
let _ , _ , Πab≡s′ = sort-gen s∈Πab
in contradiction Πab≡s′ Π≢sort
Π-can (Π c d) Πcd∈Πab =
let _ , _ , _ , _ , _ , _ , Πab≡s = Π-gen Πcd∈Πab
in contradiction Πab≡s Π≢sort
Π-can (ƛ a′ t) (ƛ a∈s t∈b) = a′ , t , refl
Π-can (ƛ a′ t) (conv λa′t∈c c∈s c≡Πab) = a′ , t , refl
-- Progress: well-typed terms do not get stuck (under CBV reduction).
prog : ∀ {a b} → [] ⊢ a ∈ b → Val a ⊎ (∃ λ a′ → a →v a′)
prog (var () Γ-wf)
prog (axiom a Γ-wf) = inj₁ (sort _)
prog (Π r a∈s₁ b∈s₂) = inj₁ (Π _ _)
prog (ƛ t∈b Πab∈s) = inj₁ (ƛ _ _)
prog (f∈Πab · t∈a) with prog f∈Πab
prog (f∈Πab · t∈a) | inj₁ u with prog t∈a
prog (f∈Πab · t∈a) | inj₁ u | inj₁ v with Π-can u f∈Πab
...| a′ , t′ , refl = inj₂ (_ , cont a′ t′ v)
prog (f∈Πab · t∈a) | inj₁ u | inj₂ (t′ , t→t′) = inj₂ (_ , u ·₂ t→t′)
prog (f∈Πab · t∈a) | inj₂ (f′ , f→f′) = inj₂ (_ , f→f′ ·₁ _)
prog (conv a∈b₁ b₂∈s b₁≡b₂) = prog a∈b₁
| 38.09589
| 74
| 0.562028
|
57100c5b6fe2e605dbe0d2031df93155b97cc16c
| 11,146
|
agda
|
Agda
|
Cubical/HITs/Pushout/Properties.agda
|
Rotsor/cubical
|
d55cd4834ca1f171f58b4a0c46b804ea6d18191f
|
[
"MIT"
] | null | null | null |
Cubical/HITs/Pushout/Properties.agda
|
Rotsor/cubical
|
d55cd4834ca1f171f58b4a0c46b804ea6d18191f
|
[
"MIT"
] | null | null | null |
Cubical/HITs/Pushout/Properties.agda
|
Rotsor/cubical
|
d55cd4834ca1f171f58b4a0c46b804ea6d18191f
|
[
"MIT"
] | null | null | null |
{-
This file contains:
- Homotopy natural equivalences of pushout spans
Written by: Loïc Pujet, September 2019
- 3×3 lemma for pushouts
Written by: Loïc Pujet, April 2019
-}
{-# OPTIONS --cubical --safe #-}
module Cubical.HITs.Pushout.Properties where
open import Cubical.Core.Glue
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.Isomorphism
open import Cubical.Foundations.HAEquiv
open import Cubical.Foundations.GroupoidLaws
open import Cubical.Foundations.Univalence
open import Cubical.Foundations.Transport
open import Cubical.Data.Prod.Base
open import Cubical.Data.Unit
open import Cubical.HITs.Pushout.Base
{-
Definition of pushout diagrams
-}
record 3-span : Type₁ where
field
A0 A2 A4 : Type₀
f1 : A2 → A0
f3 : A2 → A4
spanPushout : (s : 3-span) → Type₀
spanPushout s = Pushout (3-span.f1 s) (3-span.f3 s)
{-
Definition of a homotopy natural diagram equivalence
-}
record 3-span-equiv (s1 : 3-span) (s2 : 3-span) : Type₀ where
field
e0 : 3-span.A0 s1 ≃ 3-span.A0 s2
e2 : 3-span.A2 s1 ≃ 3-span.A2 s2
e4 : 3-span.A4 s1 ≃ 3-span.A4 s2
H1 : ∀ x → 3-span.f1 s2 (e2 .fst x) ≡ e0 .fst (3-span.f1 s1 x)
H3 : ∀ x → 3-span.f3 s2 (e2 .fst x) ≡ e4 .fst (3-span.f3 s1 x)
{-
Proof that homotopy equivalent spans are in fact equal
-}
spanEquivToPath : {s1 : 3-span} → {s2 : 3-span} → (e : 3-span-equiv s1 s2) → s1 ≡ s2
spanEquivToPath {s1} {s2} e = spanPath
where
open 3-span-equiv e
open 3-span
path0 : A0 s1 ≡ A0 s2
path0 = ua e0
path2 : A2 s1 ≡ A2 s2
path2 = ua e2
path4 : A4 s1 ≡ A4 s2
path4 = ua e4
spanPath1 : I → 3-span
spanPath1 i = record { A0 = path0 i ; A2 = path2 i ; A4 = path4 i ;
f1 = λ x → (transp (λ j → path0 (i ∧ j)) (~ i) (f1 s1 (transp (λ j → path2 (~ j ∧ i)) (~ i) x))) ;
f3 = λ x → (transp (λ j → path4 (i ∧ j)) (~ i) (f3 s1 (transp (λ j → path2 (~ j ∧ i)) (~ i) x))) }
spanPath2 : I → 3-span
spanPath2 i = record { A0 = A0 s2 ; A2 = A2 s2 ; A4 = A4 s2 ; f1 = f1Path i ; f3 = f3Path i }
where
f1Path : I → A2 s2 → A0 s2
f1Path i x = ((uaβ e0 (f1 s1 (transport (λ j → path2 (~ j)) x)))
∙ (H1 (transport (λ j → path2 (~ j)) x)) ⁻¹
∙ (λ j → f1 s2 (uaβ e2 (transport (λ j → path2 (~ j)) x) (~ j)))
∙ (λ j → f1 s2 (transportTransport⁻ path2 x j))) i
f3Path : I → A2 s2 → A4 s2
f3Path i x = ((uaβ e4 (f3 s1 (transport (λ j → path2 (~ j)) x)))
∙ (H3 (transport (λ j → path2 (~ j)) x)) ⁻¹
∙ (λ j → f3 s2 (uaβ e2 (transport (λ j → path2 (~ j)) x) (~ j)))
∙ (λ j → f3 s2 (transportTransport⁻ path2 x j))) i
spanPath : s1 ≡ s2
spanPath = (λ i → spanPath1 i) ∙ (λ i → spanPath2 i)
-- as a corollary, they have the same pushout
spanEquivToPushoutPath : {s1 : 3-span} → {s2 : 3-span} → (e : 3-span-equiv s1 s2)
→ spanPushout s1 ≡ spanPushout s2
spanEquivToPushoutPath {s1} {s2} e = cong spanPushout (spanEquivToPath e)
{-
3×3 lemma for pushouts
Let Aᵢⱼ denote a type, fᵢⱼ a map and Hᵢⱼ a homotopy. Given a diagram of the following shape:
A00 ←—f01—— A02 ——f03—→ A04
↑ ↑ ↑
f10 H11 f12 H13 f14
| | |
A20 ←—f21—— A22 ——f23—→ A24
| | |
f30 H31 f32 H33 f34
↓ ↓ ↓
A40 ←—f41—— A42 ——f43—→ A44
one can build its colimit from pushouts in two ways:
- either build pushouts A□0, A□2, A□4 of the lines and then build the pushout A□○ of the resulting
diagram A□0 ←—f□1—— A□2 ——f□3—→ A□4 ;
- or build pushouts of the columns and build the pushout A○□ of the resulting diagram A0□ ← A2□ → A4□.
Then the lemma states there is an equivalence A□○ ≃ A○□.
-}
record 3x3-span : Type₁ where
field
A00 A02 A04 A20 A22 A24 A40 A42 A44 : Type₀
f10 : A20 → A00
f12 : A22 → A02
f14 : A24 → A04
f30 : A20 → A40
f32 : A22 → A42
f34 : A24 → A44
f01 : A02 → A00
f21 : A22 → A20
f41 : A42 → A40
f03 : A02 → A04
f23 : A22 → A24
f43 : A42 → A44
H11 : ∀ x → f01 (f12 x) ≡ f10 (f21 x)
H13 : ∀ x → f03 (f12 x) ≡ f14 (f23 x)
H31 : ∀ x → f41 (f32 x) ≡ f30 (f21 x)
H33 : ∀ x → f43 (f32 x) ≡ f34 (f23 x)
-- pushouts of the lines
A□0 : Type₀
A□0 = Pushout f10 f30
A□2 : Type₀
A□2 = Pushout f12 f32
A□4 : Type₀
A□4 = Pushout f14 f34
-- maps between pushouts
f□1 : A□2 → A□0
f□1 (inl x) = inl (f01 x)
f□1 (inr x) = inr (f41 x)
f□1 (push a j) = ((λ i → inl (H11 a i))
∙∙ push (f21 a)
∙∙ (λ i → inr (H31 a (~ i)))) j
f□3 : A□2 → A□4
f□3 (inl x) = inl (f03 x)
f□3 (inr x) = inr (f43 x)
f□3 (push a j) = ((λ i → inl (H13 a i))
∙∙ push (f23 a)
∙∙ (λ i → inr (H33 a (~ i)))) j
-- total pushout
A□○ : Type₀
A□○ = Pushout f□1 f□3
-- pushouts of the columns
A0□ : Type₀
A0□ = Pushout f01 f03
A2□ : Type₀
A2□ = Pushout f21 f23
A4□ : Type₀
A4□ = Pushout f41 f43
-- maps between pushouts
f1□ : A2□ → A0□
f1□ (inl x) = inl (f10 x)
f1□ (inr x) = inr (f14 x)
f1□ (push a j) = ((λ i → inl (H11 a (~ i)))
∙∙ push (f12 a)
∙∙ (λ i → inr (H13 a i))) j
f3□ : A2□ → A4□
f3□ (inl x) = inl (f30 x)
f3□ (inr x) = inr (f34 x)
f3□ (push a j) = ((λ i → inl (H31 a (~ i)))
∙∙ push (f32 a)
∙∙ (λ i → inr (H33 a i))) j
-- total pushout
A○□ : Type₀
A○□ = Pushout f1□ f3□
-- the claimed result
3x3-lemma : A□○ ≡ A○□
3x3-lemma = isoToPath (iso A□○→A○□ A○□→A□○ A○□→A□○→A○□ A□○→A○□→A□○)
where
-- forward map of the equivalence A□○ ≃ A○□
forward-l : A□0 → A○□
forward-l (inl x) = inl (inl x)
forward-l (inr x) = inr (inl x)
forward-l (push a i) = push (inl a) i
forward-r : A□4 → A○□
forward-r (inl x) = inl (inr x)
forward-r (inr x) = inr (inr x)
forward-r (push a i) = push (inr a) i
forward-filler : A22 → I → I → I → A○□
forward-filler a i j = hfill (λ t → λ { (i = i0) → inl (doubleCompPath-filler (λ k → inl (H11 a (~ k))) (push (f12 a)) (λ k → inr (H13 a k)) j (~ t))
; (i = i1) → inr (doubleCompPath-filler (λ k → inl (H31 a (~ k))) (push (f32 a)) (λ k → inr (H33 a k)) j (~ t))
; (j = i0) → forward-l (doubleCompPath-filler (λ k → inl (H11 a k)) (push (f21 a)) (λ k → inr (H31 a (~ k))) i t)
; (j = i1) → forward-r (doubleCompPath-filler (λ k → inl (H13 a k)) (push (f23 a)) (λ k → inr (H33 a (~ k))) i t) })
(inS (push (push a j) i))
A□○→A○□ : A□○ → A○□
A□○→A○□ (inl x) = forward-l x
A□○→A○□ (inr x) = forward-r x
A□○→A○□ (push (inl x) i) = inl (push x i)
A□○→A○□ (push (inr x) i) = inr (push x i)
A□○→A○□ (push (push a i) j) = forward-filler a i j i1
-- backward map
backward-l : A0□ → A□○
backward-l (inl x) = inl (inl x)
backward-l (inr x) = inr (inl x)
backward-l (push a i) = push (inl a) i
backward-r : A4□ → A□○
backward-r (inl x) = inl (inr x)
backward-r (inr x) = inr (inr x)
backward-r (push a i) = push (inr a) i
backward-filler : A22 → I → I → I → A□○
backward-filler a i j = hfill (λ t → λ { (i = i0) → inl (doubleCompPath-filler (λ k → inl (H11 a k)) (push (f21 a)) (λ k → inr (H31 a (~ k))) j (~ t))
; (i = i1) → inr (doubleCompPath-filler (λ k → inl (H13 a k)) (push (f23 a)) (λ k → inr (H33 a (~ k))) j (~ t))
; (j = i0) → backward-l (doubleCompPath-filler (λ k → inl (H11 a (~ k))) (push (f12 a)) (λ k → inr (H13 a k)) i t)
; (j = i1) → backward-r (doubleCompPath-filler (λ k → inl (H31 a (~ k))) (push (f32 a)) (λ k → inr (H33 a k)) i t) })
(inS (push (push a j) i))
A○□→A□○ : A○□ → A□○
A○□→A□○ (inl x) = backward-l x
A○□→A□○ (inr x) = backward-r x
A○□→A□○ (push (inl x) i) = inl (push x i)
A○□→A□○ (push (inr x) i) = inr (push x i)
A○□→A□○ (push (push a i) j) = backward-filler a i j i1
-- first homotopy
homotopy1-l : ∀ x → A□○→A○□ (backward-l x) ≡ inl x
homotopy1-l (inl x) = refl
homotopy1-l (inr x) = refl
homotopy1-l (push a i) = refl
homotopy1-r : ∀ x → A□○→A○□ (backward-r x) ≡ inr x
homotopy1-r (inl x) = refl
homotopy1-r (inr x) = refl
homotopy1-r (push a i) = refl
A○□→A□○→A○□ : ∀ x → A□○→A○□ (A○□→A□○ x) ≡ x
A○□→A□○→A○□ (inl x) = homotopy1-l x
A○□→A□○→A○□ (inr x) = homotopy1-r x
A○□→A□○→A○□ (push (inl x) i) k = push (inl x) i
A○□→A□○→A○□ (push (inr x) i) k = push (inr x) i
A○□→A□○→A○□ (push (push a i) j) k =
hcomp (λ t → λ { (i = i0) → forward-l (doubleCompPath-filler (λ k → inl (H11 a k)) (push (f21 a)) (λ k → inr (H31 a (~ k))) j (~ t))
; (i = i1) → forward-r (doubleCompPath-filler (λ k → inl (H13 a k)) (push (f23 a)) (λ k → inr (H33 a (~ k))) j (~ t))
; (j = i0) → homotopy1-l (doubleCompPath-filler (λ k → inl (H11 a (~ k))) (push (f12 a)) (λ k → inr (H13 a k)) i t) k
; (j = i1) → homotopy1-r (doubleCompPath-filler (λ k → inl (H31 a (~ k))) (push (f32 a)) (λ k → inr (H33 a k)) i t) k
; (k = i0) → A□○→A○□ (backward-filler a i j t)
; (k = i1) → forward-filler a j i (~ t) })
(forward-filler a j i i1)
-- second homotopy
homotopy2-l : ∀ x → A○□→A□○ (forward-l x) ≡ inl x
homotopy2-l (inl x) = refl
homotopy2-l (inr x) = refl
homotopy2-l (push a i) = refl
homotopy2-r : ∀ x → A○□→A□○ (forward-r x) ≡ inr x
homotopy2-r (inl x) = refl
homotopy2-r (inr x) = refl
homotopy2-r (push a i) = refl
A□○→A○□→A□○ : ∀ x → A○□→A□○ (A□○→A○□ x) ≡ x
A□○→A○□→A□○ (inl x) = homotopy2-l x
A□○→A○□→A□○ (inr x) = homotopy2-r x
A□○→A○□→A□○ (push (inl x) i) k = push (inl x) i
A□○→A○□→A□○ (push (inr x) i) k = push (inr x) i
A□○→A○□→A□○ (push (push a i) j) k =
hcomp (λ t → λ { (i = i0) → backward-l (doubleCompPath-filler (λ k → inl (H11 a (~ k))) (push (f12 a)) (λ k → inr (H13 a k)) j (~ t))
; (i = i1) → backward-r (doubleCompPath-filler (λ k → inl (H31 a (~ k))) (push (f32 a)) (λ k → inr (H33 a k)) j (~ t))
; (j = i0) → homotopy2-l (doubleCompPath-filler (λ k → inl (H11 a k)) (push (f21 a)) (λ k → inr (H31 a (~ k))) i t) k
; (j = i1) → homotopy2-r (doubleCompPath-filler (λ k → inl (H13 a k)) (push (f23 a)) (λ k → inr (H33 a (~ k))) i t) k
; (k = i0) → A○□→A□○ (forward-filler a i j t)
; (k = i1) → backward-filler a j i (~ t) })
(backward-filler a j i i1)
| 35.496815
| 156
| 0.485376
|
38e485ca67430844f1bbac66f265ded754615c85
| 803
|
agda
|
Agda
|
src/Categories/Morphism/Regular/Properties.agda
|
maxsnew/agda-categories
|
8f3c844d929508040dfa21f681fa260056214b73
|
[
"MIT"
] | null | null | null |
src/Categories/Morphism/Regular/Properties.agda
|
maxsnew/agda-categories
|
8f3c844d929508040dfa21f681fa260056214b73
|
[
"MIT"
] | null | null | null |
src/Categories/Morphism/Regular/Properties.agda
|
maxsnew/agda-categories
|
8f3c844d929508040dfa21f681fa260056214b73
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --without-K --safe #-}
open import Categories.Category.Core
module Categories.Morphism.Regular.Properties {o ℓ e} (𝒞 : Category o ℓ e) where
open import Categories.Morphism 𝒞
open import Categories.Morphism.Regular 𝒞
open import Categories.Diagram.Equalizer 𝒞
open import Categories.Diagram.Equalizer.Properties 𝒞
open import Categories.Diagram.Coequalizer.Properties 𝒞
open Category 𝒞
private
variable
A B : Obj
f g : A ⇒ B
Section⇒RegularMono : f SectionOf g → RegularMono f
Section⇒RegularMono {f = f} {g = g} g∘f≈id = record
{ g = id
; h = f ∘ g
; equalizer = section-equalizer g∘f≈id
}
Retract⇒RegularEpi : f RetractOf g → RegularEpi f
Retract⇒RegularEpi {f = f} {g = g} f∘g≈id = record
{ h = g ∘ f
; g = id
; coequalizer = retract-coequalizer f∘g≈id
}
| 24.333333
| 80
| 0.702366
|
04839eccccbadac82f5477831cead1374e2dd85e
| 279
|
agda
|
Agda
|
Ix.agda
|
pigworker/InteriorDesign
|
454cdd18f56db0b0d1643a1fcf36951b5ece395c
|
[
"BSD-3-Clause"
] | 6
|
2018-06-18T15:25:39.000Z
|
2018-07-31T02:00:13.000Z
|
Ix.agda
|
pigworker/InteriorDesign
|
454cdd18f56db0b0d1643a1fcf36951b5ece395c
|
[
"BSD-3-Clause"
] | null | null | null |
Ix.agda
|
pigworker/InteriorDesign
|
454cdd18f56db0b0d1643a1fcf36951b5ece395c
|
[
"BSD-3-Clause"
] | null | null | null |
module Ix where
_-:>_ : {I : Set} -> (I -> Set) -> (I -> Set) -> (I -> Set)
(S -:> T) i = S i -> T i
infixr 4 _-:>_
[_] : {I : Set} -> (I -> Set) -> Set
[ P ] = forall i -> P i
Algebra : {I : Set}(F : (I -> Set) -> (I -> Set)) -> (I -> Set) -> Set
Algebra F X = [ F X -:> X ]
| 23.25
| 70
| 0.387097
|
1317f3eccb36f8324e73acc3e7cf64bd78d57a1a
| 2,023
|
agda
|
Agda
|
Cubical/README.agda
|
howsiyu/cubical
|
1b9c97a2140fe96fe636f4c66beedfd7b8096e8f
|
[
"MIT"
] | null | null | null |
Cubical/README.agda
|
howsiyu/cubical
|
1b9c97a2140fe96fe636f4c66beedfd7b8096e8f
|
[
"MIT"
] | null | null | null |
Cubical/README.agda
|
howsiyu/cubical
|
1b9c97a2140fe96fe636f4c66beedfd7b8096e8f
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --guardedness #-}
module Cubical.README where
------------------------------------------------------------------------
-- An experimental library for Cubical Agda
-----------------------------------------------------------------------
-- The library comes with a .agda-lib file, for use with the library
-- management system.
------------------------------------------------------------------------
-- Module hierarchy
------------------------------------------------------------------------
-- The core library for Cubical Agda.
-- It contains basic primitives, equivalences, glue types.
import Cubical.Core.Everything
-- The foundations for Cubical Agda.
-- The Prelude module is self-explanatory.
import Cubical.Foundations.Prelude
import Cubical.Foundations.Everything
-- Kinds and properties of functions
import Cubical.Functions.Everything
-- Data types and properties
import Cubical.Data.Everything
-- Higher-inductive types
import Cubical.HITs.Everything
-- Coinductive data types and properties
import Cubical.Codata.Everything
-- Papers
import Cubical.Papers.Everything
-- Properties and proofs about relations
import Cubical.Relation.Everything
-- Category theory
import Cubical.Categories.Everything
-- Homotopy theory
import Cubical.Homotopy.Everything
-- Properties and kinds of Modalities
import Cubical.Modalities.Everything
-- Various experiments using Cubical Agda
import Cubical.Experiments.Everything
-- Other modules (TODO: add descriptions)
import Cubical.Induction.Everything
import Cubical.Structures.Everything
-- general definition of cohomology
import Cubical.Cohomology.Everything
-- cohomology with constant Integer coefficients
import Cubical.ZCohomology.Everything
-- Algebra library (in development)
import Cubical.Algebra.Everything
-- Various talks
import Cubical.Talks.Everything
-- Reflection
import Cubical.Reflection.Everything
-- Displayed univalent graphs
import Cubical.Displayed.Everything
-- Syntax typeclasses
import Cubical.Syntax.Everything
| 25.607595
| 72
| 0.69303
|
38e92b837bb6cf873f0298596d98230f974f932a
| 15,568
|
agda
|
Agda
|
src/Equivalence/Erased/Contractible-preimages.agda
|
nad/equality
|
402b20615cfe9ca944662380d7b2d69b0f175200
|
[
"MIT"
] | 3
|
2020-05-21T22:58:50.000Z
|
2021-09-02T17:18:15.000Z
|
src/Equivalence/Erased/Contractible-preimages.agda
|
nad/equality
|
402b20615cfe9ca944662380d7b2d69b0f175200
|
[
"MIT"
] | null | null | null |
src/Equivalence/Erased/Contractible-preimages.agda
|
nad/equality
|
402b20615cfe9ca944662380d7b2d69b0f175200
|
[
"MIT"
] | null | null | null |
------------------------------------------------------------------------
-- Equivalences with erased "proofs", defined in terms of partly
-- erased contractible fibres
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
open import Equality
module Equivalence.Erased.Contractible-preimages
{reflexive} (eq : ∀ {a p} → Equality-with-J a p reflexive) where
open Derived-definitions-and-properties eq
open import Prelude
open import Bijection eq using (_↔_)
open import Equivalence eq as Eq using (_≃_; Is-equivalence)
import Equivalence.Contractible-preimages eq as CP
open import Erased.Level-1 eq as Erased
hiding (module []-cong; module []-cong₁; module []-cong₂)
open import Function-universe eq hiding (id; _∘_)
open import H-level eq as H-level
open import H-level.Closure eq
open import Preimage eq as Preimage using (_⁻¹_)
open import Surjection eq using (_↠_; Split-surjective)
private
variable
a b ℓ ℓ₁ ℓ₂ : Level
A B : Type a
c ext k k′ p x y : A
P : A → Type p
f : (x : A) → P x
------------------------------------------------------------------------
-- Some basic types
-- "Preimages" with erased proofs.
infix 5 _⁻¹ᴱ_
_⁻¹ᴱ_ : {A : Type a} {@0 B : Type b} → @0 (A → B) → @0 B → Type (a ⊔ b)
f ⁻¹ᴱ y = ∃ λ x → Erased (f x ≡ y)
-- Contractibility with an erased proof.
Contractibleᴱ : Type ℓ → Type ℓ
Contractibleᴱ A = ∃ λ (x : A) → Erased (∀ y → x ≡ y)
-- The property of being an equivalence (with erased proofs).
Is-equivalenceᴱ : {A : Type a} {B : Type b} → @0 (A → B) → Type (a ⊔ b)
Is-equivalenceᴱ f = ∀ y → Contractibleᴱ (f ⁻¹ᴱ y)
-- Equivalences with erased proofs.
_≃ᴱ_ : Type a → Type b → Type (a ⊔ b)
A ≃ᴱ B = ∃ λ (f : A → B) → Is-equivalenceᴱ f
------------------------------------------------------------------------
-- Some conversion lemmas
-- Conversions between _⁻¹_ and _⁻¹ᴱ_.
⁻¹→⁻¹ᴱ :
{@0 A : Type a} {@0 B : Type b} {@0 f : A → B} {@0 y : B} →
f ⁻¹ y → f ⁻¹ᴱ y
⁻¹→⁻¹ᴱ = Σ-map id [_]→
@0 ⁻¹ᴱ→⁻¹ : f ⁻¹ᴱ x → f ⁻¹ x
⁻¹ᴱ→⁻¹ = Σ-map id erased
@0 ⁻¹≃⁻¹ᴱ : f ⁻¹ y ≃ f ⁻¹ᴱ y
⁻¹≃⁻¹ᴱ {f = f} {y = y} =
(∃ λ x → f x ≡ y) ↝⟨ (∃-cong λ _ → Eq.inverse $ Eq.↔⇒≃ $ erased Erased↔) ⟩□
(∃ λ x → Erased (f x ≡ y)) □
_ : _≃_.to ⁻¹≃⁻¹ᴱ p ≡ ⁻¹→⁻¹ᴱ p
_ = refl _
@0 _ : _≃_.from ⁻¹≃⁻¹ᴱ p ≡ ⁻¹ᴱ→⁻¹ p
_ = refl _
-- Conversions between Contractible and Contractibleᴱ.
Contractible→Contractibleᴱ :
{@0 A : Type a} →
Contractible A → Contractibleᴱ A
Contractible→Contractibleᴱ = Σ-map id [_]→
@0 Contractibleᴱ→Contractible : Contractibleᴱ A → Contractible A
Contractibleᴱ→Contractible = Σ-map id erased
@0 Contractible≃Contractibleᴱ :
Contractible A ≃ Contractibleᴱ A
Contractible≃Contractibleᴱ =
(∃ λ x → ∀ y → x ≡ y) ↝⟨ (∃-cong λ _ → Eq.inverse $ Eq.↔⇒≃ $ erased Erased↔) ⟩□
(∃ λ x → Erased (∀ y → x ≡ y)) □
_ :
_≃_.to Contractible≃Contractibleᴱ c ≡ Contractible→Contractibleᴱ c
_ = refl _
@0 _ :
_≃_.from Contractible≃Contractibleᴱ c ≡ Contractibleᴱ→Contractible c
_ = refl _
-- Conversions between CP.Is-equivalence and Is-equivalenceᴱ.
Is-equivalence→Is-equivalenceᴱ :
{@0 A : Type a} {@0 B : Type b} {@0 f : A → B} →
CP.Is-equivalence f → Is-equivalenceᴱ f
Is-equivalence→Is-equivalenceᴱ eq y =
⁻¹→⁻¹ᴱ (proj₁₀ (eq y))
, [ cong ⁻¹→⁻¹ᴱ ∘ proj₂ (eq y) ∘ ⁻¹ᴱ→⁻¹ ]
@0 Is-equivalenceᴱ→Is-equivalence :
Is-equivalenceᴱ f → CP.Is-equivalence f
Is-equivalenceᴱ→Is-equivalence eq y =
⁻¹ᴱ→⁻¹ (proj₁ (eq y))
, cong ⁻¹ᴱ→⁻¹ ∘ erased (proj₂ (eq y)) ∘ ⁻¹→⁻¹ᴱ
private
-- In an erased context CP.Is-equivalence and Is-equivalenceᴱ are
-- pointwise equivalent (assuming extensionality).
--
-- This lemma is not exported. See Is-equivalence≃Is-equivalenceᴱ
-- below, which computes in a different way.
@0 Is-equivalence≃Is-equivalenceᴱ′ :
{A : Type a} {B : Type b} {f : A → B} →
CP.Is-equivalence f ↝[ a ⊔ b ∣ a ⊔ b ] Is-equivalenceᴱ f
Is-equivalence≃Is-equivalenceᴱ′ {a = a} {f = f} {k = k} ext =
(∀ y → Contractible (f ⁻¹ y)) ↝⟨ (∀-cong ext′ λ _ → H-level-cong ext 0 ⁻¹≃⁻¹ᴱ) ⟩
(∀ y → Contractible (f ⁻¹ᴱ y)) ↝⟨ (∀-cong ext′ λ _ → from-isomorphism Contractible≃Contractibleᴱ) ⟩□
(∀ y → Contractibleᴱ (f ⁻¹ᴱ y)) □
where
ext′ = lower-extensionality? k a lzero ext
------------------------------------------------------------------------
-- Some type formers are propositional in erased contexts
-- In an erased context Contractibleᴱ is propositional (assuming
-- extensionality).
@0 Contractibleᴱ-propositional :
{A : Type a} →
Extensionality a a →
Is-proposition (Contractibleᴱ A)
Contractibleᴱ-propositional ext =
H-level.respects-surjection
(_≃_.surjection Contractible≃Contractibleᴱ)
1
(Contractible-propositional ext)
-- In an erased context Is-equivalenceᴱ f is a proposition (assuming
-- extensionality).
--
-- See also Is-equivalenceᴱ-propositional-for-Erased below.
@0 Is-equivalenceᴱ-propositional :
{A : Type a} {B : Type b} →
Extensionality (a ⊔ b) (a ⊔ b) →
(f : A → B) → Is-proposition (Is-equivalenceᴱ f)
Is-equivalenceᴱ-propositional ext f =
H-level.respects-surjection
(_≃_.surjection $ Is-equivalence≃Is-equivalenceᴱ′ ext)
1
(CP.propositional ext f)
------------------------------------------------------------------------
-- More conversion lemmas
-- In an erased context CP.Is-equivalence and Is-equivalenceᴱ are
-- pointwise equivalent (assuming extensionality).
@0 Is-equivalence≃Is-equivalenceᴱ :
{A : Type a} {B : Type b} {f : A → B} →
CP.Is-equivalence f ↝[ a ⊔ b ∣ a ⊔ b ] Is-equivalenceᴱ f
Is-equivalence≃Is-equivalenceᴱ {k = equivalence} ext =
Eq.with-other-function
(Eq.with-other-inverse
(Is-equivalence≃Is-equivalenceᴱ′ ext)
Is-equivalenceᴱ→Is-equivalence
(λ _ → CP.propositional ext _ _ _))
Is-equivalence→Is-equivalenceᴱ
(λ _ → Is-equivalenceᴱ-propositional ext _ _ _)
Is-equivalence≃Is-equivalenceᴱ = Is-equivalence≃Is-equivalenceᴱ′
_ :
_≃_.to (Is-equivalence≃Is-equivalenceᴱ ext) p ≡
Is-equivalence→Is-equivalenceᴱ p
_ = refl _
@0 _ :
_≃_.from (Is-equivalence≃Is-equivalenceᴱ ext) p ≡
Is-equivalenceᴱ→Is-equivalence p
_ = refl _
-- Conversions between CP._≃_ and _≃ᴱ_.
≃→≃ᴱ :
{@0 A : Type a} {@0 B : Type b} →
A CP.≃ B → A ≃ᴱ B
≃→≃ᴱ = Σ-map id Is-equivalence→Is-equivalenceᴱ
@0 ≃ᴱ→≃ : A ≃ᴱ B → A CP.≃ B
≃ᴱ→≃ = Σ-map id Is-equivalenceᴱ→Is-equivalence
-- In an erased context CP._≃_ and _≃ᴱ_ are pointwise equivalent
-- (assuming extensionality).
@0 ≃≃≃ᴱ :
{A : Type a} {B : Type b} →
(A CP.≃ B) ↝[ a ⊔ b ∣ a ⊔ b ] (A ≃ᴱ B)
≃≃≃ᴱ {A = A} {B = B} ext =
A CP.≃ B ↔⟨⟩
(∃ λ f → CP.Is-equivalence f) ↝⟨ (∃-cong λ _ → Is-equivalence≃Is-equivalenceᴱ ext) ⟩
(∃ λ f → Is-equivalenceᴱ f) ↔⟨⟩
A ≃ᴱ B □
_ : _≃_.to (≃≃≃ᴱ ext) p ≡ ≃→≃ᴱ p
_ = refl _
@0 _ : _≃_.from (≃≃≃ᴱ ext) p ≡ ≃ᴱ→≃ p
_ = refl _
-- An isomorphism relating _⁻¹ᴱ_ to _⁻¹_.
Erased-⁻¹ᴱ↔Erased-⁻¹ :
{@0 A : Type a} {@0 B : Type b} {@0 f : A → B} {@0 y : B} →
Erased (f ⁻¹ᴱ y) ↔ Erased (f ⁻¹ y)
Erased-⁻¹ᴱ↔Erased-⁻¹ {f = f} {y = y} =
Erased (∃ λ x → Erased (f x ≡ y)) ↝⟨ Erased-Σ↔Σ ⟩
(∃ λ x → Erased (Erased (f (erased x) ≡ y))) ↝⟨ (∃-cong λ _ → Erased-Erased↔Erased) ⟩
(∃ λ x → Erased (f (erased x) ≡ y)) ↝⟨ inverse Erased-Σ↔Σ ⟩□
Erased (∃ λ x → f x ≡ y) □
-- An isomorphism relating Contractibleᴱ to Contractible.
Erased-Contractibleᴱ↔Erased-Contractible :
{@0 A : Type a} →
Erased (Contractibleᴱ A) ↔ Erased (Contractible A)
Erased-Contractibleᴱ↔Erased-Contractible =
Erased (∃ λ x → Erased (∀ y → x ≡ y)) ↝⟨ Erased-Σ↔Σ ⟩
(∃ λ x → Erased (Erased (∀ y → erased x ≡ y))) ↝⟨ (∃-cong λ _ → Erased-Erased↔Erased) ⟩
(∃ λ x → Erased (∀ y → erased x ≡ y)) ↝⟨ inverse Erased-Σ↔Σ ⟩□
Erased (∃ λ x → ∀ y → x ≡ y) □
------------------------------------------------------------------------
-- Some results related to Contractibleᴱ
-- Contractibleᴱ respects split surjections with erased proofs.
Contractibleᴱ-respects-surjection :
{@0 A : Type a} {@0 B : Type b}
(f : A → B) → @0 Split-surjective f →
Contractibleᴱ A → Contractibleᴱ B
Contractibleᴱ-respects-surjection {A = A} {B = B} f s h@(x , _) =
f x
, [ proj₂ (H-level.respects-surjection surj 0
(Contractibleᴱ→Contractible h))
]
where
@0 surj : A ↠ B
surj = record
{ logical-equivalence = record
{ to = f
; from = proj₁ ∘ s
}
; right-inverse-of = proj₂ ∘ s
}
-- "Preimages" (with erased proofs) of an erased function with a
-- quasi-inverse with erased proofs are contractible.
Contractibleᴱ-⁻¹ᴱ :
{@0 A : Type a} {@0 B : Type b}
(@0 f : A → B)
(g : B → A)
(@0 f∘g : ∀ x → f (g x) ≡ x)
(@0 g∘f : ∀ x → g (f x) ≡ x) →
∀ y → Contractibleᴱ (f ⁻¹ᴱ y)
Contractibleᴱ-⁻¹ᴱ {A = A} {B = B} f g f∘g g∘f y =
(g y , [ proj₂ (proj₁ c′) ])
, [ cong ⁻¹→⁻¹ᴱ ∘ proj₂ c′ ∘ ⁻¹ᴱ→⁻¹ ]
where
@0 A↔B : A ↔ B
A↔B = record
{ surjection = record
{ logical-equivalence = record
{ to = f
; from = g
}
; right-inverse-of = f∘g
}
; left-inverse-of = g∘f
}
@0 c′ : Contractible (f ⁻¹ y)
c′ = Preimage.bijection⁻¹-contractible A↔B y
-- If an inhabited type comes with an erased proof of
-- propositionality, then it is contractible (with erased proofs).
inhabited→Is-proposition→Contractibleᴱ :
{@0 A : Type a} →
A → @0 Is-proposition A → Contractibleᴱ A
inhabited→Is-proposition→Contractibleᴱ x prop = (x , [ prop x ])
-- Some closure properties.
Contractibleᴱ-Σ :
{@0 A : Type a} {@0 P : A → Type p} →
Contractibleᴱ A → (∀ x → Contractibleᴱ (P x)) → Contractibleᴱ (Σ A P)
Contractibleᴱ-Σ cA@(a , _) cP =
(a , proj₁₀ (cP a))
, [ proj₂ $ Σ-closure 0 (Contractibleᴱ→Contractible cA)
(Contractibleᴱ→Contractible ∘ cP)
]
Contractibleᴱ-× :
{@0 A : Type a} {@0 B : Type b} →
Contractibleᴱ A → Contractibleᴱ B → Contractibleᴱ (A × B)
Contractibleᴱ-× cA cB = Contractibleᴱ-Σ cA (λ _ → cB)
Contractibleᴱ-Π :
{@0 A : Type a} {@0 P : A → Type p} →
@0 Extensionality a p →
(∀ x → Contractibleᴱ (P x)) → Contractibleᴱ ((x : A) → P x)
Contractibleᴱ-Π ext c =
proj₁₀ ∘ c
, [ proj₂ $ Π-closure ext 0 (Contractibleᴱ→Contractible ∘ c)
]
Contractibleᴱ-↑ :
{@0 A : Type a} →
Contractibleᴱ A → Contractibleᴱ (↑ ℓ A)
Contractibleᴱ-↑ c@(a , _) =
lift a
, [ proj₂ $ ↑-closure 0 (Contractibleᴱ→Contractible c)
]
------------------------------------------------------------------------
-- Results that follow if the []-cong axioms hold for one universe
-- level
module []-cong₁ (ax : []-cong-axiomatisation ℓ) where
open Erased-cong ax ax
open Erased.[]-cong₁ ax
----------------------------------------------------------------------
-- Some results related to _⁻¹ᴱ_
-- The function _⁻¹ᴱ y respects erased extensional equality.
⁻¹ᴱ-respects-extensional-equality :
{@0 B : Type ℓ} {@0 f g : A → B} {@0 y : B} →
@0 (∀ x → f x ≡ g x) → f ⁻¹ᴱ y ≃ g ⁻¹ᴱ y
⁻¹ᴱ-respects-extensional-equality {f = f} {g = g} {y = y} f≡g =
(∃ λ x → Erased (f x ≡ y)) ↝⟨ (∃-cong λ _ → Erased-cong-≃ (≡⇒↝ _ (cong (_≡ _) $ f≡g _))) ⟩□
(∃ λ x → Erased (g x ≡ y)) □
-- An isomorphism relating _⁻¹ᴱ_ to _⁻¹_.
⁻¹ᴱ[]↔⁻¹[] :
{@0 B : Type ℓ} {f : A → Erased B} {@0 y : B} →
f ⁻¹ᴱ [ y ] ↔ f ⁻¹ [ y ]
⁻¹ᴱ[]↔⁻¹[] {f = f} {y = y} =
(∃ λ x → Erased (f x ≡ [ y ])) ↔⟨ (∃-cong λ _ → Erased-cong-≃ (Eq.≃-≡ $ Eq.↔⇒≃ $ inverse $ erased Erased↔)) ⟩
(∃ λ x → Erased (erased (f x) ≡ y)) ↝⟨ (∃-cong λ _ → Erased-≡↔[]≡[]) ⟩□
(∃ λ x → f x ≡ [ y ]) □
-- Erased "commutes" with _⁻¹ᴱ_.
Erased-⁻¹ᴱ :
{@0 A : Type a} {@0 B : Type ℓ} {@0 f : A → B} {@0 y : B} →
Erased (f ⁻¹ᴱ y) ↔ map f ⁻¹ᴱ [ y ]
Erased-⁻¹ᴱ {f = f} {y = y} =
Erased (f ⁻¹ᴱ y) ↝⟨ Erased-⁻¹ᴱ↔Erased-⁻¹ ⟩
Erased (f ⁻¹ y) ↝⟨ Erased-⁻¹ ⟩
map f ⁻¹ [ y ] ↝⟨ inverse ⁻¹ᴱ[]↔⁻¹[] ⟩□
map f ⁻¹ᴱ [ y ] □
----------------------------------------------------------------------
-- Some results related to Contractibleᴱ
-- Erased commutes with Contractibleᴱ.
Erased-Contractibleᴱ↔Contractibleᴱ-Erased :
{@0 A : Type ℓ} →
Erased (Contractibleᴱ A) ↝[ ℓ ∣ ℓ ]ᴱ Contractibleᴱ (Erased A)
Erased-Contractibleᴱ↔Contractibleᴱ-Erased {A = A} ext =
Erased (∃ λ x → Erased ((y : A) → x ≡ y)) ↔⟨ Erased-cong-↔ (∃-cong λ _ → erased Erased↔) ⟩
Erased (∃ λ x → (y : A) → x ≡ y) ↔⟨ Erased-Σ↔Σ ⟩
(∃ λ x → Erased ((y : A) → erased x ≡ y)) ↝⟨ (∃-cong λ _ →
Erased-cong?
(λ ext → ∀-cong ext λ _ →
from-isomorphism (inverse $ erased Erased↔))
ext) ⟩
(∃ λ x → Erased ((y : A) → Erased (erased x ≡ y))) ↝⟨ (∃-cong λ _ →
Erased-cong?
(λ ext → Π-cong ext (inverse $ erased Erased↔) λ _ →
from-isomorphism Erased-≡↔[]≡[])
ext) ⟩□
(∃ λ x → Erased ((y : Erased A) → x ≡ y)) □
-- An isomorphism relating Contractibleᴱ to Contractible.
Contractibleᴱ-Erased↔Contractible-Erased :
{@0 A : Type ℓ} →
Contractibleᴱ (Erased A) ↝[ ℓ ∣ ℓ ] Contractible (Erased A)
Contractibleᴱ-Erased↔Contractible-Erased {A = A} ext =
Contractibleᴱ (Erased A) ↝⟨ inverse-erased-ext? Erased-Contractibleᴱ↔Contractibleᴱ-Erased ext ⟩
Erased (Contractibleᴱ A) ↔⟨ Erased-Contractibleᴱ↔Erased-Contractible ⟩
Erased (Contractible A) ↝⟨ Erased-H-level↔H-level 0 ext ⟩□
Contractible (Erased A) □
------------------------------------------------------------------------
-- Results that follow if the []-cong axioms hold for two universe
-- levels
module []-cong₂
(ax₁ : []-cong-axiomatisation ℓ₁)
(ax₂ : []-cong-axiomatisation ℓ₂)
where
open Erased-cong ax₁ ax₂
----------------------------------------------------------------------
-- A result related to Contractibleᴱ
-- Contractibleᴱ preserves isomorphisms (assuming extensionality).
Contractibleᴱ-cong :
{A : Type ℓ₁} {B : Type ℓ₂} →
@0 Extensionality? k′ (ℓ₁ ⊔ ℓ₂) (ℓ₁ ⊔ ℓ₂) →
A ↔[ k ] B → Contractibleᴱ A ↝[ k′ ] Contractibleᴱ B
Contractibleᴱ-cong {A = A} {B = B} ext A↔B =
(∃ λ (x : A) → Erased ((y : A) → x ≡ y)) ↝⟨ (Σ-cong A≃B′ λ _ →
Erased-cong?
(λ ext → Π-cong ext A≃B′ λ _ →
from-isomorphism $ inverse $ Eq.≃-≡ A≃B′)
ext) ⟩□
(∃ λ (x : B) → Erased ((y : B) → x ≡ y)) □
where
A≃B′ = from-isomorphism A↔B
------------------------------------------------------------------------
-- Results that follow if the []-cong axioms hold for all universe
-- levels
module []-cong (ax : ∀ {ℓ} → []-cong-axiomatisation ℓ) where
private
open module BC₁ {ℓ} =
[]-cong₁ (ax {ℓ = ℓ})
public
open module BC₂ {ℓ₁ ℓ₂} =
[]-cong₂ (ax {ℓ = ℓ₁}) (ax {ℓ = ℓ₂})
public
| 33.551724
| 119
| 0.524024
|
cbd3b7c6aeb6db17928f32252382022e97c86ec5
| 389
|
agda
|
Agda
|
src/Algebra/Linear/Core.agda
|
felko/linear-algebra
|
d87c5a1eb5dd0569238272e67bce1899616b789a
|
[
"MIT"
] | 15
|
2019-11-02T14:11:00.000Z
|
2020-12-30T06:18:08.000Z
|
src/Algebra/Linear/Core.agda
|
felko/linear-algebra
|
d87c5a1eb5dd0569238272e67bce1899616b789a
|
[
"MIT"
] | null | null | null |
src/Algebra/Linear/Core.agda
|
felko/linear-algebra
|
d87c5a1eb5dd0569238272e67bce1899616b789a
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --without-K --safe #-}
module Algebra.Linear.Core where
open import Relation.Binary
open import Relation.Nullary using (¬_)
open import Level using (_⊔_)
open import Data.Fin using (Fin; suc; zero)
VectorAddition : ∀ {c} -> Set c -> Set c
VectorAddition V = V -> V -> V
ScalarMultiplication : ∀ {c k} -> Set k -> Set c -> Set (k ⊔ c)
ScalarMultiplication K V = K -> V -> V
| 25.933333
| 63
| 0.660668
|
dc4d8f40032e3a363df0c7238b208f642eb93d73
| 801
|
agda
|
Agda
|
agda-stdlib-0.9/src/Relation/Binary/Simple.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/Relation/Binary/Simple.agda
|
qwe2/try-agda
|
9d4c43b1609d3f085636376fdca73093481ab882
|
[
"Apache-2.0"
] | null | null | null |
agda-stdlib-0.9/src/Relation/Binary/Simple.agda
|
qwe2/try-agda
|
9d4c43b1609d3f085636376fdca73093481ab882
|
[
"Apache-2.0"
] | null | null | null |
------------------------------------------------------------------------
-- The Agda standard library
--
-- Some simple binary relations
------------------------------------------------------------------------
module Relation.Binary.Simple where
open import Relation.Binary
open import Data.Unit
open import Data.Empty
open import Level
-- Constant relations.
Const : ∀ {a b c} {A : Set a} {B : Set b} → Set c → REL A B c
Const I = λ _ _ → I
-- The universally true relation.
Always : ∀ {a ℓ} {A : Set a} → Rel A ℓ
Always = Const (Lift ⊤)
Always-setoid : ∀ {a ℓ} (A : Set a) → Setoid a ℓ
Always-setoid A = record
{ Carrier = A
; _≈_ = Always
; isEquivalence = record {}
}
-- The universally false relation.
Never : ∀ {a ℓ} {A : Set a} → Rel A ℓ
Never = Const (Lift ⊥)
| 22.885714
| 72
| 0.508115
|
2fba9d77a412901541eee834ac5c285b8b4175a6
| 1,043
|
agda
|
Agda
|
theorems/cw/cohomology/reconstructed/FirstGroupOnDiag.agda
|
AntoineAllioux/HoTT-Agda
|
1037d82edcf29b620677a311dcfd4fc2ade2faa6
|
[
"MIT"
] | 294
|
2015-01-09T16:23:23.000Z
|
2022-03-20T13:54:45.000Z
|
theorems/cw/cohomology/reconstructed/FirstGroupOnDiag.agda
|
AntoineAllioux/HoTT-Agda
|
1037d82edcf29b620677a311dcfd4fc2ade2faa6
|
[
"MIT"
] | 31
|
2015-03-05T20:09:00.000Z
|
2021-10-03T19:15:25.000Z
|
theorems/cw/cohomology/reconstructed/FirstGroupOnDiag.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
open import cohomology.Theory
open import cohomology.PtdMapSequence
open import groups.ExactSequence
open import groups.Exactness
open import groups.HomSequence
open import cw.CW
module cw.cohomology.reconstructed.FirstGroupOnDiag {i} (OT : OrdinaryTheory i)
(⊙skel : ⊙Skeleton {i} 1) (ac : ⊙has-cells-with-choice 0 ⊙skel i) where
open OrdinaryTheory OT
open import cw.cohomology.WedgeOfCells OT
open import cw.cohomology.reconstructed.TipCoboundary OT ⊙skel
open import cw.cohomology.reconstructed.TipGrid OT ⊙skel ac
{-
Coker ≃ C(X₁) = C(X)
^
|
|
C(X₁/X₀)
WoC
WoC := Wedges of Cells
-}
open import groups.KernelImage {K = Lift-group {j = i} Unit-group} cst-hom cw-co∂-head CX₁/X₀-is-abelian
open import groups.KernelCstImage (Lift-group {j = i} Unit-group) cw-co∂-head CX₁/X₀-is-abelian
C-cw-iso-ker/im : C 1 ⊙⟦ ⊙skel ⟧ ≃ᴳ Ker/Im
C-cw-iso-ker/im = Ker-cst-quot-Im ⁻¹ᴳ ∘eᴳ Coker-cw-co∂-head ⁻¹ᴳ where
| 28.972222
| 104
| 0.685523
|
38c8ea832bc83baf3ec010119ef3d9bad1cde15f
| 7,095
|
agda
|
Agda
|
agda/PiPath.agda
|
JacquesCarette/pi-dual
|
003835484facfde0b770bc2b3d781b42b76184c1
|
[
"BSD-2-Clause"
] | 14
|
2015-08-18T21:40:15.000Z
|
2021-05-05T01:07:57.000Z
|
agda/PiPath.agda
|
JacquesCarette/pi-dual
|
003835484facfde0b770bc2b3d781b42b76184c1
|
[
"BSD-2-Clause"
] | 4
|
2018-06-07T16:27:41.000Z
|
2021-10-29T20:41:23.000Z
|
agda/PiPath.agda
|
JacquesCarette/pi-dual
|
003835484facfde0b770bc2b3d781b42b76184c1
|
[
"BSD-2-Clause"
] | 3
|
2016-05-29T01:56:33.000Z
|
2019-09-10T09:47:13.000Z
|
{-# OPTIONS --no-termination-check #-}
module PiPath where
open import Level
open import Data.Empty
open import Data.Unit
open import Data.Sum
open import Data.Product
open import Relation.Binary.PropositionalEquality
------------------------------------------------------------------------------
-- Universe of types
-- The type < v > is the singleton type containing the one value v. We can
-- construct values of this type using (singleton v' proof) where the proof
-- asserts that v is propositionally equal to v.
data <_> {a : Level} {A : Set a} (x : A) : Set a where
singleton : (y : A) → y ≡ x → < x >
-- The types of Pi include 0, 1, +, * as usual but
data B : Set where
ZERO : B
ONE : B
PLUS : B → B → B
TIMES : B → B → B
RECIP : B → (B → B) → B
⟦_⟧ : B → Set
⟦ ZERO ⟧ = ⊥
⟦ ONE ⟧ = ⊤
⟦ PLUS b₁ b₂ ⟧ = ⟦ b₁ ⟧ ⊎ ⟦ b₂ ⟧
⟦ TIMES b₁ b₂ ⟧ = ⟦ b₁ ⟧ × ⟦ b₂ ⟧
⟦ RECIP b ⟧ = (v : ⟦ b ⟧) → ⊤
------------------------------------------------------------------------------
-- syntax and types of combinators ⟷ refers to eval
-- eval refers to evalB
-- evalB refers to eval and reverse
-- reverse refers to reverse'
-- reverse' refers to reverse
-- syntax and types of combinators
data _⟷_ : B → B → Set₁ where
unite₊ : {b : B} → PLUS ZERO b ⟷ b
uniti₊ : {b : B} → b ⟷ PLUS ZERO b
swap₊ : {b₁ b₂ : B} → PLUS b₁ b₂ ⟷ PLUS b₂ b₁
assocl₊ : { b₁ b₂ b₃ : B } → PLUS b₁ (PLUS b₂ b₃) ⟷ PLUS (PLUS b₁ b₂) b₃
assocr₊ : { b₁ b₂ b₃ : B } → PLUS (PLUS b₁ b₂) b₃ ⟷ PLUS b₁ (PLUS b₂ b₃)
unite⋆ : { b : B } → TIMES ONE b ⟷ b
uniti⋆ : { b : B } → b ⟷ TIMES ONE b
swap⋆ : {b₁ b₂ : B} → TIMES b₁ b₂ ⟷ TIMES b₂ b₁
assocl⋆ : { b₁ b₂ b₃ : B } → TIMES b₁ (TIMES b₂ b₃) ⟷ TIMES (TIMES b₁ b₂) b₃
assocr⋆ : { b₁ b₂ b₃ : B } → TIMES (TIMES b₁ b₂) b₃ ⟷ TIMES b₁ (TIMES b₂ b₃)
id⟷ : {b : B } → b ⟷ b
op : { b₁ b₂ : B } → (b₁ ⟷ b₂) → (b₂ ⟷ b₁)
_◎_ : { b₁ b₂ b₃ : B } → (b₁ ⟷ b₂) → (b₂ ⟷ b₃) → (b₁ ⟷ b₃)
_⊕_ : { b₁ b₂ b₃ b₄ : B } →
(b₁ ⟷ b₃) → (b₂ ⟷ b₄) → (PLUS b₁ b₂ ⟷ PLUS b₃ b₄)
_⊗_ : { b₁ b₂ b₃ b₄ : B } →
(b₁ ⟷ b₃) → (b₂ ⟷ b₄) → (TIMES b₁ b₂ ⟷ TIMES b₃ b₄)
ε : {b₁ : B} → TIMES b₁ (TIMES b₁ (RECIP b₁)) ⟷ b₁
-- Semantics
mutual
eval : {b₁ b₂ : B} → (c : b₁ ⟷ b₂) → ⟦ b₁ ⟧ → ⟦ b₂ ⟧
eval unite₊ (inj₁ ())
eval unite₊ (inj₂ v) = v
eval uniti₊ v = inj₂ v
eval swap₊ (inj₁ x) = inj₂ x
eval swap₊ (inj₂ y) = inj₁ y
eval assocl₊ (inj₁ x) = inj₁ (inj₁ x)
eval assocl₊ (inj₂ (inj₁ x)) = inj₁ (inj₂ x)
eval assocl₊ (inj₂ (inj₂ x)) = inj₂ x
eval assocr₊ (inj₁ (inj₁ x)) = inj₁ x
eval assocr₊ (inj₁ (inj₂ y)) = inj₂ (inj₁ y)
eval assocr₊ (inj₂ y) = inj₂ (inj₂ y)
eval unite⋆ (tt , x) = x
eval uniti⋆ v = ( tt , v)
eval swap⋆ (v₁ , v₂) = (v₂ , v₁)
eval assocl⋆ (x , (y , z)) = ((x , y), z)
eval assocr⋆ ((x , y), z) = (x , (y , z))
eval id⟷ v = v
eval (op c) v = evalB c v
eval (c₁ ◎ c₂) v = eval c₂ (eval c₁ v)
eval (c₁ ⊕ c₂) (inj₁ x) = inj₁ (eval c₁ x)
eval (c₁ ⊕ c₂) (inj₂ y) = inj₂ (eval c₂ y)
eval (c₁ ⊗ c₂) (x , y) = (eval c₁ x , eval c₂ y)
eval ε (x , y , z) = x
evalB : {b₁ b₂ : B} → (c : b₁ ⟷ b₂) → ⟦ b₂ ⟧ → ⟦ b₁ ⟧
evalB uniti₊ (inj₁ ())
evalB uniti₊ (inj₂ v) = v
evalB unite₊ v = inj₂ v
evalB swap₊ (inj₁ x) = inj₂ x
evalB swap₊ (inj₂ y) = inj₁ y
evalB assocr₊ (inj₁ x) = inj₁ (inj₁ x)
evalB assocr₊ (inj₂ (inj₁ x)) = inj₁ (inj₂ x)
evalB assocr₊ (inj₂ (inj₂ x)) = inj₂ x
evalB assocl₊ (inj₁ (inj₁ x)) = inj₁ x
evalB assocl₊ (inj₁ (inj₂ y)) = inj₂ (inj₁ y)
evalB assocl₊ (inj₂ y) = inj₂ (inj₂ y)
evalB uniti⋆ (tt , x) = x
evalB unite⋆ v = ( tt , v)
evalB swap⋆ (v₁ , v₂) = (v₂ , v₁)
evalB assocr⋆ (x , (y , z)) = ((x , y), z)
evalB assocl⋆ ((x , y), z) = (x , (y , z))
evalB id⟷ v = v
evalB (op c) v = eval c v
evalB (c₁ ◎ c₂) v = evalB c₁ (evalB c₂ v)
evalB (c₁ ⊕ c₂) (inj₁ x) = inj₁ (evalB c₁ x)
evalB (c₁ ⊕ c₂) (inj₂ y) = inj₂ (evalB c₂ y)
evalB (c₁ ⊗ c₂) (x , y) = (evalB c₁ x , evalB c₂ y)
evalB ε x = x , x , (λ _ → tt)
-- reversibility
mutual
reverse : {b₁ b₂ : B} (c : b₁ ⟷ b₂) → (v : ⟦ b₁ ⟧) → v ≡ evalB c (eval c v)
reverse unite₊ (inj₁ ())
reverse unite₊ (inj₂ y) = refl
reverse uniti₊ v = refl
reverse swap₊ (inj₁ x) = refl
reverse swap₊ (inj₂ y) = refl
reverse assocl₊ (inj₁ x) = refl
reverse assocl₊ (inj₂ (inj₁ x)) = refl
reverse assocl₊ (inj₂ (inj₂ y)) = refl
reverse assocr₊ (inj₁ (inj₁ x)) = refl
reverse assocr₊ (inj₁ (inj₂ y)) = refl
reverse assocr₊ (inj₂ y) = refl
reverse unite⋆ v = refl
reverse uniti⋆ v = refl
reverse swap⋆ v = refl
reverse assocl⋆ v = refl
reverse assocr⋆ v = refl
reverse id⟷ v = refl
reverse (op c) v = reverse' c v
reverse (c ◎ c₁) v = trans (reverse c v)
(cong (evalB c) (reverse c₁ (eval c v)))
reverse (c ⊕ _) (inj₁ x) = cong inj₁ (reverse c x)
reverse (_ ⊕ c) (inj₂ y) = cong inj₂ (reverse c y)
reverse (c₁ ⊗ c₂) (x , y) = cong₂ _,_ (reverse c₁ x) (reverse c₂ y)
reverse ε (x , y , z) = {!!}
reverse' : {b₁ b₂ : B} (c : b₁ ⟷ b₂) → (w : ⟦ b₂ ⟧) → w ≡ eval c (evalB c w)
reverse' unite₊ w = refl
reverse' uniti₊ (inj₁ ())
reverse' uniti₊ (inj₂ y) = refl
reverse' swap₊ (inj₁ x) = refl
reverse' swap₊ (inj₂ y) = refl
reverse' assocl₊ (inj₁ (inj₁ x)) = refl
reverse' assocl₊ (inj₁ (inj₂ y)) = refl
reverse' assocl₊ (inj₂ y) = refl
reverse' assocr₊ (inj₁ x) = refl
reverse' assocr₊ (inj₂ (inj₁ x)) = refl
reverse' assocr₊ (inj₂ (inj₂ y)) = refl
reverse' unite⋆ w = refl
reverse' uniti⋆ w = refl
reverse' swap⋆ w = refl
reverse' assocl⋆ w = refl
reverse' assocr⋆ w = refl
reverse' id⟷ w = refl
reverse' (op c) w = reverse c w
reverse' (c ◎ c₁) w = trans (reverse' c₁ w)
(cong (eval c₁) (reverse' c (evalB c₁ w)))
reverse' (c ⊕ _) (inj₁ x) = cong inj₁ (reverse' c x)
reverse' (_ ⊕ c) (inj₂ y) = cong inj₂ (reverse' c y)
reverse' (c₁ ⊗ c₂) (x , y) = cong₂ _,_ (reverse' c₁ x) (reverse' c₂ y)
reverse' ε _ = refl
------------------------------------------------------------------------------
-- Proofs of reversibility
{-
-- they are properly inverse of each other
-- easy direction
η∘ε : {b : B} (v : ⟦ b ⟧) → eval {b} (η ◎ ε) v ≡ v
η∘ε _ = refl
-- hard direction.
ε∘η : {b : B} (v : ⟦ b ⟧) → { w : Σ < v > (λ _ → < v > → ⊤) }
→ (eval {DTIMES b (leftIdemp {b}) } {_} (ε ◎ η) (v , w)) ≡ (v , w)
ε∘η {b} v {(singleton .v refl , r )} = cong f {v , v , (singleton v refl)} refl
where f : Σ ⟦ b ⟧ (λ x → Σ ⟦ b ⟧ (λ y → < v >)) →
Σ ⟦ b ⟧ (λ z → Σ < z > (λ x → < z > → ⊤ ))
f (_ , (_ , j)) = (v , j , r)
------------------------------------------------------------------------------
-- Examples
-- Now need to write some actual programs...
makeFunc : {b₁ b₂ : B} → (c : b₁ ⟷ b₂) →
b₁ ⟷ DTIMES b₁ (λ x → TIMES (SING (eval c x)) (RECIP x))
makeFunc c = η ◎ slide (λ {_} → (lift c refl) ⊗ id⟷)
-}
------------------------------------------------------------------------------
------------------------------------------------------------------------------
| 35.298507
| 79
| 0.497111
|
0461d168c961cea0b06e1cde29d8dc023f9f037c
| 3,777
|
agda
|
Agda
|
src/DualTail1.agda
|
peterthiemann/dual-session
|
7a8bc1f6b2f808bd2a22c592bd482dbcc271979c
|
[
"BSD-2-Clause"
] | 1
|
2022-02-13T05:43:25.000Z
|
2022-02-13T05:43:25.000Z
|
src/DualTail1.agda
|
peterthiemann/dual-session
|
7a8bc1f6b2f808bd2a22c592bd482dbcc271979c
|
[
"BSD-2-Clause"
] | null | null | null |
src/DualTail1.agda
|
peterthiemann/dual-session
|
7a8bc1f6b2f808bd2a22c592bd482dbcc271979c
|
[
"BSD-2-Clause"
] | 1
|
2019-12-07T16:12:50.000Z
|
2019-12-07T16:12:50.000Z
|
module DualTail1 where
open import Data.Nat
open import Data.Fin using (Fin; zero; suc)
open import Data.Product
open import Function using (id; _∘_)
open import Relation.Binary.PropositionalEquality using (_≡_; refl)
open import Types.Direction
open import Types.IND1 as IND hiding (GType; Type; SType; _≈_; _≈'_)
import Types.COI as COI
open import Types.Tail1
private
variable
n : ℕ
-- instead of unrolling and substituting, we maintain a stack of bodies of recursive types
data Stack {GType : ℕ → Set} : ℕ → Set where
ε : Stack 0
⟪_,_⟫ : Stack {GType} n → GType (suc n) → Stack (suc n)
-- obtain an entry from the stack
-- technically m = n - i, but we don't need to know
get : ∀ {GType} (i : Fin n) → Stack {GType} n → Σ ℕ λ m → Stack {GType} m × GType (suc m)
get zero ⟪ σ , x ⟫ = _ , (σ , x)
get (suc i) ⟪ σ , x ⟫ = get i σ
-- the dual of a stack
dual-stack : Stack {GType} n → Stack {GType} n
dual-stack ε = ε
dual-stack ⟪ σ , g ⟫ = ⟪ dual-stack σ , dualG g ⟫
-- relate a stack entry to the corresponding entry on the dual stack
get-dual-stack : (x : Fin n) (σ : Stack n) →
get x (dual-stack σ) ≡ map id (map dual-stack dualG) (get x σ)
get-dual-stack zero ⟪ σ , x ⟫ = refl
get-dual-stack (suc x) ⟪ σ , x₁ ⟫ = get-dual-stack x σ
-- stacked version of general mapping of inductive session type to COI
ind2coiS : Stack {IND.GType} n → IND.SType n → COI.SType
ind2coiG : Stack {IND.GType} n → IND.GType n → COI.STypeF COI.SType
ind2coiT : Stack {IND.GType} n → IND.TType n → COI.Type
COI.SType.force (ind2coiS σ (gdd G)) = ind2coiG σ G
COI.SType.force (ind2coiS σ (rec G)) = ind2coiG ⟪ σ , G ⟫ G
COI.SType.force (ind2coiS σ (var x)) with get x σ
... | m , σ' , gxs = ind2coiG ⟪ σ' , gxs ⟫ gxs
ind2coiG σ (transmit d T S) = COI.transmit d (ind2coiT σ T) (ind2coiS σ S)
ind2coiG σ (choice d m alt) = COI.choice d m (ind2coiS σ ∘ alt)
ind2coiG σ end = COI.end
ind2coiT σ TUnit = COI.TUnit
ind2coiT σ TInt = COI.TInt
ind2coiT σ (TPair T T₁) = COI.TPair (ind2coiT σ T) (ind2coiT σ T₁)
ind2coiT σ (TChan S) = COI.TChan (ind2coiS σ S)
-- mapping tail recursive session types to coinductive session types
-- relies on a stack to unfold variables on the fly
tail2coiT : Type → COI.Type
tail2coiS : Stack {GType} n → SType n → COI.SType
tail2coiG : Stack {GType} n → GType n → COI.STypeF COI.SType
tail2coiT TUnit = COI.TUnit
tail2coiT TInt = COI.TInt
tail2coiT (TPair t t₁) = COI.TPair (tail2coiT t) (tail2coiT t₁)
tail2coiT (TChan s) = COI.TChan (ind2coiS ε s)
COI.SType.force (tail2coiS σ (gdd g)) = tail2coiG σ g
COI.SType.force (tail2coiS σ (rec g)) = tail2coiG ⟪ σ , g ⟫ g
COI.SType.force (tail2coiS σ (var x))
with get x σ
... | m , σ' , gxs = tail2coiG ⟪ σ' , gxs ⟫ gxs
tail2coiG σ (transmit d t s) = COI.transmit d (tail2coiT t) (tail2coiS σ s)
tail2coiG σ (choice d m alt) = COI.choice d m (tail2coiS σ ∘ alt)
tail2coiG σ end = COI.end
-- get coinductive bisimulation in scope
_≈_ = COI._≈_
_≈'_ = COI._≈'_
-- main proposition
dual-tailS : (σ : Stack {GType} n) (s : SType n) →
COI.dual (tail2coiS σ s) ≈ tail2coiS (dual-stack σ) (dualS s)
dual-tailG : (σ : Stack {GType} n) (g : GType n) →
COI.dualF (tail2coiG σ g) ≈' tail2coiG (dual-stack σ) (dualG g)
COI.Equiv.force (dual-tailS σ (gdd g)) = dual-tailG σ g
COI.Equiv.force (dual-tailS σ (rec g)) = dual-tailG ⟪ σ , g ⟫ g
COI.Equiv.force (dual-tailS σ (var x))
rewrite get-dual-stack x σ
with get x σ
... | m , σ' , g = dual-tailG ⟪ σ' , g ⟫ g
dual-tailG σ (transmit d t s) = COI.eq-transmit (dual-dir d) COI.≈ᵗ-refl (dual-tailS σ s)
dual-tailG σ (choice d m alt) = COI.eq-choice (dual-dir d) (dual-tailS σ ∘ alt)
dual-tailG σ end = COI.eq-end
-- corrolary for SType 0
dual-tail : ∀ s → COI.dual (tail2coiS ε s) ≈ tail2coiS ε (dualS s)
dual-tail = dual-tailS ε
| 31.739496
| 90
| 0.663754
|
13fee178b5e35457a7f347776d51f9aa9cdd0e7b
| 1,283
|
agda
|
Agda
|
vendor/stdlib/src/Data/DifferenceVec.agda
|
isabella232/Lemmachine
|
8ef786b40e4a9ab274c6103dc697dcb658cf3db3
|
[
"MIT"
] | 56
|
2015-01-20T02:11:42.000Z
|
2021-12-21T17:02:19.000Z
|
vendor/stdlib/src/Data/DifferenceVec.agda
|
larrytheliquid/Lemmachine
|
8ef786b40e4a9ab274c6103dc697dcb658cf3db3
|
[
"MIT"
] | 1
|
2022-03-12T12:17:51.000Z
|
2022-03-12T12:17:51.000Z
|
vendor/stdlib/src/Data/DifferenceVec.agda
|
isabella232/Lemmachine
|
8ef786b40e4a9ab274c6103dc697dcb658cf3db3
|
[
"MIT"
] | 3
|
2015-07-21T16:37:58.000Z
|
2022-03-12T11:54:10.000Z
|
------------------------------------------------------------------------
-- Vectors with fast append
------------------------------------------------------------------------
module Data.DifferenceVec where
open import Data.DifferenceNat
open import Data.Vec as V using (Vec)
open import Data.Function
import Data.Nat as N
infixr 5 _∷_ _++_
DiffVec : Set → Diffℕ → Set
DiffVec A m = ∀ {n} → Vec A n → Vec A (m n)
[] : ∀ {A} → DiffVec A 0#
[] = λ k → k
_∷_ : ∀ {A n} → A → DiffVec A n → DiffVec A (suc n)
x ∷ xs = λ k → V._∷_ x (xs k)
[_] : ∀ {A} → A → DiffVec A 1#
[ x ] = x ∷ []
_++_ : ∀ {A m n} → DiffVec A m → DiffVec A n → DiffVec A (m + n)
xs ++ ys = λ k → xs (ys k)
toVec : ∀ {A n} → DiffVec A n → Vec A (toℕ n)
toVec xs = xs V.[]
-- fromVec xs is linear in the length of xs.
fromVec : ∀ {A n} → Vec A n → DiffVec A (fromℕ n)
fromVec xs = λ k → xs ⟨ V._++_ ⟩ k
head : ∀ {A n} → DiffVec A (suc n) → A
head xs = V.head (toVec xs)
tail : ∀ {A n} → DiffVec A (suc n) → DiffVec A n
tail xs = λ k → V.tail (xs k)
take : ∀ {a} m {n} → DiffVec a (fromℕ m + n) → DiffVec a (fromℕ m)
take N.zero xs = []
take (N.suc m) xs = head xs ∷ take m (tail xs)
drop : ∀ {a} m {n} → DiffVec a (fromℕ m + n) → DiffVec a n
drop N.zero xs = xs
drop (N.suc m) xs = drop m (tail xs)
| 25.66
| 72
| 0.493375
|
1ea83136a88308cbaac07074192e8218a5e8055b
| 1,267
|
agda
|
Agda
|
test/Succeed/UnquoteExtLam.agda
|
AntoineAllioux/agda
|
68ec2312961776e415c99d2839e41a92ffe464db
|
[
"BSD-3-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
test/Succeed/UnquoteExtLam.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
test/Succeed/UnquoteExtLam.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
open import Common.Reflection
open import Common.Prelude
open import Common.Equality
open import Agda.Builtin.Sigma
pattern `Nat = def (quote Nat) []
pattern _`→_ a b = pi (vArg a) (abs "_" b)
pattern `Set = sort (lit 0)
pattern `⊥ = def (quote ⊥) []
pattern `zero = con (quote zero) []
pattern `suc n = con (quote suc) (vArg n ∷ [])
prDef : FunDef
prDef =
funDef (`Nat `→ `Nat)
( clause [] [] (extLam ( clause [] (vArg `zero ∷ []) `zero
∷ clause (("x" , vArg `Nat) ∷ []) (vArg (`suc (var 0)) ∷ []) (var 0 [])
∷ []) [])
∷ [] )
magicDef : FunDef
magicDef =
funDef (pi (hArg `Set) (abs "A" (`⊥ `→ var 1 [])))
( clause [] [] (extLam ( absurdClause (("()" , vArg `⊥) ∷ []) (vArg (absurd 0) ∷ [])
∷ []) [])
∷ [] )
unquoteDecl magic = define (vArg magic) magicDef
checkMagic : {A : Set} → ⊥ → A
checkMagic = magic
unquoteDecl pr = define (vArg pr) prDef
magic′ : {A : Set} → ⊥ → A
magic′ = unquote (give (extLam (absurdClause (("()" , vArg `⊥) ∷ []) (vArg (absurd 0) ∷ []) ∷ []) []))
module Pred (A : Set) where
unquoteDecl pr′ = define (vArg pr′) prDef
check : pr 10 ≡ 9
check = refl
check′ : Pred.pr′ ⊥ 10 ≡ 9
check′ = refl
| 26.395833
| 102
| 0.509866
|
2980f84052b6f1a00e58f67b4fb40adffdeafbb1
| 2,569
|
agda
|
Agda
|
BasicIPC/Metatheory/Hilbert-TarskiGluedClosedImplicit.agda
|
mietek/hilbert-gentzen
|
fcd187db70f0a39b894fe44fad0107f61849405c
|
[
"X11"
] | 29
|
2016-07-03T18:51:56.000Z
|
2022-01-01T10:29:18.000Z
|
BasicIPC/Metatheory/Hilbert-TarskiGluedClosedImplicit.agda
|
mietek/hilbert-gentzen
|
fcd187db70f0a39b894fe44fad0107f61849405c
|
[
"X11"
] | 1
|
2018-06-10T09:11:22.000Z
|
2018-06-10T09:11:22.000Z
|
BasicIPC/Metatheory/Hilbert-TarskiGluedClosedImplicit.agda
|
mietek/hilbert-gentzen
|
fcd187db70f0a39b894fe44fad0107f61849405c
|
[
"X11"
] | null | null | null |
module BasicIPC.Metatheory.Hilbert-TarskiGluedClosedImplicit where
open import BasicIPC.Syntax.Hilbert public
open import BasicIPC.Semantics.TarskiGluedClosedImplicit public
open ImplicitSyntax (∅ ⊢_) public
-- Completeness with respect to a particular model, for closed terms only.
module _ {{_ : Model}} where
reify : ∀ {A} → ⊩ A → ∅ ⊢ A
reify {α P} s = syn s
reify {A ▻ B} s = syn s
reify {A ∧ B} s = pair (reify (π₁ s)) (reify (π₂ s))
reify {⊤} s = unit
-- Additional useful equipment.
module _ {{_ : Model}} where
⟪K⟫ : ∀ {A B} → ⊩ A → ⊩ B ▻ A
⟪K⟫ a = app ck (reify a) ⅋ K a
⟪S⟫′ : ∀ {A B C} → ⊩ A ▻ B ▻ C → ⊩ (A ▻ B) ▻ A ▻ C
⟪S⟫′ s₁ = app cs (reify s₁) ⅋ λ s₂ →
app (app cs (reify s₁)) (reify s₂) ⅋ ⟪S⟫ s₁ s₂
_⟪,⟫′_ : ∀ {A B} → ⊩ A → ⊩ B ▻ A ∧ B
_⟪,⟫′_ a = app cpair (reify a) ⅋ _,_ a
-- Soundness with respect to all models, or evaluation.
eval : ∀ {A Γ} → Γ ⊢ A → Γ ⊨ A
eval (var i) γ = lookup i γ
eval (app t u) γ = eval t γ ⟪$⟫ eval u γ
eval ci γ = ci ⅋ I
eval ck γ = ck ⅋ ⟪K⟫
eval cs γ = cs ⅋ ⟪S⟫′
eval cpair γ = cpair ⅋ _⟪,⟫′_
eval cfst γ = cfst ⅋ π₁
eval csnd γ = csnd ⅋ π₂
eval unit γ = ∙
-- Correctness of evaluation with respect to conversion.
eval✓ : ∀ {{_ : Model}} {A Γ} {t t′ : Γ ⊢ A} → t ⋙ t′ → eval t ≡ eval t′
eval✓ refl⋙ = refl
eval✓ (trans⋙ p q) = trans (eval✓ p) (eval✓ q)
eval✓ (sym⋙ p) = sym (eval✓ p)
eval✓ (congapp⋙ p q) = cong² _⟦$⟧_ (eval✓ p) (eval✓ q)
eval✓ (congi⋙ p) = cong I (eval✓ p)
eval✓ (congk⋙ p q) = cong² K (eval✓ p) (eval✓ q)
eval✓ (congs⋙ p q r) = cong³ ⟦S⟧ (eval✓ p) (eval✓ q) (eval✓ r)
eval✓ (congpair⋙ {A} {B} p q) = cong² (_⟦,⟧_ {A} {B}) (eval✓ p) (eval✓ q)
eval✓ (congfst⋙ {A} {B} p) = cong (⟦π₁⟧ {A} {B}) (eval✓ p)
eval✓ (congsnd⋙ {A} {B} p) = cong (⟦π₂⟧ {A} {B}) (eval✓ p)
eval✓ beta▻ₖ⋙ = refl
eval✓ beta▻ₛ⋙ = refl
eval✓ beta∧₁⋙ = refl
eval✓ beta∧₂⋙ = refl
eval✓ eta∧⋙ = refl
eval✓ eta⊤⋙ = refl
-- The canonical model.
private
instance
canon : Model
canon = record
{ ⊩ᵅ_ = λ P → ∅ ⊢ α P
}
-- Completeness with respect to all models, or quotation, for closed terms only.
quot₀ : ∀ {A} → ∅ ⊨ A → ∅ ⊢ A
quot₀ t = reify (t ∙)
-- Normalisation by evaluation, for closed terms only.
norm₀ : ∀ {A} → ∅ ⊢ A → ∅ ⊢ A
norm₀ = quot₀ ∘ eval
-- TODO: Correctness of normalisation with respect to conversion.
| 28.230769
| 80
| 0.511872
|
396718d892013ec0be7d8f885cb0fea80345c50b
| 272
|
agda
|
Agda
|
test/Succeed/Issue1652-2.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 2
|
2019-10-29T09:40:30.000Z
|
2020-09-20T00:28:57.000Z
|
test/Succeed/Issue1652-2.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 3
|
2018-11-14T15:31:44.000Z
|
2019-04-01T19:39:26.000Z
|
test/Succeed/Issue1652-2.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1
|
2015-09-15T14:36:15.000Z
|
2015-09-15T14:36:15.000Z
|
{- Example by Andreas (2015-09-18) -}
{-# OPTIONS --rewriting --confluence-check #-}
open import Common.Prelude
open import Common.Equality
{-# BUILTIN REWRITE _≡_ #-}
module _ (A : Set) where
postulate
plus0p : ∀{x} → (x + zero) ≡ x
{-# REWRITE plus0p #-}
| 17
| 46
| 0.621324
|
9a7d39318724c1838dfb23d77bfece152c67ab84
| 250
|
agda
|
Agda
|
test/Fail/Issue998b.agda
|
alex-mckenna/agda
|
78b62cd24bbd570271a7153e44ad280e52ef3e29
|
[
"BSD-3-Clause"
] | 3
|
2015-03-28T14:51:03.000Z
|
2015-12-07T20:14:00.000Z
|
test/Fail/Issue998b.agda
|
andersk/agda
|
56928ff709dcb931cb9a48c4790e5ed3739e3032
|
[
"BSD-3-Clause"
] | null | null | null |
test/Fail/Issue998b.agda
|
andersk/agda
|
56928ff709dcb931cb9a48c4790e5ed3739e3032
|
[
"BSD-3-Clause"
] | 1
|
2019-03-05T20:02:38.000Z
|
2019-03-05T20:02:38.000Z
|
postulate
A : Set
data D : Set → Set₁ where
d : (A : Set) → D A
f : Set → D A
f A = d A
-- Expected error:
-- A != A of type Set
-- (because one is a variable and one a defined identifier)
-- when checking that the expression d A has type D A
| 17.857143
| 59
| 0.624
|
1eee78bff8ec411aee192e49b1aaca2df5beaaac
| 1,059
|
agda
|
Agda
|
Base/Data/DependentList.agda
|
inc-lc/ilc-agda
|
39bb081c6f192bdb87bd58b4a89291686d2d7d03
|
[
"MIT"
] | 10
|
2015-03-04T06:09:20.000Z
|
2019-07-19T07:06:59.000Z
|
Base/Data/DependentList.agda
|
inc-lc/ilc-agda
|
39bb081c6f192bdb87bd58b4a89291686d2d7d03
|
[
"MIT"
] | 6
|
2015-07-01T18:09:31.000Z
|
2017-05-04T13:53:59.000Z
|
Base/Data/DependentList.agda
|
inc-lc/ilc-agda
|
39bb081c6f192bdb87bd58b4a89291686d2d7d03
|
[
"MIT"
] | 1
|
2016-02-18T12:26:44.000Z
|
2016-02-18T12:26:44.000Z
|
------------------------------------------------------------------------
-- INCREMENTAL λ-CALCULUS
--
-- Reexport Data.List.All from the standard library.
--
-- At one point, we reinvented Data.List.All from the Agda
-- standard library, under the name dependent list. We later
-- replaced our reinvention by this adapter module that just
-- exports the standard library's version with partly different
-- names.
------------------------------------------------------------------------
module Base.Data.DependentList where
open import Data.List.All public
using
( head
; tail
; map
; tabulate
)
renaming
( All to DependentList
; _∷_ to _•_
; [] to ∅
)
-- Maps a binary function over two dependent lists.
-- Should this be in the Agda standard library?
zipWith : ∀ {a p q r} {A : Set a} {P : A → Set p} {Q : A → Set q} {R : A → Set r} →
(f : {a : A} → P a → Q a → R a) →
∀ {xs} → DependentList P xs → DependentList Q xs → DependentList R xs
zipWith f ∅ ∅ = ∅
zipWith f (p • ps) (q • qs) = f p q • zipWith f ps qs
| 30.257143
| 83
| 0.548631
|
4bafbfb38a2d9b2565e684c32af7d9bb5bcf4a86
| 265
|
agda
|
Agda
|
test/fail/BadInductionRecursion1.agda
|
asr/agda-kanso
|
aa10ae6a29dc79964fe9dec2de07b9df28b61ed5
|
[
"MIT"
] | 1
|
2019-11-27T07:26:06.000Z
|
2019-11-27T07:26:06.000Z
|
test/fail/BadInductionRecursion1.agda
|
np/agda-git-experiment
|
20596e9dd9867166a64470dd24ea68925ff380ce
|
[
"MIT"
] | null | null | null |
test/fail/BadInductionRecursion1.agda
|
np/agda-git-experiment
|
20596e9dd9867166a64470dd24ea68925ff380ce
|
[
"MIT"
] | null | null | null |
module BadInductionRecursion1 where
data Unit : Set where
unit : Unit
mutual
data D : Set where
d : forall u -> (D′ u -> D′ u) -> D
D′ : Unit -> Set
D′ unit = D
_·_ : D -> D -> D
d unit f · x = f x
ω : D
ω = d unit (\x -> x · x)
Ω : D
Ω = ω · ω
| 12.045455
| 39
| 0.501887
|
a0ec74f0e3deed159eacd3810506d3a42120f155
| 108
|
agda
|
Agda
|
test/Fail/Impossible.agda
|
cagix/agda
|
cc026a6a97a3e517bb94bafa9d49233b067c7559
|
[
"BSD-2-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
test/Fail/Impossible.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
test/Fail/Impossible.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
module Impossible where
-- The only way to trigger an __IMPOSSIBLE__ that isn't a bug.
{-# IMPOSSIBLE #-}
| 18
| 62
| 0.722222
|
0ecdefc1c504bd23fda29c6733c76562fa9b8d5c
| 688
|
agda
|
Agda
|
src/fot/GroupTheory/AbelianGroup/Base.agda
|
asr/fotc
|
2fc9f2b81052a2e0822669f02036c5750371b72d
|
[
"MIT"
] | 11
|
2015-09-03T20:53:42.000Z
|
2021-09-12T16:09:54.000Z
|
src/fot/GroupTheory/AbelianGroup/Base.agda
|
asr/fotc
|
2fc9f2b81052a2e0822669f02036c5750371b72d
|
[
"MIT"
] | 2
|
2016-10-12T17:28:16.000Z
|
2017-01-01T14:34:26.000Z
|
src/fot/GroupTheory/AbelianGroup/Base.agda
|
asr/fotc
|
2fc9f2b81052a2e0822669f02036c5750371b72d
|
[
"MIT"
] | 3
|
2016-09-19T14:18:30.000Z
|
2018-03-14T08:50:00.000Z
|
------------------------------------------------------------------------------
-- Abelian group base
------------------------------------------------------------------------------
{-# OPTIONS --exact-split #-}
{-# OPTIONS --no-sized-types #-}
{-# OPTIONS --no-universe-polymorphism #-}
{-# OPTIONS --without-K #-}
module GroupTheory.AbelianGroup.Base where
-- We use the group theory base
open import GroupTheory.Base public
------------------------------------------------------------------------------
-- Abelian group theory axioms
-- We only need to add the commutativity axiom.
postulate comm : ∀ a b → a · b ≡ b · a
{-# ATP axiom comm #-}
| 32.761905
| 78
| 0.405523
|
04557016a6765fbdb18bb660de8ad43fd6a43ed4
| 6,832
|
agda
|
Agda
|
examples/ParenDepTac.agda
|
larrytheliquid/agda
|
477c8c37f948e6038b773409358fd8f38395f827
|
[
"MIT"
] | 1
|
2018-10-10T17:08:44.000Z
|
2018-10-10T17:08:44.000Z
|
examples/ParenDepTac.agda
|
np/agda-git-experiment
|
20596e9dd9867166a64470dd24ea68925ff380ce
|
[
"MIT"
] | null | null | null |
examples/ParenDepTac.agda
|
np/agda-git-experiment
|
20596e9dd9867166a64470dd24ea68925ff380ce
|
[
"MIT"
] | 1
|
2022-03-12T11:35:18.000Z
|
2022-03-12T11:35:18.000Z
|
-- Author: Makoto Takeyama
module ParenDepTac where
----------------------------------------------------------------------
-- Preliminary
----------------------------------------------------------------------
infix 3 _≡_
data _≡_ {A : Set}(x : A) : A -> Set where
refl : x ≡ x
subst : {A : Set}(C : A -> Set){x y : A} -> x ≡ y -> C y -> C x
subst C refl c = c
sym : {A : Set}{x y : A} -> x ≡ y -> y ≡ x
sym refl = refl
cong : {A B : Set}(f : A -> B){x y : A} -> x ≡ y -> f x ≡ f y
cong f refl = refl
infixl 2 _`tran`_
_`tran`_ : {A : Set}{x y z : A} -> x ≡ y -> y ≡ z -> x ≡ z
refl `tran` refl = refl
data FALSE : Set where
data TRUE : Set where tt : TRUE
data Nat : Set where
zer : Nat
suc : Nat -> Nat
_+_ : Nat -> Nat -> Nat
zer + n = n
suc m + n = suc ( m + n )
----------------------------------------------------------------------
-- Strings of parentheses
----------------------------------------------------------------------
infix 5 ≪_ ≫_
data Parens : Set where
ε : Parens
≪_ : Parens -> Parens
≫_ : Parens -> Parens
infixr 5 _·_
_·_ : Parens -> Parens -> Parens
ε · ys = ys
≪ xs · ys = ≪ (xs · ys)
≫ xs · ys = ≫ (xs · ys)
·ass : (xs : Parens){ys zs : Parens} -> xs · (ys · zs) ≡ (xs · ys) · zs
·ass ε = refl
·ass (≪ xs) = cong ≪_ (·ass xs)
·ass (≫ xs) = cong ≫_ (·ass xs)
·unitR : {xs : Parens} -> xs · ε ≡ xs
·unitR {ε} = refl
·unitR {≪ xs} = cong ≪_ ·unitR
·unitR {≫ xs} = cong ≫_ ·unitR
_≫' : Parens -> Parens
xs ≫' = xs · ≫ ε
_≪' : Parens -> Parens
xs ≪' = xs · ≪ ε
----------------------------------------------------------------------
-- A poorman's tactics for equational reasoning
----------------------------------------------------------------------
infixr 5 _⊙_
data Exp : Set where
Var : Nat -> Exp
Lit : Parens -> Exp
_⊙_ : Exp -> Exp -> Exp
nf0 : Exp -> Exp -> Exp
nf0 (Var x) e0 = Var x ⊙ e0
nf0 (Lit a) e0 = Lit a ⊙ e0
nf0 (e1 ⊙ e2) e0 = nf0 e1 (nf0 e2 e0)
nf : Exp -> Exp
nf e = nf0 e (Lit ε)
Env = Nat -> Parens
module withEnv(ρ : Env) where
⟦_⟧ : Exp -> Parens
⟦ Var x ⟧ = ρ x
⟦ Lit a ⟧ = a
⟦ e1 ⊙ e2 ⟧ = ⟦ e1 ⟧ · ⟦ e2 ⟧
nfSound0 : (e e0 : Exp) -> ⟦ e ⊙ e0 ⟧ ≡ ⟦ nf0 e e0 ⟧
nfSound0 (Var x) e0 = refl
nfSound0 (Lit a) e0 = refl
nfSound0 (e1 ⊙ e2) e0 = sym (·ass ⟦ e1 ⟧) `tran`
cong (_·_ ⟦ e1 ⟧) (nfSound0 e2 e0) `tran`
nfSound0 e1 (nf0 e2 e0)
nfSound : (e : Exp) -> ⟦ e ⟧ ≡ ⟦ nf e ⟧
nfSound e = sym ·unitR `tran` nfSound0 e (Lit ε)
tac : (e1 e2 : Exp) -> nf e1 ≡ nf e2 -> ⟦ e1 ⟧ ≡ ⟦ e2 ⟧
tac e1 e2 p = nfSound e1 `tran` subst (\x -> ⟦ x ⟧ ≡ ⟦ nf e2 ⟧) p refl `tran`
sym (nfSound e2)
module tac4 (a0 a1 a2 a3 : Parens) where
ρ : Env
ρ zer = a0
ρ (suc zer) = a1
ρ (suc (suc zer)) = a2
ρ (suc (suc (suc zer))) = a3
ρ (suc (suc (suc (suc _ )))) = ε
open module tac4' = withEnv ρ public using (tac)
v0 = Var zer
v1 = Var (suc zer)
v2 = Var (suc (suc zer))
v3 = Var (suc (suc (suc zer)))
[≪] = Lit (≪ ε)
[≫] = Lit (≫ ε)
----------------------------------------------------------------------
-- Derivations of S and T grammars
-- indexed by their underlying strings
----------------------------------------------------------------------
infix 3 _∈S _∈T
infix 4 <_> _⟨_⟩
infixl 4 _•_
data _∈S : Parens -> Set where
εS : ε ∈S
<_> : {xs : Parens} -> xs ∈S -> ≪ xs ≫' ∈S
_•_ : {xs ys : Parens} -> xs ∈S -> ys ∈S -> xs · ys ∈S
data _∈T : Parens -> Set where
εT : ε ∈T
_⟨_⟩ : {xs ys : Parens} -> xs ∈T -> ys ∈T -> xs · ≪ ys ≫' ∈T
----------------------------------------------------------------------
-- Equivalence of S and T grammars
----------------------------------------------------------------------
infixl 3 _○_
_○_ : {xs ys : Parens} -> xs ∈T -> ys ∈T -> xs · ys ∈T
t ○ εT = subst _∈T ·unitR t
_○_ {xs} t (t1 ⟨ t2 ⟩) = subst _∈T (·ass xs) ((t ○ t1) ⟨ t2 ⟩)
S⊂T : {xs : Parens} -> xs ∈S -> xs ∈T
S⊂T εS = εT
S⊂T (< s >) = εT ⟨ S⊂T s ⟩
S⊂T (s1 • s2) = S⊂T s1 ○ S⊂T s2
T⊂S : {xs : Parens} -> xs ∈T -> xs ∈S
T⊂S εT = εS
T⊂S (t1 ⟨ t2 ⟩) = T⊂S t1 • < T⊂S t2 >
----------------------------------------------------------------------
-- Recursively defined test function
----------------------------------------------------------------------
Test : Nat -> Parens -> Set
Test n (≪ xs) = Test (suc n) xs
Test (suc n) (≫ xs) = Test n xs
Test zer (≫ xs) = FALSE
Test (suc n) ε = FALSE
Test zer ε = TRUE
----------------------------------------------------------------------
-- Soundness of Test
----------------------------------------------------------------------
lemTest : (m : Nat)(xs : Parens) -> Test m xs ->
(n : Nat)(ys : Parens) -> Test n ys ->
Test (m + n) (xs · ys)
lemTest m (≪ xs) p = lemTest (suc m) xs p
lemTest (suc m) (≫ xs) p = lemTest m xs p
lemTest zer (≫ xs) ()
lemTest (suc m) ε ()
lemTest zer ε tt = \ n ys q -> q
sound : {xs : Parens} -> xs ∈S -> Test zer xs
sound εS = tt
sound (<_>{xs} s) = lemTest zer xs (sound s) (suc zer) (≫ ε) tt
sound (_•_{xs}{ys} s1 s2) = lemTest zer xs (sound s1) zer ys (sound s2)
----------------------------------------------------------------------
-- Completeness of Test
----------------------------------------------------------------------
complete : (xs : Parens) -> Test zer xs -> xs ∈S
complete xs0 p0 = parse init εS xs0 p0
where
data St : Nat -> Parens -> Set where
init : St zer ε
_*_≪ : {n : Nat} ->
{xs : Parens} -> St n xs ->
{ys : Parens} -> ys ∈S ->
St (suc n) (xs · ys ≪')
stPar : forall {n xs} -> St n xs -> Parens
stPar {xs = xs} _ = xs
∈SPar : forall {xs} -> xs ∈S -> Parens
∈SPar {xs} _ = xs
parse : {n : Nat} ->
{xs : Parens} -> St n xs ->
{ys : Parens} -> ys ∈S ->
(zs : Parens) -> Test n zs ->
xs · ys · zs ∈S
-- <SHIFT> (st , s , ≪ zs ) ↦ (st * s ≪ , εS , zs)
-- <REDUCE> (st * s3 ≪ , s , ≫ zs ) ↦ (st , s3 • < s > , zs)
-- <FINISH> (init , s , ε ) ↦ s
parse {_} {xs} st {ys} s (≪ zs) p = subst _∈S eq (parse (st * s ≪) εS zs p)
where open module foo = tac4 xs ys zs ε
eq = tac (v0 ⊙ v1 ⊙ [≪] ⊙ v2) ((v0 ⊙ v1 ⊙ [≪]) ⊙ v2) refl
parse (st * s3 ≪) {ys} s (≫ zs) p
= subst _∈S eq (parse st (s3 • < s >) zs p)
where open module foo = tac4 (stPar st) (∈SPar s3) ys zs
eq = tac ((v0 ⊙ v1 ⊙ [≪]) ⊙ v2 ⊙ [≫] ⊙ v3)
( v0 ⊙ (v1 ⊙ [≪] ⊙ v2 ⊙ [≫]) ⊙ v3) refl
parse ( _ * _ ≪) _ ε ()
parse init _ (≫ zs) ()
parse init s ε tt = subst _∈S ·unitR s
| 28.949153
| 79
| 0.384807
|
591ce2add6f3a556dea4a21a18db0f993815df61
| 3,184
|
agda
|
Agda
|
test/Succeed/Issue1435.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
test/Succeed/Issue1435.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
test/Succeed/Issue1435.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
-- Reported by nils.anders.danielsson, Feb 17, 2015
-- See also Issue 292 , Issue 1406 , and Issue 1427.
-- The code below is accepted by Agda 2.4.2.2, but not by the current
-- maintenance or master branches.
data Box (A : Set) : Set where
[_] : A → Box A
data _≡_ (A : Set) : Set → Set₁ where
refl : A ≡ A
data _≅_ {A : Set₁} (x : A) : {B : Set₁} → B → Set₂ where
refl : x ≅ x
-- C could be a typed DSEL.
data C : Set → Set₁ where
c₁ c₂ : (A : Set) → C (Box A)
-- If A is considered forced, the code no longer type-checks.
-- D could be some kind of semantics for C.
data D : {A : Set} → C A → Set₂ where
d₁ : (A : Set) → D (c₁ A)
d₂ : (A : Set) → D (c₂ A)
module Doesn't-work where
-- Let's try to write an eliminator for the part of the semantics
-- that concerns c₁ programs. The basic approach doesn't work:
D-elim-c₁ : (P : {A : Set} → D (c₁ A) → Set₂) →
((A : Set) → P (d₁ A)) →
{A : Set} (x : D (c₁ A)) → P x
D-elim-c₁ P p (d₁ A) = p A
-- The following trick also fails (but for some reason the absurd
-- case is accepted):
-- Jesper 2015-12-18 update: this is no longer accepted by the new unifier.
--D-elim-c₁-helper :
-- (P : {A B : Set} {c : C A} →
-- D c → A ≡ Box B → c ≅ c₁ B → Set₂) →
-- ((A : Set) → P (d₁ A) refl refl) →
-- {A B : Set} {c : C A}
-- (x : D c) (eq₂ : c ≅ c₁ B) (eq₁ : A ≡ Box B) → P x eq₁ eq₂
--D-elim-c₁-helper P p (d₂ A) () _
--D-elim-c₁-helper P p (d₁ A) refl refl = p A
module Works where
-- I can define the eliminators by first defining and proving no
-- confusion (following McBride, Goguen and McKinna). However, this
-- requires a fair amount of work, and easy dependent pattern
-- matching is arguably one of the defining features of Agda.
--
-- A quote from "A Few Constructions on Constructors": "The Epigram
-- language and system [25, 23] takes these constructions for
-- granted. We see no reason why the users of other systems should
-- work harder than we do."
data ⊥ : Set₁ where
No-confusion : ∀ {A B} → C A → C B → Set₁
No-confusion (c₁ A) (c₁ B) = A ≡ B
No-confusion (c₂ A) (c₂ B) = A ≡ B
No-confusion _ _ = ⊥
no-confusion :
∀ {A B} (x : C A) (y : C B) → A ≡ B → x ≅ y → No-confusion x y
no-confusion (c₁ A) .(c₁ A) refl refl = refl
no-confusion (c₂ A) .(c₂ A) refl refl = refl
D-elim-c₁-helper :
(P : {A B : Set} {c : C A} →
D c → A ≡ Box B → c ≅ c₁ B → Set₂) →
((A : Set) → P (d₁ A) refl refl) →
{A B : Set} {c : C A}
(x : D c) (eq₂ : c ≅ c₁ B) (eq₁ : A ≡ Box B) → P x eq₁ eq₂
D-elim-c₁-helper P p (d₁ A) eq₂ eq₁ with no-confusion _ _ eq₁ eq₂
D-elim-c₁-helper P p (d₁ B) refl refl | refl = p B
D-elim-c₁-helper P p (d₂ A) eq₂ eq₁ with no-confusion _ _ eq₁ eq₂
D-elim-c₁-helper P p (d₂ A) eq₂ eq₁ | ()
cast : {A B : Set} {x : C A} {y : C B} →
A ≡ B → x ≅ y → D x → D y
cast refl refl x = x
D-elim-c₁ :
(P : {A : Set} → D (c₁ A) → Set₂) →
((A : Set) → P (d₁ A)) →
{A : Set} (x : D (c₁ A)) → P x
D-elim-c₁ P p x =
D-elim-c₁-helper (λ x eq₁ eq₂ → P (cast eq₁ eq₂ x)) p x refl refl
-- should type-check
| 32.161616
| 77
| 0.557161
|
3d7ae9d208b14f15a1346d65bf3cff1ebda6153e
| 2,370
|
agda
|
Agda
|
Numeral/Natural/LinearSearch.agda
|
Lolirofle/stuff-in-agda
|
70f4fba849f2fd779c5aaa5af122ccb6a5b271ba
|
[
"MIT"
] | 6
|
2020-04-07T17:58:13.000Z
|
2022-02-05T06:53:22.000Z
|
Numeral/Natural/LinearSearch.agda
|
Lolirofle/stuff-in-agda
|
70f4fba849f2fd779c5aaa5af122ccb6a5b271ba
|
[
"MIT"
] | null | null | null |
Numeral/Natural/LinearSearch.agda
|
Lolirofle/stuff-in-agda
|
70f4fba849f2fd779c5aaa5af122ccb6a5b271ba
|
[
"MIT"
] | null | null | null |
module Numeral.Natural.LinearSearch where
open import Data.Boolean
open import Data.Boolean.Stmt
open import Data.List
import Data.List.Functions as List
open import Data.List.Relation.Membership using (_∈_)
open import Data.List.Relation.Membership.Proofs
open import Data.List.Relation.Quantification
open import Data.List.Relation.Quantification.Proofs
open import Data.List.Sorting
open import Functional
open import Logic.Propositional
open import Numeral.Finite
import Numeral.Finite.LinearSearch as 𝕟
open import Numeral.Natural
open import Numeral.Natural.Oper
open import Numeral.Natural.Oper.Comparisons
open import Numeral.Natural.Relation.Order
open import Relator.Equals
open import Relator.Equals.Proofs.Equiv
open import Structure.Function
private variable a b n i j : ℕ
private variable f : ℕ → Bool
{-
findBoundedMin : ℕ → ℕ → (ℕ → Bool) → Option(ℕ)
findBoundedMin a b f = Option.map 𝕟-to-ℕ (𝕟.findMin{b −₀ a}(f ∘ (_+ a) ∘ 𝕟-to-ℕ))
findBoundedMin-None-correctness : (a < b) → (findBoundedMin a b f ≡ None) ↔ (∀{i} → (a ≤ i) → (i < b) → IsFalse(f(i)))
findBoundedMin-None-correctness{a}{b}{f} ab
with [↔]-intro l r ← 𝕟.findMin-None-correctness{b −₀ a}{f ∘ (_+ a) ∘ 𝕟-to-ℕ}
= [↔]-intro (\p → congruence₁(Option.map 𝕟-to-ℕ) (l (\{i} → p ([≤]-of-[+]ᵣ {𝕟-to-ℕ i}) {![<]-with-[+]-weak ([∨]-introₗ ([∧]-intro ? ?))!}))) (\p{i} ai ib → {!r ? {?}!})
-}
findBoundedAll : ℕ → ℕ → (ℕ → Bool) → List(ℕ)
findBoundedAll a b f = List.map ((_+ a) ∘ 𝕟-to-ℕ) (𝕟.findAll{b −₀ a} (f ∘ (_+ a) ∘ 𝕟-to-ℕ))
findBoundedAll-correctness : AllElements(IsTrue ∘ f)(findBoundedAll a b f)
findBoundedAll-correctness {f} {a} {b} with 𝕟.findAll{b −₀ a} (f ∘ (_+ a) ∘ 𝕟-to-ℕ) | 𝕟.findAll-correctness{b −₀ a}{f ∘ (_+ a) ∘ 𝕟-to-ℕ}
... | ∅ | ∅ = ∅
... | _ ⊰ _ | p ⊰ ps = p ⊰ AllElements-mapᵣ ((_+ a) ∘ 𝕟-to-ℕ) id ps
postulate findBoundedAll-completeness : IsTrue(f(i)) → (a ≤ i) → (i < b) → (i ∈ findBoundedAll a b f)
-- findBoundedAll-completeness {f}{i}{a}{b} ai ib fi = {![∈]-map {f = 𝕟-to-ℕ} (𝕟.findAll-completeness{b −₀ a}{f ∘ (_+ a) ∘ 𝕟-to-ℕ}{ℕ-to-𝕟 (i −₀ a) ⦃ ? ⦄} ?)!}
postulate findBoundedAll-emptyness : (∀{i} → (a ≤ i) → (i < b) → IsFalse(f(i))) ↔ (findBoundedAll a b f ≡ ∅)
postulate findBoundedAll-sorted : Sorted(_≤?_)(findBoundedAll a b f)
postulate findBoundedAll-membership : (i ∈ findBoundedAll a b f) ↔ ((a ≤ i) ∧ (i < b) ∧ IsTrue(f(i)))
| 43.888889
| 170
| 0.650633
|
04ed442343906bbba934b24050f0868e2c6dd7d6
| 13,299
|
agda
|
Agda
|
agda/Number/Operations/Specification.agda
|
mchristianl/synthetic-reals
|
10206b5c3eaef99ece5d18bf703c9e8b2371bde4
|
[
"MIT"
] | 3
|
2020-07-31T18:15:26.000Z
|
2022-02-19T12:15:21.000Z
|
agda/Number/Operations/Specification.agda
|
mchristianl/synthetic-reals
|
10206b5c3eaef99ece5d18bf703c9e8b2371bde4
|
[
"MIT"
] | null | null | null |
agda/Number/Operations/Specification.agda
|
mchristianl/synthetic-reals
|
10206b5c3eaef99ece5d18bf703c9e8b2371bde4
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --cubical --no-import-sorts --allow-unsolved-metas #-}
module Number.Operations.Specification where
open import Cubical.Foundations.Everything renaming (_⁻¹ to _⁻¹ᵖ; assoc to ∙-assoc)
open import Cubical.Data.Unit.Base -- Unit
open import Number.Postulates
open import Number.Base
open ℕⁿ
open ℤᶻ
open ℚᶠ
open ℝʳ
open ℂᶜ
open PatternsType
-- workflow:
-- 1. split on the both positivities at once
-- 2. add a general clause on top
-- 3. check file
-- 4. remove all unreachable clauses and goto 2.
-- feel free to remove too many clauses and let agda display the missing ones
+-Positivityᵒʳ : PositivityKindOrderedRing → PositivityKindOrderedRing → PositivityKindOrderedRing
+-Positivityᵒʳ _ X = X
+-Positivityᵒʳ X _ = X
+-Positivityᵒʳ _ X⁺⁻ = X
+-Positivityᵒʳ X⁺⁻ _ = X
-- clauses with same sign
+-Positivityᵒʳ X₀⁺ X₀⁺ = X₀⁺
+-Positivityᵒʳ X₀⁻ X₀⁻ = X₀⁻
+-Positivityᵒʳ X₀⁺ X⁺ = X⁺
+-Positivityᵒʳ X⁺ X₀⁺ = X⁺
+-Positivityᵒʳ X⁺ X⁺ = X⁺
+-Positivityᵒʳ X₀⁻ X⁻ = X⁻
+-Positivityᵒʳ X⁻ X⁻ = X⁻
+-Positivityᵒʳ X⁻ X₀⁻ = X⁻
-- remaining clauses with alternating sign
+-Positivityᵒʳ X₀⁻ X₀⁺ = X
+-Positivityᵒʳ X₀⁺ X₀⁻ = X
+-Positivityᵒʳ X⁻ X₀⁺ = X
+-Positivityᵒʳ X₀⁺ X⁻ = X
+-Positivityᵒʳ X⁻ X⁺ = X
+-Positivityᵒʳ X⁺ X⁻ = X
+-Positivityᵒʳ X₀⁻ X⁺ = X
+-Positivityᵒʳ X⁺ X₀⁻ = X
+-Positivityᶠ : PositivityKindField → PositivityKindField → PositivityKindField
-- positivity information is lost after _+_ on a field
+-Positivityᶠ x y = X
+-Positivityʰ : (l : NumberKind) → PositivityKindType l → PositivityKindType l → PositivityKindType l
+-Positivityʰ isNat = +-Positivityᵒʳ
+-Positivityʰ isInt = +-Positivityᵒʳ
+-Positivityʰ isRat = +-Positivityᵒʳ
+-Positivityʰ isReal = +-Positivityᵒʳ
+-Positivityʰ isComplex = +-Positivityᶠ
·-Positivityᵒʳ : PositivityKindOrderedRing → PositivityKindOrderedRing → PositivityKindOrderedRing
·-Positivityᵒʳ _ X = X
·-Positivityᵒʳ X _ = X
·-Positivityᵒʳ X₀⁺ X⁺⁻ = X
·-Positivityᵒʳ X⁺⁻ X₀⁺ = X
·-Positivityᵒʳ X₀⁻ X⁺⁻ = X
·-Positivityᵒʳ X⁺⁻ X₀⁻ = X
-- multiplying nonzero numbers gives a nonzero number
·-Positivityᵒʳ X⁺⁻ X⁺⁻ = X⁺⁻
·-Positivityᵒʳ X⁺ X⁺⁻ = X⁺⁻
·-Positivityᵒʳ X⁺⁻ X⁺ = X⁺⁻
·-Positivityᵒʳ X⁻ X⁺⁻ = X⁺⁻
·-Positivityᵒʳ X⁺⁻ X⁻ = X⁺⁻
-- multiplying positive numbers gives a positive number
·-Positivityᵒʳ X₀⁺ X₀⁺ = X₀⁺
·-Positivityᵒʳ X₀⁺ X⁺ = X₀⁺
·-Positivityᵒʳ X⁺ X₀⁺ = X₀⁺
·-Positivityᵒʳ X⁺ X⁺ = X⁺
-- multiplying negative numbers gives a positive number
·-Positivityᵒʳ X₀⁻ X⁻ = X₀⁺
·-Positivityᵒʳ X⁻ X₀⁻ = X₀⁺
·-Positivityᵒʳ X₀⁻ X₀⁻ = X₀⁺
·-Positivityᵒʳ X⁻ X⁻ = X⁺
-- multiplying a positive and a negative number gives a negative number
·-Positivityᵒʳ X⁻ X₀⁺ = X₀⁻
·-Positivityᵒʳ X₀⁺ X⁻ = X₀⁻
·-Positivityᵒʳ X₀⁻ X⁺ = X₀⁻
·-Positivityᵒʳ X⁺ X₀⁻ = X₀⁻
·-Positivityᵒʳ X₀⁻ X₀⁺ = X₀⁻
·-Positivityᵒʳ X₀⁺ X₀⁻ = X₀⁻
·-Positivityᵒʳ X⁻ X⁺ = X⁻
·-Positivityᵒʳ X⁺ X⁻ = X⁻
·-Positivityᶠ : PositivityKindField → PositivityKindField → PositivityKindField
·-Positivityᶠ X X = X
·-Positivityᶠ X X⁺⁻ = X
·-Positivityᶠ X⁺⁻ X = X
-- multiplying nonzero numbers gives a nonzero number
·-Positivityᶠ X⁺⁻ X⁺⁻ = X⁺⁻
·-Positivityʰ : (l : NumberKind) → PositivityKindType l → PositivityKindType l → PositivityKindType l
·-Positivityʰ isNat = ·-Positivityᵒʳ
·-Positivityʰ isInt = ·-Positivityᵒʳ
·-Positivityʰ isRat = ·-Positivityᵒʳ
·-Positivityʰ isReal = ·-Positivityᵒʳ
·-Positivityʰ isComplex = ·-Positivityᶠ
min-Positivityᵒʳ : PositivityKindOrderedRing → PositivityKindOrderedRing → PositivityKindOrderedRing
min-Positivityᵒʳ X X = X
min-Positivityᵒʳ X X⁺⁻ = X
min-Positivityᵒʳ X X₀⁺ = X
min-Positivityᵒʳ X X⁺ = X
min-Positivityᵒʳ X X⁻ = X⁻
min-Positivityᵒʳ X X₀⁻ = X₀⁻
min-Positivityᵒʳ X⁺⁻ X = X
min-Positivityᵒʳ X⁺⁻ X⁺⁻ = X⁺⁻
min-Positivityᵒʳ X⁺⁻ X₀⁺ = X
min-Positivityᵒʳ X⁺⁻ X⁺ = X⁺⁻
min-Positivityᵒʳ X⁺⁻ X⁻ = X⁻
min-Positivityᵒʳ X⁺⁻ X₀⁻ = X₀⁻
min-Positivityᵒʳ X₀⁺ X = X
min-Positivityᵒʳ X₀⁺ X⁺⁻ = X
min-Positivityᵒʳ X₀⁺ X₀⁺ = X₀⁺
min-Positivityᵒʳ X₀⁺ X⁺ = X₀⁺
min-Positivityᵒʳ X₀⁺ X⁻ = X⁻
min-Positivityᵒʳ X₀⁺ X₀⁻ = X₀⁻
min-Positivityᵒʳ X⁺ X = X
min-Positivityᵒʳ X⁺ X⁺⁻ = X⁺⁻
min-Positivityᵒʳ X⁺ X₀⁺ = X₀⁺
min-Positivityᵒʳ X⁺ X⁺ = X⁺
min-Positivityᵒʳ X⁺ X⁻ = X⁻
min-Positivityᵒʳ X⁺ X₀⁻ = X₀⁻
min-Positivityᵒʳ X⁻ X = X⁻
min-Positivityᵒʳ X⁻ X⁺⁻ = X⁻
min-Positivityᵒʳ X⁻ X₀⁺ = X⁻
min-Positivityᵒʳ X⁻ X⁺ = X⁻
min-Positivityᵒʳ X⁻ X⁻ = X⁻
min-Positivityᵒʳ X⁻ X₀⁻ = X⁻
min-Positivityᵒʳ X₀⁻ X = X₀⁻
min-Positivityᵒʳ X₀⁻ X⁺⁻ = X₀⁻
min-Positivityᵒʳ X₀⁻ X₀⁺ = X₀⁻
min-Positivityᵒʳ X₀⁻ X⁺ = X₀⁻
min-Positivityᵒʳ X₀⁻ X⁻ = X⁻
min-Positivityᵒʳ X₀⁻ X₀⁻ = X₀⁻
max-Positivityᵒʳ : PositivityKindOrderedRing → PositivityKindOrderedRing → PositivityKindOrderedRing
max-Positivityᵒʳ X X = X
max-Positivityᵒʳ X X⁺⁻ = X
max-Positivityᵒʳ X X₀⁺ = X₀⁺
max-Positivityᵒʳ X X⁺ = X⁺
max-Positivityᵒʳ X X⁻ = X
max-Positivityᵒʳ X X₀⁻ = X
max-Positivityᵒʳ X⁺⁻ X = X
max-Positivityᵒʳ X⁺⁻ X⁺⁻ = X⁺⁻
max-Positivityᵒʳ X⁺⁻ X₀⁺ = X₀⁺
max-Positivityᵒʳ X⁺⁻ X⁺ = X⁺
max-Positivityᵒʳ X⁺⁻ X⁻ = X⁺⁻
max-Positivityᵒʳ X⁺⁻ X₀⁻ = X
max-Positivityᵒʳ X₀⁺ X = X₀⁺
max-Positivityᵒʳ X₀⁺ X⁺⁻ = X₀⁺
max-Positivityᵒʳ X₀⁺ X₀⁺ = X₀⁺
max-Positivityᵒʳ X₀⁺ X⁺ = X⁺
max-Positivityᵒʳ X₀⁺ X⁻ = X₀⁺
max-Positivityᵒʳ X₀⁺ X₀⁻ = X₀⁺
max-Positivityᵒʳ X⁺ X = X⁺
max-Positivityᵒʳ X⁺ X⁺⁻ = X⁺
max-Positivityᵒʳ X⁺ X₀⁺ = X⁺
max-Positivityᵒʳ X⁺ X⁺ = X⁺
max-Positivityᵒʳ X⁺ X⁻ = X⁺
max-Positivityᵒʳ X⁺ X₀⁻ = X⁺
max-Positivityᵒʳ X⁻ X = X
max-Positivityᵒʳ X⁻ X⁺⁻ = X⁺⁻
max-Positivityᵒʳ X⁻ X₀⁺ = X₀⁺
max-Positivityᵒʳ X⁻ X⁺ = X⁺
max-Positivityᵒʳ X⁻ X⁻ = X⁻
max-Positivityᵒʳ X⁻ X₀⁻ = X₀⁻
max-Positivityᵒʳ X₀⁻ X = X
max-Positivityᵒʳ X₀⁻ X⁺⁻ = X
max-Positivityᵒʳ X₀⁻ X₀⁺ = X₀⁺
max-Positivityᵒʳ X₀⁻ X⁺ = X⁺
max-Positivityᵒʳ X₀⁻ X⁻ = X₀⁻
max-Positivityᵒʳ X₀⁻ X₀⁻ = X₀⁻
min-Positivityʰ : (l : NumberKind) → PositivityKindType l → PositivityKindType l → PositivityKindType l
min-Positivityʰ isNat = min-Positivityᵒʳ
min-Positivityʰ isInt = min-Positivityᵒʳ
min-Positivityʰ isRat = min-Positivityᵒʳ
min-Positivityʰ isReal = min-Positivityᵒʳ
min-Positivityʰ isComplex = λ _ _ → X -- doesn't matter since `min` is undefined for ℂ
max-Positivityʰ : (l : NumberKind) → PositivityKindType l → PositivityKindType l → PositivityKindType l
max-Positivityʰ isNat = max-Positivityᵒʳ
max-Positivityʰ isInt = max-Positivityᵒʳ
max-Positivityʰ isRat = max-Positivityᵒʳ
max-Positivityʰ isReal = max-Positivityᵒʳ
max-Positivityʰ isComplex = λ _ _ → X -- doesn't matter since `max` is undefined for ℂ
+-Types : NumberProp → NumberProp → NumberProp
+-Types (level₀ , pos₀) (level₁ , pos₁) =
let level = maxₙₗ level₀ level₁
in level , +-Positivityʰ level (coerce-PositivityKind level₀ level pos₀) (coerce-PositivityKind level₁ level pos₁)
·-Types : NumberProp → NumberProp → NumberProp
·-Types (level₀ , pos₀) (level₁ , pos₁) =
let level = maxₙₗ level₀ level₁
in level , ·-Positivityʰ level (coerce-PositivityKind level₀ level pos₀) (coerce-PositivityKind level₁ level pos₁)
⁻¹-Types : ∀{l p} → Number (l , p) → Type (ℓ-max (NumberLevel (maxₙₗ l isRat)) (NumberKindProplevel l))
-- numbers that can be zero need an additional apartness proof
⁻¹-Types {isNat } {X } (x ,, p) = ∀{{ q : x #ⁿ 0ⁿ }} → Number (isRat , X⁺⁻)
⁻¹-Types {isInt } {X } (x ,, p) = ∀{{ q : x #ᶻ 0ᶻ }} → Number (isRat , X⁺⁻)
⁻¹-Types {isRat } {X } (x ,, p) = ∀{{ q : x #ᶠ 0ᶠ }} → Number (isRat , X⁺⁻)
⁻¹-Types {isReal } {X } (x ,, p) = ∀{{ q : x #ʳ 0ʳ }} → Number (isReal , X⁺⁻)
⁻¹-Types {isComplex} {X } (x ,, p) = ∀{{ q : x #ᶜ 0ᶜ }} → Number (isComplex , X⁺⁻)
⁻¹-Types {isNat } {X₀⁺} (x ,, p) = ∀{{ q : x #ⁿ 0ⁿ }} → Number (isRat , X⁺ )
⁻¹-Types {isInt } {X₀⁺} (x ,, p) = ∀{{ q : x #ᶻ 0ᶻ }} → Number (isRat , X⁺ )
⁻¹-Types {isRat } {X₀⁺} (x ,, p) = ∀{{ q : x #ᶠ 0ᶠ }} → Number (isRat , X⁺ )
⁻¹-Types {isReal } {X₀⁺} (x ,, p) = ∀{{ q : x #ʳ 0ʳ }} → Number (isReal , X⁺ )
⁻¹-Types {isNat } {X₀⁻} (x ,, p) = ∀{{ q : x #ⁿ 0ⁿ }} → Number (isRat , X⁻ )
⁻¹-Types {isInt } {X₀⁻} (x ,, p) = ∀{{ q : x #ᶻ 0ᶻ }} → Number (isRat , X⁻ )
⁻¹-Types {isRat } {X₀⁻} (x ,, p) = ∀{{ q : x #ᶠ 0ᶠ }} → Number (isRat , X⁻ )
⁻¹-Types {isReal } {X₀⁻} (x ,, p) = ∀{{ q : x #ʳ 0ʳ }} → Number (isReal , X⁻ )
-- positive, negative and nonzero numbers are already apart from zero
⁻¹-Types {isNat } {X⁺⁻} (x ,, p) = ∀{{ q : Lift {j = NumberKindProplevel isNat } Unit }} → Number (isRat , X⁺⁻)
⁻¹-Types {isNat } {X⁺ } (x ,, p) = ∀{{ q : Lift {j = NumberKindProplevel isNat } Unit }} → Number (isRat , X⁺ )
⁻¹-Types {isInt } {X⁺⁻} (x ,, p) = ∀{{ q : Lift {j = NumberKindProplevel isInt } Unit }} → Number (isRat , X⁺⁻)
⁻¹-Types {isInt } {X⁺ } (x ,, p) = ∀{{ q : Lift {j = NumberKindProplevel isInt } Unit }} → Number (isRat , X⁺ )
⁻¹-Types {isInt } {X⁻ } (x ,, p) = ∀{{ q : Lift {j = NumberKindProplevel isInt } Unit }} → Number (isRat , X⁻ )
⁻¹-Types {isRat } {X⁺⁻} (x ,, p) = ∀{{ q : Lift {j = NumberKindProplevel isRat } Unit }} → Number (isRat , X⁺⁻)
⁻¹-Types {isRat } {X⁺ } (x ,, p) = ∀{{ q : Lift {j = NumberKindProplevel isRat } Unit }} → Number (isRat , X⁺ )
⁻¹-Types {isRat } {X⁻ } (x ,, p) = ∀{{ q : Lift {j = NumberKindProplevel isRat } Unit }} → Number (isRat , X⁻ )
⁻¹-Types {isReal } {X⁺⁻} (x ,, p) = ∀{{ q : Lift {j = NumberKindProplevel isReal } Unit }} → Number (isReal , X⁺⁻)
⁻¹-Types {isReal } {X⁺ } (x ,, p) = ∀{{ q : Lift {j = NumberKindProplevel isReal } Unit }} → Number (isReal , X⁺ )
⁻¹-Types {isReal } {X⁻ } (x ,, p) = ∀{{ q : Lift {j = NumberKindProplevel isReal } Unit }} → Number (isReal , X⁻ )
⁻¹-Types {isComplex} {X⁺⁻} (x ,, p) = ∀{{ q : Lift {j = NumberKindProplevel isComplex} Unit }} → Number (isComplex , X⁺⁻)
-Types : ∀{l p} → Number (l , p) → Type (NumberLevel (maxₙₗ l isInt))
-Types {isInt } {X } (x ,, p) = Number (isInt , X)
-Types {isRat } {X } (x ,, p) = Number (isRat , X)
-Types {isReal } {X } (x ,, p) = Number (isReal , X)
-Types {isComplex} {X } (x ,, p) = Number (isComplex , X)
-- the negative of a natural number is a Nonpositive integer
-Types {isNat } {X } (x ,, p) = Number (isInt , X₀⁻)
-- the negative of a nonzero number is a nonzero number
-Types {isNat } {X⁺⁻} (x ,, p) = Number (isInt , X⁺⁻)
-Types {isInt } {X⁺⁻} (x ,, p) = Number (isInt , X⁺⁻)
-Types {isRat } {X⁺⁻} (x ,, p) = Number (isRat , X⁺⁻)
-Types {isReal } {X⁺⁻} (x ,, p) = Number (isReal , X⁺⁻)
-Types {isComplex} {X⁺⁻} (x ,, p) = Number (isComplex , X⁺⁻)
-- the negative of a positive number is a negative number
-Types {isNat } {X₀⁺} (x ,, p) = Number (isInt , X₀⁻)
-Types {isInt } {X₀⁺} (x ,, p) = Number (isInt , X₀⁻)
-Types {isRat } {X₀⁺} (x ,, p) = Number (isRat , X₀⁻)
-Types {isReal } {X₀⁺} (x ,, p) = Number (isReal , X₀⁻)
-Types {isNat } {X⁺ } (x ,, p) = Number (isInt , X⁻ )
-Types {isInt } {X⁺ } (x ,, p) = Number (isInt , X⁻ )
-Types {isRat } {X⁺ } (x ,, p) = Number (isRat , X⁻ )
-Types {isReal } {X⁺ } (x ,, p) = Number (isReal , X⁻ )
-- the negative of a negative number is a positive number
-Types {isNat } {X₀⁻} (x ,, p) = Number (isInt , X₀⁺)
-Types {isInt } {X₀⁻} (x ,, p) = Number (isInt , X₀⁺)
-Types {isRat } {X₀⁻} (x ,, p) = Number (isRat , X₀⁺)
-Types {isReal } {X₀⁻} (x ,, p) = Number (isReal , X₀⁺)
-Types {isInt } {X⁻ } (x ,, p) = Number (isInt , X⁺ )
-Types {isRat } {X⁻ } (x ,, p) = Number (isRat , X⁺ )
-Types {isReal } {X⁻ } (x ,, p) = Number (isReal , X⁺ )
abs-Types : ∀{l p} → Number (l , p) → Type (NumberLevel (minₙₗ l isReal))
abs-Types {isNat } {X } (x ,, p) = Number (isNat , X₀⁺)
abs-Types {isNat } {X⁺⁻} (x ,, p) = Number (isNat , X⁺ )
abs-Types {isNat } {X₀⁺} (x ,, p) = Number (isNat , X₀⁺)
abs-Types {isNat } {X⁺ } (x ,, p) = Number (isNat , X⁺ )
abs-Types {isNat } {X₀⁻} (x ,, p) = Number (isNat , X₀⁺)
abs-Types {isInt } {X } (x ,, p) = Number (isInt , X₀⁺)
abs-Types {isInt } {X⁺⁻} (x ,, p) = Number (isInt , X⁺ )
abs-Types {isInt } {X₀⁺} (x ,, p) = Number (isInt , X₀⁺)
abs-Types {isInt } {X⁺ } (x ,, p) = Number (isInt , X⁺ )
abs-Types {isInt } {X⁻ } (x ,, p) = Number (isInt , X⁺ )
abs-Types {isInt } {X₀⁻} (x ,, p) = Number (isInt , X₀⁺)
abs-Types {isRat } {X } (x ,, p) = Number (isRat , X₀⁺)
abs-Types {isRat } {X⁺⁻} (x ,, p) = Number (isRat , X⁺ )
abs-Types {isRat } {X₀⁺} (x ,, p) = Number (isRat , X₀⁺)
abs-Types {isRat } {X⁺ } (x ,, p) = Number (isRat , X⁺ )
abs-Types {isRat } {X⁻ } (x ,, p) = Number (isRat , X⁺ )
abs-Types {isRat } {X₀⁻} (x ,, p) = Number (isRat , X₀⁺)
abs-Types {isReal } {X } (x ,, p) = Number (isReal , X₀⁺)
abs-Types {isReal } {X⁺⁻} (x ,, p) = Number (isReal , X⁺ )
abs-Types {isReal } {X₀⁺} (x ,, p) = Number (isReal , X₀⁺)
abs-Types {isReal } {X⁺ } (x ,, p) = Number (isReal , X⁺ )
abs-Types {isReal } {X⁻ } (x ,, p) = Number (isReal , X⁺ )
abs-Types {isReal } {X₀⁻} (x ,, p) = Number (isReal , X₀⁺)
abs-Types {isComplex} {X } (x ,, p) = Number (isReal , X₀⁺)
abs-Types {isComplex} {X⁺⁻} (x ,, p) = Number (isReal , X⁺ )
| 45.389078
| 121
| 0.589894
|
a00e31a47e9720b70e50486b21e716f1a359f8f3
| 259
|
agda
|
Agda
|
test/Compiler/simple/Issue223.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
test/Compiler/simple/Issue223.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
test/Compiler/simple/Issue223.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
{-# FOREIGN GHC import qualified Issue223 #-}
data A : Set
data B : Set
data A where
BA : B → A
data B where
AB : A → B
BB : B
{-# COMPILE GHC A = data Issue223.A (Issue223.BA) #-}
{-# COMPILE GHC B = data Issue223.B (Issue223.AB | Issue223.BB) #-}
| 17.266667
| 67
| 0.610039
|
31f5d882f82b053ff07c428cc564542fc86a511e
| 1,904
|
agda
|
Agda
|
Definition/LogicalRelation/Properties/Reflexivity.agda
|
loic-p/logrel-mltt
|
2251b8da423be0c6fb916f2675d7bd8537e4cd96
|
[
"MIT"
] | null | null | null |
Definition/LogicalRelation/Properties/Reflexivity.agda
|
loic-p/logrel-mltt
|
2251b8da423be0c6fb916f2675d7bd8537e4cd96
|
[
"MIT"
] | null | null | null |
Definition/LogicalRelation/Properties/Reflexivity.agda
|
loic-p/logrel-mltt
|
2251b8da423be0c6fb916f2675d7bd8537e4cd96
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --without-K --safe #-}
open import Definition.Typed.EqualityRelation
module Definition.LogicalRelation.Properties.Reflexivity {{eqrel : EqRelSet}} where
open import Definition.Untyped
open import Definition.Typed
open import Definition.LogicalRelation
open import Tools.Embedding
open import Tools.Product
import Tools.PropositionalEquality as PE
-- Reflexivity of reducible types.
reflEq : ∀ {l Γ A} ([A] : Γ ⊩⟨ l ⟩ A) → Γ ⊩⟨ l ⟩ A ≡ A / [A]
reflEq (Uᵣ′ l′ l< ⊢Γ) = (U₌ PE.refl)
reflEq (ℕᵣ D) = ιx (ℕ₌ (red D))
reflEq (ne′ K [ ⊢A , ⊢B , D ] neK K≡K) =
ιx (ne₌ _ [ ⊢A , ⊢B , D ] neK K≡K)
reflEq (Πᵣ′ F G [ ⊢A , ⊢B , D ] ⊢F ⊢G A≡A [F] [G] G-ext) =
Π₌ _ _ D A≡A
(λ ρ ⊢Δ → reflEq ([F] ρ ⊢Δ))
(λ ρ ⊢Δ [a] → reflEq ([G] ρ ⊢Δ [a]))
reflEq (emb′ 0<1 [A]) = ιx (reflEq [A])
reflNatural-prop : ∀ {Γ n}
→ Natural-prop Γ n
→ [Natural]-prop Γ n n
reflNatural-prop (sucᵣ (ℕₜ n d t≡t prop)) =
sucᵣ (ℕₜ₌ n n d d t≡t
(reflNatural-prop prop))
reflNatural-prop zeroᵣ = zeroᵣ
reflNatural-prop (ne (neNfₜ neK ⊢k k≡k)) = ne (neNfₜ₌ neK neK k≡k)
-- Reflexivity of reducible terms.
reflEqTerm : ∀ {l Γ A t} ([A] : Γ ⊩⟨ l ⟩ A)
→ Γ ⊩⟨ l ⟩ t ∷ A / [A]
→ Γ ⊩⟨ l ⟩ t ≡ t ∷ A / [A]
reflEqTerm (Uᵣ′ ⁰ 0<1 ⊢Γ) (Uₜ A d typeA A≡A [A]) =
Uₜ₌ A A d d typeA typeA A≡A [A] [A] (reflEq [A])
reflEqTerm (ℕᵣ D) (ιx (ℕₜ n [ ⊢t , ⊢u , d ] t≡t prop)) =
ιx (ℕₜ₌ n n [ ⊢t , ⊢u , d ] [ ⊢t , ⊢u , d ] t≡t
(reflNatural-prop prop))
reflEqTerm (ne′ K D neK K≡K) (ιx (neₜ k d (neNfₜ neK₁ ⊢k k≡k))) =
ιx (neₜ₌ k k d d (neNfₜ₌ neK₁ neK₁ k≡k))
reflEqTerm (Πᵣ′ F G D ⊢F ⊢G A≡A [F] [G] G-ext) (Πₜ f d funcF f≡f [f] [f]₁) =
Πₜ₌ f f d d funcF funcF f≡f
(Πₜ f d funcF f≡f [f] [f]₁)
(Πₜ f d funcF f≡f [f] [f]₁)
(λ ρ ⊢Δ [a] → [f] ρ ⊢Δ [a] [a] (reflEqTerm ([F] ρ ⊢Δ) [a]))
reflEqTerm (emb′ 0<1 [A]) (ιx t) = ιx (reflEqTerm [A] t)
| 35.259259
| 83
| 0.540966
|
c75f369bff6e2f168a8325bd19c8b1f9f42fdb7b
| 1,253
|
agda
|
Agda
|
test/fail/IrrelevantMatchRefl.agda
|
asr/agda-kanso
|
aa10ae6a29dc79964fe9dec2de07b9df28b61ed5
|
[
"MIT"
] | 1
|
2019-11-27T07:26:06.000Z
|
2019-11-27T07:26:06.000Z
|
test/fail/IrrelevantMatchRefl.agda
|
dagit/agda
|
4383a3d20328a6c43689161496cee8eb479aca08
|
[
"MIT"
] | null | null | null |
test/fail/IrrelevantMatchRefl.agda
|
dagit/agda
|
4383a3d20328a6c43689161496cee8eb479aca08
|
[
"MIT"
] | null | null | null |
-- Andreas, 2011-10-04, transcription of Dan Doel's post on the Agda list
{-# OPTIONS --experimental-irrelevance #-}
module IrrelevantMatchRefl where
postulate
Level : Set
lzero : Level
lsuc : (i : Level) → Level
_⊔_ : Level -> Level -> Level
{-# BUILTIN LEVEL Level #-}
{-# BUILTIN LEVELZERO lzero #-}
{-# BUILTIN LEVELSUC lsuc #-}
{-# BUILTIN LEVELMAX _⊔_ #-}
infixl 6 _⊔_
data _≡_ {i : Level}{A : Set i}(a : A) : A → Set where
refl : a ≡ a
sym : ∀ {i}{A B : Set i} → A ≡ B → B ≡ A
sym refl = refl
-- irrelevant subst should be rejected, because it suggests
-- that the equality proof is irrelevant also for reduction
subst : ∀ {i j}{A : Set i}(P : A → Set j){a b : A} → .(a ≡ b) → P a → P b
subst P refl x = x
postulate
D : Set
lie : (D → D) ≡ D
-- the following two substs may not reduce! ...
abs : (D → D) → D
abs f = subst (λ T → T) lie f
app : D → D → D
app d = subst (λ T → T) (sym lie) d
ω : D
ω = abs (λ d → app d d)
-- ... otherwise Ω loops
Ω : D
Ω = app ω ω
-- ... and this would be a real fixed-point combinator
Y : (D → D) → D
Y f = app δ δ
where δ = abs (λ x → f (app x x))
K : D → D
K x = abs (λ y → x)
K∞ : D
K∞ = Y K
mayloop : K∞ ≡ abs (λ y → K∞)
mayloop = refl
-- gives error D != D → D
| 20.540984
| 73
| 0.564246
|
9ab94152c4a07ea06dbd89e0cdcc9b60a606d215
| 2,207
|
agda
|
Agda
|
src/Categories/Object/Product/Construction.agda
|
turion/agda-categories
|
ad0f94b6cf18d8a448b844b021aeda58e833d152
|
[
"MIT"
] | 279
|
2019-06-01T14:36:40.000Z
|
2022-03-22T00:40:14.000Z
|
src/Categories/Object/Product/Construction.agda
|
seanpm2001/agda-categories
|
d9e4f578b126313058d105c61707d8c8ae987fa8
|
[
"MIT"
] | 236
|
2019-06-01T14:53:54.000Z
|
2022-03-28T14:31:43.000Z
|
src/Categories/Object/Product/Construction.agda
|
seanpm2001/agda-categories
|
d9e4f578b126313058d105c61707d8c8ae987fa8
|
[
"MIT"
] | 64
|
2019-06-02T16:58:15.000Z
|
2022-03-14T02:00:59.000Z
|
{-# OPTIONS --without-K --safe #-}
open import Categories.Category
open import Categories.Object.Terminal
-- Various constructors of Product Objects
module Categories.Object.Product.Construction {o ℓ e} (C : Category o ℓ e) (T : Terminal C) where
open import Categories.Object.Exponential C hiding (repack)
open import Categories.Object.Product C
open Category C
open Terminal T
open HomReasoning
-- we can get some products
[⊤×⊤]-product : Product ⊤ ⊤
[⊤×⊤]-product = record
{ A×B = ⊤
; π₁ = !
; π₂ = !
; ⟨_,_⟩ = λ _ _ → !
; project₁ = !-unique₂
; project₂ = !-unique₂
; unique = λ _ _ → !-unique _
}
[⊤×_]-product : (X : Obj) → Product ⊤ X
[⊤×_]-product X = record
{ A×B = X
; π₁ = !
; π₂ = id
; ⟨_,_⟩ = λ _ y → y
; project₁ = !-unique₂
; project₂ = identityˡ
; unique = λ _ id∘h≈j → ⟺ id∘h≈j ○ identityˡ
}
[_×⊤]-product : (X : Obj) → Product X ⊤
[_×⊤]-product X = Reversible [⊤× X ]-product
-- and some exponentials too
[_↑⊤]-exponential : (B : Obj) → Exponential ⊤ B
[ B ↑⊤]-exponential = record
{ B^A = B
; product = [ B ×⊤]-product
; eval = id
; λg = λ {X} X×⊤ X⇒B → X⇒B ∘ repack [ X ×⊤]-product X×⊤
; β = λ p {g} → begin
id ∘ (g ∘ [ p ]⟨ id , ! ⟩) ∘ [ p ]π₁ ≈⟨ identityˡ ○ assoc ⟩
g ∘ [ p ]⟨ id , ! ⟩ ∘ [ p ]π₁ ≈⟨ refl⟩∘⟨ [ p ]⟨⟩∘ ⟩
g ∘ [ p ]⟨ id ∘ [ p ]π₁ , ! ∘ [ p ]π₁ ⟩ ≈⟨ refl⟩∘⟨ ⟨⟩-cong₂ p identityˡ !-unique₂ ⟩
g ∘ [ p ]⟨ [ p ]π₁ , [ p ]π₂ ⟩ ≈⟨ refl⟩∘⟨ η p ○ identityʳ ⟩
g ∎
; λ-unique = λ {X} p {g} {h} h-comm → begin
h ≈˘⟨ identityʳ ⟩
h ∘ id ≈˘⟨ refl⟩∘⟨ project₁ p ⟩
h ∘ [ p ]π₁ ∘ [ p ]⟨ id , ! ⟩ ≈⟨ sym-assoc ⟩
(h ∘ [ p ]π₁) ∘ [ p ]⟨ id , ! ⟩ ≈˘⟨ identityˡ ⟩∘⟨refl ⟩
(id ∘ h ∘ [ p ]π₁) ∘ [ p ]⟨ id , ! ⟩ ≈⟨ h-comm ⟩∘⟨refl ⟩
g ∘ repack [ X ×⊤]-product p ∎
}
where open Product
[⊤↑_]-exponential : (A : Obj) → Exponential A ⊤
[⊤↑ A ]-exponential = record
{ B^A = ⊤
; product = [⊤× A ]-product
; eval = !
; λg = λ _ _ → !
; β = λ _ → !-unique₂
; λ-unique = λ _ _ → !-unique₂
}
| 29.824324
| 97
| 0.463525
|
9a1b5459e2707c54360ea125a1f026ea3d839391
| 876
|
agda
|
Agda
|
sets/bool.agda
|
HoTT/M-types
|
beebe176981953ab48f37de5eb74557cfc5402f4
|
[
"BSD-3-Clause"
] | 27
|
2015-04-14T15:47:03.000Z
|
2022-01-09T07:26:57.000Z
|
src/sets/bool.agda
|
pcapriotti/agda-base
|
bbbc3bfb2f80ad08c8e608cccfa14b83ea3d258c
|
[
"BSD-3-Clause"
] | 4
|
2015-02-02T14:32:16.000Z
|
2016-10-26T11:57:26.000Z
|
src/sets/bool.agda
|
pcapriotti/agda-base
|
bbbc3bfb2f80ad08c8e608cccfa14b83ea3d258c
|
[
"BSD-3-Clause"
] | 4
|
2015-02-02T12:17:00.000Z
|
2019-05-04T19:31:00.000Z
|
{-# OPTIONS --without-K #-}
module sets.bool where
open import sets.empty using (⊥)
open import sets.unit using (⊤)
open import decidable using (Dec; yes; no)
open import equality.core using (_≡_; refl)
open import level using (Level)
infixr 6 _∧_
infixr 5 _∨_ _xor_
infix 0 if_then_else_
data Bool : Set where
true false : Bool
not : Bool → Bool
not true = false
not false = true
T : Bool → Set
T true = ⊤
T false = ⊥
if_then_else_ : {a : Level} {A : Set a} → Bool → A → A → A
if true then t else f = t
if false then t else f = f
_∧_ : Bool → Bool → Bool
true ∧ b = b
false ∧ b = false
_∨_ : Bool → Bool → Bool
true ∨ b = true
false ∨ b = b
_xor_ : Bool → Bool → Bool
true xor b = not b
false xor b = b
_≟_ : (a b : Bool) → Dec (a ≡ b)
true ≟ true = yes refl
false ≟ false = yes refl
true ≟ false = no λ ()
false ≟ true = no λ ()
| 18.638298
| 58
| 0.606164
|
4b5e7c548cb89f3c0df2fab9be87b563cbdf7ddf
| 11,248
|
agda
|
Agda
|
Cubical/Foundations/Id.agda
|
L-TChen/cubical
|
60226aacd7b386aef95d43a0c29c4eec996348a8
|
[
"MIT"
] | null | null | null |
Cubical/Foundations/Id.agda
|
L-TChen/cubical
|
60226aacd7b386aef95d43a0c29c4eec996348a8
|
[
"MIT"
] | 1
|
2022-01-27T02:07:48.000Z
|
2022-01-27T02:07:48.000Z
|
Cubical/Foundations/Id.agda
|
L-TChen/cubical
|
60226aacd7b386aef95d43a0c29c4eec996348a8
|
[
"MIT"
] | null | null | null |
{-
This file contains:
- Id, refl and J (with definitional computation rule)
- Basic theory about Id, proved using J
- Lemmas for going back and forth between Path and Id
- Function extensionality for Id
- fiber, isContr, equiv all defined using Id
- The univalence axiom expressed using only Id ([EquivContr])
- Propositional truncation and its elimination principle
-}
{-# OPTIONS --cubical --no-import-sorts --safe #-}
module Cubical.Foundations.Id where
open import Cubical.Foundations.Prelude public
hiding ( _≡_ ; _≡⟨_⟩_ ; _∎ ; isPropIsContr)
renaming ( refl to reflPath
; transport to transportPath
; J to JPath
; JRefl to JPathRefl
; sym to symPath
; _∙_ to compPath
; cong to congPath
; funExt to funExtPath
; isContr to isContrPath
; isProp to isPropPath
; isSet to isSetPath
; fst to pr₁ -- as in the HoTT book
; snd to pr₂ )
open import Cubical.Foundations.Equiv
renaming ( fiber to fiberPath
; isEquiv to isEquivPath
; _≃_ to EquivPath
; equivFun to equivFunPath
; isPropIsEquiv to isPropIsEquivPath )
hiding ( equivCtr
; equivIsEquiv )
open import Cubical.Foundations.Univalence
renaming ( EquivContr to EquivContrPath )
open import Cubical.Foundations.Isomorphism
open import Cubical.HITs.PropositionalTruncation public
renaming ( squash to squashPath
; rec to recPropTruncPath
; elim to elimPropTruncPath )
open import Cubical.Core.Id public
private
variable
ℓ ℓ' : Level
A : Type ℓ
-- Version of the constructor for Id where the y is also
-- explicit. This is sometimes useful when it is needed for
-- typechecking (see JId below).
conId : ∀ {x : A} φ (y : A [ φ ↦ (λ _ → x) ])
(w : (Path _ x (outS y)) [ φ ↦ (λ { (φ = i1) → λ _ → x}) ]) →
x ≡ outS y
conId φ _ w = ⟨ φ , outS w ⟩
-- Reflexivity
refl : ∀ {x : A} → x ≡ x
refl {x = x} = ⟨ i1 , (λ _ → x) ⟩
-- Definition of J for Id
module _ {x : A} (P : ∀ (y : A) → Id x y → Type ℓ') (d : P x refl) where
J : ∀ {y : A} (w : x ≡ y) → P y w
J {y = y} = elimId P (λ φ y w → comp (λ i → P _ (conId (φ ∨ ~ i) (inS (outS w i))
(inS (λ j → outS w (i ∧ j)))))
(λ i → λ { (φ = i1) → d}) d) {y = y}
-- Check that J of refl is the identity function
Jdefeq : Path _ (J refl) d
Jdefeq _ = d
-- Basic theory about Id, proved using J
transport : ∀ (B : A → Type ℓ') {x y : A}
→ x ≡ y → B x → B y
transport B {x} p b = J (λ y p → B y) b p
_⁻¹ : {x y : A} → x ≡ y → y ≡ x
_⁻¹ {x = x} p = J (λ z _ → z ≡ x) refl p
ap : ∀ {B : Type ℓ'} (f : A → B) → ∀ {x y : A} → x ≡ y → f x ≡ f y
ap f {x} = J (λ z _ → f x ≡ f z) refl
_∙_ : ∀ {x y z : A} → x ≡ y → y ≡ z → x ≡ z
_∙_ {x = x} p = J (λ y _ → x ≡ y) p
infix 4 _∙_
infix 3 _∎
infixr 2 _≡⟨_⟩_
_≡⟨_⟩_ : (x : A) {y z : A} → x ≡ y → y ≡ z → x ≡ z
_ ≡⟨ p ⟩ q = p ∙ q
_∎ : (x : A) → x ≡ x
_ ∎ = refl
-- Convert between Path and Id
pathToId : ∀ {x y : A} → Path _ x y → Id x y
pathToId {x = x} = JPath (λ y _ → Id x y) refl
pathToIdRefl : ∀ {x : A} → Path _ (pathToId (λ _ → x)) refl
pathToIdRefl {x = x} = JPathRefl (λ y _ → Id x y) refl
idToPath : ∀ {x y : A} → Id x y → Path _ x y
idToPath {x = x} = J (λ y _ → Path _ x y) (λ _ → x)
idToPathRefl : ∀ {x : A} → Path _ (idToPath {x = x} refl) reflPath
idToPathRefl {x = x} _ _ = x
pathToIdToPath : ∀ {x y : A} → (p : Path _ x y) → Path _ (idToPath (pathToId p)) p
pathToIdToPath {x = x} = JPath (λ y p → Path _ (idToPath (pathToId p)) p)
(λ i → idToPath (pathToIdRefl i))
idToPathToId : ∀ {x y : A} → (p : Id x y) → Path _ (pathToId (idToPath p)) p
idToPathToId {x = x} = J (λ b p → Path _ (pathToId (idToPath p)) p) pathToIdRefl
-- We get function extensionality by going back and forth between Path and Id
funExt : ∀ {B : A → Type ℓ'} {f g : (x : A) → B x} →
((x : A) → f x ≡ g x) → f ≡ g
funExt p = pathToId (λ i x → idToPath (p x) i)
-- Equivalences expressed using Id
fiber : ∀ {A : Type ℓ} {B : Type ℓ'} (f : A → B) (y : B) → Type (ℓ-max ℓ ℓ')
fiber {A = A} f y = Σ[ x ∈ A ] f x ≡ y
isContr : Type ℓ → Type ℓ
isContr A = Σ[ x ∈ A ] (∀ y → x ≡ y)
isProp : Type ℓ → Type ℓ
isProp A = (x y : A) → x ≡ y
isSet : Type ℓ → Type ℓ
isSet A = (x y : A) → isProp (x ≡ y)
record isEquiv {A : Type ℓ} {B : Type ℓ'} (f : A → B) : Type (ℓ-max ℓ ℓ') where
field
equiv-proof : (y : B) → isContr (fiber f y)
open isEquiv public
infix 4 _≃_
_≃_ : ∀ (A : Type ℓ) (B : Type ℓ') → Type (ℓ-max ℓ ℓ')
A ≃ B = Σ[ f ∈ (A → B) ] (isEquiv f)
equivFun : ∀ {B : Type ℓ'} → A ≃ B → A → B
equivFun e = pr₁ e
equivIsEquiv : ∀ {B : Type ℓ'} (e : A ≃ B) → isEquiv (equivFun e)
equivIsEquiv e = pr₂ e
equivCtr : ∀ {B : Type ℓ'} (e : A ≃ B) (y : B) → fiber (equivFun e) y
equivCtr e y = e .pr₂ .equiv-proof y .pr₁
-- Functions for going between the various definitions. This could
-- also be achieved by making lines in the universe and transporting
-- back and forth along them.
fiberPathToFiber : ∀ {B : Type ℓ'} {f : A → B} {y : B} →
fiberPath f y → fiber f y
fiberPathToFiber (x , p) = (x , pathToId p)
fiberToFiberPath : ∀ {B : Type ℓ'} {f : A → B} {y : B} →
fiber f y → fiberPath f y
fiberToFiberPath (x , p) = (x , idToPath p)
fiberToFiber : ∀ {B : Type ℓ'} {f : A → B} {y : B}
(p : fiber f y) → Path _ (fiberPathToFiber (fiberToFiberPath p)) p
fiberToFiber (x , p) = λ i → x , idToPathToId p i
fiberPathToFiberPath : ∀ {B : Type ℓ'} {f : A → B} {y : B}
(p : fiberPath f y) → Path _ (fiberToFiberPath (fiberPathToFiber p)) p
fiberPathToFiberPath (x , p) = λ i → x , pathToIdToPath p i
isContrPathToIsContr : isContrPath A → isContr A
isContrPathToIsContr (ctr , p) = (ctr , λ y → pathToId (p y))
isContrToIsContrPath : isContr A → isContrPath A
isContrToIsContrPath (ctr , p) = (ctr , λ y → idToPath (p y))
isPropPathToIsProp : isPropPath A → isProp A
isPropPathToIsProp H x y = pathToId (H x y)
isPropToIsPropPath : isProp A → isPropPath A
isPropToIsPropPath H x y i = idToPath (H x y) i
-- Specialized helper lemmas for going back and forth between
-- isContrPath and isContr:
helper1 : ∀ {A B : Type ℓ} (f : A → B) (g : B → A)
(h : (y : B) → Path B (f (g y)) y) → isContrPath A → isContr B
helper1 f g h (x , p) =
(f x , λ y → pathToId (λ i → hcomp (λ j → λ { (i = i0) → f x
; (i = i1) → h y j })
(f (p (g y) i))))
helper2 : ∀ {A B : Type ℓ} (f : A → B) (g : B → A)
(h : (y : A) → Path A (g (f y)) y) → isContr B → isContrPath A
helper2 {A = A} f g h (x , p) = (g x , λ y → idToPath (rem y))
where
rem : ∀ (y : A) → g x ≡ y
rem y =
g x ≡⟨ ap g (p (f y)) ⟩
g (f y) ≡⟨ pathToId (h y) ⟩
y ∎
-- This proof is essentially the one for proving that isContr with
-- Path is a proposition, but as we are working with Id we have to
-- insert a lof of conversion functions. It is still nice that is
-- works like this though.
isPropIsContr : ∀ (p1 p2 : isContr A) → Path (isContr A) p1 p2
isPropIsContr (a0 , p0) (a1 , p1) j =
( idToPath (p0 a1) j ,
hcomp (λ i → λ { (j = i0) → λ x → idToPathToId (p0 x) i
; (j = i1) → λ x → idToPathToId (p1 x) i })
(λ x → pathToId (λ i → hcomp (λ k → λ { (i = i0) → idToPath (p0 a1) j
; (i = i1) → idToPath (p0 x) (j ∨ k)
; (j = i0) → idToPath (p0 x) (i ∧ k)
; (j = i1) → idToPath (p1 x) i })
(idToPath (p0 (idToPath (p1 x) i)) j))))
-- We now prove that isEquiv is a proposition
isPropIsEquiv : ∀ {A : Type ℓ} {B : Type ℓ} → {f : A → B} → (h1 h2 : isEquiv f) → Path _ h1 h2
equiv-proof (isPropIsEquiv {f = f} h1 h2 i) y =
isPropIsContr {A = fiber f y} (h1 .equiv-proof y) (h2 .equiv-proof y) i
-- Go from a Path equivalence to an Id equivalence
equivPathToEquiv : ∀ {A : Type ℓ} {B : Type ℓ'} → EquivPath A B → A ≃ B
equivPathToEquiv (f , p) =
(f , λ { .equiv-proof y → helper1 fiberPathToFiber fiberToFiberPath fiberToFiber (p .equiv-proof y) })
-- Go from an Id equivalence to a Path equivalence
equivToEquivPath : ∀ {A : Type ℓ} {B : Type ℓ'} → A ≃ B → EquivPath A B
equivToEquivPath (f , p) =
(f , λ { .equiv-proof y → helper2 fiberPathToFiber fiberToFiberPath fiberPathToFiberPath (p .equiv-proof y) })
equivToEquiv : ∀ {A : Type ℓ} {B : Type ℓ} → (p : A ≃ B) → Path _ (equivPathToEquiv (equivToEquivPath p)) p
equivToEquiv (f , p) i =
(f , isPropIsEquiv (λ { .equiv-proof y → helper1 fiberPathToFiber fiberToFiberPath fiberToFiber
(helper2 fiberPathToFiber fiberToFiberPath fiberPathToFiberPath (p .equiv-proof y)) }) p i)
-- We can finally prove univalence with Id everywhere from the one for Path
EquivContr : ∀ (A : Type ℓ) → isContr (Σ[ T ∈ Type ℓ ] (T ≃ A))
EquivContr {ℓ = ℓ} A = helper1 f1 f2 f12 (EquivContrPath A)
where
f1 : {A : Type ℓ} → Σ[ T ∈ Type ℓ ] (EquivPath T A) → Σ[ T ∈ Type ℓ ] (T ≃ A)
f1 (x , p) = x , equivPathToEquiv p
f2 : {A : Type ℓ} → Σ[ T ∈ Type ℓ ] (T ≃ A) → Σ[ T ∈ Type ℓ ] (EquivPath T A)
f2 (x , p) = x , equivToEquivPath p
f12 : (y : Σ[ T ∈ Type ℓ ] (T ≃ A)) → Path (Σ[ T ∈ Type ℓ ] (T ≃ A)) (f1 (f2 y)) y
f12 (x , p) i = x , equivToEquiv {A = x} {B = A} p i
-- Propositional truncation
∥∥-isProp : ∀ (x y : ∥ A ∥) → x ≡ y
∥∥-isProp x y = pathToId (squashPath x y)
∥∥-recursion : ∀ {A : Type ℓ} {P : Type ℓ} → isProp P → (A → P) → ∥ A ∥ → P
∥∥-recursion Pprop f x = recPropTruncPath (isPropToIsPropPath Pprop) f x
∥∥-induction : ∀ {A : Type ℓ} {P : ∥ A ∥ → Type ℓ} → ((a : ∥ A ∥) → isProp (P a)) →
((x : A) → P ∣ x ∣) → (a : ∥ A ∥) → P a
∥∥-induction Pprop f x = elimPropTruncPath (λ a → isPropToIsPropPath (Pprop a)) f x
-- Univalence
path≡Id : ∀ {ℓ} {A B : Type ℓ} → Path _ (Path _ A B) (Id A B)
path≡Id = isoToPath (iso pathToId idToPath idToPathToId pathToIdToPath )
equivPathToEquivPath : ∀ {ℓ} {A : Type ℓ} {B : Type ℓ} → (p : EquivPath A B) →
Path _ (equivToEquivPath (equivPathToEquiv p)) p
equivPathToEquivPath (f , p) i =
( f , isPropIsEquivPath f (equivToEquivPath (equivPathToEquiv (f , p)) .pr₂) p i )
equivPath≡Equiv : ∀ {ℓ} {A B : Type ℓ} → Path _ (EquivPath A B) (A ≃ B)
equivPath≡Equiv {ℓ} = isoToPath (iso (equivPathToEquiv {ℓ}) equivToEquivPath equivToEquiv equivPathToEquivPath)
univalenceId : ∀ {ℓ} {A B : Type ℓ} → (A ≡ B) ≃ (A ≃ B)
univalenceId {ℓ} {A = A} {B = B} = equivPathToEquiv rem
where
rem0 : Path _ (Lift (EquivPath A B)) (Lift (A ≃ B))
rem0 = congPath Lift equivPath≡Equiv
rem1 : Path _ (Id A B) (Lift (A ≃ B))
rem1 i = hcomp (λ j → λ { (i = i0) → path≡Id {A = A} {B = B} j
; (i = i1) → rem0 j })
(univalencePath {A = A} {B = B} i)
rem : EquivPath (Id A B) (A ≃ B)
rem = compEquiv (eqweqmap rem1) (invEquiv LiftEquiv)
| 35.936102
| 136
| 0.547742
|
3d675eed1d00797a484836bc1b4c12f813d9ae20
| 12,997
|
agda
|
Agda
|
Cubical/HITs/SetQuotients/Properties.agda
|
guilhermehas/cubical
|
ce3120d3f8d692847b2744162bcd7a01f0b687eb
|
[
"MIT"
] | 1
|
2021-10-31T17:32:49.000Z
|
2021-10-31T17:32:49.000Z
|
Cubical/HITs/SetQuotients/Properties.agda
|
guilhermehas/cubical
|
ce3120d3f8d692847b2744162bcd7a01f0b687eb
|
[
"MIT"
] | null | null | null |
Cubical/HITs/SetQuotients/Properties.agda
|
guilhermehas/cubical
|
ce3120d3f8d692847b2744162bcd7a01f0b687eb
|
[
"MIT"
] | null | null | null |
{-
Set quotients:
-}
{-# OPTIONS --safe #-}
module Cubical.HITs.SetQuotients.Properties where
open import Cubical.HITs.SetQuotients.Base
open import Cubical.Core.Everything
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Function
open import Cubical.Foundations.Isomorphism
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.HLevels
open import Cubical.Foundations.Equiv.HalfAdjoint
open import Cubical.Foundations.Univalence
open import Cubical.Functions.FunExtEquiv
open import Cubical.Data.Sigma
open import Cubical.Relation.Nullary
open import Cubical.Relation.Binary.Base
open import Cubical.HITs.TypeQuotients as TypeQuot using (_/ₜ_ ; [_] ; eq/)
open import Cubical.HITs.PropositionalTruncation as PropTrunc
using (∥_∥₁ ; ∣_∣₁ ; squash₁) renaming (rec to propRec)
open import Cubical.HITs.SetTruncation as SetTrunc
using (∥_∥₂ ; ∣_∣₂ ; squash₂ ; isSetSetTrunc)
private
variable
ℓ ℓ' ℓ'' : Level
A B C Q : Type ℓ
R S T W : A → A → Type ℓ
elimProp : {P : A / R → Type ℓ}
→ (∀ x → isProp (P x))
→ (∀ a → P [ a ])
→ ∀ x → P x
elimProp prop f [ x ] = f x
elimProp prop f (squash/ x y p q i j) =
isOfHLevel→isOfHLevelDep 2 (λ x → isProp→isSet (prop x))
(g x) (g y) (cong g p) (cong g q) (squash/ x y p q) i j
where
g = elimProp prop f
elimProp prop f (eq/ a b r i) =
isProp→PathP (λ i → prop (eq/ a b r i)) (f a) (f b) i
elimProp2 : {P : A / R → B / S → Type ℓ}
→ (∀ x y → isProp (P x y))
→ (∀ a b → P [ a ] [ b ])
→ ∀ x y → P x y
elimProp2 prop f =
elimProp (λ x → isPropΠ (prop x)) λ a →
elimProp (prop [ a ]) (f a)
elimProp3 : {P : A / R → B / S → C / T → Type ℓ}
→ (∀ x y z → isProp (P x y z))
→ (∀ a b c → P [ a ] [ b ] [ c ])
→ ∀ x y z → P x y z
elimProp3 prop f =
elimProp (λ x → isPropΠ2 (prop x)) λ a →
elimProp2 (prop [ a ]) (f a)
elimProp4 : {P : A / R → B / S → C / T → Q / W → Type ℓ}
→ (∀ x y z t → isProp (P x y z t))
→ (∀ a b c d → P [ a ] [ b ] [ c ] [ d ])
→ ∀ x y z t → P x y z t
elimProp4 prop f =
elimProp (λ x → isPropΠ3 (prop x)) λ a →
elimProp3 (prop [ a ]) (f a)
-- sometimes more convenient:
elimContr : {P : A / R → Type ℓ}
→ (∀ a → isContr (P [ a ]))
→ ∀ x → P x
elimContr contr =
elimProp (elimProp (λ _ → isPropIsProp) λ _ → isContr→isProp (contr _)) λ _ →
contr _ .fst
elimContr2 : {P : A / R → B / S → Type ℓ}
→ (∀ a b → isContr (P [ a ] [ b ]))
→ ∀ x y → P x y
elimContr2 contr =
elimContr λ _ →
isOfHLevelΠ 0 (elimContr λ _ → inhProp→isContr (contr _ _) isPropIsContr)
-- lemma 6.10.2 in hott book
[]surjective : (x : A / R) → ∃[ a ∈ A ] [ a ] ≡ x
[]surjective = elimProp (λ x → squash₁) (λ a → ∣ a , refl ∣₁)
elim : {P : A / R → Type ℓ}
→ (∀ x → isSet (P x))
→ (f : (a : A) → (P [ a ]))
→ ((a b : A) (r : R a b) → PathP (λ i → P (eq/ a b r i)) (f a) (f b))
→ ∀ x → P x
elim set f feq [ a ] = f a
elim set f feq (eq/ a b r i) = feq a b r i
elim set f feq (squash/ x y p q i j) =
isOfHLevel→isOfHLevelDep 2 set
(g x) (g y) (cong g p) (cong g q) (squash/ x y p q) i j
where
g = elim set f feq
rec : isSet B
→ (f : A → B)
→ ((a b : A) (r : R a b) → f a ≡ f b)
→ A / R → B
rec set f feq [ a ] = f a
rec set f feq (eq/ a b r i) = feq a b r i
rec set f feq (squash/ x y p q i j) = set (g x) (g y) (cong g p) (cong g q) i j
where
g = rec set f feq
rec2 : isSet C
→ (f : A → B → C)
→ (∀ a b c → R a b → f a c ≡ f b c)
→ (∀ a b c → S b c → f a b ≡ f a c)
→ A / R → B / S → C
rec2 set f feql feqr =
rec (isSetΠ (λ _ → set))
(λ a → rec set (f a) (feqr a))
(λ a b r → funExt (elimProp (λ _ → set _ _) (λ c → feql a b c r)))
-- the recursor for maps into groupoids:
-- i.e. for any type A with a binary relation R and groupoid B,
-- we can construct a map A / R → B from a map A → B satisfying the conditions
-- (i) ∀ (a b : A) → R a b → f a ≡ f b
-- (ii) ∀ (a b : A) → isProp (f a ≡ f b)
-- We start by proving that we can recover the set-quotient
-- by set-truncating the (non-truncated type quotient)
typeQuotSetTruncIso : Iso (A / R) ∥ A /ₜ R ∥₂
Iso.fun typeQuotSetTruncIso = rec isSetSetTrunc (λ a → ∣ [ a ] ∣₂)
λ a b r → cong ∣_∣₂ (eq/ a b r)
Iso.inv typeQuotSetTruncIso = SetTrunc.rec squash/ (TypeQuot.rec [_] eq/)
Iso.rightInv typeQuotSetTruncIso = SetTrunc.elim (λ _ → isProp→isSet (squash₂ _ _))
(TypeQuot.elimProp (λ _ → squash₂ _ _) λ _ → refl)
Iso.leftInv typeQuotSetTruncIso = elimProp (λ _ → squash/ _ _) λ _ → refl
module rec→Gpd {B : Type ℓ''} (Bgpd : isGroupoid B)
(f : A → B)
(feq : ∀ (a b : A) → R a b → f a ≡ f b)
(fprop : ∀ (a b : A) → isProp (f a ≡ f b))
where
fun : A / R → B
fun = f₁ ∘ f₂
where
f₁ : ∥ A /ₜ R ∥₂ → B
f₁ = SetTrunc.rec→Gpd.fun Bgpd f/ congF/Const
where
f/ : A /ₜ R → B
f/ = TypeQuot.rec f feq
congF/Const : (a b : A /ₜ R) (p q : a ≡ b) → cong f/ p ≡ cong f/ q
congF/Const =
TypeQuot.elimProp2
(λ _ _ → isPropΠ2 λ _ _ → Bgpd _ _ _ _)
(λ a b p q → fprop a b (cong f/ p) (cong f/ q))
f₂ : A / R → ∥ A /ₜ R ∥₂
f₂ = Iso.fun typeQuotSetTruncIso
setQuotUniversalIso : isSet B
→ Iso (A / R → B) (Σ[ f ∈ (A → B) ] ((a b : A) → R a b → f a ≡ f b))
Iso.fun (setQuotUniversalIso Bset) g = (λ a → g [ a ]) , λ a b r i → g (eq/ a b r i)
Iso.inv (setQuotUniversalIso Bset) h = rec Bset (fst h) (snd h)
Iso.rightInv (setQuotUniversalIso Bset) h = refl
Iso.leftInv (setQuotUniversalIso Bset) g =
funExt λ x →
PropTrunc.rec
(Bset (out (intro g) x) (g x))
(λ sur → cong (out (intro g)) (sym (snd sur)) ∙ (cong g (snd sur)))
([]surjective x)
where
intro = Iso.fun (setQuotUniversalIso Bset)
out = Iso.inv (setQuotUniversalIso Bset)
setQuotUniversal : isSet B
→ (A / R → B) ≃ (Σ[ f ∈ (A → B) ] ((a b : A) → R a b → f a ≡ f b))
setQuotUniversal Bset = isoToEquiv (setQuotUniversalIso Bset)
open BinaryRelation
setQuotUnaryOp : (-_ : A → A)
→ (∀ a a' → R a a' → R (- a) (- a'))
→ (A / R → A / R)
setQuotUnaryOp -_ h = rec squash/ (λ a → [ - a ]) (λ a b x → eq/ _ _ (h _ _ x))
-- characterisation of binary functions/operations on set-quotients
setQuotUniversal2Iso : isSet C → isRefl R → isRefl S
→ Iso (A / R → B / S → C)
(Σ[ _∗_ ∈ (A → B → C) ] (∀ a a' b b' → R a a' → S b b' → a ∗ b ≡ a' ∗ b'))
Iso.fun (setQuotUniversal2Iso {R = R} {S = S} Bset isReflR isReflS) _∗/_ = _∗_ , h
where
_∗_ = λ a b → [ a ] ∗/ [ b ]
h : ∀ a a' b b' → R a a' → S b b' → a ∗ b ≡ a' ∗ b'
h a a' b b' r s = cong (_∗/ [ b ]) (eq/ _ _ r) ∙ cong ([ a' ] ∗/_) (eq/ _ _ s)
Iso.inv (setQuotUniversal2Iso {R = R} {S = S} Bset isReflR isReflS) (_∗_ , h) =
rec2 Bset _∗_ hleft hright
where
hleft : ∀ a a' b → R a a' → (a ∗ b) ≡ (a' ∗ b)
hleft _ _ b r = h _ _ _ _ r (isReflS b)
hright : ∀ a b b' → S b b' → (a ∗ b) ≡ (a ∗ b')
hright a _ _ r = h _ _ _ _ (isReflR a) r
Iso.rightInv (setQuotUniversal2Iso Bset isReflR isReflS) (_∗_ , h) =
Σ≡Prop (λ _ → isPropΠ4 λ _ _ _ _ → isPropΠ2 λ _ _ → Bset _ _) refl
Iso.leftInv (setQuotUniversal2Iso Bset isReflR isReflS) _∗/_ =
funExt₂ (elimProp2 (λ _ _ → Bset _ _) λ _ _ → refl)
setQuotUniversal2 : isSet C → isRefl R → isRefl S
→ (A / R → B / S → C)
≃ (Σ[ _∗_ ∈ (A → B → C) ] (∀ a a' b b' → R a a' → S b b' → a ∗ b ≡ a' ∗ b'))
setQuotUniversal2 Bset isReflR isReflS =
isoToEquiv (setQuotUniversal2Iso Bset isReflR isReflS)
-- corollary for binary operations
-- TODO: prove truncated inverse for effective relations
setQuotBinOp : isRefl R → isRefl S
→ (_∗_ : A → B → C)
→ (∀ a a' b b' → R a a' → S b b' → T (a ∗ b) (a' ∗ b'))
→ (A / R → B / S → C / T)
setQuotBinOp isReflR isReflS _∗_ h =
rec2 squash/ (λ a b → [ a ∗ b ])
(λ _ _ _ r → eq/ _ _ (h _ _ _ _ r (isReflS _)))
(λ _ _ _ s → eq/ _ _ (h _ _ _ _ (isReflR _) s))
setQuotSymmBinOp : isRefl R → isTrans R
→ (_∗_ : A → A → A)
→ (∀ a b → R (a ∗ b) (b ∗ a))
→ (∀ a a' b → R a a' → R (a ∗ b) (a' ∗ b))
→ (A / R → A / R → A / R)
setQuotSymmBinOp {A = A} {R = R} isReflR isTransR _∗_ ∗Rsymm h =
setQuotBinOp isReflR isReflR _∗_ h'
where
h' : ∀ a a' b b' → R a a' → R b b' → R (a ∗ b) (a' ∗ b')
h' a a' b b' ra rb =
isTransR _ _ _ (h a a' b ra)
(isTransR _ _ _ (∗Rsymm a' b)
(isTransR _ _ _ (h b b' a' rb) (∗Rsymm b' a')))
effective : (Rprop : isPropValued R) (Requiv : isEquivRel R)
→ (a b : A) → [ a ] ≡ [ b ] → R a b
effective {A = A} {R = R} Rprop (equivRel R/refl R/sym R/trans) a b p =
transport aa≡ab (R/refl _)
where
helper : A / R → hProp _
helper =
rec isSetHProp
(λ c → (R a c , Rprop a c))
(λ c d cd →
Σ≡Prop (λ _ → isPropIsProp)
(hPropExt (Rprop a c) (Rprop a d)
(λ ac → R/trans _ _ _ ac cd)
(λ ad → R/trans _ _ _ ad (R/sym _ _ cd))))
aa≡ab : R a a ≡ R a b
aa≡ab i = helper (p i) .fst
isEquivRel→effectiveIso : isPropValued R → isEquivRel R
→ (a b : A) → Iso ([ a ] ≡ [ b ]) (R a b)
Iso.fun (isEquivRel→effectiveIso {R = R} Rprop Req a b) = effective Rprop Req a b
Iso.inv (isEquivRel→effectiveIso {R = R} Rprop Req a b) = eq/ a b
Iso.rightInv (isEquivRel→effectiveIso {R = R} Rprop Req a b) _ = Rprop a b _ _
Iso.leftInv (isEquivRel→effectiveIso {R = R} Rprop Req a b) _ = squash/ _ _ _ _
isEquivRel→isEffective : isPropValued R → isEquivRel R → isEffective R
isEquivRel→isEffective Rprop Req a b =
isoToIsEquiv (invIso (isEquivRel→effectiveIso Rprop Req a b))
discreteSetQuotients : Discrete A → isPropValued R → isEquivRel R
→ (∀ a₀ a₁ → Dec (R a₀ a₁))
→ Discrete (A / R)
discreteSetQuotients {A = A} {R = R} Adis Rprop Req Rdec =
elim (λ a₀ → isSetΠ (λ a₁ → isProp→isSet (isPropDec (squash/ a₀ a₁))))
discreteSetQuotients' discreteSetQuotients'-eq
where
discreteSetQuotients' : (a : A) (y : A / R) → Dec ([ a ] ≡ y)
discreteSetQuotients' a₀ =
elim (λ a₁ → isProp→isSet (isPropDec (squash/ [ a₀ ] a₁))) dis dis-eq
where
dis : (a₁ : A) → Dec ([ a₀ ] ≡ [ a₁ ])
dis a₁ with Rdec a₀ a₁
... | (yes p) = yes (eq/ a₀ a₁ p)
... | (no ¬p) = no λ eq → ¬p (effective Rprop Req a₀ a₁ eq )
dis-eq : (a b : A) (r : R a b) →
PathP (λ i → Dec ([ a₀ ] ≡ eq/ a b r i)) (dis a) (dis b)
dis-eq a b ab = J (λ b ab → ∀ k → PathP (λ i → Dec ([ a₀ ] ≡ ab i)) (dis a) k)
(λ k → isPropDec (squash/ _ _) _ _) (eq/ a b ab) (dis b)
discreteSetQuotients'-eq : (a b : A) (r : R a b) →
PathP (λ i → (y : A / R) → Dec (eq/ a b r i ≡ y))
(discreteSetQuotients' a) (discreteSetQuotients' b)
discreteSetQuotients'-eq a b ab =
J (λ b ab → ∀ k → PathP (λ i → (y : A / R) → Dec (ab i ≡ y))
(discreteSetQuotients' a) k)
(λ k → funExt (λ x → isPropDec (squash/ _ _) _ _)) (eq/ a b ab) (discreteSetQuotients' b)
-- Quotienting by the truncated relation is equivalent to quotienting by untruncated relation
truncRelIso : Iso (A / R) (A / (λ a b → ∥ R a b ∥₁))
Iso.fun truncRelIso = rec squash/ [_] λ _ _ r → eq/ _ _ ∣ r ∣₁
Iso.inv truncRelIso = rec squash/ [_] λ _ _ → PropTrunc.rec (squash/ _ _) λ r → eq/ _ _ r
Iso.rightInv truncRelIso = elimProp (λ _ → squash/ _ _) λ _ → refl
Iso.leftInv truncRelIso = elimProp (λ _ → squash/ _ _) λ _ → refl
truncRelEquiv : A / R ≃ A / (λ a b → ∥ R a b ∥₁)
truncRelEquiv = isoToEquiv truncRelIso
-- Using this we can obtain a useful characterization of
-- path-types for equivalence relations (not prop-valued)
-- and their quotients
isEquivRel→TruncIso : isEquivRel R → (a b : A) → Iso ([ a ] ≡ [ b ]) ∥ R a b ∥₁
isEquivRel→TruncIso {A = A} {R = R} Req a b =
compIso
(isProp→Iso (squash/ _ _) (squash/ _ _)
(cong (Iso.fun truncRelIso)) (cong (Iso.inv truncRelIso)))
(isEquivRel→effectiveIso (λ _ _ → PropTrunc.isPropPropTrunc) ∥R∥eq a b)
where
open isEquivRel
∥R∥eq : isEquivRel λ a b → ∥ R a b ∥₁
reflexive ∥R∥eq a = ∣ reflexive Req a ∣₁
symmetric ∥R∥eq a b = PropTrunc.map (symmetric Req a b)
transitive ∥R∥eq a b c = PropTrunc.map2 (transitive Req a b c)
-- quotienting by 'logically equivalent' relations gives the same quotient
relBiimpl→TruncIso : ({a b : A} → R a b → S a b) → ({a b : A} → S a b → R a b) → Iso (A / R) (A / S)
Iso.fun (relBiimpl→TruncIso R→S S→R) = rec squash/ [_] λ _ _ Rab → eq/ _ _ (R→S Rab)
Iso.inv (relBiimpl→TruncIso R→S S→R) = rec squash/ [_] λ _ _ Sab → eq/ _ _ (S→R Sab)
Iso.rightInv (relBiimpl→TruncIso R→S S→R) = elimProp (λ _ → squash/ _ _) λ _ → refl
Iso.leftInv (relBiimpl→TruncIso R→S S→R) = elimProp (λ _ → squash/ _ _) λ _ → refl
descendMapPath : {M : Type ℓ} (f g : A / R → M) (isSetM : isSet M)
→ ((x : A) → f [ x ] ≡ g [ x ])
→ f ≡ g
descendMapPath f g isSetM path i x =
propRec
(isSetM (f x) (g x))
(λ {(x' , p) →
f x ≡⟨ cong f (sym p) ⟩
f [ x' ] ≡⟨ path x' ⟩
g [ x' ] ≡⟨ cong g p ⟩
g x ∎ })
([]surjective x)
i
| 36.304469
| 100
| 0.555205
|
29d246b53281354a49985b151c39e096a15a6772
| 817
|
agda
|
Agda
|
src/fot/FOTC/Data/Colist/Type/Consistency/Axioms.agda
|
asr/fotc
|
2fc9f2b81052a2e0822669f02036c5750371b72d
|
[
"MIT"
] | 11
|
2015-09-03T20:53:42.000Z
|
2021-09-12T16:09:54.000Z
|
src/fot/FOTC/Data/Colist/Type/Consistency/Axioms.agda
|
asr/fotc
|
2fc9f2b81052a2e0822669f02036c5750371b72d
|
[
"MIT"
] | 2
|
2016-10-12T17:28:16.000Z
|
2017-01-01T14:34:26.000Z
|
src/fot/FOTC/Data/Colist/Type/Consistency/Axioms.agda
|
asr/fotc
|
2fc9f2b81052a2e0822669f02036c5750371b72d
|
[
"MIT"
] | 3
|
2016-09-19T14:18:30.000Z
|
2018-03-14T08:50:00.000Z
|
------------------------------------------------------------------------------
-- Test the consistency of FOTC.Data.Colist.Type
------------------------------------------------------------------------------
{-# OPTIONS --exact-split #-}
{-# OPTIONS --no-sized-types #-}
{-# OPTIONS --no-universe-polymorphism #-}
{-# OPTIONS --without-K #-}
-- In the module FOTC.Data.Colist.Type we declare Agda postulates as
-- first-order logic axioms. We test if it is possible to prove an
-- unprovable theorem from these axioms.
module FOTC.Data.Colist.Type.Consistency.Axioms where
open import FOTC.Base
open import FOTC.Data.Colist.Type
------------------------------------------------------------------------------
postulate impossible : ∀ d e → d ≡ e
{-# ATP prove impossible #-}
| 35.521739
| 78
| 0.473684
|
1d649634be5cfc9aaf63d60df1e3defd00b18264
| 1,453
|
agda
|
Agda
|
Sets/Cardinality/Infinite/Lemmas.agda
|
Smaug123/agdaproofs
|
0f4230011039092f58f673abcad8fb0652e6b562
|
[
"MIT"
] | 4
|
2019-08-08T12:44:19.000Z
|
2022-01-28T06:04:15.000Z
|
Sets/Cardinality/Infinite/Lemmas.agda
|
Smaug123/agdaproofs
|
0f4230011039092f58f673abcad8fb0652e6b562
|
[
"MIT"
] | 14
|
2019-01-06T21:11:59.000Z
|
2020-04-11T11:03:39.000Z
|
Sets/Cardinality/Infinite/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 Functions.Definition
open import Functions.Lemmas
open import LogicalFormulae
open import Numbers.Naturals.Definition
open import Numbers.Naturals.Order
open import Sets.Cardinality.Infinite.Definition
open import Sets.FinSet.Definition
open import Sets.FinSet.Lemmas
module Sets.Cardinality.Infinite.Lemmas where
finsetNotInfinite : {n : ℕ} → InfiniteSet (FinSet n) → False
finsetNotInfinite {n} isInfinite = isInfinite n id idIsBijective
noInjectionNToFinite : {n : ℕ} → {f : ℕ → FinSet n} → Injection f → False
noInjectionNToFinite {n} {f} inj = pigeonhole (le 0 refl) tInj
where
t : FinSet (succ n) → FinSet n
t m = f (toNat m)
tInj : Injection t
tInj {x} {y} fx=fy = toNatInjective x y (inj fx=fy)
dedekindInfiniteImpliesInfinite : {a : _} (A : Set a) → DedekindInfiniteSet A → InfiniteSet A
dedekindInfiniteImpliesInfinite A record { inj = inj ; isInjection = isInjection } zero f x with Invertible.inverse (bijectionImpliesInvertible x) (inj 0)
... | ()
dedekindInfiniteImpliesInfinite A record { inj = inj ; isInjection = isInj } (succ n) f isBij = noInjectionNToFinite {f = t} tInjective
where
t : ℕ → FinSet (succ n)
t n = Invertible.inverse (bijectionImpliesInvertible isBij) (inj n)
tInjective : Injection t
tInjective pr = isInj ((Bijection.inj (invertibleImpliesBijection (inverseIsInvertible (bijectionImpliesInvertible isBij)))) pr)
| 42.735294
| 154
| 0.741913
|
224874210130a2017bf0e63e3c52acb8e5ee89cd
| 912
|
agda
|
Agda
|
test/Succeed/Conat-Sized.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 2
|
2019-10-29T09:40:30.000Z
|
2020-09-20T00:28:57.000Z
|
test/Succeed/Conat-Sized.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 3
|
2018-11-14T15:31:44.000Z
|
2019-04-01T19:39:26.000Z
|
test/Succeed/Conat-Sized.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1
|
2015-09-15T14:36:15.000Z
|
2015-09-15T14:36:15.000Z
|
-- Andreas, 2018-10-18, re issue #2757
--
-- Extracted this snippet from the standard library
-- as it caused problems during work in #2757
-- (runtime erasue using 0-quantity).
-- {-# OPTIONS -v tc.lhs.unify:65 -v tc.irr:50 #-}
open import Agda.Builtin.Size
data ⊥ : Set where
mutual
data Conat (i : Size) : Set where
zero : Conat i
suc : ∞Conat i → Conat i
record ∞Conat (i : Size) : Set where
coinductive
field force : ∀{j : Size< i} → Conat j
open ∞Conat
infinity : ∀ {i} → Conat i
infinity = suc λ where .force → infinity
data Finite : Conat ∞ → Set where
zero : Finite zero
suc : ∀ {n} → Finite (n .force) → Finite (suc n)
¬Finite∞ : Finite infinity → ⊥
¬Finite∞ (suc p) = ¬Finite∞ p
-- The problem was that the usableMod check in the
-- unifier (LHS.Unify) refuted this pattern match
-- because a runtime-erased argument ∞ (via meta-variable)
-- the the extended lambda.
| 24.648649
| 58
| 0.656798
|
ad45aa4dafe31eab50930db6bf478e19fa72b542
| 3,261
|
agda
|
Agda
|
agda/MorePropAlgebra/Properties/Ring.agda
|
mchristianl/synthetic-reals
|
10206b5c3eaef99ece5d18bf703c9e8b2371bde4
|
[
"MIT"
] | 3
|
2020-07-31T18:15:26.000Z
|
2022-02-19T12:15:21.000Z
|
agda/MorePropAlgebra/Properties/Ring.agda
|
mchristianl/synthetic-reals
|
10206b5c3eaef99ece5d18bf703c9e8b2371bde4
|
[
"MIT"
] | null | null | null |
agda/MorePropAlgebra/Properties/Ring.agda
|
mchristianl/synthetic-reals
|
10206b5c3eaef99ece5d18bf703c9e8b2371bde4
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --cubical --no-import-sorts #-}
open import Cubical.Foundations.Everything renaming (_⁻¹ to _⁻¹ᵖ; assoc to ∙-assoc)
open import Function.Base using (_∋_; _$_)
open import MorePropAlgebra.Bundles
import Cubical.Algebra.Ring as Std
module MorePropAlgebra.Properties.Ring {ℓ} (assumptions : Ring {ℓ}) where
open Ring assumptions renaming (Carrier to R)
import MorePropAlgebra.Properties.AbGroup
module AbGroup'Properties = MorePropAlgebra.Properties.AbGroup (record { Ring assumptions renaming (+-AbGroup to is-AbGroup) })
module AbGroup' = AbGroup (record { Ring assumptions renaming (+-AbGroup to is-AbGroup) })
( AbGroup') = AbGroup ∋ (record { Ring assumptions renaming (+-AbGroup to is-AbGroup) })
import MorePropAlgebra.Properties.Monoid
module Monoid'Properties = MorePropAlgebra.Properties.Monoid (record { Ring assumptions renaming (·-Monoid to is-Monoid) })
module Monoid' = Monoid (record { Ring assumptions renaming (·-Monoid to is-Monoid) })
( Monoid') = Monoid ∋ (record { Ring assumptions renaming (·-Monoid to is-Monoid) })
stdIsRing : Std.IsRing 0r 1r _+_ _·_ (-_)
stdIsRing .Std.IsRing.+-isAbGroup = AbGroup'Properties.stdIsAbGroup
stdIsRing .Std.IsRing.·-isMonoid = Monoid'Properties.stdIsMonoid
stdIsRing .Std.IsRing.dist = is-dist
stdRing : Std.Ring {ℓ}
stdRing = record { Ring assumptions ; isRing = stdIsRing }
module RingTheory' = Std.Theory stdRing
{-
-- NOTE: a few facts about rings that might be collected from elsewhere
a+b-b≡a : ∀ a b → a ≡ (a + b) - b
a+b-b≡a a b = let P = sym (fst (+-inv b))
Q = sym (fst (+-identity a))
R = transport (λ i → a ≡ a + P i) Q
S = transport (λ i → a ≡ (+-assoc a b (- b)) i ) R
in S
-- NOTE: this is called `simplL` and `simplL` in `Cubical.Structures.Group.Properties.GroupLemmas`
+-preserves-≡ : ∀{a b} → ∀ c → a ≡ b → a + c ≡ b + c
+-preserves-≡ c a≡b i = a≡b i + c
+-preserves-≡-l : ∀{a b} → ∀ c → a ≡ b → c + a ≡ c + b
+-preserves-≡-l c a≡b i = c + a≡b i
a+b≡0→a≡-b : ∀{a b} → a + b ≡ 0r → a ≡ - b
a+b≡0→a≡-b {a} {b} a+b≡0 = transport
(λ i →
let RHS = snd (+-identity (- b))
LHS₁ : a + (b + - b) ≡ a + 0r
LHS₁ = +-preserves-≡-l a (fst (+-inv b))
LHS₂ : (a + b) - b ≡ a
LHS₂ = transport (λ j → (+-assoc a b (- b)) j ≡ fst (+-identity a) j) LHS₁
in LHS₂ i ≡ RHS i
) (+-preserves-≡ (- b) a+b≡0)
-- NOTE: there is already
-- -commutesWithRight-· : (x y : R) → x · (- y) ≡ - (x · y)
a·-b≡-a·b : ∀ a b → a · (- b) ≡ - (a · b)
a·-b≡-a·b a b =
let P : a · 0r ≡ 0r
P = 0-rightNullifies a
Q : a · (- b + b) ≡ 0r
Q = transport (λ i → a · snd (+-inv b) (~ i) ≡ 0r) P
R : a · (- b) + a · b ≡ 0r
R = transport (λ i → ·-rdist-+ a (- b) b i ≡ 0r) Q
in a+b≡0→a≡-b R
a·b-a·c≡a·[b-c] : ∀ a b c → a · b - (a · c) ≡ a · (b - c)
a·b-a·c≡a·[b-c] a b c =
let P : a · b + a · (- c) ≡ a · (b + - c)
P = sym (·-rdist-+ a b (- c))
Q : a · b - a · c ≡ a · (b + - c)
Q = transport (λ i → a · b + a·-b≡-a·b a c i ≡ a · (b + - c) ) P
in Q
-}
| 38.364706
| 129
| 0.534805
|
04540d89c7520754acbc944ffa8586e5afc8a01a
| 3,052
|
agda
|
Agda
|
src/fot/FOTC/Data/Nat/UnaryNumbers.agda
|
asr/fotc
|
2fc9f2b81052a2e0822669f02036c5750371b72d
|
[
"MIT"
] | 11
|
2015-09-03T20:53:42.000Z
|
2021-09-12T16:09:54.000Z
|
src/fot/FOTC/Data/Nat/UnaryNumbers.agda
|
asr/fotc
|
2fc9f2b81052a2e0822669f02036c5750371b72d
|
[
"MIT"
] | 2
|
2016-10-12T17:28:16.000Z
|
2017-01-01T14:34:26.000Z
|
src/fot/FOTC/Data/Nat/UnaryNumbers.agda
|
asr/fotc
|
2fc9f2b81052a2e0822669f02036c5750371b72d
|
[
"MIT"
] | 3
|
2016-09-19T14:18:30.000Z
|
2018-03-14T08:50:00.000Z
|
------------------------------------------------------------------------------
-- Unary naturales numbers
------------------------------------------------------------------------------
{-# OPTIONS --exact-split #-}
{-# OPTIONS --no-sized-types #-}
{-# OPTIONS --no-universe-polymorphism #-}
{-# OPTIONS --without-K #-}
module FOTC.Data.Nat.UnaryNumbers where
open import FOTC.Base
------------------------------------------------------------------------------
0' = zero
1' = succ₁ 0'
2' = succ₁ 1'
3' = succ₁ 2'
4' = succ₁ 3'
5' = succ₁ 4'
6' = succ₁ 5'
7' = succ₁ 6'
8' = succ₁ 7'
9' = succ₁ 8'
{-# ATP definitions 0' 1' 2' 3' 4' 5' 6' 7' 8' 9' #-}
10' = succ₁ 9'
11' = succ₁ 10'
12' = succ₁ 11'
13' = succ₁ 12'
14' = succ₁ 13'
15' = succ₁ 14'
16' = succ₁ 15'
17' = succ₁ 16'
18' = succ₁ 17'
19' = succ₁ 18'
{-# ATP definition 10' 11' 12' 13' 14' 15' 16' 17' 18' 19' #-}
20' = succ₁ 19'
21' = succ₁ 20'
22' = succ₁ 21'
23' = succ₁ 22'
24' = succ₁ 23'
25' = succ₁ 24'
26' = succ₁ 25'
27' = succ₁ 26'
28' = succ₁ 27'
29' = succ₁ 28'
{-# ATP definition 20' 21' 22' 23' 24' 25' 26' 27' 28' 29' #-}
30' = succ₁ 29'
31' = succ₁ 30'
32' = succ₁ 31'
33' = succ₁ 32'
34' = succ₁ 33'
35' = succ₁ 34'
36' = succ₁ 35'
37' = succ₁ 36'
38' = succ₁ 37'
39' = succ₁ 38'
{-# ATP definition 30' 31' 32' 33' 34' 35' 36' 37' 38' 39' #-}
40' = succ₁ 39'
41' = succ₁ 40'
42' = succ₁ 41'
43' = succ₁ 42'
44' = succ₁ 43'
45' = succ₁ 44'
46' = succ₁ 45'
47' = succ₁ 46'
48' = succ₁ 47'
49' = succ₁ 48'
{-# ATP definition 40' 41' 42' 43' 44' 45' 46' 47' 48' 49' #-}
50' = succ₁ 49'
51' = succ₁ 50'
52' = succ₁ 51'
53' = succ₁ 52'
54' = succ₁ 53'
55' = succ₁ 54'
56' = succ₁ 55'
57' = succ₁ 56'
58' = succ₁ 57'
59' = succ₁ 58'
{-# ATP definition 50' 51' 52' 53' 54' 55' 56' 57' 58' 59' #-}
60' = succ₁ 59'
61' = succ₁ 60'
62' = succ₁ 61'
63' = succ₁ 62'
64' = succ₁ 63'
65' = succ₁ 64'
66' = succ₁ 65'
67' = succ₁ 66'
68' = succ₁ 67'
69' = succ₁ 68'
{-# ATP definition 60' 61' 62' 63' 64' 65' 66' 67' 68' 69' #-}
70' = succ₁ 69'
71' = succ₁ 70'
72' = succ₁ 71'
73' = succ₁ 72'
74' = succ₁ 73'
75' = succ₁ 74'
76' = succ₁ 75'
77' = succ₁ 76'
78' = succ₁ 77'
79' = succ₁ 78'
{-# ATP definition 70' 71' 72' 73' 74' 75' 76' 77' 78' 79' #-}
80' = succ₁ 79'
81' = succ₁ 80'
82' = succ₁ 81'
83' = succ₁ 82'
84' = succ₁ 83'
85' = succ₁ 84'
86' = succ₁ 85'
87' = succ₁ 86'
88' = succ₁ 87'
89' = succ₁ 88'
{-# ATP definition 80' 81' 82' 83' 84' 85' 86' 87' 88' 89' #-}
90' = succ₁ 89'
91' = succ₁ 90'
92' = succ₁ 91'
93' = succ₁ 92'
94' = succ₁ 93'
95' = succ₁ 94'
96' = succ₁ 95'
97' = succ₁ 96'
98' = succ₁ 97'
99' = succ₁ 98'
{-# ATP definition 90' 91' 92' 93' 94' 95' 96' 97' 98' 99' #-}
100' = succ₁ 99'
101' = succ₁ 100'
102' = succ₁ 101'
103' = succ₁ 102'
104' = succ₁ 103'
105' = succ₁ 104'
106' = succ₁ 105'
107' = succ₁ 106'
108' = succ₁ 107'
109' = succ₁ 108'
{-# ATP definition 100' 101' 102' 103' 104' 105' 106' 107' 108' 109' #-}
110' = succ₁ 109'
111' = succ₁ 110'
{-# ATP definition 110' 111' #-}
| 18.839506
| 78
| 0.505898
|
13c378e41620356a14f15aba94c198ba06dfbce4
| 1,882
|
agda
|
Agda
|
test/LibSucceed/SizeInconsistentMeta4.agda
|
vlopezj/agda
|
ff4d89e75970cf27599fb9f572bd43c9455cbb56
|
[
"BSD-3-Clause"
] | 2
|
2019-10-29T09:40:30.000Z
|
2020-09-20T00:28:57.000Z
|
test/LibSucceed/SizeInconsistentMeta4.agda
|
vikfret/agda
|
49ad0b3f0d39c01bc35123478b857e702b29fb9d
|
[
"BSD-3-Clause"
] | 3
|
2018-11-14T15:31:44.000Z
|
2019-04-01T19:39:26.000Z
|
test/LibSucceed/SizeInconsistentMeta4.agda
|
vikfret/agda
|
49ad0b3f0d39c01bc35123478b857e702b29fb9d
|
[
"BSD-3-Clause"
] | 1
|
2015-09-15T14:36:15.000Z
|
2015-09-15T14:36:15.000Z
|
-- Andreas, 2012-02-24 example by Ramana Kumar
{-# OPTIONS --sized-types #-}
-- {-# OPTIONS --show-implicit -v tc.size.solve:20 -v tc.conv.size:15 #-}
module SizeInconsistentMeta4 where
open import Data.Nat using (ℕ;zero;suc) renaming (_<_ to _N<_)
open import Data.Product using (_,_;_×_)
open import Data.Product.Relation.Binary.Lex.Strict using (×-Lex; ×-transitive)
open import Data.List using (List)
open import Data.List.Relation.Binary.Lex.Strict using (Lex-<) renaming (<-transitive to Lex<-trans)
open import Relation.Binary using (Rel;_Respects₂_;Transitive;IsEquivalence)
open import Relation.Binary.PropositionalEquality as PropEq using (_≡_)
import Level
open import Size using (Size;↑_)
-- keeping the definition of Vec for the positivity check
infixr 5 _∷_
data Vec {a} (A : Set a) : ℕ → Set a where
[] : Vec A zero
_∷_ : ∀ {n} (x : A) (xs : Vec A n) → Vec A (suc n)
{- produces different error
data Lex-< {A : _} (_≈_ _<_ : Rel A Level.zero) : Rel (List A) Level.zero where
postulate
Lex<-trans : ∀ {P _≈_ _<_} →
IsEquivalence _≈_ → _<_ Respects₂ _≈_ → Transitive _<_ →
Transitive (Lex-< _≈_ _<_)
-}
postulate
N<-trans : Transitive _N<_
-- Vec : ∀ {a} (A : Set a) → ℕ → Set a
Vec→List : ∀ {a n} {A : Set a} → Vec A n → List A
data Type : {z : Size} → Set where
TyApp : {z : Size} (n : ℕ) → (as : Vec (Type {z}) n) → Type {↑ z}
infix 4 _<_
data _<_ : {z : Size} → Rel (Type {z}) Level.zero where
TyApp<TyApp : ∀ {z} {n₁} {as₁} {n₂} {as₂} → ×-Lex _≡_ _N<_ (Lex-< _≡_ (_<_ {z})) (n₁ , Vec→List as₁) (n₂ , Vec→List as₂) → _<_ {↑ z} (TyApp n₁ as₁) (TyApp n₂ as₂)
<-trans : {z : Size} → Transitive (_<_ {z})
<-trans (TyApp<TyApp p) (TyApp<TyApp q) = TyApp<TyApp (×-transitive PropEq.isEquivalence (PropEq.resp₂ _N<_) N<-trans {_≤₂_ = Lex-< _≡_ _<_ } (Lex<-trans PropEq.isEquivalence (PropEq.resp₂ _<_) <-trans) p q)
| 40.913043
| 207
| 0.6339
|
c7943ad893b31cd7dacca662ad0286240ab081fc
| 7,816
|
agda
|
Agda
|
Cubical/Algebra/Group/Instances/IntMod.agda
|
thomas-lamiaux/cubical
|
58c0b83bb0fed0dc683f3d29b1709effe51c1689
|
[
"MIT"
] | null | null | null |
Cubical/Algebra/Group/Instances/IntMod.agda
|
thomas-lamiaux/cubical
|
58c0b83bb0fed0dc683f3d29b1709effe51c1689
|
[
"MIT"
] | null | null | null |
Cubical/Algebra/Group/Instances/IntMod.agda
|
thomas-lamiaux/cubical
|
58c0b83bb0fed0dc683f3d29b1709effe51c1689
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --safe #-}
module Cubical.Algebra.Group.Instances.IntMod where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Isomorphism
open import Cubical.Foundations.HLevels
open import Cubical.Data.Empty as ⊥
open import Cubical.Data.Unit
open import Cubical.Data.Bool hiding (isProp≤)
open import Cubical.Data.Nat renaming (_+_ to _+ℕ_)
open import Cubical.Data.Nat.Mod
open import Cubical.Data.Nat.Order
open import Cubical.Data.Int renaming (_+_ to _+ℤ_)
open import Cubical.Data.Fin
open import Cubical.Data.Fin.Arithmetic
open import Cubical.Data.Sigma
open import Cubical.Algebra.Monoid.Base
open import Cubical.Algebra.Semigroup.Base
open import Cubical.Algebra.Group.Base
open import Cubical.Algebra.Group.MorphismProperties
open import Cubical.Algebra.Group.Morphisms
open import Cubical.Algebra.Group.Properties
open import Cubical.Algebra.Group.Instances.Unit
open import Cubical.Algebra.Group.Instances.Bool
open import Cubical.Algebra.Group.Instances.Int
open GroupStr
open IsGroup
open IsMonoid
ℤGroup/_ : ℕ → Group₀
ℤGroup/ zero = ℤGroup
fst (ℤGroup/ suc n) = Fin (suc n)
1g (snd (ℤGroup/ suc n)) = 0
GroupStr._·_ (snd (ℤGroup/ suc n)) = _+ₘ_
inv (snd (ℤGroup/ suc n)) = -ₘ_
isGroup (snd (ℤGroup/ suc n)) = makeIsGroup
isSetFin
(λ x y z → sym (+ₘ-assoc x y z))
+ₘ-rUnit
+ₘ-lUnit
+ₘ-rCancel
+ₘ-lCancel
ℤGroup/1≅Unit : GroupIso (ℤGroup/ 1) UnitGroup₀
ℤGroup/1≅Unit = contrGroupIsoUnit isContrFin1
Bool≅ℤGroup/2 : GroupIso BoolGroup (ℤGroup/ 2)
Iso.fun (fst Bool≅ℤGroup/2) false = 1
Iso.fun (fst Bool≅ℤGroup/2) true = 0
Iso.inv (fst Bool≅ℤGroup/2) (zero , p) = true
Iso.inv (fst Bool≅ℤGroup/2) (suc zero , p) = false
Iso.inv (fst Bool≅ℤGroup/2) (suc (suc x) , p) =
⊥.rec (¬-<-zero (predℕ-≤-predℕ (predℕ-≤-predℕ p)))
Iso.rightInv (fst Bool≅ℤGroup/2) (zero , p) =
Σ≡Prop (λ _ → isProp≤) refl
Iso.rightInv (fst Bool≅ℤGroup/2) (suc zero , p) =
Σ≡Prop (λ _ → isProp≤) refl
Iso.rightInv (fst Bool≅ℤGroup/2) (suc (suc x) , p) =
⊥.rec (¬-<-zero (predℕ-≤-predℕ (predℕ-≤-predℕ p)))
Iso.leftInv (fst Bool≅ℤGroup/2) false = refl
Iso.leftInv (fst Bool≅ℤGroup/2) true = refl
snd Bool≅ℤGroup/2 =
makeIsGroupHom λ { false false → refl
; false true → refl
; true false → refl
; true true → refl}
ℤGroup/2≅Bool : GroupIso (ℤGroup/ 2) BoolGroup
ℤGroup/2≅Bool = invGroupIso Bool≅ℤGroup/2
-- Definition of the quotient map homomorphism ℤ → ℤGroup/ (suc n)
-- as a group homomorphism.
ℤ→Fin : (n : ℕ) → ℤ → Fin (suc n)
ℤ→Fin n (pos x) = x mod (suc n) , mod< n x
ℤ→Fin n (negsuc x) = -ₘ (suc x mod suc n , mod< n (suc x))
ℤ→Fin-presinv : (n : ℕ) (x : ℤ) → ℤ→Fin n (- x) ≡ -ₘ ℤ→Fin n x
ℤ→Fin-presinv n (pos zero) =
Σ≡Prop (λ _ → isProp≤) ((λ _ → zero) ∙ sym (cong fst help))
where
help : (-ₘ_ {n = n} 0) ≡ 0
help = GroupTheory.inv1g (ℤGroup/ (suc n))
ℤ→Fin-presinv n (pos (suc x)) = Σ≡Prop (λ _ → isProp≤) refl
ℤ→Fin-presinv n (negsuc x) =
sym (GroupTheory.invInv (ℤGroup/ (suc n)) _)
-ₘ1-id : (n : ℕ)
→ Path (Fin (suc n)) (-ₘ (1 mod (suc n) , mod< n 1))
(n mod (suc n) , mod< n n)
-ₘ1-id zero = refl
-ₘ1-id (suc n) =
cong -ₘ_ (FinPathℕ ((1 mod suc (suc n)) , mod< (suc n) 1) 1
(modIndBase (suc n) 1 (n , +-comm n 2)) .snd)
∙ Σ≡Prop (λ _ → isProp≤)
((+inductionBase (suc n) _
(λ x _ → ((suc (suc n)) ∸ x) mod (suc (suc n))) λ _ x → x) 1
(n , (+-comm n 2)))
suc-ₘ1 : (n y : ℕ)
→ ((suc y mod suc n) , mod< n (suc y)) -ₘ (1 mod (suc n) , mod< n 1)
≡ (y mod suc n , mod< n y)
suc-ₘ1 zero y =
isContr→isProp
(isOfHLevelRetractFromIso 0 (fst ℤGroup/1≅Unit) isContrUnit) _ _
suc-ₘ1 (suc n) y =
(λ i → ((suc y mod suc (suc n)) , mod< (suc n) (suc y))
+ₘ (-ₘ1-id (suc n) i))
∙ Σ≡Prop (λ _ → isProp≤)
(cong (_mod (2 +ℕ n))
(cong (_+ℕ (suc n) mod (2 +ℕ n))
(mod+mod≡mod (suc (suc n)) 1 y))
∙∙ sym (mod+mod≡mod (suc (suc n))
((1 mod suc (suc n))
+ℕ (y mod suc (suc n))) (suc n))
∙∙ (mod-rCancel (suc (suc n)) ((1 mod suc (suc n))
+ℕ (y mod suc (suc n))) (suc n)
∙ cong (_mod (suc (suc n)))
(cong (_+ℕ (suc n mod suc (suc n)))
(+-comm (1 mod suc (suc n)) (y mod suc (suc n)))
∙ sym (+-assoc (y mod suc (suc n))
(1 mod suc (suc n)) (suc n mod suc (suc n))))
∙∙ mod-rCancel (suc (suc n)) (y mod suc (suc n))
((1 mod suc (suc n)) +ℕ (suc n mod suc (suc n)))
∙∙ (cong (_mod (2 +ℕ n))
(cong ((y mod suc (suc n)) +ℕ_)
(sym (mod+mod≡mod (suc (suc n)) 1 (suc n))
∙ zero-charac (suc (suc n)))
∙ +-comm _ 0)
∙ mod-idempotent y)))
1-ₘsuc : (n y : ℕ)
→ ((1 mod (suc n) , mod< n 1)
+ₘ (-ₘ (((suc y mod suc n) , mod< n (suc y)))))
≡ -ₘ ((y mod suc n) , mod< n y)
1-ₘsuc n y =
sym (GroupTheory.invInv (ℤGroup/ (suc n)) _)
∙ cong -ₘ_
(GroupTheory.invDistr (ℤGroup/ (suc n))
(modInd n 1 , mod< n 1) (-ₘ (modInd n (suc y) , mod< n (suc y)))
∙ cong (_-ₘ (modInd n 1 , mod< n 1))
(GroupTheory.invInv (ℤGroup/ (suc n)) (modInd n (suc y) , mod< n (suc y)))
∙ suc-ₘ1 n y)
isHomℤ→Fin : (n : ℕ) → IsGroupHom (snd ℤGroup) (ℤ→Fin n) (snd (ℤGroup/ (suc n)))
isHomℤ→Fin n =
makeIsGroupHom
λ { (pos x) y → pos+case x y
; (negsuc x) (pos y) →
cong (ℤ→Fin n) (+Comm (negsuc x) (pos y))
∙∙ pos+case y (negsuc x)
∙∙ +ₘ-comm (ℤ→Fin n (pos y)) (ℤ→Fin n (negsuc x))
; (negsuc x) (negsuc y) →
sym (cong (ℤ→Fin n) (-Dist+ (pos (suc x)) (pos (suc y))))
∙∙ ℤ→Fin-presinv n (pos (suc x) +ℤ (pos (suc y)))
∙∙ cong -ₘ_ (pos+case (suc x) (pos (suc y)))
∙∙ GroupTheory.invDistr (ℤGroup/ (suc n))
(modInd n (suc x)
, mod< n (suc x)) (modInd n (suc y) , mod< n (suc y))
∙∙ +ₘ-comm (ℤ→Fin n (negsuc y)) (ℤ→Fin n (negsuc x))}
where
+1case : (y : ℤ) → ℤ→Fin n (1 +ℤ y) ≡ ℤ→Fin n 1 +ₘ ℤ→Fin n y
+1case (pos zero) = sym (GroupStr.·IdR (snd (ℤGroup/ (suc n))) _)
+1case (pos (suc y)) =
cong (ℤ→Fin n) (+Comm 1 (pos (suc y)))
∙ Σ≡Prop (λ _ → isProp≤) (mod+mod≡mod (suc n) 1 (suc y))
+1case (negsuc zero) =
Σ≡Prop (λ _ → isProp≤) refl
∙ sym (GroupStr.·InvR (snd (ℤGroup/ (suc n))) (modInd n 1 , mod< n 1))
+1case (negsuc (suc y)) =
Σ≡Prop (λ _ → isProp≤)
(cong fst (cong (ℤ→Fin n) (+Comm 1 (negsuc (suc y))))
∙∙ cong fst (cong -ₘ_ (refl {x = suc y mod suc n , mod< n (suc y)}))
∙∙ cong fst (sym (1-ₘsuc n (suc y)))
∙ λ i → fst ((1 mod (suc n) , mod< n 1)
+ₘ (-ₘ (((suc (suc y) mod suc n) , mod< n (suc (suc y)))))))
pos+case : (x : ℕ) (y : ℤ)
→ ℤ→Fin n (pos x +ℤ y) ≡ ℤ→Fin n (pos x) +ₘ ℤ→Fin n y
pos+case zero y =
cong (ℤ→Fin n) (+Comm 0 y)
∙ sym (GroupStr.·IdL (snd (ℤGroup/ (suc n))) (ℤ→Fin n y))
pos+case (suc zero) y = +1case y
pos+case (suc (suc x)) y =
cong (ℤ→Fin n) (cong (_+ℤ y) (+Comm (pos (suc x)) 1)
∙ sym (+Assoc 1 (pos (suc x)) y))
∙∙ +1case (pos (suc x) +ℤ y)
∙∙ (cong ((modInd n 1 , mod< n 1) +ₘ_) (pos+case (suc x) y)
∙∙ sym (+ₘ-assoc (modInd n 1 , mod< n 1)
(modInd n (suc x) , mod< n (suc x)) (ℤ→Fin n y))
∙∙ cong (_+ₘ ℤ→Fin n y) (lem x))
where
lem : (x : ℕ)
→ (modInd n 1 , mod< n 1) +ₘ (modInd n (suc x) , mod< n (suc x))
≡ ℤ→Fin n (pos (suc (suc x)))
lem x =
Σ≡Prop (λ _ → isProp≤) (sym (mod+mod≡mod (suc n) 1 (suc x)))
| 38.693069
| 81
| 0.531474
|
38d11d9454280a888e8b794cb94f316ece8a9513
| 5,889
|
agda
|
Agda
|
old/Spaces/LoopSpaceCircle.agda
|
danbornside/HoTT-Agda
|
1695a7f3dc60177457855ae846bbd86fcd96983e
|
[
"MIT"
] | 294
|
2015-01-09T16:23:23.000Z
|
2022-03-20T13:54:45.000Z
|
old/Spaces/LoopSpaceCircle.agda
|
danbornside/HoTT-Agda
|
1695a7f3dc60177457855ae846bbd86fcd96983e
|
[
"MIT"
] | 31
|
2015-03-05T20:09:00.000Z
|
2021-10-03T19:15:25.000Z
|
old/Spaces/LoopSpaceCircle.agda
|
danbornside/HoTT-Agda
|
1695a7f3dc60177457855ae846bbd86fcd96983e
|
[
"MIT"
] | 50
|
2015-01-10T01:48:08.000Z
|
2022-02-14T03:03:25.000Z
|
{-# OPTIONS --without-K #-}
open import Base
open import Spaces.Circle
open import Integers
module Spaces.LoopSpaceCircle where
-- Path fibration
path-fib : S¹ → Set
path-fib t = (t ≡ base)
tot-path-fib : Set
tot-path-fib = Σ S¹ path-fib
tot-path-fib-is-contr : is-contr tot-path-fib
tot-path-fib-is-contr = pathto-is-contr base
-- Universal cover
succ-path : ℤ ≡ ℤ
succ-path = eq-to-path succ-equiv
universal-cover : S¹ → Set
universal-cover = S¹-rec-nondep Set ℤ succ-path
tot-cover : Set
tot-cover = Σ S¹ universal-cover
-- Transport in the universal cover
loop-to-succ : (n : ℤ) → transport universal-cover loop n ≡ succ n
loop-to-succ n = ! (trans-ap (λ A → A) universal-cover loop n)
∘ (ap (λ t → transport (λ A → A) t n)
(S¹-β-loop-nondep Set ℤ succ-path)
∘ trans-id-eq-to-path succ-equiv n)
{- The flattening lemma
Here is an HIT declaration for the CW-complex of real numbers:
data ℝ : Set where
z : ℤ → ℝ
e : (n : ℤ) → z n ≡ z (succ n)
We want to show that [tot-cover] has the same introduction and elimination
rules.
-}
-- Introduction rules
R-z : ℤ → tot-cover
R-z n = (base , n)
R-e : (n : ℤ) → R-z n ≡ R-z (succ n)
R-e n = Σ-eq loop (loop-to-succ n)
-- Elimination rule
module Tot-cover-is-ℝ
{i}
(P : tot-cover → Set i)
(z : (n : ℤ) → P (R-z n))
(e : (n : ℤ) → transport P (R-e n) (z n) ≡ z (succ n)) where
-- I redefine [R-e] and [e] to have something involving
-- [transport universal-cover loop] instead of [succ]
R-e' : (n : ℤ) → R-z n ≡ R-z (transport universal-cover loop n)
R-e' n = Σ-eq loop refl
e' : (n : ℤ) → transport P (R-e' n) (z n)
≡ z (transport universal-cover loop n)
e' n = (trans-totalpath universal-cover P {x = (base , n)}
{y = (base , transport universal-cover loop n)}
loop refl z
∘ move!-transp-left (λ z → P (base , z)) _ (loop-to-succ n)
(z (succ n))
(! (trans-totalpath universal-cover P {x = (base , n)}
{y = (base , succ n)} loop (loop-to-succ n) z)
∘ e n))
∘ apd z (! (loop-to-succ n))
-- Now I can prove what I want by induction on the circle
P-base : (t : universal-cover base) → P (base , t)
P-base t = z t
P-loop : (t : universal-cover base)
→ transport (λ x → (u : universal-cover x) → P (x , u)) loop P-base t
≡ P-base t
P-loop t = transport (λ t → transport
(λ x → (u : universal-cover x) → P (x , u))
loop P-base t ≡ P-base t)
(trans-trans-opposite universal-cover loop t)
(! (trans-totalpath universal-cover P
loop refl z)
∘ e' (transport universal-cover (! loop) t))
P-R-rec : (x : S¹) → (t : universal-cover x) → P (x , t)
P-R-rec = S¹-rec (λ x → (t : universal-cover x) → P (x , t))
P-base (funext P-loop)
-- Here is the conclusion of the elimination rule
R-rec : (t : tot-cover) → P t
R-rec (x , y) = P-R-rec x y
-- We can now prove that [tot-cover] is contractible using [R-rec], that’s a
-- little tedious but not difficult
P-R-contr : (x : tot-cover) → Set _
P-R-contr x = R-z O ≡ x
R-contr-base : (n : ℤ) → P-R-contr (R-z n)
R-contr-base O = refl
R-contr-base (pos O) = R-e O
R-contr-base (pos (S y)) = R-contr-base (pos y) ∘ R-e (pos y)
R-contr-base (neg O) = ! (R-e (neg O))
R-contr-base (neg (S y)) = R-contr-base (neg y) ∘ ! (R-e (neg (S y)))
R-contr-loop : (n : ℤ)
→ transport P-R-contr (R-e n) (R-contr-base n) ≡ (R-contr-base (succ n))
R-contr-loop O = trans-cst≡id (R-e O) refl
R-contr-loop (pos O) = trans-cst≡id (R-e (pos O)) (R-e O)
R-contr-loop (pos (S y)) = trans-cst≡id (R-e (pos (S y)))
(R-contr-base (pos y) ∘ R-e (pos y))
R-contr-loop (neg O) = trans-cst≡id (R-e (neg O))
(! (R-e (neg O))) ∘ opposite-left-inverse (R-e (neg O))
R-contr-loop (neg (S y)) =
((trans-cst≡id (R-e (neg (S y))) (R-contr-base (neg y) ∘ ! (R-e (neg (S y))))
∘ concat-assoc (R-contr-base (neg y)) (! (R-e (neg (S y))))
(R-e (neg (S y))))
∘ (whisker-left (R-contr-base (neg y))
(opposite-left-inverse (R-e (neg (S y))))))
∘ refl-right-unit (R-contr-base (neg y))
R-contr : (x : tot-cover) → P-R-contr x
R-contr = Tot-cover-is-ℝ.R-rec P-R-contr R-contr-base R-contr-loop
tot-cover-is-contr : is-contr tot-cover
tot-cover-is-contr = (R-z O , λ x → ! (R-contr x))
-- We define now a fiberwise map between the two fibrations [path-fib]
-- and [universal-cover]
fiberwise-map : (x : S¹) → (path-fib x → universal-cover x)
fiberwise-map x p = transport universal-cover (! p) O
-- This induces an equivalence on the total spaces, because both total spaces
-- are contractible
total-is-equiv : is-equiv (total-map fiberwise-map)
total-is-equiv = contr-to-contr-is-equiv (total-map fiberwise-map)
tot-path-fib-is-contr
tot-cover-is-contr
-- Hence an equivalence fiberwise
fiberwise-map-is-equiv : (x : S¹) → is-equiv (fiberwise-map x)
fiberwise-map-is-equiv x = fiberwise-is-equiv fiberwise-map total-is-equiv x
-- We can then conclude that the based loop space of the circle is equivalent to
-- the type of the integers
ΩS¹≃ℤ : (base ≡ base) ≃ ℤ
ΩS¹≃ℤ = (fiberwise-map base , fiberwise-map-is-equiv base)
-- We can also deduce that the circle is 1-truncated
ΩS¹-is-set : is-set (base ≡ base)
ΩS¹-is-set = equiv-types-truncated _ (ΩS¹≃ℤ ⁻¹) ℤ-is-set
S¹-is-gpd : is-gpd S¹
S¹-is-gpd =
S¹-rec _
(S¹-rec _
ΩS¹-is-set -- [base ≡ base] is a set
(π₁ (is-truncated-is-prop _ _ _)))
(funext
(S¹-rec _
(π₁ (is-truncated-is-prop _ _ _))
(prop-has-all-paths (≡-is-truncated _ (is-truncated-is-prop _)) _ _)))
| 33.271186
| 80
| 0.572253
|
adf1903088ea88ed8968ff8744acd82741d0ba80
| 20,831
|
agda
|
Agda
|
Definition/LogicalRelation/Substitution/Introductions/IdUPiPi.agda
|
CoqHott/logrel-mltt
|
e0eeebc4aa5ed791ce3e7c0dc9531bd113dfcc04
|
[
"MIT"
] | 2
|
2018-06-21T08:39:01.000Z
|
2022-01-17T16:13:53.000Z
|
Definition/LogicalRelation/Substitution/Introductions/IdUPiPi.agda
|
CoqHott/logrel-mltt
|
e0eeebc4aa5ed791ce3e7c0dc9531bd113dfcc04
|
[
"MIT"
] | null | null | null |
Definition/LogicalRelation/Substitution/Introductions/IdUPiPi.agda
|
CoqHott/logrel-mltt
|
e0eeebc4aa5ed791ce3e7c0dc9531bd113dfcc04
|
[
"MIT"
] | 2
|
2022-01-26T14:55:51.000Z
|
2022-02-15T19:42:19.000Z
|
{-# OPTIONS --safe #-}
open import Definition.Typed.EqualityRelation
module Definition.LogicalRelation.Substitution.Introductions.IdUPiPi {{eqrel : EqRelSet}} where
open EqRelSet {{...}}
open import Definition.Untyped as U hiding (wk)
open import Definition.Untyped.Properties
open import Definition.Typed
open import Definition.Typed.Properties
open import Definition.Typed.Weakening as T hiding (wk; wkTerm; wkEqTerm)
open import Definition.Typed.RedSteps
open import Definition.LogicalRelation
open import Definition.LogicalRelation.ShapeView
open import Definition.LogicalRelation.Irrelevance
open import Definition.LogicalRelation.Weakening
open import Definition.LogicalRelation.Properties
open import Definition.LogicalRelation.Application
open import Definition.LogicalRelation.Substitution
open import Definition.LogicalRelation.Substitution.Properties
open import Definition.LogicalRelation.Substitution.Irrelevance as S
open import Definition.LogicalRelation.Substitution.Reflexivity
open import Definition.LogicalRelation.Substitution.Introductions.Sigma
open import Definition.LogicalRelation.Substitution.Introductions.Fst
open import Definition.LogicalRelation.Substitution.Introductions.Pi
open import Definition.LogicalRelation.Substitution.Introductions.Lambda
open import Definition.LogicalRelation.Substitution.Introductions.Application
open import Definition.LogicalRelation.Substitution.Introductions.Cast
open import Definition.LogicalRelation.Substitution.Introductions.Id
open import Definition.LogicalRelation.Substitution.Introductions.Transp
open import Definition.LogicalRelation.Substitution.Introductions.SingleSubst
open import Definition.LogicalRelation.Substitution.MaybeEmbed
open import Definition.LogicalRelation.Substitution.Escape
open import Definition.LogicalRelation.Substitution.Introductions.Universe
open import Definition.LogicalRelation.Substitution.Reduction
open import Definition.LogicalRelation.Substitution.Weakening
open import Definition.LogicalRelation.Substitution.ProofIrrelevance
open import Definition.LogicalRelation.Fundamental.Variable
open import Tools.Product
open import Tools.Nat
import Tools.PropositionalEquality as PE
lemma0 : ∀ σ A → (wk1 (wk1 (subst σ A))) PE.≡ subst (liftSubst (liftSubst σ)) (wk1 (wk1 A))
lemma0 σ A = PE.trans (PE.cong wk1 (PE.sym (Idsym-subst-lemma σ A))) (PE.sym (Idsym-subst-lemma (liftSubst σ) (wk1 A)))
lemma1 : ∀ {σ rA} A A' B →
wk1d (subst (liftSubst σ) B) [
cast ⁰ (wk1 (wk1 (subst σ A')))
(wk1 (wk1 (subst σ A)))
(Idsym (Univ rA ⁰) (wk1 (wk1 (subst σ A))) (wk1 (wk1 (subst σ A'))) (var 1))
(var 0)]↑
PE.≡
subst (liftSubst (liftSubst σ)) (U.wk (lift (step id)) B [
cast ⁰ (wk1 (wk1 A'))
(wk1 (wk1 A))
(Idsym (Univ rA ⁰) (wk1 (wk1 A)) (wk1 (wk1 A')) (var 1))
(var 0)]↑)
lemma1 {σ} {rA} A A' B = PE.trans (PE.cong₂ (λ X Y → X [ Y ]↑) (PE.sym (Idsym-subst-lemma-wk1d σ B))
(PE.cong₃ (λ X Y Z → cast ⁰ X Y Z (var 0)) (lemma0 σ A') (lemma0 σ A)
(PE.trans (PE.cong₂ (λ X Y → Idsym (Univ rA ⁰) X Y (var 1)) (lemma0 σ A) (lemma0 σ A'))
(PE.sym (subst-Idsym (liftSubst (liftSubst σ)) (Univ rA ⁰) (wk1 (wk1 A)) (wk1 (wk1 A')) (var 1))))))
(PE.sym ((singleSubstLift↑ (liftSubst σ) (U.wk (lift (step id)) B) _)))
lemma2 : ∀ {σ} B → U.wk (lift (step id)) (subst (liftSubst σ) B)
PE.≡
subst (liftSubst (liftSubst σ)) (U.wk (lift (step id)) B)
lemma2 B = PE.sym (Idsym-subst-lemma-wk1d _ B)
Id-U-ΠΠ-resᵗᵛ : ∀ {A B A' B' rA Γ} ([Γ] : ⊩ᵛ Γ) →
let l = ∞
lΠ = ⁰
[UA] = maybeEmbᵛ {A = Univ rA _} [Γ] (Uᵛ emb< [Γ])
[UΠ] = maybeEmbᵛ {A = Univ ! _} [Γ] (Uᵛ emb< [Γ])
Id-U-ΠΠ-res A A' B B' =
(Π (wk1 A') ^ rA ° ⁰ ▹ Id (U ⁰)
(wk1d B [ cast ⁰ (wk1 (wk1 A')) (wk1 (wk1 A)) (Idsym (Univ rA ⁰) (wk1 (wk1 A)) (wk1 (wk1 A')) (var 1)) (var 0) ]↑)
(wk1d B') ° ¹ ° ¹)
in
([A] : Γ ⊩ᵛ⟨ l ⟩ A ^ [ rA , ι lΠ ] / [Γ])
([A'] : Γ ⊩ᵛ⟨ l ⟩ A' ^ [ rA , ι lΠ ] / [Γ])
([UB] : Γ ∙ A ^ [ rA , ι lΠ ] ⊩ᵛ⟨ l ⟩ Univ ! lΠ ^ [ ! , next lΠ ] / [Γ] ∙ [A])
([UB'] : Γ ∙ A' ^ [ rA , ι lΠ ] ⊩ᵛ⟨ l ⟩ Univ ! lΠ ^ [ ! , next lΠ ] / [Γ] ∙ [A'])
([A]ₜ : Γ ⊩ᵛ⟨ l ⟩ A ∷ Univ rA lΠ ^ [ ! , next lΠ ] / [Γ] / [UA])
([B]ₜ : Γ ∙ A ^ [ rA , ι lΠ ] ⊩ᵛ⟨ l ⟩ B ∷ Univ ! lΠ ^ [ ! , next lΠ ] / [Γ] ∙ [A] / (λ {Δ} {σ} → [UB] {Δ} {σ}))
([A']ₜ : Γ ⊩ᵛ⟨ l ⟩ A' ∷ Univ rA lΠ ^ [ ! , next lΠ ] / [Γ] / [UA])
([B']ₜ : Γ ∙ A' ^ [ rA , ι lΠ ] ⊩ᵛ⟨ l ⟩ B' ∷ Univ ! lΠ ^ [ ! , next lΠ ] / [Γ] ∙ [A'] / (λ {Δ} {σ} → [UB'] {Δ} {σ})) →
let [IdAA'] = Idᵛ {A = Univ rA ⁰} {t = A} {u = A'} [Γ] (λ {Δ} {σ} → [UA] {Δ} {σ}) [A]ₜ [A']ₜ
[ΓId] = _∙_ {A = Id (Univ rA ⁰) A A'} [Γ] [IdAA']
[wA'] = wk1ᵗᵛ {F = Id (Univ rA ⁰) A A'} {G = A'} {lG = ⁰} [Γ] [IdAA'] [A']ₜ
[wA']' = wk1ᵛ {A = A'} {F = Id (Univ rA ⁰) A A'} [Γ] [IdAA'] [A']
[wA]' = wk1ᵛ {A = A} {F = Id (Univ rA ⁰) A A'} [Γ] [IdAA'] [A]
[wA] = wk1ᵗᵛ {F = Id (Univ rA ⁰) A A'} {G = A} {lG = ⁰} [Γ] [IdAA'] [A]ₜ
[ΓIdA'] = _∙_ {A = wk1 A'} [ΓId] [wA']'
[wwA']' = wk1ᵛ {A = wk1 A'} {F = wk1 A'} [ΓId] [wA']' [wA']'
[wwA'] = wk1ᵗᵛ {F = wk1 A'} {G = wk1 A'} {lG = ⁰} [ΓId] [wA']' [wA']
[wwA] = wk1ᵗᵛ {F = wk1 A'} {G = wk1 A} {lG = ⁰} [ΓId] [wA']' [wA]
[wwUA'] = λ {Δ} {σ} r → maybeEmbᵛ {A = Univ r _ } [ΓIdA'] (λ {Δ} {σ} → Uᵛ emb< [ΓIdA'] {Δ} {σ}) {Δ} {σ}
[wwIdAA'] = Idᵛ {A = Univ rA ⁰} {t = wk1 (wk1 A)} {u = wk1 (wk1 A')} [ΓIdA'] (λ {Δ} {σ} → [wwUA'] {Δ} {σ} rA) [wwA] [wwA']
[SProp] = Uᵛ {rU = %} ∞< [ΓId]
in
([var0]ₜ : (Γ ∙ Id (Univ rA ⁰) A A' ^ [ % , ι ¹ ] ∙ wk1 A' ^ [ rA , ι ⁰ ]) ⊩ᵛ⟨ ∞ ⟩ var 0 ∷ wk1 (wk1 A') ^ [ rA , ι ⁰ ] / [ΓIdA'] / [wwA']')
([var1]ₜ : (Γ ∙ Id (Univ rA ⁰) A A' ^ [ % , ι ¹ ] ∙ wk1 A' ^ [ rA , ι ⁰ ]) ⊩ᵛ⟨ ∞ ⟩ var 1 ∷ Id (Univ rA ⁰) (wk1 (wk1 A)) (wk1 (wk1 A')) ^ [ % , ι ¹ ] / [ΓIdA'] / [wwIdAA'])
→ Γ ∙ Id (Univ rA ⁰) A A' ^ [ % , ι ¹ ] ⊩ᵛ⟨ ∞ ⟩ Id-U-ΠΠ-res A A' B B' ∷ SProp ¹ ^ [ ! , ∞ ] / [ΓId] / (λ {Δ} {σ} → [SProp] {Δ} {σ})
Id-U-ΠΠ-resᵗᵛ {A} {B} {A'} {B'} {rA} {Γ}
[Γ] [A] [A'] [UB] [UB'] [A]ₜ [B]ₜ [A']ₜ [B']ₜ [var0]ₜ [var1]ₜ =
let l = ∞
lΠ = ⁰
[SProp] = Uᵛ {rU = %} ∞< [Γ]
[UA] = maybeEmbᵛ {A = Univ rA _} [Γ] (Uᵛ emb< [Γ])
[UΠ] = maybeEmbᵛ {A = Univ ! _} [Γ] (Uᵛ emb< [Γ])
⊢AΔ = λ {Δ} {σ} ⊢Δ [σ] → escapeTerm (proj₁ ([UA] {Δ} {σ} ⊢Δ [σ])) (proj₁ ([A]ₜ ⊢Δ [σ]))
⊢A'Δ = λ {Δ} {σ} ⊢Δ [σ] → escapeTerm (proj₁ ([UA] {Δ} {σ} ⊢Δ [σ])) (proj₁ ([A']ₜ ⊢Δ [σ]))
⊢A = λ {Δ} {σ} ⊢Δ [σ] → escape (proj₁ ([A] {Δ} {σ} ⊢Δ [σ]))
⊢A' = λ {Δ} {σ} ⊢Δ [σ] → escape (proj₁ ([A'] {Δ} {σ} ⊢Δ [σ]))
[ΓA] = (_∙_ {Γ} {A} [Γ] [A])
[ΓA'] = (_∙_ {Γ} {A'} [Γ] [A'])
⊢BΔ = λ {Δ} {σ} ⊢Δ [σ] → escapeTerm (proj₁ ([UB] {Δ} {σ} ⊢Δ [σ])) (proj₁ ([B]ₜ {Δ} {σ} ⊢Δ [σ]))
[A]' = univᵛ {A = A} [Γ] (≡is≤ PE.refl) (λ {Δ} {σ} → [UA] {Δ} {σ}) [A]ₜ
[A']' = univᵛ {A = A'} [Γ] (≡is≤ PE.refl) (λ {Δ} {σ} → [UA] {Δ} {σ}) [A']ₜ
[B]' = univᵛ {A = B} [ΓA] (≡is≤ PE.refl) (λ {Δ} {σ} → [UB] {Δ} {σ}) [B]ₜ
[B] = maybeEmbᵛ {A = B} [ΓA] [B]'
[B']' = univᵛ {A = B'} [ΓA'] (≡is≤ PE.refl) (λ {Δ} {σ} → [UB'] {Δ} {σ}) [B']ₜ
[B'] = maybeEmbᵛ {A = B'} [ΓA'] [B']'
⊢B'Δ = λ {Δ} {σ} ⊢Δ [σ] → escapeTerm (proj₁ ([UB'] {Δ} {σ} ⊢Δ [σ])) (proj₁ ([B']ₜ {Δ} {σ} ⊢Δ [σ]))
[liftσ] = λ {Δ} {σ} ⊢Δ [σ] → liftSubstS {F = A} {σ = σ} {Δ = Δ} [Γ] ⊢Δ [A] [σ]
[liftσ'] = λ {Δ} {σ} ⊢Δ [σ] → liftSubstS {F = A'} {σ = σ} {Δ = Δ} [Γ] ⊢Δ [A'] [σ]
[ΠAB] = Πᵗᵛ {A} {B} (≡is≤ PE.refl) (≡is≤ PE.refl) [Γ] [A] (λ {Δ} {σ} → [UB] {Δ} {σ}) [A]ₜ [B]ₜ
[ΠA'B'] = Πᵗᵛ {A'} {B'} (≡is≤ PE.refl) (≡is≤ PE.refl) [Γ] [A'] (λ {Δ} {σ} → [UB'] {Δ} {σ}) [A']ₜ [B']ₜ
[IdAA']ₜ = Idᵗᵛ {A = Univ rA ⁰} {t = A} {u = A'} [Γ] (λ {Δ} {σ} → [UA] {Δ} {σ}) [A]ₜ [A']ₜ (Uᵗᵛ [Γ])
[IdAA'] = Idᵛ {A = Univ rA ⁰} {t = A} {u = A'} [Γ] (λ {Δ} {σ} → [UA] {Δ} {σ}) [A]ₜ [A']ₜ
Id-U-ΠΠ-res A A' B B' = ∃ (Id (Univ rA ⁰) A A') ▹
(Π (wk1 A') ^ rA ° ⁰ ▹ Id (U ⁰)
((U.wk (lift (step id)) B) [ cast ⁰ (wk1 (wk1 A')) (wk1 (wk1 A)) (Idsym (Univ rA ⁰) (wk1 (wk1 A)) (wk1 (wk1 A')) (var 1)) (var 0) ]↑)
(U.wk (lift (step id)) B') ° ¹ ° ¹)
[ΓId] = _∙_ {A = Id (Univ rA ⁰) A A'} [Γ] [IdAA']
[wSProp] = Uᵛ {rU = %} ∞< [ΓId]
[wA'] = wk1ᵗᵛ {F = Id (Univ rA ⁰) A A'} {G = A'} {lG = ⁰} [Γ] [IdAA'] [A']ₜ
[wA']' = wk1ᵛ {A = A'} {F = Id (Univ rA ⁰) A A'} [Γ] [IdAA'] [A']
[wA]' = wk1ᵛ {A = A} {F = Id (Univ rA ⁰) A A'} [Γ] [IdAA'] [A]
[wA] = wk1ᵗᵛ {F = Id (Univ rA ⁰) A A'} {G = A} {lG = ⁰} [Γ] [IdAA'] [A]ₜ
[ΓIdA'] = _∙_ {A = wk1 A'} [ΓId] [wA']'
[wwU¹] = λ {Δ} {σ} r → Uᵛ {rU = r} ∞< [ΓIdA'] {Δ} {σ}
[wwUA'] = λ {Δ} {σ} r → maybeEmbᵛ {A = Univ r _ } [ΓIdA'] (λ {Δ} {σ} → Uᵛ emb< [ΓIdA'] {Δ} {σ}) {Δ} {σ}
[wwUA']ᵗ = Uᵗᵛ [ΓIdA']
[ΓIdA] = _∙_ {A = wk1 A} [ΓId] [wA]'
[wwA'] = wk1ᵗᵛ {F = wk1 A'} {G = wk1 A'} {lG = ⁰} [ΓId] [wA']' [wA']
[wwA] = wk1ᵗᵛ {F = wk1 A'} {G = wk1 A} {lG = ⁰} [ΓId] [wA']' [wA]
[wwA']' = wk1ᵛ {A = wk1 A'} {F = wk1 A'} [ΓId] [wA']' [wA']'
[wwA]' = wk1ᵛ {A = wk1 A} {F = wk1 A'} [ΓId] [wA']' [wA]'
[wwU0A] = maybeEmbᵛ {A = Univ ! _ } [ΓIdA] (λ {Δ} {σ} → Uᵛ emb< [ΓIdA] {Δ} {σ})
[wB'] = wk1dᵗᵛ {F = A'} {F' = Id (Univ rA ⁰) A A'} {G = B'} [Γ] [A'] [IdAA'] (λ {Δ} {σ} → [UB'] {Δ} {σ}) (λ {Δ} {σ} → [wwUA'] {Δ} {σ} !) [B']ₜ
[wB] = wk1dᵗᵛ {F = A} {F' = Id (Univ rA ⁰) A A'} {G = B} [Γ] [A] [IdAA'] (λ {Δ} {σ} → [UB] {Δ} {σ}) (λ {Δ} {σ} → [wwU0A] {Δ} {σ}) [B]ₜ
[wwIdAA'] = Idᵛ {A = Univ rA ⁰} {t = wk1 (wk1 A)} {u = wk1 (wk1 A')} [ΓIdA'] (λ {Δ} {σ} → [wwUA'] {Δ} {σ} rA) [wwA] [wwA']
[wwIdA'A] = Idᵛ {A = Univ rA ⁰} {t = wk1 (wk1 A')} {u = wk1 (wk1 A)} [ΓIdA'] (λ {Δ} {σ} → [wwUA'] {Δ} {σ} rA) [wwA'] [wwA]
in Πᵗᵛ {wk1 A'} {Id (U ⁰) (U.wk (lift (step id)) B [ cast ⁰ (wk1 (wk1 A')) (wk1 (wk1 A))
(Idsym (Univ rA ⁰) (wk1 (wk1 A)) (wk1 (wk1 A')) (var 1)) (var 0) ]↑)
(U.wk (lift (step id)) B')} (<is≤ 0<1) (≡is≤ PE.refl) [ΓId] [wA']' (λ {Δ} {σ} → [wwU¹] {Δ} {σ} %) [wA']
(Idᵗᵛ {A = U ⁰} {t = (U.wk (lift (step id)) B [ cast ⁰ (wk1 (wk1 A')) (wk1 (wk1 A))
(Idsym (Univ rA ⁰) (wk1 (wk1 A)) (wk1 (wk1 A')) (var 1)) (var 0) ]↑)}
{u = U.wk (lift (step id)) B'} [ΓIdA'] (λ {Δ} {σ} → [wwUA'] {Δ} {σ} !)
(subst↑STerm {F = wk1 A'} {F' = wk1 A} {G = wk1d B}
{t = cast ⁰ (wk1 (wk1 A')) (wk1 (wk1 A)) (Idsym (Univ rA ⁰) (wk1 (wk1 A)) (wk1 (wk1 A')) (var 1)) (var 0)}
[ΓId] [wA']' [wA]' (λ {Δ} {σ} → [wwUA'] {Δ} {σ} !) (λ {Δ} {σ} → [wwU0A] {Δ} {σ}) [wB]
(castᵗᵛ {A = wk1 (wk1 A')} {B = wk1 (wk1 A)} {t = var 0} {e = (Idsym (Univ rA ⁰) (wk1 (wk1 A)) (wk1 (wk1 A')) (var 1))}
[ΓIdA'] (λ {Δ} {σ} → [wwUA'] {Δ} {σ} rA) [wwA'] [wwA] [wwA']' [wwA]' [var0]ₜ
(Idᵛ {A = Univ rA ⁰} {t = wk1 (wk1 A')} {u = wk1 (wk1 A)} [ΓIdA'] (λ {Δ} {σ} → [wwUA'] {Δ} {σ} rA) [wwA'] [wwA])
(IdSymᵗᵛ {A = Univ rA ⁰} {t = wk1 (wk1 A)} {u = wk1 (wk1 A')} {e = var 1} [ΓIdA'] ((λ {Δ} {σ} → [wwU¹] {Δ} {σ} !))
(λ {Δ} {σ} → [wwUA']ᵗ {Δ} {σ}) (λ {Δ} {σ} → [wwUA'] {Δ} {σ} rA)
[wwA] [wwA'] [wwIdAA'] [wwIdA'A] [var1]ₜ))) [wB']
(λ {Δ} {σ} → Uᵗᵛ [ΓIdA'] {Δ} {σ}))
abstract
Id-U-ΠΠᵗᵛ : ∀ {A B A' B' rA Γ} ([Γ] : ⊩ᵛ Γ) →
let l = ∞
lΠ = ⁰
[UA] = maybeEmbᵛ {A = Univ rA _} [Γ] (Uᵛ emb< [Γ])
[UΠ] = maybeEmbᵛ {A = Univ ! _} [Γ] (Uᵛ emb< [Γ])
in
([A] : Γ ⊩ᵛ⟨ l ⟩ A ^ [ rA , ι lΠ ] / [Γ])
([A'] : Γ ⊩ᵛ⟨ l ⟩ A' ^ [ rA , ι lΠ ] / [Γ])
([UB] : Γ ∙ A ^ [ rA , ι lΠ ] ⊩ᵛ⟨ l ⟩ Univ ! lΠ ^ [ ! , next lΠ ] / [Γ] ∙ [A])
([UB'] : Γ ∙ A' ^ [ rA , ι lΠ ] ⊩ᵛ⟨ l ⟩ Univ ! lΠ ^ [ ! , next lΠ ] / [Γ] ∙ [A'])
([A]ₜ : Γ ⊩ᵛ⟨ l ⟩ A ∷ Univ rA lΠ ^ [ ! , next lΠ ] / [Γ] / [UA])
([B]ₜ : Γ ∙ A ^ [ rA , ι lΠ ] ⊩ᵛ⟨ l ⟩ B ∷ Univ ! lΠ ^ [ ! , next lΠ ] / [Γ] ∙ [A] / (λ {Δ} {σ} → [UB] {Δ} {σ}))
([A']ₜ : Γ ⊩ᵛ⟨ l ⟩ A' ∷ Univ rA lΠ ^ [ ! , next lΠ ] / [Γ] / [UA])
([B']ₜ : Γ ∙ A' ^ [ rA , ι lΠ ] ⊩ᵛ⟨ l ⟩ B' ∷ Univ ! lΠ ^ [ ! , next lΠ ] / [Γ] ∙ [A'] / (λ {Δ} {σ} → [UB'] {Δ} {σ}))
→ [ Γ ⊩ᵛ⟨ l ⟩ (Id (U ⁰) (Π A ^ rA ° ⁰ ▹ B ° ⁰ ° ⁰) (Π A' ^ rA ° ⁰ ▹ B' ° ⁰ ° ⁰))
≡ ∃ (Id (Univ rA ⁰) A A') ▹
(Π (wk1 A') ^ rA ° ⁰ ▹ Id (U ⁰)
((U.wk (lift (step id)) B) [ cast ⁰ (wk1 (wk1 A')) (wk1 (wk1 A)) (Idsym (Univ rA ⁰) (wk1 (wk1 A)) (wk1 (wk1 A')) (var 1)) (var 0) ]↑)
(U.wk (lift (step id)) B') ° ¹ ° ¹)
∷ SProp ¹ ^ [ ! , next ¹ ] / [Γ] ]
Id-U-ΠΠᵗᵛ {A} {B} {A'} {B'} {rA} {Γ} [Γ] [A] [A'] [UB] [UB'] [A]ₜ [B]ₜ [A']ₜ [B']ₜ =
let l = ∞
lΠ = ⁰
[SProp] = Uᵛ {rU = %} ∞< [Γ]
[UA] = maybeEmbᵛ {A = Univ rA _} [Γ] (Uᵛ emb< [Γ])
[UΠ] = maybeEmbᵛ {A = Univ ! _} [Γ] (Uᵛ emb< [Γ])
⊢AΔ = λ {Δ} {σ} ⊢Δ [σ] → escapeTerm (proj₁ ([UA] {Δ} {σ} ⊢Δ [σ])) (proj₁ ([A]ₜ ⊢Δ [σ]))
⊢A'Δ = λ {Δ} {σ} ⊢Δ [σ] → escapeTerm (proj₁ ([UA] {Δ} {σ} ⊢Δ [σ])) (proj₁ ([A']ₜ ⊢Δ [σ]))
⊢A = λ {Δ} {σ} ⊢Δ [σ] → escape (proj₁ ([A] {Δ} {σ} ⊢Δ [σ]))
⊢A' = λ {Δ} {σ} ⊢Δ [σ] → escape (proj₁ ([A'] {Δ} {σ} ⊢Δ [σ]))
[ΓA] = (_∙_ {Γ} {A} [Γ] [A])
[ΓA'] = (_∙_ {Γ} {A'} [Γ] [A'])
⊢BΔ = λ {Δ} {σ} ⊢Δ [σ] → escapeTerm (proj₁ ([UB] {Δ} {σ} ⊢Δ [σ])) (proj₁ ([B]ₜ {Δ} {σ} ⊢Δ [σ]))
[A]' = univᵛ {A = A} [Γ] (≡is≤ PE.refl) (λ {Δ} {σ} → [UA] {Δ} {σ}) [A]ₜ
[A']' = univᵛ {A = A'} [Γ] (≡is≤ PE.refl) (λ {Δ} {σ} → [UA] {Δ} {σ}) [A']ₜ
[B]' = univᵛ {A = B} [ΓA] (≡is≤ PE.refl) (λ {Δ} {σ} → [UB] {Δ} {σ}) [B]ₜ
[B] = maybeEmbᵛ {A = B} [ΓA] [B]'
[B']' = univᵛ {A = B'} [ΓA'] (≡is≤ PE.refl) (λ {Δ} {σ} → [UB'] {Δ} {σ}) [B']ₜ
[B'] = maybeEmbᵛ {A = B'} [ΓA'] [B']'
⊢B'Δ = λ {Δ} {σ} ⊢Δ [σ] → escapeTerm (proj₁ ([UB'] {Δ} {σ} ⊢Δ [σ])) (proj₁ ([B']ₜ {Δ} {σ} ⊢Δ [σ]))
[liftσ] = λ {Δ} {σ} ⊢Δ [σ] → liftSubstS {F = A} {σ = σ} {Δ = Δ} [Γ] ⊢Δ [A] [σ]
[liftσ'] = λ {Δ} {σ} ⊢Δ [σ] → liftSubstS {F = A'} {σ = σ} {Δ = Δ} [Γ] ⊢Δ [A'] [σ]
[ΠAB] = Πᵗᵛ {A} {B} (≡is≤ PE.refl) (≡is≤ PE.refl) [Γ] [A] (λ {Δ} {σ} → [UB] {Δ} {σ}) [A]ₜ [B]ₜ
[ΠA'B'] = Πᵗᵛ {A'} {B'} (≡is≤ PE.refl) (≡is≤ PE.refl) [Γ] [A'] (λ {Δ} {σ} → [UB'] {Δ} {σ}) [A']ₜ [B']ₜ
[IdAA']ₜ = Idᵗᵛ {A = Univ rA ⁰} {t = A} {u = A'} [Γ] (λ {Δ} {σ} → [UA] {Δ} {σ}) [A]ₜ [A']ₜ (Uᵗᵛ [Γ])
[IdAA'] = Idᵛ {A = Univ rA ⁰} {t = A} {u = A'} [Γ] (λ {Δ} {σ} → [UA] {Δ} {σ}) [A]ₜ [A']ₜ
Id-U-ΠΠ-res A A' B B' = ∃ (Id (Univ rA ⁰) A A') ▹
(Π (wk1 A') ^ rA ° ⁰ ▹ Id (U ⁰)
((U.wk (lift (step id)) B) [ cast ⁰ (wk1 (wk1 A')) (wk1 (wk1 A)) (Idsym (Univ rA ⁰) (wk1 (wk1 A)) (wk1 (wk1 A')) (var 1)) (var 0) ]↑)
(U.wk (lift (step id)) B') ° ¹ ° ¹)
[ΓId] = _∙_ {A = Id (Univ rA ⁰) A A'} [Γ] [IdAA']
[wSProp] = Uᵛ {rU = %} ∞< [ΓId]
[wA'] = wk1ᵗᵛ {F = Id (Univ rA ⁰) A A'} {G = A'} {lG = ⁰} [Γ] [IdAA'] [A']ₜ
[wA']' = wk1ᵛ {A = A'} {F = Id (Univ rA ⁰) A A'} [Γ] [IdAA'] [A']
[wA]' = wk1ᵛ {A = A} {F = Id (Univ rA ⁰) A A'} [Γ] [IdAA'] [A]
[wA] = wk1ᵗᵛ {F = Id (Univ rA ⁰) A A'} {G = A} {lG = ⁰} [Γ] [IdAA'] [A]ₜ
[ΓIdA'] = _∙_ {A = wk1 A'} [ΓId] [wA']'
[wwU¹] = λ {Δ} {σ} r → Uᵛ {rU = r} ∞< [ΓIdA'] {Δ} {σ}
[wwUA'] = λ {Δ} {σ} r → maybeEmbᵛ {A = Univ r _ } [ΓIdA'] (λ {Δ} {σ} → Uᵛ emb< [ΓIdA'] {Δ} {σ}) {Δ} {σ}
[ΓIdA] = _∙_ {A = wk1 A} [ΓId] [wA]'
[wwA'] = wk1ᵗᵛ {F = wk1 A'} {G = wk1 A'} {lG = ⁰} [ΓId] [wA']' [wA']
[wwA] = wk1ᵗᵛ {F = wk1 A'} {G = wk1 A} {lG = ⁰} [ΓId] [wA']' [wA]
[wwA']' = wk1ᵛ {A = wk1 A'} {F = wk1 A'} [ΓId] [wA']' [wA']'
[wwA]' = wk1ᵛ {A = wk1 A} {F = wk1 A'} [ΓId] [wA']' [wA]'
[wwU0A] = maybeEmbᵛ {A = Univ ! _ } [ΓIdA] (λ {Δ} {σ} → Uᵛ emb< [ΓIdA] {Δ} {σ})
[wB'] = wk1dᵗᵛ {F = A'} {F' = Id (Univ rA ⁰) A A'} {G = B'} [Γ] [A'] [IdAA'] (λ {Δ} {σ} → [UB'] {Δ} {σ}) (λ {Δ} {σ} → [wwUA'] {Δ} {σ} !) [B']ₜ
[wB] = wk1dᵗᵛ {F = A} {F' = Id (Univ rA ⁰) A A'} {G = B} [Γ] [A] [IdAA'] (λ {Δ} {σ} → [UB] {Δ} {σ}) (λ {Δ} {σ} → [wwU0A] {Δ} {σ}) [B]ₜ
[wwIdAA'] = Idᵛ {A = Univ rA ⁰} {t = wk1 (wk1 A)} {u = wk1 (wk1 A')} [ΓIdA'] (λ {Δ} {σ} → [wwUA'] {Δ} {σ} rA) [wwA] [wwA']
[wwIdA'A] = Idᵛ {A = Univ rA ⁰} {t = wk1 (wk1 A')} {u = wk1 (wk1 A)} [ΓIdA'] (λ {Δ} {σ} → [wwUA'] {Δ} {σ} rA) [wwA'] [wwA]
[var0]ₜ : (Γ ∙ Id (Univ rA ⁰) A A' ^ [ % , ι ¹ ] ∙ wk1 A' ^ [ rA , ι ⁰ ]) ⊩ᵛ⟨ ∞ ⟩ var 0 ∷ wk1 (wk1 A') ^ [ rA , ι ⁰ ] / [ΓIdA'] / [wwA']'
[var0]ₜ = proj₂ (fundamentalVar here [ΓIdA'])
[var1]ₜ : (Γ ∙ Id (Univ rA ⁰) A A' ^ [ % , ι ¹ ] ∙ wk1 A' ^ [ rA , ι ⁰ ]) ⊩ᵛ⟨ ∞ ⟩ var 1 ∷ Id (Univ rA ⁰) (wk1 (wk1 A)) (wk1 (wk1 A')) ^ [ % , ι ¹ ] / [ΓIdA'] / [wwIdAA']
[var1]ₜ = let X = fundamentalVar (there here) [ΓIdA'] in S.irrelevanceTerm {A = Id (Univ rA ⁰) (wk1 (wk1 A)) (wk1 (wk1 A'))} {t = var 1}
[ΓIdA'] [ΓIdA'] (proj₁ X) [wwIdAA'] (proj₂ X)
[Id-U-ΠΠ-res] : Γ ⊩ᵛ⟨ ∞ ⟩ Id-U-ΠΠ-res A A' B B' ∷ SProp ¹ ^ [ ! , ∞ ] / [Γ] / [SProp]
[Id-U-ΠΠ-res] = ∃ᵗᵛ {F = Id (Univ rA ⁰) A A'} {G = (Π (wk1 A') ^ rA ° ⁰ ▹ Id (U ⁰)
((U.wk (lift (step id)) B) [ cast ⁰ (wk1 (wk1 A')) (wk1 (wk1 A)) (Idsym (Univ rA ⁰) (wk1 (wk1 A)) (wk1 (wk1 A')) (var 1)) (var 0) ]↑)
(U.wk (lift (step id)) B') ° ¹ ° ¹)} [Γ] [IdAA'] (λ {Δ} {σ} → [wSProp] {Δ} {σ}) [IdAA']ₜ
(Id-U-ΠΠ-resᵗᵛ {A} {B} {A'} {B'} [Γ] [A] [A'] (λ {Δ} {σ} → [UB] {Δ} {σ}) (λ {Δ} {σ} → [UB'] {Δ} {σ}) [A]ₜ [B]ₜ [A']ₜ [B']ₜ [var0]ₜ [var1]ₜ)
[Id-U-ΠΠ] : Γ ⊩ᵛ Id (U ⁰) (Π A ^ rA ° ⁰ ▹ B ° ⁰ ° ⁰) (Π A' ^ rA ° ⁰ ▹ B' ° ⁰ ° ⁰) ⇒ Id-U-ΠΠ-res A A' B B' ∷ SProp ¹ ^ ∞ / [Γ]
[Id-U-ΠΠ] = λ {Δ} {σ} ⊢Δ [σ] → let Aσ = ⊢AΔ {Δ} {σ} ⊢Δ [σ]
Bσ = ⊢BΔ {Δ ∙ subst σ A ^ _} {liftSubst σ} (⊢Δ ∙ ⊢A {Δ} {σ} ⊢Δ [σ]) ([liftσ] {Δ} {σ} ⊢Δ [σ])
A'σ = ⊢A'Δ {Δ} {σ} ⊢Δ [σ]
B'σ = ⊢B'Δ {Δ ∙ subst σ A' ^ _} {liftSubst σ} (⊢Δ ∙ ⊢A' {Δ} {σ} ⊢Δ [σ]) ([liftσ'] {Δ} {σ} ⊢Δ [σ])
X : Δ ⊢ Id (U ⁰) (Π (subst σ A) ^ rA ° ⁰ ▹ (subst (liftSubst σ) B) ° ⁰ ° ⁰) (Π (subst σ A') ^ rA ° ⁰ ▹ (subst (liftSubst σ) B') ° ⁰ ° ⁰)
⇒ Id-U-ΠΠ-res (subst σ A) (subst σ A') (subst (liftSubst σ) B) (subst (liftSubst σ) B')
∷ SProp ¹ ^ ∞
X = Id-U-ΠΠ {Δ} {subst σ A} {subst σ A'} {rA} {subst (liftSubst σ) B} {subst (liftSubst σ) B'} Aσ Bσ A'σ B'σ
in PE.subst (λ BB → Δ ⊢ Id (U ⁰) (Π (subst σ A) ^ rA ° ⁰ ▹ (subst (liftSubst σ) B) ° ⁰ ° ⁰) (Π (subst σ A') ^ rA ° ⁰ ▹ (subst (liftSubst σ) B') ° ⁰ ° ⁰)
⇒ BB ∷ SProp ¹ ^ ∞ )
(PE.cong₃ (λ X Y Z → ∃ Id (Univ rA ⁰) (subst σ A) (subst σ A') ▹ Π X ^ rA ° ⁰ ▹ Id (U ⁰) Y Z ° ¹ ° ¹)
((PE.sym (Idsym-subst-lemma σ A'))) (lemma1 A A' B) (lemma2 B')) X
[id] , [eq] = redSubstTermᵛ {SProp ¹} {Id (U ⁰) (Π A ^ rA ° ⁰ ▹ B ° ⁰ ° ⁰) (Π A' ^ rA ° ⁰ ▹ B' ° ⁰ ° ⁰)} {Id-U-ΠΠ-res A A' B B'}
[Γ] [Id-U-ΠΠ]
(λ {Δ} {σ} → [SProp] {Δ} {σ}) [Id-U-ΠΠ-res]
in modelsTermEq [SProp] [id] [Id-U-ΠΠ-res] [eq]
| 75.749091
| 192
| 0.400221
|
1ee689168849441f25abcbbc3aa06d417f868c15
| 12,313
|
agda
|
Agda
|
Cubical/HITs/SetQuotients/Properties.agda
|
FernandoLarrain/cubical
|
9acdecfa6437ec455568be4e5ff04849cc2bc13b
|
[
"MIT"
] | 1
|
2022-02-05T01:25:26.000Z
|
2022-02-05T01:25:26.000Z
|
Cubical/HITs/SetQuotients/Properties.agda
|
FernandoLarrain/cubical
|
9acdecfa6437ec455568be4e5ff04849cc2bc13b
|
[
"MIT"
] | null | null | null |
Cubical/HITs/SetQuotients/Properties.agda
|
FernandoLarrain/cubical
|
9acdecfa6437ec455568be4e5ff04849cc2bc13b
|
[
"MIT"
] | null | null | null |
{-
Set quotients:
-}
{-# OPTIONS --safe #-}
module Cubical.HITs.SetQuotients.Properties where
open import Cubical.HITs.SetQuotients.Base
open import Cubical.Core.Everything
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Function
open import Cubical.Foundations.Isomorphism
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.HLevels
open import Cubical.Foundations.Equiv.HalfAdjoint
open import Cubical.Foundations.Univalence
open import Cubical.Functions.FunExtEquiv
open import Cubical.Data.Sigma
open import Cubical.Relation.Nullary
open import Cubical.Relation.Binary.Base
open import Cubical.HITs.TypeQuotients as TypeQuot using (_/ₜ_ ; [_] ; eq/)
open import Cubical.HITs.PropositionalTruncation as PropTrunc using (∥_∥ ; ∣_∣ ; squash)
open import Cubical.HITs.SetTruncation as SetTrunc using (∥_∥₂ ; ∣_∣₂ ; squash₂
; isSetSetTrunc)
private
variable
ℓ ℓ' ℓ'' : Level
A B C : Type ℓ
R S T : A → A → Type ℓ
elimProp : {P : A / R → Type ℓ}
→ (∀ x → isProp (P x))
→ (∀ a → P [ a ])
→ ∀ x → P x
elimProp prop f [ x ] = f x
elimProp prop f (squash/ x y p q i j) =
isOfHLevel→isOfHLevelDep 2 (λ x → isProp→isSet (prop x))
(g x) (g y) (cong g p) (cong g q) (squash/ x y p q) i j
where
g = elimProp prop f
elimProp prop f (eq/ a b r i) =
isProp→PathP (λ i → prop (eq/ a b r i)) (f a) (f b) i
elimProp2 : {P : A / R → B / S → Type ℓ}
→ (∀ x y → isProp (P x y))
→ (∀ a b → P [ a ] [ b ])
→ ∀ x y → P x y
elimProp2 prop f =
elimProp (λ x → isPropΠ (prop x)) λ a →
elimProp (prop [ a ]) (f a)
elimProp3 : {P : A / R → B / S → C / T → Type ℓ}
→ (∀ x y z → isProp (P x y z))
→ (∀ a b c → P [ a ] [ b ] [ c ])
→ ∀ x y z → P x y z
elimProp3 prop f =
elimProp (λ x → isPropΠ2 (prop x)) λ a →
elimProp2 (prop [ a ]) (f a)
-- sometimes more convenient:
elimContr : {P : A / R → Type ℓ}
→ (∀ a → isContr (P [ a ]))
→ ∀ x → P x
elimContr contr =
elimProp (elimProp (λ _ → isPropIsProp) λ _ → isContr→isProp (contr _)) λ _ →
contr _ .fst
elimContr2 : {P : A / R → B / S → Type ℓ}
→ (∀ a b → isContr (P [ a ] [ b ]))
→ ∀ x y → P x y
elimContr2 contr =
elimContr λ _ →
isOfHLevelΠ 0 (elimContr λ _ → inhProp→isContr (contr _ _) isPropIsContr)
-- lemma 6.10.2 in hott book
[]surjective : (x : A / R) → ∃[ a ∈ A ] [ a ] ≡ x
[]surjective = elimProp (λ x → squash) (λ a → ∣ a , refl ∣)
elim : {P : A / R → Type ℓ}
→ (∀ x → isSet (P x))
→ (f : (a : A) → (P [ a ]))
→ ((a b : A) (r : R a b) → PathP (λ i → P (eq/ a b r i)) (f a) (f b))
→ ∀ x → P x
elim set f feq [ a ] = f a
elim set f feq (eq/ a b r i) = feq a b r i
elim set f feq (squash/ x y p q i j) =
isOfHLevel→isOfHLevelDep 2 set
(g x) (g y) (cong g p) (cong g q) (squash/ x y p q) i j
where
g = elim set f feq
rec : isSet B
→ (f : A → B)
→ ((a b : A) (r : R a b) → f a ≡ f b)
→ A / R → B
rec set f feq [ a ] = f a
rec set f feq (eq/ a b r i) = feq a b r i
rec set f feq (squash/ x y p q i j) = set (g x) (g y) (cong g p) (cong g q) i j
where
g = rec set f feq
rec2 : isSet C
→ (f : A → B → C)
→ (∀ a b c → R a b → f a c ≡ f b c)
→ (∀ a b c → S b c → f a b ≡ f a c)
→ A / R → B / S → C
rec2 set f feql feqr =
rec (isSetΠ (λ _ → set))
(λ a → rec set (f a) (feqr a))
(λ a b r → funExt (elimProp (λ _ → set _ _) (λ c → feql a b c r)))
-- the recursor for maps into groupoids:
-- i.e. for any type A with a binary relation R and groupoid B,
-- we can construct a map A / R → B from a map A → B satisfying the conditions
-- (i) ∀ (a b : A) → R a b → f a ≡ f b
-- (ii) ∀ (a b : A) → isProp (f a ≡ f b)
-- We start by proving that we can recover the set-quotient
-- by set-truncating the (non-truncated type quotient)
typeQuotSetTruncIso : Iso (A / R) ∥ A /ₜ R ∥₂
Iso.fun typeQuotSetTruncIso = rec isSetSetTrunc (λ a → ∣ [ a ] ∣₂)
λ a b r → cong ∣_∣₂ (eq/ a b r)
Iso.inv typeQuotSetTruncIso = SetTrunc.rec squash/ (TypeQuot.rec [_] eq/)
Iso.rightInv typeQuotSetTruncIso = SetTrunc.elim (λ _ → isProp→isSet (squash₂ _ _))
(TypeQuot.elimProp (λ _ → squash₂ _ _) λ _ → refl)
Iso.leftInv typeQuotSetTruncIso = elimProp (λ _ → squash/ _ _) λ _ → refl
module rec→Gpd {B : Type ℓ''} (Bgpd : isGroupoid B)
(f : A → B)
(feq : ∀ (a b : A) → R a b → f a ≡ f b)
(fprop : ∀ (a b : A) → isProp (f a ≡ f b))
where
fun : A / R → B
fun = f₁ ∘ f₂
where
f₁ : ∥ A /ₜ R ∥₂ → B
f₁ = SetTrunc.rec→Gpd.fun Bgpd f/ congF/Const
where
f/ : A /ₜ R → B
f/ = TypeQuot.rec f feq
congF/Const : (a b : A /ₜ R) (p q : a ≡ b) → cong f/ p ≡ cong f/ q
congF/Const =
TypeQuot.elimProp2
(λ _ _ → isPropΠ2 λ _ _ → Bgpd _ _ _ _)
(λ a b p q → fprop a b (cong f/ p) (cong f/ q))
f₂ : A / R → ∥ A /ₜ R ∥₂
f₂ = Iso.fun typeQuotSetTruncIso
setQuotUniversalIso : isSet B
→ Iso (A / R → B) (Σ[ f ∈ (A → B) ] ((a b : A) → R a b → f a ≡ f b))
Iso.fun (setQuotUniversalIso Bset) g = (λ a → g [ a ]) , λ a b r i → g (eq/ a b r i)
Iso.inv (setQuotUniversalIso Bset) h = rec Bset (fst h) (snd h)
Iso.rightInv (setQuotUniversalIso Bset) h = refl
Iso.leftInv (setQuotUniversalIso Bset) g =
funExt λ x →
PropTrunc.rec
(Bset (out (intro g) x) (g x))
(λ sur → cong (out (intro g)) (sym (snd sur)) ∙ (cong g (snd sur)))
([]surjective x)
where
intro = Iso.fun (setQuotUniversalIso Bset)
out = Iso.inv (setQuotUniversalIso Bset)
setQuotUniversal : isSet B
→ (A / R → B) ≃ (Σ[ f ∈ (A → B) ] ((a b : A) → R a b → f a ≡ f b))
setQuotUniversal Bset = isoToEquiv (setQuotUniversalIso Bset)
open BinaryRelation
setQuotUnaryOp : (-_ : A → A)
→ (∀ a a' → R a a' → R (- a) (- a'))
→ (A / R → A / R)
setQuotUnaryOp -_ h = rec squash/ (λ a → [ - a ]) (λ a b x → eq/ _ _ (h _ _ x))
-- characterisation of binary functions/operations on set-quotients
setQuotUniversal2Iso : isSet C → isRefl R → isRefl S
→ Iso (A / R → B / S → C)
(Σ[ _∗_ ∈ (A → B → C) ] (∀ a a' b b' → R a a' → S b b' → a ∗ b ≡ a' ∗ b'))
Iso.fun (setQuotUniversal2Iso {R = R} {S = S} Bset isReflR isReflS) _∗/_ = _∗_ , h
where
_∗_ = λ a b → [ a ] ∗/ [ b ]
h : ∀ a a' b b' → R a a' → S b b' → a ∗ b ≡ a' ∗ b'
h a a' b b' r s = cong (_∗/ [ b ]) (eq/ _ _ r) ∙ cong ([ a' ] ∗/_) (eq/ _ _ s)
Iso.inv (setQuotUniversal2Iso {R = R} {S = S} Bset isReflR isReflS) (_∗_ , h) =
rec2 Bset _∗_ hleft hright
where
hleft : ∀ a a' b → R a a' → (a ∗ b) ≡ (a' ∗ b)
hleft _ _ b r = h _ _ _ _ r (isReflS b)
hright : ∀ a b b' → S b b' → (a ∗ b) ≡ (a ∗ b')
hright a _ _ r = h _ _ _ _ (isReflR a) r
Iso.rightInv (setQuotUniversal2Iso Bset isReflR isReflS) (_∗_ , h) =
Σ≡Prop (λ _ → isPropΠ4 λ _ _ _ _ → isPropΠ2 λ _ _ → Bset _ _) refl
Iso.leftInv (setQuotUniversal2Iso Bset isReflR isReflS) _∗/_ =
funExt₂ (elimProp2 (λ _ _ → Bset _ _) λ _ _ → refl)
setQuotUniversal2 : isSet C → isRefl R → isRefl S
→ (A / R → B / S → C)
≃ (Σ[ _∗_ ∈ (A → B → C) ] (∀ a a' b b' → R a a' → S b b' → a ∗ b ≡ a' ∗ b'))
setQuotUniversal2 Bset isReflR isReflS =
isoToEquiv (setQuotUniversal2Iso Bset isReflR isReflS)
-- corollary for binary operations
-- TODO: prove truncated inverse for effective relations
setQuotBinOp : isRefl R → isRefl S
→ (_∗_ : A → B → C)
→ (∀ a a' b b' → R a a' → S b b' → T (a ∗ b) (a' ∗ b'))
→ (A / R → B / S → C / T)
setQuotBinOp isReflR isReflS _∗_ h =
rec2 squash/ (λ a b → [ a ∗ b ])
(λ _ _ _ r → eq/ _ _ (h _ _ _ _ r (isReflS _)))
(λ _ _ _ s → eq/ _ _ (h _ _ _ _ (isReflR _) s))
setQuotSymmBinOp : isRefl R → isTrans R
→ (_∗_ : A → A → A)
→ (∀ a b → R (a ∗ b) (b ∗ a))
→ (∀ a a' b → R a a' → R (a ∗ b) (a' ∗ b))
→ (A / R → A / R → A / R)
setQuotSymmBinOp {A = A} {R = R} isReflR isTransR _∗_ ∗Rsymm h =
setQuotBinOp isReflR isReflR _∗_ h'
where
h' : ∀ a a' b b' → R a a' → R b b' → R (a ∗ b) (a' ∗ b')
h' a a' b b' ra rb =
isTransR _ _ _ (h a a' b ra)
(isTransR _ _ _ (∗Rsymm a' b)
(isTransR _ _ _ (h b b' a' rb) (∗Rsymm b' a')))
effective : (Rprop : isPropValued R) (Requiv : isEquivRel R)
→ (a b : A) → [ a ] ≡ [ b ] → R a b
effective {A = A} {R = R} Rprop (equivRel R/refl R/sym R/trans) a b p =
transport aa≡ab (R/refl _)
where
helper : A / R → hProp _
helper =
rec isSetHProp
(λ c → (R a c , Rprop a c))
(λ c d cd →
Σ≡Prop (λ _ → isPropIsProp)
(hPropExt (Rprop a c) (Rprop a d)
(λ ac → R/trans _ _ _ ac cd)
(λ ad → R/trans _ _ _ ad (R/sym _ _ cd))))
aa≡ab : R a a ≡ R a b
aa≡ab i = helper (p i) .fst
isEquivRel→effectiveIso : isPropValued R → isEquivRel R
→ (a b : A) → Iso ([ a ] ≡ [ b ]) (R a b)
Iso.fun (isEquivRel→effectiveIso {R = R} Rprop Req a b) = effective Rprop Req a b
Iso.inv (isEquivRel→effectiveIso {R = R} Rprop Req a b) = eq/ a b
Iso.rightInv (isEquivRel→effectiveIso {R = R} Rprop Req a b) _ = Rprop a b _ _
Iso.leftInv (isEquivRel→effectiveIso {R = R} Rprop Req a b) _ = squash/ _ _ _ _
isEquivRel→isEffective : isPropValued R → isEquivRel R → isEffective R
isEquivRel→isEffective Rprop Req a b =
isoToIsEquiv (invIso (isEquivRel→effectiveIso Rprop Req a b))
discreteSetQuotients : Discrete A → isPropValued R → isEquivRel R
→ (∀ a₀ a₁ → Dec (R a₀ a₁))
→ Discrete (A / R)
discreteSetQuotients {A = A} {R = R} Adis Rprop Req Rdec =
elim (λ a₀ → isSetΠ (λ a₁ → isProp→isSet (isPropDec (squash/ a₀ a₁))))
discreteSetQuotients' discreteSetQuotients'-eq
where
discreteSetQuotients' : (a : A) (y : A / R) → Dec ([ a ] ≡ y)
discreteSetQuotients' a₀ =
elim (λ a₁ → isProp→isSet (isPropDec (squash/ [ a₀ ] a₁))) dis dis-eq
where
dis : (a₁ : A) → Dec ([ a₀ ] ≡ [ a₁ ])
dis a₁ with Rdec a₀ a₁
... | (yes p) = yes (eq/ a₀ a₁ p)
... | (no ¬p) = no λ eq → ¬p (effective Rprop Req a₀ a₁ eq )
dis-eq : (a b : A) (r : R a b) →
PathP (λ i → Dec ([ a₀ ] ≡ eq/ a b r i)) (dis a) (dis b)
dis-eq a b ab = J (λ b ab → ∀ k → PathP (λ i → Dec ([ a₀ ] ≡ ab i)) (dis a) k)
(λ k → isPropDec (squash/ _ _) _ _) (eq/ a b ab) (dis b)
discreteSetQuotients'-eq : (a b : A) (r : R a b) →
PathP (λ i → (y : A / R) → Dec (eq/ a b r i ≡ y))
(discreteSetQuotients' a) (discreteSetQuotients' b)
discreteSetQuotients'-eq a b ab =
J (λ b ab → ∀ k → PathP (λ i → (y : A / R) → Dec (ab i ≡ y))
(discreteSetQuotients' a) k)
(λ k → funExt (λ x → isPropDec (squash/ _ _) _ _)) (eq/ a b ab) (discreteSetQuotients' b)
-- Quotienting by the truncated relation is equivalent to quotienting by untruncated relation
truncRelIso : Iso (A / R) (A / (λ a b → ∥ R a b ∥))
Iso.fun truncRelIso = rec squash/ [_] λ _ _ r → eq/ _ _ ∣ r ∣
Iso.inv truncRelIso = rec squash/ [_] λ _ _ → PropTrunc.rec (squash/ _ _) λ r → eq/ _ _ r
Iso.rightInv truncRelIso = elimProp (λ _ → squash/ _ _) λ _ → refl
Iso.leftInv truncRelIso = elimProp (λ _ → squash/ _ _) λ _ → refl
truncRelEquiv : A / R ≃ A / (λ a b → ∥ R a b ∥)
truncRelEquiv = isoToEquiv truncRelIso
-- Using this we can obtain a useful characterization of
-- path-types for equivalence relations (not prop-valued)
-- and their quotients
isEquivRel→TruncIso : isEquivRel R → (a b : A) → Iso ([ a ] ≡ [ b ]) ∥ R a b ∥
isEquivRel→TruncIso {A = A} {R = R} Req a b =
compIso
(isProp→Iso (squash/ _ _) (squash/ _ _)
(cong (Iso.fun truncRelIso)) (cong (Iso.inv truncRelIso)))
(isEquivRel→effectiveIso (λ _ _ → PropTrunc.isPropPropTrunc) ∥R∥eq a b)
where
open isEquivRel
∥R∥eq : isEquivRel λ a b → ∥ R a b ∥
reflexive ∥R∥eq a = ∣ reflexive Req a ∣
symmetric ∥R∥eq a b = PropTrunc.map (symmetric Req a b)
transitive ∥R∥eq a b c = PropTrunc.map2 (transitive Req a b c)
-- quotienting by 'logically equivalent' relations gives the same quotient
relBiimpl→TruncIso : ({a b : A} → R a b → S a b) → ({a b : A} → S a b → R a b) → Iso (A / R) (A / S)
Iso.fun (relBiimpl→TruncIso R→S S→R) = rec squash/ [_] λ _ _ Rab → eq/ _ _ (R→S Rab)
Iso.inv (relBiimpl→TruncIso R→S S→R) = rec squash/ [_] λ _ _ Sab → eq/ _ _ (S→R Sab)
Iso.rightInv (relBiimpl→TruncIso R→S S→R) = elimProp (λ _ → squash/ _ _) λ _ → refl
Iso.leftInv (relBiimpl→TruncIso R→S S→R) = elimProp (λ _ → squash/ _ _) λ _ → refl
| 36.755224
| 100
| 0.563551
|
c744807096bd5d3aa1dcdb722ea2ecfc5ca4986b
| 250
|
agda
|
Agda
|
test/Succeed/Issue3659.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 2
|
2019-10-29T09:40:30.000Z
|
2020-09-20T00:28:57.000Z
|
test/Succeed/Issue3659.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 3
|
2018-11-14T15:31:44.000Z
|
2019-04-01T19:39:26.000Z
|
test/Succeed/Issue3659.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1
|
2015-09-15T14:36:15.000Z
|
2015-09-15T14:36:15.000Z
|
{-# OPTIONS --cubical --allow-unsolved-metas #-}
open import Agda.Primitive.Cubical
module _ where
postulate
PathP : ∀ {ℓ} (A : I → Set ℓ) → A i0 → A i1 → Set ℓ
{-# BUILTIN PATHP PathP #-}
data D {ℓ} (A : Set ℓ) : Set ℓ where
c : PathP _ _ _
| 19.230769
| 53
| 0.604
|
41b4ab767d76019a85de84f3c3f5b21f726d147d
| 273
|
agda
|
Agda
|
test/interaction/Issue2413.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
test/interaction/Issue2413.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
test/interaction/Issue2413.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
-- Andreas, 2017-01-18, issue #2413
-- As-patterns of variable patterns
data Bool : Set where
true false : Bool
test : Bool → Bool
test x@y = {!x!} -- split on x
test1 : Bool → Bool
test1 x@_ = {!x!} -- split on x
test2 : Bool → Bool
test2 x@y = {!y!} -- split on y
| 18.2
| 35
| 0.608059
|
2206c58e6804f6adc8ad4a0c27f5f1bf503e8c48
| 118
|
agda
|
Agda
|
test/interaction/Issue589.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
test/interaction/Issue589.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
test/interaction/Issue589.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
module Issue589 where
data N : Set where
zero : N
suc : N -> N
_+_ : N -> N -> N
zero + y = y
suc x + y = suc ?
| 11.8
| 21
| 0.516949
|
8b82d0396f73915901b501485051e561dfe6d648
| 123
|
agda
|
Agda
|
Cubical/HITs/RPn.agda
|
kiana-S/univalent-foundations
|
8bdb0766260489f9c89a14f4c0f2ad26e5190dec
|
[
"MIT"
] | null | null | null |
Cubical/HITs/RPn.agda
|
kiana-S/univalent-foundations
|
8bdb0766260489f9c89a14f4c0f2ad26e5190dec
|
[
"MIT"
] | 1
|
2022-01-27T02:07:48.000Z
|
2022-01-27T02:07:48.000Z
|
Cubical/HITs/RPn.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.RPn where
open import Cubical.HITs.RPn.Base public
| 24.6
| 50
| 0.731707
|
adb14fb6302315b71a06ee262012b6fb3b97ca77
| 884
|
agda
|
Agda
|
test/Succeed/EtaInductiveRecord.agda
|
redfish64/autonomic-agda
|
c0ae7d20728b15d7da4efff6ffadae6fe4590016
|
[
"BSD-3-Clause"
] | null | null | null |
test/Succeed/EtaInductiveRecord.agda
|
redfish64/autonomic-agda
|
c0ae7d20728b15d7da4efff6ffadae6fe4590016
|
[
"BSD-3-Clause"
] | null | null | null |
test/Succeed/EtaInductiveRecord.agda
|
redfish64/autonomic-agda
|
c0ae7d20728b15d7da4efff6ffadae6fe4590016
|
[
"BSD-3-Clause"
] | null | null | null |
-- 2014-02-08 Andreas
-- Eta-equality for records that are recursive via some data type
module _ where
open import Common.Equality
module Nested where
data List (A : Set) : Set where
[] : List A
_∷_ : (x : A)(xs : List A) → List A
record Tree (A : Set) : Set where
inductive
constructor tree
field
elem : A
subtrees : List (Tree A)
open Tree
test : ∀ {A} (t : Tree A) → t ≡ tree (elem t) (subtrees t)
test t = refl
-- we should have eta for Tree!
module Mutual where
mutual
data TreeList (A : Set) : Set where
[] : TreeList A
_∷_ : (x : Tree A)(xs : TreeList A) → TreeList A
record Tree (A : Set) : Set where
inductive
constructor tree
field
elem : A
subtrees : TreeList A
open Tree
test : ∀ {A} (t : Tree A) → t ≡ tree (elem t) (subtrees t)
test t = refl
| 19.644444
| 65
| 0.573529
|
9a02215e6fe673c112f6bee8ab9faa0bfa21b502
| 29,114
|
agda
|
Agda
|
Cubical/Experiments/ZCohomologyOld/Properties.agda
|
L-TChen/cubical
|
60226aacd7b386aef95d43a0c29c4eec996348a8
|
[
"MIT"
] | null | null | null |
Cubical/Experiments/ZCohomologyOld/Properties.agda
|
L-TChen/cubical
|
60226aacd7b386aef95d43a0c29c4eec996348a8
|
[
"MIT"
] | null | null | null |
Cubical/Experiments/ZCohomologyOld/Properties.agda
|
L-TChen/cubical
|
60226aacd7b386aef95d43a0c29c4eec996348a8
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --cubical --no-import-sorts --safe #-}
module Cubical.Experiments.ZCohomologyOld.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 _ℤ+_) hiding (-_)
open import Cubical.Data.Nat
open import Cubical.HITs.Truncation renaming (elim to trElim ; map to trMap ; rec to trRec ; elim3 to trElim3) hiding (map2)
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.Experiments.ZCohomologyOld.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
abstract
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')
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 {G = coHom n A} (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
| 45.848819
| 168
| 0.496187
|
c77e5e426e10f58be576b49f1efacd9ab04a393e
| 5,372
|
agda
|
Agda
|
Cubical/Data/Fin/Properties.agda
|
limemloh/cubical
|
df4ef7edffd1c1deb3d4ff342c7178e9901c44f1
|
[
"MIT"
] | null | null | null |
Cubical/Data/Fin/Properties.agda
|
limemloh/cubical
|
df4ef7edffd1c1deb3d4ff342c7178e9901c44f1
|
[
"MIT"
] | null | null | null |
Cubical/Data/Fin/Properties.agda
|
limemloh/cubical
|
df4ef7edffd1c1deb3d4ff342c7178e9901c44f1
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --cubical --safe #-}
module Cubical.Data.Fin.Properties where
open import Cubical.Core.Everything
open import Cubical.Foundations.Embedding
open import Cubical.Foundations.Function
open import Cubical.Foundations.HLevels
open import Cubical.Foundations.Isomorphism
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Univalence
open import Cubical.Data.Fin.Base
open import Cubical.Data.Nat
open import Cubical.Data.Nat.Order
open import Cubical.Data.Empty
open import Cubical.Data.Sum
open import Cubical.Data.Sigma
open import Cubical.Induction.WellFounded
private
-- Σ is more convenient than the inductive ×, but I don't
-- want to have to write λ_→ all over.
_×_ : Type₀ → Type₀ → Type₀
A × B = Σ A λ _ → B
-- Fin 0 is empty, and thus a proposition.
Fin0-isProp : isProp (Fin 0)
Fin0-isProp = ⊥-elim ∘ ¬Fin0
-- Fin 1 has only one value.
Fin1-isContr : isContr (Fin 1)
Fin1-isContr
= fzero , λ
{ (zero , _) → toℕ-injective refl
; (suc k , sk<1) → ⊥-elim (¬-<-zero (pred-≤-pred sk<1))
}
-- Regardless of k, Fin k is a set.
isSetFin : ∀{k} → isSet (Fin k)
isSetFin {k} = isOfHLevelΣ 2 isSetℕ (λ _ → isProp→isSet m≤n-isProp)
-- Helper function for the reduction procedure below.
--
-- If n = expand o k m, then n is congruent to m modulo k.
expand : ℕ → ℕ → ℕ → ℕ
expand 0 k m = m
expand (suc o) k m = k + expand o k m
expand≡ : ∀ k m o → expand o k m ≡ o * k + m
expand≡ k m zero = refl
expand≡ k m (suc o)
= cong (k +_) (expand≡ k m o) ∙ +-assoc k (o * k) m
-- Expand a pair. This is useful because the whole function is
-- injective.
expand× : ∀{k} → (Fin k × ℕ) → ℕ
expand× {k} (f , o) = expand o k (toℕ f)
private
lemma₀ : ∀{k m n r} → r ≡ n → k + m ≡ n → k ≤ r
lemma₀ {k = k} {m} p q = m , +-comm m k ∙ q ∙ sym p
expand×Inj : ∀ k → {t1 t2 : Fin (suc k) × ℕ} → expand× t1 ≡ expand× t2 → t1 ≡ t2
expand×Inj k {f1 , zero} {f2 , zero} p i
= toℕ-injective {fj = f1} {f2} p i , zero
expand×Inj k {f1 , suc o1} {(r , r<sk) , zero} p
= ⊥-elim (<-asym r<sk (lemma₀ refl p))
expand×Inj k {(r , r<sk) , zero} {f2 , suc o2} p
= ⊥-elim (<-asym r<sk (lemma₀ refl (sym p)))
expand×Inj k {f1 , suc o1} {f2 , suc o2}
= cong (λ { (f , o) → (f , suc o) })
∘ expand×Inj k {f1 , o1} {f2 , o2}
∘ inj-m+ {suc k}
expand×Emb : ∀ k → isEmbedding (expand× {k})
expand×Emb 0 = ⊥-elim ∘ ¬Fin0 ∘ fst
expand×Emb (suc k)
= injEmbedding (isOfHLevelΣ 2 isSetFin (λ _ → isSetℕ)) isSetℕ (expand×Inj k)
-- A Residue is a family of types representing evidence that a
-- natural is congruent to a value of a finite type.
Residue : ℕ → ℕ → Type₀
Residue k n = Σ[ tup ∈ Fin k × ℕ ] expand× tup ≡ n
extract : ∀{k n} → Residue k n → Fin k
extract = fst ∘ fst
-- There is at most one canonical finite value congruent to each
-- natural.
isPropResidue : ∀ k n → isProp (Residue k n)
isPropResidue k = isEmbedding→hasPropFibers (expand×Emb k)
-- A value of a finite type is its own residue.
Fin→Residue : ∀{k} → (f : Fin k) → Residue k (toℕ f)
Fin→Residue f = (f , 0) , refl
-- Fibers of numbers that differ by k are equivalent in a more obvious
-- way than via the fact that they are propositions.
Residue+k : (k n : ℕ) → Residue k n → Residue k (k + n)
Residue+k k n ((f , o) , p) = (f , suc o) , cong (k +_) p
Residue-k : (k n : ℕ) → Residue k (k + n) → Residue k n
Residue-k k n (((r , r<k) , zero) , p) = ⊥-elim (<-asym r<k (lemma₀ p refl))
Residue-k k n ((f , suc o) , p) = ((f , o) , inj-m+ p)
Residue+k-k
: (k n : ℕ)
→ (R : Residue k (k + n))
→ Residue+k k n (Residue-k k n R) ≡ R
Residue+k-k k n (((r , r<k) , zero) , p) = ⊥-elim (<-asym r<k (lemma₀ p refl))
Residue+k-k k n ((f , suc o) , p)
= ΣProp≡ (λ tup → isSetℕ (expand× tup) (k + n)) refl
Residue-k+k
: (k n : ℕ)
→ (R : Residue k n)
→ Residue-k k n (Residue+k k n R) ≡ R
Residue-k+k k n ((f , o) , p)
= ΣProp≡ (λ tup → isSetℕ (expand× tup) n) refl
private
Residue≃ : ∀ k n → Residue k n ≃ Residue k (k + n)
Residue≃ k n
= Residue+k k n
, isoToIsEquiv (iso (Residue+k k n) (Residue-k k n)
(Residue+k-k k n) (Residue-k+k k n))
Residue≡ : ∀ k n → Residue k n ≡ Residue k (k + n)
Residue≡ k n = ua (Residue≃ k n)
-- For positive `k`, all `n` have a canonical residue mod `k`.
module Reduce (k₀ : ℕ) where
k : ℕ
k = suc k₀
base : ∀ n (n<k : n < k) → Residue k n
base n n<k = Fin→Residue (n , n<k)
step : ∀ n → Residue k n → Residue k (k + n)
step n = transport (Residue≡ k n)
reduce : ∀ n → Residue k n
reduce = +induction k₀ (Residue k) base step
reduce≡
: ∀ n → transport (Residue≡ k n) (reduce n) ≡ reduce (k + n)
reduce≡ n
= sym (+inductionStep k₀ _ base step n)
reduceP
: ∀ n → PathP (λ i → Residue≡ k n i) (reduce n) (reduce (k + n))
reduceP n = toPathP (reduce≡ n)
open Reduce using (reduce; reduce≡) public
private
lemma₅
: ∀ k n (R : Residue k n)
→ extract R ≡ extract (transport (Residue≡ k n) R)
lemma₅ k n = sym ∘ cong extract ∘ uaβ (Residue≃ k n)
-- The residue of n modulo k is the same as the residue of k + n.
extract≡ : ∀ k n → extract (reduce k n) ≡ extract (reduce k (suc k + n))
extract≡ k n
= lemma₅ (suc k) n (reduce k n) ∙ cong extract (Reduce.reduce≡ k n)
isContrResidue : ∀{k n} → isContr (Residue (suc k) n)
isContrResidue {k} {n} = inhProp→isContr (reduce k n) (isPropResidue (suc k) n)
| 31.232558
| 82
| 0.606664
|
04a2f3e48231e2010116a3b1be625f8ce2c6c193
| 6,435
|
agda
|
Agda
|
archive/agda-2/Oscar/Data6.agda
|
m0davis/oscar
|
52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb
|
[
"RSA-MD"
] | null | null | null |
archive/agda-2/Oscar/Data6.agda
|
m0davis/oscar
|
52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb
|
[
"RSA-MD"
] | 1
|
2019-04-29T00:35:04.000Z
|
2019-05-11T23:33:04.000Z
|
archive/agda-2/Oscar/Data6.agda
|
m0davis/oscar
|
52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb
|
[
"RSA-MD"
] | null | null | null |
{- -}
-- starting from builtins
-- forgot what the point of this was...
module Oscar.Data6 where
open import Oscar.Category.Semigroupoid
open import Oscar.Category.Category
open import Oscar.Category.Morphism
open import Oscar.Category.Setoid
open import Oscar.Function
open import Agda.Builtin.Unit using () renaming (⊤ to 𝟙; tt to ∅)
open import Agda.Builtin.Nat using () renaming (Nat to ℕ; zero to ∅; suc to ↑_)
open import Agda.Builtin.List using () renaming (List to [_]ℕ; [] to ∅; _∷_ to _+_)
open import Oscar.Level
⟦_⟧ℕ[<_↓]
⟦_⟧ℕ[_≤_↓]
⟦_⟧ℕ[↥_≤_]
⟦_⟧ℕ[↓_≤_↓]
-- Fin (with a payload)
data ⟦_⟧ℕ[0…_-1] {a} (A : ℕ → Set a) : ℕ → Set a where
∅ : ∀ {n} → ⟦ A ⟧ℕ[<↑ ↑ n ]
_∷_ : ∀ {n} → A n → ⟦ A ⟧ℕ[ n ] → ⟦ A ⟧ℕ[<↑ ↑ n ]
-- Vec (with an (optional) index)
data ⟦_⟧ℕ[≤_] {a} (A : ℕ → Set a) : ℕ → Set a where
∅ : ⟦ A ⟧ℕ[ ∅ ₀]
_∷_ : ∀ {n} → A n → ⟦ A ⟧ℕ[ n ₀] → ⟦ A ⟧ℕ[ ¡ n ₀]
-- m ≤ n, counting down from n-1 to m
data ⟦_⟧ℕ[_≤_↓] {a} (A : ℕ → Set a) (m : ℕ) : ℕ → Set a where
∅ : ⟦ A ⟧ℕ[ m ≤ m ↓]
_∷_ : ∀ {n} → A n → ⟦ A ⟧ℕ[ m ≤ n ↓] → ⟦ A ⟧ℕ[ m ≤ ¡ n ↓]
-- m ≤ n, counting up from m to n-1
data ⟦_⟧ℕ[↑_≤_] {a} (A : ℕ → Set a) (m : ℕ) : ℕ → Set a where
∅ : ⟦ A ⟧ℕ[↑ m ≤ m ]
_∷_ : ∀ {n} → A m → ⟦ A ⟧ℕ[↑ ¡ m ≤ n ] → ⟦ A ⟧ℕ[↑ m ≤ n ]
-- Inj (almost)
data ⟦_⟧ℕ[↓_≤_↓] {a} (A : ℕ → ℕ → Set a) : ℕ → ℕ → Set a where
∅ : ∀ {n} → ⟦ A ⟧ℕ[↓ ∅ ≤ n ↓]
_∷_ : ∀ {m n} → A m n → ⟦ A ⟧ℕ[↓ m ≤ n ↓] → ⟦ A ⟧ℕ[↓ ¡ m ≤ ¡ n ↓]
⟦_⟧ℕ[_⇒_]∞ : ∀ {a} (A : ℕ → Set a) → ℕ → ℕ → Set a
⟦ A ⟧ℕ[ m ⇒ n ]∞ = A m → A n
-- Fin (with a payload)
data ⟦_⟧ℕ[<_↓] {a} (A : ℕ → Set a) : ℕ → Set a where
∅ : ∀ {n} → ⟦ A ⟧[< ↑ n ↓]
_∷_ : ∀ {n} → A n → ⟦ A ⟧ℕ[< n ] → ⟦ A ⟧[< ↑ n ↓]
-- -- Vec (with an (optional) index)
data ℕ[_]=_ {a} (A : ℕ → Set a) : ℕ → Set a where
∅ : ℕ[ A ]= ∅
_∷_ : ∀ {n} → A n → ℕ[ A ]= ↑ n → ℕ[ A ]= ↑ n
ℕ=_ = ℕ[ const 𝟙 ]=_
-- m ≤ n, counting down from n-1 to m
data ℕ[_]≥_<↓_ {a} (A : ℕ → Set a) (m : ℕ) : ℕ → Set a where
∅ : ℕ[ A ]≥ m <↓ m
_∷_ : ∀ {n} → A n → ℕ[ A ]≥ m <↓ n → ℕ[ A ]≥ m <↓ ↑ n
ℕ≥_<↓_ = ℕ[ const 𝟙 ]≥_<↓_
-- m ≤ n, counting up from m to n-1
data ℕ[_]≥↑_<_ {a} (A : ℕ → Set a) (m : ℕ) : ℕ → Set a where
∅ : ℕ[ A ]≥↑ m < m
_∷_ : ∀ {n} → A m → ℕ[ A ]≥↑ ↑ m < n → ℕ[ A ]≥↑ m < n
ℕ≥↑_<_ = ℕ[ const 𝟙 ]≥↑_<_
-- -- Inj (almost)
-- data ⟦_⟧[↓_≤_↓] {a} (A : ⟦⟧ → ⟦⟧ → Set a) : ⟦⟧ → ⟦⟧ → Set a where
-- ∅ : ∀ {n} → ⟦ A ⟧[↓ ∅ ≤ n ↓]
-- _∷_ : ∀ {m n} → A m n → ⟦ A ⟧[↓ m ≤ n ↓] → ⟦ A ⟧[↓ ¡ m ≤ ¡ n ↓]
-- ⟦⟧[↓_≤_↓] = ⟦ Const Const ⊤ ⟧[↓_≤_↓]
-- ⟦_⟧[_⇒_]∞ : ∀ {a} (A : ⟦⟧ → Set a) → ⟦⟧ → ⟦⟧ → Set a
-- ⟦ A ⟧[ m ⇒ n ]∞ = A m → A n
-- --open import Oscar.Data.Equality
-- --open import Oscar.Data.Equality.properties
-- module _ {𝔬 𝔪 𝔮} (G : Semigroupoid 𝔬 𝔪 𝔮) where
-- open Semigroupoid G
-- {-
-- _≋̇_ : ∀ {a} {A : ⋆ → Set a} {m n : ⋆} → (A m → A n) → (A m → A n) → Set 𝔮
-- _≋̇_ {A = A} {m = m} m→n₁ m→n₂ = {!∀ (am : A m) → m→n₁ am ≋ m→n₂ am!}
-- cat2 : ∀ {a} (A : ⋆ → Set a) → Category {!!} {!!} {!!}
-- Semigroupoid.⋆ (Category.semigroupoid (cat2 A)) = ⋆
-- Setoid.⋆ ((Semigroupoid.𝔐 (Category.semigroupoid (cat2 A)) Morphism.⇒ m) n) = A m → A n
-- IsSetoid._≋_ (Setoid.isSetoid ((Semigroupoid.𝔐 (Category.semigroupoid (cat2 A)) Morphism.⇒ m) n)) = _≡̇_
-- IsSetoid.isEquivalence (Setoid.isSetoid ((Semigroupoid.𝔐 (Category.semigroupoid (cat2 A)) Morphism.⇒ m) n)) = it
-- Semigroupoid._∙_ (Category.semigroupoid (cat2 A)) g f = g ∘ f
-- Semigroupoid.isSemigroupoid (Category.semigroupoid (cat2 A)) = it
-- Category.ε (cat2 A) = id
-- Category.isCategory (cat2 A) = it
-- cat2G : ∀ {a} (A : ⋆ → Set a) → ∀ ℓ ⦃ _ : ∀ {n : ⋆} → IsSetoid (A n) ℓ ⦄ → Category {!!} {!!} {!!}
-- Semigroupoid.⋆ (Category.semigroupoid (cat2G A ℓ)) = ⋆
-- Setoid.⋆ ((Semigroupoid.𝔐 (Category.semigroupoid (cat2G A ℓ)) Morphism.⇒ m) n) = A m → A n
-- IsSetoid._≋_ (Setoid.isSetoid ((Semigroupoid.𝔐 (Category.semigroupoid (cat2G A ℓ)) Morphism.⇒ m) n)) m↦n₁ m↦n₂ = ∀ (am : A m) → m↦n₁ am ≋ m↦n₂ am
-- -- ∀ (am : A m) → m↦n₁ am ≋ m↦n₂ am
-- {-
-- _≋̇_ : ∀ {a} {A : ⋆ → Set a} {m n : ⋆} → (A m → A n) → (A m → A n) → Set 𝔮
-- _≋̇_ {A = A} {m = m} m→n₁ m→n₂ = {!∀ (am : A m) → m→n₁ am ≋ m→n₂ am!}
-- -}
-- IsSetoid.isEquivalence (Setoid.isSetoid ((Semigroupoid.𝔐 (Category.semigroupoid (cat2G A ℓ)) Morphism.⇒ m) n)) = {!it!}
-- Semigroupoid._∙_ (Category.semigroupoid (cat2G A ℓ)) g f = g ∘ f
-- Semigroupoid.isSemigroupoid (Category.semigroupoid (cat2G A ℓ)) = {!it!}
-- Category.ε (cat2G A ℓ) = id
-- Category.isCategory (cat2G A ℓ) = {!it!}
-- -}
-- infix 21 ‼_
-- pattern ‼_ ⟦A⟧ = tt ∷ ⟦A⟧ -- tricky, works for all above _∷_ constructors only because it is defined afterwards, won't work for any later-defined constructors
-- open import Agda.Primitive
-- open import Oscar.Data.Product
-- open import Oscar.Function
-- postulate
-- ℓ : Level
-- Term : ⟦⟧ → Set ℓ
-- Step : ⟦⟧ → Set ℓ
-- Fin = ⟦⟧[_]
-- Inj = ⟦ Const Fin ⟧[↓_≤_↓]
-- Terms = λ N n → ⟦ Const (Term n) ⟧[ N ₀]
-- AList = ⟦ (λ n → Term n × Fin (¡ n)) ⟧[_≤_↓]
-- Fx : ∀ {a} {A : Set a} → A → A → ∀ {b₁} (B₁ : A → Set b₁) → ∀ {b₂} (B₂ : A → Set b₂) → Set (b₁ ⊔ b₂)
-- Fx m n B₁ B₂ = B₁ m → B₂ n
-- Fx₁ : ∀ {a} {A : Set a} → A → ∀ {b₁} (B₁ : A → Set b₁) → ∀ {b₂} (B₂ : A → Set b₂) → Set (b₁ ⊔ b₂)
-- Fx₁ n B₁ B₂ = Fx n n B₁ B₂
-- ListStep = λ n → ⟦ Step n ⟧
-- Rel : ∀ {a} {A : Set a} {b₁} (B₁ : A → Set b₁) {b₂} (B₂ : A → Set b₂) {c₁} (C₁ : A → Set c₁) {c₂} (C₂ : A → Set c₂) → Set (a ⊔ b₁ ⊔ b₂ ⊔ c₁ ⊔ c₂)
-- Rel B₁ B₂ C₁ C₂ = ∀ {m n} → Fx m n B₁ B₂ → Fx m n C₁ C₂
-- Morph : ∀ {a} {A : Set a} {b₁} {b₂} (B : (A → Set b₁) × (A → Set b₂)) {c₁} {c₂} (C₂ : (A → Set c₁) × (A → Set c₂)) → Set (a ⊔ b₁ ⊔ b₂ ⊔ c₁ ⊔ c₂)
-- Morph (B₁ , B₂) (C₁ , C₂) = ∀ {m n} → Fx m n B₁ B₂ → Fx m n C₁ C₂
-- -- functor mappings
-- postulate
-- _◃_ : Morph (Fin , Term) (Term , Term)
-- _◃s_ : ∀ N → Morph (Fin , Term) (Terms N , Terms N)
-- sub : ∀ {m n} → AList m n → Fx m n Fin Term
-- fmapS : Morph (Term , Term) (Step , Step)
-- _◃S_ : Morph (Fin , Term) (ListStep , ListStep)
-- -- ?
-- postulate
-- _⊹_ : ∀ {n} → ⟦ Step n ⟧ → Fx₁ n Term Term
-- testNat : ⟦⟧
-- testNat = ¡ ∅
-- testListNat : ⟦ ⟦⟧ ⟧
-- testListNat = ¡ ∅ ∷ ‼ ∅ ∷ ‼ ‼ ∅ ∷ ∅ ∷ ¡ ¡ ¡ ∅ ∷ ∅
-- testFin : ⟦⟧[ ¡ ¡ ∅ ]
-- testFin = ‼ ∅
-- test≤↓ : ⟦⟧[ ‼ ‼ ‼ ∅ ≤ ‼ ‼ ‼ ‼ ‼ ∅ ↓]
-- test≤↓ = ‼ ‼ ∅
-- ⓪ ⑴ ⑵ ⑶ : ⟦⟧
-- ⓪ = ∅
-- ⑴ = ‼ ∅
-- ⑵ = ‼ ⑴
-- ⑶ = ‼ ⑵
-- testInj : Inj ⑵ ⑶
-- testInj = ‼ ∅ ∷ ∅ ∷ ∅
| 32.831633
| 161
| 0.471639
|
1e75a12d9d1821a5bc73ae8844ad46d693e717f6
| 1,138
|
agda
|
Agda
|
currypp/.cpm/packages/currycheck/examples/withVerification/PROOF-sortPreservesLength.agda
|
phlummox/curry-tools
|
7905bc4f625a94a725f9f6d8a2de1140bea5e471
|
[
"BSD-3-Clause"
] | null | null | null |
currypp/.cpm/packages/currycheck/examples/withVerification/PROOF-sortPreservesLength.agda
|
phlummox/curry-tools
|
7905bc4f625a94a725f9f6d8a2de1140bea5e471
|
[
"BSD-3-Clause"
] | null | null | null |
currypp/.cpm/packages/currycheck/examples/withVerification/PROOF-sortPreservesLength.agda
|
phlummox/curry-tools
|
7905bc4f625a94a725f9f6d8a2de1140bea5e471
|
[
"BSD-3-Clause"
] | null | null | null |
-- Agda program using the Iowa Agda library
open import bool
module PROOF-sortPreservesLength
(Choice : Set)
(choose : Choice → 𝔹)
(lchoice : Choice → Choice)
(rchoice : Choice → Choice)
where
open import eq
open import nat
open import list
open import maybe
---------------------------------------------------------------------------
-- Translated Curry operations:
insert : ℕ → 𝕃 ℕ → 𝕃 ℕ
insert x [] = x :: []
insert y (z :: u) = if y ≤ z then y :: (z :: u) else z :: (insert y u)
sort : 𝕃 ℕ → 𝕃 ℕ
sort [] = []
sort (x :: y) = insert x (sort y)
---------------------------------------------------------------------------
insertIncLength : (x : ℕ) → (xs : 𝕃 ℕ)
→ length (insert x xs) ≡ suc (length xs)
insertIncLength x [] = refl
insertIncLength x (y :: ys) with (x ≤ y)
... | tt = refl
... | ff rewrite insertIncLength x ys = refl
sortPreservesLength : (xs : 𝕃 ℕ) → length (sort xs) ≡ length xs
sortPreservesLength [] = refl
sortPreservesLength (x :: xs)
rewrite insertIncLength x (sort xs) | sortPreservesLength xs = refl
---------------------------------------------------------------------------
| 26.465116
| 75
| 0.505272
|
13917ab6ef1cbb0e2cf0878b23b9628177b1686f
| 563
|
agda
|
Agda
|
notes/papers/implicit/examples/Dangerous-AgdaLight.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
notes/papers/implicit/examples/Dangerous-AgdaLight.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
notes/papers/implicit/examples/Dangerous-AgdaLight.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
data N : Set where
zero : N
suc : N -> N
data B : Set where
true : B
false : B
data False : Set where
data True : Set where
tt : True
F : B -> Set
F true = N
F false = B
G : (x:B) -> F x -> Set
G false _ = N
G true zero = B
G true (suc n) = N
(==) : B -> B -> Set
true == true = True
false == false = True
_ == _ = False
data Equal (x,y:B) : Set where
equal : x == y -> Equal x y
refl : (x:B) -> Equal x x
refl true = equal tt
refl false = equal tt
f : (x:B) -> (y : F x) -> Equal x true -> G x y
h : N
h = f _ false (refl true)
| 14.075
| 47
| 0.520426
|
2ef2fd44746a56ddd35b39d397a33dc50f767b2d
| 1,524
|
agda
|
Agda
|
Definition/Typed/Reduction.agda
|
fhlkfy/logrel-mltt
|
ea83fc4f618d1527d64ecac82d7d17e2f18ac391
|
[
"MIT"
] | 30
|
2017-05-20T03:05:21.000Z
|
2022-03-30T18:01:07.000Z
|
Definition/Typed/Reduction.agda
|
fhlkfy/logrel-mltt
|
ea83fc4f618d1527d64ecac82d7d17e2f18ac391
|
[
"MIT"
] | 4
|
2017-06-22T12:49:23.000Z
|
2021-02-22T10:37:24.000Z
|
Definition/Typed/Reduction.agda
|
fhlkfy/logrel-mltt
|
ea83fc4f618d1527d64ecac82d7d17e2f18ac391
|
[
"MIT"
] | 8
|
2017-10-18T14:18:20.000Z
|
2021-11-27T15:58:33.000Z
|
{-# OPTIONS --without-K --safe #-}
module Definition.Typed.Reduction where
open import Definition.Untyped
open import Definition.Typed
open import Definition.Typed.Properties
open import Tools.Nat
private
variable
n : Nat
Γ : Con Term n
A A′ B B′ : Term n
a a′ b b′ : Term n
-- Weak head expansion of type equality
reduction : Γ ⊢ A ⇒* A′
→ Γ ⊢ B ⇒* B′
→ Whnf A′
→ Whnf B′
→ Γ ⊢ A′ ≡ B′
→ Γ ⊢ A ≡ B
reduction D D′ whnfA′ whnfB′ A′≡B′ =
trans (subset* D) (trans A′≡B′ (sym (subset* D′)))
reduction′ : Γ ⊢ A ⇒* A′
→ Γ ⊢ B ⇒* B′
→ Whnf A′
→ Whnf B′
→ Γ ⊢ A ≡ B
→ Γ ⊢ A′ ≡ B′
reduction′ D D′ whnfA′ whnfB′ A≡B =
trans (sym (subset* D)) (trans A≡B (subset* D′))
-- Weak head expansion of term equality
reductionₜ : Γ ⊢ A ⇒* B
→ Γ ⊢ a ⇒* a′ ∷ B
→ Γ ⊢ b ⇒* b′ ∷ B
→ Whnf B
→ Whnf a′
→ Whnf b′
→ Γ ⊢ a′ ≡ b′ ∷ B
→ Γ ⊢ a ≡ b ∷ A
reductionₜ D d d′ whnfB whnfA′ whnfB′ a′≡b′ =
conv (trans (subset*Term d)
(trans a′≡b′ (sym (subset*Term d′))))
(sym (subset* D))
reductionₜ′ : Γ ⊢ A ⇒* B
→ Γ ⊢ a ⇒* a′ ∷ B
→ Γ ⊢ b ⇒* b′ ∷ B
→ Whnf B
→ Whnf a′
→ Whnf b′
→ Γ ⊢ a ≡ b ∷ A
→ Γ ⊢ a′ ≡ b′ ∷ B
reductionₜ′ D d d′ whnfB whnfA′ whnfB′ a≡b =
trans (sym (subset*Term d))
(trans (conv a≡b (subset* D)) (subset*Term d′))
| 24.580645
| 55
| 0.446194
|
1ed5f3b51ff67762636c6b9182af9e7fc39586ee
| 2,037
|
agda
|
Agda
|
agda-stdlib/src/Data/AVL/IndexedMap.agda
|
DreamLinuxer/popl21-artifact
|
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
|
[
"MIT"
] | 5
|
2020-10-07T12:07:53.000Z
|
2020-10-10T21:41:32.000Z
|
agda-stdlib/src/Data/AVL/IndexedMap.agda
|
DreamLinuxer/popl21-artifact
|
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
|
[
"MIT"
] | null | null | null |
agda-stdlib/src/Data/AVL/IndexedMap.agda
|
DreamLinuxer/popl21-artifact
|
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
|
[
"MIT"
] | 1
|
2021-11-04T06:54:45.000Z
|
2021-11-04T06:54:45.000Z
|
------------------------------------------------------------------------
-- The Agda standard library
--
-- Finite maps with indexed keys and values, based on AVL trees
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
open import Data.Product as Prod
open import Relation.Binary
open import Relation.Binary.PropositionalEquality using (_≡_; cong; subst)
import Data.AVL.Value
module Data.AVL.IndexedMap
{i k v ℓ}
{Index : Set i} {Key : Index → Set k} (Value : Index → Set v)
{_<_ : Rel (∃ Key) ℓ}
(isStrictTotalOrder : IsStrictTotalOrder _≡_ _<_)
where
import Data.AVL
open import Data.Bool.Base
open import Data.List.Base as List using (List)
open import Data.Maybe.Base as Maybe
open import Function
open import Level
-- Key/value pairs.
KV : Set (i ⊔ k ⊔ v)
KV = ∃ λ i → Key i × Value i
-- Conversions.
private
fromKV : KV → Σ[ ik ∈ ∃ Key ] Value (proj₁ ik)
fromKV (i , k , v) = ((i , k) , v)
toKV : Σ[ ik ∈ ∃ Key ] Value (proj₁ ik) → KV
toKV ((i , k) , v) = (i , k , v)
-- The map type.
private
open module AVL =
Data.AVL (record { isStrictTotalOrder = isStrictTotalOrder })
using () renaming (Tree to Map')
Map = Map' (AVL.MkValue (Value ∘ proj₁) (subst Value ∘′ cong proj₁))
-- Repackaged functions.
empty : Map
empty = AVL.empty
singleton : ∀ {i} → Key i → Value i → Map
singleton k v = AVL.singleton (-, k) v
insert : ∀ {i} → Key i → Value i → Map → Map
insert k v = AVL.insert (-, k) v
delete : ∀ {i} → Key i → Map → Map
delete k = AVL.delete (-, k)
lookup : ∀ {i} → Key i → Map → Maybe (Value i)
lookup k m = AVL.lookup (-, k) m
infix 4 _∈?_
_∈?_ : ∀ {i} → Key i → Map → Bool
_∈?_ k = AVL._∈?_ (-, k)
headTail : Map → Maybe (KV × Map)
headTail m = Maybe.map (Prod.map toKV id) (AVL.headTail m)
initLast : Map → Maybe (Map × KV)
initLast m = Maybe.map (Prod.map id toKV) (AVL.initLast m)
fromList : List KV → Map
fromList = AVL.fromList ∘ List.map fromKV
toList : Map → List KV
toList = List.map toKV ∘ AVL.toList
| 24.25
| 74
| 0.587629
|
1eedfffd448b35a1aa8c8b1aef4782deee51f5ae
| 6,142
|
agda
|
Agda
|
src/Categories/Object/Product/Core.agda
|
MirceaS/agda-categories
|
58e5ec015781be5413bdf968f7ec4fdae0ab4b21
|
[
"MIT"
] | null | null | null |
src/Categories/Object/Product/Core.agda
|
MirceaS/agda-categories
|
58e5ec015781be5413bdf968f7ec4fdae0ab4b21
|
[
"MIT"
] | null | null | null |
src/Categories/Object/Product/Core.agda
|
MirceaS/agda-categories
|
58e5ec015781be5413bdf968f7ec4fdae0ab4b21
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --without-K --safe #-}
open import Categories.Category
module Categories.Object.Product.Core {o ℓ e} (𝒞 : Category o ℓ e) where
open import Level
open import Function using (flip; _$_)
open import Categories.Morphism 𝒞
open import Categories.Morphism.Reasoning 𝒞
open Category 𝒞
open HomReasoning
private
variable
A B C D X Y Z : Obj
h i j : A ⇒ B
-- Borrowed from Dan Doel's definition of products
record Product (A B : Obj) : Set (o ⊔ ℓ ⊔ e) where
infix 10 ⟨_,_⟩
field
A×B : Obj
π₁ : A×B ⇒ A
π₂ : A×B ⇒ B
⟨_,_⟩ : C ⇒ A → C ⇒ B → C ⇒ A×B
project₁ : π₁ ∘ ⟨ h , i ⟩ ≈ h
project₂ : π₂ ∘ ⟨ h , i ⟩ ≈ i
unique : π₁ ∘ h ≈ i → π₂ ∘ h ≈ j → ⟨ i , j ⟩ ≈ h
g-η : ⟨ π₁ ∘ h , π₂ ∘ h ⟩ ≈ h
g-η = unique refl refl
η : ⟨ π₁ , π₂ ⟩ ≈ id
η = unique identityʳ identityʳ
⟨⟩-cong₂ : ∀ {f f′ : C ⇒ A} {g g′ : C ⇒ B} → f ≈ f′ → g ≈ g′ → ⟨ f , g ⟩ ≈ ⟨ f′ , g′ ⟩
⟨⟩-cong₂ f≡f′ g≡g′ = unique (project₁ ○ ⟺ f≡f′) (project₂ ○ ⟺ g≡g′)
∘-distribʳ-⟨⟩ : ∀ {f : C ⇒ A} {g : C ⇒ B} {q : D ⇒ C} → ⟨ f , g ⟩ ∘ q ≈ ⟨ f ∘ q , g ∘ q ⟩
∘-distribʳ-⟨⟩ = ⟺ $ unique (pullˡ project₁) (pullˡ project₂)
unique′ : π₁ ∘ h ≈ π₁ ∘ i → π₂ ∘ h ≈ π₂ ∘ i → h ≈ i
unique′ eq₁ eq₂ = trans (sym (unique eq₁ eq₂)) g-η
module _ {A B : Obj} where
open Product {A} {B} renaming (⟨_,_⟩ to _⟨_,_⟩)
repack : (p₁ p₂ : Product A B) → A×B p₁ ⇒ A×B p₂
repack p₁ p₂ = p₂ ⟨ π₁ p₁ , π₂ p₁ ⟩
repack∘ : (p₁ p₂ p₃ : Product A B) → repack p₂ p₃ ∘ repack p₁ p₂ ≈ repack p₁ p₃
repack∘ p₁ p₂ p₃ = ⟺ $ unique p₃
(glueTrianglesʳ (project₁ p₃) (project₁ p₂))
(glueTrianglesʳ (project₂ p₃) (project₂ p₂))
repack≡id : (p : Product A B) → repack p p ≈ id
repack≡id = η
repack-cancel : (p₁ p₂ : Product A B) → repack p₁ p₂ ∘ repack p₂ p₁ ≈ id
repack-cancel p₁ p₂ = repack∘ p₂ p₁ p₂ ○ repack≡id p₂
up-to-iso : ∀ (p₁ p₂ : Product A B) → Product.A×B p₁ ≅ Product.A×B p₂
up-to-iso p₁ p₂ = record
{ from = repack p₁ p₂
; to = repack p₂ p₁
; iso = record
{ isoˡ = repack-cancel p₂ p₁
; isoʳ = repack-cancel p₁ p₂
}
}
transport-by-iso : ∀ (p : Product A B) → ∀ {X} → Product.A×B p ≅ X → Product A B
transport-by-iso p {X} p≅X = record
{ A×B = X
; π₁ = π₁ ∘ to
; π₂ = π₂ ∘ to
; ⟨_,_⟩ = λ h₁ h₂ → from ∘ ⟨ h₁ , h₂ ⟩
; project₁ = cancelInner isoˡ ○ project₁
; project₂ = cancelInner isoˡ ○ project₂
; unique = λ {_ i l r} pf₁ pf₂ → begin
from ∘ ⟨ l , r ⟩ ≈˘⟨ refl⟩∘⟨ ⟨⟩-cong₂ pf₁ pf₂ ⟩
from ∘ ⟨ (π₁ ∘ to) ∘ i , (π₂ ∘ to) ∘ i ⟩ ≈⟨ refl⟩∘⟨ unique sym-assoc sym-assoc ⟩
from ∘ to ∘ i ≈⟨ cancelˡ isoʳ ⟩
i ∎
}
where open Product p
open _≅_ p≅X
Reversible : (p : Product A B) → Product B A
Reversible p = record
{ A×B = A×B
; π₁ = π₂
; π₂ = π₁
; ⟨_,_⟩ = flip ⟨_,_⟩
; project₁ = project₂
; project₂ = project₁
; unique = flip unique
}
where open Product p
Commutative : (p₁ : Product A B) (p₂ : Product B A) → Product.A×B p₁ ≅ Product.A×B p₂
Commutative p₁ p₂ = up-to-iso p₁ (Reversible p₂)
Associable : ∀ (p₁ : Product X Y) (p₂ : Product Y Z) (p₃ : Product X (Product.A×B p₂)) → Product (Product.A×B p₁) Z
Associable p₁ p₂ p₃ = record
{ A×B = A×B p₃
; π₁ = p₁ ⟨ π₁ p₃ , π₁ p₂ ∘ π₂ p₃ ⟩
; π₂ = π₂ p₂ ∘ π₂ p₃
; ⟨_,_⟩ = λ f g → p₃ ⟨ π₁ p₁ ∘ f , p₂ ⟨ π₂ p₁ ∘ f , g ⟩ ⟩
; project₁ = λ {_ f g} → begin
p₁ ⟨ π₁ p₃ , π₁ p₂ ∘ π₂ p₃ ⟩ ∘ p₃ ⟨ π₁ p₁ ∘ f , p₂ ⟨ π₂ p₁ ∘ f , g ⟩ ⟩ ≈⟨ ∘-distribʳ-⟨⟩ p₁ ⟩
p₁ ⟨ π₁ p₃ ∘ p₃ ⟨ π₁ p₁ ∘ f , p₂ ⟨ π₂ p₁ ∘ f , g ⟩ ⟩
, (π₁ p₂ ∘ π₂ p₃) ∘ p₃ ⟨ π₁ p₁ ∘ f , p₂ ⟨ π₂ p₁ ∘ f , g ⟩ ⟩ ⟩ ≈⟨ ⟨⟩-cong₂ p₁ (project₁ p₃) (glueTrianglesˡ (project₁ p₂) (project₂ p₃)) ⟩
p₁ ⟨ π₁ p₁ ∘ f , π₂ p₁ ∘ f ⟩ ≈⟨ g-η p₁ ⟩
f ∎
; project₂ = λ {_ f g} → glueTrianglesˡ (project₂ p₂) (project₂ p₃)
; unique = λ {_ i f g} pf₁ pf₂ → begin
p₃ ⟨ π₁ p₁ ∘ f , p₂ ⟨ π₂ p₁ ∘ f , g ⟩ ⟩ ≈⟨ ⟨⟩-cong₂ p₃ (∘-resp-≈ʳ (sym pf₁))
(⟨⟩-cong₂ p₂ (∘-resp-≈ʳ (sym pf₁)) (sym pf₂)) ⟩
p₃ ⟨ π₁ p₁ ∘ p₁ ⟨ π₁ p₃ , π₁ p₂ ∘ π₂ p₃ ⟩ ∘ i
, p₂ ⟨ π₂ p₁ ∘ p₁ ⟨ π₁ p₃ , π₁ p₂ ∘ π₂ p₃ ⟩ ∘ i
, (π₂ p₂ ∘ π₂ p₃) ∘ i ⟩ ⟩ ≈⟨ ⟨⟩-cong₂ p₃ (pullˡ (project₁ p₁))
(⟨⟩-cong₂ p₂ (trans (pullˡ (project₂ p₁)) assoc)
assoc) ⟩
p₃ ⟨ π₁ p₃ ∘ i
, p₂ ⟨ π₁ p₂ ∘ π₂ p₃ ∘ i , π₂ p₂ ∘ π₂ p₃ ∘ i ⟩ ⟩ ≈⟨ ⟨⟩-cong₂ p₃ refl (g-η p₂) ⟩
p₃ ⟨ π₁ p₃ ∘ i , π₂ p₃ ∘ i ⟩ ≈⟨ g-η p₃ ⟩
i ∎
}
where open Product renaming (⟨_,_⟩ to _⟨_,_⟩)
Associative : ∀ (p₁ : Product X Y) (p₂ : Product Y Z)
(p₃ : Product X (Product.A×B p₂)) (p₄ : Product (Product.A×B p₁) Z) →
(Product.A×B p₃) ≅ (Product.A×B p₄)
Associative p₁ p₂ p₃ p₄ = up-to-iso (Associable p₁ p₂ p₃) p₄
Mobile : ∀ {A₁ B₁ A₂ B₂} (p : Product A₁ B₁) → A₁ ≅ A₂ → B₁ ≅ B₂ → Product A₂ B₂
Mobile p A₁≅A₂ B₁≅B₂ = record
{ A×B = A×B
; π₁ = from A₁≅A₂ ∘ π₁
; π₂ = from B₁≅B₂ ∘ π₂
; ⟨_,_⟩ = λ h k → ⟨ to A₁≅A₂ ∘ h , to B₁≅B₂ ∘ k ⟩
; project₁ = begin
(from A₁≅A₂ ∘ π₁) ∘ ⟨ to A₁≅A₂ ∘ _ , to B₁≅B₂ ∘ _ ⟩ ≈⟨ pullʳ project₁ ⟩
from A₁≅A₂ ∘ (to A₁≅A₂ ∘ _) ≈⟨ cancelˡ (isoʳ A₁≅A₂) ⟩
_ ∎
; project₂ = begin
(from B₁≅B₂ ∘ π₂) ∘ ⟨ to A₁≅A₂ ∘ _ , to B₁≅B₂ ∘ _ ⟩ ≈⟨ pullʳ project₂ ⟩
from B₁≅B₂ ∘ (to B₁≅B₂ ∘ _) ≈⟨ cancelˡ (isoʳ B₁≅B₂) ⟩
_ ∎
; unique = λ pfˡ pfʳ → unique (switch-fromtoˡ A₁≅A₂ (sym-assoc ○ pfˡ))
(switch-fromtoˡ B₁≅B₂ (sym-assoc ○ pfʳ))
}
where open Product p
open _≅_
| 38.149068
| 150
| 0.45604
|
0300fadf0b9e22f18eff270fcbdfa8c4eb01aa74
| 3,641
|
agda
|
Agda
|
examples/lib/Data/Permutation.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
examples/lib/Data/Permutation.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
examples/lib/Data/Permutation.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
module Data.Permutation where
{-
open import Prelude
open import Data.Fin as Fin hiding (_==_; _<_)
open import Data.Nat
open import Data.Vec
open import Logic.Identity
open import Logic.Base
import Logic.ChainReasoning
-- What is a permutation?
-- Answer 1: A bijection between Fin n and itself
data Permutation (n : Nat) : Set where
permutation :
(π π⁻¹ : Fin n -> Fin n) ->
(forall {i} -> π (π⁻¹ i) ≡ i) ->
Permutation n
module Permutation {n : Nat}(P : Permutation n) where
private
π' : Permutation n -> Fin n -> Fin n
π' (permutation x _ _) = x
π⁻¹' : Permutation n -> Fin n -> Fin n
π⁻¹' (permutation _ x _) = x
proof : (P : Permutation n) -> forall {i} -> π' P (π⁻¹' P i) ≡ i
proof (permutation _ _ x) = x
π : Fin n -> Fin n
π = π' P
π⁻¹ : Fin n -> Fin n
π⁻¹ = π⁻¹' P
module Proofs where
ππ⁻¹-id : {i : Fin n} -> π (π⁻¹ i) ≡ i
ππ⁻¹-id = proof P
open module Chain = Logic.ChainReasoning.Poly.Homogenous _≡_ (\x -> refl) (\x y z -> trans)
π⁻¹-inj : (i j : Fin n) -> π⁻¹ i ≡ π⁻¹ j -> i ≡ j
π⁻¹-inj i j h =
chain> i
=== π (π⁻¹ i) by sym ππ⁻¹-id
=== π (π⁻¹ j) by cong π h
=== j by ππ⁻¹-id
-- Generalise
lem : {n : Nat}(f g : Fin n -> Fin n)
-> (forall i -> f (g i) ≡ i)
-> (forall i -> g (f i) ≡ i)
lem {zero} f g inv ()
lem {suc n} f g inv i = ?
where
gz≠gs : {i : Fin n} -> g fzero ≢ g (fsuc i)
gz≠gs {i} gz=gs = fzero≠fsuc $
chain> fzero
=== f (g fzero) by sym (inv fzero)
=== f (g (fsuc i)) by cong f gz=gs
=== fsuc i by inv (fsuc i)
z≠f-thin-gz : {i : Fin n} -> fzero ≢ f (thin (g fzero) i)
z≠f-thin-gz {i} z=f-thin-gz = ?
-- f (g fzero)
-- = fzero
-- = f (thin (g fzero) i)
g' : Fin n -> Fin n
g' j = thick (g fzero) (g (fsuc j)) gz≠gs
f' : Fin n -> Fin n
f' j = thick fzero (f (thin (g fzero) j)) ?
g'f' : forall j -> g' (f' j) ≡ j
g'f' = lem {n} f' g' ?
π⁻¹π-id : forall {i} -> π⁻¹ (π i) ≡ i
π⁻¹π-id = ?
-- Answer 2: A Vec (Fin n) n with no duplicates
{-
infixr 40 _◅_ _↦_,_
infixr 20 _○_
data Permutation : Nat -> Set where
ε : Permutation zero
_◅_ : {n : Nat} -> Fin (suc n) -> Permutation n -> Permutation (suc n)
_↦_,_ : {n : Nat}(i j : Fin (suc n)) -> Permutation n -> Permutation (suc n)
fzero ↦ j , π = j ◅ π
fsuc i ↦ j , j' ◅ π = thin j j' ◅ i ↦ ? , π
indices : {n : Nat} -> Permutation n -> Vec (Fin n) n
indices ε = []
indices (i ◅ π) = i :: map (thin i) (indices π)
-- permute (i ◅ π) xs with xs [!] i where
-- permute₁ (i ◅ π) .(insert i x xs) (ixV x xs) = x :: permute π xs
permute : {n : Nat}{A : Set} -> Permutation n -> Vec A n -> Vec A n
permute (i ◅ π) xs = permute' π i xs (xs [!] i)
where
permute' : {n : Nat}{A : Set} -> Permutation n -> (i : Fin (suc n))(xs : Vec A (suc n)) ->
IndexView i xs -> Vec A (suc n)
permute' π i .(insert i x xs') (ixV x xs') = x :: permute π xs'
delete : {n : Nat} -> Fin (suc n) -> Permutation (suc n) -> Permutation n
delete fzero (j ◅ π) = π
delete {zero} (fsuc ()) _
delete {suc _} (fsuc i) (j ◅ π) = ? ◅ delete i π
identity : {n : Nat} -> Permutation n
identity {zero } = ε
identity {suc n} = fzero ◅ identity
_⁻¹ : {n : Nat} -> Permutation n -> Permutation n
ε ⁻¹ = ε
(i ◅ π) ⁻¹ = ?
_○_ : {n : Nat} -> Permutation n -> Permutation n -> Permutation n
ε ○ π₂ = ε
i ◅ π₁ ○ π₂ = (indices π₂ ! i) ◅ (π₁ ○ delete i π₂)
-}
-}
| 27.171642
| 95
| 0.495468
|
a02392aabe37c827b74f6a03cefafbe5da93e663
| 7,235
|
agda
|
Agda
|
Cubical/Categories/DistLatticeSheaf.agda
|
FernandoLarrain/cubical
|
9acdecfa6437ec455568be4e5ff04849cc2bc13b
|
[
"MIT"
] | 1
|
2022-03-05T00:29:41.000Z
|
2022-03-05T00:29:41.000Z
|
Cubical/Categories/DistLatticeSheaf.agda
|
FernandoLarrain/cubical
|
9acdecfa6437ec455568be4e5ff04849cc2bc13b
|
[
"MIT"
] | null | null | null |
Cubical/Categories/DistLatticeSheaf.agda
|
FernandoLarrain/cubical
|
9acdecfa6437ec455568be4e5ff04849cc2bc13b
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --safe #-}
module Cubical.Categories.DistLatticeSheaf where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Structure
open import Cubical.Foundations.Powerset
open import Cubical.Data.Sigma
open import Cubical.Relation.Binary.Poset
open import Cubical.Algebra.Ring
open import Cubical.Algebra.CommRing
open import Cubical.Algebra.Semilattice
open import Cubical.Algebra.Lattice
open import Cubical.Algebra.DistLattice
open import Cubical.Algebra.DistLattice.Basis
open import Cubical.Categories.Category
open import Cubical.Categories.Functor
open import Cubical.Categories.NaturalTransformation
open import Cubical.Categories.Limits.Pullback
open import Cubical.Categories.Limits.Terminal
open import Cubical.Categories.Instances.Functors
open import Cubical.Categories.Instances.CommRings
open import Cubical.Categories.Instances.Poset
open import Cubical.Categories.Instances.Semilattice
open import Cubical.Categories.Instances.Lattice
open import Cubical.Categories.Instances.DistLattice
private
variable
ℓ ℓ' ℓ'' : Level
module _ (L : DistLattice ℓ) (C : Category ℓ' ℓ'') (T : Terminal C) where
open Category hiding (_⋆_)
open Functor
open Order (DistLattice→Lattice L)
open DistLatticeStr (snd L)
open JoinSemilattice (Lattice→JoinSemilattice (DistLattice→Lattice L))
open MeetSemilattice (Lattice→MeetSemilattice (DistLattice→Lattice L))
using (∧≤RCancel ; ∧≤LCancel)
open PosetStr (IndPoset .snd) hiding (_≤_)
𝟙 : ob C
𝟙 = terminalOb C T
DLCat : Category ℓ ℓ
DLCat = DistLatticeCategory L
open Category DLCat
-- C-valued presheaves on a distributive lattice
DLPreSheaf : Type (ℓ-max (ℓ-max ℓ ℓ') ℓ'')
DLPreSheaf = Functor (DLCat ^op) C
hom-∨₁ : (x y : L .fst) → DLCat [ x , x ∨l y ]
hom-∨₁ = ∨≤RCancel
-- TODO: isn't the fixity of the operators a bit weird?
hom-∨₂ : (x y : L .fst) → DLCat [ y , x ∨l y ]
hom-∨₂ = ∨≤LCancel
hom-∧₁ : (x y : L .fst) → DLCat [ x ∧l y , x ]
hom-∧₁ _ _ = (≤m→≤j _ _ (∧≤RCancel _ _))
hom-∧₂ : (x y : L .fst) → DLCat [ x ∧l y , y ]
hom-∧₂ _ _ = (≤m→≤j _ _ (∧≤LCancel _ _))
{-
x ∧ y ----→ y
| |
| sq |
V V
x ----→ x ∨ y
-}
sq : (x y : L .fst) → hom-∧₂ x y ⋆ hom-∨₂ x y ≡ hom-∧₁ x y ⋆ hom-∨₁ x y
sq x y = is-prop-valued (x ∧l y) (x ∨l y) (hom-∧₂ x y ⋆ hom-∨₂ x y) (hom-∧₁ x y ⋆ hom-∨₁ x y)
{-
F(x ∨ y) ----→ F(y)
| |
| Fsq |
V V
F(x) ------→ F(x ∧ y)
-}
Fsq : (F : DLPreSheaf) (x y : L .fst)
→ F .F-hom (hom-∨₂ x y) ⋆⟨ C ⟩ F .F-hom (hom-∧₂ x y) ≡
F .F-hom (hom-∨₁ x y) ⋆⟨ C ⟩ F .F-hom (hom-∧₁ x y)
Fsq F x y = sym (F-seq F (hom-∨₂ x y) (hom-∧₂ x y))
∙∙ cong (F .F-hom) (sq x y)
∙∙ F-seq F (hom-∨₁ x y) (hom-∧₁ x y)
isDLSheaf : (F : DLPreSheaf) → Type (ℓ-max (ℓ-max ℓ ℓ') ℓ'')
isDLSheaf F = (F-ob F 0l ≡ 𝟙)
× ((x y : L .fst) → isPullback C _ _ _ (Fsq F x y))
-- TODO: might be better to define this as a record
DLSheaf : Type (ℓ-max (ℓ-max ℓ ℓ') ℓ'')
DLSheaf = Σ[ F ∈ DLPreSheaf ] isDLSheaf F
module SheafOnBasis (L : DistLattice ℓ) (C : Category ℓ' ℓ'') (T : Terminal C)
(L' : ℙ (fst L)) (hB : IsBasis L L') where
open Category
open Functor
open DistLatticeStr ⦃...⦄
open SemilatticeStr ⦃...⦄
open PosetStr ⦃...⦄ hiding (_≤_)
open IsBasis hB
private
BasisCat = MeetSemilatticeCategory (Basis→MeetSemilattice L L' hB)
DLBasisPreSheaf = Functor (BasisCat ^op) C
-- to avoid writing 𝟙 L C T
1c : ob C
1c = terminalOb C T
instance
_ = snd L
_ = snd (Basis→MeetSemilattice L L' hB)
module condSquare (x y : ob BasisCat) (x∨y∈L' : fst x ∨l fst y ∈ L') where
open MeetSemilattice (Lattice→MeetSemilattice (DistLattice→Lattice L))
using (∧≤RCancel ; ∧≤LCancel)
open MeetSemilattice (Basis→MeetSemilattice L L' hB)
using (IndPoset)
instance
_ = snd IndPoset
x∨y : ob BasisCat -- = Σ[ x ∈ L ] (x ∈ L')
x∨y = fst x ∨l fst y , x∨y∈L'
Bhom-∨₁ : BasisCat [ x , x∨y ]
Bhom-∨₁ = Σ≡Prop (λ _ → L' _ .snd) (∧lAbsorb∨l _ _)
Bhom-∨₂ : BasisCat [ y , x∨y ]
Bhom-∨₂ = Σ≡Prop (λ _ → L' _ .snd) (cong (fst y ∧l_) (∨lComm _ _) ∙ ∧lAbsorb∨l _ _)
Bhom-∧₁ : BasisCat [ x · y , x ]
Bhom-∧₁ = Σ≡Prop (λ _ → L' _ .snd) (∧≤RCancel _ _)
Bhom-∧₂ : BasisCat [ x · y , y ]
Bhom-∧₂ = Σ≡Prop (λ _ → L' _ .snd) (∧≤LCancel _ _)
{-
x ∧ y ----→ y
| |
| sq |
V V
x ----→ x ∨ y
-}
Bsq : Bhom-∧₂ ⋆⟨ BasisCat ⟩ Bhom-∨₂ ≡ Bhom-∧₁ ⋆⟨ BasisCat ⟩ Bhom-∨₁
Bsq = is-prop-valued (x · y) x∨y (Bhom-∧₂ ⋆⟨ BasisCat ⟩ Bhom-∨₂) (Bhom-∧₁ ⋆⟨ BasisCat ⟩ Bhom-∨₁)
{-
F(x ∨ y) ----→ F(y)
| |
| Fsq |
V V
F(x) ------→ F(x ∧ y)
-}
BFsq : (F : DLBasisPreSheaf)
→ F .F-hom Bhom-∨₂ ⋆⟨ C ⟩ F .F-hom Bhom-∧₂ ≡
F .F-hom Bhom-∨₁ ⋆⟨ C ⟩ F .F-hom Bhom-∧₁
BFsq F = sym (F-seq F Bhom-∨₂ Bhom-∧₂)
∙∙ cong (F .F-hom) Bsq
∙∙ F-seq F Bhom-∨₁ Bhom-∧₁
-- TODO: check that this is equivalent to the functor
-- preserving terminal objects and pullbacks
isDLBasisSheaf : DLBasisPreSheaf → Type (ℓ-max (ℓ-max ℓ ℓ') ℓ'')
isDLBasisSheaf F = ((0∈L' : 0l ∈ L') → F .F-ob (0l , 0∈L') ≡ 1c)
× ((x y : ob BasisCat) (x∨y∈L' : fst x ∨l fst y ∈ L')
→ isPullback C _ _ _ (BFsq x y x∨y∈L' F))
where
open condSquare
DLBasisSheaf : Type (ℓ-max (ℓ-max ℓ ℓ') ℓ'')
DLBasisSheaf = Σ[ F ∈ DLBasisPreSheaf ] isDLBasisSheaf F
-- To prove the statement we probably need that C is:
-- 1. univalent
-- 2. has finite limits (or pullbacks and a terminal object)
-- 3. isGroupoid (C .ob)
-- The last point is not strictly necessary, but we have to have some
-- control over the hLevel as we want to write F(x) in terms of its
-- basis cover which is information hidden under a prop truncation...
-- Alternatively we just prove the statement for C = CommRingsCategory
-- TODO: is unique existence expressed like this what we want?
-- statement : (F' : DLBasisSheaf)
-- → ∃![ F ∈ DLSheaf L C T ] ((x : fst L) → (x ∈ L') → CatIso C (F-ob (fst F) x) (F-ob (fst F') x)) -- TODO: if C is univalent the CatIso could be ≡?
-- statement (F' , h1 , hPb) = ?
-- It might be easier to prove all of these if we use the definition
-- in terms of particular limits instead
-- Scrap zone:
-- -- Sublattices: upstream later
-- record isSublattice (L' : ℙ (fst L)) : Type ℓ where
-- field
-- 1l-closed : 1l ∈ L'
-- 0l-closed : 0l ∈ L'
-- ∧l-closed : {x y : fst L} → x ∈ L' → y ∈ L' → x ∧l y ∈ L'
-- ∨l-closed : {x y : fst L} → x ∈ L' → y ∈ L' → x ∨l y ∈ L'
-- open isSublattice
-- Sublattice : Type (ℓ-suc ℓ)
-- Sublattice = Σ[ L' ∈ ℙ (fst L) ] isSublattice L'
-- restrictDLSheaf : DLSheaf → Sublattice → DLSheaf
-- F-ob (fst (restrictDLSheaf F (L' , HL'))) x = {!F-ob (fst F) x!} -- Hmm, not nice...
-- F-hom (fst (restrictDLSheaf F L')) = {!!}
-- F-id (fst (restrictDLSheaf F L')) = {!!}
-- F-seq (fst (restrictDLSheaf F L')) = {!!}
-- snd (restrictDLSheaf F L') = {!!}
| 31.320346
| 161
| 0.575536
|
a0eb057a40d6d5a74f7e3ab7f1a1c9deea29ae09
| 5,257
|
agda
|
Agda
|
Algebra/Construct/Free/Semilattice/Direct.agda
|
oisdk/agda-playground
|
97a3aab1282b2337c5f43e2cfa3fa969a94c11b7
|
[
"MIT"
] | 6
|
2020-09-11T17:45:41.000Z
|
2021-11-16T08:11:34.000Z
|
Algebra/Construct/Free/Semilattice/Direct.agda
|
oisdk/agda-playground
|
97a3aab1282b2337c5f43e2cfa3fa969a94c11b7
|
[
"MIT"
] | null | null | null |
Algebra/Construct/Free/Semilattice/Direct.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 Algebra.Construct.Free.Semilattice.Direct where
open import Algebra
open import Prelude
open import Path.Reasoning
infixl 6 _∪_
data 𝒦 (A : Type a) : Type a where
η : A → 𝒦 A
_∪_ : 𝒦 A → 𝒦 A → 𝒦 A
∅ : 𝒦 A
∪-assoc : ∀ xs ys zs → (xs ∪ ys) ∪ zs ≡ xs ∪ (ys ∪ zs)
∪-commutative : ∀ xs ys → xs ∪ ys ≡ ys ∪ xs
∪-idempotent : ∀ xs → xs ∪ xs ≡ xs
∪-identity : ∀ xs → xs ∪ ∅ ≡ xs
trunc : isSet (𝒦 A)
module _ (semiLattice : Semilattice b) where
open Semilattice semiLattice
module _ (sIsSet : isSet 𝑆) (h : A → 𝑆) where
μ : 𝒦 A → 𝑆
μ (η x) = h x
μ (xs ∪ ys) = μ xs ∙ μ ys
μ ∅ = ε
μ (∪-assoc xs ys zs i) = assoc (μ xs) (μ ys) (μ zs) i
μ (∪-commutative xs ys i) = comm (μ xs) (μ ys) i
μ (∪-idempotent xs i) = idem (μ xs) i
μ (∪-identity xs i) = ∙ε (μ xs) i
μ (trunc xs ys x y i j) = sIsSet (μ xs) (μ ys) (cong μ x) (cong μ y) i j
module Eliminators where
record _⇘_ {a p} (A : Type a) (P : 𝒦 A → Type p) : Type (a ℓ⊔ p) where
constructor elim
field
⟦_⟧-set : ∀ {xs} → isSet (P xs)
⟦_⟧∅ : P ∅
⟦_⟧_∪_⟨_∪_⟩ : ∀ xs ys → P xs → P ys → P (xs ∪ ys)
⟦_⟧η : ∀ x → P (η x)
private z = ⟦_⟧∅; f = ⟦_⟧_∪_⟨_∪_⟩
field
⟦_⟧-assoc : ∀ xs ys zs pxs pys pzs →
f (xs ∪ ys) zs (f xs ys pxs pys) pzs ≡[ i ≔ P (∪-assoc xs ys zs i ) ]≡
f xs (ys ∪ zs) pxs (f ys zs pys pzs)
⟦_⟧-commutative : ∀ xs ys pxs pys →
f xs ys pxs pys ≡[ i ≔ P (∪-commutative xs ys i) ]≡ f ys xs pys pxs
⟦_⟧-idempotent : ∀ xs pxs →
f xs xs pxs pxs ≡[ i ≔ P (∪-idempotent xs i) ]≡ pxs
⟦_⟧-identity : ∀ xs pxs → f xs ∅ pxs z ≡[ i ≔ P (∪-identity xs i) ]≡ pxs
⟦_⟧⇓ : ∀ xs → P xs
⟦ η x ⟧⇓ = ⟦_⟧η x
⟦ xs ∪ ys ⟧⇓ = f xs ys ⟦ xs ⟧⇓ ⟦ ys ⟧⇓
⟦ ∅ ⟧⇓ = z
⟦ ∪-assoc xs ys zs i ⟧⇓ = ⟦_⟧-assoc xs ys zs ⟦ xs ⟧⇓ ⟦ ys ⟧⇓ ⟦ zs ⟧⇓ i
⟦ ∪-commutative xs ys i ⟧⇓ = ⟦_⟧-commutative xs ys ⟦ xs ⟧⇓ ⟦ ys ⟧⇓ i
⟦ ∪-idempotent xs i ⟧⇓ = ⟦_⟧-idempotent xs ⟦ xs ⟧⇓ i
⟦ ∪-identity xs i ⟧⇓ = ⟦_⟧-identity xs ⟦ xs ⟧⇓ i
⟦ trunc xs ys x y i j ⟧⇓ =
isOfHLevel→isOfHLevelDep 2
(λ xs → ⟦_⟧-set {xs})
⟦ xs ⟧⇓ ⟦ ys ⟧⇓
(cong ⟦_⟧⇓ x) (cong ⟦_⟧⇓ y)
(trunc xs ys x y)
i j
open _⇘_ public
infixr 0 ⇘-syntax
⇘-syntax = _⇘_
syntax ⇘-syntax A (λ xs → Pxs) = xs ∈𝒦 A ⇒ Pxs
record _⇲_ {a p} (A : Type a) (P : 𝒦 A → Type p) : Type (a ℓ⊔ p) where
constructor elim-prop
field
∥_∥-prop : ∀ {xs} → isProp (P xs)
∥_∥∅ : P ∅
∥_∥_∪_⟨_∪_⟩ : ∀ xs ys → P xs → P ys → P (xs ∪ ys)
∥_∥η : ∀ x → P (η x)
private z = ∥_∥∅; f = ∥_∥_∪_⟨_∪_⟩
∥_∥⇑ = elim
(λ {xs} → isProp→isSet (∥_∥-prop {xs}))
z f ∥_∥η
(λ xs ys zs pxs pys pzs → toPathP (∥_∥-prop (transp (λ i → P (∪-assoc xs ys zs i)) i0 (f (xs ∪ ys) zs (f xs ys pxs pys) pzs)) (f xs (ys ∪ zs) pxs (f ys zs pys pzs) )))
(λ xs ys pxs pys → toPathP (∥_∥-prop (transp (λ i → P (∪-commutative xs ys i)) i0 (f xs ys pxs pys)) (f ys xs pys pxs) ))
(λ xs pxs → toPathP (∥_∥-prop (transp (λ i → P (∪-idempotent xs i)) i0 (f xs xs pxs pxs)) pxs))
(λ xs pxs → toPathP (∥_∥-prop (transp (λ i → P (∪-identity xs i)) i0 (f xs ∅ pxs z)) pxs))
∥_∥⇓ = ⟦ ∥_∥⇑ ⟧⇓
open _⇲_ public
elim-prop-syntax : ∀ {a p} → (A : Type a) → (𝒦 A → Type p) → Type (a ℓ⊔ p)
elim-prop-syntax = _⇲_
syntax elim-prop-syntax A (λ xs → Pxs) = xs ∈𝒦 A ⇒∥ Pxs ∥
module _ {a} {A : Type a} where
open Semilattice
open CommutativeMonoid
open Monoid
𝒦-semilattice : Semilattice a
𝒦-semilattice .commutativeMonoid .monoid .𝑆 = 𝒦 A
𝒦-semilattice .commutativeMonoid .monoid ._∙_ = _∪_
𝒦-semilattice .commutativeMonoid .monoid .ε = ∅
𝒦-semilattice .commutativeMonoid .monoid .assoc = ∪-assoc
𝒦-semilattice .commutativeMonoid .monoid .ε∙ x = ∪-commutative ∅ x ; ∪-identity x
𝒦-semilattice .commutativeMonoid .monoid .∙ε = ∪-identity
𝒦-semilattice .commutativeMonoid .comm = ∪-commutative
𝒦-semilattice .idem = ∪-idempotent
import Algebra.Construct.Free.Semilattice as Listed
Listed→Direct : Listed.𝒦 A → 𝒦 A
Listed→Direct = Listed.μ 𝒦-semilattice trunc η
Direct→Listed : 𝒦 A → Listed.𝒦 A
Direct→Listed = μ Listed.𝒦-semilattice Listed.trunc (Listed._∷ Listed.[])
Listed→Direct→Listed : (xs : Listed.𝒦 A) → Direct→Listed (Listed→Direct xs) ≡ xs
Listed→Direct→Listed = ∥ ldl ∥⇓
where
open Listed using (_⇲_; elim-prop-syntax)
open _⇲_
ldl : xs ∈𝒦 A ⇒∥ Direct→Listed (Listed→Direct xs) ≡ xs ∥
∥ ldl ∥-prop = Listed.trunc _ _
∥ ldl ∥[] = refl
∥ ldl ∥ x ∷ xs ⟨ Pxs ⟩ = cong (x Listed.∷_) Pxs
open Eliminators
Direct→Listed→Direct : (xs : 𝒦 A) → Listed→Direct (Direct→Listed xs) ≡ xs
Direct→Listed→Direct = ∥ dld ∥⇓
where
dld : xs ∈𝒦 A ⇒∥ Listed→Direct (Direct→Listed xs) ≡ xs ∥
∥ dld ∥-prop = trunc _ _
∥ dld ∥∅ = refl
∥ dld ∥η x = ∪-identity (η x)
∥ dld ∥ xs ∪ ys ⟨ Pxs ∪ Pys ⟩ =
sym (Listed.∙-hom 𝒦-semilattice trunc η (Direct→Listed xs) (Direct→Listed ys)) ;
cong₂ _∪_ Pxs Pys
Direct⇔Listed : 𝒦 A ⇔ Listed.𝒦 A
Direct⇔Listed .fun = Direct→Listed
Direct⇔Listed .inv = Listed→Direct
Direct⇔Listed .rightInv = Listed→Direct→Listed
Direct⇔Listed .leftInv = Direct→Listed→Direct
| 36.006849
| 179
| 0.548602
|
2e309a94689a9df1dcf90d9091d70dfd503f504d
| 502
|
agda
|
Agda
|
lib/Explore/Experimental/Maybe.agda
|
crypto-agda/explore
|
16bc8333503ff9c00d47d56f4ec6113b9269a43e
|
[
"BSD-3-Clause"
] | 2
|
2016-06-05T09:25:32.000Z
|
2017-06-28T19:19:29.000Z
|
lib/Explore/Experimental/Maybe.agda
|
crypto-agda/explore
|
16bc8333503ff9c00d47d56f4ec6113b9269a43e
|
[
"BSD-3-Clause"
] | 1
|
2019-03-16T14:24:04.000Z
|
2019-03-16T14:24:04.000Z
|
lib/Explore/Experimental/Maybe.agda
|
crypto-agda/explore
|
16bc8333503ff9c00d47d56f4ec6113b9269a43e
|
[
"BSD-3-Clause"
] | null | null | null |
{-# OPTIONS --without-K #-}
open import Function.Related.TypeIsomorphisms.NP
open import Function.Inverse.NP
open import Data.Maybe.NP
open import Data.Nat
open import Explore.Type
open import Explore.Explorable
open import Explore.Sum
module Explore.Explorable.Maybe where
μMaybe : ∀ {A} → Explorable A → Explorable (Maybe A)
μMaybe μA = μ-iso (sym Maybe↔𝟙⊎) (μ𝟙 ⊎-μ μA)
μMaybe^ : ∀ {A} n → Explorable A → Explorable (Maybe^ n A)
μMaybe^ zero μA = μA
μMaybe^ (suc n) μA = μMaybe (μMaybe^ n μA)
| 26.421053
| 58
| 0.719124
|
597cd56871ba5edd3e9119412ea351d4383015ee
| 6,566
|
agda
|
Agda
|
Cubical/Foundations/Path.agda
|
borsiemir/cubical
|
cefeb3669ffdaea7b88ae0e9dd258378418819ca
|
[
"MIT"
] | null | null | null |
Cubical/Foundations/Path.agda
|
borsiemir/cubical
|
cefeb3669ffdaea7b88ae0e9dd258378418819ca
|
[
"MIT"
] | null | null | null |
Cubical/Foundations/Path.agda
|
borsiemir/cubical
|
cefeb3669ffdaea7b88ae0e9dd258378418819ca
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --cubical --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
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
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)) (transp (λ j → P (i ∧ j)) (~ i) p) q
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 → Set ℓ) {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 A 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 A 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 A 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 p q = (q ∙ sym p) ∙ p ≡⟨ sym (assoc q (sym p) p) ⟩
q ∙ (sym p ∙ p) ≡⟨ cong (q ∙_) (lCancel p) ⟩
q ∙ refl ≡⟨ sym (rUnit q) ⟩
q ∎
compPathl-isEquiv : ∀ {ℓ} {A : Type ℓ} {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)))
compPathr-isEquiv : ∀ {ℓ} {A : Type ℓ} {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)))
-- Variation of isProp→isSet for PathP
isProp→isSet-PathP : ∀ {ℓ} {B : I → Type ℓ} → ((i : I) → isProp (B i))
→ (b0 : B i0) (b1 : B i1)
→ isProp (PathP (λ i → B i) b0 b1)
isProp→isSet-PathP {B = B} hB b0 b1 =
transport (λ i → isProp (PathP≡Path B b0 b1 (~ i))) (isProp→isSet (hB i1) _ _)
| 56.603448
| 125
| 0.347853
|
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.