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
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
43469d92f69a739af0d76a327909961e445ffa7a
| 2,918
|
agda
|
Agda
|
Cats/Trans/Iso.agda
|
alessio-b-zak/cats
|
a3b69911c4c6ec380ddf6a0f4510d3a755734b86
|
[
"MIT"
] | null | null | null |
Cats/Trans/Iso.agda
|
alessio-b-zak/cats
|
a3b69911c4c6ec380ddf6a0f4510d3a755734b86
|
[
"MIT"
] | null | null | null |
Cats/Trans/Iso.agda
|
alessio-b-zak/cats
|
a3b69911c4c6ec380ddf6a0f4510d3a755734b86
|
[
"MIT"
] | null | null | null |
module Cats.Trans.Iso where
open import Level using (_⊔_)
open import Relation.Binary.PropositionalEquality using (_≡_ ; refl)
open import Cats.Category.Base
open import Cats.Functor using (Functor)
open import Cats.Util.Simp using (simp!)
open import Cats.Trans using (Trans ; component ; natural)
import Cats.Category.Constructions.Iso as Iso
open Functor
open Iso.Build._≅_
module _ {lo la l≈ lo′ la′ l≈′}
{C : Category lo la l≈} {D : Category lo′ la′ l≈′}
where
private
module C = Category C
module D = Category D
open module D≅ = Iso.Build D using (_≅_)
module ≅ = D≅.≅
open D.≈-Reasoning
record NatIso (F G : Functor C D) : Set (lo ⊔ la ⊔ lo′ ⊔ la′ ⊔ l≈′)
where
field
iso : ∀ {c} → fobj F c ≅ fobj G c
forth-natural : ∀ {c d} {f : c C.⇒ d}
→ forth iso D.∘ fmap F f D.≈ fmap G f D.∘ forth iso
back-natural : ∀ {c d} {f : c C.⇒ d}
→ back iso D.∘ fmap G f D.≈ fmap F f D.∘ back iso
back-natural {f = f} =
begin
back iso D.∘ fmap G f
≈⟨ D.∘-resp-r (D.≈.sym D.id-r) ⟩
back iso D.∘ fmap G f D.∘ D.id
≈⟨ D.∘-resp-r (D.∘-resp-r (D.≈.sym (forth-back iso))) ⟩
back iso D.∘ fmap G f D.∘ forth iso D.∘ back iso
≈⟨ simp! D ⟩
back iso D.∘ (fmap G f D.∘ forth iso) D.∘ back iso
≈⟨ D.∘-resp-r (D.∘-resp-l (D.≈.sym forth-natural)) ⟩
back iso D.∘ (forth iso D.∘ fmap F f) D.∘ back iso
≈⟨ simp! D ⟩
(back iso D.∘ (forth iso)) D.∘ fmap F f D.∘ back iso
≈⟨ D.∘-resp-l (back-forth iso) ⟩
D.id D.∘ fmap F f D.∘ back iso
≈⟨ D.id-l ⟩
fmap F f D.∘ back iso
∎
Forth : Trans F G
Forth = record
{ component = λ _ → forth iso
; natural = forth-natural
}
Back : Trans G F
Back = record
{ component = λ _ → back iso
; natural = back-natural
}
open NatIso public
id : ∀ {F} → NatIso F F
id = record
{ iso = ≅.refl
; forth-natural = D.≈.trans D.id-l (D.≈.sym D.id-r)
}
sym : ∀ {F G} → NatIso F G → NatIso G F
sym θ = record
{ iso = ≅.sym (iso θ)
; forth-natural = back-natural θ
}
_∘_ : ∀ {F G H} → NatIso G H → NatIso F G → NatIso F H
_∘_ {F} {G} {H} θ ι = record
{ iso = ≅.trans (iso ι) (iso θ)
; forth-natural = λ {_} {_} {f} →
begin
(forth (iso θ) D.∘ forth (iso ι)) D.∘ fmap F f
≈⟨ D.assoc ⟩
forth (iso θ) D.∘ forth (iso ι) D.∘ fmap F f
≈⟨ D.∘-resp-r (forth-natural ι) ⟩
forth (iso θ) D.∘ fmap G f D.∘ forth (iso ι)
≈⟨ D.unassoc ⟩
(forth (iso θ) D.∘ fmap G f) D.∘ forth (iso ι)
≈⟨ D.∘-resp-l (forth-natural θ) ⟩
(fmap H f D.∘ forth (iso θ)) D.∘ forth (iso ι)
≈⟨ D.assoc ⟩
fmap H f D.∘ forth (iso θ) D.∘ forth (iso ι)
∎
}
| 26.770642
| 69
| 0.496573
|
ad30a61510cc057c6092345f220267d2f802d706
| 4,060
|
agda
|
Agda
|
test/asset/agda-stdlib-1.0/Data/List/Relation/Ternary/Interleaving/Properties.agda
|
omega12345/agda-mode
|
0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71
|
[
"MIT"
] | null | null | null |
test/asset/agda-stdlib-1.0/Data/List/Relation/Ternary/Interleaving/Properties.agda
|
omega12345/agda-mode
|
0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71
|
[
"MIT"
] | null | null | null |
test/asset/agda-stdlib-1.0/Data/List/Relation/Ternary/Interleaving/Properties.agda
|
omega12345/agda-mode
|
0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71
|
[
"MIT"
] | null | null | null |
------------------------------------------------------------------------
-- The Agda standard library
--
-- Properties of general interleavings
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
module Data.List.Relation.Ternary.Interleaving.Properties where
open import Data.Nat
open import Data.Nat.Properties using (+-suc)
open import Data.List.Base hiding (_∷ʳ_)
open import Data.List.Properties using (reverse-involutive)
open import Data.List.Relation.Ternary.Interleaving hiding (map)
open import Function
open import Relation.Binary
open import Relation.Binary.PropositionalEquality
using (_≡_; refl; sym; cong; module ≡-Reasoning)
open ≡-Reasoning
------------------------------------------------------------------------
-- length
module _ {a b c l r} {A : Set a} {B : Set b} {C : Set c}
{L : REL A C l} {R : REL B C r} where
interleave-length : ∀ {as l r} → Interleaving L R l r as →
length as ≡ length l + length r
interleave-length [] = refl
interleave-length (l ∷ˡ sp) = cong suc (interleave-length sp)
interleave-length {as} {l} {r ∷ rs} (_ ∷ʳ sp) = begin
length as ≡⟨ cong suc (interleave-length sp) ⟩
suc (length l + length rs) ≡⟨ sym $ +-suc _ _ ⟩
length l + length (r ∷ rs) ∎
------------------------------------------------------------------------
-- _++_
++⁺ : ∀ {as₁ as₂ l₁ l₂ r₁ r₂} →
Interleaving L R as₁ l₁ r₁ → Interleaving L R as₂ l₂ r₂ →
Interleaving L R (as₁ ++ as₂) (l₁ ++ l₂) (r₁ ++ r₂)
++⁺ [] sp₂ = sp₂
++⁺ (l ∷ˡ sp₁) sp₂ = l ∷ˡ (++⁺ sp₁ sp₂)
++⁺ (r ∷ʳ sp₁) sp₂ = r ∷ʳ (++⁺ sp₁ sp₂)
++-disjoint : ∀ {as₁ as₂ l₁ r₂} →
Interleaving L R l₁ [] as₁ → Interleaving L R [] r₂ as₂ →
Interleaving L R l₁ r₂ (as₁ ++ as₂)
++-disjoint [] sp₂ = sp₂
++-disjoint (l ∷ˡ sp₁) sp₂ = l ∷ˡ ++-disjoint sp₁ sp₂
------------------------------------------------------------------------
-- map
module _ {a b c d e f l r}
{A : Set a} {B : Set b} {C : Set c}
{D : Set d} {E : Set e} {F : Set f}
{L : REL A C l} {R : REL B C r}
(f : E → A) (g : F → B) (h : D → C)
where
map⁺ : ∀ {as l r} →
Interleaving (λ x z → L (f x) (h z)) (λ y z → R (g y) (h z)) l r as →
Interleaving L R (map f l) (map g r) (map h as)
map⁺ [] = []
map⁺ (l ∷ˡ sp) = l ∷ˡ map⁺ sp
map⁺ (r ∷ʳ sp) = r ∷ʳ map⁺ sp
map⁻ : ∀ {as l r} →
Interleaving L R (map f l) (map g r) (map h as) →
Interleaving (λ x z → L (f x) (h z)) (λ y z → R (g y) (h z)) l r as
map⁻ {[]} {[]} {[]} [] = []
map⁻ {_ ∷ _} {[]} {_ ∷ _} (r ∷ʳ sp) = r ∷ʳ map⁻ sp
map⁻ {_ ∷ _} {_ ∷ _} {[]} (l ∷ˡ sp) = l ∷ˡ map⁻ sp
map⁻ {_ ∷ _} {_ ∷ _} {_ ∷ _} (l ∷ˡ sp) = l ∷ˡ map⁻ sp
map⁻ {_ ∷ _} {_ ∷ _} {_ ∷ _} (r ∷ʳ sp) = r ∷ʳ map⁻ sp
-- impossible cases needed until 2.6.0
map⁻ {[]} {_} {_ ∷ _} ()
map⁻ {[]} {_ ∷ _} {_} ()
map⁻ {_ ∷ _} {[]} {[]} ()
------------------------------------------------------------------------
-- reverse
module _ {a b c l r} {A : Set a} {B : Set b} {C : Set c}
{L : REL A C l} {R : REL B C r}
where
reverseAcc⁺ : ∀ {as₁ as₂ l₁ l₂ r₁ r₂} →
Interleaving L R l₁ r₁ as₁ →
Interleaving L R l₂ r₂ as₂ →
Interleaving L R (reverseAcc l₁ l₂) (reverseAcc r₁ r₂) (reverseAcc as₁ as₂)
reverseAcc⁺ sp₁ [] = sp₁
reverseAcc⁺ sp₁ (l ∷ˡ sp₂) = reverseAcc⁺ (l ∷ˡ sp₁) sp₂
reverseAcc⁺ sp₁ (r ∷ʳ sp₂) = reverseAcc⁺ (r ∷ʳ sp₁) sp₂
reverse⁺ : ∀ {as l r} → Interleaving L R l r as →
Interleaving L R (reverse l) (reverse r) (reverse as)
reverse⁺ = reverseAcc⁺ []
reverse⁻ : ∀ {as l r} → Interleaving L R (reverse l) (reverse r) (reverse as) →
Interleaving L R l r as
reverse⁻ {as} {l} {r} sp with reverse⁺ sp
... | sp′ rewrite reverse-involutive as
| reverse-involutive l
| reverse-involutive r = sp′
| 37.592593
| 91
| 0.458621
|
30fc8abfbada8042e51a7bde5d4f63bc1cf984bf
| 9,360
|
agda
|
Agda
|
src/fot/FOTC/Program/GCD/Total/CommonDivisorATP.agda
|
asr/fotc
|
2fc9f2b81052a2e0822669f02036c5750371b72d
|
[
"MIT"
] | 11
|
2015-09-03T20:53:42.000Z
|
2021-09-12T16:09:54.000Z
|
src/fot/FOTC/Program/GCD/Total/CommonDivisorATP.agda
|
asr/fotc
|
2fc9f2b81052a2e0822669f02036c5750371b72d
|
[
"MIT"
] | 2
|
2016-10-12T17:28:16.000Z
|
2017-01-01T14:34:26.000Z
|
src/fot/FOTC/Program/GCD/Total/CommonDivisorATP.agda
|
asr/fotc
|
2fc9f2b81052a2e0822669f02036c5750371b72d
|
[
"MIT"
] | 3
|
2016-09-19T14:18:30.000Z
|
2018-03-14T08:50:00.000Z
|
------------------------------------------------------------------------------
-- The gcd is a common divisor
------------------------------------------------------------------------------
{-# OPTIONS --exact-split #-}
{-# OPTIONS --no-sized-types #-}
{-# OPTIONS --no-universe-polymorphism #-}
{-# OPTIONS --without-K #-}
module FOTC.Program.GCD.Total.CommonDivisorATP where
open import FOTC.Base
open import FOTC.Data.Nat
open import FOTC.Data.Nat.Divisibility.By0
open import FOTC.Data.Nat.Divisibility.By0.PropertiesATP
open import FOTC.Data.Nat.Induction.NonAcc.LexicographicATP
open import FOTC.Data.Nat.Inequalities
open import FOTC.Data.Nat.Inequalities.EliminationPropertiesATP
open import FOTC.Data.Nat.Inequalities.PropertiesATP
open import FOTC.Data.Nat.PropertiesATP
open import FOTC.Program.GCD.Total.Definitions
open import FOTC.Program.GCD.Total.GCD
open import FOTC.Program.GCD.Total.TotalityATP
------------------------------------------------------------------------------
-- gcd 0 0 | 0.
postulate gcd-00∣0 : gcd zero zero ∣ zero
{-# ATP prove gcd-00∣0 #-}
------------------------------------------------------------------------------
-- Some cases of the gcd-∣₁.
-- Some cases of the gcd-∣₁.
-- We don't prove that
--
-- gcd-∣₁ : ... → (gcd m n) ∣ m
-- because this proof should be defined mutually recursive with the
-- proof
--
-- gcd-∣₂ : ... → (gcd m n) ∣ n.
--
-- Therefore, instead of proving
--
-- gcdCD : ... → CD m n (gcd m n)
--
-- using these proofs (i.e. the conjunction of them), we proved it
-- using well-founded induction.
-- gcd 0 (succ n) ∣ 0.
postulate gcd-0S-∣₁ : ∀ {n} → N n → gcd zero (succ₁ n) ∣ zero
{-# ATP prove gcd-0S-∣₁ #-}
-- gcd (succ₁ m) 0 ∣ succ₁ m.
postulate gcd-S0-∣₁ : ∀ {n} → N n → gcd (succ₁ n) zero ∣ succ₁ n
{-# ATP prove gcd-S0-∣₁ ∣-refl #-}
-- gcd (succ₁ m) (succ₁ n) ∣ succ₁ m, when succ₁ m ≯ succ₁ n.
postulate gcd-S≯S-∣₁ : ∀ {m n} → N m → N n →
(gcd (succ₁ m) (succ₁ n ∸ succ₁ m) ∣ succ₁ m) →
succ₁ m ≯ succ₁ n →
gcd (succ₁ m) (succ₁ n) ∣ succ₁ m
{-# ATP prove gcd-S≯S-∣₁ #-}
-- gcd (succ₁ m) (succ₁ n) ∣ succ₁ m when succ₁ m > succ₁ n.
{- Proof:
1. gcd (Sm ∸ Sn) Sn | (Sm ∸ Sn) IH
2. gcd (Sm ∸ Sn) Sn | Sn gcd-∣₂
3. gcd (Sm ∸ Sn) Sn | (Sm ∸ Sn) + Sn m∣n→m∣o→m∣n+o 1,2
4. Sm > Sn Hip
5. gcd (Sm ∸ Sn) Sn | Sm arith-gcd-m>n₂ 3,4
6. gcd Sm Sn = gcd (Sm ∸ Sn) Sn gcd eq. 4
7. gcd Sm Sn | Sm subst 5,6
-}
-- For the proof using the ATP we added the helper hypothesis:
-- 1. gcd (succ₁ m ∸ succ₁ n) (succ₁ n) ∣ (succ₁ m ∸ succ₁ n) + succ₁ n.
-- 2. (succ₁ m ∸ succ₁ n) + succ₁ n ≡ succ₁ m.
postulate
gcd-S>S-∣₁-ah :
∀ {m n} → N m → N n →
(gcd (succ₁ m ∸ succ₁ n) (succ₁ n) ∣ (succ₁ m ∸ succ₁ n)) →
(gcd (succ₁ m ∸ succ₁ n) (succ₁ n) ∣ succ₁ n) →
succ₁ m > succ₁ n →
gcd (succ₁ m ∸ succ₁ n) (succ₁ n) ∣ (succ₁ m ∸ succ₁ n) + succ₁ n →
((succ₁ m ∸ succ₁ n) + succ₁ n ≡ succ₁ m) →
gcd (succ₁ m) (succ₁ n) ∣ succ₁ m
{-# ATP prove gcd-S>S-∣₁-ah #-}
gcd-S>S-∣₁ :
∀ {m n} → N m → N n →
(gcd (succ₁ m ∸ succ₁ n) (succ₁ n) ∣ (succ₁ m ∸ succ₁ n)) →
(gcd (succ₁ m ∸ succ₁ n) (succ₁ n) ∣ succ₁ n) →
succ₁ m > succ₁ n →
gcd (succ₁ m) (succ₁ n) ∣ succ₁ m
gcd-S>S-∣₁ {m} {n} Nm Nn ih gcd-∣₂ Sm>Sn =
gcd-S>S-∣₁-ah Nm Nn ih gcd-∣₂ Sm>Sn
(x∣y→x∣z→x∣y+z gcd-Sm-Sn,Sn-N Sm-Sn-N (nsucc Nn) ih gcd-∣₂)
(x>y→x∸y+y≡x (nsucc Nm) (nsucc Nn) Sm>Sn)
where
Sm-Sn-N : N (succ₁ m ∸ succ₁ n)
Sm-Sn-N = ∸-N (nsucc Nm) (nsucc Nn)
gcd-Sm-Sn,Sn-N : N (gcd (succ₁ m ∸ succ₁ n) (succ₁ n))
gcd-Sm-Sn,Sn-N = gcd-N Sm-Sn-N (nsucc Nn)
------------------------------------------------------------------------------
-- Some case of the gcd-∣₂.
-- We don't prove that gcd-∣₂ : ... → gcd m n ∣ n. The reason is
-- the same to don't prove gcd-∣₁ : ... → gcd m n ∣ m.
-- gcd 0 (succ₁ n) ∣₂ succ₁ n.
postulate gcd-0S-∣₂ : ∀ {n} → N n → gcd zero (succ₁ n) ∣ succ₁ n
{-# ATP prove gcd-0S-∣₂ ∣-refl #-}
-- gcd (succ₁ m) 0 ∣ 0.
postulate gcd-S0-∣₂ : ∀ {m} → N m → gcd (succ₁ m) zero ∣ zero
{-# ATP prove gcd-S0-∣₂ #-}
-- gcd (succ₁ m) (succ₁ n) ∣ succ₁ n when succ₁ m ≯ succ₁ n.
{- Proof:
1. gcd Sm (Sn ∸ Sm) | (Sn ∸ Sm) IH
2 gcd Sm (Sn ∸ Sm) | Sm gcd-∣₁
3. gcd Sm (Sn ∸ Sm) | (Sn ∸ Sm) + Sm m∣n→m∣o→m∣n+o 1,2
4. Sm ≯ Sn Hip
5. gcd (Sm ∸ Sn) Sn | Sm arith-gcd-m≤n₂ 3,4
6. gcd Sm Sn = gcd Sm (Sn ∸ Sm) gcd eq. 4
7. gcd Sm Sn | Sn subst 5,6
-}
-- For the proof using the ATP we added the helper hypothesis:
-- 1. gcd (succ₁ m) (succ₁ n ∸ succ₁ m) ∣ (succ₁ n ∸ succ₁ m) + succ₁ m.
-- 2 (succ₁ n ∸ succ₁ m) + succ₁ m ≡ succ₁ n.
postulate
gcd-S≯S-∣₂-ah :
∀ {m n} → N m → N n →
(gcd (succ₁ m) (succ₁ n ∸ succ₁ m) ∣ (succ₁ n ∸ succ₁ m)) →
(gcd (succ₁ m) (succ₁ n ∸ succ₁ m) ∣ succ₁ m) →
succ₁ m ≯ succ₁ n →
(gcd (succ₁ m) (succ₁ n ∸ succ₁ m) ∣ (succ₁ n ∸ succ₁ m) + succ₁ m) →
((succ₁ n ∸ succ₁ m) + succ₁ m ≡ succ₁ n) →
gcd (succ₁ m) (succ₁ n) ∣ succ₁ n
{-# ATP prove gcd-S≯S-∣₂-ah #-}
gcd-S≯S-∣₂ :
∀ {m n} → N m → N n →
(gcd (succ₁ m) (succ₁ n ∸ succ₁ m) ∣ (succ₁ n ∸ succ₁ m)) →
(gcd (succ₁ m) (succ₁ n ∸ succ₁ m) ∣ succ₁ m) →
succ₁ m ≯ succ₁ n →
gcd (succ₁ m) (succ₁ n) ∣ succ₁ n
gcd-S≯S-∣₂ {m} {n} Nm Nn ih gcd-∣₁ Sm≯Sn =
gcd-S≯S-∣₂-ah Nm Nn ih gcd-∣₁ Sm≯Sn
(x∣y→x∣z→x∣y+z gcd-Sm,Sn-Sm-N Sn-Sm-N (nsucc Nm) ih gcd-∣₁)
(x≤y→y∸x+x≡y (nsucc Nm) (nsucc Nn) (x≯y→x≤y (nsucc Nm) (nsucc Nn) Sm≯Sn))
where
Sn-Sm-N : N (succ₁ n ∸ succ₁ m)
Sn-Sm-N = ∸-N (nsucc Nn) (nsucc Nm)
gcd-Sm,Sn-Sm-N : N (gcd (succ₁ m) (succ₁ n ∸ succ₁ m))
gcd-Sm,Sn-Sm-N = gcd-N (nsucc Nm) (Sn-Sm-N)
-- gcd (succ₁ m) (succ₁ n) ∣ succ₁ n when succ₁ m > succ₁ n.
postulate gcd-S>S-∣₂ : ∀ {m n} → N m → N n →
(gcd (succ₁ m ∸ succ₁ n) (succ₁ n) ∣ succ₁ n) →
succ₁ m > succ₁ n →
gcd (succ₁ m) (succ₁ n) ∣ succ₁ n
{-# ATP prove gcd-S>S-∣₂ #-}
------------------------------------------------------------------------------
-- The gcd is CD.
-- We will prove that gcdCD : ... → CD m n (gcd m n).
-- The gcd 0 0 is CD.
gcd-00-CD : CD zero zero (gcd zero zero)
gcd-00-CD = gcd-00∣0 , gcd-00∣0
-- The gcd 0 (succ₁ n) is CD.
gcd-0S-CD : ∀ {n} → N n → CD zero (succ₁ n) (gcd zero (succ₁ n))
gcd-0S-CD Nn = (gcd-0S-∣₁ Nn , gcd-0S-∣₂ Nn)
-- The gcd (succ₁ m) 0 is CD.
gcd-S0-CD : ∀ {m} → N m → CD (succ₁ m) zero (gcd (succ₁ m) zero)
gcd-S0-CD Nm = (gcd-S0-∣₁ Nm , gcd-S0-∣₂ Nm)
-- The gcd (succ₁ m) (succ₁ n) when succ₁ m > succ₁ n is CD.
gcd-S>S-CD :
∀ {m n} → N m → N n →
(CD (succ₁ m ∸ succ₁ n) (succ₁ n) (gcd (succ₁ m ∸ succ₁ n) (succ₁ n))) →
succ₁ m > succ₁ n →
CD (succ₁ m) (succ₁ n) (gcd (succ₁ m) (succ₁ n))
gcd-S>S-CD {m} {n} Nm Nn acc Sm>Sn =
(gcd-S>S-∣₁ Nm Nn acc-∣₁ acc-∣₂ Sm>Sn , gcd-S>S-∣₂ Nm Nn acc-∣₂ Sm>Sn)
where
acc-∣₁ : gcd (succ₁ m ∸ succ₁ n) (succ₁ n) ∣ (succ₁ m ∸ succ₁ n)
acc-∣₁ = ∧-proj₁ acc
acc-∣₂ : gcd (succ₁ m ∸ succ₁ n) (succ₁ n) ∣ succ₁ n
acc-∣₂ = ∧-proj₂ acc
-- The gcd (succ₁ m) (succ₁ n) when succ₁ m ≯ succ₁ n is CD.
gcd-S≯S-CD :
∀ {m n} → N m → N n →
(CD (succ₁ m) (succ₁ n ∸ succ₁ m) (gcd (succ₁ m) (succ₁ n ∸ succ₁ m))) →
succ₁ m ≯ succ₁ n →
CD (succ₁ m) (succ₁ n) (gcd (succ₁ m) (succ₁ n))
gcd-S≯S-CD {m} {n} Nm Nn acc Sm≯Sn =
(gcd-S≯S-∣₁ Nm Nn acc-∣₁ Sm≯Sn , gcd-S≯S-∣₂ Nm Nn acc-∣₂ acc-∣₁ Sm≯Sn)
where
acc-∣₁ : gcd (succ₁ m) (succ₁ n ∸ succ₁ m) ∣ succ₁ m
acc-∣₁ = ∧-proj₁ acc
acc-∣₂ : gcd (succ₁ m) (succ₁ n ∸ succ₁ m) ∣ (succ₁ n ∸ succ₁ m)
acc-∣₂ = ∧-proj₂ acc
-- The gcd m n when m > n is CD.
gcd-x>y-CD :
∀ {m n} → N m → N n →
(∀ {o p} → N o → N p → Lexi o p m n → CD o p (gcd o p)) →
m > n →
CD m n (gcd m n)
gcd-x>y-CD nzero Nn _ 0>n = ⊥-elim (0>x→⊥ Nn 0>n)
gcd-x>y-CD (nsucc Nm) nzero _ _ = gcd-S0-CD Nm
gcd-x>y-CD (nsucc {m} Nm) (nsucc {n} Nn) ah Sm>Sn = gcd-S>S-CD Nm Nn ih Sm>Sn
where
-- Inductive hypothesis.
ih : CD (succ₁ m ∸ succ₁ n) (succ₁ n) (gcd (succ₁ m ∸ succ₁ n) (succ₁ n))
ih = ah {succ₁ m ∸ succ₁ n}
{succ₁ n}
(∸-N (nsucc Nm) (nsucc Nn))
(nsucc Nn)
([Sx∸Sy,Sy]<[Sx,Sy] Nm Nn)
-- The gcd m n when m ≯ n is CD.
gcd-x≯y-CD :
∀ {m n} → N m → N n →
(∀ {o p} → N o → N p → Lexi o p m n → CD o p (gcd o p)) →
m ≯ n →
CD m n (gcd m n)
gcd-x≯y-CD nzero nzero _ _ = gcd-00-CD
gcd-x≯y-CD nzero (nsucc Nn) _ _ = gcd-0S-CD Nn
gcd-x≯y-CD (nsucc _) nzero _ Sm≯0 = ⊥-elim (S≯0→⊥ Sm≯0)
gcd-x≯y-CD (nsucc {m} Nm) (nsucc {n} Nn) ah Sm≯Sn =
gcd-S≯S-CD Nm Nn ih Sm≯Sn
where
-- Inductive hypothesis.
ih : CD (succ₁ m) (succ₁ n ∸ succ₁ m) (gcd (succ₁ m) (succ₁ n ∸ succ₁ m))
ih = ah {succ₁ m}
{succ₁ n ∸ succ₁ m}
(nsucc Nm)
(∸-N (nsucc Nn) (nsucc Nm))
([Sx,Sy∸Sx]<[Sx,Sy] Nm Nn)
-- The gcd is CD.
gcdCD : ∀ {m n} → N m → N n → CD m n (gcd m n)
gcdCD = Lexi-wfind A h
where
A : D → D → Set
A i j = CD i j (gcd i j)
h : ∀ {i j} → N i → N j → (∀ {k l} → N k → N l → Lexi k l i j → A k l) →
A i j
h Ni Nj ah = case (gcd-x>y-CD Ni Nj ah) (gcd-x≯y-CD Ni Nj ah) (x>y∨x≯y Ni Nj)
| 35.18797
| 79
| 0.501175
|
526aaadd7f8052db42893b783e583cecb8cb3ad4
| 8,339
|
agda
|
Agda
|
src/Categories/Category/Instance/Properties/Setoids/Extensive.agda
|
sergey-goncharov/agda-categories
|
e2d7596549e7840b521576f48746ac3c4560f126
|
[
"MIT"
] | null | null | null |
src/Categories/Category/Instance/Properties/Setoids/Extensive.agda
|
sergey-goncharov/agda-categories
|
e2d7596549e7840b521576f48746ac3c4560f126
|
[
"MIT"
] | null | null | null |
src/Categories/Category/Instance/Properties/Setoids/Extensive.agda
|
sergey-goncharov/agda-categories
|
e2d7596549e7840b521576f48746ac3c4560f126
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --without-K --safe #-}
module Categories.Category.Instance.Properties.Setoids.Extensive where
open import Level
open import Data.Product using (Σ; proj₁; proj₂; _,_; Σ-syntax; _×_; -,_)
open import Function.Equality using (Π)
open import Relation.Binary using (Setoid; Rel)
open import Categories.Category using (Category; _[_,_])
open import Categories.Category.Instance.Setoids
open import Categories.Category.Extensive
open import Categories.Category.Cocartesian
open import Categories.Diagram.Pullback
open import Categories.Category.Instance.Properties.Setoids.Limits.Canonical
open import Categories.Category.Monoidal.Instance.Setoids
open import Data.Sum.Relation.Binary.Pointwise
open import Data.Unit.Polymorphic using (⊤; tt)
open import Data.Empty using (⊥; ⊥-elim)
open import Data.Sum.Base using ([_,_]′; _⊎_)
open import Function.Equality as SΠ renaming (id to ⟶-id)
open import Data.Product using (∃)
open import Relation.Binary.PropositionalEquality using (_≡_; [_]; inspect)
open Π
module _ ℓ where
private
S = Setoids ℓ ℓ
module S = Category S
open Pullback
Setoids-Extensive : (ℓ : Level) → Extensive (Setoids ℓ ℓ)
Setoids-Extensive ℓ = record
{ cocartesian = record { initial = initial ; coproducts = coproducts }
; pullback₁ = λ f → pullback ℓ ℓ f i₁
; pullback₂ = λ f → pullback ℓ ℓ f i₂
; pullback-of-cp-is-cp = λ {C A B} f → record
{ [_,_] = λ g h → record
{ _⟨$⟩_ = copair-$ f g h
; cong = λ {z z′} → copair-cong f g h z z′
}
; inject₁ = λ {X g h z} eq →
trans (isEquivalence {ℓ} X) (copair-inject₁ f g h z) (cong g eq)
; inject₂ = λ {X g h z} eq →
trans (isEquivalence {ℓ} X) (copair-inject₂ f g h z) (cong h eq)
; unique = λ {X u g h} feq₁ feq₂ {z z′} eq →
trans (isEquivalence {ℓ} X) (copair-unique f g h u z (λ {z} → feq₁ {z}) (λ {z} → feq₂ {z})) (cong u eq)
}
; pullback₁-is-mono = λ _ _ eq x≈y → drop-inj₁ (eq x≈y)
; pullback₂-is-mono = λ _ _ eq x≈y → drop-inj₂ (eq x≈y)
; disjoint = λ {A B} → record
{ commute = λ { {()} _}
; universal = λ {C f g} eq → record
{ _⟨$⟩_ = λ z → conflict A B (f ⟨$⟩ z) (g ⟨$⟩ z) (eq (refl (isEquivalence {ℓ} C)))
; cong = λ z → tt
}
; unique = λ _ _ _ → tt
; p₁∘universal≈h₁ = λ {C h₁ h₂ eq x y} x≈y → conflict A B (h₁ ⟨$⟩ x) (h₂ ⟨$⟩ y) (eq x≈y)
; p₂∘universal≈h₂ = λ {C h₁ h₂ eq x y} x≈y → conflict A B (h₁ ⟨$⟩ x) (h₂ ⟨$⟩ y) (eq x≈y)
}
}
where
open Cocartesian (Setoids-Cocartesian {ℓ} {ℓ})
open Relation.Binary.IsEquivalence
open import Data.Sum using (inj₁; inj₂)
open Setoid renaming (_≈_ to [_][_≈_]; Carrier to ∣_∣) using (isEquivalence)
-- must be in the standard library. Maybe it is?
conflict : ∀ {ℓ ℓ' ℓ''} (X Y : Setoid ℓ ℓ') {Z : Set ℓ''}
(x : ∣ X ∣) (y : ∣ Y ∣) → [ ⊎-setoid X Y ][ inj₁ x ≈ inj₂ y ] → Z
conflict X Y x y ()
module Diagram {A B C X : Setoid ℓ ℓ} (f : C ⟶ ⊎-setoid A B)
(g : P (pullback ℓ ℓ f i₁) ⟶ X) (h : P (pullback ℓ ℓ f i₂) ⟶ X) where
private
A⊎B = ⊎-setoid A B
A′ = P (pullback ℓ ℓ f i₁)
B′ = P (pullback ℓ ℓ f i₂)
refl-A = refl (isEquivalence A)
refl-B = refl (isEquivalence B)
refl-C = refl (isEquivalence C)
refl-A⊎B = refl (isEquivalence A⊎B)
reflexive-A⊎B = reflexive (isEquivalence A⊎B)
sym-A = sym (isEquivalence A)
sym-B = sym (isEquivalence B)
sym-C = sym (isEquivalence C)
sym-X = sym (isEquivalence X)
sym-A⊎B = sym (isEquivalence A⊎B)
trans-X = trans (isEquivalence X)
trans-A⊎B = trans (isEquivalence A⊎B)
-- copairing of g : A′ → X and h : B′ → X, resulting in C → X
copair-$ : ∣ C ∣ → ∣ X ∣
copair-$ z with (f ⟨$⟩ z) | inspect (f ⟨$⟩_) z
... | inj₁ x | [ eq ] = g ⟨$⟩ record { elem₁ = z ; elem₂ = x ; commute = reflexive-A⊎B eq }
... | inj₂ y | [ eq ] = h ⟨$⟩ record { elem₁ = z ; elem₂ = y ; commute = reflexive-A⊎B eq }
-- somewhat roundabout way to expand the definition of copair-$ z if f ⟨$⟩ z ≈ inj₁ x,
-- in order to circumwent the pitfalls of the with-abstraction
copair-$-i₁ : (x : ∣ A ∣) (z : ∣ C ∣) → (eq : [ A⊎B ][ f ⟨$⟩ z ≈ inj₁ x ]) →
∃ (λ v → [ X ][ copair-$ z ≈ g ⟨$⟩ v ] ×
[ C ][ FiberProduct.elem₁ v ≈ z ] ×
[ A ][ FiberProduct.elem₂ v ≈ x ])
copair-$-i₁ x z eq with (f ⟨$⟩ z) | inspect (f ⟨$⟩_) z
... | inj₁ x′ | [ eq′ ] =
record { elem₁ = z ; elem₂ = x′ ; commute = reflexive-A⊎B eq′}
, cong g (refl-C , refl-A)
, refl-C
, drop-inj₁ eq
-- same for f ⟨$⟩ z ≈ inj₂ y
copair-$-i₂ : (y : ∣ B ∣) (z : ∣ C ∣) → (eq : [ A⊎B ][ f ⟨$⟩ z ≈ inj₂ y ]) →
∃ (λ v → [ X ][ copair-$ z ≈ h ⟨$⟩ v ] × [ C ][ FiberProduct.elem₁ v ≈ z ] × [ B ][ FiberProduct.elem₂ v ≈ y ])
copair-$-i₂ y z eq with (f ⟨$⟩ z) | inspect (f ⟨$⟩_) z
... | inj₂ y′ | [ eq′ ] =
record { elem₁ = z ; elem₂ = y′ ; commute = reflexive-A⊎B eq′}
, cong h (refl-C , refl-B)
, refl-C
, drop-inj₂ eq
case-f⟨$⟩z : (z : ∣ C ∣) → (∃ λ x → [ A⊎B ][ f ⟨$⟩ z ≈ inj₁ x ]) ⊎ (∃ λ y → [ A⊎B ][ f ⟨$⟩ z ≈ inj₂ y ])
case-f⟨$⟩z z with (f ⟨$⟩ z)
... | inj₁ x = inj₁ (x , refl-A⊎B)
... | inj₂ y = inj₂ (y , refl-A⊎B)
copair-cong : (z z′ : ∣ C ∣) → (z≈z′ : [ C ][ z ≈ z′ ]) → [ X ][ copair-$ z ≈ copair-$ z′ ]
copair-cong z z′ z≈z′ with (f ⟨$⟩ z) | inspect (_⟨$⟩_ f) z | (f ⟨$⟩ z′) | inspect (_⟨$⟩_ f) z′
... | inj₁ x | [ eq ] | inj₁ x′ | [ eq′ ] = cong g
(z≈z′ , drop-inj₁ (trans-A⊎B (sym-A⊎B (reflexive-A⊎B eq)) (trans-A⊎B (cong f z≈z′) (reflexive-A⊎B eq′))))
... | inj₁ x | [ eq ] | inj₂ y | [ eq′ ] = conflict A B x y
(trans-A⊎B (sym-A⊎B (reflexive-A⊎B eq)) (trans-A⊎B (cong f z≈z′) (reflexive-A⊎B eq′)))
... | inj₂ y | [ eq ] | inj₁ x | [ eq′ ] = conflict A B x y
(trans-A⊎B (sym-A⊎B (reflexive-A⊎B eq′)) (trans-A⊎B (cong f (sym-C z≈z′)) (reflexive-A⊎B eq)))
... | inj₂ y | [ eq ] | inj₂ y′ | [ eq′ ] = cong h (z≈z′ , drop-inj₂
(trans-A⊎B (sym-A⊎B (reflexive-A⊎B eq)) (trans-A⊎B (cong f z≈z′) (reflexive-A⊎B eq′))))
copair-inject₁ : (z : FiberProduct f i₁) → [ X ][ copair-$ (FiberProduct.elem₁ z) ≈ g ⟨$⟩ z ]
copair-inject₁ record { elem₁ = z ; elem₂ = x ; commute = eq } with case-f⟨$⟩z z
... | inj₁ _ with copair-$-i₁ x z eq
... | _ , eq₁ , eq₂ , eq₃ = trans-X eq₁ (cong g (eq₂ , eq₃))
copair-inject₁ record { elem₁ = z ; elem₂ = x ; commute = eq } | inj₂ (y , eq′) =
conflict A B x y (trans-A⊎B (sym-A⊎B eq) eq′)
copair-inject₂ : (z : FiberProduct f i₂) → [ X ][ copair-$ (FiberProduct.elem₁ z) ≈ h ⟨$⟩ z ]
copair-inject₂ record { elem₁ = z ; elem₂ = y ; commute = eq } with case-f⟨$⟩z z
... | inj₂ _ with copair-$-i₂ y z eq
... | _ , eq₁ , eq₂ , eq₃ = trans-X eq₁ (cong h (eq₂ , eq₃))
copair-inject₂ record { elem₁ = z ; elem₂ = y ; commute = eq } | inj₁ (x , eq′) =
conflict A B x y (trans-A⊎B (sym-A⊎B eq′) eq)
copair-unique : (u : C ⟶ X) (z : ∣ C ∣) →
[ A′ ⇨ X ][ u ∘ p₁ (pullback ℓ ℓ f i₁) ≈ g ] →
[ B′ ⇨ X ][ u ∘ p₁ (pullback ℓ ℓ f i₂) ≈ h ] →
[ X ][ copair-$ z ≈ u ⟨$⟩ z ]
copair-unique u z feq₁ feq₂ with case-f⟨$⟩z z
... | inj₁ (x , eq) with copair-$-i₁ x z eq
... | z′ , eq₁ , eq₂ , _ = trans-X eq₁ (trans-X (sym-X (feq₁{z′} (refl-C , refl-A))) (cong u eq₂))
copair-unique u z feq₁ feq₂ | inj₂ (y , eq) with copair-$-i₂ y z eq
... | z′ , eq₁ , eq₂ , _ = trans-X eq₁ (trans-X (sym-X (feq₂{z′} (refl-C , refl-B))) (cong u eq₂))
open Diagram
| 49.343195
| 124
| 0.487349
|
048d52b32f4a2d39f25724b4e61baa45794587a7
| 20,153
|
agda
|
Agda
|
src/Circle/Erased.agda
|
nad/equality
|
402b20615cfe9ca944662380d7b2d69b0f175200
|
[
"MIT"
] | 3
|
2020-05-21T22:58:50.000Z
|
2021-09-02T17:18:15.000Z
|
src/Circle/Erased.agda
|
nad/equality
|
402b20615cfe9ca944662380d7b2d69b0f175200
|
[
"MIT"
] | null | null | null |
src/Circle/Erased.agda
|
nad/equality
|
402b20615cfe9ca944662380d7b2d69b0f175200
|
[
"MIT"
] | null | null | null |
------------------------------------------------------------------------
-- The circle with an erased higher constructor
------------------------------------------------------------------------
{-# OPTIONS --erased-cubical --safe #-}
-- Partly following the HoTT book.
-- The module is parametrised by a notion of equality. The higher
-- constructor of the HIT defining the circle uses path equality, but
-- the supplied notion of equality is used for many other things.
import Equality.Path as P
module Circle.Erased
{e⁺} (eq : ∀ {a p} → P.Equality-with-paths a p e⁺) where
open P.Derived-definitions-and-properties eq hiding (elim)
open import Prelude
open import Bijection equality-with-J using (_↔_)
open import Circle eq as C using (𝕊¹)
open import Equality.Groupoid equality-with-J
open import Equality.Path.Isomorphisms eq
open import Equality.Path.Isomorphisms.Univalence eq
open import Equivalence equality-with-J as Eq using (_≃_)
import Equivalence P.equality-with-J as PE
open import Erased.Cubical eq
open import Function-universe equality-with-J hiding (id; _∘_)
open import Group equality-with-J as G using (_≃ᴳ_)
open import H-level equality-with-J
open import H-level.Truncation.Propositional.Erased eq as T using (∥_∥ᴱ)
open import H-level.Truncation.Propositional.One-step eq as O
using (∥_∥¹)
open import H-level.Truncation.Propositional.One-step.Erased eq as OE
using (∥_∥¹ᴱ)
open import Integer equality-with-J using (ℤ; +_; ℤ-group)
open import Nat equality-with-J
open import Pointed-type equality-with-J as PT using (_≃ᴮ_)
open import Pointed-type.Homotopy-group eq
private
variable
a p : Level
A : Type p
P : A → Type p
b ℓ : A
------------------------------------------------------------------------
-- The type and some eliminators
-- The circle.
data 𝕊¹ᴱ : Type where
base : 𝕊¹ᴱ
@0 loopᴾ : base P.≡ base
@0 loop : base ≡ base
loop = _↔_.from ≡↔≡ loopᴾ
-- A dependent eliminator, expressed using paths.
elimᴾ :
(P : 𝕊¹ᴱ → Type p)
(b : P base) →
@0 P.[ (λ i → P (loopᴾ i)) ] b ≡ b →
(x : 𝕊¹ᴱ) → P x
elimᴾ P b ℓ base = b
elimᴾ P b ℓ (loopᴾ i) = ℓ i
-- A non-dependent eliminator, expressed using paths.
recᴾ : (b : A) → @0 b P.≡ b → 𝕊¹ᴱ → A
recᴾ = elimᴾ _
-- A dependent eliminator.
elim :
(P : 𝕊¹ᴱ → Type p)
(b : P base) →
@0 subst P loop b ≡ b →
(x : 𝕊¹ᴱ) → P x
elim P b ℓ = elimᴾ P b (subst≡→[]≡ ℓ)
-- A "computation" rule.
@0 elim-loop :
dcong (elim P b ℓ) loop ≡ ℓ
elim-loop = dcong-subst≡→[]≡ (refl _)
-- Every dependent function of type (x : 𝕊¹ᴱ) → P x can be expressed
-- using elim.
η-elim :
{f : (x : 𝕊¹ᴱ) → P x} →
f ≡ elim P (f base) (dcong f loop)
η-elim {P = P} {f = f} =
⟨ext⟩ $ elim _ (refl _)
(subst (λ x → f x ≡ elim P (f base) (dcong f loop) x) loop (refl _) ≡⟨ subst-in-terms-of-trans-and-dcong ⟩
trans (sym (dcong f loop))
(trans (cong (subst P loop) (refl _))
(dcong (elim P (f base) (dcong f loop)) loop)) ≡⟨ cong (trans (sym (dcong f loop))) $
trans (cong (flip trans _) $ cong-refl _) $
trans-reflˡ _ ⟩
trans (sym (dcong f loop))
(dcong (elim P (f base) (dcong f loop)) loop) ≡⟨ cong (trans (sym (dcong f loop))) elim-loop ⟩
trans (sym (dcong f loop)) (dcong f loop) ≡⟨ trans-symˡ _ ⟩∎
refl _ ∎)
-- A non-dependent eliminator.
rec : (b : A) → @0 b ≡ b → 𝕊¹ᴱ → A
rec b ℓ = recᴾ b (_↔_.to ≡↔≡ ℓ)
-- A "computation" rule.
@0 rec-loop : cong (rec b ℓ) loop ≡ ℓ
rec-loop = cong-≡↔≡ (refl _)
-- Every function from 𝕊¹ᴱ to A can be expressed using rec.
η-rec : {f : 𝕊¹ᴱ → A} → f ≡ rec (f base) (cong f loop)
η-rec {f = f} =
⟨ext⟩ $ elim _ (refl _)
(subst (λ x → f x ≡ rec (f base) (cong f loop) x) loop (refl _) ≡⟨ subst-in-terms-of-trans-and-cong ⟩
trans (sym (cong f loop))
(trans (refl _) (cong (rec (f base) (cong f loop)) loop)) ≡⟨ cong (trans (sym (cong f loop))) $ trans-reflˡ _ ⟩
trans (sym (cong f loop)) (cong (rec (f base) (cong f loop)) loop) ≡⟨ cong (trans (sym (cong f loop))) rec-loop ⟩
trans (sym (cong f loop)) (cong f loop) ≡⟨ trans-symˡ _ ⟩∎
refl _ ∎)
------------------------------------------------------------------------
-- Conversion functions
-- In erased contexts 𝕊¹ is equivalent to 𝕊¹ᴱ.
@0 𝕊¹≃𝕊¹ᴱ : 𝕊¹ ≃ 𝕊¹ᴱ
𝕊¹≃𝕊¹ᴱ = Eq.↔→≃
𝕊¹→𝕊¹ᴱ
𝕊¹ᴱ→𝕊¹
(elim _ (refl _)
(subst (λ x → 𝕊¹→𝕊¹ᴱ (𝕊¹ᴱ→𝕊¹ x) ≡ x) loop (refl _) ≡⟨ subst-in-terms-of-trans-and-cong ⟩
trans (sym (cong (𝕊¹→𝕊¹ᴱ ∘ 𝕊¹ᴱ→𝕊¹) loop))
(trans (refl _) (cong id loop)) ≡⟨ cong (trans _) $
trans (trans-reflˡ _) $
sym $ cong-id _ ⟩
trans (sym (cong (𝕊¹→𝕊¹ᴱ ∘ 𝕊¹ᴱ→𝕊¹) loop)) loop ≡⟨ cong (flip trans _) $ cong sym $
trans (sym $ cong-∘ _ _ _) $
trans (cong (cong 𝕊¹→𝕊¹ᴱ)
rec-loop) $
C.rec-loop ⟩
trans (sym loop) loop ≡⟨ trans-symˡ _ ⟩∎
refl _ ∎))
(C.elim _ (refl _)
(subst (λ x → 𝕊¹ᴱ→𝕊¹ (𝕊¹→𝕊¹ᴱ x) ≡ x) C.loop (refl _) ≡⟨ subst-in-terms-of-trans-and-cong ⟩
trans (sym (cong (𝕊¹ᴱ→𝕊¹ ∘ 𝕊¹→𝕊¹ᴱ) C.loop))
(trans (refl _) (cong id C.loop)) ≡⟨ cong (trans _) $
trans (trans-reflˡ _) $
sym $ cong-id _ ⟩
trans (sym (cong (𝕊¹ᴱ→𝕊¹ ∘ 𝕊¹→𝕊¹ᴱ) C.loop)) C.loop ≡⟨ cong (flip trans _) $ cong sym $
trans (sym $ cong-∘ _ _ _) $
trans (cong (cong 𝕊¹ᴱ→𝕊¹)
C.rec-loop) $
rec-loop ⟩
trans (sym C.loop) C.loop ≡⟨ trans-symˡ _ ⟩∎
refl _ ∎))
where
𝕊¹→𝕊¹ᴱ = C.rec base loop
𝕊¹ᴱ→𝕊¹ = rec C.base C.loop
-- In erased contexts there is a based equivalence between 𝕊¹ , C.base
-- and 𝕊¹ᴱ , base.
@0 𝕊¹≃ᴮ𝕊¹ᴱ : (𝕊¹ , C.base) ≃ᴮ (𝕊¹ᴱ , base)
𝕊¹≃ᴮ𝕊¹ᴱ = 𝕊¹≃𝕊¹ᴱ , refl _
-- The one-step truncation of the unit type is equivalent to 𝕊¹ᴱ.
--
-- Paolo Capriotti informed me about the corresponding result without
-- erasure.
∥⊤∥¹ᴱ≃𝕊¹ᴱ : ∥ ⊤ ∥¹ᴱ ≃ 𝕊¹ᴱ
∥⊤∥¹ᴱ≃𝕊¹ᴱ = _↔_.from ≃↔≃ $ PE.↔→≃
(OE.recᴾ λ where
.OE.∣∣ʳ _ → base
.OE.∣∣-constantʳ _ _ → loopᴾ)
(recᴾ OE.∣ _ ∣ (OE.∣∣-constantᴾ _ _))
(elimᴾ _ P.refl (λ _ → P.refl))
(OE.elimᴾ λ where
.OE.∣∣ʳ _ → P.refl
.OE.∣∣-constantʳ _ _ _ → P.refl)
------------------------------------------------------------------------
-- The loop space of 𝕊¹ᴱ
-- The function trans is commutative for the loop space of 𝕊¹ᴱ.
trans-commutative : (p q : base ≡ base) → trans p q ≡ trans q p
trans-commutative =
flip $ Transitivity-commutative.commutative base _∙_ ∙-base base-∙
where
_∙_ : 𝕊¹ᴱ → 𝕊¹ᴱ → 𝕊¹ᴱ
x ∙ y = rec x (elim (λ x → x ≡ x) loop lemma x) y
where
@0 lemma : subst (λ x → x ≡ x) loop loop ≡ loop
lemma = ≡⇒↝ _ (sym [subst≡]≡[trans≡trans]) (refl _)
base-∙ : ∀ x → x ∙ base ≡ x
base-∙ _ = refl _
∙-base : ∀ y → base ∙ y ≡ y
∙-base =
elim _ (refl _)
(subst (λ x → rec base loop x ≡ x) loop (refl _) ≡⟨ subst-in-terms-of-trans-and-cong ⟩
trans (sym (cong (rec base loop) loop))
(trans (refl _) (cong id loop)) ≡⟨ cong (trans _) $ trans-reflˡ _ ⟩
trans (sym (cong (rec base loop) loop)) (cong id loop) ≡⟨ cong₂ (trans ∘ sym)
rec-loop
(sym $ cong-id _) ⟩
trans (sym loop) loop ≡⟨ trans-symˡ _ ⟩∎
refl _ ∎)
-- The loop space is equivalent to x ≡ x, for any x : 𝕊¹ᴱ.
base≡base≃≡ : {x : 𝕊¹ᴱ} → (base ≡ base) ≃ (x ≡ x)
base≡base≃≡ = elim
(λ x → (base ≡ base) ≃ (x ≡ x))
Eq.id
(Eq.lift-equality ext $ ⟨ext⟩ λ eq →
_≃_.to (subst (λ x → (base ≡ base) ≃ (x ≡ x)) loop Eq.id) eq ≡⟨ cong (_$ eq) Eq.to-subst ⟩
subst (λ x → base ≡ base → x ≡ x) loop id eq ≡⟨ subst-→ ⟩
subst (λ x → x ≡ x) loop (subst (λ _ → base ≡ base) (sym loop) eq) ≡⟨ cong (subst (λ x → x ≡ x) loop) $ subst-const _ ⟩
subst (λ x → x ≡ x) loop eq ≡⟨ ≡⇒↝ _ (sym [subst≡]≡[trans≡trans]) (
trans eq loop ≡⟨ trans-commutative _ _ ⟩∎
trans loop eq ∎) ⟩∎
eq ∎)
_
-- In erased contexts the loop space of 𝕊¹ᴱ is equivalent to the type
-- of integers.
@0 base≡base≃ℤ : (base ≡ base) ≃ ℤ
base≡base≃ℤ =
base ≡ base ↝⟨ Eq.≃-≡ 𝕊¹≃𝕊¹ᴱ ⟩
C.base ≡ C.base ↝⟨ C.base≡base≃ℤ univ ⟩□
ℤ □
-- In erased contexts the fundamental group of 𝕊¹ᴱ is equivalent to
-- the group of integers.
@0 Fundamental-group≃ℤ : Fundamental-group (𝕊¹ᴱ , base) ≃ᴳ ℤ-group
Fundamental-group≃ℤ =
G.↝ᴳ-trans (G.≃ᴳ-sym $ ≃ᴮ→≃ᴳ _ _ 0 𝕊¹≃ᴮ𝕊¹ᴱ)
(C.Fundamental-group≃ℤ univ)
-- 𝕊¹ᴱ is a groupoid (in erased contexts).
@0 𝕊¹ᴱ-groupoid : H-level 3 𝕊¹ᴱ
𝕊¹ᴱ-groupoid = $⟨ (λ {_ _ _ _} → C.𝕊¹-groupoid univ) ⟩
H-level 3 𝕊¹ ↝⟨ H-level-cong _ 3 𝕊¹≃𝕊¹ᴱ ⦂ (_ → _) ⟩□
H-level 3 𝕊¹ᴱ □
-- The type of endofunctions on 𝕊¹ᴱ is equivalent to
-- ∃ λ (x : 𝕊¹ᴱ) → Erased (x ≡ x).
𝕊¹ᴱ→𝕊¹ᴱ≃Σ𝕊¹ᴱ-Erased≡ : (𝕊¹ᴱ → 𝕊¹ᴱ) ≃ ∃ λ (x : 𝕊¹ᴱ) → Erased (x ≡ x)
𝕊¹ᴱ→𝕊¹ᴱ≃Σ𝕊¹ᴱ-Erased≡ = Eq.↔→≃ to from to-from from-to
where
to : (𝕊¹ᴱ → 𝕊¹ᴱ) → ∃ λ (x : 𝕊¹ᴱ) → Erased (x ≡ x)
to f = f base , [ cong f loop ]
from : (∃ λ (x : 𝕊¹ᴱ) → Erased (x ≡ x)) → (𝕊¹ᴱ → 𝕊¹ᴱ)
from (x , [ eq ]) = rec x eq
to-from : ∀ p → to (from p) ≡ p
to-from (x , [ eq ]) = cong (x ,_)
([ cong (rec x eq) loop ] ≡⟨ []-cong [ rec-loop ] ⟩∎
[ eq ] ∎)
from-to : ∀ f → from (to f) ≡ f
from-to f =
rec (f base) (cong f loop) ≡⟨ sym η-rec ⟩∎
f ∎
-- The type of endofunctions on 𝕊¹ᴱ is equivalent to 𝕊¹ᴱ × Erased ℤ.
𝕊¹ᴱ→𝕊¹ᴱ≃𝕊¹ᴱ×Erased-ℤ : (𝕊¹ᴱ → 𝕊¹ᴱ) ≃ (𝕊¹ᴱ × Erased ℤ)
𝕊¹ᴱ→𝕊¹ᴱ≃𝕊¹ᴱ×Erased-ℤ =
(𝕊¹ᴱ → 𝕊¹ᴱ) ↝⟨ 𝕊¹ᴱ→𝕊¹ᴱ≃Σ𝕊¹ᴱ-Erased≡ ⟩
(∃ λ (x : 𝕊¹ᴱ) → Erased (x ≡ x)) ↝⟨ (∃-cong λ _ → Erased-cong (inverse base≡base≃≡)) ⟩
𝕊¹ᴱ × Erased (base ≡ base) ↝⟨ (∃-cong λ _ → Erased-cong base≡base≃ℤ) ⟩□
𝕊¹ᴱ × Erased ℤ □
-- The forward direction of 𝕊¹ᴱ→𝕊¹ᴱ≃𝕊¹ᴱ×Erased-ℤ maps the identity
-- function to base , [ + 1 ].
𝕊¹ᴱ→𝕊¹ᴱ≃𝕊¹ᴱ×Erased-ℤ-id :
_≃_.to 𝕊¹ᴱ→𝕊¹ᴱ≃𝕊¹ᴱ×Erased-ℤ id ≡ (base , [ + 1 ])
𝕊¹ᴱ→𝕊¹ᴱ≃𝕊¹ᴱ×Erased-ℤ-id = _≃_.from-to 𝕊¹ᴱ→𝕊¹ᴱ≃𝕊¹ᴱ×Erased-ℤ
(rec base (cong (_≃_.to 𝕊¹≃𝕊¹ᴱ) (trans (refl C.base) C.loop)) ≡⟨ cong (λ ([ ℓ ]) → rec base ℓ) $ []-cong [ lemma ] ⟩
rec base (cong id loop) ≡⟨ sym η-rec ⟩∎
id ∎)
where
@0 lemma : _
lemma =
cong (_≃_.to 𝕊¹≃𝕊¹ᴱ) (trans (refl C.base) C.loop) ≡⟨ cong (cong (_≃_.to 𝕊¹≃𝕊¹ᴱ)) $ trans-reflˡ _ ⟩
cong (_≃_.to 𝕊¹≃𝕊¹ᴱ) C.loop ≡⟨ C.rec-loop ⟩
loop ≡⟨ cong-id _ ⟩∎
cong id loop ∎
-- The forward direction of 𝕊¹ᴱ→𝕊¹ᴱ≃𝕊¹ᴱ×Erased-ℤ maps the constant
-- function returning base to base , [ + 0 ].
𝕊¹ᴱ→𝕊¹ᴱ≃𝕊¹ᴱ×Erased-ℤ-const :
_≃_.to 𝕊¹ᴱ→𝕊¹ᴱ≃𝕊¹ᴱ×Erased-ℤ (const base) ≡ (base , [ + 0 ])
𝕊¹ᴱ→𝕊¹ᴱ≃𝕊¹ᴱ×Erased-ℤ-const = _≃_.from-to 𝕊¹ᴱ→𝕊¹ᴱ≃𝕊¹ᴱ×Erased-ℤ
(rec base (cong (_≃_.to 𝕊¹≃𝕊¹ᴱ) (refl C.base)) ≡⟨ cong (λ ([ ℓ ]) → rec base ℓ) $ []-cong [ lemma ] ⟩
rec base (cong (const base) loop) ≡⟨ sym η-rec ⟩∎
const base ∎)
where
@0 lemma : _
lemma =
cong (_≃_.to 𝕊¹≃𝕊¹ᴱ) (refl C.base) ≡⟨ cong-refl _ ⟩
refl _ ≡⟨ sym $ cong-const _ ⟩∎
cong (const base) loop ∎
------------------------------------------------------------------------
-- Some negative results
-- The equality loop is not equal to refl base.
loop≢refl : loop ≢ refl base
loop≢refl =
Stable-¬
[ loop ≡ refl base ↔⟨ inverse $ Eq.≃-≡ $ inverse $ Eq.≃-≡ $ inverse 𝕊¹≃𝕊¹ᴱ ⟩
cong (_≃_.from 𝕊¹≃𝕊¹ᴱ) loop ≡ cong (_≃_.from 𝕊¹≃𝕊¹ᴱ) (refl base) ↝⟨ trans (sym rec-loop) ∘ flip trans (cong-refl _) ⟩
C.loop ≡ refl C.base ↝⟨ C.loop≢refl ⟩□
⊥ □
]
-- 𝕊¹ᴱ is not a set.
¬-𝕊¹ᴱ-set : ¬ Is-set 𝕊¹ᴱ
¬-𝕊¹ᴱ-set =
Stable-¬
[ Is-set 𝕊¹ᴱ ↝⟨ H-level-cong _ 2 $ inverse 𝕊¹≃𝕊¹ᴱ ⟩
Is-set 𝕊¹ ↝⟨ C.¬-𝕊¹-set ⟩□
⊥ □
]
-- It is not necessarily the case that the one-step truncation of a
-- proposition is a proposition.
¬-Is-proposition-∥∥¹ᴱ :
¬ ({A : Type a} → Is-proposition A → Is-proposition ∥ A ∥¹ᴱ)
¬-Is-proposition-∥∥¹ᴱ {a = a} =
Stable-¬
[ ({A : Type a} → Is-proposition A → Is-proposition ∥ A ∥¹ᴱ) ↝⟨ (implicit-∀-cong _ $ ∀-cong _ λ _ → H-level-cong _ 1 O.∥∥¹ᴱ≃∥∥¹) ⟩
({A : Type a} → Is-proposition A → Is-proposition ∥ A ∥¹) ↝⟨ C.¬-Is-proposition-∥∥¹ ⟩□
⊥ □
]
-- A function with the type of refl (for 𝕊¹ᴱ) that is not equal to
-- refl. The function is available in erased contexts.
@0 not-refl : (x : 𝕊¹ᴱ) → x ≡ x
not-refl x = $⟨ C.not-refl (_≃_.from 𝕊¹≃𝕊¹ᴱ x) ⟩
_≃_.from 𝕊¹≃𝕊¹ᴱ x ≡ _≃_.from 𝕊¹≃𝕊¹ᴱ x ↝⟨ Eq.≃-≡ $ inverse 𝕊¹≃𝕊¹ᴱ ⟩□
x ≡ x □
-- The function not-refl is not equal to refl.
not-refl≢refl : not-refl ≢ refl
not-refl≢refl =
Stable-¬
[ not-refl ≡ refl ↔⟨⟩
_≃_.to (Eq.≃-≡ $ inverse 𝕊¹≃𝕊¹ᴱ) ∘ C.not-refl ∘ _≃_.from 𝕊¹≃𝕊¹ᴱ ≡
refl ↝⟨ flip trans (⟨ext⟩ lemma) ⟩
_≃_.to (Eq.≃-≡ $ inverse 𝕊¹≃𝕊¹ᴱ) ∘ C.not-refl ∘ _≃_.from 𝕊¹≃𝕊¹ᴱ ≡
_≃_.to (Eq.≃-≡ $ inverse 𝕊¹≃𝕊¹ᴱ) ∘ refl ∘ _≃_.from 𝕊¹≃𝕊¹ᴱ ↔⟨ (Eq.≃-≡ $ inverse $
Π-cong ext (inverse 𝕊¹≃𝕊¹ᴱ) λ _ →
inverse $ Eq.≃-≡ $ inverse 𝕊¹≃𝕊¹ᴱ) ⟩
C.not-refl ≡ refl ↝⟨ C.not-refl≢refl ⟩□
⊥ □
]
where
@0 lemma : _
lemma x = sym $ _≃_.from-to (Eq.≃-≡ $ Eq.inverse 𝕊¹≃𝕊¹ᴱ)
(_≃_.from (Eq.≃-≡ $ Eq.inverse 𝕊¹≃𝕊¹ᴱ) (refl x) ≡⟨⟩
cong (_≃_.from 𝕊¹≃𝕊¹ᴱ) (refl x) ≡⟨ cong-refl _ ⟩∎
refl (_≃_.from 𝕊¹≃𝕊¹ᴱ x) ∎)
-- For every universe level there is a type A such that
-- (x : A) → x ≡ x is not a proposition.
¬-type-of-refl-propositional :
∃ λ (A : Type a) → ¬ Is-proposition ((x : A) → x ≡ x)
¬-type-of-refl-propositional {a = a} =
↑ _ 𝕊¹ᴱ
, Stable-¬
[ Is-proposition ((x : ↑ _ 𝕊¹ᴱ) → x ≡ x) ↝⟨ (H-level-cong _ 1 $
Π-cong ext (↑-cong $ inverse 𝕊¹≃𝕊¹ᴱ) λ _ →
inverse $ Eq.≃-≡ $ ↑-cong $ inverse 𝕊¹≃𝕊¹ᴱ) ⟩
Is-proposition ((x : ↑ _ 𝕊¹) → x ≡ x) ↝⟨ proj₂ C.¬-type-of-refl-propositional ⟩□
⊥ □
]
-- Every value of type 𝕊¹ᴱ is merely equal to the base point (using
-- ∥_∥ᴱ to express "merely").
--
-- A variant of this lemma was mentioned by Mike Shulman in a blog
-- post (http://homotopytypetheory.org/2013/07/24/cohomology/).
all-points-on-the-circle-are-merely-equal :
(x : 𝕊¹ᴱ) → ∥ x ≡ base ∥ᴱ
all-points-on-the-circle-are-merely-equal =
elim _
T.∣ refl base ∣
(T.truncation-is-proposition _ _)
-- Every value of type 𝕊¹ᴱ is not not equal to the base point.
all-points-on-the-circle-are-¬¬-equal :
(x : 𝕊¹ᴱ) → ¬ ¬ x ≡ base
all-points-on-the-circle-are-¬¬-equal x =
Stable-¬
[ x ≢ base ↔⟨ →-cong ext (inverse $ Eq.≃-≡ $ inverse 𝕊¹≃𝕊¹ᴱ) Eq.id ⟩
_≃_.from 𝕊¹≃𝕊¹ᴱ x ≢ C.base ↝⟨ C.all-points-on-the-circle-are-¬¬-equal _ ⟩□
⊥ □
]
-- It is not the case that every value of type 𝕊¹ᴱ is equal to the
-- base point.
¬-all-points-on-the-circle-are-equal :
¬ ((x : 𝕊¹ᴱ) → x ≡ base)
¬-all-points-on-the-circle-are-equal =
Stable-¬
[ ((x : 𝕊¹ᴱ) → x ≡ base) ↔⟨ (Π-cong ext (inverse 𝕊¹≃𝕊¹ᴱ) λ _ →
inverse $ Eq.≃-≡ $ Eq.inverse 𝕊¹≃𝕊¹ᴱ) ⟩
((x : 𝕊¹) → x ≡ C.base) ↝⟨ C.¬-all-points-on-the-circle-are-equal ⟩□
⊥ □
]
-- Double-negation shift for Type-valued predicates over 𝕊¹ᴱ does not
-- hold in general.
¬-double-negation-shift :
¬ ({P : 𝕊¹ᴱ → Type} → ((x : 𝕊¹ᴱ) → ¬ ¬ P x) → ¬ ¬ ((x : 𝕊¹ᴱ) → P x))
¬-double-negation-shift =
Stable-¬
[ ({P : 𝕊¹ᴱ → Type} → ((x : 𝕊¹ᴱ) → ¬ ¬ P x) → ¬ ¬ ((x : 𝕊¹ᴱ) → P x)) ↔⟨ (implicit-Π-cong ext
(→-cong₁ {k₂ = equivalence} ext $ inverse 𝕊¹≃𝕊¹ᴱ) λ _ →
→-cong ext (inverse $ Π-cong ext 𝕊¹≃𝕊¹ᴱ λ _ → Eq.id) $
¬-cong ext $ ¬-cong ext $ inverse $ Π-cong ext 𝕊¹≃𝕊¹ᴱ λ _ → Eq.id) ⟩
({P : 𝕊¹ → Type} → ((x : 𝕊¹) → ¬ ¬ P x) → ¬ ¬ ((x : 𝕊¹) → P x)) ↝⟨ C.¬-double-negation-shift ⟩□
⊥ □
]
-- H-level.Closure.proj₁-closure cannot be generalised by replacing
-- the assumption ∀ a → B a with ∀ a → ∥ B a ∥ᴱ.
--
-- A variant of this observation is due to Andrea Vezzosi.
¬-generalised-proj₁-closure :
¬ ({A : Type} {B : A → Type} →
(∀ a → ∥ B a ∥ᴱ) →
∀ n → H-level n (Σ A B) → H-level n A)
¬-generalised-proj₁-closure generalised-proj₁-closure =
$⟨ singleton-contractible _ ⟩
Contractible (Σ 𝕊¹ᴱ (_≡ base)) ↝⟨ generalised-proj₁-closure
all-points-on-the-circle-are-merely-equal
0 ⟩
Contractible 𝕊¹ᴱ ↝⟨ ¬-𝕊¹ᴱ-set ∘ mono (zero≤ 2) ⟩□
⊥ □
-- There is no based equivalence between 𝕊¹ᴱ and the product of 𝕊¹ᴱ
-- with itself.
𝕊¹ᴱ≄ᴮ𝕊¹ᴱ×𝕊¹ᴱ : ¬ (𝕊¹ᴱ , base) ≃ᴮ ((𝕊¹ᴱ , base) PT.× (𝕊¹ᴱ , base))
𝕊¹ᴱ≄ᴮ𝕊¹ᴱ×𝕊¹ᴱ =
Stable-¬
[ (𝕊¹ᴱ , base) ≃ᴮ ((𝕊¹ᴱ , base) PT.× (𝕊¹ᴱ , base)) ↝⟨ PT.↝ᴮ-trans 𝕊¹≃ᴮ𝕊¹ᴱ ∘
flip PT.↝ᴮ-trans (PT.≃ᴮ-sym (𝕊¹≃ᴮ𝕊¹ᴱ PT.×-cong-≃ᴮ 𝕊¹≃ᴮ𝕊¹ᴱ)) ⟩
(𝕊¹ , C.base) ≃ᴮ ((𝕊¹ , C.base) PT.× (𝕊¹ , C.base)) ↝⟨ C.𝕊¹≄ᴮ𝕊¹×𝕊¹ ⟩□
⊥ □
]
-- 𝕊¹ᴱ is not equivalent to 𝕊¹ᴱ × 𝕊¹ᴱ.
𝕊¹ᴱ≄𝕊¹ᴱ×𝕊¹ᴱ : ¬ 𝕊¹ᴱ ≃ (𝕊¹ᴱ × 𝕊¹ᴱ)
𝕊¹ᴱ≄𝕊¹ᴱ×𝕊¹ᴱ =
Stable-¬
[ 𝕊¹ᴱ ≃ (𝕊¹ᴱ × 𝕊¹ᴱ) ↔⟨ Eq.≃-preserves ext (inverse 𝕊¹≃𝕊¹ᴱ) (inverse $ 𝕊¹≃𝕊¹ᴱ ×-cong 𝕊¹≃𝕊¹ᴱ) ⟩
𝕊¹ ≃ (𝕊¹ × 𝕊¹) ↝⟨ C.𝕊¹≄𝕊¹×𝕊¹ ⟩□
⊥ □
]
| 38.459924
| 146
| 0.457252
|
5286267555d9f7c3b38f5a92395a218c48961793
| 37,348
|
agda
|
Agda
|
Cubical/Homotopy/HopfInvariant/Homomorphism.agda
|
FernandoLarrain/cubical
|
9acdecfa6437ec455568be4e5ff04849cc2bc13b
|
[
"MIT"
] | 1
|
2022-02-05T01:25:02.000Z
|
2022-02-05T01:25:02.000Z
|
Cubical/Homotopy/HopfInvariant/Homomorphism.agda
|
FernandoLarrain/cubical
|
9acdecfa6437ec455568be4e5ff04849cc2bc13b
|
[
"MIT"
] | null | null | null |
Cubical/Homotopy/HopfInvariant/Homomorphism.agda
|
FernandoLarrain/cubical
|
9acdecfa6437ec455568be4e5ff04849cc2bc13b
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --safe --experimental-lossy-unification #-}
module Cubical.Homotopy.HopfInvariant.Homomorphism where
open import Cubical.Homotopy.HopfInvariant.Base
open import Cubical.Homotopy.Group.Base
open import Cubical.Homotopy.Group.SuspensionMap
open import Cubical.ZCohomology.Base
open import Cubical.ZCohomology.GroupStructure
open import Cubical.ZCohomology.Properties
open import Cubical.ZCohomology.MayerVietorisUnreduced
open import Cubical.ZCohomology.Groups.Unit
open import Cubical.ZCohomology.Groups.Wedge
open import Cubical.ZCohomology.Groups.Sn
open import Cubical.ZCohomology.RingStructure.CupProduct
open import Cubical.ZCohomology.RingStructure.GradedCommutativity
open import Cubical.ZCohomology.Gysin
open import Cubical.Foundations.Path
open import Cubical.Foundations.HLevels
open import Cubical.Foundations.Transport
open import Cubical.Foundations.Function
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Pointed
open import Cubical.Foundations.Isomorphism
open import Cubical.Foundations.GroupoidLaws
open import Cubical.Foundations.Equiv
open import Cubical.Data.Sigma
open import Cubical.Data.Int hiding (_+'_)
open import Cubical.Data.Nat renaming (_+_ to _+ℕ_ ; _·_ to _·ℕ_)
open import Cubical.Data.Unit
open import Cubical.Algebra.Group
renaming (ℤ to ℤGroup ; Unit to UnitGroup)
open import Cubical.Algebra.Group.ZAction
open import Cubical.Algebra.Group.Exact
open import Cubical.HITs.Pushout
open import Cubical.HITs.Sn
open import Cubical.HITs.Susp
open import Cubical.HITs.Wedge
open import Cubical.HITs.Truncation
open import Cubical.HITs.SetTruncation
renaming (elim to sElim ; elim2 to sElim2 ; map to sMap)
open import Cubical.HITs.PropositionalTruncation
-- The pushout describing the hopf invariant of the multiplication (∙Π) of
-- two maps (S³⁺²ⁿ →∙ S²⁺ⁿ)
C·Π : (n : ℕ) (f g : S₊∙ (3 +ℕ (n +ℕ n)) →∙ S₊∙ (2 +ℕ n)) → Type _
C·Π n f g = Pushout (λ _ → tt) (∙Π f g .fst)
-- Another pushout, essentially the same, but starting with
-- S³⁺²ⁿ ∨ S³⁺²ⁿ. This will be used to break up the hopf invariant
-- of ∙Π f g.
C* : ∀ n → (f g : S₊∙ (3 +ℕ (n +ℕ n)) →∙ S₊∙ (2 +ℕ n)) → Type _
C* n f g = Pushout (λ _ → tt) (fst (∨→∙ f g))
-- The coequaliser of ∙Π and ∨→∙
θ : ∀ {ℓ} {A : Pointed ℓ} → Susp (fst A)
→ (Susp (fst A) , north) ⋁ (Susp (fst A) , north)
θ north = inl north
θ south = inr north
θ {A = A} (merid a i₁) =
((λ i → inl ((merid a ∙ sym (merid (pt A))) i))
∙∙ push tt
∙∙ λ i → inr ((merid a ∙ sym (merid (pt A))) i)) i₁
∙Π≡∨→∘θ : ∀ n → (f g : S₊∙ (3 +ℕ (n +ℕ n)) →∙ S₊∙ (2 +ℕ n))
→ (x : _) → ∙Π f g .fst x ≡ (f ∨→ g) (θ {A = S₊∙ _} x)
∙Π≡∨→∘θ n f g north = sym (snd f)
∙Π≡∨→∘θ n f g south = sym (snd g)
∙Π≡∨→∘θ n f g (merid a i₁) j = main j i₁
where
help : cong (f ∨→ g) (cong (θ {A = S₊∙ _}) (merid a))
≡ (refl ∙∙ cong (fst f) (merid a ∙ sym (merid north)) ∙∙ snd f)
∙ (sym (snd g) ∙∙ cong (fst g) (merid a ∙ sym (merid north)) ∙∙ refl)
help = cong-∙∙ (f ∨→ g) ((λ i → inl ((merid a ∙ sym (merid north)) i)))
(push tt)
(λ i → inr ((merid a ∙ sym (merid north)) i))
∙∙ doubleCompPath≡compPath _ _ _
∙∙ cong (cong (f ∨→ g)
(λ i₂ → inl ((merid a ∙ (λ i₃ → merid north (~ i₃))) i₂)) ∙_)
(sym (assoc _ _ _))
∙∙ assoc _ _ _
∙∙ cong₂ _∙_ refl (compPath≡compPath' _ _)
main : PathP (λ i → snd f (~ i)
≡ snd g (~ i)) (λ i₁ → ∙Π f g .fst (merid a i₁))
λ i₁ → (f ∨→ g) (θ {A = S₊∙ _} (merid a i₁))
main = (λ i → ((λ j → snd f (~ i ∧ ~ j))
∙∙ cong (fst f) (merid a ∙ sym (merid north))
∙∙ snd f)
∙ (sym (snd g)
∙∙ cong (fst g) (merid a ∙ sym (merid north))
∙∙ λ j → snd g (~ i ∧ j)))
▷ sym help
private
WedgeElim : ∀ {ℓ} (n : ℕ)
{P : S₊∙ (3 +ℕ (n +ℕ n)) ⋁ S₊∙ (3 +ℕ (n +ℕ n)) → Type ℓ}
→ ((x : _) → isOfHLevel (3 +ℕ n) (P x))
→ P (inl north)
→ (x : _) → P x
WedgeElim n {P = P} x s (inl x₁) =
sphereElim _ {A = P ∘ inl}
(λ _ → isOfHLevelPlus' {n = n} (3 +ℕ n) (x _)) s x₁
WedgeElim n {P = P} x s (inr x₁) =
sphereElim _ {A = P ∘ inr}
(sphereElim _ (λ _ → isProp→isOfHLevelSuc ((suc (suc (n +ℕ n))))
(isPropIsOfHLevel (suc (suc (suc (n +ℕ n))))))
(subst (isOfHLevel ((3 +ℕ n) +ℕ n)) (cong P (push tt))
(isOfHLevelPlus' {n = n} (3 +ℕ n) (x _))))
(subst P (push tt) s) x₁
WedgeElim n {P = P} x s (push a j) =
transp (λ i → P (push tt (i ∧ j))) (~ j) s
H²C*≅ℤ : ∀ n → (f g : S₊∙ (3 +ℕ (n +ℕ n)) →∙ S₊∙ (2 +ℕ n))
→ GroupIso (coHomGr (2 +ℕ n) (C* n f g)) ℤGroup
H²C*≅ℤ n f g = compGroupIso is (Hⁿ-Sⁿ≅ℤ (suc n))
where
∘inr : (coHom (2 +ℕ n) (C* n f g)) → coHom (2 +ℕ n) (S₊ (2 +ℕ n))
∘inr = sMap λ f → f ∘ inr
invMapPrim : (S₊ (2 +ℕ n) → coHomK (2 +ℕ n))
→ C* n f g → coHomK (2 +ℕ n)
invMapPrim h (inl x) = h (ptSn _)
invMapPrim h (inr x) = h x
invMapPrim h (push a i₁) =
WedgeElim n {P = λ a → h north ≡ h (fst (∨→∙ f g) a)}
(λ _ → isOfHLevelTrunc (4 +ℕ n) _ _)
(cong h (sym (snd f))) a i₁
invMap : coHom (2 +ℕ n) (S₊ (2 +ℕ n)) → (coHom (2 +ℕ n) (C* n f g))
invMap = sMap invMapPrim
∘inrSect : (x : coHom (2 +ℕ n) (S₊ (2 +ℕ n))) → ∘inr (invMap x) ≡ x
∘inrSect = sElim (λ _ → isOfHLevelPath 2 squash₂ _ _)
λ a → refl
∘inrRetr : (x : (coHom (2 +ℕ n) (C* n f g))) → invMap (∘inr x) ≡ x
∘inrRetr =
sElim (λ _ → isOfHLevelPath 2 squash₂ _ _)
λ h → cong ∣_∣₂ (funExt λ { (inl x) → cong h ((λ i → inr ((snd f) (~ i)))
∙ sym (push (inl north)))
; (inr x) → refl
; (push a i) → lem₁ h a i})
where
lem₁ : (h : C* n f g → coHomK (2 +ℕ n)) (a : _)
→ PathP (λ i → invMapPrim (h ∘ inr) (push a i) ≡ h (push a i))
(cong h ((λ i → inr ((snd f) (~ i)))
∙ sym (push (inl north))))
refl
lem₁ h =
WedgeElim n (λ _ → isOfHLevelPathP (3 +ℕ n)
(isOfHLevelTrunc (4 +ℕ n) _ _) _ _)
lem₂
where
lem₂ : PathP (λ i → invMapPrim (h ∘ inr) (push (inl north) i)
≡ h (push (inl north) i))
(cong h ((λ i → inr ((snd f) (~ i)))
∙ sym (push (inl north))))
refl
lem₂ i j = h (hcomp (λ k → λ { (i = i1) → inr (fst f north)
; (j = i0) → inr (snd f (~ i))
; (j = i1) → push (inl north) (i ∨ ~ k)})
(inr (snd f (~ i ∧ ~ j))))
is : GroupIso (coHomGr (2 +ℕ n) (C* n f g)) (coHomGr (2 +ℕ n) (S₊ (2 +ℕ n)))
Iso.fun (fst is) = ∘inr
Iso.inv (fst is) = invMap
Iso.rightInv (fst is) = ∘inrSect
Iso.leftInv (fst is) = ∘inrRetr
snd is = makeIsGroupHom
(sElim2 (λ _ _ → isOfHLevelPath 2 squash₂ _ _)
λ f g → refl)
H⁴-C·Π : (n : ℕ) (f g : S₊∙ (3 +ℕ (n +ℕ n)) →∙ S₊∙ (2 +ℕ n))
→ GroupIso (coHomGr ((2 +ℕ n) +' (2 +ℕ n)) (C·Π n f g))
ℤGroup
H⁴-C·Π n f g = compGroupIso
(transportCohomIso (cong (3 +ℕ_) (+-suc n n))) (Hopfβ-Iso n (∙Π f g))
H²-C·Π : (n : ℕ) (f g : S₊∙ (3 +ℕ (n +ℕ n)) →∙ S₊∙ (2 +ℕ n))
→ GroupIso (coHomGr (2 +ℕ n) (C·Π n f g))
ℤGroup
H²-C·Π n f g = Hopfα-Iso n (∙Π f g)
H⁴-C* : ∀ n → (f g : S₊∙ (3 +ℕ (n +ℕ n)) →∙ S₊∙ (2 +ℕ n))
→ GroupIso (coHomGr ((2 +ℕ n) +' (2 +ℕ n)) (C* n f g))
(DirProd ℤGroup ℤGroup)
H⁴-C* n f g =
compGroupIso (GroupEquiv→GroupIso (invGroupEquiv fstIso))
(compGroupIso (transportCohomIso (cong (2 +ℕ_) (+-suc n n)))
(compGroupIso (Hⁿ-⋁ (S₊∙ (suc (suc (suc (n +ℕ n)))))
(S₊∙ (suc (suc (suc (n +ℕ n))))) _)
(GroupIsoDirProd (Hⁿ-Sⁿ≅ℤ _) (Hⁿ-Sⁿ≅ℤ _))))
where
module Ms = MV _ _ _ (λ _ → tt) (fst (∨→∙ f g))
fstIso : GroupEquiv (coHomGr ((suc (suc (n +ℕ suc n))))
(S₊∙ (3 +ℕ (n +ℕ n)) ⋁ S₊∙ (3 +ℕ (n +ℕ n))))
(coHomGr ((2 +ℕ n) +' (2 +ℕ n)) (C* n f g))
fst (fst fstIso) = Ms.d (suc (suc (n +ℕ suc n))) .fst
snd (fst fstIso) =
SES→isEquiv
(sym (fst (GroupPath _ _)
(isContr→≃Unit
(isContrΣ (subst isContr (isoToPath (invIso (fst (Hⁿ-Unit≅0 _))))
isContrUnit)
(λ _ → subst isContr (isoToPath (invIso
(fst (Hⁿ-Sᵐ≅0 _ _ λ p →
¬lemHopf 0 ((λ _ → north) , refl)
n n (cong suc (sym (+-suc n n)) ∙ p)))))
isContrUnit))
, makeIsGroupHom λ _ _ → refl)))
(GroupPath _ _ .fst
(compGroupEquiv (invEquiv (isContr→≃Unit ((tt , tt) , (λ _ → refl)))
, makeIsGroupHom λ _ _ → refl)
(GroupEquivDirProd
(GroupIso→GroupEquiv (invGroupIso (Hⁿ-Unit≅0 _)))
(GroupIso→GroupEquiv
(invGroupIso (Hⁿ-Sᵐ≅0 _ _ λ p →
¬lemHopf 0 ((λ _ → north) , refl)
n (suc n) (cong (2 +ℕ_) (sym (+-suc n n))
∙ p)))))))
(Ms.Δ (suc (suc (n +ℕ suc n))))
(Ms.d (suc (suc (n +ℕ suc n))))
(Ms.i (suc (suc (suc (n +ℕ suc n)))))
(Ms.Ker-d⊂Im-Δ _)
(Ms.Ker-i⊂Im-d _)
snd fstIso = Ms.d (suc (suc (n +ℕ suc n))) .snd
module _ (n : ℕ) (f g : S₊∙ (3 +ℕ (n +ℕ n)) →∙ S₊∙ (2 +ℕ n)) where
C·Π' = C·Π n f g
-- The generators of the cohomology groups of C* and C·Π
βₗ : coHom ((2 +ℕ n) +' (2 +ℕ n)) (C* n f g)
βₗ = Iso.inv (fst (H⁴-C* n f g)) (1 , 0)
βᵣ : coHom ((2 +ℕ n) +' (2 +ℕ n)) (C* n f g)
βᵣ = Iso.inv (fst (H⁴-C* n f g)) (0 , 1)
β·Π : coHom ((2 +ℕ n) +' (2 +ℕ n)) C·Π'
β·Π = Iso.inv (fst (H⁴-C·Π n f g)) 1
α* : coHom (2 +ℕ n) (C* n f g)
α* = Iso.inv (fst (H²C*≅ℤ n f g)) 1
-- They can be difficult to work with in this form.
-- We give them simpler forms and prove that these are equivalent
βᵣ'-fun : C* n f g → coHomK ((4 +ℕ (n +ℕ n)))
βᵣ'-fun (inl x) = 0ₖ _
βᵣ'-fun (inr x) = 0ₖ _
βᵣ'-fun (push (inl x) i₁) = 0ₖ _
βᵣ'-fun (push (inr x) i₁) = Kn→ΩKn+1 _ ∣ x ∣ i₁
βᵣ'-fun (push (push a i₂) i₁) = Kn→ΩKn+10ₖ _ (~ i₂) i₁
βₗ'-fun : C* n f g → coHomK (4 +ℕ (n +ℕ n))
βₗ'-fun (inl x) = 0ₖ _
βₗ'-fun (inr x) = 0ₖ _
βₗ'-fun (push (inl x) i₁) = Kn→ΩKn+1 _ ∣ x ∣ i₁
βₗ'-fun (push (inr x) i₁) = 0ₖ _
βₗ'-fun (push (push a i₂) i₁) = Kn→ΩKn+10ₖ _ i₂ i₁
βₗ''-fun : coHom ((2 +ℕ n) +' (2 +ℕ n)) (C* n f g)
βₗ''-fun = subst (λ m → coHom m (C* n f g))
(cong (suc ∘ suc ∘ suc) (sym (+-suc n n)))
∣ βₗ'-fun ∣₂
βᵣ''-fun : coHom ((2 +ℕ n) +' (2 +ℕ n)) (C* n f g)
βᵣ''-fun = subst (λ m → coHom m (C* n f g))
(cong (suc ∘ suc ∘ suc) (sym (+-suc n n)))
∣ βᵣ'-fun ∣₂
private
0ₖ≡∨→ : (a : _) → 0ₖ (suc (suc n)) ≡ ∣ (f ∨→ g) a ∣
0ₖ≡∨→ = WedgeElim _ (λ _ → isOfHLevelTrunc (4 +ℕ n) _ _)
(cong ∣_∣ₕ (sym (snd f)))
0ₖ≡∨→-inr : 0ₖ≡∨→ (inr north) ≡ cong ∣_∣ₕ (sym (snd g))
0ₖ≡∨→-inr =
(λ j → transport (λ i → 0ₖ (2 +ℕ n)
≡ ∣ compPath-filler' (snd f) (sym (snd g)) (~ j) i ∣ₕ)
λ i → ∣ snd f (~ i ∨ j) ∣ₕ)
∙ λ j → transp (λ i → 0ₖ (2 +ℕ n) ≡ ∣ snd g (~ i ∧ ~ j) ∣ₕ) j
λ i → ∣ snd g (~ i ∨ ~ j) ∣ₕ
α*'-fun : C* n f g → coHomK (2 +ℕ n)
α*'-fun (inl x) = 0ₖ _
α*'-fun (inr x) = ∣ x ∣
α*'-fun (push a i₁) = 0ₖ≡∨→ a i₁
α*' : coHom (2 +ℕ n) (C* n f g)
α*' = ∣ α*'-fun ∣₂
-- We also need the following three maps
jₗ : HopfInvariantPush n (fst f) → C* n f g
jₗ (inl x) = inl x
jₗ (inr x) = inr x
jₗ (push a i₁) = push (inl a) i₁
jᵣ : HopfInvariantPush n (fst g) → C* n f g
jᵣ (inl x) = inl x
jᵣ (inr x) = inr x
jᵣ (push a i₁) = push (inr a) i₁
q : C·Π' → C* n f g
q (inl x) = inl x
q (inr x) = inr x
q (push a i₁) = (push (θ a) ∙ λ i → inr (∙Π≡∨→∘θ n f g a (~ i))) i₁
α↦1 : (n : ℕ) (f g : S₊∙ (3 +ℕ (n +ℕ n)) →∙ S₊∙ (2 +ℕ n))
→ Iso.fun (fst (H²C*≅ℤ n f g)) (α*' n f g) ≡ 1
α↦1 n f g =
sym (cong (Iso.fun (fst (Hⁿ-Sⁿ≅ℤ (suc n)))) (Hⁿ-Sⁿ≅ℤ-nice-generator n))
∙ Iso.rightInv (fst (Hⁿ-Sⁿ≅ℤ (suc n))) (pos 1)
α≡ : (n : ℕ) (f g : S₊∙ (3 +ℕ (n +ℕ n)) →∙ S₊∙ (2 +ℕ n))
→ α* n f g ≡ α*' n f g
α≡ n f g = sym (Iso.leftInv (fst (H²C*≅ℤ n f g)) _)
∙∙ cong (Iso.inv (fst (H²C*≅ℤ n f g))) lem
∙∙ Iso.leftInv (fst (H²C*≅ℤ n f g)) _
where
lem : Iso.fun (fst (H²C*≅ℤ n f g)) (α* n f g)
≡ Iso.fun (fst (H²C*≅ℤ n f g)) (α*' n f g)
lem = (Iso.rightInv (fst (H²C*≅ℤ n f g)) (pos 1)) ∙ sym (α↦1 n f g)
q-α : (n : ℕ) (f g : S₊∙ (3 +ℕ (n +ℕ n)) →∙ S₊∙ (2 +ℕ n))
→ coHomFun _ (q n f g) (α* n f g) ≡ Hopfα n (∙Π f g)
q-α n f g = (λ i → coHomFun _ (q n f g) (α≡ n f g i))
∙ sym (Iso.leftInv is _)
∙∙ cong (Iso.inv is) lem
∙∙ Iso.leftInv is _
where
is = fst (Hopfα-Iso n (∙Π f g))
lem : Iso.fun is (coHomFun _ (q n f g) (α*' n f g))
≡ Iso.fun is (Hopfα n (∙Π f g))
lem = sym (cong (Iso.fun (fst (Hⁿ-Sⁿ≅ℤ (suc n)))) (Hⁿ-Sⁿ≅ℤ-nice-generator n))
∙∙ Iso.rightInv (fst (Hⁿ-Sⁿ≅ℤ (suc n))) (pos 1)
∙∙ sym (Hopfα-Iso-α n (∙Π f g))
βₗ≡ : (n : ℕ) (f g : S₊∙ (3 +ℕ (n +ℕ n)) →∙ S₊∙ (2 +ℕ n))
→ βₗ n f g ≡ βₗ''-fun n f g
βₗ≡ n f g = cong (∨-d ∘ subber₂)
(cong (Iso.inv (fst ((Hⁿ-⋁ (S₊∙ (suc (suc (suc (n +ℕ n)))))
(S₊∙ (suc (suc (suc (n +ℕ n)))))
(((suc (suc (n +ℕ n))))))))) help
∙ lem)
∙ funExt⁻ ∨-d∘subber ∣ wedgeGen ∣₂
∙ cong subber₃ (sym βₗ'-fun≡)
where
∨-d = MV.d _ _ _ (λ _ → tt) (fst (∨→∙ f g)) (suc (suc (n +ℕ suc n))) .fst
∨-d' = MV.d _ _ _ (λ _ → tt) (fst (∨→∙ f g)) (suc (suc (suc (n +ℕ n)))) .fst
help : Iso.inv (fst (GroupIsoDirProd
(Hⁿ-Sⁿ≅ℤ (suc (suc (n +ℕ n))))
(Hⁿ-Sⁿ≅ℤ (suc (suc (n +ℕ n)))))) (1 , 0)
≡ (∣ ∣_∣ ∣₂ , 0ₕ _)
help = ΣPathP ((Hⁿ-Sⁿ≅ℤ-nice-generator _)
, IsGroupHom.pres1 (snd (invGroupIso (Hⁿ-Sⁿ≅ℤ (suc (suc (n +ℕ n)))))))
subber₃ = subst (λ m → coHom m (C* n f g))
(cong (suc ∘ suc ∘ suc) (sym (+-suc n n)))
subber₂ = (subst (λ m → coHom m (S₊∙ (suc (suc (suc (n +ℕ n))))
⋁ S₊∙ (suc (suc (suc (n +ℕ n))))))
(sym (cong (2 +ℕ_) (+-suc n n))))
∨-d∘subber : ∨-d ∘ subber₂ ≡ subber₃ ∘ ∨-d'
∨-d∘subber =
funExt (λ a →
(λ j → transp (λ i → coHom ((suc ∘ suc ∘ suc) (+-suc n n (~ i ∧ j)))
(C* n f g)) (~ j)
(MV.d _ _ _ (λ _ → tt) (fst (∨→∙ f g))
(suc (suc (+-suc n n j))) .fst
(transp (λ i → coHom (2 +ℕ (+-suc n n (j ∨ ~ i)))
(S₊∙ (suc (suc (suc (n +ℕ n))))
⋁ S₊∙ (suc (suc (suc (n +ℕ n)))))) j
a))))
wedgeGen : (S₊∙ (suc (suc (suc (n +ℕ n)))) ⋁ S₊∙ (suc (suc (suc (n +ℕ n))))
→ coHomK (suc (suc (suc (n +ℕ n)))))
wedgeGen (inl x) = ∣ x ∣
wedgeGen (inr x) = 0ₖ _
wedgeGen (push a i₁) = 0ₖ _
βₗ'-fun≡ : ∣ βₗ'-fun n f g ∣₂ ≡ ∨-d' ∣ wedgeGen ∣₂
βₗ'-fun≡ =
cong ∣_∣₂ (funExt λ { (inl x) → refl
; (inr x) → refl
; (push (inl x) i₁) → refl
; (push (inr x) i₁) j → Kn→ΩKn+10ₖ _ (~ j) i₁
; (push (push a i₂) i₁) j → Kn→ΩKn+10ₖ _ (~ j ∧ i₂) i₁})
lem : Iso.inv (fst (Hⁿ-⋁ (S₊∙ (suc (suc (suc (n +ℕ n)))))
(S₊∙ (suc (suc (suc (n +ℕ n)))))
(((suc (suc (n +ℕ n)))))))
(∣ ∣_∣ ∣₂ , 0ₕ _)
≡ ∣ wedgeGen ∣₂
lem = cong ∣_∣₂ (funExt λ { (inl x) → rUnitₖ (suc (suc (suc (n +ℕ n)))) ∣ x ∣
; (inr x) → refl
; (push a i₁) → refl})
βᵣ≡ : (n : ℕ) (f g : S₊∙ (3 +ℕ (n +ℕ n)) →∙ S₊∙ (2 +ℕ n))
→ βᵣ n f g ≡ βᵣ''-fun n f g
βᵣ≡ n f g =
cong (∨-d ∘ subber₂)
(cong (Iso.inv (fst (Hⁿ-⋁ (S₊∙ (suc (suc (suc (n +ℕ n)))))
(S₊∙ (suc (suc (suc (n +ℕ n)))))
(suc (suc (n +ℕ n))))))
help
∙ lem)
∙ funExt⁻ ∨-d∘subber ∣ wedgeGen ∣₂
∙ cong (subber₃) (sym βᵣ'-fun≡)
where
∨-d = MV.d _ _ _ (λ _ → tt) (fst (∨→∙ f g)) (suc (suc (n +ℕ suc n))) .fst
∨-d' = MV.d _ _ _ (λ _ → tt) (fst (∨→∙ f g)) (suc (suc (suc (n +ℕ n)))) .fst
help : Iso.inv (fst (GroupIsoDirProd
(Hⁿ-Sⁿ≅ℤ (suc (suc (n +ℕ n))))
(Hⁿ-Sⁿ≅ℤ (suc (suc (n +ℕ n)))))) (0 , 1)
≡ (0ₕ _ , ∣ ∣_∣ ∣₂)
help =
ΣPathP (IsGroupHom.pres1 (snd (invGroupIso (Hⁿ-Sⁿ≅ℤ (suc (suc (n +ℕ n))))))
, (Hⁿ-Sⁿ≅ℤ-nice-generator _))
subber₃ = subst (λ m → coHom m (C* n f g))
(cong (suc ∘ suc ∘ suc) (sym (+-suc n n)))
subber₂ = (subst (λ m → coHom m (S₊∙ (suc (suc (suc (n +ℕ n))))
⋁ S₊∙ (suc (suc (suc (n +ℕ n))))))
(sym (cong (2 +ℕ_) (+-suc n n))))
∨-d∘subber : ∨-d ∘ subber₂ ≡ subber₃ ∘ ∨-d'
∨-d∘subber =
funExt (λ a →
(λ j → transp (λ i → coHom ((suc ∘ suc ∘ suc) (+-suc n n (~ i ∧ j)))
(C* n f g)) (~ j)
(MV.d _ _ _ (λ _ → tt)
(fst (∨→∙ f g)) (suc (suc (+-suc n n j))) .fst
(transp (λ i → coHom (2 +ℕ (+-suc n n (j ∨ ~ i)))
(S₊∙ (suc (suc (suc (n +ℕ n))))
⋁ S₊∙ (suc (suc (suc (n +ℕ n)))))) j
a))))
wedgeGen : (S₊∙ (suc (suc (suc (n +ℕ n)))) ⋁ S₊∙ (suc (suc (suc (n +ℕ n))))
→ coHomK (suc (suc (suc (n +ℕ n)))))
wedgeGen (inl x) = 0ₖ _
wedgeGen (inr x) = ∣ x ∣
wedgeGen (push a i₁) = 0ₖ _
lem : Iso.inv (fst ((Hⁿ-⋁ (S₊∙ (suc (suc (suc (n +ℕ n)))))
(S₊∙ (suc (suc (suc (n +ℕ n)))))
(suc (suc (n +ℕ n))))))
(0ₕ _ , ∣ ∣_∣ ∣₂)
≡ ∣ wedgeGen ∣₂
lem = cong ∣_∣₂ (funExt λ { (inl x) → refl
; (inr x) → lUnitₖ (suc (suc (suc (n +ℕ n)))) ∣ x ∣
; (push a i₁) → refl})
βᵣ'-fun≡ : ∣ βᵣ'-fun n f g ∣₂ ≡ ∨-d' ∣ wedgeGen ∣₂
βᵣ'-fun≡ =
cong ∣_∣₂ (funExt
λ { (inl x) → refl
; (inr x) → refl
; (push (inl x) i₁) j → Kn→ΩKn+10ₖ _ (~ j) i₁
; (push (inr x) i₁) → refl
; (push (push a i₂) i₁) j → Kn→ΩKn+10ₖ _ (~ j ∧ ~ i₂) i₁})
q-βₗ : (n : ℕ) (f g : S₊∙ (3 +ℕ (n +ℕ n)) →∙ S₊∙ (2 +ℕ n))
→ coHomFun _ (q n f g) (βₗ n f g)
≡ β·Π n f g
q-βₗ n f g = cong (coHomFun _ (q n f g)) (βₗ≡ n f g)
∙ transportLem
∙ cong (subst (λ m → coHom m (C·Π' n f g))
(cong (suc ∘ suc ∘ suc) (sym (+-suc n n))))
(sym (Iso.leftInv (fst (Hopfβ-Iso n (∙Π f g)))
(Hopfβ n (∙Π f g)))
∙ cong (Iso.inv ((fst (Hopfβ-Iso n (∙Π f g)))))
(Hopfβ↦1 n (∙Π f g)))
where
transportLem : coHomFun (suc (suc (suc (n +ℕ suc n)))) (q n f g)
(βₗ''-fun n f g)
≡ subst (λ m → coHom m (C·Π' n f g))
(cong (suc ∘ suc ∘ suc) (sym (+-suc n n)))
(Hopfβ n (∙Π f g))
transportLem =
natTranspLem ∣ βₗ'-fun n f g ∣₂ (λ m → coHomFun m (q n f g))
(cong (suc ∘ suc ∘ suc) (sym (+-suc n n)))
∙ cong (subst (λ m → coHom m (C·Π' n f g))
(cong (suc ∘ suc ∘ suc) (sym (+-suc n n))))
(cong ∣_∣₂ (funExt λ { (inl x) → refl
; (inr x) → refl
; (push a i₁) → push-lem a i₁}))
where
push-lem : (x : fst (S₊∙ (3 +ℕ (n +ℕ n)))) →
PathP (λ i₁ → βₗ'-fun n f g ((push (θ x)
∙ λ i → inr (∙Π≡∨→∘θ n f g x (~ i))) i₁)
≡ MV.d-pre Unit (fst (S₊∙ (2 +ℕ n))) (fst (S₊∙ (3 +ℕ n +ℕ n)))
(λ _ → tt) (fst (∙Π f g)) (3 +ℕ n +ℕ n) ∣_∣ (push x i₁))
(λ _ → βₗ'-fun n f g (q n f g (inl tt)))
(λ _ → βₗ'-fun n f g (q n f g (inr (∙Π f g .fst x))))
push-lem x =
flipSquare (cong-∙ (βₗ'-fun n f g)
(push (θ x)) (λ i → inr (∙Π≡∨→∘θ n f g x (~ i)))
∙∙ sym (rUnit _)
∙∙ lem₁ x)
where
lem₁ : (x : _) → cong (βₗ'-fun n f g) (push (θ {A = S₊∙ _} x))
≡ Kn→ΩKn+1 _ ∣ x ∣
lem₁ north = refl
lem₁ south =
sym (Kn→ΩKn+10ₖ _)
∙ cong (Kn→ΩKn+1 (suc (suc (suc (n +ℕ n))))) (cong ∣_∣ₕ (merid north))
lem₁ (merid a j) k = merid-lem k j
where
p = pt (S₊∙ (suc (suc (n +ℕ n))))
merid-lem :
PathP (λ k → Kn→ΩKn+1 _ ∣ north ∣ₕ
≡ (sym (Kn→ΩKn+10ₖ _)
∙ cong (Kn→ΩKn+1 (suc (suc (suc (n +ℕ n)))))
(cong ∣_∣ₕ (merid north))) k)
(λ j → cong (βₗ'-fun n f g) (push (θ {A = S₊∙ _} (merid a j))))
(cong (Kn→ΩKn+1 (suc (suc (suc (n +ℕ n)))) ∘ ∣_∣ₕ) (merid a))
merid-lem =
(cong-∙∙ (cong (βₗ'-fun n f g) ∘ push)
(λ i₁ → inl ((merid a ∙ (sym (merid p))) i₁))
(push tt)
((λ i₁ → inr ((merid a ∙ (sym (merid p))) i₁)))
∙ sym (compPath≡compPath' _ _)
∙ cong (_∙ Kn→ΩKn+10ₖ _)
(cong-∙ ((Kn→ΩKn+1 (suc (suc (suc (n +ℕ n)))) ∘ ∣_∣ₕ))
(merid a) (sym (merid north)))
∙ sym (assoc _ _ _)
∙ cong (cong (Kn→ΩKn+1 (suc (suc (suc (n +ℕ n)))) ∘ ∣_∣ₕ) (merid a) ∙_)
(sym (symDistr (sym ((Kn→ΩKn+10ₖ _)))
(cong (Kn→ΩKn+1 (suc (suc (suc (n +ℕ n)))))
(cong ∣_∣ₕ (merid north))))))
◁ λ i j → compPath-filler
(cong (Kn→ΩKn+1 (suc (suc (suc (n +ℕ n)))) ∘ ∣_∣ₕ) (merid a))
(sym (sym (Kn→ΩKn+10ₖ _)
∙ cong (Kn→ΩKn+1 (suc (suc (suc (n +ℕ n)))))
(cong ∣_∣ₕ (merid north))))
(~ i) j
q-βᵣ : (n : ℕ) (f g : S₊∙ (3 +ℕ (n +ℕ n)) →∙ S₊∙ (2 +ℕ n))
→ coHomFun _ (q n f g) (βᵣ n f g)
≡ β·Π n f g
q-βᵣ n f g = cong (coHomFun _ (q n f g)) (βᵣ≡ n f g)
∙ transportLem
∙ cong (subst (λ m → coHom m (C·Π' n f g))
(cong (suc ∘ suc ∘ suc) (sym (+-suc n n))))
(sym (Iso.leftInv (fst (Hopfβ-Iso n (∙Π f g)))
(Hopfβ n (∙Π f g)))
∙ cong (Iso.inv ((fst (Hopfβ-Iso n (∙Π f g)))))
(Hopfβ↦1 n (∙Π f g)))
where
transportLem : coHomFun (suc (suc (suc (n +ℕ suc n)))) (q n f g)
(βᵣ''-fun n f g)
≡ subst (λ m → coHom m (C·Π' n f g))
(cong (suc ∘ suc ∘ suc) (sym (+-suc n n)))
(Hopfβ n (∙Π f g))
transportLem =
natTranspLem ∣ βᵣ'-fun n f g ∣₂ (λ m → coHomFun m (q n f g))
(cong (suc ∘ suc ∘ suc) (sym (+-suc n n)))
∙ cong (subst (λ m → coHom m (C·Π' n f g))
(cong (suc ∘ suc ∘ suc) (sym (+-suc n n))))
(cong ∣_∣₂ (funExt λ { (inl x) → refl
; (inr x) → refl
; (push a i₁) → push-lem a i₁}))
where
push-lem : (x : fst (S₊∙ (3 +ℕ (n +ℕ n)))) →
PathP
(λ i₁ →
βᵣ'-fun n f g ((push (θ x) ∙ λ i → inr (∙Π≡∨→∘θ n f g x (~ i))) i₁) ≡
MV.d-pre Unit (fst (S₊∙ (2 +ℕ n))) (fst (S₊∙ (3 +ℕ n +ℕ n)))
(λ _ → tt) (fst (∙Π f g)) (3 +ℕ n +ℕ n) ∣_∣ (push x i₁))
(λ _ → βᵣ'-fun n f g (q n f g (inl tt)))
(λ _ → βᵣ'-fun n f g (q n f g (inr (∙Π f g .fst x))))
push-lem x = flipSquare (cong-∙ (βᵣ'-fun n f g) (push (θ x))
(λ i → inr (∙Π≡∨→∘θ n f g x (~ i)))
∙∙ sym (rUnit _)
∙∙ lem₁ x)
where
lem₁ : (x : _) → cong (βᵣ'-fun n f g) (push (θ {A = S₊∙ _} x))
≡ Kn→ΩKn+1 _ ∣ x ∣
lem₁ north = sym (Kn→ΩKn+10ₖ _)
lem₁ south = cong (Kn→ΩKn+1 (suc (suc (suc (n +ℕ n)))))
(cong ∣_∣ₕ (merid north))
lem₁ (merid a j) k = merid-lem k j
where
p = pt (S₊∙ (suc (suc (n +ℕ n))))
merid-lem :
PathP (λ k → (Kn→ΩKn+10ₖ _) (~ k)
≡ (cong (Kn→ΩKn+1 (suc (suc (suc (n +ℕ n)))))
(cong ∣_∣ₕ (merid north))) k)
(λ j → cong (βᵣ'-fun n f g) (push (θ {A = S₊∙ _} (merid a j))))
(cong (Kn→ΩKn+1 (suc (suc (suc (n +ℕ n)))) ∘ ∣_∣ₕ) (merid a))
merid-lem =
(cong-∙∙ (cong (βᵣ'-fun n f g) ∘ push)
(λ i₁ → inl ((merid a
∙ (sym (merid p))) i₁))
(push tt)
(λ i₁ → inr ((merid a
∙ (sym (merid p))) i₁))
∙∙ (cong (sym (Kn→ΩKn+10ₖ _) ∙_)
(cong-∙ (Kn→ΩKn+1 (suc (suc (suc (n +ℕ n)))) ∘ ∣_∣ₕ)
(merid a) (sym (merid (ptSn _)))))
∙∙ sym (doubleCompPath≡compPath _ _ _))
◁ symP (doubleCompPath-filler
(sym (Kn→ΩKn+10ₖ _))
(cong (Kn→ΩKn+1 (suc (suc (suc (n +ℕ n)))) ∘ ∣_∣ₕ)
(merid a))
(cong (Kn→ΩKn+1 (suc (suc (suc (n +ℕ n)))) ∘ ∣_∣ₕ)
(sym (merid north))))
jₗ-α : (n : ℕ) (f g : S₊∙ (3 +ℕ (n +ℕ n)) →∙ S₊∙ (2 +ℕ n))
→ coHomFun _ (jₗ n f g) (α* n f g)
≡ Hopfα n f
jₗ-α n f g =
cong (coHomFun _ (jₗ n f g)) (α≡ n f g)
∙ cong ∣_∣₂ (funExt (HopfInvariantPushElim n (fst f)
(isOfHLevelPath ((suc (suc (suc (suc (n +ℕ n))))))
(isOfHLevelPlus' {n = n} (4 +ℕ n)
(isOfHLevelTrunc (4 +ℕ n))) _ _)
refl
(λ _ → refl)
λ j → refl))
jₗ-βₗ : (n : ℕ) (f g : S₊∙ (3 +ℕ (n +ℕ n)) →∙ S₊∙ (2 +ℕ n))
→ coHomFun _ (jₗ n f g) (βₗ n f g)
≡ subst (λ m → coHom m (HopfInvariantPush n (fst f)))
(cong (suc ∘ suc ∘ suc) (sym (+-suc n n)))
(Hopfβ n f)
jₗ-βₗ n f g =
cong (coHomFun _ (jₗ n f g)) (βₗ≡ n f g)
∙∙ natTranspLem ∣ βₗ'-fun n f g ∣₂ (λ m → coHomFun m (jₗ n f g))
(cong (suc ∘ suc ∘ suc) (sym (+-suc n n)))
∙∙ cong (subst (λ m → coHom m (HopfInvariantPush n (fst f)))
(cong (suc ∘ suc ∘ suc) (sym (+-suc n n))))
(cong ∣_∣₂
(funExt λ { (inl x) → refl
; (inr x) → refl
; (push a i₁) → refl}))
jₗ-βᵣ : (n : ℕ) (f g : S₊∙ (3 +ℕ (n +ℕ n)) →∙ S₊∙ (2 +ℕ n))
→ coHomFun _ (jₗ n f g) (βᵣ n f g)
≡ 0ₕ _
jₗ-βᵣ n f g =
cong (coHomFun _ (jₗ n f g)) (βᵣ≡ n f g)
∙∙ natTranspLem ∣ βᵣ'-fun n f g ∣₂ (λ m → coHomFun m (jₗ n f g))
(cong (suc ∘ suc ∘ suc) (sym (+-suc n n)))
∙∙ cong (subst (λ m → coHom m (HopfInvariantPush n (fst f)))
(cong (suc ∘ suc ∘ suc) (sym (+-suc n n))))
cool
where
cool : coHomFun (suc (suc (suc (suc (n +ℕ n))))) (jₗ n f g)
∣ βᵣ'-fun n f g ∣₂ ≡ 0ₕ _
cool = cong ∣_∣₂ (funExt λ { (inl x) → refl
; (inr x) → refl
; (push a i₁) → refl})
jᵣ-α : (n : ℕ) (f g : S₊∙ (3 +ℕ (n +ℕ n)) →∙ S₊∙ (2 +ℕ n))
→ coHomFun _ (jᵣ n f g) (α* n f g)
≡ Hopfα n g
jᵣ-α n f g = cong (coHomFun _ (jᵣ n f g)) (α≡ n f g)
∙ cong ∣_∣₂ (funExt (HopfInvariantPushElim n (fst g)
(isOfHLevelPath ((suc (suc (suc (suc (n +ℕ n))))))
(isOfHLevelPlus' {n = n} (4 +ℕ n)
(isOfHLevelTrunc (4 +ℕ n))) _ _)
refl
(λ _ → refl)
(flipSquare (0ₖ≡∨→-inr n f g))))
jᵣ-βₗ : (n : ℕ) (f g : S₊∙ (3 +ℕ (n +ℕ n)) →∙ S₊∙ (2 +ℕ n))
→ coHomFun _ (jᵣ n f g) (βₗ n f g) ≡ 0ₕ _
jᵣ-βₗ n f g =
cong (coHomFun _ (jᵣ n f g)) (βₗ≡ n f g)
∙∙ natTranspLem ∣ βₗ'-fun n f g ∣₂ (λ m → coHomFun m (jᵣ n f g))
(cong (suc ∘ suc ∘ suc) (sym (+-suc n n)))
∙∙ cong (subst (λ m → coHom m (HopfInvariantPush n (fst f)))
(cong (suc ∘ suc ∘ suc) (sym (+-suc n n))))
cool
where
cool : coHomFun (suc (suc (suc (suc (n +ℕ n))))) (jᵣ n f g)
∣ βₗ'-fun n f g ∣₂ ≡ 0ₕ _
cool = cong ∣_∣₂ (funExt λ { (inl x) → refl
; (inr x) → refl
; (push a i₁) → refl})
jᵣ-βᵣ : (n : ℕ) (f g : S₊∙ (3 +ℕ (n +ℕ n)) →∙ S₊∙ (2 +ℕ n))
→ coHomFun _ (jᵣ n f g) (βᵣ n f g)
≡ subst (λ m → coHom m (HopfInvariantPush n (fst g)))
(cong (suc ∘ suc ∘ suc) (sym (+-suc n n)))
(Hopfβ n g)
jᵣ-βᵣ n f g =
cong (coHomFun _ (jᵣ n f g)) (βᵣ≡ n f g)
∙∙ natTranspLem ∣ βᵣ'-fun n f g ∣₂ (λ m → coHomFun m (jᵣ n f g))
(cong (suc ∘ suc ∘ suc) (sym (+-suc n n)))
∙∙ cong (subst (λ m → coHom m (HopfInvariantPush n (fst g)))
(cong (suc ∘ suc ∘ suc) (sym (+-suc n n))))
(cong ∣_∣₂
(funExt λ { (inl x) → refl
; (inr x) → refl
; (push a i₁) → refl}))
genH²ⁿC* : (n : ℕ) (f g : S₊∙ (3 +ℕ (n +ℕ n)) →∙ S₊∙ (2 +ℕ n))
→ gen₂-by (coHomGr ((2 +ℕ n) +' (2 +ℕ n)) (C* n f g))
(βₗ n f g)
(βᵣ n f g)
genH²ⁿC* n f g =
Iso-pres-gen₂ (DirProd ℤGroup ℤGroup)
(coHomGr ((2 +ℕ n) +' (2 +ℕ n)) (C* n f g))
(1 , 0)
(0 , 1)
gen₂ℤ×ℤ
(invGroupIso (H⁴-C* n f g))
private
H⁴C* : (n : ℕ) (f g : S₊∙ (3 +ℕ (n +ℕ n)) →∙ S₊∙ (2 +ℕ n)) → Group _
H⁴C* n f g = coHomGr ((2 +ℕ n) +' (2 +ℕ n)) (C* n f g)
X : (n : ℕ) (f g : S₊∙ (3 +ℕ (n +ℕ n)) →∙ S₊∙ (2 +ℕ n))
→ ℤ
X n f g = (genH²ⁿC* n f g) (α* n f g ⌣ α* n f g) .fst .fst
Y : (n : ℕ) (f g : S₊∙ (3 +ℕ (n +ℕ n)) →∙ S₊∙ (2 +ℕ n))
→ ℤ
Y n f g = (genH²ⁿC* n f g) (α* n f g ⌣ α* n f g) .fst .snd
α*≡⌣ : (n : ℕ) (f g : S₊∙ (3 +ℕ (n +ℕ n)) →∙ S₊∙ (2 +ℕ n))
→ α* n f g ⌣ α* n f g ≡ ((X n f g) ℤ[ H⁴C* n f g ]· βₗ n f g)
+ₕ ((Y n f g) ℤ[ H⁴C* n f g ]· βᵣ n f g)
α*≡⌣ n f g = (genH²ⁿC* n f g) (α* n f g ⌣ α* n f g) .snd
coHomFun⌣ : ∀ {ℓ ℓ'} {A : Type ℓ} {B : Type ℓ'} (f : A → B)
→ (n : ℕ) (x y : coHom n B)
→ coHomFun _ f (x ⌣ y) ≡ coHomFun _ f x ⌣ coHomFun _ f y
coHomFun⌣ f n = sElim2 (λ _ _ → isOfHLevelPath 2 squash₂ _ _) λ _ _ → refl
isHom-HopfInvariant :
(n : ℕ) (f g : S₊∙ (suc (suc (suc (n +ℕ n)))) →∙ S₊∙ (suc (suc n)))
→ HopfInvariant n (∙Π f g) ≡ HopfInvariant n f + HopfInvariant n g
isHom-HopfInvariant n f g =
mainL
∙ sym (cong₂ _+_ f-id g-id)
where
eq₁ : (Hopfα n (∙Π f g)) ⌣ (Hopfα n (∙Π f g))
≡ ((X n f g + Y n f g) ℤ[ coHomGr _ _ ]· (β·Π n f g))
eq₁ = cong (λ x → x ⌣ x) (sym (q-α n f g)
∙ cong (coHomFun (suc (suc n)) (q n f g)) (α≡ n f g))
∙ cong ((coHomFun _) (q _ f g)) (cong (λ x → x ⌣ x) (sym (α≡ n f g))
∙ α*≡⌣ n f g)
∙ IsGroupHom.pres· (coHomMorph _ (q n f g) .snd) _ _
∙ cong₂ _+ₕ_ (homPresℤ· (coHomMorph _ (q n f g)) (βₗ n f g) (X n f g)
∙ cong (λ z → (X n f g) ℤ[ coHomGr _ _ ]· z)
(q-βₗ n f g))
(homPresℤ· (coHomMorph _ (q n f g)) (βᵣ n f g) (Y n f g)
∙ cong (λ z → (Y n f g) ℤ[ coHomGr _ _ ]· z)
(q-βᵣ n f g))
∙ sym (distrℤ· (coHomGr _ _) (β·Π n f g) (X n f g) (Y n f g))
eq₂ : Hopfα n f ⌣ Hopfα n f
≡ (X n f g ℤ[ coHomGr _ _ ]·
subst (λ m → coHom m (HopfInvariantPush n (fst f)))
(cong (suc ∘ suc ∘ suc) (sym (+-suc n n)))
(Hopfβ n f))
eq₂ = cong (λ x → x ⌣ x) (sym (jₗ-α n f g))
∙∙ sym (coHomFun⌣ (jₗ n f g) _ _ _)
∙∙ cong (coHomFun _ (jₗ n f g)) (α*≡⌣ n f g)
∙∙ IsGroupHom.pres· (snd (coHomMorph _ (jₗ n f g))) _ _
∙∙ cong₂ _+ₕ_ (homPresℤ· (coHomMorph _ (jₗ n f g)) (βₗ n f g) (X n f g))
(homPresℤ· (coHomMorph _ (jₗ n f g)) (βᵣ n f g) (Y n f g)
∙ cong (λ z → (Y n f g) ℤ[ coHomGr _ _ ]· z)
(jₗ-βᵣ n f g))
∙∙ cong₂ _+ₕ_ refl (rUnitℤ· (coHomGr _ _) (Y n f g))
∙∙ (rUnitₕ _ _
∙ cong (X n f g ℤ[ coHomGr _ _ ]·_) (jₗ-βₗ n f g))
eq₃ : Hopfα n g ⌣ Hopfα n g
≡ (Y n f g ℤ[ coHomGr _ _ ]·
subst (λ m → coHom m (HopfInvariantPush n (fst f)))
(cong (suc ∘ suc ∘ suc) (sym (+-suc n n)))
(Hopfβ n g))
eq₃ = cong (λ x → x ⌣ x) (sym (jᵣ-α n f g))
∙∙ sym (coHomFun⌣ (jᵣ n f g) _ _ _)
∙∙ cong (coHomFun _ (jᵣ n f g)) (α*≡⌣ n f g)
∙∙ IsGroupHom.pres· (snd (coHomMorph _ (jᵣ n f g))) _ _
∙∙ cong₂ _+ₕ_ (homPresℤ· (coHomMorph _ (jᵣ n f g)) (βₗ n f g) (X n f g)
∙ cong (λ z → (X n f g) ℤ[ coHomGr _ _ ]· z)
(jᵣ-βₗ n f g))
(homPresℤ· (coHomMorph _ (jᵣ n f g)) (βᵣ n f g) (Y n f g))
∙∙ cong₂ _+ₕ_ (rUnitℤ· (coHomGr _ _) (X n f g)) refl
∙∙ ((lUnitₕ _ _) ∙ cong (Y n f g ℤ[ coHomGr _ _ ]·_) (jᵣ-βᵣ n f g))
transpLem : ∀ {ℓ} {G : ℕ → Group ℓ} (n m : ℕ) (x : ℤ) (p : m ≡ n)
(g : fst (G n))
→ subst (fst ∘ G) p (x ℤ[ G m ]· subst (fst ∘ G) (sym p) g)
≡ (x ℤ[ G n ]· g)
transpLem {G = G} n m x =
J (λ n p → (g : fst (G n))
→ subst (fst ∘ G) p (x ℤ[ G m ]· subst (fst ∘ G) (sym p) g)
≡ (x ℤ[ G n ]· g))
λ g → transportRefl _ ∙ cong (x ℤ[ G m ]·_) (transportRefl _)
mainL : HopfInvariant n (∙Π f g) ≡ X n f g + Y n f g
mainL =
cong (Iso.fun (fst (Hopfβ-Iso n (∙Π f g))))
(cong (subst (λ x → coHom x (HopfInvariantPush n (fst (∙Π f g))))
λ i₁ → suc (suc (suc (+-suc n n i₁))))
eq₁)
∙∙ cong (Iso.fun (fst (Hopfβ-Iso n (∙Π f g))))
(transpLem {G = λ x → coHomGr x
(HopfInvariantPush n (fst (∙Π f g)))} _ _
(X n f g + Y n f g)
(λ i₁ → suc (suc (suc (+-suc n n i₁))))
(Iso.inv (fst (Hopfβ-Iso n (∙Π f g))) 1))
∙∙ homPresℤ· (_ , snd (Hopfβ-Iso n (∙Π f g)))
(Iso.inv (fst (Hopfβ-Iso n (∙Π f g))) 1)
(X n f g + Y n f g)
∙∙ cong ((X n f g + Y n f g) ℤ[ ℤ , ℤGroup .snd ]·_)
(Iso.rightInv ((fst (Hopfβ-Iso n (∙Π f g)))) 1)
∙∙ rUnitℤ·ℤ (X n f g + Y n f g)
f-id : HopfInvariant n f ≡ X n f g
f-id =
cong (Iso.fun (fst (Hopfβ-Iso n f)))
(cong (subst (λ x → coHom x (HopfInvariantPush n (fst f)))
(λ i₁ → suc (suc (suc (+-suc n n i₁))))) eq₂)
∙ cong (Iso.fun (fst (Hopfβ-Iso n f)))
(transpLem {G = λ x → coHomGr x
(HopfInvariantPush n (fst f))} _ _
(X n f g)
((cong (suc ∘ suc ∘ suc) (+-suc n n)))
(Hopfβ n f))
∙ homPresℤ· (_ , snd (Hopfβ-Iso n f)) (Hopfβ n f) (X n f g)
∙ cong (X n f g ℤ[ ℤ , ℤGroup .snd ]·_) (Hopfβ↦1 n f)
∙ rUnitℤ·ℤ (X n f g)
g-id : HopfInvariant n g ≡ Y n f g
g-id =
cong (Iso.fun (fst (Hopfβ-Iso n g)))
(cong (subst (λ x → coHom x (HopfInvariantPush n (fst g)))
(λ i₁ → suc (suc (suc (+-suc n n i₁)))))
eq₃)
∙∙ cong (Iso.fun (fst (Hopfβ-Iso n g)))
(transpLem {G = λ x → coHomGr x
(HopfInvariantPush n (fst g))} _ _
(Y n f g)
((cong (suc ∘ suc ∘ suc) (+-suc n n)))
(Hopfβ n g))
∙∙ homPresℤ· (_ , snd (Hopfβ-Iso n g)) (Hopfβ n g) (Y n f g)
∙∙ cong (Y n f g ℤ[ ℤ , ℤGroup .snd ]·_) (Hopfβ↦1 n g)
∙∙ rUnitℤ·ℤ (Y n f g)
GroupHom-HopfInvariant-π' : (n : ℕ)
→ GroupHom (π'Gr (suc (suc (n +ℕ n))) (S₊∙ (suc (suc n)))) ℤGroup
fst (GroupHom-HopfInvariant-π' n) = HopfInvariant-π' n
snd (GroupHom-HopfInvariant-π' n) =
makeIsGroupHom (sElim2 (λ _ _ → isOfHLevelPath 2 isSetℤ _ _)
(isHom-HopfInvariant n))
GroupHom-HopfInvariant-π : (n : ℕ)
→ GroupHom (πGr (suc (suc (n +ℕ n))) (S₊∙ (suc (suc n)))) ℤGroup
fst (GroupHom-HopfInvariant-π n) = HopfInvariant-π n
snd (GroupHom-HopfInvariant-π n) =
makeIsGroupHom (sElim2 (λ _ _ → isOfHLevelPath 2 isSetℤ _ _)
λ p q → cong (HopfInvariant-π' n)
(IsGroupHom.pres·
(snd (invGroupIso (π'Gr≅πGr (suc (suc (n +ℕ n)))
(S₊∙ (suc (suc n))))))
∣ p ∣₂ ∣ q ∣₂)
∙ IsGroupHom.pres· (GroupHom-HopfInvariant-π' n .snd)
∣ Ω→SphereMap _ p ∣₂ ∣ Ω→SphereMap _ q ∣₂)
| 42.20113
| 80
| 0.420558
|
0386e4b4e7d4a6c89022b876004d843387132727
| 18,809
|
agda
|
Agda
|
CaTT/Relation.agda
|
ThiBen/catt-formalization
|
ed45935b38d6a86fa662f561866140122ee3dcef
|
[
"MIT"
] | 2
|
2020-05-01T08:26:53.000Z
|
2020-05-20T00:41:09.000Z
|
CaTT/Relation.agda
|
ThiBen/catt-formalization
|
ed45935b38d6a86fa662f561866140122ee3dcef
|
[
"MIT"
] | null | null | null |
CaTT/Relation.agda
|
ThiBen/catt-formalization
|
ed45935b38d6a86fa662f561866140122ee3dcef
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --without-K #-}
open import Prelude
open import GSeTT.Syntax
open import GSeTT.Rules
open import GSeTT.Uniqueness-Derivations
open import Sets ℕ eqdecℕ
open import GSeTT.Dec-Type-Checking
open import CaTT.Ps-contexts
{- PS-contexts -}
module CaTT.Relation where
-- The relation ◃ generating cases
data _,_◃₀_ Γ x y : Set₁ where
◃∂⁻ : ∀{A z} → Γ ⊢t (Var y) # (Var x ⇒[ A ] Var z) → Γ , x ◃₀ y
◃∂⁺ : ∀{A z} → Γ ⊢t (Var x) # (Var z ⇒[ A ] Var y) → Γ , x ◃₀ y
-- Transitive closure : we associate on the right
data _,_◃_ Γ x y : Set₁ where
gen : Γ , x ◃₀ y → Γ , x ◃ y
◃T : ∀{z} → Γ , x ◃ z → Γ , z ◃₀ y → Γ , x ◃ y
rel : ∀ Γ x y → Set₁
rel Γ x y = Γ , x ◃ y
W◃₀ : ∀ {Γ x y z A} → (Γ :: (z , A)) ⊢C → Γ , x ◃₀ y → (Γ :: (z , A)) , x ◃₀ y
W◃₀ Γ+⊢ (◃∂⁻ Γ⊢x) = ◃∂⁻ (wkt Γ⊢x Γ+⊢)
W◃₀ Γ+⊢ (◃∂⁺ Γ⊢x) = ◃∂⁺ (wkt Γ⊢x Γ+⊢)
W◃ : ∀ {Γ x y z A} → (Γ :: (z , A)) ⊢C → Γ , x ◃ y → (Γ :: (z , A)) , x ◃ y
W◃ Γ+⊢ (gen x◃₀y) = gen (W◃₀ Γ+⊢ x◃₀y)
W◃ Γ+⊢ (◃T x◃y y◃₀z) = ◃T (W◃ Γ+⊢ x◃y) (W◃₀ Γ+⊢ y◃₀z)
WW◃ : ∀ {Γ x y z f A B} → ((Γ :: (z , A)) :: (f , B)) ⊢C → Γ , x ◃ y → ((Γ :: (z , A)) :: (f , B)) , x ◃ y
WW◃ Γ+⊢@(cc Γ⊢ _ idp) x◃y = W◃ Γ+⊢ (W◃ Γ⊢ x◃y)
◃-trans : ∀ {Γ x y z} → Γ , x ◃ y → Γ , y ◃ z → Γ , x ◃ z
◃-trans x◃y (gen y◃₀z) = ◃T x◃y y◃₀z
◃-trans x◃y (◃T y◃z z◃₀w) = ◃T (◃-trans x◃y y◃z) z◃₀w
-- TODO : Move at the right place
x#A∈Γ→x∈Γ : ∀ {Γ x A} → x # A ∈ Γ → x ∈ Γ
x#A∈Γ→x∈Γ {Γ :: (y , _)} (inl x#A∈Γ) = inl (x#A∈Γ→x∈Γ x#A∈Γ)
x#A∈Γ→x∈Γ {Γ :: (y , _)} (inr (idp , idp)) = inr idp
Γ⊢x:A→x∈Γ : ∀ {Γ x A} → Γ ⊢t (Var x) # A → x ∈ Γ
Γ⊢x:A→x∈Γ (var _ x#A∈Γ) = x#A∈Γ→x∈Γ x#A∈Γ
data _,_⟿_ : Pre-Ctx → ℕ → ℕ → Set₁ where -- y is an iterated target of x in Γ
∂⁺⟿ : ∀{Γ x a y A} → Γ ⊢t (Var x) # (Var a ⇒[ A ] Var y) → Γ , x ⟿ y
x⟿∂⁺ : ∀{Γ x a y z A} → Γ ⊢t (Var x) # (Var a ⇒[ A ] Var y) → Γ , y ⟿ z → Γ , x ⟿ z
W⟿ : ∀ {Γ x y z A} → (Γ :: (z , A)) ⊢C → Γ , x ⟿ y → (Γ :: (z , A)) , x ⟿ y
W⟿ Γ+⊢ (∂⁺⟿ Γ⊢x) = ∂⁺⟿ (wkt Γ⊢x Γ+⊢)
W⟿ Γ+⊢ (x⟿∂⁺ Γ⊢x x⟿y) = x⟿∂⁺ (wkt Γ⊢x Γ+⊢) (W⟿ Γ+⊢ x⟿y)
WW⟿ : ∀ {Γ x y z w A B} → ((Γ :: (z , A)) :: (w , B)) ⊢C → Γ , x ⟿ y → ((Γ :: (z , A)) :: (w , B)) , x ⟿ y
WW⟿ Γ++⊢@(cc Γ+⊢ _ idp) x⟿y = W⟿ Γ++⊢ (W⟿ Γ+⊢ x⟿y)
⟿→◃ : ∀ {Γ x y} → Γ , x ⟿ y → Γ , x ◃ y
⟿→◃ (∂⁺⟿ Γ⊢x) = gen (◃∂⁺ Γ⊢x)
⟿→◃ (x⟿∂⁺ Γ⊢x x⟿y) = ◃-trans (gen (◃∂⁺ Γ⊢x)) (⟿→◃ x⟿y)
Γ++ : ∀ {Γ x A} → Γ ⊢ps x # A → Pre-Ctx
Γ++ {Γ} {x} {A} _ = (Γ :: (length Γ , A)) :: (S (length Γ) , Var x ⇒[ A ] Var (length Γ))
//⟿ : ∀ {Γ Δ x y A a} → Γ ⊢t (Var x) # A → Δ ⊢t (Var y) # A → Γ , x ⟿ a → Δ , y ⟿ a
//⟿ Γ⊢x Δ⊢y (∂⁺⟿ Γ⊢x') with unique-type Γ⊢x Γ⊢x' idp
... | idp = ∂⁺⟿ Δ⊢y
//⟿ Γ⊢x Δ⊢y (x⟿∂⁺ Γ⊢x' x⟿a) with unique-type Γ⊢x Γ⊢x' idp
... | idp = x⟿∂⁺ Δ⊢y (//⟿ (Γ⊢tgt (Γ⊢t:A→Γ⊢A Γ⊢x)) (Γ⊢tgt (Γ⊢t:A→Γ⊢A Δ⊢y)) x⟿a)
T⟿ : ∀ {Γ x y z} → Γ , x ⟿ y → Γ , y ⟿ z → Γ , x ⟿ z
T⟿ (∂⁺⟿ Γ⊢x) y⟿z = x⟿∂⁺ Γ⊢x y⟿z
T⟿ (x⟿∂⁺ Γ⊢x x⟿y) y⟿z = x⟿∂⁺ Γ⊢x (T⟿ x⟿y y⟿z)
⟿dim : ∀ {Γ x y A B} → Γ ⊢t Var x # A → Γ ⊢t Var y # B → Γ , x ⟿ y → dim B < dim A
⟿dim Γ⊢x:A Γ⊢y:B (∂⁺⟿ Γ⊢x) with unique-type Γ⊢x:A Γ⊢x idp | unique-type Γ⊢y:B (Γ⊢tgt(Γ⊢t:A→Γ⊢A Γ⊢x)) idp
... | idp | idp = n≤n _
⟿dim Γ⊢x:A Γ⊢y:B (x⟿∂⁺ Γ⊢x z⟿y) with unique-type Γ⊢x:A Γ⊢x idp
... | idp = n≤m→n≤Sm (⟿dim (Γ⊢tgt(Γ⊢t:A→Γ⊢A Γ⊢x)) Γ⊢y:B z⟿y)
𝔻0-◃ : ∀ z → ¬ ((nil :: (0 , ∗)) , 0 ◃ z)
𝔻0-◃ z (gen (◃∂⁻ (var _ (inl ()))))
𝔻0-◃ z (gen (◃∂⁻ (var _ (inr ()))))
𝔻0-◃ z (gen (◃∂⁺ (var _ (inl ()))))
𝔻0-◃ z (gen (◃∂⁺ (var _ (inr ()))))
𝔻0-◃ z (◃T 0◃x _) = 𝔻0-◃ _ 0◃x
𝔻0-⟿ : ∀ z → ¬ ((nil :: (0 , ∗)) , 0 ⟿ z)
𝔻0-⟿ z (∂⁺⟿ (var _ (inl ())))
𝔻0-⟿ z (∂⁺⟿ (var _ (inr ())))
𝔻0-⟿ z (x⟿∂⁺ (var _ (inl ())) _)
𝔻0-⟿ z (x⟿∂⁺ (var _ (inr ())) _)
n≮n : ∀ n → ¬ (n < n)
n≮n n n<n = Sn≰n _ n<n
⟿-is-tgt : ∀ {Γ x y z A} → Γ ⊢t Var x # Var y ⇒[ A ] Var z → Γ , x ⟿ y → y == z
⟿-is-tgt Γ⊢x (∂⁺⟿ Γ⊢'x) with unique-type Γ⊢x Γ⊢'x idp
... | idp = idp
⟿-is-tgt Γ⊢x (x⟿∂⁺ Γ⊢'x y'⟿y) with unique-type Γ⊢x Γ⊢'x idp
... | idp = ⊥-elim (Sn≰n _ (⟿dim (Γ⊢tgt (Γ⊢t:A→Γ⊢A Γ⊢'x)) (Γ⊢src (Γ⊢t:A→Γ⊢A Γ⊢x)) y'⟿y))
no-loop : ∀{Γ x y z T a A} → Γ ⊢ps a # A → Γ ⊢t Var x # Var y ⇒[ T ] Var z → y ≠ z
no-loop pss (var _ (inl ())) idp
no-loop pss (var _ (inr ())) idp
no-loop (psd Γ⊢psf) Γ⊢x idp = no-loop Γ⊢psf Γ⊢x idp
no-loop (pse Γ⊢psb idp idp idp idp idp) (var _ (inl (inl x∈Γ))) idp = no-loop Γ⊢psb (var (Γ⊢psx:A→Γ⊢ Γ⊢psb) x∈Γ) idp
no-loop (pse Γ⊢psb idp idp idp idp idp) (var _ (inl (inr (idp , idp)))) idp = no-loop Γ⊢psb (Γ⊢psx:A→Γ⊢x:A Γ⊢psb) idp
no-loop (pse Γ⊢psb idp idp idp idp idp) (var _ (inr (idp , idp))) idp = x∉ (Γ⊢psx:A→Γ⊢ Γ⊢psb) (n≤n _) (Γ⊢psx:A→Γ⊢x:A Γ⊢psb)
dangling-is-not-a-source : ∀ {Γ x A} → Γ ⊢ps x # A → (∀ f z {B} → ¬ (Γ ⊢t Var f # Var x ⇒[ B ] Var z))
post-dangling-is-not-a-source : ∀ {Γ x A} → Γ ⊢ps x # A → (∀ {y B} f z → Γ , x ⟿ y → ¬ (Γ ⊢t (Var f) # Var y ⇒[ B ] Var z))
dangling-is-not-a-source pss _ _ (var _ (inl ()))
dangling-is-not-a-source pss _ _ (var _ (inr ()))
dangling-is-not-a-source {x = x} (psd Γ⊢ps) t u Γ⊢t = post-dangling-is-not-a-source Γ⊢ps t u (∂⁺⟿ (psvar Γ⊢ps)) Γ⊢t
dangling-is-not-a-source (pse Γ⊢ps idp idp idp idp idp) _ _ (var _ (inl (inl x∈Γ))) = x∉ (psv Γ⊢ps) (n≤Sn _) (Γ⊢src (Γ⊢t:A→Γ⊢A (var (psv Γ⊢ps) x∈Γ)))
dangling-is-not-a-source (pse Γ⊢ps idp idp idp idp idp) _ _ (var _ (inl (inr (idp , idp)))) = x∉ (psv Γ⊢ps) (n≤Sn _) (Γ⊢src (Γ⊢t:A→Γ⊢A (psvar Γ⊢ps)))
dangling-is-not-a-source (pse Γ⊢ps idp idp idp idp idp) _ _ (var _ (inr (idp , idp))) = x∉ (psv Γ⊢ps) (n≤Sn _) (psvar Γ⊢ps)
post-dangling-is-not-a-source pss t u x⟿y Γ⊢t = 𝔻0-⟿ _ x⟿y
post-dangling-is-not-a-source (psd Γ⊢ps) t u x⟿y Γ⊢t = post-dangling-is-not-a-source Γ⊢ps t u (T⟿ (∂⁺⟿ (psvar Γ⊢ps)) x⟿y) Γ⊢t
post-dangling-is-not-a-source Γ+⊢@(pse Γ⊢ps idp idp idp idp idp) t u (∂⁺⟿ Γ⊢Sl) Γ⊢t with unique-type Γ⊢Sl (psvar Γ+⊢) idp
post-dangling-is-not-a-source (pse Γ⊢ps idp idp idp idp idp) _ _ (∂⁺⟿ Γ⊢Sl) (var _ (inl (inl t∈Γ))) | idp = x∉ (psv Γ⊢ps) (n≤n _) (Γ⊢src (Γ⊢t:A→Γ⊢A (var (psv Γ⊢ps) t∈Γ)))
post-dangling-is-not-a-source (pse Γ⊢ps idp idp idp idp idp) _ _ (∂⁺⟿ Γ⊢Sl) (var _ (inl (inr (idp , idp)))) | idp = x∉ (psv Γ⊢ps) (n≤n _) (Γ⊢src (Γ⊢t:A→Γ⊢A (psvar Γ⊢ps)))
post-dangling-is-not-a-source (pse Γ⊢ps idp idp idp idp idp) _ _ (∂⁺⟿ Γ⊢Sl) (var _ (inr (idp , idp))) | idp = x∉ (psv Γ⊢ps) (n≤n _) (psvar Γ⊢ps)
post-dangling-is-not-a-source Γ+⊢@(pse Γ⊢ps idp idp idp idp idp) t u (x⟿∂⁺ Γ⊢Sl x⟿y) Γ⊢t with unique-type Γ⊢Sl (psvar Γ+⊢) idp
post-dangling-is-not-a-source (pse Γ⊢ps idp idp idp idp idp) _ _ (x⟿∂⁺ Γ⊢Sl x⟿y) (var Γ+⊢ (inl (inl t∈Γ))) | idp =
post-dangling-is-not-a-source Γ⊢ps _ _ (//⟿ (var Γ+⊢ (inl (inr (idp , idp)))) (psvar Γ⊢ps) x⟿y) (var (psv Γ⊢ps) t∈Γ)
post-dangling-is-not-a-source (pse Γ⊢ps idp idp idp idp idp) _ _ (x⟿∂⁺ Γ⊢Sl x⟿y) (var Γ+⊢ (inl (inr (idp , idp)))) | idp with ⟿-is-tgt (var Γ+⊢ (inl (inr (idp , idp)))) x⟿y
... | idp = no-loop Γ⊢ps (psvar Γ⊢ps) idp
post-dangling-is-not-a-source (pse Γ⊢ps idp idp idp idp idp) _ _ (x⟿∂⁺ Γ⊢Sl x⟿y) (var Γ++⊢@(cc Γ+⊢ _ p) (inr (idp , idp))) | idp = n≮n _ (⟿dim (var Γ++⊢ (inl (inr (idp , idp)))) (wkt (wkt (psvar Γ⊢ps) Γ+⊢) Γ++⊢) x⟿y)
⊢psx-◃₀→⟿ : ∀ {Γ x a A} → Γ ⊢ps x # A → Γ , x ◃₀ a → Γ , x ⟿ a
⊢psx-◃₀→⟿ Γ⊢psx (◃∂⁻ Γ⊢a) = ⊥-elim (dangling-is-not-a-source Γ⊢psx _ _ Γ⊢a)
⊢psx-◃₀→⟿ Γ⊢psx (◃∂⁺ Γ⊢x) = ∂⁺⟿ Γ⊢x
⊢psx-◃₀→⟿+ : ∀ {Γ x y a A} → Γ ⊢ps x # A → Γ , x ⟿ y → Γ , y ◃₀ a → Γ , y ⟿ a
⊢psx-◃₀→⟿+ Γ⊢psx x⟿y (◃∂⁻ Γ⊢a) = ⊥-elim (post-dangling-is-not-a-source Γ⊢psx _ _ x⟿y Γ⊢a)
⊢psx-◃₀→⟿+ Γ⊢psx x⟿y (◃∂⁺ Γ⊢y) = ∂⁺⟿ Γ⊢y
⊢psx-◃→⟿ : ∀ {Γ x a A} → Γ ⊢ps x # A → Γ , x ◃ a → Γ , x ⟿ a
⊢psx-◃→⟿+ : ∀ {Γ x a b A} → Γ ⊢ps x # A → Γ , x ⟿ a → Γ , a ◃ b → Γ , a ⟿ b
⊢psx-◃→⟿ Γ⊢psx (gen x◃₀a) = ⊢psx-◃₀→⟿ Γ⊢psx x◃₀a
⊢psx-◃→⟿ Γ⊢psx (◃T x◃z z◃₀a) = T⟿ (⊢psx-◃→⟿ Γ⊢psx x◃z) (⊢psx-◃₀→⟿+ Γ⊢psx (⊢psx-◃→⟿ Γ⊢psx x◃z) z◃₀a)
⊢psx-◃→⟿+ Γ⊢psx x⟿y (gen y◃₀a) = ⊢psx-◃₀→⟿+ Γ⊢psx x⟿y y◃₀a
⊢psx-◃→⟿+ Γ⊢psx x⟿y (◃T y◃z z◃₀a) = T⟿ (⊢psx-◃→⟿+ Γ⊢psx x⟿y y◃z) (⊢psx-◃₀→⟿+ Γ⊢psx (T⟿ x⟿y (⊢psx-◃→⟿+ Γ⊢psx x⟿y y◃z)) z◃₀a)
-- easy to finish, and follows the paper proof
psx-◃-linear→ : ∀ {Γ x A} → Γ ⊢ps x # A → (∀ a b → a ∈ Γ → b ∈ Γ → (((Γ , a ◃ b) + (Γ , b ◃ a)) + (a == b)))
psx-◃-linear→ pss .0 .0 (inr idp) (inr idp) = inr idp
psx-◃-linear→ (psd Γ⊢psx) a b a∈Γ b∈Γ = psx-◃-linear→ Γ⊢psx a b a∈Γ b∈Γ
psx-◃-linear→ Γ++⊢ps@(pse Γ⊢psx idp idp idp idp idp) a b (inl (inl a∈Γ)) (inl (inl b∈Γ)) with psx-◃-linear→ Γ⊢psx a b a∈Γ b∈Γ
... | inl (inl a◃b) = inl (inl (WW◃ (psv Γ++⊢ps) a◃b))
... | inl (inr b◃a) = inl (inr (WW◃ (psv Γ++⊢ps) b◃a))
... | inr idp = inr idp
psx-◃-linear→ Γ++⊢ps@(pse {x = x} Γ⊢psx idp idp idp idp idp) a .(length _) (inl (inl a∈Γ)) (inl (inr idp)) with psx-◃-linear→ Γ⊢psx a x a∈Γ (Γ⊢x:A→x∈Γ (psvar Γ⊢psx)) -- a ∈ Γ , b = y
... | inl (inl a◃x) = inl (inl (◃-trans (WW◃ (psv Γ++⊢ps) a◃x) (◃T (gen (◃∂⁻ (psvar Γ++⊢ps))) ((◃∂⁺ (psvar Γ++⊢ps)))))) -- a ◃ x
... | inl (inr x◃a) = inl (inr (⟿→◃ (//⟿ (psvar Γ⊢psx) (var (psv Γ++⊢ps) (inl (inr (idp , idp)))) (⊢psx-◃→⟿ Γ⊢psx x◃a)))) -- x ◃ a
... | inr idp = inl (inl (◃T (gen (◃∂⁻ (psvar Γ++⊢ps))) (◃∂⁺ (psvar Γ++⊢ps)))) -- a = x
psx-◃-linear→ Γ++⊢ps@(pse {x = x} Γ⊢psx idp idp idp idp idp) a .(S (length _)) (inl (inl a∈Γ)) (inr idp) with psx-◃-linear→ Γ⊢psx a x a∈Γ (Γ⊢x:A→x∈Γ (psvar Γ⊢psx)) -- a ∈ Γ , b = f (**)
... | inl (inl a◃x) = inl (inl (◃T (WW◃ (psv Γ++⊢ps) a◃x) (◃∂⁻ (psvar Γ++⊢ps)))) -- a ◃ x
... | inl (inr x◃a) = inl (inr (⟿→◃ (x⟿∂⁺ (psvar Γ++⊢ps) (//⟿ (psvar Γ⊢psx) (var (psv Γ++⊢ps) (inl (inr (idp , idp)))) (⊢psx-◃→⟿ Γ⊢psx x◃a))))) -- x ◃ a
... | inr idp = inl (inl (gen (◃∂⁻ (psvar Γ++⊢ps)))) -- a = x
psx-◃-linear→ Γ++⊢ps@(pse {x = x} Γ⊢psx idp idp idp idp idp) .(length _) b (inl (inr idp)) (inl (inl b∈Γ)) with psx-◃-linear→ Γ⊢psx b x b∈Γ (Γ⊢x:A→x∈Γ (psvar Γ⊢psx)) -- a = y, b ∈ Γ
... | inl (inl b◃x) = inl (inr (◃-trans (WW◃ (psv Γ++⊢ps) b◃x) (◃T (gen (◃∂⁻ (psvar Γ++⊢ps))) (◃∂⁺ (psvar Γ++⊢ps))))) -- b ◃ x
... | inl (inr x◃b) = inl (inl (⟿→◃ (//⟿ (psvar Γ⊢psx) (var (psv Γ++⊢ps) (inl (inr (idp , idp)))) (⊢psx-◃→⟿ Γ⊢psx x◃b)))) -- x ◃ b
... | inr idp = inl (inr (◃T (gen (◃∂⁻ (psvar Γ++⊢ps))) (◃∂⁺ (psvar Γ++⊢ps)))) -- b = x
psx-◃-linear→ (pse Γ⊢psx idp idp idp idp idp) .(length _) .(length _) (inl (inr idp)) (inl (inr idp)) = inr idp
psx-◃-linear→ Γ++⊢ps@(pse Γ⊢psx idp idp idp idp idp) .(length _) .(S (length _)) (inl (inr idp)) (inr idp) = inl (inr (gen (◃∂⁺ (psvar Γ++⊢ps)))) -- a = y, b = f
psx-◃-linear→ Γ++⊢ps@(pse {x = x} Γ⊢psx idp idp idp idp idp) .(S (length _)) b (inr idp) (inl (inl b∈Γ)) with psx-◃-linear→ Γ⊢psx b x b∈Γ (Γ⊢x:A→x∈Γ (psvar Γ⊢psx)) -- a = f b ∈ Γ
... | inl (inl b◃x) = inl (inr (◃T (WW◃ (psv Γ++⊢ps) b◃x) (◃∂⁻ (psvar Γ++⊢ps)))) -- b ◃ x
... | inl (inr x◃b) = inl (inl (⟿→◃ (x⟿∂⁺ (psvar Γ++⊢ps) (//⟿ (psvar Γ⊢psx) (var (psv Γ++⊢ps) (inl (inr (idp , idp)))) (⊢psx-◃→⟿ Γ⊢psx x◃b))))) -- x ◃ b
... | inr idp = inl (inr (gen (◃∂⁻ (psvar Γ++⊢ps)))) -- b = x
psx-◃-linear→ Γ++⊢ps@(pse Γ⊢psx idp idp idp idp idp) .(S (length _)) .(length _) (inr idp) (inl (inr idp)) = inl (inl (gen (◃∂⁺ (psvar Γ++⊢ps)))) -- a = f, b = y
psx-◃-linear→ (pse Γ⊢psx idp idp idp idp idp) .(S (length _)) .(S (length _)) (inr idp) (inr idp) = inr idp
strengthen : ∀ {Γ x A y B} → (Γ :: (y , B)) ⊢t Var x # A → x ∈ Γ → Γ ⊢t Var x # A
strengthen (var (cc Γ⊢ _ idp) (inl x#A∈Γ)) x∈Γ = var Γ⊢ x#A∈Γ
strengthen (var (cc Γ⊢ _ idp) (inr (idp , idp))) x∈Γ = ⊥-elim (l∉ Γ⊢ (n≤n _) x∈Γ)
strengthen+ : ∀ {Γ x A y B z C} → ((Γ :: (y , B)) :: (z , C)) ⊢t Var x # A → x ∈ Γ → Γ ⊢t Var x # A
strengthen+ Γ++⊢x x∈Γ = strengthen (strengthen Γ++⊢x (inl x∈Γ)) x∈Γ
◃₀∈ : ∀ {Γ x a} → Γ , x ◃₀ a → a ∈ Γ
◃₀∈ (◃∂⁻ Γ⊢a) = Γ⊢x:A→x∈Γ Γ⊢a
◃₀∈ (◃∂⁺ Γ⊢x) = Γ⊢x:A→x∈Γ (Γ⊢tgt (Γ⊢t:A→Γ⊢A Γ⊢x))
◃∈ : ∀ {Γ x a} → Γ , x ◃ a → a ∈ Γ
◃∈ (gen x◃₀a) = ◃₀∈ x◃₀a
◃∈ (◃T _ z◃₀x) = ◃₀∈ z◃₀x
∈◃₀ : ∀ {Γ x a} → Γ , x ◃₀ a → x ∈ Γ
∈◃₀ (◃∂⁻ Γ⊢a) = Γ⊢x:A→x∈Γ (Γ⊢src (Γ⊢t:A→Γ⊢A Γ⊢a))
∈◃₀ (◃∂⁺ Γ⊢x) = Γ⊢x:A→x∈Γ Γ⊢x
∈◃ : ∀ {Γ x a} → Γ , x ◃ a → x ∈ Γ
∈◃ (gen x◃₀a) = ∈◃₀ x◃₀a
∈◃ (◃T x◃z _) = ∈◃ x◃z
WWpsx : ∀ {Γ x A} → (Γ⊢ps : Γ ⊢ps x # A) → Γ++ Γ⊢ps ⊢t (Var x) # A
WWpsx Γ⊢ps = wkt (wkt (psvar Γ⊢ps) (cc (psv Γ⊢ps) (Γ⊢t:A→Γ⊢A (psvar Γ⊢ps)) idp)) (psv (pse Γ⊢ps idp idp idp idp idp))
dangling-◃₀ : ∀ {Γ x A a} → (Γ⊢ps : Γ ⊢ps x # A) → Γ++ Γ⊢ps , S (length Γ) ◃₀ a → a == length Γ
dangling-◃₀ Γ⊢ps (◃∂⁻ Γ⊢a) = ⊥-elim (dangling-is-not-a-source (pse Γ⊢ps idp idp idp idp idp) _ _ Γ⊢a)
dangling-◃₀ Γ⊢ps (◃∂⁺ (var _ (inl (inl Sl∈Γ)))) = ⊥-elim (l∉ (psv Γ⊢ps) (n≤Sn _) (x#A∈Γ→x∈Γ Sl∈Γ))
dangling-◃₀ Γ⊢ps (◃∂⁺ (var _ (inl (inr (Sl=l , idp))))) = ⊥-elim (Sn≠n _ Sl=l)
dangling-◃₀ Γ⊢ps (◃∂⁺ (var _ (inr (_ , idp)))) = idp
◃₀-dangling : ∀ {Γ x A a} → (Γ⊢ps : Γ ⊢ps x # A) → Γ++ Γ⊢ps , a ◃₀ S (length Γ) → a == x
◃₀-dangling Γ⊢ps (◃∂⁻ Γ+⊢Sl) with unique-type Γ+⊢Sl (psvar (pse Γ⊢ps idp idp idp idp idp)) idp
... | idp = idp
◃₀-dangling Γ⊢ps (◃∂⁺ (var x (inl (inl a∈Γ)))) = ⊥-elim (x∉ (psv Γ⊢ps) (n≤Sn _) (Γ⊢tgt (Γ⊢t:A→Γ⊢A (var (psv Γ⊢ps) a∈Γ))))
◃₀-dangling Γ⊢ps (◃∂⁺ (var x (inl (inr (idp , idp))))) = ⊥-elim (x∉ (psv Γ⊢ps) (n≤Sn _) (Γ⊢tgt (Γ⊢t:A→Γ⊢A (psvar Γ⊢ps))))
◃₀-dangling Γ⊢ps (◃∂⁺ (var x (inr (idp , abs)))) = ⊥-elim (Sn≠n _ (=Var (snd (=⇒ abs))))
◃₀-dangling-tgt : ∀ {Γ x A a} → (Γ⊢ps : Γ ⊢ps x # A) → Γ++ Γ⊢ps , a ◃₀ length Γ → (a == S (length Γ)) + (Γ++ Γ⊢ps , a ◃₀ x)
◃₀-dangling-tgt Γ⊢ps (◃∂⁻ Γ+⊢l) with unique-type Γ+⊢l (var (psv (pse Γ⊢ps idp idp idp idp idp)) (inl (inr (idp , idp)))) idp
... | idp = inr (◃∂⁻ (WWpsx Γ⊢ps))
◃₀-dangling-tgt Γ⊢ps (◃∂⁺ (var x (inl (inl a∈Γ)))) = ⊥-elim (x∉ (psv Γ⊢ps) (n≤n _) (Γ⊢tgt (Γ⊢t:A→Γ⊢A (var (psv Γ⊢ps) a∈Γ))))
◃₀-dangling-tgt Γ⊢ps (◃∂⁺ (var x (inl (inr (idp , idp))))) = ⊥-elim (x∉ (psv Γ⊢ps) (n≤n _) (Γ⊢tgt (Γ⊢t:A→Γ⊢A (psvar Γ⊢ps))))
◃₀-dangling-tgt Γ⊢ps (◃∂⁺ (var x (inr (p , _)))) = inl p
◃-dangling : ∀ {Γ x A a} → (Γ⊢ps : Γ ⊢ps x # A) → Γ++ Γ⊢ps , a ◃ S (length Γ) → (a == x) + (Γ++ Γ⊢ps , a ◃ x)
◃-dangling Γ⊢ps (gen x◃₀Sl) with ◃₀-dangling Γ⊢ps x◃₀Sl
... | idp = inl idp
◃-dangling Γ⊢ps (◃T a◃x x◃₀Sl) with ◃₀-dangling Γ⊢ps x◃₀Sl
... | idp = inr a◃x
◃-dangling-tgt : ∀ {Γ x A a} → (Γ⊢ps : Γ ⊢ps x # A) → Γ++ Γ⊢ps , a ◃ length Γ → (a == S (length Γ) + (a == x)) + (Γ++ Γ⊢ps , a ◃ x)
◃-dangling-tgt Γ⊢ps (gen a◃₀l) with ◃₀-dangling-tgt Γ⊢ps a◃₀l
... | inl idp = inl (inl idp)
... | inr a◃₀x = inr (gen a◃₀x)
◃-dangling-tgt Γ⊢ps (◃T a◃z z◃₀l) with ◃₀-dangling-tgt Γ⊢ps z◃₀l
... | inl idp with ◃-dangling Γ⊢ps a◃z
... | inl idp = inl (inr idp)
... | inr a◃x = inr a◃x
◃-dangling-tgt Γ⊢ps (◃T a◃z z◃₀l) | inr z◃₀x = inr (◃T a◃z z◃₀x)
strengthen-◃₀ : ∀ {Γ x A a b} → (Γ⊢ps : Γ ⊢ps x # A) → a ∈ Γ → b ∈ Γ → Γ++ Γ⊢ps , a ◃₀ b → Γ , a ◃₀ b
strengthen-◃₀ Γ⊢ps a∈Γ b∈Γ (◃∂⁻ Γ⊢b) = ◃∂⁻ (strengthen+ Γ⊢b b∈Γ)
strengthen-◃₀ Γ⊢ps a∈Γ b∈Γ (◃∂⁺ Γ⊢a) = ◃∂⁺ (strengthen+ Γ⊢a a∈Γ)
-- useful particular case
strengthen-◃₀-dangling : ∀ {Γ x A a} → (Γ⊢ps : Γ ⊢ps x # A) → Γ++ Γ⊢ps , length Γ ◃₀ a → Γ , x ◃₀ a
strengthen-◃₀-dangling Γ⊢ps (◃∂⁻ Γ⊢a) = ⊥-elim (post-dangling-is-not-a-source (pse Γ⊢ps idp idp idp idp idp) _ _ (∂⁺⟿ (psvar (pse Γ⊢ps idp idp idp idp idp))) Γ⊢a)
strengthen-◃₀-dangling Γ⊢ps (◃∂⁺ (var _ (inl (inl l∈Γ)))) = ⊥-elim (l∉ (psv Γ⊢ps) (n≤n _) (x#A∈Γ→x∈Γ l∈Γ))
strengthen-◃₀-dangling Γ⊢ps (◃∂⁺ (var _ (inl (inr (_ , idp))))) = ◃∂⁺ (psvar Γ⊢ps)
strengthen-◃₀-dangling Γ⊢ps (◃∂⁺ (var _ (inr (l=Sl , _)))) = ⊥-elim (Sn≠n _ (l=Sl ^))
∈-dangling : ∀ {Γ x A} → Γ ⊢ps x # A → x ∈ Γ
∈-dangling Γ⊢ps = Γ⊢x:A→x∈Γ (psvar Γ⊢ps)
∈-dangling-◃₀ : ∀ {Γ x A a} → (Γ⊢ps : Γ ⊢ps x # A) → Γ++ Γ⊢ps , a ◃₀ x → a ∈ Γ
∈-dangling-◃₀ Γ⊢ps (◃∂⁻ Γ+⊢x) with unique-type Γ+⊢x (WWpsx Γ⊢ps) idp
... | idp = Γ⊢x:A→x∈Γ (Γ⊢src (Γ⊢t:A→Γ⊢A (psvar Γ⊢ps)))
∈-dangling-◃₀ Γ⊢ps (◃∂⁺ (var _ (inl (inl a∈Γ)))) = x#A∈Γ→x∈Γ a∈Γ
∈-dangling-◃₀ Γ⊢ps (◃∂⁺ (var _ (inl (inr (idp , idp))))) with unique-type (psvar Γ⊢ps) (Γ⊢tgt (Γ⊢t:A→Γ⊢A (psvar Γ⊢ps))) idp
... | ()
∈-dangling-◃₀ Γ⊢ps (◃∂⁺ (var _ (inr (idp , idp)))) = ⊥-elim (x∉ (psv Γ⊢ps) (n≤n _) (psvar Γ⊢ps))
strengthen-dangling-◃₀ : ∀ {Γ x A a} → (Γ⊢ps : Γ ⊢ps x # A) → Γ++ Γ⊢ps , a ◃₀ x → Γ , a ◃₀ x
strengthen-dangling-◃₀ Γ⊢ps a◃₀x = strengthen-◃₀ Γ⊢ps (∈-dangling-◃₀ Γ⊢ps a◃₀x) (∈-dangling Γ⊢ps) a◃₀x
-- Not easy to find a way to express in a terminating way
pse-◃-elim : ∀ {Γ x A a b} → (Γ⊢ps : Γ ⊢ps x # A) → a ∈ Γ → b ∈ Γ → Γ++ Γ⊢ps , a ◃ b → Γ , a ◃ b
pse-◃-elim Γ⊢ps a∈Γ b∈Γ (gen a◃₀b) = gen (strengthen-◃₀ Γ⊢ps a∈Γ b∈Γ a◃₀b)
pse-◃-elim Γ⊢ps a∈Γ b∈Γ (◃T a◃z z◃₀b) with ◃∈ a◃z
pse-◃-elim Γ⊢ps a∈Γ b∈Γ (◃T a◃z z◃₀b) | inl (inl z∈Γ) = ◃T (pse-◃-elim Γ⊢ps a∈Γ z∈Γ a◃z) (strengthen-◃₀ Γ⊢ps z∈Γ b∈Γ z◃₀b)
pse-◃-elim Γ⊢ps a∈Γ b∈Γ (◃T (gen a◃₀l) l◃₀b) | inl (inr idp) with ◃₀-dangling-tgt Γ⊢ps a◃₀l
... | inl idp = ⊥-elim (l∉ (psv Γ⊢ps) (n≤Sn _) a∈Γ)
... | inr a◃₀x = ◃T (gen (strengthen-◃₀ Γ⊢ps a∈Γ (∈-dangling Γ⊢ps) a◃₀x)) (strengthen-◃₀-dangling Γ⊢ps l◃₀b)
pse-◃-elim Γ⊢ps a∈Γ b∈Γ (◃T (◃T a◃z z◃₀l) l◃₀b) | inl (inr idp) with ◃₀-dangling-tgt Γ⊢ps z◃₀l
... | inr z◃₀x = ◃T (◃T (pse-◃-elim Γ⊢ps a∈Γ (∈-dangling-◃₀ Γ⊢ps z◃₀x) a◃z) (strengthen-dangling-◃₀ Γ⊢ps z◃₀x)) (strengthen-◃₀-dangling Γ⊢ps l◃₀b)
pse-◃-elim Γ⊢ps a∈Γ b∈Γ (◃T (◃T (gen a◃₀Sl) Sl◃₀l) l◃₀b) | inl (inr idp) | inl idp with ◃₀-dangling Γ⊢ps a◃₀Sl
... | idp = gen (strengthen-◃₀-dangling Γ⊢ps l◃₀b)
pse-◃-elim Γ⊢ps a∈Γ b∈Γ (◃T (◃T (◃T a◃z z◃₀Sl) Sl◃₀l) l◃₀b) | inl (inr idp) | inl idp with ◃₀-dangling Γ⊢ps z◃₀Sl
... | idp = ◃T (pse-◃-elim Γ⊢ps a∈Γ (∈-dangling Γ⊢ps) a◃z) (strengthen-◃₀-dangling Γ⊢ps l◃₀b)
pse-◃-elim Γ⊢ps a∈Γ b∈Γ (◃T a◃z z◃₀b) | inr idp with dangling-◃₀ Γ⊢ps z◃₀b
... | idp = ⊥-elim (l∉ (psv Γ⊢ps) (n≤n _) b∈Γ)
psx-◃-linear← : ∀ {Γ z A} → Γ ⊢ps z # A → (∀ x → x ∈ Γ → ¬ (Γ , x ◃ x))
psx-◃-linear← pss .0 (inr idp) x◃x = 𝔻0-◃ 0 x◃x
psx-◃-linear← (psd Γ⊢psz) x x∈Γ x◃x = psx-◃-linear← Γ⊢psz x x∈Γ x◃x
psx-◃-linear← (pse Γ⊢psz idp idp idp idp idp) x (inl (inl x∈Γ)) x◃x = psx-◃-linear← Γ⊢psz x x∈Γ (pse-◃-elim Γ⊢psz x∈Γ x∈Γ x◃x)
psx-◃-linear← Γ+⊢ps@(pse Γ⊢psz idp idp idp idp idp) x (inl (inr idp)) x◃x = ⊥-elim (Sn≰n _ (⟿dim (var (psv Γ+⊢ps) (inl (inr (idp , idp)))) (var (psv Γ+⊢ps) (inl (inr (idp , idp)))) (⊢psx-◃→⟿+ Γ+⊢ps (∂⁺⟿ (psvar Γ+⊢ps)) x◃x)))
psx-◃-linear← Γ+⊢ps@(pse Γ⊢psz idp idp idp idp idp) x (inr idp) x◃x = ⊥-elim (Sn≰n _ (⟿dim (psvar Γ+⊢ps) (psvar Γ+⊢ps) (⊢psx-◃→⟿ Γ+⊢ps x◃x)))
◃-linear : Pre-Ctx → Set₁
◃-linear Γ = ∀ x y → x ∈ Γ → y ∈ Γ → (x ≠ y) ↔ ((Γ , x ◃ y) + (Γ , y ◃ x))
ps-◃-linear : ∀ Γ → Γ ⊢ps → ◃-linear Γ
fst (ps-◃-linear Γ (ps Γ⊢psz) x y x∈Γ y∈Γ) x≠y with psx-◃-linear→ Γ⊢psz x y x∈Γ y∈Γ
... | inl H = H
... | inr x=y = ⊥-elim (x≠y x=y)
snd (ps-◃-linear Γ (ps Γ⊢psz) x .x x∈Γ y∈Γ) (inl x◃x) idp = psx-◃-linear← Γ⊢psz x x∈Γ x◃x
snd (ps-◃-linear Γ (ps Γ⊢psz) x .x x∈Γ y∈Γ) (inr x◃x) idp = psx-◃-linear← Γ⊢psz x x∈Γ x◃x
| 61.668852
| 226
| 0.474507
|
591036d28bc6a8ae63745919444a7426ac8c1b10
| 5,334
|
agda
|
Agda
|
src/is-lib/InfSys/Container.agda
|
boystrange/FairSubtypingAgda
|
c4b78e70c3caf68d509f4360b9171d9f80ecb825
|
[
"MIT"
] | 4
|
2021-07-29T14:32:30.000Z
|
2022-01-24T14:38:47.000Z
|
src/is-lib/InfSys/Container.agda
|
boystrange/FairSubtypingAgda
|
c4b78e70c3caf68d509f4360b9171d9f80ecb825
|
[
"MIT"
] | null | null | null |
src/is-lib/InfSys/Container.agda
|
boystrange/FairSubtypingAgda
|
c4b78e70c3caf68d509f4360b9171d9f80ecb825
|
[
"MIT"
] | null | null | null |
--------------------------------------------------------------------------------
-- This is part of Agda Inference Systems
{-# OPTIONS --sized-types --guardedness #-}
open import Agda.Builtin.Equality
open import Data.Product
open import Data.Sum
open import Data.Empty
open import Data.Unit
open import Level
open import Size
open import Codata.Thunk
open import Relation.Unary using (_⊆_)
open import Data.Container.Indexed
module is-lib.InfSys.Container {𝓁}(U : Set 𝓁) where
module ISCont {𝓁p} where
ISCont : {𝓁c : Level} → Set _
ISCont {𝓁c} = Container U U 𝓁c 𝓁p
ISContClosed : ∀{𝓁c 𝓁'}(is : ISCont {𝓁c}) → (U → Set 𝓁') → Set _
ISContClosed is P = (⟦ is ⟧ P ⊆ P)
_↾_ : ∀{𝓁c 𝓁'} → ISCont {𝓁c} → (U → Set 𝓁') → ISCont {𝓁c ⊔ 𝓁'}
(is ↾ P) .Command u = is .Command u × P u
(is ↾ P) .Response (c , p) = is .Response c
(is ↾ P) .next (c , p) r = is .next c r
_∪_ : ∀{𝓁c 𝓁c'} → ISCont {𝓁c} → ISCont {𝓁c'} → ISCont {𝓁c ⊔ 𝓁c'}
(is ∪ is') .Command u = is .Command u ⊎ is' .Command u
(is ∪ is') .Response = [ is .Response , is' .Response ]
(is ∪ is') .next = [ is .next , is' .next ]
Ind⟦_⟧ = μ
-- Coinductive interpretation
record CoInd⟦_⟧ {𝓁c : Level}(is : ISCont {𝓁c}) (u : U) : Set (𝓁c ⊔ 𝓁p) where
coinductive
constructor cofold_
field
unfold : ⟦ is ⟧ CoInd⟦ is ⟧ u
-- Sized coinductive interpretation
record CoInd⟦_⟧^ {𝓁c : Level}(is : ISCont {𝓁c}) (i : Size) (u : U) : Set (𝓁c ⊔ 𝓁p) where
coinductive
constructor cofold_
field
unfold : {j : Size< i} → ⟦ is ⟧ (CoInd⟦ is ⟧^ j) u
-- Sized coinductive interpretation (using Thunk)
data SCoInd⟦_⟧ {𝓁c : Level}(is : ISCont {𝓁c}) (u : U) (i : Size) : Set (𝓁c ⊔ 𝓁p) where
sfold : ⟦ is ⟧ (λ u → Thunk (SCoInd⟦ is ⟧ u) i) u → SCoInd⟦ is ⟧ u i
FCoInd⟦_,_⟧ : ∀{𝓁c 𝓁c'} → (I : ISCont {𝓁c}) (C : ISCont {𝓁c'}) → U → Set _
FCoInd⟦ I , C ⟧ = CoInd⟦ I ↾ Ind⟦ I ∪ C ⟧ ⟧
module _ {𝓁c 𝓁'} (is : ISCont {𝓁c}) (P : U → Set 𝓁') (closed : ISContClosed is P) where
open import Data.W.Indexed using (iter)
ind[_] : Ind⟦ is ⟧ ⊆ P
ind[_] = iter is closed
module _ {𝓁c 𝓁'} (is : ISCont {𝓁c}) (P : U → Set 𝓁') (consistent : P ⊆ ⟦ is ⟧ P) where
open CoInd⟦_⟧
coind[] : P ⊆ CoInd⟦ is ⟧
coind[] p .unfold .proj₁ = consistent p .proj₁
coind[] p .unfold .proj₂ r = coind[] (consistent p .proj₂ r)
module _ {𝓁c 𝓁c' 𝓁'}(I : ISCont {𝓁c}) (C : ISCont {𝓁c'}) (P : U → Set 𝓁') (bounded : P ⊆ Ind⟦ I ∪ C ⟧) (consistent : P ⊆ ⟦ I ⟧ P) where
open CoInd⟦_⟧
bounded-coind[] : P ⊆ FCoInd⟦ I , C ⟧
bounded-coind[] p .unfold .proj₁ .proj₁ = consistent p .proj₁
bounded-coind[] p .unfold .proj₁ .proj₂ = bounded p
bounded-coind[] p .unfold .proj₂ r = bounded-coind[] (consistent p .proj₂ r)
module Equivalence {𝓁p 𝓁P 𝓁P'} where
open ISCont {𝓁p}
open import is-lib.InfSys.Base {𝓁} as IS
open IS.MetaRule
open IS.IS
{- Every IS is an EndoContainer -}
C[_] : ∀{𝓁c 𝓁n} → IS {𝓁c} {𝓁p} {𝓁n} U → ISCont {𝓁 ⊔ 𝓁c ⊔ 𝓁n}
C[ is ] .Command u = Σ[ rn ∈ is .Names ] Σ[ c ∈ is .rules rn .Ctx ] u ≡ is .rules rn .conclu c
C[ is ] .Response (rn , c , refl) = is .rules rn .Pos c
C[ is ] .next (rn , c , refl) r = is .rules rn .prems c r
{- Every EndoContainer is an IS -}
IS[_] : ∀{𝓁'} → ISCont {𝓁'} → IS {zero} {𝓁p} {𝓁 ⊔ 𝓁'} U
IS[_] C .Names = Σ[ u ∈ U ] C .Command u
IS[ C ] .rules (u , c) =
record {
Ctx = ⊤ ;
Pos = λ _ → C .Response c ;
prems = λ _ r → C .next c r ;
conclu = λ _ → u }
{- Equivalence -}
isf-to-c : ∀{𝓁c 𝓁n} → {is : IS {𝓁c} {𝓁p} {𝓁n} U}{P : U → Set 𝓁P}
→ ISF[ is ] P ⊆ ⟦ C[ is ] ⟧ P
isf-to-c (rn , c , refl , pr) = (rn , c , refl) , pr
c-to-isf : ∀{𝓁'}{C : ISCont {𝓁'}}{P : U → Set 𝓁P}
→ ⟦ C ⟧ P ⊆ ISF[ IS[ C ] ] P
c-to-isf (c , pr) = (_ , c) , tt , refl , pr
∪-IS-eq : ∀{𝓁c 𝓁n 𝓁n'}{is : IS {𝓁c} {𝓁p} {𝓁n} U}{is' : IS {𝓁c} {𝓁p} {𝓁n'} U}{P : U → Set 𝓁P}
→ ISF[ is IS.∪ is' ] P ⊆ ⟦ C[ is ] ISCont.∪ C[ is' ] ⟧ P
∪-IS-eq (inj₁ rn , c , refl , pr) = inj₁ (rn , c , refl) , pr
∪-IS-eq (inj₂ rn , c , refl , pr) = inj₂ (rn , c , refl) , pr
∪-C-eq : ∀{𝓁1 𝓁2}{c : ISCont {𝓁1}}{c' : ISCont {𝓁2}}{P : U → Set 𝓁P}
→ ⟦ c ISCont.∪ c' ⟧ P ⊆ ISF[ IS[ c ] IS.∪ IS[ c' ] ] P
∪-C-eq (inj₁ c , r) = inj₁ (_ , c) , tt , refl , r
∪-C-eq (inj₂ c , r) = inj₂ (_ , c) , tt , refl , r
⊓-IS-eq : ∀{𝓁c 𝓁n}{is : IS {𝓁c} {𝓁p} {𝓁n} U}{P : U → Set 𝓁P}{P' : U → Set 𝓁P'}
→ ISF[ is ⊓ P ] P' ⊆ ⟦ C[ is ] ↾ P ⟧ P'
⊓-IS-eq (rn , (c , Pu) , refl , pr) = ((rn , c , refl) , Pu) , pr
↾-C-eq : ∀{𝓁c}{c : ISCont {𝓁c}}{P : U → Set 𝓁P}{P' : U → Set 𝓁P'}
→ ⟦ c ↾ P ⟧ P' ⊆ ISF[ IS[ c ] ⊓ P ] P'
↾-C-eq ((c , Pu) , r) = (_ , c) , (tt , Pu) , refl , r
| 38.652174
| 143
| 0.449944
|
380df9d2397cb003b492dfbef028ac030ea4956f
| 209
|
agda
|
Agda
|
test/Fail/Issue3090-rparen.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
test/Fail/Issue3090-rparen.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
test/Fail/Issue3090-rparen.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
-- Andreas, 2018-05-27, issue #3090, reported by anka-213
-- Parser should not raise internal error for invalid symbol in name
{-# BUILTIN NATURAL ) #-}
-- Should fail with a parse error, not internal error
| 29.857143
| 68
| 0.722488
|
23042b00c90f1d74174c53c29e36a99e08a3993c
| 37
|
agda
|
Agda
|
test/Fail/Polarity-pragma-for-defined-name.agda
|
pthariensflame/agda
|
222c4c64b2ccf8e0fc2498492731c15e8fef32d4
|
[
"BSD-3-Clause"
] | 3
|
2015-03-28T14:51:03.000Z
|
2015-12-07T20:14:00.000Z
|
test/Fail/Polarity-pragma-for-defined-name.agda
|
Blaisorblade/Agda
|
802a28aa8374f15fe9d011ceb80317fdb1ec0949
|
[
"BSD-3-Clause"
] | null | null | null |
test/Fail/Polarity-pragma-for-defined-name.agda
|
Blaisorblade/Agda
|
802a28aa8374f15fe9d011ceb80317fdb1ec0949
|
[
"BSD-3-Clause"
] | null | null | null |
A : Set₁
A = Set
{-# POLARITY A #-}
| 7.4
| 18
| 0.486486
|
13b0d37c1110068e13511c1edabc1d246612df36
| 2,147
|
agda
|
Agda
|
Cubical/Foundations/Pointed/Base.agda
|
Schippmunk/cubical
|
c345dc0c49d3950dc57f53ca5f7099bb53a4dc3a
|
[
"MIT"
] | null | null | null |
Cubical/Foundations/Pointed/Base.agda
|
Schippmunk/cubical
|
c345dc0c49d3950dc57f53ca5f7099bb53a4dc3a
|
[
"MIT"
] | null | null | null |
Cubical/Foundations/Pointed/Base.agda
|
Schippmunk/cubical
|
c345dc0c49d3950dc57f53ca5f7099bb53a4dc3a
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --cubical --no-import-sorts --safe #-}
module Cubical.Foundations.Pointed.Base where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.HLevels
open import Cubical.Foundations.Isomorphism
open import Cubical.Data.Sigma
open import Cubical.Foundations.Structure
open import Cubical.Foundations.Structure using (typ) public
open import Cubical.Foundations.GroupoidLaws
open import Cubical.Foundations.Isomorphism
private
variable
ℓ ℓ' : Level
Pointed : (ℓ : Level) → Type (ℓ-suc ℓ)
Pointed ℓ = TypeWithStr ℓ (λ x → x)
pt : ∀ {ℓ} (A∙ : Pointed ℓ) → typ A∙
pt = str
Pointed₀ = Pointed ℓ-zero
{- Pointed functions -}
_→∙_ : ∀{ℓ ℓ'} → (A : Pointed ℓ) (B : Pointed ℓ') → Type (ℓ-max ℓ ℓ')
_→∙_ A B = Σ[ f ∈ (typ A → typ B) ] f (pt A) ≡ pt B
_→∙_∙ : ∀{ℓ ℓ'} → (A : Pointed ℓ) (B : Pointed ℓ') → Pointed (ℓ-max ℓ ℓ')
A →∙ B ∙ = (A →∙ B) , (λ x → pt B) , refl
idfun∙ : ∀ {ℓ} (A : Pointed ℓ) → A →∙ A
idfun∙ A = (λ x → x) , refl
-- Pointed equivalences
_≃∙_ : (A : Pointed ℓ) (B : Pointed ℓ') → Type (ℓ-max ℓ ℓ')
A ≃∙ B = Σ[ (f , p) ∈ A →∙ B ] isEquiv f
≃∙→≃ : {A : Pointed ℓ} {B : Pointed ℓ'}
(f : A ≃∙ B)
→ typ A ≃ typ B
≃∙→≃ f = fst (fst f) , snd f
idEquiv∙ : (A : Pointed ℓ) → A ≃∙ A
idEquiv∙ (A , ⋆) =
(idfun∙ (A , ⋆)) ,
record { equiv-proof = λ a → p a }
where
module _ (a : A) where
p : isContr (Σ[ a' ∈ A ] a' ≡ a)
p = isContrRespectEquiv (Σ-cong-equiv-snd (λ a₁ → isoToEquiv (iso sym sym (λ _ → refl) λ _ → refl))) (isContrSingl a)
{- HIT allowing for pattern matching on pointed types -}
data Pointer {ℓ} (A : Pointed ℓ) : Type ℓ where
pt₀ : Pointer A
⌊_⌋ : typ A → Pointer A
id : ⌊ pt A ⌋ ≡ pt₀
IsoPointedPointer : ∀ {ℓ} {A : Pointed ℓ} → Iso (typ A) (Pointer A)
Iso.fun IsoPointedPointer = ⌊_⌋
Iso.inv (IsoPointedPointer {A = A}) pt₀ = pt A
Iso.inv IsoPointedPointer ⌊ x ⌋ = x
Iso.inv (IsoPointedPointer {A = A}) (id i) = pt A
Iso.rightInv IsoPointedPointer pt₀ = id
Iso.rightInv IsoPointedPointer ⌊ x ⌋ = refl
Iso.rightInv IsoPointedPointer (id i) j = id (i ∧ j)
Iso.leftInv IsoPointedPointer x = refl
| 30.239437
| 125
| 0.616209
|
4a082d2dbccc4bea95793310b4383b7513713c74
| 686
|
agda
|
Agda
|
test/Succeed/Issue1922.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
test/Succeed/Issue1922.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
test/Succeed/Issue1922.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
data Bool : Set where
true false : Bool
data Nat : Set where
zero : Nat
suc : Nat → Nat
one : Nat
one = suc zero
two : Nat
two = suc one
data Fin : Nat → Set where
zero : ∀{n} → Fin (suc n)
suc : ∀{n} (i : Fin n) → Fin (suc n)
--This part works as expected:
s : ∀ n → (f : (k : Fin n) → Bool) → Fin (suc n)
s n f = zero
t1 : Fin two
t1 = s one (λ { zero → true ; (suc ()) })
-- But Agda is not able to infer the 1 in this case:
ttwo : Fin two
ttwo = s _ (λ { zero → true ; (suc ()) })
-- Warning:
-- _142 : Nat
-- The problem gets worse when i add arguments to the ttwo function. This gives an error:
t3 : Set → Fin two
t3 A = s _ (λ { zero → true ; (suc ()) })
| 17.589744
| 89
| 0.565598
|
529bc807a19aec7ce946f4cacc59f8debc74e052
| 348
|
agda
|
Agda
|
src/Everything.agda
|
guilhermehas/crypto-agda
|
ac91e00abca9a26678d0cbc1bedecf8abef6b703
|
[
"MIT"
] | 4
|
2020-02-13T16:56:47.000Z
|
2021-03-22T19:27:12.000Z
|
src/Everything.agda
|
guilhermehas/cripto-agda
|
ac91e00abca9a26678d0cbc1bedecf8abef6b703
|
[
"MIT"
] | 1
|
2019-11-01T11:36:06.000Z
|
2019-11-03T14:31:16.000Z
|
src/Everything.agda
|
guilhermehas/cripto-agda
|
ac91e00abca9a26678d0cbc1bedecf8abef6b703
|
[
"MIT"
] | null | null | null |
open import agdaExamples public
open import Blockchain public
open import Crypto public
open import examples public
open import lambdaCalculus
open import Ledger public
open import proofsTXTree public
open import RawTransactions public
open import RawTXTree public
open import Transactions public
open import TXTree public
open import Utils public
| 26.769231
| 34
| 0.864943
|
1ee3b8b2ba48ca67657aff6c9e0a0d1e01bf8bf9
| 3,207
|
agda
|
Agda
|
src/FOmegaInt/Typing/Preservation.agda
|
Blaisorblade/f-omega-int-agda
|
ae20dac2a5e0c18dff2afda4c19954e24d73a24f
|
[
"MIT"
] | 12
|
2017-06-13T16:05:35.000Z
|
2021-09-27T05:53:06.000Z
|
src/FOmegaInt/Typing/Preservation.agda
|
Blaisorblade/f-omega-int-agda
|
ae20dac2a5e0c18dff2afda4c19954e24d73a24f
|
[
"MIT"
] | 1
|
2021-05-14T08:09:40.000Z
|
2021-05-14T08:54:39.000Z
|
src/FOmegaInt/Typing/Preservation.agda
|
Blaisorblade/f-omega-int-agda
|
ae20dac2a5e0c18dff2afda4c19954e24d73a24f
|
[
"MIT"
] | 2
|
2021-05-13T22:29:48.000Z
|
2021-05-14T10:25:05.000Z
|
------------------------------------------------------------------------
-- Subject reduction for typing in Fω with interval kinds
------------------------------------------------------------------------
{-# OPTIONS --safe --without-K #-}
-- This module proves a variant of subject reduction (aka the
-- "preservation" theorem) for term reduction in Fω with interval
-- kinds. The subject reduction property proved here is weaker than
-- the one typically found in the literature on other variants of Fω:
-- subject reduction does not hold in arbitrary typing contexts in Fω
-- with interval types because type variables of interval kind can be
-- used to introduce arbitrary typing (in)equalities into the
-- subtyping relation. In other words, subject reduction does not
-- hold for full β-reduction as reductions under type abstractions are
-- not safe in general. Note, however, that subject reduction does
-- hold for arbitrary β-reductions in *types* (see `pres-Tp∈-→β*' in
-- the Kinding.Declarative.Validity module for a proof).
--
-- NOTE. Here we use the CBV evaluation strategy, but this is
-- unnecessarily restrictive. Other evaluation strategies work so
-- long as they do not allow reductions under type abstractions.
--
-- Together with the "progress" theorem from Typing.Progress, subject
-- reduction ensures type safety. For details, see e.g.
--
-- * B. C. Pierce, TAPL (2002), pp. 95.
--
-- * A. Wright and M. Felleisen, "A Syntactic Approach to Type
-- Soundness" (1994).
module FOmegaInt.Typing.Preservation where
open import Data.Product using (_,_)
open import Relation.Binary.Construct.Closure.ReflexiveTransitive using (ε; _◅_)
open import Relation.Binary.PropositionalEquality using (subst)
open import Relation.Nullary.Negation using (contradiction)
open import FOmegaInt.Syntax
open import FOmegaInt.Typing
open import FOmegaInt.Typing.Inversion
open import FOmegaInt.Reduction.Cbv
open import FOmegaInt.Reduction.Full
open Syntax
open TermCtx
open Substitution using (_[_]; weaken-sub)
open Typing
open TypedSubstitution using (Tm∈-[]; <:-[])
-- Types of closed terms are preserved under single-step reduction.
pres : ∀ {a b c} → [] ⊢Tm a ∈ c → a →v b → [] ⊢Tm b ∈ c
pres (∈-var () _ _)
pres (∈-∀-i k-kd a∈b) ()
pres (∈-→-i a∈* b∈c c∈*) ()
pres (∈-∀-e Λja∈Πkc b∈k) (cont-⊡ j a b) with Tm∈-gen Λja∈Πkc
... | ∈-∀-i j-kd a∈d Πjd<:Πkc =
let k<∷j , d<:c = <:-∀-inv Πjd<:Πkc
in ∈-⇑ (Tm∈-[] a∈d (∈-tp (∈-⇑ b∈k k<∷j))) (<:-[] d<:c (∈-tp b∈k))
pres (∈-∀-e a∈Πcd b∈c) (a→e ⊡ b) = ∈-∀-e (pres a∈Πcd a→e) b∈c
pres (∈-→-e ƛea∈c⇒d v∈c) (cont-· e a v) with Tm∈-gen ƛea∈c⇒d
... | ∈-→-i e∈* a∈f e⇒f<:c⇒d =
let c<:e , f<:d = <:-→-inv e⇒f<:c⇒d
in ∈-⇑ (subst (_ ⊢Tm _ ∈_) (weaken-sub _) (Tm∈-[] a∈f (∈-tm (∈-⇑ v∈c c<:e))))
f<:d
pres (∈-→-e a∈c⇒d b∈c) (a→e ·₁ b) = ∈-→-e (pres a∈c⇒d a→e) b∈c
pres (∈-→-e a∈c⇒d b∈c) (v ·₂ b→e) = ∈-→-e a∈c⇒d (pres b∈c b→e)
pres (∈-⇑ a∈c c<:d) a→b = ∈-⇑ (pres a∈c a→b) c<:d
-- Weak preservation (aka subject reduction): types of closed terms
-- are preserved under reduction.
pres* : ∀ {a b c} → [] ⊢Tm a ∈ c → a →v* b → [] ⊢Tm b ∈ c
pres* a∈c ε = a∈c
pres* a∈d (a→b ◅ b→*c) = pres* (pres a∈d a→b) b→*c
| 42.76
| 80
| 0.618647
|
c595a1600fa3affd9c078bb951605eae73d5a95c
| 9,152
|
agda
|
Agda
|
Basic/Compiler/Test.agda
|
AndrasKovacs/SemanticsWithApplications
|
05200d60b4a4b2c6fa37806ced9247055d24db94
|
[
"MIT"
] | 8
|
2016-09-12T04:25:39.000Z
|
2020-02-02T10:01:52.000Z
|
Basic/Compiler/Test.agda
|
AndrasKovacs/SemanticsWithApplications
|
05200d60b4a4b2c6fa37806ced9247055d24db94
|
[
"MIT"
] | null | null | null |
Basic/Compiler/Test.agda
|
AndrasKovacs/SemanticsWithApplications
|
05200d60b4a4b2c6fa37806ced9247055d24db94
|
[
"MIT"
] | null | null | null |
module Basic.Compiler.Test where
open import Basic.AST
open import Basic.Compiler.Code
open import Basic.Compiler.Machine
open import Basic.BigStep
open import Data.Fin
open import Data.Nat
open import Data.Vec
open import Data.Product
open import Data.Bool
open import Data.List
open Basic.BigStep.Fac
{- Just a sandbox for testing the interpreters in Compiler.Machine -}
fac' : Code 3
fac' = 𝓒⟦ fac ⟧ˢ
test = trace fac' [] (1 ∷ 0 ∷ 0 ∷ []) 1000
-- normal form of "test"
-- (PUSH 0 ∷
-- STORE (suc zero) ∷
-- PUSH 1 ∷
-- STORE (suc (suc zero)) ∷
-- LOOP (FETCH zero ∷ FETCH (suc zero) ∷ LT ∷ [])
-- (FETCH (suc zero) ∷
-- PUSH 1 ∷
-- ADD ∷
-- STORE (suc zero) ∷
-- FETCH (suc (suc zero)) ∷
-- FETCH (suc zero) ∷ MUL ∷ STORE (suc (suc zero)) ∷ [])
-- ∷ []
-- , [] , 1 ∷ 0 ∷ 0 ∷ [])
-- ∷
-- (STORE (suc zero) ∷
-- PUSH 1 ∷
-- STORE (suc (suc zero)) ∷
-- LOOP (FETCH zero ∷ FETCH (suc zero) ∷ LT ∷ [])
-- (FETCH (suc zero) ∷
-- PUSH 1 ∷
-- ADD ∷
-- STORE (suc zero) ∷
-- FETCH (suc (suc zero)) ∷
-- FETCH (suc zero) ∷ MUL ∷ STORE (suc (suc zero)) ∷ [])
-- ∷ []
-- , nat 0 ∷ [] , 1 ∷ 0 ∷ 0 ∷ [])
-- ∷
-- (PUSH 1 ∷
-- STORE (suc (suc zero)) ∷
-- LOOP (FETCH zero ∷ FETCH (suc zero) ∷ LT ∷ [])
-- (FETCH (suc zero) ∷
-- PUSH 1 ∷
-- ADD ∷
-- STORE (suc zero) ∷
-- FETCH (suc (suc zero)) ∷
-- FETCH (suc zero) ∷ MUL ∷ STORE (suc (suc zero)) ∷ [])
-- ∷ []
-- , [] , 1 ∷ 0 ∷ 0 ∷ [])
-- ∷
-- (STORE (suc (suc zero)) ∷
-- LOOP (FETCH zero ∷ FETCH (suc zero) ∷ LT ∷ [])
-- (FETCH (suc zero) ∷
-- PUSH 1 ∷
-- ADD ∷
-- STORE (suc zero) ∷
-- FETCH (suc (suc zero)) ∷
-- FETCH (suc zero) ∷ MUL ∷ STORE (suc (suc zero)) ∷ [])
-- ∷ []
-- , nat 1 ∷ [] , 1 ∷ 0 ∷ 0 ∷ [])
-- ∷
-- (LOOP (FETCH zero ∷ FETCH (suc zero) ∷ LT ∷ [])
-- (FETCH (suc zero) ∷
-- PUSH 1 ∷
-- ADD ∷
-- STORE (suc zero) ∷
-- FETCH (suc (suc zero)) ∷
-- FETCH (suc zero) ∷ MUL ∷ STORE (suc (suc zero)) ∷ [])
-- ∷ []
-- , [] , 1 ∷ 0 ∷ 1 ∷ [])
-- ∷
-- (FETCH zero ∷
-- FETCH (suc zero) ∷
-- LT ∷
-- BRANCH
-- (FETCH (suc zero) ∷
-- PUSH 1 ∷
-- ADD ∷
-- STORE (suc zero) ∷
-- FETCH (suc (suc zero)) ∷
-- FETCH (suc zero) ∷
-- MUL ∷
-- STORE (suc (suc zero)) ∷
-- LOOP (FETCH zero ∷ FETCH (suc zero) ∷ LT ∷ [])
-- (FETCH (suc zero) ∷
-- PUSH 1 ∷
-- ADD ∷
-- STORE (suc zero) ∷
-- FETCH (suc (suc zero)) ∷
-- FETCH (suc zero) ∷ MUL ∷ STORE (suc (suc zero)) ∷ [])
-- ∷ [])
-- (NOOP ∷ [])
-- ∷ []
-- , [] , 1 ∷ 0 ∷ 1 ∷ [])
-- ∷
-- (FETCH (suc zero) ∷
-- LT ∷
-- BRANCH
-- (FETCH (suc zero) ∷
-- PUSH 1 ∷
-- ADD ∷
-- STORE (suc zero) ∷
-- FETCH (suc (suc zero)) ∷
-- FETCH (suc zero) ∷
-- MUL ∷
-- STORE (suc (suc zero)) ∷
-- LOOP (FETCH zero ∷ FETCH (suc zero) ∷ LT ∷ [])
-- (FETCH (suc zero) ∷
-- PUSH 1 ∷
-- ADD ∷
-- STORE (suc zero) ∷
-- FETCH (suc (suc zero)) ∷
-- FETCH (suc zero) ∷ MUL ∷ STORE (suc (suc zero)) ∷ [])
-- ∷ [])
-- (NOOP ∷ [])
-- ∷ []
-- , nat 1 ∷ [] , 1 ∷ 0 ∷ 1 ∷ [])
-- ∷
-- (LT ∷
-- BRANCH
-- (FETCH (suc zero) ∷
-- PUSH 1 ∷
-- ADD ∷
-- STORE (suc zero) ∷
-- FETCH (suc (suc zero)) ∷
-- FETCH (suc zero) ∷
-- MUL ∷
-- STORE (suc (suc zero)) ∷
-- LOOP (FETCH zero ∷ FETCH (suc zero) ∷ LT ∷ [])
-- (FETCH (suc zero) ∷
-- PUSH 1 ∷
-- ADD ∷
-- STORE (suc zero) ∷
-- FETCH (suc (suc zero)) ∷
-- FETCH (suc zero) ∷ MUL ∷ STORE (suc (suc zero)) ∷ [])
-- ∷ [])
-- (NOOP ∷ [])
-- ∷ []
-- , nat 0 ∷ nat 1 ∷ [] , 1 ∷ 0 ∷ 1 ∷ [])
-- ∷
-- (BRANCH
-- (FETCH (suc zero) ∷
-- PUSH 1 ∷
-- ADD ∷
-- STORE (suc zero) ∷
-- FETCH (suc (suc zero)) ∷
-- FETCH (suc zero) ∷
-- MUL ∷
-- STORE (suc (suc zero)) ∷
-- LOOP (FETCH zero ∷ FETCH (suc zero) ∷ LT ∷ [])
-- (FETCH (suc zero) ∷
-- PUSH 1 ∷
-- ADD ∷
-- STORE (suc zero) ∷
-- FETCH (suc (suc zero)) ∷
-- FETCH (suc zero) ∷ MUL ∷ STORE (suc (suc zero)) ∷ [])
-- ∷ [])
-- (NOOP ∷ [])
-- ∷ []
-- , bool true ∷ [] , 1 ∷ 0 ∷ 1 ∷ [])
-- ∷
-- (FETCH (suc zero) ∷
-- PUSH 1 ∷
-- ADD ∷
-- STORE (suc zero) ∷
-- FETCH (suc (suc zero)) ∷
-- FETCH (suc zero) ∷
-- MUL ∷
-- STORE (suc (suc zero)) ∷
-- LOOP (FETCH zero ∷ FETCH (suc zero) ∷ LT ∷ [])
-- (FETCH (suc zero) ∷
-- PUSH 1 ∷
-- ADD ∷
-- STORE (suc zero) ∷
-- FETCH (suc (suc zero)) ∷
-- FETCH (suc zero) ∷ MUL ∷ STORE (suc (suc zero)) ∷ [])
-- ∷ []
-- , [] , 1 ∷ 0 ∷ 1 ∷ [])
-- ∷
-- (PUSH 1 ∷
-- ADD ∷
-- STORE (suc zero) ∷
-- FETCH (suc (suc zero)) ∷
-- FETCH (suc zero) ∷
-- MUL ∷
-- STORE (suc (suc zero)) ∷
-- LOOP (FETCH zero ∷ FETCH (suc zero) ∷ LT ∷ [])
-- (FETCH (suc zero) ∷
-- PUSH 1 ∷
-- ADD ∷
-- STORE (suc zero) ∷
-- FETCH (suc (suc zero)) ∷
-- FETCH (suc zero) ∷ MUL ∷ STORE (suc (suc zero)) ∷ [])
-- ∷ []
-- , nat 0 ∷ [] , 1 ∷ 0 ∷ 1 ∷ [])
-- ∷
-- (ADD ∷
-- STORE (suc zero) ∷
-- FETCH (suc (suc zero)) ∷
-- FETCH (suc zero) ∷
-- MUL ∷
-- STORE (suc (suc zero)) ∷
-- LOOP (FETCH zero ∷ FETCH (suc zero) ∷ LT ∷ [])
-- (FETCH (suc zero) ∷
-- PUSH 1 ∷
-- ADD ∷
-- STORE (suc zero) ∷
-- FETCH (suc (suc zero)) ∷
-- FETCH (suc zero) ∷ MUL ∷ STORE (suc (suc zero)) ∷ [])
-- ∷ []
-- , nat 1 ∷ nat 0 ∷ [] , 1 ∷ 0 ∷ 1 ∷ [])
-- ∷
-- (STORE (suc zero) ∷
-- FETCH (suc (suc zero)) ∷
-- FETCH (suc zero) ∷
-- MUL ∷
-- STORE (suc (suc zero)) ∷
-- LOOP (FETCH zero ∷ FETCH (suc zero) ∷ LT ∷ [])
-- (FETCH (suc zero) ∷
-- PUSH 1 ∷
-- ADD ∷
-- STORE (suc zero) ∷
-- FETCH (suc (suc zero)) ∷
-- FETCH (suc zero) ∷ MUL ∷ STORE (suc (suc zero)) ∷ [])
-- ∷ []
-- , nat 1 ∷ [] , 1 ∷ 0 ∷ 1 ∷ [])
-- ∷
-- (FETCH (suc (suc zero)) ∷
-- FETCH (suc zero) ∷
-- MUL ∷
-- STORE (suc (suc zero)) ∷
-- LOOP (FETCH zero ∷ FETCH (suc zero) ∷ LT ∷ [])
-- (FETCH (suc zero) ∷
-- PUSH 1 ∷
-- ADD ∷
-- STORE (suc zero) ∷
-- FETCH (suc (suc zero)) ∷
-- FETCH (suc zero) ∷ MUL ∷ STORE (suc (suc zero)) ∷ [])
-- ∷ []
-- , [] , 1 ∷ 1 ∷ 1 ∷ [])
-- ∷
-- (FETCH (suc zero) ∷
-- MUL ∷
-- STORE (suc (suc zero)) ∷
-- LOOP (FETCH zero ∷ FETCH (suc zero) ∷ LT ∷ [])
-- (FETCH (suc zero) ∷
-- PUSH 1 ∷
-- ADD ∷
-- STORE (suc zero) ∷
-- FETCH (suc (suc zero)) ∷
-- FETCH (suc zero) ∷ MUL ∷ STORE (suc (suc zero)) ∷ [])
-- ∷ []
-- , nat 1 ∷ [] , 1 ∷ 1 ∷ 1 ∷ [])
-- ∷
-- (MUL ∷
-- STORE (suc (suc zero)) ∷
-- LOOP (FETCH zero ∷ FETCH (suc zero) ∷ LT ∷ [])
-- (FETCH (suc zero) ∷
-- PUSH 1 ∷
-- ADD ∷
-- STORE (suc zero) ∷
-- FETCH (suc (suc zero)) ∷
-- FETCH (suc zero) ∷ MUL ∷ STORE (suc (suc zero)) ∷ [])
-- ∷ []
-- , nat 1 ∷ nat 1 ∷ [] , 1 ∷ 1 ∷ 1 ∷ [])
-- ∷
-- (STORE (suc (suc zero)) ∷
-- LOOP (FETCH zero ∷ FETCH (suc zero) ∷ LT ∷ [])
-- (FETCH (suc zero) ∷
-- PUSH 1 ∷
-- ADD ∷
-- STORE (suc zero) ∷
-- FETCH (suc (suc zero)) ∷
-- FETCH (suc zero) ∷ MUL ∷ STORE (suc (suc zero)) ∷ [])
-- ∷ []
-- , nat 1 ∷ [] , 1 ∷ 1 ∷ 1 ∷ [])
-- ∷
-- (LOOP (FETCH zero ∷ FETCH (suc zero) ∷ LT ∷ [])
-- (FETCH (suc zero) ∷
-- PUSH 1 ∷
-- ADD ∷
-- STORE (suc zero) ∷
-- FETCH (suc (suc zero)) ∷
-- FETCH (suc zero) ∷ MUL ∷ STORE (suc (suc zero)) ∷ [])
-- ∷ []
-- , [] , 1 ∷ 1 ∷ 1 ∷ [])
-- ∷
-- (FETCH zero ∷
-- FETCH (suc zero) ∷
-- LT ∷
-- BRANCH
-- (FETCH (suc zero) ∷
-- PUSH 1 ∷
-- ADD ∷
-- STORE (suc zero) ∷
-- FETCH (suc (suc zero)) ∷
-- FETCH (suc zero) ∷
-- MUL ∷
-- STORE (suc (suc zero)) ∷
-- LOOP (FETCH zero ∷ FETCH (suc zero) ∷ LT ∷ [])
-- (FETCH (suc zero) ∷
-- PUSH 1 ∷
-- ADD ∷
-- STORE (suc zero) ∷
-- FETCH (suc (suc zero)) ∷
-- FETCH (suc zero) ∷ MUL ∷ STORE (suc (suc zero)) ∷ [])
-- ∷ [])
-- (NOOP ∷ [])
-- ∷ []
-- , [] , 1 ∷ 1 ∷ 1 ∷ [])
-- ∷
-- (FETCH (suc zero) ∷
-- LT ∷
-- BRANCH
-- (FETCH (suc zero) ∷
-- PUSH 1 ∷
-- ADD ∷
-- STORE (suc zero) ∷
-- FETCH (suc (suc zero)) ∷
-- FETCH (suc zero) ∷
-- MUL ∷
-- STORE (suc (suc zero)) ∷
-- LOOP (FETCH zero ∷ FETCH (suc zero) ∷ LT ∷ [])
-- (FETCH (suc zero) ∷
-- PUSH 1 ∷
-- ADD ∷
-- STORE (suc zero) ∷
-- FETCH (suc (suc zero)) ∷
-- FETCH (suc zero) ∷ MUL ∷ STORE (suc (suc zero)) ∷ [])
-- ∷ [])
-- (NOOP ∷ [])
-- ∷ []
-- , nat 1 ∷ [] , 1 ∷ 1 ∷ 1 ∷ [])
-- ∷
-- (LT ∷
-- BRANCH
-- (FETCH (suc zero) ∷
-- PUSH 1 ∷
-- ADD ∷
-- STORE (suc zero) ∷
-- FETCH (suc (suc zero)) ∷
-- FETCH (suc zero) ∷
-- MUL ∷
-- STORE (suc (suc zero)) ∷
-- LOOP (FETCH zero ∷ FETCH (suc zero) ∷ LT ∷ [])
-- (FETCH (suc zero) ∷
-- PUSH 1 ∷
-- ADD ∷
-- STORE (suc zero) ∷
-- FETCH (suc (suc zero)) ∷
-- FETCH (suc zero) ∷ MUL ∷ STORE (suc (suc zero)) ∷ [])
-- ∷ [])
-- (NOOP ∷ [])
-- ∷ []
-- , nat 1 ∷ nat 1 ∷ [] , 1 ∷ 1 ∷ 1 ∷ [])
-- ∷
-- (BRANCH
-- (FETCH (suc zero) ∷
-- PUSH 1 ∷
-- ADD ∷
-- STORE (suc zero) ∷
-- FETCH (suc (suc zero)) ∷
-- FETCH (suc zero) ∷
-- MUL ∷
-- STORE (suc (suc zero)) ∷
-- LOOP (FETCH zero ∷ FETCH (suc zero) ∷ LT ∷ [])
-- (FETCH (suc zero) ∷
-- PUSH 1 ∷
-- ADD ∷
-- STORE (suc zero) ∷
-- FETCH (suc (suc zero)) ∷
-- FETCH (suc zero) ∷ MUL ∷ STORE (suc (suc zero)) ∷ [])
-- ∷ [])
-- (NOOP ∷ [])
-- ∷ []
-- , bool false ∷ [] , 1 ∷ 1 ∷ 1 ∷ [])
-- ∷
-- (NOOP ∷ [] , [] , 1 ∷ 1 ∷ 1 ∷ []) ∷ ([] , [] , 1 ∷ 1 ∷ 1 ∷ []) ∷ []
| 22.994975
| 70
| 0.442198
|
52b8d95462a20ebd0b6b67ac8e30023cde93173e
| 9,003
|
agda
|
Agda
|
agda/course/2017-conor_mcbride_cs410/CS410-17-master/lectures/Lec3Done.agda
|
haroldcarr/learn-haskell-coq-ml-etc
|
3dc7abca7ad868316bb08f31c77fbba0d3910225
|
[
"Unlicense"
] | 36
|
2015-01-29T14:37:15.000Z
|
2021-07-30T06:55:03.000Z
|
agda/course/2017-conor_mcbride_cs410/CS410-17-master/lectures/Lec3Done.agda
|
haroldcarr/learn-haskell-coq-ml-etc
|
3dc7abca7ad868316bb08f31c77fbba0d3910225
|
[
"Unlicense"
] | null | null | null |
agda/course/2017-conor_mcbride_cs410/CS410-17-master/lectures/Lec3Done.agda
|
haroldcarr/learn-haskell-coq-ml-etc
|
3dc7abca7ad868316bb08f31c77fbba0d3910225
|
[
"Unlicense"
] | 8
|
2015-04-13T21:40:15.000Z
|
2021-09-21T15:58:10.000Z
|
{-# OPTIONS --type-in-type #-} -- yes, there will be some cheating in this lecture
module Lec3Done where
open import Lec1Done
open import Lec2Done
postulate
extensionality : {S : Set}{T : S -> Set}
{f g : (x : S) -> T x} ->
((x : S) -> f x == g x) ->
f == g
imp : {S : Set}{T : S -> Set}(f : (x : S) -> T x){x : S} -> T x
imp f {x} = f x
extensionality' : {S : Set}{T : S -> Set}
{f g : {x : S} -> T x} ->
((x : S) -> f {x} == g {x}) ->
_==_ {forall {x : S} -> T x} f g
extensionality' {f = f}{g = g} q =
refl imp =$= extensionality {f = \ x -> f {x}}{g = \ x -> g {x}}
q
_[QED] : {X : Set}(x : X) -> x == x
x [QED] = refl x
_=[_>=_ : {X : Set}(x : X){y z : X} -> x == y -> y == z -> x == z
x =[ refl .x >= q = q
_=<_]=_ : {X : Set}(x : X){y z : X} -> y == x -> y == z -> x == z
x =< refl .x ]= q = q
infixr 1 _=[_>=_ _=<_]=_
infixr 2 _[QED]
record Category : Set where
field
-- two types of thing
Obj : Set -- "objects"
_~>_ : Obj -> Obj -> Set -- "arrows" or "morphisms"
-- or "homomorphisms"
-- two operations
id~> : {T : Obj} -> T ~> T
_>~>_ : {R S T : Obj} -> R ~> S -> S ~> T -> R ~> T
-- three laws
law-id~>>~> : {S T : Obj} (f : S ~> T) ->
(id~> >~> f) == f
law->~>id~> : {S T : Obj} (f : S ~> T) ->
(f >~> id~>) == f
law->~>>~> : {Q R S T : Obj} (f : Q ~> R)(g : R ~> S)(h : S ~> T) ->
((f >~> g) >~> h) == (f >~> (g >~> h))
assocn : {Q R R' S T : Obj}
{f : Q ~> R} {g : R ~> S}
{f' : Q ~> R'}{g' : R' ~> S}
{h : S ~> T} ->
(f >~> g) == (f' >~> g') ->
(f >~> g >~> h) == (f' >~> g' >~> h)
assocn {f = f} {g = g} {f' = f'} {g' = g'} {h = h} q =
f >~> g >~> h
=< law->~>>~> _ _ _ ]=
(f >~> g) >~> h
=[ refl _>~>_ =$= q =$= refl h >=
(f' >~> g') >~> h
=[ law->~>>~> _ _ _ >=
f' >~> g' >~> h
[QED]
infixr 3 _>~>_
-- Sets and functions are the classic example of a category.
SET : Category
SET = record
{ Obj = Set
; _~>_ = \ S T -> S -> T
; id~> = id
; _>~>_ = _>>_
; law-id~>>~> = \ f -> refl f
; law->~>id~> = \ f -> refl f
; law->~>>~> = \ f g h -> refl (f >> (g >> h))
}
-- A PREORDER is a category where there is at most one arrow between
-- any two objects. (So arrows are unique.)
NAT->= : Category
unique->= : (m n : Nat)(p q : m >= n) -> p == q
unique->= m zero p q = refl <>
unique->= zero (suc n) () q
unique->= (suc m) (suc n) p q = unique->= m n p q
NAT->= = record
{ Obj = Nat
; _~>_ = _>=_
; id~> = \ {n} -> refl->= n
; _>~>_ = \ {m}{n}{p} m>=n n>=p -> trans->= m n p m>=n n>=p
; law-id~>>~> = \ {m}{n} m>=n -> unique->= m n _ _
; law->~>id~> = \ {m}{n} m>=n -> unique->= m n _ _
; law->~>>~> = \ {m}{n}{p}{q} m>n n>=p p>=q -> unique->= m q _ _
} where
-- A MONOID is a category with Obj = One.
-- The values in the monoid are the *arrows*.
ONE-Nat : Category
ONE-Nat = record
{ Obj = One
; _~>_ = \ _ _ -> Nat
; id~> = 0
; _>~>_ = _+N_
; law-id~>>~> = \ n -> zero-+N n
; law->~>id~> = \ n -> +N-zero n
; law->~>>~> = \ m n p -> assocLR-+N m n p
}
eqUnique : {X : Set}{x y : X}(p q : x == y) -> p == q
eqUnique (refl x) (refl .x) = refl (refl x)
-- A DISCRETE category is one where the only arrows are the identities.
DISCRETE : (X : Set) -> Category
DISCRETE X = record
{ Obj = X
; _~>_ = _==_
; id~> = refl _
; _>~>_ = \ { {x} (refl .x) (refl .x) -> refl x }
; law-id~>>~> = \ _ -> eqUnique _ _
; law->~>id~> = \ _ -> eqUnique _ _
; law->~>>~> = \ _ _ _ -> eqUnique _ _
}
module FUNCTOR where
open Category
record _=>_ (C D : Category) : Set where -- "Functor from C to D"
field
-- two actions
F-Obj : Obj C -> Obj D
F-map : {S T : Obj C} -> _~>_ C S T -> _~>_ D (F-Obj S) (F-Obj T)
-- two laws
F-map-id~> : {T : Obj C} -> F-map (id~> C {T}) == id~> D {F-Obj T}
F-map->~> : {R S T : Obj C}(f : _~>_ C R S)(g : _~>_ C S T) ->
F-map (_>~>_ C f g) == _>~>_ D (F-map f) (F-map g)
open FUNCTOR public
postulate homework : {A : Set} -> A
VEC : Nat -> SET => SET
VEC n = record
{ F-Obj = \ X -> Vec X n
; F-map = homework
; F-map-id~> = homework
; F-map->~> = homework
}
VTAKE : Set -> NAT->= => SET
VTAKE X = record
{ F-Obj = Vec X
; F-map = \ {m}{n} m>=n xs -> vTake m n m>=n xs
; F-map-id~> = \ {n} -> extensionality \ xs -> vTakeIdFact n xs
; F-map->~> = \ {m}{n}{p} m>=n n>=p -> extensionality \ xs ->
vTakeCpFact m n p m>=n n>=p xs
}
ADD : Nat -> NAT->= => NAT->=
ADD d = record { F-Obj = (d +N_)
; F-map = \ {m}{n} -> help d m n
; F-map-id~> = \ {n} -> unique->= (d +N n) (d +N n) _ _
; F-map->~> = \ {m}{n}{p} x y ->
unique->= (d +N m) (d +N p) _ _
} where
help : (d m n : Nat) -> m >= n -> (d +N m) >= (d +N n)
help zero m n m>=n = m>=n
help (suc d) m n m>=n = help d m n m>=n
Thing : {C D : Category}(F G : C => D) -> Set
Thing {C}{D}
(record { F-Obj = F-Obj ; F-map = F-map
; F-map-id~> = F-map-id~> ; F-map->~> = F-map->~> })
(record { F-Obj = G-Obj ; F-map = G-map
; F-map-id~> = G-map-id~> ; F-map->~> = G-map->~> })
= Sg (F-Obj == G-Obj)
\ { (refl _) ->
Sg (_==_ {forall {S T : Category.Obj C} →
(C Category.~> S) T → (D Category.~> F-Obj S) (F-Obj T)}
F-map G-map)
\ { (refl _) ->
_==_ {forall {T : Category.Obj C} →
F-map (Category.id~> C {T}) == Category.id~> D} F-map-id~> G-map-id~>
*
_==_ {forall {R S T : Category.Obj C} (f : (C Category.~> R) S)
(g : (C Category.~> S) T) →
F-map ((C Category.>~> f) g) == (D Category.>~> F-map f) (F-map g)}
F-map->~> G-map->~>
}}
Lemma : {C D : Category}{F G : C => D} -> Thing F G -> F == G
Lemma (refl _ , (refl _ , (refl _ , refl _))) = refl _
CATEGORY : Category
CATEGORY = record
{ Obj = Category
; _~>_ = _=>_
; id~> = record { F-Obj = \ X -> X
; F-map = \ a -> a
; F-map-id~> = refl _
; F-map->~> = \ _ _ -> refl _ }
; _>~>_ = \ {R}{S}{T} F G -> record
{ F-Obj = F-Obj F >> F-Obj G
; F-map = F-map F >> F-map G
; F-map-id~> = F-map G (F-map F (Category.id~> R))
=[ refl (F-map G) =$= F-map-id~> F >=
F-map G (Category.id~> S)
=[ F-map-id~> G >=
Category.id~> T
[QED]
; F-map->~> = \ f g ->
F-map G (F-map F (Category._>~>_ R f g))
=[ refl (F-map G) =$= F-map->~> F f g >=
F-map G (Category._>~>_ S (F-map F f) (F-map F g))
=[ F-map->~> G (F-map F f) (F-map F g) >=
Category._>~>_ T (F-map G (F-map F f))
(F-map G (F-map F g))
[QED]
}
; law-id~>>~> = \ F -> Lemma
((refl _) , ((refl _) ,
(extensionality' (\ x -> eqUnique _ _) ,
extensionality' (\ x ->
extensionality' \ y -> extensionality' \ z ->
extensionality \ f -> extensionality \ g ->
eqUnique _ _))))
; law->~>id~> = \ F -> Lemma
((refl _) , ((refl _) ,
(extensionality' (\ x -> eqUnique _ _) ,
extensionality' (\ x ->
extensionality' \ y -> extensionality' \ z ->
extensionality \ f -> extensionality \ g ->
eqUnique _ _))))
; law->~>>~> = \ F G H -> Lemma
((refl _) , ((refl _) ,
(extensionality' (\ x -> eqUnique _ _) ,
extensionality' (\ x ->
extensionality' \ y -> extensionality' \ z ->
extensionality \ f -> extensionality \ g ->
eqUnique _ _))))
} where
open _=>_
| 35.868526
| 83
| 0.354882
|
3882806bb942ef9e458bb9b2e1a5e36ae05aef44
| 5,247
|
agda
|
Agda
|
test/Succeed/Issue473-1606.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
test/Succeed/Issue473-1606.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
test/Succeed/Issue473-1606.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
-- Andreas, 2015-07-07 continuation of issue 665
-- Jesper, 2015-12-18 some of these don't work anymore with the new unifier,
-- but a few others that weren't accepted are now.
{-# OPTIONS --show-implicit #-}
-- {-# OPTIONS -v tc.with.strip:10 #-}
-- {-# OPTIONS -v tc.with.strip:60 -v tc.lhs:20 -v tc.lhs.unify:20 #-}
postulate
C : Set
anything : C
record I : Set where
constructor c
field
{f} : C
data Wrap : (i : I) → Set where
wrap : ∀ {i} → Wrap i
-- Test 0: first argument not given
test0 : ∀ {j} → Wrap j → C
test0 wrap with anything
test0 wrap | z = z
test0a : ∀ {j} → Wrap j → C
test0a (wrap {c {x}}) with anything
test0a wrap | z = z
test0b : ∀ {j} → Wrap j → C
test0b (wrap {c {_}}) with anything
test0b wrap | z = z
test0c : ∀ {j} → Wrap j → C
test0c (wrap {c}) with anything
test0c wrap | z = z
test0d : ∀ {j} → Wrap j → C
test0d (wrap {c {._}}) with anything
test0d wrap | z = z
test0e : ∀ {j} → Wrap j → C
test0e (wrap .{c}) with anything
test0e wrap | z = z
test0f : ∀ {j} → Wrap j → C
test0f (wrap .{c {_}}) with anything
test0f wrap | z = z
test00 : ∀ {j} → Wrap j → C
test00 wrap with anything
test00 {.c} wrap | z = z
test00a : ∀ {j} → Wrap j → C
test00a (wrap {c {x}}) with anything
test00a {.c} wrap | z = z
test00b : ∀ {j} → Wrap j → C
test00b (wrap {c {_}}) with anything
test00b {.c} wrap | z = z
test00c : ∀ {j} → Wrap j → C
test00c (wrap {c}) with anything
test00c {.c} wrap | z = z
test00d : ∀ {j} → Wrap j → C
test00d (wrap {c {._}}) with anything
test00d {.c} wrap | z = z
test00e : ∀ {j} → Wrap j → C
test00e (wrap .{c}) with anything
test00e {.c} wrap | z = z
test00f : ∀ {j} → Wrap j → C
test00f (wrap .{c {_}}) with anything
test00f {.c} wrap | z = z
test000 : ∀ {j} → Wrap j → C
test000 wrap with anything
test000 .{c {_}} wrap | z = z
test000a : ∀ {j} → Wrap j → C
test000a (wrap {c {x}}) with anything
test000a .{c {_}} wrap | z = z
test000b : ∀ {j} → Wrap j → C
test000b (wrap {c {_}}) with anything
test000b .{c {_}} wrap | z = z
test000c : ∀ {j} → Wrap j → C
test000c (wrap {c}) with anything
test000c .{c {_}} wrap | z = z
test000d : ∀ {j} → Wrap j → C
test000d (wrap {c {._}}) with anything
test000d .{c {_}} wrap | z = z
test000e : ∀ {j} → Wrap j → C
test000e (wrap .{c}) with anything
test000e .{c {_}} wrap | z = z
test000f : ∀ {j} → Wrap j → C
test000f (wrap .{c {_}}) with anything
test000f .{c {_}} wrap | z = z
-- Test 1: first argument is dot pattern
test1a : ∀ {j} → Wrap j → C
test1a .{c} (wrap {c {x}}) with anything
test1a .{c} wrap | z = z
test1b : ∀ {j} → Wrap j → C
test1b .{c} (wrap {c {_}}) with anything
test1b .{c} wrap | z = z
test1c : ∀ {j} → Wrap j → C
test1c .{c} (wrap {c}) with anything
test1c .{c} wrap | z = z
test11a : ∀ {j} → Wrap j → C
test11a .{c} (wrap {c {x}}) with anything
test11a wrap | z = z
test11b : ∀ {j} → Wrap j → C
test11b .{c} (wrap {c {_}}) with anything
test11b wrap | z = z
test11c : ∀ {j} → Wrap j → C
test11c .{c} (wrap {c}) with anything
test11c wrap | z = z
test111a : ∀ {j} → Wrap j → C
test111a (wrap {c {x}}) with anything
test111a .{c} wrap | z = z
test111b : ∀ {j} → Wrap j → C
test111b (wrap {c {_}}) with anything
test111b .{c} wrap | z = z
test111c : ∀ {j} → Wrap j → C
test111c (wrap {c}) with anything
test111c .{c} wrap | z = z
-- Test 2: First argument is record pattern
test2a : ∀ {j} → Wrap j → C
test2a {c} wrap with anything
test2a {c} wrap | z = z
test2b : ∀ {j} → Wrap j → C
test2b {c} wrap with anything
test2b wrap | z = z
test2c : ∀ {j} → Wrap j → C
test2c {c} (wrap {c}) with anything
test2c {c} wrap | z = z
test2d : ∀ {j} → Wrap j → C
test2d {c} (wrap {c}) with anything
test2d wrap | z = z
test2e : ∀ {j} → Wrap j → C
test2e {c} (wrap {c {._}}) with anything
test2e {c} wrap | z = z
test2f : ∀ {j} → Wrap j → C
test2f {c} (wrap {c {._}}) with anything
test2f wrap | z = z
test2g : ∀ {j} → Wrap j → C
test2g {c} (wrap {c {x}}) with anything
test2g {c} wrap | z = z
test2h : ∀ {j} → Wrap j → C
test2h {c} (wrap {c {x}}) with anything
test2h wrap | z = z
test2i : ∀ {j} → Wrap j → C
test2i {c} (wrap {c {_}}) with anything
test2i {c} wrap | z = z
test2j : ∀ {j} → Wrap j → C
test2j {c} (wrap {c {_}}) with anything
test2j wrap | z = z
-- Test 3: First argument is record of dot pattern, second is record pattern
test3a : ∀ {j} → Wrap j → C
test3a {c {._}} wrap with anything
test3a {c {._}} wrap | z = z
test3b : ∀ {j} → Wrap j → C
test3b {c {._}} wrap with anything
test3b wrap | z = z
test3c : ∀ {j} → Wrap j → C
test3c {c {._}} (wrap {c}) with anything
test3c {c {._}} wrap | z = z
test3d : ∀ {j} → Wrap j → C
test3d {c {._}} (wrap {c}) with anything
test3d wrap | z = z
test3e : ∀ {j} → Wrap j → C
test3e {c {._}} (wrap {c {._}}) with anything
test3e {c {._}} wrap | z = z
test3f : ∀ {j} → Wrap j → C
test3f {c {._}} (wrap {c {._}}) with anything
test3f wrap | z = z
test3g : ∀ {j} → Wrap j → C
test3g {c {_}} (wrap {c {x}}) with anything
test3g {c {_}} wrap | z = z
test3h : ∀ {j} → Wrap j → C
test3h {c {_}} (wrap {c {x}}) with anything
test3h wrap | z = z
test3i : ∀ {j} → Wrap j → C
test3i {c {_}} (wrap {c {_}}) with anything
test3i {c {_}} wrap | z = z
test3j : ∀ {j} → Wrap j → C
test3j {c {_}} (wrap {c {_}}) with anything
test3j wrap | z = z
| 22.912664
| 76
| 0.576901
|
a0a80d4c38e4c530002c79fecb49a38f6be09432
| 9,532
|
agda
|
Agda
|
theorems/homotopy/Pi2HSuspCompose.agda
|
AntoineAllioux/HoTT-Agda
|
1037d82edcf29b620677a311dcfd4fc2ade2faa6
|
[
"MIT"
] | 294
|
2015-01-09T16:23:23.000Z
|
2022-03-20T13:54:45.000Z
|
theorems/homotopy/Pi2HSuspCompose.agda
|
AntoineAllioux/HoTT-Agda
|
1037d82edcf29b620677a311dcfd4fc2ade2faa6
|
[
"MIT"
] | 31
|
2015-03-05T20:09:00.000Z
|
2021-10-03T19:15:25.000Z
|
theorems/homotopy/Pi2HSuspCompose.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 homotopy.HSpace renaming (HSpaceStructure to HSS)
open import homotopy.Pi2HSusp
open import homotopy.WedgeExtension
open import lib.types.TwoSemiCategory
open import lib.two-semi-categories.FundamentalCategory
module homotopy.Pi2HSuspCompose {i} {X : Ptd i} {{_ : has-level 1 (de⊙ X)}}
{{is-0-connected : is-connected 0 (de⊙ X)}} (H-X : HSS X)
(H-X-assoc : associator H-X)
(coh-assoc-unit-l-r-pentagon : coh-unit-l-r-pentagon H-X H-X-assoc)
where
private
A = de⊙ X
e = pt X
open Pi2HSusp H-X public
infixr 80 _∙₁_
_∙₁_ : {x y z : Susp A} → Trunc 1 (x == y) → Trunc 1 (y == z) → Trunc 1 (x == z)
_∙₁_ {x} {y} {z} p q = _∙ₜ_ {A = Susp A} {ta = [ x ]} {tb = [ y ]} {tc = [ z ]} p q
module _ {k} {B : Type k} where
add-path-inverse-l : {x y z : B}
→ (p : x == y) (q : x == z)
→ p == (q ∙ ! q) ∙ p
add-path-inverse-l p q = ap (_∙ p) (! (!-inv-r q))
add-path-inverse-r : {x y z : B}
→ (p : x == y) (r : y == z)
→ p == p ∙ (r ∙ ! r)
add-path-inverse-r p r =
! (∙-unit-r p) ∙ ap (p ∙_) (! (!-inv-r r))
abstract
add-path-inverse-coh : {x y : B} (p : x == x) (q : x == y)
→ add-path-inverse-r p q ◃∙
ap (_∙ (q ∙ ! q)) (add-path-inverse-l p q) ◃∙
∙-assoc (q ∙ ! q) p (q ∙ ! q) ◃∎
=ₛ
add-path-inverse-l p q ◃∙
ap ((q ∙ ! q) ∙_) (add-path-inverse-r p q) ◃∎
add-path-inverse-coh p idp =
add-path-inverse-r p idp ◃∙
idp ◃∙
idp ◃∎
=ₛ⟨ 1 & 1 & expand [] ⟩
add-path-inverse-r p idp ◃∙
idp ◃∎
=ₛ⟨ 1 & 1 & expand [] ⟩
add-path-inverse-r p idp ◃∎
=ₛ₁⟨ ! (ap-idf (add-path-inverse-r p idp)) ⟩
ap (λ q → q) (add-path-inverse-r p idp) ◃∎
=ₛ⟨ 0 & 0 & contract ⟩
add-path-inverse-l p idp ◃∙
ap (λ q → q) (add-path-inverse-r p idp) ◃∎ ∎ₛ
comp-l-seq : (a' : A) → η (μ e a') =-= η e ∙ η a'
comp-l-seq a' =
η (μ e a')
=⟪ ap η (μ.unit-l a') ⟫
η a'
=⟪ add-path-inverse-l (η a') (merid e) ⟫
η e ∙ η a' ∎∎
comp-l : (a' : A) → η (μ e a') == η e ∙ η a'
comp-l a' = ↯ (comp-l-seq a')
comp-r-seq : (a : A) → η (μ a e) =-= η a ∙ η e
comp-r-seq a =
η (μ a e)
=⟪ ap η (μ.unit-r a) ⟫
η a
=⟪ add-path-inverse-r (η a) (merid e) ⟫
η a ∙ η e ∎∎
comp-r : (a : A) → η (μ a e) == η a ∙ η e
comp-r a = ↯ (comp-r-seq a)
comp-lr-coh : comp-l e == comp-r e
comp-lr-coh =
ap2 (λ p₁ p₂ → ap η p₁ ∙ p₂)
μ.coh
(add-path-inverse-lr-coh (merid e))
where
add-path-inverse-lr-coh : {B : Type i} {b b' : B} (p : b == b')
→ add-path-inverse-l (p ∙ ! p) p == add-path-inverse-r (p ∙ ! p) p
add-path-inverse-lr-coh idp = idp
comp-l₁ : (a' : A) → [ η (μ e a') ]₁ == [ η e ∙ η a' ]₁
comp-l₁ = ap [_]₁ ∘ comp-l
comp-r₁ : (a : A) → [ η (μ a e) ]₁ == [ η a ∙ η e ]₁
comp-r₁ = ap [_]₁ ∘ comp-r
comp-args : args {i} {i} {A} {e} {A} {e}
comp-args =
record {
m = -1; n = -1;
P = λ a a' → (Q a a' , ⟨⟩);
f = comp-r₁;
g = comp-l₁;
p = ap (ap [_]₁) (! comp-lr-coh)
}
where
Q : A → A → Type i
Q a a' = [ η (μ a a' ) ]₁ == [ η a ∙ η a' ]₁
module Comp = WedgeExt {i} {i} {A} {e} {A} {e} comp-args
comp : (a a' : A) → [ η (μ a a') ]₁ == [ η a ]₁ ∙₁ [ η a' ]₁
comp = Comp.ext
comp-unit-l : (a' : A) → comp e a' == comp-l₁ a'
comp-unit-l a' = Comp.β-r a'
comp-unit-r : (a : A) → comp a e == comp-r₁ a
comp-unit-r a = Comp.β-l a
module CoherenceProof (a' : A) where
P : A → A → Type i
P a a'' =
comp (μ a a') a'' ◃∙
ap (_∙₁ [ η a'' ]₁) (comp a a') ◃∙
ap [_]₁ (∙-assoc (η a) (η a') (η a'')) ◃∎
=ₛ
ap ([_]₁ ∘ η) (H-X-assoc a a' a'') ◃∙
comp a (μ a' a'') ◃∙
ap ([ η a ]₁ ∙₁_) (comp a' a'') ◃∎
P-is-prop : ∀ a a'' → is-prop (P a a'')
P-is-prop a a'' = =ₛ-level (Trunc-level {n = 1})
Q : A → A → hProp i
Q a a'' = P a a'' , P-is-prop a a''
inner-coh :
comp-r (μ e a') ◃∙
ap (_∙ η e) (comp-l a') ◃∙
∙-assoc (η e) (η a') (η e) ◃∎
=ₛ
ap η (H-X-assoc e a' e) ◃∙
comp-l (μ a' e) ◃∙
ap (η e ∙_) (comp-r a') ◃∎
inner-coh =
comp-r (μ e a') ◃∙
ap (_∙ η e) (comp-l a') ◃∙
∙-assoc (η e) (η a') (η e) ◃∎
=ₛ⟨ 0 & 1 & expand (comp-r-seq (μ e a')) ⟩
ap η (μ.unit-r (μ e a')) ◃∙
add-path-inverse-r (η (μ e a')) (merid e) ◃∙
ap (_∙ η e) (comp-l a') ◃∙
∙-assoc (η e) (η a') (η e) ◃∎
=ₛ⟨ 2 & 1 & ap-seq-∙ (_∙ η e) (comp-l-seq a') ⟩
ap η (μ.unit-r (μ e a')) ◃∙
add-path-inverse-r (η (μ e a')) (merid e) ◃∙
ap (_∙ η e) (ap η (μ.unit-l a')) ◃∙
ap (_∙ η e) (add-path-inverse-l (η a') (merid e)) ◃∙
∙-assoc (η e) (η a') (η e) ◃∎
=ₛ⟨ 1 & 2 & !ₛ $
homotopy-naturality-from-idf (_∙ η e)
(λ r → add-path-inverse-r r (merid e))
(ap η (μ.unit-l a')) ⟩
ap η (μ.unit-r (μ e a')) ◃∙
ap η (μ.unit-l a') ◃∙
add-path-inverse-r (η a') (merid e) ◃∙
ap (_∙ η e) (add-path-inverse-l (η a') (merid e)) ◃∙
∙-assoc (η e) (η a') (η e) ◃∎
=ₛ⟨ 2 & 3 & add-path-inverse-coh (η a') (merid e) ⟩
ap η (μ.unit-r (μ e a')) ◃∙
ap η (μ.unit-l a') ◃∙
add-path-inverse-l (η a') (merid e) ◃∙
ap (η e ∙_) (add-path-inverse-r (η a') (merid e)) ◃∎
=ₛ⟨ 0 & 2 & ap-seq-=ₛ η (coh-assoc-unit-l-r-pentagon a') ⟩
ap η (H-X-assoc e a' e) ◃∙
ap η (μ.unit-l (μ a' e)) ◃∙
ap η (μ.unit-r a') ◃∙
add-path-inverse-l (η a') (merid e) ◃∙
ap (η e ∙_) (add-path-inverse-r (η a') (merid e)) ◃∎
=ₛ⟨ 2 & 2 &
homotopy-naturality-from-idf (η e ∙_)
(λ v → add-path-inverse-l v (merid e))
(ap η (μ.unit-r a')) ⟩
ap η (H-X-assoc e a' e) ◃∙
ap η (μ.unit-l (μ a' e)) ◃∙
add-path-inverse-l (η (μ a' e)) (merid e) ◃∙
ap (η e ∙_) (ap η (μ.unit-r a')) ◃∙
ap (η e ∙_) (add-path-inverse-r (η a') (merid e)) ◃∎
=ₛ⟨ 3 & 2 & ∙-ap-seq (η e ∙_) (comp-r-seq a')⟩
ap η (H-X-assoc e a' e) ◃∙
ap η (μ.unit-l (μ a' e)) ◃∙
add-path-inverse-l (η (μ a' e)) (merid e) ◃∙
ap (η e ∙_) (comp-r a') ◃∎
=ₛ⟨ 1 & 2 & contract ⟩
ap η (H-X-assoc e a' e) ◃∙
comp-l (μ a' e) ◃∙
ap (η e ∙_) (comp-r a') ◃∎ ∎ₛ
coh : P e e
coh =
comp (μ e a') e ◃∙
ap (_∙₁ [ η e ]₁) (comp e a') ◃∙
ap [_]₁ (∙-assoc (η e) (η a') (η e)) ◃∎
=ₛ₁⟨ 0 & 1 & comp-unit-r (μ e a') ⟩
comp-r₁ (μ e a') ◃∙
ap (_∙₁ [ η e ]₁) (comp e a') ◃∙
ap [_]₁ (∙-assoc (η e) (η a') (η e)) ◃∎
=ₛ₁⟨ 1 & 1 & step₂ ⟩
comp-r₁ (μ e a') ◃∙
ap [_]₁ (ap (_∙ η e) (comp-l a')) ◃∙
ap [_]₁ (∙-assoc (η e) (η a') (η e)) ◃∎
=ₛ⟨ 0 & 3 & ap-seq-=ₛ [_]₁ inner-coh ⟩
ap [_]₁ (ap η (H-X-assoc e a' e)) ◃∙
comp-l₁ (μ a' e) ◃∙
ap [_]₁ (ap (η e ∙_) (comp-r a')) ◃∎
=ₛ₁⟨ 0 & 1 & ∘-ap [_]₁ η (H-X-assoc e a' e) ⟩
ap ([_]₁ ∘ η) (H-X-assoc e a' e) ◃∙
comp-l₁ (μ a' e) ◃∙
ap [_]₁ (ap (η e ∙_) (comp-r a')) ◃∎
=ₛ₁⟨ 1 & 1 & ! (comp-unit-l (μ a' e)) ⟩
ap ([_]₁ ∘ η) (H-X-assoc e a' e) ◃∙
comp e (μ a' e) ◃∙
ap [_]₁ (ap (η e ∙_) (comp-r a')) ◃∎
=ₛ₁⟨ 2 & 1 & step₈ ⟩
ap ([_]₁ ∘ η) (H-X-assoc e a' e) ◃∙
comp e (μ a' e) ◃∙
ap ([ η e ]₁ ∙₁_) (comp a' e) ◃∎ ∎ₛ
where
step₂ : ap (_∙₁ [ η e ]₁) (comp e a') == ap [_]₁ (ap (_∙ η e) (comp-l a'))
step₂ =
ap (_∙₁ [ η e ]₁) (comp e a')
=⟨ ap (ap (_∙₁ [ η e ]₁)) (comp-unit-l a') ⟩
ap (_∙₁ [ η e ]₁) (comp-l₁ a')
=⟨ ∘-ap (_∙₁ [ η e ]₁) [_]₁ (comp-l a') ⟩
ap ([_]₁ ∘ (_∙ η e)) (comp-l a')
=⟨ ap-∘ [_]₁ (_∙ η e) (comp-l a') ⟩
ap [_]₁ (ap (_∙ η e) (comp-l a')) =∎
step₈ : ap [_]₁ (ap (η e ∙_) (comp-r a')) == ap ([ η e ]₁ ∙₁_) (comp a' e)
step₈ =
ap [_]₁ (ap (η e ∙_) (comp-r a'))
=⟨ ∘-ap [_]₁ (η e ∙_) (comp-r a') ⟩
ap (λ v → [ η e ∙ v ]₁) (comp-r a')
=⟨ ap-∘ ([ η e ]₁ ∙₁_) [_]₁ (comp-r a') ⟩
ap ([ η e ]₁ ∙₁_) (comp-r₁ a')
=⟨ ! (ap (ap ([ η e ]₁ ∙₁_)) (comp-unit-r a')) ⟩
ap ([ η e ]₁ ∙₁_) (comp a' e) =∎
abstract
comp-coh : (a a' a'' : A)
→ comp (μ a a') a'' ◃∙
ap (λ v → v ∙₁ [ η a'' ]₁) (comp a a') ◃∙
ap [_]₁ (∙-assoc (η a) (η a') (η a'')) ◃∎
=ₛ
ap ([_]₁ ∘ η) (H-X-assoc a a' a'') ◃∙
comp a (μ a' a'') ◃∙
ap (λ v → [ η a ] ∙₁ v) (comp a' a'') ◃∎
comp-coh a a' a'' =
prop-over-connected {A = A} {a = e} {{is-0-connected}}
(λ a → CoherenceProof.Q a' a a'')
(prop-over-connected {A = A} {a = e} {{is-0-connected}}
(λ a'' → CoherenceProof.Q a' e a'')
(CoherenceProof.coh a')
a'')
a
comp-functor : (pentagon : coh-assoc-pentagon H-X H-X-assoc)
→ TwoSemiFunctor
(HSpace-2-semi-category H-X {{⟨⟩}} H-X-assoc pentagon)
(=ₜ-fundamental-cat (Susp (de⊙ X)))
comp-functor _ =
record
{ F₀ = λ _ → [ north ]
; F₁ = λ x → [ η x ]
; pres-comp = comp
; pres-comp-coh = comp-coh
}
| 33.801418
| 85
| 0.402014
|
8bf2952c7fdf2de79c4a0ba3844fe0f455a88335
| 2,883
|
agda
|
Agda
|
src/MJ/Syntax/Scoped.agda
|
metaborg/mj.agda
|
0c096fea1716d714db0ff204ef2a9450b7a816df
|
[
"Apache-2.0"
] | 10
|
2017-11-17T17:10:36.000Z
|
2021-09-24T08:02:33.000Z
|
src/MJ/Syntax/Scoped.agda
|
metaborg/mj.agda
|
0c096fea1716d714db0ff204ef2a9450b7a816df
|
[
"Apache-2.0"
] | 1
|
2019-01-13T13:03:47.000Z
|
2020-10-14T13:41:58.000Z
|
src/MJ/Syntax/Scoped.agda
|
metaborg/mj.agda
|
0c096fea1716d714db0ff204ef2a9450b7a816df
|
[
"Apache-2.0"
] | 1
|
2021-12-28T17:38:05.000Z
|
2021-12-28T17:38:05.000Z
|
module MJ.Syntax.Scoped where
open import Prelude
open import Data.Maybe as Maybe using (Maybe; just)
open import Data.Maybe.All as MayAll
open import Data.Vec as Vec hiding (_∈_)
open import Data.Star.Indexed
open import Data.List
open import Data.List.Properties.Extra
open import Data.List.Prefix
open import Data.List.Any
open import Data.List.All as List∀ hiding (lookup)
open import Data.List.All.Properties.Extra
open import Relation.Binary.PropositionalEquality
import Data.Vec.All as Vec∀
open Membership-≡
open import MJ.Types
NativeBinOp = ℕ → ℕ → ℕ
data Expr {n : ℕ} (Γ : Ctx c n) : Ty c → Set where
new : (C : Fin c) → All (Expr Γ) (Class.constr (clookup C)) → Expr Γ (ref C)
unit : Expr Γ void
num : ℕ → Expr Γ int
iop : NativeBinOp → (l r : Expr Γ int) → Expr Γ int
call : ∀ {cid as b} →
Expr Γ (ref cid) → Member Σ cid MTH (as , b) → All (Expr Γ) as →
Expr Γ b
var : (i : Fin n) → Expr Γ (lookup i Γ)
get : ∀ {cid ty} → Expr Γ (ref cid) → Member Σ cid FLD ty → Expr Γ ty
upcast : ∀ {c c'} → Σ ⊢ c <: c' → Expr Γ (ref c) → Expr Γ (ref c')
data Cmd {n}(I : Ctx c n)(r : Ty c) : ∀ {m} → (O : Ctx c m) → Set where
loc : ∀ a → Expr I a → Cmd I r (a ∷ I)
asgn : ∀ (i : Fin n) → Expr I (lookup i I) → Cmd I r I
set : ∀ {C a} → Expr I (ref C) →
Member Σ C FLD a → Expr I a → Cmd I r I
do : ∀ {a} → Expr I a → Cmd I r I
ret : Expr I r → Cmd I r I
Stmts : ∀ {n m}→ (Ctx c n) → Ty c → (Ctx c m) → Set
Stmts I r O = Star ℕ (λ n m (I : Ctx c n) (O : Ctx c m) → Cmd I r O) I O
data Body {n}(I : Ctx c n) : Ty c → Set where
body : ∀ {m r}{O : Ctx c m} → Stmts I r O → Expr O r → Body I r
-- mapping of namespace typings to the type of their implementation
Def : ∀ {ns} → Fin c → typing ns c → Set
-- methods have bodies
Def {MTH} C (as , b) = Body (ref C ∷ (fromList as)) b
-- fields have initializers
Def {FLD} C a = Body (fromList (Class.constr (clookup C))) a
record Implementation (cid : Fin c) : Set where
constructor impl
open Class (clookup cid) public
field
-- mapping construct arguments to super constructor arguments
super-args :
Maybe.All
(λ p → All (Expr (fromList constr)) (Class.constr (clookup p)))
parent
-- definitions for all local members
defs : ∀ ns → All (Def cid) (decls ns)
-- implementation of a classtable
record Impl : Set where
field
bodies : ∀ (cid : Fin c) → Implementation cid
-- get member definition from a class
getDef : ∀ {ns ty}→ (cid : Fin c) → (m : Member Σ cid ns ty) → Impl → Def (proj₁ m) ty
getDef {ns = ns} cid (_ , refl , def) I with clookup cid | inspect clookup cid
... | C@(class parent constr decls) | [ refl ] with Impl.bodies I cid
... | impl _ defs = ∈-all def (defs ns)
getDef cid (P' , super {pid = pid} p P<:P' , def) I = getDef pid (P' , P<:P' , def) I
Prog : Ty c → Set
Prog a = Impl × (Body [] a)
| 34.73494
| 86
| 0.610128
|
034e4c86817c034e57fbeaab49991c282c3212b9
| 183
|
agda
|
Agda
|
nat.agda
|
uedatakumi/nat
|
2f064f660d6f3ce5fc3e5b05e8f096fa4b26c717
|
[
"MIT"
] | 1
|
2021-06-02T15:31:17.000Z
|
2021-06-02T15:31:17.000Z
|
nat.agda
|
uedatakumi/nat
|
2f064f660d6f3ce5fc3e5b05e8f096fa4b26c717
|
[
"MIT"
] | null | null | null |
nat.agda
|
uedatakumi/nat
|
2f064f660d6f3ce5fc3e5b05e8f096fa4b26c717
|
[
"MIT"
] | null | null | null |
module nat where
data N : Set where
zero : N
suc : N -> N
_+_ : N -> N -> N
n + zero = n
n + (suc m) = suc (n + m)
_*_ : N -> N -> N
n * zero = zero
n * (suc m) = (m * n) + m
| 13.071429
| 25
| 0.437158
|
5e010c641fd706c74a3a17992f815cb5aaf6c889
| 2,854
|
agda
|
Agda
|
theorems/cw/cohomology/ReconstructedCochainsIsoCellularCochains.agda
|
mikeshulman/HoTT-Agda
|
e7d663b63d89f380ab772ecb8d51c38c26952dbb
|
[
"MIT"
] | null | null | null |
theorems/cw/cohomology/ReconstructedCochainsIsoCellularCochains.agda
|
mikeshulman/HoTT-Agda
|
e7d663b63d89f380ab772ecb8d51c38c26952dbb
|
[
"MIT"
] | null | null | null |
theorems/cw/cohomology/ReconstructedCochainsIsoCellularCochains.agda
|
mikeshulman/HoTT-Agda
|
e7d663b63d89f380ab772ecb8d51c38c26952dbb
|
[
"MIT"
] | 1
|
2018-12-26T21:31:57.000Z
|
2018-12-26T21:31:57.000Z
|
{-# OPTIONS --without-K --rewriting #-}
open import HoTT
open import cw.CW
open import homotopy.DisjointlyPointedSet
open import cohomology.Theory
open import cohomology.ChainComplex
module cw.cohomology.ReconstructedCochainsIsoCellularCochains {i : ULevel}
(OT : OrdinaryTheory i) where
open OrdinaryTheory OT
open import cw.cohomology.CellularChainComplex as CCC
open import cw.cohomology.ReconstructedCochainComplex OT as RCC
open import cw.cohomology.TipAndAugment OT
open import cw.cohomology.WedgeOfCells OT
private
rcc-iso-ccc-nth : ∀ {n} (⊙skel : ⊙Skeleton n) {m} (m≤n : m ≤ n)
→ ⊙has-cells-with-choice 0 ⊙skel i
→ AbGroup.grp (RCC.cochain-template ⊙skel (inl m≤n))
≃ᴳ hom-group (AbGroup.grp (CCC.chain-template (⊙Skeleton.skel ⊙skel) (inl m≤n))) (C2-abgroup 0)
rcc-iso-ccc-nth ⊙skel {m = O} (inl idp) ac
= FreeAbGroup-extend-iso (C2-abgroup 0)
∘eᴳ Πᴳ-emap-l (λ _ → C2 0) (separable-unite-equiv (⊙Skeleton.pt-dec ⊙skel))
∘eᴳ Πᴳ₁-⊔-iso-×ᴳ {A = Unit} {B = MinusPoint (⊙cw-head ⊙skel)} (λ _ → C2 0) ⁻¹ᴳ
∘eᴳ ×ᴳ-emap (Πᴳ₁-Unit ⁻¹ᴳ) (CX₀-β ⊙skel 0 ac)
rcc-iso-ccc-nth ⊙skel {m = S m} (inl idp) ac
= FreeAbGroup-extend-iso (C2-abgroup 0)
∘eᴳ CXₙ/Xₙ₋₁-β-diag ⊙skel ac
rcc-iso-ccc-nth ⊙skel {m = O} (inr ltS) ac =
rcc-iso-ccc-nth (⊙cw-init ⊙skel) (inl idp) (⊙init-has-cells-with-choice ⊙skel ac)
rcc-iso-ccc-nth ⊙skel {m = S m} (inr ltS) ac =
rcc-iso-ccc-nth (⊙cw-init ⊙skel) (inl idp) (⊙init-has-cells-with-choice ⊙skel ac)
rcc-iso-ccc-nth ⊙skel {m = O} (inr (ltSR lt)) ac =
rcc-iso-ccc-nth (⊙cw-init ⊙skel) (inr lt) (⊙init-has-cells-with-choice ⊙skel ac)
rcc-iso-ccc-nth ⊙skel {m = S m} (inr (ltSR lt)) ac =
rcc-iso-ccc-nth (⊙cw-init ⊙skel) (inr lt) (⊙init-has-cells-with-choice ⊙skel ac)
rcc-iso-ccc-above : ∀ {n} (⊙skel : ⊙Skeleton n) {m} (m≰n : ¬ (m ≤ n))
→ AbGroup.grp (RCC.cochain-template ⊙skel (inr m≰n))
≃ᴳ hom-group (AbGroup.grp (CCC.chain-template (⊙Skeleton.skel ⊙skel) (inr m≰n))) (C2-abgroup 0)
rcc-iso-ccc-above ⊙skel _
= pre∘ᴳ-iso (C2-abgroup 0) lower-iso
∘eᴳ trivial-iso-Unit (hom₁-Unit-is-trivial (C2-abgroup 0)) ⁻¹ᴳ
∘eᴳ lower-iso
rcc-iso-ccc : ∀ {n} (⊙skel : ⊙Skeleton n) (m : ℕ)
→ ⊙has-cells-with-choice 0 ⊙skel i
→ AbGroup.grp (RCC.cochain-template ⊙skel (≤-dec m n))
≃ᴳ hom-group (AbGroup.grp (CCC.chain-template (⊙Skeleton.skel ⊙skel) (≤-dec m n))) (C2-abgroup 0)
rcc-iso-ccc {n} ⊙skel m ac with ≤-dec m n
rcc-iso-ccc ⊙skel m ac | inl m≤n = rcc-iso-ccc-nth ⊙skel m≤n ac
rcc-iso-ccc ⊙skel m ac | inr m≰n = rcc-iso-ccc-above ⊙skel m≰n
rhead-iso-chead : C2 0 ≃ᴳ hom-group ℤ-group (C2-abgroup 0)
rhead-iso-chead
= pre∘ᴳ-iso (C2-abgroup 0) ℤ-iso-FreeAbGroup-Unit
∘eᴳ FreeAbGroup-extend-iso (C2-abgroup 0)
∘eᴳ Πᴳ₁-Unit ⁻¹ᴳ
| 46.786885
| 101
| 0.633847
|
a01b1db1be2ee3247e091a328dfe1325ac0c0f68
| 3,385
|
agda
|
Agda
|
Cubical/HITs/Ints/DiffInt/Base.agda
|
maxdore/cubical
|
ef62b84397396d48135d73ba7400b71c721ddc94
|
[
"MIT"
] | null | null | null |
Cubical/HITs/Ints/DiffInt/Base.agda
|
maxdore/cubical
|
ef62b84397396d48135d73ba7400b71c721ddc94
|
[
"MIT"
] | null | null | null |
Cubical/HITs/Ints/DiffInt/Base.agda
|
maxdore/cubical
|
ef62b84397396d48135d73ba7400b71c721ddc94
|
[
"MIT"
] | 1
|
2021-03-12T20:08:45.000Z
|
2021-03-12T20:08:45.000Z
|
{-# OPTIONS --safe #-}
module Cubical.HITs.Ints.DiffInt.Base where
open import Cubical.Foundations.Prelude
open import Cubical.HITs.SetQuotients
open import Cubical.Foundations.Isomorphism
open import Cubical.Data.Sigma
open import Cubical.Data.Nat hiding (+-comm ; +-assoc) renaming (_+_ to _+ℕ_)
open import Cubical.Data.Int
rel : (ℕ × ℕ) → (ℕ × ℕ) → Type₀
rel (a₀ , b₀) (a₁ , b₁) = x ≡ y
where
x = a₀ +ℕ b₁
y = a₁ +ℕ b₀
ℤ = (ℕ × ℕ) / rel
-- Proof of equivalence between Int and DiffInt
private
-- Prove all the identities for ℕ×ℕ first and use that to build to ℤ
Int→ℕ×ℕ : Int → (ℕ × ℕ)
Int→ℕ×ℕ (pos n) = ( n , zero )
Int→ℕ×ℕ (negsuc n) = ( zero , suc n )
ℕ×ℕ→Int : (ℕ × ℕ) → Int
ℕ×ℕ→Int(n , m) = n ℕ- m
relInt→ℕ×ℕ : ∀ m n → rel (Int→ℕ×ℕ (m ℕ- n)) (m , n)
relInt→ℕ×ℕ zero zero = refl
relInt→ℕ×ℕ zero (suc n) = refl
relInt→ℕ×ℕ (suc m) zero = refl
relInt→ℕ×ℕ (suc m) (suc n) =
fst (Int→ℕ×ℕ (m ℕ- n)) +ℕ suc n ≡⟨ +-suc (fst (Int→ℕ×ℕ (m ℕ- n))) n ⟩
suc (fst (Int→ℕ×ℕ (m ℕ- n)) +ℕ n) ≡⟨ cong suc (relInt→ℕ×ℕ m n) ⟩
suc (m +ℕ snd (Int→ℕ×ℕ (m ℕ- n))) ∎
Int→ℕ×ℕ→Int : ∀ n → ℕ×ℕ→Int (Int→ℕ×ℕ n) ≡ n
Int→ℕ×ℕ→Int (pos n) = refl
Int→ℕ×ℕ→Int (negsuc n) = refl
ℕ×ℕ→Int→ℕ×ℕ : ∀ p → rel (Int→ℕ×ℕ (ℕ×ℕ→Int p)) p
ℕ×ℕ→Int→ℕ×ℕ (p₀ , p₁) = relInt→ℕ×ℕ p₀ p₁
-- Now build to ℤ using the above
Int→ℤ : Int → ℤ
Int→ℤ n = [ Int→ℕ×ℕ n ]
ℤ→Int : ℤ → Int
ℤ→Int [ z ] = ℕ×ℕ→Int z
ℤ→Int(eq/ a b r i) = lemℤeq a b r i
where lemℤeq : (a b : (ℕ × ℕ)) → rel a b → ℕ×ℕ→Int(a) ≡ ℕ×ℕ→Int(b)
lemℤeq (a₀ , a₁) (b₀ , b₁) r = a₀ ℕ- a₁ ≡⟨ pos- a₀ a₁ ⟩
pos a₀ - pos a₁ ≡[ i ]⟨ ((pos a₀ - pos a₁) + -Cancel (pos b₁) (~ i)) ⟩
(pos a₀ - pos a₁) + (pos b₁ - pos b₁) ≡⟨ +-assoc (pos a₀ + (- pos a₁)) (pos b₁) (- pos b₁) ⟩
((pos a₀ - pos a₁) + pos b₁) - pos b₁ ≡[ i ]⟨ +-assoc (pos a₀) (- pos a₁) (pos b₁) (~ i) + (- pos b₁) ⟩
(pos a₀ + ((- pos a₁) + pos b₁)) - pos b₁ ≡[ i ]⟨ (pos a₀ + +-comm (- pos a₁) (pos b₁) i) - pos b₁ ⟩
(pos a₀ + (pos b₁ - pos a₁)) - pos b₁ ≡[ i ]⟨ +-assoc (pos a₀) (pos b₁) (- pos a₁) i + (- pos b₁) ⟩
((pos a₀ + pos b₁) - pos a₁) - pos b₁ ≡[ i ]⟨ (pos+ a₀ b₁ (~ i) - pos a₁) - pos b₁ ⟩
(pos (a₀ +ℕ b₁) - pos a₁) - pos b₁ ≡[ i ]⟨ (pos (r i) - pos a₁) - pos b₁ ⟩
(pos (b₀ +ℕ a₁) - pos a₁) - pos b₁ ≡[ i ]⟨ (pos+ b₀ a₁ i - pos a₁) - pos b₁ ⟩
((pos b₀ + pos a₁) - pos a₁) - pos b₁ ≡[ i ]⟨ +-assoc (pos b₀) (pos a₁) (- pos a₁) (~ i) + (- pos b₁) ⟩
(pos b₀ + (pos a₁ - pos a₁)) - pos b₁ ≡[ i ]⟨ (pos b₀ + (-Cancel (pos a₁) i)) - pos b₁ ⟩
pos b₀ - pos b₁ ≡[ i ]⟨ pos- b₀ b₁ (~ i) ⟩
b₀ ℕ- b₁ ∎
ℤ→Int(squash/ x x₀ p q i j) = isSetInt (ℤ→Int x) (ℤ→Int x₀) (cong ℤ→Int p) (cong ℤ→Int q) i j
Int→ℤ→Int : ∀ z → ℤ→Int (Int→ℤ z) ≡ z
Int→ℤ→Int (pos n) = refl
Int→ℤ→Int (negsuc n) = refl
ℤ→Int→ℤ : ∀ z → Int→ℤ (ℤ→Int z) ≡ z
ℤ→Int→ℤ = elimProp (λ z → squash/ (Int→ℤ (ℤ→Int z)) z) ℕ×ℕprf
where ℕ×ℕprf : (a : ℕ × ℕ) → Int→ℤ (ℤ→Int [ a ]) ≡ [ a ]
ℕ×ℕprf (a , b) = eq/ (Int→ℕ×ℕ (ℕ×ℕ→Int (a , b))) (a , b) (ℕ×ℕ→Int→ℕ×ℕ (a , b))
Int≡DiffInt : Int ≡ ℤ
Int≡DiffInt = isoToPath (iso Int→ℤ ℤ→Int ℤ→Int→ℤ Int→ℤ→Int)
| 39.823529
| 122
| 0.472969
|
188f4db8129e78ed7816f013787372afd8ec8e2b
| 830
|
agda
|
Agda
|
test/fail/WithoutK3.agda
|
asr/agda-kanso
|
aa10ae6a29dc79964fe9dec2de07b9df28b61ed5
|
[
"MIT"
] | null | null | null |
test/fail/WithoutK3.agda
|
asr/agda-kanso
|
aa10ae6a29dc79964fe9dec2de07b9df28b61ed5
|
[
"MIT"
] | null | null | null |
test/fail/WithoutK3.agda
|
asr/agda-kanso
|
aa10ae6a29dc79964fe9dec2de07b9df28b61ed5
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --without-K #-}
module WithoutK3 where
-- Homogeneous equality.
data _≡_ {A : Set} (x : A) : A → Set where
refl : x ≡ x
-- The J rule.
J : {A : Set} (P : {x y : A} → x ≡ y → Set) →
(∀ x → P (refl {x = x})) →
∀ {x y} (x≡y : x ≡ y) → P x≡y
J P p refl = p _
-- Heterogeneous equality.
data _≅_ {A : Set} (x : A) : {B : Set} → B → Set where
refl : x ≅ x
-- Substitutivity.
subst : {A : Set} {x y : A} (P : A → Set) → x ≅ y → P x → P y
subst P refl p = p
-- The K rule. (The implementation is based on a construction in Conor
-- McBride's PhD thesis.)
K : {A : Set} {x : A} (P : {x : A} → x ≡ x → Set) →
(∀ x → P (refl {x = x})) →
∀ {x} (p : x ≡ x) → P p
K P p x≡x =
J (λ {x y} (p : x ≡ y) → (x≡x : x ≡ x) → p ≅ x≡x → P x≡x)
(λ x x≡x refl≅x≡x → subst P refl≅x≡x (p x))
x≡x x≡x refl
| 22.432432
| 70
| 0.462651
|
5ef0217bbdeec3cd8fc5b884248c15a6dded27dd
| 2,855
|
agda
|
Agda
|
src/Tactic/Reflection.agda
|
t-more/agda-prelude
|
da4fca7744d317b8843f2bc80a923972f65548d3
|
[
"MIT"
] | 111
|
2015-01-05T11:28:15.000Z
|
2022-02-12T23:29:26.000Z
|
src/Tactic/Reflection.agda
|
t-more/agda-prelude
|
da4fca7744d317b8843f2bc80a923972f65548d3
|
[
"MIT"
] | 59
|
2016-02-09T05:36:44.000Z
|
2022-01-14T07:32:36.000Z
|
src/Tactic/Reflection.agda
|
t-more/agda-prelude
|
da4fca7744d317b8843f2bc80a923972f65548d3
|
[
"MIT"
] | 24
|
2015-03-12T18:03:45.000Z
|
2021-04-22T06:10:41.000Z
|
module Tactic.Reflection where
open import Prelude hiding (abs; _>>=_) renaming (_>>=′_ to _>>=_)
open import Builtin.Reflection public
open import Tactic.Reflection.DeBruijn public
open import Tactic.Reflection.Telescope public
open import Tactic.Reflection.Substitute public
open import Tactic.Reflection.Free public
open import Tactic.Reflection.Equality public
open import Tactic.Reflection.Meta public
open import Tactic.Reflection.Printf public hiding (formatError)
set₀ : Type
set₀ = agda-sort (lit 0)
set! : Type
set! = agda-sort unknown
pattern var₀ x = var x []
pattern var₁ x a = var x (vArg a ∷ [])
pattern var₂ x a b = var x (vArg a ∷ vArg b ∷ [])
pattern var₃ x a b c = var x (vArg a ∷ vArg b ∷ vArg c ∷ [])
pattern var₄ x a b c d = var x (vArg a ∷ vArg b ∷ vArg c ∷ vArg d ∷ [])
pattern con₀ c = con c []
pattern con₁ c x = con c (vArg x ∷ [])
pattern con₂ c x y = con c (vArg x ∷ vArg y ∷ [])
pattern con₃ c x y z = con c (vArg x ∷ vArg y ∷ vArg z ∷ [])
pattern con₄ c x y z u = con c (vArg x ∷ vArg y ∷ vArg z ∷ vArg u ∷ [])
pattern def₀ f = def f []
pattern def₁ f x = def f (vArg x ∷ [])
pattern def₂ f x y = def f (vArg x ∷ vArg y ∷ [])
pattern def₃ f x y z = def f (vArg x ∷ vArg y ∷ vArg z ∷ [])
pattern def₄ f x y z u = def f (vArg x ∷ vArg y ∷ vArg z ∷ vArg u ∷ [])
infixr 4 _`→_ _`→ʰ_ _`→ⁱ_
_`→_ _`→ʰ_ _`→ⁱ_ : Type → Type → Type
_`→_ a b = pi (vArg a) (abs "_" b)
_`→ʰ_ a b = pi (hArg a) (abs "_" b)
_`→ⁱ_ a b = pi (iArg a) (abs "_" b)
`λ : Term → Term
`λ b = lam visible (abs "_" b)
infixl 9 _`∘_
_`∘_ : Term → Term → Term
_`∘_ = def₂ (quote _∘_)
infixr -20 _`$_
_`$_ : Term → Term → Term
_`$_ = def₂ (quote _$_)
_:′_ : Term → Type → TC Term
_:′_ = checkType
λ′ : ∀ {a} {A : Set a} → Arg Type → TC A → TC A
λ′ = extendContext
infix 2 _=′_
_=′_ : Term → Term → TC ⊤
_=′_ = unify
on-goal : (Type → Tactic) → Tactic
on-goal tac hole = inferNormalisedType hole >>= λ goal → tac goal hole
forceFun : Type → TC Type
forceFun a = do
dom ← newMeta set!
rng ← newMeta set!
unify a (dom `→ weaken 1 rng)
normalise a
inferFunRange : Term → TC Type
inferFunRange hole = unPi =<< forceFun =<< inferType hole where
unPi : Type → TC Type
unPi (pi _ (abs _ (meta x _))) = blockOnMeta! x
unPi (pi _ (abs _ b)) = maybe (typeError ( strErr "Must be applied in a non-dependent function position"
∷ termErr b ∷ [])) pure $ strengthen 1 b
unPi x = typeError (strErr "Invalid goal" ∷ termErr x ∷ [])
macro
runT : Tactic → Tactic
runT t = t
evalTC : ∀ {a} {A : Set a} → TC A → Tactic
evalTC {A = A} c hole = do
v ← c
`v ← quoteTC v
`A ← quoteTC A
checkedHole ← checkType hole `A
unify checkedHole `v
macro
evalT : ∀ {a} {A : Set a} → TC A → Tactic
evalT = evalTC
| 29.132653
| 106
| 0.596848
|
57f3cef1a7ecdf58f2bc9b2e746589b8bf8f5f06
| 6,157
|
agda
|
Agda
|
Cubical/Homotopy/Group/Pi3S2.agda
|
guilhermehas/cubical
|
ce3120d3f8d692847b2744162bcd7a01f0b687eb
|
[
"MIT"
] | 1
|
2021-10-31T17:32:49.000Z
|
2021-10-31T17:32:49.000Z
|
Cubical/Homotopy/Group/Pi3S2.agda
|
guilhermehas/cubical
|
ce3120d3f8d692847b2744162bcd7a01f0b687eb
|
[
"MIT"
] | null | null | null |
Cubical/Homotopy/Group/Pi3S2.agda
|
guilhermehas/cubical
|
ce3120d3f8d692847b2744162bcd7a01f0b687eb
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --safe --experimental-lossy-unification #-}
{-
This file contains:
1. The iso π₃S²≅ℤ
2. A proof that π₃S² is generated by the Hopf map
-}
module Cubical.Homotopy.Group.Pi3S2 where
open import Cubical.Homotopy.Loopspace
open import Cubical.Homotopy.Group.LES
open import Cubical.Homotopy.Group.PinSn
open import Cubical.Homotopy.Group.Base
open import Cubical.Homotopy.HopfInvariant.HopfMap
open import Cubical.Homotopy.HopfInvariant.Base
open import Cubical.Homotopy.HopfInvariant.Homomorphism
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Pointed
open import Cubical.Foundations.HLevels
open import Cubical.Foundations.GroupoidLaws
open import Cubical.Foundations.Isomorphism
open Iso
open import Cubical.Foundations.Equiv
open import Cubical.HITs.SetTruncation renaming (elim to sElim)
open import Cubical.HITs.Sn
open import Cubical.HITs.Susp
open import Cubical.HITs.S1
open import Cubical.Data.Sigma
open import Cubical.Data.Nat
open import Cubical.Data.Int
open import Cubical.Algebra.Group
open import Cubical.Algebra.Group.ZAction
open import Cubical.Algebra.Group.Exact
open import Cubical.Algebra.Group.Morphisms
open import Cubical.Algebra.Group.MorphismProperties
open import Cubical.Algebra.Group.Instances.Unit
open import Cubical.Algebra.Group.Instances.Int
TotalHopf→∙S² : (Σ (S₊ 2) S¹Hopf , north , base) →∙ S₊∙ 2
fst TotalHopf→∙S² = fst
snd TotalHopf→∙S² = refl
IsoTotalSpaceJoin' : Iso (Σ (S₊ 2) S¹Hopf) (S₊ 3)
IsoTotalSpaceJoin' = compIso hopfS¹.IsoTotalSpaceJoin (IsoSphereJoin 1 1)
IsoFiberTotalHopfS¹ : Iso (fiber (fst TotalHopf→∙S²) north) S¹
fun IsoFiberTotalHopfS¹ ((x , y) , z) = subst S¹Hopf z y
inv IsoFiberTotalHopfS¹ x = (north , x) , refl
rightInv IsoFiberTotalHopfS¹ x = refl
leftInv IsoFiberTotalHopfS¹ ((x , y) , z) =
ΣPathP
((ΣPathP
(sym z , (λ i → transp (λ j → S¹Hopf (z (~ i ∧ j))) i y)))
, (λ j i → z (i ∨ ~ j)))
IsoFiberTotalHopfS¹∙≡ :
(fiber (fst TotalHopf→∙S²) north , (north , base) , refl) ≡ S₊∙ 1
IsoFiberTotalHopfS¹∙≡ = ua∙ (isoToEquiv IsoFiberTotalHopfS¹) refl
private
transportGroupEquiv : ∀ {ℓ ℓ'} {A : Pointed ℓ} {B : Pointed ℓ'}
(n : ℕ) (f : A →∙ B)
→ isEquiv (fst (πLES.A→B f n))
→ isEquiv (fst (π'∘∙Hom n f))
transportGroupEquiv n f iseq =
transport (λ i → isEquiv (fst (π∘∙A→B-PathP n f i))) iseq
π₃S²≅π₃TotalHopf : GroupEquiv (πGr 2 (Σ (S₊ 2) S¹Hopf , north , base))
(πGr 2 (S₊∙ 2))
fst (fst π₃S²≅π₃TotalHopf) = fst (πLES.A→B TotalHopf→∙S² 2)
snd (fst π₃S²≅π₃TotalHopf) =
SES→isEquiv
(isContr→≡UnitGroup
(subst isContr (cong (π 3) (sym IsoFiberTotalHopfS¹∙≡))
(∣ refl ∣₂ , (sElim (λ _ → isSetPathImplicit)
(λ p → cong ∣_∣₂
(isOfHLevelSuc 3 isGroupoidS¹ _ _ _ _ _ _ refl p))))))
(isContr→≡UnitGroup
(subst isContr (cong (π 2) (sym IsoFiberTotalHopfS¹∙≡))
(∣ refl ∣₂ , (sElim (λ _ → isSetPathImplicit) (λ p
→ cong ∣_∣₂ (isGroupoidS¹ _ _ _ _ refl p))))))
(πLES.fib→A TotalHopf→∙S² 2)
(πLES.A→B TotalHopf→∙S² 2)
(πLES.B→fib TotalHopf→∙S² 1)
(πLES.Ker-A→B⊂Im-fib→A TotalHopf→∙S² 2)
(πLES.Ker-B→fib⊂Im-A→B TotalHopf→∙S² 1)
snd π₃S²≅π₃TotalHopf = snd (πLES.A→B TotalHopf→∙S² 2)
π'₃S²≅π'₃TotalHopf : GroupEquiv (π'Gr 2 (Σ (S₊ 2) S¹Hopf , north , base))
(π'Gr 2 (S₊∙ 2))
fst (fst π'₃S²≅π'₃TotalHopf) = fst (π'∘∙Hom 2 TotalHopf→∙S²)
snd (fst π'₃S²≅π'₃TotalHopf) =
transportGroupEquiv 2 TotalHopf→∙S² (π₃S²≅π₃TotalHopf .fst .snd)
snd π'₃S²≅π'₃TotalHopf = snd (π'∘∙Hom 2 TotalHopf→∙S²)
πS³≅πTotalHopf : (n : ℕ)
→ GroupEquiv (π'Gr n (S₊∙ 3)) (π'Gr n (Σ (S₊ 2) S¹Hopf , north , base))
πS³≅πTotalHopf n =
π'Iso n
((isoToEquiv
(invIso
(compIso
(hopfS¹.IsoTotalSpaceJoin)
(IsoSphereJoin 1 1))))
, refl)
π₃S²≅ℤ : GroupEquiv (π'Gr 2 (S₊∙ 2)) ℤGroup
π₃S²≅ℤ =
compGroupEquiv
(invGroupEquiv
(compGroupEquiv (πS³≅πTotalHopf 2) π'₃S²≅π'₃TotalHopf))
(GroupIso→GroupEquiv (πₙ'Sⁿ≅ℤ 2))
-- We prove that the generator is the Hopf map
π₃TotalHopf-gen' : π' 3 (Σ (Susp S¹) S¹Hopf , north , base)
π₃TotalHopf-gen' =
∣ inv (compIso (hopfS¹.IsoTotalSpaceJoin) (IsoSphereJoin 1 1)) , refl ∣₂
πS³≅πTotalHopf-gen :
fst (fst (πS³≅πTotalHopf 2)) ∣ idfun∙ _ ∣₂ ≡ π₃TotalHopf-gen'
πS³≅πTotalHopf-gen =
cong ∣_∣₂
(∘∙-idʳ (inv (compIso (hopfS¹.IsoTotalSpaceJoin)
(IsoSphereJoin 1 1)) , refl))
πTotalHopf-gen :
gen₁-by (π'Gr 2 (Σ (S₊ 2) S¹Hopf , north , base))
∣ inv (compIso (hopfS¹.IsoTotalSpaceJoin) (IsoSphereJoin 1 1)) , refl ∣₂
πTotalHopf-gen =
subst (gen₁-by (π'Gr 2 (Σ (S₊ 2) S¹Hopf , north , base)))
πS³≅πTotalHopf-gen
(Iso-pres-gen₁ (π'Gr 2 (S₊∙ 3))
(π'Gr 2 (Σ (S₊ 2) S¹Hopf , north , base))
∣ idfun∙ _ ∣₂
(πₙ'Sⁿ-gen-by-idfun 2)
(GroupEquiv→GroupIso (πS³≅πTotalHopf 2)))
πTotalHopf≅πS²-gen :
fst (fst π'₃S²≅π'₃TotalHopf)
π₃TotalHopf-gen'
≡ ∣ HopfMap' , refl ∣₂
πTotalHopf≅πS²-gen =
cong ∣_∣₂ (ΣPathP (refl , (sym (rUnit refl))))
π₂S³-gen-by-HopfMap' : gen₁-by (π'Gr 2 (S₊∙ 2)) ∣ HopfMap' , refl ∣₂
π₂S³-gen-by-HopfMap' =
subst (gen₁-by (π'Gr 2 (S₊∙ 2))) πTotalHopf≅πS²-gen
(Iso-pres-gen₁ (π'Gr 2 (Σ (S₊ 2) S¹Hopf , north , base)) (π'Gr 2 (S₊∙ 2))
∣ inv (compIso (hopfS¹.IsoTotalSpaceJoin) (IsoSphereJoin 1 1)) , refl ∣₂
πTotalHopf-gen
(GroupEquiv→GroupIso π'₃S²≅π'₃TotalHopf))
π₂S³-gen-by-HopfMap : gen₁-by (π'Gr 2 (S₊∙ 2)) ∣ HopfMap ∣₂
π₂S³-gen-by-HopfMap =
subst (gen₁-by (π'Gr 2 (S₊∙ 2)))
(cong ∣_∣₂ (sym hopfMap≡HopfMap'))
π₂S³-gen-by-HopfMap'
-- As a consequence, we also get that the Hopf invariant determines
-- an iso π₃S²≅ℤ
hopfInvariantEquiv : GroupEquiv (π'Gr 2 (S₊∙ 2)) ℤGroup
fst (fst hopfInvariantEquiv) = HopfInvariant-π' 0
snd (fst hopfInvariantEquiv) =
GroupEquivℤ-isEquiv (invGroupEquiv π₃S²≅ℤ) ∣ HopfMap ∣₂
π₂S³-gen-by-HopfMap (GroupHom-HopfInvariant-π' 0)
(abs→⊎ _ _ HopfInvariant-HopfMap)
snd hopfInvariantEquiv = snd (GroupHom-HopfInvariant-π' 0)
| 35.796512
| 78
| 0.652266
|
a0422e3dd05c57a2dae2009004da9dad4844b0db
| 535
|
agda
|
Agda
|
test/interaction/Issue2291.agda
|
cagix/agda
|
cc026a6a97a3e517bb94bafa9d49233b067c7559
|
[
"BSD-2-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
test/interaction/Issue2291.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
test/interaction/Issue2291.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
-- Andreas, 2016-11-03, issue #2291, reported by Aerate
-- {-# OPTIONS -v interaction.helper:100 #-}
{-# OPTIONS --guardedness #-}
record Foo : Set where
coinductive
field one : Foo
open Foo
someFoo : Foo
someFoo .one = {! {R} -> Foo.one R !}
-- WAS: C-c C-h gives:
-- An internal error has occurred. Please report this as a bug.
-- Location of the error: src/full/Agda/Syntax/Translation/ConcreteToAbstract.hs:1248
-- NOW:
-- Expected an argument of the form f e1 e2 .. en
-- when checking that the expression ? has type Foo
| 25.47619
| 85
| 0.684112
|
528face292b3ad9b69329ad41ea632f03ae6604c
| 4,092
|
agda
|
Agda
|
Data/Row.agda
|
oisdk/agda-playground
|
97a3aab1282b2337c5f43e2cfa3fa969a94c11b7
|
[
"MIT"
] | 6
|
2020-09-11T17:45:41.000Z
|
2021-11-16T08:11:34.000Z
|
Data/Row.agda
|
oisdk/agda-playground
|
97a3aab1282b2337c5f43e2cfa3fa969a94c11b7
|
[
"MIT"
] | null | null | null |
Data/Row.agda
|
oisdk/agda-playground
|
97a3aab1282b2337c5f43e2cfa3fa969a94c11b7
|
[
"MIT"
] | 1
|
2021-11-11T12:30:21.000Z
|
2021-11-11T12:30:21.000Z
|
{-# OPTIONS --cubical --allow-unsolved-metas --postfix-projections #-}
module Data.Row where
open import Prelude
open import Data.Nat.Properties using (snotz)
open import Data.Bool.Properties using (isPropT)
infixr 5 _∷_
data Row (A : Type a) : Type a where
[] : Row A
_∷_ : A → Row A → Row A
swap : ∀ x y xs → x ∷ y ∷ xs ≡ y ∷ x ∷ xs
record Alg {a p} (A : Type a) (P : Row A → Type p) : Type (a ℓ⊔ p) where
constructor algebra
field
[_]_∷_⟨_⟩ : (x : A) → (xs : Row A) → (P⟨xs⟩ : P xs) → P (x ∷ xs)
[_][] : P []
private _∷_⟨_⟩ = [_]_∷_⟨_⟩
Swap-Coh : Type _
Swap-Coh =
∀ x y xs (P⟨xs⟩ : P xs) →
PathP (λ i → P (swap x y xs i)) (x ∷ (y ∷ xs) ⟨ y ∷ xs ⟨ P⟨xs⟩ ⟩ ⟩) (y ∷ (x ∷ xs) ⟨ x ∷ xs ⟨ P⟨xs⟩ ⟩ ⟩)
open Alg
infixr 2 ψ
record ψ {a p} (A : Type a) (P : Row A → Type p) : Type (a ℓ⊔ p) where
constructor elim
field
alg : Alg A P
field
swap-coh : Swap-Coh alg
[_] : ∀ xs → P xs
[ [] ] = [ alg ][]
[ x ∷ xs ] = [ alg ] x ∷ xs ⟨ [ xs ] ⟩
[ swap x y xs i ] = swap-coh x y xs [ xs ] i
syntax ψ ty (λ v → e) = ψ[ v ⦂ ty ] e
open ψ
record ψ-prop {a p} (A : Type a) (P : Row A → Type p) : Type (a ℓ⊔ p) where
constructor elim-prop
field
p-alg : Alg A P
is-prop : ∀ xs → isProp (P xs)
prop-swap-coh : Swap-Coh p-alg
prop-swap-coh x y xs P⟨xs⟩ = toPathP (is-prop _ (transp (λ i → P (swap x y xs i)) i0 _) _)
to-elim : ψ A P
to-elim = elim p-alg prop-swap-coh
∥_∥⇓ : ∀ xs → P xs
∥_∥⇓ = [ to-elim ]
syntax ψ-prop ty (λ v → e) = ψ[ v ⦂ ty ]∥ e ∥
open ψ-prop
foldr : (f : A → B → B) (n : B)
(p : ∀ x y xs → f x (f y xs) ≡ f y (f x xs)) →
Row A → B
foldr f n p = [ elim (algebra (λ x _ xs → f x xs) n) (λ x y _ → p x y) ]
length : Row A → ℕ
length = foldr (const suc) zero λ _ _ _ → refl
infixr 5 _∈_ _∉_
_∈_ : A → Row A → Type _
x ∈ xs = ∃ ys × (x ∷ ys ≡ xs)
_∉_ : A → Row A → Type _
x ∉ xs = ¬ (x ∈ xs)
union-alg : (ys : Row A) → ψ[ xs ⦂ A ] Row A
[ union-alg ys .alg ] x ∷ xs ⟨ P⟨xs⟩ ⟩ = x ∷ P⟨xs⟩
[ union-alg ys .alg ][] = ys
union-alg ys .swap-coh x y xs pxs = swap x y pxs
_∪_ : Row A → Row A → Row A
xs ∪ ys = [ union-alg ys ] xs
open import Data.List using (List; _∷_; [])
import Data.List as List
unorder : List A → Row A
unorder = List.foldr _∷_ []
infix 4 _↭_
_↭_ : List A → List A → Type _
xs ↭ ys = unorder xs ≡ unorder ys
↭-refl : {xs : List A} → xs ↭ xs
↭-refl = refl
↭-sym : {xs ys : List A} → xs ↭ ys → ys ↭ xs
↭-sym = sym
↭-trans : {xs ys zs : List A} → xs ↭ ys → ys ↭ zs → xs ↭ zs
↭-trans = _;_
↭-swap : ∀ {x y : A} {xs} → x ∷ y ∷ xs ↭ y ∷ x ∷ xs
↭-swap = swap _ _ _
open import Relation.Nullary.Decidable.Logic
module _ (_≟_ : Discrete A) where
_⁻ : A → ψ[ xs ⦂ A ] Row A
[ (x ⁻) .alg ] y ∷ xs ⟨ P⟨xs⟩ ⟩ = if does (x ≟ y) then xs else y ∷ P⟨xs⟩
[ (x ⁻) .alg ][] = []
(x ⁻) .swap-coh y z xs pxs with x ≟ y | x ≟ z
(x ⁻) .swap-coh y z xs pxs | no _ | no _ = swap y z pxs
(x ⁻) .swap-coh y z xs pxs | no _ | yes _ = refl
(x ⁻) .swap-coh y z xs pxs | yes _ | no _ = refl
(x ⁻) .swap-coh y z xs pxs | yes x≡y | yes x≡z = cong (Row._∷ xs) (sym x≡z ; x≡y)
rem-cons : ∀ x xs → [ x ⁻ ] (x ∷ xs) ≡ xs
rem-cons x xs with x ≟ x
... | yes _ = refl
... | no ¬p = ⊥-elim (¬p refl)
rem-swap : ∀ x y xs → x ≢ y → x ∷ [ y ⁻ ] xs ≡ [ y ⁻ ] (x ∷ xs)
rem-swap x y xs x≢y with y ≟ x
rem-swap x y xs x≢y | yes x≡y = ⊥-elim (x≢y (sym x≡y))
rem-swap x y xs x≢y | no _ = refl
∷-inj : ∀ x xs ys → x ∷ xs ≡ x ∷ ys → xs ≡ ys
∷-inj x xs ys p with x ≟ x | cong [ x ⁻ ] p
∷-inj x xs ys p | yes _ | q = q
∷-inj x xs ys p | no ¬p | q = ⊥-elim (¬p refl)
elem-push : ∀ x y (xs : Row A) → x ≢ y → x ∉ xs → x ∉ y ∷ xs
elem-push x y xs x≢y x∉xs (ys , x∷ys≡y∷xs) =
let q = rem-swap x y ys x≢y ; cong [ y ⁻ ] x∷ys≡y∷xs ; rem-cons y xs
in x∉xs ([ y ⁻ ] ys , q)
elem-alg : ∀ x → Alg A (λ xs → Dec (x ∈ xs))
[ elem-alg x ] y ∷ xs ⟨ P⟨xs⟩ ⟩ = disj (λ x≡y → (xs , cong (_∷ xs) x≡y)) (λ { (ys , x∷ys≡xs) → y ∷ ys , swap x y ys ; cong (y ∷_) x∷ys≡xs }) (elem-push x y xs) (x ≟ y) P⟨xs⟩
[ elem-alg x ][] = no (snotz ∘ cong length ∘ snd)
| 28.816901
| 175
| 0.495112
|
19db6bbf8b22364efec1253f6b68f8d2320e6a26
| 12,079
|
agda
|
Agda
|
Mockingbird/Forest/Birds.agda
|
splintah/combinatory-logic
|
df8bf877e60b3059532c54a247a36a3d83cd55b0
|
[
"MIT"
] | 1
|
2022-02-28T23:44:42.000Z
|
2022-02-28T23:44:42.000Z
|
Mockingbird/Forest/Birds.agda
|
splintah/combinatory-logic
|
df8bf877e60b3059532c54a247a36a3d83cd55b0
|
[
"MIT"
] | null | null | null |
Mockingbird/Forest/Birds.agda
|
splintah/combinatory-logic
|
df8bf877e60b3059532c54a247a36a3d83cd55b0
|
[
"MIT"
] | null | null | null |
open import Mockingbird.Forest.Base using (Forest)
module Mockingbird.Forest.Birds {b ℓ} (forest : Forest {b} {ℓ}) where
open import Level using (_⊔_)
open import Data.Product using (_×_; ∃-syntax)
open import Relation.Unary using (Pred)
open import Relation.Binary using (Rel)
open Forest forest
-- TODO: consider using implicit arguments in the predicates, e.g.
-- IsMockingbird M = ∀ {x} → M ∙ x ≈ x ∙ x.
IsComposition : (A B C : Bird) → Set (b ⊔ ℓ)
IsComposition A B C = ∀ x → C ∙ x ≈ A ∙ (B ∙ x)
-- A forest ‘has composition’ if for every two birds A and B there exists a bird
-- C = A ∘ B such that C is the composition of A and B.
record HasComposition : Set (b ⊔ ℓ) where
infixr 6 _∘_
field
_∘_ : (A B : Bird) → Bird
isComposition : ∀ A B → IsComposition A B (A ∘ B)
open HasComposition ⦃ ... ⦄ public
IsMockingbird : Pred Bird (b ⊔ ℓ)
IsMockingbird M = ∀ x → M ∙ x ≈ x ∙ x
record HasMockingbird : Set (b ⊔ ℓ) where
field
M : Bird
isMockingbird : IsMockingbird M
open HasMockingbird ⦃ ... ⦄ public
infix 4 _IsFondOf_
_IsFondOf_ : Rel Bird ℓ
A IsFondOf B = A ∙ B ≈ B
IsEgocentric : Pred Bird ℓ
IsEgocentric A = A IsFondOf A
Agree : (A B x : Bird) → Set ℓ
Agree A B x = A ∙ x ≈ B ∙ x
IsAgreeable : Pred Bird (b ⊔ ℓ)
IsAgreeable A = ∀ B → ∃[ x ] Agree A B x
Compatible : Rel Bird (b ⊔ ℓ)
Compatible A B = ∃[ x ] ∃[ y ] (A ∙ x ≈ y) × (B ∙ y ≈ x)
IsHappy : Pred Bird (b ⊔ ℓ)
IsHappy A = Compatible A A
IsNormal : Pred Bird (b ⊔ ℓ)
IsNormal A = ∃[ x ] A IsFondOf x
infix 4 _IsFixatedOn_
_IsFixatedOn_ : Rel Bird (b ⊔ ℓ)
A IsFixatedOn B = ∀ x → A ∙ x ≈ B
IsHopelesslyEgocentric : Pred Bird (b ⊔ ℓ)
IsHopelesslyEgocentric A = A IsFixatedOn A
IsKestrel : Pred Bird (b ⊔ ℓ)
IsKestrel K = ∀ x y → (K ∙ x) ∙ y ≈ x
-- Alternative definition:
-- IsKestrel K = ∀ x → K ∙ x IsFixatedOn x
record HasKestrel : Set (b ⊔ ℓ) where
field
K : Bird
isKestrel : IsKestrel K
open HasKestrel ⦃ ... ⦄ public
IsIdentity : Pred Bird (b ⊔ ℓ)
IsIdentity I = ∀ x → I ∙ x ≈ x
record HasIdentity : Set (b ⊔ ℓ) where
field
I : Bird
isIdentity : IsIdentity I
open HasIdentity ⦃ ... ⦄ public
IsLark : Pred Bird (b ⊔ ℓ)
IsLark L = ∀ x y → (L ∙ x) ∙ y ≈ x ∙ (y ∙ y)
record HasLark : Set (b ⊔ ℓ) where
field
L : Bird
isLark : IsLark L
IsSageBird : Pred Bird (b ⊔ ℓ)
IsSageBird Θ = ∀ x → x IsFondOf (Θ ∙ x)
open HasLark ⦃ ... ⦄ public
record HasSageBird : Set (b ⊔ ℓ) where
field
Θ : Bird
isSageBird : IsSageBird Θ
IsBluebird : Pred Bird (b ⊔ ℓ)
IsBluebird B = ∀ x y z → B ∙ x ∙ y ∙ z ≈ x ∙ (y ∙ z)
open HasSageBird ⦃ ... ⦄ public
record HasBluebird : Set (b ⊔ ℓ) where
field
B : Bird
isBluebird : IsBluebird B
open HasBluebird ⦃ ... ⦄ public
IsDove : Pred Bird (b ⊔ ℓ)
IsDove D = ∀ x y z w → D ∙ x ∙ y ∙ z ∙ w ≈ x ∙ y ∙ (z ∙ w)
record HasDove : Set (b ⊔ ℓ) where
field
D : Bird
isDove : IsDove D
open HasDove ⦃ ... ⦄ public
IsBlackbird : Pred Bird (b ⊔ ℓ)
IsBlackbird B₁ = ∀ x y z w → B₁ ∙ x ∙ y ∙ z ∙ w ≈ x ∙ (y ∙ z ∙ w)
record HasBlackbird : Set (b ⊔ ℓ) where
field
B₁ : Bird
isBlackbird : IsBlackbird B₁
open HasBlackbird ⦃ ... ⦄ public
IsEagle : Pred Bird (b ⊔ ℓ)
IsEagle E = ∀ x y z w v → E ∙ x ∙ y ∙ z ∙ w ∙ v ≈ x ∙ y ∙ (z ∙ w ∙ v)
record HasEagle : Set (b ⊔ ℓ) where
field
E : Bird
isEagle : IsEagle E
open HasEagle ⦃ ... ⦄ public
IsBunting : Pred Bird (b ⊔ ℓ)
IsBunting B₂ = ∀ x y z w v → B₂ ∙ x ∙ y ∙ z ∙ w ∙ v ≈ x ∙ (y ∙ z ∙ w ∙ v)
record HasBunting : Set (b ⊔ ℓ) where
field
B₂ : Bird
isBunting : IsBunting B₂
open HasBunting ⦃ ... ⦄ public
IsDickcissel : Pred Bird (b ⊔ ℓ)
IsDickcissel D₁ = ∀ x y z w v → D₁ ∙ x ∙ y ∙ z ∙ w ∙ v ≈ x ∙ y ∙ z ∙ (w ∙ v)
record HasDickcissel : Set (b ⊔ ℓ) where
field
D₁ : Bird
isDickcissel : IsDickcissel D₁
open HasDickcissel ⦃ ... ⦄ public
IsBecard : Pred Bird (b ⊔ ℓ)
IsBecard B₃ = ∀ x y z w → B₃ ∙ x ∙ y ∙ z ∙ w ≈ x ∙ (y ∙ (z ∙ w))
record HasBecard : Set (b ⊔ ℓ) where
field
B₃ : Bird
isBecard : IsBecard B₃
open HasBecard ⦃ ... ⦄ public
IsDovekie : Pred Bird (b ⊔ ℓ)
IsDovekie D₂ = ∀ x y z w v → D₂ ∙ x ∙ y ∙ z ∙ w ∙ v ≈ x ∙ (y ∙ z) ∙ (w ∙ v)
record HasDovekie : Set (b ⊔ ℓ) where
field
D₂ : Bird
isDovekie : IsDovekie D₂
open HasDovekie ⦃ ... ⦄ public
IsBaldEagle : Pred Bird (b ⊔ ℓ)
IsBaldEagle Ê = ∀ x y₁ y₂ y₃ z₁ z₂ z₃ → Ê ∙ x ∙ y₁ ∙ y₂ ∙ y₃ ∙ z₁ ∙ z₂ ∙ z₃ ≈ x ∙ (y₁ ∙ y₂ ∙ y₃) ∙ (z₁ ∙ z₂ ∙ z₃)
record HasBaldEagle : Set (b ⊔ ℓ) where
field
Ê : Bird
isBaldEagle : IsBaldEagle Ê
open HasBaldEagle ⦃ ... ⦄ public
IsWarbler : Pred Bird (b ⊔ ℓ)
IsWarbler W = ∀ x y → W ∙ x ∙ y ≈ x ∙ y ∙ y
record HasWarbler : Set (b ⊔ ℓ) where
field
W : Bird
isWarbler : IsWarbler W
open HasWarbler ⦃ ... ⦄ public
IsCardinal : Pred Bird (b ⊔ ℓ)
IsCardinal C = ∀ x y z → C ∙ x ∙ y ∙ z ≈ x ∙ z ∙ y
record HasCardinal : Set (b ⊔ ℓ) where
field
C : Bird
isCardinal : IsCardinal C
open HasCardinal ⦃ ... ⦄ public
IsThrush : Pred Bird (b ⊔ ℓ)
IsThrush T = ∀ x y → T ∙ x ∙ y ≈ y ∙ x
record HasThrush : Set (b ⊔ ℓ) where
field
T : Bird
isThrush : IsThrush T
open HasThrush ⦃ ... ⦄ public
Commute : (x y : Bird) → Set ℓ
Commute x y = x ∙ y ≈ y ∙ x
IsRobin : Pred Bird (b ⊔ ℓ)
IsRobin R = ∀ x y z → R ∙ x ∙ y ∙ z ≈ y ∙ z ∙ x
record HasRobin : Set (b ⊔ ℓ) where
field
R : Bird
isRobin : IsRobin R
open HasRobin ⦃ ... ⦄ public
IsFinch : Pred Bird (b ⊔ ℓ)
IsFinch F = ∀ x y z → F ∙ x ∙ y ∙ z ≈ z ∙ y ∙ x
record HasFinch : Set (b ⊔ ℓ) where
field
F : Bird
isFinch : IsFinch F
open HasFinch ⦃ ... ⦄ public
IsVireo : Pred Bird (b ⊔ ℓ)
IsVireo V = ∀ x y z → V ∙ x ∙ y ∙ z ≈ z ∙ x ∙ y
record HasVireo : Set (b ⊔ ℓ) where
field
V : Bird
isVireo : IsVireo V
open HasVireo ⦃ ... ⦄ public
IsCardinalOnceRemoved : Pred Bird (b ⊔ ℓ)
IsCardinalOnceRemoved C* = ∀ x y z w → C* ∙ x ∙ y ∙ z ∙ w ≈ x ∙ y ∙ w ∙ z
record HasCardinalOnceRemoved : Set (b ⊔ ℓ) where
field
C* : Bird
isCardinalOnceRemoved : IsCardinalOnceRemoved C*
open HasCardinalOnceRemoved ⦃ ... ⦄ public
IsRobinOnceRemoved : Pred Bird (b ⊔ ℓ)
IsRobinOnceRemoved R* = ∀ x y z w → R* ∙ x ∙ y ∙ z ∙ w ≈ x ∙ z ∙ w ∙ y
record HasRobinOnceRemoved : Set (b ⊔ ℓ) where
field
R* : Bird
isRobinOnceRemoved : IsRobinOnceRemoved R*
open HasRobinOnceRemoved ⦃ ... ⦄ public
IsFinchOnceRemoved : Pred Bird (b ⊔ ℓ)
IsFinchOnceRemoved F* = ∀ x y z w → F* ∙ x ∙ y ∙ z ∙ w ≈ x ∙ w ∙ z ∙ y
record HasFinchOnceRemoved : Set (b ⊔ ℓ) where
field
F* : Bird
isFinchOnceRemoved : IsFinchOnceRemoved F*
open HasFinchOnceRemoved ⦃ ... ⦄ public
IsVireoOnceRemoved : Pred Bird (b ⊔ ℓ)
IsVireoOnceRemoved V* = ∀ x y z w → V* ∙ x ∙ y ∙ z ∙ w ≈ x ∙ w ∙ y ∙ z
record HasVireoOnceRemoved : Set (b ⊔ ℓ) where
field
V* : Bird
isVireoOnceRemoved : IsVireoOnceRemoved V*
open HasVireoOnceRemoved ⦃ ... ⦄ public
IsCardinalTwiceRemoved : Pred Bird (b ⊔ ℓ)
IsCardinalTwiceRemoved C** = ∀ x y z₁ z₂ z₃ → C** ∙ x ∙ y ∙ z₁ ∙ z₂ ∙ z₃ ≈ x ∙ y ∙ z₁ ∙ z₃ ∙ z₂
record HasCardinalTwiceRemoved : Set (b ⊔ ℓ) where
field
C** : Bird
isCardinalTwiceRemoved : IsCardinalTwiceRemoved C**
open HasCardinalTwiceRemoved ⦃ ... ⦄ public
IsRobinTwiceRemoved : Pred Bird (b ⊔ ℓ)
IsRobinTwiceRemoved R** = ∀ x y z₁ z₂ z₃ → R** ∙ x ∙ y ∙ z₁ ∙ z₂ ∙ z₃ ≈ x ∙ y ∙ z₂ ∙ z₃ ∙ z₁
record HasRobinTwiceRemoved : Set (b ⊔ ℓ) where
field
R** : Bird
isRobinTwiceRemoved : IsRobinTwiceRemoved R**
open HasRobinTwiceRemoved ⦃ ... ⦄ public
IsFinchTwiceRemoved : Pred Bird (b ⊔ ℓ)
IsFinchTwiceRemoved F** = ∀ x y z₁ z₂ z₃ → F** ∙ x ∙ y ∙ z₁ ∙ z₂ ∙ z₃ ≈ x ∙ y ∙ z₃ ∙ z₂ ∙ z₁
record HasFinchTwiceRemoved : Set (b ⊔ ℓ) where
field
F** : Bird
isFinchTwiceRemoved : IsFinchTwiceRemoved F**
open HasFinchTwiceRemoved ⦃ ... ⦄ public
IsVireoTwiceRemoved : Pred Bird (b ⊔ ℓ)
IsVireoTwiceRemoved V** = ∀ x y z₁ z₂ z₃ → V** ∙ x ∙ y ∙ z₁ ∙ z₂ ∙ z₃ ≈ x ∙ y ∙ z₃ ∙ z₁ ∙ z₂
record HasVireoTwiceRemoved : Set (b ⊔ ℓ) where
field
V** : Bird
isVireoTwiceRemoved : IsVireoTwiceRemoved V**
open HasVireoTwiceRemoved ⦃ ... ⦄ public
IsQueerBird : Pred Bird (b ⊔ ℓ)
IsQueerBird Q = ∀ x y z → Q ∙ x ∙ y ∙ z ≈ y ∙ (x ∙ z)
record HasQueerBird : Set (b ⊔ ℓ) where
field
Q : Bird
isQueerBird : IsQueerBird Q
open HasQueerBird ⦃ ... ⦄ public
IsQuixoticBird : Pred Bird (b ⊔ ℓ)
IsQuixoticBird Q₁ = ∀ x y z → Q₁ ∙ x ∙ y ∙ z ≈ x ∙ (z ∙ y)
record HasQuixoticBird : Set (b ⊔ ℓ) where
field
Q₁ : Bird
isQuixoticBird : IsQuixoticBird Q₁
open HasQuixoticBird ⦃ ... ⦄ public
IsQuizzicalBird : Pred Bird (b ⊔ ℓ)
IsQuizzicalBird Q₂ = ∀ x y z → Q₂ ∙ x ∙ y ∙ z ≈ y ∙ (z ∙ x)
record HasQuizzicalBird : Set (b ⊔ ℓ) where
field
Q₂ : Bird
isQuizzicalBird : IsQuizzicalBird Q₂
open HasQuizzicalBird ⦃ ... ⦄ public
IsQuirkyBird : Pred Bird (b ⊔ ℓ)
IsQuirkyBird Q₃ = ∀ x y z → Q₃ ∙ x ∙ y ∙ z ≈ z ∙ (x ∙ y)
record HasQuirkyBird : Set (b ⊔ ℓ) where
field
Q₃ : Bird
isQuirkyBird : IsQuirkyBird Q₃
open HasQuirkyBird ⦃ ... ⦄ public
IsQuackyBird : Pred Bird (b ⊔ ℓ)
IsQuackyBird Q₄ = ∀ x y z → Q₄ ∙ x ∙ y ∙ z ≈ z ∙ (y ∙ x)
record HasQuackyBird : Set (b ⊔ ℓ) where
field
Q₄ : Bird
isQuackyBird : IsQuackyBird Q₄
open HasQuackyBird ⦃ ... ⦄ public
IsGoldfinch : Pred Bird (b ⊔ ℓ)
IsGoldfinch G = ∀ x y z w → G ∙ x ∙ y ∙ z ∙ w ≈ x ∙ w ∙ (y ∙ z)
record HasGoldfinch : Set (b ⊔ ℓ) where
field
G : Bird
isGoldfinch : IsGoldfinch G
open HasGoldfinch ⦃ ... ⦄ public
IsDoubleMockingbird : Pred Bird (b ⊔ ℓ)
IsDoubleMockingbird M₂ = ∀ x y → M₂ ∙ x ∙ y ≈ x ∙ y ∙ (x ∙ y)
record HasDoubleMockingbird : Set (b ⊔ ℓ) where
field
M₂ : Bird
isDoubleMockingbird : IsDoubleMockingbird M₂
open HasDoubleMockingbird ⦃ ... ⦄ public
IsConverseWarbler : Pred Bird (b ⊔ ℓ)
IsConverseWarbler W′ = ∀ x y → W′ ∙ x ∙ y ≈ y ∙ x ∙ x
record HasConverseWarbler : Set (b ⊔ ℓ) where
field
W′ : Bird
isConverseWarbler : IsConverseWarbler W′
open HasConverseWarbler ⦃ ... ⦄ public
IsWarblerOnceRemoved : Pred Bird (b ⊔ ℓ)
IsWarblerOnceRemoved W* = ∀ x y z → W* ∙ x ∙ y ∙ z ≈ x ∙ y ∙ z ∙ z
record HasWarblerOnceRemoved : Set (b ⊔ ℓ) where
field
W* : Bird
isWarblerOnceRemoved : IsWarblerOnceRemoved W*
open HasWarblerOnceRemoved ⦃ ... ⦄ public
IsWarblerTwiceRemoved : Pred Bird (b ⊔ ℓ)
IsWarblerTwiceRemoved W** = ∀ x y z w → W** ∙ x ∙ y ∙ z ∙ w ≈ x ∙ y ∙ z ∙ w ∙ w
record HasWarblerTwiceRemoved : Set (b ⊔ ℓ) where
field
W** : Bird
isWarblerTwiceRemoved : IsWarblerTwiceRemoved W**
open HasWarblerTwiceRemoved ⦃ ... ⦄ public
IsHummingbird : Pred Bird (b ⊔ ℓ)
IsHummingbird H = ∀ x y z → H ∙ x ∙ y ∙ z ≈ x ∙ y ∙ z ∙ y
record HasHummingbird : Set (b ⊔ ℓ) where
field
H : Bird
isHummingbird : IsHummingbird H
open HasHummingbird ⦃ ... ⦄ public
IsStarling : Pred Bird (b ⊔ ℓ)
IsStarling S = ∀ x y z → S ∙ x ∙ y ∙ z ≈ x ∙ z ∙ (y ∙ z)
record HasStarling : Set (b ⊔ ℓ) where
field
S : Bird
isStarling : IsStarling S
open HasStarling ⦃ ... ⦄ public
IsPhoenix : Pred Bird (b ⊔ ℓ)
IsPhoenix Φ = ∀ x y z w → Φ ∙ x ∙ y ∙ z ∙ w ≈ x ∙ (y ∙ w) ∙ (z ∙ w)
record HasPhoenix : Set (b ⊔ ℓ) where
field
Φ : Bird
isPhoenix : IsPhoenix Φ
open HasPhoenix ⦃ ... ⦄ public
IsPsiBird : Pred Bird (b ⊔ ℓ)
IsPsiBird Ψ = ∀ x y z w → Ψ ∙ x ∙ y ∙ z ∙ w ≈ x ∙ (y ∙ z) ∙ (y ∙ w)
record HasPsiBird : Set (b ⊔ ℓ) where
field
Ψ : Bird
isPsiBird : IsPsiBird Ψ
open HasPsiBird ⦃ ... ⦄ public
IsTuringBird : Pred Bird (b ⊔ ℓ)
IsTuringBird U = ∀ x y → U ∙ x ∙ y ≈ y ∙ (x ∙ x ∙ y)
record HasTuringBird : Set (b ⊔ ℓ) where
field
U : Bird
isTuringBird : IsTuringBird U
open HasTuringBird ⦃ ... ⦄ public
IsOwl : Pred Bird (b ⊔ ℓ)
IsOwl O = ∀ x y → O ∙ x ∙ y ≈ y ∙ (x ∙ y)
record HasOwl : Set (b ⊔ ℓ) where
field
O : Bird
isOwl : IsOwl O
open HasOwl ⦃ ... ⦄ public
IsChoosy : Pred Bird (b ⊔ ℓ)
IsChoosy A = ∀ x → A IsFondOf x → IsSageBird x
IsJaybird : Pred Bird (b ⊔ ℓ)
IsJaybird J = ∀ x y z w → J ∙ x ∙ y ∙ z ∙ w ≈ x ∙ y ∙ (x ∙ w ∙ z)
record HasJaybird : Set (b ⊔ ℓ) where
field
J : Bird
isJaybird : IsJaybird J
open HasJaybird ⦃ ... ⦄ public
| 23.454369
| 113
| 0.601126
|
5269e3e844de9813469272fa76749d399736b380
| 233
|
agda
|
Agda
|
test/Succeed/Issue1719/Spans.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
test/Succeed/Issue1719/Spans.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
test/Succeed/Issue1719/Spans.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
{-# OPTIONS --without-K --rewriting --confluence-check #-}
module Issue1719.Spans where
open import Issue1719.Common
record Span : Set₁ where
constructor span
field
A B C : Set
f : C → A
g : C → B
open Span public
| 16.642857
| 58
| 0.660944
|
341becc5f31dc4bbf667e344fd8b715d970ff7a9
| 13,906
|
agda
|
Agda
|
Cubical/HITs/Hopf.agda
|
limemloh/cubical
|
df4ef7edffd1c1deb3d4ff342c7178e9901c44f1
|
[
"MIT"
] | null | null | null |
Cubical/HITs/Hopf.agda
|
limemloh/cubical
|
df4ef7edffd1c1deb3d4ff342c7178e9901c44f1
|
[
"MIT"
] | null | null | null |
Cubical/HITs/Hopf.agda
|
limemloh/cubical
|
df4ef7edffd1c1deb3d4ff342c7178e9901c44f1
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --cubical --safe #-}
module Cubical.HITs.Hopf where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.HLevels
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.Isomorphism
open import Cubical.Foundations.Univalence
open import Cubical.Data.Int
open import Cubical.Data.Prod
open import Cubical.HITs.S1
open import Cubical.HITs.S2
open import Cubical.HITs.S3
open import Cubical.HITs.Susp
open import Cubical.HITs.Join
open import Cubical.HITs.Interval
renaming ( zero to I0 ; one to I1 )
Border : (x : S¹) → (j : I) → Partial (j ∨ ~ j) (Σ Type₀ (λ T → T ≃ S¹))
Border x j (j = i0) = S¹ , rot x , rotIsEquiv x
Border x j (j = i1) = S¹ , idEquiv S¹
-- Hopf fibration using SuspS¹
HopfSuspS¹ : SuspS¹ → Type₀
HopfSuspS¹ north = S¹
HopfSuspS¹ south = S¹
HopfSuspS¹ (merid x j) = Glue S¹ (Border x j)
-- Hopf fibration using S²
-- TODO : prove that it is equivalent to HopfSuspS¹
HopfS² : S² → Type₀
HopfS² base = S¹
HopfS² (surf i j) = Glue S¹ (λ { (i = i0) → _ , idEquiv S¹
; (i = i1) → _ , idEquiv S¹
; (j = i0) → _ , idEquiv S¹
; (j = i1) → _ , _ , rotIsEquiv (loop i) } )
-- Hopf fibration using more direct definition of the rot equivalence
-- TODO : prove that it is equivalent to HopfSuspS¹
HopfS²' : S² → Type₀
HopfS²' base = S¹
HopfS²' (surf i j) = Glue S¹ (λ { (i = i0) → _ , rotLoopEquiv i0
; (i = i1) → _ , rotLoopEquiv i0
; (j = i0) → _ , rotLoopEquiv i0
; (j = i1) → _ , rotLoopEquiv i } )
-- Total space of the fibration
TotalHopf : Type₀
TotalHopf = Σ SuspS¹ HopfSuspS¹
-- Forward direction
filler-1 : I → (j : I) → (y : S¹) → Glue S¹ (Border y j) → join S¹ S¹
filler-1 i j y x = hfill (λ t → λ { (j = i0) → inl (rotInv-1 x y t)
; (j = i1) → inr x })
(inS (push ((unglue (j ∨ ~ j) x) * inv y) (unglue (j ∨ ~ j) x) j)) i
TotalHopf→JoinS¹S¹ : TotalHopf → join S¹ S¹
TotalHopf→JoinS¹S¹ (north , x) = inl x
TotalHopf→JoinS¹S¹ (south , x) = inr x
TotalHopf→JoinS¹S¹ (merid y j , x) = filler-1 i1 j y x
-- Backward direction
JoinS¹S¹→TotalHopf : join S¹ S¹ → TotalHopf
JoinS¹S¹→TotalHopf (inl x) = (north , x)
JoinS¹S¹→TotalHopf (inr x) = (south , x)
JoinS¹S¹→TotalHopf (push y x j) =
(merid (inv y * x) j
, glue (λ { (j = i0) → y ; (j = i1) → x }) (rotInv-2 x y j))
-- Now for the homotopies, we will need to fill squares indexed by x y : S¹ with value in S¹
-- Some will be extremeley tough, but happen to be easy when x = y = base
-- therefore, we fill them for x = y = base and then use the connectedness of S¹ × S¹ and
-- the discreteness of ΩS¹ to get general fillers.
-- To proceed with that strategy, we first need a lemma :
-- the sections of the trivial fibration λ (_ : S¹) (_ : S¹) → Int are constant
-- this should be generalized to a constant fibration over a connected space with
-- discrete fiber
fibInt : S¹ → S¹ → Type₀
fibInt _ _ = Int
S¹→HSet : (A : Type₀) (p : isSet A) (F : S¹ → A) (x : S¹) → F base ≡ F x
S¹→HSet A p F base = refl {x = F base}
S¹→HSet A p F (loop i) = f' i
where
f : PathP (λ i → F base ≡ F (loop i)) refl (cong F loop)
f i = λ j → F (loop (i ∧ j))
L : cong F loop ≡ refl
L = p (F base) (F base) (f i1) refl
f' : PathP (λ i → F base ≡ F (loop i)) (refl {x = F base}) (refl {x = F base})
f' = transport (λ i → PathP (λ j → F base ≡ F (loop j)) refl (L i)) f
constant-loop : (F : S¹ → S¹ → Int) → (x y : S¹) → F base base ≡ F x y
constant-loop F x y = L0 ∙ L1
where
p : isSet (S¹ → Int)
p = hLevelPi 2 (λ _ → isSetInt)
L : F base ≡ F x
L = S¹→HSet (S¹ → Int) p F x
L0 : F base base ≡ F x base
L0 i = L i base
L1 : F x base ≡ F x y
L1 = S¹→HSet Int isSetInt (F x) y
discretefib : (F : S¹ → S¹ → Type₀) → Type₀
discretefib F = (a : (x y : S¹) → F x y) →
(b : (x y : S¹) → F x y) →
(a base base ≡ b base base) →
(x y : S¹) → a x y ≡ b x y
discretefib-fibInt : discretefib fibInt
discretefib-fibInt a b h x y i =
hcomp (λ t → λ { (i = i0) → constant-loop a x y t
; (i = i1) → constant-loop b x y t })
(h i)
-- first homotopy
assocFiller-3-aux : I → I → I → I → S¹
assocFiller-3-aux x y j i =
hfill (λ t → λ { (i = i0) → rotInv-1 (loop y) (loop (~ y) * loop x) t
; (i = i1) → rotInv-3 (loop y) (loop x) t
; (x = i0) (y = i0) → base
; (x = i0) (y = i1) → base
; (x = i1) (y = i0) → base
; (x = i1) (y = i1) → base })
(inS ((rotInv-2 (loop x) (loop y) i) * (inv (loop (~ y) * loop x)))) j
-- assocFiller-3-endpoint is used only in the type of the next function, to specify the
-- second endpoint.
-- However, I only need the first endpoint, but I cannot specify only one of them as is.
-- TODO : use cubical extension types when available to remove assocFiller-3-endpoint
assocFiller-3-endpoint : (x : S¹) → (y : S¹) → y ≡ y
assocFiller-3-endpoint base base i = base
assocFiller-3-endpoint (loop x) base i = assocFiller-3-aux x i0 i1 i
assocFiller-3-endpoint base (loop y) i = assocFiller-3-aux i0 y i1 i
assocFiller-3-endpoint (loop x) (loop y) i = assocFiller-3-aux x y i1 i
assocFiller-3 : (x : S¹) → (y : S¹) →
PathP (λ j → rotInv-1 y (inv y * x) j ≡ rotInv-3 y x j)
(λ i → ((rotInv-2 x y i) * (inv (inv y * x))))
(assocFiller-3-endpoint x y)
assocFiller-3 base base j i = base
assocFiller-3 (loop x) base j i = assocFiller-3-aux x i0 j i
assocFiller-3 base (loop y) j i = assocFiller-3-aux i0 y j i
assocFiller-3 (loop x) (loop y) j i = assocFiller-3-aux x y j i
assoc-3 : (_ y : S¹) → basedΩS¹ y
assoc-3 x y i = assocFiller-3 x y i1 i
fibInt≡fibAssoc-3 : fibInt ≡ (λ _ y → basedΩS¹ y)
fibInt≡fibAssoc-3 i = λ x y → basedΩS¹≡Int y (~ i)
discretefib-fibAssoc-3 : discretefib (λ _ y → basedΩS¹ y)
discretefib-fibAssoc-3 =
transp (λ i → discretefib (fibInt≡fibAssoc-3 i)) i0 discretefib-fibInt
assocConst-3 : (x y : S¹) → assoc-3 x y ≡ refl
assocConst-3 x y = discretefib-fibAssoc-3 assoc-3 (λ _ _ → refl) refl x y
assocSquare-3 : I → I → S¹ → S¹ → S¹
assocSquare-3 i j x y = hcomp (λ t → λ { (i = i0) → assocFiller-3 x y j i0
; (i = i1) → assocFiller-3 x y j i1
; (j = i0) → assocFiller-3 x y i0 i
; (j = i1) → assocConst-3 x y t i })
(assocFiller-3 x y j i)
filler-3 : I → I → S¹ → S¹ → join S¹ S¹
filler-3 i j y x =
hcomp (λ t → λ { (i = i0) → filler-1 t j (inv y * x)
(glue (λ { (j = i0) → y ; (j = i1) → x })
(rotInv-2 x y j))
; (i = i1) → push (rotInv-3 y x t) x j
; (j = i0) → inl (assocSquare-3 i t x y)
; (j = i1) → inr x })
(push ((rotInv-2 x y (i ∨ j)) * (inv (inv y * x))) (rotInv-2 x y (i ∨ j)) j)
JoinS¹S¹→TotalHopf→JoinS¹S¹ : ∀ x → TotalHopf→JoinS¹S¹ (JoinS¹S¹→TotalHopf x) ≡ x
JoinS¹S¹→TotalHopf→JoinS¹S¹ (inl x) i = inl x
JoinS¹S¹→TotalHopf→JoinS¹S¹ (inr x) i = inr x
JoinS¹S¹→TotalHopf→JoinS¹S¹ (push y x j) i = filler-3 i j y x
-- Second homotopy
-- This HIT is the total space of the Hopf fibration but the ends of SuspS¹ have not been
-- glued together yet — which makes it into a cylinder.
-- This allows to write compositions that do not properly match at the endpoints. However,
-- I suspect it is unnecessary. TODO : do without PseudoHopf
PseudoHopf : Type₀
PseudoHopf = (S¹ × Interval) × S¹
PseudoHopf-π1 : PseudoHopf → S¹
PseudoHopf-π1 ((y , _) , _) = y
PseudoHopf-π2 : PseudoHopf → S¹
PseudoHopf-π2 (_ , x) = x
assocFiller-4-aux : I → I → I → I → S¹
assocFiller-4-aux x y j i =
hfill (λ t → λ { (i = i0) → ((inv (loop y * loop x * loop (~ y))) * (loop y * loop x))
* (rotInv-1 (loop x) (loop y) t)
; (i = i1) → (rotInv-4 (loop y) (loop y * loop x) (~ t)) * loop x
; (x = i0) (y = i0) → base
; (x = i0) (y = i1) → base
; (x = i1) (y = i0) → base
; (x = i1) (y = i1) → base })
(inS (rotInv-2 (loop y * loop x) (loop y * loop x * loop (~ y)) i)) j
-- See assocFiller-3-endpoint
-- TODO : use cubical extension types when available to remove assocFiller-4-endpoint
assocFiller-4-endpoint : (x y : S¹) → basedΩS¹ (((inv (y * x * inv y)) * (y * x)) * x)
assocFiller-4-endpoint base base i = base
assocFiller-4-endpoint (loop x) base i = assocFiller-4-aux x i0 i1 i
assocFiller-4-endpoint base (loop y) i = assocFiller-4-aux i0 y i1 i
assocFiller-4-endpoint (loop x) (loop y) i = assocFiller-4-aux x y i1 i
assocFiller-4 : (x y : S¹) →
PathP (λ j → ((inv (y * x * inv y)) * (y * x)) * (rotInv-1 x y j) ≡ (rotInv-4 y (y * x) (~ j)) * x)
(λ i → (rotInv-2 (y * x) (y * x * inv y) i))
(assocFiller-4-endpoint x y)
assocFiller-4 base base j i = base
assocFiller-4 (loop x) base j i = assocFiller-4-aux x i0 j i
assocFiller-4 base (loop y) j i = assocFiller-4-aux i0 y j i
assocFiller-4 (loop x) (loop y) j i = assocFiller-4-aux x y j i
assoc-4 : (x y : S¹) → basedΩS¹ (((inv (y * x * inv y)) * (y * x)) * x)
assoc-4 x y i = assocFiller-4 x y i1 i
fibInt≡fibAssoc-4 : fibInt ≡ (λ x y → basedΩS¹ (((inv (y * x * inv y)) * (y * x)) * x))
fibInt≡fibAssoc-4 i = λ x y → basedΩS¹≡Int (((inv (y * x * inv y)) * (y * x)) * x) (~ i)
discretefib-fibAssoc-4 : discretefib (λ x y → basedΩS¹ (((inv (y * x * inv y)) * (y * x)) * x))
discretefib-fibAssoc-4 =
transp (λ i → discretefib (fibInt≡fibAssoc-4 i)) i0 discretefib-fibInt
assocConst-4 : (x y : S¹) → assoc-4 x y ≡ refl
assocConst-4 x y = discretefib-fibAssoc-4 assoc-4 (λ _ _ → refl) refl x y
assocSquare-4 : I → I → S¹ → S¹ → S¹
assocSquare-4 i j x y =
hcomp (λ t → λ { (i = i0) → assocFiller-4 x y j i0
; (i = i1) → assocFiller-4 x y j i1
; (j = i0) → assocFiller-4 x y i0 i
; (j = i1) → assocConst-4 x y t i })
(assocFiller-4 x y j i)
filler-4-0 : (_ j : I) → (y : S¹) → Glue S¹ (Border y j) → PseudoHopf
filler-4-0 i j y x =
let x' = unglue (j ∨ ~ j) x in
hfill (λ t → λ { (j = i0) → ((inv (y * x * inv y) * (y * x) , I0)
, inv (y * x * inv y) * (y * x) * (rotInv-1 x y t))
; (j = i1) → ((inv (x * inv y) * x , I1) , x) })
(inS ((inv (x' * inv y) * x' , seg j) , rotInv-2 x' (x' * inv y) j)) i
filler-4-1 : (_ j : I) → (y : S¹) → Glue S¹ (Border y j) → PseudoHopf
filler-4-1 i j y x =
let x' = unglue (j ∨ ~ j) x in
hfill (λ t → λ { (j = i0) → ((inv (y * x * inv y) * (y * x) , I0)
, (rotInv-4 y (y * x) (~ t)) * x)
; (j = i1) → ((inv (x * inv y) * x , I1) , x) })
(inS ((inv (x' * inv y) * x' , seg j) , unglue (j ∨ ~ j) x)) i
filler-4-2 : (_ j : I) → (y : S¹) → Glue S¹ (Border y j) → TotalHopf
filler-4-2 i j y x =
let x' = unglue (j ∨ ~ j) x in
hcomp (λ t → λ { (i = i0) → JoinS¹S¹→TotalHopf (filler-1 t j y x)
; (i = i1) → (merid (PseudoHopf-π1 (filler-4-0 t j y x)) j
, glue (λ { (j = i0) → rotInv-1 x y t ; (j = i1) → x })
(PseudoHopf-π2 (filler-4-0 t j y x)))
; (j = i0) → (north , rotInv-1 x y t)
; (j = i1) → (south , x) })
(merid (inv (x' * inv y) * x') j
, glue (λ { (j = i0) → y * x * inv y ; (j = i1) → x }) (rotInv-2 x' (x' * inv y) j))
filler-4-3 : (_ j : I) → (y : S¹) → Glue S¹ (Border y j) → PseudoHopf
filler-4-3 i j y x =
let x' = unglue (j ∨ ~ j) x in
hcomp (λ t → λ { (i = i0) → filler-4-0 t j y x
; (i = i1) → filler-4-1 t j y x
; (j = i0) → ((inv (y * x * inv y) * (y * x) , I0) , assocSquare-4 i t x y)
; (j = i1) → ((inv (x * inv y) * x , I1) , x) })
((inv (x' * inv y) * x' , seg j) , rotInv-2 x' (x' * inv y) (i ∨ j))
filler-4-4 : (_ j : I) → (y : S¹) → Glue S¹ (Border y j) → PseudoHopf
filler-4-4 i j y x =
let x' = unglue (j ∨ ~ j) x in
hcomp (λ t → λ { (i = i0) → filler-4-1 t j y x
; (i = i1) → ((y , seg j) , unglue (j ∨ ~ j) x)
; (j = i0) → ((rotInv-4 y (y * x) i , I0)
, (rotInv-4 y (y * x) (i ∨ ~ t)) * x)
; (j = i1) → ((rotInv-4 y x i , I1) , x) })
((rotInv-4 y x' i , seg j) , x')
filler-4-5 : (_ j : I) → (y : S¹) → Glue S¹ (Border y j) → TotalHopf
filler-4-5 i j y x =
hcomp (λ t → λ { (i = i0) → filler-4-2 (~ t) j y x
; (i = i1) → (merid (PseudoHopf-π1 (filler-4-4 t j y x)) j
, glue (λ { (j = i0) → x ; (j = i1) → x })
(PseudoHopf-π2 (filler-4-4 t j y x)))
; (j = i0) → (north , x)
; (j = i1) → (south , x) })
(merid (PseudoHopf-π1 (filler-4-3 i j y x)) j
, glue (λ { (j = i0) → x ; (j = i1) → x }) (PseudoHopf-π2 (filler-4-3 i j y x)))
TotalHopf→JoinS¹S¹→TotalHopf : ∀ x → JoinS¹S¹→TotalHopf (TotalHopf→JoinS¹S¹ x) ≡ x
TotalHopf→JoinS¹S¹→TotalHopf (north , x) i = (north , x)
TotalHopf→JoinS¹S¹→TotalHopf (south , x) i = (south , x)
TotalHopf→JoinS¹S¹→TotalHopf (merid y j , x) i = filler-4-5 i j y x
JoinS¹S¹≡TotalHopf : join S¹ S¹ ≡ TotalHopf
JoinS¹S¹≡TotalHopf = isoToPath (iso JoinS¹S¹→TotalHopf
TotalHopf→JoinS¹S¹
TotalHopf→JoinS¹S¹→TotalHopf
JoinS¹S¹→TotalHopf→JoinS¹S¹)
S³≡TotalHopf : S³ ≡ TotalHopf
S³≡TotalHopf = S³≡joinS¹S¹ ∙ JoinS¹S¹≡TotalHopf
| 43.052632
| 115
| 0.523515
|
4ad8d6368987a67f703747de159893b8fe5a6556
| 442
|
agda
|
Agda
|
test/Fail/WithClausePatternMismatch.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
test/Fail/WithClausePatternMismatch.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
test/Fail/WithClausePatternMismatch.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
-- Andreas, 2015-12-29
record ⊤ : Set where
data P : ⊤ → Set where
c : P record{}
d : P record{}
test : (x : ⊤) (p : P x) → Set
test _ c with Set
test _ d | z = ⊤
-- Expected error: with-clause pattern mismatch.
-- The error should be printed nicely, like:
--
-- With clause pattern d is not an instance of its parent pattern c
-- when checking that the clause
-- test _ c with Set
-- test _ d | z = ⊤
-- has type (x : ⊤) → P x → Set
| 21.047619
| 67
| 0.61086
|
347e0675b1b10d28f874d0af7144637dd6e414e4
| 6,600
|
agda
|
Agda
|
Cubical/Foundations/Transport.agda
|
Schippmunk/cubical
|
c345dc0c49d3950dc57f53ca5f7099bb53a4dc3a
|
[
"MIT"
] | null | null | null |
Cubical/Foundations/Transport.agda
|
Schippmunk/cubical
|
c345dc0c49d3950dc57f53ca5f7099bb53a4dc3a
|
[
"MIT"
] | null | null | null |
Cubical/Foundations/Transport.agda
|
Schippmunk/cubical
|
c345dc0c49d3950dc57f53ca5f7099bb53a4dc3a
|
[
"MIT"
] | null | null | null |
{- Basic theory about transport:
- transport is invertible
- transport is an equivalence ([transportEquiv])
-}
{-# OPTIONS --cubical --no-import-sorts --safe #-}
module Cubical.Foundations.Transport where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.Isomorphism
open import Cubical.Foundations.Univalence
open import Cubical.Foundations.GroupoidLaws
open import Cubical.Foundations.Function using (_∘_)
-- Direct definition of transport filler, note that we have to
-- explicitly tell Agda that the type is constant (like in CHM)
transpFill : ∀ {ℓ} {A : Type ℓ}
(φ : I)
(A : (i : I) → Type ℓ [ φ ↦ (λ _ → A) ])
(u0 : outS (A i0))
→ --------------------------------------
PathP (λ i → outS (A i)) u0 (transp (λ i → outS (A i)) φ u0)
transpFill φ A u0 i = transp (λ j → outS (A (i ∧ j))) (~ i ∨ φ) u0
transport⁻ : ∀ {ℓ} {A B : Type ℓ} → A ≡ B → B → A
transport⁻ p = transport (λ i → p (~ i))
subst⁻ : ∀ {ℓ ℓ'} {A : Type ℓ} {x y : A} (B : A → Type ℓ') (p : x ≡ y) → B y → B x
subst⁻ B p pa = transport⁻ (λ i → B (p i)) pa
transport-fillerExt : ∀ {ℓ} {A B : Type ℓ} (p : A ≡ B)
→ PathP (λ i → A → p i) (λ x → x) (transport p)
transport-fillerExt p i x = transport-filler p x i
transport⁻-fillerExt : ∀ {ℓ} {A B : Type ℓ} (p : A ≡ B)
→ PathP (λ i → p i → A) (λ x → x) (transport⁻ p)
transport⁻-fillerExt p i x = transp (λ j → p (i ∧ ~ j)) (~ i) x
transport-fillerExt⁻ : ∀ {ℓ} {A B : Type ℓ} (p : A ≡ B)
→ PathP (λ i → p i → B) (transport p) (λ x → x)
transport-fillerExt⁻ p = symP (transport⁻-fillerExt (sym p))
transport⁻-fillerExt⁻ : ∀ {ℓ} {A B : Type ℓ} (p : A ≡ B)
→ PathP (λ i → B → p i) (transport⁻ p) (λ x → x)
transport⁻-fillerExt⁻ p = symP (transport-fillerExt (sym p))
transport⁻-filler : ∀ {ℓ} {A B : Type ℓ} (p : A ≡ B) (x : B)
→ PathP (λ i → p (~ i)) x (transport⁻ p x)
transport⁻-filler p x = transport-filler (λ i → p (~ i)) x
transport⁻Transport : ∀ {ℓ} {A B : Type ℓ} → (p : A ≡ B) → (a : A) →
transport⁻ p (transport p a) ≡ a
transport⁻Transport p a j = transport⁻-fillerExt p (~ j) (transport-fillerExt p (~ j) a)
transportTransport⁻ : ∀ {ℓ} {A B : Type ℓ} → (p : A ≡ B) → (b : B) →
transport p (transport⁻ p b) ≡ b
transportTransport⁻ p b j = transport-fillerExt⁻ p j (transport⁻-fillerExt⁻ p j b)
-- Transport is an equivalence
isEquivTransport : ∀ {ℓ} {A B : Type ℓ} (p : A ≡ B) → isEquiv (transport p)
isEquivTransport {A = A} {B = B} p =
transport (λ i → isEquiv (transport-fillerExt p i)) (idIsEquiv A)
transportEquiv : ∀ {ℓ} {A B : Type ℓ} → A ≡ B → A ≃ B
transportEquiv p = (transport p , isEquivTransport p)
substEquiv : ∀ {ℓ ℓ'} {A B : Type ℓ} (P : Type ℓ → Type ℓ') (p : A ≡ B) → P A ≃ P B
substEquiv P p = (subst P p , isEquivTransport (λ i → P (p i)))
liftEquiv : ∀ {ℓ ℓ'} {A B : Type ℓ} (P : Type ℓ → Type ℓ') (e : A ≃ B) → P A ≃ P B
liftEquiv P e = substEquiv P (ua e)
transpEquiv : ∀ {ℓ} {A B : Type ℓ} (p : A ≡ B) → ∀ i → p i ≃ B
transpEquiv P i .fst = transp (λ j → P (i ∨ j)) i
transpEquiv P i .snd
= transp (λ k → isEquiv (transp (λ j → P (i ∨ (j ∧ k))) (i ∨ ~ k)))
i (idIsEquiv (P i))
uaTransportη : ∀ {ℓ} {A B : Type ℓ} (P : A ≡ B) → ua (transportEquiv P) ≡ P
uaTransportη P i j
= Glue (P i1) λ where
(j = i0) → P i0 , transportEquiv P
(i = i1) → P j , transpEquiv P j
(j = i1) → P i1 , idEquiv (P i1)
pathToIso : ∀ {ℓ} {A B : Type ℓ} → A ≡ B → Iso A B
Iso.fun (pathToIso x) = transport x
Iso.inv (pathToIso x) = transport⁻ x
Iso.rightInv (pathToIso x) = transportTransport⁻ x
Iso.leftInv (pathToIso x) = transport⁻Transport x
isInjectiveTransport : ∀ {ℓ : Level} {A B : Type ℓ} {p q : A ≡ B}
→ transport p ≡ transport q → p ≡ q
isInjectiveTransport {p = p} {q} α i =
hcomp
(λ j → λ
{ (i = i0) → secEq univalence p j
; (i = i1) → secEq univalence q j
})
(invEq univalence ((λ a → α i a) , t i))
where
t : PathP (λ i → isEquiv (λ a → α i a)) (pathToEquiv p .snd) (pathToEquiv q .snd)
t = isProp→PathP (λ i → isPropIsEquiv (λ a → α i a)) _ _
transportUaInv : ∀ {ℓ} {A B : Type ℓ} (e : A ≃ B) → transport (ua (invEquiv e)) ≡ transport (sym (ua e))
transportUaInv e = cong transport (uaInvEquiv e)
-- notice that transport (ua e) would reduce, thus an alternative definition using EquivJ can give
-- refl for the case of idEquiv:
-- transportUaInv e = EquivJ (λ _ e → transport (ua (invEquiv e)) ≡ transport (sym (ua e))) refl e
isSet-subst : ∀ {ℓ ℓ′} {A : Type ℓ} {B : A → Type ℓ′}
→ (isSet-A : isSet A)
→ ∀ {a : A}
→ (p : a ≡ a) → (x : B a) → subst B p x ≡ x
isSet-subst {B = B} isSet-A p x = subst (λ p′ → subst B p′ x ≡ x) (isSet-A _ _ refl p) (substRefl {B = B} x)
-- substituting along a composite path is equivalent to substituting twice
substComposite : ∀ {ℓ ℓ′} {A : Type ℓ} → (B : A → Type ℓ′)
→ {x y z : A} (p : x ≡ y) (q : y ≡ z) (u : B x)
→ subst B (p ∙ q) u ≡ subst B q (subst B p u)
substComposite B p q Bx i =
transport (cong B (compPath-filler' p q (~ i))) (transport-fillerExt (cong B p) i Bx)
-- substitution commutes with morphisms in slices
substCommSlice : ∀ {ℓ ℓ′} {A : Type ℓ}
→ (B C : A → Type ℓ′)
→ (F : ∀ i → B i → C i)
→ {x y : A} (p : x ≡ y) (u : B x)
→ subst C p (F x u) ≡ F y (subst B p u)
substCommSlice B C F p Bx i =
transport-fillerExt⁻ (cong C p) i (F _ (transport-fillerExt (cong B p) i Bx))
-- transporting over (λ i → B (p i) → C (p i)) divides the transport into
-- transports over (λ i → C (p i)) and (λ i → B (p (~ i)))
funTypeTransp : ∀ {ℓ ℓ'} {A : Type ℓ} (B C : A → Type ℓ') {x y : A} (p : x ≡ y) (f : B x → C x)
→ PathP (λ i → B (p i) → C (p i)) f (subst C p ∘ f ∘ subst B (sym p))
funTypeTransp B C {x = x} p f i b =
transp (λ j → C (p (j ∧ i))) (~ i) (f (transp (λ j → B (p (i ∧ ~ j))) (~ i) b))
-- transports between loop spaces preserve path composition
overPathFunct : ∀ {ℓ} {A : Type ℓ} {x y : A} (p q : x ≡ x) (P : x ≡ y)
→ transport (λ i → P i ≡ P i) (p ∙ q)
≡ transport (λ i → P i ≡ P i) p ∙ transport (λ i → P i ≡ P i) q
overPathFunct p q =
J (λ y P → transport (λ i → P i ≡ P i) (p ∙ q) ≡ transport (λ i → P i ≡ P i) p ∙ transport (λ i → P i ≡ P i) q)
(transportRefl (p ∙ q) ∙ cong₂ _∙_ (sym (transportRefl p)) (sym (transportRefl q)))
| 44
| 113
| 0.539394
|
1e50dba5e509ca01d213aa27fc9724b63be8fbe5
| 181
|
agda
|
Agda
|
test/interaction/Issue3735.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
test/interaction/Issue3735.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
test/interaction/Issue3735.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
variable
a : Level
postulate
works : Set a → {a : Set} → a
fails : Set a → {a : Set} → {!a!}
module _ (A : Set a) (a : A) where
x : A
x = a
| 12.928571
| 35
| 0.535912
|
067c6c94975379ddebb37c740e31c212b3efddf9
| 887
|
agda
|
Agda
|
Constructive/Common.agda
|
rei1024/agda-misc
|
37200ea91d34a6603d395d8ac81294068303f577
|
[
"MIT"
] | 3
|
2020-04-07T17:49:42.000Z
|
2020-04-21T00:03:43.000Z
|
Constructive/Common.agda
|
rei1024/agda-misc
|
37200ea91d34a6603d395d8ac81294068303f577
|
[
"MIT"
] | null | null | null |
Constructive/Common.agda
|
rei1024/agda-misc
|
37200ea91d34a6603d395d8ac81294068303f577
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --without-K --safe --exact-split #-}
module Constructive.Common where
open import Level
open import Data.Product
open import Data.Sum
open import Function.Base
open import Relation.Nullary
infix 2 _<=>_
-- Logical equivalence
_<=>_ : ∀ {a b} → Set a → Set b → Set (a ⊔ b)
A <=> B = (A → B) × (B → A)
module _ {a b} {A : Set a} {B : Set b} where
mk<=> : (A → B) → (B → A) → A <=> B
mk<=> = _,_
fwd : A <=> B → A → B
fwd = proj₁
bwd : A <=> B → B → A
bwd = proj₂
_∘<=>_ : ∀ {a b c} {A : Set a} {B : Set b} {C : Set c} →
B <=> C → A <=> B → A <=> C
(f , g) ∘<=> (h , i) = f ∘ h , i ∘ g
Stable : ∀ {a} → Set a → Set a
Stable A = ¬ ¬ A → A
Dec⊎ : ∀ {a} → Set a → Set a
Dec⊎ A = A ⊎ ¬ A
-- Unary decidable predicate
DecU : ∀ {a p} {A : Set a} → (A → Set p) → Set (a ⊔ p)
DecU P = ∀ x → P x ⊎ ¬ P x
Inhabited : ∀ {a} → Set a → Set a
Inhabited A = A
| 20.627907
| 56
| 0.487035
|
9a590a214ec53f91574dbe1b08b8f38570e65038
| 7,025
|
agda
|
Agda
|
Modules/PolynomialModule.agda
|
Smaug123/agdaproofs
|
0f4230011039092f58f673abcad8fb0652e6b562
|
[
"MIT"
] | 4
|
2019-08-08T12:44:19.000Z
|
2022-01-28T06:04:15.000Z
|
Modules/PolynomialModule.agda
|
Smaug123/agdaproofs
|
0f4230011039092f58f673abcad8fb0652e6b562
|
[
"MIT"
] | 14
|
2019-01-06T21:11:59.000Z
|
2020-04-11T11:03:39.000Z
|
Modules/PolynomialModule.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 Sets.EquivalenceRelations
open import LogicalFormulae
open import Setoids.Setoids
open import Rings.Definition
open import Modules.Definition
open import Numbers.Naturals.Semiring
open import Numbers.Naturals.Order
open import Lists.Lists
open import Vectors
open import Groups.Definition
open import Orders.Total.Definition
open import Groups.Homomorphisms.Definition
open import Groups.Homomorphisms.Lemmas
open import Rings.Homomorphisms.Definition
module Modules.PolynomialModule {a b : _} {A : Set a} {S : Setoid {a} {b} A} {_+_ _*_ : A → A → A} (R : Ring S _+_ _*_) where
open Ring R
open import Groups.Polynomials.Definition additiveGroup
open import Groups.Polynomials.Group additiveGroup
open import Rings.Polynomial.Multiplication R
open import Rings.Polynomial.Evaluation R
open import Rings.Polynomial.Ring R
open import Rings.Lemmas polyRing
polynomialRingModule : Module R abelianUnderlyingGroup (λ a b → _*P_ (polyInjection a) b)
Module.dotWellDefined (polynomialRingModule) r=s t=u = Ring.*WellDefined polyRing (r=s ,, record {}) t=u
Module.dotDistributesLeft (polynomialRingModule) {r} {s} {t} = Ring.*DistributesOver+ polyRing {polyInjection r} {s} {t}
Module.dotDistributesRight (polynomialRingModule) {r} {s} {t} = Ring.*DistributesOver+' polyRing {polyInjection r} {polyInjection s} {t}
Module.dotAssociative (polynomialRingModule) {r} {s} {t} = Equivalence.transitive (Setoid.eq naivePolySetoid) (Ring.*WellDefined polyRing m (Equivalence.reflexive (Setoid.eq naivePolySetoid) {t})) (Equivalence.symmetric (Setoid.eq naivePolySetoid) (Ring.*Associative polyRing {polyInjection r} {polyInjection s} {t}))
where
m : Setoid._∼_ naivePolySetoid ((r * s) :: []) ((r * s) :: (([] +P []) +P (0R :: [])))
m = Equivalence.reflexive (Setoid.eq S) ,, (Equivalence.reflexive (Setoid.eq S) ,, record {})
Module.dotIdentity (polynomialRingModule) = Ring.identIsIdent polyRing
open import Modules.Span polynomialRingModule
polynomialBasis : ℕ → NaivePoly
polynomialBasis zero = polyInjection 1R
polynomialBasis (succ a) = 0R :: polynomialBasis a
count : (n : ℕ) → Vec ℕ n
count zero = []
count (succ n) = 0 ,- vecMap succ (count n)
lemma : {d : _} {D : Set d} → (f : D → List A) → {n : ℕ} → (m : Vec D n) (r : Vec A n) → Setoid._∼_ naivePolySetoid (dot (vecMap (λ i → 0R :: f i) m) r) (0R :: dot (vecMap f m) r)
lemma f [] [] = reflexive ,, record {}
where
open Setoid S
open Equivalence eq
lemma f (m ,- ms) (r ,- rs) rewrite refl {x = 0} = transitive (+WellDefined {(r * 0R) :: (((map (_*_ r) (f m)) +P []) +P (0R :: []))} {_} {(r * 0R) :: (((map (_*_ r) (f m)) +P []) +P (0R :: []))} (reflexive {(r * 0R) :: (((map (_*_ r) (f m)) +P []) +P (0R :: []))}) (lemma f ms rs)) (Equivalence.transitive (Setoid.eq S) (Group.identRight additiveGroup) (Ring.timesZero R) ,, +WellDefined {((map (_*_ r) (f m)) +P []) +P (0R :: [])} {dot (vecMap f ms) rs} {(r :: []) *P f m} {dot (vecMap f ms) rs} t (reflexive {dot (vecMap f ms) rs}))
where
open Setoid naivePolySetoid
open Equivalence eq
open Group polyGroup
lemm : (v : List A) → polysEqual (map (_*_ r) v) ((r :: []) *P v)
lemm [] = record {}
lemm (x :: v) = Equivalence.reflexive (Setoid.eq S) ,, symmetric (transitive (+WellDefined {map (_*_ r) v +P []} {0R :: []} {_} {[]} reflexive (Equivalence.reflexive (Setoid.eq S) ,, record {})) (transitive (identRight {(map (_*_ r) v) +P []}) (identRight {map (_*_ r) v})))
t : ((map (_*_ r) (f m) +P []) +P (0R :: [])) ∼ ((r :: []) *P f m)
t = transitive (+WellDefined {map (_*_ r) (f m) +P []} {0R :: []} {_} {[]} reflexive (Equivalence.reflexive (Setoid.eq S) ,, record {})) (transitive (identRight {map (_*_ r) (f m) +P []}) (transitive (identRight {map (_*_ r) (f m)}) (lemm (f m))))
identityMap : (v : List A) → Setoid._∼_ naivePolySetoid (dot (vecMap polynomialBasis (count (length v))) (listToVec v)) v
identityMap [] = record {}
identityMap (x :: v) rewrite vecMapCompose succ polynomialBasis (count (length v)) = transitive (+WellDefined {(x * 1R) :: Group.0G additiveGroup :: []} {dot (vecMap (λ i → Group.0G additiveGroup :: polynomialBasis i) (count (length v))) (listToVec v)} {(x * 1R) :: 0R :: []} {0R :: dot (vecMap polynomialBasis (count (length v))) (listToVec v)} (reflexive {(x * 1R) :: 0R :: []}) (lemma polynomialBasis (count (length v)) (listToVec v))) (Equivalence.transitive (Setoid.eq S) (Group.identRight additiveGroup) (Equivalence.transitive (Setoid.eq S) *Commutative identIsIdent) ,, transitive (+WellDefined {0R :: []} {dot (vecMap polynomialBasis (count (length v))) (listToVec v)} {[]} (Equivalence.reflexive (Setoid.eq S) ,, record {}) reflexive) (transitive identLeft (identityMap v)))
where
open Group polyGroup
open Setoid naivePolySetoid
open Equivalence eq
polynomialBasisSpans : Spans polynomialBasis
polynomialBasisSpans m = length m , ((count (length m) ,, listToVec m) , identityMap m)
{-
private
indepWithZero : {n : ℕ} (rs : Vec ℕ n) (indicesDistinct : {a b : ℕ} → (a<n : a <N succ n) (b<n : b <N succ n) → vecIndex (0 ,- rs) a a<n ≡ vecIndex (0 ,- rs) b b<n → a ≡ b) (b : A) (bs : Vec A n) (dotZero : Setoid._∼_ naivePolySetoid (((b * 1R) :: 0R :: []) +P (dot (vecMap polynomialBasis rs) bs)) []) → (nonzero : {a : ℕ} → (a<n : a <N n) → 0 <N vecIndex rs a a<n) → Setoid._∼_ S 0R b && _=V_ additiveGroup (vecPure 0R) bs
indepWithZero rs indicesDistinct b bs dotZero indicesNonzero = symmetric b=0 ,, {!!}
where
open Setoid S
open Equivalence eq
open Group additiveGroup
t : (inducedFunction (((b * 1R) :: 0R :: []) +P (dot (vecMap polynomialBasis rs) bs)) 0R) ∼ 0R
t = inducedFunctionWellDefined dotZero 0R
u : ((inducedFunction ((b * 1R) :: 0R :: []) 0R) + inducedFunction (dot (vecMap polynomialBasis rs) bs) 0R) ∼ 0R
u = transitive (symmetric (GroupHom.groupHom (RingHom.groupHom (inducedFunctionIsHom 0R)) {((b * 1R) :: 0R :: [])} {dot (vecMap polynomialBasis rs) bs})) t
b=0 : b ∼ 0R
b=0 = transitive (symmetric (transitive (+WellDefined (transitive (transitive (transitive (+WellDefined reflexive (transitive *Commutative timesZero)) identRight) *Commutative) identIsIdent) {!imageOfIdentityIsIdentity (RingHom.groupHom (inducedFunctionIsHom 0R))!}) (identRight {b}))) u
polynomialBasisIndependent : Independent polynomialBasis
polynomialBasisIndependent [] indicesDistinct [] dotZero = record {}
polynomialBasisIndependent {succ n} (zero ,- rs) indicesDistinct (b ,- bs) dotZero = indepWithZero rs indicesDistinct b bs dotZero t
where
t : {a : ℕ} (a<n : a <N n) → 0 <N vecIndex rs a a<n
t {a} a<n with TotalOrder.totality ℕTotalOrder 0 (vecIndex rs a a<n)
t {a} a<n | inl (inl x) = x
t {a} a<n | inr x with indicesDistinct {succ a} {0} (succPreservesInequality a<n) (succIsPositive n) (equalityCommutative x)
... | ()
polynomialBasisIndependent (succ r ,- rs) indicesDistinct (b ,- bs) dotZero = {!!}
where
rearr : {!!}
rearr = {!!}
-}
| 66.904762
| 784
| 0.661779
|
0b29014f06d4c653c84758eb7bd93f58f45435b5
| 2,176
|
agda
|
Agda
|
archive/agda-2/Oscar/Data/Term/AlphaConversion/internal.agda
|
m0davis/oscar
|
52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb
|
[
"RSA-MD"
] | null | null | null |
archive/agda-2/Oscar/Data/Term/AlphaConversion/internal.agda
|
m0davis/oscar
|
52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb
|
[
"RSA-MD"
] | 1
|
2019-04-29T00:35:04.000Z
|
2019-05-11T23:33:04.000Z
|
archive/agda-2/Oscar/Data/Term/AlphaConversion/internal.agda
|
m0davis/oscar
|
52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb
|
[
"RSA-MD"
] | null | null | null |
module Oscar.Data.Term.AlphaConversion.internal {𝔣} (FunctionName : Set 𝔣) where
open import Oscar.Data.Term FunctionName
open import Oscar.Data.Equality
open import Oscar.Data.Fin
open import Oscar.Data.Vec
open import Oscar.Function
open import Oscar.Relation
infixr 19 _◂_ _◂s_
mutual
_◂_ : ∀ {m n} → m ⟨ Fin ⟩→ n → m ⟨ Term ⟩→ n
_◂_ f (i 𝑥) = i (f 𝑥)
_◂_ f leaf = leaf
_◂_ f (τ₁ fork τ₂) = (f ◂ τ₁) fork (f ◂ τ₂)
_◂_ f (function 𝑓 τs) = function 𝑓 (f ◂s τs)
_◂s_ : ∀ {m n} → m ⟨ Fin ⟩→ n → ∀ {N} → m ⟨ Terms N ⟩→ n
_◂s_ f [] = []
_◂s_ f (τ ∷ τs) = f ◂ τ ∷ f ◂s τs
mutual
◂-identity : ∀ {m} (τ : Term m) → id ◂ τ ≡ τ
◂-identity (i _) = refl
◂-identity leaf = refl
◂-identity (τ₁ fork τ₂) rewrite ◂-identity τ₁ | ◂-identity τ₂ = refl
◂-identity (function 𝑓 τs) rewrite ◂s-identity τs = refl
◂s-identity : ∀ {N m} (τs : Terms N m) → id ◂s τs ≡ τs
◂s-identity [] = refl
◂s-identity (τ ∷ τs) rewrite ◂-identity τ | ◂s-identity τs = refl
mutual
◂-associativity : ∀ {l m n} (f : l ⟨ Fin ⟩→ m) (g : m ⟨ Fin ⟩→ n) → (τ : Term l) → (g ∘ f) ◂ τ ≡ g ◂ f ◂ τ
◂-associativity _ _ (i _) = refl
◂-associativity _ _ leaf = refl
◂-associativity f g (τ₁ fork τ₂) rewrite ◂-associativity f g τ₁ | ◂-associativity f g τ₂ = refl
◂-associativity f g (function 𝑓 τs) rewrite ◂s-associativity f g τs = refl
◂s-associativity : ∀ {l m n} (f : l ⟨ Fin ⟩→ m) (g : m ⟨ Fin ⟩→ n) → ∀ {N} (x : Terms N l) → (g ∘ f) ◂s x ≡ g ◂s f ◂s x
◂s-associativity _ _ [] = refl
◂s-associativity f g (τ ∷ τs) rewrite ◂-associativity f g τ | ◂s-associativity f g τs = refl
mutual
◂-extensionality : ∀ {m n} {f g : m ⟨ Fin ⟩→ n} → f ≡̇ g → f ◂_ ≡̇ g ◂_
◂-extensionality f≡̇g (i 𝑥) rewrite f≡̇g 𝑥 = refl
◂-extensionality f≡̇g leaf = refl
◂-extensionality f≡̇g (τ₁ fork τ₂) rewrite ◂-extensionality f≡̇g τ₁ | ◂-extensionality f≡̇g τ₂ = refl
◂-extensionality f≡̇g (function 𝑓 τs) rewrite ◂s-extensionality f≡̇g τs = refl
◂s-extensionality : ∀ {m n} {f g : m ⟨ Fin ⟩→ n} → f ≡̇ g → ∀ {N} → _◂s_ f {N} ≡̇ _◂s_ g {N}
◂s-extensionality _ [] = refl
◂s-extensionality f≡̇g (τ ∷ τs) rewrite ◂-extensionality f≡̇g τ | ◂s-extensionality f≡̇g τs = refl
| 35.672131
| 121
| 0.581801
|
43edde66b34467fc61856e6a7b1ef060e0b5bb79
| 622
|
agda
|
Agda
|
src/Prelude/Decidable.agda
|
t-more/agda-prelude
|
da4fca7744d317b8843f2bc80a923972f65548d3
|
[
"MIT"
] | 111
|
2015-01-05T11:28:15.000Z
|
2022-02-12T23:29:26.000Z
|
src/Prelude/Decidable.agda
|
t-more/agda-prelude
|
da4fca7744d317b8843f2bc80a923972f65548d3
|
[
"MIT"
] | 59
|
2016-02-09T05:36:44.000Z
|
2022-01-14T07:32:36.000Z
|
src/Prelude/Decidable.agda
|
t-more/agda-prelude
|
da4fca7744d317b8843f2bc80a923972f65548d3
|
[
"MIT"
] | 24
|
2015-03-12T18:03:45.000Z
|
2021-04-22T06:10:41.000Z
|
module Prelude.Decidable where
open import Prelude.Empty
data Dec {a} (P : Set a) : Set a where
yes : P → Dec P
no : ¬ P → Dec P
infix 0 ifYes_then_else_ ifNo_then_else_
ifYes_then_else_ : ∀ {a b} {A : Set a} {B : Set b} → Dec A → B → B → B
ifYes yes _ then x else _ = x
ifYes no _ then _ else y = y
ifNo_then_else_ : ∀ {a b} {A : Set a} {B : Set b} → Dec A → B → B → B
ifNo d then x else y = ifYes d then y else x
FromDec : ∀ {a} {P : Set a} → Dec P → Set a
FromDec {P = P} (yes _) = P
FromDec {P = P} (no _) = ¬ P
fromDec : ∀ {a} {P : Set a} (d : Dec P) → FromDec d
fromDec (yes x) = x
fromDec (no x) = x
| 24.88
| 70
| 0.57717
|
52019141956082c2664f08de064819e4cd25e6de
| 1,325
|
agda
|
Agda
|
src/Util/Encode.agda
|
LaudateCorpus1/bft-consensus-agda
|
a4674fc473f2457fd3fe5123af48253cfb2404ef
|
[
"UPL-1.0"
] | null | null | null |
src/Util/Encode.agda
|
LaudateCorpus1/bft-consensus-agda
|
a4674fc473f2457fd3fe5123af48253cfb2404ef
|
[
"UPL-1.0"
] | null | null | null |
src/Util/Encode.agda
|
LaudateCorpus1/bft-consensus-agda
|
a4674fc473f2457fd3fe5123af48253cfb2404ef
|
[
"UPL-1.0"
] | null | null | null |
{- Byzantine Fault Tolerant Consensus Verification in Agda, version 0.9.
Copyright (c) 2020 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 Util.ByteString
open import Util.Prelude
------------------------------------------------------------------------------
open import Data.String using (String)
module Util.Encode where
-- An encoder for values of type A is
-- an injective mapping of 'A's into 'ByteString's
record Encoder {a}(A : Set a) : Set a where
constructor mkEncoder
field
encode : A → ByteString
encode-inj : ∀{a₁ a₂} → encode a₁ ≡ encode a₂ → a₁ ≡ a₂
open Encoder {{...}} public
≡-Encoder : ∀ {a} {A : Set a} → Encoder A → DecidableEquality A
≡-Encoder (mkEncoder enc enc-inj) x y
with enc x ≟ByteString enc y
...| yes enc≡ = yes (enc-inj enc≡)
...| no neq = no (⊥-elim ∘ neq ∘ cong enc)
postulate -- valid assumption
instance
encℕ : Encoder ℕ
encBS : Encoder ByteString
instance
encFin : {n : ℕ} → Encoder (Fin n)
encFin {n} = record { encode = encode ⦃ encℕ ⦄ ∘ toℕ ;
encode-inj = toℕ-injective ∘ encode-inj ⦃ encℕ ⦄ }
postulate -- TODO-2 decoder
decode : ∀ {A : Set} → ByteString → Either String A
| 32.317073
| 111
| 0.608302
|
cbc712a7c7ce1e5ec83acfad635d471b2f9f2070
| 23,110
|
agda
|
Agda
|
Cubical/Algebra/Group/EilenbergMacLane/Properties.agda
|
guilhermehas/cubical
|
ce3120d3f8d692847b2744162bcd7a01f0b687eb
|
[
"MIT"
] | 1
|
2021-10-31T17:32:49.000Z
|
2021-10-31T17:32:49.000Z
|
Cubical/Algebra/Group/EilenbergMacLane/Properties.agda
|
guilhermehas/cubical
|
ce3120d3f8d692847b2744162bcd7a01f0b687eb
|
[
"MIT"
] | null | null | null |
Cubical/Algebra/Group/EilenbergMacLane/Properties.agda
|
guilhermehas/cubical
|
ce3120d3f8d692847b2744162bcd7a01f0b687eb
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --safe --experimental-lossy-unification #-}
module Cubical.Algebra.Group.EilenbergMacLane.Properties where
open import Cubical.Algebra.Group.EilenbergMacLane.Base renaming (elim to EM-elim)
open import Cubical.Algebra.Group.EilenbergMacLane.WedgeConnectivity
open import Cubical.Algebra.Group.EilenbergMacLane.GroupStructure
open import Cubical.Algebra.Group.Base
open import Cubical.Algebra.Group.Properties
open import Cubical.Algebra.Group.Morphisms
open import Cubical.Algebra.Group.MorphismProperties
open import Cubical.Algebra.AbGroup.TensorProduct
open import Cubical.Algebra.AbGroup.Base
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Isomorphism
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.GroupoidLaws renaming (assoc to ∙assoc)
open import Cubical.Foundations.Path
open import Cubical.Foundations.HLevels
open import Cubical.Foundations.Univalence
open import Cubical.Foundations.Pointed
open import Cubical.Foundations.Transport
open import Cubical.Foundations.Pointed.Homogeneous
open import Cubical.Homotopy.Connected
open import Cubical.Homotopy.Loopspace
open import Cubical.Functions.Morphism
open import Cubical.Data.Sigma
open import Cubical.Data.Nat hiding (_·_)
open import Cubical.HITs.Truncation as Trunc
renaming (rec to trRec; elim to trElim)
open import Cubical.HITs.EilenbergMacLane1 renaming (rec to EMrec)
open import Cubical.HITs.Truncation
renaming (elim to trElim ; rec to trRec ; rec2 to trRec2)
open import Cubical.HITs.Susp
private
variable ℓ ℓ' ℓ'' : Level
isConnectedEM₁ : (G : Group ℓ) → isConnected 2 (EM₁ G)
isConnectedEM₁ G = ∣ embase ∣ , h
where
h : (y : hLevelTrunc 2 (EM₁ G)) → ∣ embase ∣ ≡ y
h = trElim (λ y → isOfHLevelSuc 1 (isOfHLevelTrunc 2 ∣ embase ∣ y))
(elimProp G (λ x → isOfHLevelTrunc 2 ∣ embase ∣ ∣ x ∣) refl)
module _ {G' : AbGroup ℓ} where
private
G = fst G'
open AbGroupStr (snd G') renaming (_+_ to _+G_)
isConnectedEM : (n : ℕ) → isConnected (suc n) (EM G' n)
fst (isConnectedEM zero) = ∣ 0g ∣
snd (isConnectedEM zero) y = isOfHLevelTrunc 1 _ _
isConnectedEM (suc zero) = isConnectedEM₁ (AbGroup→Group G')
fst (isConnectedEM (suc (suc n))) = ∣ 0ₖ _ ∣
snd (isConnectedEM (suc (suc n))) =
trElim (λ _ → isOfHLevelTruncPath)
(trElim (λ _ → isOfHLevelSuc (3 + n) (isOfHLevelTruncPath {n = (3 + n)}))
(raw-elim G'
(suc n)
(λ _ → isOfHLevelTrunc (3 + n) _ _)
refl))
module _ (Ĝ : Group ℓ) where
private
G = fst Ĝ
open GroupStr (snd Ĝ)
emloop-id : emloop 1g ≡ refl
emloop-id =
emloop 1g ≡⟨ rUnit (emloop 1g) ⟩
emloop 1g ∙ refl ≡⟨ cong (emloop 1g ∙_) (rCancel (emloop 1g) ⁻¹) ⟩
emloop 1g ∙ (emloop 1g ∙ (emloop 1g) ⁻¹) ≡⟨ ∙assoc _ _ _ ⟩
(emloop 1g ∙ emloop 1g) ∙ (emloop 1g) ⁻¹ ≡⟨ cong (_∙ emloop 1g ⁻¹)
((emloop-comp Ĝ 1g 1g) ⁻¹) ⟩
emloop (1g · 1g) ∙ (emloop 1g) ⁻¹ ≡⟨ cong (λ g → emloop {Group = Ĝ} g
∙ (emloop 1g) ⁻¹)
(rid 1g) ⟩
emloop 1g ∙ (emloop 1g) ⁻¹ ≡⟨ rCancel (emloop 1g) ⟩
refl ∎
emloop-inv : (g : G) → emloop (inv g) ≡ (emloop g) ⁻¹
emloop-inv g =
emloop (inv g) ≡⟨ rUnit (emloop (inv g)) ⟩
emloop (inv g) ∙ refl ≡⟨ cong (emloop (inv g) ∙_)
(rCancel (emloop g) ⁻¹) ⟩
emloop (inv g) ∙ (emloop g ∙ (emloop g) ⁻¹) ≡⟨ ∙assoc _ _ _ ⟩
(emloop (inv g) ∙ emloop g) ∙ (emloop g) ⁻¹ ≡⟨ cong (_∙ emloop g ⁻¹)
((emloop-comp Ĝ (inv g) g) ⁻¹) ⟩
emloop (inv g · g) ∙ (emloop g) ⁻¹ ≡⟨ cong (λ h → emloop {Group = Ĝ} h
∙ (emloop g) ⁻¹)
(invl g) ⟩
emloop 1g ∙ (emloop g) ⁻¹ ≡⟨ cong (_∙ (emloop g) ⁻¹) emloop-id ⟩
refl ∙ (emloop g) ⁻¹ ≡⟨ (lUnit ((emloop g) ⁻¹)) ⁻¹ ⟩
(emloop g) ⁻¹ ∎
isGroupoidEM₁ : isGroupoid (EM₁ Ĝ)
isGroupoidEM₁ = emsquash
--------- Ω (EM₁ G) ≃ G ---------
{- since we write composition in diagrammatic order,
and function composition in the other order,
we need right multiplication here -}
rightEquiv : (g : G) → G ≃ G
rightEquiv g = isoToEquiv isom
where
isom : Iso G G
isom .Iso.fun = _· g
isom .Iso.inv = _· inv g
isom .Iso.rightInv h =
(h · inv g) · g ≡⟨ (assoc h (inv g) g) ⁻¹ ⟩
h · inv g · g ≡⟨ cong (h ·_) (invl g) ⟩
h · 1g ≡⟨ rid h ⟩ h ∎
isom .Iso.leftInv h =
(h · g) · inv g ≡⟨ (assoc h g (inv g)) ⁻¹ ⟩
h · g · inv g ≡⟨ cong (h ·_) (invr g) ⟩
h · 1g ≡⟨ rid h ⟩ h ∎
compRightEquiv : (g h : G)
→ compEquiv (rightEquiv g) (rightEquiv h) ≡ rightEquiv (g · h)
compRightEquiv g h = equivEq (funExt (λ x → (assoc x g h) ⁻¹))
CodesSet : EM₁ Ĝ → hSet ℓ
CodesSet = EMrec Ĝ (isOfHLevelTypeOfHLevel 2) (G , is-set) RE REComp
where
RE : (g : G) → Path (hSet ℓ) (G , is-set) (G , is-set)
RE g = Σ≡Prop (λ X → isPropIsOfHLevel {A = X} 2) (ua (rightEquiv g))
lemma₁ : (g h : G) → Square
(ua (rightEquiv g)) (ua (rightEquiv (g · h)))
refl (ua (rightEquiv h))
lemma₁ g h = invEq
(Square≃doubleComp (ua (rightEquiv g)) (ua (rightEquiv (g · h)))
refl (ua (rightEquiv h)))
(ua (rightEquiv g) ∙ ua (rightEquiv h)
≡⟨ (uaCompEquiv (rightEquiv g) (rightEquiv h)) ⁻¹ ⟩
ua (compEquiv (rightEquiv g) (rightEquiv h))
≡⟨ cong ua (compRightEquiv g h) ⟩
ua (rightEquiv (g · h)) ∎)
REComp : (g h : G) → Square (RE g) (RE (g · h)) refl (RE h)
REComp g h = ΣSquareSet (λ _ → isProp→isSet isPropIsSet) (lemma₁ g h)
Codes : EM₁ Ĝ → Type ℓ
Codes x = CodesSet x .fst
encode : (x : EM₁ Ĝ) → embase ≡ x → Codes x
encode x p = subst Codes p 1g
decode : (x : EM₁ Ĝ) → Codes x → embase ≡ x
decode = elimSet Ĝ (λ x → isOfHLevelΠ 2 (λ c → isGroupoidEM₁ (embase) x))
emloop λ g → ua→ λ h → emcomp h g
decode-encode : (x : EM₁ Ĝ) (p : embase ≡ x) → decode x (encode x p) ≡ p
decode-encode x p = J (λ y q → decode y (encode y q) ≡ q)
(emloop (transport refl 1g) ≡⟨ cong emloop (transportRefl 1g) ⟩
emloop 1g ≡⟨ emloop-id ⟩ refl ∎) p
encode-decode : (x : EM₁ Ĝ) (c : Codes x) → encode x (decode x c) ≡ c
encode-decode = elimProp Ĝ (λ x → isOfHLevelΠ 1 (λ c → CodesSet x .snd _ _))
λ g → encode embase (decode embase g) ≡⟨ refl ⟩
encode embase (emloop g) ≡⟨ refl ⟩
transport (ua (rightEquiv g)) 1g ≡⟨ uaβ (rightEquiv g) 1g ⟩
1g · g ≡⟨ lid g ⟩
g ∎
ΩEM₁Iso : Iso (Path (EM₁ Ĝ) embase embase) G
Iso.fun ΩEM₁Iso = encode embase
Iso.inv ΩEM₁Iso = emloop
Iso.rightInv ΩEM₁Iso = encode-decode embase
Iso.leftInv ΩEM₁Iso = decode-encode embase
ΩEM₁≡ : (Path (EM₁ Ĝ) embase embase) ≡ G
ΩEM₁≡ = isoToPath ΩEM₁Iso
--------- Ω (EMₙ₊₁ G) ≃ EMₙ G ---------
module _ {G : AbGroup ℓ} where
open AbGroupStr (snd G)
renaming (_+_ to _+G_ ; -_ to -G_ ; assoc to assocG)
CODE : (n : ℕ) → EM G (suc (suc n)) → TypeOfHLevel ℓ (3 + n)
CODE n =
trElim (λ _ → isOfHLevelTypeOfHLevel (3 + n))
λ { north → EM G (suc n) , hLevelEM G (suc n)
; south → EM G (suc n) , hLevelEM G (suc n)
; (merid a i) → fib n a i}
where
fib : (n : ℕ) → (a : EM-raw G (suc n))
→ Path (TypeOfHLevel _ (3 + n))
(EM G (suc n) , hLevelEM G (suc n))
(EM G (suc n) , hLevelEM G (suc n))
fib zero a = Σ≡Prop (λ _ → isPropIsOfHLevel 3)
(isoToPath (addIso 1 a))
fib (suc n) a = Σ≡Prop (λ _ → isPropIsOfHLevel (4 + n))
(isoToPath (addIso (suc (suc n)) ∣ a ∣))
decode' : (n : ℕ) (x : EM G (suc (suc n))) → CODE n x .fst → 0ₖ (suc (suc n)) ≡ x
decode' n =
trElim (λ _ → isOfHLevelΠ (4 + n)
λ _ → isOfHLevelPath (4 + n) (isOfHLevelTrunc (4 + n)) _ _)
λ { north → f n
; south → g n
; (merid a i) → main a i}
where
f : (n : ℕ) → _
f n = σ-EM' n
g : (n : ℕ) → EM G (suc n) → ∣ ptEM-raw ∣ ≡ ∣ south ∣
g n x = σ-EM' n x ∙ cong ∣_∣ₕ (merid ptEM-raw)
lem₂ : (n : ℕ) (a x : _)
→ Path (Path (EM G (suc (suc n))) _ _)
((λ i → cong ∣_∣ₕ (σ-EM n x) i) ∙ sym (cong ∣_∣ₕ (σ-EM n a)) ∙ (λ i → ∣ merid a i ∣ₕ))
(g n (EM-raw→EM G (suc n) x))
lem₂ zero a x =
cong (f zero x ∙_)
(cong (_∙ cong ∣_∣ₕ (merid a)) (cong (cong ∣_∣ₕ) (symDistr (merid a) (sym (merid embase)))
∙ cong-∙ ∣_∣ₕ (merid embase) (sym (merid a)))
∙∙ sym (∙assoc _ _ _)
∙∙ cong (cong ∣_∣ₕ (merid embase) ∙_) (lCancel (cong ∣_∣ₕ (merid a)))
∙ sym (rUnit _))
lem₂ (suc n) a x =
cong (f (suc n) ∣ x ∣ ∙_)
((cong (_∙ cong ∣_∣ₕ (merid a)) (cong (cong ∣_∣ₕ) (symDistr (merid a) (sym (merid north)))
∙ cong-∙ ∣_∣ₕ (merid north) (sym (merid a)))
∙∙ sym (∙assoc _ _ _)
∙∙ cong (cong ∣_∣ₕ (merid north) ∙_) (lCancel (cong ∣_∣ₕ (merid a)))
∙ sym (rUnit _)))
lem : (n : ℕ) (x a : EM-raw G (suc n))
→ f n (transport (sym (cong (λ x → CODE n x .fst) (cong ∣_∣ₕ (merid a))))
(EM-raw→EM G (suc n) x))
≡ cong ∣_∣ₕ (σ-EM n x) ∙ sym (cong ∣_∣ₕ (σ-EM n a))
lem zero x a = (λ i → cong ∣_∣ₕ (merid (transportRefl x i -[ 1 ]ₖ a) ∙ sym (merid embase)))
∙∙ σ-EM'-hom zero x (-ₖ a)
∙∙ cong (f zero x ∙_) (σ-EM'-ₖ zero a)
lem (suc n) x a =
cong (f (suc n)) (λ i → transportRefl ∣ x ∣ i -[ 2 + n ]ₖ ∣ a ∣)
∙∙ σ-EM'-hom (suc n) ∣ x ∣ (-ₖ ∣ a ∣)
∙∙ cong (f (suc n) ∣ x ∣ ∙_) (σ-EM'-ₖ (suc n) ∣ a ∣)
main : (a : _)
→ PathP (λ i → CODE n ∣ merid a i ∣ₕ .fst
→ 0ₖ (suc (suc n)) ≡ ∣ merid a i ∣ₕ) (f n) (g n)
main a =
toPathP (funExt
(EM-elim _ (λ _ → isOfHLevelPathP (2 + (suc n)) (isOfHLevelTrunc (4 + n) _ _) _ _)
λ x →
((λ i → transp (λ j → Path (EM G (2 + n)) ∣ ptEM-raw ∣ ∣ merid a (i ∨ j) ∣)
i (compPath-filler (lem n x a i) (cong ∣_∣ₕ (merid a)) i) ))
∙∙ sym (∙assoc _ _ _)
∙∙ lem₂ n a x))
encode' : (n : ℕ) (x : EM G (suc (suc n))) → 0ₖ (suc (suc n)) ≡ x → CODE n x .fst
encode' n x p = subst (λ x → CODE n x .fst) p (0ₖ (suc n))
decode'-encode' : (n : ℕ) (x : EM G (2 + n)) (p : 0ₖ (2 + n) ≡ x)
→ decode' n x (encode' n x p) ≡ p
decode'-encode' zero x =
J (λ x p → decode' 0 x (encode' 0 x p) ≡ p)
(σ-EM'-0ₖ 0)
decode'-encode' (suc n) x =
J (λ x p → decode' (suc n) x (encode' (suc n) x p) ≡ p)
(σ-EM'-0ₖ (suc n))
encode'-decode' : (n : ℕ) (x : _)
→ encode' n (0ₖ (suc (suc n))) (decode' n (0ₖ (suc (suc n))) x) ≡ x
encode'-decode' zero x =
cong (encode' zero (0ₖ 2)) (cong-∙ ∣_∣ₕ (merid x) (sym (merid embase)))
∙∙ substComposite (λ x → CODE zero x .fst)
(cong ∣_∣ₕ (merid x)) (sym (cong ∣_∣ₕ (merid ptEM-raw))) embase
∙∙ (cong (subst (λ x₁ → CODE zero x₁ .fst) (λ i → ∣ merid embase (~ i) ∣ₕ))
(λ i → lUnitₖ 1 (transportRefl x i) i)
∙ (λ i → rUnitₖ 1 (transportRefl x i) i))
encode'-decode' (suc n) =
trElim (λ _ → isOfHLevelTruncPath {n = 4 + n})
λ x → cong (encode' (suc n) (0ₖ (3 + n))) (cong-∙ ∣_∣ₕ (merid x) (sym (merid north)))
∙∙ substComposite (λ x → CODE (suc n) x .fst)
(cong ∣_∣ₕ (merid x)) (sym (cong ∣_∣ₕ (merid ptEM-raw))) (0ₖ (2 + n))
∙∙ cong (subst (λ x₁ → CODE (suc n) x₁ .fst) (λ i → ∣ merid ptEM-raw (~ i) ∣ₕ))
(λ i → lUnitₖ (2 + n) (transportRefl ∣ x ∣ₕ i) i)
∙ (λ i → rUnitₖ (2 + n) (transportRefl ∣ x ∣ₕ i) i)
Iso-EM-ΩEM+1 : (n : ℕ) → Iso (EM G n) (typ (Ω (EM∙ G (suc n))))
Iso-EM-ΩEM+1 zero = invIso (ΩEM₁Iso (AbGroup→Group G))
Iso.fun (Iso-EM-ΩEM+1 (suc zero)) = decode' 0 (0ₖ 2)
Iso.inv (Iso-EM-ΩEM+1 (suc zero)) = encode' 0 (0ₖ 2)
Iso.rightInv (Iso-EM-ΩEM+1 (suc zero)) = decode'-encode' 0 (0ₖ 2)
Iso.leftInv (Iso-EM-ΩEM+1 (suc zero)) = encode'-decode' 0
Iso.fun (Iso-EM-ΩEM+1 (suc (suc n))) = decode' (suc n) (0ₖ (3 + n))
Iso.inv (Iso-EM-ΩEM+1 (suc (suc n))) = encode' (suc n) (0ₖ (3 + n))
Iso.rightInv (Iso-EM-ΩEM+1 (suc (suc n))) = decode'-encode' (suc n) (0ₖ (3 + n))
Iso.leftInv (Iso-EM-ΩEM+1 (suc (suc n))) = encode'-decode' (suc n)
EM≃ΩEM+1 : (n : ℕ) → EM G n ≃ typ (Ω (EM∙ G (suc n)))
EM≃ΩEM+1 n = isoToEquiv (Iso-EM-ΩEM+1 n)
-- Some properties of the isomorphism
EM→ΩEM+1 : (n : ℕ) → EM G n → typ (Ω (EM∙ G (suc n)))
EM→ΩEM+1 n = Iso.fun (Iso-EM-ΩEM+1 n)
ΩEM+1→EM : (n : ℕ) → typ (Ω (EM∙ G (suc n))) → EM G n
ΩEM+1→EM n = Iso.inv (Iso-EM-ΩEM+1 n)
EM→ΩEM+1-0ₖ : (n : ℕ) → EM→ΩEM+1 n (0ₖ n) ≡ refl
EM→ΩEM+1-0ₖ zero = emloop-1g _
EM→ΩEM+1-0ₖ (suc zero) = cong (cong ∣_∣ₕ) (rCancel (merid ptEM-raw))
EM→ΩEM+1-0ₖ (suc (suc n)) = cong (cong ∣_∣ₕ) (rCancel (merid ptEM-raw))
EM→ΩEM+1-hom : (n : ℕ) (x y : EM G n)
→ EM→ΩEM+1 n (x +[ n ]ₖ y) ≡ EM→ΩEM+1 n x ∙ EM→ΩEM+1 n y
EM→ΩEM+1-hom zero x y = emloop-comp _ x y
EM→ΩEM+1-hom (suc zero) x y = σ-EM'-hom zero x y
EM→ΩEM+1-hom (suc (suc n)) x y = σ-EM'-hom (suc n) x y
ΩEM+1→EM-hom : (n : ℕ) → (p q : typ (Ω (EM∙ G (suc n))))
→ ΩEM+1→EM n (p ∙ q) ≡ (ΩEM+1→EM n p) +[ n ]ₖ (ΩEM+1→EM n q)
ΩEM+1→EM-hom n =
morphLemmas.isMorphInv (λ x y → x +[ n ]ₖ y) (_∙_) (EM→ΩEM+1 n)
(EM→ΩEM+1-hom n) (ΩEM+1→EM n)
(Iso.rightInv (Iso-EM-ΩEM+1 n)) (Iso.leftInv (Iso-EM-ΩEM+1 n))
ΩEM+1→EM-refl : (n : ℕ) → ΩEM+1→EM n refl ≡ 0ₖ n
ΩEM+1→EM-refl zero = transportRefl 0g
ΩEM+1→EM-refl (suc zero) = refl
ΩEM+1→EM-refl (suc (suc n)) = refl
EM→ΩEM+1∙ : (n : ℕ) → EM∙ G n →∙ Ω (EM∙ G (suc n))
EM→ΩEM+1∙ n .fst = EM→ΩEM+1 n
EM→ΩEM+1∙ zero .snd = emloop-1g (AbGroup→Group G)
EM→ΩEM+1∙ (suc zero) .snd = cong (cong ∣_∣ₕ) (rCancel (merid embase))
EM→ΩEM+1∙ (suc (suc n)) .snd = cong (cong ∣_∣ₕ) (rCancel (merid north))
EM≃ΩEM+1∙ : (n : ℕ) → EM∙ G n ≡ Ω (EM∙ G (suc n))
EM≃ΩEM+1∙ n = ua∙ (EM≃ΩEM+1 n) (EM→ΩEM+1-0ₖ n)
isHomogeneousEM : (n : ℕ) → isHomogeneous (EM∙ G n)
isHomogeneousEM n x =
ua∙ (isoToEquiv (addIso n x)) (lUnitₖ n x)
-- Some HLevel lemmas about function spaces (EM∙ G n →∙ EM∙ H m), mainly used for
-- the cup product
module _ where
open AbGroupStr renaming (_+_ to comp)
isContr-↓∙ : {G : AbGroup ℓ} {H : AbGroup ℓ'} (n : ℕ) → isContr (EM∙ G (suc n) →∙ EM∙ H n)
fst (isContr-↓∙ {G = G} {H = H} zero) = (λ _ → 0g (snd H)) , refl
snd (isContr-↓∙{G = G} {H = H} zero) (f , p) =
Σ≡Prop (λ x → is-set (snd H) _ _)
(funExt (raw-elim G 0 (λ _ → is-set (snd H) _ _) (sym p)))
fst (isContr-↓∙ {G = G} {H = H} (suc n)) = (λ _ → 0ₖ (suc n)) , refl
fst (snd (isContr-↓∙ {G = G} {H = H} (suc n)) f i) x =
trElim {B = λ x → 0ₖ (suc n) ≡ fst f x}
(λ _ → isOfHLevelPath (4 + n) (isOfHLevelSuc (3 + n) (hLevelEM H (suc n))) _ _)
(raw-elim _ _ (λ _ → hLevelEM H (suc n) _ _) (sym (snd f)))
x i
snd (snd (isContr-↓∙ (suc n)) f i) j = snd f (~ i ∨ j)
isContr-↓∙' : {G : AbGroup ℓ} {H : AbGroup ℓ'} (n : ℕ)
→ isContr ((EM-raw G (suc n) , ptEM-raw) →∙ EM∙ H n)
isContr-↓∙' zero = isContr-↓∙ zero
fst (isContr-↓∙' (suc n)) = (λ _ → 0ₖ (suc n)) , refl
fst (snd (isContr-↓∙' {H = H} (suc n)) f i) x =
raw-elim _ _ {A = λ x → 0ₖ (suc n) ≡ fst f x}
(λ _ → hLevelEM H (suc n) _ _) (sym (snd f)) x i
snd (snd (isContr-↓∙' (suc n)) f i) j = snd f (~ i ∨ j)
isOfHLevel→∙EM : ∀ {ℓ} {A : Pointed ℓ} {G : AbGroup ℓ'} (n m : ℕ)
→ isOfHLevel (suc m) (A →∙ EM∙ G n)
→ isOfHLevel (suc (suc m)) (A →∙ EM∙ G (suc n))
isOfHLevel→∙EM {A = A} {G = G} n m hlev = step₃
where
step₁ : isOfHLevel (suc m) (A →∙ Ω (EM∙ G (suc n)))
step₁ =
subst (isOfHLevel (suc m))
(λ i → A →∙ ua∙ {A = Ω (EM∙ G (suc n))} {B = EM∙ G n}
(invEquiv (EM≃ΩEM+1 n))
(ΩEM+1→EM-refl n) (~ i)) hlev
step₂ : isOfHLevel (suc m) (typ (Ω (A →∙ EM∙ G (suc n) ∙)))
step₂ = isOfHLevelRetractFromIso (suc m) (invIso (invIso (ΩfunExtIso _ _))) step₁
step₃ : isOfHLevel (suc (suc m)) (A →∙ EM∙ G (suc n))
step₃ = isOfHLevelΩ→isOfHLevel m
λ f → subst (λ x → isOfHLevel (suc m) (typ (Ω x)))
(isHomogeneous→∙ (isHomogeneousEM (suc n)) f)
step₂
isOfHLevel↑∙ : {G : AbGroup ℓ} {H : AbGroup ℓ'}
→ ∀ n m → isOfHLevel (2 + n) (EM∙ G (suc m) →∙ EM∙ H (suc (n + m)))
isOfHLevel↑∙ zero m = isOfHLevel→∙EM m 0 (isContr→isProp (isContr-↓∙ m))
isOfHLevel↑∙ (suc n) m = isOfHLevel→∙EM (suc (n + m)) (suc n) (isOfHLevel↑∙ n m)
isOfHLevel↑∙' : {G : AbGroup ℓ} {H : AbGroup ℓ'}
→ ∀ n m → isOfHLevel (2 + n) (EM-raw∙ G (suc m) →∙ EM∙ H (suc (n + m)))
isOfHLevel↑∙' zero m = isOfHLevel→∙EM m 0 (isContr→isProp (isContr-↓∙' m))
isOfHLevel↑∙' (suc n) m = isOfHLevel→∙EM (suc (n + m)) (suc n) (isOfHLevel↑∙' n m)
→∙EMPath : ∀ {ℓ} {G : AbGroup ℓ} (A : Pointed ℓ') (n : ℕ)
→ Ω (A →∙ EM∙ G (suc n) ∙) ≡ (A →∙ EM∙ G n ∙)
→∙EMPath {G = G} A n =
ua∙ (isoToEquiv (ΩfunExtIso A (EM∙ G (suc n)))) refl
∙ (λ i → (A →∙ EM≃ΩEM+1∙ {G = G} n (~ i) ∙))
private
contr∙-lem : {G : AbGroup ℓ} {H : AbGroup ℓ'} {L : AbGroup ℓ''} (n m : ℕ)
→ isContr (EM∙ G (suc n) →∙ (EM∙ H (suc m) →∙ EM∙ L (suc (n + m)) ∙))
fst (contr∙-lem n m) = (λ _ → (λ _ → 0ₖ _) , refl), refl
snd (contr∙-lem {G = G} {H = H} {L = L} n m) (f , p) =
→∙Homogeneous≡ (isHomogeneous→∙ (isHomogeneousEM _))
(sym (funExt (help n f p)))
where
help : (n : ℕ) → (f : EM G (suc n) → EM∙ H (suc m) →∙ EM∙ L (suc (n + m)))
→ f (snd (EM∙ G (suc n))) ≡ snd (EM∙ H (suc m) →∙ EM∙ L (suc (n + m)) ∙)
→ (x : _) → (f x) ≡ ((λ _ → 0ₖ _) , refl)
help zero f p =
raw-elim G zero
(λ _ → isOfHLevel↑∙ zero m _ _) p
help (suc n) f p =
trElim (λ _ → isOfHLevelPath (4 + n)
(subst (λ x → isOfHLevel x (EM∙ H (suc m) →∙ EM∙ L (suc ((suc n) + m))))
(λ i → suc (suc (+-comm (suc n) 1 i)))
(isOfHLevelPlus' {n = 1} (3 + n) (isOfHLevel↑∙ (suc n) m))) _ _)
(raw-elim G (suc n)
(λ _ → isOfHLevel↑∙ (suc n) m _ _) p)
isOfHLevel↑∙∙ : {G : AbGroup ℓ} {H : AbGroup ℓ'} {L : AbGroup ℓ''}
→ ∀ n m l → isOfHLevel (2 + l) (EM∙ G (suc n)
→∙ (EM∙ H (suc m)
→∙ EM∙ L (suc (suc (l + n + m))) ∙))
isOfHLevel↑∙∙ {G = G} {H = H} {L = L} n m zero =
isOfHLevelΩ→isOfHLevel 0 λ f
→ subst
isProp (cong (λ x → typ (Ω x))
(isHomogeneous→∙ (isHomogeneous→∙ (isHomogeneousEM _)) f))
(isOfHLevelRetractFromIso 1 (ΩfunExtIso _ _) h)
where
h : isProp (EM∙ G (suc n)
→∙ (Ω (EM∙ H (suc m)
→∙ EM∙ L (suc (suc (n + m))) ∙)))
h =
subst isProp
(λ i → EM∙ G (suc n)
→∙ (→∙EMPath {G = L} (EM∙ H (suc m)) (suc (n + m)) (~ i)))
(isContr→isProp (contr∙-lem n m))
isOfHLevel↑∙∙ {G = G} {H = H} {L = L} n m (suc l) =
isOfHLevelΩ→isOfHLevel (suc l)
λ f →
subst (isOfHLevel (2 + l))
(cong (λ x → typ (Ω x))
(isHomogeneous→∙ (isHomogeneous→∙ (isHomogeneousEM _)) f))
(isOfHLevelRetractFromIso (2 + l) (ΩfunExtIso _ _) h)
where
h : isOfHLevel (2 + l)
(EM∙ G (suc n)
→∙ (Ω (EM∙ H (suc m)
→∙ EM∙ L (suc (suc (suc (l + n + m)))) ∙)))
h =
subst (isOfHLevel (2 + l))
(λ i → EM∙ G (suc n)
→∙ →∙EMPath {G = L} (EM∙ H (suc m)) (suc (suc (l + n + m))) (~ i))
(isOfHLevel↑∙∙ n m l)
-- A homomorphism φ : G → H of AbGroups induces a homomorphism
-- φ' : K(G,n) → K(H,n)
inducedFun-EM-raw : {G' : AbGroup ℓ} {H' : AbGroup ℓ'}
→ AbGroupHom G' H'
→ ∀ n
→ EM-raw G' n → EM-raw H' n
inducedFun-EM-raw f =
elim+2 (fst f)
(EMrec _ emsquash embase
(λ g → emloop (fst f g))
λ g h → compPathR→PathP (sym
(sym (lUnit _)
∙∙ cong (_∙ (sym (emloop (fst f h))))
(cong emloop (IsGroupHom.pres· (snd f) g h)
∙ emloop-comp _ (fst f g) (fst f h))
∙∙ sym (∙assoc _ _ _)
∙∙ cong (emloop (fst f g) ∙_) (rCancel _)
∙∙ sym (rUnit _))))
(λ n ind → λ { north → north
; south → south
; (merid a i) → merid (ind a) i} )
inducedFun-EM-rawIso : {G' : AbGroup ℓ} {H' : AbGroup ℓ'}
→ AbGroupEquiv G' H'
→ ∀ n → Iso (EM-raw G' n) (EM-raw H' n)
Iso.fun (inducedFun-EM-rawIso e n) = inducedFun-EM-raw (_ , (snd e)) n
Iso.inv (inducedFun-EM-rawIso e n) = inducedFun-EM-raw (_ , isGroupHomInv e) n
Iso.rightInv (inducedFun-EM-rawIso e n) = h n
where
h : (n : ℕ) → section (inducedFun-EM-raw (fst e .fst , snd e) n)
(inducedFun-EM-raw (invEq (fst e) , isGroupHomInv e) n)
h = elim+2
(secEq (fst e))
(elimSet _ (λ _ → emsquash _ _) refl
(λ g → compPathR→PathP
((sym (cong₂ _∙_ (cong emloop (secEq (fst e) g)) (sym (lUnit _))
∙ rCancel _)))))
λ n p → λ { north → refl
; south → refl
; (merid a i) k → merid (p a k) i}
Iso.leftInv (inducedFun-EM-rawIso e n) = h n
where
h : (n : ℕ) → retract (Iso.fun (inducedFun-EM-rawIso e n))
(Iso.inv (inducedFun-EM-rawIso e n))
h = elim+2
(retEq (fst e))
(elimSet _ (λ _ → emsquash _ _) refl
(λ g → compPathR→PathP
((sym (cong₂ _∙_ (cong emloop (retEq (fst e) g)) (sym (lUnit _))
∙ rCancel _)))))
λ n p → λ { north → refl
; south → refl
; (merid a i) k → merid (p a k) i}
Iso→EMIso : {G : AbGroup ℓ} {H : AbGroup ℓ'}
→ AbGroupEquiv G H → ∀ n → Iso (EM G n) (EM H n)
Iso→EMIso is zero = inducedFun-EM-rawIso is zero
Iso→EMIso is (suc zero) = inducedFun-EM-rawIso is 1
Iso→EMIso is (suc (suc n)) = mapCompIso (inducedFun-EM-rawIso is (suc (suc n)))
EM⊗-commIso : {G : AbGroup ℓ} {H : AbGroup ℓ'}
→ ∀ n → Iso (EM (G ⨂ H) n) (EM (H ⨂ G) n)
EM⊗-commIso {G = G} {H = H} = Iso→EMIso (GroupIso→GroupEquiv ⨂-commIso)
EM⊗-assocIso : {G : AbGroup ℓ} {H : AbGroup ℓ'} {L : AbGroup ℓ''}
→ ∀ n → Iso (EM (G ⨂ (H ⨂ L)) n) (EM ((G ⨂ H) ⨂ L) n)
EM⊗-assocIso = Iso→EMIso (GroupIso→GroupEquiv (GroupEquiv→GroupIso ⨂assoc))
| 42.796296
| 101
| 0.501817
|
341fe40b673875166055ca293c18f814759f5b99
| 1,000
|
agda
|
Agda
|
presentationsAndExampleCode/agdaImplementorsMeetingGlasgow22April2016AntonSetzer/NativeIOSafe.agda
|
agda/ooAgda
|
7cc45e0148a4a508d20ed67e791544c30fecd795
|
[
"MIT"
] | 23
|
2016-06-19T12:57:55.000Z
|
2020-10-12T23:15:25.000Z
|
presentationsAndExampleCode/agdaImplementorsMeetingGlasgow22April2016AntonSetzer/NativeIOSafe.agda
|
agda/ooAgda
|
7cc45e0148a4a508d20ed67e791544c30fecd795
|
[
"MIT"
] | null | null | null |
presentationsAndExampleCode/agdaImplementorsMeetingGlasgow22April2016AntonSetzer/NativeIOSafe.agda
|
agda/ooAgda
|
7cc45e0148a4a508d20ed67e791544c30fecd795
|
[
"MIT"
] | 2
|
2018-09-01T15:02:37.000Z
|
2022-03-12T11:41:00.000Z
|
module NativeIOSafe where
open import Data.Maybe.Base using (Maybe; nothing; just) public
open import Data.String.Base using (String) public
record Unit : Set where
constructor unit
{-# COMPILED_DATA Unit () () #-}
postulate
NativeIO : Set → Set
nativeReturn : {A : Set} → A → NativeIO A
_native>>=_ : {A B : Set} → NativeIO A → (A → NativeIO B) → NativeIO B
{-# BUILTIN IO NativeIO #-}
{-# COMPILED_TYPE NativeIO IO #-} -- IO.FFI.AgdaIO
{-# COMPILED _native>>=_ (\_ _ -> (>>=) :: IO a -> (a -> IO b) -> IO b) #-}
{-# COMPILED nativeReturn (\_ -> return :: a -> IO a) #-}
postulate
nativeGetLine : NativeIO (Maybe String)
nativePutStrLn : String → NativeIO Unit
{-# IMPORT Data.Text #-}
{-# IMPORT System.IO.Error #-}
{-# COMPILED nativePutStrLn (\ s -> putStrLn (Data.Text.unpack s)) #-}
{-# COMPILED nativeGetLine (fmap (Just . Data.Text.pack) getLine `System.IO.Error.catchIOError` \ err -> if System.IO.Error.isEOFError err then return Nothing else ioError err) #-}
| 33.333333
| 180
| 0.651
|
43edc4ab94e45358cb68f1f0e07c898ec0d67cbf
| 43,113
|
agda
|
Agda
|
src/Quotient.agda
|
nad/equality
|
402b20615cfe9ca944662380d7b2d69b0f175200
|
[
"MIT"
] | 3
|
2020-05-21T22:58:50.000Z
|
2021-09-02T17:18:15.000Z
|
src/Quotient.agda
|
nad/equality
|
402b20615cfe9ca944662380d7b2d69b0f175200
|
[
"MIT"
] | null | null | null |
src/Quotient.agda
|
nad/equality
|
402b20615cfe9ca944662380d7b2d69b0f175200
|
[
"MIT"
] | null | null | null |
------------------------------------------------------------------------
-- Quotients (set-quotients), defined using a higher inductive type
------------------------------------------------------------------------
{-# OPTIONS --erased-cubical --safe #-}
-- Partly following the HoTT book.
--
-- Unlike the HoTT book, but following the cubical library (in which
-- set quotients were implemented by Zesen Qian and Anders Mörtberg),
-- the quotienting relations are not (always) required to be
-- propositional.
-- The module is parametrised by a notion of equality. The higher
-- constructors of the HIT defining quotients use path equality, but
-- the supplied notion of equality is used for many other things.
import Equality.Path as P
module Quotient
{e⁺} (eq : ∀ {a p} → P.Equality-with-paths a p e⁺) where
private
open module D = P.Derived-definitions-and-properties eq hiding (elim)
import H-level
open import Logical-equivalence using (_⇔_)
open import Prelude
open import Bijection equality-with-J using (_↔_)
open import Equality.Decidable-UIP equality-with-J
open import Equality.Path.Isomorphisms eq
open import Equivalence equality-with-J as Eq using (_≃_)
open import Equivalence-relation equality-with-J
open import Erased.Cubical eq as E
using (Erased; Erasedᴾ; Stable; Very-stable; Very-stable-≡)
open import Function-universe equality-with-J as F hiding (_∘_; id)
open import H-level.Closure equality-with-J
import H-level.Truncation.Church equality-with-J as Trunc
open import H-level.Truncation.Propositional eq as TruncP
using (∥_∥; ∣_∣; Surjective; Axiom-of-countable-choice)
open import Monad equality-with-J
open import Preimage equality-with-J using (_⁻¹_)
open import Quotient.Erased.Basics eq as QE using (_/ᴱ_)
import Quotient.Families-of-equivalence-classes equality-with-J
as Quotient
open import Surjection equality-with-J using (_↠_)
open import Univalence-axiom equality-with-J
private
module PH = H-level P.equality-with-J
open module H = H-level equality-with-J
private
variable
a a₁ a₂ b p r r₁ r₂ : Level
k : Isomorphism-kind
A A₁ A₂ B : Type a
P : A → Type p
R R₁ R₂ : A → A → Type r
f x y : A
------------------------------------------------------------------------
-- Quotients
-- The quotient type constructor.
infix 5 _/_
data _/_ (A : Type a) (R : A → A → Type r) : Type (a ⊔ r) where
[_] : A → A / R
[]-respects-relationᴾ : R x y → [ x ] P.≡ [ y ]
/-is-setᴾ : P.Is-set (A / R)
-- [_] respects the quotient relation.
[]-respects-relation : R x y → _≡_ {A = A / R} [ x ] [ y ]
[]-respects-relation = _↔_.from ≡↔≡ ∘ []-respects-relationᴾ
-- Quotients are sets.
/-is-set : Is-set (A / R)
/-is-set = _↔_.from (H-level↔H-level 2) /-is-setᴾ
-- An eliminator, expressed using paths.
record Elimᴾ′ {A : Type a} {R : A → A → Type r} (P : A / R → Type p) :
Type (a ⊔ r ⊔ p) where
no-eta-equality
field
[]ʳ : ∀ x → P [ x ]
[]-respects-relationʳ :
(r : R x y) →
P.[ (λ i → P ([]-respects-relationᴾ r i)) ] []ʳ x ≡ []ʳ y
is-setʳ :
{eq₁ eq₂ : x P.≡ y} {p : P x} {q : P y}
(eq₃ : P.[ (λ i → P (eq₁ i)) ] p ≡ q)
(eq₄ : P.[ (λ i → P (eq₂ i)) ] p ≡ q) →
P.[ (λ i → P.[ (λ j → P (/-is-setᴾ eq₁ eq₂ i j)) ] p ≡ q) ]
eq₃ ≡ eq₄
open Elimᴾ′ public
elimᴾ′ : Elimᴾ′ P → (x : A / R) → P x
elimᴾ′ {A = A} {R = R} {P = P} e = helper
where
module E′ = Elimᴾ′ e
helper : (x : A / R) → P x
helper [ x ] = E′.[]ʳ x
helper ([]-respects-relationᴾ r i) = E′.[]-respects-relationʳ r i
helper (/-is-setᴾ p q i j) =
E′.is-setʳ (λ i → helper (p i)) (λ i → helper (q i)) i j
-- A possibly more useful eliminator, expressed using paths.
record Elimᴾ {A : Type a} {R : A → A → Type r} (P : A / R → Type p) :
Type (a ⊔ r ⊔ p) where
no-eta-equality
field
[]ʳ : ∀ x → P [ x ]
[]-respects-relationʳ :
(r : R x y) →
P.[ (λ i → P ([]-respects-relationᴾ r i)) ] []ʳ x ≡ []ʳ y
is-setʳ : ∀ x → P.Is-set (P x)
open Elimᴾ public
elimᴾ : Elimᴾ P → (x : A / R) → P x
elimᴾ e = elimᴾ′ λ where
.[]ʳ → E′.[]ʳ
.[]-respects-relationʳ → E′.[]-respects-relationʳ
.is-setʳ → P.heterogeneous-UIP E′.is-setʳ _
where
module E′ = Elimᴾ e
private
-- One can define elimᴾ′ using elimᴾ.
elimᴾ′₂ : Elimᴾ′ P → (x : A / R) → P x
elimᴾ′₂ {P = P} e = elimᴾ λ where
.[]ʳ → E′.[]ʳ
.[]-respects-relationʳ → E′.[]-respects-relationʳ
.is-setʳ x {y} {z} p q → $⟨ E′.is-setʳ p q ⟩
P.[ (λ i →
P.[ (λ j → P (/-is-setᴾ P.refl P.refl i j)) ] y ≡ z) ]
p ≡ q ↝⟨ P.subst (λ eq → P.[ (λ i → P.[ (λ j → P (eq i j)) ] y ≡ z) ] p ≡ q)
(PH.mono₁ 2 /-is-setᴾ _ _) ⟩
P.[ (λ _ → P.[ (λ _ → P x) ] y ≡ z) ] p ≡ q ↔⟨⟩
p P.≡ q □
where
module E′ = Elimᴾ′ e
-- A non-dependent eliminator, expressed using paths.
record Recᴾ {A : Type a} (R : A → A → Type r) (B : Type b) :
Type (a ⊔ r ⊔ b) where
no-eta-equality
field
[]ʳ : A → B
[]-respects-relationʳ : (r : R x y) → []ʳ x P.≡ []ʳ y
is-setʳ : P.Is-set B
open Recᴾ public
recᴾ : Recᴾ R B → A / R → B
recᴾ r = elimᴾ λ where
.[]ʳ → R.[]ʳ
.[]-respects-relationʳ → R.[]-respects-relationʳ
.is-setʳ _ → R.is-setʳ
where
module R = Recᴾ r
-- An eliminator.
record Elim {A : Type a} {R : A → A → Type r} (P : A / R → Type p) :
Type (a ⊔ r ⊔ p) where
no-eta-equality
field
[]ʳ : ∀ x → P [ x ]
[]-respects-relationʳ :
(r : R x y) →
subst P ([]-respects-relation r) ([]ʳ x) ≡ []ʳ y
is-setʳ : ∀ x → Is-set (P x)
open Elim public
elim : Elim P → (x : A / R) → P x
elim e = elimᴾ λ where
.[]ʳ → E′.[]ʳ
.[]-respects-relationʳ → subst≡→[]≡ ∘ E′.[]-respects-relationʳ
.is-setʳ → _↔_.to (H-level↔H-level 2) ∘ E′.is-setʳ
where
module E′ = Elim e
-- A non-dependent eliminator.
record Rec {A : Type a} (R : A → A → Type r) (B : Type b) :
Type (a ⊔ r ⊔ b) where
no-eta-equality
field
[]ʳ : A → B
[]-respects-relationʳ : (r : R x y) → []ʳ x ≡ []ʳ y
is-setʳ : Is-set B
open Rec public
rec : Rec R B → A / R → B
rec r = recᴾ λ where
.[]ʳ → R.[]ʳ
.[]-respects-relationʳ → _↔_.to ≡↔≡ ∘ R.[]-respects-relationʳ
.is-setʳ → _↔_.to (H-level↔H-level 2) R.is-setʳ
where
module R = Rec r
-- A variant of elim that can be used if the motive composed with [_]
-- is a family of propositions.
--
-- I took the idea for this eliminator from Nicolai Kraus.
record Elim-prop
{A : Type a} {R : A → A → Type r} (P : A / R → Type p) :
Type (a ⊔ r ⊔ p) where
no-eta-equality
field
[]ʳ : ∀ x → P [ x ]
is-propositionʳ : ∀ x → Is-proposition (P [ x ])
open Elim-prop public
elim-prop : Elim-prop P → (x : A / R) → P x
elim-prop e = elim λ where
.[]ʳ → E′.[]ʳ
.[]-respects-relationʳ _ → E′.is-propositionʳ _ _ _
.is-setʳ → elim λ where
.[]ʳ → mono₁ 1 ∘ E′.is-propositionʳ
.[]-respects-relationʳ _ → H-level-propositional ext 2 _ _
.is-setʳ _ → mono₁ 1 (H-level-propositional ext 2)
where
module E′ = Elim-prop e
-- A variant of rec that can be used if the motive is a proposition.
record Rec-prop (A : Type a) (B : Type b) : Type (a ⊔ b) where
no-eta-equality
field
[]ʳ : A → B
is-propositionʳ : Is-proposition B
open Rec-prop public
rec-prop : Rec-prop A B → A / R → B
rec-prop r = elim-prop λ where
.[]ʳ → R.[]ʳ
.is-propositionʳ _ → R.is-propositionʳ
where
module R = Rec-prop r
------------------------------------------------------------------------
-- Conversion functions
-- One can convert from quotients with erased higher constructors to
-- quotients with regular higher constructors.
/ᴱ→/ : A /ᴱ R → A / R
/ᴱ→/ = QE.rec λ where
.QE.[]ʳ → [_]
.QE.[]-respects-relationʳ → []-respects-relation
.QE.is-setʳ → /-is-set
-- In an erased context quotients with erased higher constructors are
-- equivalent to quotients with regular higher constructors.
@0 /ᴱ≃/ : A /ᴱ R ≃ A / R
/ᴱ≃/ {A = A} {R = R} = Eq.↔⇒≃ (record
{ surjection = record
{ logical-equivalence = record
{ to = /ᴱ→/
; from = rec λ @0 where
.[]ʳ → QE.[_]
.[]-respects-relationʳ → QE.[]-respects-relation
.is-setʳ → QE./ᴱ-is-set
}
; right-inverse-of = elim λ @0 where
.[]ʳ _ → refl _
.[]-respects-relationʳ _ → /-is-set _ _
.is-setʳ _ → mono₁ 2 /-is-set
}
; left-inverse-of = QE.elim λ where
.QE.[]ʳ _ → refl _
.QE.[]-respects-relationʳ _ → QE./ᴱ-is-set _ _
.QE.is-setʳ _ → mono₁ 2 QE./ᴱ-is-set
})
------------------------------------------------------------------------
-- Some properties
-- [_] is surjective.
[]-surjective : Surjective ([_] {R = R})
[]-surjective = elim-prop λ where
.[]ʳ x → ∣ x , refl _ ∣
.is-propositionʳ _ → TruncP.truncation-is-proposition
-- QE.[_] is surjective.
--
-- This result is not proved in Quotient.Erased, because that module
-- uses --erased-cubical.
[]ᴱ-surjective : Surjective (QE.[_] {R = R})
[]ᴱ-surjective = QE.elim-prop λ where
.QE.[]ʳ x → ∣ x , refl _ ∣
.QE.is-propositionʳ _ → TruncP.truncation-is-proposition
-- Some preservation lemmas.
infix 5 _/-map-∥∥_ _/-map_ _/-cong-∥∥-↠_ _/-cong-↠_ _/-cong-∥∥_ _/-cong_
_/-map-∥∥_ :
(A₁→A₂ : A₁ → A₂) →
(∀ x y → ∥ R₁ x y ∥ → ∥ R₂ (A₁→A₂ x) (A₁→A₂ y) ∥) →
A₁ / R₁ → A₂ / R₂
_/-map-∥∥_ {R₁ = R₁} {R₂ = R₂} A₁→A₂ R₁→R₂ = rec λ where
.[]ʳ → [_] ∘ A₁→A₂
.is-setʳ → /-is-set
.[]-respects-relationʳ {x = x} {y = y} →
R₁ x y ↝⟨ ∣_∣ ⟩
∥ R₁ x y ∥ ↝⟨ R₁→R₂ _ _ ⟩
∥ R₂ (A₁→A₂ x) (A₁→A₂ y) ∥ ↝⟨ TruncP.rec /-is-set []-respects-relation ⟩□
[ A₁→A₂ x ] ≡ [ A₁→A₂ y ] □
_/-map_ :
(A₁→A₂ : A₁ → A₂) →
(∀ x y → R₁ x y → R₂ (A₁→A₂ x) (A₁→A₂ y)) →
A₁ / R₁ → A₂ / R₂
A₁→A₂ /-map R₁→R₂ = A₁→A₂ /-map-∥∥ λ x y → TruncP.∥∥-map (R₁→R₂ x y)
/-cong-∥∥-⇔ :
(A₁⇔A₂ : A₁ ⇔ A₂) →
(∀ x y → ∥ R₁ x y ∥ → ∥ R₂ (_⇔_.to A₁⇔A₂ x) (_⇔_.to A₁⇔A₂ y) ∥) →
(∀ x y → ∥ R₂ x y ∥ → ∥ R₁ (_⇔_.from A₁⇔A₂ x) (_⇔_.from A₁⇔A₂ y) ∥) →
A₁ / R₁ ⇔ A₂ / R₂
/-cong-∥∥-⇔ A₁⇔A₂ R₁→R₂ R₂→R₁ = record
{ to = _⇔_.to A₁⇔A₂ /-map-∥∥ R₁→R₂
; from = _⇔_.from A₁⇔A₂ /-map-∥∥ R₂→R₁
}
/-cong-⇔ :
(A₁⇔A₂ : A₁ ⇔ A₂) →
(∀ x y → R₁ x y → R₂ (_⇔_.to A₁⇔A₂ x) (_⇔_.to A₁⇔A₂ y)) →
(∀ x y → R₂ x y → R₁ (_⇔_.from A₁⇔A₂ x) (_⇔_.from A₁⇔A₂ y)) →
A₁ / R₁ ⇔ A₂ / R₂
/-cong-⇔ A₁⇔A₂ R₁→R₂ R₂→R₁ =
/-cong-∥∥-⇔ A₁⇔A₂ (λ x y → TruncP.∥∥-map (R₁→R₂ x y))
(λ x y → TruncP.∥∥-map (R₂→R₁ x y))
_/-cong-∥∥-↠_ :
(A₁↠A₂ : A₁ ↠ A₂) →
(∀ x y → ∥ R₁ x y ∥ ⇔ ∥ R₂ (_↠_.to A₁↠A₂ x) (_↠_.to A₁↠A₂ y) ∥) →
A₁ / R₁ ↠ A₂ / R₂
_/-cong-∥∥-↠_ {R₁ = R₁} {R₂ = R₂} A₁↠A₂ R₁⇔R₂ = record
{ logical-equivalence = /-cong-∥∥-⇔
(_↠_.logical-equivalence A₁↠A₂)
(λ x y → _⇔_.to (R₁⇔R₂ x y))
(λ x y → ∥ R₂ x y ∥ ↝⟨ ≡⇒↝ _ (sym $ cong₂ (λ x y → ∥ R₂ x y ∥) (right-inverse-of x) (right-inverse-of y)) ⟩
∥ R₂ (to (from x)) (to (from y)) ∥ ↝⟨ _⇔_.from (R₁⇔R₂ _ _) ⟩□
∥ R₁ (from x) (from y) ∥ □)
; right-inverse-of = elim-prop λ where
.[]ʳ x →
[ to (from x) ] ≡⟨ cong [_] $ right-inverse-of x ⟩∎
[ x ] ∎
.is-propositionʳ _ → /-is-set
}
where
open _↠_ A₁↠A₂
_/-cong-↠_ :
(A₁↠A₂ : A₁ ↠ A₂) →
(∀ x y → R₁ x y ⇔ R₂ (_↠_.to A₁↠A₂ x) (_↠_.to A₁↠A₂ y)) →
A₁ / R₁ ↠ A₂ / R₂
A₁↠A₂ /-cong-↠ R₁⇔R₂ =
A₁↠A₂ /-cong-∥∥-↠ λ x y → TruncP.∥∥-cong-⇔ (R₁⇔R₂ x y)
_/-cong-∥∥_ :
{A₁ : Type a₁} {A₂ : Type a₂}
{R₁ : A₁ → A₁ → Type r₁}
{R₂ : A₂ → A₂ → Type r₂} →
(A₁↔A₂ : A₁ ↔[ k ] A₂) →
(∀ x y →
∥ R₁ x y ∥ ⇔
∥ R₂ (to-implication A₁↔A₂ x) (to-implication A₁↔A₂ y) ∥) →
A₁ / R₁ ↔[ k ] A₂ / R₂
_/-cong-∥∥_ {k = k} {R₁ = R₁} {R₂ = R₂} A₁↔A₂′ R₁⇔R₂ =
from-bijection (record
{ surjection = from-isomorphism A₁↔A₂ /-cong-∥∥-↠ λ x y →
∥ R₁ x y ∥ ↝⟨ R₁⇔R₂ x y ⟩
∥ R₂ (to-implication A₁↔A₂′ x) (to-implication A₁↔A₂′ y) ∥ ↝⟨ ≡⇒↝ _ $ cong₂ (λ f g → ∥ R₂ (f x) (g y) ∥)
(to-implication∘from-isomorphism k bijection)
(to-implication∘from-isomorphism k bijection) ⟩□
∥ R₂ (to x) (to y) ∥ □
; left-inverse-of = elim-prop λ where
.[]ʳ x →
[ from (to x) ] ≡⟨ cong [_] $ left-inverse-of x ⟩∎
[ x ] ∎
.is-propositionʳ _ → /-is-set
})
where
A₁↔A₂ = from-isomorphism A₁↔A₂′
open _↔_ A₁↔A₂
_/-cong_ :
{A₁ : Type a₁} {A₂ : Type a₂}
{R₁ : A₁ → A₁ → Type r₁}
{R₂ : A₂ → A₂ → Type r₂} →
(A₁↔A₂ : A₁ ↔[ k ] A₂) →
(∀ x y →
R₁ x y ⇔ R₂ (to-implication A₁↔A₂ x) (to-implication A₁↔A₂ y)) →
A₁ / R₁ ↔[ k ] A₂ / R₂
_/-cong_ A₁↔A₂ R₁⇔R₂ =
A₁↔A₂ /-cong-∥∥ λ x y → TruncP.∥∥-cong-⇔ (R₁⇔R₂ x y)
-- Quotienting by the propositional truncation of a relation is
-- equivalent to quotienting by the relation itself.
/-∥∥≃/ : A / (λ x y → ∥ R x y ∥) ≃ A / R
/-∥∥≃/ {R = R} = F.id /-cong-∥∥ λ x y →
∥ ∥ R x y ∥ ∥ ↔⟨ TruncP.flatten ⟩□
∥ R x y ∥ □
-- If the relation is a propositional equivalence relation, then it is
-- equivalent to equality under [_] (assuming propositional
-- extensionality).
--
-- The basic structure of this proof is that of Proposition 2 in
-- "Quotienting the Delay Monad by Weak Bisimilarity" by Chapman,
-- Uustalu and Veltri.
related≃[equal] :
{R : A → A → Type r} →
Propositional-extensionality r →
Is-equivalence-relation R →
(∀ {x y} → Is-proposition (R x y)) →
∀ {x y} → R x y ≃ _≡_ {A = A / R} [ x ] [ y ]
related≃[equal] {A = A} {r = r} {R = R}
prop-ext R-equiv R-prop {x = x} {y = y} =
_↠_.from (Eq.≃↠⇔ R-prop /-is-set)
(record
{ to = []-respects-relation
; from = λ [x]≡[y] →
$⟨ reflexive ⟩
proj₁ (R′ x [ x ]) ↝⟨ ≡⇒→ (cong (proj₁ ∘ R′ x) [x]≡[y]) ⟩
proj₁ (R′ x [ y ]) ↝⟨ id ⟩□
R x y □
})
where
open Is-equivalence-relation R-equiv
lemma : ∀ {x y z} → R y z → (R x y , R-prop) ≡ (R x z , R-prop)
lemma {x} {y} {z} =
R y z ↝⟨ (λ r → record
{ to = flip transitive r
; from = flip transitive (symmetric r)
}) ⟩
R x y ⇔ R x z ↔⟨ ⇔↔≡″ ext prop-ext ⟩□
(R x y , R-prop) ≡ (R x z , R-prop) □
R′ : A → A / R → Proposition r
R′ x = rec λ where
.[]ʳ y → R x y , R-prop
.[]-respects-relationʳ → lemma
.is-setʳ → Is-set-∃-Is-proposition ext prop-ext
-- A variant of related≃[equal].
∥related∥≃[equal] :
{R : A → A → Type r} →
Propositional-extensionality r →
Is-equivalence-relation R →
∀ {x y} → ∥ R x y ∥ ≃ _≡_ {A = A / R} [ x ] [ y ]
∥related∥≃[equal] {A = A} {R = R} prop-ext R-equiv {x = x} {y = y} =
∥ R x y ∥ ↝⟨ related≃[equal]
prop-ext
(TruncP.∥∥-preserves-Is-equivalence-relation R-equiv)
TruncP.truncation-is-proposition ⟩
_≡_ {A = A / λ x y → ∥ R x y ∥} [ x ] [ y ] ↝⟨ Eq.≃-≡ (inverse /-∥∥≃/) ⟩□
_≡_ {A = A / R} [ x ] [ y ] □
-- Quotienting with equality (for a set) amounts to the same thing as
-- not quotienting at all.
/≡↔ : Is-set A → A / _≡_ ↔ A
/≡↔ A-set = record
{ surjection = record
{ logical-equivalence = record
{ from = [_]
; to = rec λ where
.[]ʳ → id
.[]-respects-relationʳ → id
.is-setʳ → A-set
}
; right-inverse-of = λ _ → refl _
}
; left-inverse-of = elim-prop λ where
.[]ʳ _ → refl _
.is-propositionʳ _ → /-is-set
}
-- Quotienting with a trivial relation amounts to the same thing as
-- using the propositional truncation.
/trivial↔∥∥ : (∀ x y → R x y) → A / R ↔ ∥ A ∥
/trivial↔∥∥ {A = A} {R = R} trivial = record
{ surjection = record
{ logical-equivalence = record
{ from = TruncP.rec /-prop [_]
; to = rec-prop λ where
.[]ʳ → ∣_∣
.is-propositionʳ → TruncP.truncation-is-proposition
}
; right-inverse-of = TruncP.elim
_
(λ _ → ⇒≡ 1 TruncP.truncation-is-proposition)
(λ _ → refl _)
}
; left-inverse-of = elim-prop λ where
.[]ʳ _ → refl _
.is-propositionʳ _ → /-is-set
}
where
/-prop : Is-proposition (A / R)
/-prop = elim-prop λ where
.[]ʳ x → elim-prop λ where
.[]ʳ y → []-respects-relation (trivial x y)
.is-propositionʳ _ → /-is-set
.is-propositionʳ _ →
Π-closure ext 1 λ _ →
/-is-set
-- The previous property gives us an alternative to
-- constant-function≃∥inhabited∥⇒inhabited.
constant-function↔∥inhabited∥⇒inhabited :
Is-set B →
(∃ λ (f : A → B) → Constant f) ↔ (∥ A ∥ → B)
constant-function↔∥inhabited∥⇒inhabited {B = B} {A = A} B-set =
(∃ λ (f : A → B) → Constant f) ↝⟨ record
{ surjection = record
{ logical-equivalence = record
{ to = λ { (f , c) → rec λ where
.[]ʳ → f
.[]-respects-relationʳ _ → c _ _
.is-setʳ → B-set }
; from = λ f → (f ∘ [_])
, (λ _ _ → cong f ([]-respects-relation _))
}
; right-inverse-of = λ f → ⟨ext⟩ $ elim λ where
.[]ʳ _ → refl _
.[]-respects-relationʳ _ → B-set _ _
.is-setʳ _ → mono₁ 2 B-set
}
; left-inverse-of = λ _ → Σ-≡,≡→≡
(refl _)
((Π-closure ext 1 λ _ →
Π-closure ext 1 λ _ →
B-set) _ _)
} ⟩
(A / (λ _ _ → ⊤) → B) ↝⟨ →-cong₁ ext (/trivial↔∥∥ _) ⟩□
(∥ A ∥ → B) □
private
-- The two directions of the proposition above compute in the
-- "right" way. Note that (at the time of writing) an analogue of
-- the second property below fails to hold definitionally for
-- constant-function≃∥inhabited∥⇒inhabited.
to-constant-function↔∥inhabited∥⇒inhabited :
(B-set : Is-set B) →
_↔_.to (constant-function↔∥inhabited∥⇒inhabited B-set) f ∣ x ∣ ≡
proj₁ f x
to-constant-function↔∥inhabited∥⇒inhabited _ = refl _
from-constant-function↔∥inhabited∥⇒inhabited :
(B-set : Is-set B) →
proj₁ (_↔_.from (constant-function↔∥inhabited∥⇒inhabited B-set) f)
x ≡
f ∣ x ∣
from-constant-function↔∥inhabited∥⇒inhabited _ = refl _
-- The quotient type ⊤ / R is equivalent to ⊤.
⊤/≃ : ⊤ / R ≃ ⊤
⊤/≃ = Eq.↔→≃
_
[_]
refl
(elim-prop λ where
.is-propositionʳ _ → /-is-set
.[]ʳ _ → refl _)
-- If R is a propositional equivalence relation that is pointwise
-- stable, then equality is very stable for A / R (assuming
-- propositional extensionality).
Very-stable-≡-/ :
{R : A → A → Type r} →
Propositional-extensionality r →
Is-equivalence-relation R →
(∀ x y → Is-proposition (R x y)) →
(∀ x y → Stable (R x y)) →
Very-stable-≡ (A / R)
Very-stable-≡-/ {A = A} {R = R} prop-ext equiv prop s =
elim-prop λ where
.[]ʳ x → elim-prop λ where
.[]ʳ y → $⟨ s _ _ ⟩
Stable (R x y) ↝⟨ flip E.Stable-proposition→Very-stable (prop _ _) ⟩
Very-stable (R x y) ↝⟨ E.Very-stable-cong _ (related≃[equal] prop-ext equiv (prop _ _)) ⟩□
Very-stable ([ x ] ≡ [ y ]) □
.is-propositionʳ _ → E.Very-stable-propositional ext
.is-propositionʳ _ →
Π-closure ext 1 λ _ →
E.Very-stable-propositional ext
private
-- An alternative definition of the quotients from
-- Quotient.Families-of-equivalence-classes.
infix 5 _/′_
_/′_ : (A : Type a) → (A → A → Type a) → Type (lsuc a)
_/′_ {a = a} A R = ∃ λ (P : A → Type a) → ∥ (∃ λ x → R x ≡ P) ∥
/↔/′ : A Quotient./ R ↔ A /′ R
/↔/′ {A = A} {R = R} =
A Quotient./ R ↔⟨⟩
(∃ λ (P : A → Type _) → Trunc.∥ (∃ λ x → R x ≡ P) ∥ 1 _) ↝⟨ (∃-cong λ _ → inverse $ TruncP.∥∥↔∥∥ lzero) ⟩
(∃ λ (P : A → Type _) → ∥ (∃ λ x → R x ≡ P) ∥) ↔⟨⟩
A /′ R □
[_]′ : A → A /′ R
[_]′ = _↔_.to /↔/′ ∘ Quotient.[_]
rec′ :
{A : Type a} {R : A → A → Type a} →
(∀ {x} → R x x) →
(B : Type a) →
Is-set B →
(f : A → B) →
(∀ {x y} → R x y → f x ≡ f y) →
A /′ R → B
rec′ refl B B-set f R⇒≡ =
Quotient.rec ext refl B B-set f R⇒≡ ∘
_↔_.from /↔/′
elim-Prop′ :
{A : Type a} {R : A → A → Type a} →
Quotient.Strong-equivalence-with surjection R →
(B : A /′ R → Type (lsuc a)) →
(∀ x → Is-proposition (B [ x ]′)) →
(f : ∀ x → B [ x ]′) →
∀ x → B x
elim-Prop′ strong-equivalence B B-prop f x =
subst B (_↔_.right-inverse-of /↔/′ _) $
Quotient.elim-Prop
ext
strong-equivalence
(B ∘ _↔_.to /↔/′)
B-prop
f
(_↔_.from /↔/′ x)
-- If the relation is a propositional equivalence relation of a
-- certain size, then the quotients defined above are isomorphic to
-- families of equivalence relations, defined in a certain way
-- (assuming univalence).
/↔ :
{A : Type a} {R : A → A → Type a} →
Univalence a →
Univalence lzero →
Is-equivalence-relation R →
(∀ {x y} → Is-proposition (R x y)) →
A / R ↔ ∃ λ (P : A → Type a) → ∥ (∃ λ x → R x ≡ P) ∥
/↔ {a = a} {A = A} {R = R} univ univ₀ R-equiv R-prop = record
{ surjection = record
{ logical-equivalence = record
{ to = to
; from = from
}
; right-inverse-of = to∘from
}
; left-inverse-of = from∘to
}
where
R-is-strong-equivalence : Quotient.Strong-equivalence R
R-is-strong-equivalence =
Quotient.propositional-equivalence⇒strong-equivalence
ext univ R-equiv (λ _ _ → R-prop)
to : A / R → A /′ R
to = rec λ where
.[]ʳ → [_]′
.[]-respects-relationʳ {x = x} {y = y} →
R x y ↝⟨ _≃_.to (Quotient.related↝[equal] ext R-is-strong-equivalence) ⟩
Quotient.[ x ] ≡ Quotient.[ y ] ↝⟨ cong (_↔_.to /↔/′) ⟩□
[ x ]′ ≡ [ y ]′ □
.is-setʳ → $⟨ (λ {_ _} → Quotient.quotient's-h-level-is-1-+-relation's-h-level
ext univ univ₀ 1 (λ _ _ → R-prop)) ⟩
Is-set (A Quotient./ R) ↝⟨ H.respects-surjection (_↔_.surjection /↔/′) 2 ⟩□
Is-set (A /′ R) □
from : A /′ R → A / R
from = rec′
(Is-equivalence-relation.reflexive R-equiv)
_
/-is-set
[_]
[]-respects-relation
to∘from : ∀ x → to (from x) ≡ x
to∘from = elim-Prop′
(Quotient.strong-equivalence⇒strong-equivalence-with
R-is-strong-equivalence)
_
(λ x → $⟨ (λ {_ _} → Quotient.quotient's-h-level-is-1-+-relation's-h-level
ext univ univ₀ 1 λ _ _ → R-prop) ⟩
Is-set (A Quotient./ R) ↝⟨ H.respects-surjection (_↔_.surjection /↔/′) 2 ⟩
Is-set (A /′ R) ↝⟨ +⇒≡ {n = 1} ⟩□
Is-proposition (to (from [ x ]′) ≡ [ x ]′) □)
(λ _ → refl _)
from∘to : ∀ x → from (to x) ≡ x
from∘to = elim-prop λ where
.[]ʳ _ → refl _
.is-propositionʳ _ → /-is-set
-- If the relation is a propositional equivalence relation of a
-- certain size, then the definition of quotients given in
-- Quotient.Families-of-equivalence-classes is isomorphic to the one
-- given here (assuming univalence).
/↔/ :
{A : Type a} {R : A → A → Type a} →
Univalence a →
Univalence lzero →
Is-equivalence-relation R →
(R-prop : ∀ {x y} → Is-proposition (R x y)) →
A Quotient./ R ↔ A / R
/↔/ {a = a} {A = A} {R = R} univ univ₀ R-equiv R-prop =
A Quotient./ R ↔⟨⟩
(∃ λ (P : A → Type a) → Trunc.∥ (∃ λ x → R x ≡ P) ∥ 1 (lsuc a)) ↝⟨ (∃-cong λ _ → inverse $ TruncP.∥∥↔∥∥ lzero) ⟩
(∃ λ (P : A → Type a) → ∥ (∃ λ x → R x ≡ P) ∥) ↝⟨ inverse $ /↔ univ univ₀ R-equiv R-prop ⟩□
A / R □
------------------------------------------------------------------------
-- Various type formers commute with quotients
-- _⊎_ commutes with quotients.
⊎/-comm : (A₁ ⊎ A₂) / (R₁ ⊎ᴾ R₂) ↔ A₁ / R₁ ⊎ A₂ / R₂
⊎/-comm = record
{ surjection = record
{ logical-equivalence = record
{ to = rec λ where
.[]ʳ → ⊎-map [_] [_]
.is-setʳ → ⊎-closure 0 /-is-set /-is-set
.[]-respects-relationʳ {x = inj₁ _} {y = inj₁ _} →
cong inj₁ ∘ []-respects-relation
.[]-respects-relationʳ {x = inj₂ _} {y = inj₂ _} →
cong inj₂ ∘ []-respects-relation
; from = Prelude.[ rec (λ where
.[]ʳ → [_] ∘ inj₁
.[]-respects-relationʳ → []-respects-relation
.is-setʳ → /-is-set)
, rec (λ where
.[]ʳ → [_] ∘ inj₂
.[]-respects-relationʳ → []-respects-relation
.is-setʳ → /-is-set)
]
}
; right-inverse-of =
Prelude.[ elim-prop (λ where
.[]ʳ _ → refl _
.is-propositionʳ _ → ⊎-closure 0 /-is-set /-is-set)
, elim-prop (λ where
.[]ʳ _ → refl _
.is-propositionʳ _ → ⊎-closure 0 /-is-set /-is-set)
]
}
; left-inverse-of = elim-prop λ where
.[]ʳ → Prelude.[ (λ _ → refl _) , (λ _ → refl _) ]
.is-propositionʳ _ → /-is-set
}
-- Maybe commutes with quotients.
--
-- Chapman, Uustalu and Veltri mention a similar result in
-- "Quotienting the Delay Monad by Weak Bisimilarity".
Maybe/-comm : Maybe A / Maybeᴾ R ↔ Maybe (A / R)
Maybe/-comm {A = A} {R = R} =
Maybe A / Maybeᴾ R ↝⟨ ⊎/-comm ⟩
⊤ / Trivial ⊎ A / R ↝⟨ /trivial↔∥∥ _ ⊎-cong F.id ⟩
∥ ⊤ ∥ ⊎ A / R ↝⟨ TruncP.∥∥↔ (mono₁ 0 ⊤-contractible) ⊎-cong F.id ⟩□
Maybe (A / R) □
-- A simplification lemma for Maybe/-comm.
Maybe/-comm-[] : _↔_.to Maybe/-comm ∘ [_] ≡ ⊎-map id ([_] {R = R})
Maybe/-comm-[] =
_↔_.to Maybe/-comm ∘ [_] ≡⟨⟩
⊎-map _ id ∘ ⊎-map _ id ∘ ⊎-map [_] [_] ≡⟨ cong (_∘ ⊎-map [_] [_]) ⊎-map-∘ ⟩
⊎-map _ id ∘ ⊎-map [_] [_] ≡⟨ ⊎-map-∘ ⟩∎
⊎-map id [_] ∎
where
⊎-map-∘ : ∀ {a₁ b₁ c₁} {A₁ : Type a₁} {B₁ : Type b₁} {C₁ : Type c₁}
{a₂ b₂ c₂} {A₂ : Type a₂} {B₂ : Type b₂} {C₂ : Type c₂}
{f₁ : B₁ → C₁} {g₁ : A₁ → B₁}
{f₂ : B₂ → C₂} {g₂ : A₂ → B₂} →
⊎-map f₁ f₂ ∘ ⊎-map g₁ g₂ ≡ ⊎-map (f₁ ∘ g₁) (f₂ ∘ g₂)
⊎-map-∘ = ⟨ext⟩ Prelude.[ (λ _ → refl _) , (λ _ → refl _) ]
-- Cartesian products commute with quotients, assuming that the two
-- binary relations involved in the statement are reflexive.
×/-comm :
(∀ {x} → R₁ x x) →
(∀ {x} → R₂ x x) →
(A₁ × A₂) / (R₁ ×ᴾ R₂) ≃ (A₁ / R₁ × A₂ / R₂)
×/-comm {R₁ = R₁} {R₂ = R₂} R₁-refl R₂-refl = Eq.↔→≃
(rec λ where
.is-setʳ → ×-closure 2 /-is-set /-is-set
.[]ʳ → Σ-map [_] [_]
.[]-respects-relationʳ {x = x₁ , x₂} {y = y₁ , y₂} →
R₁ x₁ y₁ × R₂ x₂ y₂ ↝⟨ Σ-map []-respects-relation
[]-respects-relation ⟩
[ x₁ ] ≡ [ y₁ ] × [ x₂ ] ≡ [ y₂ ] ↝⟨ uncurry (cong₂ _,_) ⟩□
([ x₁ ] , [ x₂ ]) ≡ ([ y₁ ] , [ y₂ ]) □)
(uncurry $ rec λ where
.is-setʳ →
Π-closure ext 2 λ _ →
/-is-set
.[]ʳ x → (x ,_) /-map λ y₁ y₂ →
R₂ y₁ y₂ ↝⟨ R₁-refl ,_ ⟩□
R₁ x x × R₂ y₁ y₂ □
.[]-respects-relationʳ {x = x₁} {y = x₂} R₁x₁x₂ →
⟨ext⟩ $ elim-prop λ where
.is-propositionʳ _ →
/-is-set
.[]ʳ y →
[ (x₁ , y) ] ≡⟨ []-respects-relation (R₁x₁x₂ , R₂-refl) ⟩∎
[ (x₂ , y) ] ∎)
(uncurry $ elim-prop λ where
.is-propositionʳ _ →
Π-closure ext 1 λ _ →
×-closure 2 /-is-set /-is-set
.[]ʳ _ → elim-prop λ where
.is-propositionʳ _ →
×-closure 2 /-is-set /-is-set
.[]ʳ _ →
refl _)
(elim-prop λ where
.is-propositionʳ _ → /-is-set
.[]ʳ _ → refl _)
-- The sigma type former commutes (kind of) with quotients, assuming
-- that the second projections come from propositional types.
Σ/-comm :
{P : A / R → Type p} →
(∀ {x} → Is-proposition (P x)) →
Σ (A / R) P ↔ Σ A (P ∘ [_]) / (R on proj₁)
Σ/-comm {A = A} {R = R} {P = P} P-prop = record
{ surjection = record
{ logical-equivalence = record
{ to =
uncurry $
elim λ where
.[]ʳ → curry [_]
.[]-respects-relationʳ {x = x} {y = y} r → ⟨ext⟩ λ P[y] →
subst (λ x → P x → Σ A (P ∘ [_]) / (R on proj₁))
([]-respects-relation r)
(curry [_] x) P[y] ≡⟨ subst-→-domain P {f = curry [_] _} ([]-respects-relation r) ⟩
[ (x , subst P (sym $ []-respects-relation r) P[y]) ] ≡⟨ []-respects-relation r ⟩∎
[ (y , P[y]) ] ∎
.is-setʳ _ →
Π-closure ext 2 λ _ →
/-is-set
; from = rec λ where
.[]ʳ → Σ-map [_] id
.is-setʳ → Σ-closure 2 /-is-set (λ _ → mono₁ 1 P-prop)
.[]-respects-relationʳ {x = (x₁ , x₂)} {y = (y₁ , y₂)} →
R x₁ y₁ ↝⟨ []-respects-relation ⟩
[ x₁ ] ≡ [ y₁ ] ↔⟨ ignore-propositional-component P-prop ⟩
([ x₁ ] , x₂) ≡ ([ y₁ ] , y₂) □
}
; right-inverse-of = elim-prop λ where
.[]ʳ _ → refl _
.is-propositionʳ _ → /-is-set
}
; left-inverse-of = uncurry $ elim-prop λ where
.[]ʳ _ _ → refl _
.is-propositionʳ _ →
Π-closure ext 1 λ _ →
Σ-closure 2 /-is-set (λ _ → mono₁ 1 P-prop)
}
-- Erased commutes with quotients if certain conditions hold.
Erased/-comm :
{@0 A : Type a} {@0 R : A → A → Type r} →
@0 Is-set A →
@0 (∀ {x y} → R x y → x ≡ y) →
Erased A / Erasedᴾ R ≃ Erased (A / R)
Erased/-comm {A = A} {R = R} set R→≡ = Eq.↔→≃
(rec λ where
.is-setʳ → E.H-level-Erased 2 /-is-set
.[]ʳ → E.map [_]
.[]-respects-relationʳ E.[ Rxy ] →
E.[]-cong E.[ []-respects-relation Rxy ])
(λ (E.[ x ]) → [ E.[ from′ x ] ])
(λ (E.[ x ]) →
E.[]-cong
E.[ flip (elim-prop {P = λ x → [ from′ x ] ≡ x}) x (λ @0 where
.is-propositionʳ _ → /-is-set
.[]ʳ _ → refl _)
])
(elim-prop λ where
.is-propositionʳ _ → /-is-set
.[]ʳ _ → refl _)
where
@0 from′ : A / R → A
from′ = rec λ @0 where
.is-setʳ → set
.[]ʳ → id
.[]-respects-relationʳ → R→≡
-- The type former λ X → ℕ → X commutes with quotients, assuming that
-- the quotient relation is a propositional equivalence relation, and
-- also assuming countable choice and propositional extensionality.
--
-- This result is very similar to Proposition 5 in "Quotienting the
-- Delay Monad by Weak Bisimilarity" by Chapman, Uustalu and Veltri.
-- The forward component of the isomorphism. This component can be
-- defined without any extra assumptions.
ℕ→/-comm-to : (ℕ → A) / (ℕ →ᴾ R) → (ℕ → A / R)
ℕ→/-comm-to = rec λ where
.[]ʳ f n → [ f n ]
.[]-respects-relationʳ r → ⟨ext⟩ ([]-respects-relation ∘ r)
.is-setʳ →
Π-closure ext 2 λ _ →
/-is-set
-- The isomorphism.
ℕ→/-comm :
{A : Type a} {R : A → A → Type r} →
Axiom-of-countable-choice (a ⊔ r) →
Propositional-extensionality r →
Is-equivalence-relation R →
(∀ {x y} → Is-proposition (R x y)) →
(ℕ → A) / (ℕ →ᴾ R) ↔ (ℕ → A / R)
ℕ→/-comm {A = A} {R = R} cc prop-ext R-equiv R-prop = record
{ surjection = record
{ logical-equivalence = record
{ to = ℕ→/-comm-to
; from = from unit
}
; right-inverse-of = to∘from unit
}
; left-inverse-of = from∘to unit
}
where
[_]→ : (ℕ → A) → (ℕ → A / R)
[ f ]→ n = [ f n ]
-- A module that is introduced to ensure that []→-surjective is not
-- in the same abstract block as the abstract definitions below.
module Dummy where
abstract
[]→-surjective : Surjective [_]→
[]→-surjective f = $⟨ []-surjective ⟩
Surjective [_] ↝⟨ (λ surj → surj ∘ f) ⦂ (_ → _) ⟩
(∀ n → ∥ (∃ λ x → [ x ] ≡ f n) ∥) ↔⟨ TruncP.countable-choice-bijection cc ⟩
∥ (∀ n → ∃ λ x → [ x ] ≡ f n) ∥ ↔⟨ TruncP.∥∥-cong ΠΣ-comm ⟩
∥ (∃ λ g → ∀ n → [ g n ] ≡ f n) ∥ ↔⟨⟩
∥ (∃ λ g → ∀ n → [ g ]→ n ≡ f n) ∥ ↔⟨ TruncP.∥∥-cong (∃-cong λ _ → Eq.extensionality-isomorphism ext) ⟩□
∥ (∃ λ g → [ g ]→ ≡ f) ∥ □
open Dummy
from₁ : ∀ f → [_]→ ⁻¹ f → ℕ→/-comm-to ⁻¹ f
from₁ f (g , [g]→≡f) =
[ g ]
, (ℕ→/-comm-to [ g ] ≡⟨⟩
[ g ]→ ≡⟨ [g]→≡f ⟩∎
f ∎)
from₁-constant : ∀ f → Constant (from₁ f)
from₁-constant f (g₁ , [g₁]→≡f) (g₂ , [g₂]→≡f) =
$⟨ (λ n → cong (_$ n) (
[ g₁ ]→ ≡⟨ [g₁]→≡f ⟩
f ≡⟨ sym [g₂]→≡f ⟩∎
[ g₂ ]→ ∎)) ⟩
(∀ n → [ g₁ ]→ n ≡ [ g₂ ]→ n) ↔⟨⟩
(∀ n → [ g₁ n ] ≡ [ g₂ n ]) ↔⟨ ∀-cong ext (λ _ → inverse $ related≃[equal] prop-ext R-equiv R-prop) ⟩
(∀ n → R (g₁ n) (g₂ n)) ↔⟨⟩
(ℕ →ᴾ R) g₁ g₂ ↝⟨ []-respects-relation ⟩
[ g₁ ] ≡ [ g₂ ] ↔⟨ ignore-propositional-component
(Π-closure ext 2 λ _ →
/-is-set) ⟩□
([ g₁ ] , [g₁]→≡f) ≡ ([ g₂ ] , [g₂]→≡f) □
from₂ : Unit → ∀ f → ∥ [_]→ ⁻¹ f ∥ → ℕ→/-comm-to ⁻¹ f
from₂ unit f =
_≃_.to (TruncP.constant-function≃∥inhabited∥⇒inhabited
(Σ-closure 2 /-is-set λ _ →
mono₁ 1 (Π-closure ext 2 (λ _ → /-is-set))))
(from₁ f , from₁-constant f)
unblock-from₂ : ∀ x f p → from₂ x f ∣ p ∣ ≡ from₁ f p
unblock-from₂ unit _ _ = refl _
abstract
from₃ : Unit → (f : ℕ → A / R) → ℕ→/-comm-to ⁻¹ f
from₃ x f = from₂ x f ([]→-surjective f)
from : Unit → (ℕ → A / R) → (ℕ → A) / (ℕ →ᴾ R)
from x f = proj₁ (from₃ x f)
to∘from : ∀ x f → ℕ→/-comm-to (from x f) ≡ f
to∘from x f = proj₂ (from₃ x f)
from∘to : ∀ x f → from x (ℕ→/-comm-to f) ≡ f
from∘to x = elim-prop λ where
.[]ʳ f →
from x (ℕ→/-comm-to [ f ]) ≡⟨⟩
proj₁ (from₂ x [ f ]→ ([]→-surjective [ f ]→)) ≡⟨ cong (proj₁ ∘ from₂ x [ f ]→) $ TruncP.truncation-is-proposition _ _ ⟩
proj₁ (from₂ x [ f ]→ ∣ f , refl _ ∣) ≡⟨ cong proj₁ $ unblock-from₂ x _ (f , refl _) ⟩
proj₁ (from₁ [ f ]→ (f , refl _)) ≡⟨⟩
[ f ] ∎
.is-propositionʳ _ → /-is-set
------------------------------------------------------------------------
-- Quotient-like eliminators
-- If there is a split surjection from a quotient type to some other
-- type, then one can construct a quotient-like eliminator for the
-- other type.
--
-- This kind of construction is used in "Quotienting the Delay Monad
-- by Weak Bisimilarity" by Chapman, Uustalu and Veltri.
↠-eliminator :
(surj : A / R ↠ B)
(P : B → Type p)
(p-[] : ∀ x → P (_↠_.to surj [ x ])) →
(∀ {x y} (r : R x y) →
subst P (cong (_↠_.to surj) ([]-respects-relation r)) (p-[] x) ≡
p-[] y) →
(∀ x → Is-set (P x)) →
∀ x → P x
↠-eliminator surj P p-[] ok P-set x =
subst P (_↠_.right-inverse-of surj x) p′
where
p′ : P (_↠_.to surj (_↠_.from surj x))
p′ = elim
(λ where
.[]ʳ → p-[]
.[]-respects-relationʳ {x = x} {y = y} r →
subst (P ∘ _↠_.to surj) ([]-respects-relation r) (p-[] x) ≡⟨ subst-∘ P (_↠_.to surj) ([]-respects-relation r) ⟩
subst P (cong (_↠_.to surj) ([]-respects-relation r)) (p-[] x) ≡⟨ ok r ⟩∎
p-[] y ∎
.is-setʳ _ → P-set _)
(_↠_.from surj x)
-- The eliminator "computes" in the "right" way for elements that
-- satisfy a certain property.
↠-eliminator-[] :
∀ (surj : A / R ↠ B)
(P : B → Type p)
(p-[] : ∀ x → P (_↠_.to surj [ x ]))
(ok : ∀ {x y} (r : R x y) →
subst P (cong (_↠_.to surj) ([]-respects-relation r)) (p-[] x) ≡
p-[] y)
(P-set : ∀ x → Is-set (P x)) x →
_↠_.from surj (_↠_.to surj [ x ]) ≡ [ x ] →
↠-eliminator surj P p-[] ok P-set (_↠_.to surj [ x ]) ≡ p-[] x
↠-eliminator-[] {R = R} surj P p-[] ok P-set x hyp =
subst P (_↠_.right-inverse-of surj (_↠_.to surj [ x ]))
(elim e (_↠_.from surj (_↠_.to surj [ x ]))) ≡⟨ cong (λ p → subst P p (elim e _)) $
H.respects-surjection surj 2 /-is-set
(_↠_.right-inverse-of surj (_↠_.to surj [ x ]))
(cong (_↠_.to surj) hyp) ⟩
subst P (cong (_↠_.to surj) hyp)
(elim e (_↠_.from surj (_↠_.to surj [ x ]))) ≡⟨ D.elim
(λ {x y} p → subst P (cong (_↠_.to surj) p) (elim e x) ≡ elim e y)
(λ y →
subst P (cong (_↠_.to surj) (refl _)) (elim e y) ≡⟨ cong (λ p → subst P p (elim e _)) $ cong-refl (_↠_.to surj) ⟩
subst P (refl _) (elim e y) ≡⟨ subst-refl P _ ⟩∎
elim e y ∎)
hyp ⟩
elim e [ x ] ≡⟨⟩
p-[] x ∎
where
e = _
-- If there is a bijection from a quotient type to some other type,
-- then one can also construct a quotient-like eliminator for the
-- other type.
↔-eliminator :
(bij : A / R ↔ B)
(P : B → Type p)
(p-[] : ∀ x → P (_↔_.to bij [ x ])) →
(∀ {x y} (r : R x y) →
subst P (cong (_↔_.to bij) ([]-respects-relation r)) (p-[] x) ≡
p-[] y) →
(∀ x → Is-set (P x)) →
∀ x → P x
↔-eliminator bij = ↠-eliminator (_↔_.surjection bij)
-- This latter eliminator always "computes" in the "right" way.
↔-eliminator-[] :
∀ (bij : A / R ↔ B)
(P : B → Type p)
(p-[] : ∀ x → P (_↔_.to bij [ x ]))
(ok : ∀ {x y} (r : R x y) →
subst P (cong (_↔_.to bij) ([]-respects-relation r)) (p-[] x) ≡
p-[] y)
(P-set : ∀ x → Is-set (P x)) x →
↔-eliminator bij P p-[] ok P-set (_↔_.to bij [ x ]) ≡ p-[] x
↔-eliminator-[] bij P p-[] ok P-set x =
↠-eliminator-[] (_↔_.surjection bij) P p-[] ok P-set x
(_↔_.left-inverse-of bij [ x ])
-- A quotient-like eliminator for functions of type ℕ → A / R, where R
-- is a propositional equivalence relation. Defined using countable
-- choice and propositional extensionality.
--
-- This eliminator is taken from Corollary 1 in "Quotienting the Delay
-- Monad by Weak Bisimilarity" by Chapman, Uustalu and Veltri.
ℕ→/-elim :
{A : Type a} {R : A → A → Type r} →
Axiom-of-countable-choice (a ⊔ r) →
Propositional-extensionality r →
Is-equivalence-relation R →
(∀ {x y} → Is-proposition (R x y)) →
(P : (ℕ → A / R) → Type p)
(p-[] : ∀ f → P (λ n → [ f n ])) →
(∀ {f g} (r : (ℕ →ᴾ R) f g) →
subst P (cong ℕ→/-comm-to ([]-respects-relation r)) (p-[] f) ≡
p-[] g) →
(∀ f → Is-set (P f)) →
∀ f → P f
ℕ→/-elim cc prop-ext R-equiv R-prop =
↔-eliminator (ℕ→/-comm cc prop-ext R-equiv R-prop)
-- The eliminator "computes" in the "right" way.
ℕ→/-elim-[] :
∀ {A : Type a} {R : A → A → Type r}
(cc : Axiom-of-countable-choice (a ⊔ r))
(prop-ext : Propositional-extensionality r)
(R-equiv : Is-equivalence-relation R)
(R-prop : ∀ {x y} → Is-proposition (R x y))
(P : (ℕ → A / R) → Type p)
(p-[] : ∀ f → P (λ n → [ f n ]))
(ok : ∀ {f g} (r : (ℕ →ᴾ R) f g) →
subst P (cong ℕ→/-comm-to ([]-respects-relation r)) (p-[] f) ≡
p-[] g)
(P-set : ∀ f → Is-set (P f)) f →
ℕ→/-elim cc prop-ext R-equiv R-prop P p-[] ok P-set (λ n → [ f n ]) ≡
p-[] f
ℕ→/-elim-[] cc prop-ext R-equiv R-prop =
↔-eliminator-[] (ℕ→/-comm cc prop-ext R-equiv R-prop)
| 35.66005
| 144
| 0.450862
|
03669299c43ea45df30f48663b2af5943d0b80f4
| 2,088
|
agda
|
Agda
|
agda-stdlib/src/Data/List/Relation/Binary/Disjoint/Setoid/Properties.agda
|
DreamLinuxer/popl21-artifact
|
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
|
[
"MIT"
] | 5
|
2020-10-07T12:07:53.000Z
|
2020-10-10T21:41:32.000Z
|
agda-stdlib/src/Data/List/Relation/Binary/Disjoint/Setoid/Properties.agda
|
DreamLinuxer/popl21-artifact
|
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
|
[
"MIT"
] | null | null | null |
agda-stdlib/src/Data/List/Relation/Binary/Disjoint/Setoid/Properties.agda
|
DreamLinuxer/popl21-artifact
|
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
|
[
"MIT"
] | 1
|
2021-11-04T06:54:45.000Z
|
2021-11-04T06:54:45.000Z
|
------------------------------------------------------------------------
-- The Agda standard library
--
-- Properties of disjoint lists (setoid equality)
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
module Data.List.Relation.Binary.Disjoint.Setoid.Properties where
open import Data.List.Base
open import Data.List.Relation.Binary.Disjoint.Setoid
import Data.List.Relation.Unary.Any as Any
open import Data.List.Relation.Unary.All as All
open import Data.List.Relation.Unary.All.Properties using (¬Any⇒All¬)
open import Data.List.Relation.Unary.Any.Properties using (++⁻)
open import Data.Product using (_,_)
open import Data.Sum.Base using (inj₁; inj₂)
open import Relation.Binary
open import Relation.Nullary using (¬_)
------------------------------------------------------------------------
-- Relational properties
------------------------------------------------------------------------
module _ {c ℓ} (S : Setoid c ℓ) where
sym : Symmetric (Disjoint S)
sym xs#ys (v∈ys , v∈xs) = xs#ys (v∈xs , v∈ys)
------------------------------------------------------------------------
-- Relationship with other predicates
------------------------------------------------------------------------
module _ {c ℓ} (S : Setoid c ℓ) where
open Setoid S
Disjoint⇒AllAll : ∀ {xs ys} → Disjoint S xs ys →
All (λ x → All (λ y → ¬ x ≈ y) ys) xs
Disjoint⇒AllAll xs#ys = All.map (¬Any⇒All¬ _)
(All.tabulate (λ v∈xs v∈ys → xs#ys (Any.map reflexive v∈xs , v∈ys)))
------------------------------------------------------------------------
-- Introduction (⁺) and elimination (⁻) rules for list operations
------------------------------------------------------------------------
-- concat
module _ {c ℓ} (S : Setoid c ℓ) where
concat⁺ʳ : ∀ {vs xss} → All (Disjoint S vs) xss → Disjoint S vs (concat xss)
concat⁺ʳ {xss = xs ∷ xss} (vs#xs ∷ vs#xss) (v∈vs , v∈xs++concatxss)
with ++⁻ xs v∈xs++concatxss
... | inj₁ v∈xs = vs#xs (v∈vs , v∈xs)
... | inj₂ v∈xss = concat⁺ʳ vs#xss (v∈vs , v∈xss)
| 37.285714
| 78
| 0.478927
|
349dd4c4e896a1cc1416edba1cd2bc6e7fe40a83
| 414
|
agda
|
Agda
|
test/interaction/Issue1104.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
test/interaction/Issue1104.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
test/interaction/Issue1104.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
?bug : Set
?bug = ?
-- Andreas, 2014-04-16
-- Issue 1104 reported by Fabien Renaud.
-- Emacs mode got confused by identifiers containing --
-- Problem: {!!} is not turned into hole
bug-- : Set
bug-- = ?
another : Set
another = (-- Senfgurke ?
{!!})-- Noch eine Senfgurke ?
_:--_ : Set → Set → Set
_:--_ = {!!}
bla = let x = Set ;-- bla ?
y = Set in Set
bug? : Set
bug? = {!!}
| 16.56
| 55
| 0.531401
|
9a23a27f7630a99bffb8ae427b523f870ad9a73c
| 1,392
|
agda
|
Agda
|
Definition/Typed/RedSteps.agda
|
CoqHott/logrel-mltt
|
e0eeebc4aa5ed791ce3e7c0dc9531bd113dfcc04
|
[
"MIT"
] | 2
|
2018-06-21T08:39:01.000Z
|
2022-01-17T16:13:53.000Z
|
Definition/Typed/RedSteps.agda
|
CoqHott/logrel-mltt
|
e0eeebc4aa5ed791ce3e7c0dc9531bd113dfcc04
|
[
"MIT"
] | null | null | null |
Definition/Typed/RedSteps.agda
|
CoqHott/logrel-mltt
|
e0eeebc4aa5ed791ce3e7c0dc9531bd113dfcc04
|
[
"MIT"
] | 2
|
2022-01-26T14:55:51.000Z
|
2022-02-15T19:42:19.000Z
|
{-# OPTIONS --safe #-}
module Definition.Typed.RedSteps where
open import Definition.Untyped
open import Definition.Typed
-- Concatenation of type reduction closures
_⇨*_ : ∀ {Γ A B C r} → Γ ⊢ A ⇒* B ^ r → Γ ⊢ B ⇒* C ^ r → Γ ⊢ A ⇒* C ^ r
id ⊢B ⇨* B⇒C = B⇒C
(A⇒A′ ⇨ A′⇒B) ⇨* B⇒C = A⇒A′ ⇨ (A′⇒B ⇨* B⇒C)
-- Concatenation of term reduction closures
_⇨∷*_ : ∀ {Γ A t u v l} → Γ ⊢ t ⇒* u ∷ A ^ l → Γ ⊢ u ⇒* v ∷ A ^ l → Γ ⊢ t ⇒* v ∷ A ^ l
id ⊢u ⇨∷* u⇒v = u⇒v
(t⇒t′ ⇨ t′⇒u) ⇨∷* u⇒v = t⇒t′ ⇨ (t′⇒u ⇨∷* u⇒v)
-- Conversion of reduction closures
conv* : ∀ {Γ A B t u l } → Γ ⊢ t ⇒* u ∷ A ^ l → Γ ⊢ A ≡ B ^ [ ! , l ] → Γ ⊢ t ⇒* u ∷ B ^ l
conv* (id x) A≡B = id (conv x A≡B)
conv* (x ⇨ d) A≡B = conv x A≡B ⇨ conv* d A≡B
conv:* : ∀ {Γ A B t u l } → Γ ⊢ t :⇒*: u ∷ A ^ l → Γ ⊢ A ≡ B ^ [ ! , l ] → Γ ⊢ t :⇒*: u ∷ B ^ l
conv:* [[ ⊢t , ⊢u , d ]] e = [[ (conv ⊢t e) , (conv ⊢u e) , (conv* d e) ]]
-- Universe of reduction closures
univ* : ∀ {Γ A B r l} → Γ ⊢ A ⇒* B ∷ (Univ r l) ^ next l → Γ ⊢ A ⇒* B ^ [ r , ι l ]
univ* (id x) = id (univ x)
univ* (x ⇨ A⇒B) = univ x ⇨ univ* A⇒B
-- Application substitution of reduction closures
app-subst* : ∀ {Γ A B t t′ a rA lA lB l} → Γ ⊢ t ⇒* t′ ∷ Π A ^ rA ° lA ▹ B ° lB ° l ^ ι l → Γ ⊢ a ∷ A ^ [ rA , ι lA ]
→ Γ ⊢ t ∘ a ^ l ⇒* t′ ∘ a ^ l ∷ B [ a ] ^ ι lB
app-subst* (id x) a₁ = id (x ∘ⱼ a₁)
app-subst* (x ⇨ t⇒t′) a₁ = app-subst x a₁ ⇨ app-subst* t⇒t′ a₁
| 37.621622
| 117
| 0.454741
|
5e42ba1ceece1ad240a38dc172131106c4794a4a
| 3,835
|
agda
|
Agda
|
LibraBFT/Abstract/Records/Extends.agda
|
oracle/bft-consensus-agda
|
49f8b1b70823be805d84ffc3157c3b880edb1e92
|
[
"UPL-1.0"
] | 4
|
2020-12-16T19:43:41.000Z
|
2021-12-18T19:24:05.000Z
|
LibraBFT/Abstract/Records/Extends.agda
|
oracle/bft-consensus-agda
|
49f8b1b70823be805d84ffc3157c3b880edb1e92
|
[
"UPL-1.0"
] | 72
|
2021-02-04T05:04:33.000Z
|
2022-03-25T05:36:11.000Z
|
LibraBFT/Abstract/Records/Extends.agda
|
oracle/bft-consensus-agda
|
49f8b1b70823be805d84ffc3157c3b880edb1e92
|
[
"UPL-1.0"
] | 6
|
2020-12-16T19:43:52.000Z
|
2022-02-18T01:04:32.000Z
|
{- Byzantine Fault Tolerant Consensus Verification in Agda, version 0.9.
Copyright (c) 2020, 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.Abstract.Types
open import LibraBFT.Abstract.Types.EpochConfig
open import LibraBFT.Lemmas
open import LibraBFT.Prelude
open WithAbsVote
-- This module defines the notion of one Record r "extending" another
-- Record r' (denoted r' ← r), ensuring rules about rounds and that r
-- correctly identifies r'
module LibraBFT.Abstract.Records.Extends
(UID : Set)
(_≟UID_ : (u₀ u₁ : UID) → Dec (u₀ ≡ u₁))
(NodeId : Set)
(𝓔 : EpochConfig UID NodeId)
(𝓥 : VoteEvidence UID NodeId 𝓔)
where
open import LibraBFT.Abstract.Records UID _≟UID_ NodeId 𝓔 𝓥
-- Most of the conditions in section 4.2 of the paper (see
-- LibraBFT.Abstract.RecordChain.Properties) would be checked
-- by the implementation to validate data received.
--
-- In the Abstract model, however, we are only concerned with
-- proving the properties; only round numbers and identifiers
-- for previous records are actually critical to thm S5!
data _←_ : Record → Record → Set where
I←B : {b : Block}
→ 0 < getRound b
→ bPrevQC b ≡ nothing
→ I ← B b
Q←B : {q : QC} {b : Block}
→ getRound q < getRound b
→ just (qCertBlockId q) ≡ bPrevQC b
→ Q q ← B b
B←Q : {b : Block} {q : QC}
→ getRound q ≡ getRound b
→ bId b ≡ qCertBlockId q
→ B b ← Q q
-- Equivalent records extend equivalent records (modulo injectivity
-- failure of bId).
←-≈Rec : ∀{r₀ r₁ s₀ s₁} → (ext₀ : s₀ ← r₀) → (ext₁ : s₁ ← r₁)
→ r₀ ≈Rec r₁
→ NonInjective-≡-preds ((s₀ ≡_) ∘ B) ((s₁ ≡_) ∘ B) bId ⊎ (s₀ ≈Rec s₁)
←-≈Rec (I←B x x₁) (I←B x₂ x₃) hyp = inj₂ eq-I
←-≈Rec (I←B x x₁) (Q←B x₂ x₃) (eq-B refl)
= ⊥-elim (maybe-⊥ (sym x₃) x₁)
←-≈Rec (Q←B x x₁) (I←B x₂ x₃) (eq-B refl)
= ⊥-elim (maybe-⊥ (sym x₁) x₃)
←-≈Rec (Q←B {q₀} x refl) (Q←B {q₁} x₂ refl) (eq-B refl)
= inj₂ (eq-Q refl) -- Here is where we wouldn't be able to
-- complete the proof if we required round equality
-- in eq-Q
←-≈Rec (B←Q {b₀} x refl) (B←Q {b₁} w refl) (eq-Q refl)
with b₀ ≟Block b₁
...| no hb = inj₁ (((b₀ , b₁) , (λ x → hb x) , refl) , refl , refl)
...| yes prf = inj₂ (eq-B prf)
←-irrelevant : Irrelevant _←_
←-irrelevant (I←B r₁ h₁) (I←B r₂ h₂)
= cong₂ I←B (≤-irrelevant r₁ r₂) (≡-irrelevant h₁ h₂)
←-irrelevant (Q←B r₁ h₁) (Q←B r₂ h₂)
= cong₂ Q←B (≤-irrelevant r₁ r₂) (≡-irrelevant h₁ h₂)
←-irrelevant (B←Q r₁ h₁) (B←Q r₂ h₂)
= cong₂ B←Q (≡-irrelevant r₁ r₂) (≡-irrelevant h₁ h₂)
←-round-≤ : ∀{r₀ r₁} → r₀ ← r₁ → round r₀ ≤ round r₁
←-round-≤ (I←B r h) = z≤n
←-round-≤ (Q←B r h) = <⇒≤ r
←-round-≤ (B←Q refl h) = ≤-refl
←←-round-< : ∀{r r₀ r₁} → r ← r₀ → r₀ ← r₁
→ round r < round r₁
←←-round-< (I←B r h) (B←Q refl _) = r
←←-round-< (Q←B r h) rr = ≤-trans r (←-round-≤ rr)
←←-round-< (B←Q refl h) (Q←B prf _) = prf
-- LemmaS1, clause 2: injectivity of _←_
lemmaS1-2 : ∀{r₀ r₁ r₂ r₂'}
→ r₂ ≈Rec r₂'
→ r₀ ← r₂ → r₁ ← r₂'
→ uid r₀ ≡ uid r₁
lemmaS1-2 {i₀} {i₁} {b} hyp (I←B _ i₀←b) (I←B _ i₁←b) = refl
lemmaS1-2 {q} {i} {b} (eq-B refl) (Q←B _ ()) (I←B _ refl)
lemmaS1-2 {i} {q} {b} (eq-B refl) (I←B _ refl) (Q←B _ ())
lemmaS1-2 {q₀} {q₁} {b} (eq-B refl) (Q←B _ refl) (Q←B _ refl) = refl
lemmaS1-2 {b₀} {b₁} {q} (eq-Q refl) (B←Q _ refl) (B←Q _ refl) = refl
-- A better name for lemmaS1-2
←-inj : ∀{r₀ r₁ r₂}
→ r₀ ← r₂ → r₁ ← r₂
→ uid r₀ ≡ uid r₁
←-inj = lemmaS1-2 ≈Rec-refl
| 37.598039
| 111
| 0.560104
|
52bcc327f48feefe2a0c8b654d0bd06bf40c6ef9
| 2,856
|
agda
|
Agda
|
agda-stdlib-0.9/src/Function.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/Function.agda
|
qwe2/try-agda
|
9d4c43b1609d3f085636376fdca73093481ab882
|
[
"Apache-2.0"
] | null | null | null |
agda-stdlib-0.9/src/Function.agda
|
qwe2/try-agda
|
9d4c43b1609d3f085636376fdca73093481ab882
|
[
"Apache-2.0"
] | null | null | null |
------------------------------------------------------------------------
-- The Agda standard library
--
-- Simple combinators working solely on and with functions
------------------------------------------------------------------------
module Function where
open import Level
infixr 9 _∘_ _∘′_
infixl 8 _ˢ_
infixl 1 _on_
infixl 1 _⟨_⟩_
infixr 0 _-[_]-_ _$_
infixl 0 _∋_
------------------------------------------------------------------------
-- Types
-- Unary functions on a given set.
Fun₁ : ∀ {i} → Set i → Set i
Fun₁ A = A → A
-- Binary functions on a given set.
Fun₂ : ∀ {i} → Set i → Set i
Fun₂ A = A → A → A
------------------------------------------------------------------------
-- Functions
_∘_ : ∀ {a b c}
{A : Set a} {B : A → Set b} {C : {x : A} → B x → Set c} →
(∀ {x} (y : B x) → C y) → (g : (x : A) → B x) →
((x : A) → C (g x))
f ∘ g = λ x → f (g x)
_∘′_ : ∀ {a b c} {A : Set a} {B : Set b} {C : Set c} →
(B → C) → (A → B) → (A → C)
f ∘′ g = _∘_ f g
id : ∀ {a} {A : Set a} → A → A
id x = x
const : ∀ {a b} {A : Set a} {B : Set b} → A → B → A
const x = λ _ → x
-- The S combinator. (Written infix as in Conor McBride's paper
-- "Outrageous but Meaningful Coincidences: Dependent type-safe syntax
-- and evaluation".)
_ˢ_ : ∀ {a b c}
{A : Set a} {B : A → Set b} {C : (x : A) → B x → Set c} →
((x : A) (y : B x) → C x y) →
(g : (x : A) → B x) →
((x : A) → C x (g x))
f ˢ g = λ x → f x (g x)
flip : ∀ {a b c} {A : Set a} {B : Set b} {C : A → B → Set c} →
((x : A) (y : B) → C x y) → ((y : B) (x : A) → C x y)
flip f = λ y x → f x y
-- Note that _$_ is right associative, like in Haskell. If you want a
-- left associative infix application operator, use
-- Category.Functor._<$>_, available from
-- Category.Monad.Identity.IdentityMonad.
_$_ : ∀ {a b} {A : Set a} {B : A → Set b} →
((x : A) → B x) → ((x : A) → B x)
f $ x = f x
_⟨_⟩_ : ∀ {a b c} {A : Set a} {B : Set b} {C : Set c} →
A → (A → B → C) → B → C
x ⟨ f ⟩ y = f x y
_on_ : ∀ {a b c} {A : Set a} {B : Set b} {C : Set c} →
(B → B → C) → (A → B) → (A → A → C)
_*_ on f = λ x y → f x * f y
_-[_]-_ : ∀ {a b c d e} {A : Set a} {B : Set b} {C : Set c}
{D : Set d} {E : Set e} →
(A → B → C) → (C → D → E) → (A → B → D) → (A → B → E)
f -[ _*_ ]- g = λ x y → f x y * g x y
-- In Agda you cannot annotate every subexpression with a type
-- signature. This function can be used instead.
_∋_ : ∀ {a} (A : Set a) → A → A
A ∋ x = x
-- Case expressions (to be used with pattern-matching lambdas, see
-- README.Case).
infix 0 case_return_of_ case_of_
case_return_of_ :
∀ {a b} {A : Set a}
(x : A) (B : A → Set b) → ((x : A) → B x) → B x
case x return B of f = f x
case_of_ : ∀ {a b} {A : Set a} {B : Set b} → A → (A → B) → B
case x of f = case x return _ of f
| 27.2
| 72
| 0.429272
|
3485aa2b780d2a9191cecbdd7399d2e22d385900
| 2,994
|
agda
|
Agda
|
agda-stdlib/src/Function/Nary/NonDependent.agda
|
DreamLinuxer/popl21-artifact
|
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
|
[
"MIT"
] | 5
|
2020-10-07T12:07:53.000Z
|
2020-10-10T21:41:32.000Z
|
agda-stdlib/src/Function/Nary/NonDependent.agda
|
DreamLinuxer/popl21-artifact
|
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
|
[
"MIT"
] | null | null | null |
agda-stdlib/src/Function/Nary/NonDependent.agda
|
DreamLinuxer/popl21-artifact
|
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
|
[
"MIT"
] | 1
|
2021-11-04T06:54:45.000Z
|
2021-11-04T06:54:45.000Z
|
------------------------------------------------------------------------
-- The Agda standard library
--
-- Heterogeneous N-ary Functions
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
module Function.Nary.NonDependent where
------------------------------------------------------------------------
-- Concrete examples can be found in README.Nary. This file's comments
-- are more focused on the implementation details and the motivations
-- behind the design decisions.
------------------------------------------------------------------------
open import Level using (Level; 0ℓ; _⊔_; Lift)
open import Data.Nat.Base using (ℕ; zero; suc)
open import Data.Fin.Base using (Fin; zero; suc)
open import Data.Product using (_×_; _,_)
open import Data.Product.Nary.NonDependent
open import Function.Base using (_∘′_; _$′_; const; flip)
open import Relation.Unary using (IUniversal)
open import Relation.Binary.PropositionalEquality
private
variable
a b r : Level
A : Set a
B : Set b
------------------------------------------------------------------------
-- Re-exporting the basic operations
open import Function.Nary.NonDependent.Base public
------------------------------------------------------------------------
-- Additional operations on Levels
ltabulate : ∀ n → (Fin n → Level) → Levels n
ltabulate zero f = _
ltabulate (suc n) f = f zero , ltabulate n (f ∘′ suc)
lreplicate : ∀ n → Level → Levels n
lreplicate n ℓ = ltabulate n (const ℓ)
0ℓs : ∀[ Levels ]
0ℓs = lreplicate _ 0ℓ
------------------------------------------------------------------------
-- Congruence
module _ n {ls} {as : Sets n ls} {R : Set r} (f : as ⇉ R) where
private
g : Product n as → R
g = uncurryₙ n f
-- Congruentₙ : ∀ n. ∀ a₁₁ a₁₂ ⋯ aₙ₁ aₙ₂ →
-- a₁₁ ≡ a₁₂ → ⋯ → aₙ₁ ≡ aₙ₂ →
-- f a₁₁ ⋯ aₙ₁ ≡ f a₁₂ ⋯ aₙ₂
Congruentₙ : Set (r Level.⊔ ⨆ n ls)
Congruentₙ = ∀ {l r} → Equalₙ n l r ⇉ (g l ≡ g r)
congₙ : Congruentₙ
congₙ = curryₙ n (cong g ∘′ fromEqualₙ n)
-- Congruence at a specific location
module _ m n {ls ls'} {as : Sets m ls} {bs : Sets n ls'}
(f : as ⇉ (A → bs ⇉ B)) where
private
g : Product m as → A → Product n bs → B
g vs a ws = uncurryₙ n (uncurryₙ m f vs a) ws
congAt : ∀ {vs ws a₁ a₂} → a₁ ≡ a₂ → g vs a₁ ws ≡ g vs a₂ ws
congAt {vs} {ws} = cong (λ a → g vs a ws)
------------------------------------------------------------------------
-- Injectivity
module _ n {ls} {as : Sets n ls} {R : Set r} (con : as ⇉ R) where
-- Injectiveₙ : ∀ n. ∀ a₁₁ a₁₂ ⋯ aₙ₁ aₙ₂ →
-- con a₁₁ ⋯ aₙ₁ ≡ con a₁₂ ⋯ aₙ₂ →
-- a₁₁ ≡ a₁₂ × ⋯ × aₙ₁ ≡ aₙ₂
private
c : Product n as → R
c = uncurryₙ n con
Injectiveₙ : Set (r Level.⊔ ⨆ n ls)
Injectiveₙ = ∀ {l r} → c l ≡ c r → Product n (Equalₙ n l r)
injectiveₙ : (∀ {l r} → c l ≡ c r → l ≡ r) → Injectiveₙ
injectiveₙ con-inj eq = toEqualₙ n (con-inj eq)
| 30.242424
| 72
| 0.48831
|
8be1f36189d79d322c95c00b42a2d6f4f4798f03
| 1,745
|
agda
|
Agda
|
agda/Cardinality/Finite/SplitEnumerable/Isomorphism.agda
|
oisdk/combinatorics-paper
|
3c176d4690566d81611080e9378f5a178b39b851
|
[
"MIT"
] | 4
|
2021-01-05T14:07:44.000Z
|
2021-01-05T15:32:14.000Z
|
agda/Cardinality/Finite/SplitEnumerable/Isomorphism.agda
|
oisdk/combinatorics-paper
|
3c176d4690566d81611080e9378f5a178b39b851
|
[
"MIT"
] | null | null | null |
agda/Cardinality/Finite/SplitEnumerable/Isomorphism.agda
|
oisdk/combinatorics-paper
|
3c176d4690566d81611080e9378f5a178b39b851
|
[
"MIT"
] | 1
|
2021-01-05T14:05:30.000Z
|
2021-01-05T14:05:30.000Z
|
{-# OPTIONS --cubical --safe #-}
module Cardinality.Finite.SplitEnumerable.Isomorphism where
open import Prelude
open import Container
open import Container.List
open import Data.Fin
open import Container.Membership (ℕ , Fin)
open import Path.Reasoning
open import Data.Sigma.Properties
open import Function.Surjective.Properties
open import Data.Fin.Properties
import Data.List.Membership as 𝕃
open import Container.List.Isomorphism
open import Data.Nat.Properties
open import Data.List using (_∷_; []; List)
import Cardinality.Finite.SplitEnumerable.Container as ℒ
import Cardinality.Finite.SplitEnumerable.Inductive as 𝕃
∈ℒ⇒∈𝕃 : ∀ (x : A) (xs : ⟦ ℕ , Fin ⟧ A) → x ∈ xs → x 𝕃.∈ ℒ→𝕃 xs
∈ℒ⇒∈𝕃 x (suc l , xs) (f0 , p) = f0 , p
∈ℒ⇒∈𝕃 x (suc l , xs) (fs n , p) = 𝕃.push (∈ℒ⇒∈𝕃 x (l , xs ∘ fs) (n , p))
𝕃⇔ℒ⟨ℰ!⟩ : 𝕃.ℰ! A ⇔ ℒ.ℰ! A
𝕃⇔ℒ⟨ℰ!⟩ .fun (sup , cov) = 𝕃→ℒ sup , cov
𝕃⇔ℒ⟨ℰ!⟩ .inv (sup , cov) = ℒ→𝕃 sup , λ x → ∈ℒ⇒∈𝕃 x sup (cov x)
𝕃⇔ℒ⟨ℰ!⟩ .rightInv (sup , cov) i .fst = 𝕃⇔ℒ .rightInv sup i
𝕃⇔ℒ⟨ℰ!⟩ .rightInv (sup , cov) i .snd x = ∈ℒ⇒∈𝕃-rightInv sup (cov x) i
where
∈ℒ⇒∈𝕃-rightInv : ∀ xs x∈xs →
PathP (λ i → x ∈ 𝕃⇔ℒ .rightInv xs i)
(∈ℒ⇒∈𝕃 x xs x∈xs) x∈xs
∈ℒ⇒∈𝕃-rightInv (suc l , xs) (f0 , x∈xs) i = f0 , x∈xs
∈ℒ⇒∈𝕃-rightInv (suc l , xs) (fs n , x∈xs) i =
let m , q = ∈ℒ⇒∈𝕃-rightInv (l , xs ∘ fs) (n , x∈xs) i
in fs m , q
𝕃⇔ℒ⟨ℰ!⟩ .leftInv (sup , cov) i .fst = 𝕃⇔ℒ .leftInv sup i
𝕃⇔ℒ⟨ℰ!⟩ .leftInv (sup , cov) i .snd x = ∈ℒ⇒∈𝕃-leftInv sup (cov x) i
where
∈ℒ⇒∈𝕃-leftInv : ∀ xs x∈xs →
PathP (λ i → x 𝕃.∈ 𝕃→ℒ→𝕃 xs i)
(∈ℒ⇒∈𝕃 x (𝕃→ℒ xs) x∈xs) x∈xs
∈ℒ⇒∈𝕃-leftInv (_ ∷ xs) (f0 , x∈xs) i = f0 , x∈xs
∈ℒ⇒∈𝕃-leftInv (_ ∷ xs) (fs n , x∈xs) i =
let m , p = ∈ℒ⇒∈𝕃-leftInv xs (n , x∈xs) i
in fs m , p
| 35.612245
| 72
| 0.590831
|
19dafdcdd0614f7859e24db6550d6fe19df173e9
| 7,891
|
agda
|
Agda
|
agda-stdlib/src/Algebra/Properties/CommutativeMonoid.agda
|
DreamLinuxer/popl21-artifact
|
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
|
[
"MIT"
] | 5
|
2020-10-07T12:07:53.000Z
|
2020-10-10T21:41:32.000Z
|
agda-stdlib/src/Algebra/Properties/CommutativeMonoid.agda
|
DreamLinuxer/popl21-artifact
|
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
|
[
"MIT"
] | null | null | null |
agda-stdlib/src/Algebra/Properties/CommutativeMonoid.agda
|
DreamLinuxer/popl21-artifact
|
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
|
[
"MIT"
] | 1
|
2021-11-04T06:54:45.000Z
|
2021-11-04T06:54:45.000Z
|
------------------------------------------------------------------------
-- The Agda standard library
--
-- Some derivable properties
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
-- Disabled to prevent warnings from deprecated Table
{-# OPTIONS --warn=noUserWarning #-}
open import Algebra.Bundles
module Algebra.Properties.CommutativeMonoid
{g₁ g₂} (M : CommutativeMonoid g₁ g₂) where
open import Algebra.Operations.CommutativeMonoid M
open import Algebra.Solver.CommutativeMonoid M
open import Relation.Binary as B using (_Preserves_⟶_)
open import Function
open import Function.Equality using (_⟨$⟩_)
open import Data.Product
open import Data.Bool.Base using (Bool; true; false)
open import Data.Nat.Base using (ℕ; zero; suc)
open import Data.Fin.Base using (Fin; zero; suc)
open import Data.List.Base as List using ([]; _∷_)
import Data.Fin.Properties as FP
open import Data.Fin.Permutation as Perm using (Permutation; Permutation′; _⟨$⟩ˡ_; _⟨$⟩ʳ_)
open import Data.Fin.Permutation.Components as PermC
open import Data.Table as Table
open import Data.Table.Relation.Binary.Equality as TE using (_≗_)
open import Data.Unit using (tt)
import Data.Table.Properties as TP
open import Relation.Binary.PropositionalEquality as P using (_≡_)
open import Relation.Nullary as Nullary using (¬_; does; _because_)
open import Relation.Nullary.Negation using (contradiction)
open import Relation.Nullary.Decidable using (⌊_⌋; dec-true; dec-false)
open import Relation.Nullary.Reflects using (invert)
open CommutativeMonoid M
renaming
( ε to 0#
; _∙_ to _+_
; ∙-cong to +-cong
; ∙-congˡ to +-congˡ
; ∙-congʳ to +-congʳ
; identityˡ to +-identityˡ
; identityʳ to +-identityʳ
; assoc to +-assoc
; comm to +-comm
)
open import Algebra.Definitions _≈_
open import Relation.Binary.Reasoning.Setoid setoid
module _ {n} where
open B.Setoid (TE.setoid setoid n) public
using ()
renaming (_≈_ to _≋_)
-- When summing over a function from a finite set, we can pull out any value and move it to the front.
sumₜ-remove : ∀ {n} {i : Fin (suc n)} t → sumₜ t ≈ lookup t i + sumₜ (remove i t)
sumₜ-remove {_} {zero} t = refl
sumₜ-remove {suc n} {suc i} t′ =
begin
t₀ + ∑t ≈⟨ +-congˡ (sumₜ-remove t) ⟩
t₀ + (tᵢ + ∑t′) ≈⟨ solve 3 (λ x y z → x ⊕ (y ⊕ z) ⊜ y ⊕ (x ⊕ z)) refl t₀ tᵢ ∑t′ ⟩
tᵢ + (t₀ + ∑t′) ∎
where
t = tail t′
t₀ = head t′
tᵢ = lookup t i
∑t = sumₜ t
∑t′ = sumₜ (remove i t)
-- '_≈_' is a congruence over 'sumTable n'.
sumₜ-cong-≈ : ∀ {n} → sumₜ {n} Preserves _≋_ ⟶ _≈_
sumₜ-cong-≈ {zero} p = refl
sumₜ-cong-≈ {suc n} p = +-cong (p _) (sumₜ-cong-≈ (p ∘ suc))
-- '_≡_' is a congruence over 'sum n'.
sumₜ-cong-≡ : ∀ {n} → sumₜ {n} Preserves _≗_ ⟶ _≡_
sumₜ-cong-≡ {zero} p = P.refl
sumₜ-cong-≡ {suc n} p = P.cong₂ _+_ (p _) (sumₜ-cong-≡ (p ∘ suc))
-- If addition is idempotent on a particular value 'x', then summing over a
-- nonzero number of copies of 'x' gives back 'x'.
sumₜ-idem-replicate : ∀ n {x} → _+_ IdempotentOn x → sumₜ (replicate {n = suc n} x) ≈ x
sumₜ-idem-replicate zero idem = +-identityʳ _
sumₜ-idem-replicate (suc n) {x} idem = begin
x + (x + sumₜ (replicate {n = n} x)) ≈⟨ sym (+-assoc _ _ _) ⟩
(x + x) + sumₜ (replicate {n = n} x) ≈⟨ +-congʳ idem ⟩
x + sumₜ (replicate {n = n} x) ≈⟨ sumₜ-idem-replicate n idem ⟩
x ∎
-- The sum over the constantly zero function is zero.
sumₜ-zero : ∀ n → sumₜ (replicate {n = n} 0#) ≈ 0#
sumₜ-zero n = begin
sumₜ (replicate {n = n} 0#) ≈⟨ sym (+-identityˡ _) ⟩
0# + sumₜ (replicate {n = n} 0#) ≈⟨ sumₜ-idem-replicate n (+-identityˡ 0#) ⟩
0# ∎
-- The '∑' operator distributes over addition.
∑-distrib-+ : ∀ n (f g : Fin n → Carrier) → ∑[ i < n ] (f i + g i) ≈ ∑[ i < n ] f i + ∑[ i < n ] g i
∑-distrib-+ zero f g = sym (+-identityˡ _)
∑-distrib-+ (suc n) f g = begin
f₀ + g₀ + ∑fg ≈⟨ +-assoc _ _ _ ⟩
f₀ + (g₀ + ∑fg) ≈⟨ +-congˡ (+-congˡ (∑-distrib-+ n _ _)) ⟩
f₀ + (g₀ + (∑f + ∑g)) ≈⟨ solve 4 (λ a b c d → a ⊕ (c ⊕ (b ⊕ d)) ⊜ (a ⊕ b) ⊕ (c ⊕ d)) refl f₀ ∑f g₀ ∑g ⟩
(f₀ + ∑f) + (g₀ + ∑g) ∎
where
f₀ = f zero
g₀ = g zero
∑f = ∑[ i < n ] f (suc i)
∑g = ∑[ i < n ] g (suc i)
∑fg = ∑[ i < n ] (f (suc i) + g (suc i))
-- The '∑' operator commutes with itself.
∑-comm : ∀ n m (f : Fin n → Fin m → Carrier) → ∑[ i < n ] ∑[ j < m ] f i j ≈ ∑[ j < m ] ∑[ i < n ] f i j
∑-comm zero m f = sym (sumₜ-zero m)
∑-comm (suc n) m f = begin
∑[ j < m ] f zero j + ∑[ i < n ] ∑[ j < m ] f (suc i) j ≈⟨ +-congˡ (∑-comm n m _) ⟩
∑[ j < m ] f zero j + ∑[ j < m ] ∑[ i < n ] f (suc i) j ≈⟨ sym (∑-distrib-+ m _ _) ⟩
∑[ j < m ] (f zero j + ∑[ i < n ] f (suc i) j) ∎
-- Any permutation of a table has the same sum as the original.
sumₜ-permute : ∀ {m n} t (π : Permutation m n) → sumₜ t ≈ sumₜ (permute π t)
sumₜ-permute {zero} {zero} t π = refl
sumₜ-permute {zero} {suc n} t π = contradiction π (Perm.refute λ())
sumₜ-permute {suc m} {zero} t π = contradiction π (Perm.refute λ())
sumₜ-permute {suc m} {suc n} t π = begin
sumₜ t ≡⟨⟩
lookup t 0i + sumₜ (remove 0i t) ≡⟨ P.cong₂ _+_ (P.cong (lookup t) (P.sym (Perm.inverseʳ π))) P.refl ⟩
lookup πt (π ⟨$⟩ˡ 0i) + sumₜ (remove 0i t) ≈⟨ +-congˡ (sumₜ-permute (remove 0i t) (Perm.remove (π ⟨$⟩ˡ 0i) π)) ⟩
lookup πt (π ⟨$⟩ˡ 0i) + sumₜ (permute (Perm.remove (π ⟨$⟩ˡ 0i) π) (remove 0i t)) ≡⟨ P.cong₂ _+_ P.refl (sumₜ-cong-≡ (P.sym ∘ TP.remove-permute π 0i t)) ⟩
lookup πt (π ⟨$⟩ˡ 0i) + sumₜ (remove (π ⟨$⟩ˡ 0i) πt) ≈⟨ sym (sumₜ-remove (permute π t)) ⟩
sumₜ πt ∎
where
0i = zero
πt = permute π t
∑-permute : ∀ {m n} f (π : Permutation m n) → ∑[ i < n ] f i ≈ ∑[ i < m ] f (π ⟨$⟩ʳ i)
∑-permute = sumₜ-permute ∘ tabulate
-- If the function takes the same value at 'i' and 'j', then transposing 'i' and
-- 'j' then selecting 'j' is the same as selecting 'i'.
select-transpose :
∀ {n} t (i j : Fin n) → lookup t i ≈ lookup t j →
∀ k → (lookup (select 0# j t) ∘ PermC.transpose i j) k
≈ lookup (select 0# i t) k
select-transpose _ i j e k with k FP.≟ i
... | true because _ rewrite dec-true (j FP.≟ j) P.refl = sym e
... | false because [k≢i] with k FP.≟ j
... | true because [k≡j]
rewrite dec-false (i FP.≟ j) (invert [k≢i] ∘ P.trans (invert [k≡j]) ∘ P.sym)
= refl
... | false because [k≢j] rewrite dec-false (k FP.≟ j) (invert [k≢j]) = refl
-- Summing over a pulse gives you the single value picked out by the pulse.
sumₜ-select : ∀ {n i} (t : Table Carrier n) → sumₜ (select 0# i t) ≈ lookup t i
sumₜ-select {suc n} {i} t = begin
sumₜ (select 0# i t) ≈⟨ sumₜ-remove {i = i} (select 0# i t) ⟩
lookup (select 0# i t) i + sumₜ (remove i (select 0# i t)) ≡⟨ P.cong₂ _+_ (TP.select-lookup t) (sumₜ-cong-≡ (TP.select-remove i t)) ⟩
lookup t i + sumₜ (replicate {n = n} 0#) ≈⟨ +-congˡ (sumₜ-zero n) ⟩
lookup t i + 0# ≈⟨ +-identityʳ _ ⟩
lookup t i ∎
-- Converting to a table then summing is the same as summing the original list
sumₜ-fromList : ∀ xs → sumₜ (fromList xs) ≡ sumₗ xs
sumₜ-fromList [] = P.refl
sumₜ-fromList (x ∷ xs) = P.cong (_ +_) (sumₜ-fromList xs)
-- Converting to a list then summing is the same as summing the original table
sumₜ-toList : ∀ {n} (t : Table Carrier n) → sumₜ t ≡ sumₗ (toList t)
sumₜ-toList {zero} _ = P.refl
sumₜ-toList {suc n} _ = P.cong (_ +_) (sumₜ-toList {n} _)
| 41.973404
| 156
| 0.548219
|
13691d8be8bdf53698a63d63a907498e766e6eaf
| 982
|
agda
|
Agda
|
theorems/homotopy/CircleHSpace.agda
|
mikeshulman/HoTT-Agda
|
e7d663b63d89f380ab772ecb8d51c38c26952dbb
|
[
"MIT"
] | null | null | null |
theorems/homotopy/CircleHSpace.agda
|
mikeshulman/HoTT-Agda
|
e7d663b63d89f380ab772ecb8d51c38c26952dbb
|
[
"MIT"
] | null | null | null |
theorems/homotopy/CircleHSpace.agda
|
mikeshulman/HoTT-Agda
|
e7d663b63d89f380ab772ecb8d51c38c26952dbb
|
[
"MIT"
] | 1
|
2018-12-26T21:31:57.000Z
|
2018-12-26T21:31:57.000Z
|
{-# OPTIONS --without-K --rewriting #-}
open import HoTT
open import homotopy.HSpace
module homotopy.CircleHSpace where
⊙S¹-hSpace : HSpaceStructure ⊙S¹
⊙S¹-hSpace = hSpaceStructure μ μ-e-l μ-e-r μ-coh where
turn-around : (x : S¹) → x == x
turn-around = S¹-elim loop (↓-idf=idf-in' (∙=∙' loop loop))
module Mu = S¹Rec (idf S¹) (λ= turn-around)
μ : S¹ → S¹ → S¹
μ = Mu.f
μ-e-l : (x : S¹) → μ base x == x
μ-e-l x = idp
μ-e-r : (x : S¹) → μ x base == x
μ-e-r = S¹-elim idp (↓-app=idf-in
(idp ∙' loop =⟨ ∙'-unit-l loop ⟩
loop =⟨ idp ⟩
turn-around base =⟨ ! (app=-β turn-around base) ⟩
ap (λ z → z base) (λ= turn-around) =⟨ ! (Mu.loop-β |in-ctx (ap (λ z → z base))) ⟩
ap (λ z → z base) (ap μ loop) =⟨ ! (ap-∘ (λ z → z base) μ loop) ⟩
ap (λ z → μ z base) loop =⟨ ! (∙-unit-r _) ⟩
ap (λ z → μ z base) loop ∙ idp ∎))
μ-coh = idp
| 29.757576
| 88
| 0.479633
|
3469271934ce1ed70461a3855b62d2f508a6648b
| 6,167
|
agda
|
Agda
|
src/Categories/Diagram/Limit/Properties.agda
|
glittershark/agda-categories
|
2128fab9e8d341364cbf784bb17c547bf73891de
|
[
"MIT"
] | null | null | null |
src/Categories/Diagram/Limit/Properties.agda
|
glittershark/agda-categories
|
2128fab9e8d341364cbf784bb17c547bf73891de
|
[
"MIT"
] | null | null | null |
src/Categories/Diagram/Limit/Properties.agda
|
glittershark/agda-categories
|
2128fab9e8d341364cbf784bb17c547bf73891de
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --without-K --safe #-}
open import Categories.Category
open import Categories.Functor
module Categories.Diagram.Limit.Properties
{o ℓ e} {o′ ℓ′ e′} {C : Category o ℓ e} {J : Category o′ ℓ′ e′} where
open import Function.Equality using (Π)
open import Relation.Binary using (Setoid)
open import Categories.Category.Instance.Setoids
open import Categories.Diagram.Cone.Properties
open import Categories.Functor.Hom
open import Categories.NaturalTransformation.NaturalIsomorphism using (NaturalIsomorphism; _≃_; module ≃)
open import Categories.Morphism.Reasoning C
open import Categories.Morphism C
import Categories.Category.Construction.Cones as Con
import Categories.Diagram.Limit as Lim
open Π
open Hom C
private
module J = Category J
module C = Category C
open C
variable
X Y Z : Obj
f g h : X ⇒ Y
open HomReasoning
-- Hom functor preserves limits in C
module _ (W : Obj) {F : Functor J C} (lim : Lim.Limit F) where
private
module F = Functor F
module LF = Lim F
module CF = Con F
module lim = LF.Limit lim
open lim
HomF : Functor J (Setoids ℓ e)
HomF = Hom[ W ,-] ∘F F
module LHomF = Lim HomF
module CHomF = Con HomF
hom-resp-limit : LHomF.Limit
hom-resp-limit = record
{ terminal = record
{ ⊤ = ⊤
; ! = !
; !-unique = !-unique
}
}
where ⊤ : CHomF.Cone
⊤ = record
{ N = hom-setoid {W} {apex}
; apex = record
{ ψ = λ X → record
{ _⟨$⟩_ = λ f → proj X ∘ f
; cong = ∘-resp-≈ʳ
}
; commute = λ {X Y} f {h i} eq → begin
F.F₁ f ∘ (proj X ∘ h) ∘ C.id ≈⟨ center⁻¹ (limit-commute f) identityʳ ⟩
proj Y ∘ h ≈⟨ refl⟩∘⟨ eq ⟩
proj Y ∘ i ∎
}
}
KW : (K : CHomF.Cone) → Setoid.Carrier (CHomF.Cone.N K) → CF.Cone
KW K x = record
{ N = W
; apex = record
{ ψ = λ X → K.ψ X ⟨$⟩ x
; commute = λ f → ⟺ (∘-resp-≈ʳ identityʳ) ○ K.commute f (Setoid.refl K.N)
}
}
where module K = CHomF.Cone K
! : ∀ {K : CHomF.Cone} → CHomF.Cones [ K , ⊤ ]
! {K} = record
{ arr = record
{ _⟨$⟩_ = λ x → rep (KW K x)
; cong = λ {x y} eq → LF.ψ-≈⇒rep-≈ W (CF.Cone.apex (KW K x)) (CF.Cone.apex (KW K y)) lim
(λ A → cong (K.ψ A) eq)
}
; commute = λ {X} {x y} eq → begin
proj X ∘ rep (KW K x) ≈⟨ lim.commute ⟩
K.ψ X ⟨$⟩ x ≈⟨ cong (K.ψ X) eq ⟩
K.ψ X ⟨$⟩ y ∎
}
where module K = CHomF.Cone K
!-unique : ∀ {K : CHomF.Cone} (f : CHomF.Cones [ K , ⊤ ]) → CHomF.Cones [ ! ≈ f ]
!-unique {K} f {x} {y} x≈y = begin
rep (KW K x) ≈⟨ terminal.!-unique f′ ⟩
f.arr ⟨$⟩ x ≈⟨ cong f.arr x≈y ⟩
f.arr ⟨$⟩ y ∎
where module K = CHomF.Cone K
module f = CHomF.Cone⇒ f
f′ : CF.Cones [ KW K x , limit ]
f′ = record
{ arr = f.arr ⟨$⟩ x
; commute = f.commute (Setoid.refl K.N)
}
-- natural isomorphisms respects limits
module _ {F G : Functor J C} (F≃G : F ≃ G) where
private
module F = Functor F
module G = Functor G
module LF = Lim F
module LG = Lim G
open NaturalIsomorphism F≃G
≃-resp-lim : LF.Limit → LG.Limit
≃-resp-lim L = record
{ terminal = record
{ ⊤ = record
{ apex = record
{ ψ = λ j → ⇒.η j ∘ proj j
; commute = λ {X Y} f → begin
G.F₁ f ∘ ⇒.η X ∘ proj X ≈⟨ pullˡ (⇒.sym-commute f) ⟩
(⇒.η Y ∘ F.F₁ f) ∘ proj X ≈⟨ pullʳ (limit-commute f) ⟩
⇒.η Y ∘ proj Y ∎
}
}
; ! = λ {A} → record
{ arr = rep (nat-map-Cone F⇐G A)
; commute = λ {j} → assoc ○ ⟺ (switch-tofromˡ (record { iso = iso j }) (⟺ commute))
}
; !-unique = λ {K} f →
let module f = Con.Cone⇒ G f
in terminal.!-unique record
{ arr = f.arr
; commute = λ {j} → switch-fromtoˡ (record { iso = iso j }) (sym-assoc ○ f.commute)
}
}
}
where open LF.Limit L
≃⇒Cone⇒ : ∀ (Lf : LF.Limit) (Lg : LG.Limit) → Con.Cones G [ LG.Limit.limit (≃-resp-lim Lf) , LG.Limit.limit Lg ]
≃⇒Cone⇒ Lf Lg = rep-cone (LG.Limit.limit (≃-resp-lim Lf))
where open LG.Limit Lg
≃⇒lim≅ : ∀ {F G : Functor J C} (F≃G : F ≃ G) (Lf : Lim.Limit F) (Lg : Lim.Limit G) → Lim.Limit.apex Lf ≅ Lim.Limit.apex Lg
≃⇒lim≅ {F = F} {G} F≃G Lf Lg = record
{ from = arr (≃⇒Cone⇒ F≃G Lf Lg)
; to = arr (≃⇒Cone⇒ (≃.sym F≃G) Lg Lf)
; iso = record
{ isoˡ = Lf.terminal.⊤-id record
{ commute = λ {j} → begin
Lf.proj j ∘ arr (≃⇒Cone⇒ (≃.sym F≃G) Lg Lf) ∘ arr (≃⇒Cone⇒ F≃G Lf Lg) ≈⟨ pullˡ (⇒-commute (≃⇒Cone⇒ (≃.sym F≃G) Lg Lf)) ⟩
(⇐.η j ∘ Lg.proj j) ∘ arr (≃⇒Cone⇒ F≃G Lf Lg) ≈⟨ pullʳ (⇒-commute (≃⇒Cone⇒ F≃G Lf Lg)) ⟩
⇐.η j ∘ ⇒.η j ∘ Lf.proj j ≈⟨ cancelˡ (iso.isoˡ j) ⟩
Lf.proj j ∎
}
; isoʳ = Lg.terminal.⊤-id record
{ commute = λ {j} → begin
Lg.proj j ∘ arr (≃⇒Cone⇒ F≃G Lf Lg) ∘ arr (≃⇒Cone⇒ (≃.sym F≃G) Lg Lf) ≈⟨ pullˡ (⇒-commute (≃⇒Cone⇒ F≃G Lf Lg)) ⟩
(⇒.η j ∘ Lf.proj j) ∘ arr (≃⇒Cone⇒ (≃.sym F≃G) Lg Lf) ≈⟨ pullʳ (⇒-commute (≃⇒Cone⇒ (≃.sym F≃G) Lg Lf)) ⟩
⇒.η j ∘ ⇐.η j ∘ Lg.proj j ≈⟨ cancelˡ (iso.isoʳ j) ⟩
Lg.proj j ∎
}
}
}
where open Con.Cone⇒ renaming (commute to ⇒-commute)
module Lf = Lim.Limit Lf
module Lg = Lim.Limit Lg
open NaturalIsomorphism F≃G
| 35.039773
| 128
| 0.453543
|
43dd01afb286442db9f772571e3ddb38d8222184
| 1,762
|
agda
|
Agda
|
test/Fail/Issue3404.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
test/Fail/Issue3404.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
test/Fail/Issue3404.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
-- Andreas, 2018-11-23, issue #3404, regression in Agda 2.5.4
--
-- The positivity checker judged postulates in mutual blocks
-- as constants, since it found no uses of its arguments.
--
-- The natural cure is to not unleash the positivity checker
-- onto things that do not have a definition, such as postulates.
open import Agda.Builtin.Nat
open import Agda.Builtin.Equality
cong : ∀{A B : Set} (f : A → B) {x y : A} (eq : x ≡ y) → f x ≡ f y
cong f refl = refl
trans : {A : Set} {a b c : A} → a ≡ b → b ≡ c → a ≡ c
trans refl refl = refl
module UnsolvedMeta where
postulate A : Set
mutual postulate B : A → Set -- Problem WAS: B is judged constant
postulate f : (a : A) → B a
g : (a : A) → B a
g a = f _ -- WAS: yellow
-- Should solve.
-- False golfing:
module Word64 where
postulate Word64 : Set
{-# BUILTIN WORD64 Word64 #-}
primitive primWord64ToNat : Word64 → Nat
mutual primitive primWord64FromNat : Nat → Word64
-- Before fix of #3404, positivity checker judged
-- a primitive in a mutual block as constant.
fromNatConst : ∀ x y → primWord64FromNat x ≡ primWord64FromNat y
fromNatConst x y = refl
-- Should fail with error like:
--
-- x != y of type Nat
-- when checking that the expression refl has type
-- primWord64FromNat x ≡ primWord64FromNat y
0≡1 : 0 ≡ 1
0≡1 = cong primWord64ToNat (fromNatConst 0 1)
-- Guillaume Brunerie's original example:
mutual
postulate
2^ : Nat → Nat -- If this function is deemed constant,
2^0 : 1 ≡ 2^ 0 -- then these equalities can be composed.
2^1 : 2^ 1 ≡ 2
bad : 1 ≡ 2
bad = trans 2^0 2^1
-- Should fail with error like:
--
-- 1 != 0 of type Nat
-- when checking that the expression 2^1 has type 2^ 0 ≡ 2
| 25.911765
| 73
| 0.643019
|
8bc7f756592962b0709bbc0daeed36815ea6c8ce
| 7,025
|
agda
|
Agda
|
test/Compiler/with-stdlib/dimensions.agda
|
AntoineAllioux/agda
|
68ec2312961776e415c99d2839e41a92ffe464db
|
[
"BSD-3-Clause"
] | null | null | null |
test/Compiler/with-stdlib/dimensions.agda
|
AntoineAllioux/agda
|
68ec2312961776e415c99d2839e41a92ffe464db
|
[
"BSD-3-Clause"
] | null | null | null |
test/Compiler/with-stdlib/dimensions.agda
|
AntoineAllioux/agda
|
68ec2312961776e415c99d2839e41a92ffe464db
|
[
"BSD-3-Clause"
] | null | null | null |
-- Source: https://raw.githubusercontent.com/gallais/potpourri/master/agda/poc/dimensions/dimensions.agda
-- Author: Original by gallais, modified for test suite by P. Hausmann
module dimensions where
open import Data.Nat as ℕ using (ℕ)
open import Data.Nat.LCM
open import Data.Nat.DivMod hiding (_/_)
open import Data.Integer as ℤ using (ℤ ; +_)
open import Data.Unit.Polymorphic using (⊤)
open import Function
open import Relation.Nullary.Decidable
------------------------------------------------
-- DIMENSIONS
-- record { kilogram = x ; meter = y ; second = z }
-- corresponds to the dimension: kg^x * m^y * s^z
module Dimension where
record dimension : Set where
field
kilogram : ℤ
meter : ℤ
second : ℤ
open dimension public
_*_ : (d e : dimension) → dimension
d * e = record { kilogram = kilogram d ℤ.+ kilogram e
; meter = meter d ℤ.+ meter e
; second = second d ℤ.+ second e }
_/_ : (d e : dimension) → dimension
d / e = record { kilogram = kilogram d ℤ.- kilogram e
; meter = meter d ℤ.- meter e
; second = second d ℤ.- second e }
open Dimension using (dimension ; kilogram ; meter ; second)
kgram met sec : dimension
kgram = record { kilogram = + 1
; meter = + 0
; second = + 0 }
met = record { kilogram = + 0
; meter = + 1
; second = + 0 }
sec = record { kilogram = + 0
; meter = + 0
; second = + 1 }
≠0-mult : ∀ (m n : ℕ) (hm : False (m ℕ.≟ 0)) (hn : False (n ℕ.≟ 0)) →
False (m ℕ.* n ℕ.≟ 0)
≠0-mult ℕ.zero n () hn
≠0-mult m 0 hm ()
≠0-mult (ℕ.suc m) (ℕ.suc n) hm hn = _
------------------------------------------------
-- UNITS
-- A unit is a dimension together with a coefficient
-- 60 , _ # sec represents a minute (60 seconds)
module Unit where
infix 1 _,_#_
data unit : Set where
_,_#_ : (n : ℕ) (hn : False (n ℕ.≟ 0)) (d : dimension) → unit
coeff : (u : unit) → ℕ
coeff (k , _ # _) = k
coeff≠0 : (u : unit) → False (coeff u ℕ.≟ 0)
coeff≠0 (k , hk # _) = hk
_*_ : (u v : unit) → unit
(k , hk # d) * (l , hl # e) =
( k ℕ.* l ) , (≠0-mult k l hk hl) # (d Dimension.* e)
_/_ : (u v : unit)
{≠0 : False (((coeff u) div (coeff v)) {coeff≠0 v} ℕ.≟ 0)} →
unit
_/_ (k , hk # d) (l , hl # e) {≠0} = (k div l) {hl} , ≠0 # (d Dimension./ e)
open Unit using (unit ; _,_#_ ; coeff ; coeff≠0)
------------------------------------------------
-- VALUES
-- Finally, values are natural numbers repackaged
-- with a unit
module Values where
data [_] : (d : unit) → Set where
⟨_∶_⟩ : (value : ℕ) (d : unit) → [ d ]
val : ∀ {d} → [ d ] → ℕ
val ⟨ m ∶ _ ⟩ = m
infix 3 _+_
infix 4 _*_ _/_
_+_ : ∀ {k hk l hl m hm} {d : dimension} (v₁ : [ k , hk # d ])
(v₂ : [ l , hl # d ]) → [ m , hm # d ]
_+_ {k} {hk} {l} {hl} {m} {hm} ⟨ v₁ ∶ ._ ⟩ ⟨ v₂ ∶ ._ ⟩ =
⟨ ((k ℕ.* v₁ ℕ.+ l ℕ.* v₂) div m) {hm} ∶ _ ⟩
_:+_ : ∀ {k hk l hl} {d : dimension} (v₁ : [ k , hk # d ])
(v₂ : [ l , hl # d ]) → [ 1 , _ # d ]
_:+_ = _+_
_*_ : ∀ {k hk l hl m hm} {d e : dimension}
(vd : [ k , hk # d ]) (ve : [ l , hl # e ]) →
[ m , hm # (d Dimension.* e) ]
_*_ {k} {hk} {l} {hl} {m} {hm} ⟨ vd ∶ ._ ⟩ ⟨ ve ∶ ._ ⟩ =
⟨ ((k ℕ.* vd ℕ.* l ℕ.* ve) div m) {hm} ∶ _ ⟩
_:*_ : ∀ {k hk l hl} {d e : dimension}
(vd : [ k , hk # d ]) (ve : [ l , hl # e ]) →
[ 1 , _ # (d Dimension.* e) ]
_:*_ = _*_
_/_ : ∀ {k hk l hl m hm} {d e : dimension}
(vd : [ k , hk # d ]) (ve : [ l , hl # e ])
{≠0 : False (val ve ℕ.≟ 0)} → [ m , hm # (d Dimension./ e) ]
_/_ {k} {hk} {l} {hl} {m} {hm} ⟨ vd ∶ ._ ⟩ ⟨ ve ∶ ._ ⟩ {≠0} =
⟨ ((k ℕ.* vd) div (l ℕ.* ve ℕ.* m)) {≠0-mult _ _ (≠0-mult _ _ hl ≠0) hm} ∶ _ ⟩
↑ : ∀ {k hk l hl d} → [ k , hk # d ] → [ l , hl # d ]
↑ {k} {hk} {l} {hl} ⟨ v ∶ ._ ⟩ = ⟨ ((k ℕ.* v) div l) {hl} ∶ _ ⟩
open Values
------------------------------------------------
-- SI PREFIXES
-- They are simply unit-modifying functions.
infix 5 _**_
_**_ : (k : ℕ) {hk : False $ k ℕ.≟ 0} (d : dimension) → unit
_**_ k {hk} d = k , hk # d
centi : (u : unit) {≠0 : False (coeff u div 100 ℕ.≟ 0)} → unit
centi (k , hk # d) {≠0} = _ , ≠0 # d
deci : (u : unit) {≠0 : False (coeff u div 10 ℕ.≟ 0)} → unit
deci (k , hk # d) {≠0} = _ , ≠0 # d
deca hecto kilo : unit → unit
deca (k , hk # d) = 10 ℕ.* k , ≠0-mult 10 k _ hk # d
hecto (k , hk # d) = 100 ℕ.* k , ≠0-mult 100 k _ hk # d
kilo (k , hk # d) = 1000 ℕ.* k , ≠0-mult 1000 k _ hk # d
cst : unit
cst =
let dcst = record { kilogram = + 0
; meter = + 0
; second = + 0 }
in 1 , _ # dcst
infix 3 κ_
κ_ : (n : ℕ) → [ cst ]
κ n = ⟨ n ∶ cst ⟩
------------------------------------------------
-- EXAMPLES
s min hr : unit
s = 1 ** sec
min = 60 ** sec
hr = 60 ℕ.* 60 ** sec
m : unit
m = 1 ** met
1s : [ s ]
1s = ⟨ 1 ∶ s ⟩
1min : [ min ]
1min = ⟨ 1 ∶ min ⟩
1hr 2hr : [ min ]
1hr = ⟨ 60 ∶ min ⟩
2hr = 1hr + 1hr
1min² : [ s Unit.* s ]
1min² = 1min * 1min
60km : [ kilo m ]
60km = ⟨ 60 ∶ kilo m ⟩
60hm : [ hecto m ]
60hm = ⟨ 60 ∶ hecto m ⟩
60hm/min : [ deca m Unit./ s ]
60hm/min = ⟨ 60 ∶ hecto m ⟩ / ⟨ 1 ∶ min ⟩
acc : unit
acc = m Unit./ (s Unit.* s)
spd : unit
spd = m Unit./ s
------------------------------------------------
-- APPLICATION:
-- free fall of a ball with an initial horizontal speed.
record point : Set where
field
accx accy : [ acc ]
vx vy : [ spd ]
x y : [ m ]
open point public
g : [ acc ]
g = ⟨ 10 ∶ _ ⟩
newton : ∀ (dt : [ s ]) (p : point) → point
newton dt p =
record { accx = accx p
; accy = accy p + g
; vx = vx p + (accx p :* dt)
; vy = vy p + (accy p :* dt)
; x = x p + (vx p :* dt)
; y = y p + (vy p :* dt) }
------------------------------------------------
-- TRACING
-- the initial condition a point is in
base : point
base = record
{ accx = ⟨ 0 ∶ _ ⟩
; accy = ⟨ 0 ∶ _ ⟩
; vx = ⟨ 45 ∶ _ ⟩
; vy = ⟨ 0 ∶ _ ⟩
; x = ⟨ 0 ∶ _ ⟩
; y = ⟨ 0 ∶ _ ⟩ }
-- the consecutive steps of its fall
open import Data.Vec as V using (Vec)
throw : (n : ℕ) (dt : [ s ]) → point → Vec point (ℕ.suc n)
throw ℕ.zero dt p = p V.∷ V.[]
throw (ℕ.suc n) dt p = p V.∷ throw n dt (newton dt p)
-- the display function generating the output
open import Data.String renaming (_++_ to _+s+_)
open import IO
import IO.Primitive
open import Codata.Musical.Colist
open import Data.Nat.Show as Nat
open import Level using (0ℓ)
printPoint : point → IO {0ℓ} ⊤
printPoint p = putStrLn ((Nat.show (val (x p))) +s+ ";" +s+ Nat.show (val (y p)))
main : IO.Primitive.IO ⊤
main = run (Colist.mapM printPoint (Codata.Musical.Colist.fromList trace) >> return _)
where trace = V.toList $ throw 15 ⟨ 1 ∶ s ⟩ base
| 26.609848
| 105
| 0.455943
|
22f11e5d4db856fbe41b387b626c1fe95a4db081
| 5,186
|
agda
|
Agda
|
agda-stdlib/README/Inspect.agda
|
DreamLinuxer/popl21-artifact
|
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
|
[
"MIT"
] | 5
|
2020-10-07T12:07:53.000Z
|
2020-10-10T21:41:32.000Z
|
agda-stdlib/README/Inspect.agda
|
DreamLinuxer/popl21-artifact
|
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
|
[
"MIT"
] | null | null | null |
agda-stdlib/README/Inspect.agda
|
DreamLinuxer/popl21-artifact
|
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
|
[
"MIT"
] | 1
|
2021-11-04T06:54:45.000Z
|
2021-11-04T06:54:45.000Z
|
------------------------------------------------------------------------
-- The Agda standard library
--
-- Explaining how to use the inspect idiom and elaborating on the way
-- it is implemented in the standard library.
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
module README.Inspect where
open import Data.Nat.Base
open import Data.Nat.Properties
open import Data.Product
open import Relation.Binary.PropositionalEquality
------------------------------------------------------------------------
-- Using inspect
-- We start with the definition of a (silly) predicate: `Plus m n p` states
-- that `m + n` is equal to `p` in a rather convoluted way. Crucially, it
-- distinguishes two cases: whether `p` is 0 or not.
Plus-eq : (m n p : ℕ) → Set
Plus-eq m n zero = m ≡ 0 × n ≡ 0
Plus-eq m n p@(suc _) = m + n ≡ p
-- A sensible lemma to prove of this predicate is that whenever `p` is literally
-- `m + n` then `Plus m n p` holds. That is to say `∀ m n → Plus m n (m + n)`.
-- To be able to prove `Plus-eq m n (m + n)`, we need `m + n` to have either
-- the shape `zero` or `suc _` so that `Plus-eq` may reduce.
-- We could follow the way `_+_` computes by mimicking the same splitting
-- strategy, thus forcing `m + n` to reduce:
plus-eq-+ : ∀ m n → Plus-eq m n (m + n)
plus-eq-+ zero zero = refl , refl
plus-eq-+ zero (suc n) = refl
plus-eq-+ (suc m) n = refl
-- Or we could attempt to compute `m + n` first and check whether the result
-- is `zero` or `suc p`. By using `with m + n` and naming the result `p`,
-- the goal will become `Plus-eq m n p`. We can further refine this definition
-- by distinguishing two cases like so:
-- plus-eq-with : ∀ m n → Plus-eq m n (m + n)
-- plus-eq-with m n with m + n
-- ... | zero = {!!}
-- ... | suc p = {!!}
-- The problem however is that we have abolutely lost the connection between the
-- computation `m + n` and its result `p`. Which makes the two goals unprovable:
-- 1. `m ≡ 0 × n ≡ 0`, with no assumption whatsoever
-- 2. `m + n ≡ suc p`, with no assumption either
-- By using the `with` construct, we have generated an auxiliary function that
-- looks like this:
-- `plus-eq-with-aux : ∀ m n p → Plus-eq m n p`
-- when we would have wanted a more precise type of the form:
-- `plus-eq-aux : ∀ m n p → m + n ≡ p → Plus-eq m n p`.
-- This is where we can use `inspect`. By using `with f x | inspect f x`,
-- we get both a `y` which is the result of `f x` and a proof that `f x ≡ y`.
-- Splitting on the result of `m + n`, we get two cases:
-- 1. `m ≡ 0 × n ≡ 0` under the assumption that `m + n ≡ zero`
-- 2. `m + n ≡ suc p` under the assumption that `m + n ≡ suc p`
-- The first one can be discharged using lemmas from Data.Nat.Properties and
-- the second one is trivial.
plus-eq-with : ∀ m n → Plus-eq m n (m + n)
plus-eq-with m n with m + n | inspect (m +_) n
... | zero | [ m+n≡0 ] = m+n≡0⇒m≡0 m m+n≡0 , m+n≡0⇒n≡0 m m+n≡0
... | suc p | [ m+n≡1+p ] = m+n≡1+p
------------------------------------------------------------------------
-- Understanding the implementation of inspect
-- So why is it that we have to go through the record type `Reveal_·_is_`
-- and the ̀inspect` function? The fact is: we don't have to if we write
-- our own auxiliary lemma:
plus-eq-aux : ∀ m n → Plus-eq m n (m + n)
plus-eq-aux m n = aux m n (m + n) refl where
aux : ∀ m n p → m + n ≡ p → Plus-eq m n p
aux m n zero m+n≡0 = m+n≡0⇒m≡0 m m+n≡0 , m+n≡0⇒n≡0 m m+n≡0
aux m n (suc p) m+n≡1+p = m+n≡1+p
-- The problem is that when we write ̀with f x | pr`, `with` decides to call `y`
-- the result `f x` and to replace *all* of the occurences of `f x` in the type
-- of `pr` with `y`. That is to say that if we were to write:
-- plus-eq-naïve : ∀ m n → Plus-eq m n (m + n)
-- plus-eq-naïve m n with m + n | refl {x = m + n}
-- ... | p | eq = {!!}
-- then `with` would abstract `m + n` as `p` on *both* sides of the equality
-- proven by `refl` thus giving us the following goal with an extra, useless,
-- assumption:
-- 1. `Plus-eq m n p` under the assumption that `p ≡ p`
-- So how does `inspect` work? The standard library uses a more general version
-- of the following type and function:
record MyReveal_·_is_ (f : ℕ → ℕ) (x y : ℕ) : Set where
constructor [_]
field eq : f x ≡ y
my-inspect : ∀ f n → MyReveal f · n is (f n)
my-inspect f n = [ refl ]
-- Given that `inspect` has the type `∀ f n → Reveal f · n is (f n)`, when we
-- write `with f n | inspect f n`, the only `f n` that can be abstracted in the
-- type of `inspect f n` is the third argument to `Reveal_·_is_`.
-- That is to say that the auxiliary definition generated looks like this:
plus-eq-reveal : ∀ m n → Plus-eq m n (m + n)
plus-eq-reveal m n = aux m n (m + n) (my-inspect (m +_) n) where
aux : ∀ m n p → MyReveal (m +_) · n is p → Plus-eq m n p
aux m n zero [ m+n≡0 ] = m+n≡0⇒m≡0 m m+n≡0 , m+n≡0⇒n≡0 m m+n≡0
aux m n (suc p) [ m+n≡1+p ] = m+n≡1+p
-- At the cost of having to unwrap the constructor `[_]` around the equality
-- we care about, we can keep relying on `with` and avoid having to roll out
-- handwritten auxiliary definitions.
| 38.992481
| 80
| 0.590629
|
526ea83158572f2e7d450e5df71f5d17ee1797a4
| 22,458
|
agda
|
Agda
|
F2.agda
|
JacquesCarette/pi-dual
|
003835484facfde0b770bc2b3d781b42b76184c1
|
[
"BSD-2-Clause"
] | 14
|
2015-08-18T21:40:15.000Z
|
2021-05-05T01:07:57.000Z
|
F2.agda
|
JacquesCarette/pi-dual
|
003835484facfde0b770bc2b3d781b42b76184c1
|
[
"BSD-2-Clause"
] | 4
|
2018-06-07T16:27:41.000Z
|
2021-10-29T20:41:23.000Z
|
F2.agda
|
JacquesCarette/pi-dual
|
003835484facfde0b770bc2b3d781b42b76184c1
|
[
"BSD-2-Clause"
] | 3
|
2016-05-29T01:56:33.000Z
|
2019-09-10T09:47:13.000Z
|
module F2 where
open import Data.Empty
open import Data.Unit
open import Data.Sum hiding (map; [_,_])
open import Data.Product hiding (map; ,_)
open import Function using (flip)
open import Relation.Binary.Core
using (IsEquivalence; Reflexive; Symmetric; Transitive)
open import Relation.Binary
open import Groupoid
infix 2 _∎ -- equational reasoning
infixr 2 _≡⟨_⟩_ -- equational reasoning
---------------------------------------------------------------------------
-- Paths
-- these are individual paths so to speak
-- should we represent a path like swap+ as a family explicitly:
-- swap+ : (x : A) -> x ⇛ swapF x
-- I guess we can: swap+ : (x : A) -> case x of inj1 -> swap1 x else swap2 x
{--
Use pointed types instead of singletons
If A={x0,x1,x2}, 1/A has three values:
(x0<-x0, x0<-x1, x0<-x2)
(x1<-x0, x1<-x1, x1<-x2)
(x2<-x0, x2<-x1, x2<-x2)
It is a fake choice between x0, x1, and x2 (some negative information). You base
yourself at x0 for example and enforce that any other value can be mapped to x0.
So think of a value of type 1/A as an uncertainty about which value of A we
have. It could be x0, x1, or x2 but at the end it makes no difference. There is
no choice.
You can manipulate a value of type 1/A (x0<-x0, x0<-x1, x0<-x2) by with a
path to some arbitrary path to b0 for example:
(b0<-x0<-x0, b0<-x0<-x1, b0<-x0<-x2)
eta_3 will give (x0<-x0, x0<-x1, x0<-x2, x0) for example but any other
combination is equivalent.
epsilon_3 will take (x0<-x0, x0<-x1, x0<-x2) and one actual xi which is now
certain; we can resolve our previous uncertainty by following the path from
xi to x0 thus eliminating the fake choice we seemed to have.
Explain connection to negative information.
Knowing head or tails is 1 bits. Giving you a choice between heads and tails
and then cooking this so that heads=tails takes away your choice.
--}
data _⇛_ : {A B : Set} → (x : A) → (y : B) → Set₁ where
-- +
unite₊⇛ : {A : Set} {x : A} → _⇛_ {⊥ ⊎ A} {A} (inj₂ x) x
uniti₊⇛ : {A : Set} {x : A} → _⇛_ {A} {⊥ ⊎ A} x (inj₂ x)
swap₁₊⇛ : {A B : Set} {x : A} → _⇛_ {A ⊎ B} {B ⊎ A} (inj₁ x) (inj₂ x)
swap₂₊⇛ : {A B : Set} {y : B} → _⇛_ {A ⊎ B} {B ⊎ A} (inj₂ y) (inj₁ y)
assocl₁₊⇛ : {A B C : Set} {x : A} →
_⇛_ {A ⊎ (B ⊎ C)} {(A ⊎ B) ⊎ C} (inj₁ x) (inj₁ (inj₁ x))
assocl₂₁₊⇛ : {A B C : Set} {y : B} →
_⇛_ {A ⊎ (B ⊎ C)} {(A ⊎ B) ⊎ C} (inj₂ (inj₁ y)) (inj₁ (inj₂ y))
assocl₂₂₊⇛ : {A B C : Set} {z : C} →
_⇛_ {A ⊎ (B ⊎ C)} {(A ⊎ B) ⊎ C} (inj₂ (inj₂ z)) (inj₂ z)
assocr₁₁₊⇛ : {A B C : Set} {x : A} →
_⇛_ {(A ⊎ B) ⊎ C} {A ⊎ (B ⊎ C)} (inj₁ (inj₁ x)) (inj₁ x)
assocr₁₂₊⇛ : {A B C : Set} {y : B} →
_⇛_ {(A ⊎ B) ⊎ C} {A ⊎ (B ⊎ C)} (inj₁ (inj₂ y)) (inj₂ (inj₁ y))
assocr₂₊⇛ : {A B C : Set} {z : C} →
_⇛_ {(A ⊎ B) ⊎ C} {A ⊎ (B ⊎ C)} (inj₂ z) (inj₂ (inj₂ z))
-- *
unite⋆⇛ : {A : Set} {x : A} → _⇛_ {⊤ × A} {A} (tt , x) x
uniti⋆⇛ : {A : Set} {x : A} → _⇛_ {A} {⊤ × A} x (tt , x)
swap⋆⇛ : {A B : Set} {x : A} {y : B} → _⇛_ {A × B} {B × A} (x , y) (y , x)
assocl⋆⇛ : {A B C : Set} {x : A} {y : B} {z : C} →
_⇛_ {A × (B × C)} {(A × B) × C} (x , (y , z)) ((x , y) , z)
assocr⋆⇛ : {A B C : Set} {x : A} {y : B} {z : C} →
_⇛_ {(A × B) × C} {A × (B × C)} ((x , y) , z) (x , (y , z))
-- distributivity
dist₁⇛ : {A B C : Set} {x : A} {z : C} →
_⇛_ {(A ⊎ B) × C} {(A × C) ⊎ (B × C)} (inj₁ x , z) (inj₁ (x , z))
dist₂⇛ : {A B C : Set} {y : B} {z : C} →
_⇛_ {(A ⊎ B) × C} {(A × C) ⊎ (B × C)} (inj₂ y , z) (inj₂ (y , z))
factor₁⇛ : {A B C : Set} {x : A} {z : C} →
_⇛_ {(A × C) ⊎ (B × C)} {(A ⊎ B) × C} (inj₁ (x , z)) (inj₁ x , z)
factor₂⇛ : {A B C : Set} {y : B} {z : C} →
_⇛_ {(A × C) ⊎ (B × C)} {(A ⊎ B) × C}
(inj₂ (y , z)) (inj₂ y , z)
dist0⇛ : {A : Set} {• : ⊥} {x : A} → _⇛_ {⊥ × A} {⊥} (• , x) •
factor0⇛ : {A : Set} {• : ⊥} {x : A} → _⇛_ {⊥} {⊥ × A} • (• , x)
-- congruence
id⇛ : {A : Set} → (x : A) → x ⇛ x
sym⇛ : {A B : Set} {x : A} {y : B} → x ⇛ y → y ⇛ x
trans⇛ : {A B C : Set} {x : A} {y : B} {z : C} → x ⇛ y → y ⇛ z → x ⇛ z
plus₁⇛ : {A B C D : Set} {x : A} {z : C} →
x ⇛ z → _⇛_ {A ⊎ B} {C ⊎ D} (inj₁ x) (inj₁ z)
plus₂⇛ : {A B C D : Set} {y : B} {w : D} →
y ⇛ w → _⇛_ {A ⊎ B} {C ⊎ D} (inj₂ y) (inj₂ w)
times⇛ : {A B C D : Set} {x : A} {y : B} {z : C} {w : D} →
x ⇛ z → y ⇛ w → _⇛_ {A × B} {C × D} (x , y) (z , w)
-- permute
-- for any given type, we should be able to generate permutations mapping any
-- point to any other type
-- Introduce equational reasoning syntax to simplify proofs
_≡⟨_⟩_ : {A B C : Set} (x : A) {y : B} {z : C} → (x ⇛ y) → (y ⇛ z) → (x ⇛ z)
_ ≡⟨ p ⟩ q = trans⇛ p q
bydef : {A : Set} {x : A} → (x ⇛ x)
bydef {A} {x} = id⇛ x
_∎ : {A : Set} (x : A) → x ⇛ x
_∎ x = id⇛ x
data Singleton {A : Set} : A → Set where
singleton : (x : A) → Singleton x
mutual
ap : {A B : Set} {x : A} {y : B} → x ⇛ y → Singleton x → Singleton y
ap {.(⊥ ⊎ A)} {A} {.(inj₂ x)} {x} unite₊⇛ (singleton .(inj₂ x)) =
singleton x
ap uniti₊⇛ (singleton x) = singleton (inj₂ x)
ap (swap₁₊⇛ {A} {B} {x}) (singleton .(inj₁ x)) = singleton (inj₂ x)
ap (swap₂₊⇛ {A} {B} {y}) (singleton .(inj₂ y)) = singleton (inj₁ y)
ap (assocl₁₊⇛ {A} {B} {C} {x}) (singleton .(inj₁ x)) =
singleton (inj₁ (inj₁ x))
ap (assocl₂₁₊⇛ {A} {B} {C} {y}) (singleton .(inj₂ (inj₁ y))) =
singleton (inj₁ (inj₂ y))
ap (assocl₂₂₊⇛ {A} {B} {C} {z}) (singleton .(inj₂ (inj₂ z))) =
singleton (inj₂ z)
ap (assocr₁₁₊⇛ {A} {B} {C} {x}) (singleton .(inj₁ (inj₁ x))) =
singleton (inj₁ x)
ap (assocr₁₂₊⇛ {A} {B} {C} {y}) (singleton .(inj₁ (inj₂ y))) =
singleton (inj₂ (inj₁ y))
ap (assocr₂₊⇛ {A} {B} {C} {z}) (singleton .(inj₂ z)) =
singleton (inj₂ (inj₂ z))
ap {.(⊤ × A)} {A} {.(tt , x)} {x} unite⋆⇛ (singleton .(tt , x)) =
singleton x
ap uniti⋆⇛ (singleton x) = singleton (tt , x)
ap (swap⋆⇛ {A} {B} {x} {y}) (singleton .(x , y)) = singleton (y , x)
ap (assocl⋆⇛ {A} {B} {C} {x} {y} {z}) (singleton .(x , (y , z))) =
singleton ((x , y) , z)
ap (assocr⋆⇛ {A} {B} {C} {x} {y} {z}) (singleton .((x , y) , z)) =
singleton (x , (y , z))
ap (dist₁⇛ {A} {B} {C} {x} {z}) (singleton .(inj₁ x , z)) =
singleton (inj₁ (x , z))
ap (dist₂⇛ {A} {B} {C} {y} {z}) (singleton .(inj₂ y , z)) =
singleton (inj₂ (y , z))
ap (factor₁⇛ {A} {B} {C} {x} {z}) (singleton .(inj₁ (x , z))) =
singleton (inj₁ x , z)
ap (factor₂⇛ {A} {B} {C} {y} {z}) (singleton .(inj₂ (y , z))) =
singleton (inj₂ y , z)
ap {.(⊥ × A)} {.⊥} {.(• , x)} {•} (dist0⇛ {A} {.•} {x}) (singleton .(• , x)) =
singleton •
ap factor0⇛ (singleton ())
ap (id⇛ .x) (singleton x) = singleton x
ap (sym⇛ c) (singleton x) = apI c (singleton x)
ap (trans⇛ c₁ c₂) (singleton x) = ap c₂ (ap c₁ (singleton x))
ap (plus₁⇛ {A} {B} {C} {D} {x} {z} c) (singleton .(inj₁ x))
with ap c (singleton x)
... | singleton .z = singleton (inj₁ z)
ap (plus₂⇛ {A} {B} {C} {D} {y} {w} c) (singleton .(inj₂ y))
with ap c (singleton y)
... | singleton .w = singleton (inj₂ w)
ap (times⇛ {A} {B} {C} {D} {x} {y} {z} {w} c₁ c₂) (singleton .(x , y))
with ap c₁ (singleton x) | ap c₂ (singleton y)
... | singleton .z | singleton .w = singleton (z , w)
apI : {A B : Set} {x : A} {y : B} → x ⇛ y → Singleton y → Singleton x
apI unite₊⇛ (singleton x) = singleton (inj₂ x)
apI {A} {.(⊥ ⊎ A)} {x} uniti₊⇛ (singleton .(inj₂ x)) = singleton x
apI (swap₁₊⇛ {A} {B} {x}) (singleton .(inj₂ x)) = singleton (inj₁ x)
apI (swap₂₊⇛ {A} {B} {y}) (singleton .(inj₁ y)) = singleton (inj₂ y)
apI (assocl₁₊⇛ {A} {B} {C} {x}) (singleton .(inj₁ (inj₁ x))) =
singleton (inj₁ x)
apI (assocl₂₁₊⇛ {A} {B} {C} {y}) (singleton .(inj₁ (inj₂ y))) =
singleton (inj₂ (inj₁ y))
apI (assocl₂₂₊⇛ {A} {B} {C} {z}) (singleton .(inj₂ z)) =
singleton (inj₂ (inj₂ z))
apI (assocr₁₁₊⇛ {A} {B} {C} {x}) (singleton .(inj₁ x)) =
singleton (inj₁ (inj₁ x))
apI (assocr₁₂₊⇛ {A} {B} {C} {y}) (singleton .(inj₂ (inj₁ y))) =
singleton (inj₁ (inj₂ y))
apI (assocr₂₊⇛ {A} {B} {C} {z}) (singleton .(inj₂ (inj₂ z))) =
singleton (inj₂ z)
apI unite⋆⇛ (singleton x) = singleton (tt , x)
apI {A} {.(⊤ × A)} {x} uniti⋆⇛ (singleton .(tt , x)) = singleton x
apI (swap⋆⇛ {A} {B} {x} {y}) (singleton .(y , x)) = singleton (x , y)
apI (assocl⋆⇛ {A} {B} {C} {x} {y} {z}) (singleton .((x , y) , z)) =
singleton (x , (y , z))
apI (assocr⋆⇛ {A} {B} {C} {x} {y} {z}) (singleton .(x , (y , z))) =
singleton ((x , y) , z)
apI (dist₁⇛ {A} {B} {C} {x} {z}) (singleton .(inj₁ (x , z))) =
singleton (inj₁ x , z)
apI (dist₂⇛ {A} {B} {C} {y} {z}) (singleton .(inj₂ (y , z))) =
singleton (inj₂ y , z)
apI (factor₁⇛ {A} {B} {C} {x} {z}) (singleton .(inj₁ x , z)) =
singleton (inj₁ (x , z))
apI (factor₂⇛ {A} {B} {C} {y} {z}) (singleton .(inj₂ y , z)) =
singleton (inj₂ (y , z))
apI dist0⇛ (singleton ())
apI {.⊥} {.(⊥ × A)} {•} (factor0⇛ {A} {.•} {x}) (singleton .(• , x)) =
singleton •
apI (id⇛ .x) (singleton x) = singleton x
apI (sym⇛ c) (singleton x) = ap c (singleton x)
apI {A} {B} {x} {y} (trans⇛ c₁ c₂) (singleton .y) =
apI c₁ (apI c₂ (singleton y))
apI (plus₁⇛ {A} {B} {C} {D} {x} {z} c) (singleton .(inj₁ z))
with apI c (singleton z)
... | singleton .x = singleton (inj₁ x)
apI (plus₂⇛ {A} {B} {C} {D} {y} {w} c) (singleton .(inj₂ w))
with apI c (singleton w)
... | singleton .y = singleton (inj₂ y)
apI (times⇛ {A} {B} {C} {D} {x} {y} {z} {w} c₁ c₂) (singleton .(z , w))
with apI c₁ (singleton z) | apI c₂ (singleton w)
... | singleton .x | singleton .y = singleton (x , y)
-- Path induction
pathInd :
(C : (A : Set) → (B : Set) → (x : A) → (y : B) → x ⇛ y → Set) →
(c : (A : Set) → (x : A) → C A A x x (id⇛ x)) →
-- add more cases, one for each constructor
(A : Set) → (B : Set) → (x : A) → (y : B) → (p : x ⇛ y) → C A B x y p
pathInd C c .(⊥ ⊎ B) B .(inj₂ y) y unite₊⇛ = {!!}
pathInd C c A .(⊥ ⊎ A) x .(inj₂ x) uniti₊⇛ = {!!}
pathInd C c .(A ⊎ B) .(B ⊎ A) .(inj₁ x) .(inj₂ x) (swap₁₊⇛ {A} {B} {x}) = {!!}
pathInd C c .(A ⊎ B) .(B ⊎ A) .(inj₂ y) .(inj₁ y) (swap₂₊⇛ {A} {B} {y}) = {!!}
pathInd C c .(A ⊎ B ⊎ C₁) .((A ⊎ B) ⊎ C₁) .(inj₁ x) .(inj₁ (inj₁ x))
(assocl₁₊⇛ {A} {B} {C₁} {x}) = {!!}
pathInd C c .(A ⊎ B ⊎ C₁) .((A ⊎ B) ⊎ C₁) .(inj₂ (inj₁ y)) .(inj₁ (inj₂ y))
(assocl₂₁₊⇛ {A} {B} {C₁} {y}) = {!!}
pathInd C c .(A ⊎ B ⊎ C₁) .((A ⊎ B) ⊎ C₁) .(inj₂ (inj₂ z)) .(inj₂ z)
(assocl₂₂₊⇛ {A} {B} {C₁} {z}) = {!!}
pathInd C c .((A ⊎ B) ⊎ C₁) .(A ⊎ B ⊎ C₁) .(inj₁ (inj₁ x)) .(inj₁ x)
(assocr₁₁₊⇛ {A} {B} {C₁} {x}) = {!!}
pathInd C c .((A ⊎ B) ⊎ C₁) .(A ⊎ B ⊎ C₁) .(inj₁ (inj₂ y)) .(inj₂ (inj₁ y))
(assocr₁₂₊⇛ {A} {B} {C₁} {y}) = {!!}
pathInd C c .((A ⊎ B) ⊎ C₁) .(A ⊎ B ⊎ C₁) .(inj₂ z) .(inj₂ (inj₂ z))
(assocr₂₊⇛ {A} {B} {C₁} {z}) = {!!}
pathInd C c .(Σ ⊤ (λ x₁ → B)) B .(tt , y) y unite⋆⇛ = {!!}
pathInd C c A .(Σ ⊤ (λ x₁ → A)) x .(tt , x) uniti⋆⇛ = {!!}
pathInd C c .(Σ A (λ x₁ → B)) .(Σ B (λ x₁ → A)) .(x , y) .(y , x)
(swap⋆⇛ {A} {B} {x} {y}) = {!!}
pathInd C c .(Σ A (λ x₁ → Σ B (λ x₂ → C₁))) .(Σ (Σ A (λ x₁ → B)) (λ x₁ → C₁))
.(x , y , z) .((x , y) , z) (assocl⋆⇛ {A} {B} {C₁} {x} {y} {z}) = {!!}
pathInd C c .(Σ (Σ A (λ x₁ → B)) (λ x₁ → C₁)) .(Σ A (λ x₁ → Σ B (λ x₂ → C₁)))
.((x , y) , z) .(x , y , z) (assocr⋆⇛ {A} {B} {C₁} {x} {y} {z}) = {!!}
pathInd C c .(Σ (A ⊎ B) (λ x₁ → C₁)) .(Σ A (λ x₁ → C₁) ⊎ Σ B (λ x₁ → C₁))
.(inj₁ x , z) .(inj₁ (x , z)) (dist₁⇛ {A} {B} {C₁} {x} {z}) = {!!}
pathInd C c .(Σ (A ⊎ B) (λ x₁ → C₁)) .(Σ A (λ x₁ → C₁) ⊎ Σ B (λ x₁ → C₁))
.(inj₂ y , z) .(inj₂ (y , z)) (dist₂⇛ {A} {B} {C₁} {y} {z}) = {!!}
pathInd C c .(Σ A (λ x₁ → C₁) ⊎ Σ B (λ x₁ → C₁)) .(Σ (A ⊎ B) (λ x₁ → C₁))
.(inj₁ (x , z)) .(inj₁ x , z) (factor₁⇛ {A} {B} {C₁} {x} {z}) = {!!}
pathInd C c .(Σ A (λ x₁ → C₁) ⊎ Σ B (λ x₁ → C₁)) .(Σ (A ⊎ B) (λ x₁ → C₁))
.(inj₂ (y , z)) .(inj₂ y , z) (factor₂⇛ {A} {B} {C₁} {y} {z}) = {!!}
pathInd C c .(Σ ⊥ (λ x₁ → A)) .⊥ .(y , x) y (dist0⇛ {A} {.y} {x}) = {!!}
pathInd C c .⊥ .(Σ ⊥ (λ x₁ → A)) x .(x , x₁) (factor0⇛ {A} {.x} {x₁}) = {!!}
pathInd C c A .A x .x (id⇛ .x) = c A x
pathInd C c A B x y (sym⇛ p) = {!!}
pathInd C c A B x y (trans⇛ p p₁) = {!!}
pathInd C c .(A ⊎ B) .(C₁ ⊎ D) .(inj₁ x) .(inj₁ z)
(plus₁⇛ {A} {B} {C₁} {D} {x} {z} p) = {!!}
pathInd C c .(A ⊎ B) .(C₁ ⊎ D) .(inj₂ y) .(inj₂ w)
(plus₂⇛ {A} {B} {C₁} {D} {y} {w} p) = {!!}
pathInd C c .(Σ A (λ x₁ → B)) .(Σ C₁ (λ x₁ → D)) .(x , y) .(z , w)
(times⇛ {A} {B} {C₁} {D} {x} {y} {z} {w} p p₁) = {!!}
------------------------------------------------------------------------------
-- Now interpret a path (x ⇛ y) as a value of type (1/x , y)
Recip : {A : Set} → (base : A) → (x : A) → Set₁
Recip {A} base = λ x → (x ⇛ base)
η : {A : Set} {base : A} → ⊤ → Recip base × Singleton base
η {A} {base} tt = (λ x → ? , singleton base)
{--
If A={x0,x1,x2}, 1/A has three values:
(x0<-x0, x0<-x1, x0<-x2)
η : {A : Set} {x : A} → ⊤ → Recip x × Singleton x
η {A} {x} tt = (id⇛ x , singleton x)
ε : {A : Set} {x : A} → Recip x × Singleton x → ⊤
ε {A} {x} (rx , singleton .x) = tt -- makes no sense
apr : {A B : Set} {x : A} {y : B} → (x ⇛ y) → Recip y → Recip x
apr {A} {B} {x} {y} p ry =
x
≡⟨ p ⟩
y
≡⟨ ry ⟩
y
≡⟨ sym⇛ p ⟩
x ∎
ε : {A B : Set} {x : A} {y : B} → Recip x → Singleton y → x ⇛ y
ε rx (singleton y) = rx y
pathV : {A B : Set} {x : A} {y : B} → (x ⇛ y) → Recip x × Singleton y
pathV unite₊⇛ = {!!}
pathV uniti₊⇛ = {!!}
-- swap₁₊⇛ : {A B : Set} {x : A} → _⇛_ {A ⊎ B} {B ⊎ A} (inj₁ x) (inj₂ x)
pathV (swap₁₊⇛ {A} {B} {x}) = ((λ x' → {!!}) , singleton (inj₂ x))
pathV swap₂₊⇛ = {!!}
pathV assocl₁₊⇛ = {!!}
pathV assocl₂₁₊⇛ = {!!}
pathV assocl₂₂₊⇛ = {!!}
pathV assocr₁₁₊⇛ = {!!}
pathV assocr₁₂₊⇛ = {!!}
pathV assocr₂₊⇛ = {!!}
pathV unite⋆⇛ = {!!}
pathV uniti⋆⇛ = {!!}
pathV swap⋆⇛ = {!!}
pathV assocl⋆⇛ = {!!}
pathV assocr⋆⇛ = {!!}
pathV dist₁⇛ = {!!}
pathV dist₂⇛ = {!!}
pathV factor₁⇛ = {!!}
pathV factor₂⇛ = {!!}
pathV dist0⇛ = {!!}
pathV factor0⇛ = {!!}
pathV {A} {.A} {x} (id⇛ .x) = {!!}
pathV (sym⇛ p) = {!!}
pathV (trans⇛ p p₁) = {!!}
pathV (plus₁⇛ p) = {!!}
pathV (plus₂⇛ p) = {!!}
pathV (times⇛ p p₁) = {!!}
data _⇛_ : {A B : Set} → (x : A) → (y : B) → Set₁ where
------------------------------------------------------------------------------
-- pi types with exactly one level of reciprocals
-- interpretation of B1 types as 1-groupoids
data B0 : Set where
ZERO : B0
ONE : B0
PLUS0 : B0 → B0 → B0
TIMES0 : B0 → B0 → B0
⟦_⟧₀ : B0 → Set
⟦ ZERO ⟧₀ = ⊥
⟦ ONE ⟧₀ = ⊤
⟦ PLUS0 b₁ b₂ ⟧₀ = ⟦ b₁ ⟧₀ ⊎ ⟦ b₂ ⟧₀
⟦ TIMES0 b₁ b₂ ⟧₀ = ⟦ b₁ ⟧₀ × ⟦ b₂ ⟧₀
data B1 : Set where
LIFT0 : B0 → B1
PLUS1 : B1 → B1 → B1
TIMES1 : B1 → B1 → B1
RECIP1 : B0 → B1
open 1Groupoid
⟦_⟧₁ : B1 → 1Groupoid
⟦ LIFT0 b0 ⟧₁ = discrete ⟦ b0 ⟧₀
⟦ PLUS1 b₁ b₂ ⟧₁ = ⟦ b₁ ⟧₁ ⊎G ⟦ b₂ ⟧₁
⟦ TIMES1 b₁ b₂ ⟧₁ = ⟦ b₁ ⟧₁ ×G ⟦ b₂ ⟧₁
⟦ RECIP1 b0 ⟧₁ = {!!} -- allPaths (ı₀ b0)
ı₁ : B1 → Set
ı₁ b = set ⟦ b ⟧₁
test10 = ⟦ LIFT0 ONE ⟧₁
test11 = ⟦ LIFT0 (PLUS0 ONE ONE) ⟧₁
test12 = ⟦ RECIP1 (PLUS0 ONE ONE) ⟧₁
-- interpret isos as functors
data _⟷₁_ : B1 → B1 → Set where
-- +
swap₊ : { b₁ b₂ : B1 } → PLUS1 b₁ b₂ ⟷₁ PLUS1 b₂ b₁
assocl₊ : { b₁ b₂ b₃ : B1 } → PLUS b₁ (PLUS b₂ b₃) ⟷₁ PLUS (PLUS b₁ b₂) b₃
assocr₊ : { b₁ b₂ b₃ : B1 } → PLUS (PLUS b₁ b₂) b₃ ⟷₁ PLUS b₁ (PLUS b₂ b₃)
-- *
unite⋆ : { b : B1 } → TIMES1 (LIFT0 ONE) b ⟷₁ b
uniti⋆ : { b : B1 } → b ⟷₁ TIMES1 (LIFT0 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₃)
-- * distributes over +
dist : { b₁ b₂ b₃ : B } →
TIMES (PLUS b₁ b₂) b₃ ⟷₁ PLUS (TIMES b₁ b₃) (TIMES b₂ b₃)
factor : { b₁ b₂ b₃ : B } →
PLUS (TIMES b₁ b₃) (TIMES b₂ b₃) ⟷₁ TIMES (PLUS b₁ b₂) b₃
-- congruence
id⟷₁ : { b : B } → b ⟷₁ b
sym : { 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 : B0) → LIFT0 ONE ⟷₁ TIMES1 (LIFT0 b) (RECIP1 b)
ε⋆ : (b : B0) → TIMES1 (LIFT0 b) (RECIP1 b) ⟷₁ LIFT0 ONE
record 1-functor (A B : 1Groupoid) : Set where
constructor 1F
private module A = 1Groupoid A
private module B = 1Groupoid B
field
F₀ : set A → set B
F₁ : ∀ {X Y : set A} → A [ X , Y ] → B [ F₀ X , F₀ Y ]
-- identity : ∀ {X} → B._≈_ (F₁ (A.id {X})) B.id
-- F-resp-≈ : ∀ {X Y} {F G : A [ X , Y ]} → A._≈_ F G → B._≈_ (F₁ F) (F₁ G)
open 1-functor public
ipath : (b : B1) → ı₁ b → ı₁ b → Set
ipath b x y = Path {ı₁ b} x y
swap⊎ : {A B : Set} → A ⊎ B → B ⊎ A
swap⊎ (inj₁ a) = inj₂ a
swap⊎ (inj₂ b) = inj₁ b
intro1⋆ : {b : B1} {x y : ı₁ b} → ipath b x y → ipath (TIMES1 (LIFT0 ONE) b) (tt , x) (tt , y)
intro1⋆ (y ⇛ z) = (tt , y) ⇛ (tt , z)
objη⋆ : (b : B0) → ı₁ (LIFT0 ONE) → ı₁ (TIMES1 (LIFT0 b) (RECIP1 b))
objη⋆ b tt = point b , point b
objε⋆ : (b : B0) → ı₁ (TIMES1 (LIFT0 b) (RECIP1 b)) → ı₁ (LIFT0 ONE)
objε⋆ b (x , y) = tt
elim1∣₁ : (b : B1) → ı₁ (TIMES1 (LIFT0 ONE) b) → ı₁ b
elim1∣₁ b (tt , x) = x
intro1∣₁ : (b : B1) → ı₁ b → ı₁ (TIMES1 (LIFT0 ONE) b)
intro1∣₁ b x = (tt , x)
swapF : {b₁ b₂ : B1} →
let G = ⟦ b₁ ⟧₁ ⊎G ⟦ b₂ ⟧₁
G' = ⟦ b₂ ⟧₁ ⊎G ⟦ b₁ ⟧₁ in
{X Y : set G} → G [ X , Y ] → G' [ swap⊎ X , swap⊎ Y ]
swapF {X = inj₁ _} {inj₁ _} f = f
swapF {X = inj₁ _} {inj₂ _} ()
swapF {X = inj₂ _} {inj₁ _} ()
swapF {X = inj₂ _} {inj₂ _} f = f
eta : (b : B0) → List (ipath (LIFT0 ONE)) → List (ipath (TIMES1 (LIFT0 b) (RECIP1 b)))
-- note how the input list is not used at all!
eta b _ = prod (λ a a' → _↝_ (a , tt) (a' , tt)) (elems0 b) (elems0 b)
eps : (b : B0) → ipath (TIMES1 (LIFT0 b) (RECIP1 b)) → ipath (LIFT0 ONE)
eps b0 (a ⇛ b) = tt ⇛ tt
Funite⋆ : {b₁ : B1} → ∀ {X Y : set (discrete (ı₀ ONE) ×G ⟦ b₁ ⟧₁)} → DPath (proj₁ X) (proj₁ Y) × (_↝_ ⟦ b₁ ⟧₁) (proj₂ X) (proj₂ Y) → _↝_ ⟦ b₁ ⟧₁ (proj₂ X) (proj₂ Y)
Funite⋆ {b₁} {tt , _} {tt , _} (reflD , y) = y
Funiti⋆ : {b₁ : B1} → ∀ {X Y : set (discrete (ı₀ ONE) ×G ⟦ b₁ ⟧₁)} → _↝_ ⟦ b₁ ⟧₁ (proj₂ X) (proj₂ Y) → DPath (proj₁ X) (proj₁ Y) × (_↝_ ⟦ b₁ ⟧₁) (proj₂ X) (proj₂ Y)
Funiti⋆ y = reflD , y
mutual
eval : {b₁ b₂ : B1} → (b₁ ⟷₁ b₂) → 1-functor ⟦ b₁ ⟧₁ ⟦ b₂ ⟧₁
eval (swap₊ {b₁} {b₂}) = 1F swap⊎ (λ {X Y} → swapF {b₁} {b₂} {X} {Y})
eval (unite⋆ {b}) = 1F (elim1∣₁ b) (Funite⋆ {b})
eval (uniti⋆ {b}) = 1F (intro1∣₁ b) (Funiti⋆ {b})
-- eval (η⋆ b) = F₁ (objη⋆ b) (eta b )
-- eval (ε⋆ b) = F₁ (objε⋆ b) (map (eps b))
evalB : {b₁ b₂ : B1} → (b₁ ⟷₁ b₂) → 1-functor ⟦ b₂ ⟧₁ ⟦ b₁ ⟧₁
evalB (swap₊ {b₁} {b₂}) = 1F swap⊎ ((λ {X Y} → swapF {b₂} {b₁} {X} {Y}))
evalB (unite⋆ {b}) = 1F (intro1∣₁ b) (Funiti⋆ {b})
evalB (uniti⋆ {b}) = 1F (elim1∣₁ b) (Funite⋆ {b})
-- evalB (η⋆ b) = F₁ (objε⋆ b) (map (eps b))
-- evalB (ε⋆ b) = F₁ (objη⋆ b) (eta b)
eval assocl₊ = ? -- : { b₁ b₂ b₃ : B } → PLUS b₁ (PLUS b₂ b₃) ⟷₁ PLUS (PLUS b₁ b₂) b₃
eval assocr₊ = ? -- : { b₁ b₂ b₃ : B } → PLUS (PLUS b₁ b₂) b₃ ⟷₁ PLUS b₁ (PLUS b₂ b₃)
eval uniti⋆ = ? -- : { b : B } → b ⟷₁ TIMES ONE b
eval swap⋆ = ? -- : { b₁ b₂ : B } → TIMES b₁ b₂ ⟷₁ TIMES b₂ b₁
eval assocl⋆ = ? -- : { b₁ b₂ b₃ : B } → TIMES b₁ (TIMES b₂ b₃) ⟷₁ TIMES (TIMES b₁ b₂) b₃
eval assocr⋆ = ? -- : { b₁ b₂ b₃ : B } → TIMES (TIMES b₁ b₂) b₃ ⟷₁ TIMES b₁ (TIMES b₂ b₃)
eval dist = ? -- : { b₁ b₂ b₃ : B } → TIMES (PLUS b₁ b₂) b₃ ⟷₁ PLUS (TIMES b₁ b₃) (TIMES b₂ b₃)
eval factor = ? -- : { b₁ b₂ b₃ : B } → PLUS (TIMES b₁ b₃) (TIMES b₂ b₃) ⟷₁ TIMES (PLUS b₁ b₂) b₃
eval id⟷₁ = ? -- : { b : B } → b ⟷₁ b
eval (sym c) = ? -- : { b₁ b₂ : B } → (b₁ ⟷₁ b₂) → (b₂ ⟷₁ b₁)
eval (c₁ ∘ c₂) = ? -- : { b₁ b₂ b₃ : B } → (b₁ ⟷₁ b₂) → (b₂ ⟷₁ b₃) → (b₁ ⟷₁ b₃)
eval (c₁ ⊕ c₂) = ? -- : { b₁ b₂ b₃ b₄ : B } → (b₁ ⟷₁ b₃) → (b₂ ⟷₁ b₄) → (PLUS b₁ b₂ ⟷₁ PLUS b₃ b₄)
eval (c₁ ⊗ c₂) = ? -- : { b₁ b₂ b₃ b₄ : B } → (b₁ ⟷₁ b₃) → (b₂ ⟷₁ b₄) → (TIMES b₁ b₂ ⟷₁ TIMES b₃ b₄)
-- lid⇛ : {A B : Set} {x : A} {y : B} → (trans⇛ (id⇛ x) (x ⇛ y)) ⇛ (x ⇛ y)
-- lid⇛ {A} {B} {x} {y} =
-- pathInd ?
ap : {A B : Set} → (f : A → B) → {a a' : A} → Path a a' → Path (f a) (f a')
ap f (a ⇛ a') = (f a) ⇛ (f a')
_∙⇛_ : {A : Set} {a b c : A} → Path b c → Path a b → Path a c
(b ⇛ c) ∙⇛ (a ⇛ .b) = a ⇛ c
_⇚ : {A : Set} {a b : A} → Path a b → Path b a
(x ⇛ y) ⇚ = y ⇛ x
lid⇛ : {A : Set} {x y : A} (α : Path x y) → (id⇛ y ∙⇛ α) ≣⇛ α
lid⇛ (x ⇛ y) = refl⇛
rid⇛ : {A : Set} {x y : A} (α : Path x y) → (α ∙⇛ id⇛ x) ≣⇛ α
rid⇛ (x ⇛ y) = refl⇛
assoc⇛ : {A : Set} {w x y z : A} (α : Path y z) (β : Path x y) (δ : Path w x) → ((α ∙⇛ β) ∙⇛ δ) ≣⇛ (α ∙⇛ (β ∙⇛ δ))
assoc⇛ (y ⇛ z) (x ⇛ .y) (w ⇛ .x) = refl⇛
l⇚ : {A : Set} {x y : A} (α : Path x y) → ((α ⇚) ∙⇛ α) ≣⇛ id⇛ x
l⇚ (x ⇛ y) = refl⇛
r⇚ : {A : Set} {x y : A} (α : Path x y) → (α ∙⇛ (α ⇚)) ≣⇛ id⇛ y
r⇚ (x ⇛ y) = refl⇛
sym⇛ : {A : Set} {x y : A} {α β : Path x y} → α ≣⇛ β → β ≣⇛ α
sym⇛ refl⇛ = refl⇛
trans⇛ : {A : Set} {x y : A} {α β δ : Path x y} → α ≣⇛ β → β ≣⇛ δ → α ≣⇛ δ
trans⇛ refl⇛ refl⇛ = refl⇛
equiv≣⇛ : {A : Set} {x y : A} → IsEquivalence {_} {_} {Path x y} (_≣⇛_)
equiv≣⇛ = record { refl = refl⇛; sym = sym⇛; trans = trans⇛ }
resp≣⇛ : {A : Set} {x y z : A} {f h : Path y z} {g i : Path x y} →
f ≣⇛ h → g ≣⇛ i → (f ∙⇛ g) ≣⇛ (h ∙⇛ i)
resp≣⇛ refl⇛ refl⇛ = refl⇛
record 0-type : Set₁ where
constructor G₀
field
∣_∣₀ : Set
open 0-type public
plus : 0-type → 0-type → 0-type
plus t₁ t₂ = G₀ (∣ t₁ ∣₀ ⊎ ∣ t₂ ∣₀)
times : 0-type → 0-type → 0-type
times t₁ t₂ = G₀ (∣ t₁ ∣₀ × ∣ t₂ ∣₀)
⟦_⟧₀ : B0 → 0-type
⟦ ONE ⟧₀ = G₀ ⊤
⟦ PLUS0 b₁ b₂ ⟧₀ = plus ⟦ b₁ ⟧₀ ⟦ b₂ ⟧₀
⟦ TIMES0 b₁ b₂ ⟧₀ = times ⟦ b₁ ⟧₀ ⟦ b₂ ⟧₀
ı₀ : B0 → Set
ı₀ b = ∣ ⟦ b ⟧₀ ∣₀
point : (b : B0) → ı₀ b
point ONE = tt
point (PLUS0 b _) = inj₁ (point b)
point (TIMES0 b₀ b₁) = point b₀ , point b₁
allPaths : Set → 1Groupoid
allPaths a = record
{ set = a
; _↝_ = Path
; _≈_ = _≣⇛_
; id = λ {x} → id⇛ x
; _∘_ = _∙⇛_
; _⁻¹ = _⇚
; lneutr = lid⇛
; rneutr = rid⇛
; assoc = assoc⇛
; linv = l⇚
; rinv = r⇚
; equiv = equiv≣⇛
; ∘-resp-≈ = resp≣⇛}
--}
| 38.854671
| 168
| 0.463309
|
ade3ad434d519e000814290ccd08b29df607e7b4
| 256
|
agda
|
Agda
|
Cubical/Codata/Stream/Base.agda
|
kiana-S/univalent-foundations
|
8bdb0766260489f9c89a14f4c0f2ad26e5190dec
|
[
"MIT"
] | null | null | null |
Cubical/Codata/Stream/Base.agda
|
kiana-S/univalent-foundations
|
8bdb0766260489f9c89a14f4c0f2ad26e5190dec
|
[
"MIT"
] | 1
|
2022-01-27T02:07:48.000Z
|
2022-01-27T02:07:48.000Z
|
Cubical/Codata/Stream/Base.agda
|
kiana-S/univalent-foundations
|
8bdb0766260489f9c89a14f4c0f2ad26e5190dec
|
[
"MIT"
] | 1
|
2021-11-22T02:02:01.000Z
|
2021-11-22T02:02:01.000Z
|
{-# OPTIONS --cubical --no-import-sorts --safe --guardedness #-}
module Cubical.Codata.Stream.Base where
open import Cubical.Core.Everything
record Stream (A : Type₀) : Type₀ where
coinductive
constructor _,_
field
head : A
tail : Stream A
| 21.333333
| 64
| 0.703125
|
2ea437b386146d14964e82ee16325f72116b996f
| 6,267
|
agda
|
Agda
|
agda/Util.agda
|
halfaya/MusicTools
|
04896c61b603d46011b7d718fcb47dd756e66021
|
[
"MIT"
] | 28
|
2017-04-21T09:08:52.000Z
|
2022-03-04T18:04:07.000Z
|
agda/Util.agda
|
halfaya/MusicTools
|
04896c61b603d46011b7d718fcb47dd756e66021
|
[
"MIT"
] | 1
|
2020-11-13T01:26:20.000Z
|
2020-11-17T00:58:55.000Z
|
agda/Util.agda
|
halfaya/MusicTools
|
04896c61b603d46011b7d718fcb47dd756e66021
|
[
"MIT"
] | 3
|
2019-01-12T17:02:36.000Z
|
2020-11-10T04:04:40.000Z
|
{-# OPTIONS --erased-cubical --safe #-}
module Util 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)
--open import Cubical.Foundations.Function using (_∘_)
open import Cubical.Foundations.Univalence using (ua)
open import Cubical.Foundations.Isomorphism using (iso; Iso; isoToPath; section; retract; isoToEquiv)
open import Agda.Primitive using (Level)
open import Data.Fin using (Fin; #_; toℕ; inject; fromℕ; fromℕ<; inject₁) renaming (zero to fz; suc to fsuc)
open import Data.Bool using (Bool; true; false; if_then_else_)
open import Data.Integer using (ℤ; +_; -[1+_]; _-_; ∣_∣; -_)
open import Data.List using (List; concat; replicate; []; _∷_; _∷ʳ_; map; _++_; reverse)
open import Data.Maybe using (Maybe; just; nothing)
open import Data.Nat using (ℕ; zero; suc; _+_; _*_; _<ᵇ_; _≤ᵇ_; _≡ᵇ_; _<?_; _≟_; _∸_; _<_; s≤s; z≤n; _⊓_)
open import Data.Nat.DivMod using (_mod_)
open import Data.Nat.Properties using (≤-step; ≤-trans; ≤-refl)
open import Data.Product using (_×_; _,_)
open import Data.Vec using (Vec; _∷_; []; zip; last) renaming (concat to cat; replicate to rep; map to vmap; _∷ʳ_ to _v∷ʳ_)
open import Relation.Nullary using (yes; no; ¬_)
open import Relation.Nullary.Decidable using (False)
open import Relation.Unary using (Pred; Decidable)
infixr 9 _∘_
_∘_ : {ℓ : Level}{A : Type ℓ}{B : A → Type ℓ}{C : (a : A) → B a → Type ℓ}
(g : {a : A} → (b : B a) → C a b) → (f : (a : A) → B a) → (a : A) → C a (f a)
g ∘ f = λ x → g (f x)
{-# INLINE _∘_ #-}
repeat : {ℓ : Level} {A : Type ℓ} → (n : ℕ) → List A → List A
repeat n = concat ∘ replicate n
repeatV : {ℓ : Level} {A : Type ℓ} {k : ℕ} → (n : ℕ) → Vec A k → Vec A (n * k)
repeatV n = cat ∘ rep {n = n}
-- return index of first element that satisfies predicate or last element if none do
findIndex : {a ℓ : Level} {A : Type a} {n : ℕ} {P : Pred A ℓ} → Decidable P → Vec A (suc n) → Fin (suc n)
findIndex _ (x ∷ []) = # 0
findIndex P (x ∷ y ∷ ys) with P x
... | yes _ = # 0
... | no _ = fsuc (findIndex P (y ∷ ys))
-- Returns a list of all adjacent pairs in the original list.
pairs : {ℓ : Level} {A : Type ℓ} → List A → List (A × A)
pairs [] = []
pairs (x ∷ []) = []
pairs (x ∷ y ∷ xs) = (x , y) ∷ pairs (y ∷ xs)
-- Returns a list of all pairs in the original list.
allPairs : {ℓ : Level} {A : Type ℓ} → List A → List (A × A)
allPairs [] = []
allPairs (x ∷ xs) = map (x ,_) xs ++ allPairs xs
-- Returns a singleton list of the pair of the first and last element if the list has at least 2 elements,
-- or the empty list otherwise.
firstLast : {ℓ : Level} {A : Type ℓ} → List A → List (A × A)
firstLast [] = []
firstLast (x ∷ xs) with reverse xs
... | [] = []
... | y ∷ ys = (x , y) ∷ []
-- Returns a list of all adjacent pairs in the original list, prepended by the pair of the first and last elements.
◯pairs : {ℓ : Level} {A : Type ℓ} → List A → List (A × A)
◯pairs xs = firstLast xs ++ pairs xs
-- Returns a list of the first element paired with all later elements, in order.
firstPairs : {ℓ : Level} {A : Type ℓ} → List A → List (A × A)
firstPairs [] = []
firstPairs (x ∷ xs) = map (x ,_) xs
-- Basic Boolean Filter and Elem
filter : {ℓ : Level} {A : Type ℓ} → (A → Bool) → List A → List A
filter f [] = []
filter f (x ∷ xs) = if f x then x ∷ filter f xs else filter f xs
infix 4 _∈_via_
_∈_via_ : {ℓ : Level} {A : Type ℓ} → A → List A → (A → A → Bool) → Bool
x ∈ [] via f = false
x ∈ y ∷ ys via f = if f x y then true else x ∈ ys via f
concatMaybe : {ℓ : Level} {A : Type ℓ} → List (Maybe A) → List A
concatMaybe [] = []
concatMaybe (nothing ∷ xs) = concatMaybe xs
concatMaybe (just x ∷ xs) = x ∷ concatMaybe xs
listMin : {ℓ : Level} {A : Type ℓ} → (A → ℕ) → List A → Maybe A
listMin f [] = nothing
listMin f (x ∷ xs) with listMin f xs
... | nothing = just x
... | just y = if f x <ᵇ f y then just x else just y
fins : (k : ℕ) → Vec (Fin k) k
fins zero = []
fins (suc k) = fz ∷ vmap fsuc (fins k)
fins' : (n : ℕ) → (k : Fin n) → Vec (Fin n) (toℕ k)
fins' n k = vmap inject (fins (toℕ k))
finSuc : {n : ℕ} → Fin (suc n) → Fin (suc n)
finSuc {n} m with suc (toℕ m) <? suc n
... | yes x = fromℕ< x
... | no _ = fz
_+N_ : {n : ℕ} → Fin (suc n) → ℕ → Fin (suc n)
a +N zero = a
a +N suc b = finSuc a +N b
∣-∣helper : (n : ℕ) → ℕ → ℕ → ℕ
∣-∣helper n a b with a ≤ᵇ b
... | true = (b ∸ a) ⊓ ((n + a) ∸ b)
... | false = (a ∸ b) ⊓ ((n + b) ∸ a)
⟨_⟩∣_-_∣ : (n : ℕ) → Fin n → Fin n → ℕ
⟨_⟩∣_-_∣ n a b = ∣-∣helper n (toℕ a) (toℕ b)
n∸k<n : (n k : ℕ) → (suc n) ∸ (suc k) < suc n
n∸k<n zero zero = s≤s z≤n
n∸k<n (suc n) zero = s≤s (n∸k<n n zero)
n∸k<n zero (suc k) = s≤s z≤n
n∸k<n (suc n) (suc k) = ≤-trans (n∸k<n n k) (≤-step ≤-refl)
opposite' : ∀ {n} → Fin n → Fin n
opposite' {suc n} fz = fz
opposite' {suc n} (fsuc k) = fromℕ< (n∸k<n n (toℕ k))
-- opposite "i" = "n - i" (i.e. the additive inverse).
opposite : ∀ {n} → Fin n → Fin n
opposite {suc n} fz = fz
opposite {suc n} (fsuc fz) = fromℕ n
opposite {suc n} (fsuc (fsuc i)) = inject₁ (opposite (fsuc i))
_modℕ_ : (dividend : ℤ) (divisor : ℕ) {≢0 : False (divisor ≟ 0)} → Fin divisor
((+ n) modℕ d) {d≠0} = (n mod d) {d≠0}
(-[1+ n ] modℕ d) {d≠0} = opposite ((suc n mod d) {d≠0})
zipWithIndex : {ℓ : Level} {A : Type ℓ} {k : ℕ} → Vec A k → Vec (Fin k × A) k
zipWithIndex {k = k} = zip (fins k)
iter : {ℓ : Level} {A : Type ℓ} → (A → A) → ℕ → A → List A
iter f zero x = x ∷ []
iter f (suc n) x = x ∷ iter f n (f x)
rotateLeft : {ℓ : Level} {A : Type ℓ} → List A → List A
rotateLeft [] = []
rotateLeft (x ∷ xs) = xs ∷ʳ x
rotateRight : {ℓ : Level} {A : Type ℓ} → List A → List A
rotateRight = reverse ∘ rotateLeft ∘ reverse
vrotateLeft : {ℓ : Level} {A : Type ℓ} {k : ℕ} → Vec A k → Vec A k
vrotateLeft {k = zero} [] = []
vrotateLeft {k = suc k} (x ∷ xs) = xs v∷ʳ x
vrotateRight : {ℓ : Level} {A : Type ℓ} {k : ℕ} → Vec A k → Vec A k
vrotateRight {k = zero} [] = []
vrotateRight {k = suc k} xs@(_ ∷ ys) = last xs ∷ ys
| 38.685185
| 135
| 0.559598
|
22a0e92ae2a0de22e8cc2d134d9ed93cf56c4127
| 1,759
|
agda
|
Agda
|
agda-stdlib/src/Reflection/Argument/Information.agda
|
DreamLinuxer/popl21-artifact
|
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
|
[
"MIT"
] | 5
|
2020-10-07T12:07:53.000Z
|
2020-10-10T21:41:32.000Z
|
agda-stdlib/src/Reflection/Argument/Information.agda
|
DreamLinuxer/popl21-artifact
|
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
|
[
"MIT"
] | null | null | null |
agda-stdlib/src/Reflection/Argument/Information.agda
|
DreamLinuxer/popl21-artifact
|
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
|
[
"MIT"
] | 1
|
2021-11-04T06:54:45.000Z
|
2021-11-04T06:54:45.000Z
|
------------------------------------------------------------------------
-- The Agda standard library
--
-- Argument information used in the reflection machinery
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
module Reflection.Argument.Information where
open import Data.Product
open import Relation.Nullary
import Relation.Nullary.Decidable as Dec
open import Relation.Nullary.Product using (_×-dec_)
open import Relation.Binary
open import Relation.Binary.PropositionalEquality
open import Reflection.Argument.Relevance as Relevance using (Relevance)
open import Reflection.Argument.Visibility as Visibility using (Visibility)
------------------------------------------------------------------------
-- Re-exporting the builtins publically
open import Agda.Builtin.Reflection public using (ArgInfo)
open ArgInfo public
------------------------------------------------------------------------
-- Operations
visibility : ArgInfo → Visibility
visibility (arg-info v _) = v
relevance : ArgInfo → Relevance
relevance (arg-info _ r) = r
------------------------------------------------------------------------
-- Decidable equality
arg-info-injective₁ : ∀ {v r v′ r′} → arg-info v r ≡ arg-info v′ r′ → v ≡ v′
arg-info-injective₁ refl = refl
arg-info-injective₂ : ∀ {v r v′ r′} → arg-info v r ≡ arg-info v′ r′ → r ≡ r′
arg-info-injective₂ refl = refl
arg-info-injective : ∀ {v r v′ r′} → arg-info v r ≡ arg-info v′ r′ → v ≡ v′ × r ≡ r′
arg-info-injective = < arg-info-injective₁ , arg-info-injective₂ >
_≟_ : DecidableEquality ArgInfo
arg-info v r ≟ arg-info v′ r′ =
Dec.map′ (uncurry (cong₂ arg-info))
arg-info-injective
(v Visibility.≟ v′ ×-dec r Relevance.≟ r′)
| 33.188679
| 84
| 0.567368
|
2e072aea4c2a6f62fab8474f63991b807dc16bec
| 16,835
|
agda
|
Agda
|
Cubical/HITs/S1/Base.agda
|
knrafto/cubical
|
f6771617374bfe65a7043d00731fed5a673aa729
|
[
"MIT"
] | null | null | null |
Cubical/HITs/S1/Base.agda
|
knrafto/cubical
|
f6771617374bfe65a7043d00731fed5a673aa729
|
[
"MIT"
] | null | null | null |
Cubical/HITs/S1/Base.agda
|
knrafto/cubical
|
f6771617374bfe65a7043d00731fed5a673aa729
|
[
"MIT"
] | null | null | null |
{-
Definition of the circle as a HIT with a proof that Ω(S¹) ≡ ℤ
-}
{-# OPTIONS --cubical --no-import-sorts --safe #-}
module Cubical.HITs.S1.Base where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.GroupoidLaws
open import Cubical.Foundations.HLevels
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.Function
open import Cubical.Foundations.Isomorphism
open import Cubical.Foundations.Transport
open import Cubical.Foundations.Univalence
open import Cubical.Data.Nat
hiding (_+_ ; _*_ ; +-assoc ; +-comm)
open import Cubical.Data.Int
data S¹ : Type₀ where
base : S¹
loop : base ≡ base
-- Check that transp is the identity function for S¹
module _ where
transpS¹ : ∀ (φ : I) (u0 : S¹) → transp (λ _ → S¹) φ u0 ≡ u0
transpS¹ φ u0 = refl
compS1 : ∀ (φ : I) (u : ∀ i → Partial φ S¹) (u0 : S¹ [ φ ↦ u i0 ]) →
comp (λ _ → S¹) (\ i → u i) (outS u0) ≡ hcomp u (outS u0)
compS1 φ u u0 = refl
-- ΩS¹ ≡ Int
helix : S¹ → Type₀
helix base = Int
helix (loop i) = sucPathInt i
ΩS¹ : Type₀
ΩS¹ = base ≡ base
encode : ∀ x → base ≡ x → helix x
encode x p = subst helix p (pos zero)
winding : ΩS¹ → Int
winding = encode base
intLoop : Int → ΩS¹
intLoop (pos zero) = refl
intLoop (pos (suc n)) = intLoop (pos n) ∙ loop
intLoop (negsuc zero) = sym loop
intLoop (negsuc (suc n)) = intLoop (negsuc n) ∙ sym loop
decodeSquare : (n : Int) → PathP (λ i → base ≡ loop i) (intLoop (predInt n)) (intLoop n)
decodeSquare (pos zero) i j = loop (i ∨ ~ j)
decodeSquare (pos (suc n)) i j = hfill (λ k → λ { (j = i0) → base
; (j = i1) → loop k } )
(inS (intLoop (pos n) j)) i
decodeSquare (negsuc n) i j = hfill (λ k → λ { (j = i0) → base
; (j = i1) → loop (~ k) })
(inS (intLoop (negsuc n) j)) (~ i)
decode : (x : S¹) → helix x → base ≡ x
decode base = intLoop
decode (loop i) y j =
let n : Int
n = unglue (i ∨ ~ i) y
in hcomp (λ k → λ { (i = i0) → intLoop (predSuc y k) j
; (i = i1) → intLoop y j
; (j = i0) → base
; (j = i1) → loop i })
(decodeSquare n i j)
decodeEncode : (x : S¹) (p : base ≡ x) → decode x (encode x p) ≡ p
decodeEncode x p = J (λ y q → decode y (encode y q) ≡ q) (λ _ → refl) p
isSetΩS¹ : isSet ΩS¹
isSetΩS¹ p q r s j i =
hcomp (λ k → λ { (i = i0) → decodeEncode base p k
; (i = i1) → decodeEncode base q k
; (j = i0) → decodeEncode base (r i) k
; (j = i1) → decodeEncode base (s i) k })
(decode base (isSetInt (winding p) (winding q) (cong winding r) (cong winding s) j i))
-- This proof does not rely on rewriting hcomp with empty systems in
-- Int as ghcomp has been implemented!
windingIntLoop : (n : Int) → winding (intLoop n) ≡ n
windingIntLoop (pos zero) = refl
windingIntLoop (pos (suc n)) = cong sucInt (windingIntLoop (pos n))
windingIntLoop (negsuc zero) = refl
windingIntLoop (negsuc (suc n)) = cong predInt (windingIntLoop (negsuc n))
ΩS¹IsoInt : Iso ΩS¹ Int
Iso.fun ΩS¹IsoInt = winding
Iso.inv ΩS¹IsoInt = intLoop
Iso.rightInv ΩS¹IsoInt = windingIntLoop
Iso.leftInv ΩS¹IsoInt = decodeEncode base
ΩS¹≡Int : ΩS¹ ≡ Int
ΩS¹≡Int = isoToPath ΩS¹IsoInt
-- intLoop and winding are group homomorphisms
private
intLoop-sucInt : (z : Int) → intLoop (sucInt z) ≡ intLoop z ∙ loop
intLoop-sucInt (pos n) = refl
intLoop-sucInt (negsuc zero) = sym (lCancel loop)
intLoop-sucInt (negsuc (suc n)) =
rUnit (intLoop (negsuc n))
∙ (λ i → intLoop (negsuc n) ∙ lCancel loop (~ i))
∙ assoc (intLoop (negsuc n)) (sym loop) loop
intLoop-predInt : (z : Int) → intLoop (predInt z) ≡ intLoop z ∙ sym loop
intLoop-predInt (pos zero) = lUnit (sym loop)
intLoop-predInt (pos (suc n)) =
rUnit (intLoop (pos n))
∙ (λ i → intLoop (pos n) ∙ (rCancel loop (~ i)))
∙ assoc (intLoop (pos n)) loop (sym loop)
intLoop-predInt (negsuc n) = refl
intLoop-hom : (a b : Int) → (intLoop a) ∙ (intLoop b) ≡ intLoop (a + b)
intLoop-hom a (pos zero) = sym (rUnit (intLoop a))
intLoop-hom a (pos (suc n)) =
assoc (intLoop a) (intLoop (pos n)) loop
∙ (λ i → (intLoop-hom a (pos n) i) ∙ loop)
∙ sym (intLoop-sucInt (a + pos n))
intLoop-hom a (negsuc zero) = sym (intLoop-predInt a)
intLoop-hom a (negsuc (suc n)) =
assoc (intLoop a) (intLoop (negsuc n)) (sym loop)
∙ (λ i → (intLoop-hom a (negsuc n) i) ∙ (sym loop))
∙ sym (intLoop-predInt (a + negsuc n))
winding-hom : (a b : ΩS¹) → winding (a ∙ b) ≡ (winding a) + (winding b)
winding-hom a b i =
hcomp (λ t → λ { (i = i0) → winding (decodeEncode base a t ∙ decodeEncode base b t)
; (i = i1) → windingIntLoop (winding a + winding b) t })
(winding (intLoop-hom (winding a) (winding b) i))
-- Commutativity
comm-ΩS¹ : (p q : ΩS¹) → p ∙ q ≡ q ∙ p
comm-ΩS¹ p q = sym (cong₂ (_∙_) (decodeEncode base p) (decodeEncode base q))
∙ intLoop-hom (winding p) (winding q)
∙ cong intLoop (+-comm (winding p) (winding q))
∙ sym (intLoop-hom (winding q) (winding p))
∙ (cong₂ (_∙_) (decodeEncode base q) (decodeEncode base p))
-- Based homotopy group
basedΩS¹ : (x : S¹) → Type₀
basedΩS¹ x = x ≡ x
-- Proof that the homotopy group is actually independent on the basepoint
-- first, give a quasi-inverse to the basechange basedΩS¹→ΩS¹ for any loop i
-- (which does *not* match at endpoints)
private
ΩS¹→basedΩS¹-filler : I → I → ΩS¹ → I → S¹
ΩS¹→basedΩS¹-filler l i x j =
hfill (λ t → λ { (j = i0) → loop (i ∧ t)
; (j = i1) → loop (i ∧ t) })
(inS (x j)) l
basedΩS¹→ΩS¹-filler : (_ i : I) → basedΩS¹ (loop i) → I → S¹
basedΩS¹→ΩS¹-filler l i x j =
hfill (λ t → λ { (j = i0) → loop (i ∧ (~ t))
; (j = i1) → loop (i ∧ (~ t)) })
(inS (x j)) l
ΩS¹→basedΩS¹ : (i : I) → ΩS¹ → basedΩS¹ (loop i)
ΩS¹→basedΩS¹ i x j = ΩS¹→basedΩS¹-filler i1 i x j
basedΩS¹→ΩS¹ : (i : I) → basedΩS¹ (loop i) → ΩS¹
basedΩS¹→ΩS¹ i x j = basedΩS¹→ΩS¹-filler i1 i x j
basedΩS¹→ΩS¹→basedΩS¹ : (i : I) → (x : basedΩS¹ (loop i))
→ ΩS¹→basedΩS¹ i (basedΩS¹→ΩS¹ i x) ≡ x
basedΩS¹→ΩS¹→basedΩS¹ i x j k =
hcomp (λ t → λ { (j = i1) → basedΩS¹→ΩS¹-filler (~ t) i x k
; (j = i0) → ΩS¹→basedΩS¹ i (basedΩS¹→ΩS¹ i x) k
; (k = i0) → loop (i ∧ (t ∨ (~ j)))
; (k = i1) → loop (i ∧ (t ∨ (~ j))) })
(ΩS¹→basedΩS¹-filler (~ j) i (basedΩS¹→ΩS¹ i x) k)
ΩS¹→basedΩS¹→ΩS¹ : (i : I) → (x : ΩS¹)
→ basedΩS¹→ΩS¹ i (ΩS¹→basedΩS¹ i x) ≡ x
ΩS¹→basedΩS¹→ΩS¹ i x j k =
hcomp (λ t → λ { (j = i1) → ΩS¹→basedΩS¹-filler (~ t) i x k
; (j = i0) → basedΩS¹→ΩS¹ i (ΩS¹→basedΩS¹ i x) k
; (k = i0) → loop (i ∧ ((~ t) ∧ j))
; (k = i1) → loop (i ∧ ((~ t) ∧ j)) })
(basedΩS¹→ΩS¹-filler (~ j) i (ΩS¹→basedΩS¹ i x) k)
-- from the existence of our quasi-inverse, we deduce that the basechange is an equivalence
-- for all loop i
basedΩS¹→ΩS¹-isequiv : (i : I) → isEquiv (basedΩS¹→ΩS¹ i)
basedΩS¹→ΩS¹-isequiv i = isoToIsEquiv (iso (basedΩS¹→ΩS¹ i) (ΩS¹→basedΩS¹ i)
(ΩS¹→basedΩS¹→ΩS¹ i) (basedΩS¹→ΩS¹→basedΩS¹ i))
-- now extend the basechange so that both ends match
-- (and therefore we get a basechange for any x : S¹)
loop-conjugation : basedΩS¹→ΩS¹ i1 ≡ λ x → x
loop-conjugation i x =
let p = (doubleCompPath-elim loop x (sym loop))
∙ (λ i → (lUnit loop i ∙ x) ∙ sym loop)
in
((sym (decodeEncode base (basedΩS¹→ΩS¹ i1 x)))
∙ (λ t → intLoop (winding (p t)))
∙ (λ t → intLoop (winding-hom (intLoop (pos (suc zero)) ∙ x)
(intLoop (negsuc zero)) t))
∙ (λ t → intLoop ((winding-hom (intLoop (pos (suc zero))) x t)
+ (windingIntLoop (negsuc zero) t)))
∙ (λ t → intLoop (((windingIntLoop (pos (suc zero)) t) + (winding x)) + (negsuc zero)))
∙ (λ t → intLoop ((+-comm (pos (suc zero)) (winding x) t) + (negsuc zero)))
∙ (λ t → intLoop (+-assoc (winding x) (pos (suc zero)) (negsuc zero) (~ t)))
∙ (decodeEncode base x)) i
refl-conjugation : basedΩS¹→ΩS¹ i0 ≡ λ x → x
refl-conjugation i x j =
hfill (λ t → λ { (j = i0) → base
; (j = i1) → base })
(inS (x j)) (~ i)
basechange : (x : S¹) → basedΩS¹ x → ΩS¹
basechange base y = y
basechange (loop i) y =
hcomp (λ t → λ { (i = i0) → refl-conjugation t y
; (i = i1) → loop-conjugation t y })
(basedΩS¹→ΩS¹ i y)
-- for any loop i, the old basechange is equal to the new one
basedΩS¹→ΩS¹≡basechange : (i : I) → basedΩS¹→ΩS¹ i ≡ basechange (loop i)
basedΩS¹→ΩS¹≡basechange i j y =
hfill (λ t → λ { (i = i0) → refl-conjugation t y
; (i = i1) → loop-conjugation t y })
(inS (basedΩS¹→ΩS¹ i y)) j
-- so for any loop i, the extended basechange is an equivalence
basechange-isequiv-aux : (i : I) → isEquiv (basechange (loop i))
basechange-isequiv-aux i =
transport (λ j → isEquiv (basedΩS¹→ΩS¹≡basechange i j)) (basedΩS¹→ΩS¹-isequiv i)
-- as being an equivalence is contractible, basechange is an equivalence for all x : S¹
basechange-isequiv : (x : S¹) → isEquiv (basechange x)
basechange-isequiv base = basechange-isequiv-aux i0
basechange-isequiv (loop i) =
hcomp (λ t → λ { (i = i0) → basechange-isequiv-aux i0
; (i = i1) → isPropIsEquiv (basechange base) (basechange-isequiv-aux i1)
(basechange-isequiv-aux i0) t })
(basechange-isequiv-aux i)
basedΩS¹≡ΩS¹' : (x : S¹) → basedΩS¹ x ≡ ΩS¹
basedΩS¹≡ΩS¹' x = ua (basechange x , basechange-isequiv x)
basedΩS¹≡Int' : (x : S¹) → basedΩS¹ x ≡ Int
basedΩS¹≡Int' x = (basedΩS¹≡ΩS¹' x) ∙ ΩS¹≡Int
---- Alternative proof of the same thing -----
toPropElim : ∀ {ℓ} {B : S¹ → Type ℓ}
→ ((s : S¹) → isProp (B s))
→ B base
→ (s : S¹) → B s
toPropElim isprop b base = b
toPropElim isprop b (loop i) =
isOfHLevel→isOfHLevelDep 1 isprop b b loop i
isSetΩx : (x : S¹) → isSet (x ≡ x)
isSetΩx = toPropElim (λ _ → isPropIsSet) isSetΩS¹
basechange2 : (x : S¹) → ΩS¹ → (x ≡ x)
basechange2 base p = p
basechange2 (loop i) p =
hcomp (λ k → λ { (i = i0) → lUnit (rUnit p (~ k)) (~ k)
; (i = i1) → (cong ((sym loop) ∙_) (comm-ΩS¹ p loop)
∙ assoc (sym loop) loop p
∙ cong (_∙ p) (lCancel loop)
∙ sym (lUnit _)) k })
((λ j → loop (~ j ∧ i)) ∙ p ∙ λ j → loop (j ∧ i))
basechange2⁻ : (x : S¹) → (x ≡ x) → ΩS¹
basechange2⁻ base p = p
basechange2⁻ (loop i) p =
hcomp (λ k → λ { (i = i0) → lUnit (rUnit p (~ k)) (~ k)
; (i = i1) → (cong (loop ∙_) (comm-ΩS¹ p (sym loop))
∙ assoc loop (sym loop) p
∙ cong (_∙ p) (rCancel loop)
∙ sym (lUnit _)) k })
((λ j → loop (i ∧ j)) ∙ p ∙ λ j → loop (i ∧ (~ j)))
basechange2-sect : (x : S¹) → section (basechange2 x) (basechange2⁻ x)
basechange2-sect =
toPropElim (λ _ → isOfHLevelΠ 1 λ _ → isSetΩx _ _ _ )
λ _ → refl
basechange2-retr : (x : S¹) → retract (basechange2 x) (basechange2⁻ x)
basechange2-retr =
toPropElim (λ s → isOfHLevelΠ 1 λ x → isSetΩx _ _ _)
λ _ → refl
basedΩS¹≡ΩS¹ : (x : S¹) → basedΩS¹ x ≡ ΩS¹
basedΩS¹≡ΩS¹ x = isoToPath (iso (basechange2⁻ x)
(basechange2 x)
(basechange2-retr x)
(basechange2-sect x))
basedΩS¹≡Int : (x : S¹) → basedΩS¹ x ≡ Int
basedΩS¹≡Int x = (basedΩS¹≡ΩS¹ x) ∙ ΩS¹≡Int
-- baschange2⁻ is a morphism
basechange2⁻-morph : (x : S¹) (p q : x ≡ x) →
basechange2⁻ x (p ∙ q) ≡ basechange2⁻ x p ∙ basechange2⁻ x q
basechange2⁻-morph =
toPropElim {B = λ x → (p q : x ≡ x) → basechange2⁻ x (p ∙ q) ≡ basechange2⁻ x p ∙ basechange2⁻ x q}
(λ _ → isPropΠ2 λ _ _ → isSetΩS¹ _ _)
λ _ _ → refl
-- Some tests
module _ where
private
test-winding-pos : winding (intLoop (pos 5)) ≡ pos 5
test-winding-pos = refl
test-winding-neg : winding (intLoop (negsuc 5)) ≡ negsuc 5
test-winding-neg = refl
-- the inverse when S¹ is seen as a group
inv : S¹ → S¹
inv base = base
inv (loop i) = loop (~ i)
invInvolutive : section inv inv
invInvolutive base = refl
invInvolutive (loop i) = refl
invS¹Equiv : S¹ ≃ S¹
invS¹Equiv = isoToEquiv (iso inv inv invInvolutive invInvolutive)
invS¹Path : S¹ ≡ S¹
invS¹Path = ua invS¹Equiv
-- rot, used in the Hopf fibration
rotLoop : (a : S¹) → a ≡ a
rotLoop base = loop
rotLoop (loop i) j =
hcomp (λ k → λ { (i = i0) → loop (j ∨ ~ k)
; (i = i1) → loop (j ∧ k)
; (j = i0) → loop (i ∨ ~ k)
; (j = i1) → loop (i ∧ k)}) base
rot : S¹ → S¹ → S¹
rot base x = x
rot (loop i) x = rotLoop x i
_*_ : S¹ → S¹ → S¹
a * b = rot a b
infixl 30 _*_
-- rot i j = filler-rot i j i1
filler-rot : I → I → I → S¹
filler-rot i j = hfill (λ k → λ { (i = i0) → loop (j ∨ ~ k)
; (i = i1) → loop (j ∧ k)
; (j = i0) → loop (i ∨ ~ k)
; (j = i1) → loop (i ∧ k) }) (inS base)
isPropFamS¹ : ∀ {ℓ} (P : S¹ → Type ℓ) (pP : (x : S¹) → isProp (P x)) (b0 : P base) →
PathP (λ i → P (loop i)) b0 b0
isPropFamS¹ P pP b0 i = pP (loop i) (transp (λ j → P (loop (i ∧ j))) (~ i) b0)
(transp (λ j → P (loop (i ∨ ~ j))) i b0) i
rotIsEquiv : (a : S¹) → isEquiv (rot a)
rotIsEquiv base = idIsEquiv S¹
rotIsEquiv (loop i) = isPropFamS¹ (λ x → isEquiv (rot x))
(λ x → isPropIsEquiv (rot x))
(idIsEquiv _) i
-- more direct definition of the rot (loop i) equivalence
rotLoopInv : (a : S¹) → PathP (λ i → rotLoop (rotLoop a (~ i)) i ≡ a) refl refl
rotLoopInv a i j = homotopySymInv rotLoop a j i
rotLoopEquiv : (i : I) → S¹ ≃ S¹
rotLoopEquiv i =
isoToEquiv
(iso (λ a → rotLoop a i)
(λ a → rotLoop a (~ i))
(λ a → rotLoopInv a i)
(λ a → rotLoopInv a (~ i)))
-- some cancellation laws, used in the Hopf fibration
private
rotInv-aux-1 : I → I → I → I → S¹
rotInv-aux-1 j k i =
hfill (λ l → λ { (k = i0) → (loop (i ∧ ~ l)) * loop j
; (k = i1) → loop j
; (i = i0) → (loop k * loop j) * loop (~ k)
; (i = i1) → loop (~ k ∧ ~ l) * loop j })
(inS ((loop (k ∨ i) * loop j) * loop (~ k)))
rotInv-aux-2 : I → I → I → S¹
rotInv-aux-2 i j k =
hcomp (λ l → λ { (k = i0) → inv (filler-rot (~ i) (~ j) l)
; (k = i1) → loop (j ∧ l)
; (i = i0) → filler-rot k j l
; (i = i1) → loop (j ∧ l)
; (j = i0) → loop (i ∨ k ∨ (~ l))
; (j = i1) → loop ((i ∨ k) ∧ l) })
(base)
rotInv-aux-3 : I → I → I → I → S¹
rotInv-aux-3 j k i =
hfill (λ l → λ { (k = i0) → rotInv-aux-2 i j l
; (k = i1) → loop j
; (i = i0) → loop (k ∨ l) * loop j
; (i = i1) → loop k * (inv (loop (~ j) * loop k)) })
(inS (loop k * (inv (loop (~ j) * loop (k ∨ ~ i)))))
rotInv-aux-4 : I → I → I → I → S¹
rotInv-aux-4 j k i =
hfill (λ l → λ { (k = i0) → rotInv-aux-2 i j l
; (k = i1) → loop j
; (i = i0) → loop j * loop (k ∨ l)
; (i = i1) → (inv (loop (~ j) * loop k)) * loop k })
(inS ((inv (loop (~ j) * loop (k ∨ ~ i))) * loop k))
rotInv-1 : (a b : S¹) → b * a * inv b ≡ a
rotInv-1 base base i = base
rotInv-1 base (loop k) i = rotInv-aux-1 i0 k i i1
rotInv-1 (loop j) base i = loop j
rotInv-1 (loop j) (loop k) i = rotInv-aux-1 j k i i1
rotInv-2 : (a b : S¹) → inv b * a * b ≡ a
rotInv-2 base base i = base
rotInv-2 base (loop k) i = rotInv-aux-1 i0 (~ k) i i1
rotInv-2 (loop j) base i = loop j
rotInv-2 (loop j) (loop k) i = rotInv-aux-1 j (~ k) i i1
rotInv-3 : (a b : S¹) → b * (inv (inv a * b)) ≡ a
rotInv-3 base base i = base
rotInv-3 base (loop k) i = rotInv-aux-3 i0 k (~ i) i1
rotInv-3 (loop j) base i = loop j
rotInv-3 (loop j) (loop k) i = rotInv-aux-3 j k (~ i) i1
rotInv-4 : (a b : S¹) → inv (b * inv a) * b ≡ a
rotInv-4 base base i = base
rotInv-4 base (loop k) i = rotInv-aux-4 i0 k (~ i) i1
rotInv-4 (loop j) base i = loop j
rotInv-4 (loop j) (loop k) i = rotInv-aux-4 j k (~ i) i1
| 36.838074
| 101
| 0.528661
|
8b6ad690a6aa438f7597e49abf9dbc4f46191eac
| 3,087
|
agda
|
Agda
|
theorems/homotopy/SuspensionJoin.agda
|
cmknapp/HoTT-Agda
|
bc849346a17b33e2679a5b3f2b8efbe7835dc4b6
|
[
"MIT"
] | null | null | null |
theorems/homotopy/SuspensionJoin.agda
|
cmknapp/HoTT-Agda
|
bc849346a17b33e2679a5b3f2b8efbe7835dc4b6
|
[
"MIT"
] | null | null | null |
theorems/homotopy/SuspensionJoin.agda
|
cmknapp/HoTT-Agda
|
bc849346a17b33e2679a5b3f2b8efbe7835dc4b6
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --without-K #-}
open import HoTT
module homotopy.SuspensionJoin {i} (A : Type i) where
{- To -}
false, : A → Bool × A
false, a = false , a
true, : A → Bool × A
true, a = true , a
module To = SuspensionRec {i} (left false :> Bool * A) (left true) (λ a → glue (false, a) ∙ ! (glue (true, a)))
to : Suspension A → (Bool * A)
to = To.f
{- From -}
from : Bool * A → Suspension A
from = From.f module _ where
from-bool : Bool → Suspension A
from-bool false = north
from-bool true = south
from-glue : (c : Bool × A) → from-bool (fst c) == south
from-glue (false , a) = merid a
from-glue (true , a) = idp
module From = PushoutRec {d = *-span Bool A} from-bool (λ _ → south) from-glue
{- ToFrom -}
to-from : (c : Bool * A) → to (from c) == c
to-from = Pushout-elim to-from-left (λ a → glue (true , a)) to-from-glue where
to-from-left : (b : Bool) → to (from (left b)) == left b
to-from-left false = idp
to-from-left true = idp
to-from-glue' : (b : Bool) (a : A)
→ ap to (ap from (glue (b , a))) ∙' glue (true , a) == to-from-left b ∙ glue (b , a)
to-from-glue' true a =
ap to (ap from (glue (true , a))) ∙' glue (true , a) =⟨ From.glue-β (true , a) |in-ctx (λ u → ap to u ∙' glue (true , a)) ⟩
idp ∙' glue (true , a) =⟨ ∙'-unit-l _ ⟩
glue (true , a) ∎
to-from-glue' false a =
ap to (ap from (glue (false , a))) ∙' glue (true , a) =⟨ From.glue-β (false , a) |in-ctx (λ u → ap to u ∙' glue (true , a)) ⟩
ap to (merid a) ∙' glue (true , a) =⟨ To.merid-β a |in-ctx (λ u → u ∙' glue (true , a)) ⟩
(glue (false , a) ∙ ! (glue (true , a))) ∙' glue (true , a) =⟨ coh (glue (false , a)) (glue (true , a)) ⟩
glue (false , a) ∎ where
coh : ∀ {i} {A : Type i} {a b c : A} (p : a == b) (q : c == b) → (p ∙ ! q) ∙' q == p
coh idp idp = idp
to-from-glue : (c : Bool × A)
→ to-from-left (fst c) == glue (true , snd c) [ (λ z → to (from z) == z) ↓ glue c ]
to-from-glue c = ↓-∘=idf-in to from (uncurry to-from-glue' c)
{- FromTo -}
from-to : (c : Suspension A) → from (to c) == c
from-to = Suspension-elim idp idp from-to-merid where
from-to-merid' : (a : A) → ap from (ap to (merid a)) == merid a
from-to-merid' a =
ap from (ap to (merid a)) =⟨ To.merid-β a |in-ctx ap from ⟩
ap from (glue (false , a) ∙ ! (glue (true , a))) =⟨ ap-∙ from (glue (false , a)) (! (glue (true , a))) ⟩
ap from (glue (false , a)) ∙ ap from (! (glue (true , a))) =⟨ ap-! from (glue (true , a)) |in-ctx (λ u → ap from (glue (false , a)) ∙ u) ⟩
ap from (glue (false , a)) ∙ ! (ap from (glue (true , a))) =⟨ From.glue-β (false , a) |in-ctx (λ u → u ∙ ! (ap from (glue (true , a)))) ⟩
merid a ∙ ! (ap from (glue (true , a))) =⟨ From.glue-β (true , a) |in-ctx (λ u → merid a ∙ ! u) ⟩
merid a ∙ idp =⟨ ∙-unit-r _ ⟩
merid a ∎
from-to-merid : (a : A) → idp == idp [ (λ z → from (to z) == z) ↓ merid a ]
from-to-merid a = ↓-∘=idf-in from to (from-to-merid' a)
{- Conclusion -}
e : Suspension A ≃ (Bool * A)
e = equiv to from to-from from-to
| 35.895349
| 144
| 0.516683
|
526677ea2b52e1cba02866e0a10bce505207c3c4
| 491
|
agda
|
Agda
|
test/Fail/Issue631.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
test/Fail/Issue631.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
test/Fail/Issue631.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
{-# OPTIONS --show-implicit --show-irrelevant #-}
-- {-# OPTIONS -v tc.conv.irr:20 -v tc.constr.findInScope:20 -v tc.meta:20 -v tc.conv.type:50 -v tc.conv.term:30 -v tc.conv.atom:50 -v tc.inj.use:20 #-}
module Issue631 where
import Common.Level -- for debug messages
data Bool : Set where
false true : Bool
F : Bool → Set
F true = Bool
F false = Bool
postulate
BAD : ∀ {u} → F u
Goal : Set
score : .Goal → Set
buggy : Set
buggy = score _ -- {!!}
-- should remain unsolved
| 22.318182
| 152
| 0.639511
|
9ad63527cd27cfc0bcec3ae29d8be5f1469bafcc
| 429
|
agda
|
Agda
|
test/bags.agda
|
jonaprieto/agda-prop
|
a1730062a6aaced2bb74878c1071db06477044ae
|
[
"MIT"
] | 13
|
2017-05-01T16:45:41.000Z
|
2022-01-17T03:33:12.000Z
|
test/bags.agda
|
jonaprieto/agda-prop
|
a1730062a6aaced2bb74878c1071db06477044ae
|
[
"MIT"
] | 18
|
2017-03-08T14:33:10.000Z
|
2017-12-18T16:34:21.000Z
|
test/bags.agda
|
jonaprieto/agda-prop
|
a1730062a6aaced2bb74878c1071db06477044ae
|
[
"MIT"
] | 2
|
2017-03-30T16:41:56.000Z
|
2017-12-01T17:01:25.000Z
|
module bags where
open import Data.PropFormula.Syntax 4
open import Data.PropFormula.SyntaxExperiment 4 public
open import Data.Fin using (suc; zero; #_)
open import Relation.Binary.PropositionalEquality using (_≡_)
p : PropFormula
p = Var (# 0)
q : PropFormula
q = Var (# 1)
pq : PropFormula
pq = p ∧ q
qp : PropFormula
qp = q ∧ p
listpq : List PropFormula
listpq = toList pq
listqp : List PropFormula
listqp = toList qp
| 17.16
| 61
| 0.734266
|
380ceea4c5be725383345e7440b04c32b0878f3d
| 1,843
|
agda
|
Agda
|
src/Selective/Examples/TestSelectiveReceive-calc.agda
|
Zalastax/singly-typed-actors
|
ae541df13d069df4eb1464f29fbaa9804aad439f
|
[
"MIT"
] | 1
|
2019-10-29T09:30:26.000Z
|
2019-10-29T09:30:26.000Z
|
src/Selective/Examples/TestSelectiveReceive-calc.agda
|
Zalastax/singly-typed-actors
|
ae541df13d069df4eb1464f29fbaa9804aad439f
|
[
"MIT"
] | null | null | null |
src/Selective/Examples/TestSelectiveReceive-calc.agda
|
Zalastax/singly-typed-actors
|
ae541df13d069df4eb1464f29fbaa9804aad439f
|
[
"MIT"
] | null | null | null |
module Selective.Examples.TestSelectiveReceive-calc where
open import Selective.ActorMonad
open import Prelude
open import Debug
open import Data.Nat.Show using (show)
UniqueTag = ℕ
TagField = ValueType UniqueTag
ℕ-ReplyMessage : MessageType
ℕ-ReplyMessage = ValueType UniqueTag ∷ [ ValueType ℕ ]ˡ
ℕ-Reply : InboxShape
ℕ-Reply = [ ℕ-ReplyMessage ]ˡ
ℕ×ℕ→ℕ-Message : MessageType
ℕ×ℕ→ℕ-Message = ValueType UniqueTag ∷ ReferenceType ℕ-Reply ∷ ValueType ℕ ∷ [ ValueType ℕ ]ˡ
Calculate : InboxShape
Calculate = [ ℕ×ℕ→ℕ-Message ]ˡ
Calculator : InboxShape
Calculator = ℕ×ℕ→ℕ-Message ∷ [ ℕ×ℕ→ℕ-Message ]ˡ
calculator-actor : ∀ {i} → ∞ActorM (↑ i) Calculator (Lift (lsuc lzero) ⊤) [] (λ _ → [])
calculator-actor .force = receive ∞>>= λ {
(Msg Z (tag ∷ _ ∷ n ∷ m ∷ [])) .force →
Z ![t: Z ] (lift tag ∷ [ lift (n + m) ]ᵃ) ∞>> (do
strengthen []
calculator-actor)
; (Msg (S Z) (tag ∷ _ ∷ n ∷ m ∷ [])) .force →
(Z ![t: Z ] (lift tag ∷ ([ lift (n * m) ]ᵃ))) ∞>> (do
(strengthen [])
calculator-actor)
; (Msg (S (S ())) _)
}
TestBox : InboxShape
TestBox = ℕ-Reply
accept-tagged-ℕ : UniqueTag → MessageFilter TestBox
accept-tagged-ℕ tag (Msg Z (tag' ∷ _)) = ⌊ tag ≟ tag' ⌋
accept-tagged-ℕ tag (Msg (S ()) _)
calculator-test-actor : ∀{i} → ∞ActorM i TestBox (Lift (lsuc lzero) ℕ) [] (λ _ → [])
calculator-test-actor = do
spawn∞ calculator-actor
self
(S Z ![t: Z ] ((lift 0) ∷ (([ Z ]>: ⊆-refl) ∷ lift 32 ∷ [ lift 10 ]ᵃ)))
(strengthen (⊆-suc ⊆-refl))
sm: Msg Z (_ ∷ n ∷ []) [ _ ] ← (selective-receive (accept-tagged-ℕ 0))
where
sm: Msg (S ()) _ [ _ ]
self
(S Z ![t: S Z ] ((lift 0) ∷ (([ Z ]>: ⊆-refl) ∷ lift 32 ∷ [ lift 10 ]ᵃ)))
strengthen (⊆-suc ⊆-refl)
sm: Msg Z (_ ∷ m ∷ []) [ _ ] ← (selective-receive (accept-tagged-ℕ 0))
where
sm: Msg (S ()) _ [ _ ]
strengthen []
return m
| 28.796875
| 92
| 0.593055
|
8b7d5aa7ee9c89c94ec3b535c9312b326229ab34
| 659
|
agda
|
Agda
|
Cubical/HITs/Ints/HAEquivInt/Base.agda
|
kiana-S/univalent-foundations
|
8bdb0766260489f9c89a14f4c0f2ad26e5190dec
|
[
"MIT"
] | null | null | null |
Cubical/HITs/Ints/HAEquivInt/Base.agda
|
kiana-S/univalent-foundations
|
8bdb0766260489f9c89a14f4c0f2ad26e5190dec
|
[
"MIT"
] | null | null | null |
Cubical/HITs/Ints/HAEquivInt/Base.agda
|
kiana-S/univalent-foundations
|
8bdb0766260489f9c89a14f4c0f2ad26e5190dec
|
[
"MIT"
] | 1
|
2021-11-22T02:02:01.000Z
|
2021-11-22T02:02:01.000Z
|
{-# OPTIONS --cubical --no-import-sorts --safe #-}
module Cubical.HITs.Ints.HAEquivInt.Base where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Equiv.HalfAdjoint
data HAEquivInt : Type₀ where
zero : HAEquivInt
suc : HAEquivInt -> HAEquivInt
-- suc is a HAEquiv:
pred : HAEquivInt -> HAEquivInt
suc-pred : ∀ z -> suc (pred z) ≡ z
pred-suc : ∀ z -> pred (suc z) ≡ z
coh : ∀ z → (λ i → suc (pred-suc z i)) ≡ suc-pred (suc z)
suc-haequiv : HAEquiv HAEquivInt HAEquivInt
suc-haequiv = suc , record { g = pred ; sec = pred-suc ; ret = suc-pred ; com = coh }
-- OPEN: prove HAEquivInt ≃ Int! See Experiments/HInt.agda
| 27.458333
| 85
| 0.670713
|
dffe39e28ee907893bd8a46b90aea9b52002346f
| 1,735
|
agda
|
Agda
|
src/SystemF/Substitutions/Types.agda
|
metaborg/ts.agda
|
7fe638b87de26df47b6437f5ab0a8b955384958d
|
[
"MIT"
] | 4
|
2019-04-05T17:57:11.000Z
|
2021-05-07T04:08:41.000Z
|
src/SystemF/Substitutions/Types.agda
|
metaborg/ts.agda
|
7fe638b87de26df47b6437f5ab0a8b955384958d
|
[
"MIT"
] | null | null | null |
src/SystemF/Substitutions/Types.agda
|
metaborg/ts.agda
|
7fe638b87de26df47b6437f5ab0a8b955384958d
|
[
"MIT"
] | null | null | null |
module SystemF.Substitutions.Types where
open import Prelude
open import SystemF.Syntax.Type
open import Data.Fin.Substitution
open import Data.Star hiding (map)
open import Data.Vec
module TypeSubst where
module TypeApp {T} (l : Lift T Type) where
open Lift l hiding (var)
infixl 8 _/_
_/_ : ∀ {m n} → Type m → Sub T m n → Type n
tc c / σ = tc c
tvar x / σ = lift (lookup x σ)
(a →' b) / σ = (a / σ) →' (b / σ)
(a ⟶ b) / σ = (a / σ) ⟶ (b / σ)
∀' a / σ = ∀' (a / σ ↑)
open Application (record { _/_ = _/_ }) using (_/✶_)
→'-/✶-↑✶ : ∀ k {m n a b} (ρs : Subs T m n) →
(a →' b) /✶ ρs ↑✶ k ≡ (a /✶ ρs ↑✶ k) →' (b /✶ ρs ↑✶ k)
→'-/✶-↑✶ k ε = refl
→'-/✶-↑✶ k (ρ ◅ ρs) = cong₂ _/_ (→'-/✶-↑✶ k ρs) refl
⟶-/✶-↑✶ : ∀ k {m n a b} (ρs : Subs T m n) →
(a ⟶ b) /✶ ρs ↑✶ k ≡ (a /✶ ρs ↑✶ k) ⟶ (b /✶ ρs ↑✶ k)
⟶-/✶-↑✶ k ε = refl
⟶-/✶-↑✶ k (ρ ◅ ρs) = cong₂ _/_ (⟶-/✶-↑✶ k ρs) refl
∀'-/✶-↑✶ : ∀ k {m n a} (ρs : Subs T m n) →
(∀' a) /✶ ρs ↑✶ k ≡ ∀' (a /✶ ρs ↑✶ (1 + k))
∀'-/✶-↑✶ k ε = refl
∀'-/✶-↑✶ k (ρ ◅ ρs) = cong₂ _/_ (∀'-/✶-↑✶ k ρs) refl
tc-/✶-↑✶ : ∀ k {c m n} (ρs : Subs T m n) →
(tc c) /✶ ρs ↑✶ k ≡ tc c
tc-/✶-↑✶ k ε = refl
tc-/✶-↑✶ k (r ◅ ρs) = cong₂ _/_ (tc-/✶-↑✶ k ρs) refl
typeSubst : TermSubst Type
typeSubst = record { var = tvar; app = TypeApp._/_ }
open TermSubst typeSubst public hiding (var)
infix 8 _[/_]
-- Shorthand for single-variable type substitutions
_[/_] : ∀ {n} → Type (suc n) → Type n → Type n
a [/ b ] = a / sub b
open TypeSubst public using ()
renaming (_/_ to _tp/tp_; _[/_] to _tp[/tp_]; weaken to tp-weaken)
| 29.913793
| 69
| 0.441499
|
5e6af3942ab4110874fbfe9365a8c2b54477b311
| 330
|
agda
|
Agda
|
test/Fail/TypeConstructorsWhichPreserveGuardedness4.agda
|
vlopezj/agda
|
ff4d89e75970cf27599fb9f572bd43c9455cbb56
|
[
"BSD-3-Clause"
] | 3
|
2015-03-28T14:51:03.000Z
|
2015-12-07T20:14:00.000Z
|
test/Fail/TypeConstructorsWhichPreserveGuardedness4.agda
|
vikfret/agda
|
49ad0b3f0d39c01bc35123478b857e702b29fb9d
|
[
"BSD-3-Clause"
] | 3
|
2018-11-14T15:31:44.000Z
|
2019-04-01T19:39:26.000Z
|
test/Fail/TypeConstructorsWhichPreserveGuardedness4.agda
|
vikfret/agda
|
49ad0b3f0d39c01bc35123478b857e702b29fb9d
|
[
"BSD-3-Clause"
] | 1
|
2019-03-05T20:02:38.000Z
|
2019-03-05T20:02:38.000Z
|
{-# OPTIONS --guardedness-preserving-type-constructors #-}
module TypeConstructorsWhichPreserveGuardedness4 where
open import Common.Coinduction
data Rec (A : ∞ Set) : Set where
fold : ♭ A → Rec A
D : Set
D = Rec (♯ (D → D))
-- _·_ : D → D → D
-- fold f · x = f x
-- ω : D
-- ω = fold (λ x → x · x)
-- Ω : D
-- Ω = ω · ω
| 15.714286
| 58
| 0.575758
|
5eb743dd3978e5db3cebb86a56369d94a0316c86
| 13,610
|
agda
|
Agda
|
Definition/Conversion/Transitivity.agda
|
Vtec234/logrel-mltt
|
4746894adb5b8edbddc8463904ee45c2e9b29b69
|
[
"MIT"
] | null | null | null |
Definition/Conversion/Transitivity.agda
|
Vtec234/logrel-mltt
|
4746894adb5b8edbddc8463904ee45c2e9b29b69
|
[
"MIT"
] | null | null | null |
Definition/Conversion/Transitivity.agda
|
Vtec234/logrel-mltt
|
4746894adb5b8edbddc8463904ee45c2e9b29b69
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --without-K --safe #-}
module Definition.Conversion.Transitivity where
open import Definition.Untyped
open import Definition.Typed
open import Definition.Typed.Properties
open import Definition.Typed.RedSteps
open import Definition.Conversion
open import Definition.Conversion.Soundness
open import Definition.Conversion.Stability
open import Definition.Conversion.Whnf
open import Definition.Conversion.Conversion
open import Definition.Conversion.Reduction
open import Definition.Conversion.Lift
open import Definition.Typed.Consequences.Syntactic
open import Definition.Typed.Consequences.Injectivity
import Definition.Typed.Consequences.Inequality as WF
open import Definition.Typed.Consequences.Syntactic
open import Definition.Typed.Consequences.Substitution
open import Definition.Typed.Consequences.NeTypeEq
open import Definition.Typed.Consequences.SucCong
open import Definition.Typed.Consequences.Inversion
open import Definition.Typed.Consequences.Reduction
open import Tools.Nat
open import Tools.Product
open import Tools.Empty
import Tools.PropositionalEquality as PE
mutual
-- Transitivity of algorithmic equality of neutrals.
trans~↑ : ∀ {t u v A B Γ}
→ Γ ⊢ t ~ u ↑ A
→ Γ ⊢ u ~ v ↑ B
→ Γ ⊢ t ~ v ↑ A
× Γ ⊢ A ≡ B
trans~↑ (var-refl x₁ x≡y) (var-refl x₂ x≡y₁) =
var-refl x₁ (PE.trans x≡y x≡y₁)
, neTypeEq (var _) x₁
(PE.subst (λ x → _ ⊢ var x ∷ _) (PE.sym x≡y)
x₂)
trans~↑ (app-cong t~u a<>b) (app-cong u~v b<>c) =
let t~v , ΠFG≡ΠF′G′ = trans~↓ t~u u~v
F≡F₁ , G≡G₁ = injectivity ΠFG≡ΠF′G′
a<>c = transConv↑Term F≡F₁ a<>b b<>c
in app-cong t~v a<>c , substTypeEq G≡G₁ (soundnessConv↑Term a<>b)
trans~↑ (fst-cong t~u) (fst-cong u~v) =
let t~v , ΣFG≡ΣF′G′ = trans~↓ t~u u~v
F≡F′ , _ = Σ-injectivity ΣFG≡ΣF′G′
in fst-cong t~v , F≡F′
trans~↑ (snd-cong t~u) (snd-cong u~v) =
let t~v , ΣFG≡ΣF′G′ = trans~↓ t~u u~v
F≡F′ , G≡G′ = Σ-injectivity ΣFG≡ΣF′G′
in snd-cong t~v , substTypeEq G≡G′ (soundness~↑ (fst-cong t~u))
trans~↑ (natrec-cong A<>B a₀<>b₀ aₛ<>bₛ t~u) (natrec-cong B<>C b₀<>c₀ bₛ<>cₛ u~v) =
let ⊢Γ = wf (proj₁ (syntacticEqTerm (soundness~↓ t~u)))
A≡B = soundnessConv↑ A<>B
F[0]≡F₁[0] = substTypeEq A≡B (refl (zeroⱼ ⊢Γ))
ΠℕFs≡ΠℕF₁s = sucCong A≡B
A<>C = transConv↑ A<>B B<>C
a₀<>c₀ = transConv↑Term F[0]≡F₁[0] a₀<>b₀ b₀<>c₀
aₛ<>cₛ = transConv↑Term ΠℕFs≡ΠℕF₁s aₛ<>bₛ bₛ<>cₛ
t~v , _ = trans~↓ t~u u~v
in natrec-cong A<>C a₀<>c₀ aₛ<>cₛ t~v
, substTypeEq A≡B (soundness~↓ t~u)
trans~↑ (Emptyrec-cong A<>B t~u) (Emptyrec-cong B<>C u~v) =
let A≡B = soundnessConv↑ A<>B
A<>C = transConv↑ A<>B B<>C
t~v , _ = trans~↓ t~u u~v
in Emptyrec-cong A<>C t~v , A≡B
-- Transitivity of algorithmic equality of neutrals with types in WHNF.
trans~↓ : ∀ {t u v A B Γ}
→ Γ ⊢ t ~ u ↓ A
→ Γ ⊢ u ~ v ↓ B
→ Γ ⊢ t ~ v ↓ A
× Γ ⊢ A ≡ B
trans~↓ ([~] A₁ D whnfA k~l) ([~] A₂ D₁ whnfA₁ k~l₁) =
let t~v , A≡B = trans~↑ k~l k~l₁
in [~] A₁ D whnfA t~v
, trans (sym (subset* D))
(trans A≡B
(subset* D₁))
-- Transitivity of algorithmic equality of types.
transConv↑ : ∀ {A B C Γ}
→ Γ ⊢ A [conv↑] B
→ Γ ⊢ B [conv↑] C
→ Γ ⊢ A [conv↑] C
transConv↑ ([↑] A′ B′ D D′ whnfA′ whnfB′ A′<>B′)
([↑] A″ B″ D₁ D″ whnfA″ whnfB″ A′<>B″) =
[↑] A′ B″ D D″ whnfA′ whnfB″
(transConv↓ A′<>B′
(PE.subst (λ x → _ ⊢ x [conv↓] B″)
(whrDet* (D₁ , whnfA″)
(D′ , whnfB′))
A′<>B″))
transConv↑′ : ∀ {A B C Γ Δ}
→ ⊢ Γ ≡ Δ
→ Γ ⊢ A [conv↑] B
→ Δ ⊢ B [conv↑] C
→ Γ ⊢ A [conv↑] C
transConv↑′ Γ≡Δ aConvB bConvC =
transConv↑ aConvB (stabilityConv↑ (symConEq Γ≡Δ) bConvC)
-- Transitivity of algorithmic equality of types in WHNF.
transConv↓ : ∀ {A B C Γ}
→ Γ ⊢ A [conv↓] B
→ Γ ⊢ B [conv↓] C
→ Γ ⊢ A [conv↓] C
transConv↓ (U-refl x) (U-refl x₁) = U-refl x
transConv↓ (ℕ-refl x) (ℕ-refl x₁) = ℕ-refl x
transConv↓ (Empty-refl x) (Empty-refl x₁) = Empty-refl x
transConv↓ (Unit-refl x) (Unit-refl x₁) = Unit-refl x
transConv↓ (ne x) (ne x₁) =
let A~C , U≡U = trans~↓ x x₁
in ne A~C
transConv↓ (Π-cong x x₁ x₂) (Π-cong x₃ x₄ x₅) =
Π-cong x (transConv↑ x₁ x₄) (transConv↑′ (reflConEq (wf x) ∙ soundnessConv↑ x₁) x₂ x₅)
transConv↓ (Σ-cong x x₁ x₂) (Σ-cong x₃ x₄ x₅) =
Σ-cong x (transConv↑ x₁ x₄) (transConv↑′ (reflConEq (wf x) ∙ soundnessConv↑ x₁) x₂ x₅)
-- Refutable cases
transConv↓ (U-refl x) (ne ([~] A D whnfB ()))
transConv↓ (ℕ-refl x) (ne ([~] A D whnfB ()))
transConv↓ (Empty-refl x) (ne ([~] A D whnfB ()))
transConv↓ (Π-cong x x₁ x₂) (ne ([~] A D whnfB ()))
transConv↓ (Σ-cong x x₁ x₂) (ne ([~] A D whnfB ()))
transConv↓ (ne ([~] A₁ D whnfB ())) (U-refl x₁)
transConv↓ (ne ([~] A₁ D whnfB ())) (ℕ-refl x₁)
transConv↓ (ne ([~] A₁ D whnfB ())) (Empty-refl x₁)
transConv↓ (ne ([~] A₁ D whnfB ())) (Π-cong x₁ x₂ x₃)
transConv↓ (ne ([~] A₁ D whnfB ())) (Σ-cong x₁ x₂ x₃)
-- Transitivity of algorithmic equality of terms.
transConv↑Term : ∀ {t u v A B Γ}
→ Γ ⊢ A ≡ B
→ Γ ⊢ t [conv↑] u ∷ A
→ Γ ⊢ u [conv↑] v ∷ B
→ Γ ⊢ t [conv↑] v ∷ A
transConv↑Term A≡B ([↑]ₜ B₁ t′ u′ D d d′ whnfB whnft′ whnfu′ t<>u)
([↑]ₜ B₂ t″ u″ D₁ d₁ d″ whnfB₁ whnft″ whnfu″ t<>u₁) =
let B₁≡B₂ = trans (sym (subset* D))
(trans A≡B
(subset* D₁))
d₁″ = conv* d″ (sym B₁≡B₂)
d₁′ = conv* d′ B₁≡B₂
in [↑]ₜ B₁ t′ u″ D d d₁″ whnfB whnft′ whnfu″
(transConv↓Term B₁≡B₂ t<>u
(PE.subst (λ x → _ ⊢ x [conv↓] u″ ∷ B₂)
(whrDet*Term (d₁ , whnft″)
(d₁′ , whnfu′))
t<>u₁))
transConv↑Term′ : ∀ {t u v A B Γ Δ}
→ ⊢ Γ ≡ Δ
→ Γ ⊢ A ≡ B
→ Γ ⊢ t [conv↑] u ∷ A
→ Δ ⊢ u [conv↑] v ∷ B
→ Γ ⊢ t [conv↑] v ∷ A
transConv↑Term′ Γ≡Δ A≡B tConvU uConvV =
transConv↑Term A≡B tConvU (stabilityConv↑Term (symConEq Γ≡Δ) uConvV)
-- Transitivity of algorithmic equality of terms in WHNF.
transConv↓Term : ∀ {t u v A B Γ}
→ Γ ⊢ A ≡ B
→ Γ ⊢ t [conv↓] u ∷ A
→ Γ ⊢ u [conv↓] v ∷ B
→ Γ ⊢ t [conv↓] v ∷ A
transConv↓Term A≡B (ℕ-ins x) (ℕ-ins x₁) =
ℕ-ins (proj₁ (trans~↓ x x₁))
transConv↓Term A≡B (Empty-ins x) (Empty-ins x₁) =
Empty-ins (proj₁ (trans~↓ x x₁))
transConv↓Term A≡B (Unit-ins t~u) uConvV =
let _ , [t] , _ = syntacticEqTerm (soundness~↓ t~u)
_ , tNe , _ = ne~↓ t~u
_ , _ , [v] = syntacticEqTerm (soundnessConv↓Term uConvV)
[v] = conv [v] (sym A≡B)
_ , _ , vWhnf = whnfConv↓Term uConvV
in η-unit [t] [v] (ne tNe) vWhnf
transConv↓Term A≡B (ne-ins t u x x₁) (ne-ins t′ u′ x₂ x₃) =
ne-ins t (conv u′ (sym A≡B)) x
(proj₁ (trans~↓ x₁ x₃))
transConv↓Term A≡B (univ x x₁ x₂) (univ x₃ x₄ x₅) =
univ x x₄ (transConv↓ x₂ x₅)
transConv↓Term A≡B (zero-refl x) conv↓ =
convConv↓Term (reflConEq x) (sym A≡B) ℕₙ conv↓
transConv↓Term A≡B conv↓ (zero-refl _) = conv↓
transConv↓Term A≡B (suc-cong x) (suc-cong x₁) =
suc-cong (transConv↑Term A≡B x x₁)
transConv↓Term A≡B (η-eq x₁ x₂ y y₁ x₃) (η-eq x₅ x₆ y₂ y₃ x₇) =
let F₁≡F , G₁≡G = injectivity A≡B
in η-eq x₁ (conv x₆ (sym A≡B))
y y₃ (transConv↑Term′ (reflConEq (wfEq F₁≡F) ∙ F₁≡F) G₁≡G x₃ x₇)
transConv↓Term A≡B (Σ-η ⊢p ⊢r pProd rProd fstConv sndConv)
(Σ-η ⊢r′ ⊢q _ qProd fstConv′ sndConv′) =
let F≡ , G≡ = Σ-injectivity A≡B
Gfst≡ = substTypeEq G≡ (soundnessConv↑Term fstConv)
in Σ-η ⊢p (conv ⊢q (sym A≡B)) pProd qProd
(transConv↑Term F≡ fstConv fstConv′)
(transConv↑Term Gfst≡ sndConv sndConv′)
transConv↓Term A≡B (η-unit [t] [u] tUnit uUnit) uConvV =
let _ , _ , [v] = syntacticEqTerm (soundnessConv↓Term uConvV)
[v] = conv [v] (sym A≡B)
_ , _ , vWhnf = whnfConv↓Term uConvV
in η-unit [t] [v] tUnit vWhnf
-- Refutable cases
transConv↓Term A≡B (ℕ-ins x) (ne-ins t u x₂ x₃) = ⊥-elim (WF.ℕ≢ne x₂ A≡B)
transConv↓Term A≡B (ℕ-ins x) (univ x₂ x₃ x₄) = ⊥-elim (WF.U≢ℕ (sym A≡B))
transConv↓Term A≡B (ℕ-ins x) (Empty-ins x₁) = ⊥-elim (WF.ℕ≢Emptyⱼ A≡B)
transConv↓Term A≡B (ℕ-ins x) (Unit-ins x₁) = ⊥-elim (WF.ℕ≢Unitⱼ A≡B)
transConv↓Term A≡B (ℕ-ins ([~] A D whnfB ())) (suc-cong x₂)
transConv↓Term A≡B (ℕ-ins x) (η-eq x₃ x₄ y y₁ x₅) = ⊥-elim (WF.ℕ≢Π A≡B)
transConv↓Term A≡B (ℕ-ins x₁) (Σ-η x₂ x₃ x₄ x₅ x₆ x₇) = ⊥-elim (WF.ℕ≢Σ A≡B)
transConv↓Term A≡B (ℕ-ins x) (η-unit _ _ _ _) = ⊥-elim (WF.ℕ≢Unitⱼ A≡B)
transConv↓Term A≡B (Empty-ins x) (ne-ins t u x₂ x₃) = ⊥-elim (WF.Empty≢neⱼ x₂ A≡B)
transConv↓Term A≡B (Empty-ins x) (univ x₂ x₃ x₄) = ⊥-elim (WF.U≢Emptyⱼ (sym A≡B))
transConv↓Term A≡B (Empty-ins x₁) (ℕ-ins x) = ⊥-elim (WF.ℕ≢Emptyⱼ (sym A≡B))
transConv↓Term A≡B (Empty-ins x₁) (Unit-ins x) = ⊥-elim (WF.Empty≢Unitⱼ A≡B)
transConv↓Term A≡B (Empty-ins ([~] A D whnfB ())) (suc-cong x₂)
transConv↓Term A≡B (Empty-ins x) (η-eq x₃ x₄ y y₁ x₅) = ⊥-elim (WF.Empty≢Πⱼ A≡B)
transConv↓Term A≡B (Empty-ins x₁) (Σ-η x₂ x₃ x₄ x₅ x₆ x₇) = ⊥-elim (WF.Empty≢Σⱼ A≡B)
transConv↓Term A≡B (Empty-ins x₁) (η-unit _ _ _ _) = ⊥-elim (WF.Empty≢Unitⱼ A≡B)
transConv↓Term A≡B (ne-ins t u x x₁) (ℕ-ins x₂) = ⊥-elim (WF.ℕ≢ne x (sym A≡B))
transConv↓Term A≡B (ne-ins t u x x₁) (Empty-ins x₂) = ⊥-elim (WF.Empty≢neⱼ x (sym A≡B))
transConv↓Term A≡B (ne-ins t u x x₁) (Unit-ins x₂) = ⊥-elim (WF.Unit≢neⱼ x (sym A≡B))
transConv↓Term A≡B (ne-ins t u x x₁) (univ x₃ x₄ x₅) = ⊥-elim (WF.U≢ne x (sym A≡B))
transConv↓Term A≡B (ne-ins t u x ([~] A D whnfB ())) (suc-cong x₃)
transConv↓Term A≡B (ne-ins t u x x₁) (η-eq x₄ x₅ y y₁ x₆) = ⊥-elim (WF.Π≢ne x (sym A≡B))
transConv↓Term A≡B (ne-ins t u x x₁) (Σ-η x₅ x₆ x₇ x₈ x₉ x₁₀) = ⊥-elim (WF.Σ≢ne x (sym A≡B))
transConv↓Term A≡B (ne-ins t u x x₁) (η-unit _ _ _ _) = ⊥-elim (WF.Unit≢neⱼ x (sym A≡B))
transConv↓Term A≡B (univ x x₁ x₂) (ℕ-ins x₃) = ⊥-elim (WF.U≢ℕ A≡B)
transConv↓Term A≡B (univ x x₁ x₂) (Empty-ins x₃) = ⊥-elim (WF.U≢Emptyⱼ A≡B)
transConv↓Term A≡B (univ x x₁ x₂) (Unit-ins x₃) = ⊥-elim (WF.U≢Unitⱼ A≡B)
transConv↓Term A≡B (univ x x₁ x₂) (ne-ins t u x₃ x₄) = ⊥-elim (WF.U≢ne x₃ A≡B)
transConv↓Term A≡B (univ x x₁ x₂) (suc-cong x₃) = ⊥-elim (WF.U≢ℕ A≡B)
transConv↓Term A≡B (univ x x₁ x₂) (η-eq x₄ x₅ y y₁ x₆) = ⊥-elim (WF.U≢Π A≡B)
transConv↓Term A≡B (univ x₁ x₂ x₃) (Σ-η x₄ x₅ x₆ x₇ x₈ x₉) = ⊥-elim (WF.U≢Σ A≡B)
transConv↓Term A≡B (univ x x₁ x₂) (η-unit _ _ _ _) = ⊥-elim (WF.U≢Unitⱼ A≡B)
transConv↓Term A≡B (suc-cong x) (ℕ-ins ([~] A D whnfB ()))
transConv↓Term A≡B (suc-cong x) (Empty-ins ([~] A D whnfB ()))
transConv↓Term A≡B (suc-cong x) (ne-ins t u x₁ ([~] A D whnfB ()))
transConv↓Term A≡B (suc-cong x) (univ x₁ x₂ x₃) = ⊥-elim (WF.U≢ℕ (sym A≡B))
transConv↓Term A≡B (suc-cong x) (η-eq x₂ x₃ y y₁ x₄) = ⊥-elim (WF.ℕ≢Π A≡B)
transConv↓Term A≡B (suc-cong x₁) (Σ-η x₂ x₃ x₄ x₅ x₆ x₇) = ⊥-elim (WF.ℕ≢Σ A≡B)
transConv↓Term A≡B (suc-cong x) (η-unit _ _ _ _) = ⊥-elim (WF.ℕ≢Unitⱼ A≡B)
transConv↓Term A≡B (η-eq x₁ x₂ y y₁ x₃) (ℕ-ins x₄) = ⊥-elim (WF.ℕ≢Π (sym A≡B))
transConv↓Term A≡B (η-eq x₁ x₂ y y₁ x₃) (Empty-ins x₄) = ⊥-elim (WF.Empty≢Πⱼ (sym A≡B))
transConv↓Term A≡B (η-eq x₁ x₂ y y₁ x₃) (Unit-ins _) = ⊥-elim (WF.Unit≢Πⱼ (sym A≡B))
transConv↓Term A≡B (η-eq x₁ x₂ y y₁ x₃) (ne-ins t u x₄ x₅) = ⊥-elim (WF.Π≢ne x₄ A≡B)
transConv↓Term A≡B (η-eq x₁ x₂ y y₁ x₃) (univ x₄ x₅ x₆) = ⊥-elim (WF.U≢Π (sym A≡B))
transConv↓Term A≡B (η-eq x₁ x₂ y y₁ x₃) (suc-cong x₄) = ⊥-elim (WF.ℕ≢Π (sym A≡B))
transConv↓Term A≡B (η-eq x₂ x₃ x₄ x₅ x₆) (Σ-η x₇ x₈ x₉ x₁₀ x₁₁ x₁₂) = ⊥-elim (WF.Π≢Σ A≡B)
transConv↓Term A≡B (η-eq x₁ x₂ y y₁ x₃) (η-unit _ _ _ _) = ⊥-elim (WF.Unit≢Πⱼ (sym A≡B))
transConv↓Term A≡B (Σ-η x₁ x₂ x₃ x₄ x₅ x₆) (ℕ-ins x₇) = ⊥-elim (WF.ℕ≢Σ (sym A≡B))
transConv↓Term A≡B (Σ-η x₁ x₂ x₃ x₄ x₅ x₆) (Empty-ins x₇) = ⊥-elim (WF.Empty≢Σⱼ (sym A≡B))
transConv↓Term A≡B (Σ-η x₁ x₂ x₃ x₄ x₅ x₆) (Unit-ins x₇) = ⊥-elim (WF.Unit≢Σⱼ (sym A≡B))
transConv↓Term A≡B (Σ-η x₁ x₂ x₃ x₄ x₅ x₆) (ne-ins x₇ x₈ x₉ x₁₀) = ⊥-elim (WF.Σ≢ne x₉ A≡B)
transConv↓Term A≡B (Σ-η x₁ x₂ x₃ x₄ x₅ x₆) (univ x₇ x₈ x₉) = ⊥-elim (WF.U≢Σ (sym A≡B))
transConv↓Term A≡B (Σ-η x₁ x₂ x₃ x₄ x₅ x₆) (suc-cong x₇) = ⊥-elim (WF.ℕ≢Σ (sym A≡B))
transConv↓Term A≡B (Σ-η x₁ x₂ x₃ x₄ x₅ x₆) (η-eq x₈ x₉ x₁₀ x₁₁ x₁₂) = ⊥-elim (WF.Π≢Σ (sym A≡B))
transConv↓Term A≡B (Σ-η x₁ x₂ x₃ x₄ x₅ x₆) (η-unit x₇ x₈ x₉ x₁₀) = ⊥-elim (WF.Unit≢Σⱼ (sym A≡B))
-- Transitivity of algorithmic equality of types of the same context.
transConv : ∀ {A B C Γ}
→ Γ ⊢ A [conv↑] B
→ Γ ⊢ B [conv↑] C
→ Γ ⊢ A [conv↑] C
transConv A<>B B<>C = transConv↑ A<>B B<>C
-- Transitivity of algorithmic equality of terms of the same context.
transConvTerm : ∀ {t u v A Γ}
→ Γ ⊢ t [conv↑] u ∷ A
→ Γ ⊢ u [conv↑] v ∷ A
→ Γ ⊢ t [conv↑] v ∷ A
transConvTerm t<>u u<>v =
let t≡u = soundnessConv↑Term t<>u
⊢A , _ , _ = syntacticEqTerm t≡u
in transConv↑Term (refl ⊢A) t<>u u<>v
| 48.262411
| 98
| 0.551065
|
0effa83c42c7f8a199c298b376605153a2b55009
| 2,083
|
agda
|
Agda
|
agda-stdlib-0.9/src/Induction.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/Induction.agda
|
qwe2/try-agda
|
9d4c43b1609d3f085636376fdca73093481ab882
|
[
"Apache-2.0"
] | null | null | null |
agda-stdlib-0.9/src/Induction.agda
|
qwe2/try-agda
|
9d4c43b1609d3f085636376fdca73093481ab882
|
[
"Apache-2.0"
] | null | null | null |
------------------------------------------------------------------------
-- The Agda standard library
--
-- An abstraction of various forms of recursion/induction
------------------------------------------------------------------------
-- The idea underlying Induction.* comes from Epigram 1, see Section 4
-- of "The view from the left" by McBride and McKinna.
-- Note: The types in this module can perhaps be easier to understand
-- if they are normalised. Note also that Agda can do the
-- normalisation for you.
module Induction where
open import Level
open import Relation.Unary
-- A RecStruct describes the allowed structure of recursion. The
-- examples in Induction.Nat should explain what this is all about.
RecStruct : ∀ {a} → Set a → (ℓ₁ ℓ₂ : Level) → Set _
RecStruct A ℓ₁ ℓ₂ = Pred A ℓ₁ → Pred A ℓ₂
-- A recursor builder constructs an instance of a recursion structure
-- for a given input.
RecursorBuilder : ∀ {a ℓ₁ ℓ₂} {A : Set a} → RecStruct A ℓ₁ ℓ₂ → Set _
RecursorBuilder Rec = ∀ P → Rec P ⊆′ P → Universal (Rec P)
-- A recursor can be used to actually compute/prove something useful.
Recursor : ∀ {a ℓ₁ ℓ₂} {A : Set a} → RecStruct A ℓ₁ ℓ₂ → Set _
Recursor Rec = ∀ P → Rec P ⊆′ P → Universal P
-- And recursors can be constructed from recursor builders.
build : ∀ {a ℓ₁ ℓ₂} {A : Set a} {Rec : RecStruct A ℓ₁ ℓ₂} →
RecursorBuilder Rec →
Recursor Rec
build builder P f x = f x (builder P f x)
-- We can repeat the exercise above for subsets of the type we are
-- recursing over.
SubsetRecursorBuilder : ∀ {a ℓ₁ ℓ₂ ℓ₃} {A : Set a} →
Pred A ℓ₁ → RecStruct A ℓ₂ ℓ₃ → Set _
SubsetRecursorBuilder Q Rec = ∀ P → Rec P ⊆′ P → Q ⊆′ Rec P
SubsetRecursor : ∀ {a ℓ₁ ℓ₂ ℓ₃} {A : Set a} →
Pred A ℓ₁ → RecStruct A ℓ₂ ℓ₃ → Set _
SubsetRecursor Q Rec = ∀ P → Rec P ⊆′ P → Q ⊆′ P
subsetBuild : ∀ {a ℓ₁ ℓ₂ ℓ₃}
{A : Set a} {Q : Pred A ℓ₁} {Rec : RecStruct A ℓ₂ ℓ₃} →
SubsetRecursorBuilder Q Rec →
SubsetRecursor Q Rec
subsetBuild builder P f x q = f x (builder P f x q)
| 35.305085
| 72
| 0.605857
|
3840c74d3e98adfddca92e1c59fff8e090ac3618
| 159
|
agda
|
Agda
|
slides/Slides.agda
|
larrytheliquid/generic-elim
|
832383d7adf37aa2364213fb0aeb67e9f61a248f
|
[
"MIT"
] | 11
|
2015-06-02T14:05:20.000Z
|
2021-09-09T08:46:42.000Z
|
slides/Slides.agda
|
larrytheliquid/generic-elim
|
832383d7adf37aa2364213fb0aeb67e9f61a248f
|
[
"MIT"
] | null | null | null |
slides/Slides.agda
|
larrytheliquid/generic-elim
|
832383d7adf37aa2364213fb0aeb67e9f61a248f
|
[
"MIT"
] | 2
|
2016-05-02T08:56:15.000Z
|
2022-03-12T11:31:22.000Z
|
module Slides where
import Background
import OpenTheory
import OpenTheory2
import ClosedTheory
import ClosedTheory2
import ClosedTheory3
import ClosedTheory4
| 15.9
| 20
| 0.886792
|
a0eb8b07edb7c64f95a0fac655a867857d79a1d9
| 2,688
|
agda
|
Agda
|
examples/StateSized/cellStateDependent.agda
|
agda/ooAgda
|
7cc45e0148a4a508d20ed67e791544c30fecd795
|
[
"MIT"
] | 23
|
2016-06-19T12:57:55.000Z
|
2020-10-12T23:15:25.000Z
|
examples/StateSized/cellStateDependent.agda
|
agda/ooAgda
|
7cc45e0148a4a508d20ed67e791544c30fecd795
|
[
"MIT"
] | null | null | null |
examples/StateSized/cellStateDependent.agda
|
agda/ooAgda
|
7cc45e0148a4a508d20ed67e791544c30fecd795
|
[
"MIT"
] | 2
|
2018-09-01T15:02:37.000Z
|
2022-03-12T11:41:00.000Z
|
{-# OPTIONS --postfix-projections #-}
module StateSized.cellStateDependent where
open import Data.Product
open import Data.String.Base
{-
open import SizedIO.Object
open import SizedIO.ConsoleObject
-}
open import SizedIO.Console hiding (main)
open import SizedIO.Base
open import NativeIO
open import StateSizedIO.Object
open import StateSizedIO.IOObject
open import Size
open import StateSizedIO.cellStateDependent
{- I moved most into src/StateSizedIO/cellStateDependent.agda
now the code doesn't work
-}
-- Program is another program
program : IOConsole ∞ Unit
program =
let c₀ = cellPempty ∞ in
exec getLine λ str →
method c₀ (put str) >>= λ{ (_ , c₁) → -- empty
method c₁ get >>= λ{ (str₁ , c₂) → -- full
exec (putStrLn ("we got " ++ str₁)) λ _ →
exec (putStrLn ("Second Round")) λ _ →
exec getLine λ str₂ →
method c₂ (put str₂) >>= λ{ (_ , c₃) →
method c₃ get >>= λ{ (str₃ , c₄) →
exec (putStrLn ("we got " ++ str₃) ) λ _ →
return unit
}}}}
main : NativeIO Unit
main = translateIOConsole program
-- cellP is constructor for the consoleObject for interface (cellI String)
{-
cellPˢ : ∀{i} → CellCˢ i
force (method cellPˢ (put x)) = {!!}
-}
{-
cellP : ∀{i} (s : String) → CellC i
force (method (cellP s) get) =
exec' (putStrLn ("getting (" ++ s ++ ")")) λ _ →
return (s , cellP s)
force (method (cellP s) (put x)) =
exec' (putStrLn ("putting (" ++ x ++ ")")) λ _ →
return (_ , (cellP x))
-}
{-
-- cellI is the interface of the object of a simple cell
cellI : (A : Set) → Interfaceˢ
Method (cellI A) = CellMethodˢ A
Result (cellI A) m = CellResultˢ m
-- cellC is the type of consoleObjects with interface (cellI String)
CellC : (i : Size) → Set
CellC i = ConsoleObject i (cellI String)
-}
{-
-- cellO is a program for a simple cell which
-- when get is called writes "getting s" for the string s of the object
-- and when putting s writes "putting s" for the string
-- cellP is constructor for the consoleObject for interface (cellI String)
cellP : ∀{i} (s : String) → CellC i
force (method (cellP s) get) =
exec' (putStrLn ("getting (" ++ s ++ ")")) λ _ →
return (s , cellP s)
force (method (cellP s) (put x)) =
exec' (putStrLn ("putting (" ++ x ++ ")")) λ _ →
return (_ , (cellP x))
-- Program is another program
program : String → IOConsole ∞ Unit
program arg =
let c₀ = cellP "Start" in
method c₀ get >>= λ{ (s , c₁) →
exec1 (putStrLn s) >>
method c₁ (put arg) >>= λ{ (_ , c₂) →
method c₂ get >>= λ{ (s' , c₃) →
exec1 (putStrLn s') }}}
main : NativeIO Unit
main = translateIOConsole (program "hello")
-}
| 25.121495
| 74
| 0.624256
|
ada23fc138c1e66f317da46a6851e454c23a2e5e
| 2,628
|
agda
|
Agda
|
unused/Membership-old.agda
|
Zalastax/thesis
|
ae541df13d069df4eb1464f29fbaa9804aad439f
|
[
"MIT"
] | 1
|
2018-02-02T16:44:43.000Z
|
2018-02-02T16:44:43.000Z
|
unused/Membership-old.agda
|
Zalastax/thesis
|
ae541df13d069df4eb1464f29fbaa9804aad439f
|
[
"MIT"
] | null | null | null |
unused/Membership-old.agda
|
Zalastax/thesis
|
ae541df13d069df4eb1464f29fbaa9804aad439f
|
[
"MIT"
] | null | null | null |
------------------------------------------------------------------------
-- List membership and some related definitions
open import Level using (Level; _⊔_)
open import Relation.Binary
open import Relation.Binary.List.Pointwise as ListEq using ([]; _∷_)
open import Relation.Nullary
open import Data.List
open import Data.List.Any
open import Function
import Relation.Binary.InducedPreorders as Ind
open import Data.Product as Prod using (∃; _×_; _,_)
module Membership-old {c ℓ : Level} (S : Setoid c ℓ) where
private
open module S = Setoid S using (_≈_) renaming (Carrier to A)
open module LS = Setoid (ListEq.setoid S)
using () renaming (_≈_ to _≋_)
-- If a predicate P respects the underlying equality then Any P
-- respects the list equality.
lift-resp : ∀ {p} {P : A → Set p} →
P Respects _≈_ → Any P Respects _≋_
lift-resp resp [] ()
lift-resp resp (x≈y ∷ xs≈ys) (here px) = here (resp x≈y px)
lift-resp resp (x≈y ∷ xs≈ys) (there pxs) =
there (lift-resp resp xs≈ys pxs)
-- List membership.
infix 4 _∈_ _∉_
_∈_ : A → List A → Set _
x ∈ xs = Any (_≈_ x) xs
_∉_ : A → List A → Set _
x ∉ xs = ¬ x ∈ xs
-- Subsets.
infix 4 _⊆_ _⊈_
_⊆_ : List A → List A → Set _
xs ⊆ ys = ∀ {x} → x ∈ xs → x ∈ ys
_⊈_ : List A → List A → Set _
xs ⊈ ys = ¬ xs ⊆ ys
-- Equality is respected by the predicate which is used to define
-- _∈_.
∈-resp-≈ : ∀ {x} → (_≈_ x) Respects _≈_
∈-resp-≈ = flip S.trans
-- List equality is respected by _∈_.
∈-resp-list-≈ : ∀ {x} → _∈_ x Respects _≋_
∈-resp-list-≈ = lift-resp ∈-resp-≈
-- _⊆_ is a preorder.
⊆-preorder : Preorder _ _ _
⊆-preorder = Ind.InducedPreorder₂ (ListEq.setoid S) _∈_ ∈-resp-list-≈
module ⊆-Reasoning where
import Relation.Binary.PreorderReasoning as PreR
open PreR ⊆-preorder public
renaming (_∼⟨_⟩_ to _⊆⟨_⟩_)
infix 1 _∈⟨_⟩_
_∈⟨_⟩_ : ∀ x {xs ys} → x ∈ xs → xs IsRelatedTo ys → x ∈ ys
x ∈⟨ x∈xs ⟩ xs⊆ys = (begin xs⊆ys) x∈xs
-- A variant of List.map.
map-with-∈ : ∀ {b} {B : Set b}
(xs : List A) → (∀ {x} → x ∈ xs → B) → List B
map-with-∈ [] f = []
map-with-∈ (x ∷ xs) f = f (here S.refl) ∷ map-with-∈ xs (f ∘ there)
-- Finds an element satisfying the predicate.
find : ∀ {p} {P : A → Set p} {xs} →
Any P xs → ∃ λ x → x ∈ xs × P x
find (here px) = (_ , here S.refl , px)
find (there pxs) = Prod.map id (Prod.map there id) (find pxs)
lose : ∀ {p} {P : A → Set p} {x xs} →
P Respects _≈_ → x ∈ xs → P x → Any P xs
lose resp x∈xs px = Data.List.Any.map (flip resp px) x∈xs
| 28.565217
| 72
| 0.560883
|
2ff8a5d17995a697e9cfc6cdf4b1f0877a4371bc
| 1,882
|
agda
|
Agda
|
src/is-lib/InfSys/SCoinduction.agda
|
boystrange/FairSubtypingAgda
|
c4b78e70c3caf68d509f4360b9171d9f80ecb825
|
[
"MIT"
] | 4
|
2021-07-29T14:32:30.000Z
|
2022-01-24T14:38:47.000Z
|
src/is-lib/InfSys/SCoinduction.agda
|
boystrange/FairSubtypingAgda
|
c4b78e70c3caf68d509f4360b9171d9f80ecb825
|
[
"MIT"
] | null | null | null |
src/is-lib/InfSys/SCoinduction.agda
|
boystrange/FairSubtypingAgda
|
c4b78e70c3caf68d509f4360b9171d9f80ecb825
|
[
"MIT"
] | null | null | null |
--------------------------------------------------------------------------------
-- This is part of Agda Inference Systems
{-# OPTIONS --sized-types #-}
open import Agda.Builtin.Equality
open import Data.Product
open import Size
open import Codata.Thunk
open import Level
open import Relation.Unary using (_⊆_)
module is-lib.InfSys.SCoinduction {𝓁} where
private
variable
U : Set 𝓁
open import is-lib.InfSys.Base {𝓁}
open import is-lib.InfSys.Induction {𝓁}
open MetaRule
open IS
{- Coinductive interpretation -}
data SCoInd⟦_⟧ {𝓁c 𝓁p 𝓁n : Level} (is : IS {𝓁c} {𝓁p} {𝓁n} U) : U → Size → Set (𝓁 ⊔ 𝓁c ⊔ 𝓁p ⊔ 𝓁n) where
sfold : ∀{u i} → ISF[ is ] (λ u → Thunk (SCoInd⟦ is ⟧ u) i) u → SCoInd⟦ is ⟧ u i
{- Coinduction Principle -}
scoind[_] : ∀{𝓁c 𝓁p 𝓁n 𝓁'}
→ (is : IS {𝓁c} {𝓁p} {𝓁n} U)
→ (S : U → Set 𝓁')
→ S ⊆ ISF[ is ] S -- S is consistent
→ S ⊆ λ u → ∀{i} → SCoInd⟦ is ⟧ u i
scoind[ is ] S cn Su with cn Su
... | rn , c , refl , pr = sfold (rn , c , refl , λ i → λ where .force → scoind[ is ] S cn (pr i))
{- Apply Rule -}
apply-scoind : ∀{𝓁c 𝓁p 𝓁n}{is : IS {𝓁c} {𝓁p} {𝓁n} U} → (rn : is .Names) → RClosed (is .rules rn) (λ u → ∀{i} → SCoInd⟦ is ⟧ u i)
apply-scoind {is = is} rn =
prefix⇒closed (is .rules rn) {P = λ u → ∀{i} → SCoInd⟦ is ⟧ u i } λ{(c , refl , pr) → sfold (rn , c , refl , λ i → λ where .force → pr i)}
{- Postfix - Prefix -}
scoind-postfix : ∀{𝓁c 𝓁p 𝓁n}{is : IS {𝓁c} {𝓁p} {𝓁n} U} → (λ u → ∀{i} → SCoInd⟦ is ⟧ u i) ⊆ ISF[ is ] (λ u → ∀{i} → SCoInd⟦ is ⟧ u i)
scoind-postfix p-scoind with p-scoind
... | sfold (rn , c , refl , pr) = rn , c , refl , λ i → (pr i) .force
scoind-prefix : ∀{𝓁c 𝓁p 𝓁n}{is : IS {𝓁c} {𝓁p} {𝓁n} U} → ISF[ is ] (λ u → ∀{i} → SCoInd⟦ is ⟧ u i) ⊆ λ u → ∀{i} → SCoInd⟦ is ⟧ u i
scoind-prefix (rn , c , refl , pr) = apply-scoind rn c pr
| 36.192308
| 142
| 0.519129
|
341fca72bd3662cc60cd77d143ddcb67c48ba7eb
| 21,877
|
agda
|
Agda
|
Cubical/Algebra/ZariskiLattice/Base.agda
|
FernandoLarrain/cubical
|
9acdecfa6437ec455568be4e5ff04849cc2bc13b
|
[
"MIT"
] | 1
|
2022-03-05T00:28:39.000Z
|
2022-03-05T00:28:39.000Z
|
Cubical/Algebra/ZariskiLattice/Base.agda
|
FernandoLarrain/cubical
|
9acdecfa6437ec455568be4e5ff04849cc2bc13b
|
[
"MIT"
] | null | null | null |
Cubical/Algebra/ZariskiLattice/Base.agda
|
FernandoLarrain/cubical
|
9acdecfa6437ec455568be4e5ff04849cc2bc13b
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --safe --experimental-lossy-unification #-}
module Cubical.Algebra.ZariskiLattice.Base where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Function
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.Isomorphism
open import Cubical.Foundations.Univalence
open import Cubical.Foundations.HLevels
open import Cubical.Foundations.Transport
open import Cubical.Foundations.Powerset using (ℙ ; ⊆-refl-consequence)
renaming (_∈_ to _∈ₚ_ ; subst-∈ to subst-∈ₚ)
import Cubical.Data.Empty as ⊥
open import Cubical.Data.Bool
open import Cubical.Data.Nat renaming ( _+_ to _+ℕ_ ; _·_ to _·ℕ_
; +-comm to +ℕ-comm ; +-assoc to +ℕ-assoc
; ·-assoc to ·ℕ-assoc ; ·-comm to ·ℕ-comm
; ·-identityʳ to ·ℕ-rid)
open import Cubical.Data.Sigma.Base
open import Cubical.Data.Sigma.Properties
open import Cubical.Data.FinData
open import Cubical.Relation.Nullary
open import Cubical.Relation.Binary
open import Cubical.Relation.Binary.Poset
open import Cubical.Algebra.Ring
open import Cubical.Algebra.Ring.Properties
open import Cubical.Algebra.Ring.BigOps
open import Cubical.Algebra.Algebra
open import Cubical.Algebra.CommRing
open import Cubical.Algebra.CommRing.BinomialThm
open import Cubical.Algebra.CommRing.Ideal
open import Cubical.Algebra.CommRing.FGIdeal
open import Cubical.Algebra.CommRing.RadicalIdeal
open import Cubical.Algebra.CommRing.Localisation.Base
open import Cubical.Algebra.CommRing.Localisation.UniversalProperty
open import Cubical.Algebra.CommRing.Localisation.InvertingElements
open import Cubical.Algebra.CommAlgebra.Base
open import Cubical.Algebra.CommAlgebra.Properties
open import Cubical.Algebra.CommAlgebra.Localisation
open import Cubical.Algebra.RingSolver.Reflection
open import Cubical.Algebra.Semilattice
open import Cubical.Algebra.Lattice
open import Cubical.Algebra.DistLattice
open import Cubical.Algebra.DistLattice.Basis
open import Cubical.Algebra.DistLattice.BigOps
open import Cubical.Algebra.Matrix
open import Cubical.Categories.Category.Base hiding (_[_,_])
open import Cubical.Categories.Functor
open import Cubical.Categories.Instances.CommAlgebras
open import Cubical.Categories.Instances.DistLattice
open import Cubical.Categories.Instances.Semilattice
open import Cubical.HITs.SetQuotients as SQ
open import Cubical.HITs.PropositionalTruncation as PT
open Iso
open BinaryRelation
open isEquivRel
private
variable
ℓ ℓ' : Level
module ZarLat (R' : CommRing ℓ) where
open CommRingStr (snd R')
open RingTheory (CommRing→Ring R')
open Sum (CommRing→Ring R')
open CommRingTheory R'
open Exponentiation R'
open BinomialThm R'
open CommIdeal R'
open RadicalIdeal R'
open isCommIdeal
open ProdFin R'
private
R = fst R'
A = Σ[ n ∈ ℕ ] (FinVec R n)
⟨_⟩ : {n : ℕ} → FinVec R n → CommIdeal
⟨ V ⟩ = ⟨ V ⟩[ R' ]
_∼_ : A → A → Type (ℓ-suc ℓ)
(_ , α) ∼ (_ , β) = √ ⟨ α ⟩ ≡ √ ⟨ β ⟩
∼EquivRel : isEquivRel (_∼_)
reflexive ∼EquivRel _ = refl
symmetric ∼EquivRel _ _ = sym
transitive ∼EquivRel _ _ _ = _∙_
ZL : Type (ℓ-suc ℓ)
ZL = A / _∼_
0z : ZL
0z = [ 0 , (λ ()) ]
1z : ZL
1z = [ 1 , (replicateFinVec 1 1r) ]
_∨z_ : ZL → ZL → ZL
_∨z_ = setQuotSymmBinOp (reflexive ∼EquivRel) (transitive ∼EquivRel)
(λ (_ , α) (_ , β) → (_ , α ++Fin β))
(λ (_ , α) (_ , β) → cong √ (FGIdealAddLemma _ α β ∙∙ +iComm _ _ ∙∙ sym (FGIdealAddLemma _ β α)))
λ (_ , α) (_ , β) (_ , γ) α∼β → --need to show α∨γ ∼ β∨γ
√ ⟨ α ++Fin γ ⟩ ≡⟨ cong √ (FGIdealAddLemma _ α γ) ⟩
√ (⟨ α ⟩ +i ⟨ γ ⟩) ≡⟨ sym (√+LContr _ _) ⟩
√ (√ ⟨ α ⟩ +i ⟨ γ ⟩) ≡⟨ cong (λ I → √ (I +i ⟨ γ ⟩)) α∼β ⟩
√ (√ ⟨ β ⟩ +i ⟨ γ ⟩) ≡⟨ √+LContr _ _ ⟩
√ (⟨ β ⟩ +i ⟨ γ ⟩) ≡⟨ cong √ (sym (FGIdealAddLemma _ β γ)) ⟩
√ ⟨ β ++Fin γ ⟩ ∎
_∧z_ : ZL → ZL → ZL
_∧z_ = setQuotSymmBinOp (reflexive ∼EquivRel) (transitive ∼EquivRel)
(λ (_ , α) (_ , β) → (_ , α ··Fin β))
(λ (_ , α) (_ , β) → cong √ (FGIdealMultLemma _ α β ∙∙ ·iComm _ _ ∙∙ sym (FGIdealMultLemma _ β α)))
λ (_ , α) (_ , β) (_ , γ) α∼β → --need to show α∧γ ∼ β∧γ
√ ⟨ α ··Fin γ ⟩ ≡⟨ cong √ (FGIdealMultLemma _ α γ) ⟩
√ (⟨ α ⟩ ·i ⟨ γ ⟩) ≡⟨ sym (√·LContr _ _) ⟩
√ (√ ⟨ α ⟩ ·i ⟨ γ ⟩) ≡⟨ cong (λ I → √ (I ·i ⟨ γ ⟩)) α∼β ⟩
√ (√ ⟨ β ⟩ ·i ⟨ γ ⟩) ≡⟨ √·LContr _ _ ⟩
√ (⟨ β ⟩ ·i ⟨ γ ⟩) ≡⟨ cong √ (sym (FGIdealMultLemma _ β γ)) ⟩
√ ⟨ β ··Fin γ ⟩ ∎
-- join axioms
∨zAssoc : ∀ (𝔞 𝔟 𝔠 : ZL) → 𝔞 ∨z (𝔟 ∨z 𝔠) ≡ (𝔞 ∨z 𝔟) ∨z 𝔠
∨zAssoc = SQ.elimProp3 (λ _ _ _ → squash/ _ _)
λ (_ , α) (_ , β) (_ , γ) → eq/ _ _ (cong √ (IdealAddAssoc _ _ _ _))
∨zComm : ∀ (𝔞 𝔟 : ZL) → 𝔞 ∨z 𝔟 ≡ 𝔟 ∨z 𝔞
∨zComm = SQ.elimProp2 (λ _ _ → squash/ _ _)
λ (_ , α) (_ , β) → eq/ _ _
(cong √ (FGIdealAddLemma _ α β ∙∙ +iComm _ _ ∙∙ sym (FGIdealAddLemma _ β α)))
∨zLid : ∀ (𝔞 : ZL) → 0z ∨z 𝔞 ≡ 𝔞
∨zLid = SQ.elimProp (λ _ → squash/ _ _) λ _ → eq/ _ _ refl
∨zRid : ∀ (𝔞 : ZL) → 𝔞 ∨z 0z ≡ 𝔞
∨zRid _ = ∨zComm _ _ ∙ ∨zLid _
-- -- meet axioms
∧zAssoc : ∀ (𝔞 𝔟 𝔠 : ZL) → 𝔞 ∧z (𝔟 ∧z 𝔠) ≡ (𝔞 ∧z 𝔟) ∧z 𝔠
∧zAssoc = SQ.elimProp3 (λ _ _ _ → squash/ _ _)
λ (_ , α) (_ , β) (_ , γ) → eq/ _ _
(√ ⟨ α ··Fin (β ··Fin γ) ⟩ ≡⟨ cong √ (FGIdealMultLemma _ _ _) ⟩
√ (⟨ α ⟩ ·i ⟨ β ··Fin γ ⟩) ≡⟨ cong (λ x → √ (⟨ α ⟩ ·i x)) (FGIdealMultLemma _ _ _) ⟩
√ (⟨ α ⟩ ·i (⟨ β ⟩ ·i ⟨ γ ⟩)) ≡⟨ cong √ (·iAssoc _ _ _) ⟩
√ ((⟨ α ⟩ ·i ⟨ β ⟩) ·i ⟨ γ ⟩) ≡⟨ cong (λ x → √ (x ·i ⟨ γ ⟩)) (sym (FGIdealMultLemma _ _ _)) ⟩
√ (⟨ α ··Fin β ⟩ ·i ⟨ γ ⟩) ≡⟨ cong √ (sym (FGIdealMultLemma _ _ _)) ⟩
√ ⟨ (α ··Fin β) ··Fin γ ⟩ ∎)
∧zComm : ∀ (𝔞 𝔟 : ZL) → 𝔞 ∧z 𝔟 ≡ 𝔟 ∧z 𝔞
∧zComm = SQ.elimProp2 (λ _ _ → squash/ _ _)
λ (_ , α) (_ , β) → eq/ _ _
(cong √ (FGIdealMultLemma _ α β ∙∙ ·iComm _ _ ∙∙ sym (FGIdealMultLemma _ β α)))
∧zRid : ∀ (𝔞 : ZL) → 𝔞 ∧z 1z ≡ 𝔞
∧zRid = SQ.elimProp (λ _ → squash/ _ _)
λ (_ , α) → eq/ _ _ (cong √
(⟨ α ··Fin (replicateFinVec 1 1r) ⟩ ≡⟨ FGIdealMultLemma _ _ _ ⟩
⟨ α ⟩ ·i ⟨ (replicateFinVec 1 1r) ⟩ ≡⟨ cong (⟨ α ⟩ ·i_) (contains1Is1 _ (indInIdeal _ _ zero)) ⟩
⟨ α ⟩ ·i 1Ideal ≡⟨ ·iRid _ ⟩
⟨ α ⟩ ∎))
-- absorption and distributivity
∧zAbsorb∨z : ∀ (𝔞 𝔟 : ZL) → 𝔞 ∧z (𝔞 ∨z 𝔟) ≡ 𝔞
∧zAbsorb∨z = SQ.elimProp2 (λ _ _ → squash/ _ _)
λ (_ , α) (_ , β) → eq/ _ _
(√ ⟨ α ··Fin (α ++Fin β) ⟩ ≡⟨ cong √ (FGIdealMultLemma _ α (α ++Fin β)) ⟩
√ (⟨ α ⟩ ·i ⟨ α ++Fin β ⟩) ≡⟨ cong (λ x → √ (⟨ α ⟩ ·i x)) (FGIdealAddLemma _ α β) ⟩
√ (⟨ α ⟩ ·i (⟨ α ⟩ +i ⟨ β ⟩)) ≡⟨ √·Absorb+ _ _ ⟩
√ ⟨ α ⟩ ∎)
∧zLDist∨z : ∀ (𝔞 𝔟 𝔠 : ZL) → 𝔞 ∧z (𝔟 ∨z 𝔠) ≡ (𝔞 ∧z 𝔟) ∨z (𝔞 ∧z 𝔠)
∧zLDist∨z = SQ.elimProp3 (λ _ _ _ → squash/ _ _)
λ (_ , α) (_ , β) (_ , γ) → eq/ _ _
(√ ⟨ α ··Fin (β ++Fin γ) ⟩ ≡⟨ cong √ (FGIdealMultLemma _ _ _) ⟩
√ (⟨ α ⟩ ·i ⟨ β ++Fin γ ⟩) ≡⟨ cong (λ x → √ (⟨ α ⟩ ·i x)) (FGIdealAddLemma _ _ _) ⟩
√ (⟨ α ⟩ ·i (⟨ β ⟩ +i ⟨ γ ⟩)) ≡⟨ cong √ (·iRdist+i _ _ _) ⟩
-- L/R-dist are swapped
-- in Lattices vs Rings
√ (⟨ α ⟩ ·i ⟨ β ⟩ +i ⟨ α ⟩ ·i ⟨ γ ⟩) ≡⟨ cong₂ (λ x y → √ (x +i y))
(sym (FGIdealMultLemma _ _ _))
(sym (FGIdealMultLemma _ _ _)) ⟩
√ (⟨ α ··Fin β ⟩ +i ⟨ α ··Fin γ ⟩) ≡⟨ cong √ (sym (FGIdealAddLemma _ _ _)) ⟩
√ ⟨ (α ··Fin β) ++Fin (α ··Fin γ) ⟩ ∎)
ZariskiLattice : DistLattice (ℓ-suc ℓ)
fst ZariskiLattice = ZL
DistLatticeStr.0l (snd ZariskiLattice) = 0z
DistLatticeStr.1l (snd ZariskiLattice) = 1z
DistLatticeStr._∨l_ (snd ZariskiLattice) = _∨z_
DistLatticeStr._∧l_ (snd ZariskiLattice) = _∧z_
DistLatticeStr.isDistLattice (snd ZariskiLattice) =
makeIsDistLattice∧lOver∨l squash/ ∨zAssoc ∨zRid ∨zComm
∧zAssoc ∧zRid ∧zComm ∧zAbsorb∨z ∧zLDist∨z
module _ (R' : CommRing ℓ) (L' : DistLattice ℓ') where
open CommRingStr (R' .snd)
open RingTheory (CommRing→Ring R')
open Sum (CommRing→Ring R')
open CommRingTheory R'
open Exponentiation R'
open DistLatticeStr (L' .snd) renaming (is-set to isSetL)
open Join L'
open LatticeTheory (DistLattice→Lattice L')
open Order (DistLattice→Lattice L')
open JoinSemilattice (Lattice→JoinSemilattice (DistLattice→Lattice L'))
open PosetReasoning IndPoset
open PosetStr (IndPoset .snd) hiding (_≤_)
private
R = fst R'
L = fst L'
record IsZarMap (d : R → L) : Type (ℓ-max ℓ ℓ') where
constructor iszarmap
field
pres0 : d 0r ≡ 0l
pres1 : d 1r ≡ 1l
·≡∧ : ∀ x y → d (x · y) ≡ d x ∧l d y
+≤∨ : ∀ x y → d (x + y) ≤ d x ∨l d y
∑≤⋁ : {n : ℕ} (U : FinVec R n) → d (∑ U) ≤ ⋁ λ i → d (U i)
∑≤⋁ {n = zero} U = ∨lRid _ ∙ pres0
∑≤⋁ {n = suc n} U = d (∑ U) ≤⟨ ∨lIdem _ ⟩
d (U zero + ∑ (U ∘ suc)) ≤⟨ +≤∨ _ _ ⟩
d (U zero) ∨l d (∑ (U ∘ suc)) ≤⟨ ≤-∨LPres _ _ _ (∑≤⋁ (U ∘ suc)) ⟩
d (U zero) ∨l ⋁ (d ∘ U ∘ suc) ≤⟨ ∨lIdem _ ⟩
⋁ (d ∘ U) ◾
d·LCancel : ∀ x y → d (x · y) ≤ d y
d·LCancel x y = subst (λ a → a ≤ d y) (sym (·≡∧ x y)) (∧≤LCancelJoin _ _)
linearCombination≤LCancel : {n : ℕ} (α β : FinVec R n)
→ d (linearCombination R' α β) ≤ ⋁ (d ∘ β)
linearCombination≤LCancel α β = is-trans _ _ _ (∑≤⋁ (λ i → α i · β i))
(≤-⋁Ext _ _ λ i → d·LCancel (α i) (β i))
ZarMapIdem : ∀ (n : ℕ) (x : R) → d (x ^ (suc n)) ≡ d x
ZarMapIdem zero x = ·≡∧ _ _ ∙∙ cong (d x ∧l_) pres1 ∙∙ ∧lRid _
ZarMapIdem (suc n) x = ·≡∧ _ _ ∙∙ cong (d x ∧l_) (ZarMapIdem n x) ∙∙ ∧lIdem _
ZarMapExpIneq : ∀ (n : ℕ) (x : R) → d x ≤ d (x ^ n)
ZarMapExpIneq zero x = cong (d x ∨l_) pres1 ∙∙ 1lRightAnnihilates∨l _ ∙∙ sym pres1
ZarMapExpIneq (suc n) x = subst (λ y → d x ≤ y) (sym (ZarMapIdem _ x)) (∨lIdem _)
-- the crucial lemma about "Zariski maps"
open CommIdeal R'
open RadicalIdeal R'
open isCommIdeal
private
⟨_⟩ : {n : ℕ} → FinVec R n → CommIdeal
⟨ V ⟩ = ⟨ V ⟩[ R' ]
ZarMapRadicalIneq : ∀ {n : ℕ} (α : FinVec R n) (x : R)
→ x ∈ √ ⟨ α ⟩ → d x ≤ ⋁ (d ∘ α)
ZarMapRadicalIneq α x = PT.elim (λ _ → isSetL _ _)
(uncurry (λ n → (PT.elim (λ _ → isSetL _ _) (uncurry (curriedHelper n)))))
where
curriedHelper : (n : ℕ) (β : FinVec R _)
→ x ^ n ≡ linearCombination R' β α → d x ≤ ⋁ (d ∘ α)
curriedHelper n β xⁿ≡∑βα = d x ≤⟨ ZarMapExpIneq n x ⟩
d (x ^ n)
≤⟨ subst (λ y → y ≤ ⋁ (d ∘ α)) (sym (cong d xⁿ≡∑βα)) (linearCombination≤LCancel β α) ⟩
⋁ (d ∘ α) ◾
module ZarLatUniversalProp (R' : CommRing ℓ) where
open CommRingStr (snd R')
open RingTheory (CommRing→Ring R')
open Sum (CommRing→Ring R')
open CommRingTheory R'
open Exponentiation R'
open BinomialThm R'
open CommIdeal R'
open RadicalIdeal R'
open isCommIdeal
open ProdFin R'
open ZarLat R'
open IsZarMap
private
R = fst R'
⟨_⟩ : {n : ℕ} → FinVec R n → CommIdeal
⟨ V ⟩ = ⟨ V ⟩[ R' ]
D : R → ZL
D x = [ 1 , replicateFinVec 1 x ] -- λ x → √⟨x⟩
isZarMapD : IsZarMap R' ZariskiLattice D
pres0 isZarMapD = eq/ _ _ (cong √ (0FGIdeal _ ∙ sym (emptyFGIdeal _ _)))
pres1 isZarMapD = refl
·≡∧ isZarMapD x y = cong {B = λ _ → ZL} (λ U → [ 1 , U ]) (Length1··Fin x y)
+≤∨ isZarMapD x y = eq/ _ _ (cong √ (CommIdeal≡Char (inclOfFGIdeal _ 3Vec ⟨ 2Vec ⟩ 3Vec⊆2Vec)
(inclOfFGIdeal _ 2Vec ⟨ 3Vec ⟩ 2Vec⊆3Vec)))
where
2Vec = replicateFinVec 1 x ++Fin replicateFinVec 1 y
3Vec = replicateFinVec 1 (x + y) ++Fin (replicateFinVec 1 x ++Fin replicateFinVec 1 y)
3Vec⊆2Vec : ∀ (i : Fin 3) → 3Vec i ∈ ⟨ 2Vec ⟩
3Vec⊆2Vec zero = ⟨ 2Vec ⟩ .snd .+Closed (indInIdeal _ _ zero) (indInIdeal _ _ (suc zero))
3Vec⊆2Vec (suc zero) = indInIdeal _ _ zero
3Vec⊆2Vec (suc (suc zero)) = indInIdeal _ _ (suc zero)
2Vec⊆3Vec : ∀ (i : Fin 2) → 2Vec i ∈ ⟨ 3Vec ⟩
2Vec⊆3Vec zero = indInIdeal _ _ (suc zero)
2Vec⊆3Vec (suc zero) = indInIdeal _ _ (suc (suc zero))
-- defintion of the universal property
hasZarLatUniversalProp : (L : DistLattice ℓ') (D : R → fst L)
→ IsZarMap R' L D
→ Type _
hasZarLatUniversalProp {ℓ' = ℓ'} L D _ = ∀ (L' : DistLattice ℓ') (d : R → fst L')
→ IsZarMap R' L' d
→ ∃![ χ ∈ DistLatticeHom L L' ] (fst χ) ∘ D ≡ d
isPropZarLatUniversalProp : (L : DistLattice ℓ') (D : R → fst L) (isZarMapD : IsZarMap R' L D)
→ isProp (hasZarLatUniversalProp L D isZarMapD)
isPropZarLatUniversalProp L D isZarMapD = isPropΠ3 (λ _ _ _ → isPropIsContr)
ZLHasUniversalProp : hasZarLatUniversalProp ZariskiLattice D isZarMapD
ZLHasUniversalProp L' d isZarMapd = (χ , funExt χcomp) , χunique
where
open DistLatticeStr (snd L') renaming (is-set to isSetL)
open LatticeTheory (DistLattice→Lattice L')
open Join L'
open IsLatticeHom
L = fst L'
χ : DistLatticeHom ZariskiLattice L'
fst χ = SQ.rec isSetL (λ (_ , α) → ⋁ (d ∘ α))
λ (_ , α) (_ , β) → curriedHelper α β
where
curriedHelper : {n m : ℕ} (α : FinVec R n) (β : FinVec R m)
→ √ ⟨ α ⟩ ≡ √ ⟨ β ⟩ → ⋁ (d ∘ α) ≡ ⋁ (d ∘ β)
curriedHelper α β √⟨α⟩≡√⟨β⟩ = is-antisym _ _ ineq1 ineq2
where
open Order (DistLattice→Lattice L')
open JoinSemilattice (Lattice→JoinSemilattice (DistLattice→Lattice L'))
open PosetReasoning IndPoset
open PosetStr (IndPoset .snd) hiding (_≤_)
incl1 : √ ⟨ α ⟩ ⊆ √ ⟨ β ⟩
incl1 = ⊆-refl-consequence _ _ (cong fst √⟨α⟩≡√⟨β⟩) .fst
ineq1 : ⋁ (d ∘ α) ≤ ⋁ (d ∘ β)
ineq1 = ⋁IsMax (d ∘ α) (⋁ (d ∘ β))
λ i → ZarMapRadicalIneq isZarMapd β (α i) (√FGIdealCharLImpl α ⟨ β ⟩ incl1 i)
incl2 : √ ⟨ β ⟩ ⊆ √ ⟨ α ⟩
incl2 = ⊆-refl-consequence _ _ (cong fst √⟨α⟩≡√⟨β⟩) .snd
ineq2 : ⋁ (d ∘ β) ≤ ⋁ (d ∘ α)
ineq2 = ⋁IsMax (d ∘ β) (⋁ (d ∘ α))
λ i → ZarMapRadicalIneq isZarMapd α (β i) (√FGIdealCharLImpl β ⟨ α ⟩ incl2 i)
pres0 (snd χ) = refl
pres1 (snd χ) = ∨lRid _ ∙ isZarMapd .pres1
pres∨l (snd χ) = elimProp2 (λ _ _ → isSetL _ _) (uncurry (λ n α → uncurry (curriedHelper n α)))
where
curriedHelper : (n : ℕ) (α : FinVec R n) (m : ℕ) (β : FinVec R m)
→ ⋁ (d ∘ (α ++Fin β)) ≡ ⋁ (d ∘ α) ∨l ⋁ (d ∘ β)
curriedHelper zero α _ β = sym (∨lLid _)
curriedHelper (suc n) α _ β =
⋁ (d ∘ (α ++Fin β)) ≡⟨ refl ⟩
d (α zero) ∨l ⋁ (d ∘ ((α ∘ suc) ++Fin β))
≡⟨ cong (d (α zero) ∨l_) (curriedHelper _ (α ∘ suc) _ β) ⟩
d (α zero) ∨l (⋁ (d ∘ α ∘ suc) ∨l ⋁ (d ∘ β))
≡⟨ ∨lAssoc _ _ _ ⟩
⋁ (d ∘ α) ∨l ⋁ (d ∘ β) ∎
pres∧l (snd χ) = elimProp2 (λ _ _ → isSetL _ _) (uncurry (λ n α → uncurry (curriedHelper n α)))
where
-- have to repeat this one here so the termination checker won't complain
oldHelper : (n : ℕ) (α : FinVec R n) (m : ℕ) (β : FinVec R m)
→ ⋁ (d ∘ (α ++Fin β)) ≡ ⋁ (d ∘ α) ∨l ⋁ (d ∘ β)
oldHelper zero α _ β = sym (∨lLid _)
oldHelper (suc n) α _ β = cong (d (α zero) ∨l_) (oldHelper _ (α ∘ suc) _ β) ∙ ∨lAssoc _ _ _
curriedHelper : (n : ℕ) (α : FinVec R n) (m : ℕ) (β : FinVec R m)
→ ⋁ (d ∘ (α ··Fin β)) ≡ ⋁ (d ∘ α) ∧l ⋁ (d ∘ β)
curriedHelper zero α _ β = sym (0lLeftAnnihilates∧l _)
curriedHelper (suc n) α _ β =
⋁ (d ∘ (α ··Fin β)) ≡⟨ refl ⟩
⋁ (d ∘ ((λ j → α zero · β j) ++Fin ((α ∘ suc) ··Fin β)))
≡⟨ oldHelper _ (λ j → α zero · β j) _ ((α ∘ suc) ··Fin β) ⟩
⋁ (d ∘ (λ j → α zero · β j)) ∨l ⋁ (d ∘ ((α ∘ suc) ··Fin β))
≡⟨ cong (_∨l ⋁ (d ∘ ((α ∘ suc) ··Fin β))) (⋁Ext (λ j → isZarMapd .·≡∧ (α zero) (β j))) ⟩
⋁ (λ j → d (α zero) ∧l d (β j)) ∨l ⋁ (d ∘ ((α ∘ suc) ··Fin β))
≡⟨ cong (_∨l ⋁ (d ∘ ((α ∘ suc) ··Fin β))) (sym (⋁Meetrdist _ _)) ⟩
(d (α zero) ∧l ⋁ (d ∘ β)) ∨l ⋁ (d ∘ ((α ∘ suc) ··Fin β))
≡⟨ cong ((d (α zero) ∧l ⋁ (d ∘ β)) ∨l_) (curriedHelper _ (α ∘ suc) _ β) ⟩
(d (α zero) ∧l ⋁ (d ∘ β)) ∨l (⋁ (d ∘ α ∘ suc) ∧l ⋁ (d ∘ β))
≡⟨ sym (∧lRdist∨l _ _ _) ⟩
⋁ (d ∘ α) ∧l ⋁ (d ∘ β) ∎
χcomp : ∀ (f : R) → χ .fst (D f) ≡ d f
χcomp f = ∨lRid (d f)
χunique : (y : Σ[ χ' ∈ DistLatticeHom ZariskiLattice L' ] fst χ' ∘ D ≡ d)
→ (χ , funExt χcomp) ≡ y
χunique (χ' , χ'∘D≡d) = Σ≡Prop (λ _ → isSetΠ (λ _ → isSetL) _ _) (LatticeHom≡f _ _
(funExt (elimProp (λ _ → isSetL _ _) (uncurry uniqHelper))))
where
uniqHelper : (n : ℕ) (α : FinVec R n) → fst χ [ n , α ] ≡ fst χ' [ n , α ]
uniqHelper zero _ = sym (cong (λ α → fst χ' [ 0 , α ]) (funExt (λ ())) ∙ χ' .snd .pres0)
uniqHelper (suc n) α =
⋁ (d ∘ α) ≡⟨ refl ⟩
d (α zero) ∨l ⋁ (d ∘ α ∘ suc)
≡⟨ cong (d (α zero) ∨l_) (uniqHelper n (α ∘ suc)) ⟩ -- the inductive step
d (α zero) ∨l fst χ' [ n , α ∘ suc ]
≡⟨ cong (_∨l fst χ' [ n , α ∘ suc ]) (sym (funExt⁻ χ'∘D≡d (α zero))) ⟩
fst χ' (D (α zero)) ∨l fst χ' [ n , α ∘ suc ]
≡⟨ sym (χ' .snd .pres∨l _ _) ⟩
fst χ' (D (α zero) ∨z [ n , α ∘ suc ])
≡⟨ cong (λ β → fst χ' [ suc n , β ]) (funExt (λ { zero → refl ; (suc i) → refl })) ⟩
fst χ' [ suc n , α ] ∎
-- the map induced by applying the universal property to the Zariski lattice
-- itself is the identity hom
ZLUniversalPropCorollary : ZLHasUniversalProp ZariskiLattice D isZarMapD .fst .fst
≡ idDistLatticeHom ZariskiLattice
ZLUniversalPropCorollary = cong fst
(ZLHasUniversalProp ZariskiLattice D isZarMapD .snd
(idDistLatticeHom ZariskiLattice , refl))
-- An equivalent definition that doesn't bump up the unviverse level
module SmallZarLat (R' : CommRing ℓ) where
open CommRingStr (snd R')
open CommIdeal R'
open RadicalIdeal R'
open ZarLat R'
open Iso
private
R = fst R'
A = Σ[ n ∈ ℕ ] (FinVec R n)
⟨_⟩ : {n : ℕ} → FinVec R n → CommIdeal
⟨ V ⟩ = ⟨ V ⟩[ R' ]
-- This is small!
_≼_ : A → A → Type ℓ
(_ , α) ≼ (_ , β) = ∀ i → α i ∈ √ ⟨ β ⟩
_∼'_ : A → A → Type ℓ
α ∼' β = (α ≼ β) × (β ≼ α)
-- lives in the same universe as R
ZL' : Type ℓ
ZL' = A / (_∼'_)
IsoLarLatSmall : Iso ZL ZL'
IsoLarLatSmall = relBiimpl→TruncIso ~→∼' ~'→∼
where
~→∼' : ∀ {a b : A} → a ∼ b → a ∼' b
~→∼' r = √FGIdealCharLImpl _ ⟨ _ ⟩ (λ x h → subst (λ p → x ∈ p) r h)
, √FGIdealCharLImpl _ ⟨ _ ⟩ (λ x h → subst (λ p → x ∈ p) (sym r) h)
~'→∼ : ∀ {a b : A} → a ∼' b → a ∼ b
~'→∼ r = CommIdeal≡Char (√FGIdealCharRImpl _ ⟨ _ ⟩ (fst r))
(√FGIdealCharRImpl _ ⟨ _ ⟩ (snd r))
ZL≃ZL' : ZL ≃ ZL'
ZL≃ZL' = isoToEquiv IsoLarLatSmall
module BasicOpens (R' : CommRing ℓ) where
open CommRingStr ⦃...⦄
open RingTheory (CommRing→Ring R')
open CommIdeal R'
open isCommIdeal
open ZarLat R'
open ZarLatUniversalProp R'
open IsZarMap
open Join ZariskiLattice
open IsBasis
private
R = fst R'
instance
_ = snd R'
⟨_⟩ : {n : ℕ} → FinVec R n → CommIdeal
⟨ V ⟩ = ⟨ V ⟩[ R' ]
BasicOpens : ℙ ZL
BasicOpens 𝔞 = (∃[ f ∈ R ] (D f ≡ 𝔞)) , isPropPropTrunc
BO : Type (ℓ-suc ℓ)
BO = Σ[ 𝔞 ∈ ZL ] (𝔞 ∈ₚ BasicOpens)
basicOpensAreBasis : IsBasis ZariskiLattice BasicOpens
contains1 basicOpensAreBasis = ∣ 1r , isZarMapD .pres1 ∣
∧lClosed basicOpensAreBasis 𝔞 𝔟 = map2
λ (f , Df≡𝔞) (g , Dg≡𝔟) → (f · g) , isZarMapD .·≡∧ f g ∙ cong₂ (_∧z_) Df≡𝔞 Dg≡𝔟
⋁Basis basicOpensAreBasis = elimProp (λ _ → isPropPropTrunc) Σhelper
where
Σhelper : (a : Σ[ n ∈ ℕ ] FinVec R n)
→ ∃[ n ∈ ℕ ] Σ[ α ∈ FinVec ZL n ] (∀ i → α i ∈ₚ BasicOpens) × (⋁ α ≡ [ a ])
Σhelper (n , α) = ∣ n , (D ∘ α) , (λ i → ∣ α i , refl ∣) , path ∣
where
path : ⋁ (D ∘ α) ≡ [ n , α ]
path = funExt⁻ (cong fst ZLUniversalPropCorollary) _
-- The structure presheaf on BO
BOCat : Category (ℓ-suc ℓ) (ℓ-suc ℓ)
BOCat = ΣPropCat (DistLatticeCategory ZariskiLattice) BasicOpens
BasisStructurePShf : Functor (BOCat ^op) (CommAlgebrasCategory R')
BasisStructurePShf = universalPShf (DistLatticeCategory ZariskiLattice)
(λ 𝔞 → Σ[ f ∈ R ] (D f ≡ 𝔞)) -- the untruncated defining prop
(λ (_ , f , _) → R[1/ f ]AsCommAlgebra) -- D(f) ↦ R[1/f]
λ (𝔞 , f , p) (𝔟 , g , q) → contrHoms 𝔞 𝔟 f g p q
where
open PreSheafFromUniversalProp
open JoinSemilattice (Lattice→JoinSemilattice (DistLattice→Lattice ZariskiLattice))
open InvertingElementsBase R'
contrHoms : (𝔞 𝔟 : ZL) (f g : R) (p : D f ≡ 𝔞) (q : D g ≡ 𝔟)
→ 𝔞 ≤ 𝔟 → isContr (CommAlgebraHom R[1/ g ]AsCommAlgebra R[1/ f ]AsCommAlgebra)
contrHoms 𝔞 𝔟 f g p q 𝔞≤𝔟 = R[1/g]HasAlgUniversalProp R[1/ f ]AsCommAlgebra
λ s s∈[gⁿ|n≥0] → subst-∈ₚ (R[1/ f ]AsCommRing ˣ)
(sym (·Rid (s /1))) --can't apply the lemma directly as we get mult with 1 somewhere
(RadicalLemma.toUnit R' f g f∈√⟨g⟩ s s∈[gⁿ|n≥0])
where
open AlgLoc R' [ g ⁿ|n≥0] (powersFormMultClosedSubset g)
renaming (S⁻¹RHasAlgUniversalProp to R[1/g]HasAlgUniversalProp)
open S⁻¹RUniversalProp R' [ f ⁿ|n≥0] (powersFormMultClosedSubset f) using (_/1)
open RadicalIdeal R'
private
instance
_ = snd R[1/ f ]AsCommRing
Df≤Dg : D f ≤ D g
Df≤Dg = subst2 _≤_ (sym p) (sym q) 𝔞≤𝔟
radicalHelper : √ ⟨ replicateFinVec 1 f ++Fin replicateFinVec 1 g ⟩
≡ √ ⟨ replicateFinVec 1 g ⟩
radicalHelper =
isEquivRel→effectiveIso (λ _ _ → isSetCommIdeal _ _) ∼EquivRel _ _ .fun Df≤Dg
f∈√⟨g⟩ : f ∈ √ ⟨ replicateFinVec 1 g ⟩
f∈√⟨g⟩ = subst (f ∈_) radicalHelper (∈→∈√ _ _ (indInIdeal _ _ zero))
| 37.332765
| 102
| 0.537642
|
9a98c291144800cf917ec0a337e0def54c0b5350
| 208
|
agda
|
Agda
|
test/fail/Issue481.agda
|
masondesu/agda
|
70c8a575c46f6a568c7518150a1a64fcd03aa437
|
[
"MIT"
] | 1
|
2018-10-10T17:08:44.000Z
|
2018-10-10T17:08:44.000Z
|
test/fail/Issue481.agda
|
np/agda-git-experiment
|
20596e9dd9867166a64470dd24ea68925ff380ce
|
[
"MIT"
] | null | null | null |
test/fail/Issue481.agda
|
np/agda-git-experiment
|
20596e9dd9867166a64470dd24ea68925ff380ce
|
[
"MIT"
] | null | null | null |
-- Andreas, 2012-10-18
module Issue481 where
as = Set
open import Common.Issue481ParametrizedModule as as -- as clause
open import Common.Issue481ParametrizedModule as as as -- as clause, duplicate def.
| 18.909091
| 83
| 0.774038
|
31efed10b9830710a5d6ca0ec567ad0d8d918080
| 2,251
|
agda
|
Agda
|
Cubical/Data/SumFin/Base.agda
|
guilhermehas/cubical
|
ce3120d3f8d692847b2744162bcd7a01f0b687eb
|
[
"MIT"
] | 1
|
2021-10-31T17:32:49.000Z
|
2021-10-31T17:32:49.000Z
|
Cubical/Data/SumFin/Base.agda
|
guilhermehas/cubical
|
ce3120d3f8d692847b2744162bcd7a01f0b687eb
|
[
"MIT"
] | null | null | null |
Cubical/Data/SumFin/Base.agda
|
guilhermehas/cubical
|
ce3120d3f8d692847b2744162bcd7a01f0b687eb
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --safe #-}
module Cubical.Data.SumFin.Base where
open import Cubical.Foundations.Prelude
open import Cubical.Data.Empty as ⊥ using (⊥)
open import Cubical.Data.Unit using (tt) renaming (Unit to ⊤) public
open import Cubical.Data.Sum using (_⊎_; inl; inr) public
open import Cubical.Data.Nat hiding (elim)
open import Cubical.Relation.Nullary
open import Cubical.Relation.Nullary.DecidableEq
private
variable
ℓ : Level
k : ℕ
Fin : ℕ → Type₀
Fin zero = ⊥
Fin (suc n) = ⊤ ⊎ (Fin n)
pattern fzero = inl tt
pattern fsuc n = inr n
elim
: (P : ∀ {k} → Fin k → Type ℓ)
→ (∀ {k} → P {suc k} fzero)
→ (∀ {k} {fn : Fin k} → P fn → P (fsuc fn))
→ {k : ℕ} (fn : Fin k) → P fn
elim P fz fs {zero} f0 = ⊥.rec f0
elim P fz fs {suc k} fzero = fz
elim P fz fs {suc k} (fsuc fk) = fs (elim P fz fs fk)
finj : Fin k → Fin (suc k)
finj {suc k} fzero = fzero
finj {suc k} (fsuc n) = fsuc (finj {k} n)
flast : Fin (suc k)
flast {k = 0} = fzero
flast {k = suc k} = fsuc flast
toℕ : Fin k → ℕ
toℕ {suc k} (inl tt) = zero
toℕ {suc k} (inr x) = suc (toℕ {k} x)
toℕ-injective : {m n : Fin k} → toℕ m ≡ toℕ n → m ≡ n
toℕ-injective {suc k} {fzero} {fzero} _ = refl
toℕ-injective {suc k} {fzero} {fsuc x} p = ⊥.rec (znots p)
toℕ-injective {suc k} {fsuc m} {fzero} p = ⊥.rec (snotz p)
toℕ-injective {suc k} {fsuc m} {fsuc x} p = cong fsuc (toℕ-injective (injSuc p))
fromℕ : (n : ℕ) → Fin (suc k)
fromℕ {k = 0} _ = fzero
fromℕ {k = suc k} 0 = fzero
fromℕ {k = suc k} (suc n) = fsuc (fromℕ n)
-- Thus, Fin k is discrete
discreteFin : Discrete (Fin k)
discreteFin fj fk with discreteℕ (toℕ fj) (toℕ fk)
... | yes p = yes (toℕ-injective p)
... | no ¬p = no (λ p → ¬p (cong toℕ p))
isSetFin : isSet (Fin k)
isSetFin = Discrete→isSet discreteFin
-- Summation and multiplication
totalSum : {k : ℕ} → (f : Fin k → ℕ) → ℕ
totalSum {k = 0} _ = 0
totalSum {k = suc n} f = f (inl tt) + totalSum {k = n} (λ x → f (inr x))
totalProd : {k : ℕ} → (f : Fin k → ℕ) → ℕ
totalProd {k = 0} _ = 1
totalProd {k = suc n} f = f (inl tt) · totalProd {k = n} (λ x → f (inr x))
totalSumConst : {m : ℕ} → (n : ℕ) → totalSum {k = m} (λ _ → n) ≡ m · n
totalSumConst {m = 0} _ = refl
totalSumConst {m = suc m} n i = n + totalSumConst {m = m} n i
| 27.790123
| 80
| 0.592625
|
226e3a7416adf21e2762fda210556bbbe85c97cb
| 617
|
agda
|
Agda
|
test/Succeed/UncurryMeta.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
test/Succeed/UncurryMeta.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
test/Succeed/UncurryMeta.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
-- It would be nice if this worked. The constraint we can't solve is
-- P x y = ? (x, y)
-- Solution: extend the notion of Miller patterns to include record
-- constructions.
--
-- Andreas, 2012-02-27 works now! (see issues 376 and 456)
module UncurryMeta where
data Unit : Set where
unit : Unit
record R : Set where
constructor _,_
field
x : Unit
y : Unit
data P : Unit -> Unit -> Set where
mkP : forall x y -> P x y
data D : (R -> Set) -> Set1 where
d : {F : R -> Set} -> (forall x y -> F (x , y)) -> D F
unD : {F : R -> Set} -> D F -> Unit
unD (d _) = unit
test : Unit
test = unD (d mkP)
| 21.275862
| 68
| 0.594814
|
39f06e46238f667985dbc6014da7b7737b91e049
| 1,575
|
agda
|
Agda
|
examples/outdated-and-incorrect/Alonzo/PreludeNat.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
examples/outdated-and-incorrect/Alonzo/PreludeNat.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
examples/outdated-and-incorrect/Alonzo/PreludeNat.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
module PreludeNat where
open import AlonzoPrelude
import PreludeBool as Bool
open Bool
infix 40 _==_ _<_
infixl 60 _+_ _-_
infixl 70 _*_
infixr 80 _^_
infix 100 _!
_+_ : Nat -> Nat -> Nat
zero + m = m
suc n + m = suc (n + m)
_-_ : Nat -> Nat -> Nat
zero - m = zero
suc n - zero = suc n
suc n - suc m = n - m
_*_ : Nat -> Nat -> Nat
zero * m = zero
suc n * m = m + n * m
_^_ : Nat -> Nat -> Nat
n ^ zero = 1
n ^ suc m = n * n ^ m
_! : Nat -> Nat
zero ! = 1
suc n ! = suc n * n !
{-# BUILTIN NATPLUS _+_ #-}
{-# BUILTIN NATMINUS _-_ #-}
{-# BUILTIN NATTIMES _*_ #-}
divSuc : Nat -> Nat -> Nat
divSuc zero _ = zero
divSuc (suc n) m = 1 + divSuc (n - m) m
modSuc : Nat -> Nat -> Nat
modSuc zero _ = zero
modSuc (suc n) m = modSuc (n - m) m
{-# BUILTIN NATDIVSUC divSuc #-}
{-# BUILTIN NATMODSUC modSuc #-}
div : Nat -> Nat -> Nat
div n zero = zero
div n (suc m) = divSuc n m
mod : Nat -> Nat -> Nat
mod n zero = zero
mod n (suc m) = modSuc n m
gcd : Nat -> Nat -> Nat
gcd a 0 = a
gcd a b = gcd b (mod a b)
lcm : Nat -> Nat -> Nat
lcm a b = div (a * b) (gcd a b)
_==_ : Nat -> Nat -> Bool
zero == zero = true
zero == suc _ = false
suc _ == zero = false
suc n == suc m = n == m
_<_ : Nat -> Nat -> Bool
n < zero = false
zero < suc m = true
suc n < suc m = n < m
_≤_ : Nat -> Nat -> Bool
n ≤ m = n < suc m
_>_ = flip _<_
_≥_ = flip _≤_
even : Nat -> Bool
even n = mod n 2 == 0
odd : Nat -> Bool
odd n = mod n 2 == 1
_≡_ : Nat -> Nat -> Set
n ≡ m = IsTrue (n == m)
{-# BUILTIN NATEQUALS _==_ #-}
{-# BUILTIN NATLESS _<_ #-}
| 16.935484
| 39
| 0.533333
|
8b8e00ba2bd05b0b5d77bf2d211e873781c90e05
| 6,244
|
agda
|
Agda
|
LibraBFT/Abstract/Properties.agda
|
lisandrasilva/bft-consensus-agda-1
|
b7dd98dd90d98fbb934ef8cb4f3314940986790d
|
[
"UPL-1.0"
] | null | null | null |
LibraBFT/Abstract/Properties.agda
|
lisandrasilva/bft-consensus-agda-1
|
b7dd98dd90d98fbb934ef8cb4f3314940986790d
|
[
"UPL-1.0"
] | null | null | null |
LibraBFT/Abstract/Properties.agda
|
lisandrasilva/bft-consensus-agda-1
|
b7dd98dd90d98fbb934ef8cb4f3314940986790d
|
[
"UPL-1.0"
] | null | null | null |
{- Byzantine Fault Tolerant Consensus Verification in Agda, version 0.9.
Copyright (c) 2020 Oracle and/or its affiliates.
Licensed under the Universal Permissive License v 1.0 as shown at https://opensource.oracle.com/licenses/upl
-}
{-# OPTIONS --allow-unsolved-metas #-}
open import LibraBFT.Prelude
open import LibraBFT.Lemmas
open import LibraBFT.Abstract.Types
-- For each desired property (VotesOnce and LockedRoundRule), we have a
-- module containing a Type that defines a property that an implementation
-- should prove, and a proof that it implies the corresponding rule used by
-- the abstract proofs. Then, we use those proofs to instantiate thmS5,
-- and the use thmS5 to prove a number of correctness conditions.
--
-- TODO-1: refactor this file to separate the definitions and proofs of
-- VotesOnce and LockedRoundRule from their use in proving the correctness
-- properties.
module LibraBFT.Abstract.Properties
(𝓔 : EpochConfig)
(UID : Set)
(_≟UID_ : (u₀ u₁ : UID) → Dec (u₀ ≡ u₁))
(𝓥 : VoteEvidence 𝓔 UID)
where
open import LibraBFT.Abstract.Records 𝓔 UID _≟UID_ 𝓥
open import LibraBFT.Abstract.Records.Extends 𝓔 UID _≟UID_ 𝓥
open import LibraBFT.Abstract.RecordChain 𝓔 UID _≟UID_ 𝓥
import LibraBFT.Abstract.RecordChain.Assumptions 𝓔 UID _≟UID_ 𝓥
as StaticAssumptions
open import LibraBFT.Abstract.System 𝓔 UID _≟UID_ 𝓥
open EpochConfig 𝓔
open import LibraBFT.Abstract.Obligations.VotesOnce 𝓔 UID _≟UID_ 𝓥 as VO
open import LibraBFT.Abstract.Obligations.LockedRound 𝓔 UID _≟UID_ 𝓥 as LR
--------------------------------------------------------------------------------------------
-- * A /ValidSysState/ is one in which both peer obligations are obeyed by honest peers * --
--------------------------------------------------------------------------------------------
record ValidSysState {ℓ}(𝓢 : AbsSystemState ℓ) : Set (ℓ+1 ℓ0 ℓ⊔ ℓ) where
field
vss-votes-once : VO.Type 𝓢
vss-locked-round : LR.Type 𝓢
open ValidSysState public
-- And a valid system state offers the desired /CommitsDoNotConflict/ property
-- and variants.
module _ {ℓ}(𝓢 : AbsSystemState ℓ) (st-valid : ValidSysState 𝓢) where
open AbsSystemState 𝓢
open All-InSys-props InSys
import LibraBFT.Abstract.RecordChain.Properties 𝓔 UID _≟UID_ 𝓥 as Props
CommitsDoNotConflict : ∀{q q'}
→ {rc : RecordChain (Q q)} → All-InSys rc
→ {rc' : RecordChain (Q q')} → All-InSys rc'
→ {b b' : Block}
→ CommitRule rc b
→ CommitRule rc' b'
→ NonInjective-≡ bId ⊎ ((B b) ∈RC rc' ⊎ (B b') ∈RC rc)
CommitsDoNotConflict = Props.WithInvariants.thmS5 InSys
(VO.proof 𝓢 (vss-votes-once st-valid))
(LR.proof 𝓢 (vss-locked-round st-valid))
-- When we are dealing with a /Complete/ AbsSystem, we can go a few steps
-- further and prove that commits do not conflict even if we have only partial
-- knowledge about Records represented in the system.
module _ (∈QC⇒AllSent : Complete 𝓢) where
-- For a /complete/ system we can go even further; if we have evidence that
-- only the tip of the record chains is in the system, we can infer
-- the rest of it is also in the system (or blockIDs are not injective).
CommitsDoNotConflict'
: ∀{q q'}{rc : RecordChain (Q q)}{rc' : RecordChain (Q q')}{b b' : Block}
→ InSys (Q q) → InSys (Q q')
→ CommitRule rc b
→ CommitRule rc' b'
→ NonInjective-≡ bId ⊎ ((B b) ∈RC rc' ⊎ (B b') ∈RC rc)
CommitsDoNotConflict' {q} {q'} {step {r = B bb} rc b←q} {step {r = B bb'} rc' b←q'} {b} {b'} q∈sys q'∈sys cr cr'
with bft-assumption (qVotes-C2 q) (qVotes-C2 q')
...| α , α∈qmem , α∈q'mem , hα
with Any-sym (Any-map⁻ α∈qmem) | Any-sym (Any-map⁻ α∈q'mem)
...| α∈q | α∈q'
with ∈QC⇒AllSent {q = q} hα α∈q q∈sys | ∈QC⇒AllSent {q = q'} hα α∈q' q'∈sys
...| ab , ab←q , arc , ais | ab' , ab←q' , arc' , ais'
with RecordChain-irrelevant (step arc ab←q) (step rc b←q) |
RecordChain-irrelevant (step arc' ab←q') (step rc' b←q')
...| inj₁ hb | _ = inj₁ hb
...| inj₂ _ | inj₁ hb = inj₁ hb
...| inj₂ arc≈rc | inj₂ arc'≈rc'
with CommitsDoNotConflict
(All-InSys-step ais ab←q q∈sys )
(All-InSys-step ais' ab←q' q'∈sys)
(transp-CR (≈RC-sym arc≈rc ) cr )
(transp-CR (≈RC-sym arc'≈rc') cr')
...| inj₁ hb = inj₁ hb
...| inj₂ (inj₁ b∈arc') = inj₂ (inj₁ (transp-B∈RC arc'≈rc' b∈arc'))
...| inj₂ (inj₂ b'∈arc) = inj₂ (inj₂ (transp-B∈RC arc≈rc b'∈arc))
-- The final property is even stronger; it states that even if an observer
-- has access only to suffixes of record chains that match the commit rule,
-- we can still guarantee that b and b' are non-conflicting blocks. This
-- will be important for showing that observers can have confidence in commit
-- messages without participating in the protocol and without having access to
-- all previously sent records.
CommitsDoNotConflict''
: ∀{o o' q q'}
→ {rcf : RecordChainFrom o (Q q)}
→ {rcf' : RecordChainFrom o' (Q q')}
→ {b b' : Block}
→ InSys (Q q)
→ InSys (Q q')
→ CommitRuleFrom rcf b
→ CommitRuleFrom rcf' b'
→ NonInjective-≡ bId ⊎ Σ (RecordChain (Q q')) ((B b) ∈RC_)
⊎ Σ (RecordChain (Q q)) ((B b') ∈RC_)
CommitsDoNotConflict'' {cb} {q = q} {q'} {rcf} {rcf'} q∈sys q'∈sys crf crf'
with bft-assumption (qVotes-C2 q) (qVotes-C2 q')
...| α , α∈qmem , α∈q'mem , hα
with Any-sym (Any-map⁻ α∈qmem) | Any-sym (Any-map⁻ α∈q'mem)
...| α∈q | α∈q'
with ∈QC⇒AllSent {q = q} hα α∈q q∈sys | ∈QC⇒AllSent {q = q'} hα α∈q' q'∈sys
...| ab , ab←q , arc , ais | ab' , ab←q' , arc' , ais'
with step arc ab←q | step arc' ab←q'
...| rcq | rcq'
with crf⇒cr rcf rcq crf | crf⇒cr rcf' rcq' crf'
...| inj₁ hb | _ = inj₁ hb
...| inj₂ _ | inj₁ hb = inj₁ hb
...| inj₂ cr | inj₂ cr'
with CommitsDoNotConflict' q∈sys q'∈sys cr cr'
...| inj₁ hb = inj₁ hb
...| inj₂ (inj₁ b∈arc') = inj₂ (inj₁ (rcq' , b∈arc'))
...| inj₂ (inj₂ b'∈arc) = inj₂ (inj₂ (rcq , b'∈arc))
| 45.576642
| 116
| 0.600737
|
ad3ef1ffeff506a426a15a212a89238145d3e7de
| 1,310
|
agda
|
Agda
|
Graphs/Colouring.agda
|
Smaug123/agdaproofs
|
0f4230011039092f58f673abcad8fb0652e6b562
|
[
"MIT"
] | 4
|
2019-08-08T12:44:19.000Z
|
2022-01-28T06:04:15.000Z
|
Graphs/Colouring.agda
|
Smaug123/agdaproofs
|
0f4230011039092f58f673abcad8fb0652e6b562
|
[
"MIT"
] | 14
|
2019-01-06T21:11:59.000Z
|
2020-04-11T11:03:39.000Z
|
Graphs/Colouring.agda
|
Smaug123/agdaproofs
|
0f4230011039092f58f673abcad8fb0652e6b562
|
[
"MIT"
] | 1
|
2021-11-29T13:23:07.000Z
|
2021-11-29T13:23:07.000Z
|
{-# OPTIONS --warning=error --safe --without-K #-}
open import LogicalFormulae
open import Agda.Primitive using (Level; lzero; lsuc; _⊔_)
open import Functions.Definition
open import Setoids.Setoids
open import Setoids.Subset
open import Graphs.Definition
open import Sets.FinSet.Definition
open import Numbers.Naturals.Semiring
module Graphs.Colouring where
Colouring : (n : ℕ) {a b c : _} {V' : Set a} {V : Setoid {a} {b} V'} (G : Graph c V) → Set (a ⊔ c)
Colouring n {V' = V'} G = {x y : V'} → (Graph._<->_ G x y) → FinSet n
inheritColouring : {n : ℕ} {a b c : _} {V' : Set a} {V : Setoid {a} {b} V'} {G : Graph c V} → (k : Colouring n G) → {e : _} {pred : V' → Set e} {sub : subset V pred} {d : _} {_<->'_ : Rel {_} {d} (Sg V' pred)} (H : Subgraph G sub _<->'_) → Colouring n (subgraphIsGraph H)
inheritColouring k H {v1 , _} {v2 , _} x-y = k (Subgraph.inherits H x-y)
Monochromatic : {a b c : Level} {V' : Set a} {V : Setoid {a} {b} V'} {G : Graph c V} {n : ℕ} → (k : Colouring n G) → {d e : _} {pred : V' → Set d} {sub : subset V pred} {_<->'_ : Rel {_} {e} (Sg V' pred)} (H : Subgraph G sub _<->'_) → Set (a ⊔ d ⊔ e)
Monochromatic {V' = V'} {n = n} k {pred = pred} {sub = sub} {_<->'_} H = Sg (FinSet n) (λ c → {x : Sg V' pred} {y : Sg V' pred} (edge : x <->' y) → (inheritColouring k H) edge ≡ c)
| 59.545455
| 271
| 0.581679
|
9a6e9064f4f7ad1dd7df4326be4fd5f03de35658
| 771
|
agda
|
Agda
|
index.agda
|
danbornside/HoTT-Agda
|
1695a7f3dc60177457855ae846bbd86fcd96983e
|
[
"MIT"
] | 1
|
2021-06-30T00:17:55.000Z
|
2021-06-30T00:17:55.000Z
|
index.agda
|
danbornside/HoTT-Agda
|
1695a7f3dc60177457855ae846bbd86fcd96983e
|
[
"MIT"
] | null | null | null |
index.agda
|
danbornside/HoTT-Agda
|
1695a7f3dc60177457855ae846bbd86fcd96983e
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --without-K #-}
{-
Imports everything that is not imported by something else.
This is not supposed to be used anywhere, this is just a simple way to
do `make all'
This file is intentionally named index.agda so that
Agda will generate index.html.
-}
module index where
-- import Spaces.IntervalProps
-- import Algebra.F2NotCommutative
import homotopy.LoopSpaceCircle
import homotopy.HopfJunior
import homotopy.Hopf
import homotopy.CoverClassification
import homotopy.AnyUniversalCoverIsPathSet
import homotopy.PathSetIsInital
-- import Spaces.LoopSpaceDecidableWedgeCircles
-- import Homotopy.PullbackIsPullback
-- import Homotopy.PushoutIsPushout
-- import Homotopy.Truncation
-- import Sets.QuotientUP
-- import Spaces.PikSn
-- import Homotopy.VanKampen
| 26.586207
| 70
| 0.81323
|
4bcce2845d9dc6c6386c5905defdfeffedee2f25
| 3,792
|
agda
|
Agda
|
Definition/Conversion/Soundness.agda
|
Vtec234/logrel-mltt
|
4746894adb5b8edbddc8463904ee45c2e9b29b69
|
[
"MIT"
] | null | null | null |
Definition/Conversion/Soundness.agda
|
Vtec234/logrel-mltt
|
4746894adb5b8edbddc8463904ee45c2e9b29b69
|
[
"MIT"
] | null | null | null |
Definition/Conversion/Soundness.agda
|
Vtec234/logrel-mltt
|
4746894adb5b8edbddc8463904ee45c2e9b29b69
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --without-K --safe #-}
module Definition.Conversion.Soundness where
open import Definition.Untyped
open import Definition.Typed
open import Definition.Typed.Properties
open import Definition.Conversion
open import Definition.Conversion.Whnf
open import Definition.Typed.Consequences.InverseUniv
open import Definition.Typed.Consequences.Syntactic
open import Definition.Typed.Consequences.NeTypeEq
open import Tools.Product
import Tools.PropositionalEquality as PE
mutual
-- Algorithmic equality of neutrals is well-formed.
soundness~↑ : ∀ {k l A Γ} → Γ ⊢ k ~ l ↑ A → Γ ⊢ k ≡ l ∷ A
soundness~↑ (var-refl x x≡y) = PE.subst (λ y → _ ⊢ _ ≡ var y ∷ _) x≡y (refl x)
soundness~↑ (app-cong k~l x₁) = app-cong (soundness~↓ k~l) (soundnessConv↑Term x₁)
soundness~↑ (fst-cong x) =
let p≡ = soundness~↓ x
⊢ΣFG = proj₁ (syntacticEqTerm p≡)
⊢F , ⊢G = syntacticΣ ⊢ΣFG
in fst-cong ⊢F ⊢G p≡
soundness~↑ (snd-cong x) =
let p≡ = soundness~↓ x
⊢ΣFG = proj₁ (syntacticEqTerm p≡)
⊢F , ⊢G = syntacticΣ ⊢ΣFG
in snd-cong ⊢F ⊢G p≡
soundness~↑ (natrec-cong x₁ x₂ x₃ k~l) =
natrec-cong (soundnessConv↑ x₁) (soundnessConv↑Term x₂)
(soundnessConv↑Term x₃) (soundness~↓ k~l)
soundness~↑ (Emptyrec-cong x₁ k~l) =
Emptyrec-cong (soundnessConv↑ x₁) (soundness~↓ k~l)
-- Algorithmic equality of neutrals in WHNF is well-formed.
soundness~↓ : ∀ {k l A Γ} → Γ ⊢ k ~ l ↓ A → Γ ⊢ k ≡ l ∷ A
soundness~↓ ([~] A₁ D whnfA k~l) = conv (soundness~↑ k~l) (subset* D)
-- Algorithmic equality of types is well-formed.
soundnessConv↑ : ∀ {A B Γ} → Γ ⊢ A [conv↑] B → Γ ⊢ A ≡ B
soundnessConv↑ ([↑] A′ B′ D D′ whnfA′ whnfB′ A′<>B′) =
trans (subset* D) (trans (soundnessConv↓ A′<>B′) (sym (subset* D′)))
-- Algorithmic equality of types in WHNF is well-formed.
soundnessConv↓ : ∀ {A B Γ} → Γ ⊢ A [conv↓] B → Γ ⊢ A ≡ B
soundnessConv↓ (U-refl ⊢Γ) = refl (Uⱼ ⊢Γ)
soundnessConv↓ (ℕ-refl ⊢Γ) = refl (ℕⱼ ⊢Γ)
soundnessConv↓ (Empty-refl ⊢Γ) = refl (Emptyⱼ ⊢Γ)
soundnessConv↓ (Unit-refl ⊢Γ) = refl (Unitⱼ ⊢Γ)
soundnessConv↓ (ne x) = univ (soundness~↓ x)
soundnessConv↓ (Π-cong F c c₁) =
Π-cong F (soundnessConv↑ c) (soundnessConv↑ c₁)
soundnessConv↓ (Σ-cong F c c₁) =
Σ-cong F (soundnessConv↑ c) (soundnessConv↑ c₁)
-- Algorithmic equality of terms is well-formed.
soundnessConv↑Term : ∀ {a b A Γ} → Γ ⊢ a [conv↑] b ∷ A → Γ ⊢ a ≡ b ∷ A
soundnessConv↑Term ([↑]ₜ B t′ u′ D d d′ whnfB whnft′ whnfu′ t<>u) =
conv (trans (subset*Term d)
(trans (soundnessConv↓Term t<>u)
(sym (subset*Term d′))))
(sym (subset* D))
-- Algorithmic equality of terms in WHNF is well-formed.
soundnessConv↓Term : ∀ {a b A Γ} → Γ ⊢ a [conv↓] b ∷ A → Γ ⊢ a ≡ b ∷ A
soundnessConv↓Term (ℕ-ins x) = soundness~↓ x
soundnessConv↓Term (Empty-ins x) = soundness~↓ x
soundnessConv↓Term (Unit-ins x) = soundness~↓ x
soundnessConv↓Term (ne-ins t u x x₁) =
let _ , neA , _ = ne~↓ x₁
_ , t∷M , _ = syntacticEqTerm (soundness~↓ x₁)
M≡A = neTypeEq neA t∷M t
in conv (soundness~↓ x₁) M≡A
soundnessConv↓Term (univ x x₁ x₂) = inverseUnivEq x (soundnessConv↓ x₂)
soundnessConv↓Term (zero-refl ⊢Γ) = refl (zeroⱼ ⊢Γ)
soundnessConv↓Term (suc-cong c) = suc-cong (soundnessConv↑Term c)
soundnessConv↓Term (η-eq x x₁ y y₁ c) =
let ⊢ΠFG = syntacticTerm x
⊢F , _ = syntacticΠ ⊢ΠFG
in η-eq ⊢F x x₁ (soundnessConv↑Term c)
soundnessConv↓Term (Σ-η ⊢p ⊢r pProd rProd fstConv sndConv) =
let ⊢ΣFG = syntacticTerm ⊢p
⊢F , ⊢G = syntacticΣ ⊢ΣFG
fst≡ = soundnessConv↑Term fstConv
snd≡ = soundnessConv↑Term sndConv
in Σ-η ⊢F ⊢G ⊢p ⊢r fst≡ snd≡
soundnessConv↓Term (η-unit [a] [b] aUnit bUnit) = η-unit [a] [b]
| 41.217391
| 84
| 0.622627
|
1e8ea17b7d0cf6ee69d78785268408233262d62b
| 193
|
agda
|
Agda
|
test/Fail/Issue1295.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
test/Fail/Issue1295.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
test/Fail/Issue1295.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
-- Andreas, 2014-10-09, issue reported by jesper.cockx
open import Common.Product
pattern foo x = x , x
-- Should complain about non-linearity.
test : {A : Set} → A × A → A
test (foo x) = x
| 19.3
| 54
| 0.663212
|
9af7c703cf8cad8037f9815b94307d4f31026bd9
| 1,601
|
agda
|
Agda
|
Cubical/Data/SumFin/Base.agda
|
kiana-S/univalent-foundations
|
8bdb0766260489f9c89a14f4c0f2ad26e5190dec
|
[
"MIT"
] | null | null | null |
Cubical/Data/SumFin/Base.agda
|
kiana-S/univalent-foundations
|
8bdb0766260489f9c89a14f4c0f2ad26e5190dec
|
[
"MIT"
] | 1
|
2022-01-27T02:07:48.000Z
|
2022-01-27T02:07:48.000Z
|
Cubical/Data/SumFin/Base.agda
|
kiana-S/univalent-foundations
|
8bdb0766260489f9c89a14f4c0f2ad26e5190dec
|
[
"MIT"
] | 1
|
2021-11-22T02:02:01.000Z
|
2021-11-22T02:02:01.000Z
|
{-# OPTIONS --cubical --no-import-sorts --safe #-}
module Cubical.Data.SumFin.Base where
open import Cubical.Foundations.Prelude
open import Cubical.Data.Empty as ⊥ using (⊥)
open import Cubical.Data.Unit using (tt) renaming (Unit to ⊤) public
open import Cubical.Data.Sum using (_⊎_; inl; inr) public
open import Cubical.Data.Nat hiding (elim)
open import Cubical.Relation.Nullary
open import Cubical.Relation.Nullary.DecidableEq
private
variable
ℓ : Level
k : ℕ
Fin : ℕ → Type₀
Fin zero = ⊥
Fin (suc n) = ⊤ ⊎ (Fin n)
pattern fzero = inl tt
pattern fsuc n = inr n
elim
: (P : ∀ {k} → Fin k → Type ℓ)
→ (∀ {k} → P {suc k} fzero)
→ (∀ {k} {fn : Fin k} → P fn → P (fsuc fn))
→ {k : ℕ} (fn : Fin k) → P fn
elim P fz fs {zero} f0 = ⊥.rec f0
elim P fz fs {suc k} fzero = fz
elim P fz fs {suc k} (fsuc fk) = fs (elim P fz fs fk)
finj : Fin k → Fin (suc k)
finj {suc k} fzero = fzero
finj {suc k} (fsuc n) = fsuc (finj {k} n)
toℕ : Fin k → ℕ
toℕ {suc k} (inl tt) = zero
toℕ {suc k} (inr x) = suc (toℕ {k} x)
toℕ-injective : {m n : Fin k} → toℕ m ≡ toℕ n → m ≡ n
toℕ-injective {suc k} {fzero} {fzero} _ = refl
toℕ-injective {suc k} {fzero} {fsuc x} p = ⊥.rec (znots p)
toℕ-injective {suc k} {fsuc m} {fzero} p = ⊥.rec (snotz p)
toℕ-injective {suc k} {fsuc m} {fsuc x} p = cong fsuc (toℕ-injective (injSuc p))
-- Thus, Fin k is discrete
discreteFin : Discrete (Fin k)
discreteFin fj fk with discreteℕ (toℕ fj) (toℕ fk)
... | yes p = yes (toℕ-injective p)
... | no ¬p = no (λ p → ¬p (cong toℕ p))
isSetFin : isSet (Fin k)
isSetFin = Discrete→isSet discreteFin
| 27.603448
| 80
| 0.619613
|
2e1cf51c68fda863d6c811bc4e10998c0f3871f6
| 4,706
|
agda
|
Agda
|
test/Succeed/Issue4032.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
test/Succeed/Issue4032.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
test/Succeed/Issue4032.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
{-# OPTIONS --without-K --rewriting --confluence-check #-}
open import Agda.Primitive using (Level; _⊔_; Setω; lzero; lsuc)
module Issue4032 where
infix 4 _≡_
data _≡_ {ℓ : Level} {A : Set ℓ} (a : A) : A → Set ℓ where
refl : a ≡ a
{-# BUILTIN REWRITE _≡_ #-}
run : ∀ {ℓ} {A B : Set ℓ} → A ≡ B → A → B
run refl x = x
nur : ∀ {ℓ} {A B : Set ℓ} → A ≡ B → B → A
nur refl x = x
convert : ∀ {ℓ} {A B : Set ℓ} (p : A ≡ B) (a : A) → nur p (run p a) ≡ a
convert refl a = refl
trevnoc : ∀ {ℓ} {A B : Set ℓ} (p : A ≡ B) (b : B) → run p (nur p b) ≡ b
trevnoc refl b = refl
ap : ∀ {a b} {A : Set a} {B : Set b} (f : A → B) {a₁ a₂} → a₁ ≡ a₂ → f a₁ ≡ f a₂
ap f refl = refl
transport : ∀ {a b} {A : Set a} (B : A → Set b) {x y : A} (p : x ≡ y) → B x → B y
transport B p = run (ap B p)
apD : ∀ {a b} {A : Set a} {B : A → Set b} (f : (x : A) → B x) {a₁ a₂} → (p : a₁ ≡ a₂) → transport B p (f a₁) ≡ f a₂
apD f refl = refl
ap2 : ∀ {a b c} {A : Set a} {B : A → Set b} {C : Set c} (f : (x : A) → B x → C) {a₁ a₂} (pa : a₁ ≡ a₂) {b₁ b₂} → transport B pa b₁ ≡ b₂ → f a₁ b₁ ≡ f a₂ b₂
ap2 f refl refl = refl
postulate fromIso : ∀ {ℓ} {A B : Set ℓ} (f : A → B) (g : B → A) (η : (x : A) → g (f x) ≡ x) (ε : (x : B) → f (g x) ≡ x) (τ : (x : A) → ap f (η x) ≡ ε (f x)) → A ≡ B
postulate fromIso-refl : ∀ {ℓ} {A : Set ℓ} → fromIso {ℓ} {A} {A} (λ x → x) (λ x → x) (λ x → refl) (λ x → refl) (λ x → refl) ≡ refl
{-# REWRITE fromIso-refl #-}
J : ∀ {ℓ₁ ℓ₂} {A : Set ℓ₁} {a : A} (P : (b : A) → a ≡ b → Set ℓ₂) {b : A} (p : a ≡ b) → P a refl → P b p
J R refl r = r
module foo {-ℓ₁-} {ℓ} {Γ : Set ℓ{-₁-}} {xs ys : Γ} (ps : xs ≡ ys) (tA : Γ → Set ℓ) (tB : (γ : Γ) → tA γ → Set ℓ) where
module pf where
iso-f : ((a : tA xs) → (tB xs) a) → ((a : tA ys) → (tB ys) a)
iso-f var1 var0 = run (ap2 tB ps (trevnoc (ap tA ps) var0)) (var1 (nur (ap tA ps) var0))
iso-g : ((a : tA ys) → (tB ys) a) → ((a : tA xs) → (tB xs) a)
iso-g var1 var0 = nur (ap2 tB ps refl) (var1 (run (ap tA ps) var0))
iso-η : (var0 : _) → iso-g (iso-f var0) ≡ var0
iso-η var0 = J (λ ys (ps : xs ≡ ys) → (λ var1 → nur (ap2 tB ps refl) (run (ap2 tB ps (trevnoc (ap tA ps) (run (ap tA ps) var1))) (var0 (nur (ap tA ps) (run (ap tA ps) var1))))) ≡ var0) ps refl
iso-ε : (var0 : _) → iso-f (iso-g var0) ≡ var0
iso-ε = J (λ ys (ps : xs ≡ ys) → (var0 : (a : tA ys) → tB ys a) → (λ var1 → run (ap2 tB ps (trevnoc (ap tA ps) var1)) (nur (ap2 tB ps refl) (var0 (run (ap tA ps) (nur (ap tA ps) var1))))) ≡ var0) ps (λ var0 → refl)
iso-τ : (var0 : _) → ap iso-f (iso-η var0) ≡ iso-ε (iso-f var0)
iso-τ var0 = J
(λ ys (ps : xs ≡ ys) →
ap
(λ var1 var2 →
run (ap2 tB ps (trevnoc (ap tA ps) var2))
(var1 (nur (ap tA ps) var2)))
(J
(λ ys₁ ps₁ →
(λ var1 →
nur (ap2 tB ps₁ refl)
(run (ap2 tB ps₁ (trevnoc (ap tA ps₁) (run (ap tA ps₁) var1)))
(var0 (nur (ap tA ps₁) (run (ap tA ps₁) var1)))))
≡ var0)
ps refl)
≡
J
(λ ys₁ ps₁ →
(var1 : (a : tA ys₁) → tB ys₁ a) →
(λ var2 →
run (ap2 tB ps₁ (trevnoc (ap tA ps₁) var2))
(nur (ap2 tB ps₁ refl)
(var1 (run (ap tA ps₁) (nur (ap tA ps₁) var2)))))
≡ var1)
ps (λ var1 → refl)
(λ var1 →
run (ap2 tB ps (trevnoc (ap tA ps) var1))
(var0 (nur (ap tA ps) var1))))
ps refl
open pf
pf : ((a : tA xs) → (tB xs) a) ≡ ((a : tA ys) → (tB ys) a)
pf = fromIso iso-f iso-g iso-η iso-ε iso-τ
module bar {ℓ} {Γ : Set ℓ} {γ : Γ} {A : Γ → Set ℓ} {B : (γ : Γ) → A γ → Set ℓ} where
g1 : ((a : A γ) → B γ a) → (a : A γ) → B γ a
g2 : ((a : A γ) → B γ a) → (a : A γ) → B γ a
g1 = foo.pf.iso-g {xs = γ} refl A B
g2 = λ f x → f x
pfg : g1 ≡ g2
pfg = refl
baz : foo.pf {xs = γ} refl A B ≡ refl
baz = pf
where
pf : fromIso {_} {(x : A γ) → B γ x} (λ f x → f x) g2 (foo.pf.iso-η refl A B) (foo.pf.iso-ε refl A B) (foo.pf.iso-τ refl A B) ≡ refl
pf = refl
{- WAS:
refl !=
fromIso (foo.pf.iso-f refl A B) (foo.pf.iso-g refl A B)
(foo.pf.iso-η refl A B) (foo.pf.iso-ε refl A B)
(foo.pf.iso-τ refl A B)
of type ((x : A γ) → B γ x) ≡ ((x : A γ) → B γ x)
when checking that the expression pf has type
foo.pf refl A B ≡ refl
-}
| 39.881356
| 218
| 0.429664
|
d1d6b6e0839ef20fd77a84d9caeadca889881750
| 8,022
|
agda
|
Agda
|
src/Categories/Adjoint/Construction/Kleisli.agda
|
Trebor-Huang/agda-categories
|
d9e4f578b126313058d105c61707d8c8ae987fa8
|
[
"MIT"
] | 5
|
2019-05-21T17:07:19.000Z
|
2019-05-22T03:54:24.000Z
|
src/Categories/Adjoint/Construction/Kleisli.agda
|
seanpm2001/agda-categories
|
d9e4f578b126313058d105c61707d8c8ae987fa8
|
[
"MIT"
] | null | null | null |
src/Categories/Adjoint/Construction/Kleisli.agda
|
seanpm2001/agda-categories
|
d9e4f578b126313058d105c61707d8c8ae987fa8
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --without-K --safe #-}
open import Categories.Category.Core using (Category)
open import Categories.Monad using (Monad)
module Categories.Adjoint.Construction.Kleisli {o ℓ e} {C : Category o ℓ e} (M : Monad C) where
open import Categories.Category.Construction.Kleisli using (Kleisli)
open import Categories.Adjoint using (_⊣_)
open import Categories.Functor using (Functor; _∘F_)
open import Categories.Morphism using (Iso)
open import Categories.Functor.Properties using ([_]-resp-square)
open import Categories.NaturalTransformation.Core using (ntHelper)
open import Categories.NaturalTransformation.NaturalIsomorphism using (_≃_)
open import Categories.Morphism.Reasoning C
private
module C = Category C
module M = Monad M
open M.F
open M using (module μ; module η)
open C using (Obj; _⇒_; _∘_; _≈_; ∘-resp-≈ʳ; ∘-resp-≈ˡ; assoc; sym-assoc; identityˡ)
open C.HomReasoning
open C.Equiv
Forgetful : Functor (Kleisli M) C
Forgetful = record
{ F₀ = λ X → F₀ X
; F₁ = λ f → μ.η _ ∘ F₁ f
; identity = M.identityˡ
; homomorphism = λ {X Y Z} {f g} → begin
μ.η Z ∘ F₁ ((μ.η Z ∘ F₁ g) ∘ f) ≈⟨ refl⟩∘⟨ homomorphism ⟩
μ.η Z ∘ F₁ (μ.η Z ∘ F₁ g) ∘ F₁ f ≈⟨ refl⟩∘⟨ homomorphism ⟩∘⟨refl ⟩
μ.η Z ∘ (F₁ (μ.η Z) ∘ F₁ (F₁ g)) ∘ F₁ f ≈⟨ pull-first M.assoc ⟩
(μ.η Z ∘ μ.η (F₀ Z)) ∘ F₁ (F₁ g) ∘ F₁ f ≈⟨ center (μ.commute g) ⟩
μ.η Z ∘ (F₁ g ∘ μ.η Y) ∘ F₁ f ≈⟨ pull-first refl ⟩
(μ.η Z ∘ F₁ g) ∘ μ.η Y ∘ F₁ f ∎
; F-resp-≈ = λ eq → ∘-resp-≈ʳ (F-resp-≈ eq)
}
Free : Functor C (Kleisli M)
Free = record
{ F₀ = λ X → X
; F₁ = λ f → η.η _ ∘ f
; identity = C.identityʳ
; homomorphism = λ {X Y Z} {f g} → begin
η.η Z ∘ g ∘ f ≈⟨ sym-assoc ○ ⟺ identityˡ ⟩
C.id ∘ (η.η Z ∘ g) ∘ f ≈˘⟨ pull-first M.identityˡ ⟩
μ.η Z ∘ (F₁ (η.η Z) ∘ η.η Z ∘ g) ∘ f ≈⟨ refl⟩∘⟨ pushʳ (η.commute g) ⟩∘⟨refl ⟩
μ.η Z ∘ ((F₁ (η.η Z) ∘ F₁ g) ∘ η.η Y) ∘ f ≈˘⟨ center (∘-resp-≈ˡ homomorphism) ⟩
(μ.η Z ∘ F₁ (η.η Z ∘ g)) ∘ η.η Y ∘ f ∎
; F-resp-≈ = ∘-resp-≈ʳ
}
FF≃F : Forgetful ∘F Free ≃ M.F
FF≃F = record
{ F⇒G = ntHelper record
{ η = λ X → F₁ C.id
; commute = λ {X Y} f → begin
F₁ C.id ∘ μ.η Y ∘ F₁ (η.η Y ∘ f) ≈⟨ refl⟩∘⟨ refl⟩∘⟨ homomorphism ⟩
F₁ C.id ∘ μ.η Y ∘ F₁ (η.η Y) ∘ F₁ f ≈⟨ refl⟩∘⟨ cancelˡ M.identityˡ ⟩
F₁ C.id ∘ F₁ f ≈⟨ [ M.F ]-resp-square id-comm-sym ⟩
F₁ f ∘ F₁ C.id ∎
}
; F⇐G = ntHelper record
{ η = λ X → F₁ C.id
; commute = λ {X Y} f → begin
F₁ C.id ∘ F₁ f ≈⟨ [ M.F ]-resp-square id-comm-sym ⟩
F₁ f ∘ F₁ C.id ≈˘⟨ cancelˡ M.identityˡ ⟩∘⟨refl ⟩
(μ.η Y ∘ F₁ (η.η Y) ∘ F₁ f) ∘ F₁ C.id ≈˘⟨ ∘-resp-≈ʳ homomorphism ⟩∘⟨refl ⟩
(μ.η Y ∘ F₁ (η.η Y ∘ f)) ∘ F₁ C.id ∎
}
; iso = λ X → record
{ isoˡ = elimˡ identity ○ identity
; isoʳ = elimˡ identity ○ identity
}
}
Free⊣Forgetful : Free ⊣ Forgetful
Free⊣Forgetful = record
{ unit = ntHelper record
{ η = η.η
; commute = λ {X Y} f → begin
η.η Y ∘ f ≈⟨ η.commute f ⟩
F₁ f ∘ η.η X ≈˘⟨ cancelˡ M.identityˡ ⟩∘⟨refl ⟩
(μ.η Y ∘ F₁ (η.η Y) ∘ F₁ f) ∘ η.η X ≈˘⟨ ∘-resp-≈ʳ homomorphism ⟩∘⟨refl ⟩
(μ.η Y ∘ F₁ (η.η Y ∘ f)) ∘ η.η X ∎
}
; counit = ntHelper record
{ η = λ X → F₁ C.id
; commute = λ {X Y} f → begin
(μ.η Y ∘ F₁ (F₁ C.id)) ∘ η.η (F₀ Y) ∘ μ.η Y ∘ F₁ f ≈⟨ elimʳ (F-resp-≈ identity ○ identity) ⟩∘⟨refl ⟩
μ.η Y ∘ η.η (F₀ Y) ∘ μ.η Y ∘ F₁ f ≈⟨ cancelˡ M.identityʳ ⟩
μ.η Y ∘ F₁ f ≈⟨ introʳ identity ⟩
(μ.η Y ∘ F₁ f) ∘ F₁ C.id ∎
}
; zig = λ {A} → begin
(μ.η A ∘ F₁ (F₁ C.id)) ∘ η.η (F₀ A) ∘ η.η A ≈⟨ elimʳ (F-resp-≈ identity ○ identity) ⟩∘⟨refl ⟩
μ.η A ∘ η.η (F₀ A) ∘ η.η A ≈⟨ cancelˡ M.identityʳ ⟩
η.η A ∎
; zag = λ {B} → begin
(μ.η B ∘ F₁ (F₁ C.id)) ∘ η.η (F₀ B) ≈⟨ elimʳ (F-resp-≈ identity ○ identity) ⟩∘⟨refl ⟩
μ.η B ∘ η.η (F₀ B) ≈⟨ M.identityʳ ⟩
C.id ∎
}
module KleisliExtension where
κ : {A B : Obj} → (f : A ⇒ F₀ B) → F₀ A ⇒ F₀ B
κ {_} {B} f = μ.η B ∘ F₁ f
f-iso⇒Klf-iso : ∀ {A B : Obj} → (f : A ⇒ F₀ B) → (g : B ⇒ F₀ A) → Iso (Kleisli M) g f → Iso C (κ f) (κ g)
f-iso⇒Klf-iso {A} {B} f g (record { isoˡ = isoˡ ; isoʳ = isoʳ }) = record
{ isoˡ = begin
(μ.η A ∘ F₁ g) ∘ μ.η B ∘ F₁ f ≈⟨ center (sym (μ.commute g)) ⟩
μ.η A ∘ (μ.η (F₀ A) ∘ F₁ (F₁ g)) ∘ F₁ f ≈⟨ assoc²'' ○ pushˡ M.sym-assoc ⟩
μ.η A ∘ F₁ (μ.η A) ∘ F₁ (F₁ g) ∘ F₁ f ≈⟨ refl⟩∘⟨ sym trihom ⟩
μ.η A ∘ F₁ (μ.η A ∘ F₁ g ∘ f) ≈⟨ refl⟩∘⟨ F-resp-≈ sym-assoc ⟩
μ.η A ∘ F₁ ((μ.η A ∘ F₁ g) ∘ f) ≈⟨ refl⟩∘⟨ F-resp-≈ isoʳ ○ M.identityˡ ⟩
C.id ∎
; isoʳ = begin
(μ.η B ∘ F₁ f) ∘ μ.η A ∘ F₁ g ≈⟨ center (sym (μ.commute f)) ⟩
μ.η B ∘ (μ.η (F₀ B) ∘ F₁ (F₁ f)) ∘ F₁ g ≈⟨ assoc²'' ○ pushˡ M.sym-assoc ⟩
μ.η B ∘ F₁ (μ.η B) ∘ F₁ (F₁ f) ∘ F₁ g ≈⟨ refl⟩∘⟨ sym trihom ⟩
μ.η B ∘ F₁ (μ.η B ∘ F₁ f ∘ g) ≈⟨ refl⟩∘⟨ F-resp-≈ sym-assoc ⟩
μ.η B ∘ F₁ ((μ.η B ∘ F₁ f) ∘ g) ≈⟨ refl⟩∘⟨ F-resp-≈ isoˡ ○ M.identityˡ ⟩
C.id ∎
}
where
trihom : {X Y Z W : Obj} {f : X ⇒ Y} {g : Y ⇒ Z} {h : Z ⇒ W} → F₁ (h ∘ g ∘ f) ≈ F₁ h ∘ F₁ g ∘ F₁ f
trihom {X} {Y} {Z} {W} {f} {g} {h} = begin
F₁ (h ∘ g ∘ f) ≈⟨ homomorphism ⟩
F₁ h ∘ F₁ (g ∘ f) ≈⟨ refl⟩∘⟨ homomorphism ⟩
F₁ h ∘ F₁ g ∘ F₁ f ∎
Klf-iso⇒f-iso : ∀ {A B : Obj} → (f : A ⇒ F₀ B) → (g : B ⇒ F₀ A) → Iso C (κ f) (κ g) → Iso (Kleisli M) g f
Klf-iso⇒f-iso {A} {B} f g record { isoˡ = isoˡ ; isoʳ = isoʳ } = record
{ isoˡ = begin
(μ.η B ∘ F₁ f) ∘ g ≈⟨ introʳ M.identityʳ ⟩∘⟨refl ⟩
((μ.η B ∘ F₁ f) ∘ (μ.η A ∘ η.η (F₀ A))) ∘ g ≈⟨ assoc ⟩∘⟨refl ○ assoc ○ refl⟩∘⟨ assoc ○ refl⟩∘⟨ refl⟩∘⟨ assoc ⟩
μ.η B ∘ F₁ f ∘ (μ.η A) ∘ (η.η (F₀ A) ∘ g) ≈⟨ refl⟩∘⟨ refl⟩∘⟨ refl⟩∘⟨ η.commute g ⟩
μ.η B ∘ F₁ f ∘ μ.η A ∘ (F₁ g ∘ η.η B) ≈˘⟨ assoc ⟩∘⟨refl ○ assoc ○ refl⟩∘⟨ assoc ○ refl⟩∘⟨ refl⟩∘⟨ assoc ⟩
((μ.η B ∘ F₁ f) ∘ μ.η A ∘ F₁ g) ∘ η.η B ≈⟨ elimˡ isoʳ ⟩
η.η B ∎
; isoʳ = begin
(μ.η A ∘ F₁ g) ∘ f ≈⟨ introʳ M.identityʳ ⟩∘⟨refl ⟩
((μ.η A ∘ F₁ g) ∘ (μ.η B ∘ η.η (F₀ B))) ∘ f ≈⟨ assoc ⟩∘⟨refl ○ assoc ○ refl⟩∘⟨ assoc ○ refl⟩∘⟨ refl⟩∘⟨ assoc ⟩
μ.η A ∘ F₁ g ∘ (μ.η B) ∘ (η.η (F₀ B) ∘ f) ≈⟨ refl⟩∘⟨ refl⟩∘⟨ refl⟩∘⟨ η.commute f ⟩
μ.η A ∘ F₁ g ∘ μ.η B ∘ (F₁ f ∘ η.η A) ≈˘⟨ assoc ⟩∘⟨refl ○ assoc ○ refl⟩∘⟨ assoc ○ refl⟩∘⟨ refl⟩∘⟨ assoc ⟩
((μ.η A ∘ F₁ g) ∘ μ.η B ∘ F₁ f) ∘ η.η A ≈⟨ elimˡ isoˡ ⟩
η.η A ∎
}
kl-ext-compat : ∀ {A B X : Obj} → (f : A ⇒ F₀ B) → (g : B ⇒ F₀ X) → κ ((κ g) ∘ f) ≈ κ g ∘ κ f
kl-ext-compat {A} {B} {X} f g = begin
μ.η X ∘ F₁ ((μ.η X ∘ F₁ g) ∘ f) ≈⟨ refl⟩∘⟨ F-resp-≈ assoc ○ refl⟩∘⟨ trihom ⟩
μ.η X ∘ (F₁ (μ.η X) ∘ F₁ (F₁ g) ∘ F₁ f) ≈⟨ sym-assoc ⟩
(μ.η X ∘ F₁ (μ.η X)) ∘ F₁ (F₁ g) ∘ F₁ f ≈⟨ M.assoc ⟩∘⟨refl ⟩
(μ.η X ∘ μ.η (F₀ X)) ∘ F₁ (F₁ g) ∘ F₁ f ≈⟨ center (μ.commute g) ⟩
μ.η X ∘ (F₁ g ∘ μ.η B) ∘ F₁ f ≈⟨ sym-assoc ○ (sym-assoc ⟩∘⟨refl) ○ assoc ⟩
(μ.η X ∘ F₁ g) ∘ μ.η B ∘ F₁ f ∎
where
trihom : {X Y Z W : Obj} {f : X ⇒ Y} {g : Y ⇒ Z} {h : Z ⇒ W} → F₁ (h ∘ g ∘ f) ≈ F₁ h ∘ F₁ g ∘ F₁ f
trihom {X} {Y} {Z} {W} {f} {g} {h} = begin
F₁ (h ∘ g ∘ f) ≈⟨ homomorphism ⟩
F₁ h ∘ F₁ (g ∘ f) ≈⟨ refl⟩∘⟨ homomorphism ⟩
F₁ h ∘ F₁ g ∘ F₁ f ∎
| 47.75
| 117
| 0.435677
|
299d7f63d93befa89651e3252e45f7a2d7800620
| 750
|
agda
|
Agda
|
test/fail/Test0.agda
|
AntoineAllioux/HoTT-Agda
|
1037d82edcf29b620677a311dcfd4fc2ade2faa6
|
[
"MIT"
] | 294
|
2015-01-09T16:23:23.000Z
|
2022-03-20T13:54:45.000Z
|
test/fail/Test0.agda
|
AntoineAllioux/HoTT-Agda
|
1037d82edcf29b620677a311dcfd4fc2ade2faa6
|
[
"MIT"
] | 31
|
2015-03-05T20:09:00.000Z
|
2021-10-03T19:15:25.000Z
|
test/fail/Test0.agda
|
AntoineAllioux/HoTT-Agda
|
1037d82edcf29b620677a311dcfd4fc2ade2faa6
|
[
"MIT"
] | 50
|
2015-01-10T01:48:08.000Z
|
2022-02-14T03:03:25.000Z
|
{-# OPTIONS --without-K #-}
open import lib.Base
module fail.Test0 where
data Bool : Type₀ where
true false : Bool
module _ where
private
data #I : Type₀ where
#zero : #I
#one : #I
I : Type₀
I = #I
zero : I
zero = #zero
one : I
one = #one
postulate
seg : zero == one
I-elim : ∀ {i} {P : I → Type i} (zero* : P zero) (one* : P one)
(seg* : zero* == one* [ P ↓ seg ]) → Π I P
I-elim zero* one* seg* #zero = zero*
I-elim zero* one* seg* #one = one*
postulate
I-seg-β : ∀ {i} {P : I → Type i} (zero* : P zero) (one* : P one)
(seg* : zero* == one* [ P ↓ seg ])
→ apd (I-elim zero* one* seg*) seg == seg*
test : I → Bool
test zero = true
test one = false
| 17.857143
| 68
| 0.5
|
d1e1f8fb3638d523a0b9018fe52a27ca469c6cb9
| 3,817
|
agda
|
Agda
|
BasicIS4/Metatheory/DyadicGentzen-TarskiGluedDyadicGentzen.agda
|
mietek/hilbert-gentzen
|
fcd187db70f0a39b894fe44fad0107f61849405c
|
[
"X11"
] | 29
|
2016-07-03T18:51:56.000Z
|
2022-01-01T10:29:18.000Z
|
BasicIS4/Metatheory/DyadicGentzen-TarskiGluedDyadicGentzen.agda
|
mietek/hilbert-gentzen
|
fcd187db70f0a39b894fe44fad0107f61849405c
|
[
"X11"
] | 1
|
2018-06-10T09:11:22.000Z
|
2018-06-10T09:11:22.000Z
|
BasicIS4/Metatheory/DyadicGentzen-TarskiGluedDyadicGentzen.agda
|
mietek/hilbert-gentzen
|
fcd187db70f0a39b894fe44fad0107f61849405c
|
[
"X11"
] | null | null | null |
module BasicIS4.Metatheory.DyadicGentzen-TarskiGluedDyadicGentzen where
open import BasicIS4.Syntax.DyadicGentzen public
open import BasicIS4.Semantics.TarskiGluedDyadicGentzen public
-- Internalisation of syntax as syntax representation in a particular model.
module _ {{_ : Model}} where
[_] : ∀ {A Γ Δ} → Γ ⁏ Δ ⊢ A → Γ ⁏ Δ [⊢] A
[ var i ] = [var] i
[ lam t ] = [lam] [ t ]
[ app t u ] = [app] [ t ] [ u ]
[ mvar i ] = [mvar] i
[ box t ] = [box] [ t ]
[ unbox t u ] = [unbox] [ t ] [ u ]
[ pair t u ] = [pair] [ t ] [ u ]
[ fst t ] = [fst] [ t ]
[ snd t ] = [snd] [ t ]
[ unit ] = [unit]
-- Soundness with respect to all models, or evaluation.
-- FIXME
postulate
reifyʳ⋆ : ∀ {{_ : Model}} {Ξ Γ Δ} → Γ ⁏ Δ ⊩⋆ Ξ → Γ ⁏ Δ [⊢]⋆ Ξ
eval : ∀ {A Γ Δ} → Γ ⁏ Δ ⊢ A → Γ ⁏ Δ ⊨ A
eval (var i) γ δ = lookup i γ
eval (lam t) γ δ = λ ψ a → eval t (mono²⊩⋆ ψ γ , a) (mono²⊩⋆ ψ δ)
eval (app {A} {B} t u) γ δ = _⟪$⟫_ {A} {B} (eval t γ δ) (eval u γ δ)
eval (mvar i) γ δ = mlookup i δ
eval (box t) γ δ = λ ψ → let δ′ = mono²⊩⋆ ψ δ
in [mmulticut] (reifyʳ⋆ δ′) [ box t ] ⅋
eval t ∙ δ′
eval (unbox {A} {C} t u) γ δ = eval u γ (δ , λ ψ →
let γ′ = mono²⊩⋆ ψ γ
δ′ = mono²⊩⋆ ψ δ
in [multicut²] (reifyʳ⋆ γ′) (reifyʳ⋆ δ′) [ t ] ⅋
⟪↓⟫ (eval t γ′ δ′))
eval (pair t u) γ δ = eval t γ δ , eval u γ δ
eval (fst t) γ δ = π₁ (eval t γ δ)
eval (snd t) γ δ = π₂ (eval t γ δ)
eval unit γ δ = ∙
-- TODO: Correctness of evaluation with respect to conversion.
-- The canonical model.
private
instance
canon : Model
canon = record
{ _⊩ᵅ_ = λ Π P → Π ⊢ α P
; mono²⊩ᵅ = mono²⊢
; _[⊢]_ = _⊢_
; mono²[⊢] = mono²⊢
; [var] = var
; [lam] = lam
; [app] = app
; [mvar] = mvar
; [box] = box
; [unbox] = unbox
; [pair] = pair
; [fst] = fst
; [snd] = snd
; [unit] = unit
}
-- Soundness and completeness with respect to the canonical model.
mutual
reflectᶜ : ∀ {A Γ Δ} → Γ ⁏ Δ ⊢ A → Γ ⁏ Δ ⊩ A
reflectᶜ {α P} t = t
reflectᶜ {A ▻ B} t = λ ψ → let t′ = mono²⊢ ψ t
in λ a → reflectᶜ (app t′ (reifyᶜ a))
reflectᶜ {□ A} t = λ ψ → let t′ = mono²⊢ ψ t
in t′ ⅋ reflectᶜ (down t′)
reflectᶜ {A ∧ B} t = reflectᶜ (fst t) , reflectᶜ (snd t)
reflectᶜ {⊤} t = ∙
reifyᶜ : ∀ {A Γ Δ} → Γ ⁏ Δ ⊩ A → Γ ⁏ Δ ⊢ A
reifyᶜ {α P} s = s
reifyᶜ {A ▻ B} s = lam (reifyᶜ (s weak⊆²₁ (reflectᶜ {A} v₀)))
reifyᶜ {□ A} s = syn (s refl⊆²)
reifyᶜ {A ∧ B} s = pair (reifyᶜ (π₁ s)) (reifyᶜ (π₂ s))
reifyᶜ {⊤} s = unit
reflectᶜ⋆ : ∀ {Ξ Γ Δ} → Γ ⁏ Δ ⊢⋆ Ξ → Γ ⁏ Δ ⊩⋆ Ξ
reflectᶜ⋆ {∅} ∙ = ∙
reflectᶜ⋆ {Ξ , A} (ts , t) = reflectᶜ⋆ ts , reflectᶜ t
reifyᶜ⋆ : ∀ {Ξ Γ Δ} → Γ ⁏ Δ ⊩⋆ Ξ → Γ ⁏ Δ ⊢⋆ Ξ
reifyᶜ⋆ {∅} ∙ = ∙
reifyᶜ⋆ {Ξ , A} (ts , t) = reifyᶜ⋆ ts , reifyᶜ t
-- Reflexivity and transitivity.
refl⊩⋆ : ∀ {Γ Δ} → Γ ⁏ Δ ⊩⋆ Γ
refl⊩⋆ = reflectᶜ⋆ refl⊢⋆
mrefl⊩⋆ : ∀ {Γ Δ} → Γ ⁏ Δ ⊩⋆ □⋆ Δ
mrefl⊩⋆ = reflectᶜ⋆ mrefl⊢⋆
trans⊩⋆ : ∀ {Γ Γ′ Δ Δ′ Ξ} → Γ ⁏ Δ ⊩⋆ Γ′ ⧺ (□⋆ Δ′) → Γ′ ⁏ Δ′ ⊩⋆ Ξ → Γ ⁏ Δ ⊩⋆ Ξ
trans⊩⋆ ts us = reflectᶜ⋆ (trans⊢⋆ (reifyᶜ⋆ ts) (reifyᶜ⋆ us))
-- Completeness with respect to all models, or quotation.
quot : ∀ {A Γ Δ} → Γ ⁏ Δ ⊨ A → Γ ⁏ Δ ⊢ A
quot s = reifyᶜ (s refl⊩⋆ mrefl⊩⋆)
-- Normalisation by evaluation.
norm : ∀ {A Γ Δ} → Γ ⁏ Δ ⊢ A → Γ ⁏ Δ ⊢ A
norm = quot ∘ eval
-- TODO: Correctness of normalisation with respect to conversion.
| 30.055118
| 82
| 0.449044
|
303cf6f32457f7752b17c04b58f0fa85935bef89
| 2,189
|
agda
|
Agda
|
Cubical/Foundations/Pointed/Properties.agda
|
RobertHarper/cubical
|
d13941587a58895b65f714f1ccc9c1f5986b109c
|
[
"MIT"
] | null | null | null |
Cubical/Foundations/Pointed/Properties.agda
|
RobertHarper/cubical
|
d13941587a58895b65f714f1ccc9c1f5986b109c
|
[
"MIT"
] | null | null | null |
Cubical/Foundations/Pointed/Properties.agda
|
RobertHarper/cubical
|
d13941587a58895b65f714f1ccc9c1f5986b109c
|
[
"MIT"
] | 1
|
2021-11-22T02:02:01.000Z
|
2021-11-22T02:02:01.000Z
|
{-# OPTIONS --cubical --no-import-sorts --safe #-}
module Cubical.Foundations.Pointed.Properties where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Pointed.Base
open import Cubical.Foundations.Function
open import Cubical.Foundations.GroupoidLaws
open import Cubical.Data.Sigma
Π∙ : ∀ {ℓ ℓ'} (A : Type ℓ) (B∙ : A → Pointed ℓ') → Pointed (ℓ-max ℓ ℓ')
Π∙ A B∙ = (∀ a → typ (B∙ a)) , (λ a → pt (B∙ a))
Σ∙ : ∀ {ℓ ℓ'} (A∙ : Pointed ℓ) (B∙ : typ A∙ → Pointed ℓ') → Pointed (ℓ-max ℓ ℓ')
Σ∙ A∙ B∙ = (Σ[ a ∈ typ A∙ ] typ (B∙ a)) , (pt A∙ , pt (B∙ (pt A∙)))
_×∙_ : ∀ {ℓ ℓ'} (A∙ : Pointed ℓ) (B∙ : Pointed ℓ') → Pointed (ℓ-max ℓ ℓ')
A∙ ×∙ B∙ = ((typ A∙) × (typ B∙)) , (pt A∙ , pt B∙)
{- composition of pointed maps -}
_∘∙_ : ∀ {ℓA ℓB ℓC} {A : Pointed ℓA} {B : Pointed ℓB} {C : Pointed ℓC}
(g : B →∙ C) (f : A →∙ B) → (A →∙ C)
(g , g∙) ∘∙ (f , f∙) = (λ x → g (f x)) , ((cong g f∙) ∙ g∙)
{- pointed identity -}
id∙ : ∀ {ℓA} (A : Pointed ℓA) → (A →∙ A)
id∙ A = ((λ x → x) , refl)
{- constant pointed map -}
const∙ : ∀ {ℓA ℓB} (A : Pointed ℓA) (B : Pointed ℓB) → (A →∙ B)
const∙ _ (_ , b) = (λ _ → b) , refl
{- left identity law for pointed maps -}
∘∙-idˡ : ∀ {ℓA ℓB} {A : Pointed ℓA} {B : Pointed ℓB} (f : A →∙ B) → f ∘∙ id∙ A ≡ f
∘∙-idˡ (_ , f∙) = ΣPathP ( refl , (lUnit f∙) ⁻¹ )
{- right identity law for pointed maps -}
∘∙-idʳ : ∀ {ℓA ℓB} {A : Pointed ℓA} {B : Pointed ℓB} (f : A →∙ B) → id∙ B ∘∙ f ≡ f
∘∙-idʳ (_ , f∙) = ΣPathP ( refl , (rUnit f∙) ⁻¹ )
{- associativity for composition of pointed maps -}
∘∙-assoc : ∀ {ℓA ℓB ℓC ℓD} {A : Pointed ℓA} {B : Pointed ℓB} {C : Pointed ℓC} {D : Pointed ℓD}
(h : C →∙ D) (g : B →∙ C) (f : A →∙ B)
→ (h ∘∙ g) ∘∙ f ≡ h ∘∙ (g ∘∙ f)
∘∙-assoc (h , h∙) (g , g∙) (f , f∙) = ΣPathP (refl , q)
where
q : (cong (h ∘ g) f∙) ∙ (cong h g∙ ∙ h∙) ≡ cong h (cong g f∙ ∙ g∙) ∙ h∙
q = ( (cong (h ∘ g) f∙) ∙ (cong h g∙ ∙ h∙)
≡⟨ refl ⟩
(cong h (cong g f∙)) ∙ (cong h g∙ ∙ h∙)
≡⟨ assoc (cong h (cong g f∙)) (cong h g∙) h∙ ⟩
(cong h (cong g f∙) ∙ cong h g∙) ∙ h∙
≡⟨ cong (λ p → p ∙ h∙) ((cong-∙ h (cong g f∙) g∙) ⁻¹) ⟩
(cong h (cong g f∙ ∙ g∙) ∙ h∙) ∎ )
| 39.8
| 94
| 0.480128
|
120f2fb7fd3f587c6f832fea032f6584a074d72e
| 192
|
agda
|
Agda
|
test/Succeed/OmegaInOmega.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
test/Succeed/OmegaInOmega.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
test/Succeed/OmegaInOmega.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
{-# OPTIONS --omega-in-omega #-}
open import Agda.Primitive
test : Setω
test = Setω
record R : Setω where
field
A : ∀ {ℓ} → Set ℓ
data Type : Setω where
el : ∀ {ℓ} → Set ℓ → Type
| 13.714286
| 32
| 0.588542
|
355ceec5bdc36243a92bfcd48133bfff27ce1440
| 15,037
|
agda
|
Agda
|
Cubical/Homotopy/HopfInvariant/Brunerie.agda
|
guilhermehas/cubical
|
ce3120d3f8d692847b2744162bcd7a01f0b687eb
|
[
"MIT"
] | 1
|
2021-10-31T17:32:49.000Z
|
2021-10-31T17:32:49.000Z
|
Cubical/Homotopy/HopfInvariant/Brunerie.agda
|
guilhermehas/cubical
|
ce3120d3f8d692847b2744162bcd7a01f0b687eb
|
[
"MIT"
] | null | null | null |
Cubical/Homotopy/HopfInvariant/Brunerie.agda
|
guilhermehas/cubical
|
ce3120d3f8d692847b2744162bcd7a01f0b687eb
|
[
"MIT"
] | null | null | null |
{-
This file contains a proof of the fact that the Brunerie number,
i.e. absolute value of the Hopf invariant of [e , e] : π₃S², is 2.
Here, e is the generator of π₂S² and [_,_] denotes the Whitehead
product. The proof follows Proposition 5.4.4. in Brunerie (2016)
closely, but, for simplicity, considers only the case n = 2.
-}
{-# OPTIONS --safe --experimental-lossy-unification #-}
module Cubical.Homotopy.HopfInvariant.Brunerie where
open import Cubical.Homotopy.HopfInvariant.Base
open import Cubical.Homotopy.Group.Pi4S3.BrunerieNumber
open import Cubical.Homotopy.Group.Pi4S3.S3PushoutIso
open import Cubical.Homotopy.Whitehead
open import Cubical.ZCohomology.Base
open import Cubical.ZCohomology.GroupStructure
open import Cubical.ZCohomology.MayerVietorisUnreduced
open import Cubical.ZCohomology.Groups.Sn
open import Cubical.ZCohomology.Groups.Wedge
open import Cubical.ZCohomology.Groups.SphereProduct
open import Cubical.ZCohomology.RingStructure.CupProduct
open import Cubical.ZCohomology.RingStructure.RingLaws
open import Cubical.ZCohomology.RingStructure.GradedCommutativity
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.HLevels
open import Cubical.Foundations.Function
open import Cubical.Foundations.Pointed
open import Cubical.Foundations.Isomorphism
open import Cubical.Foundations.GroupoidLaws
open import Cubical.Foundations.Equiv
open import Cubical.Data.Sigma
open import Cubical.Data.Int hiding (_+'_)
open import Cubical.Data.Nat hiding (_+_)
open import Cubical.Data.Unit
open import Cubical.Data.Sum renaming (rec to ⊎rec)
open import Cubical.HITs.Pushout
open import Cubical.HITs.S1
open import Cubical.HITs.Sn
open import Cubical.HITs.Join
open import Cubical.HITs.Susp
open import Cubical.HITs.Wedge
open import Cubical.HITs.Truncation
open import Cubical.HITs.SetTruncation
renaming (elim to sElim ; elim2 to sElim2 ; map to sMap)
open import Cubical.HITs.PropositionalTruncation
renaming (map to pMap ; rec to pRec)
open import Cubical.Algebra.Group
open import Cubical.Algebra.Group.ZAction
open import Cubical.Algebra.Group.Exact
open import Cubical.Algebra.Group.Morphisms
open import Cubical.Algebra.Group.MorphismProperties
open import Cubical.Algebra.Group.Instances.Int
open import Cubical.Algebra.Group.Instances.Unit
open Iso
open IsGroupHom
-- Some abstract versions of imported lemmas/definitions from
-- ZCohomology.Groups.SphereProduct for faster type checking.
abstract
H²-genₗabs : coHom 2 (S₊ 2 × S₊ 2)
H²-genₗabs = H²-S²×S²-genₗ
H²-genᵣabs : coHom 2 (S₊ 2 × S₊ 2)
H²-genᵣabs = H²-S²×S²-genᵣ
Hⁿ⁺ᵐ-Sⁿ×Sᵐ≅ℤ-abs : (n m : ℕ)
→ GroupIso (coHomGr ((suc n) +' (suc m))
(S₊ (suc n) × S₊ (suc m)))
ℤGroup
Hⁿ⁺ᵐ-Sⁿ×Sᵐ≅ℤ-abs = Hⁿ⁺ᵐ-Sⁿ×Sᵐ≅ℤ
Hⁿ⁺ᵐ-Sⁿ×Sᵐ≅ℤ-abs≡ : (n m : ℕ)
→ Hⁿ⁺ᵐ-Sⁿ×Sᵐ≅ℤ-abs n m ≡ Hⁿ⁺ᵐ-Sⁿ×Sᵐ≅ℤ n m
Hⁿ⁺ᵐ-Sⁿ×Sᵐ≅ℤ-abs≡ n m = refl
Hⁿ⁺ᵐ-Sⁿ×Sᵐ≅ℤ-⌣ :
fun (fst (Hⁿ⁺ᵐ-Sⁿ×Sᵐ≅ℤ-abs 1 1))
(H²-S²×S²-genₗ ⌣ H²-S²×S²-genᵣ)
≡ 1
Hⁿ⁺ᵐ-Sⁿ×Sᵐ≅ℤ-⌣ =
fun (fst (Hⁿ⁺ᵐ-Sⁿ×Sᵐ≅ℤ-abs 1 1)) (H²-S²×S²-genₗ ⌣ H²-S²×S²-genᵣ)
≡⟨ cong (fun (fst (Hⁿ⁺ᵐ-Sⁿ×Sᵐ≅ℤ-abs 1 1))) (sym H²-S²≅H⁴-S²×S²⌣) ⟩
fun (fst (Hⁿ⁺ᵐ-Sⁿ×Sᵐ≅ℤ-abs 1 1)) (fun (fst (H²-S²≅H⁴-S²×S²)) ∣ ∣_∣ₕ ∣₂)
≡⟨ speedUp ∣_∣ₕ ⟩
fun (fst (Hⁿ-Sⁿ≅ℤ 1)) ∣ ∣_∣ₕ ∣₂
≡⟨ refl ⟩ -- Computation! :-)
1 ∎
where
speedUp : (f : _) →
fun (fst (Hⁿ⁺ᵐ-Sⁿ×Sᵐ≅ℤ-abs 1 1)) (fun (fst (H²-S²≅H⁴-S²×S²)) ∣ f ∣₂)
≡ fun (fst (Hⁿ-Sⁿ≅ℤ 1)) ∣ f ∣₂
speedUp f i =
fun (fst (Hⁿ-Sⁿ≅ℤ 1)) (leftInv (fst H²-S²≅H⁴-S²×S²) ∣ f ∣₂ i)
-- Some abbreviations
private
inl' : S₊ 2 × S₊ 2 → Pushout⋁↪fold⋁ (S₊∙ 2)
inl' = inl
qHom : GroupHom (coHomGr 4 (Pushout⋁↪fold⋁ (S₊∙ 2)))
(coHomGr 4 (S₊ 2 × S₊ 2))
qHom = coHomMorph 4 inl'
qHomGen : (n : ℕ) →
GroupHom (coHomGr n (Pushout⋁↪fold⋁ (S₊∙ 2)))
(coHomGr n (S₊ 2 × S₊ 2))
qHomGen n = coHomMorph n inl'
-- The type C and generator α, β in dim 2 and 4 respectively
-- Recall, the goal is to prove that α ⌣ α = ±2 β
CHopf : Type
CHopf = HopfInvariantPush 0 fold∘W
Hopfαfold∘W = Hopfα 0 (fold∘W , refl)
Hopfβfold∘W = Hopfβ 0 (fold∘W , refl)
-- Rewriting CHopf as our favourite pushout
-- S²×S² ← S²∨S² → S²
CHopfIso : Iso CHopf (Pushout⋁↪fold⋁ (S₊∙ 2))
CHopfIso =
compIso (invIso (equivToIso
(compEquiv (compEquiv pushoutSwitchEquiv
(isoToEquiv (PushoutDistr.PushoutDistrIso fold⋁ W λ _ → tt)))
pushoutSwitchEquiv)))
(equivToIso Pushout-coFibW-fold⋁≃Pushout⋁↪fold⋁)
-- Cohomology group version of the Iso
coHomCHopfIso : (n : ℕ)
→ GroupIso (coHomGr n CHopf) (coHomGr n (Pushout⋁↪fold⋁ (S₊∙ 2)))
coHomCHopfIso n = invGroupIso (coHomIso n CHopfIso)
-- We instantiate Mayer-Vietoris for the pushout
module MV-⋁↪-fold⋁ = MV _ _ (S₊∙ 2 ⋁ S₊∙ 2) ⋁↪ fold⋁
-- This give us an iso H⁴(S²×S² ← S²∨S² → S²) ≅ H⁴(S²×S²)
isEquiv-qHom : GroupEquiv (coHomGr 4 (Pushout⋁↪fold⋁ (S₊∙ 2)))
(coHomGr 4 (S₊ 2 × S₊ 2))
fst (fst isEquiv-qHom) = qHom .fst
snd (fst isEquiv-qHom) =
subst isEquiv
(funExt (sElim (λ _ → isSetPathImplicit) (λ _ → refl)))
(×UnitEquiv (isoToPath
(invIso
(fst (Hⁿ-Sᵐ≅0 3 1 λ p → snotz (cong predℕ p)))))
_ isEquiv-i)
where
×UnitEquiv : {A B C : Type}
→ Unit ≡ C
→ (f : A → B × C)
→ isEquiv f
→ isEquiv (fst ∘ f)
×UnitEquiv {A = A} {B = B} =
J (λ C _ → (f : A → B × C) → isEquiv f → isEquiv (fst ∘ f))
λ f eq → record { equiv-proof =
λ b → ((fst (fst (equiv-proof eq (b , tt))))
, cong fst (fst (equiv-proof eq (b , tt)) .snd))
, λ y → ΣPathP ((cong fst (equiv-proof eq (b , tt)
.snd ((fst y)
, ΣPathP ((snd y) , refl))))
, λ i j → equiv-proof eq (b , tt) .snd ((fst y)
, ΣPathP ((snd y) , refl)) i .snd j .fst) }
isEquiv-i : isEquiv (fst (MV-⋁↪-fold⋁.i 4))
isEquiv-i =
SES→isEquiv
(isContr→≡UnitGroup
(isOfHLevelRetractFromIso 0
(compIso
(fst (Hⁿ-⋁ (S₊∙ 2) (S₊∙ 2) 2))
(compIso
(prodIso (fst (Hⁿ-Sᵐ≅0 2 1 λ p → snotz (cong predℕ p)))
(fst (Hⁿ-Sᵐ≅0 2 1 λ p → snotz (cong predℕ p))))
rUnit×Iso))
isContrUnit))
((isContr→≡UnitGroup
(isOfHLevelRetractFromIso 0
(compIso
(fst (Hⁿ-⋁ (S₊∙ 2) (S₊∙ 2) 3))
(compIso
(prodIso (fst (Hⁿ-Sᵐ≅0 3 1 λ p → snotz (cong predℕ p)))
(fst (Hⁿ-Sᵐ≅0 3 1 λ p → snotz (cong predℕ p))))
rUnit×Iso))
isContrUnit)))
(MV-⋁↪-fold⋁.d 3)
(MV-⋁↪-fold⋁.i 4)
(MV-⋁↪-fold⋁.Δ 4)
(MV-⋁↪-fold⋁.Ker-i⊂Im-d 3)
(MV-⋁↪-fold⋁.Ker-Δ⊂Im-i 4)
snd isEquiv-qHom = qHom .snd
-- The goal now is reducing α ⌣ α = ±2 β to gₗ ⌣ gᵣ = e for
-- gₗ, gᵣ generators of H²(S²×S²) ≅ ℤ × ℤ and e generator of
-- H⁴(S²×S²) ≅ ℤ. This essentially just elementary linear algebra at
-- this point. We do it for an arbitrary (well-behaved) iso
-- H⁴(S²×S²) ≅ ℤ in order to speed up type checking.
module BrunerieNumLem
(is : GroupIso (coHomGr 4 (S₊ 2 × S₊ 2)) ℤGroup)
(isEq : (fun (fst is) (H²-S²×S²-genₗ ⌣ H²-S²×S²-genᵣ) ≡ 1)) where
x = H²-S²×S²-genₗ
y = H²-S²×S²-genᵣ
α = Hopfαfold∘W
β = Hopfβfold∘W
α' : coHom 2 (Pushout⋁↪fold⋁ (S₊∙ 2))
α' = fun (fst (coHomCHopfIso 2)) α
β' : coHom 4 (Pushout⋁↪fold⋁ (S₊∙ 2))
β' = fun (fst (coHomCHopfIso 4)) β
rewriteEquation :
(α' ⌣ α' ≡ β' +ₕ β') ⊎ (α' ⌣ α' ≡ -ₕ (β' +ₕ β'))
→ (α ⌣ α ≡ β +ₕ β) ⊎ (α ⌣ α ≡ -ₕ (β +ₕ β))
rewriteEquation (inl x) =
inl ((λ i → leftInv (fst (coHomCHopfIso 2)) α (~ i)
⌣ leftInv (fst (coHomCHopfIso 2)) α (~ i))
∙∙ cong (inv (fst (coHomCHopfIso 4))) x
∙∙ leftInv (fst (coHomCHopfIso 4)) (β +ₕ β))
rewriteEquation (inr x) =
inr ((λ i → leftInv (fst (coHomCHopfIso 2)) α (~ i)
⌣ leftInv (fst (coHomCHopfIso 2)) α (~ i))
∙∙ cong (inv (fst (coHomCHopfIso 4))) x
∙∙ leftInv (fst (coHomCHopfIso 4))
(-ₕ (β +ₕ β)))
rewriteEquation2 : (qHom .fst β' ≡ x ⌣ y) ⊎ (qHom .fst β' ≡ -ₕ (x ⌣ y))
rewriteEquation2 =
⊎rec
(λ p → inl (sym (leftInv (fst is) (qHom .fst β'))
∙∙ cong (inv (fst is)) (p ∙ sym isEq)
∙∙ leftInv (fst is) (x ⌣ y)))
(λ p → inr (sym (leftInv (fst is) (qHom .fst β'))
∙∙ cong (inv (fst is))
(p ∙ sym (cong (GroupStr.inv (snd ℤGroup)) isEq))
∙∙ (presinv (invGroupIso is .snd) (fun (fst is) (x ⌣ y))
∙ cong -ₕ_ (leftInv (fst is) (x ⌣ y)))))
eqs
where
grIso : GroupEquiv (coHomGr 4 (HopfInvariantPush 0 fold∘W)) ℤGroup
grIso = compGroupEquiv (GroupIso→GroupEquiv (coHomCHopfIso 4))
(compGroupEquiv
isEquiv-qHom
(GroupIso→GroupEquiv is))
eqs : (fst (fst grIso) β ≡ 1) ⊎ (fst (fst grIso) β ≡ -1)
eqs = groupEquivPresGen _ (GroupIso→GroupEquiv (Hopfβ-Iso 0 (fold∘W , refl)))
β (inl (Hopfβ↦1 0 (fold∘W , refl))) grIso
qpres⌣ : (x y : coHom 2 _)
→ fst qHom (x ⌣ y) ≡ fst (qHomGen 2) x ⌣ fst (qHomGen 2) y
qpres⌣ = sElim2 (λ _ _ → isSetPathImplicit) λ _ _ → refl
α'↦x+y : fst (qHomGen 2) α' ≡ x +ₕ y
α'↦x+y = lem ((coHomFun 2 (inv CHopfIso) α)) refl
where
lem : (x' : coHom 2 (Pushout⋁↪fold⋁ (S₊∙ 2)))
→ coHomFun 2 inr x' ≡ ∣ ∣_∣ ∣₂
→ fst (qHomGen 2) x' ≡ x +ₕ y
lem = sElim (λ _ → isSetΠ λ _ → isSetPathImplicit)
λ f p → Cubical.HITs.PropositionalTruncation.rec
(squash₂ _ _)
(λ r → cong ∣_∣₂ (funExt (uncurry
(wedgeconFun 1 1 (λ _ _ → isOfHLevelPath 4 (isOfHLevelTrunc 4) _ _)
(λ x → cong f (push (inr x)) ∙∙ funExt⁻ r x ∙∙ refl)
((λ x → cong f (push (inl x)) ∙∙ funExt⁻ r x ∙∙ sym (rUnitₖ 2 ∣ x ∣ₕ)))
(cong (_∙∙ funExt⁻ r north ∙∙ refl)
(cong (cong f) λ j i → push (push tt j) i))))))
(fun PathIdTrunc₀Iso p)
mainEq : ((fst qHom) (α' ⌣ α') ≡ qHom .fst (β' +ₕ β'))
⊎ ((fst qHom) (α' ⌣ α') ≡ qHom .fst (-ₕ (β' +ₕ β')))
mainEq =
⊎rec
(λ id → inl (lem₁ ∙ lem₂
∙ cong (λ x → x +ₕ x) (sym id)
∙ sym (pres· (snd qHom) β' β')))
(λ id → inr (lem₁ ∙ lem₂
∙ ((sym (distLem (x ⌣ y))
∙ cong -ₕ_ (cong (λ x → x +ₕ x) (sym id)))
∙ cong (-ₕ_) (pres· (snd qHom) β' β'))
∙ sym (presinv (snd qHom) (β' +ₕ β'))))
rewriteEquation2
where
triv⌣ : (a : S¹)
→ cong₂ (_⌣ₖ_ {n = 2} {m = 2}) (cong ∣_∣ₕ (merid a)) (cong ∣_∣ₕ (merid a))
≡ λ _ → ∣ north ∣ₕ
triv⌣ a =
cong₂Funct (_⌣ₖ_ {n = 2} {m = 2})
(cong ∣_∣ₕ (merid a)) (cong ∣_∣ₕ (merid a))
∙ sym (rUnit λ j → _⌣ₖ_ {n = 2} {m = 2} ∣ merid a j ∣ₕ ∣ north ∣)
∙ (λ i j → ⌣ₖ-0ₖ 2 2 ∣ merid a j ∣ₕ i)
distLem : (x : coHom 4 (S₊ 2 × S₊ 2)) → -ₕ ((-ₕ x) +ₕ (-ₕ x)) ≡ x +ₕ x
distLem =
sElim (λ _ → isSetPathImplicit)
λ f → cong ∣_∣₂ (funExt λ x → cong -ₖ_ (sym (-distrₖ 4 (f x) (f x)))
∙ -ₖ^2 (f x +ₖ f x))
x⌣x≡0 : x ⌣ x ≡ 0ₕ 4
x⌣x≡0 =
cong ∣_∣₂
(funExt (uncurry λ { north y → refl
; south y → refl
; (merid a i) y j → triv⌣ a j i}))
y⌣y≡0 : y ⌣ y ≡ 0ₕ 4
y⌣y≡0 =
cong ∣_∣₂
(funExt (uncurry λ { x north → refl
; x south → refl
; x (merid a i) j → triv⌣ a j i}))
-ₕ'Id : (x : coHom 4 (S₊ 2 × S₊ 2)) → (-ₕ'^ 2 · 2) x ≡ x
-ₕ'Id =
sElim (λ _ → isSetPathImplicit)
λ f → cong ∣_∣₂ (funExt λ x → -ₖ'-gen-inl-left 2 2 tt (inl tt) (f x))
y⌣x≡x⌣y : y ⌣ x ≡ x ⌣ y
y⌣x≡x⌣y =
y ⌣ x ≡⟨ gradedComm'-⌣ 2 2 y x ⟩
(-ₕ'^ 2 · 2) (transport refl (x ⌣ y)) ≡⟨ -ₕ'Id (transport refl (x ⌣ y)) ⟩
transport refl (x ⌣ y) ≡⟨ transportRefl (x ⌣ y) ⟩
x ⌣ y ∎
lem₂ : (x +ₕ y) ⌣ (x +ₕ y) ≡ (x ⌣ y) +ₕ (x ⌣ y)
lem₂ =
(x +ₕ y) ⌣ (x +ₕ y) ≡⟨ leftDistr-⌣ 2 2 (x +ₕ y) x y ⟩
((x +ₕ y) ⌣ x) +ₕ ((x +ₕ y) ⌣ y) ≡⟨ cong₂ _+ₕ_ (rightDistr-⌣ 2 2 x y x) (rightDistr-⌣ 2 2 x y y) ⟩
((x ⌣ x +ₕ y ⌣ x)) +ₕ (x ⌣ y +ₕ y ⌣ y) ≡⟨ cong₂ _+ₕ_ (cong (_+ₕ y ⌣ x) x⌣x≡0 ∙ lUnitₕ 4 (y ⌣ x))
(cong (x ⌣ y +ₕ_) y⌣y≡0 ∙ rUnitₕ 4 (x ⌣ y)) ⟩
y ⌣ x +ₕ x ⌣ y ≡⟨ cong (_+ₕ (x ⌣ y)) y⌣x≡x⌣y ⟩
((x ⌣ y) +ₕ (x ⌣ y)) ∎
lem₁ : (fst qHom) (α' ⌣ α') ≡ (x +ₕ y) ⌣ (x +ₕ y)
lem₁ =
fst qHom (α' ⌣ α') ≡⟨ refl ⟩
fst (qHomGen 2) α' ⌣ fst (qHomGen 2) α' ≡⟨ cong (λ x → x ⌣ x) α'↦x+y ⟩
((x +ₕ y) ⌣ (x +ₕ y)) ∎
main⊎ : (HopfInvariant 0 (fold∘W , refl) ≡ 2)
⊎ (HopfInvariant 0 (fold∘W , refl) ≡ -2)
main⊎ =
⊎rec (λ p → inl (lem₁
∙ cong (fun (fst (Hopfβ-Iso 0 (fold∘W , refl)))) p
∙ pres· (Hopfβ-Iso 0 (fold∘W , refl) .snd) β β
∙ cong (λ x → x + x) (Hopfβ↦1 0 (fold∘W , refl))))
(λ p → inr (lem₁
∙ cong (fun (fst (Hopfβ-Iso 0 (fold∘W , refl)))) p
∙ presinv (Hopfβ-Iso 0 (fold∘W , refl) .snd) (β +ₕ β)
∙ cong (GroupStr.inv (snd ℤGroup))
(pres· (Hopfβ-Iso 0 (fold∘W , refl) .snd) β β
∙ cong (λ x → x + x) (Hopfβ↦1 0 (fold∘W , refl)))))
lem₂
where
lem₁ : HopfInvariant 0 (fold∘W , refl)
≡ fun (fst (Hopfβ-Iso 0 (fold∘W , refl))) (α ⌣ α)
lem₁ =
cong (fun (fst (Hopfβ-Iso 0 (fold∘W , refl)))) (transportRefl (α ⌣ α))
lem₂ : (α ⌣ α ≡ β +ₕ β) ⊎ (α ⌣ α ≡ -ₕ (β +ₕ β))
lem₂ =
rewriteEquation
(⊎rec (λ p → inl (sym (retEq (fst isEquiv-qHom) (α' ⌣ α'))
∙∙ cong (invEq (fst isEquiv-qHom)) p
∙∙ retEq (fst isEquiv-qHom) (β' +ₕ β')))
(λ p → inr ((sym (retEq (fst isEquiv-qHom) (α' ⌣ α'))
∙∙ cong (invEq (fst isEquiv-qHom)) p
∙∙ retEq (fst isEquiv-qHom) (-ₕ (β' +ₕ β')))))
mainEq)
main : abs (HopfInvariant 0 (fold∘W , refl)) ≡ 2
main = ⊎→abs _ 2 main⊎
-- We instantiate the module
Brunerie'≡2 : abs (HopfInvariant 0 (fold∘W , refl)) ≡ 2
Brunerie'≡2 = BrunerieNumLem.main (Hⁿ⁺ᵐ-Sⁿ×Sᵐ≅ℤ-abs 1 1) Hⁿ⁺ᵐ-Sⁿ×Sᵐ≅ℤ-⌣
-- We rewrite the it slightly, to get the definition of the Brunerie
-- number in Brunerie (2016)
Brunerie'≡Brunerie : [ ∣ idfun∙ (S₊∙ 2) ∣₂ ∣ ∣ idfun∙ (S₊∙ 2) ∣₂ ]π' ≡ ∣ fold∘W , refl ∣₂
Brunerie'≡Brunerie =
cong ∣_∣₂ ([]≡[]₂ (idfun∙ (S₊∙ 2)) (idfun∙ (S₊∙ 2)) )
∙ sym fold∘W≡Whitehead
∙ cong ∣_∣₂ (∘∙-idˡ (fold∘W , refl))
-- And we get the main result
Brunerie≡2 : Brunerie ≡ 2
Brunerie≡2 =
cong abs (cong (HopfInvariant-π' 0) Brunerie'≡Brunerie)
∙ Brunerie'≡2
| 37.405473
| 112
| 0.530092
|
41a622ad7d108b39857d47e57ea5238e325d5fda
| 6,150
|
agda
|
Agda
|
src/fot/FOTC/Data/Nat/Induction/NonAcc/LexicographicATP.agda
|
asr/fotc
|
2fc9f2b81052a2e0822669f02036c5750371b72d
|
[
"MIT"
] | 11
|
2015-09-03T20:53:42.000Z
|
2021-09-12T16:09:54.000Z
|
src/fot/FOTC/Data/Nat/Induction/NonAcc/LexicographicATP.agda
|
asr/fotc
|
2fc9f2b81052a2e0822669f02036c5750371b72d
|
[
"MIT"
] | 2
|
2016-10-12T17:28:16.000Z
|
2017-01-01T14:34:26.000Z
|
src/fot/FOTC/Data/Nat/Induction/NonAcc/LexicographicATP.agda
|
asr/fotc
|
2fc9f2b81052a2e0822669f02036c5750371b72d
|
[
"MIT"
] | 3
|
2016-09-19T14:18:30.000Z
|
2018-03-14T08:50:00.000Z
|
------------------------------------------------------------------------------
-- Well-founded induction on the lexicographic order on natural numbers
------------------------------------------------------------------------------
{-# OPTIONS --exact-split #-}
{-# OPTIONS --no-sized-types #-}
{-# OPTIONS --no-universe-polymorphism #-}
{-# OPTIONS --without-K #-}
-- N.B This module does not contain combined proofs, but it imports
-- modules which contain combined proofs.
module FOTC.Data.Nat.Induction.NonAcc.LexicographicATP where
open import FOTC.Base
open import FOTC.Data.Nat.Inequalities
open import FOTC.Data.Nat.Inequalities.EliminationPropertiesATP
open import FOTC.Data.Nat.Inequalities.PropertiesATP
open import FOTC.Data.Nat.Type
------------------------------------------------------------------------------
Lexi-wfind :
(A : D → D → Set) →
(∀ {m₁ n₁} → N m₁ → N n₁ →
(∀ {m₂ n₂} → N m₂ → N n₂ → Lexi m₂ n₂ m₁ n₁ → A m₂ n₂) → A m₁ n₁) →
∀ {m n} → N m → N n → A m n
Lexi-wfind A h Nm Nn = h Nm Nn (helper₂ Nm Nn)
where
helper₁ : ∀ {m n o} → N m → N n → N o → m < o → o < succ₁ n → m < n
helper₁ {m} {n} {o} Nm Nn No m<o o<Sn =
Sx≤y→x<y Nm Nn (≤-trans (nsucc Nm) No Nn
(x<y→Sx≤y Nm No m<o)
(Sx≤Sy→x≤y {o} {n} (x<y→Sx≤y No (nsucc Nn) o<Sn)))
helper₂ : ∀ {m₁ n₁ m₂ n₂} → N m₁ → N n₁ → N m₂ → N n₂ →
Lexi m₂ n₂ m₁ n₁ → A m₂ n₂
helper₂ Nm₁ Nn₂ nzero nzero 00<00 =
h nzero nzero (λ Nm' Nn' m'n'<00 → ⊥-elim (xy<00→⊥ Nm' Nn' m'n'<00))
helper₂ nzero nzero (nsucc Nm₂) nzero Sm₂0<00 = ⊥-elim (Sxy₁<0y₂→⊥ Sm₂0<00)
helper₂ (nsucc Nm₁) nzero (nsucc Nm₂) nzero Sm₂0<Sm₁0 =
h (nsucc Nm₂) nzero (λ Nm' Nn' m'n'<Sm₂0 →
helper₂ Nm₁ nzero Nm' Nn'
(inj₁ (helper₁ Nm' Nm₁ (nsucc Nm₂)
(x₁y<x₂0→x₁<x₂ Nn' m'n'<Sm₂0)
(x₁y<x₂0→x₁<x₂ nzero Sm₂0<Sm₁0))))
helper₂ nzero (nsucc Nn₁) (nsucc Nm₂) nzero Sm₂0<0Sn₁ =
⊥-elim (Sxy₁<0y₂→⊥ Sm₂0<0Sn₁)
helper₂ (nsucc Nm₁) (nsucc Nn₁) (nsucc Nm₂) nzero Sm₂0<Sm₁Sn₁ =
h (nsucc Nm₂) nzero (λ Nm' Nn' m'n'<Sm₂0 →
helper₂ (nsucc Nm₁) Nn₁ Nm' Nn'
(inj₁ (case (λ Sm₂<Sm₁ → x<y→x<Sy Nm' Nm₁
(helper₁ Nm' Nm₁ (nsucc Nm₂)
(x₁y<x₂0→x₁<x₂ Nn' m'n'<Sm₂0)
Sm₂<Sm₁))
(λ Sm₂≡Sm₁∧0<Sn₁ → x<y→y≡z→x<z (x₁y<x₂0→x₁<x₂ Nn' m'n'<Sm₂0)
(∧-proj₁ Sm₂≡Sm₁∧0<Sn₁))
Sm₂0<Sm₁Sn₁)))
helper₂ nzero nzero nzero (nsucc Nn₂) 0Sn₂<00 = ⊥-elim (0Sx<00→⊥ 0Sn₂<00)
helper₂ (nsucc {m₁} Nm₁) nzero nzero (nsucc Nn₂) 0Sn₂<Sm₁0 =
h nzero (nsucc Nn₂) (λ Nm' Nn' m'n'<0Nn₂ →
helper₂ Nm₁ (nsucc Nn₂) Nm' Nn'
(case (λ m'<0 → ⊥-elim (x<0→⊥ Nm' m'<0))
(λ m'≡0∧n'<Sn₂ →
case (λ 0<m₁ → inj₁ (x≡y→y<z→x<z (∧-proj₁ m'≡0∧n'<Sn₂) 0<m₁))
(λ 0≡m₁ → inj₂ ((trans (∧-proj₁ m'≡0∧n'<Sn₂) 0≡m₁)
, (∧-proj₂ m'≡0∧n'<Sn₂)))
(x<Sy→x<y∨x≡y nzero Nm₁ 0<Sm₁))
m'n'<0Nn₂))
where
0<Sm₁ : zero < succ₁ m₁
0<Sm₁ = x₁y<x₂0→x₁<x₂ (nsucc Nn₂) 0Sn₂<Sm₁0
helper₂ nzero (nsucc Nn₁) nzero (nsucc Nn₂) 0Sn₂<0Sn₁ =
case (λ 0<0 → ⊥-elim (0<0→⊥ 0<0))
(λ 0≡0∧Sn₂<Sn₁ →
h nzero (nsucc Nn₂) (λ Nm' Nn' m'n'<0Sn₂ →
case (λ m'<0 → ⊥-elim (x<0→⊥ Nm' m'<0))
(λ m'≡0∧n'<Sn₂ →
helper₂ nzero Nn₁ Nm' Nn'
(inj₂ (∧-proj₁ m'≡0∧n'<Sn₂
, helper₁ Nn' Nn₁ (nsucc Nn₂)
(∧-proj₂ m'≡0∧n'<Sn₂)
(∧-proj₂ 0≡0∧Sn₂<Sn₁))))
m'n'<0Sn₂))
0Sn₂<0Sn₁
helper₂ (nsucc Nm₁) (nsucc Nn₁) nzero (nsucc Nn₂) 0Sn₂<Sm₁Sn₁ =
h nzero (nsucc Nn₂) (λ Nm' Nn' m'n'<0Sn₂ →
helper₂ (nsucc Nm₁) Nn₁ Nm' Nn'
(case (λ m'<0 → ⊥-elim (x<0→⊥ Nm' m'<0))
(λ m'≡0∧n'<Sn₂ →
case (λ 0<Sm₁ → inj₁ (x≡y→y<z→x<z (∧-proj₁ m'≡0∧n'<Sn₂) 0<Sm₁))
(λ 0≡Sn₂∧Sn₂<Sn₁ → ⊥-elim (0≢S (∧-proj₁ 0≡Sn₂∧Sn₂<Sn₁)))
0Sn₂<Sm₁Sn₁)
m'n'<0Sn₂))
helper₂ nzero nzero (nsucc Nm₂) (nsucc Nn₂) Sm₂Sn₂<00 =
⊥-elim (xy<00→⊥ (nsucc Nm₂) (nsucc Nn₂) Sm₂Sn₂<00)
helper₂ (nsucc {m₁} Nm₁) nzero (nsucc {m₂} Nm₂) (nsucc Nn₂) Sm₂Sn₂<Sm₁0 =
h (nsucc Nm₂) (nsucc Nn₂) (λ Nm' Nn' m'n'<Sm₂Sn₂ →
helper₂ Nm₁ (nsucc Nn₂) Nm' Nn'
(case (λ m'<Sm₂ → inj₁ (helper₁ Nm' Nm₁ (nsucc Nm₂) m'<Sm₂ Sm₂<Sm₁))
(λ m'≡Sm₂∧n'<Sn₂ →
case (λ m'<m₁ → inj₁ m'<m₁)
(λ m'≡m₁ → inj₂ (m'≡m₁ , ∧-proj₂ m'≡Sm₂∧n'<Sn₂))
(x<Sy→x<y∨x≡y Nm' Nm₁
(x≡y→y<z→x<z (∧-proj₁ m'≡Sm₂∧n'<Sn₂) Sm₂<Sm₁)))
m'n'<Sm₂Sn₂))
where
Sm₂<Sm₁ : succ₁ m₂ < succ₁ m₁
Sm₂<Sm₁ = x₁y<x₂0→x₁<x₂ (nsucc Nn₂) Sm₂Sn₂<Sm₁0
helper₂ nzero (nsucc Nn₁) (nsucc Nm₂) (nsucc Nn₂) Sm₂Sn₂<0Sn₁
= ⊥-elim (Sxy₁<0y₂→⊥ Sm₂Sn₂<0Sn₁)
helper₂ (nsucc Nm₁) (nsucc Nn₁) (nsucc Nm₂) (nsucc Nn₂) Sm₂Sn₂<Sm₁Sn₁ =
h (nsucc Nm₂) (nsucc Nn₂) (λ Nm' Nn' m'n'<Sm₂Sn₂ →
helper₂ (nsucc Nm₁) Nn₁ Nm' Nn'
(case (λ Sm₂<Sm₁ →
case (λ m'<Sm₂ → inj₁ (x<y→x<Sy Nm' Nm₁ (helper₁ Nm' Nm₁ (nsucc Nm₂) m'<Sm₂ Sm₂<Sm₁)))
(λ m'≡Sm₂∧n'<Sn₂ → inj₁ (x≡y→y<z→x<z (∧-proj₁ m'≡Sm₂∧n'<Sn₂) Sm₂<Sm₁))
m'n'<Sm₂Sn₂)
(λ Sm₂≡Sm₁∧Sn₂<Sn₁ →
case (λ m'<Sm₂ → inj₁ (x<y→y≡z→x<z m'<Sm₂ (∧-proj₁ Sm₂≡Sm₁∧Sn₂<Sn₁)))
(λ m'≡Sm₂∧n'<Sn₂ → inj₂
(trans (∧-proj₁ m'≡Sm₂∧n'<Sn₂) (∧-proj₁ Sm₂≡Sm₁∧Sn₂<Sn₁)
, helper₁ Nn' Nn₁ (nsucc Nn₂) (∧-proj₂ m'≡Sm₂∧n'<Sn₂) (∧-proj₂ Sm₂≡Sm₁∧Sn₂<Sn₁)))
m'n'<Sm₂Sn₂)
Sm₂Sn₂<Sm₁Sn₁))
| 43.309859
| 104
| 0.454472
|
34465fe79c0e109897b948dc12bf5fcd7da33d59
| 6,838
|
agda
|
Agda
|
Cubical/Data/Fin/Properties.agda
|
ryanorendorff/cubical
|
c67854d2e11aafa5677e25a09087e176fafd3e43
|
[
"MIT"
] | 1
|
2020-03-23T23:52:11.000Z
|
2020-03-23T23:52:11.000Z
|
Cubical/Data/Fin/Properties.agda
|
ryanorendorff/cubical
|
c67854d2e11aafa5677e25a09087e176fafd3e43
|
[
"MIT"
] | null | null | null |
Cubical/Data/Fin/Properties.agda
|
ryanorendorff/cubical
|
c67854d2e11aafa5677e25a09087e176fafd3e43
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --cubical --safe #-}
module Cubical.Data.Fin.Properties where
open import Cubical.Core.Everything
open import Cubical.Functions.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 as Fin
open import Cubical.Data.Nat
open import Cubical.Data.Nat.Order
open import Cubical.Data.Empty as Empty
open import Cubical.Data.Sum
open import Cubical.Data.Sigma
open import Cubical.Induction.WellFounded
private
variable
a b ℓ : Level
A : Type a
-- Fin 0 is empty, and thus a proposition.
isPropFin0 : isProp (Fin 0)
isPropFin0 = Empty.rec ∘ ¬Fin0
-- Fin 1 has only one value.
isContrFin1 : isContr (Fin 1)
isContrFin1
= fzero , λ
{ (zero , _) → toℕ-injective refl
; (suc k , sk<1) → Empty.rec (¬-<-zero (pred-≤-pred sk<1))
}
-- Regardless of k, Fin k is a set.
isSetFin : ∀{k} → isSet (Fin k)
isSetFin {k} = isSetΣ isSetℕ (λ _ → isProp→isSet m≤n-isProp)
private
subst-app : (B : A → Type b) (f : (x : A) → B x) {x y : A} (x≡y : x ≡ y) →
subst B x≡y (f x) ≡ f y
subst-app B f {x = x} =
J (λ y e → subst B e (f x) ≡ f y) (substRefl {B = B} (f x))
-- Computation rules for the eliminator.
module _ (P : ∀ {k} → Fin k → Type ℓ)
(fz : ∀ {k} → P {suc k} fzero)
(fs : ∀ {k} {fn : Fin k} → P fn → P (fsuc fn))
{k : ℕ} where
elim-fzero : Fin.elim P fz fs {k = suc k} fzero ≡ fz
elim-fzero =
subst P (toℕ-injective _) fz ≡⟨ cong (λ p → subst P p fz) (isSetFin _ _ _ _) ⟩
subst P refl fz ≡⟨ substRefl {B = P} fz ⟩
fz ∎
elim-fsuc : (fk : Fin k) → Fin.elim P fz fs (fsuc fk) ≡ fs (Fin.elim P fz fs fk)
elim-fsuc fk =
subst P (toℕ-injective (λ _ → toℕ (fsuc fk′))) (fs (Fin.elim P fz fs fk′))
≡⟨ cong (λ p → subst P p (fs (Fin.elim P fz fs fk′)) ) (isSetFin _ _ _ _) ⟩
subst P (cong fsuc fk′≡fk) (fs (Fin.elim P fz fs fk′))
≡⟨ subst-app _ (λ fj → fs (Fin.elim P fz fs fj)) fk′≡fk ⟩
fs (Fin.elim P fz fs fk)
∎
where
fk′ = fst fk , pred-≤-pred (snd (fsuc fk))
fk′≡fk : fk′ ≡ fk
fk′≡fk = toℕ-injective refl
-- 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
= Empty.rec (<-asym r<sk (lemma₀ refl p))
expand×Inj k {(r , r<sk) , zero} {f2 , suc o2} p
= Empty.rec (<-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 = Empty.rec ∘ ¬Fin0 ∘ fst
expand×Emb (suc k)
= injEmbedding (isSetΣ 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) = Empty.rec (<-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) = Empty.rec (<-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)
-- the modulo operator on ℕ
_%_ : ℕ → ℕ → ℕ
n % zero = n
n % (suc k) = toℕ (extract (reduce k n))
n%k≡n[modk] : ∀ n k → Σ[ o ∈ ℕ ] o * k + n % k ≡ n
n%k≡n[modk] n zero = zero , refl
n%k≡n[modk] n (suc k) = o , sym (expand≡ _ _ o) ∙ reduce k n .snd
where o = reduce k n .fst .snd
n%sk<sk : (n k : ℕ) → (n % suc k) < suc k
n%sk<sk n k = extract (reduce k n) .snd
| 31.657407
| 82
| 0.582042
|
4399a07c62dc148c5b35f55ae7b216cad2a76576
| 4,230
|
agda
|
Agda
|
Cubical/Codata/M.agda
|
FernandoLarrain/cubical
|
9acdecfa6437ec455568be4e5ff04849cc2bc13b
|
[
"MIT"
] | 301
|
2018-10-17T18:00:24.000Z
|
2022-03-24T02:10:47.000Z
|
Cubical/Codata/M.agda
|
FernandoLarrain/cubical
|
9acdecfa6437ec455568be4e5ff04849cc2bc13b
|
[
"MIT"
] | 584
|
2018-10-15T09:49:02.000Z
|
2022-03-30T12:09:17.000Z
|
Cubical/Codata/M.agda
|
FernandoLarrain/cubical
|
9acdecfa6437ec455568be4e5ff04849cc2bc13b
|
[
"MIT"
] | 134
|
2018-11-16T06:11:03.000Z
|
2022-03-23T16:22:13.000Z
|
{-# OPTIONS --safe --guardedness #-}
module Cubical.Codata.M where
open import Cubical.Foundations.Prelude
-- TODO move
module Helpers where
module _ {ℓ ℓ'} {A : Type ℓ} {x : A} (P : ∀ y → x ≡ y → Type ℓ') (d : P x refl) where
-- A version with y as an explicit argument can be used to make Agda
-- infer the family P.
J' : ∀ y (p : x ≡ y) → P y p
J' y p = J P d p
lem-transp : ∀ {ℓ} {A : Type ℓ} (i : I) → (B : Type ℓ) (P : A ≡ B) → (p : P i) → PathP (\ j → P j) (transp (\ k → P (~ k ∧ i)) (~ i) p)
(transp (\ k → P (k ∨ i)) i p)
lem-transp {A = A} i = J' _ (\ p j → transp (\ _ → A) ((~ j ∧ ~ i) ∨ (j ∧ i)) p )
transp-over : ∀ {ℓ} (A : I → Type ℓ) (i j : I) → A i → A j
transp-over A i k p = transp (\ j → A ((~ j ∧ i) ∨ (j ∧ k))) (~ i ∧ ~ k) p
transp-over-1 : ∀ {ℓ} (A : I → Type ℓ) (i j : I) → A i → A j
transp-over-1 A i k p = transp (\ j → A ((j ∨ i) ∧ (~ j ∨ k))) (i ∧ k) p
compPathD : {ℓ ℓ' : _} {X : Type ℓ} (F : X → Type ℓ') {A B C : X} (P : A ≡ B) (Q : B ≡ C)
→ ∀ {x y z} → (\ i → F (P i)) [ x ≡ y ] → (\ i → F (Q i)) [ y ≡ z ] → (\ i → F ((P ∙ Q) i)) [ x ≡ z ]
compPathD F {A = A} P Q {x} p q i =
comp (\ j → F (hfill (λ j → \ { (i = i0) → A ; (i = i1) → Q j })
(inS (P i))
j))
(λ j → \ { (i = i0) → x; (i = i1) → q j })
(p i)
open Helpers
IxCont : ∀ {ℓ} -> Type ℓ → Type (ℓ-suc ℓ)
IxCont {ℓ} X = Σ (X → Type ℓ) λ S → ∀ x → S x → X → Type ℓ
⟦_⟧ : ∀ {ℓ} {X : Type ℓ} → IxCont X → (X → Type ℓ) → (X → Type ℓ)
⟦ (S , P) ⟧ X x = Σ (S x) λ s → ∀ y → P x s y → X y
record M {ℓ} {X : Type ℓ} (C : IxCont X) (x : X) : Type ℓ where -- Type₀
coinductive
field
head : C .fst x
tails : ∀ y → C .snd x head y → M C y
open M public
module _ {ℓ} {X : Type ℓ} {C : IxCont X} where
private
F = ⟦ C ⟧
inM : ∀ x → F (M C) x → M C x
inM x (head , tail) = record { head = head ; tails = tail }
out : ∀ x → M C x → F (M C) x
out x a = (a .head) , (a .tails)
mapF : ∀ {A B} → (∀ x → A x → B x) → ∀ x → F A x → F B x
mapF f x (s , t) = s , \ y p → f _ (t y p)
unfold : ∀ {A} (α : ∀ x → A x → F A x) → ∀ x → A x → M C x
unfold α x a .head = α x a .fst
unfold α x a .tails y p = unfold α y (α x a .snd y p)
-- We generalize the type to avoid upsetting --guardedness by
-- transporting after the corecursive call.
-- Recognizing hcomp/transp as guardedness-preserving could be a better solution.
unfold-η' : ∀ {A} (α : ∀ x → A x → F A x) → (h : ∀ x → A x → M C x)
→ (∀ (x : X) (a : A x) → out x (h x a) ≡ mapF h x (α x a))
→ ∀ (x : X) (a : A x) m → h x a ≡ m → m ≡ unfold α x a
unfold-η' α h eq x a m eq' = let heq = cong head (sym eq') ∙ cong fst (eq x a)
in \ where
i .head → heq i
i .tails y p →
let p0 = (transp-over-1 (\ k → C .snd x (heq k) y) i i1 p)
p1 = (transp-over (\ k → C .snd x (heq k) y) i i0 p)
pe = lem-transp i _ (\ k → C .snd x (heq k) y) p
tl = compPathD (λ p → C .snd x p y → M C y)
(cong head (sym eq')) (cong fst (eq x a))
(cong (\ f → f .tails y) (sym eq'))
(cong (\ f → f .snd y) (eq x a))
in unfold-η' α h eq y (α x a .snd y p0)
(m .tails y p1)
(sym (\ k → tl k (pe k)))
i
unfold-η : ∀ {A} (α : ∀ x → A x → F A x) → (h : ∀ x → A x → M C x)
→ (∀ (x : X) (a : A x) → out x (h x a) ≡ mapF h x (α x a))
→ ∀ (x : X) (a : A x) → h x a ≡ unfold α x a
unfold-η α h eq x a = unfold-η' α h eq x a _ refl
| 44.0625
| 137
| 0.362175
|
d0b329fcabecd17bc34ba8716e8d5d687d1c2dbd
| 961
|
agda
|
Agda
|
src/fot/FOTC/Data/Nat/List/PropertiesATP.agda
|
asr/fotc
|
2fc9f2b81052a2e0822669f02036c5750371b72d
|
[
"MIT"
] | 11
|
2015-09-03T20:53:42.000Z
|
2021-09-12T16:09:54.000Z
|
src/fot/FOTC/Data/Nat/List/PropertiesATP.agda
|
asr/fotc
|
2fc9f2b81052a2e0822669f02036c5750371b72d
|
[
"MIT"
] | 2
|
2016-10-12T17:28:16.000Z
|
2017-01-01T14:34:26.000Z
|
src/fot/FOTC/Data/Nat/List/PropertiesATP.agda
|
asr/fotc
|
2fc9f2b81052a2e0822669f02036c5750371b72d
|
[
"MIT"
] | 3
|
2016-09-19T14:18:30.000Z
|
2018-03-14T08:50:00.000Z
|
------------------------------------------------------------------------------
-- Properties related with lists of natural numbers
------------------------------------------------------------------------------
{-# OPTIONS --exact-split #-}
{-# OPTIONS --no-sized-types #-}
{-# OPTIONS --no-universe-polymorphism #-}
{-# OPTIONS --without-K #-}
module FOTC.Data.Nat.List.PropertiesATP where
open import FOTC.Base
open import FOTC.Base.List
open import FOTC.Data.Nat.List
open import FOTC.Data.List
------------------------------------------------------------------------------
++-ListN : ∀ {ms ns} → ListN ms → ListN ns → ListN (ms ++ ns)
++-ListN {ns = ns} lnnil nsL = prf
where postulate prf : ListN ([] ++ ns)
{-# ATP prove prf #-}
++-ListN {ns = ns} (lncons {m} {ms} Nd LNms) LNns = prf (++-ListN LNms LNns)
where postulate prf : ListN (ms ++ ns) → ListN ((m ∷ ms) ++ ns)
{-# ATP prove prf #-}
| 35.592593
| 78
| 0.443288
|
0324fea1a84fd48e792a4a07b5f669f7406f138a
| 202
|
agda
|
Agda
|
examples/AIM5/PolyDep/Main.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
examples/AIM5/PolyDep/Main.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
examples/AIM5/PolyDep/Main.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
module Main where
import PolyDepPrelude
import Homogenous.Base
import Homogenous.Equality
import Homogenous.Reflexivity
import Homogenous.Nat
import Tools
import Reflexivity
import EqBase
import TYPE
| 15.538462
| 29
| 0.866337
|
22a2e80c8608329a491c4aa3146cb5202e862d73
| 1,919
|
agda
|
Agda
|
src/Control/Comonad.agda
|
andreasabel/cubical
|
914f655c7c0417754c2ffe494d3f6ea7a357b1c3
|
[
"MIT"
] | null | null | null |
src/Control/Comonad.agda
|
andreasabel/cubical
|
914f655c7c0417754c2ffe494d3f6ea7a357b1c3
|
[
"MIT"
] | null | null | null |
src/Control/Comonad.agda
|
andreasabel/cubical
|
914f655c7c0417754c2ffe494d3f6ea7a357b1c3
|
[
"MIT"
] | null | null | null |
-- Non-indexed (plain) monads in form of Kleisli triple, presented in point-free style.
module Control.Comonad where
open import Function using (id) renaming (_∘′_ to _∘_)
open import Relation.Binary.PropositionalEquality
open ≡-Reasoning
open import Axiom.FunctionExtensionality
open import Control.Functor
record IsComonad (W : Set → Set) : Set₁ where
-- Methods.
field
extract : ∀ {A } → W A → A
extend : ∀ {A B} → (W A → B) → W A → W B
-- Laws.
field
extend-β : ∀ {A B} {k : W A → B} →
extract ∘ extend k ≡ k
extend-η : ∀ {A} →
extend {A = A} extract ≡ id
extend-∘ : ∀ {A B C} {k : W A → B} {l : W B → C} →
extend (l ∘ extend k) ≡ extend l ∘ extend k
-- Comonadic composition.
comComp : ∀ {A B C : Set} (l : W B → C) (k : W A → B) → (W A → C)
comComp l k = l ∘ extend k
-- Functoriality.
isFunctor : IsFunctor W
isFunctor = record
{ ops = record { map = map }
; laws = record { map-id = extend-η ; map-∘ = λ {A B C f g} → sym (map-∘-sym f g) }
}
where
map : ∀ {A B} → (A → B) → W A → W B
map f = extend (f ∘ extract)
map-∘-sym : ∀ {A B C} (f : A → B) (g : B → C) → map g ∘ map f ≡ map (g ∘ f)
map-∘-sym f g = begin
map g ∘ map f ≡⟨⟩
extend (g ∘ extract) ∘ extend (f ∘ extract) ≡⟨ sym extend-∘ ⟩
extend (g ∘ extract ∘ extend (f ∘ extract)) ≡⟨ cong (λ z → extend (g ∘ z)) extend-β ⟩
extend (g ∘ f ∘ extract) ≡⟨⟩
map (g ∘ f) ∎
open IsFunctor isFunctor public
-- Monads in Kleisli Triple presentation.
record Comonad : Set₁ where
constructor comonad
field
W : Set → Set
W! : IsComonad W
open IsComonad W! public
-- Casting a Comonad to a Functor
FunctorOfComonad : Comonad → Functor
FunctorOfComonad WW = functor W isFunctor
where open Comonad WW
| 24.922078
| 94
| 0.53778
|
5ebdb4891aeba5ea2d542daf61544891a560bb7c
| 1,263
|
agda
|
Agda
|
Examples/Lambda/Lambda.agda
|
LcicC/inference-systems-agda
|
b9043f99e4bf7211db4066a7a943401d127f0c8f
|
[
"MIT"
] | 3
|
2022-03-10T15:53:47.000Z
|
2022-03-25T15:48:52.000Z
|
Examples/Lambda/Lambda.agda
|
LcicC/inference-systems-agda
|
b9043f99e4bf7211db4066a7a943401d127f0c8f
|
[
"MIT"
] | null | null | null |
Examples/Lambda/Lambda.agda
|
LcicC/inference-systems-agda
|
b9043f99e4bf7211db4066a7a943401d127f0c8f
|
[
"MIT"
] | null | null | null |
--------------------------------------------------------------------------------
-- This is part of Agda Inference Systems
open import Data.Nat
open import Data.Fin
module Examples.Lambda.Lambda where
{- Terms & Values -}
data Term (n : ℕ) : Set where
var : Fin n → Term n
lambda : Term (suc n) → Term n
app : Term n → Term n → Term n
data Value : Set where
lambda : Term 1 → Value
term : Value → Term 0
term (lambda x) = lambda x
{- Substitution -}
ext : ∀{n m} → (Fin n → Fin m) → (Fin (suc n) → Fin (suc m))
ext f zero = zero
ext f (suc n) = suc (f n)
rename : ∀{n m} → (Fin n → Fin m) → (Term n → Term m)
rename f (var x) = var (f x)
rename f (lambda t) = lambda (rename (ext f) t)
rename f (app t t₁) = app (rename f t) (rename f t₁)
exts : ∀{n m} → (Fin n → Term m) → (Fin (suc n) → Term (suc m))
exts _ zero = var zero
exts f (suc n) = rename suc (f n)
subst : ∀{n m} → (Fin n → Term m) → (Term n → Term m)
subst f (var x) = f x
subst f (lambda t) = lambda (subst (exts f) t)
subst f (app t t₁) = app (subst f t) (subst f t₁)
subst-0 : ∀{n} → Term (suc n) → Term n → Term n
subst-0 {n} t t₁ = subst {suc n}{n} f t where
f : Fin (suc n) → Term n
f zero = t₁
f (suc n) = var n
| 28.704545
| 80
| 0.518606
|
d16d57eea1074f5d7c33e9193a7427a058f5e55c
| 4,622
|
agda
|
Agda
|
theorems/homotopy/EilenbergMacLane1.agda
|
timjb/HoTT-Agda
|
66f800adef943afdf08c17b8ecfba67340fead5e
|
[
"MIT"
] | null | null | null |
theorems/homotopy/EilenbergMacLane1.agda
|
timjb/HoTT-Agda
|
66f800adef943afdf08c17b8ecfba67340fead5e
|
[
"MIT"
] | null | null | null |
theorems/homotopy/EilenbergMacLane1.agda
|
timjb/HoTT-Agda
|
66f800adef943afdf08c17b8ecfba67340fead5e
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --without-K --rewriting #-}
open import HoTT
module homotopy.EilenbergMacLane1 {i} (G : Group i) where
private
module G = Group G
comp-equiv : ∀ g → G.El ≃ G.El
comp-equiv g = equiv
(λ x → G.comp x g)
(λ x → G.comp x (G.inv g))
(λ x → G.assoc x (G.inv g) g ∙ ap (G.comp x) (G.inv-l g) ∙ G.unit-r x)
(λ x → G.assoc x g (G.inv g) ∙ ap (G.comp x) (G.inv-r g) ∙ G.unit-r x)
comp-equiv-id : comp-equiv G.ident == ide G.El
comp-equiv-id =
pair= (λ= G.unit-r)
(prop-has-all-paths-↓ {B = is-equiv})
comp-equiv-comp : (g₁ g₂ : G.El) → comp-equiv (G.comp g₁ g₂)
== (comp-equiv g₂ ∘e comp-equiv g₁)
comp-equiv-comp g₁ g₂ =
pair= (λ= (λ x → ! (G.assoc x g₁ g₂)))
(prop-has-all-paths-↓ {B = is-equiv})
Ω-group : Group (lsucc i)
Ω-group = Ω^S-group 0
⊙[ (0 -Type i) , (G.El , G.El-level) ]
Codes-hom : G →ᴳ Ω-group
Codes-hom = group-hom (nType=-out ∘ ua ∘ comp-equiv) pres-comp where
abstract
pres-comp : ∀ g₁ g₂
→ nType=-out {A = G.El , G.El-level} {B = G.El , G.El-level} (ua (comp-equiv (G.comp g₁ g₂)))
== nType=-out {A = G.El , G.El-level} {B = G.El , G.El-level} (ua (comp-equiv g₁))
∙ nType=-out {A = G.El , G.El-level} {B = G.El , G.El-level} (ua (comp-equiv g₂))
pres-comp g₁ g₂ =
nType=-out {A = G.El , G.El-level} {B = G.El , G.El-level} (ua (comp-equiv (G.comp g₁ g₂)))
=⟨ comp-equiv-comp g₁ g₂ |in-ctx nType=-out ∘ ua ⟩
nType=-out {A = G.El , G.El-level} {B = G.El , G.El-level} (ua (comp-equiv g₂ ∘e comp-equiv g₁))
=⟨ ua-∘e (comp-equiv g₁) (comp-equiv g₂) |in-ctx nType=-out ⟩
nType=-out {A = G.El , G.El-level} {B = G.El , G.El-level} (ua (comp-equiv g₁) ∙ ua (comp-equiv g₂))
=⟨ ! $ nType-∙ {A = G.El , G.El-level} {B = G.El , G.El-level} {C = G.El , G.El-level}
(ua (comp-equiv g₁)) (ua (comp-equiv g₂)) ⟩
nType=-out {A = G.El , G.El-level} {B = G.El , G.El-level} (ua (comp-equiv g₁))
∙ nType=-out {A = G.El , G.El-level} {B = G.El , G.El-level} (ua (comp-equiv g₂))
=∎
Codes : EM₁ G → 0 -Type i
Codes = EM₁-rec {G = G} {C = 0 -Type i}
(G.El , G.El-level)
Codes-hom
abstract
↓-Codes-loop : ∀ g g' → g' == G.comp g' g [ fst ∘ Codes ↓ emloop g ]
↓-Codes-loop g g' =
↓-ap-out fst Codes (emloop g) $
↓-ap-out (idf _) fst (ap Codes (emloop g)) $
transport (λ w → g' == G.comp g' g [ idf _ ↓ ap fst w ])
(! (EM₁Rec.emloop-β (G.El , G.El-level) Codes-hom g)) $
transport (λ w → g' == G.comp g' g [ idf _ ↓ w ])
(! (fst=-β (ua $ comp-equiv g) _)) $
↓-idf-ua-in (comp-equiv g) idp
encode : {x : EM₁ G} → embase == x → fst (Codes x)
encode α = transport (fst ∘ Codes) α G.ident
encode-emloop : ∀ g → encode (emloop g) == g
encode-emloop g = to-transp $
transport (λ x → G.ident == x [ fst ∘ Codes ↓ emloop g ])
(G.unit-l g) (↓-Codes-loop g G.ident)
decode : {x : EM₁ G} → fst (Codes x) → embase == x
decode {x} =
EM₁-elim {P = λ x' → fst (Codes x') → embase == x'}
emloop
loop'
(λ _ _ → prop-has-all-paths-↓ {{↓-level ⟨⟩}})
x
where
loop' : (g : G.El)
→ emloop == emloop [ (λ x' → fst (Codes x') → embase == x') ↓ emloop g ]
loop' g = ↓-→-from-transp $ λ= $ λ y →
transport (λ z → embase == z) (emloop g) (emloop y)
=⟨ transp-cst=idf (emloop g) (emloop y) ⟩
emloop y ∙ emloop g
=⟨ ! (emloop-comp y g) ⟩
emloop (G.comp y g)
=⟨ ap emloop (! (to-transp (↓-Codes-loop g y))) ⟩
emloop (transport (λ z → fst (Codes z)) (emloop g) y) =∎
decode-encode : ∀ {x} (α : embase' G == x) → decode (encode α) == α
decode-encode idp = emloop-ident {G = G}
emloop-equiv : G.El ≃ (embase' G == embase)
emloop-equiv = equiv emloop encode decode-encode encode-emloop
Ω¹-EM₁ : Ω^S-group 0 (⊙EM₁ G) ≃ᴳ G
Ω¹-EM₁ = ≃-to-≃ᴳ (emloop-equiv ⁻¹)
(λ l₁ l₂ → <– (ap-equiv emloop-equiv _ _) $
emloop (encode (l₁ ∙ l₂))
=⟨ decode-encode (l₁ ∙ l₂) ⟩
l₁ ∙ l₂
=⟨ ! $ ap2 _∙_ (decode-encode l₁) (decode-encode l₂) ⟩
emloop (encode l₁) ∙ emloop (encode l₂)
=⟨ ! $ emloop-comp (encode l₁) (encode l₂) ⟩
emloop (G.comp (encode l₁) (encode l₂))
=∎)
π₁-EM₁ : πS 0 (⊙EM₁ G) ≃ᴳ G
π₁-EM₁ = Ω¹-EM₁ ∘eᴳ unTrunc-iso (Ω^S-group-structure 0 (⊙EM₁ G))
| 40.54386
| 110
| 0.492211
|
43e3a3f804fe974134432a12706f9df093294e92
| 28,686
|
agda
|
Agda
|
FOLdisplay.agda
|
goodlyrottenapple/FOLdisplay
|
b4f3ce288633417ce309a0a1371ad0907a007b30
|
[
"MIT"
] | null | null | null |
FOLdisplay.agda
|
goodlyrottenapple/FOLdisplay
|
b4f3ce288633417ce309a0a1371ad0907a007b30
|
[
"MIT"
] | null | null | null |
FOLdisplay.agda
|
goodlyrottenapple/FOLdisplay
|
b4f3ce288633417ce309a0a1371ad0907a007b30
|
[
"MIT"
] | null | null | null |
module FOLdisplay where
open import Data.String using (String)
open import Data.Empty
open import Data.Nat
open import Data.Product
open import Relation.Binary.PropositionalEquality as PropEq
using (_≡_; _≢_; refl; sym; cong; subst)
open import Relation.Nullary
open import Data.String using (String; _++_)
-- open import Data.Fin
-- open import Data.Fin.Subset
open import Data.List.Base as List using (List; []; _∷_; [_])
-- open import Data.Bool using () renaming (_∨_ to _∨B_)
Name : Set
Name = String
insert : ℕ → List ℕ → List ℕ
insert n List.[] = n ∷ []
insert n (x ∷ l) with n ≟ x
insert n (.n ∷ l) | yes refl = n ∷ l
insert n (x ∷ l) | no n≠x with n ≤? x
insert n (x ∷ l) | no n≠x | yes n<x = n ∷ x ∷ l
insert n (x ∷ l) | no n≠x | no n>x = x ∷ insert n l
sortRemDups : List ℕ → List ℕ
sortRemDups [] = []
sortRemDups (x ∷ xs) = insert x (sortRemDups xs)
union : List ℕ → List ℕ → List ℕ
union [] ys = ys
union (x ∷ xs) ys = insert x (union xs ys)
remove : ℕ → List ℕ → List ℕ
remove n [] = []
remove n (x ∷ xs) with n Data.Nat.≟ x
remove n (.n ∷ xs) | yes refl = xs
remove n (x ∷ xs) | no _ = x ∷ remove n xs
remove-rewrite : ∀ x {xs} -> remove x (x ∷ xs) ≡ xs
remove-rewrite x with x ≟ x
remove-rewrite x | yes refl = refl
remove-rewrite x | no x≠x = ⊥-elim (x≠x refl)
-- xs \\ ys
diff : List ℕ → List ℕ → List ℕ
diff xs [] = xs
diff xs (x ∷ ys) = diff (remove x xs) ys
--
-- mutual
-- data TermT : List ℕ -> Set where
-- VarT : (n : ℕ) → TermT [ n ]
-- ConstT : Name → TermT []
-- FunT : ∀ {xs} -> Name → (TermList xs) → TermT xs
-- -- [[[_]]]T_ : List (Term × ℕ) → Term → Term
-- data TermList : List ℕ -> Set where
-- []T : TermList []
-- _∷T_ : ∀ {xs ys} (t : TermT xs) (ts : TermT ys) -> TermList (union xs ys)
--
-- data SubstList : List ℕ -> Set where
-- []S : SubstList []
-- _/_∷S_ : ∀ {xs ys} (t : TermT xs) (x : ℕ) (ts : TermT ys) -> SubstList (union xs (remove x ys))
data Term : Set where
Var : ℕ → Term
Const : Name → Term
Fun : Name → List Term → Term
-- [[_/_]]_ : Term → ℕ → Term → Term
[[[_]]]_ : List (Term × ℕ) → Term → Term
mutual
data _⊢≡_ : Term → Term → Set where
atom : ∀ {n} → Var n ⊢≡ Var n
atomC : ∀ {n} → Const n ⊢≡ Const n
funEq : ∀ {n arg1 arg2} → arg1 ≡ₗ arg2 → Fun n arg1 ⊢≡ Fun n arg2
-- subMon : ∀ {substs X Y} → X ⊢≡ Y → ([[[ substs ]]] X) ⊢≡ ([[[ substs ]]] Y) -- this rule is derivable
sub[]R : ∀ {X Y} → X ⊢≡ Y → X ⊢≡ ([[[ [] ]]] Y)
sub[]L : ∀ {X Y} → X ⊢≡ Y → ([[[ [] ]]] X) ⊢≡ Y
subAtomEqR : ∀ {x t lst X} → X ⊢≡ ([[[ lst ]]] t) → X ⊢≡ ([[[ (t , x) ∷ lst ]]] (Var x))
subAtomEqL : ∀ {x t lst Y} → ([[[ lst ]]] t) ⊢≡ Y → ([[[ (t , x) ∷ lst ]]] (Var x)) ⊢≡ Y
subAtomNeqR : ∀ {x y t lst X} → X ⊢≡ ([[[ lst ]]] (Var x)) → x ≢ y → X ⊢≡ ([[[ (t , y) ∷ lst ]]] (Var x))
subAtomNeqL : ∀ {x y t lst Y} → ([[[ lst ]]] (Var x)) ⊢≡ Y → x ≢ y → ([[[ (t , y) ∷ lst ]]] (Var x)) ⊢≡ Y
subAtomCR : ∀ {n lst X} → X ⊢≡ (Const n) → X ⊢≡ ([[[ lst ]]] (Const n))
subAtomCL : ∀ {n lst Y} → (Const n) ⊢≡ Y → ([[[ lst ]]] (Const n)) ⊢≡ Y
subFunR : ∀ {n arg lst X} → X ⊢≡ (Fun n (List.map ([[[_]]]_ lst) arg)) → X ⊢≡ ([[[ lst ]]] (Fun n arg))
subFunL : ∀ {n arg lst Y} → (Fun n (List.map ([[[_]]]_ lst) arg)) ⊢≡ Y → ([[[ lst ]]] (Fun n arg)) ⊢≡ Y
subConsR : ∀ {lst lst' X Y} → X ⊢≡ ([[[ lst List.++ lst' ]]] Y) → X ⊢≡ ([[[ lst' ]]] ([[[ lst ]]] Y))
subConsL : ∀ {lst lst' X Y} → ([[[ lst List.++ lst' ]]] X) ⊢≡ Y → ([[[ lst' ]]] ([[[ lst ]]] X)) ⊢≡ Y
data _≡ₗ_ : List Term → List Term → Set where
[]≡ : [] ≡ₗ []
_∷≡_ : {xs : List Term} {ys : List Term} {t1 t2 : Term} → t1 ⊢≡ t2 → xs ≡ₗ ys → (t1 ∷ xs) ≡ₗ (t2 ∷ ys)
-- open import Data.Maybe using (Maybe; just; nothing; monad)
--
-- open import Category.Monad using (RawMonad)
-- open import Agda.Primitive as P
--
-- open RawMonad (monad {P.lzero}) using (_>>=_;return)
-- open Category.Monad.rawMonad
open import Data.String using () renaming (_≟_ to _≟S_)
data Term' : Set where
Var' : ℕ → Term'
Const' : Name → Term'
Fun' : Name → List Term' → Term'
mutual
data TTerm : List ℕ -> Set where
TVar : (n : ℕ) → TTerm [ n ]
TConst : Name → TTerm []
TFun : ∀ {xs} -> Name → TTermList xs → TTerm xs
data TTermList : List ℕ -> Set where
[]T : TTermList []
_∷T_ : ∀ {xs ys} (t : TTerm xs) (ts : TTermList ys) -> TTermList (union xs ys)
open import Relation.Nullary.Decidable
open import Relation.Binary.Core
open import Data.List.Any as LAny
open LAny.Membership-≡
∈-∷-elim : ∀ {A : Set} {x : A} (y : A) xs -> ¬(x ≡ y) -> y ∈ x ∷ xs -> y ∈ xs
∈-∷-elim x [] x≠y (here refl) = ⊥-elim (x≠y refl)
∈-∷-elim y [] _ (there ())
∈-∷-elim x (x₁ ∷ xs) x≠y (here refl) = ⊥-elim (x≠y refl)
∈-∷-elim y (x₁ ∷ xs) _ (there y∈x∷xs) = y∈x∷xs
_∈ℕ?_ : Decidable {A = ℕ} (_∈_)
x ∈ℕ? [] = no (λ ())
x ∈ℕ? (x' ∷ xs) with x ≟ x'
x ∈ℕ? (.x ∷ xs) | yes refl = yes (here refl)
x ∈ℕ? (x' ∷ xs) | no x≠x' with x ∈ℕ? xs
x ∈ℕ? (x' ∷ xs) | no x≠x' | yes x∈xs = yes (there x∈xs)
x ∈ℕ? (x' ∷ xs) | no x≠x' | no x∉xs = no (λ x∈x'∷xs → x∉xs (∈-∷-elim x xs (λ x'≡x → x≠x' (sym x'≡x)) x∈x'∷xs))
-- subTaux : List ℕ -> ℕ -> List ℕ -> List ℕ
-- subTaux xs x ys with x ∈ℕ? ys
-- subTaux xs x ys | yes _ = union xs (remove x ys)
-- subTaux xs x ys | no _ = ys
-- mutual
-- subT : ∀ {ts ys} → TTerm ts → (x : ℕ) -> TTerm ys → TTerm (subTaux ts x ys)
-- subT t x (TVar x') with x ≟ x'
-- subT t .x' (TVar x') | yes refl rewrite remove-rewrite x' {[]} = {! t' !}
-- ... | no _ = (TVar x')
-- subT _ _ (TConst n) = TConst n
-- subT t x (TFun n args) = TFun n (subTList t x args)
--
-- subTList : ∀ {ts ys} → TTerm ts → (x : ℕ) -> TTermList ys → TTermList (subTaux ts x ys)
-- subTList _ _ []T = []T
-- subTList {ts} t x (_∷T_ {xs} {ys} a args) = rec
-- where
-- a' : TTerm (subTaux ts x xs)
-- a' = subT t x a
--
-- args' : TTermList (subTaux ts x ys)
-- args' = subTList t x args
--
-- ≡-subTaux : ∀ x xs ys -> subTaux ts x (union xs ys) ≡ union (subTaux ts x xs) (subTaux ts x ys)
-- ≡-subTaux _ [] _ = refl
-- ≡-subTaux x (x' ∷ xs) ys = {! !}
--
-- rec : TTermList (subTaux ts x (union xs ys))
-- rec rewrite ≡-subTaux x xs ys = a' ∷T args'
--
-- --subT x t' t ∷T subTList x t' l
--
TTerm→Term : ∀ {xs} -> TTerm xs -> Term
TTerm→Term (TVar n) = Var n
TTerm→Term (TConst c) = Const c
TTerm→Term (TFun n args) = Fun n (TTermList→ListTerm args)
where
TTermList→ListTerm : ∀ {xs} -> TTermList xs -> List Term
TTermList→ListTerm []T = []
TTermList→ListTerm (_∷T_ {_} {ys} t ts) = (TTerm→Term t) ∷ (TTermList→ListTerm {ys} ts)
mutual
sub : ℕ → Term' → Term' → Term'
sub x t' (Var' x') with x ≟ x'
... | yes _ = t'
... | no _ = (Var' x')
sub x t' (Const' n) = Const' n
sub x t' (Fun' n args) = Fun' n (subList x t' args)
subList : ℕ → Term' → List Term' → List Term'
subList x t' [] = []
subList x t' (t ∷ l) = sub x t' t ∷ subList x t' l
mutual
Term→Term' : Term → Term'
Term→Term' (Var x) = Var' x
Term→Term' (Const c) = Const' c
Term→Term' (Fun n args) = Fun' n (LTerm→LTerm' args)
Term→Term' ([[[ lst ]]] t) = STerm lst (Term→Term' t)
LTerm→LTerm' : List Term → List Term'
LTerm→LTerm' [] = []
LTerm→LTerm' (x ∷ l) = Term→Term' x ∷ LTerm→LTerm' l
STerm : List (Term × ℕ) → Term' → Term'
STerm [] t = t
STerm ((t' , x) ∷ lst) t = STerm lst (sub x (Term→Term' t') t)
mutual
⊢≡symm : ∀ {t1 t2 : Term} → t1 ⊢≡ t2 → t2 ⊢≡ t1
⊢≡symm atom = atom
⊢≡symm atomC = atomC
⊢≡symm (funEq x) = funEq (≡ₗsymm x)
⊢≡symm (sub[]R {Y = Y} t1⊢≡t2) = sub[]L (⊢≡symm t1⊢≡t2)
⊢≡symm (sub[]L {X = X} t1⊢≡t2) = sub[]R (⊢≡symm t1⊢≡t2)
⊢≡symm (subAtomEqR {t = t} {lst} t1⊢≡t2) = subAtomEqL (⊢≡symm t1⊢≡t2)
⊢≡symm (subAtomEqL {t = t} {lst} t1⊢≡t2) = subAtomEqR (⊢≡symm t1⊢≡t2)
⊢≡symm (subAtomNeqR {x = x} t1⊢≡t2 x₁) = subAtomNeqL (⊢≡symm t1⊢≡t2) x₁
⊢≡symm (subAtomNeqL {x = x} t1⊢≡t2 x₁) = subAtomNeqR (⊢≡symm t1⊢≡t2) x₁
⊢≡symm (subAtomCR {n = n} t1⊢≡t2) = subAtomCL (⊢≡symm t1⊢≡t2)
⊢≡symm (subAtomCL t1⊢≡t2) = subAtomCR (⊢≡symm t1⊢≡t2)
⊢≡symm (subFunR t1⊢≡t2) = subFunL (⊢≡symm t1⊢≡t2)
⊢≡symm (subFunL t1⊢≡t2) = subFunR (⊢≡symm t1⊢≡t2)
⊢≡symm (subConsR t1⊢≡t2) = subConsL (⊢≡symm t1⊢≡t2)
⊢≡symm (subConsL t1⊢≡t2) = subConsR (⊢≡symm t1⊢≡t2)
≡ₗsymm : ∀ {arg1 arg2} → arg1 ≡ₗ arg2 → arg2 ≡ₗ arg1
≡ₗsymm []≡ = []≡
≡ₗsymm (x ∷≡ arg1≡ₗarg2) = (⊢≡symm x) ∷≡ (≡ₗsymm arg1≡ₗarg2)
≡-Fun-nm : ∀ {n n' args args'} → Fun' n args ≡ Fun' n' args' → n ≡ n'
≡-Fun-nm refl = refl
≡-Fun-args : ∀ {n args args'} → Fun' n args ≡ Fun' n args' → args ≡ args'
≡-Fun-args refl = refl
Fun-args-≡ : ∀ {n args args'} → args ≡ args' → Fun' n args ≡ Fun' n args'
Fun-args-≡ refl = refl
substFun≡aux : ∀ {n} lst args → STerm lst (Fun' n args) ≡ Fun' n (List.map (STerm lst) args)
substFun≡aux [] args = Fun-args-≡ (aux args)
where
aux : ∀ args → args ≡ List.map (STerm []) args
aux [] = refl
aux (a ∷ args) = cong (_∷_ a) (aux args)
substFun≡aux {n} ((t , x) ∷ lst) args = PropEq.trans (substFun≡aux {n} lst (subList x (Term→Term' t) args)) (Fun-args-≡ (aux lst x t args))
where
aux : ∀ lst x t args → List.map (STerm lst) (subList x (Term→Term' t) args) ≡ List.map (STerm ((t , x) ∷ lst)) args
aux lst x t [] = refl
aux lst x t (x' ∷ args) = cong (_∷_ (STerm lst (sub x (Term→Term' t) x'))) (aux lst x t args)
substFun≡ : ∀ {n} args lst → Term→Term' ([[[ lst ]]] Fun n args) ≡ Fun' n (LTerm→LTerm' (List.map ([[[_]]]_ lst) args))
substFun≡ [] [] = refl
substFun≡ [] (s ∷ lst) = substFun≡ [] lst
substFun≡ (a ∷ args) [] = Fun-args-≡ (cong (_∷_ (Term→Term' a)) (LTerm[]Subst args))
where
LTerm[]Subst : ∀ args → LTerm→LTerm' args ≡ LTerm→LTerm' (List.map ([[[_]]]_ []) args)
LTerm[]Subst [] = refl
LTerm[]Subst (a ∷ args) = cong (_∷_ (Term→Term' a)) (LTerm[]Subst args)
substFun≡ (a ∷ args) ((t , x) ∷ lst) = PropEq.trans
(substFun≡aux lst (subList x (Term→Term' t) (LTerm→LTerm' (a ∷ args))))
(Fun-args-≡ (aux (a ∷ args)))
where
aux : ∀ args {lst x t} → List.map (STerm lst) (subList x (Term→Term' t) (LTerm→LTerm' args)) ≡ LTerm→LTerm' (List.map ([[[_]]]_ ((t , x) ∷ lst)) args)
aux [] = refl
aux (a ∷ args) {lst} {x} {t} = cong (_∷_ (STerm lst (sub x (Term→Term' t) (Term→Term' a)))) (aux args)
++[]-id : ∀ {a} {A : Set a} (lst : List A) → lst List.++ [] ≡ lst
++[]-id [] = refl
++[]-id (x ∷ xs) = cong (_∷_ x) (++[]-id xs)
substSubst≡ : ∀ {lst lst' t} → Term→Term' ([[[ lst ]]] ([[[ lst' ]]] t)) ≡ Term→Term' ([[[ lst' List.++ lst ]]] t)
substSubst≡ {[]} {lst'} rewrite ++[]-id lst' = refl
substSubst≡ {(t , x₂) ∷ lst} {[]} = refl
substSubst≡ {(t , x) ∷ lst} {(t' , x') ∷ lst'} {t''} = substSubst≡ {(t , x) ∷ lst} {lst'} {[[[ [ (t' , x') ] ]]] t''}
subsConst≡ : ∀ {lst c} → Term→Term' ([[[ lst ]]] (Const c)) ≡ Const' c
subsConst≡ {[]} = refl
subsConst≡ {_ ∷ lst} {c} = subsConst≡ {lst} {c}
open import Data.List.Properties
substTac : (t1 : Term) → (t2 : Term) → {_ : Term→Term' t1 ≡ Term→Term' t2} → t1 ⊢≡ t2
{-# TERMINATING #-}
substTac (Var x) (Var .x) {refl} = atom
substTac (Var _) (Const _) {()}
substTac (Var _) (Fun _ _) {()}
substTac (Const _) (Var _) {()}
substTac (Const c) (Const .c) {refl} = atomC
substTac (Const _) (Fun _ _) {()}
substTac (Fun _ _) (Var _) {()}
substTac (Fun _ _) (Const _) {()}
substTac (Fun n args) (Fun n' args') with n ≟S n'
substTac (Fun n []) (Fun .n []) | yes refl = funEq []≡
substTac (Fun n []) (Fun .n (_ ∷ _)) {()} | yes refl
substTac (Fun n (x ∷ args)) (Fun .n []) {()} | yes refl
substTac (Fun n (t ∷ args)) (Fun .n (t' ∷ args')) {eq} | yes refl with
substTac t t' {proj₁ (∷-injective (≡-Fun-args eq))} |
substTac (Fun n args) (Fun n args') {Fun-args-≡ (proj₂ (∷-injective (≡-Fun-args eq)))}
substTac (Fun n (t ∷ args)) (Fun .n (t' ∷ args')) | yes refl | t⊢≡t' | funEq args≡ₗargs' = funEq (t⊢≡t' ∷≡ args≡ₗargs')
substTac (Fun n args) (Fun n' args') {eq} | no ¬p = ⊥-elim (¬p (≡-Fun-nm eq))
substTac t1 ([[[ [] ]]] t2) {eq} = sub[]R (substTac t1 t2 {eq})
substTac t1 ([[[ (t , x') ∷ lst ]]] Var x) with x ≟ x'
substTac t1 ([[[ (t , x') ∷ lst ]]] Var .x') {eq} | yes refl =
subAtomEqR (substTac t1 ([[[ lst ]]] t) {eq' {x'} {Term→Term' t1} {t} {lst} eq}) -- agda doesnt like this call because it doesnt get structurally smaller, but its fine...
where
eq' : ∀ {x t t' lst} → t ≡ Term→Term' (([[[ (t' , x) ∷ lst ]]] Var x)) → t ≡ Term→Term' ([[[ lst ]]] t')
eq' {x} refl with x ≟ x
eq' {x} refl | yes _ = refl
eq' {x} refl | no ¬p = ⊥-elim (¬p refl)
substTac t1 ([[[ (t , x') ∷ lst ]]] Var x) {eq} | no ¬p = subAtomNeqR (substTac t1 ([[[ lst ]]] (Var x)) {eq' {x} {x'} {Term→Term' t1} {t} {lst} eq ¬p}) ¬p
where
eq' : ∀ {x x' t t' lst} → t ≡ Term→Term' (([[[ (t' , x') ∷ lst ]]] Var x)) → x ≢ x' → t ≡ Term→Term' ([[[ lst ]]] Var x)
eq' {x} {x'} refl x≠x' with x' ≟ x
eq' {x} {.x} refl x≠x' | yes refl = ⊥-elim (x≠x' refl)
eq' {x} {x'} refl x≠x' | no ¬p = refl
substTac t1 ([[[ x ∷ lst ]]] Const c) {eq} = subAtomCR (substTac t1 (Const c) {PropEq.trans eq (subsConst≡ {x ∷ lst} {c})})
substTac t1 ([[[ x ∷ lst ]]] Fun n args) {eq} = subFunR (substTac t1 (Fun n (List.map ([[[_]]]_ (x ∷ lst)) args)) {PropEq.trans eq (substFun≡ args (x ∷ lst))})
substTac t1 ([[[ x ∷ lst ]]] ([[[ lst' ]]] t2)) {eq} =
subConsR (substTac t1 ([[[ lst' List.++ x ∷ lst ]]] t2) {PropEq.trans eq (substSubst≡ {x ∷ lst} {lst'} {t2})})
substTac ([[[ lst ]]] t1) t2 {eq} = ⊢≡symm (substTac t2 ([[[ lst ]]] t1) {sym eq}) -- adga doesn't like this, but it should be fine...
⊢≡-≡ : ∀ {X Y} → X ⊢≡ Y → Term→Term' X ≡ Term→Term' Y
⊢≡-≡ atom = refl
⊢≡-≡ atomC = refl
⊢≡-≡ (funEq x) = Fun-args-≡ (≡ₗ→≡ x)
where
∷-≡ : ∀ {a} {A : Set a} {x y : A} {xs ys} → x ≡ y → xs ≡ ys → x ∷ xs ≡ y ∷ ys
∷-≡ refl refl = refl
≡ₗ→≡ : ∀ {arg1 arg2} → arg1 ≡ₗ arg2 → (LTerm→LTerm' arg1) ≡ (LTerm→LTerm' arg2)
≡ₗ→≡ []≡ = refl
≡ₗ→≡ (t1⊢≡t2 ∷≡ ≡ₗ) = ∷-≡ (⊢≡-≡ t1⊢≡t2) (≡ₗ→≡ ≡ₗ)
⊢≡-≡ (sub[]R X⊢≡Y) = ⊢≡-≡ X⊢≡Y
⊢≡-≡ (sub[]L X⊢≡Y) = ⊢≡-≡ X⊢≡Y
⊢≡-≡ (subAtomEqR {x} X⊢≡Y) with x ≟ x
⊢≡-≡ (subAtomEqR {x} X⊢≡Y) | yes p = ⊢≡-≡ X⊢≡Y
⊢≡-≡ (subAtomEqR {x} X⊢≡Y) | no ¬p = ⊥-elim (¬p refl)
⊢≡-≡ (subAtomEqL {x} X⊢≡Y) with x ≟ x
⊢≡-≡ (subAtomEqL {x} X⊢≡Y) | yes p = ⊢≡-≡ X⊢≡Y
⊢≡-≡ (subAtomEqL {x} X⊢≡Y) | no ¬p = ⊥-elim (¬p refl)
⊢≡-≡ (subAtomNeqR {x} {y} X⊢≡Y x₁) with y ≟ x
⊢≡-≡ (subAtomNeqR {x} {.x} X⊢≡Y x₁) | yes refl = ⊥-elim (x₁ refl)
⊢≡-≡ (subAtomNeqR {x} {y} X⊢≡Y x₁) | no ¬p = ⊢≡-≡ X⊢≡Y
⊢≡-≡ (subAtomNeqL {x} {y} X⊢≡Y x₁) with y ≟ x
⊢≡-≡ (subAtomNeqL {x} {.x} X⊢≡Y x₁) | yes refl = ⊥-elim (x₁ refl)
⊢≡-≡ (subAtomNeqL {x} {y} X⊢≡Y x₁) | no ¬p = ⊢≡-≡ X⊢≡Y
⊢≡-≡ (subAtomCR {c} {lst} X⊢≡Y) = PropEq.trans (⊢≡-≡ X⊢≡Y) (sym (subsConst≡ {lst} {c}))
⊢≡-≡ (subAtomCL {c} {lst} X⊢≡Y) = PropEq.trans (subsConst≡ {lst} {c}) (⊢≡-≡ X⊢≡Y)
⊢≡-≡ (subFunR {n} {args} {lst} X⊢≡Y) = PropEq.trans (⊢≡-≡ X⊢≡Y) (sym (substFun≡ {n} args lst))
⊢≡-≡ (subFunL {n} {args} {lst} X⊢≡Y) = PropEq.trans (substFun≡ {n} args lst) (⊢≡-≡ X⊢≡Y)
⊢≡-≡ (subConsR {lst} {lst'} {_} {Y} X⊢≡Y) = PropEq.trans (⊢≡-≡ X⊢≡Y) (sym (substSubst≡ {lst'} {lst} {Y}))
⊢≡-≡ (subConsL {lst} {lst'} {X} X⊢≡Y) = PropEq.trans (substSubst≡ {lst'} {lst} {X}) (⊢≡-≡ X⊢≡Y)
mutual
⊢≡atom : ∀ {t} → t ⊢≡ t
⊢≡atom {Var x} = atom
⊢≡atom {Const x} = atomC
⊢≡atom {Fun x x₁} = funEq ≡ₗatom
where
≡ₗatom : ∀ {xs} → xs ≡ₗ xs
≡ₗatom {[]} = []≡
≡ₗatom {x ∷ xs} = ⊢≡atom ∷≡ ≡ₗatom
⊢≡atom {[[[ x ]]] t} = ⊢≡subMon ⊢≡atom
⊢≡subMon : ∀ {sub X Y} → X ⊢≡ Y → ([[[ sub ]]] X) ⊢≡ ([[[ sub ]]] Y)
⊢≡subMon {sub} {X} {Y} X⊢≡Y = substTac ([[[ sub ]]] X) ([[[ sub ]]] Y) {mon {sub} {Term→Term' X} {Term→Term' Y} (⊢≡-≡ X⊢≡Y)}
where
mon : ∀ {sub X Y} → X ≡ Y → STerm sub X ≡ STerm sub Y
mon refl = refl
-- data _∈_ : ℕ → List ℕ → Set where
-- here : ∀ {x xs} → x ∈ (x ∷ xs)
-- there : ∀ {x y xs} → x ∈ xs → x ∈ (y ∷ xs)
--
-- data _⊆_ : List ℕ → List ℕ → Set where
-- nil : ∀ {xs} → [] ⊆ xs
-- cons : ∀ {x xs ys} → x ∈ ys → xs ⊆ ys → (x ∷ xs) ⊆ ys
--
-- _∉_ : ℕ → List ℕ → Set
-- n ∉ ns = ¬ (n ∈ ns)
--
-- _⊈_ : List ℕ → List ℕ → Set
-- xs ⊈ ys = ¬ (xs ⊆ ys)
mutual
FV : Term' → List ℕ
FV (Var' x) = [ x ]
FV (Const' _) = []
FV (Fun' _ args) = FVs args
FVs : List Term' → List ℕ
FVs [] = []
FVs (t ∷ ts) = union (FV t) (FVs ts)
data Formula : List ℕ → Set where
_⟨_⟩ : Name → ∀ {xs} (ts : TTermList xs) → Formula xs
_∧_ : ∀ {ns} → Formula ns → Formula ns → Formula ns
_∨_ : ∀ {ns} → Formula ns → Formula ns → Formula ns
_⟶_ : ∀ {ns} → Formula ns → Formula ns → Formula ns
∘ : ∀ {ns} v → Formula ns → {v∉ : v ∉ ns} → Formula (insert v ns)
-- [_/_] : ∀ {y ns} → Term → (x : ℕ) → {x∈ : x ∈ ns} → {y⊆ : y ⊆ ns} → {x≠y : [ x ] ≢ y} → Formula ns → Formula (remove x ns)
-- [_//_] : ∀ {y ns} → Term y → (x : ℕ) → {x⊆ : x ∈ ns} → {y⊈ : y ⊈ ns} → {x≠y : [ x ] ≢ y} → Formula ns → Formula (union y (remove x ns))
All : ∀ {ns} v → Formula ns → Formula (remove v ns)
Ex : ∀ {ns} v → Formula ns → Formula (remove v ns)
data Structure : List ℕ → Set where
∣_∣ : ∀ {n} → Formula n → Structure n
_,_ : ∀ {n m} → Structure n → Structure m → {n≡m : n ≡ m} -> Structure n
_>>_ : ∀ {n m} → Structure n → Structure m → {n≡m : n ≡ m} → Structure n
_<<_ : ∀ {n m} → Structure n → Structure m → {n≡m : n ≡ m} → Structure n
I : ∀ {n} → Structure n
○ : ∀ {n} v → Structure n → {v∉ : v ∉ n} → Structure (insert v n)
Q : ∀ {n} v → Structure n → Structure (remove v n)
data _⊢_ : ∀ {n} → Structure n → Structure n → Set where
atom : ∀ {n xs} {ts us : TTermList xs} →
∣ n ⟨ ts ⟩ ∣ ⊢ ∣ n ⟨ us ⟩ ∣
allR : ∀ {x n X Y} →
Y ⊢ Q {n} x ∣ X ∣ →
-------------------
Y ⊢ ∣ All {n} x X ∣
allL : ∀ {x n X Y} →
∣ Y ∣ ⊢ ∣ X ∣ →
-------------------------------
∣ All {n} x Y ∣ ⊢ Q {n} x ∣ X ∣
open import Data.Unit as Unit using (⊤)
open import Data.Nat.Properties as Propℕ
_≤'?_ : Decidable _≤′_
x ≤'? y with x ≤? y
x ≤'? y | yes p = yes (≤⇒≤′ p)
x ≤'? y | no ¬p = no (λ x₁ → ¬p (≤′⇒≤ x₁))
-- mutual
-- data OList : Set where
-- []O : OList
-- _∷O_ : (x : ℕ) -> (xs : OList) -> {x< : isLess x xs} -> OList
--
-- isLess : ℕ -> OList -> Set
-- isLess x []O = ⊤
-- isLess x (y ∷O ol) with x ≤'? y
-- isLess x (.x ∷O ol) | yes ≤′-refl = ⊥
-- isLess x (.(suc _) ∷O ol) | yes (≤′-step _) = ⊤
-- isLess x (y ∷O ol) | no _ = ⊥
--
--
--
-- mutual
-- data IsLess : ℕ -> OList -> Set where
-- nil : ∀ {x} -> IsLess x []O
-- cons : ∀ {x x' xs} -> x < x' -> (x'<xs : IsLess x' xs) -> IsLess x ((x' ∷O xs) {IsLess→isLess x'<xs})
--
-- IsLess→isLess : ∀ {x xs} -> IsLess x xs -> isLess x xs
-- IsLess→isLess nil = ⊤.tt
-- IsLess→isLess {x} (cons {x' = x'} x<x' x<xs) with x ≤'? x'
-- IsLess→isLess {x} (cons {_} {.x} x<x' x<xs) | yes ≤′-refl = contr x<x'
-- where
-- contr : ∀ {x} -> suc x ≤ x -> ⊥
-- contr {zero} ()
-- contr {suc x} (s≤s sx≤x) = contr sx≤x
-- IsLess→isLess {x} (cons {_} {.(suc _)} x<x' x<xs) | yes (≤′-step p) = ⊤.tt
-- IsLess→isLess {x} (cons {_} {x'} x<x' x<xs) | no ¬x≤′x' = ¬x≤′x' (≤⇒≤′ (sucx≤y→x≤y x<x'))
-- where
-- sucx≤y→x≤y : ∀ {x y} -> suc x ≤ y -> x ≤ y
-- sucx≤y→x≤y {zero} sx≤y = z≤n
-- sucx≤y→x≤y {suc x} (s≤s sx≤y) = s≤s (sucx≤y→x≤y sx≤y)
--
-- open import Data.Sum
--
--
-- isLess→IsLess : ∀ {x xs} -> isLess x xs -> IsLess x xs
-- isLess→IsLess {x} {[]O} ⊤.tt = nil
-- isLess→IsLess {x} {x' ∷O xs} x< with x ≤'? x'
-- isLess→IsLess {.x'} {x' ∷O xs} () | yes ≤′-refl
-- isLess→IsLess {x} {(.(suc _) ∷O xs) {sn<}} ⊤.tt | yes (≤′-step {n = n} x≤′n) = {!sn< !}
-- where
-- aux : x < suc n
-- aux = {! sn< !}
--
-- rec : IsLess (suc n) xs
-- rec = isLess→IsLess sn<
-- --
-- aux₂ : IsLess x ((suc n ∷O xs) {sn<})
-- aux₂ = cons aux rec
--
-- isLess→IsLess {x} {x' ∷O xs} x< | no ¬p = {! !}
mutual
data OList : Set where
[]O : OList
_∷O_ : (x : ℕ) -> (xs : OList) -> {x< : IsLess x xs} -> OList
data IsLess : ℕ -> OList -> Set where
base : ∀ {x} -> IsLess x []O
step : ∀ {x x' xs} -> x < x' -> (x'<xs : IsLess x' xs) -> IsLess x ((x' ∷O xs) {x'<xs})
IsLess→< : ∀ {x x' xs x'<} -> IsLess x ((x' ∷O xs) {x'<}) -> x < x'
IsLess→< (step x<x' _) = x<x'
mutual
insertO : ℕ -> OList -> OList
insertO x []O = (x ∷O []O) {base}
insertO x (x' ∷O xs) with x ≤'? x'
insertO x ((.x ∷O xs) {x<}) | yes ≤′-refl = (x ∷O xs) {x<}
insertO x ((.(suc _) ∷O xs) {x<}) | yes (≤′-step {n = x'} p) = (x ∷O (((suc x') ∷O xs) {x<})) {step (s≤s (≤′⇒≤ p)) x<}
insertO x ((x' ∷O xs) {x'<}) | no x'<x = (x' ∷O insertO x xs) {insertO-lemma xs x'< x'<x}
insertO-lemma : ∀ {x x'} xs -> IsLess x' xs -> ¬ x ≤′ x' -> IsLess x' (insertO x xs)
insertO-lemma []O base ¬x≤′x' = step (≰⇒> (λ x≤x' → ¬x≤′x' (≤⇒≤′ x≤x'))) base
insertO-lemma {x} {x'} (x'' ∷O xs) x'<xs x'<x with x ≤'? x''
insertO-lemma {.x''} {x'} ((x'' ∷O xs) {x''<}) x'<xs _ | yes ≤′-refl = step (IsLess→< x'<xs) x''<
insertO-lemma {x} {x'} ((.(suc _) ∷O xs) {sn<xs}) x'<xs ¬x≤′x' | yes (≤′-step x≤′n) =
step (≰⇒> (λ x≤x' → ¬x≤′x' (≤⇒≤′ x≤x'))) (step (s≤s (≤′⇒≤ x≤′n)) sn<xs)
insertO-lemma {x} {x'} ((x'' ∷O xs) {x''<xs}) x'<xs _ | no x''<x = step (IsLess→< x'<xs) (insertO-lemma {x} {x''} xs x''<xs x''<x)
data _∈O_ : ℕ -> OList -> Set where
here : ∀ {x xs x<xs} -> x ∈O ((x ∷O xs) {x<xs})
there : ∀ {x y xs y<xs} -> x ∈O xs -> x ∈O ((y ∷O xs) {y<xs})
_∉O_ : ℕ -> OList -> Set
x ∉O xs = ¬ (x ∈O xs)
IsLess-remove : ∀ {x x'} xs {x'<xs} -> IsLess x ((x' ∷O xs) {x'<xs}) -> IsLess x xs
IsLess-remove []O x<x∷xs = base
IsLess-remove ((x'' ∷O xs) {x''<xs}) (step x<x' x'<x''∷xs) = step (<-trans x<x' (IsLess→< x'<x''∷xs)) x''<xs
mutual
removeO : ℕ -> OList -> OList
removeO x []O = []O
removeO x (x' ∷O xs) with x ≟ x'
removeO x (.x ∷O xs) | yes refl = xs
removeO x ((x' ∷O xs) {x'<xs}) | no ¬p = (x' ∷O removeO x xs) {removeO-lemma {x} {x'} xs x'<xs}
removeO-lemma : ∀ {x x'} xs -> IsLess x' xs -> IsLess x' (removeO x xs)
removeO-lemma []O x'<xs = base
removeO-lemma {x} {x'} (x'' ∷O xs) x'<xs with x ≟ x''
removeO-lemma {.x''} {x'} (x'' ∷O xs) x<xs | yes refl = IsLess-remove xs x<xs
removeO-lemma {x} {x'} ((x'' ∷O xs) {x''<xs}) x'<xs | no ¬p = step (IsLess→< x'<xs) (removeO-lemma {x} {x''} xs x''<xs)
-- isLess : ℕ -> OList -> Set
-- isLess x []O = ⊤
-- isLess x (y ∷O ol) with x ≤'? y
-- isLess x (.x ∷O ol) | yes ≤′-refl = ⊥
-- isLess x (.(suc _) ∷O ol) | yes (≤′-step _) = ⊤
-- isLess x (y ∷O ol) | no _ = ⊥
--
-- smart constructor for OList
_∷O'_ : (x : ℕ) -> (xs : OList) -> OList
x ∷O' xs = insertO x xs
testOList : OList
testOList = 2 ∷O' (1 ∷O' (2 ∷O' []O))
data Formula' : OList → Set where
-- _⟨_⟩ : Name → ∀ {xs} (ts : TTermList xs) → Formula xs
_∧_ : ∀ {ns} → Formula' ns → Formula' ns → Formula' ns
_∨_ : ∀ {ns} → Formula' ns → Formula' ns → Formula' ns
_⟶_ : ∀ {ns} → Formula' ns → Formula' ns → Formula' ns
∘ : ∀ {ns} v → Formula' ns → {v∉ : v ∉O ns} → Formula' (insertO v ns)
-- [_/_] : ∀ {y ns} → Term → (x : ℕ) → {x∈ : x ∈ ns} → {y⊆ : y ⊆ ns} → {x≠y : [ x ] ≢ y} → Formula ns → Formula (remove x ns)
-- [_//_] : ∀ {y ns} → Term y → (x : ℕ) → {x⊆ : x ∈ ns} → {y⊈ : y ⊈ ns} → {x≠y : [ x ] ≢ y} → Formula ns → Formula (union y (remove x ns))
All : ∀ {ns} v → Formula' ns → Formula' (removeO v ns)
Ex : ∀ {ns} v → Formula' ns → Formula' (removeO v ns)
-- insert-reomve-id : ∀ {x n m} -> n ≡ m -> n ≡ insertO x (removeO x m)
-- insert-reomve-id {x} {xs} refl = {! xs !}
rem-inj : ∀ {n m} x -> n ≡ m -> remove x n ≡ remove x m
rem-inj _ refl = refl
data _⊢⟨_⟩_ : ∀ {n m} → Structure n → n ≡ m -> Structure m → Set where
atom : ∀ {n xs n≡m} {ts us : TTermList xs} →
∣ n ⟨ ts ⟩ ∣ ⊢⟨ n≡m ⟩ ∣ n ⟨ us ⟩ ∣
allR : ∀ {x n m n≡m X} {Y : Structure m} →
Y ⊢⟨ n≡m ⟩ Q {n} x ∣ X ∣ →
-------------------
Y ⊢⟨ n≡m ⟩ ∣ All {n} x X ∣
allL : ∀ {x n m n≡m X} {Y : Formula m} →
∣ X ∣ ⊢⟨ n≡m ⟩ ∣ Y ∣ →
-------------------------------
∣ All {n} x X ∣ ⊢⟨ rem-inj x n≡m ⟩ Q {m} x ∣ Y ∣
IL : ∀ {n m n≡m} {X : Structure n} {Y : Structure m} →
X ⊢⟨ n≡m ⟩ Y →
-------------------
(I , X) {refl} ⊢⟨ n≡m ⟩ Y
IL2 : ∀ {n m n≡m} {X : Structure n} {Y : Structure m} →
(I , X) {refl} ⊢⟨ n≡m ⟩ Y →
-------------------
X ⊢⟨ n≡m ⟩ Y
IR : ∀ {n m n≡m} {X : Structure n} {Y : Structure m} →
X ⊢⟨ n≡m ⟩ Y →
-----------------
X ⊢⟨ n≡m ⟩ (Y , I) {refl}
IR2 : ∀ {n m n≡m} {X : Structure n} {Y : Structure m} →
X ⊢⟨ n≡m ⟩ (Y , I) {refl} →
-----------------
X ⊢⟨ n≡m ⟩ Y
,>>disp : ∀ {n m n≡m} {Z : Structure n} {X Y : Structure m} →
Z ⊢⟨ n≡m ⟩ (X , Y) {refl} →
-----------------
(X >> Z) {sym n≡m} ⊢⟨ refl ⟩ Y
,>>disp2 : ∀ {n m n≡m} {Z : Structure n} {X Y : Structure m} →
(X >> Z) {sym n≡m} ⊢⟨ refl ⟩ Y →
-----------------
Z ⊢⟨ n≡m ⟩ (X , Y) {refl}
○IR : ∀ {x n m n≡m x∉m} {X : Structure n} →
X ⊢⟨ n≡m ⟩ (I {insert x m}) →
-----------------
X ⊢⟨ n≡m ⟩ ○ x (I {m}) {x∉m}
○IR2 : ∀ {x n m n≡m x∉m} {X : Structure n} →
X ⊢⟨ n≡m ⟩ ○ x (I {m}) {x∉m} →
-----------------
X ⊢⟨ n≡m ⟩ (I {insert x m})
-- ,<<disp : ∀ {n m n≡m} {X : Structure n} {Y Z : Structure m} →
-- X ⊢⟨ n≡m ⟩ (Y , Z) {refl} →
-- -----------------
-- (X >> Z) {n≡m} ⊢⟨ n≡m ⟩ Y
-- ,<<disp2 : ∀ {n m n≡m} {X : Structure n} {Y Z : Structure m} →
-- (X >> Z) {n≡m} ⊢⟨ n≡m ⟩ Y →
-- -----------------
-- X ⊢⟨ n≡m ⟩ (Y , Z) {refl}
rem-union-id : ∀ x -> remove x (union [ x ] []) ≡ []
rem-union-id x rewrite remove-rewrite x {[]} = refl
test : ∀ x y {n} -> ∣ All x (n ⟨ (TVar x) ∷T []T ⟩) ∣ ⊢⟨ PropEq.trans (rem-union-id x) (sym (rem-union-id y)) ⟩ ∣ All y (n ⟨ (TVar y) ∷T []T ⟩) ∣
test x y = allR ?
data Map : List ℕ → Set where
nil : Map []
_/_:::_ : ∀ {xs} (x : ℕ) → String → Map xs → Map (x ∷ xs)
_!!_ : List (ℕ × String) → ℕ → String
[] !! _ = "not found"
((x , s) ∷ m) !! y with x ≟ y
... | yes _ = s
... | no _ = m !! y
Term→Str : List (ℕ × String) → Term → String
Term→Str m (Var x) = "\\textit{" ++ (m !! x) ++ "}"
Term→Str m (Const s) = "\\textbf{" ++ s ++ "}"
Term→Str m (Fun n args) = "" --"\\textbf{" ++ s ++ "}"
-- Term→Str m ([[_/_]]_ _ _ _) = "" --"\\textbf{" ++ s ++ "}"
Term→Str m ([[[_]]]_ _ _) = ""
Formula→Str : ∀ {xs} → List (ℕ × String) → Formula xs → String
Formula→Str m (n ⟨ args ⟩) = n ++ "(" ++ ")" --aux args ++ ")"
-- where
-- aux : List Term → String
-- aux [] = ""
-- aux (x ∷ []) = Term→Str m x
-- aux (x ∷ (y ∷ args)) = Term→Str m x ++ ", " ++ aux (y ∷ args)
Formula→Str m (f ∧ f₁) = Formula→Str m f ++ " \\land " ++ Formula→Str m f₁
Formula→Str m (f ∨ f₁) = Formula→Str m f ++ " \\lor " ++ Formula→Str m f₁
Formula→Str m (f ⟶ f₁) = Formula→Str m f ++ " \\leftarrow " ++ Formula→Str m f₁
Formula→Str m (∘ v f) = "\\circ_" ++ (m !! v) ++ Formula→Str m f
-- Formula→Str m ([ y / x ] f) = "(" ++ Term→Str m y ++ "/" ++ (m !! x) ++ ") " ++ Formula→Str m f
-- Formula→Str m ([ y // x ] f) = "(" ++ Term→Str m y ++ "//" ++ (m !! x) ++ ") " ++ Formula→Str m f
Formula→Str m (All v f) = "\\forall " ++ (m !! v) ++ Formula→Str m f
Formula→Str m (Ex v f) = "\\exists " ++ (m !! v) ++ Formula→Str m f
Structure→Str : ∀ {xs} → List (ℕ × String) → Structure xs → String
Structure→Str m ∣ x ∣ = Formula→Str m x
Structure→Str m (s , s₁) = Structure→Str m s ++ " , " ++ Structure→Str m s₁
Structure→Str m (s >> s₁) = Structure→Str m s ++ " >> " ++ Structure→Str m s₁
Structure→Str m (s << s₁) = Structure→Str m s ++ " << " ++ Structure→Str m s₁
Structure→Str m I = "I"
Structure→Str m (○ v s) = "\\bigcirc_" ++ (m !! v) ++ Structure→Str m s
Structure→Str m (Q v s) = "Q " ++ (m !! v) ++ Structure→Str m s
⊢concl : ∀ {n} {xs ys : Structure n} → xs ⊢ ys → (Structure n × Structure n)
⊢concl {_} {xs} {ys} _ = xs , ys
data ⊢List : Set where
⊢nil : ⊢List
_⊢::_ : ∀ {n} {xs ys : Structure n} → xs ⊢ ys → ⊢List → ⊢List
⊢prems : ∀ {n} {xs ys : Structure n} → xs ⊢ ys → ⊢List
⊢prems atom = ⊢nil
⊢prems (allR xs⊢ys) = xs⊢ys ⊢:: ⊢nil
⊢prems (allL xs⊢ys) = xs⊢ys ⊢:: ⊢nil
-- proof1 : ∀ {n} P (args : TList n) → ∣ P ⟨ args ⟩ ∣ ⊢ ∣ P ⟨ args ⟩ ∣
-- proof1 P args = atom
--
-- proof : ∣ "P" ⟨ Var 0 ::: nil ⟩ ∣ ⊢ ∣ "P" ⟨ Var 0 ::: nil ⟩ ∣
-- proof = let (x , y) = ⊢concl (proof1 "P" (Var 0 ::: nil)) in {!Structure→Str [ (0 , "x") ] x !}
⊢→Str' : ∀ {n} {xs ys : Structure n} → List (ℕ × String) → xs ⊢ ys → String
⊢→Str' m xs⊢ys with ⊢concl xs⊢ys | ⊢prems xs⊢ys
⊢→Str' m xs⊢ys | xs , ys | prems = Structure→Str m xs ++ " \\vdash " ++ Structure→Str m ys
where
prems→Str : ⊢List → String
prems→Str ⊢nil = ""
prems→Str (x ⊢:: lst) = {! !}
open import IO
main = run (putStrLn "Hello, world!")
| 36.449809
| 172
| 0.482535
|
5209e0a166b0ed2d50e16b59a00f569cf1b6608b
| 2,420
|
agda
|
Agda
|
Graph/Walk/Properties.agda
|
Lolirofle/stuff-in-agda
|
70f4fba849f2fd779c5aaa5af122ccb6a5b271ba
|
[
"MIT"
] | 6
|
2020-04-07T17:58:13.000Z
|
2022-02-05T06:53:22.000Z
|
Graph/Walk/Properties.agda
|
Lolirofle/stuff-in-agda
|
70f4fba849f2fd779c5aaa5af122ccb6a5b271ba
|
[
"MIT"
] | null | null | null |
Graph/Walk/Properties.agda
|
Lolirofle/stuff-in-agda
|
70f4fba849f2fd779c5aaa5af122ccb6a5b271ba
|
[
"MIT"
] | null | null | null |
open import Type
module Graph.Walk.Properties {ℓ₁ ℓ₂} {V : Type{ℓ₁}} where
open import Lang.Instance
open import Logic
import Lvl
open import Graph{ℓ₁}{ℓ₂}(V)
open import Graph.Walk{ℓ₁}{ℓ₂}{V}
open import Relator.Equals.Proofs.Equiv
open import Type.Properties.MereProposition
module _ (_⟶_ : Graph) where
-- `Passes edge walk` states that the walk `walk` contains the edge `edge`.
-- In other words, there is a step in the walk which is `edge`.
-- Note: Passes is a generalized containment relation for paths instead of lists.
data Passes {v₁ v₂ : V} (edge : v₁ ⟶ v₂) : ∀{a b : V} → Walk(_⟶_) a b → Type{ℓ₁ Lvl.⊔ ℓ₂} where
current : ∀{c}{rest : Walk(_⟶_) v₂ c} → Passes edge (Walk.prepend edge rest)
skip : ∀{b c}{rest : Walk(_⟶_) b c} → Passes edge rest → ∀{a}{e : (a ⟶ b)} → Passes edge (Walk.prepend e rest)
-- `Visits v walk` states that the walk `walk` visits the vertex `v`.
-- In other words, one of the steps/edges in the walk mention the vertex v.
data Visits (v : V) : ∀{a b : V} → Walk(_⟶_) a b → Type{ℓ₁ Lvl.⊔ ℓ₂} where
current : ∀{b}{path : Walk(_⟶_) v b} → Visits v path
skip : ∀{a b c}{e : (a ⟶ b)}{rest : Walk(_⟶_) b c} → Visits v rest → Visits v (Walk.prepend e rest)
module _ {a b : V} (walk₁ : Walk(_⟶_) a b) {c d : V} (walk₂ : Walk(_⟶_) c d) where
record Subwalk : Stmt{ℓ₁ Lvl.⊔ ℓ₂} where
constructor intro
field proof : ∀{v₁ v₂ : V}{edge : v₁ ⟶ v₂} → Passes edge walk₁ → Passes edge walk₂
module _ {_⟶_ : Graph} {a b : V} (walk : Walk(_⟶_) a b) where
-- A walk that never visits the same edge twice.
-- Note: Equality on edges must respect uniqueness. In other words, one edge must not have multiple constructions.
record Trail : Type{ℓ₁ Lvl.⊔ ℓ₂} where
constructor intro
field proof : ∀{v₁ v₂ : V}{edge : v₁ ⟶ v₂} → MereProposition(Passes(_⟶_) edge walk)
-- A walk that never visits the same vertex twice.
-- Also called "Simple path".
-- Note: Equality on edges must respect uniqueness. In other words, one edge must not have multiple constructions.
record Path : Stmt{ℓ₁ Lvl.⊔ ℓ₂} where
constructor intro
field proof : ∀{v : V} → MereProposition(Visits(_⟶_) v walk)
path = inst-fn Path.proof
-- A walk that visits every vertex in the graph.
record Traceable : Stmt{ℓ₁ Lvl.⊔ ℓ₂} where
constructor intro
field proof : ∀{v : V} → Visits(_⟶_) v walk
traceable = inst-fn Traceable.proof
| 46.538462
| 117
| 0.652479
|
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.