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
57fcbe3f103e275f9ee8be49c174fd3aba8becb6
751
agda
Agda
Data/Binary/PerformanceTests/Addition.agda
oisdk/agda-playground
97a3aab1282b2337c5f43e2cfa3fa969a94c11b7
[ "MIT" ]
6
2020-09-11T17:45:41.000Z
2021-11-16T08:11:34.000Z
Data/Binary/PerformanceTests/Addition.agda
oisdk/agda-playground
97a3aab1282b2337c5f43e2cfa3fa969a94c11b7
[ "MIT" ]
null
null
null
Data/Binary/PerformanceTests/Addition.agda
oisdk/agda-playground
97a3aab1282b2337c5f43e2cfa3fa969a94c11b7
[ "MIT" ]
1
2021-11-11T12:30:21.000Z
2021-11-11T12:30:21.000Z
{-# OPTIONS --cubical --safe #-} module Data.Binary.PerformanceTests.Addition where open import Prelude open import Data.Binary.Definition open import Data.Binary.Addition using (_+_) sum-r : 𝔹 → ℕ → 𝔹 sum-r′ : 𝔹 → ℕ → 𝔹 sum-r′ x zero = x sum-r′ x (suc n) = x + sum-r (2ᵇ x) n sum-r x zero = x sum-r x (suc n) = x + sum-r′ (1ᵇ x) n sum-l : 𝔹 → ℕ → 𝔹 sum-l′ : 𝔹 → ℕ → 𝔹 sum-l′ x zero = x sum-l′ x (suc n) = sum-l (2ᵇ x) n + x sum-l x zero = x sum-l x (suc n) = sum-l′ (1ᵇ x) n + x one-thousand : 𝔹 one-thousand = 2ᵇ 1ᵇ 1ᵇ 2ᵇ 1ᵇ 2ᵇ 2ᵇ 2ᵇ 2ᵇ 0ᵇ f : 𝔹 f = one-thousand n : ℕ n = 1000 -- The actual performance test (uncomment and time how long it takes to type-check) -- _ : sum-l one-thousand n ≡ sum-r one-thousand n -- _ = refl
19.25641
83
0.601864
58725d4f9890f4b78f31775b97f57cfcc8e9d5e3
521
agda
Agda
test/Fail/InstanceErrorMessage.agda
mdimjasevic/agda
8fb548356b275c7a1e79b768b64511ae937c738b
[ "BSD-3-Clause" ]
1,989
2015-01-09T23:51:16.000Z
2022-03-30T18:20:48.000Z
test/Fail/InstanceErrorMessage.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
4,066
2015-01-10T11:24:51.000Z
2022-03-31T21:14:49.000Z
test/Fail/InstanceErrorMessage.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
371
2015-01-03T14:04:08.000Z
2022-03-30T19:00:30.000Z
module _ where record Semiring (A : Set) : Set where infixl 6 _+_ field _+_ : A → A → A open Semiring {{...}} public infix 4 _≡_ postulate Nat Bool : Set _≡_ : Nat → Nat → Set refl : ∀ {x} → x ≡ x to : ∀ {x} (y : Nat) → x ≡ y trans : {x y z : Nat} → x ≡ y → y ≡ z → x ≡ z instance _ : Semiring Nat _ : Semiring Bool bad : (a b c : Nat) → a + b ≡ c + a bad a b c = trans (to (a + c)) refl -- Should complain about a != c when checking refl, not a missing instance Semiring Nat.
19.296296
88
0.533589
4d5ec9a2b93a6697edf34ee3d1d023236100c2f3
1,015
agda
Agda
agda/hott/types/int.agda
piyush-kurur/hott
876ecdcfddca1abf499e8f00db321c6dc3d5b2bc
[ "BSD-3-Clause" ]
null
null
null
agda/hott/types/int.agda
piyush-kurur/hott
876ecdcfddca1abf499e8f00db321c6dc3d5b2bc
[ "BSD-3-Clause" ]
null
null
null
agda/hott/types/int.agda
piyush-kurur/hott
876ecdcfddca1abf499e8f00db321c6dc3d5b2bc
[ "BSD-3-Clause" ]
null
null
null
module hott.types.int where open import hott.functions open import hott.core import hott.types.nat as nat open nat using (ℕ) data ℤ : Type₀ where zero : ℤ +ve : ℕ → ℤ -ve : ℕ → ℤ fromNat : ℕ → ℤ fromNat nat.zero = zero fromNat (nat.succ n) = +ve n neg : ℤ → ℤ neg zero = zero neg (+ve n) = -ve n neg (-ve n) = +ve n suc : ℤ → ℤ suc zero = +ve 0 suc (+ve x) = +ve (nat.succ x) suc (-ve 0) = zero suc (-ve (nat.succ x)) = -ve x pred : ℤ → ℤ pred zero = -ve 0 pred (-ve x) = -ve (nat.succ x) pred (+ve 0) = zero pred (+ve (nat.succ x)) = +ve x suc∘pred~id : suc ∘ pred ~ id suc∘pred~id zero = refl suc∘pred~id (+ve 0) = refl suc∘pred~id (+ve (nat.succ x)) = refl suc∘pred~id (-ve x) = refl pred∘suc~id : pred ∘ suc ~ id pred∘suc~id zero = refl pred∘suc~id (+ve x) = refl pred∘suc~id (-ve 0) = refl pred∘suc~id (-ve (nat.succ x)) = refl
19.901961
44
0.498522
2efe07d894f45e30648323fa03ec1d10fe11a6f2
562
agda
Agda
test/Succeed/Issue2182.agda
mdimjasevic/agda
8fb548356b275c7a1e79b768b64511ae937c738b
[ "BSD-3-Clause" ]
1,989
2015-01-09T23:51:16.000Z
2022-03-30T18:20:48.000Z
test/Succeed/Issue2182.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
4,066
2015-01-10T11:24:51.000Z
2022-03-31T21:14:49.000Z
test/Succeed/Issue2182.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
371
2015-01-03T14:04:08.000Z
2022-03-30T19:00:30.000Z
open import Agda.Builtin.Reflection open import Agda.Builtin.Bool open import Agda.Builtin.String open import Agda.Builtin.Equality open import Agda.Builtin.Unit open import Agda.Builtin.List _>>=_ = bindTC `false `true : Term `false = con (quote false) [] `true = con (quote true) [] macro macro? : Name → Term → TC ⊤ macro? x hole = isMacro x >>= λ where false → unify hole `false true → unify hole `true test₁ : macro? macro? ≡ true test₁ = refl test₂ : macro? test₁ ≡ false test₂ = refl test₃ : macro? true ≡ false test₃ = refl
18.733333
35
0.679715
23cf52a28a54b02ed942dfdfa316ef45d7cf672a
621
agda
Agda
agda-stdlib/src/Data/Table/Relation/Equality.agda
DreamLinuxer/popl21-artifact
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
[ "MIT" ]
5
2020-10-07T12:07:53.000Z
2020-10-10T21:41:32.000Z
agda-stdlib/src/Data/Table/Relation/Equality.agda
DreamLinuxer/popl21-artifact
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
[ "MIT" ]
null
null
null
agda-stdlib/src/Data/Table/Relation/Equality.agda
DreamLinuxer/popl21-artifact
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
[ "MIT" ]
1
2021-11-04T06:54:45.000Z
2021-11-04T06:54:45.000Z
------------------------------------------------------------------------ -- The Agda standard library -- -- This module is DEPRECATED. Please use `Data.Vec.Functional` instead. ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} -- Disabled to prevent warnings from other Table modules {-# OPTIONS --warn=noUserWarning #-} module Data.Table.Relation.Equality where open import Data.Table.Relation.Binary.Equality public {-# WARNING_ON_IMPORT "Data.Table.Relation.Equality was deprecated in v1.0. Use Data.Vec.Functional.Relation.Binary.Pointwise instead." #-}
31.05
72
0.5781
dcf41a7e31422eb16415bbf9054dd3e418092921
9,824
agda
Agda
Multidimensional/Data/NNat/Properties.agda
wrrnhttn/agda-cubical-multidimensional
55709dd950e319c4a105ace33ddaf8b955354add
[ "MIT" ]
null
null
null
Multidimensional/Data/NNat/Properties.agda
wrrnhttn/agda-cubical-multidimensional
55709dd950e319c4a105ace33ddaf8b955354add
[ "MIT" ]
4
2019-06-19T20:40:07.000Z
2019-07-02T16:24:01.000Z
Multidimensional/Data/NNat/Properties.agda
wrrnhttn/agda-cubical-multidimensional
55709dd950e319c4a105ace33ddaf8b955354add
[ "MIT" ]
null
null
null
{-# OPTIONS --cubical #-} module Multidimensional.Data.NNat.Properties where open import Cubical.Core.Glue open import Cubical.Foundations.Prelude open import Cubical.Foundations.Equiv open import Cubical.Foundations.Univalence open import Cubical.Foundations.Isomorphism open import Cubical.Data.Nat open import Cubical.Data.Prod open import Cubical.Data.Empty open import Cubical.Relation.Nullary open import Multidimensional.Data.Extra.Nat open import Multidimensional.Data.Dir open import Multidimensional.Data.DirNum open import Multidimensional.Data.NNat.Base -- N→ℕsucN : (r : ℕ) (x : N r) → N→ℕ r (sucN x) ≡ suc (N→ℕ r x) -- N→ℕsucN zero (bn tt) = refl -- N→ℕsucN zero (xr tt x) = -- suc (N→ℕ zero (sucN x)) -- ≡⟨ cong suc (N→ℕsucN zero x) ⟩ -- suc (suc (N→ℕ zero x)) -- ∎ -- N→ℕsucN (suc r) (bn (↓ , d)) = refl -- N→ℕsucN (suc r) (bn (↑ , d)) with max? d -- ... | no d≠max = -- doubleℕ (DirNum→ℕ (next d)) -- ≡⟨ cong doubleℕ (next≡suc r d d≠max) ⟩ -- doubleℕ (suc (DirNum→ℕ d)) -- ∎ -- ... | yes d≡max = -- this can probably be shortened by not reducing down to zero -- sucn (doubleℕ (DirNum→ℕ (zero-n r))) -- (doublesℕ r (suc (suc (doubleℕ (doubleℕ (DirNum→ℕ (zero-n r))))))) -- ≡⟨ cong (λ x → sucn (doubleℕ x) (doublesℕ r (suc (suc (doubleℕ (doubleℕ x)))))) (zero-n→0 {r}) ⟩ -- sucn (doubleℕ zero) (doublesℕ r (suc (suc (doubleℕ (doubleℕ zero))))) -- ≡⟨ refl ⟩ -- doublesℕ (suc r) (suc zero) -- 2^(r+1) -- ≡⟨ sym (doubleDoubles r 1) ⟩ -- doubleℕ (doublesℕ r (suc zero)) --2*2^r -- ≡⟨ sym (sucPred (doubleℕ (doublesℕ r (suc zero))) (doubleDoublesOne≠0 r)) ⟩ -- suc (predℕ (doubleℕ (doublesℕ r (suc zero)))) -- ≡⟨ cong suc (sym (sucPred (predℕ (doubleℕ (doublesℕ r (suc zero)))) (predDoubleDoublesOne≠0 r))) ⟩ -- suc (suc (predℕ (predℕ (doubleℕ (doublesℕ r (suc zero)))))) -- ≡⟨ cong (λ x → suc (suc x)) (sym (doublePred (doublesℕ r (suc zero)))) ⟩ -- suc (suc (doubleℕ (predℕ (doublesℕ r (suc zero))))) -- ≡⟨ cong (λ x → suc (suc (doubleℕ x))) (sym (maxr≡pred2ʳ r d d≡max)) ⟩ -- suc (suc (doubleℕ (DirNum→ℕ d))) -- 2*(2^r - 1) + 2 = 2^(r+1) - 2 + 2 = 2^(r+1) -- ∎ -- N→ℕsucN (suc r) (xr (↓ , d) x) = refl -- N→ℕsucN (suc r) (xr (↑ , d) x) with max? d -- ... | no d≠max = -- sucn (doubleℕ (DirNum→ℕ (next d))) -- (doublesℕ r (doubleℕ (N→ℕ (suc r) x))) -- ≡⟨ cong (λ y → sucn (doubleℕ y) (doublesℕ r (doubleℕ (N→ℕ (suc r) x)))) (next≡suc r d d≠max) ⟩ -- sucn (doubleℕ (suc (DirNum→ℕ d))) -- (doublesℕ r (doubleℕ (N→ℕ (suc r) x))) -- ≡⟨ refl ⟩ -- suc -- (suc -- (iter (doubleℕ (DirNum→ℕ d)) suc -- (doublesℕ r (doubleℕ (N→ℕ (suc r) x))))) -- ∎ -- ... | yes d≡max = -- sucn (doubleℕ (DirNum→ℕ (zero-n r))) -- (doublesℕ r (doubleℕ (N→ℕ (suc r) (sucN x)))) -- ≡⟨ cong (λ z → sucn (doubleℕ z) (doublesℕ r (doubleℕ (N→ℕ (suc r) (sucN x))))) (zero-n≡0 {r}) ⟩ -- sucn (doubleℕ zero) -- (doublesℕ r (doubleℕ (N→ℕ (suc r) (sucN x)))) -- ≡⟨ refl ⟩ -- doublesℕ r (doubleℕ (N→ℕ (suc r) (sucN x))) -- ≡⟨ cong (λ x → doublesℕ r (doubleℕ x)) (N→ℕsucN (suc r) x) ⟩ -- doublesℕ r (doubleℕ (suc (N→ℕ (suc r) x))) -- ≡⟨ refl ⟩ -- doublesℕ r (suc (suc (doubleℕ (N→ℕ (suc r) x)))) -- 2^r * (2x + 2) = 2^(r+1)x + 2^(r+1) -- ≡⟨ doublesSucSuc r (doubleℕ (N→ℕ (suc r) x)) ⟩ -- sucn (doublesℕ (suc r) 1) -- _ + 2^(r+1) -- (doublesℕ (suc r) (N→ℕ (suc r) x)) -- 2^(r+1)x + 2^(r+1) -- ≡⟨ H r (doublesℕ (suc r) (N→ℕ (suc r) x)) ⟩ -- suc -- (suc -- (sucn (doubleℕ (predℕ (doublesℕ r 1))) -- _ + 2(2^r - 1) + 2 -- (doublesℕ (suc r) (N→ℕ (suc r) x)))) -- ≡⟨ refl ⟩ -- suc -- (suc -- (sucn (doubleℕ (predℕ (doublesℕ r 1))) -- (doublesℕ r (doubleℕ (N→ℕ (suc r) x))))) -- ≡⟨ cong (λ z → suc (suc (sucn (doubleℕ z) (doublesℕ r (doubleℕ (N→ℕ (suc r) x)))))) (sym (max→ℕ r)) ⟩ -- suc -- (suc -- (sucn (doubleℕ (DirNum→ℕ (max-n r))) -- (doublesℕ r (doubleℕ (N→ℕ (suc r) x))))) -- ≡⟨ cong (λ z → suc (suc (sucn (doubleℕ (DirNum→ℕ z)) (doublesℕ r (doubleℕ (N→ℕ (suc r) x)))))) (sym (d≡max)) ⟩ -- suc -- (suc -- (sucn (doubleℕ (DirNum→ℕ d)) -- (doublesℕ r (doubleℕ (N→ℕ (suc r) x))))) -- (2^r*2x + (2*(2^r - 1))) + 2 = 2^(r+1)x + 2^(r+1) -- ∎ -- where -- H : (n m : ℕ) → sucn (doublesℕ (suc n) 1) m ≡ suc (suc (sucn (doubleℕ (predℕ (doublesℕ n 1))) m)) -- H zero m = refl -- H (suc n) m = -- sucn (doublesℕ n 4) m -- ≡⟨ cong (λ z → sucn z m) (doublesSucSuc n 2) ⟩ -- sucn (sucn (doublesℕ (suc n) 1) (doublesℕ n 2)) m -- ≡⟨ refl ⟩ -- sucn (sucn (doublesℕ n 2) (doublesℕ n 2)) m -- ≡⟨ {!!} ⟩ -- sucn (doubleℕ (doublesℕ n 2)) m -- ≡⟨ {!!} ⟩ {!!} -- ℕ→Nsuc : (r : ℕ) (n : ℕ) → ℕ→N r (suc n) ≡ sucN (ℕ→N r n) -- ℕ→Nsuc r n = {!!} -- ℕ→Nsucn : (r : ℕ) (n m : ℕ) → ℕ→N r (sucn n m) ≡ sucnN n (ℕ→N r m) -- ℕ→Nsucn r n m = {!!} -- NℕNlemma : (r : ℕ) (d : DirNum r) → ℕ→N r (DirNum→ℕ d) ≡ bn d -- NℕNlemma zero tt = refl -- NℕNlemma (suc r) (↓ , ds) = -- ℕ→N (suc r) (doubleℕ (DirNum→ℕ ds)) -- ≡⟨ {!!} ⟩ {!!} -- NℕNlemma (suc r) (↑ , ds) = {!!} -- N→ℕ→N : (r : ℕ) → (x : N r) → ℕ→N r (N→ℕ r x) ≡ x -- N→ℕ→N zero (bn tt) = refl -- N→ℕ→N zero (xr tt x) = cong (xr tt) (N→ℕ→N zero x) -- N→ℕ→N (suc r) (bn (↓ , ds)) = -- ℕ→N (suc r) (doubleℕ (DirNum→ℕ ds)) -- ≡⟨ cong (λ x → ℕ→N (suc r) x) (double-lemma ds) ⟩ -- ℕ→N (suc r) (DirNum→ℕ {suc r} (↓ , ds)) -- ≡⟨ NℕNlemma (suc r) (↓ , ds) ⟩ -- bn (↓ , ds) -- ∎ -- N→ℕ→N (suc r) (bn (↑ , ds)) = -- sucN (ℕ→N (suc r) (doubleℕ (DirNum→ℕ ds))) -- ≡⟨ cong (λ x → sucN (ℕ→N (suc r) x)) (double-lemma ds) ⟩ -- sucN (ℕ→N (suc r) (DirNum→ℕ {suc r} (↓ , ds))) -- ≡⟨ cong sucN (NℕNlemma (suc r) (↓ , ds)) ⟩ -- sucN (bn (↓ , ds)) -- ≡⟨ refl ⟩ -- bn (↑ , ds) -- ∎ -- N→ℕ→N (suc r) (xr (↓ , ds) x) = -- ℕ→N (suc r) -- (sucn (doubleℕ (DirNum→ℕ ds)) -- (doublesℕ r (doubleℕ (N→ℕ (suc r) x)))) -- ≡⟨ cong (λ z → ℕ→N (suc r) (sucn z (doublesℕ r (doubleℕ (N→ℕ (suc r) x))))) (double-lemma ds) ⟩ -- ℕ→N (suc r) -- (sucn (DirNum→ℕ {suc r} (↓ , ds)) -- (doublesℕ r (doubleℕ (N→ℕ (suc r) x)))) -- ≡⟨ refl ⟩ -- ℕ→N (suc r) -- (sucn (DirNum→ℕ {suc r} (↓ , ds)) -- (doublesℕ (suc r) (N→ℕ (suc r) x))) -- ≡⟨ ℕ→Nsucn (suc r) (DirNum→ℕ {suc r} (↓ , ds)) (doublesℕ (suc r) (N→ℕ (suc r) x)) ⟩ -- sucnN (DirNum→ℕ {suc r} (↓ , ds)) -- (ℕ→N (suc r) (doublesℕ (suc r) (N→ℕ (suc r) x))) -- ≡⟨ cong (λ z → sucnN (DirNum→ℕ {suc r} (↓ , ds)) z) (H (suc r) (suc r) (N→ℕ (suc r) x)) ⟩ -- sucnN (DirNum→ℕ {suc r} (↓ , ds)) -- (doublesN (suc r) (suc r) (ℕ→N (suc r) (N→ℕ (suc r) x))) -- ≡⟨ cong (λ z → sucnN (DirNum→ℕ {suc r} (↓ , ds)) (doublesN (suc r) (suc r) z)) (N→ℕ→N (suc r) x) ⟩ -- sucnN (DirNum→ℕ {suc r} (↓ , ds)) -- (doublesN (suc r) (suc r) x) -- ≡⟨ G (suc r) (↓ , ds) x snotz ⟩ -- xr (↓ , ds) x ∎ -- where -- H : (r m n : ℕ) → ℕ→N r (doublesℕ m n) ≡ doublesN r m (ℕ→N r n) -- H r m n = {!!} -- G : (r : ℕ) (d : DirNum r) (x : N r) → ¬ (r ≡ 0) → sucnN (DirNum→ℕ {r} d) (doublesN r r x) ≡ xr d x -- G zero d x 0≠0 = ⊥-elim (0≠0 refl) -- G (suc r) d (bn x) r≠0 = {!!} -- G (suc r) d (xr x x₁) r≠0 = {!!} -- N→ℕ→N (suc r) (xr (↑ , ds) x) with max? ds -- ... | no ds≠max = -- sucN -- (ℕ→N (suc r) -- (sucn (doubleℕ (DirNum→ℕ ds)) -- (doublesℕ r (doubleℕ (N→ℕ (suc r) x))))) -- ≡⟨ sym (ℕ→Nsuc (suc r) -- (sucn (doubleℕ (DirNum→ℕ ds)) (doublesℕ r (doubleℕ (N→ℕ (suc r) x))))) -- ⟩ -- ℕ→N (suc r) -- (suc (sucn (doubleℕ (DirNum→ℕ ds)) (doublesℕ r (doubleℕ (N→ℕ (suc r) x))))) -- ≡⟨ refl ⟩ -- ℕ→N (suc r) -- (suc (sucn (doubleℕ (DirNum→ℕ ds)) (doublesℕ (suc r) (N→ℕ (suc r) x)))) -- ≡⟨ cong (λ z → ℕ→N (suc r) z) -- (sym (sucnsuc (doubleℕ (DirNum→ℕ ds)) (doublesℕ (suc r) (N→ℕ (suc r) x)))) -- ⟩ -- ℕ→N (suc r) -- (sucn (doubleℕ (DirNum→ℕ ds)) (suc (doublesℕ (suc r) (N→ℕ (suc r) x)))) -- ≡⟨ ℕ→Nsucn (suc r) (doubleℕ (DirNum→ℕ ds)) (suc (doublesℕ (suc r) (N→ℕ (suc r) x))) ⟩ -- sucnN (doubleℕ (DirNum→ℕ ds)) (ℕ→N (suc r) (suc (doublesℕ (suc r) (N→ℕ (suc r) x)))) -- ≡⟨ cong (λ z → sucnN (doubleℕ (DirNum→ℕ ds)) z) -- (ℕ→Nsuc (suc r) (doublesℕ (suc r) (N→ℕ (suc r) x))) -- ⟩ -- -- (2^(r+1)*x + 1) + 2*ds -- -- = 2*(2^r*x + ds) + 1 -- -- = 2*( -- sucnN (doubleℕ (DirNum→ℕ ds)) (sucN (ℕ→N (suc r) (doublesℕ (suc r) (N→ℕ (suc r) x)))) -- ≡⟨ {!!} ⟩ {!!} -- ... | yes ds≡max = {!!} -- ℕ→N→ℕ : (r : ℕ) → (n : ℕ) → N→ℕ r (ℕ→N r n) ≡ n -- ℕ→N→ℕ zero zero = refl -- ℕ→N→ℕ (suc r) zero = -- doubleℕ (DirNum→ℕ (zero-n r)) -- ≡⟨ cong doubleℕ (zero-n≡0 {r}) ⟩ -- doubleℕ zero -- ≡⟨ refl ⟩ -- zero -- ∎ -- ℕ→N→ℕ zero (suc n) = cong suc (ℕ→N→ℕ zero n) -- ℕ→N→ℕ (suc r) (suc n) = -- N→ℕ (suc r) (sucN (ℕ→N (suc r) n)) -- ≡⟨ N→ℕsucN (suc r) (ℕ→N (suc r) n) ⟩ -- suc (N→ℕ (suc r) (ℕ→N (suc r) n)) -- ≡⟨ cong suc (ℕ→N→ℕ (suc r) n) ⟩ -- suc n -- ∎ -- N≃ℕ : (r : ℕ) → N r ≃ ℕ -- N≃ℕ r = isoToEquiv (iso (N→ℕ r) (ℕ→N r) (ℕ→N→ℕ r) (N→ℕ→N r)) -- N≡ℕ : (r : ℕ) → N r ≡ ℕ -- N≡ℕ r = ua (N≃ℕ r)
41.982906
119
0.447577
1ae76563b36b4851a63792301bb7e63d4f823e76
306
agda
Agda
test/Succeed/Issue551b.agda
mdimjasevic/agda
8fb548356b275c7a1e79b768b64511ae937c738b
[ "BSD-3-Clause" ]
1,989
2015-01-09T23:51:16.000Z
2022-03-30T18:20:48.000Z
test/Succeed/Issue551b.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
4,066
2015-01-10T11:24:51.000Z
2022-03-31T21:14:49.000Z
test/Succeed/Issue551b.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
371
2015-01-03T14:04:08.000Z
2022-03-30T19:00:30.000Z
-- Andreas, 2012-01-11 module Issue551b where data Box (A : Set) : Set where [_] : .A → Box A implicit : {A : Set}{{a : A}} -> A implicit {{a}} = a postulate A B : Set instance a : A a' : Box A a' = [ implicit ] -- this should succeed f : Box B → Box (Box B) f [ x ] = [ [ x ] ] -- this as well
14.571429
34
0.539216
1c80c98041b06a97e16c185b641aa51e2ebd7854
177
agda
Agda
Cubical/Data/Empty.agda
kiana-S/univalent-foundations
8bdb0766260489f9c89a14f4c0f2ad26e5190dec
[ "MIT" ]
null
null
null
Cubical/Data/Empty.agda
kiana-S/univalent-foundations
8bdb0766260489f9c89a14f4c0f2ad26e5190dec
[ "MIT" ]
1
2022-01-27T02:07:48.000Z
2022-01-27T02:07:48.000Z
Cubical/Data/Empty.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.Empty where open import Cubical.Data.Empty.Base public open import Cubical.Data.Empty.Properties public
25.285714
50
0.768362
dce14b2fa54b1c2fcd42ca0a6f2e02074b38b5e4
3,372
agda
Agda
old/Homotopy/TruncationHIT.agda
danbornside/HoTT-Agda
1695a7f3dc60177457855ae846bbd86fcd96983e
[ "MIT" ]
294
2015-01-09T16:23:23.000Z
2022-03-20T13:54:45.000Z
old/Homotopy/TruncationHIT.agda
danbornside/HoTT-Agda
1695a7f3dc60177457855ae846bbd86fcd96983e
[ "MIT" ]
31
2015-03-05T20:09:00.000Z
2021-10-03T19:15:25.000Z
old/Homotopy/TruncationHIT.agda
danbornside/HoTT-Agda
1695a7f3dc60177457855ae846bbd86fcd96983e
[ "MIT" ]
50
2015-01-10T01:48:08.000Z
2022-02-14T03:03:25.000Z
{-# OPTIONS --without-K #-} open import Base open import Homotopy.TruncatedHIT {- The idea is that if [n : ℕ] and [A : Set i], then [τ n A] is defined by the following n-truncated higher inductive type: module Homotopy.TruncationHIT {i} (n : ℕ) (A : Set i) where (n)data τ : Set i where proj : A → τ More explanations on the way this is done can be found in TruncatedHIT.agda. This file contains nothing but stuff that could (should) be autogenerated from the three lines above. -} module Homotopy.TruncationHIT {i} (n : ℕ₋₂) (A : Set i) where private data #τ : Set i where #proj : A → #τ #top : (f : hSⁿ n → #τ) → #τ τ : Set i τ = #τ proj : A → τ proj = #proj top : (f : hSⁿ n → τ) → τ top = #top postulate -- HIT rays : (f : hSⁿ n → τ) (x : hSⁿ n) → top f ≡ f x hack-prop : (p : n ≡ ⟨-2⟩) (x y : τ) → (x ≡ y) #τ-rec : ∀ {j} (P : τ → Set j) (proj* : (x : A) → P (proj x)) {top* : (f : hSⁿ n → τ) (p : (x : hSⁿ n) → P (f x)) → P (top f)} {rays* : (f : hSⁿ n → τ) (p : (x : hSⁿ n) → P (f x)) (x : hSⁿ n) → transport P (rays f x) (top* f p) ≡ p x} {hack-prop* : (p : n ≡ ⟨-2⟩) (x y : τ) (x* : P x) (y* : P y) → (transport P (hack-prop p x y) x* ≡ y* )} → ((x : τ) → P x) #τ-rec P proj* {top*} {rays*} {hack-prop*} (#proj u) = proj* u #τ-rec P proj* {top*} {rays*} {hack-prop*} (#top f) = top* f (λ x → #τ-rec P proj* {top*} {rays*} {hack-prop*} (f x)) #τ-rec-nondep : ∀ {j} (C : Set j) (proj* : A → C) {top* : (f : hSⁿ n → τ) (p : hSⁿ n → C) → C} {rays* : (f : hSⁿ n → τ) (p : hSⁿ n → C) (x : hSⁿ n) → top* f p ≡ p x} {hack-prop* : (p : n ≡ ⟨-2⟩) (x y : τ) (x* y* : C) → x* ≡ y*} → (τ → C) #τ-rec-nondep C proj* {top*} {rays*} {hack-prop*} (#proj u) = proj* u #τ-rec-nondep C proj* {top*} {rays*} {hack-prop*} (#top f) = top* f (λ x → #τ-rec-nondep C proj* {top*} {rays*} {hack-prop*} (f x)) private contr : (n ≡ ⟨-2⟩) → is-contr τ abstract contr p = inhab-prop-is-contr (top (λ x → abort-nondep (transport hSⁿ p x))) (all-paths-is-prop (hack-prop p)) -- Computation rules for [rays] are not needed τ-rec : ∀ {j} (P : τ → Set j) (proj* : (x : A) → P (proj x)) {hack-prop* : (p : n ≡ ⟨-2⟩) (x y : τ) (x* : P x) (y* : P y) → (transport P (hack-prop p x y) x* ≡ y* )} (trunc : (x : τ) → is-truncated n (P x)) → ((x : τ) → P x) τ-rec P proj* {hack-prop*} trunc = #τ-rec P proj* {x₁} {x₂} {hack-prop*} where abstract u : (f : hSⁿ n → τ) (p : (x : hSⁿ n) → P (f x)) → filling-dep n P f (top f , rays f) p u = truncated-has-filling-dep τ P n contr (λ f → (top f , rays f)) x₁ : (f : hSⁿ n → τ) (p : (x : hSⁿ n) → P (f x)) → P (top f) x₁ = λ f p → π₁ (u f p) x₂ : (f : hSⁿ n → τ) (p : (x : hSⁿ n) → P (f x)) (x : hSⁿ n) → transport P (rays f x) (x₁ f p) ≡ p x x₂ = λ f p → π₂ (u f p) τ-rec-nondep : ∀ {j} (C : Set j) (proj* : A → C) {hack-prop* : (p : n ≡ ⟨-2⟩) (x y : τ) (x* y* : C) → x* ≡ y*} (trunc : is-truncated n C) → (τ → C) τ-rec-nondep C proj* {hack-prop*} trunc = #τ-rec-nondep C proj* {λ _ p → π₁ (u p)} {λ _ p → π₂ (u p)} {hack-prop*} where u : _ u = truncated-has-spheres-filled n _ trunc -- The nth truncation is of h-level [n] abstract τ-is-truncated : is-truncated n τ τ-is-truncated = spheres-filled-is-truncated n τ contr (λ f → (top f , rays f))
31.514019
78
0.498221
c771eee347486acdfef5761855bb482a3fbe478b
5,744
agda
Agda
src/README.agda
sstucki/f-omega-int-agda
ae648c9520895a8428a7ad80f47bb55ecf4d50ea
[ "MIT" ]
12
2017-06-13T16:05:35.000Z
2021-09-27T05:53:06.000Z
src/README.agda
sstucki/f-omega-int-agda
ae648c9520895a8428a7ad80f47bb55ecf4d50ea
[ "MIT" ]
1
2021-05-14T08:09:40.000Z
2021-05-14T08:54:39.000Z
src/README.agda
sstucki/f-omega-int-agda
ae648c9520895a8428a7ad80f47bb55ecf4d50ea
[ "MIT" ]
2
2021-05-13T22:29:48.000Z
2021-05-14T10:25:05.000Z
------------------------------------------------------------------------ -- Fω with interval kinds ------------------------------------------------------------------------ {-# OPTIONS --safe --without-K #-} -- Author: Sandro Stucki -- Copyright (c) 2017-2021 EPFL, Sandro Stucki -- The code in this repository contains an Agda mechanization of the -- type system Fω extended with interval kinds ("F omega int"). An -- interval kind `A..B' represents a type interval bounded by a pair -- of types `A', `B'. It is inhabited by all proper types `C : A..B' -- that are both supertypes of `A' and subtypes of `B'. Interval -- kinds are flexible enough to express various features found in -- other type systems, such as -- -- * F-<:-style bounded polymorphism, -- * bounded type operators, -- * singleton kinds and first-class type definitions. -- -- The mechanization includes a small-step operational call-by-value -- semantics, declarative and canonical presentations of typing and -- kinding, along with (syntactic) proofs of various meta-theoretic -- properties, such as -- -- * weak normalization of types (and kinds) via hereditary substitution, -- * subject reduction for types (w.r.t. full β-reduction), -- * type safety (progress & preservation) w.r.t. to the CBV semantics, -- * undecidability of subtyping. -- -- For more details on Fω with interval kinds, see my PhD thesis -- "Higher-Order Subtyping with Type Intervals", which is available at -- -- http://dx.doi.org/10.5075/epfl-thesis-8014 -- -- The code makes heavy use of the Agda standard library, which is -- freely available at -- -- https://github.com/agda/agda-stdlib/ -- -- The code has been tested using Agda 2.6.2 and version 1.7 of -- the Agda standard library. module README where ------------------------------------------------------------------------ -- Modules related to Fω with interval kinds. -- Syntax of (untyped) terms along with support for substitutions, -- (untyped) hereditary substitutions and normalization. open import FOmegaInt.Syntax open import FOmegaInt.Syntax.SingleVariableSubstitution open import FOmegaInt.Syntax.HereditarySubstitution open import FOmegaInt.Syntax.Normalization -- Weak equality of (untyped) terms up to kind annotations in -- abstractions. open import FOmegaInt.Syntax.WeakEquality -- Variants of β-reduction/equivalence and properties thereof. open import FOmegaInt.Reduction.Cbv open import FOmegaInt.Reduction.Full -- Typing, kinding, subtyping, etc. along with corresponding -- substitution lemmas. open import FOmegaInt.Typing -- An alternate presentation of kinding and subtyping that is better -- suited for proving functionality and validity lemmas, along with a -- proof that the two presentations are equivalent. open import FOmegaInt.Kinding.Declarative open import FOmegaInt.Kinding.Declarative.Validity open import FOmegaInt.Kinding.Declarative.Equivalence -- Soundness of normalization w.r.t. to declarative kinding. open import FOmegaInt.Kinding.Declarative.Normalization -- Simple kinding of types, (hereditary) substitution lemmas. open import FOmegaInt.Kinding.Simple -- Lemmas about η-expansion of simply kinded and normalization and -- simultaneous simplification of declaratively kinded types. open import FOmegaInt.Kinding.Simple.EtaExpansion open import FOmegaInt.Kinding.Simple.Normalization -- Canonical kinding of types along with (hereditary) substitution, -- validity and inversion lemmas for canonical kinding and subtyping. open import FOmegaInt.Kinding.Canonical open import FOmegaInt.Kinding.Canonical.HereditarySubstitution open import FOmegaInt.Kinding.Canonical.Validity open import FOmegaInt.Kinding.Canonical.Inversion -- Lifting of weak (untyped) kind and type equality to canonical kind -- and type equality. open import FOmegaInt.Kinding.Canonical.WeakEquality -- Equivalence of canonical and declarative kinding. open import FOmegaInt.Kinding.Canonical.Equivalence -- Generation of typing and inversion of declarative subtyping in the -- empty context. open import FOmegaInt.Typing.Inversion -- Type safety (preservation/subject reduction and progress). open import FOmegaInt.Typing.Preservation open import FOmegaInt.Typing.Progress -- Encodings and properties of higher-order extremal types, interval -- kinds and bounded quantifiers. open import FOmegaInt.Typing.Encodings -- A reduced variant of the canonical system to be used in the -- undecidability proof. open import FOmegaInt.Kinding.Canonical.Reduced -- Setup for the undecidability proof: syntax and lemmas for the SK -- combinator calculus, and support for encoding/decoding SK terms and -- equality proofs into types and subtyping derivations. open import FOmegaInt.Undecidable.SK open import FOmegaInt.Undecidable.Encoding open import FOmegaInt.Undecidable.Decoding -- Undecidability of subtyping open import FOmegaInt.Undecidable ------------------------------------------------------------------------ -- Modules containing generic functionality -- Extra lemmas that are derivable in the substitution framework of -- the Agda standard library, as well as support for binary (term) -- relations lifted to substitutions, typed substitutions, and typed -- relations lifted to substitutions. open import Data.Context open import Data.Context.WellFormed open import Data.Context.Properties open import Data.Fin.Substitution.Extra open import Data.Fin.Substitution.ExtraLemmas open import Data.Fin.Substitution.Relation open import Data.Fin.Substitution.Typed open import Data.Fin.Substitution.TypedRelation -- Support for generic reduction relations. open import Relation.Binary.Reduction -- Relational reasoning for transitive relations. open import Relation.Binary.TransReasoning
38.293333
74
0.751915
d062795f2d3ea2daa3579a5fcdf5a2df2022a61a
783
agda
Agda
test/succeed/PostponedUnification.agda
asr/agda-kanso
aa10ae6a29dc79964fe9dec2de07b9df28b61ed5
[ "MIT" ]
1
2018-10-10T17:08:44.000Z
2018-10-10T17:08:44.000Z
test/succeed/PostponedUnification.agda
np/agda-git-experiment
20596e9dd9867166a64470dd24ea68925ff380ce
[ "MIT" ]
null
null
null
test/succeed/PostponedUnification.agda
np/agda-git-experiment
20596e9dd9867166a64470dd24ea68925ff380ce
[ "MIT" ]
1
2022-03-12T11:35:18.000Z
2022-03-12T11:35:18.000Z
{- This example test that the order in which unification constraints are generated doesn't matter. The pattern matching in foo generates the unification problem [x, zero] = [n + m, n] with n and m flexible. The first equation can only be solved after the second one has been solved. For completeness we check that the other way around also works. -} module PostponedUnification where data Nat : Set where zero : Nat suc : Nat -> Nat _+_ : Nat -> Nat -> Nat zero + m = m suc n + m = suc (n + m) data T : Nat -> Nat -> Set where t : (x : Nat) -> T x zero foo : (n m : Nat) -> T (n + m) n -> Set foo ._ ._ (t x) = Nat data U : Nat -> Nat -> Set where u : (x : Nat) -> U zero x bar : (n m : Nat) -> U n (n + m) -> Set bar ._ ._ (u x) = Nat
24.46875
65
0.600255
2ec719df18f150ca8a3a080e09443417b71f6c79
4,823
agda
Agda
src/sets/nat/struct.agda
pcapriotti/agda-base
bbbc3bfb2f80ad08c8e608cccfa14b83ea3d258c
[ "BSD-3-Clause" ]
20
2015-06-12T12:20:17.000Z
2022-02-01T11:25:54.000Z
src/sets/nat/struct.agda
pcapriotti/agda-base
bbbc3bfb2f80ad08c8e608cccfa14b83ea3d258c
[ "BSD-3-Clause" ]
4
2015-02-02T14:32:16.000Z
2016-10-26T11:57:26.000Z
src/sets/nat/struct.agda
pcapriotti/agda-base
bbbc3bfb2f80ad08c8e608cccfa14b83ea3d258c
[ "BSD-3-Clause" ]
4
2015-02-02T12:17:00.000Z
2019-05-04T19:31:00.000Z
{-# OPTIONS --without-K #-} module sets.nat.struct where open import level open import sum open import equality open import function open import container.core open import container.w open import sets.empty open import sets.unit open import sets.nat.core open import sets.fin open import sets.vec.dependent open import hott.level ℕ-c : Container lzero lzero lzero ℕ-c = record { I = ⊤ ; A = λ _ → Fin 2 ; B = ⊥ ∷∷ ⊤ ∷∷ ⟦⟧ ; r = λ _ → tt } open Container ℕ-c ℕ-algebra-iso : (⊤ {lzero} ⊎ ℕ) ≅ ℕ ℕ-algebra-iso = record { to = λ { (inj₁ _) → zero ; (inj₂ n) → suc n } ; from = λ { zero → inj₁ tt ; (suc n) → inj₂ n } ; iso₁ = λ { (inj₁ _) → refl ; (inj₂ n) → refl } ; iso₂ = λ { zero → refl ; (suc n) → refl } } private inℕ : F (λ _ → ℕ) tt → ℕ inℕ (zero , u) = 0 inℕ (suc zero , u) = suc (u tt) inℕ (suc (suc ()) , u) ℕ-struct-iso : ℕ ≅ W ℕ-c tt ℕ-struct-iso = iso f g α β where f : ℕ → W ℕ-c tt f 0 = sup (# 0) (λ ()) f (suc n) = sup (# 1) (λ _ → f n) g : W ℕ-c tt → ℕ g = fold ℕ-c (λ i → inℕ) tt α : (n : ℕ) → g (f n) ≡ n α zero = refl α (suc n) = ap suc (α n) β : (n : W ℕ-c tt) → f (g n) ≡ n β (sup zero u) = ap (sup zero) (funext λ ()) β (sup (suc zero) u) = ap (sup (# 1)) (funext (λ x → β (u tt))) β (sup (suc (suc ())) u) private F-struct-iso : ∀ {i}(X : ⊤ → Set i) → F X tt ≅ (⊤ ⊎ X tt) F-struct-iso X = begin ( Σ (A tt) λ a → B a → X tt ) ≅⟨ sym≅ (⊎-Σ-iso (λ a → B a → X tt)) ⟩ ( (⊥ → X tt) ⊎ (⊤ → X tt) ) ≅⟨ ⊎-ap-iso (contr-⊤-iso ⊥-initial) Π-left-unit ⟩ ( ⊤ ⊎ X tt ) ∎ where open ≅-Reasoning ℕ-initial : ∀ {i} (X : ℕ → Set i) → (x₀ : X 0)(f : ∀ n → X n → X (suc n)) → contr ( Σ ((n : ℕ) → X n) λ x → (x₀ ≡ x 0) × (∀ n → f n (x n) ≡ x (suc n)) ) ℕ-initial X x₀ f = iso-level ℕ-alg-iso (W-section-contr ℕ-c 𝓧) where ψ : ∀ x → ((b : B (proj₁ x)) → X (proj₂ x b)) → X (inℕ x) ψ (zero , u) v = x₀ ψ (suc zero , u) v = f (u tt) (v tt) ψ (suc (suc ()) , u) v P : ∀ i (n : W ℕ-c i) → Set _ P i n = X (invert ℕ-struct-iso n) θ : ∀ i x → ((b : B (proj₁ x)) → P tt (proj₂ x b)) → P i (inW ℕ-c i x) θ i (a , u) v = ψ (a , invert ℕ-struct-iso ∘' u) v 𝓧 : AlgFib ℕ-c _ 𝓧 = P , θ ℕ-alg-iso : AlgSection ℕ-c 𝓧 ≅ ( Σ ((n : ℕ) → X n) λ x → (x₀ ≡ x 0) × (∀ n → f n (x n) ≡ x (suc n)) ) ℕ-alg-iso = begin AlgSection ℕ-c 𝓧 ≅⟨ ( Σ-ap-iso Π-left-unit λ g → iso≡ Π-left-unit) ⟩ ( Σ ((w : W ℕ-c tt) → P tt w) λ g → ( _≡_ {A = (x : F (W ℕ-c) tt) → P tt (inW ℕ-c tt x)} (λ x → θ tt x (λ b → g (proj₂ x b))) (λ x → g (inW ℕ-c tt x)) ) ) ≅⟨ sym≅ ( Σ-ap-iso (Π-ap-iso ℕ-struct-iso λ _ → refl≅) λ g → iso≡ (Π-ap-iso (sym≅ (F-ap-iso (λ i → sym≅ ℕ-struct-iso) tt)) λ x → refl≅ ) ) ⟩ ( Σ ((n : ℕ) → X n) λ g → ( _≡_ {A = (x : F (λ _ → ℕ) tt) → X (inℕ x)} (λ x → ψ x (λ b → g (proj₂ x b))) (λ x → g (inℕ x)) ) ) ≅⟨ ( Σ-ap-iso refl≅ λ g → iso≡ (Π-ap-iso (F-struct-iso (λ _ → ℕ)) λ _ → refl≅) ) ⟩ ( let φ = invert (F-struct-iso (λ _ → ℕ)) in Σ ((n : ℕ) → X n) λ g → ( _≡_ {A = (x : ⊤ ⊎ ℕ) → X (inℕ (φ x))} (λ x → ψ (φ x) (λ b → g (proj₂ (φ x) b))) (λ x → g (inℕ (φ x))) ) ) ≅⟨ ( Σ-ap-iso refl≅ λ x → iso≡ ⊎-universal ) ⟩ ( Σ ((n : ℕ) → X n) λ x → ( _≡_ {A = (⊤ → X 0) × ((n : ℕ) → X (suc n))} ((λ _ → x₀) , (λ n → f n (x n))) ((λ _ → x 0) , (λ n → x (suc n))) ) ) ≅⟨ ( Σ-ap-iso refl≅ λ x → sym≅ ×-split-iso ) ⟩ ( Σ ((n : ℕ) → X n) λ x → (_≡_ {A = ⊤ → X 0} (λ _ → x₀) (λ _ → x 0)) × (_≡_ {A = (n : ℕ) → X (suc n)} (λ n → f n (x n)) (λ n → x (suc n))) ) ≅⟨ ( Σ-ap-iso refl≅ λ x → ×-ap-iso (iso≡ Π-left-unit) (sym≅ strong-funext-iso) ) ⟩ ( Σ ((n : ℕ) → X n) λ x → (x₀ ≡ x 0) × (∀ n → f n (x n) ≡ x (suc n)) ) ∎ where open ≅-Reasoning ℕ-initial-simple : ∀ {i} {X : Set i} (x₀ : X) → contr ( Σ (ℕ → X) λ x → (x₀ ≡ x 0) × (∀ n → x n ≡ x (suc n)) ) ℕ-initial-simple {X = X} x₀ = ((λ _ → x₀) , refl , λ _ → refl) , (λ u → contr⇒prop (ℕ-initial (λ _ → X) x₀ (λ _ x → x)) _ u) ℕ-elim-shift : ∀ {i}{X : ℕ → Set i} → ((n : ℕ) → X n) ≅ ( (X 0) × ((n : ℕ) → X (suc n)) ) ℕ-elim-shift {i}{X} = begin ((n : ℕ) → X n) ≅⟨ (Π-ap-iso (sym≅ ℕ-algebra-iso) λ _ → refl≅) ⟩ ((n : ⊤ ⊎ ℕ) → X (apply ℕ-algebra-iso n)) ≅⟨ ⊎-universal ⟩ ((⊤ → X 0) × ((n : ℕ) → X (suc n))) ≅⟨ ×-ap-iso Π-left-unit refl≅ ⟩ (X 0 × ((n : ℕ) → X (suc n))) ∎ where open ≅-Reasoning
31.318182
88
0.403691
29fcc758cfa468078601af31b98873fef1e934fe
2,305
agda
Agda
htype-decidable.agda
hazelgrove/hazelnut-agda
a3640d7b0f76cdac193afd382694197729ed6d57
[ "MIT" ]
null
null
null
htype-decidable.agda
hazelgrove/hazelnut-agda
a3640d7b0f76cdac193afd382694197729ed6d57
[ "MIT" ]
null
null
null
htype-decidable.agda
hazelgrove/hazelnut-agda
a3640d7b0f76cdac193afd382694197729ed6d57
[ "MIT" ]
null
null
null
open import Nat open import Prelude open import dynamics-core open import contexts module htype-decidable where arr-lemma : ∀{t1 t2 t3 t4} → t1 ==> t2 == t3 ==> t4 → t1 == t3 × t2 == t4 arr-lemma refl = refl , refl sum-lemma : ∀{t1 t2 t3 t4} → t1 ⊕ t2 == t3 ⊕ t4 → t1 == t3 × t2 == t4 sum-lemma refl = refl , refl prod-lemma : ∀{t1 t2 t3 t4} → t1 ⊠ t2 == t3 ⊠ t4 → t1 == t3 × t2 == t4 prod-lemma refl = refl , refl htype-dec : (t1 t2 : htyp) → t1 == t2 + (t1 == t2 → ⊥) htype-dec num num = Inl refl htype-dec num ⦇-⦈ = Inr (λ ()) htype-dec num (t1 ==> t2) = Inr (λ ()) htype-dec num (t1 ⊕ t2) = Inr (λ ()) htype-dec ⦇-⦈ num = Inr (λ ()) htype-dec ⦇-⦈ ⦇-⦈ = Inl refl htype-dec ⦇-⦈ (t1 ==> t2) = Inr (λ ()) htype-dec ⦇-⦈ (t1 ⊕ t2) = Inr (λ ()) htype-dec (t1 ==> t2) num = Inr (λ ()) htype-dec (t1 ==> t2) ⦇-⦈ = Inr (λ ()) htype-dec (t1 ==> t2) (t3 ==> t4) with htype-dec t1 t3 | htype-dec t2 t4 ... | Inl refl | Inl refl = Inl refl ... | Inl refl | Inr x₁ = Inr (λ x → x₁ (π2 (arr-lemma x))) ... | Inr x | Inl refl = Inr (λ x₁ → x (π1 (arr-lemma x₁))) ... | Inr x | Inr x₁ = Inr (λ x₂ → x (π1 (arr-lemma x₂))) htype-dec (t1 ==> t2) (t3 ⊕ t4) = Inr (λ ()) htype-dec (t1 ⊕ t2) num = Inr (λ ()) htype-dec (t1 ⊕ t2) ⦇-⦈ = Inr (λ ()) htype-dec (t1 ⊕ t2) (t3 ==> t4) = Inr (λ ()) htype-dec (t1 ⊕ t2) (t3 ⊕ t4) with htype-dec t1 t3 | htype-dec t2 t4 ... | Inl refl | Inl refl = Inl refl ... | Inl refl | Inr x₁ = Inr (λ x → x₁ (π2 (sum-lemma x))) ... | Inr x | Inl refl = Inr (λ x₁ → x (π1 (sum-lemma x₁))) ... | Inr x | Inr x₁ = Inr (λ x₂ → x (π1 (sum-lemma x₂))) htype-dec num (t3 ⊠ t4) = Inr (λ ()) htype-dec ⦇-⦈ (t3 ⊠ t4) = Inr (λ ()) htype-dec (t1 ==> t2) (t3 ⊠ t4) = Inr (λ ()) htype-dec (t1 ⊕ t2) (t3 ⊠ t4) = Inr (λ ()) htype-dec (t1 ⊠ t2) num = Inr (λ ()) htype-dec (t1 ⊠ t2) ⦇-⦈ = Inr (λ ()) htype-dec (t1 ⊠ t2) (t3 ==> t4) = Inr (λ ()) htype-dec (t1 ⊠ t2) (t3 ⊕ t4) = Inr (λ ()) htype-dec (t1 ⊠ t2) (t3 ⊠ t4) with htype-dec t1 t3 | htype-dec t2 t4 ... | Inl refl | Inl refl = Inl refl ... | Inl refl | Inr x₁ = Inr (λ x → x₁ (π2 (prod-lemma x))) ... | Inr x | Inl refl = Inr (λ x₁ → x (π1 (prod-lemma x₁))) ... | Inr x | Inr x₁ = Inr (λ x₂ → x (π1 (prod-lemma x₂)))
40.438596
75
0.492408
c744cc6ac70bce8b5e48fb46d4fdc43e1a913b02
3,353
agda
Agda
Cubical/Data/Queue/Untruncated2ListInvariant.agda
kiana-S/univalent-foundations
8bdb0766260489f9c89a14f4c0f2ad26e5190dec
[ "MIT" ]
null
null
null
Cubical/Data/Queue/Untruncated2ListInvariant.agda
kiana-S/univalent-foundations
8bdb0766260489f9c89a14f4c0f2ad26e5190dec
[ "MIT" ]
1
2022-01-27T02:07:48.000Z
2022-01-27T02:07:48.000Z
Cubical/Data/Queue/Untruncated2ListInvariant.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.Queue.Untruncated2ListInvariant where open import Cubical.Foundations.Everything open import Cubical.Data.Empty as ⊥ open import Cubical.Data.List open import Cubical.Data.Maybe open import Cubical.Data.Prod module Untruncated2ListInvariant {ℓ} (A : Type ℓ) where -- Invariant Inv : List A → List A → Type ℓ Inv xs ys = ys ≡ [] → xs ≡ [] isPropInv : (xs ys : List A) → isProp (Inv xs ys) isPropInv xs ys = isPropΠ λ _ → isPropXs≡[] Inv-ys≡ys' : {xs ys ys' : List A} → (p : ys ≡ ys') → (invL : Inv xs ys) → (invR : Inv xs ys') → PathP (λ i → Inv xs (p i)) invL invR Inv-ys≡ys' {xs = xs} p invL invR = isProp→PathP (λ i → isPropInv xs (p i)) invL invR inv-xs-∷ : {xs ys : List A} {y : A} → Inv xs (y ∷ ys) inv-xs-∷ contra = ⊥.rec (¬cons≡nil contra) inv-xs-∷ʳ : {xs ys : List A} → {y : A} → Inv xs (ys ∷ʳ y) inv-xs-∷ʳ contra = ⊥.rec (¬snoc≡nil contra) inv-[]-ys : {ys : List A} → Inv [] ys inv-[]-ys ys = refl inv-invalid : {xs : List A} {x : A} → Inv (xs ∷ʳ x) [] → ⊥ inv-invalid inv = ¬snoc≡nil (inv refl) -- Queue data Q : Type ℓ where Q⟨_,_!_⟩ : (xs ys : List A) → (inv : Inv xs ys) → Q tilt : ∀ xs ys z l r → Q⟨ xs ++ [ z ] , ys ! l ⟩ ≡ Q⟨ xs , ys ++ [ z ] ! r ⟩ Q-ys≡ys' : ∀ xs {ys ys' : List A} l r → (p : ys ≡ ys') → Q⟨ xs , ys ! l ⟩ ≡ Q⟨ xs , ys' ! r ⟩ Q-ys≡ys' xs l r p i = Q⟨ xs , p i ! Inv-ys≡ys' p l r i ⟩ flush-xs : ∀ xs ys l r → Q⟨ xs , ys ! l ⟩ ≡ Q⟨ [] , ys ++ rev xs ! r ⟩ flush-xs xs ys l r = helper xs ys l r (snocView xs) where helper : ∀ xs ys l r → SnocView xs → Q⟨ xs , ys ! l ⟩ ≡ Q⟨ [] , ys ++ rev xs ! r ⟩ helper .[] ys l r nil i = Q⟨ [] , ++-unit-r ys (~ i) ! Inv-ys≡ys' (++-unit-r ys ⁻¹) l r i ⟩ helper .(xs ∷ʳ x) ys l r (snoc x xs s) = move-x ∙ IH ∙ Q-ys≡ys' [] inv-[]-ys r lemma where move-x : Q⟨ xs ∷ʳ x , ys ! l ⟩ ≡ Q⟨ xs , ys ∷ʳ x ! inv-xs-∷ʳ ⟩ move-x = tilt xs ys x l inv-xs-∷ʳ IH : Q⟨ xs , ys ∷ʳ x ! inv-xs-∷ʳ ⟩ ≡ Q⟨ [] , (ys ∷ʳ x) ++ rev xs ! inv-[]-ys ⟩ IH = helper xs (ys ∷ʳ x) inv-xs-∷ʳ inv-[]-ys s lemma : (ys ∷ʳ x) ++ rev xs ≡ ys ++ rev (xs ∷ʳ x) lemma = ++-assoc ys (x ∷ []) (rev xs) ∙ cong (ys ++_) (cons≡rev-snoc x xs) emp : Q emp = Q⟨ [] , [] ! inv-[]-ys ⟩ enq : A → Q → Q enq a Q⟨ xs , [] ! inv ⟩ = Q⟨ xs , a ∷ [] ! inv-xs-∷ ⟩ enq a Q⟨ xs , y ∷ ys ! inv ⟩ = Q⟨ a ∷ xs , y ∷ ys ! inv-xs-∷ ⟩ enq a (tilt xs [] z l r i) = proof i where proof : Q⟨ xs ++ z ∷ [] , a ∷ [] ! inv-xs-∷ ⟩ ≡ Q⟨ a ∷ xs , z ∷ [] ! inv-xs-∷ ⟩ proof = ⊥.rec (inv-invalid l) enq a (tilt xs (y ∷ ys) z l r i) = tilt (a ∷ xs) (y ∷ ys) z inv-xs-∷ inv-xs-∷ i deq : Q → Maybe (Q × A) deq Q⟨ xs , [] ! inv ⟩ = nothing deq Q⟨ xs , y ∷ [] ! inv ⟩ = just (Q⟨ [] , rev xs ! inv-[]-ys ⟩ , y) deq Q⟨ xs , y₁ ∷ y₂ ∷ ys ! inv ⟩ = just (Q⟨ xs , y₂ ∷ ys ! inv-xs-∷ ⟩ , y₁) deq (tilt xs [] z l r i) = proof i where proof : nothing ≡ just (Q⟨ [] , rev xs ! inv-[]-ys ⟩ , z) proof = ⊥.rec (inv-invalid l) deq (tilt xs (y ∷ []) z l r i) = just (proof i , y) where proof : Q⟨ [] , rev (xs ∷ʳ z) ! inv-[]-ys ⟩ ≡ Q⟨ xs , z ∷ [] ! inv-xs-∷ ⟩ proof = Q-ys≡ys' [] inv-[]-ys inv-xs-∷ (cons≡rev-snoc z xs ⁻¹) ∙ flush-xs xs (z ∷ []) inv-xs-∷ inv-xs-∷ ⁻¹ deq (tilt xs (y₁ ∷ y₂ ∷ ys) z l r i) = just ((tilt xs (y₂ ∷ ys) z inv-xs-∷ inv-xs-∷ i) , y₁)
40.890244
109
0.49329
58bad7f64a9a02433553172c629aa9f3b52ce646
8,013
agda
Agda
src/Colimit/Sequential/Erased.agda
nad/equality
402b20615cfe9ca944662380d7b2d69b0f175200
[ "MIT" ]
3
2020-05-21T22:58:50.000Z
2021-09-02T17:18:15.000Z
src/Colimit/Sequential/Erased.agda
nad/equality
402b20615cfe9ca944662380d7b2d69b0f175200
[ "MIT" ]
null
null
null
src/Colimit/Sequential/Erased.agda
nad/equality
402b20615cfe9ca944662380d7b2d69b0f175200
[ "MIT" ]
null
null
null
------------------------------------------------------------------------ -- The sequential colimit HIT with an erased higher constructor ------------------------------------------------------------------------ {-# OPTIONS --erased-cubical --safe #-} -- The definition of sequential colimits and the statement of the -- non-dependent universal property are based on those in van Doorn's -- "Constructing the Propositional Truncation using Non-recursive -- HITs". -- The module is parametrised by a notion of equality. The higher -- constructor of the HIT defining sequential colimits uses path -- equality, but the supplied notion of equality is used for many -- other things. import Equality.Path as P module Colimit.Sequential.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 Equality.Path.Isomorphisms eq open import Equivalence equality-with-J as Eq using (_≃_) open import Erased.Cubical eq private variable a b p q : Level A B : Type a P : A → Type p n : ℕ e x : A ------------------------------------------------------------------------ -- The type -- Sequential colimits, with an erased higher constructor. data Colimitᴱ (P : ℕ → Type p) (@0 step : ∀ {n} → P n → P (suc n)) : Type p where ∣_∣ : P n → Colimitᴱ P step @0 ∣∣≡∣∣ᴾ : (x : P n) → ∣ step x ∣ P.≡ ∣ x ∣ -- A variant of ∣∣≡∣∣ᴾ. @0 ∣∣≡∣∣ : {step : ∀ {n} → P n → P (suc n)} (x : P n) → _≡_ {A = Colimitᴱ P step} ∣ step x ∣ ∣ x ∣ ∣∣≡∣∣ x = _↔_.from ≡↔≡ (∣∣≡∣∣ᴾ x) ------------------------------------------------------------------------ -- Eliminators -- A dependent eliminator, expressed using paths. record Elimᴾ {P : ℕ → Type p} {@0 step : ∀ {n} → P n → P (suc n)} (Q : Colimitᴱ P step → Type q) : Type (p ⊔ q) where no-eta-equality field ∣∣ʳ : (x : P n) → Q ∣ x ∣ @0 ∣∣≡∣∣ʳ : (x : P n) → P.[ (λ i → Q (∣∣≡∣∣ᴾ x i)) ] ∣∣ʳ (step x) ≡ ∣∣ʳ x open Elimᴾ public elimᴾ : {@0 step : ∀ {n} → P n → P (suc n)} {Q : Colimitᴱ P step → Type q} → Elimᴾ Q → (x : Colimitᴱ P step) → Q x elimᴾ {P = P} {step = step} {Q = Q} e = helper where module E = Elimᴾ e helper : (x : Colimitᴱ P step) → Q x helper ∣ x ∣ = E.∣∣ʳ x helper (∣∣≡∣∣ᴾ x i) = E.∣∣≡∣∣ʳ x i -- A non-dependent eliminator, expressed using paths. record Recᴾ (P : ℕ → Type p) (@0 step : ∀ {n} → P n → P (suc n)) (B : Type b) : Type (p ⊔ b) where no-eta-equality field ∣∣ʳ : P n → B @0 ∣∣≡∣∣ʳ : (x : P n) → ∣∣ʳ (step x) P.≡ ∣∣ʳ x open Recᴾ public recᴾ : {@0 step : ∀ {n} → P n → P (suc n)} → Recᴾ P step B → Colimitᴱ P step → B recᴾ r = elimᴾ λ where .∣∣ʳ → R.∣∣ʳ .∣∣≡∣∣ʳ → R.∣∣≡∣∣ʳ where module R = Recᴾ r -- A dependent eliminator. record Elim {P : ℕ → Type p} {@0 step : ∀ {n} → P n → P (suc n)} (Q : Colimitᴱ P step → Type q) : Type (p ⊔ q) where no-eta-equality field ∣∣ʳ : (x : P n) → Q ∣ x ∣ @0 ∣∣≡∣∣ʳ : (x : P n) → subst Q (∣∣≡∣∣ x) (∣∣ʳ (step x)) ≡ ∣∣ʳ x open Elim public elim : {@0 step : ∀ {n} → P n → P (suc n)} {Q : Colimitᴱ P step → Type q} → Elim Q → (x : Colimitᴱ P step) → Q x elim e = elimᴾ λ where .∣∣ʳ → E.∣∣ʳ .∣∣≡∣∣ʳ x → subst≡→[]≡ (E.∣∣≡∣∣ʳ x) where module E = Elim e -- A "computation" rule. @0 elim-∣∣≡∣∣ : dcong (elim e) (∣∣≡∣∣ x) ≡ Elim.∣∣≡∣∣ʳ e x elim-∣∣≡∣∣ = dcong-subst≡→[]≡ (refl _) -- A non-dependent eliminator. record Rec (P : ℕ → Type p) (@0 step : ∀ {n} → P n → P (suc n)) (B : Type b) : Type (p ⊔ b) where no-eta-equality field ∣∣ʳ : P n → B @0 ∣∣≡∣∣ʳ : (x : P n) → ∣∣ʳ (step x) ≡ ∣∣ʳ x open Rec public rec : {@0 step : ∀ {n} → P n → P (suc n)} → Rec P step B → Colimitᴱ P step → B rec r = recᴾ λ where .∣∣ʳ → R.∣∣ʳ .∣∣≡∣∣ʳ x → _↔_.to ≡↔≡ (R.∣∣≡∣∣ʳ x) where module R = Rec r -- A "computation" rule. @0 rec-∣∣≡∣∣ : {step : ∀ {n} → P n → P (suc n)} {r : Rec P step B} {x : P n} → cong (rec r) (∣∣≡∣∣ x) ≡ Rec.∣∣≡∣∣ʳ r x rec-∣∣≡∣∣ = cong-≡↔≡ (refl _) ------------------------------------------------------------------------ -- The universal property -- The universal property of the sequential colimit. universal-property : {@0 step : ∀ {n} → P n → P (suc n)} → (Colimitᴱ P step → B) ≃ (∃ λ (f : ∀ n → P n → B) → Erased (∀ n x → f (suc n) (step x) ≡ f n x)) universal-property {P = P} {B = B} {step = step} = Eq.↔→≃ to from to∘from from∘to where to : (Colimitᴱ P step → B) → ∃ λ (f : ∀ n → P n → B) → Erased (∀ n x → f (suc n) (step x) ≡ f n x) to h = (λ _ → h ∘ ∣_∣) , [ (λ _ x → h ∣ step x ∣ ≡⟨ cong h (∣∣≡∣∣ x) ⟩∎ h ∣ x ∣ ∎) ] from : (∃ λ (f : ∀ n → P n → B) → Erased (∀ n x → f (suc n) (step x) ≡ f n x)) → Colimitᴱ P step → B from (f , g) = rec λ where .∣∣ʳ → f _ .∣∣≡∣∣ʳ → erased g _ to∘from : ∀ p → to (from p) ≡ p to∘from (f , g) = cong (f ,_) $ []-cong [ (⟨ext⟩ λ n → ⟨ext⟩ λ x → cong (rec _) (∣∣≡∣∣ x) ≡⟨ rec-∣∣≡∣∣ ⟩∎ erased g n x ∎) ] from∘to : ∀ h → from (to h) ≡ h from∘to h = ⟨ext⟩ $ elim λ where .∣∣ʳ _ → refl _ .∣∣≡∣∣ʳ x → subst (λ z → from (to h) z ≡ h z) (∣∣≡∣∣ x) (refl _) ≡⟨ subst-in-terms-of-trans-and-cong ⟩ trans (sym (cong (from (to h)) (∣∣≡∣∣ x))) (trans (refl _) (cong h (∣∣≡∣∣ x))) ≡⟨ cong₂ (λ p q → trans (sym p) q) rec-∣∣≡∣∣ (trans-reflˡ _) ⟩ trans (sym (cong h (∣∣≡∣∣ x))) (cong h (∣∣≡∣∣ x)) ≡⟨ trans-symˡ _ ⟩∎ refl _ ∎ -- A dependently typed variant of the sequential colimit's universal -- property. universal-property-Π : {@0 step : ∀ {n} → P n → P (suc n)} → {Q : Colimitᴱ P step → Type q} → ((x : Colimitᴱ P step) → Q x) ≃ (∃ λ (f : ∀ n (x : P n) → Q ∣ x ∣) → Erased (∀ n x → subst Q (∣∣≡∣∣ x) (f (suc n) (step x)) ≡ f n x)) universal-property-Π {P = P} {step = step} {Q = Q} = Eq.↔→≃ to from to∘from from∘to where to : ((x : Colimitᴱ P step) → Q x) → ∃ λ (f : ∀ n (x : P n) → Q ∣ x ∣) → Erased (∀ n x → subst Q (∣∣≡∣∣ x) (f (suc n) (step x)) ≡ f n x) to h = (λ _ → h ∘ ∣_∣) , [ (λ _ x → subst Q (∣∣≡∣∣ x) (h ∣ step x ∣) ≡⟨ dcong h (∣∣≡∣∣ x) ⟩∎ h ∣ x ∣ ∎) ] from : (∃ λ (f : ∀ n (x : P n) → Q ∣ x ∣) → Erased (∀ n x → subst Q (∣∣≡∣∣ x) (f (suc n) (step x)) ≡ f n x)) → (x : Colimitᴱ P step) → Q x from (f , [ g ]) = elim λ where .∣∣ʳ → f _ .∣∣≡∣∣ʳ → g _ to∘from : ∀ p → to (from p) ≡ p to∘from (f , [ g ]) = cong (f ,_) $ []-cong [ (⟨ext⟩ λ n → ⟨ext⟩ λ x → dcong (elim _) (∣∣≡∣∣ x) ≡⟨ elim-∣∣≡∣∣ ⟩∎ g n x ∎) ] from∘to : ∀ h → from (to h) ≡ h from∘to h = ⟨ext⟩ $ elim λ where .∣∣ʳ _ → refl _ .∣∣≡∣∣ʳ x → subst (λ z → from (to h) z ≡ h z) (∣∣≡∣∣ x) (refl _) ≡⟨ subst-in-terms-of-trans-and-dcong ⟩ trans (sym (dcong (from (to h)) (∣∣≡∣∣ x))) (trans (cong (subst Q (∣∣≡∣∣ x)) (refl _)) (dcong h (∣∣≡∣∣ x))) ≡⟨ cong₂ (λ p q → trans (sym p) q) elim-∣∣≡∣∣ (trans (cong (flip trans _) $ cong-refl _) $ trans-reflˡ _) ⟩ trans (sym (dcong h (∣∣≡∣∣ x))) (dcong h (∣∣≡∣∣ x)) ≡⟨ trans-symˡ _ ⟩∎ refl _ ∎
29.788104
98
0.41208
ad3264dca1832138afc440beb6ab794a83142eac
181
agda
Agda
Agda/00-preamble.agda
jonsterling/HoTT-Intro
7457d00fbd2c0a993b01cd2b3dbc4f259213845e
[ "CC-BY-4.0" ]
null
null
null
Agda/00-preamble.agda
jonsterling/HoTT-Intro
7457d00fbd2c0a993b01cd2b3dbc4f259213845e
[ "CC-BY-4.0" ]
null
null
null
Agda/00-preamble.agda
jonsterling/HoTT-Intro
7457d00fbd2c0a993b01cd2b3dbc4f259213845e
[ "CC-BY-4.0" ]
null
null
null
{-# OPTIONS --without-K --exact-split #-} module 00-preamble where open import Agda.Primitive using (Level; lzero; lsuc; _⊔_) public UU : (i : Level) → Set (lsuc i) UU i = Set i
20.111111
65
0.657459
2e01160c069c86937ad3a6cd271a5119ced83604
412
agda
Agda
src/Singleton.agda
Zalastax/singly-typed-actors
ae541df13d069df4eb1464f29fbaa9804aad439f
[ "MIT" ]
1
2019-10-29T09:30:26.000Z
2019-10-29T09:30:26.000Z
src/Singleton.agda
Zalastax/singly-typed-actors
ae541df13d069df4eb1464f29fbaa9804aad439f
[ "MIT" ]
null
null
null
src/Singleton.agda
Zalastax/singly-typed-actors
ae541df13d069df4eb1464f29fbaa9804aad439f
[ "MIT" ]
null
null
null
module Singleton where open import Data.List using (List ; [] ; _∷_) open import Data.List.All using (All ; [] ; _∷_) open import Membership using (_∈_; _⊆_ ; _∷_ ; []) [_]ˡ : ∀{a}{A : Set a} → A → List A [ a ]ˡ = a ∷ [] [_]ᵃ : ∀{a p} {A : Set a} {P : A → Set p} {x : A} → P x → All P (x ∷ []) [ p ]ᵃ = p ∷ [] [_]ᵐ : ∀{a} {A : Set a} {x : A} {ys : List A} → (x ∈ ys) → ((x ∷ []) ⊆ ys) [ p ]ᵐ = p ∷ []
22.888889
75
0.43932
4d590d368a1292ca1e362fe1c66c976ed9651d33
23
agda
Agda
test/Fail/ParseError.agda
mdimjasevic/agda
8fb548356b275c7a1e79b768b64511ae937c738b
[ "BSD-3-Clause" ]
1,989
2015-01-09T23:51:16.000Z
2022-03-30T18:20:48.000Z
test/Fail/ParseError.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
4,066
2015-01-10T11:24:51.000Z
2022-03-31T21:14:49.000Z
test/Fail/ParseError.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
371
2015-01-03T14:04:08.000Z
2022-03-30T19:00:30.000Z
modle ParseError where
11.5
22
0.869565
2e790bed89d5ca0e327751d86cb42758181b2af1
3,024
agda
Agda
src/Lens/Non-dependent/Higher/Surjective-remainder.agda
nad/dependent-lenses
f2da6f7e95b87ca525e8ea43929c6d6163a74811
[ "MIT" ]
3
2020-04-16T12:10:46.000Z
2020-07-03T08:55:52.000Z
src/Lens/Non-dependent/Higher/Surjective-remainder.agda
nad/dependent-lenses
f2da6f7e95b87ca525e8ea43929c6d6163a74811
[ "MIT" ]
null
null
null
src/Lens/Non-dependent/Higher/Surjective-remainder.agda
nad/dependent-lenses
f2da6f7e95b87ca525e8ea43929c6d6163a74811
[ "MIT" ]
1
2020-07-01T14:33:26.000Z
2020-07-01T14:33:26.000Z
------------------------------------------------------------------------ -- Higher lenses, defined using the requirement that the remainder -- function should be surjective ------------------------------------------------------------------------ {-# OPTIONS --cubical #-} import Equality.Path as P module Lens.Non-dependent.Higher.Surjective-remainder {e⁺} (eq : ∀ {a p} → P.Equality-with-paths a p e⁺) where open P.Derived-definitions-and-properties eq open import Prelude open import Equality.Path.Isomorphisms eq open import Equivalence equality-with-J as Eq using (_≃_) open import Function-universe equality-with-J hiding (_∘_) open import H-level.Truncation.Propositional eq open import Lens.Non-dependent eq import Lens.Non-dependent.Higher eq as Higher private variable a b : Level A B : Type a -- A variant of the lenses defined in Lens.Non-dependent.Higher. In -- this definition the function called inhabited is replaced by a -- requirement that the remainder function should be surjective. record Lens (A : Type a) (B : Type b) : Type (lsuc (a ⊔ b)) where field -- Remainder type. R : Type (a ⊔ b) -- Equivalence. equiv : A ≃ (R × B) -- Remainder. remainder : A → R remainder a = proj₁ (_≃_.to equiv a) field -- The remainder function is surjective. remainder-surjective : Surjective remainder -- Getter. get : A → B get a = proj₂ (_≃_.to equiv a) -- Setter. set : A → B → A set a b = _≃_.from equiv (remainder a , b) instance -- The lenses defined above have getters and setters. has-getter-and-setter : Has-getter-and-setter (Lens {a = a} {b = b}) has-getter-and-setter = record { get = Lens.get ; set = Lens.set } -- Lens can be expressed as a nested Σ-type. Lens-as-Σ : {A : Type a} {B : Type b} → Lens A B ≃ ∃ λ (R : Type (a ⊔ b)) → ∃ λ (equiv : A ≃ (R × B)) → Surjective (proj₁ ∘ _≃_.to equiv) Lens-as-Σ = Eq.↔→≃ (λ l → R l , equiv l , remainder-surjective l) (λ (R , equiv , remainder-surjective) → record { R = R ; equiv = equiv ; remainder-surjective = remainder-surjective }) refl refl where open Lens -- Higher.Lens A B is equivalent to Lens A B. Higher-lens≃Lens : Higher.Lens A B ≃ Lens A B Higher-lens≃Lens {A = A} {B = B} = Higher.Lens A B ↔⟨ Higher.Lens-as-Σ ⟩ (∃ λ (R : Type _) → (A ≃ (R × B)) × (R → ∥ B ∥)) ↝⟨ (∃-cong λ _ → ∃-cong Higher.inhabited≃remainder-surjective) ⟩ (∃ λ (R : Type _) → ∃ λ (equiv : A ≃ (R × B)) → Surjective (proj₁ ∘ _≃_.to equiv)) ↝⟨ inverse Lens-as-Σ ⟩□ Lens A B □ -- The equivalence preserves getters and setters. Higher-lens≃Lens-preserves-getters-and-setters : Preserves-getters-and-setters-⇔ A B (_≃_.logical-equivalence Higher-lens≃Lens) Higher-lens≃Lens-preserves-getters-and-setters = (λ _ → refl _ , refl _) , (λ _ → refl _ , refl _)
26.295652
111
0.577712
31fe9142c146df5df4820bff3bc5d8bfedb63dfb
325
agda
Agda
test/Succeed/RewritingGlobalConfluenceWithProp.agda
cagix/agda
cc026a6a97a3e517bb94bafa9d49233b067c7559
[ "BSD-2-Clause" ]
1,989
2015-01-09T23:51:16.000Z
2022-03-30T18:20:48.000Z
test/Succeed/RewritingGlobalConfluenceWithProp.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
4,066
2015-01-10T11:24:51.000Z
2022-03-31T21:14:49.000Z
test/Succeed/RewritingGlobalConfluenceWithProp.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
371
2015-01-03T14:04:08.000Z
2022-03-30T19:00:30.000Z
{-# OPTIONS --prop --rewriting --confluence-check #-} open import Agda.Builtin.Equality open import Agda.Builtin.Equality.Rewrite postulate A : Prop a : A B : Set b : B f : A → B → Set₁ g : B → Set₁ rew₁ : ∀ y → f a y ≡ g y rew₂ : ∀ x → f x b ≡ Set rew₃ : ∀ y → g y ≡ Set {-# REWRITE rew₁ rew₂ rew₃ #-}
17.105263
53
0.569231
2fd76c1df7c68ead2e5275cb7c0f19f263dff2ba
2,229
agda
Agda
examples/AIM6/RegExp/talk/SimpleMatcher.agda
asr/agda-kanso
aa10ae6a29dc79964fe9dec2de07b9df28b61ed5
[ "MIT" ]
1
2019-11-27T07:26:06.000Z
2019-11-27T07:26:06.000Z
examples/AIM6/RegExp/talk/SimpleMatcher.agda
np/agda-git-experiment
20596e9dd9867166a64470dd24ea68925ff380ce
[ "MIT" ]
null
null
null
examples/AIM6/RegExp/talk/SimpleMatcher.agda
np/agda-git-experiment
20596e9dd9867166a64470dd24ea68925ff380ce
[ "MIT" ]
null
null
null
------------------------------------------------------------------------ -- Simple regular expression matcher ------------------------------------------------------------------------ open import Eq open import Setoids open import Prelude import RegExps module SimpleMatcher (D : Datoid) where private open module D' = Datoid D open module S' = Setoid setoid open module R = RegExps setoid infix 4 _∈‿⟦_⟧¿ ------------------------------------------------------------------------ -- A lemma private lemma : forall {a x xs₂} -> (xs₁ : [ a ]) -> (xs₁ ++ x ∷ []) ++ xs₂ ≡ xs₁ ++ x ∷ xs₂ lemma [] = refl lemma (x ∷ xs) = cong (\ys -> x ∷ ys) (lemma xs) ------------------------------------------------------------------------ -- Regular expression matcher -- The type of _∈‿⟦_⟧¿ documents its soundness (assuming that the code -- is terminating). To prove completeness more work is necessary. matches-⊙¿ : forall xs₁ xs₂ re₁ re₂ -> Maybe (xs₁ ++ xs₂ ∈‿⟦ re₁ ⊙ re₂ ⟧) _∈‿⟦_⟧¿ : (xs : [ carrier ]) -> (re : RegExp) -> Maybe (xs ∈‿⟦ re ⟧) [] ∈‿⟦ ε ⟧¿ = just matches-ε _ ∷ [] ∈‿⟦ • ⟧¿ = just matches-• x ∷ [] ∈‿⟦ sym y ⟧¿ with x ≟ y x ∷ [] ∈‿⟦ sym y ⟧¿ | yes eq = just (matches-sym eq) x ∷ [] ∈‿⟦ sym y ⟧¿ | no _ = nothing xs ∈‿⟦ re₁ ∣ re₂ ⟧¿ with xs ∈‿⟦ re₁ ⟧¿ xs ∈‿⟦ re₁ ∣ re₂ ⟧¿ | just m = just (matches-∣ˡ m) xs ∈‿⟦ re₁ ∣ re₂ ⟧¿ | nothing with xs ∈‿⟦ re₂ ⟧¿ xs ∈‿⟦ re₁ ∣ re₂ ⟧¿ | nothing | just m = just (matches-∣ʳ m) xs ∈‿⟦ re₁ ∣ re₂ ⟧¿ | nothing | nothing = nothing xs ∈‿⟦ re₁ ⊙ re₂ ⟧¿ = matches-⊙¿ [] xs re₁ re₂ [] ∈‿⟦ re ⋆ ⟧¿ = just (matches-⋆ (matches-∣ˡ matches-ε)) x ∷ xs ∈‿⟦ re ⋆ ⟧¿ with matches-⊙¿ (x ∷ []) xs re (re ⋆) x ∷ xs ∈‿⟦ re ⋆ ⟧¿ | just m = just (matches-⋆ (matches-∣ʳ m)) x ∷ xs ∈‿⟦ re ⋆ ⟧¿ | nothing = nothing _ ∈‿⟦ _ ⟧¿ = nothing matches-⊙¿ xs₁ xs₂ re₁ re₂ with xs₁ ∈‿⟦ re₁ ⟧¿ | xs₂ ∈‿⟦ re₂ ⟧¿ matches-⊙¿ xs₁ xs₂ re₁ re₂ | just m₁ | just m₂ = just (matches-⊙ m₁ m₂) matches-⊙¿ xs₁ [] re₁ re₂ | _ | _ = nothing matches-⊙¿ xs₁ (x ∷ xs₂) re₁ re₂ | _ | _ = subst (\xs -> Maybe (xs ∈‿⟦ re₁ ⊙ re₂ ⟧)) (lemma xs₁) (matches-⊙¿ (xs₁ ++ x ∷ []) xs₂ re₁ re₂)
35.380952
72
0.444594
2eb34f6bcabf4308841436b225e64f422b764cba
2,770
agda
Agda
test/Succeed/Issue3889.agda
mdimjasevic/agda
8fb548356b275c7a1e79b768b64511ae937c738b
[ "BSD-3-Clause" ]
1,989
2015-01-09T23:51:16.000Z
2022-03-30T18:20:48.000Z
test/Succeed/Issue3889.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
4,066
2015-01-10T11:24:51.000Z
2022-03-31T21:14:49.000Z
test/Succeed/Issue3889.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
371
2015-01-03T14:04:08.000Z
2022-03-30T19:00:30.000Z
-- Andreas, 2019-07-05, during work on issue #3889 -- Test-case for with extracted from the standard library {-# OPTIONS --without-K #-} open import Agda.Primitive open import Agda.Builtin.Equality open import Agda.Builtin.List open import Common.Equality open import Common.Product data Any {a}{A : Set a} {p} (P : A → Set p) : List A → Set (a ⊔ p) where here : ∀ {x xs} (px : P x) → Any P (x ∷ xs) there : ∀ {x xs} (pxs : Any P xs) → Any P (x ∷ xs) _∈_ : ∀{a}{A : Set a} → A → List A → Set _ x ∈ xs = Any (x ≡_) xs map : ∀ {a} {A : Set a} {p q} {P : A → Set p} {Q : A → Set q} → (∀{x} → P x → Q x) → ∀{xs} → Any P xs → Any Q xs map g (here px) = here (g px) map g (there pxs) = there (map g pxs) map₁ : ∀ {a b c} {A : Set a} {B : Set b} {C : Set c} → (A → B) → A × C → B × C map₁ f (x , y)= f x , y map₂ : ∀ {a b c} {A : Set a} {B : A → Set b} {C : A → Set c} → (∀ {x} → B x → C x) → Σ A B → Σ A C map₂ f (x , y) = (x , f y) find : ∀ {a} {p} {A : Set a} {P : A → Set p} {xs} → Any P xs → Σ _ λ x → x ∈ xs × P x find (here px) = (_ , here refl , px) find (there pxs) = map₂ (map₁ there) (find pxs) lose : ∀ {a} {p} {A : Set a} {P : A → Set p} {x xs} → x ∈ xs → P x → Any P xs lose x∈xs px = map (λ eq → subst _ eq px) x∈xs map∘find : ∀ {a p} {A : Set a} {P : A → Set p} {xs} (p : Any P xs) → let p′ = find p in {f : ∀{x} → proj₁ p′ ≡ x → P x} → f refl ≡ proj₂ (proj₂ p′) → map f (proj₁ (proj₂ p′)) ≡ p map∘find (here p) hyp = cong here hyp map∘find (there p) hyp = cong there (map∘find p hyp) find∘map : ∀ {a p q} {A : Set a} {P : A → Set p} {Q : A → Set q} {xs : List A} (p : Any P xs) (f : ∀{x} → P x → Q x) → find (map f p) ≡ map₂ (map₂ f) (find p) find∘map (here p) f = refl find∘map (there p) f rewrite find∘map p f = refl lose∘find : ∀ {a p} {A : Set a} {P : A → Set p} {xs : List A} (p : Any P xs) → (let (y , z) = proj₂ (find p)) → lose y z ≡ p lose∘find p = map∘find p refl postulate a b ℓ : Level A : Set a B : Set b P : A → Set ℓ Q : B → Set ℓ -- Level needed Any-×⁺ : ∀ {xs ys} → Any P xs × Any Q ys → Any (λ x → Any (λ y → P x × Q y) ys) xs Any-×⁺ (p , q) = map (λ p → map (λ q → (p , q)) q) p Any-×⁻ : ∀ {xs ys} → Any (λ x → Any (λ y → P x × Q y) ys) xs → Any P xs × Any Q ys Any-×⁻ pq with map₂ (map₂ find) (find pq) ... | (x , x∈xs , y , y∈ys , p , q) = (lose x∈xs p , lose y∈ys q) module _ where from∘to : ∀{xs ys} (pq : Any P xs × Any Q ys) → Any-×⁻ (Any-×⁺ pq) ≡ pq -- from∘to (p , q) = {!!} from∘to (p , q) rewrite find∘map p (λ p → map (λ q → (p , q)) q) | find∘map q (λ q → proj₂ (proj₂ (find p)) , q) | lose∘find p | lose∘find q = refl
32.97619
112
0.474007
ad5f6f4712d08c5cdae4bf98a53bdb6f6a6e3c0a
291
agda
Agda
test/Succeed/Issue296.agda
mdimjasevic/agda
8fb548356b275c7a1e79b768b64511ae937c738b
[ "BSD-3-Clause" ]
1,989
2015-01-09T23:51:16.000Z
2022-03-30T18:20:48.000Z
test/Succeed/Issue296.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
4,066
2015-01-10T11:24:51.000Z
2022-03-31T21:14:49.000Z
test/Succeed/Issue296.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
371
2015-01-03T14:04:08.000Z
2022-03-30T19:00:30.000Z
module Issue296 where postulate Unit : Set IO : Set → Set foo : ((A B : Set) → Unit) → IO Unit bar : (A B : Set) → Unit {-# BUILTIN IO IO #-} {-# COMPILE GHC IO = type IO #-} {-# COMPILE GHC Unit = type () #-} {-# COMPILE GHC bar = undefined #-} main : IO Unit main = foo bar
18.1875
39
0.556701
c7b40b41c557889beedf15d31cfedae58d341107
10,788
agda
Agda
core/lib/types/Modality.agda
AntoineAllioux/HoTT-Agda
1037d82edcf29b620677a311dcfd4fc2ade2faa6
[ "MIT" ]
294
2015-01-09T16:23:23.000Z
2022-03-20T13:54:45.000Z
core/lib/types/Modality.agda
AntoineAllioux/HoTT-Agda
1037d82edcf29b620677a311dcfd4fc2ade2faa6
[ "MIT" ]
31
2015-03-05T20:09:00.000Z
2021-10-03T19:15:25.000Z
core/lib/types/Modality.agda
AntoineAllioux/HoTT-Agda
1037d82edcf29b620677a311dcfd4fc2ade2faa6
[ "MIT" ]
50
2015-01-10T01:48:08.000Z
2022-02-14T03:03:25.000Z
{-# OPTIONS --without-K --rewriting #-} open import lib.Basics open import lib.NType2 open import lib.types.Sigma module lib.types.Modality where -- Where to put this? Or maybe there's -- a simpler proof from some library function? !ᵈ-inv-l-out : ∀ {ℓ} {A : Type ℓ} {P : A → Type ℓ} {a₀ a₁ : A} {p : a₀ == a₁} {x₀ x₁ : P a₁} → (q : x₀ == x₁ [ P ↓ ! p ∙ p ]) → x₀ == x₁ !ᵈ-inv-l-out {p = idp} q = q record Modality ℓ : Type (lsucc ℓ) where field is-local : Type ℓ → Type ℓ is-local-is-prop : {A : Type ℓ} → is-prop (is-local A) ◯ : Type ℓ → Type ℓ ◯-is-local : {A : Type ℓ} → is-local (◯ A) η : {A : Type ℓ} → A → ◯ A ◯-elim : {A : Type ℓ} {B : ◯ A → Type ℓ} (B-local : (x : ◯ A) → is-local (B x)) → Π A (B ∘ η) → Π (◯ A) B ◯-elim-β : {A : Type ℓ} {B : ◯ A → Type ℓ} (B-local : (x : ◯ A) → is-local (B x)) (f : Π A (B ∘ η)) → (a : A) → ◯-elim B-local f (η a) == f a ◯-=-is-local : {A : Type ℓ} (a₀ a₁ : ◯ A) → is-local (a₀ == a₁) ◯-Type : Type (lsucc ℓ) ◯-Type = Σ (Type ℓ) is-local {- elimination rules -} module ◯Elim {A : Type ℓ} {B : ◯ A → Type ℓ} (B-local : (x : ◯ A) → is-local (B x)) (η* : Π A (B ∘ η)) where f = ◯-elim B-local η* η-β = ◯-elim-β B-local η* module ◯Rec {A : Type ℓ} {B : Type ℓ} (B-local : is-local B) (η* : A → B) = ◯Elim (λ _ → B-local) η* ◯-rec = ◯Rec.f ◯-rec-β = ◯Rec.η-β {- functoriality -} module ◯Fmap {A B : Type ℓ} (f : A → B) = ◯Rec ◯-is-local (η ∘ f) ◯-fmap = ◯Fmap.f ◯-fmap-β = ◯Fmap.η-β ◯-isemap : {A B : Type ℓ} (f : A → B) → is-equiv f → is-equiv (◯-fmap f) ◯-isemap f f-ise = is-eq _ (◯-fmap g) to-from from-to where open is-equiv f-ise abstract to-from : ∀ ◯b → ◯-fmap f (◯-fmap g ◯b) == ◯b to-from = ◯-elim (λ ◯b → ◯-=-is-local (◯-fmap f (◯-fmap g ◯b)) ◯b) (λ b → ap (◯-fmap f) (◯-fmap-β g b) ∙ ◯-fmap-β f (g b) ∙ ap η (f-g b)) from-to : ∀ ◯a → ◯-fmap g (◯-fmap f ◯a) == ◯a from-to = ◯-elim (λ ◯a → ◯-=-is-local (◯-fmap g (◯-fmap f ◯a)) ◯a) (λ a → ap (◯-fmap g) (◯-fmap-β f a) ∙ ◯-fmap-β g (f a) ∙ ap η (g-f a)) ◯-emap : {A B : Type ℓ} → A ≃ B → ◯ A ≃ ◯ B ◯-emap (f , f-ise) = ◯-fmap f , ◯-isemap f f-ise {- equivalences preserve locality -} -- This is the only appearence of univalence, but ... local-is-replete : {A B : Type ℓ} → is-local A → A ≃ B → is-local B local-is-replete w eq = transport is-local (ua eq) w -- This name aligns with the current codebase better. equiv-preserves-local : {A B : Type ℓ} → A ≃ B → is-local A → is-local B equiv-preserves-local e A-is-loc = local-is-replete A-is-loc e {- locality and [η] being an equivalence -} local-implies-η-equiv : {A : Type ℓ} → is-local A → is-equiv (η {A}) local-implies-η-equiv {A} w = is-eq (η {A}) η-inv inv-l inv-r where η-inv : ◯ A → A η-inv = ◯-rec w (idf A) abstract inv-r : (a : A) → η-inv (η a) == a inv-r = ◯-rec-β w (idf A) inv-l : (a : ◯ A) → η (η-inv a) == a inv-l = ◯-elim (λ a₀ → ◯-=-is-local _ _) (λ a₀ → ap η (inv-r a₀)) abstract η-equiv-implies-local : {A : Type ℓ} → is-equiv (η {A}) → is-local A η-equiv-implies-local {A} eq = local-is-replete {◯ A} {A} ◯-is-local ((η , eq) ⁻¹) retract-is-local : {A B : Type ℓ} (w : is-local A) (f : A → B) (g : B → A) (r : (b : B) → f (g b) == b) → is-local B retract-is-local {A} {B} w f g r = η-equiv-implies-local (is-eq η η-inv inv-l inv-r) where η-inv : ◯ B → B η-inv = f ∘ (◯-rec w g) inv-r : (b : B) → η-inv (η b) == b inv-r b = ap f (◯-rec-β w g b) ∙ r b inv-l : (b : ◯ B) → η (η-inv b) == b inv-l = ◯-elim (λ b → ◯-=-is-local _ _) (λ b → ap η (inv-r b)) {- locality of identification -} abstract =-preserves-local : {A : Type ℓ} → is-local A → {a₀ a₁ : A} → is-local (a₀ == a₁) =-preserves-local {A} w {a₀} {a₁} = local-is-replete (◯-=-is-local (η a₀) (η a₁)) (ap-equiv (η , local-implies-η-equiv w) a₀ a₁ ⁻¹) {- ◯-connectness and ◯-equivalences -} is-◯-connected : Type ℓ → Type ℓ is-◯-connected A = is-contr (◯ A) is-◯-connected-is-prop : ∀ {A} → is-prop (is-◯-connected A) is-◯-connected-is-prop {A} = is-contr-is-prop is-◯-equiv : {A B : Type ℓ} → (A → B) → Type ℓ is-◯-equiv {B = B} f = (b : B) → is-◯-connected (hfiber f b) has-◯-conn-fibers = is-◯-equiv is-lex : Type (lsucc ℓ) is-lex = {A B : Type ℓ} (f : A → B) → is-◯-connected A → is-◯-connected B → is-◯-equiv f equiv-preserves-◯-conn : {A B : Type ℓ} → A ≃ B → is-◯-connected A → is-◯-connected B equiv-preserves-◯-conn e c = equiv-preserves-level (◯-emap e) {{c}} total-◯-equiv : {A : Type ℓ} {P Q : A → Type ℓ} (φ : ∀ a → P a → Q a) → (∀ a → is-◯-equiv (φ a)) → is-◯-equiv (Σ-fmap-r φ) total-◯-equiv φ e (a , q) = equiv-preserves-◯-conn (hfiber-Σ-fmap-r φ q ⁻¹) (e a q) module _ {A B : Type ℓ} {h : A → B} (c : is-◯-equiv h) (P : B → ◯-Type) where abstract pre∘-◯-conn-is-equiv : is-equiv (λ (s : Π B (fst ∘ P)) → s ∘ h) pre∘-◯-conn-is-equiv = is-eq f g f-g g-f where f : Π B (fst ∘ P) → Π A (fst ∘ P ∘ h) f k a = k (h a) helper : Π A (fst ∘ P ∘ h) → (b : B) → ◯ (Σ A (λ a → h a == b)) → (fst (P b)) helper t b = ◯-rec (snd (P b)) (λ x → transport (fst ∘ P) (snd x) (t (fst x))) helper-β : (t : Π A (fst ∘ P ∘ h)) → (b : B) → (r : hfiber h b) → helper t b (η r) == transport (fst ∘ P) (snd r) (t (fst r)) helper-β t b = ◯-rec-β (snd (P b)) (λ x → transport (fst ∘ P) (snd x) (t (fst x))) g : Π A (fst ∘ P ∘ h) → Π B (fst ∘ P) g t b = helper t b (contr-center (c b)) f-g : ∀ t → f (g t) == t f-g t = λ= $ λ a → transport (λ r → ◯-rec (snd (P (h a))) _ r == t a) (! (contr-path (c (h a)) (η (a , idp)))) (◯-rec-β (snd (P (h a))) _ (a , idp)) g-f : ∀ k → g (f k) == k g-f k = λ= λ (b : B) → ◯-elim {A = hfiber h b} (λ r → =-preserves-local (snd (P b)) {g (f k) b}) (λ r → lemma₁ (fst r) b (snd r)) (contr-center (c b)) where lemma₀ : (a : A) → (b : B) → (p : h a == b) → helper (k ∘ h) b (η (a , p)) == k b lemma₀ a .(h a) idp = helper-β (k ∘ h) (h a) (a , idp) lemma₁ : (a : A) → (b : B) → (p : h a == b) → helper (k ∘ h) b (contr-center (c b)) == k b lemma₁ a b p = transport! (λ r → helper (k ∘ h) b r == k b) (contr-path (c b) (η (a , p))) (lemma₀ a b p) ◯-extend : Π A (fst ∘ P ∘ h) → Π B (fst ∘ P) ◯-extend = is-equiv.g pre∘-◯-conn-is-equiv ◯-extend-β : ∀ f a → ◯-extend f (h a) == f a ◯-extend-β f = app= (is-equiv.f-g pre∘-◯-conn-is-equiv f) {- locality of function types -} abstract Π-is-local : {A : Type ℓ} {B : A → Type ℓ} (w : (a : A) → is-local (B a)) → is-local (Π A B) Π-is-local {A} {B} w = retract-is-local {◯ (Π A B)} {Π A B} ◯-is-local η-inv η r where η-inv : ◯ (Π A B) → Π A B η-inv φ' a = ◯-rec (w a) (λ φ → φ a) φ' r : (φ : Π A B) → η-inv (η φ) == φ r φ = λ= (λ a → ◯-rec-β (w a) (λ φ₀ → φ₀ a) φ) →-is-local : {A B : Type ℓ} → is-local B → is-local (A → B) →-is-local w = Π-is-local (λ _ → w) -- Fmap2 because of locality of function types module ◯Fmap2 {A B C : Type ℓ} (η* : A → B → C) where private module M = ◯Rec (→-is-local ◯-is-local) (◯-fmap ∘ η*) f = M.f η-β : ∀ a b → f (η a) (η b) == η (η* a b) η-β a b = app= (M.η-β a) (η b) ∙ ◯-fmap-β (η* a) b ◯-fmap2 = ◯Fmap2.f ◯-fmap2-β = ◯Fmap2.η-β {- locality of sigma types -} abstract Σ-is-local : {A : Type ℓ} (B : A → Type ℓ) → is-local A → ((a : A) → is-local (B a)) → is-local (Σ A B) Σ-is-local {A} B lA lB = retract-is-local {◯ (Σ A B)} {Σ A B} ◯-is-local η-inv η r where h : ◯ (Σ A B) → A h = ◯-rec lA fst h-β : (ab : Σ A B) → h (η ab) == fst ab h-β = ◯-rec-β lA fst k : (w : ◯ (Σ A B)) → B (h w) k = ◯-elim (lB ∘ h) λ ab → transport! B (h-β ab) (snd ab) k-β : (ab : Σ A B) → k (η ab) == snd ab [ B ↓ h-β ab ] k-β ab = from-transp! B (h-β ab) $ ◯-elim-β (lB ∘ h) (λ ab → transport! B (h-β ab) (snd ab)) ab η-inv : ◯ (Σ A B) → Σ A B η-inv w = h w , k w r : (x : Σ A B) → η-inv (η x) == x r ab = pair= (h-β ab) (k-β ab) ×-is-local : {A B : Type ℓ} → is-local A → is-local B → is-local (A × B) ×-is-local {B = B} lA lB = Σ-is-local (λ _ → B) lA (λ _ → lB) ◯-×-econv : {A B : Type ℓ} → ◯ (A × B) ≃ ◯ A × ◯ B ◯-×-econv {A} {B} = equiv ◯-split ◯-pair inv-l inv-r where ◯-fst : ◯ (A × B) → ◯ A ◯-fst = ◯-fmap fst ◯-fst-β : (ab : A × B) → ◯-fst (η ab) == η (fst ab) ◯-fst-β = ◯-fmap-β fst ◯-snd : ◯ (A × B) → ◯ B ◯-snd = ◯-fmap snd ◯-snd-β : (ab : A × B) → ◯-snd (η ab) == η (snd ab) ◯-snd-β = ◯-fmap-β snd ◯-split : ◯ (A × B) → ◯ A × ◯ B ◯-split = fanout ◯-fst ◯-snd ◯-pair : ◯ A × ◯ B → ◯ (A × B) ◯-pair = uncurry (◯-fmap2 _,_) ◯-pair-β : (a : A) (b : B) → ◯-pair (η a , η b) == η (a , b) ◯-pair-β = ◯-fmap2-β _,_ abstract inv-l : (ab : ◯ A × ◯ B) → ◯-split (◯-pair ab) == ab inv-l = uncurry $ ◯-elim (λ _ → Π-is-local λ _ → =-preserves-local (×-is-local ◯-is-local ◯-is-local)) (λ a → ◯-elim (λ _ → =-preserves-local (×-is-local ◯-is-local ◯-is-local)) (λ b → ap ◯-split (◯-pair-β a b) ∙ pair×= (◯-fst-β (a , b)) (◯-snd-β (a , b)))) inv-r : (ab : ◯ (A × B)) → ◯-pair (◯-split ab) == ab inv-r = ◯-elim (λ _ → ◯-=-is-local _ _) (λ ab → ap ◯-pair (pair×= (◯-fst-β ab) (◯-snd-β ab)) ∙ ◯-pair-β (fst ab) (snd ab))
37.072165
111
0.412495
4afa2fbc13e35892d57703c71473c3561d3fa59b
71
agda
Agda
test/Succeed/Issue4267/A0.agda
mdimjasevic/agda
8fb548356b275c7a1e79b768b64511ae937c738b
[ "BSD-3-Clause" ]
1,989
2015-01-09T23:51:16.000Z
2022-03-30T18:20:48.000Z
test/Succeed/Issue4267/A0.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
4,066
2015-01-10T11:24:51.000Z
2022-03-31T21:14:49.000Z
test/Succeed/Issue4267/A0.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
371
2015-01-03T14:04:08.000Z
2022-03-30T19:00:30.000Z
module Issue4267.A0 where record RA0 : Set₁ where field A : Set
11.833333
25
0.690141
a1c06f2997cb6445e2a5609d2c2ee02f5e5e7b5a
1,533
agda
Agda
test/Succeed/Issue1269.agda
mdimjasevic/agda
8fb548356b275c7a1e79b768b64511ae937c738b
[ "BSD-3-Clause" ]
3
2015-03-28T14:51:03.000Z
2015-12-07T20:14:00.000Z
test/Succeed/Issue1269.agda
mdimjasevic/agda
8fb548356b275c7a1e79b768b64511ae937c738b
[ "BSD-3-Clause" ]
3
2018-11-14T15:31:44.000Z
2019-04-01T19:39:26.000Z
test/Succeed/Issue1269.agda
mdimjasevic/agda
8fb548356b275c7a1e79b768b64511ae937c738b
[ "BSD-3-Clause" ]
1
2015-09-15T14:36:15.000Z
2015-09-15T14:36:15.000Z
-- ASR (29 September 2014). Adapted from the example in issue 1269. -- Case: quote η-reduced and quoteTerm η-reduced. open import Common.Equality open import Common.Level open import Common.Prelude renaming (Nat to ℕ) open import Common.Product open import Common.Reflection data Even : ℕ → Set where isEven0 : Even 0 isEven+2 : ∀ {n} → Even n → Even (suc (suc n)) pattern expected = def (quote ∃) ( arg (argInfo hidden relevant) (def (quote Common.Level.lzero) []) ∷ arg (argInfo hidden relevant) (def (quote Common.Level.lzero) []) ∷ arg (argInfo hidden relevant) (def (quote ℕ) []) ∷ arg (argInfo visible relevant) (def (quote Even) []) ∷ [] ) isExpected : Term → Bool isExpected expected = true isExpected _ = false `_ : Bool → Term ` true = con (quote true) [] ` false = con (quote false) [] macro checkExpectedType : QName → Tactic checkExpectedType i hole = bindTC (getType i) λ t → give (` isExpected t) hole input0 : ∃ Even input0 = 0 , isEven0 input1 : ∃ (λ n → Even n) input1 = 0 , isEven0 quote0 : Bool quote0 = checkExpectedType input0 quote1 : Bool quote1 = checkExpectedType input1 ok0 : quote0 ≡ true ok0 = refl ok1 : quote1 ≡ true ok1 = refl ------------------------------------------------------------------------------ -- For debugging purpose quotedTerm0 : Term quotedTerm0 = quoteTerm (∃ Even) quotedTerm1 : Term quotedTerm1 = quoteTerm (∃ (λ n → Even n)) b : quotedTerm0 ≡ expected b = refl c : quotedTerm1 ≡ expected c = refl
22.217391
78
0.631442
57290a35e33bc5bdf9039e2b23495893884b3cb3
643
agda
Agda
test/Succeed/Issue3274.agda
mdimjasevic/agda
8fb548356b275c7a1e79b768b64511ae937c738b
[ "BSD-3-Clause" ]
1,989
2015-01-09T23:51:16.000Z
2022-03-30T18:20:48.000Z
test/Succeed/Issue3274.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
4,066
2015-01-10T11:24:51.000Z
2022-03-31T21:14:49.000Z
test/Succeed/Issue3274.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
371
2015-01-03T14:04:08.000Z
2022-03-30T19:00:30.000Z
open import Agda.Builtin.Nat data Vec (A : Set) : Nat → Set where variable A : Set x : A n : Nat xs : Vec A n postulate IsHead : A → Vec A (suc n) → Set -- The `n` should be generalized over since the generalizable n in the type of xs -- is solved with suc n. foo : IsHead {n = _} x xs → Nat foo h = 0 check-foo : {A : Set} {x : A} {n : Nat} {xs : Vec A (suc n)} → IsHead x xs → Nat check-foo = foo -- Should work also if the meta is created in an extended context bar : (X : Set) → IsHead x xs → Nat bar X h = 0 check-bar : {A : Set} {x : A} {n : Nat} {xs : Vec A (suc n)} → (X : Set) → IsHead x xs → Nat check-bar = bar
22.172414
92
0.59098
c7ed5e75ae186911881b15dc4df408ad918d67f7
5,286
agda
Agda
src/data/lib/prim/Agda/Builtin/Cubical/Glue.agda
phadej/agda
2fa8ede09451d43647f918dbfb24ff7b27c52edc
[ "BSD-3-Clause" ]
null
null
null
src/data/lib/prim/Agda/Builtin/Cubical/Glue.agda
phadej/agda
2fa8ede09451d43647f918dbfb24ff7b27c52edc
[ "BSD-3-Clause" ]
null
null
null
src/data/lib/prim/Agda/Builtin/Cubical/Glue.agda
phadej/agda
2fa8ede09451d43647f918dbfb24ff7b27c52edc
[ "BSD-3-Clause" ]
null
null
null
{-# OPTIONS --cubical --safe --no-sized-types --no-guardedness #-} module Agda.Builtin.Cubical.Glue where open import Agda.Primitive open import Agda.Builtin.Sigma open import Agda.Primitive.Cubical renaming (primINeg to ~_; primIMax to _∨_; primIMin to _∧_; primHComp to hcomp; primTransp to transp; primComp to comp; itIsOne to 1=1) open import Agda.Builtin.Cubical.Path open import Agda.Builtin.Cubical.Sub renaming (Sub to _[_↦_]; primSubOut to ouc) module Helpers where -- Homogeneous filling hfill : ∀ {ℓ} {A : Set ℓ} {φ : I} (u : ∀ i → Partial φ A) (u0 : A [ φ ↦ u i0 ]) (i : I) → A hfill {φ = φ} u u0 i = hcomp (λ j → \ { (φ = i1) → u (i ∧ j) 1=1 ; (i = i0) → ouc u0 }) (ouc u0) -- Heterogeneous filling defined using comp fill : ∀ {ℓ : I → Level} (A : ∀ i → Set (ℓ i)) {φ : I} (u : ∀ i → Partial φ (A i)) (u0 : A i0 [ φ ↦ u i0 ]) → ∀ i → A i fill A {φ = φ} u u0 i = comp (λ j → A (i ∧ j)) _ (λ j → \ { (φ = i1) → u (i ∧ j) 1=1 ; (i = i0) → ouc u0 }) (ouc {φ = φ} u0) module _ {ℓ} {A : Set ℓ} where refl : {x : A} → x ≡ x refl {x = x} = λ _ → x sym : {x y : A} → x ≡ y → y ≡ x sym p = λ i → p (~ i) cong : ∀ {ℓ'} {B : A → Set ℓ'} {x y : A} (f : (a : A) → B a) (p : x ≡ y) → PathP (λ i → B (p i)) (f x) (f y) cong f p = λ i → f (p i) isContr : ∀ {ℓ} → Set ℓ → Set ℓ isContr A = Σ A \ x → (∀ y → x ≡ y) fiber : ∀ {ℓ ℓ'} {A : Set ℓ} {B : Set ℓ'} (f : A → B) (y : B) → Set (ℓ ⊔ ℓ') fiber {A = A} f y = Σ A \ x → f x ≡ y open Helpers -- We make this a record so that isEquiv can be proved using -- copatterns. This is good because copatterns don't get unfolded -- unless a projection is applied so it should be more efficient. record isEquiv {ℓ ℓ'} {A : Set ℓ} {B : Set ℓ'} (f : A → B) : Set (ℓ ⊔ ℓ') where field equiv-proof : (y : B) → isContr (fiber f y) open isEquiv public infix 4 _≃_ _≃_ : ∀ {ℓ ℓ'} (A : Set ℓ) (B : Set ℓ') → Set (ℓ ⊔ ℓ') A ≃ B = Σ (A → B) \ f → (isEquiv f) equivFun : ∀ {ℓ ℓ'} {A : Set ℓ} {B : Set ℓ'} → A ≃ B → A → B equivFun e = fst e -- Improved version of equivProof compared to Lemma 5 in CCHM. We put -- the (φ = i0) face in contr' making it be definitionally c in this -- case. This makes the computational behavior better, in particular -- for transp in Glue. equivProof : ∀ {la lt} (T : Set la) (A : Set lt) → (w : T ≃ A) → (a : A) → ∀ ψ → (Partial ψ (fiber (w .fst) a)) → fiber (w .fst) a equivProof A B w a ψ fb = contr' {A = fiber (w .fst) a} (w .snd .equiv-proof a) ψ fb where contr' : ∀ {ℓ} {A : Set ℓ} → isContr A → (φ : I) → (u : Partial φ A) → A contr' {A = A} (c , p) φ u = hcomp (λ i → λ { (φ = i1) → p (u 1=1) i ; (φ = i0) → c }) c {-# BUILTIN EQUIV _≃_ #-} {-# BUILTIN EQUIVFUN equivFun #-} {-# BUILTIN EQUIVPROOF equivProof #-} primitive primGlue : ∀ {ℓ ℓ'} (A : Set ℓ) {φ : I} → (T : Partial φ (Set ℓ')) → (e : PartialP φ (λ o → T o ≃ A)) → Set ℓ' prim^glue : ∀ {ℓ ℓ'} {A : Set ℓ} {φ : I} → {T : Partial φ (Set ℓ')} → {e : PartialP φ (λ o → T o ≃ A)} → PartialP φ T → A → primGlue A T e prim^unglue : ∀ {ℓ ℓ'} {A : Set ℓ} {φ : I} → {T : Partial φ (Set ℓ')} → {e : PartialP φ (λ o → T o ≃ A)} → primGlue A T e → A -- Needed for transp in Glue. primFaceForall : (I → I) → I module _ {ℓ : I → Level} (P : (i : I) → Set (ℓ i)) where private E : (i : I) → Set (ℓ i) E = λ i → P i ~E : (i : I) → Set (ℓ (~ i)) ~E = λ i → P (~ i) A = P i0 B = P i1 f : A → B f x = transp E i0 x g : B → A g y = transp ~E i0 y u : ∀ i → A → E i u i x = transp (λ j → E (i ∧ j)) (~ i) x v : ∀ i → B → E i v i y = transp (λ j → ~E ( ~ i ∧ j)) i y fiberPath : (y : B) → (xβ0 xβ1 : fiber f y) → xβ0 ≡ xβ1 fiberPath y (x0 , β0) (x1 , β1) k = ω , λ j → δ (~ j) where module _ (j : I) where private sys : A → ∀ i → PartialP (~ j ∨ j) (λ _ → E (~ i)) sys x i (j = i0) = v (~ i) y sys x i (j = i1) = u (~ i) x ω0 = comp ~E _ (sys x0) ((β0 (~ j))) ω1 = comp ~E _ (sys x1) ((β1 (~ j))) θ0 = fill ~E (sys x0) (inc (β0 (~ j))) θ1 = fill ~E (sys x1) (inc (β1 (~ j))) sys = λ {j (k = i0) → ω0 j ; j (k = i1) → ω1 j} ω = hcomp sys (g y) θ = hfill sys (inc (g y)) δ = λ (j : I) → comp E _ (λ i → λ { (j = i0) → v i y ; (k = i0) → θ0 j (~ i) ; (j = i1) → u i ω ; (k = i1) → θ1 j (~ i) }) (θ j) γ : (y : B) → y ≡ f (g y) γ y j = comp E _ (λ i → λ { (j = i0) → v i y ; (j = i1) → u i (g y) }) (g y) pathToisEquiv : isEquiv f pathToisEquiv .equiv-proof y .fst .fst = g y pathToisEquiv .equiv-proof y .fst .snd = sym (γ y) pathToisEquiv .equiv-proof y .snd = fiberPath y _ pathToEquiv : A ≃ B pathToEquiv .fst = f pathToEquiv .snd = pathToisEquiv {-# BUILTIN PATHTOEQUIV pathToEquiv #-}
33.245283
104
0.449678
c7ade1a29356fc1999a888784079d6a94bf3ec05
1,568
agda
Agda
src/Experimental/SimpleTT.agda
cilinder/formaltt
0a9d25e6e3965913d9b49a47c88cdfb94b55ffeb
[ "MIT" ]
21
2021-02-16T14:07:06.000Z
2021-11-19T15:50:08.000Z
src/Experimental/SimpleTT.agda
andrejbauer/formaltt
2aaf850bb1a262681c5a232cdefae312f921b9d4
[ "MIT" ]
1
2021-04-30T14:18:25.000Z
2021-05-14T16:15:17.000Z
src/Experimental/SimpleTT.agda
andrejbauer/formaltt
2aaf850bb1a262681c5a232cdefae312f921b9d4
[ "MIT" ]
6
2021-02-16T13:43:07.000Z
2021-05-24T02:51:43.000Z
module SimpleTT where data 𝟘 : Set where absurd : ∀ {ℓ} {A : Set ℓ} → 𝟘 → A absurd () data _⁺ (A : Set) : Set where Z : A ⁺ S : A → A ⁺ record Signature : Set₁ where field ty-op : Set tm-op : Set ty-ty-arg : ty-op → Set -- ty-tm-arg : ty-op → Set -- tm-ty-arg : tm-op → Set tm-tm-arg : tm-op → Set open Signature data Theory : Set₁ thy-signature : Theory → Signature data Ty (T : Theory) : Set data Tm (T : Theory) (A : Ty T) : Set data Theory where thy-empty : Theory th-type : ∀ (T : Theory) → (α : Set) → (α → Ty T) → Theory th-term : ∀ (T : Theory) → (α : Set) → (α → Ty T) → Ty T → Theory thy-signature thy-empty = record { ty-op = 𝟘 ; tm-op = 𝟘 ; ty-ty-arg = absurd ; tm-tm-arg = absurd } thy-signature (th-type T α x) = record { ty-op = (ty-op Σ) ⁺ ; tm-op = tm-op Σ ; ty-ty-arg = t ; tm-tm-arg = tm-tm-arg Σ } where Σ = thy-signature T t : ∀ (f : (ty-op Σ) ⁺) → Set t Z = α t (S f) = ty-ty-arg (thy-signature T) f thy-signature (th-term T α ts t) = record { ty-op = ty-op Σ ; tm-op = (tm-op Σ) ⁺ ; ty-ty-arg = ty-ty-arg Σ ; tm-tm-arg = tm } where Σ = thy-signature T tm : ∀ (f : (tm-op Σ) ⁺) → Set tm Z = {!!} tm (S x) = {!!} data Ty T where ty-expr : ∀ (f : ty-op (thy-signature T)) → (ty-ty-arg (thy-signature T) f → Ty T) → Ty T data Tm T A where
23.058824
93
0.458546
2ef65e1768bf0635f13b7ad2c8f0a572a779d619
11,071
agda
Agda
src/Categories/Category/CartesianClosed.agda
jaykru/agda-categories
a4053cf700bcefdf73b857c3352f1eae29382a60
[ "MIT" ]
1
2021-04-18T18:21:47.000Z
2021-04-18T18:21:47.000Z
src/Categories/Category/CartesianClosed.agda
jaykru/agda-categories
a4053cf700bcefdf73b857c3352f1eae29382a60
[ "MIT" ]
null
null
null
src/Categories/Category/CartesianClosed.agda
jaykru/agda-categories
a4053cf700bcefdf73b857c3352f1eae29382a60
[ "MIT" ]
null
null
null
{-# OPTIONS --without-K --safe #-} open import Categories.Category module Categories.Category.CartesianClosed {o ℓ e} (𝒞 : Category o ℓ e) where open import Level open import Function using (_$_; flip) open import Data.Product using (Σ; _,_; uncurry) open import Categories.Functor renaming (id to idF) open import Categories.Functor.Bifunctor open import Categories.NaturalTransformation hiding (id) open import Categories.NaturalTransformation.Properties open import Categories.Category.Cartesian 𝒞 open import Categories.Category.Monoidal.Closed open import Categories.Object.Product 𝒞 hiding (repack≡id; repack∘; repack-cancel; up-to-iso; transport-by-iso) open import Categories.Object.Exponential 𝒞 hiding (repack) open import Categories.Morphism 𝒞 open import Categories.Morphism.Reasoning 𝒞 private module 𝒞 = Category 𝒞 open Category 𝒞 open HomReasoning open Equiv variable A B C : Obj f g h i : A ⇒ B -- Cartesian closed category -- is a category with all products and exponentials record CartesianClosed : Set (levelOfTerm 𝒞) where infixr 9 _^_ -- an alternative notation for exponential, which emphasizes its internal hom natural infixr 5 _⇨_ field cartesian : Cartesian exp : Exponential A B module exp {A B} = Exponential (exp {A} {B}) _^_ : Obj → Obj → Obj B ^ A = exp.B^A {A} {B} _⇨_ : Obj → Obj → Obj _⇨_ = flip _^_ module cartesian = Cartesian cartesian open cartesian public open CartesianMonoidal cartesian using (A×⊤≅A) B^A×A : ∀ B A → Product (B ^ A) A B^A×A B A = exp.product {A} {B} eval : Product.A×B (B^A×A B A) ⇒ B eval = exp.eval λg : C × A ⇒ B → C ⇒ B ^ A λg f = exp.λg product f λ-cong : f ≈ g → λg f ≈ λg g λ-cong eq = exp.λ-cong product eq _×id : (f : C ⇒ B ^ A) → C × A ⇒ [[ B^A×A B A ]] f ×id = [ product ⇒ exp.product ] f ×id β : eval ∘ λg f ×id ≈ f β = exp.β product η-exp : λg (eval ∘ f ×id) ≈ f η-exp = exp.η product λ-unique : eval ∘ f ×id ≈ g → f ≈ λg g λ-unique = exp.λ-unique product λ-unique₂ : eval ∘ f ×id ≈ eval ∘ g ×id → f ≈ g λ-unique₂ = exp.λ-unique′ product -- the annoying detail is that B^A×A is NOT the same as B ^ A × A, but they are isomorphic. -- make some infra so that the latter (which is more intuitive) can be used. B^A×A-iso : Product.A×B (B^A×A B A) ≅ B ^ A × A B^A×A-iso {B = B} {A = A} = record { from = repack exp.product product ; to = repack product exp.product ; iso = record { isoˡ = begin repack product exp.product ∘ repack exp.product product ≈⟨ [ exp.product ]⟨⟩∘ ⟩ [ exp.product ]⟨ π₁ ∘ repack exp.product product , π₂ ∘ repack exp.product product ⟩ ≈⟨ Product.⟨⟩-cong₂ exp.product project₁ project₂ ⟩ [ exp.product ]⟨ [ exp.product ]π₁ , [ exp.product ]π₂ ⟩ ≈⟨ Product.η exp.product ⟩ id ∎ ; isoʳ = begin repack exp.product product ∘ repack product exp.product ≈⟨ ⟨⟩∘ ⟩ ⟨ [ exp.product ]π₁ ∘ repack product exp.product , [ exp.product ]π₂ ∘ repack product exp.product ⟩ ≈⟨ ⟨⟩-cong₂ (Product.project₁ exp.product) (Product.project₂ exp.product) ⟩ ⟨ π₁ , π₂ ⟩ ≈⟨ η ⟩ id ∎ } } eval′ : B ^ A × A ⇒ B eval′ = eval ∘ to where open _≅_ B^A×A-iso λ-unique′ : eval′ ∘ (f ⁂ id) ≈ g → f ≈ λg g λ-unique′ eq = exp.λ-unique product (⟺ (pullʳ [ product ⇒ product ⇒ exp.product ]repack∘×) ○ eq) λ-unique₂′ : eval′ ∘ (f ⁂ id) ≈ eval′ ∘ (g ⁂ id) → f ≈ g λ-unique₂′ eq = (λ-unique′ eq) ○ ⟺ (λ-unique′ refl) β′ : eval′ ∘ (λg f ⁂ id) ≈ f β′ {f = f} = begin eval′ ∘ (λg f ⁂ id) ≈⟨ pullʳ [ product ⇒ product ⇒ exp.product ]repack∘× ⟩ eval ∘ λg f ×id ≈⟨ β ⟩ f ∎ η-exp′ : λg (eval′ ∘ (f ⁂ id)) ≈ f η-exp′ = sym (λ-unique′ refl) η-id′ : λg (eval′ {B = B} {A = A}) ≈ id η-id′ = sym (λ-unique′ (elimʳ (id×id product))) ⊤^A≅⊤ : ⊤ ^ A ≅ ⊤ ⊤^A≅⊤ = record { from = ! ; to = λg ! ; iso = record { isoˡ = λ-unique₂ !-unique₂ ; isoʳ = ⊤-id _ } } A^⊤≅A : A ^ ⊤ ≅ A A^⊤≅A = record { from = let open _≅_ A×⊤≅A in eval′ ∘ to ; to = let open _≅_ A×⊤≅A in λg from ; iso = record { isoˡ = λ-unique₂′ $ begin eval′ ∘ ((λg π₁ ∘ eval′ ∘ ⟨ id , ! ⟩) ⁂ id) ≈˘⟨ refl⟩∘⟨ first∘first ⟩ eval′ ∘ ((λg π₁ ⁂ id) ∘ ((eval′ ∘ ⟨ id , ! ⟩) ⁂ id)) ≈⟨ pullˡ β′ ⟩ π₁ ∘ ((eval′ ∘ ⟨ id , ! ⟩) ⁂ id) ≈⟨ helper ⟩ eval′ ∘ (id ⁂ id) ∎ ; isoʳ = firstid ! $ begin ((eval′ ∘ ⟨ id , ! ⟩) ∘ λg π₁) ⁂ id ≈˘⟨ first∘first ⟩ (eval′ ∘ ⟨ id , ! ⟩ ⁂ id) ∘ (λg π₁ ⁂ id) ≈⟨ helper′ ⟩∘⟨refl ⟩ (⟨ id , ! ⟩ ∘ eval′) ∘ (λg π₁ ⁂ id) ≈⟨ pullʳ β′ ⟩ ⟨ id , ! ⟩ ∘ π₁ ≈⟨ ⟨⟩∘ ⟩ ⟨ id ∘ π₁ , ! ∘ π₁ ⟩ ≈⟨ ⟨⟩-cong₂ identityˡ !-unique₂ ⟩ ⟨ π₁ , π₂ ⟩ ≈⟨ η ⟩ id ∎ } } where helper = begin π₁ ∘ ((eval′ ∘ ⟨ id , ! ⟩) ⁂ id) ≈⟨ project₁ ⟩ (eval′ ∘ ⟨ id , ! ⟩) ∘ π₁ ≈⟨ pullʳ ⟨⟩∘ ⟩ eval′ ∘ ⟨ id ∘ π₁ , ! ∘ π₁ ⟩ ≈⟨ refl⟩∘⟨ ⟨⟩-congˡ !-unique₂ ⟩ eval′ ∘ (id ⁂ id) ∎ helper′ = let open _≅_ A×⊤≅A in begin (eval′ ∘ ⟨ id , ! ⟩) ⁂ id ≈⟨ introˡ isoˡ ⟩ (⟨ id , ! ⟩ ∘ π₁) ∘ ((eval′ ∘ ⟨ id , ! ⟩) ⁂ id) ≈⟨ pullʳ helper ⟩ ⟨ id , ! ⟩ ∘ (eval′ ∘ (id ⁂ id)) ≈⟨ refl⟩∘⟨ elimʳ (id×id product) ⟩ ⟨ id , ! ⟩ ∘ eval′ ∎ -- we use -⇨- to represent the bifunctor. -- -^- would generate a bifunctor of type Bifunctor 𝒞 𝒞.op 𝒞 which is not very typical. -⇨- : Bifunctor 𝒞.op 𝒞 𝒞 -⇨- = record { F₀ = uncurry _⇨_ ; F₁ = λ where (f , g) → λg (g ∘ eval′ ∘ second f) ; identity = λ-cong (identityˡ ○ (elimʳ (id×id product))) ○ η-id′ ; homomorphism = λ-unique₂′ helper ; F-resp-≈ = λ where (eq₁ , eq₂) → λ-cong (∘-resp-≈ eq₂ (∘-resp-≈ʳ (⁂-cong₂ refl eq₁))) } where helper : eval′ ∘ first (λg ((g ∘ f) ∘ eval′ ∘ second (h ∘ i))) ≈ eval′ ∘ first (λg (g ∘ eval′ ∘ second i) ∘ λg (f ∘ eval′ ∘ second h)) helper {g = g} {f = f} {h = h} {i = i} = begin eval′ ∘ first (λg ((g ∘ f) ∘ eval′ ∘ second (h ∘ i))) ≈⟨ β′ ⟩ (g ∘ f) ∘ eval′ ∘ second (h ∘ i) ≈˘⟨ refl⟩∘⟨ pullʳ second∘second ⟩ (g ∘ f) ∘ (eval′ ∘ second h) ∘ second i ≈⟨ center refl ⟩ g ∘ (f ∘ eval′ ∘ second h) ∘ second i ≈˘⟨ refl⟩∘⟨ pullˡ β′ ⟩ g ∘ eval′ ∘ first (λg (f ∘ eval′ ∘ second h)) ∘ second i ≈⟨ refl⟩∘⟨ pushʳ first↔second ⟩ g ∘ (eval′ ∘ second i) ∘ first (λg (f ∘ eval′ ∘ second h)) ≈⟨ sym-assoc ⟩ (g ∘ eval′ ∘ second i) ∘ first (λg (f ∘ eval′ ∘ second h)) ≈˘⟨ pullˡ β′ ⟩ eval′ ∘ first (λg (g ∘ eval′ ∘ second i)) ∘ first (λg (f ∘ eval′ ∘ second h)) ≈⟨ refl⟩∘⟨ first∘first ⟩ eval′ ∘ first (λg (g ∘ eval′ ∘ second i) ∘ λg (f ∘ eval′ ∘ second h)) ∎ _⇨- : Obj → Endofunctor 𝒞 _⇨- = appˡ -⇨- -⇨_ : Obj → Functor 𝒞.op 𝒞 -⇨_ = appʳ -⇨- -- The cartesian closed structure induces a monoidal closed one: -- 𝒞 is cartesian monoidal closed. module CartesianMonoidalClosed (cartesianClosed : CartesianClosed) where open CartesianClosed cartesianClosed open CartesianMonoidal cartesian using (monoidal) private A⇨[-×A] : Obj → Endofunctor 𝒞 A⇨[-×A] A = A ⇨- ∘F -× A module A⇨[-×A] {A} = Functor (A⇨[-×A] A) [A⇨-]×A : Obj → Endofunctor 𝒞 [A⇨-]×A A = -× A ∘F A ⇨- module [A⇨-]×A {A} = Functor ([A⇨-]×A A) closedMonoidal : Closed monoidal closedMonoidal = record { [-,-] = -⇨- ; adjoint = λ {A} → record { unit = ntHelper record { η = λ _ → λg id ; commute = λ f → λ-unique₂′ $ begin eval′ ∘ first (λg id ∘ f) ≈˘⟨ refl⟩∘⟨ first∘first ⟩ eval′ ∘ first (λg id) ∘ first f ≈⟨ cancelˡ β′ ⟩ first f ≈˘⟨ cancelʳ β′ ⟩ (first f ∘ eval′) ∘ first (λg id) ≈˘⟨ ∘-resp-≈ʳ (elimʳ (id×id product)) ⟩∘⟨refl ⟩ (first f ∘ eval′ ∘ first id) ∘ first (λg id) ≈˘⟨ pullˡ β′ ⟩ eval′ ∘ first (A⇨[-×A].F₁ f) ∘ first (λg id) ≈⟨ refl⟩∘⟨ first∘first ⟩ eval′ ∘ first (A⇨[-×A].F₁ f ∘ λg id) ∎ } ; counit = ntHelper record { η = λ _ → eval′ ; commute = λ f → begin eval′ ∘ [A⇨-]×A.F₁ f ≈⟨ β′ ⟩ f ∘ eval′ ∘ first id ≈⟨ refl⟩∘⟨ elimʳ (id×id product) ⟩ f ∘ eval′ ∎ } ; zig = β′ ; zag = λ-unique₂′ $ begin eval′ ∘ first (λg (eval′ ∘ eval′ ∘ second id) ∘ λg id) ≈˘⟨ refl⟩∘⟨ first∘first ⟩ eval′ ∘ first (λg (eval′ ∘ eval′ ∘ second id)) ∘ first (λg id) ≈⟨ pullˡ β′ ⟩ (eval′ ∘ eval′ ∘ second id) ∘ first (λg id) ≈⟨ ∘-resp-≈ʳ (elimʳ (id×id product)) ⟩∘⟨refl ⟩ (eval′ ∘ eval′) ∘ first (λg id) ≈⟨ cancelʳ β′ ⟩ eval′ ≈˘⟨ elimʳ (id×id product) ⟩ eval′ ∘ first id ∎ } ; mate = λ {X Y} f → record { commute₁ = λ-unique₂′ $ begin eval′ ∘ first (λg (second f ∘ eval′ ∘ second id) ∘ λg id) ≈˘⟨ refl⟩∘⟨ first∘first ⟩ eval′ ∘ first (λg (second f ∘ eval′ ∘ second id)) ∘ first (λg id) ≈⟨ pullˡ β′ ⟩ (second f ∘ eval′ ∘ second id) ∘ first (λg id) ≈⟨ ∘-resp-≈ʳ (elimʳ (id×id product)) ⟩∘⟨refl ⟩ (second f ∘ eval′) ∘ first (λg id) ≈⟨ cancelʳ β′ ⟩ second f ≈˘⟨ cancelˡ β′ ⟩ eval′ ∘ first (λg id) ∘ second f ≈⟨ pushʳ first↔second ⟩ (eval′ ∘ second f) ∘ first (λg id) ≈˘⟨ identityˡ ⟩∘⟨refl ⟩ (id ∘ eval′ ∘ second f) ∘ first (λg id) ≈˘⟨ pullˡ β′ ⟩ eval′ ∘ first (λg (id ∘ eval′ ∘ second f)) ∘ first (λg id) ≈⟨ refl⟩∘⟨ first∘first ⟩ eval′ ∘ first (λg (id ∘ eval′ ∘ second f) ∘ λg id) ∎ ; commute₂ = begin eval′ ∘ first (λg (id ∘ eval′ ∘ second f)) ≈⟨ β′ ⟩ id ∘ eval′ ∘ second f ≈⟨ identityˡ ⟩ eval′ ∘ second f ∎ } } open Closed closedMonoidal public
39.967509
123
0.45434
1d5ff5bba48410ad4a766691584139a07e979d36
142
agda
Agda
test/Succeed/Issue279.agda
mdimjasevic/agda
8fb548356b275c7a1e79b768b64511ae937c738b
[ "BSD-3-Clause" ]
1,989
2015-01-09T23:51:16.000Z
2022-03-30T18:20:48.000Z
test/Succeed/Issue279.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
4,066
2015-01-10T11:24:51.000Z
2022-03-31T21:14:49.000Z
test/Succeed/Issue279.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
371
2015-01-03T14:04:08.000Z
2022-03-30T19:00:30.000Z
module Issue279 where record Unit : Set where constructor tt open Unit tt -- this no longer brings tt into scope test : Unit test = tt
12.909091
52
0.725352
1cd204186e02ddb0d43ba00c3ddf1de484ca9aec
1,646
agda
Agda
agda/Algebra/Construct/Free/Semilattice/Relation/Unary/Any/Def.agda
oisdk/masters-thesis
9c5e8b6f546bee952e92db0b73bfc12592bf3152
[ "MIT" ]
4
2021-01-05T14:07:44.000Z
2021-01-05T15:32:14.000Z
agda/Algebra/Construct/Free/Semilattice/Relation/Unary/Any/Def.agda
oisdk/masters-thesis
9c5e8b6f546bee952e92db0b73bfc12592bf3152
[ "MIT" ]
null
null
null
agda/Algebra/Construct/Free/Semilattice/Relation/Unary/Any/Def.agda
oisdk/masters-thesis
9c5e8b6f546bee952e92db0b73bfc12592bf3152
[ "MIT" ]
1
2021-01-05T14:05:30.000Z
2021-01-05T14:05:30.000Z
{-# OPTIONS --cubical --safe #-} module Algebra.Construct.Free.Semilattice.Relation.Unary.Any.Def where open import Prelude hiding (⊥; ⊤) open import Algebra.Construct.Free.Semilattice.Eliminators open import Algebra.Construct.Free.Semilattice.Definition open import Cubical.Foundations.HLevels open import Data.Empty.UniversePolymorphic open import HITs.PropositionalTruncation.Sugar open import HITs.PropositionalTruncation.Properties open import HITs.PropositionalTruncation open import Data.Unit.UniversePolymorphic private variable p : Level dup-◇ : (P : A → Type p) → (x : A) (xs : Type p) → ∥ P x ⊎ ∥ P x ⊎ xs ∥ ∥ ⇔ ∥ P x ⊎ xs ∥ dup-◇ P x xs .inv p = ∣ inr p ∣ dup-◇ P x xs .fun ps = ps >>= either (∣_∣ ∘ inl) id dup-◇ P x xs .leftInv p = squash _ p dup-◇ P x xs .rightInv p = squash p _ swap-◇ : {x y xs : Type p} → ∥ x ⊎ ∥ y ⊎ xs ∥ ∥ → ∥ y ⊎ ∥ x ⊎ xs ∥ ∥ swap-◇ p = p >>= either′ (∣_∣ ∘ inr ∘ ∣_∣ ∘ inl) (mapʳ (∣_∣ ∘ inr) ∥$∥_) com-◇ : (P : A → Type p) → (x y : A) (xs : Type p) → ∥ P x ⊎ ∥ P y ⊎ xs ∥ ∥ ⇔ ∥ P y ⊎ ∥ P x ⊎ xs ∥ ∥ com-◇ P y z xs .fun = swap-◇ com-◇ P y z xs .inv = swap-◇ com-◇ P y z xs .leftInv p = squash _ p com-◇ P y z xs .rightInv p = squash _ p ◇′ : (P : A → Type p) → 𝒦 A → hProp p ◇′ P = 𝒦-rec isSetHProp (λ { x (xs , _) → ∥ P x ⊎ xs ∥ , squash }) (⊥ , λ ()) (λ x xs → Σ≡Prop (λ _ → isPropIsProp) (isoToPath (dup-◇ P x (xs .fst)))) (λ x y xs → Σ≡Prop (λ _ → isPropIsProp) (isoToPath (com-◇ P x y (xs .fst)))) {-# INLINE ◇′ #-} ◇ : (P : A → Type p) → 𝒦 A → Type p ◇ P xs = ◇′ P xs .fst isProp-◇ : ∀ {P : A → Type p} {xs} → isProp (◇ P xs) isProp-◇ {P = P} {xs = xs} = ◇′ P xs .snd
34.291667
100
0.572904
3188561dbbb613d3d186d2e550084ca213d138b6
364
agda
Agda
test/Succeed/Issue550.agda
mdimjasevic/agda
8fb548356b275c7a1e79b768b64511ae937c738b
[ "BSD-3-Clause" ]
1,989
2015-01-09T23:51:16.000Z
2022-03-30T18:20:48.000Z
test/Succeed/Issue550.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
4,066
2015-01-10T11:24:51.000Z
2022-03-31T21:14:49.000Z
test/Succeed/Issue550.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
371
2015-01-03T14:04:08.000Z
2022-03-30T19:00:30.000Z
module Issue550 where data Box (A : Set) : Set where [_] : A → Box A postulate A : Set B : Set b : B f : B -> A ⋯ : {{a : A}} → A ⋯ {{a = a}} = a test : Box A test = let instance a : A a = f b in [ ⋯ ] -- should succeed. Old message: -- No variable of type A was found in scope. -- when checking that the expression ⋯ has type A
15.166667
49
0.532967
4d702232f3795a3a4ac710f921768cf66180c0c9
6,351
agda
Agda
src/LibraBFT/Impl/Properties/PreferredRound.agda
LaudateCorpus1/bft-consensus-agda
a4674fc473f2457fd3fe5123af48253cfb2404ef
[ "UPL-1.0" ]
null
null
null
src/LibraBFT/Impl/Properties/PreferredRound.agda
LaudateCorpus1/bft-consensus-agda
a4674fc473f2457fd3fe5123af48253cfb2404ef
[ "UPL-1.0" ]
null
null
null
src/LibraBFT/Impl/Properties/PreferredRound.agda
LaudateCorpus1/bft-consensus-agda
a4674fc473f2457fd3fe5123af48253cfb2404ef
[ "UPL-1.0" ]
null
null
null
{- Byzantine Fault Tolerant Consensus Verification in Agda, version 0.9. Copyright (c) 2021, Oracle and/or its affiliates. Licensed under the Universal Permissive License v 1.0 as shown at https://opensource.oracle.com/licenses/upl -} open import LibraBFT.Concrete.Records open import LibraBFT.Concrete.System open import LibraBFT.Concrete.System.Parameters open import LibraBFT.Concrete.Obligations.PreferredRound import LibraBFT.Concrete.Properties.Common as Common import LibraBFT.Concrete.Properties.PreferredRound as PR open import LibraBFT.Impl.Consensus.Network as Network open import LibraBFT.Impl.Consensus.Network.Properties as NetworkProps open import LibraBFT.Impl.Consensus.RoundManager import LibraBFT.Impl.Handle as Handle open import LibraBFT.Impl.Handle.Properties open import LibraBFT.Impl.Handle.InitProperties open initHandlerSpec open import LibraBFT.Impl.IO.OBM.InputOutputHandlers open import LibraBFT.Impl.IO.OBM.Properties.InputOutputHandlers open import LibraBFT.Impl.Properties.Common open import LibraBFT.ImplShared.Consensus.Types open import LibraBFT.ImplShared.Consensus.Types.EpochDep open import LibraBFT.ImplShared.Interface.Output open import LibraBFT.ImplShared.Util.Crypto open import LibraBFT.ImplShared.Util.Dijkstra.All open ReachableSystemStateProps open import LibraBFT.Impl.Properties.Util open import Optics.All open import Util.Lemmas open import Util.PKCS open import Util.Prelude open Invariants open RoundManagerTransProps open import LibraBFT.Abstract.Types.EpochConfig UID NodeId open ParamsWithInitAndHandlers Handle.InitHandler.initAndHandlers open import LibraBFT.ImplShared.Util.HashCollisions Handle.InitHandler.initAndHandlers open import Yasm.Yasm ℓ-RoundManager ℓ-VSFP ConcSysParms Handle.InitHandler.initAndHandlers PeerCanSignForPK PeerCanSignForPK-stable open Structural impl-sps-avp -- This module proves the two "PreferredRound" proof obligations for our handler. module LibraBFT.Impl.Properties.PreferredRound (𝓔 : EpochConfig) where ------------------------------------------------------------------------------ preferredRound₁ : PR.ImplObligation₁ Handle.InitHandler.initAndHandlers 𝓔 preferredRound₁ {pid} {pid'} {pk = pk} {pre} preach sps@(step-init rm×acts uni) {v = v} {m = m} {v' = v'} {m' = m'} hpk v'⊂m' m'∈acts sig' ¬bootstrap' pcs4' v⊂m m∈pool sig ¬bootstrap eid≡ rnd< v≈vabs v'≈vabs' c3 with initHandlerSpec.contract pid fakeBootstrapInfo rm×acts ...| init-contract with initHandlerSpec.ContractOk.isInitPM init-contract m'∈acts ...| (_ , refl , noSigs) with v'⊂m' ...| vote∈qc vs∈qc _ qc∈pm = ⊥-elim (noSigs vs∈qc qc∈pm) preferredRound₁ {pid} {pid'} {pk = pk} {pre} preach sps@(step-msg {sndr , P vm} vm'∈pool ini) {v = v} {m = m} {v' = v'} {m' = m'} hpk v'⊂m' m'∈acts sig' ¬bootstrap' pcs4' v⊂m m∈pool sig ¬bootstrap eid≡ rnd< v≈vabs v'≈vabs' c3 = obm-dangerous-magic' "Extend and use handleProposalSpec.contract" preferredRound₁ {pid} {pre = pre} preach sps@(step-msg {_ , V vm} _ _) _ v'⊂m' m'∈acts sig' ¬bootstrap' ¬msb _ _ _ _ _ _ _ _ _ with v'⊂m' ...| vote∈qc vs∈qc v≈rbld qc∈m' rewrite cong _vSignature v≈rbld = ⊥-elim ∘′ ¬msb $ qcVoteSigsSentB4-handle pid preach sps m'∈acts qc∈m' sig' vs∈qc v≈rbld ¬bootstrap' ...| vote∈vm = ⊥-elim (sendVote∉actions{outs = hvOut}{st = hvPre} (sym noVotes) m'∈acts) where hvPre = peerStates pre pid hvOut = LBFT-outs (handleVote 0 vm) hvPre open handleVoteSpec.Contract (handleVoteSpec.contract! 0 vm (msgPool pre) hvPre) ------------------------------------------------------------------------------ -- This proof is essentially the same as the votesOnce₂: no handler sends two different Votes -- TODO-2: refactor for DRY? preferredRound₂ : PR.ImplObligation₂ Handle.InitHandler.initAndHandlers 𝓔 preferredRound₂ {pid} _ (step-init rm×acts uni) _ v⊂m m∈acts _ _ _ _ _ _ _ _ _ _ _ _ with initHandlerSpec.contract pid fakeBootstrapInfo rm×acts ...| init-contract with initHandlerSpec.ContractOk.isInitPM init-contract m∈acts ...| (_ , refl , noSigs) with v⊂m ...| vote∈qc vs∈qc _ qc∈pm = ⊥-elim (noSigs vs∈qc qc∈pm) preferredRound₂ {pid}{pk = pk}{pre} rss (step-msg{sndr , m“} m“∈pool ini) {v = v}{v' = v'} hpk v⊂m m∈acts sig ¬bootstrap ¬msb4 pcsfpk v'⊂m' m'∈acts sig' ¬bootstrap' ¬msb4' _ _ round< with v⊂m ...| vote∈qc vs∈qc v≈rbld qc∈m rewrite cong _vSignature v≈rbld = ⊥-elim ∘′ ¬msb4 $ qcVoteSigsSentB4-handle pid rss (step-msg m“∈pool ini) m∈acts qc∈m sig vs∈qc v≈rbld ¬bootstrap ...| vote∈vm with v'⊂m' ...| vote∈qc vs∈qc' v≈rbld' qc∈m' rewrite cong _vSignature v≈rbld' = ⊥-elim ∘′ ¬msb4' $ qcVoteSigsSentB4-handle pid rss (step-msg m“∈pool ini) m'∈acts qc∈m' sig' vs∈qc' v≈rbld' ¬bootstrap' ...| vote∈vm with m“ ...| P pm = ⊥-elim (<⇒≢ round< (cong (_^∙ vRound) v≡v')) where hpPool = msgPool pre hpPre = peerStates pre pid hpOut = LBFT-outs (handleProposal 0 pm) hpPre open handleProposalSpec.Contract (handleProposalSpec.contract! 0 pm hpPool hpPre) v≡v' : v ≡ v' v≡v' with BlockId-correct? (pm ^∙ pmProposal) ...| no ¬validProposal = ⊥-elim (sendVote∉actions {outs = hpOut} {st = hpPre} (sym (proj₂ $ invalidProposal ¬validProposal)) m∈acts) ...| yes refl with voteAttemptCorrect refl (nohc rss m“∈pool pid ini (invariantsCorrect pid pre ini rss) refl refl ) ...| Voting.mkVoteAttemptCorrectWithEpochReq (Left (_ , Voting.mkVoteUnsentCorrect noVoteMsgOuts _)) _ = ⊥-elim (sendVote∉actions{outs = hpOut}{st = hpPre} (sym noVoteMsgOuts) m∈acts) ...| Voting.mkVoteAttemptCorrectWithEpochReq (Right (Voting.mkVoteSentCorrect vm pid voteMsgOuts _)) _ = begin v ≡⟨ cong (_^∙ vmVote) (sendVote∈actions{outs = hpOut}{st = hpPre} (sym voteMsgOuts) m∈acts) ⟩ vm ^∙ vmVote ≡⟨ (sym $ cong (_^∙ vmVote) (sendVote∈actions{outs = hpOut}{st = hpPre} (sym voteMsgOuts) m'∈acts)) ⟩ v' ∎ where open ≡-Reasoning ... | V vm = ⊥-elim (sendVote∉actions{outs = hvOut}{st = hvPre} (sym noVotes) m∈acts) where hvPre = peerStates pre pid hvOut = LBFT-outs (handle pid (V vm) 0) hvPre open handleVoteSpec.Contract (handleVoteSpec.contract! 0 vm (msgPool pre) hvPre)
48.480916
182
0.686664
1a42e23edca4b0e6e13b8e8e843a16558db80e49
496
agda
Agda
test/Fail/Issue1946-5.agda
mdimjasevic/agda
8fb548356b275c7a1e79b768b64511ae937c738b
[ "BSD-3-Clause" ]
2
2019-10-29T09:40:30.000Z
2020-09-20T00:28:57.000Z
test/Fail/Issue1946-5.agda
mdimjasevic/agda
8fb548356b275c7a1e79b768b64511ae937c738b
[ "BSD-3-Clause" ]
3
2018-11-14T15:31:44.000Z
2019-04-01T19:39:26.000Z
test/Fail/Issue1946-5.agda
mdimjasevic/agda
8fb548356b275c7a1e79b768b64511ae937c738b
[ "BSD-3-Clause" ]
1
2015-09-15T14:36:15.000Z
2015-09-15T14:36:15.000Z
-- This test case was reported by Andrea Vezzosi. {-# OPTIONS --no-guardedness #-} open import Agda.Builtin.Size data Σ (A : Set) (B : A → Set) : Set where _,_ : (x : A) → B x → Σ A B data ⊥ : Set where record T (i : Size) : Set where constructor con coinductive field force : Σ (Size< i) \ { j → T j } open T public empty : ∀ i → T i → ⊥ empty i x with force x ... | j , y = empty j y inh : T ∞ inh = \ { .force → ∞ , inh } -- using oo < oo here false : ⊥ false = empty ∞ inh
18.37037
50
0.566532
58827e1d1dee34177440fdfbfcc6f1c32bfc8956
3,638
agda
Agda
RMonads/CatofRAdj/TermRAdj.agda
jmchapman/Relative-Monads
74707d3538bf494f4bd30263d2f5515a84733865
[ "MIT" ]
21
2015-07-30T01:25:12.000Z
2021-02-13T18:02:18.000Z
RMonads/CatofRAdj/TermRAdj.agda
jmchapman/Relative-Monads
74707d3538bf494f4bd30263d2f5515a84733865
[ "MIT" ]
3
2019-01-13T13:12:33.000Z
2019-05-29T09:50:26.000Z
RMonads/CatofRAdj/TermRAdj.agda
jmchapman/Relative-Monads
74707d3538bf494f4bd30263d2f5515a84733865
[ "MIT" ]
1
2019-11-04T21:33:13.000Z
2019-11-04T21:33:13.000Z
open import Categories open import Functors open import RMonads module RMonads.CatofRAdj.TermRAdj {a b c d}{C : Cat {a}{b}}{D : Cat {c}{d}} {J : Fun C D}(M : RMonad J) where open import Library open import RAdjunctions open import RMonads.CatofRAdj M open import Categories.Terminal open import RMonads.REM M open import RMonads.REM.Adjunction M open import RAdjunctions.RAdj2RMon open import RMonads.CatofRAdj.TermRAdjObj M open import RMonads.CatofRAdj.TermRAdjHom M open Cat open Fun open RAdj omaplem : {X : Obj CatofAdj} {f : Hom CatofAdj X EMObj} → OMap (HomAdj.K (EMHom {X})) ≅ OMap (HomAdj.K f) omaplem {A}{f} = ext (λ X → AlgEq (fcong X (cong OMap (HomAdj.Rlaw f))) (iext λ Y → dext (λ {g} {g'} p → trans (trans (stripsubst (λ Z → Hom D Z (OMap (R (ObjAdj.adj A)) X)) (HMap (R (ObjAdj.adj A)) (right (ObjAdj.adj A) g)) (fcong Y (cong OMap (ObjAdj.law A)))) (cong' refl (ext (λ g₁ → cong (λ (F : Obj (ObjAdj.E A) → Obj D) → Hom D (F (OMap (L (ObjAdj.adj A)) Y)) (F X)) (cong OMap (HomAdj.Rlaw f)))) (icong' refl (ext (λ Z → cong (λ (F : Obj (ObjAdj.E A) → Obj D) → Hom (ObjAdj.E A) (OMap (L (ObjAdj.adj A)) Y) Z → Hom D (F (OMap (L (ObjAdj.adj A)) Y)) (F Z)) (cong OMap (HomAdj.Rlaw f)))) (icong' refl (ext (λ Z → cong (λ (F : Obj (ObjAdj.E A) → Obj D) → {Y₁ : Obj (ObjAdj.E A)} → Hom (ObjAdj.E A) Z Y₁ → Hom D (F Z) (F Y₁)) (cong OMap (HomAdj.Rlaw f)))) (cong HMap (HomAdj.Rlaw f)) (refl {x = OMap (L (ObjAdj.adj A)) Y})) (refl {x = X})) (refl {x = right (ObjAdj.adj A) g}))) (trans (cong₃ (λ A1 A2 → RAlgMorph.amor {A1}{A2}) (fcong Y (cong OMap (HomAdj.Llaw f))) refl (HomAdj.rightlaw f {Y} {X} {g})) (cong (RAlg.astr (OMap (HomAdj.K f) X)) (trans (stripsubst (Hom D (OMap J Y)) g (fcong X (cong OMap (HomAdj.Rlaw f)))) p)))))) hmaplem : {X : Obj CatofAdj} {f : Hom CatofAdj X EMObj} → {X₁ Y : Obj (ObjAdj.E X)} (f₁ : Hom (ObjAdj.E X) X₁ Y) → HMap (HomAdj.K (EMHom {X})) f₁ ≅ HMap (HomAdj.K f) f₁ hmaplem {A}{V}{X}{Y} f = lemZ (fcong X (omaplem {A} {V})) (fcong Y (omaplem {A} {V})) (cong' refl (ext (λ Z → cong (λ (F : Obj (ObjAdj.E A) → Obj D) → Hom D (F X) (F Y)) (cong OMap (HomAdj.Rlaw V)))) (icong' refl (ext (λ Z → cong (λ (F : Obj (ObjAdj.E A) → Obj D) → Hom (ObjAdj.E A) X Z → Hom D (F X) (F Z)) (cong OMap (HomAdj.Rlaw V)))) (icong' refl (ext (λ Z → cong (λ (F : Obj (ObjAdj.E A) → Obj D) → {Y₁ : Obj (ObjAdj.E A)} → Hom (ObjAdj.E A) Z Y₁ → Hom D (F Z) (F Y₁)) (cong OMap (HomAdj.Rlaw V)))) (cong HMap (HomAdj.Rlaw V)) (refl {x = X})) (refl {x = Y})) (refl {x = f})) uniq : {X : Obj CatofAdj} {f : Hom CatofAdj X EMObj} → EMHom {X} ≅ f uniq {X} {f} = HomAdjEq _ _ (FunctorEq _ _ (omaplem {X} {f}) (iext λ _ → iext λ _ → ext (hmaplem {X}{f}))) EMIsTerm : Term CatofAdj EMObj EMIsTerm = record { t = EMHom; law = uniq}
34
75
0.460143
186017cce6aca0f27d43cb2fe517ce1782c5cba2
27,624
agda
Agda
Univalence/PiWithLevels/Pi-1.agda
JacquesCarette/pi-dual
003835484facfde0b770bc2b3d781b42b76184c1
[ "BSD-2-Clause" ]
14
2015-08-18T21:40:15.000Z
2021-05-05T01:07:57.000Z
Univalence/PiWithLevels/Pi-1.agda
JacquesCarette/pi-dual
003835484facfde0b770bc2b3d781b42b76184c1
[ "BSD-2-Clause" ]
4
2018-06-07T16:27:41.000Z
2021-10-29T20:41:23.000Z
Univalence/PiWithLevels/Pi-1.agda
JacquesCarette/pi-dual
003835484facfde0b770bc2b3d781b42b76184c1
[ "BSD-2-Clause" ]
3
2016-05-29T01:56:33.000Z
2019-09-10T09:47:13.000Z
module Pi-1 where open import Data.Empty open import Data.Unit open import Data.Product open import Relation.Binary.PropositionalEquality open import Groupoid import Pi-2 as P --infixr 10 _◎_ --infixr 30 _⟷_ ------------------------------------------------------------------------------ -- Level -1: -- Types are -1 groupoids or equivalently all types are mere propositions -- -- Types and values are defined without references to programs -- Types include PATHs from the previous level in addition to the usual types data U : Set where ZERO : U ONE : U TIMES : U → U → U PATH : {t₁ t₂ : P.U•} → (t₁ P.⟷ t₂) → U data Path {t₁ t₂ : P.U•} : P.Space t₁ → P.Space t₂ → Set where path : (c : t₁ P.⟷ t₂) → Path (P.point t₁) (P.point t₂) ⟦_⟧ : U → Set ⟦ ZERO ⟧ = ⊥ ⟦ ONE ⟧ = ⊤ ⟦ TIMES t₁ t₂ ⟧ = ⟦ t₁ ⟧ × ⟦ t₂ ⟧ ⟦ PATH {t₁} {t₂} c ⟧ = Path {t₁} {t₂} (P.point t₁) (P.point t₂) -- Proof that all types are mere propositions. Def. 3.3.1 in the HoTT book isMereProposition : (t : U) → (v v' : ⟦ t ⟧) → (v ≡ v') isMereProposition ZERO () isMereProposition ONE tt tt = refl isMereProposition (TIMES t₁ t₂) (v₁ , v₂) (v₁' , v₂') = cong₂ _,′_ (isMereProposition t₁ v₁ v₁') (isMereProposition t₂ v₂ v₂') isMereProposition (PATH {t₁} {t₂} c) (path c₁) (path c₂) = {!!} -- c₁ : t₁ ⟷ t₂ in Pi-2 -- c₂ : t₁ ⟷ t₂ in Pi-2 -- Proof that every type is a groupoid; this does not depend on the -- definition of programs isGroupoid : U → 1Groupoid isGroupoid ZERO = discrete ⊥ isGroupoid ONE = discrete ⊤ isGroupoid (TIMES t₁ t₂) = isGroupoid t₁ ×G isGroupoid t₂ isGroupoid (PATH {t₁} {t₂} c) = {!!} {-- ------------------------------------------------------------------------------ -- Level -1: -- if types are non-empty they must contain one point only like above -- types may however be empty -- -- We can prove that all types are either empty or equivalent to the unit -- type (i.e., they are mere propositions) module Pi-1 where data U : Set where ZERO : U ONE : U TIMES : U → U → U ⟦_⟧ : U → Set ⟦ ZERO ⟧ = ⊥ ⟦ ONE ⟧ = ⊤ ⟦ TIMES t₁ t₂ ⟧ = ⟦ t₁ ⟧ × ⟦ t₂ ⟧ ------------------------------------------------------------------------------ -- Level 0: -- types may contain any number of points (including none) -- they are sets -- -- We define isomorphisms between these sets that are reified to paths in the -- next level (level 1). These isomorphisms are the combinators for a -- commutative semiring structure which is sound and complete for sets. module Pi0 where infixr 10 _◎_ infixr 30 _⟷_ -- types data U : Set where ZERO : U ONE : U PLUS : U → U → U TIMES : U → U → U -- values ⟦_⟧ : U → Set ⟦ ZERO ⟧ = ⊥ ⟦ ONE ⟧ = ⊤ ⟦ PLUS t₁ t₂ ⟧ = ⟦ t₁ ⟧ ⊎ ⟦ t₂ ⟧ ⟦ TIMES t₁ t₂ ⟧ = ⟦ t₁ ⟧ × ⟦ t₂ ⟧ -- pointed types record U• : Set where constructor •[_,_] field ∣_∣ : U • : ⟦ ∣_∣ ⟧ open U• Space : (t• : U•) → Set Space •[ t , v ] = ⟦ t ⟧ point : (t• : U•) → Space t• point •[ t , v ] = v -- examples ONE• : U• ONE• = •[ ONE , tt ] BOOL : U BOOL = PLUS ONE ONE BOOL² : U BOOL² = TIMES BOOL BOOL TRUE : ⟦ BOOL ⟧ TRUE = inj₁ tt FALSE : ⟦ BOOL ⟧ FALSE = inj₂ tt BOOL•F : U• BOOL•F = •[ BOOL , FALSE ] BOOL•T : U• BOOL•T = •[ BOOL , TRUE ] -- isomorphisms between pointed types data _⟷_ : U• → U• → Set where unite₊ : {t : U•} → •[ PLUS ZERO ∣ t ∣ , inj₂ (• t) ] ⟷ t uniti₊ : {t : U•} → t ⟷ •[ PLUS ZERO ∣ t ∣ , inj₂ (• t) ] swap1₊ : {t₁ t₂ : U•} → •[ PLUS ∣ t₁ ∣ ∣ t₂ ∣ , inj₁ (• t₁) ] ⟷ •[ PLUS ∣ t₂ ∣ ∣ t₁ ∣ , inj₂ (• t₁) ] swap2₊ : {t₁ t₂ : U•} → •[ PLUS ∣ t₁ ∣ ∣ t₂ ∣ , inj₂ (• t₂) ] ⟷ •[ PLUS ∣ t₂ ∣ ∣ t₁ ∣ , inj₁ (• t₂) ] assocl1₊ : {t₁ t₂ t₃ : U•} → •[ PLUS ∣ t₁ ∣ (PLUS ∣ t₂ ∣ ∣ t₃ ∣) , inj₁ (• t₁) ] ⟷ •[ PLUS (PLUS ∣ t₁ ∣ ∣ t₂ ∣) ∣ t₃ ∣ , inj₁ (inj₁ (• t₁)) ] assocl2₊ : {t₁ t₂ t₃ : U•} → •[ PLUS ∣ t₁ ∣ (PLUS ∣ t₂ ∣ ∣ t₃ ∣) , inj₂ (inj₁ (• t₂)) ] ⟷ •[ PLUS (PLUS ∣ t₁ ∣ ∣ t₂ ∣) ∣ t₃ ∣ , inj₁ (inj₂ (• t₂)) ] assocl3₊ : {t₁ t₂ t₃ : U•} → •[ PLUS ∣ t₁ ∣ (PLUS ∣ t₂ ∣ ∣ t₃ ∣) , inj₂ (inj₂ (• t₃)) ] ⟷ •[ PLUS (PLUS ∣ t₁ ∣ ∣ t₂ ∣) ∣ t₃ ∣ , inj₂ (• t₃) ] assocr1₊ : {t₁ t₂ t₃ : U•} → •[ PLUS (PLUS ∣ t₁ ∣ ∣ t₂ ∣) ∣ t₃ ∣ , inj₁ (inj₁ (• t₁)) ] ⟷ •[ PLUS ∣ t₁ ∣ (PLUS ∣ t₂ ∣ ∣ t₃ ∣) , inj₁ (• t₁) ] assocr2₊ : {t₁ t₂ t₃ : U•} → •[ PLUS (PLUS ∣ t₁ ∣ ∣ t₂ ∣) ∣ t₃ ∣ , inj₁ (inj₂ (• t₂)) ] ⟷ •[ PLUS ∣ t₁ ∣ (PLUS ∣ t₂ ∣ ∣ t₃ ∣) , inj₂ (inj₁ (• t₂)) ] assocr3₊ : {t₁ t₂ t₃ : U•} → •[ PLUS (PLUS ∣ t₁ ∣ ∣ t₂ ∣) ∣ t₃ ∣ , inj₂ (• t₃) ] ⟷ •[ PLUS ∣ t₁ ∣ (PLUS ∣ t₂ ∣ ∣ t₃ ∣) , inj₂ (inj₂ (• t₃)) ] unite⋆ : {t : U•} → •[ TIMES ONE ∣ t ∣ , (tt , • t) ] ⟷ t uniti⋆ : {t : U•} → t ⟷ •[ TIMES ONE ∣ t ∣ , (tt , • t) ] swap⋆ : {t₁ t₂ : U•} → •[ TIMES ∣ t₁ ∣ ∣ t₂ ∣ , (• t₁ , • t₂) ] ⟷ •[ TIMES ∣ t₂ ∣ ∣ t₁ ∣ , (• t₂ , • t₁) ] assocl⋆ : {t₁ t₂ t₃ : U•} → •[ TIMES ∣ t₁ ∣ (TIMES ∣ t₂ ∣ ∣ t₃ ∣) , (• t₁ , (• t₂ , • t₃)) ] ⟷ •[ TIMES (TIMES ∣ t₁ ∣ ∣ t₂ ∣) ∣ t₃ ∣ , ((• t₁ , • t₂) , • t₃) ] assocr⋆ : {t₁ t₂ t₃ : U•} → •[ TIMES (TIMES ∣ t₁ ∣ ∣ t₂ ∣) ∣ t₃ ∣ , ((• t₁ , • t₂) , • t₃) ] ⟷ •[ TIMES ∣ t₁ ∣ (TIMES ∣ t₂ ∣ ∣ t₃ ∣) , (• t₁ , (• t₂ , • t₃)) ] distz : {t : U•} {absurd : ⟦ ZERO ⟧} → •[ TIMES ZERO ∣ t ∣ , (absurd , • t) ] ⟷ •[ ZERO , absurd ] factorz : {t : U•} {absurd : ⟦ ZERO ⟧} → •[ ZERO , absurd ] ⟷ •[ TIMES ZERO ∣ t ∣ , (absurd , • t) ] dist1 : {t₁ t₂ t₃ : U•} → •[ TIMES (PLUS ∣ t₁ ∣ ∣ t₂ ∣) ∣ t₃ ∣ , (inj₁ (• t₁) , • t₃) ] ⟷ •[ PLUS (TIMES ∣ t₁ ∣ ∣ t₃ ∣) (TIMES ∣ t₂ ∣ ∣ t₃ ∣) , inj₁ (• t₁ , • t₃) ] dist2 : {t₁ t₂ t₃ : U•} → •[ TIMES (PLUS ∣ t₁ ∣ ∣ t₂ ∣) ∣ t₃ ∣ , (inj₂ (• t₂) , • t₃) ] ⟷ •[ PLUS (TIMES ∣ t₁ ∣ ∣ t₃ ∣) (TIMES ∣ t₂ ∣ ∣ t₃ ∣) , inj₂ (• t₂ , • t₃) ] factor1 : {t₁ t₂ t₃ : U•} → •[ PLUS (TIMES ∣ t₁ ∣ ∣ t₃ ∣) (TIMES ∣ t₂ ∣ ∣ t₃ ∣) , inj₁ (• t₁ , • t₃) ] ⟷ •[ TIMES (PLUS ∣ t₁ ∣ ∣ t₂ ∣) ∣ t₃ ∣ , (inj₁ (• t₁) , • t₃) ] factor2 : {t₁ t₂ t₃ : U•} → •[ PLUS (TIMES ∣ t₁ ∣ ∣ t₃ ∣) (TIMES ∣ t₂ ∣ ∣ t₃ ∣) , inj₂ (• t₂ , • t₃) ] ⟷ •[ TIMES (PLUS ∣ t₁ ∣ ∣ t₂ ∣) ∣ t₃ ∣ , (inj₂ (• t₂) , • t₃) ] id⟷ : {t : U•} → t ⟷ t sym⟷ : {t₁ t₂ : U•} → (t₁ ⟷ t₂) → (t₂ ⟷ t₁) _◎_ : {t₁ t₂ t₃ : U•} → (t₁ ⟷ t₂) → (t₂ ⟷ t₃) → (t₁ ⟷ t₃) _⊕1_ : {t₁ t₂ t₃ t₄ : U•} → (t₁ ⟷ t₃) → (t₂ ⟷ t₄) → (•[ PLUS ∣ t₁ ∣ ∣ t₂ ∣ , inj₁ (• t₁) ] ⟷ •[ PLUS ∣ t₃ ∣ ∣ t₄ ∣ , inj₁ (• t₃) ]) _⊕2_ : {t₁ t₂ t₃ t₄ : U•} → (t₁ ⟷ t₃) → (t₂ ⟷ t₄) → (•[ PLUS ∣ t₁ ∣ ∣ t₂ ∣ , inj₂ (• t₂) ] ⟷ •[ PLUS ∣ t₃ ∣ ∣ t₄ ∣ , inj₂ (• t₄) ]) _⊗_ : {t₁ t₂ t₃ t₄ : U•} → (t₁ ⟷ t₃) → (t₂ ⟷ t₄) → (•[ TIMES ∣ t₁ ∣ ∣ t₂ ∣ , (• t₁ , • t₂ ) ] ⟷ •[ TIMES ∣ t₃ ∣ ∣ t₄ ∣ , (• t₃ , • t₄ ) ]) -- examples NOT•T : •[ BOOL , TRUE ] ⟷ •[ BOOL , FALSE ] NOT•T = swap1₊ NOT•F : •[ BOOL , FALSE ] ⟷ •[ BOOL , TRUE ] NOT•F = swap2₊ CNOT•Fx : {b : ⟦ BOOL ⟧} → •[ BOOL² , (FALSE , b) ] ⟷ •[ BOOL² , (FALSE , b) ] CNOT•Fx = dist2 ◎ ((id⟷ ⊗ NOT•F) ⊕2 id⟷) ◎ factor2 CNOT•TF : •[ BOOL² , (TRUE , FALSE) ] ⟷ •[ BOOL² , (TRUE , TRUE) ] CNOT•TF = dist1 ◎ ((id⟷ ⊗ NOT•F) ⊕1 (id⟷ {•[ TIMES ONE BOOL , (tt , FALSE) ]})) ◎ factor1 CNOT•TT : •[ BOOL² , (TRUE , TRUE) ] ⟷ •[ BOOL² , (TRUE , FALSE) ] CNOT•TT = dist1 ◎ ((id⟷ ⊗ NOT•T) ⊕1 (id⟷ {•[ TIMES ONE BOOL , (tt , TRUE) ]})) ◎ factor1 ------------------------------------------------------------------------------ -- Level 1 -- types are 1groupoids; they consist of points with collections of -- non-trivial paths between them; the paths are defined at the previous -- level (level 0). -- -- We define isomorphisms between these level 1 paths that are reified as -- 2paths in the next level (level 2). These isomorphisms include groupoid -- combinators and commutative semiring combinators module Pi1 where infixr 10 _◎_ infixr 30 _⟷_ -- types data U : Set where ZERO : U ONE : U PLUS : U → U → U TIMES : U → U → U PATH : {t₁ t₂ : Pi0.U•} → (t₁ Pi0.⟷ t₂) → U -- values data Path {t₁ t₂ : Pi0.U•} : (Pi0.Space t₁) → (Pi0.Space t₂) → Set where path : (c : t₁ Pi0.⟷ t₂) → Path (Pi0.point t₁) (Pi0.point t₂) ⟦_⟧ : U → Set ⟦ ZERO ⟧ = ⊥ ⟦ ONE ⟧ = ⊤ ⟦ PLUS t₁ t₂ ⟧ = ⟦ t₁ ⟧ ⊎ ⟦ t₂ ⟧ ⟦ TIMES t₁ t₂ ⟧ = ⟦ t₁ ⟧ × ⟦ t₂ ⟧ ⟦ PATH {t₁} {t₂} c ⟧ = Path {t₁} {t₂} (Pi0.point t₁) (Pi0.point t₂) -- pointed types record U• : Set where constructor •[_,_] field ∣_∣ : U • : ⟦ ∣_∣ ⟧ open U• Space : (t• : U•) → Set Space •[ t , p ] = ⟦ t ⟧ point : (t• : U•) → Space t• point •[ t , p ] = p _∘_ : {t₁ t₂ t₃ : Pi0.U•} → Path (Pi0.point t₁) (Pi0.point t₂) → Path (Pi0.point t₂) (Pi0.point t₃) → Path (Pi0.point t₁) (Pi0.point t₃) path c₁ ∘ path c₂ = path (c₁ Pi0.◎ c₂) PathSpace : {t₁ t₂ : Pi0.U•} → (c : t₁ Pi0.⟷ t₂) → U• PathSpace c = •[ PATH c , path c ] -- examples -- several paths between T and F; some of these will be equivalent p₁ p₂ p₃ p₄ : Path Pi0.TRUE Pi0.FALSE p₁ = path Pi0.swap1₊ p₂ = path (Pi0.swap1₊ Pi0.◎ Pi0.id⟷) p₃ = path (Pi0.swap1₊ Pi0.◎ Pi0.swap2₊ Pi0.◎ Pi0.swap1₊) p₄ = path (Pi0.uniti⋆ Pi0.◎ Pi0.swap⋆ Pi0.◎ (Pi0.swap1₊ Pi0.⊗ Pi0.id⟷) Pi0.◎ Pi0.swap⋆ Pi0.◎ Pi0.unite⋆) -- groupoid combinators to reason about id, sym, and trans -- commutative semiring combinators for 0, 1, +, * data _⟷_ : U• → U• → Set where -- common combinators id⟷ : {t : U•} → t ⟷ t sym⟷ : {t₁ t₂ : U•} → (t₁ ⟷ t₂) → (t₂ ⟷ t₁) _◎_ : {t₁ t₂ t₃ : U•} → (t₁ ⟷ t₂) → (t₂ ⟷ t₃) → (t₁ ⟷ t₃) -- groupoid combinators lidl : {t₁ t₂ : Pi0.U•} {c : t₁ Pi0.⟷ t₂} → PathSpace (Pi0.id⟷ Pi0.◎ c) ⟷ PathSpace c lidr : {t₁ t₂ : Pi0.U•} {c : t₁ Pi0.⟷ t₂} → PathSpace c ⟷ PathSpace (Pi0.id⟷ Pi0.◎ c) ridl : {t₁ t₂ : Pi0.U•} {c : t₁ Pi0.⟷ t₂} → PathSpace (c Pi0.◎ Pi0.id⟷) ⟷ PathSpace c ridr : {t₁ t₂ : Pi0.U•} {c : t₁ Pi0.⟷ t₂} → PathSpace c ⟷ PathSpace (c Pi0.◎ Pi0.id⟷) invll : {t₁ t₂ : Pi0.U•} {c : t₁ Pi0.⟷ t₂} → PathSpace (Pi0.sym⟷ c Pi0.◎ c) ⟷ PathSpace {t₂} {t₂} Pi0.id⟷ invlr : {t₁ t₂ : Pi0.U•} {c : t₁ Pi0.⟷ t₂} → PathSpace {t₂} {t₂} Pi0.id⟷ ⟷ PathSpace (Pi0.sym⟷ c Pi0.◎ c) invrl : {t₁ t₂ : Pi0.U•} {c : t₁ Pi0.⟷ t₂} → PathSpace (c Pi0.◎ Pi0.sym⟷ c) ⟷ PathSpace {t₁} {t₁} Pi0.id⟷ invrr : {t₁ t₂ : Pi0.U•} {c : t₁ Pi0.⟷ t₂} → PathSpace {t₁} {t₁} Pi0.id⟷ ⟷ PathSpace (c Pi0.◎ Pi0.sym⟷ c) invinvl : {t₁ t₂ : Pi0.U•} {c : t₁ Pi0.⟷ t₂} → PathSpace (Pi0.sym⟷ (Pi0.sym⟷ c)) ⟷ PathSpace c invinvr : {t₁ t₂ : Pi0.U•} {c : t₁ Pi0.⟷ t₂} → PathSpace c ⟷ PathSpace (Pi0.sym⟷ (Pi0.sym⟷ c)) tassocl : {t₁ t₂ t₃ t₄ : Pi0.U•} {c₁ : t₁ Pi0.⟷ t₂} {c₂ : t₂ Pi0.⟷ t₃} {c₃ : t₃ Pi0.⟷ t₄} → PathSpace (c₁ Pi0.◎ (c₂ Pi0.◎ c₃)) ⟷ PathSpace ((c₁ Pi0.◎ c₂) Pi0.◎ c₃) tassocr : {t₁ t₂ t₃ t₄ : Pi0.U•} {c₁ : t₁ Pi0.⟷ t₂} {c₂ : t₂ Pi0.⟷ t₃} {c₃ : t₃ Pi0.⟷ t₄} → PathSpace ((c₁ Pi0.◎ c₂) Pi0.◎ c₃) ⟷ PathSpace (c₁ Pi0.◎ (c₂ Pi0.◎ c₃)) -- resp◎ is closely related to Eckmann-Hilton resp◎ : {t₁ t₂ t₃ : Pi0.U•} {c₁ : t₁ Pi0.⟷ t₂} {c₂ : t₂ Pi0.⟷ t₃} {c₃ : t₁ Pi0.⟷ t₂} {c₄ : t₂ Pi0.⟷ t₃} → (PathSpace c₁ ⟷ PathSpace c₃) → (PathSpace c₂ ⟷ PathSpace c₄) → PathSpace (c₁ Pi0.◎ c₂) ⟷ PathSpace (c₃ Pi0.◎ c₄) -- commutative semiring combinators unite₊ : {t : U•} → •[ PLUS ZERO ∣ t ∣ , inj₂ (• t) ] ⟷ t uniti₊ : {t : U•} → t ⟷ •[ PLUS ZERO ∣ t ∣ , inj₂ (• t) ] swap1₊ : {t₁ t₂ : U•} → •[ PLUS ∣ t₁ ∣ ∣ t₂ ∣ , inj₁ (• t₁) ] ⟷ •[ PLUS ∣ t₂ ∣ ∣ t₁ ∣ , inj₂ (• t₁) ] swap2₊ : {t₁ t₂ : U•} → •[ PLUS ∣ t₁ ∣ ∣ t₂ ∣ , inj₂ (• t₂) ] ⟷ •[ PLUS ∣ t₂ ∣ ∣ t₁ ∣ , inj₁ (• t₂) ] assocl1₊ : {t₁ t₂ t₃ : U•} → •[ PLUS ∣ t₁ ∣ (PLUS ∣ t₂ ∣ ∣ t₃ ∣) , inj₁ (• t₁) ] ⟷ •[ PLUS (PLUS ∣ t₁ ∣ ∣ t₂ ∣) ∣ t₃ ∣ , inj₁ (inj₁ (• t₁)) ] assocl2₊ : {t₁ t₂ t₃ : U•} → •[ PLUS ∣ t₁ ∣ (PLUS ∣ t₂ ∣ ∣ t₃ ∣) , inj₂ (inj₁ (• t₂)) ] ⟷ •[ PLUS (PLUS ∣ t₁ ∣ ∣ t₂ ∣) ∣ t₃ ∣ , inj₁ (inj₂ (• t₂)) ] assocl3₊ : {t₁ t₂ t₃ : U•} → •[ PLUS ∣ t₁ ∣ (PLUS ∣ t₂ ∣ ∣ t₃ ∣) , inj₂ (inj₂ (• t₃)) ] ⟷ •[ PLUS (PLUS ∣ t₁ ∣ ∣ t₂ ∣) ∣ t₃ ∣ , inj₂ (• t₃) ] assocr1₊ : {t₁ t₂ t₃ : U•} → •[ PLUS (PLUS ∣ t₁ ∣ ∣ t₂ ∣) ∣ t₃ ∣ , inj₁ (inj₁ (• t₁)) ] ⟷ •[ PLUS ∣ t₁ ∣ (PLUS ∣ t₂ ∣ ∣ t₃ ∣) , inj₁ (• t₁) ] assocr2₊ : {t₁ t₂ t₃ : U•} → •[ PLUS (PLUS ∣ t₁ ∣ ∣ t₂ ∣) ∣ t₃ ∣ , inj₁ (inj₂ (• t₂)) ] ⟷ •[ PLUS ∣ t₁ ∣ (PLUS ∣ t₂ ∣ ∣ t₃ ∣) , inj₂ (inj₁ (• t₂)) ] assocr3₊ : {t₁ t₂ t₃ : U•} → •[ PLUS (PLUS ∣ t₁ ∣ ∣ t₂ ∣) ∣ t₃ ∣ , inj₂ (• t₃) ] ⟷ •[ PLUS ∣ t₁ ∣ (PLUS ∣ t₂ ∣ ∣ t₃ ∣) , inj₂ (inj₂ (• t₃)) ] unite⋆ : {t : U•} → •[ TIMES ONE ∣ t ∣ , (tt , • t) ] ⟷ t uniti⋆ : {t : U•} → t ⟷ •[ TIMES ONE ∣ t ∣ , (tt , • t) ] swap⋆ : {t₁ t₂ : U•} → •[ TIMES ∣ t₁ ∣ ∣ t₂ ∣ , (• t₁ , • t₂) ] ⟷ •[ TIMES ∣ t₂ ∣ ∣ t₁ ∣ , (• t₂ , • t₁) ] assocl⋆ : {t₁ t₂ t₃ : U•} → •[ TIMES ∣ t₁ ∣ (TIMES ∣ t₂ ∣ ∣ t₃ ∣) , (• t₁ , (• t₂ , • t₃)) ] ⟷ •[ TIMES (TIMES ∣ t₁ ∣ ∣ t₂ ∣) ∣ t₃ ∣ , ((• t₁ , • t₂) , • t₃) ] assocr⋆ : {t₁ t₂ t₃ : U•} → •[ TIMES (TIMES ∣ t₁ ∣ ∣ t₂ ∣) ∣ t₃ ∣ , ((• t₁ , • t₂) , • t₃) ] ⟷ •[ TIMES ∣ t₁ ∣ (TIMES ∣ t₂ ∣ ∣ t₃ ∣) , (• t₁ , (• t₂ , • t₃)) ] distz : {t : U•} {absurd : ⟦ ZERO ⟧} → •[ TIMES ZERO ∣ t ∣ , (absurd , • t) ] ⟷ •[ ZERO , absurd ] factorz : {t : U•} {absurd : ⟦ ZERO ⟧} → •[ ZERO , absurd ] ⟷ •[ TIMES ZERO ∣ t ∣ , (absurd , • t) ] dist1 : {t₁ t₂ t₃ : U•} → •[ TIMES (PLUS ∣ t₁ ∣ ∣ t₂ ∣) ∣ t₃ ∣ , (inj₁ (• t₁) , • t₃) ] ⟷ •[ PLUS (TIMES ∣ t₁ ∣ ∣ t₃ ∣) (TIMES ∣ t₂ ∣ ∣ t₃ ∣) , inj₁ (• t₁ , • t₃) ] dist2 : {t₁ t₂ t₃ : U•} → •[ TIMES (PLUS ∣ t₁ ∣ ∣ t₂ ∣) ∣ t₃ ∣ , (inj₂ (• t₂) , • t₃) ] ⟷ •[ PLUS (TIMES ∣ t₁ ∣ ∣ t₃ ∣) (TIMES ∣ t₂ ∣ ∣ t₃ ∣) , inj₂ (• t₂ , • t₃) ] factor1 : {t₁ t₂ t₃ : U•} → •[ PLUS (TIMES ∣ t₁ ∣ ∣ t₃ ∣) (TIMES ∣ t₂ ∣ ∣ t₃ ∣) , inj₁ (• t₁ , • t₃) ] ⟷ •[ TIMES (PLUS ∣ t₁ ∣ ∣ t₂ ∣) ∣ t₃ ∣ , (inj₁ (• t₁) , • t₃) ] factor2 : {t₁ t₂ t₃ : U•} → •[ PLUS (TIMES ∣ t₁ ∣ ∣ t₃ ∣) (TIMES ∣ t₂ ∣ ∣ t₃ ∣) , inj₂ (• t₂ , • t₃) ] ⟷ •[ TIMES (PLUS ∣ t₁ ∣ ∣ t₂ ∣) ∣ t₃ ∣ , (inj₂ (• t₂) , • t₃) ] _⊕1_ : {t₁ t₂ t₃ t₄ : U•} → (t₁ ⟷ t₃) → (t₂ ⟷ t₄) → (•[ PLUS ∣ t₁ ∣ ∣ t₂ ∣ , inj₁ (• t₁) ] ⟷ •[ PLUS ∣ t₃ ∣ ∣ t₄ ∣ , inj₁ (• t₃) ]) _⊕2_ : {t₁ t₂ t₃ t₄ : U•} → (t₁ ⟷ t₃) → (t₂ ⟷ t₄) → (•[ PLUS ∣ t₁ ∣ ∣ t₂ ∣ , inj₂ (• t₂) ] ⟷ •[ PLUS ∣ t₃ ∣ ∣ t₄ ∣ , inj₂ (• t₄) ]) _⊗_ : {t₁ t₂ t₃ t₄ : U•} → (t₁ ⟷ t₃) → (t₂ ⟷ t₄) → (•[ TIMES ∣ t₁ ∣ ∣ t₂ ∣ , (• t₁ , • t₂ ) ] ⟷ •[ TIMES ∣ t₃ ∣ ∣ t₄ ∣ , (• t₃ , • t₄ ) ]) -- proof that we have a 1Groupoid structure G : 1Groupoid G = record { set = Pi0.U• ; _↝_ = Pi0._⟷_ ; _≈_ = λ c₀ c₁ → PathSpace c₀ ⟷ PathSpace c₁ ; id = Pi0.id⟷ ; _∘_ = λ c₀ c₁ → c₁ Pi0.◎ c₀ ; _⁻¹ = Pi0.sym⟷ ; lneutr = λ _ → ridl ; rneutr = λ _ → lidl ; assoc = λ _ _ _ → tassocl ; equiv = record { refl = id⟷ ; sym = λ c → sym⟷ c ; trans = λ c₀ c₁ → c₀ ◎ c₁ } ; linv = λ _ → invrl ; rinv = λ _ → invll ; ∘-resp-≈ = λ f⟷h g⟷i → resp◎ g⟷i f⟷h } ------------------------------------------------------------------------------ -- Level 2 -- types are 2groupoids; they are points with non-trivial paths between them -- and non-trivial 2paths between the paths module Pi2 where infixr 10 _◎_ infixr 30 _⟷_ -- types data U : Set where ZERO : U ONE : U PLUS : U → U → U TIMES : U → U → U PATH : {t₁ t₂ : Pi0.U•} → (t₁ Pi0.⟷ t₂) → U 2PATH : {t₁ t₂ : Pi1.U•} → (t₁ Pi1.⟷ t₂) → U -- values data Path {t₁ t₂ : Pi0.U•} : (Pi0.Space t₁) → (Pi0.Space t₂) → Set where path : (c : t₁ Pi0.⟷ t₂) → Path (Pi0.point t₁) (Pi0.point t₂) data 2Path {t₁ t₂ : Pi1.U•} : Pi1.Space t₁ → Pi1.Space t₂ → Set where 2path : (c : t₁ Pi1.⟷ t₂) → 2Path (Pi1.point t₁) (Pi1.point t₂) ⟦_⟧ : U → Set ⟦ ZERO ⟧ = ⊥ ⟦ ONE ⟧ = ⊤ ⟦ PLUS t₁ t₂ ⟧ = ⟦ t₁ ⟧ ⊎ ⟦ t₂ ⟧ ⟦ TIMES t₁ t₂ ⟧ = ⟦ t₁ ⟧ × ⟦ t₂ ⟧ ⟦ PATH {t₁} {t₂} c ⟧ = Path {t₁} {t₂} (Pi0.point t₁) (Pi0.point t₂) ⟦ 2PATH {t₁} {t₂} c ⟧ = 2Path {t₁} {t₂} (Pi1.point t₁) (Pi1.point t₂) -- pointed types record U• : Set where constructor •[_,_] field ∣_∣ : U • : ⟦ ∣_∣ ⟧ open U• Space : (t• : U•) → Set Space •[ t , p ] = ⟦ t ⟧ point : (t• : U•) → Space t• point •[ t , p ] = p _∘1_ : {t₁ t₂ t₃ : Pi0.U•} → Path (Pi0.point t₁) (Pi0.point t₂) → Path (Pi0.point t₂) (Pi0.point t₃) → Path (Pi0.point t₁) (Pi0.point t₃) path c₁ ∘1 path c₂ = path (c₁ Pi0.◎ c₂) _∘2_ : {t₁ t₂ t₃ : Pi1.U•} → 2Path (Pi1.point t₁) (Pi1.point t₂) → 2Path (Pi1.point t₂) (Pi1.point t₃) → 2Path (Pi1.point t₁) (Pi1.point t₃) 2path c₁ ∘2 2path c₂ = 2path (c₁ Pi1.◎ c₂) PathSpace : {t₁ t₂ : Pi0.U•} → (c : t₁ Pi0.⟷ t₂) → U• PathSpace c = •[ PATH c , path c ] 2PathSpace : {t₁ t₂ : Pi1.U•} → (c : t₁ Pi1.⟷ t₂) → U• 2PathSpace c = •[ 2PATH c , 2path c ] -- examples -- groupoid combinators to reason about id, sym, and trans -- commutative semiring combinators for 0, 1, +, * data _⟷_ : U• → U• → Set where -- common combinators id⟷ : {t : U•} → t ⟷ t sym⟷ : {t₁ t₂ : U•} → (t₁ ⟷ t₂) → (t₂ ⟷ t₁) _◎_ : {t₁ t₂ t₃ : U•} → (t₁ ⟷ t₂) → (t₂ ⟷ t₃) → (t₁ ⟷ t₃) -- 1groupoid combinators 1lidl : {t₁ t₂ : Pi0.U•} {c : t₁ Pi0.⟷ t₂} → PathSpace (Pi0.id⟷ Pi0.◎ c) ⟷ PathSpace c 1lidr : {t₁ t₂ : Pi0.U•} {c : t₁ Pi0.⟷ t₂} → PathSpace c ⟷ PathSpace (Pi0.id⟷ Pi0.◎ c) 1ridl : {t₁ t₂ : Pi0.U•} {c : t₁ Pi0.⟷ t₂} → PathSpace (c Pi0.◎ Pi0.id⟷) ⟷ PathSpace c 1ridr : {t₁ t₂ : Pi0.U•} {c : t₁ Pi0.⟷ t₂} → PathSpace c ⟷ PathSpace (c Pi0.◎ Pi0.id⟷) 1invll : {t₁ t₂ : Pi0.U•} {c : t₁ Pi0.⟷ t₂} → PathSpace (Pi0.sym⟷ c Pi0.◎ c) ⟷ PathSpace {t₂} {t₂} Pi0.id⟷ 1invlr : {t₁ t₂ : Pi0.U•} {c : t₁ Pi0.⟷ t₂} → PathSpace {t₂} {t₂} Pi0.id⟷ ⟷ PathSpace (Pi0.sym⟷ c Pi0.◎ c) 1invrl : {t₁ t₂ : Pi0.U•} {c : t₁ Pi0.⟷ t₂} → PathSpace (c Pi0.◎ Pi0.sym⟷ c) ⟷ PathSpace {t₁} {t₁} Pi0.id⟷ 1invrr : {t₁ t₂ : Pi0.U•} {c : t₁ Pi0.⟷ t₂} → PathSpace {t₁} {t₁} Pi0.id⟷ ⟷ PathSpace (c Pi0.◎ Pi0.sym⟷ c) 1invinvl : {t₁ t₂ : Pi0.U•} {c : t₁ Pi0.⟷ t₂} → PathSpace (Pi0.sym⟷ (Pi0.sym⟷ c)) ⟷ PathSpace c 1invinvr : {t₁ t₂ : Pi0.U•} {c : t₁ Pi0.⟷ t₂} → PathSpace c ⟷ PathSpace (Pi0.sym⟷ (Pi0.sym⟷ c)) 1tassocl : {t₁ t₂ t₃ t₄ : Pi0.U•} {c₁ : t₁ Pi0.⟷ t₂} {c₂ : t₂ Pi0.⟷ t₃} {c₃ : t₃ Pi0.⟷ t₄} → PathSpace (c₁ Pi0.◎ (c₂ Pi0.◎ c₃)) ⟷ PathSpace ((c₁ Pi0.◎ c₂) Pi0.◎ c₃) 1tassocr : {t₁ t₂ t₃ t₄ : Pi0.U•} {c₁ : t₁ Pi0.⟷ t₂} {c₂ : t₂ Pi0.⟷ t₃} {c₃ : t₃ Pi0.⟷ t₄} → PathSpace ((c₁ Pi0.◎ c₂) Pi0.◎ c₃) ⟷ PathSpace (c₁ Pi0.◎ (c₂ Pi0.◎ c₃)) -- resp◎ is closely related to Eckmann-Hilton 1resp◎ : {t₁ t₂ t₃ : Pi0.U•} {c₁ : t₁ Pi0.⟷ t₂} {c₂ : t₂ Pi0.⟷ t₃} {c₃ : t₁ Pi0.⟷ t₂} {c₄ : t₂ Pi0.⟷ t₃} → (PathSpace c₁ ⟷ PathSpace c₃) → (PathSpace c₂ ⟷ PathSpace c₄) → PathSpace (c₁ Pi0.◎ c₂) ⟷ PathSpace (c₃ Pi0.◎ c₄) -- 2groupoid combinators lidl : {t₁ t₂ : Pi1.U•} {c : t₁ Pi1.⟷ t₂} → 2PathSpace (Pi1.id⟷ Pi1.◎ c) ⟷ 2PathSpace c lidr : {t₁ t₂ : Pi1.U•} {c : t₁ Pi1.⟷ t₂} → 2PathSpace c ⟷ 2PathSpace (Pi1.id⟷ Pi1.◎ c) ridl : {t₁ t₂ : Pi1.U•} {c : t₁ Pi1.⟷ t₂} → 2PathSpace (c Pi1.◎ Pi1.id⟷) ⟷ 2PathSpace c ridr : {t₁ t₂ : Pi1.U•} {c : t₁ Pi1.⟷ t₂} → 2PathSpace c ⟷ 2PathSpace (c Pi1.◎ Pi1.id⟷) invll : {t₁ t₂ : Pi1.U•} {c : t₁ Pi1.⟷ t₂} → 2PathSpace (Pi1.sym⟷ c Pi1.◎ c) ⟷ 2PathSpace {t₂} {t₂} Pi1.id⟷ invlr : {t₁ t₂ : Pi1.U•} {c : t₁ Pi1.⟷ t₂} → 2PathSpace {t₂} {t₂} Pi1.id⟷ ⟷ 2PathSpace (Pi1.sym⟷ c Pi1.◎ c) invrl : {t₁ t₂ : Pi1.U•} {c : t₁ Pi1.⟷ t₂} → 2PathSpace (c Pi1.◎ Pi1.sym⟷ c) ⟷ 2PathSpace {t₁} {t₁} Pi1.id⟷ invrr : {t₁ t₂ : Pi1.U•} {c : t₁ Pi1.⟷ t₂} → 2PathSpace {t₁} {t₁} Pi1.id⟷ ⟷ 2PathSpace (c Pi1.◎ Pi1.sym⟷ c) invinvl : {t₁ t₂ : Pi1.U•} {c : t₁ Pi1.⟷ t₂} → 2PathSpace (Pi1.sym⟷ (Pi1.sym⟷ c)) ⟷ 2PathSpace c invinvr : {t₁ t₂ : Pi1.U•} {c : t₁ Pi1.⟷ t₂} → 2PathSpace c ⟷ 2PathSpace (Pi1.sym⟷ (Pi1.sym⟷ c)) tassocl : {t₁ t₂ t₃ t₄ : Pi1.U•} {c₁ : t₁ Pi1.⟷ t₂} {c₂ : t₂ Pi1.⟷ t₃} {c₃ : t₃ Pi1.⟷ t₄} → 2PathSpace (c₁ Pi1.◎ (c₂ Pi1.◎ c₃)) ⟷ 2PathSpace ((c₁ Pi1.◎ c₂) Pi1.◎ c₃) tassocr : {t₁ t₂ t₃ t₄ : Pi1.U•} {c₁ : t₁ Pi1.⟷ t₂} {c₂ : t₂ Pi1.⟷ t₃} {c₃ : t₃ Pi1.⟷ t₄} → 2PathSpace ((c₁ Pi1.◎ c₂) Pi1.◎ c₃) ⟷ 2PathSpace (c₁ Pi1.◎ (c₂ Pi1.◎ c₃)) -- resp◎ is closely related to Eckmann-Hilton resp◎ : {t₁ t₂ t₃ : Pi1.U•} {c₁ : t₁ Pi1.⟷ t₂} {c₂ : t₂ Pi1.⟷ t₃} {c₃ : t₁ Pi1.⟷ t₂} {c₄ : t₂ Pi1.⟷ t₃} → (2PathSpace c₁ ⟷ 2PathSpace c₃) → (2PathSpace c₂ ⟷ 2PathSpace c₄) → 2PathSpace (c₁ Pi1.◎ c₂) ⟷ 2PathSpace (c₃ Pi1.◎ c₄) -- commutative semiring combinators unite₊ : {t : U•} → •[ PLUS ZERO ∣ t ∣ , inj₂ (• t) ] ⟷ t uniti₊ : {t : U•} → t ⟷ •[ PLUS ZERO ∣ t ∣ , inj₂ (• t) ] swap1₊ : {t₁ t₂ : U•} → •[ PLUS ∣ t₁ ∣ ∣ t₂ ∣ , inj₁ (• t₁) ] ⟷ •[ PLUS ∣ t₂ ∣ ∣ t₁ ∣ , inj₂ (• t₁) ] swap2₊ : {t₁ t₂ : U•} → •[ PLUS ∣ t₁ ∣ ∣ t₂ ∣ , inj₂ (• t₂) ] ⟷ •[ PLUS ∣ t₂ ∣ ∣ t₁ ∣ , inj₁ (• t₂) ] assocl1₊ : {t₁ t₂ t₃ : U•} → •[ PLUS ∣ t₁ ∣ (PLUS ∣ t₂ ∣ ∣ t₃ ∣) , inj₁ (• t₁) ] ⟷ •[ PLUS (PLUS ∣ t₁ ∣ ∣ t₂ ∣) ∣ t₃ ∣ , inj₁ (inj₁ (• t₁)) ] assocl2₊ : {t₁ t₂ t₃ : U•} → •[ PLUS ∣ t₁ ∣ (PLUS ∣ t₂ ∣ ∣ t₃ ∣) , inj₂ (inj₁ (• t₂)) ] ⟷ •[ PLUS (PLUS ∣ t₁ ∣ ∣ t₂ ∣) ∣ t₃ ∣ , inj₁ (inj₂ (• t₂)) ] assocl3₊ : {t₁ t₂ t₃ : U•} → •[ PLUS ∣ t₁ ∣ (PLUS ∣ t₂ ∣ ∣ t₃ ∣) , inj₂ (inj₂ (• t₃)) ] ⟷ •[ PLUS (PLUS ∣ t₁ ∣ ∣ t₂ ∣) ∣ t₃ ∣ , inj₂ (• t₃) ] assocr1₊ : {t₁ t₂ t₃ : U•} → •[ PLUS (PLUS ∣ t₁ ∣ ∣ t₂ ∣) ∣ t₃ ∣ , inj₁ (inj₁ (• t₁)) ] ⟷ •[ PLUS ∣ t₁ ∣ (PLUS ∣ t₂ ∣ ∣ t₃ ∣) , inj₁ (• t₁) ] assocr2₊ : {t₁ t₂ t₃ : U•} → •[ PLUS (PLUS ∣ t₁ ∣ ∣ t₂ ∣) ∣ t₃ ∣ , inj₁ (inj₂ (• t₂)) ] ⟷ •[ PLUS ∣ t₁ ∣ (PLUS ∣ t₂ ∣ ∣ t₃ ∣) , inj₂ (inj₁ (• t₂)) ] assocr3₊ : {t₁ t₂ t₃ : U•} → •[ PLUS (PLUS ∣ t₁ ∣ ∣ t₂ ∣) ∣ t₃ ∣ , inj₂ (• t₃) ] ⟷ •[ PLUS ∣ t₁ ∣ (PLUS ∣ t₂ ∣ ∣ t₃ ∣) , inj₂ (inj₂ (• t₃)) ] unite⋆ : {t : U•} → •[ TIMES ONE ∣ t ∣ , (tt , • t) ] ⟷ t uniti⋆ : {t : U•} → t ⟷ •[ TIMES ONE ∣ t ∣ , (tt , • t) ] swap⋆ : {t₁ t₂ : U•} → •[ TIMES ∣ t₁ ∣ ∣ t₂ ∣ , (• t₁ , • t₂) ] ⟷ •[ TIMES ∣ t₂ ∣ ∣ t₁ ∣ , (• t₂ , • t₁) ] assocl⋆ : {t₁ t₂ t₃ : U•} → •[ TIMES ∣ t₁ ∣ (TIMES ∣ t₂ ∣ ∣ t₃ ∣) , (• t₁ , (• t₂ , • t₃)) ] ⟷ •[ TIMES (TIMES ∣ t₁ ∣ ∣ t₂ ∣) ∣ t₃ ∣ , ((• t₁ , • t₂) , • t₃) ] assocr⋆ : {t₁ t₂ t₃ : U•} → •[ TIMES (TIMES ∣ t₁ ∣ ∣ t₂ ∣) ∣ t₃ ∣ , ((• t₁ , • t₂) , • t₃) ] ⟷ •[ TIMES ∣ t₁ ∣ (TIMES ∣ t₂ ∣ ∣ t₃ ∣) , (• t₁ , (• t₂ , • t₃)) ] distz : {t : U•} {absurd : ⟦ ZERO ⟧} → •[ TIMES ZERO ∣ t ∣ , (absurd , • t) ] ⟷ •[ ZERO , absurd ] factorz : {t : U•} {absurd : ⟦ ZERO ⟧} → •[ ZERO , absurd ] ⟷ •[ TIMES ZERO ∣ t ∣ , (absurd , • t) ] dist1 : {t₁ t₂ t₃ : U•} → •[ TIMES (PLUS ∣ t₁ ∣ ∣ t₂ ∣) ∣ t₃ ∣ , (inj₁ (• t₁) , • t₃) ] ⟷ •[ PLUS (TIMES ∣ t₁ ∣ ∣ t₃ ∣) (TIMES ∣ t₂ ∣ ∣ t₃ ∣) , inj₁ (• t₁ , • t₃) ] dist2 : {t₁ t₂ t₃ : U•} → •[ TIMES (PLUS ∣ t₁ ∣ ∣ t₂ ∣) ∣ t₃ ∣ , (inj₂ (• t₂) , • t₃) ] ⟷ •[ PLUS (TIMES ∣ t₁ ∣ ∣ t₃ ∣) (TIMES ∣ t₂ ∣ ∣ t₃ ∣) , inj₂ (• t₂ , • t₃) ] factor1 : {t₁ t₂ t₃ : U•} → •[ PLUS (TIMES ∣ t₁ ∣ ∣ t₃ ∣) (TIMES ∣ t₂ ∣ ∣ t₃ ∣) , inj₁ (• t₁ , • t₃) ] ⟷ •[ TIMES (PLUS ∣ t₁ ∣ ∣ t₂ ∣) ∣ t₃ ∣ , (inj₁ (• t₁) , • t₃) ] factor2 : {t₁ t₂ t₃ : U•} → •[ PLUS (TIMES ∣ t₁ ∣ ∣ t₃ ∣) (TIMES ∣ t₂ ∣ ∣ t₃ ∣) , inj₂ (• t₂ , • t₃) ] ⟷ •[ TIMES (PLUS ∣ t₁ ∣ ∣ t₂ ∣) ∣ t₃ ∣ , (inj₂ (• t₂) , • t₃) ] _⊕1_ : {t₁ t₂ t₃ t₄ : U•} → (t₁ ⟷ t₃) → (t₂ ⟷ t₄) → (•[ PLUS ∣ t₁ ∣ ∣ t₂ ∣ , inj₁ (• t₁) ] ⟷ •[ PLUS ∣ t₃ ∣ ∣ t₄ ∣ , inj₁ (• t₃) ]) _⊕2_ : {t₁ t₂ t₃ t₄ : U•} → (t₁ ⟷ t₃) → (t₂ ⟷ t₄) → (•[ PLUS ∣ t₁ ∣ ∣ t₂ ∣ , inj₂ (• t₂) ] ⟷ •[ PLUS ∣ t₃ ∣ ∣ t₄ ∣ , inj₂ (• t₄) ]) _⊗_ : {t₁ t₂ t₃ t₄ : U•} → (t₁ ⟷ t₃) → (t₂ ⟷ t₄) → (•[ TIMES ∣ t₁ ∣ ∣ t₂ ∣ , (• t₁ , • t₂ ) ] ⟷ •[ TIMES ∣ t₃ ∣ ∣ t₄ ∣ , (• t₃ , • t₄ ) ]) -- proof that we have a 2Groupoid structure; this is 1Groupoid whose -- equivalences are themselves a 1Groupoid G : 1Groupoid G = record { set = Pi1.U• ; _↝_ = Pi1._⟷_ ; _≈_ = λ c₀ c₁ → 2PathSpace c₀ ⟷ 2PathSpace c₁ ; id = Pi1.id⟷ ; _∘_ = λ c₀ c₁ → c₁ Pi1.◎ c₀ ; _⁻¹ = Pi1.sym⟷ ; lneutr = λ _ → ridl ; rneutr = λ _ → lidl ; assoc = λ _ _ _ → tassocl ; equiv = record { refl = id⟷ ; sym = λ c → sym⟷ c ; trans = λ c₀ c₁ → c₀ ◎ c₁ } ; linv = λ _ → invrl ; rinv = λ _ → invll ; ∘-resp-≈ = λ f⟷h g⟷i → resp◎ g⟷i f⟷h } -- examples ------------------------------------------------------------------------------ --}
39.350427
78
0.407146
22c3b9e65497ceb53e288b9803bdaf27bf0ca01f
187
agda
Agda
Cubical/Codata/M/AsLimit/M.agda
FernandoLarrain/cubical
9acdecfa6437ec455568be4e5ff04849cc2bc13b
[ "MIT" ]
301
2018-10-17T18:00:24.000Z
2022-03-24T02:10:47.000Z
Cubical/Codata/M/AsLimit/M.agda
FernandoLarrain/cubical
9acdecfa6437ec455568be4e5ff04849cc2bc13b
[ "MIT" ]
584
2018-10-15T09:49:02.000Z
2022-03-30T12:09:17.000Z
Cubical/Codata/M/AsLimit/M.agda
FernandoLarrain/cubical
9acdecfa6437ec455568be4e5ff04849cc2bc13b
[ "MIT" ]
134
2018-11-16T06:11:03.000Z
2022-03-23T16:22:13.000Z
{-# OPTIONS --guardedness --safe #-} module Cubical.Codata.M.AsLimit.M where open import Cubical.Codata.M.AsLimit.M.Base public open import Cubical.Codata.M.AsLimit.M.Properties public
26.714286
56
0.775401
127157f5a25a76e5b32f805b644a32aada01ef20
1,170
agda
Agda
test/Succeed/Issue1663.agda
favonia/agda
8d433b967567c08afe15d04a5cb63b6f6d8884ee
[ "BSD-2-Clause" ]
null
null
null
test/Succeed/Issue1663.agda
favonia/agda
8d433b967567c08afe15d04a5cb63b6f6d8884ee
[ "BSD-2-Clause" ]
6
2021-10-18T08:12:24.000Z
2021-11-24T08:31:10.000Z
test/Succeed/Issue1663.agda
antoinevanmuylder/agda
bd59d5b07ffe02a43b28d186d95e1747aac5bc8c
[ "BSD-2-Clause" ]
null
null
null
{-# OPTIONS --cubical-compatible --rewriting --confluence-check #-} postulate _↦_ : ∀ {i} {A : Set i} → A → A → Set i idr : ∀ {i} {A : Set i} {a : A} → a ↦ a {-# BUILTIN REWRITE _↦_ #-} data _==_ {i} {A : Set i} (a : A) : A → Set i where idp : a == a PathOver : ∀ {i j} {A : Set i} (B : A → Set j) {x y : A} (p : x == y) (u : B x) (v : B y) → Set j PathOver B idp u v = (u == v) syntax PathOver B p u v = u == v [ B ↓ p ] postulate PathOver-rewr : ∀ {i j} {A : Set i} {B : Set j} {x y : A} (p : x == y) (u v : B) → (PathOver (λ _ → B) p u v) ↦ (u == v) {-# REWRITE PathOver-rewr #-} ap : ∀ {i j} {A : Set i} {B : A → Set j} (f : (a : A) → B a) {x y : A} → (p : x == y) → PathOver B p (f x) (f y) ap f idp = idp postulate Circle : Set base : Circle loop : base == base module _ {i} {P : Circle → Set i} (base* : P base) (loop* : base* == base* [ P ↓ loop ]) where postulate Circle-elim : (x : Circle) → P x Circle-base-β : Circle-elim base ↦ base* {-# REWRITE Circle-base-β #-} Circle-loop-β : ap Circle-elim loop ↦ loop* {-# REWRITE Circle-loop-β #-} idCircle : Circle → Circle idCircle = Circle-elim base loop
26.590909
88
0.504274
2e1f8fe200a8fd71a0d98e5525cc50e1cd8ff0d0
6,037
agda
Agda
BasicIS4/Semantics/TarskiGluedDyadicGentzen.agda
mietek/hilbert-gentzen
fcd187db70f0a39b894fe44fad0107f61849405c
[ "X11" ]
29
2016-07-03T18:51:56.000Z
2022-01-01T10:29:18.000Z
BasicIS4/Semantics/TarskiGluedDyadicGentzen.agda
mietek/hilbert-gentzen
fcd187db70f0a39b894fe44fad0107f61849405c
[ "X11" ]
1
2018-06-10T09:11:22.000Z
2018-06-10T09:11:22.000Z
BasicIS4/Semantics/TarskiGluedDyadicGentzen.agda
mietek/hilbert-gentzen
fcd187db70f0a39b894fe44fad0107f61849405c
[ "X11" ]
null
null
null
-- Basic intuitionistic modal logic S4, without ∨, ⊥, or ◇. -- Tarski-style semantics with context pairs as concrete worlds, and glueing for □ only. -- Gentzen-style syntax. module BasicIS4.Semantics.TarskiGluedDyadicGentzen where open import BasicIS4.Syntax.Common public open import Common.Semantics public -- Intuitionistic Tarski models. record Model : Set₁ where infix 3 _⊩ᵅ_ _[⊢]_ field -- Forcing for atomic propositions; monotonic. _⊩ᵅ_ : Cx² Ty Ty → Atom → Set mono²⊩ᵅ : ∀ {P Π Π′} → Π ⊆² Π′ → Π ⊩ᵅ P → Π′ ⊩ᵅ P -- Gentzen-style syntax representation; monotonic. _[⊢]_ : Cx² Ty Ty → Ty → Set mono²[⊢] : ∀ {A Π Π′} → Π ⊆² Π′ → Π [⊢] A → Π′ [⊢] A [var] : ∀ {A Γ Δ} → A ∈ Γ → Γ ⁏ Δ [⊢] A [lam] : ∀ {A B Γ Δ} → Γ , A ⁏ Δ [⊢] B → Γ ⁏ Δ [⊢] A ▻ B [app] : ∀ {A B Γ Δ} → Γ ⁏ Δ [⊢] A ▻ B → Γ ⁏ Δ [⊢] A → Γ ⁏ Δ [⊢] B [mvar] : ∀ {A Γ Δ} → A ∈ Δ → Γ ⁏ Δ [⊢] A [box] : ∀ {A Γ Δ} → ∅ ⁏ Δ [⊢] A → Γ ⁏ Δ [⊢] □ A [unbox] : ∀ {A C Γ Δ} → Γ ⁏ Δ [⊢] □ A → Γ ⁏ Δ , A [⊢] C → Γ ⁏ Δ [⊢] C [pair] : ∀ {A B Γ Δ} → Γ ⁏ Δ [⊢] A → Γ ⁏ Δ [⊢] B → Γ ⁏ Δ [⊢] A ∧ B [fst] : ∀ {A B Γ Δ} → Γ ⁏ Δ [⊢] A ∧ B → Γ ⁏ Δ [⊢] A [snd] : ∀ {A B Γ Δ} → Γ ⁏ Δ [⊢] A ∧ B → Γ ⁏ Δ [⊢] B [unit] : ∀ {Γ Δ} → Γ ⁏ Δ [⊢] ⊤ infix 3 _[⊢]⋆_ _[⊢]⋆_ : Cx² Ty Ty → Cx Ty → Set Π [⊢]⋆ ∅ = 𝟙 Π [⊢]⋆ Ξ , A = Π [⊢]⋆ Ξ × Π [⊢] A open Model {{…}} public -- Forcing in a particular model. module _ {{_ : Model}} where infix 3 _⊩_ _⊩_ : Cx² Ty Ty → Ty → Set Π ⊩ α P = Π ⊩ᵅ P Π ⊩ A ▻ B = ∀ {Π′} → Π ⊆² Π′ → Π′ ⊩ A → Π′ ⊩ B Π ⊩ □ A = ∀ {Π′} → Π ⊆² Π′ → Glue (Π′ [⊢] □ A) (Π′ ⊩ A) Π ⊩ A ∧ B = Π ⊩ A × Π ⊩ B Π ⊩ ⊤ = 𝟙 infix 3 _⊩⋆_ _⊩⋆_ : Cx² Ty Ty → Cx Ty → Set Π ⊩⋆ ∅ = 𝟙 Π ⊩⋆ Ξ , A = Π ⊩⋆ Ξ × Π ⊩ A -- Monotonicity with respect to context inclusion. module _ {{_ : Model}} where mono²⊩ : ∀ {A Π Π′} → Π ⊆² Π′ → Π ⊩ A → Π′ ⊩ A mono²⊩ {α P} ψ s = mono²⊩ᵅ ψ s mono²⊩ {A ▻ B} ψ s = λ ψ′ → s (trans⊆² ψ ψ′) mono²⊩ {□ A} ψ s = λ ψ′ → s (trans⊆² ψ ψ′) mono²⊩ {A ∧ B} ψ s = mono²⊩ {A} ψ (π₁ s) , mono²⊩ {B} ψ (π₂ s) mono²⊩ {⊤} ψ s = ∙ mono²⊩⋆ : ∀ {Ξ Π Π′} → Π ⊆² Π′ → Π ⊩⋆ Ξ → Π′ ⊩⋆ Ξ mono²⊩⋆ {∅} ψ ∙ = ∙ mono²⊩⋆ {Ξ , A} ψ (ts , t) = mono²⊩⋆ ψ ts , mono²⊩ {A} ψ t -- Shorthand for variables. module _ {{_ : Model}} where [v₀] : ∀ {A Γ Δ} → Γ , A ⁏ Δ [⊢] A [v₀] = [var] i₀ [v₁] : ∀ {A B Γ Δ} → Γ , A , B ⁏ Δ [⊢] A [v₁] = [var] i₁ [v₂] : ∀ {A B C Γ Δ} → Γ , A , B , C ⁏ Δ [⊢] A [v₂] = [var] i₂ [mv₀] : ∀ {A Γ Δ} → Γ ⁏ Δ , A [⊢] A [mv₀] = [mvar] i₀ [mv₁] : ∀ {A B Γ Δ} → Γ ⁏ Δ , A , B [⊢] A [mv₁] = [mvar] i₁ [mv₂] : ∀ {A B C Γ Δ} → Γ ⁏ Δ , A , B , C [⊢] A [mv₂] = [mvar] i₂ -- Useful theorems in functional form. module _ {{_ : Model}} where [mlam] : ∀ {A B Γ Δ} → Γ ⁏ Δ , A [⊢] B → Γ ⁏ Δ [⊢] □ A ▻ B [mlam] t = [lam] ([unbox] [v₀] (mono²[⊢] (weak⊆ , refl⊆) t)) [multicut] : ∀ {Ξ A Γ Δ} → Γ ⁏ Δ [⊢]⋆ Ξ → Ξ ⁏ Δ [⊢] A → Γ ⁏ Δ [⊢] A [multicut] {∅} ∙ u = mono²[⊢] (bot⊆ , refl⊆) u [multicut] {Ξ , B} (ts , t) u = [app] ([multicut] ts ([lam] u)) t [mmulticut] : ∀ {Ξ A Γ Δ} → Γ ⁏ Δ [⊢]⋆ □⋆ Ξ → Γ ⁏ Ξ [⊢] A → Γ ⁏ Δ [⊢] A [mmulticut] {∅} ∙ u = mono²[⊢] (refl⊆ , bot⊆) u [mmulticut] {Ξ , B} (ts , t) u = [app] ([mmulticut] ts ([mlam] u)) t [multicut²] : ∀ {Ξ Ξ′ A Γ Δ} → Γ ⁏ Δ [⊢]⋆ Ξ → Γ ⁏ Δ [⊢]⋆ □⋆ Ξ′ → Ξ ⁏ Ξ′ [⊢] A → Γ ⁏ Δ [⊢] A [multicut²] {∅} ∙ us v = [mmulticut] us (mono²[⊢] (bot⊆ , refl⊆) v) [multicut²] {Ξ , B} (ts , t) us v = [app] ([multicut²] ts us ([lam] v)) t [dist] : ∀ {A B Γ Δ} → Γ ⁏ Δ [⊢] □ (A ▻ B) → Γ ⁏ Δ [⊢] □ A → Γ ⁏ Δ [⊢] □ B [dist] t u = [unbox] t ([unbox] (mono²[⊢] (refl⊆ , weak⊆) u) ([box] ([app] [mv₁] [mv₀]))) [up] : ∀ {A Γ Δ} → Γ ⁏ Δ [⊢] □ A → Γ ⁏ Δ [⊢] □ □ A [up] t = [unbox] t ([box] ([box] [mv₀])) -- Additional useful equipment. module _ {{_ : Model}} where _⟪$⟫_ : ∀ {A B Π} → Π ⊩ A ▻ B → Π ⊩ A → Π ⊩ B s ⟪$⟫ a = s refl⊆² a ⟪K⟫ : ∀ {A B Π} → Π ⊩ A → Π ⊩ B ▻ A ⟪K⟫ {A} a ψ = K (mono²⊩ {A} ψ a) ⟪S⟫ : ∀ {A B C Π} → Π ⊩ A ▻ B ▻ C → Π ⊩ A ▻ B → Π ⊩ A → Π ⊩ C ⟪S⟫ {A} {B} {C} s₁ s₂ a = _⟪$⟫_ {B} {C} (_⟪$⟫_ {A} {B ▻ C} s₁ a) (_⟪$⟫_ {A} {B} s₂ a) ⟪S⟫′ : ∀ {A B C Π} → Π ⊩ A ▻ B ▻ C → Π ⊩ (A ▻ B) ▻ A ▻ C ⟪S⟫′ {A} {B} {C} s₁ ψ s₂ ψ′ a = let s₁′ = mono²⊩ {A ▻ B ▻ C} (trans⊆² ψ ψ′) s₁ s₂′ = mono²⊩ {A ▻ B} ψ′ s₂ in ⟪S⟫ {A} {B} {C} s₁′ s₂′ a _⟪D⟫_ : ∀ {A B Γ Δ} → Γ ⁏ Δ ⊩ □ (A ▻ B) → Γ ⁏ Δ ⊩ □ A → Γ ⁏ Δ ⊩ □ B _⟪D⟫_ {A} {B} s₁ s₂ ψ = let t ⅋ s₁′ = s₁ ψ u ⅋ a = s₂ ψ in [dist] t u ⅋ (_⟪$⟫_ {A} {B} s₁′ a) _⟪D⟫′_ : ∀ {A B Γ Δ} → Γ ⁏ Δ ⊩ □ (A ▻ B) → Γ ⁏ Δ ⊩ □ A ▻ □ B _⟪D⟫′_ {A} {B} s₁ ψ = _⟪D⟫_ (mono²⊩ {□ (A ▻ B)} ψ s₁) ⟪↑⟫ : ∀ {A Γ Δ} → Γ ⁏ Δ ⊩ □ A → Γ ⁏ Δ ⊩ □ □ A ⟪↑⟫ s ψ = [up] (syn (s ψ)) ⅋ λ ψ′ → s (trans⊆² ψ ψ′) ⟪↓⟫ : ∀ {A Π} → Π ⊩ □ A → Π ⊩ A ⟪↓⟫ s = sem (s refl⊆²) _⟪,⟫′_ : ∀ {A B Π} → Π ⊩ A → Π ⊩ B ▻ A ∧ B _⟪,⟫′_ {A} {B} a ψ = _,_ (mono²⊩ {A} ψ a) -- Forcing in a particular world of a particular model, for sequents. module _ {{_ : Model}} where infix 3 _⊩_⇒_ _⊩_⇒_ : Cx² Ty Ty → Cx² Ty Ty → Ty → Set Π ⊩ Γ ⁏ Δ ⇒ A = Π ⊩⋆ Γ → Π ⊩⋆ □⋆ Δ → Π ⊩ A infix 3 _⊩_⇒⋆_ _⊩_⇒⋆_ : Cx² Ty Ty → Cx² Ty Ty → Cx Ty → Set Π ⊩ Γ ⁏ Δ ⇒⋆ Ξ = Π ⊩⋆ Γ → Π ⊩⋆ □⋆ Δ → Π ⊩⋆ Ξ -- Entailment, or forcing in all worlds of all models, for sequents. infix 3 _⊨_ _⊨_ : Cx² Ty Ty → Ty → Set₁ Π ⊨ A = ∀ {{_ : Model}} {w : Cx² Ty Ty} → w ⊩ Π ⇒ A infix 3 _⊨⋆_ _⊨⋆_ : Cx² Ty Ty → Cx Ty → Set₁ Π ⊨⋆ Ξ = ∀ {{_ : Model}} {w : Cx² Ty Ty} → w ⊩ Π ⇒⋆ Ξ -- Additional useful equipment, for sequents. module _ {{_ : Model}} where lookup : ∀ {A Γ w} → A ∈ Γ → w ⊩⋆ Γ → w ⊩ A lookup top (γ , a) = a lookup (pop i) (γ , b) = lookup i γ mlookup : ∀ {A Δ w} → A ∈ Δ → w ⊩⋆ □⋆ Δ → w ⊩ A mlookup top (γ , s) = sem (s refl⊆²) mlookup (pop i) (γ , s) = mlookup i γ -- TODO: More equipment.
31.60733
93
0.400696
cb228262913b20df1fa6e0daffe811c0e419724e
4,583
agda
Agda
lib/Explore/Explorable/Fun.agda
crypto-agda/explore
16bc8333503ff9c00d47d56f4ec6113b9269a43e
[ "BSD-3-Clause" ]
2
2016-06-05T09:25:32.000Z
2017-06-28T19:19:29.000Z
lib/Explore/Explorable/Fun.agda
crypto-agda/explore
16bc8333503ff9c00d47d56f4ec6113b9269a43e
[ "BSD-3-Clause" ]
1
2019-03-16T14:24:04.000Z
2019-03-16T14:24:04.000Z
lib/Explore/Explorable/Fun.agda
crypto-agda/explore
16bc8333503ff9c00d47d56f4ec6113b9269a43e
[ "BSD-3-Clause" ]
null
null
null
{-# OPTIONS --without-K #-} module Search.Searchable.Fun where open import Type hiding (★) open import Data.Product open import Data.Sum open import Data.One open import Data.Bits open import Function.NP open import Search.Type open import Search.Searchable open import Search.Searchable.Product open import Search.Searchable.Sum import Function.Inverse.NP as FI open FI using (_↔_; inverses; module Inverse) renaming (_$₁_ to to; _$₂_ to from) open import Function.Related.TypeIsomorphisms.NP import Relation.Binary.PropositionalEquality.NP as ≡ open ≡ using (_≡_; _≗_) private -- unused SΠΣ⁻ : ∀ {m A} {B : A → ★ _} {C : Σ A B → ★ _} → Search m ((x : A) (y : B x) → C (x , y)) → Search m (Π (Σ A B) C) SΠΣ⁻ s _∙_ f = s _∙_ (f ∘ uncurry) SΠΣ⁻-ind : ∀ {m p A} {B : A → ★ _} {C : Σ A B → ★ _} → {s : Search m ((x : A) (y : B x) → C (x , y))} → SearchInd p s → SearchInd p (SΠΣ⁻ s) SΠΣ⁻-ind ind P P∙ Pf = ind (P ∘ SΠΣ⁻) P∙ (Pf ∘ uncurry) S×⁻ : ∀ {m A B C} → Search m (A → B → C) → Search m (A × B → C) S×⁻ = SΠΣ⁻ S×⁻-ind : ∀ {m p A B C} → {s : Search m (A → B → C)} → SearchInd p s → SearchInd p (S×⁻ s) S×⁻-ind = SΠΣ⁻-ind SΠ⊎⁻ : ∀ {m A B} {C : A ⊎ B → ★ _} → Search m (Π A (C ∘ inj₁) × Π B (C ∘ inj₂)) → Search m (Π (A ⊎ B) C) SΠ⊎⁻ s _∙_ f = s _∙_ (f ∘ uncurry [_,_]) SΠ⊎⁻-ind : ∀ {m p A B} {C : A ⊎ B → ★ _} {s : Search m (Π A (C ∘ inj₁) × Π B (C ∘ inj₂))} (i : SearchInd p s) → SearchInd p (SΠ⊎⁻ {C = C} s) -- A sB) SΠ⊎⁻-ind i P P∙ Pf = i (P ∘ SΠ⊎⁻) P∙ (Pf ∘ uncurry [_,_]) {- For each A→C function and each B→C function an A⊎B→C function is yield -} S⊎⁻ : ∀ {m A B C} → Search m (A → C) → Search m (B → C) → Search m (A ⊎ B → C) S⊎⁻ sA sB = SΠ⊎⁻ (sA ×-search sB) μΠΣ⁻ : ∀ {A B}{C : Σ A B → ★₀} → Searchable ((x : A)(y : B x) → C (x , y)) → Searchable (Π (Σ A B) C) μΠΣ⁻ = μ-iso (FI.sym curried) Σ-Fun : ∀ {A B} → Funable A → Funable B → Funable (A × B) Σ-Fun (μA , μA→) FB = μΣ μA (searchable FB) , (λ x → μΠΣ⁻ (μA→ (negative FB x))) where open Funable {- μΠ⊎⁻ : ∀ {A B : ★₀}{C : A ⊎ B → ★ _} → Searchable (Π A (C ∘ inj₁) × Π B (C ∘ inj₂)) → Searchable (Π (A ⊎ B) C) μΠ⊎⁻ = μ-iso ? _⊎-Fun_ : ∀ {A B : ★₀} → Funable A → Funable B → Funable (A ⊎ B) _⊎-Fun_ (μA , μA→) (μB , μB→) = (μA ⊎-μ μB) , (λ X → μΠ⊎⁻ (μA→ X ×-μ μB→ X)) -} S𝟙 : ∀ {m A} → Search m A → Search m (𝟙 → A) S𝟙 sA _∙_ f = sA _∙_ (f ∘ const) SΠBit : ∀ {m A} → Search m (A 0b) → Search m (A 1b) → Search m (Π Bit A) SΠBit sA₀ sA₁ _∙_ f = sA₀ _∙_ λ x → sA₁ _∙_ λ y → f λ {true → y; false → x} ×-Dist : ∀ {A B} FA FB → DistFunable {A} FA → DistFunable {B} FB → DistFunable (Σ-Fun FA FB) ×-Dist FA FB FA-dist FB-dist μX c _⊙_ distrib _⊙-cong_ f = Πᴬ (λ x → Πᴮ (λ y → Σ' (f (x , y)))) ≈⟨ ⟦search⟧ (searchable FA){_≡_} ≡.refl _≈_ (λ x y → x ⊙-cong y) (λ { {x} {.x} ≡.refl → FB-dist μX c _⊙_ distrib _⊙-cong_ (curry f x)}) ⟩ Πᴬ (λ x → Σᴮ (λ fb → Πᴮ (λ y → f (x , y) (fb y)))) ≈⟨ FA-dist (negative FB μX) c _⊙_ distrib _⊙-cong_ (λ x fb → search (searchable FB) _⊙_ (λ y → f (x , y) (fb y))) ⟩ Σᴬᴮ (λ fab → Πᴬ (λ x → Πᴮ (λ y → f (x , y) (fab x y)))) ∎ where open CMon c open Funable Σ' = search μX _∙_ Πᴬ = search (searchable FA) _⊙_ Πᴮ = search (searchable FB) _⊙_ Σᴬᴮ = search (negative FA (negative FB μX)) _∙_ Σᴮ = search (negative FB μX) _∙_ {- ⊎-Dist : ∀ {A B : ★₀} FA FB → DistFunable {A} FA → DistFunable {B} FB → DistFunable (FA ⊎-Fun FB) ⊎-Dist FA FB FA-dist FB-dist μX c _◎_ distrib _◎-cong_ f = Πᴬ (Σ' ∘ f ∘ inj₁) ◎ Πᴮ (Σ' ∘ f ∘ inj₂) ≈⟨ {!FA-dist μX c _◎_ distrib _◎-cong_ (f ∘ inj₁) ◎-cong FB-dist μX c _◎_ distrib _◎-cong_ (f ∘ inj₂)!} ⟩ {- Σᴬ (λ fa → Πᴬ (λ i → f (inj₁ i) (fa i))) ◎ Σᴮ (λ fb → Πᴮ (λ i → f (inj₂ i) (fb i))) ≈⟨ sym (search-linʳ (negative FA μX) monoid _◎_ _ _ (proj₂ distrib)) ⟩ Σᴬ (λ fa → Πᴬ (λ i → f (inj₁ i) (fa i)) ◎ Σᴮ (λ fb → Πᴮ (λ i → f (inj₂ i) (fb i)))) ≈⟨ search-sg-ext (negative FA μX) semigroup (λ fa → sym (search-linˡ (negative FB μX) monoid _◎_ _ _ (proj₁ distrib))) ⟩ -} (Σᴬ λ fa → Σᴮ λ fb → Πᴬ ((f ∘ inj₁) ˢ fa) ◎ Πᴮ ((f ∘ inj₂) ˢ fb)) ∎ where open CMon c open Funable Σ' = search μX _∙_ Πᴬ = search (searchable FA) _◎_ Πᴮ = search (searchable FB) _◎_ Σᴬ = search (negative FA μX) _∙_ Σᴮ = search (negative FB μX) _∙_ -} -- -} -- -} -- -}
34.201493
121
0.499018
1a0fe91f86617a9a57f3931a8300774fcdef07df
931
agda
Agda
test/interaction/Issue2437.agda
mdimjasevic/agda
8fb548356b275c7a1e79b768b64511ae937c738b
[ "BSD-3-Clause" ]
1,989
2015-01-09T23:51:16.000Z
2022-03-30T18:20:48.000Z
test/interaction/Issue2437.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
4,066
2015-01-10T11:24:51.000Z
2022-03-31T21:14:49.000Z
test/interaction/Issue2437.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
371
2015-01-03T14:04:08.000Z
2022-03-30T19:00:30.000Z
-- Andreas, 2017-01-27, issue #2437 -- Polarity checker turns Nonvariant to Unused arg in types, -- thus, reducing them. -- However, this should not happen without need. -- We wish to preserve the types as much as possible. -- {-# OPTIONS -v 20 #-} -- {-# OPTIONS -v tc.polarity:30 #-} -- {-# OPTIONS -v tc.decl:30 #-} -- {-# OPTIONS -v tc.term:30 #-} -- {-# OPTIONS -v tc.conv.coerce:20 #-} -- {-# OPTIONS -v tc.signature:30 #-} -- {-# OPTIONS -v import.iface:100 #-} open import Agda.Primitive open import Agda.Builtin.Nat open import Agda.Builtin.Equality plus0 : ∀ x → x + 0 ≡ x plus0 zero = refl plus0 (suc x) rewrite plus0 x = refl Identity : ∀{a} {A : Set a} (f : A → A) → Set a Identity f = ∀ x → f x ≡ x plus-0 : Identity (_+ 0) plus-0 = plus0 -- Test (interactive): C-c C-d plus-0 RET -- Expected: Identity (λ section → section + 0) -- Type should be inferred non-reduced, i.e, not as -- ∀ x → x + 0 ≡ x
27.382353
60
0.617615
22387f01a872a9b5821a86a16229bc55c41c8130
2,003
agda
Agda
test/Common/IO.agda
alex-mckenna/agda
78b62cd24bbd570271a7153e44ad280e52ef3e29
[ "BSD-3-Clause" ]
1
2016-03-17T01:45:59.000Z
2016-03-17T01:45:59.000Z
test/Common/IO.agda
andersk/agda
56928ff709dcb931cb9a48c4790e5ed3739e3032
[ "BSD-3-Clause" ]
null
null
null
test/Common/IO.agda
andersk/agda
56928ff709dcb931cb9a48c4790e5ed3739e3032
[ "BSD-3-Clause" ]
1
2019-03-05T20:02:38.000Z
2019-03-05T20:02:38.000Z
module Common.IO where open import Agda.Builtin.IO public open import Common.Bool open import Common.Char open import Common.Nat open import Common.String open import Common.Unit open import Common.Float infixl 1 _>>=_ postulate return : ∀ {a} {A : Set a} → A → IO A _>>=_ : ∀ {a b} {A : Set a} {B : Set b} → IO A → (A → IO B) → IO B {-# COMPILE GHC return = \_ _ -> return #-} {-# COMPILE GHC _>>=_ = \_ _ _ _ -> (>>=) #-} {-# COMPILE UHC return = \_ _ x -> UHC.Agda.Builtins.primReturn x #-} {-# COMPILE UHC _>>=_ = \_ _ _ _ x y -> UHC.Agda.Builtins.primBind x y #-} {-# COMPILE JS return = function(u0) { return function(u1) { return function(x) { return function(cb) { cb(x); }; }; }; } #-} {-# COMPILE JS _>>=_ = function(u0) { return function(u1) { return function(u2) { return function(u3) { return function(x) { return function(y) { return function(cb) { x(function (xx) { y(xx)(cb); }); }; }; }; }; }; }; } #-} {-# FOREIGN GHC import qualified Data.Text.IO #-} postulate putStr : String -> IO Unit {-# COMPILE GHC putStr = Data.Text.IO.putStr #-} {-# COMPILE UHC putStr = UHC.Agda.Builtins.primPutStr #-} {-# COMPILE JS putStr = function (x) { return function(cb) { process.stdout.write(x); cb(0); }; } #-} printChar : Char -> IO Unit printChar c = putStr (charToStr c) putStrLn : String -> IO Unit putStrLn s = putStr s >>= \_ -> putStr "\n" printNat : Nat -> IO Unit printNat n = putStr (natToString n) printBool : Bool -> IO Unit printBool true = putStr "true" printBool false = putStr "false" printFloat : Float -> IO Unit printFloat f = putStr (floatToString f) infixr 2 _<$>_ _<$>_ : {A B : Set}(f : A -> B)(m : IO A) -> IO B f <$> x = x >>= λ y -> return (f y) infixr 0 bind bind : ∀ {a b} {A : Set a} {B : Set b} → IO A → (A → IO B) → IO B bind m f = m >>= f infixr 0 then then : ∀ {a b} {A : Set a} {B : Set b} -> IO A -> IO B -> IO B then m f = m >>= λ _ -> f syntax bind e (\ x -> f) = x <- e , f syntax then e f = e ,, f
28.211268
105
0.584623
596dab1834b1e284de6b1d676a7e596096e588e7
34,253
agda
Agda
src/Functor.agda
nad/equality
402b20615cfe9ca944662380d7b2d69b0f175200
[ "MIT" ]
3
2020-05-21T22:58:50.000Z
2021-09-02T17:18:15.000Z
src/Functor.agda
nad/equality
402b20615cfe9ca944662380d7b2d69b0f175200
[ "MIT" ]
null
null
null
src/Functor.agda
nad/equality
402b20615cfe9ca944662380d7b2d69b0f175200
[ "MIT" ]
null
null
null
------------------------------------------------------------------------ -- Functors and natural transformations (for 1-categories) ------------------------------------------------------------------------ -- The code is based on the presentation in the HoTT book (but might -- not follow it exactly). {-# OPTIONS --without-K --safe #-} open import Equality module Functor {reflexive} (eq : ∀ {a p} → Equality-with-J a p reflexive) where import Surjection open import Bijection eq hiding (id; _∘_; inverse; step-↔; finally-↔) open import Category eq open Derived-definitions-and-properties eq open import Equivalence eq as Eq using (_≃_; module _≃_; ↔⇒≃) open import Function-universe eq hiding (id; _∘_) open import H-level eq open import H-level.Closure eq open import Logical-equivalence using (_⇔_; module _⇔_) open import Prelude as P hiding (id; _^_) ------------------------------------------------------------------------ -- Functors Functor : ∀ {ℓ₁ ℓ₂ ℓ₃ ℓ₄} → Precategory ℓ₁ ℓ₂ → Precategory ℓ₃ ℓ₄ → Type _ Functor C D = -- Object map. ∃ λ (F₀ : Obj C → Obj D) → -- Morphism map. ∃ λ (F : ∀ {X Y} → Hom C X Y → Hom D (F₀ X) (F₀ Y)) → -- F should be homomorphic with respect to identity and composition. (∀ {X} → F (id C {X = X}) ≡ id D) × (∀ {X Y Z} {f : Hom C X Y} {g : Hom C Y Z} → F (_∙_ C g f) ≡ _∙_ D (F g) (F f)) where open Precategory -- A wrapper. infix 4 _⇨_ record _⇨_ {ℓ₁ ℓ₂ ℓ₃ ℓ₄} (C : Precategory ℓ₁ ℓ₂) (D : Precategory ℓ₃ ℓ₄) : Type (ℓ₁ ⊔ ℓ₂ ⊔ ℓ₃ ⊔ ℓ₄) where field functor : Functor C D open Precategory infixr 10 _⊚_ _⊙_ -- Object map. _⊚_ : Obj C → Obj D _⊚_ = proj₁ functor -- Morphism map. _⊙_ : ∀ {X Y} → Hom C X Y → Hom D (_⊚_ X) (_⊚_ Y) _⊙_ = proj₁ (proj₂ functor) -- The morphism map is homomorphic with respect to identity. ⊙-id : ∀ {X} → _⊙_ (id C {X = X}) ≡ id D ⊙-id = proj₁ (proj₂ (proj₂ functor)) -- The morphism map is homomorphic with respect to composition. ⊙-∙ : ∀ {X Y Z} {f : Hom C X Y} {g : Hom C Y Z} → _⊙_ (_∙_ C g f) ≡ _∙_ D (_⊙_ g) (_⊙_ f) ⊙-∙ = proj₂ (proj₂ (proj₂ functor)) open _⇨_ public private module Dummy₁ where abstract -- The homomorphism properties are propositional (assuming -- extensionality). functor-properties-propositional : ∀ {ℓ₁ ℓ₂ ℓ₃ ℓ₄} → Extensionality (ℓ₁ ⊔ ℓ₂) (ℓ₁ ⊔ ℓ₂ ⊔ ℓ₄) → {C : Precategory ℓ₁ ℓ₂} {D : Precategory ℓ₃ ℓ₄} (F : C ⇨ D) → let open Precategory in Is-proposition ((∀ {X} → F ⊙ id C {X = X} ≡ id D) × (∀ {X Y Z} {f : Hom C X Y} {g : Hom C Y Z} → F ⊙ (_∙_ C g f) ≡ _∙_ D (F ⊙ g) (F ⊙ f))) functor-properties-propositional {ℓ₁} {ℓ₂} ext {D = D} _ = ×-closure 1 (implicit-Π-closure (lower-extensionality ℓ₂ (ℓ₁ ⊔ ℓ₂) ext) 1 λ _ → Precategory.Hom-is-set D) (implicit-Π-closure (lower-extensionality ℓ₂ lzero ext) 1 λ _ → implicit-Π-closure (lower-extensionality ℓ₂ lzero ext) 1 λ _ → implicit-Π-closure (lower-extensionality ℓ₂ ℓ₁ ext) 1 λ _ → implicit-Π-closure (lower-extensionality ℓ₁ ℓ₁ ext) 1 λ _ → implicit-Π-closure (lower-extensionality ℓ₁ (ℓ₁ ⊔ ℓ₂) ext) 1 λ _ → Precategory.Hom-is-set D) open Dummy₁ public private module Dummy₂ where abstract -- Functor equality is equivalent to equality of the corresponding -- maps, suitably transported (assuming extensionality). equality-characterisation⇨ : ∀ {ℓ₁ ℓ₂ ℓ₃ ℓ₄} → Extensionality (ℓ₁ ⊔ ℓ₂) (ℓ₁ ⊔ ℓ₂ ⊔ ℓ₄) → {C : Precategory ℓ₁ ℓ₂} {D : Precategory ℓ₃ ℓ₄} {F G : C ⇨ D} → let open Precategory in (F ≡ G) ≃ ∃ λ (⊚F≡⊚G : _⊚_ F ≡ _⊚_ G) → _≡_ {A = ∀ {X Y} → Hom C X Y → Hom D (G ⊚ X) (G ⊚ Y)} (subst (λ F → ∀ {X Y} → Hom C X Y → Hom D (F X) (F Y)) ⊚F≡⊚G (_⊙_ F)) (_⊙_ G) equality-characterisation⇨ ext {C} {D} {F} {G} = let P : (Obj C → Obj D) → Type _ P = λ F₀ → ∀ {X Y} → Hom C X Y → Hom D (F₀ X) (F₀ Y) Q : ∃ P → Type _ Q = λ { (F₀ , F) → (∀ {X} → F (id C {X = X}) ≡ id D) × (∀ {X Y Z} {f : Hom C X Y} {g : Hom C Y Z} → F (_∙_ C g f) ≡ _∙_ D (F g) (F f)) } in (F ≡ G) ↝⟨ ↔⇒≃ record { surjection = record { logical-equivalence = record { to = cong functor ; from = cong λ f → record { functor = f } } ; right-inverse-of = λ _ → trans (cong-∘ _ _ _) (sym $ cong-id _) } ; left-inverse-of = λ _ → trans (cong-∘ _ _ _) (sym $ cong-id _) } ⟩ (functor F ≡ functor G) ↔⟨ inverse Σ-≡,≡↔≡ ⟩ (∃ λ (⊚F≡⊚G : _⊚_ F ≡ _⊚_ G) → subst (λ F₀ → ∃ λ (F : P F₀) → Q (F₀ , F)) ⊚F≡⊚G (proj₂ $ functor F) ≡ proj₂ (functor G)) ↝⟨ ∃-cong (λ ⊚F≡⊚G → ≡⇒↝ _ $ cong (λ x → x ≡ proj₂ (functor G)) $ push-subst-pair P Q) ⟩ (∃ λ (⊚F≡⊚G : _⊚_ F ≡ _⊚_ G) → _≡_ {A = ∃ λ (H : P (_⊚_ G)) → Q (_⊚_ G , H)} ( subst P ⊚F≡⊚G (_⊙_ F) , subst Q (Σ-≡,≡→≡ ⊚F≡⊚G (refl _)) (proj₂ $ proj₂ $ functor F) ) (proj₂ (functor G))) ↔⟨ ∃-cong (λ ⊚F≡⊚G → inverse $ ignore-propositional-component (functor-properties-propositional ext G)) ⟩□ (∃ λ (⊚F≡⊚G : _⊚_ F ≡ _⊚_ G) → (λ {_ _} → subst P ⊚F≡⊚G (_⊙_ F)) ≡ _⊙_ G) □ where open Precategory -- Some simplification lemmas. proj₁-to-equality-characterisation⇨ : ∀ {ℓ₁ ℓ₂ ℓ₃ ℓ₄} (ext : Extensionality (ℓ₁ ⊔ ℓ₂) (ℓ₁ ⊔ ℓ₂ ⊔ ℓ₄)) {C : Precategory ℓ₁ ℓ₂} {D : Precategory ℓ₃ ℓ₄} {F G : C ⇨ D} → let open Precategory in (F≡G : F ≡ G) → proj₁ (_≃_.to (equality-characterisation⇨ ext {F = F} {G = G}) F≡G) ≡ cong _⊚_ F≡G proj₁-to-equality-characterisation⇨ ext F≡G = proj₁ (_≃_.to (equality-characterisation⇨ ext) F≡G) ≡⟨ proj₁-Σ-≡,≡←≡ _ ⟩ cong proj₁ (cong functor F≡G) ≡⟨ cong-∘ _ _ _ ⟩∎ cong _⊚_ F≡G ∎ cong-⊚-from-equality-characterisation⇨ : ∀ {ℓ₁ ℓ₂ ℓ₃ ℓ₄} (ext : Extensionality (ℓ₁ ⊔ ℓ₂) (ℓ₁ ⊔ ℓ₂ ⊔ ℓ₄)) {C : Precategory ℓ₁ ℓ₂} {D : Precategory ℓ₃ ℓ₄} {F G : C ⇨ D} → let open Precategory in (⊚F≡⊚G : _⊚_ F ≡ _⊚_ G) → (⊙F≡⊙G : _≡_ {A = ∀ {X Y} → Hom C X Y → Hom D (G ⊚ X) (G ⊚ Y)} (subst (λ F → ∀ {X Y} → Hom C X Y → Hom D (F X) (F Y)) ⊚F≡⊚G (_⊙_ F)) (_⊙_ G)) → cong _⊚_ (_≃_.from (equality-characterisation⇨ ext {F = F} {G = G}) (⊚F≡⊚G , ⊙F≡⊙G)) ≡ ⊚F≡⊚G cong-⊚-from-equality-characterisation⇨ ext {F = F} {G} ⊚F≡⊚G ⊙F≡⊙G = cong _⊚_ (_≃_.from (equality-characterisation⇨ ext {F = F} {G = G}) (⊚F≡⊚G , ⊙F≡⊙G)) ≡⟨ cong-∘ _ _ _ ⟩ cong proj₁ (Σ-≡,≡→≡ ⊚F≡⊚G _) ≡⟨ proj₁-Σ-≡,≡→≡ _ _ ⟩∎ ⊚F≡⊚G ∎ open Dummy₂ public private module Dummy₃ where abstract -- Another equality characterisation lemma. equality-characterisation≡⇨ : ∀ {ℓ₁ ℓ₂ ℓ₃ ℓ₄} → Extensionality (ℓ₁ ⊔ ℓ₂) (ℓ₁ ⊔ ℓ₂ ⊔ ℓ₄) → {C : Precategory ℓ₁ ℓ₂} {D : Precategory ℓ₃ ℓ₄} {F G : C ⇨ D} {eq₁ eq₂ : F ≡ G} → (eq₁ ≡ eq₂) ≃ (cong _⊚_ eq₁ ≡ cong _⊚_ eq₂) equality-characterisation≡⇨ {ℓ₁} {ℓ₂} ext {D = D} {eq₁ = eq₁} {eq₂} = eq₁ ≡ eq₂ ↝⟨ inverse $ Eq.≃-≡ (equality-characterisation⇨ ext) ⟩ _≃_.to (equality-characterisation⇨ ext) eq₁ ≡ _≃_.to (equality-characterisation⇨ ext) eq₂ ↔⟨ inverse $ ignore-propositional-component (implicit-Π-closure (lower-extensionality ℓ₂ lzero ext) 2 λ _ → implicit-Π-closure (lower-extensionality ℓ₂ ℓ₁ ext) 2 λ _ → Π-closure (lower-extensionality ℓ₁ (ℓ₁ ⊔ ℓ₂) ext) 2 λ _ → Precategory.Hom-is-set D) ⟩ proj₁ (_≃_.to (equality-characterisation⇨ ext) eq₁) ≡ proj₁ (_≃_.to (equality-characterisation⇨ ext) eq₂) ↝⟨ ≡⇒↝ _ (cong₂ _≡_ (proj₁-to-equality-characterisation⇨ _ _) (proj₁-to-equality-characterisation⇨ _ _)) ⟩□ cong _⊚_ eq₁ ≡ cong _⊚_ eq₂ □ open Dummy₃ public -- Identity functor. id⇨ : ∀ {ℓ₁ ℓ₂} {C : Precategory ℓ₁ ℓ₂} → C ⇨ C functor id⇨ = P.id , P.id , refl _ , refl _ -- Composition of functors. infixr 10 _∙⇨_ _∙⇨_ : ∀ {ℓ₁ ℓ₂} {C : Precategory ℓ₁ ℓ₂} {ℓ₃ ℓ₄} {D : Precategory ℓ₃ ℓ₄} {ℓ₅ ℓ₆} {E : Precategory ℓ₅ ℓ₆} → D ⇨ E → C ⇨ D → C ⇨ E functor (_∙⇨_ {C = C} {D = D} {E = E} G F) = (G ⊚_) ∘ (F ⊚_) , (G ⊙_) ∘ (F ⊙_) , (G ⊙ F ⊙ id C ≡⟨ cong (G ⊙_) $ ⊙-id F ⟩ G ⊙ id D ≡⟨ ⊙-id G ⟩∎ id E ∎) , (λ {_ _ _ f g} → G ⊙ F ⊙ _∙_ C g f ≡⟨ cong (G ⊙_) $ ⊙-∙ F ⟩ G ⊙ _∙_ D (F ⊙ g) (F ⊙ f) ≡⟨ ⊙-∙ G ⟩∎ _∙_ E (G ⊙ F ⊙ g) (G ⊙ F ⊙ f) ∎) where open Precategory -- id⇨ is a left identity (assuming extensionality). id⇨∙⇨ : ∀ {ℓ₁ ℓ₂} {C : Precategory ℓ₁ ℓ₂} {ℓ₃ ℓ₄} {D : Precategory ℓ₃ ℓ₄} → Extensionality (ℓ₁ ⊔ ℓ₂) (ℓ₁ ⊔ ℓ₂ ⊔ ℓ₄) → {F : C ⇨ D} → id⇨ ∙⇨ F ≡ F id⇨∙⇨ ext {F} = _≃_.from (equality-characterisation⇨ ext) ( refl (F ⊚_) , (subst _ (refl (F ⊚_)) (λ {_ _} → F ⊙_) ≡⟨ subst-refl _ _ ⟩∎ (λ {_ _} → F ⊙_) ∎) ) -- id⇨ is a right identity (assuming extensionality). ∙⇨id⇨ : ∀ {ℓ₁ ℓ₂} {C : Precategory ℓ₁ ℓ₂} {ℓ₃ ℓ₄} {D : Precategory ℓ₃ ℓ₄} → Extensionality (ℓ₁ ⊔ ℓ₂) (ℓ₁ ⊔ ℓ₂ ⊔ ℓ₄) → {F : C ⇨ D} → F ∙⇨ id⇨ ≡ F ∙⇨id⇨ ext {F} = _≃_.from (equality-characterisation⇨ ext) ( refl (F ⊚_) , (subst _ (refl (F ⊚_)) (λ {_ _} → F ⊙_) ≡⟨ subst-refl _ _ ⟩∎ (λ {_ _} → F ⊙_) ∎) ) -- _∙⇨_ is associative (assuming extensionality). ∙⇨-assoc : ∀ {ℓ₁ ℓ₂} {C₁ : Precategory ℓ₁ ℓ₂} {ℓ₃ ℓ₄} {C₂ : Precategory ℓ₃ ℓ₄} {ℓ₅ ℓ₆} {C₃ : Precategory ℓ₅ ℓ₆} {ℓ₇ ℓ₈} {C₄ : Precategory ℓ₇ ℓ₈} → Extensionality (ℓ₁ ⊔ ℓ₂) (ℓ₁ ⊔ ℓ₂ ⊔ ℓ₈) → (F : C₃ ⇨ C₄) (G : C₂ ⇨ C₃) {H : C₁ ⇨ C₂} → F ∙⇨ (G ∙⇨ H) ≡ (F ∙⇨ G) ∙⇨ H ∙⇨-assoc ext F G {H} = _≃_.from (equality-characterisation⇨ ext) ( refl _ , (subst _ (refl _) (λ {_ _} → (F ∙⇨ G ∙⇨ H) ⊙_) ≡⟨ subst-refl _ _ ⟩ (λ {_ _} → (F ∙⇨ G ∙⇨ H) ⊙_) ∎) ) ------------------------------------------------------------------------ -- Natural transformations Natural-transformation : ∀ {ℓ₁ ℓ₂} {C : Precategory ℓ₁ ℓ₂} {ℓ₃ ℓ₄} {D : Precategory ℓ₃ ℓ₄} → C ⇨ D → C ⇨ D → Type _ Natural-transformation {C = C} {D = D} F G = -- Morphisms. ∃ λ (γ : ∀ {X} → Hom D (F ⊚ X) (G ⊚ X)) → -- Naturality. ∀ {X Y} {f : Hom C X Y} → (G ⊙ f) ∙ γ ≡ γ ∙ (F ⊙ f) where open Precategory hiding (_∙_) open Precategory D using (_∙_) -- A wrapper. infix 4 _⇾_ record _⇾_ {ℓ₁ ℓ₂} {C : Precategory ℓ₁ ℓ₂} {ℓ₃ ℓ₄} {D : Precategory ℓ₃ ℓ₄} (F G : C ⇨ D) : Type (ℓ₁ ⊔ ℓ₂ ⊔ ℓ₃ ⊔ ℓ₄) where field natural-transformation : Natural-transformation F G open Precategory hiding (_∙_) open Precategory D using (_∙_) -- Morphisms. transformation : ∀ {X} → Hom D (F ⊚ X) (G ⊚ X) transformation = proj₁ natural-transformation -- Naturality. natural : ∀ {X Y} {f : Hom C X Y} → (G ⊙ f) ∙ transformation ≡ transformation ∙ (F ⊙ f) natural = proj₂ natural-transformation private module Dummy₄ where abstract -- The naturality property is a proposition (assuming -- extensionality). naturality-propositional : ∀ {ℓ₁ ℓ₂ ℓ₃ ℓ₄} → Extensionality (ℓ₁ ⊔ ℓ₂) (ℓ₁ ⊔ ℓ₂ ⊔ ℓ₄) → {C : Precategory ℓ₁ ℓ₂} {D : Precategory ℓ₃ ℓ₄} (F G : C ⇨ D) → let open Precategory hiding (_∙_); open Precategory D using (_∙_) in {transformation : ∀ {X} → Hom D (F ⊚ X) (G ⊚ X)} → Is-proposition (∀ {X Y} {f : Hom C X Y} → (G ⊙ f) ∙ transformation ≡ transformation ∙ (F ⊙ f)) naturality-propositional {ℓ₁} {ℓ₂} ext {D = D} _ _ = implicit-Π-closure (lower-extensionality ℓ₂ lzero ext) 1 λ _ → implicit-Π-closure (lower-extensionality ℓ₂ ℓ₁ ext) 1 λ _ → implicit-Π-closure (lower-extensionality ℓ₁ (ℓ₁ ⊔ ℓ₂) ext) 1 λ _ → Precategory.Hom-is-set D -- Natural transformation equality is equivalent to pointwise -- equality of the corresponding "transformations" (assuming -- extensionality). equality-characterisation⇾ : ∀ {ℓ₁ ℓ₂ ℓ₃ ℓ₄} → Extensionality (ℓ₁ ⊔ ℓ₂) (ℓ₁ ⊔ ℓ₂ ⊔ ℓ₄) → {C : Precategory ℓ₁ ℓ₂} {D : Precategory ℓ₃ ℓ₄} {F G : C ⇨ D} {γ δ : F ⇾ G} → (γ ≡ δ) ≃ (∀ {X} → _⇾_.transformation γ {X = X} ≡ _⇾_.transformation δ {X = X}) equality-characterisation⇾ {ℓ₁} {ℓ₂} ext {F = F} {G} {γ} {δ} = γ ≡ δ ↝⟨ inverse $ Eq.≃-≡ $ ↔⇒≃ record { surjection = record { logical-equivalence = record { to = _⇾_.natural-transformation ; from = λ γ → record { natural-transformation = γ } } ; right-inverse-of = refl } ; left-inverse-of = refl } ⟩ _⇾_.natural-transformation γ ≡ _⇾_.natural-transformation δ ↔⟨ inverse $ ignore-propositional-component (naturality-propositional ext F G) ⟩ (λ {X} → _⇾_.transformation γ {X = X}) ≡ _⇾_.transformation δ ↝⟨ inverse $ Eq.≃-≡ (Eq.↔⇒≃ implicit-Π↔Π) ⟩ (λ X → _⇾_.transformation γ {X = X}) ≡ (λ X → _⇾_.transformation δ {X = X}) ↝⟨ inverse $ Eq.extensionality-isomorphism (lower-extensionality ℓ₂ (ℓ₁ ⊔ ℓ₂) ext) ⟩ (∀ X → _⇾_.transformation γ {X = X} ≡ _⇾_.transformation δ {X = X}) ↔⟨ inverse implicit-Π↔Π ⟩□ (∀ {X} → _⇾_.transformation γ {X = X} ≡ _⇾_.transformation δ {X = X}) □ -- Natural transformations form sets (assuming extensionality). ⇾-set : ∀ {ℓ₁ ℓ₂ ℓ₃ ℓ₄} → Extensionality (ℓ₁ ⊔ ℓ₂) (ℓ₁ ⊔ ℓ₂ ⊔ ℓ₄) → {C : Precategory ℓ₁ ℓ₂} {D : Precategory ℓ₃ ℓ₄} {F G : C ⇨ D} → Is-set (F ⇾ G) ⇾-set {ℓ₁} {ℓ₂} ext {D = D} {F = F} {G = G} = let surj = record { logical-equivalence = record { to = λ γ → record { natural-transformation = γ } ; from = _⇾_.natural-transformation } ; right-inverse-of = refl } in respects-surjection surj 2 $ Σ-closure 2 (implicit-Π-closure (lower-extensionality ℓ₂ (ℓ₁ ⊔ ℓ₂) ext) 2 λ _ → Precategory.Hom-is-set D) (λ _ → mono₁ 1 $ naturality-propositional ext F G) open Dummy₄ public -- Identity natural transformation. id⇾ : ∀ {ℓ₁ ℓ₂} {C : Precategory ℓ₁ ℓ₂} {ℓ₃ ℓ₄} {D : Precategory ℓ₃ ℓ₄} (F : C ⇨ D) → F ⇾ F id⇾ {C = C} {D = D} F = record { natural-transformation = id , Dummy₅.nat } where open Precategory D module Dummy₅ where abstract nat : ∀ {X Y} {f : Precategory.Hom C X Y} → (F ⊙ f) ∙ id ≡ id ∙ (F ⊙ f) nat {f = f} = (F ⊙ f) ∙ id ≡⟨ right-identity ⟩ F ⊙ f ≡⟨ sym $ left-identity ⟩∎ id ∙ (F ⊙ f) ∎ -- Composition of natural transformations. infixr 10 _∙⇾_ _∙⇾_ : ∀ {ℓ₁ ℓ₂} {C : Precategory ℓ₁ ℓ₂} {ℓ₃ ℓ₄} {D : Precategory ℓ₃ ℓ₄} {F G H : C ⇨ D} → G ⇾ H → F ⇾ G → F ⇾ H _∙⇾_ {C = C} {D = D} {F} {G} {H} γ δ = record { natural-transformation = ε , Dummy₅.nat } where open Precategory D open _⇾_ ε : ∀ {X} → Hom (F ⊚ X) (H ⊚ X) ε = transformation γ ∙ transformation δ module Dummy₅ where abstract nat : ∀ {X Y} {f : Precategory.Hom C X Y} → (H ⊙ f) ∙ ε ≡ ε ∙ (F ⊙ f) nat {f = f} = (H ⊙ f) ∙ (transformation γ ∙ transformation δ) ≡⟨ assoc ⟩ ((H ⊙ f) ∙ transformation γ) ∙ transformation δ ≡⟨ cong (λ f → f ∙ _) $ natural γ ⟩ (transformation γ ∙ (G ⊙ f)) ∙ transformation δ ≡⟨ sym assoc ⟩ transformation γ ∙ ((G ⊙ f) ∙ transformation δ) ≡⟨ cong (_∙_ _) $ natural δ ⟩ transformation γ ∙ (transformation δ ∙ (F ⊙ f)) ≡⟨ assoc ⟩∎ (transformation γ ∙ transformation δ) ∙ (F ⊙ f) ∎ -- Composition of functors and natural transformations. infixr 10 _⇾∙⇨_ _⇨∙⇾_ _⇾∙⇨_ : ∀ {ℓ₁ ℓ₂} {C : Precategory ℓ₁ ℓ₂} {ℓ₃ ℓ₄} {D : Precategory ℓ₃ ℓ₄} {ℓ₅ ℓ₆} {E : Precategory ℓ₅ ℓ₆} {G H : D ⇨ E} → G ⇾ H → (F : C ⇨ D) → (G ∙⇨ F) ⇾ (H ∙⇨ F) _⇾_.natural-transformation (γ ⇾∙⇨ _) = transformation , natural where open _⇾_ γ _⇨∙⇾_ : ∀ {ℓ₁ ℓ₂} {C : Precategory ℓ₁ ℓ₂} {ℓ₃ ℓ₄} {D : Precategory ℓ₃ ℓ₄} {ℓ₅ ℓ₆} {E : Precategory ℓ₅ ℓ₆} {G H : C ⇨ D} → (F : D ⇨ E) → G ⇾ H → (F ∙⇨ G) ⇾ (F ∙⇨ H) _⇾_.natural-transformation (_⇨∙⇾_ {C = C} {D = D} {E = E} {G} {H} F γ) = ε , Dummy₅.nat where open Precategory open _⇾_ γ ε : ∀ {X} → Hom E (F ⊚ G ⊚ X) (F ⊚ H ⊚ X) ε = F ⊙ transformation module Dummy₅ where abstract nat : ∀ {X Y} {f : Hom C X Y} → _∙_ E (F ⊙ H ⊙ f) ε ≡ _∙_ E ε (F ⊙ G ⊙ f) nat {f = f} = _∙_ E (F ⊙ H ⊙ f) (F ⊙ transformation) ≡⟨ sym $ ⊙-∙ F ⟩ F ⊙ _∙_ D (H ⊙ f) transformation ≡⟨ cong (F ⊙_) natural ⟩ F ⊙ _∙_ D transformation (G ⊙ f) ≡⟨ ⊙-∙ F ⟩∎ _∙_ E (F ⊙ transformation) (F ⊙ G ⊙ f) ∎ ------------------------------------------------------------------------ -- Functor precategories -- Functor precategories are defined using extensionality. infix 10 _^_ _^_ : ∀ {ℓ₁ ℓ₂ ℓ₃ ℓ₄} → Precategory ℓ₁ ℓ₂ → Precategory ℓ₃ ℓ₄ → Extensionality (ℓ₃ ⊔ ℓ₄) (ℓ₂ ⊔ ℓ₃ ⊔ ℓ₄) → Precategory _ _ (D ^ C) ext = record { precategory = (C ⇨ D) , (λ F G → (F ⇾ G) , ⇾-set ext) , id⇾ _ , _∙⇾_ , _≃_.from (equality-characterisation⇾ ext) left-identity , _≃_.from (equality-characterisation⇾ ext) right-identity , _≃_.from (equality-characterisation⇾ ext) assoc } where open Precategory D private module Dummy₅ where abstract -- The natural transformation γ is an isomorphism in (D ^ C) ext iff -- _⇾_.transformation γ {X = X} is an isomorphism in D for every X. natural-isomorphism-lemma : ∀ {ℓ₁ ℓ₂ ℓ₃ ℓ₄} (ext : Extensionality (ℓ₁ ⊔ ℓ₂) (ℓ₁ ⊔ ℓ₂ ⊔ ℓ₄)) → {C : Precategory ℓ₁ ℓ₂} {D : Precategory ℓ₃ ℓ₄} {F G : C ⇨ D} {γ : F ⇾ G} → let open Precategory in Is-isomorphism ((D ^ C) ext) γ ⇔ (∀ {X} → Is-isomorphism D (_⇾_.transformation γ {X = X})) natural-isomorphism-lemma ext {D = D} {F} {G} {γ} = record { to = λ { (δ , γδ , δγ) → transformation δ , (transformation γ ∙ transformation δ ≡⟨⟩ transformation (γ ∙⇾ δ) ≡⟨ cong (λ ε → transformation ε) γδ ⟩ transformation (id⇾ G) ≡⟨⟩ id ∎) , (transformation δ ∙ transformation γ ≡⟨⟩ transformation (δ ∙⇾ γ) ≡⟨ cong (λ ε → transformation ε) δγ ⟩ transformation (id⇾ F) ≡⟨⟩ id ∎) } ; from = λ iso → record { natural-transformation = proj₁ iso , (λ {_ _ f} → (F ⊙ f) ∙ proj₁ iso ≡⟨ sym left-identity ⟩ id ∙ (F ⊙ f) ∙ proj₁ iso ≡⟨ cong (λ g → g ∙ (F ⊙ f) ∙ proj₁ iso) $ sym $ proj₂ (proj₂ iso) ⟩ (proj₁ iso ∙ transformation γ) ∙ (F ⊙ f) ∙ proj₁ iso ≡⟨ sym assoc ⟩ proj₁ iso ∙ (transformation γ ∙ (F ⊙ f) ∙ proj₁ iso) ≡⟨ cong (_ ∙_) assoc ⟩ proj₁ iso ∙ ((transformation γ ∙ (F ⊙ f)) ∙ proj₁ iso) ≡⟨ cong (λ g → _ ∙ (g ∙ _)) $ sym $ natural γ ⟩ proj₁ iso ∙ (((G ⊙ f) ∙ transformation γ) ∙ proj₁ iso) ≡⟨ cong (_ ∙_) $ sym assoc ⟩ proj₁ iso ∙ (G ⊙ f) ∙ (transformation γ ∙ proj₁ iso) ≡⟨ cong ((_ ∙_) ∘ ((G ⊙ f) ∙_)) $ proj₁ (proj₂ iso) ⟩ proj₁ iso ∙ (G ⊙ f) ∙ id ≡⟨ assoc ⟩ (proj₁ iso ∙ (G ⊙ f)) ∙ id ≡⟨ right-identity ⟩∎ proj₁ iso ∙ (G ⊙ f) ∎) } , _≃_.from (equality-characterisation⇾ ext) (proj₁ (proj₂ iso)) , _≃_.from (equality-characterisation⇾ ext) (proj₂ (proj₂ iso)) } where open Precategory D open _⇾_ open Dummy₅ public abstract -- If D is a category, then (D ^ C) ext is also a category. infix 10 _↑_ _↑_ : ∀ {ℓ₁ ℓ₂ ℓ₃ ℓ₄} → Category ℓ₁ ℓ₂ → Precategory ℓ₃ ℓ₄ → Extensionality (ℓ₃ ⊔ ℓ₄) (ℓ₁ ⊔ ℓ₂ ⊔ ℓ₃ ⊔ ℓ₄) → Category (ℓ₁ ⊔ ℓ₂ ⊔ ℓ₃ ⊔ ℓ₄) (ℓ₁ ⊔ ℓ₂ ⊔ ℓ₃ ⊔ ℓ₄) _↑_ {ℓ₁} {ℓ₂} {ℓ₃} {ℓ₄} D C ext = record { category = D^C , (λ {F G} → _≃_.is-equivalence $ ↔⇒≃ $ record { surjection = record { logical-equivalence = record { to = Precategory.≡→≅ D^C ; from = λ { (F⇾G , F⇾G-iso) → let γ : ∀ X → F ⊚ X ≅ G ⊚ X γ _ = _⇾_.transformation F⇾G , _⇔_.to (natural-isomorphism-lemma ext₁) F⇾G-iso ⊚F≡⊚G : _⊚_ F ≡ _⊚_ G ⊚F≡⊚G = apply-ext (Eq.good-ext ext₂) λ X → F ⊚ X ≡⟨ ≅→≡ (γ X) ⟩∎ G ⊚ X ∎ cong-⊚F≡⊚G : ∀ {X} → cong (λ H → H X) ⊚F≡⊚G ≡ ≅→≡ (γ X) cong-⊚F≡⊚G = Eq.cong-good-ext ext₂ (≅→≡ ∘ γ) ⊙F≡⊙G : _≡_ {A = ∀ {X Y} → HomC X Y → Hom (G ⊚ X) (G ⊚ Y)} (subst (λ F → ∀ {X Y} → HomC X Y → Hom (F X) (F Y)) ⊚F≡⊚G (_⊙_ F)) (_⊙_ G) ⊙F≡⊙G = implicit-extensionality (lower-extensionality ℓ₄ ℓ₁ ext) λ X → implicit-extensionality (lower-extensionality ℓ₄ (ℓ₁ ⊔ ℓ₃) ext) λ Y → apply-ext (lower-extensionality ℓ₃ (ℓ₁ ⊔ ℓ₃ ⊔ ℓ₄) ext) λ f → subst (λ F → ∀ {X Y} → HomC X Y → Hom (F X) (F Y)) ⊚F≡⊚G (_⊙_ F) f ≡⟨ cong (λ H → H f) $ sym $ push-subst-implicit-application ⊚F≡⊚G (λ F X → ∀ {Y} → HomC X Y → Hom (F X) (F Y)) ⟩ subst (λ F → ∀ {Y} → HomC X Y → Hom (F X) (F Y)) ⊚F≡⊚G (_⊙_ F) f ≡⟨ cong (λ H → H f) $ sym $ push-subst-implicit-application ⊚F≡⊚G (λ F Y → HomC X Y → Hom (F X) (F Y)) ⟩ subst (λ F → HomC X Y → Hom (F X) (F Y)) ⊚F≡⊚G (_⊙_ F) f ≡⟨ sym $ push-subst-application ⊚F≡⊚G (λ F _ → Hom (F X) (F Y)) ⟩ subst (λ F → Hom (F X) (F Y)) ⊚F≡⊚G (F ⊙ f) ≡⟨ subst-∘ (uncurry Hom) (λ H → (H X , H Y)) ⊚F≡⊚G ⟩ subst (uncurry Hom) (cong (λ H → (H X , H Y)) ⊚F≡⊚G) (F ⊙ f) ≡⟨ cong (λ p → subst (uncurry Hom) p (F ⊙ f)) $ sym $ cong₂-cong-cong {eq = ⊚F≡⊚G} (λ H → H X) (λ H → H Y) _,_ ⟩ subst (uncurry Hom) (cong₂ _,_ (cong (λ H → H X) ⊚F≡⊚G) (cong (λ H → H Y) ⊚F≡⊚G)) (F ⊙ f) ≡⟨ cong₂ (λ p q → subst (uncurry Hom) (cong₂ _,_ p q) (F ⊙ f)) cong-⊚F≡⊚G cong-⊚F≡⊚G ⟩ subst (uncurry Hom) (cong₂ _,_ (≅→≡ (γ X)) (≅→≡ (γ Y))) (F ⊙ f) ≡⟨ Hom-, (≅→≡ (γ X)) (≅→≡ (γ Y)) ⟩ ≡→≅ (≅→≡ (γ Y)) ¹ ∙ (F ⊙ f) ∙ ≡→≅ (≅→≡ (γ X)) ⁻¹ ≡⟨ cong₂ (λ p q → p ¹ ∙ (F ⊙ f) ∙ q ⁻¹) (_≃_.right-inverse-of ≡≃≅ _) (_≃_.right-inverse-of ≡≃≅ _) ⟩ γ Y ¹ ∙ (F ⊙ f) ∙ γ X ⁻¹ ≡⟨ assoc ⟩ (γ Y ¹ ∙ (F ⊙ f)) ∙ γ X ⁻¹ ≡⟨ cong (_∙ γ X ⁻¹) $ sym $ _⇾_.natural F⇾G ⟩ ((G ⊙ f) ∙ γ X ¹) ∙ γ X ⁻¹ ≡⟨ sym assoc ⟩ (G ⊙ f) ∙ γ X ¹ ∙ γ X ⁻¹ ≡⟨ cong (_ ∙_) $ γ X ¹⁻¹ ⟩ (G ⊙ f) ∙ id ≡⟨ right-identity ⟩∎ G ⊙ f ∎ in _≃_.from (equality-characterisation⇨ ext₁) (⊚F≡⊚G , ⊙F≡⊙G) } } ; right-inverse-of = λ { (F⇾G , F⇾G-iso) → _≃_.from (Precategory.≡≃≡¹ D^C) $ _≃_.from (equality-characterisation⇾ ext₁) λ {X} → _⇾_.transformation (proj₁ (Precategory.≡→≅ D^C _)) ≡⟨⟩ _⇾_.transformation (proj₁ (elim (λ {F G} _ → Precategory._≅_ D^C F G) (λ _ → Precategory.id≅ D^C) _)) ≡⟨ elim (λ {F G} F≡G → _⇾_.transformation (proj₁ (Precategory.≡→≅ D^C F≡G)) ≡ elim (λ {F G} _ → Hom (F X) (G X)) (λ _ → id) (cong _⊚_ F≡G)) (λ F → _⇾_.transformation (proj₁ (elim (λ {F G} _ → Precategory._≅_ D^C F G) (λ _ → Precategory.id≅ D^C) (refl F))) ≡⟨ cong (λ f → _⇾_.transformation (proj₁ f) {X = X}) $ elim-refl (λ {X Y} _ → Precategory._≅_ D^C X Y) _ ⟩ _⇾_.transformation {F = F} (proj₁ (Precategory.id≅ D^C)) ≡⟨⟩ id ≡⟨ sym $ elim-refl (λ {F G} _ → Hom (F X) (G X)) _ ⟩ elim (λ {F G} _ → Hom (F X) (G X)) (λ _ → id) (refl (_⊚_ F)) ≡⟨ cong (elim (λ {F G} _ → Hom (F X) (G X)) _) $ sym $ cong-refl _⊚_ ⟩∎ elim (λ {F G} _ → Hom (F X) (G X)) (λ _ → id) (cong _⊚_ (refl F)) ∎) _ ⟩ elim (λ {F G} _ → Hom (F X) (G X)) (λ _ → id) (cong _⊚_ _) ≡⟨ cong (elim (λ {F G} _ → Hom (F X) (G X)) (λ _ → id)) $ cong-⊚-from-equality-characterisation⇨ _ _ _ ⟩ elim (λ {F G} _ → Hom (F X) (G X)) (λ _ → id) (apply-ext (Eq.good-ext ext₂) λ Y → ≅→≡ (_⇾_.transformation F⇾G {X = Y} , _)) ≡⟨ Eq.elim-good-ext ext₂ _ _ _ ⟩ elim (λ {X Y} _ → Hom X Y) (λ _ → id) (≅→≡ (_⇾_.transformation F⇾G {X = X} , _)) ≡⟨ elim (λ {X Y} X≡Y → elim (λ {X Y} _ → Hom X Y) (λ _ → id) X≡Y ≡ proj₁ (≡→≅ X≡Y)) (λ X → elim (λ {X Y} _ → Hom X Y) (λ _ → id) (refl X) ≡⟨ elim-refl (λ {X Y} _ → Hom X Y) _ ⟩ id ≡⟨⟩ proj₁ id≅ ≡⟨ cong proj₁ (sym ≡→≅-refl) ⟩∎ proj₁ (≡→≅ (refl X)) ∎ ) _ ⟩ proj₁ (≡→≅ (≅→≡ (_⇾_.transformation F⇾G {X = X} , _))) ≡⟨ cong proj₁ (_≃_.right-inverse-of ≡≃≅ _) ⟩∎ _⇾_.transformation F⇾G {X = X} ∎ } } ; left-inverse-of = λ F≡G → _≃_.from (equality-characterisation≡⇨ ext₁) ( cong _⊚_ _ ≡⟨ cong-⊚-from-equality-characterisation⇨ _ _ _ ⟩ apply-ext (Eq.good-ext ext₂) (λ X → ≅→≡ ( _⇾_.transformation (proj₁ $ Precategory.≡→≅ D^C F≡G) {X = X} , _ )) ≡⟨ elim (λ {F G} F≡G → (f : (X : _) → _) → apply-ext (Eq.good-ext ext₂) (λ X → ≅→≡ (_⇾_.transformation (proj₁ $ Precategory.≡→≅ D^C F≡G) , f X)) ≡ cong _⊚_ F≡G) (λ F _ → apply-ext (Eq.good-ext ext₂) (λ _ → ≅→≡ ( _⇾_.transformation (proj₁ $ Precategory.≡→≅ D^C (refl F)) , _ )) ≡⟨ cong (apply-ext (Eq.good-ext ext₂)) (apply-ext ext₂ λ X → cong ≅→≡ $ Σ-≡,≡→≡ (cong (λ f → _⇾_.transformation (proj₁ f) {X = X}) $ Precategory.≡→≅-refl D^C) (refl _)) ⟩ apply-ext (Eq.good-ext ext₂) (λ _ → ≅→≡ ( _⇾_.transformation {F = F} (proj₁ $ Precategory.id≅ D^C) , _ )) ≡⟨⟩ apply-ext (Eq.good-ext ext₂) (λ _ → ≅→≡ (id , _)) ≡⟨ cong (apply-ext (Eq.good-ext ext₂)) (apply-ext ext₂ λ _ → cong ≅→≡ $ _≃_.from ≡≃≡¹ $ refl _) ⟩ apply-ext (Eq.good-ext ext₂) (λ _ → ≅→≡ id≅) ≡⟨ cong (apply-ext (Eq.good-ext ext₂)) (apply-ext ext₂ λ _ → ≅→≡-refl) ⟩ apply-ext (Eq.good-ext ext₂) (λ X → refl (F ⊚ X)) ≡⟨ Eq.good-ext-refl ext₂ _ ⟩ refl (_⊚_ F) ≡⟨ sym $ cong-refl _ ⟩∎ cong _⊚_ (refl F) ∎) F≡G _ ⟩∎ cong _⊚_ F≡G ∎) }) } where open Category D open Precategory C using () renaming (Hom to HomC) ext₁ : Extensionality (ℓ₃ ⊔ ℓ₄) (ℓ₂ ⊔ ℓ₃ ⊔ ℓ₄) ext₁ = lower-extensionality lzero ℓ₁ ext ext₂ : Extensionality ℓ₃ ℓ₁ ext₂ = lower-extensionality ℓ₄ (ℓ₂ ⊔ ℓ₃ ⊔ ℓ₄) ext D^C : Precategory (ℓ₁ ⊔ ℓ₂ ⊔ ℓ₃ ⊔ ℓ₄) (ℓ₁ ⊔ ℓ₂ ⊔ ℓ₃ ⊔ ℓ₄) D^C = (precategory ^ C) ext₁
43.523507
147
0.383616
a12eef9d78855305944d4bce0682dd451ce2a5d3
174
agda
Agda
Cubical/Relation/Binary.agda
limemloh/cubical
df4ef7edffd1c1deb3d4ff342c7178e9901c44f1
[ "MIT" ]
1
2020-03-23T23:52:11.000Z
2020-03-23T23:52:11.000Z
Cubical/Relation/Binary.agda
limemloh/cubical
df4ef7edffd1c1deb3d4ff342c7178e9901c44f1
[ "MIT" ]
null
null
null
Cubical/Relation/Binary.agda
limemloh/cubical
df4ef7edffd1c1deb3d4ff342c7178e9901c44f1
[ "MIT" ]
null
null
null
{-# OPTIONS --cubical --safe #-} module Cubical.Relation.Binary where open import Cubical.Relation.Binary.Base public open import Cubical.Relation.Binary.Properties public
24.857143
53
0.793103
229f333be405c9ee9ba059951584000ad4e71a6d
937
agda
Agda
src/data/lib/prim/Agda/Builtin/String.agda
alex-mckenna/agda
78b62cd24bbd570271a7153e44ad280e52ef3e29
[ "BSD-3-Clause" ]
1
2021-07-07T10:49:57.000Z
2021-07-07T10:49:57.000Z
src/data/lib/prim/Agda/Builtin/String.agda
andersk/agda
56928ff709dcb931cb9a48c4790e5ed3739e3032
[ "BSD-3-Clause" ]
null
null
null
src/data/lib/prim/Agda/Builtin/String.agda
andersk/agda
56928ff709dcb931cb9a48c4790e5ed3739e3032
[ "BSD-3-Clause" ]
null
null
null
{-# OPTIONS --without-K #-} module Agda.Builtin.String where open import Agda.Builtin.Bool open import Agda.Builtin.List open import Agda.Builtin.Char {-# BUILTIN STRING String #-} primitive primStringToList : String → List Char primStringFromList : List Char → String primStringAppend : String → String → String primStringEquality : String → String → Bool primShowChar : Char → String primShowString : String → String {-# COMPILE JS primStringToList = function(x) { return x.split(""); } #-} {-# COMPILE JS primStringFromList = function(x) { return x.join(""); } #-} {-# COMPILE JS primStringAppend = function(x) { return function(y) { return x+y; }; } #-} {-# COMPILE JS primStringEquality = function(x) { return function(y) { return x===y; }; } #-} {-# COMPILE JS primShowChar = function(x) { return JSON.stringify(x); } #-} {-# COMPILE JS primShowString = function(x) { return JSON.stringify(x); } #-}
37.48
93
0.677695
315e93c25ba479dc507ff5583212a82fb3c360a9
5,398
agda
Agda
src/Calculator.agda
MaisaMilena/AgdaCalculator
e977a5f2a005682cee123568b49462dd7d7b11ad
[ "MIT" ]
1
2019-03-29T02:30:10.000Z
2019-03-29T02:30:10.000Z
src/Calculator.agda
MaisaMilena/AgdaCalculator
e977a5f2a005682cee123568b49462dd7d7b11ad
[ "MIT" ]
null
null
null
src/Calculator.agda
MaisaMilena/AgdaCalculator
e977a5f2a005682cee123568b49462dd7d7b11ad
[ "MIT" ]
null
null
null
module Calculator where open import Human.Humanity hiding (_==_) open import Human.Nat public hiding (_==_) open import Human.Char public open import Human.Equality public --------- Data --------- -- Generic proof to proof "Or" operation. Proof that one of the arguments must be true data Either (A B : Set) : Set where fst : A -> Either A B snd : B -> Either A B -- Declaring a set of operations data Operation : Set where add sub mul : Operation -- It's used to identify which number will be updated, the one on the right or left data Side : Set where right left : Side -- Can be a number, an operation symbol or execution command data Event : Set where clr : Event -- base case num : Side -> Nat -> Event -- a digit ope : Operation -> Event -- operator data State : Set where state : Operation → Nat → Nat → State --------- Auxiliar properties --------- -- Proof of commutativity of addition. Proof by beala x+0 : (a : Nat) → (a + 0) == a x+0 zero = refl x+0 (suc a) rewrite x+0 a = refl -- Agda knows that 0 * a == 0, now we are telling that "a * 0 == 0 * a" a*0 : (a : Nat) -> (a * 0) == 0 a*0 zero = refl a*0 (suc a) rewrite (a*0 a) = refl -- does that 0 * a == 0 -- Proof that 1 is identity element of multiply over nats. Proof by beala a*1 : (a : Nat) -> (a * 1) == a a*1 zero = refl a*1 (suc a) rewrite a*1 a | a*0 a | x+0 a = refl -- Tells Agda that 1 * a == a 1*a : (a : Nat) -> (1 * a) == a 1*a zero = refl 1*a (suc a) rewrite 1*a a = refl --------- Calculator --------- -- Initial state init : State init = (state add 0 0) -- Calculates the operation related to a state result : State -> Nat result (state add a b) = (a + b) result (state sub a b) = (a - b) result (state mul a b) = (a * b) -- Get the current State, an Event and update to a new State updateState : State -> Event -> State -- clear updateState s clr = init -- "num operation": update the numbers values updateState (state op m n) (num right x) = (state op m x) updateState (state op m n) (num left x) = (state op x n) -- execute an operation updateState (state op m n) (ope e) = (state e m n) --------- Testing Calculator --------- testUpState0 : State -- add a number on the left testUpState0 = (updateState init (num left 1)) testUpState1 : State -- add a number on the right testUpState1 = (updateState testUpState0 (num right 1)) testUpState2 : State -- executes an operation on both numbers testUpState2 = (updateState testUpState1 (ope add)) -- A type of test as is usually done in other programming languages. Given some input what do I expect as result? testUpStateResult : (result (updateState testUpState1 (ope add))) == 2 testUpStateResult = refl testUpState0a : State -- add a number on the left testUpState0a = (updateState init (num left 3)) testUpState1a : State -- add a number on the right testUpState1a = (updateState testUpState0a (num right 5)) testUpState2a : State -- executes an operation on both numbers testUpState2a = (updateState testUpState1a (ope mul)) testUpState0b : State testUpState0b = (updateState testUpState2a (clr)) --------- Theorems --------- -- Proofs that the result showing up an operation will always do that operation -- theorem-0 : (s : State) -> (a b : Nat) -> (result (state add a b)) == (a + b) theorem-0 s a b = refl theorem-1 : (s : State) -> (a b : Nat) -> (result (state sub a b)) == (a - b) theorem-1 s a b = refl theorem-2 : (s : State) -> (a b : Nat) -> (result (state mul a b)) == (a * b) theorem-2 s a b = refl -- Given a and b and a proof that one of them is 0, then the result of multiplicating a and b must be 0 theorem-3 : ∀ (a b : Nat) -> Either (a == 0) (b == 0) -> (a * b) == 0 theorem-3 .0 b (fst refl) = refl -- Agda knows that 0 * n == 0 (refl) theorem-3 a .0 (snd refl) = (a*0 a) -- then we proof that n * 0 is also 0 -- if a == 1: (mul a b) == b -- if b == 1: (mul a b) == a -- if a == 1 OR b == 1: Either ((mul a b) == b) ((mul a b) == a) -- Given a and b and a proof that one of them is 1, -- then the result of multiplicating a and b must be the number that is not 1 theorem-4 : ∀ (a b : Nat) -> Either (a == 1) (b == 1) -> Either ((a * b) == b) ((a * b) == a) theorem-4 .1 b (fst refl) = fst (1*a b) -- A proof that 1 * b == b theorem-4 a .1 (snd refl) = snd (a*1 a) -- A proof that b * 1 == b -- Proof that update state works as expected update-theorem : ∀ (x y : Nat) → (s : State) → (result (updateState (updateState (updateState s (num left x)) (ope add)) (num right y))) == (x + y) update-theorem x y (state op m n) = refl -- TODO -- -- -- Evaluates several expressions. E.g. (2 + 3) * 5 -- data Expression : Set where -- num : Nat -> Expression -- add : Expression -> Expression -> Expression -- sub : Expression -> Expression -> Expression ----- VIEW? ----- -- main : Program -- main _ = do -- -- print "-- Calculator --" -- -- Receives a number, an operation symbol and a execution command -- -- let result = exe-operation 2 3 add -- print (show result) -- let result2 = (primNatToChar (exe-operation 2 3 add)) -- print (primShowChar result2) -- for i from 0 to 10 do: -- print ("i: " ++ show i) -- -- if (2 == 2) -- (then: print "foo") -- (else: print "bar") -- -- let num = -- init 0.0 -- for i from 0 to 1000000 do: -- λ result → result f+ 1.0 -- print (primShowFloat num)
31.940828
147
0.616525
c7bd71c9711765c7b70ba4794c7c086179d5ada9
872
agda
Agda
src/Implicits/Resolution/Finite/Resolution.agda
metaborg/ts.agda
7fe638b87de26df47b6437f5ab0a8b955384958d
[ "MIT" ]
4
2019-04-05T17:57:11.000Z
2021-05-07T04:08:41.000Z
src/Implicits/Resolution/Finite/Resolution.agda
metaborg/ts.agda
7fe638b87de26df47b6437f5ab0a8b955384958d
[ "MIT" ]
null
null
null
src/Implicits/Resolution/Finite/Resolution.agda
metaborg/ts.agda
7fe638b87de26df47b6437f5ab0a8b955384958d
[ "MIT" ]
null
null
null
open import Prelude module Implicits.Resolution.Finite.Resolution where open import Coinduction open import Data.Fin.Substitution open import Data.List open import Data.List.Any open Membership-≡ open import Implicits.Syntax open import Implicits.Substitutions open import Implicits.Resolution.Termination open import Induction open import Induction.Nat open import Relation.Binary using (Rel) mutual data _⊢_↓_ {ν} (Δ : ICtx ν) : Type ν → SimpleType ν → Set where i-simp : ∀ a → Δ ⊢ simpl a ↓ a i-iabs : ∀ {ρ₁ ρ₂ a} → (, ρ₁) hρ< (, ρ₂) → Δ ⊢ᵣ ρ₁ → Δ ⊢ ρ₂ ↓ a → Δ ⊢ ρ₁ ⇒ ρ₂ ↓ a i-tabs : ∀ {ρ a} b → Δ ⊢ ρ tp[/tp b ] ↓ a → Δ ⊢ ∀' ρ ↓ a data _⊢ᵣ_ {ν} (Δ : ICtx ν) : Type ν → Set where r-simp : ∀ {r τ} → r ∈ Δ → Δ ⊢ r ↓ τ → Δ ⊢ᵣ simpl τ r-iabs : ∀ {ρ₁ ρ₂} → ((ρ₁ ∷ Δ) ⊢ᵣ ρ₂) → Δ ⊢ᵣ (ρ₁ ⇒ ρ₂) r-tabs : ∀ {ρ} → ictx-weaken Δ ⊢ᵣ ρ → Δ ⊢ᵣ ∀' ρ
31.142857
85
0.611239
570d4e5f2a18320d6ca91e6233e3dbb8a2f7ec94
4,910
agda
Agda
src/Categories/Diagram/Pullback/Properties.agda
jaykru/agda-categories
a4053cf700bcefdf73b857c3352f1eae29382a60
[ "MIT" ]
1
2021-04-18T18:21:47.000Z
2021-04-18T18:21:47.000Z
src/Categories/Diagram/Pullback/Properties.agda
jaykru/agda-categories
a4053cf700bcefdf73b857c3352f1eae29382a60
[ "MIT" ]
null
null
null
src/Categories/Diagram/Pullback/Properties.agda
jaykru/agda-categories
a4053cf700bcefdf73b857c3352f1eae29382a60
[ "MIT" ]
null
null
null
{-# OPTIONS --without-K --safe #-} open import Categories.Category module Categories.Diagram.Pullback.Properties {o ℓ e} (C : Category o ℓ e) where open import Function using (_$_) open import Categories.Category.Cartesian C open import Categories.Diagram.Pullback C open import Categories.Diagram.Equalizer C open import Categories.Object.Product C open import Categories.Object.Terminal C open import Categories.Morphism C open import Categories.Morphism.Reasoning C private open Category C variable X Y Z : Obj f g h i : X ⇒ Y open HomReasoning open Equiv -- pullbacks of a monomorphism along itself give us the identity arrow. pullback-self-mono : Mono f → IsPullback id id f f pullback-self-mono mono = record { commute = refl ; universal = λ {X} {h₁} {h₂} eq → h₁ ; unique = λ id∘i≈h₁ _ → ⟺ identityˡ ○ id∘i≈h₁ ; p₁∘universal≈h₁ = identityˡ ; p₂∘universal≈h₂ = λ {X} {h₁} {h₂} {eq} → identityˡ ○ mono h₁ h₂ eq } -- pullback from a terminal object is the same as a product module _ (t : Terminal) where open Terminal t pullback-⊤⇒product : Pullback (! {X}) (! {Y}) → Product X Y pullback-⊤⇒product p = record { A×B = P ; π₁ = p₁ ; π₂ = p₂ ; ⟨_,_⟩ = λ f g → universal (!-unique₂ {f = ! ∘ f} {g = ! ∘ g}) ; project₁ = p₁∘universal≈h₁ ; project₂ = p₂∘universal≈h₂ ; unique = λ eq eq′ → ⟺ (unique eq eq′) } where open Pullback p product⇒pullback-⊤ : Product X Y → Pullback (! {X}) (! {Y}) product⇒pullback-⊤ p = record { p₁ = π₁ ; p₂ = π₂ ; isPullback = record { commute = !-unique₂ ; universal = λ {_ f g} _ → ⟨ f , g ⟩ ; unique = λ eq eq′ → ⟺ (unique eq eq′) ; p₁∘universal≈h₁ = project₁ ; p₂∘universal≈h₂ = project₂ } } where open Product p -- pullbacks respect _≈_ module _ (p : Pullback f g) where open Pullback p pullback-resp-≈ : f ≈ h → g ≈ i → Pullback h i pullback-resp-≈ eq eq′ = record { p₁ = p₁ ; p₂ = p₂ ; isPullback = record { commute = ∘-resp-≈ˡ (⟺ eq) ○ commute ○ ∘-resp-≈ˡ eq′ ; universal = λ eq″ → universal (∘-resp-≈ˡ eq ○ eq″ ○ ∘-resp-≈ˡ (⟺ eq′)) ; unique = unique ; p₁∘universal≈h₁ = p₁∘universal≈h₁ ; p₂∘universal≈h₂ = p₂∘universal≈h₂ } } -- Some facts about pulling back along identity module _ (p : Pullback id f) where open Pullback p -- This is a more subtle way of saying that 'p₂ ≈ id', without involving heterogenous equality. pullback-identity : universal id-comm-sym ∘ p₂ ≈ id pullback-identity = begin universal Basic.id-comm-sym ∘ p₂ ≈⟨ unique ( pullˡ p₁∘universal≈h₁ ) (pullˡ p₂∘universal≈h₂) ⟩ universal eq ≈⟨ universal-resp-≈ (⟺ commute ○ identityˡ) identityˡ ⟩ universal commute ≈˘⟨ Pullback.id-unique p ⟩ id ∎ where eq : id ∘ f ∘ p₂ ≈ f ∘ id ∘ p₂ eq = begin (id ∘ f ∘ p₂) ≈⟨ elimˡ Equiv.refl ⟩ (f ∘ p₂) ≈˘⟨ refl⟩∘⟨ identityˡ ⟩ (f ∘ id ∘ p₂) ∎ module _ (pullbacks : ∀ {X Y Z} (f : X ⇒ Z) (g : Y ⇒ Z) → Pullback f g) (cartesian : Cartesian) where open Cartesian cartesian pullback×cartesian⇒equalizer : Equalizer f g pullback×cartesian⇒equalizer {f = f} {g = g} = record { arr = p.p₁ ; isEqualizer = record { equality = equality ; equalize = λ {_ h} eq → p.universal $ begin ⟨ f , g ⟩ ∘ h ≈⟨ ⟨⟩∘ ⟩ ⟨ f ∘ h , g ∘ h ⟩ ≈˘⟨ ⟨⟩-cong₂ identityˡ (identityˡ ○ eq) ⟩ ⟨ id ∘ f ∘ h , id ∘ f ∘ h ⟩ ≈˘⟨ ⟨⟩∘ ⟩ ⟨ id , id ⟩ ∘ f ∘ h ∎ ; universal = ⟺ p.p₁∘universal≈h₁ ; unique = λ eq → p.unique (⟺ eq) (⟺ (pullˡ eq′) ○ ⟺ (∘-resp-≈ʳ eq)) } } where p : Pullback ⟨ f , g ⟩ ⟨ id , id ⟩ p = pullbacks _ _ module p = Pullback p eq : ⟨ f ∘ p.p₁ , g ∘ p.p₁ ⟩ ≈ ⟨ p.p₂ , p.p₂ ⟩ eq = begin ⟨ f ∘ p.p₁ , g ∘ p.p₁ ⟩ ≈˘⟨ ⟨⟩∘ ⟩ ⟨ f , g ⟩ ∘ p.p₁ ≈⟨ p.commute ⟩ ⟨ id , id ⟩ ∘ p.p₂ ≈⟨ ⟨⟩∘ ⟩ ⟨ id ∘ p.p₂ , id ∘ p.p₂ ⟩ ≈⟨ ⟨⟩-cong₂ identityˡ identityˡ ⟩ ⟨ p.p₂ , p.p₂ ⟩ ∎ eq′ : f ∘ p.p₁ ≈ p.p₂ eq′ = begin f ∘ p.p₁ ≈˘⟨ project₁ ⟩ π₁ ∘ ⟨ f ∘ p.p₁ , g ∘ p.p₁ ⟩ ≈⟨ refl⟩∘⟨ eq ⟩ π₁ ∘ ⟨ p.p₂ , p.p₂ ⟩ ≈⟨ project₁ ⟩ p.p₂ ∎ equality : f ∘ p.p₁ ≈ g ∘ p.p₁ equality = begin f ∘ p.p₁ ≈⟨ eq′ ⟩ p.p₂ ≈˘⟨ project₂ ⟩ π₂ ∘ ⟨ p.p₂ , p.p₂ ⟩ ≈˘⟨ refl⟩∘⟨ eq ⟩ π₂ ∘ ⟨ f ∘ p.p₁ , g ∘ p.p₁ ⟩ ≈⟨ project₂ ⟩ g ∘ p.p₁ ∎
34.335664
99
0.490224
22c3b75170804f505abc3bfa2a3cea941262b586
5,975
agda
Agda
src/Categories/Category/Instance/SimplicialSet/Properties.agda
yourboynico/agda-categories
6a087c592dbe58fc4bd9d02e1be9b94a9e138aca
[ "MIT" ]
279
2019-06-01T14:36:40.000Z
2022-03-22T00:40:14.000Z
src/Categories/Category/Instance/SimplicialSet/Properties.agda
seanpm2001/agda-categories
d9e4f578b126313058d105c61707d8c8ae987fa8
[ "MIT" ]
236
2019-06-01T14:53:54.000Z
2022-03-28T14:31:43.000Z
src/Categories/Category/Instance/SimplicialSet/Properties.agda
seanpm2001/agda-categories
d9e4f578b126313058d105c61707d8c8ae987fa8
[ "MIT" ]
64
2019-06-02T16:58:15.000Z
2022-03-14T02:00:59.000Z
{-# OPTIONS --without-K --safe #-} open import Level module Categories.Category.Instance.SimplicialSet.Properties (o ℓ : Level) where open import Function using (_$_) open import Data.Empty.Polymorphic using (⊥; ⊥-elim) open import Data.Nat using (ℕ) open import Data.Fin using (Fin) open import Data.Product using (proj₁) import Relation.Binary.PropositionalEquality as Eq open import Categories.Category using (Category; _[_,_]; _[_∘_]; _[_≈_]) open import Categories.Category.Instance.SimplicialSet using (SimplicialSet) open import Categories.Category.Instance.Simplex using (Δ; δ; σ; ⟦_⟧; Δ-eq; Δ-pointwise) open import Categories.Functor using (Functor; _∘F_) open import Categories.Functor.Construction.Constant using (const) open import Categories.Functor.Construction.LiftSetoids using (LiftSetoids) open import Categories.NaturalTransformation using (ntHelper) open import Categories.Yoneda private module Y = Functor (Yoneda.embed Δ) module Δ = Category Δ -- Some useful notation for a simplicial set ΔSet : Set (suc o ⊔ suc ℓ) ΔSet = Category.Obj (SimplicialSet o ℓ ) -- The standard n-simplex. Δ[_] : ℕ → ΔSet Δ[_] n = LiftSetoids o ℓ ∘F Y.F₀ n -------------------------------------------------------------------------------- -- Boundaries of the Standard Simplicies -- -- The basic idea here is that we will build up boundary of 'Δ[ n ]' by considering -- all of the morphisms 'Δ[ m , n ]' that factor through some face map 'face i : Δ[ n - 1 , n ]' -- The indexing here is a bit tricky, but this is the price we pay to avoid 'pred' -- A 'Boundary m n' represents some set of maps into 'Δ[ ℕ.suc n ]' that factor through -- a face map. To make this indexing more obvious, we use the suggestively named variable 'n-1'. record Boundary (m n-1 : ℕ) : Set where -- To avoid the (somewhat confusion) pattern of 'ℕ.suc n-1', let's define -- a bit of helpful local notation. private n : ℕ n = ℕ.suc n-1 field hom : Δ [ m , n ] factor : Δ [ m , n-1 ] factor-dim : Fin n factor-face : Δ [ hom ≈ Δ [ δ factor-dim ∘ factor ] ] -- Lift morphisms in Δ to maps between boundary sets on 'Δ[ n ]' boundary-map : ∀ {x y n} → Δ [ x , y ] → Boundary y n → Boundary x n boundary-map {n = n} f b = record { hom = hom b ∘ f ; factor = factor b ∘ f ; factor-dim = factor-dim b ; factor-face = Δ-eq (Δ-pointwise (factor-face b)) } where open Category Δ open Boundary -- The boundary of an n-simplex ∂Δ[_] : ℕ → ΔSet ∂Δ[_] ℕ.zero = const record { Carrier = ⊥ ; _≈_ = λ () ; isEquivalence = record { refl = λ { {()} } ; sym = λ { {()} } ; trans = λ { {()} } } } ∂Δ[_] (ℕ.suc n) = record { F₀ = λ m → record { Carrier = Lift o (Boundary m n) ; _≈_ = λ (lift b) (lift b′) → Lift ℓ (Δ [ hom b ≈ hom b′ ]) ; isEquivalence = record { refl = lift Δ.Equiv.refl ; sym = λ (lift eq) → lift (Δ.Equiv.sym eq) ; trans = λ (lift eq₁) (lift eq₂) → lift (Δ.Equiv.trans eq₁ eq₂) } } ; F₁ = λ f → record { _⟨$⟩_ = λ (lift b) → lift (boundary-map f b) ; cong = λ (lift eq) → lift (Δ-eq (Δ-pointwise eq)) } ; identity = λ (lift eq) → lift (Δ-eq (Δ-pointwise eq)) ; homomorphism = λ (lift eq) → lift (Δ-eq (Δ-pointwise eq)) ; F-resp-≈ = λ {_} {_} {f} {g} f≈g {b} {b′} eq → lift $ Δ-eq $ λ {x} → begin ⟦ hom (lower b) ⟧ (⟦ f ⟧ x) ≡⟨ Δ-pointwise (lower eq) ⟩ ⟦ hom (lower b′) ⟧ (⟦ f ⟧ x) ≡⟨ cong ⟦ hom (lower b′) ⟧ (Δ-pointwise f≈g) ⟩ ⟦ hom (lower b′) ⟧ (⟦ g ⟧ x) ∎ } where open Boundary open Eq open ≡-Reasoning -------------------------------------------------------------------------------- -- Horns -- -- The idea here is essentially the same as the boundaries, but we exclude the kth -- face map as a possible factor. record Horn (m n-1 : ℕ) (k : Fin (ℕ.suc n-1)) : Set where field horn : Boundary m n-1 open Boundary horn public field is-horn : factor-dim Eq.≢ k Λ[_,_] : (n : ℕ) → Fin n → ΔSet Λ[ ℕ.suc n , k ] = record { F₀ = λ m → record { Carrier = Lift o (Horn m n k) ; _≈_ = λ (lift h) (lift h′) → Lift ℓ (Δ [ hom h ≈ hom h′ ]) ; isEquivalence = record { refl = lift Δ.Equiv.refl ; sym = λ (lift eq) → lift (Δ.Equiv.sym eq) ; trans = λ (lift eq₁) (lift eq₂) → lift (Δ.Equiv.trans eq₁ eq₂) } } ; F₁ = λ f → record { _⟨$⟩_ = λ (lift h) → lift record { horn = boundary-map f (horn h) ; is-horn = is-horn h } ; cong = λ (lift eq) → lift (Δ-eq (Δ-pointwise eq)) } ; identity = λ (lift eq) → lift (Δ-eq (Δ-pointwise eq)) ; homomorphism = λ (lift eq) → lift (Δ-eq (Δ-pointwise eq)) ; F-resp-≈ = λ {_} {_} {f} {g} f≈g {h} {h′} eq → lift $ Δ-eq $ λ {x} → begin ⟦ hom (lower h) ⟧ (⟦ f ⟧ x) ≡⟨ Δ-pointwise (lower eq) ⟩ ⟦ hom (lower h′) ⟧ (⟦ f ⟧ x) ≡⟨ cong ⟦ hom (lower h′) ⟧ (Δ-pointwise f≈g) ⟩ ⟦ hom (lower h′) ⟧ (⟦ g ⟧ x) ∎ } where open Horn open Eq open ≡-Reasoning -------------------------------------------------------------------------------- -- Morphims between simplicial sets module _ where open Category (SimplicialSet o ℓ) -- Inclusion of boundaries ∂Δ-inj : ∀ {n} → ∂Δ[ n ] ⇒ Δ[ n ] ∂Δ-inj {ℕ.zero} = ntHelper record { η = λ X → record { _⟨$⟩_ = ⊥-elim ; cong = λ { {()} } } ; commute = λ { _ {()} _ } } ∂Δ-inj {ℕ.suc n} = ntHelper record { η = λ X → record { _⟨$⟩_ = λ (lift b) → lift (hom b) ; cong = λ (lift eq) → lift (Δ-eq (Δ-pointwise eq)) } ; commute = λ f (lift eq) → lift (Δ-eq (Δ-pointwise eq)) } where open Boundary -- Inclusion of n-horns into n-simplicies Λ-inj : ∀ {n} → (k : Fin n) → Λ[ n , k ] ⇒ Δ[ n ] Λ-inj {n = ℕ.suc n} k = ntHelper record { η = λ X → record { _⟨$⟩_ = λ (lift h) → lift (hom h) ; cong = λ (lift eq) → lift (Δ-eq (Δ-pointwise eq)) } ; commute = λ f (lift eq) → lift (Δ-eq (Δ-pointwise eq)) } where open Horn
30.958549
96
0.552803
0ec51501b863b3df2c4d4af0c2b76de06e6aab65
12,927
agda
Agda
Categories/Category/Cartesian.agda
Taneb/agda-categories
6ebc1349ee79669c5c496dcadd551d5bbefd1972
[ "MIT" ]
null
null
null
Categories/Category/Cartesian.agda
Taneb/agda-categories
6ebc1349ee79669c5c496dcadd551d5bbefd1972
[ "MIT" ]
null
null
null
Categories/Category/Cartesian.agda
Taneb/agda-categories
6ebc1349ee79669c5c496dcadd551d5bbefd1972
[ "MIT" ]
null
null
null
{-# OPTIONS --without-K --safe #-} open import Categories.Category -- Defines the following properties of a Category: -- 1. BinaryProducts -- for when a Category has all Binary Products -- 2. Cartesian -- a Cartesian category is a category with all products module Categories.Category.Cartesian {o ℓ e} (𝒞 : Category o ℓ e) where open import Level open import Data.Product using (Σ; _,_; uncurry) open Category 𝒞 open HomReasoning open import Categories.Object.Terminal 𝒞 open import Categories.Object.Product 𝒞 open import Categories.Morphism 𝒞 open import Categories.Morphism.Reasoning 𝒞 open import Categories.Category.Monoidal import Categories.Category.Monoidal.Symmetric as Sym open import Categories.Functor renaming (id to idF) open import Categories.Functor.Bifunctor open import Categories.NaturalTransformation using (ntHelper) open import Categories.NaturalTransformation.NaturalIsomorphism hiding (refl; sym; trans) private variable A B C D X Y Z : Obj f f′ g g′ h i : A ⇒ B record BinaryProducts : Set (levelOfTerm 𝒞) where infixr 7 _×_ infixr 8 _⁂_ infix 11 ⟨_,_⟩ field product : ∀ {A B} → Product A B module product {A} {B} = Product (product {A} {B}) _×_ : Obj → Obj → Obj A × B = Product.A×B (product {A} {B}) ×-comm : A × B ≅ B × A ×-comm = Commutative product product ×-assoc : X × Y × Z ≅ (X × Y) × Z ×-assoc = Associative product product product product open product hiding (⟨_,_⟩; ∘-distribʳ-⟨⟩) public -- define it like this instead of reexporting to redefine fixity ⟨_,_⟩ : X ⇒ A → X ⇒ B → X ⇒ A × B ⟨_,_⟩ = Product.⟨_,_⟩ product _⁂_ : A ⇒ B → C ⇒ D → A × C ⇒ B × D f ⁂ g = [ product ⇒ product ] f × g assocˡ : (A × B) × C ⇒ A × B × C assocˡ = _≅_.to ×-assoc assocʳ : A × B × C ⇒ (A × B) × C assocʳ = _≅_.from ×-assoc assocʳ∘assocˡ : assocʳ {A}{B}{C} ∘ assocˡ {A}{B}{C} ≈ id assocʳ∘assocˡ = Iso.isoʳ (_≅_.iso ×-assoc) assocˡ∘assocʳ : assocˡ {A}{B}{C} ∘ assocʳ {A}{B}{C} ≈ id assocˡ∘assocʳ = Iso.isoˡ (_≅_.iso ×-assoc) ⟨⟩-congʳ : f ≈ f′ → ⟨ f , g ⟩ ≈ ⟨ f′ , g ⟩ ⟨⟩-congʳ pf = ⟨⟩-cong₂ pf refl ⟨⟩-congˡ : g ≈ g′ → ⟨ f , g ⟩ ≈ ⟨ f , g′ ⟩ ⟨⟩-congˡ pf = ⟨⟩-cong₂ refl pf swap : A × B ⇒ B × A swap = ⟨ π₂ , π₁ ⟩ -- TODO: this is probably harder to use than necessary because of this definition. Maybe make a version -- that doesn't have an explicit id in it, too? first : A ⇒ B → A × C ⇒ B × C first f = f ⁂ id second : C ⇒ D → A × C ⇒ A × D second g = id ⁂ g -- Just to make this more obvious π₁∘⁂ : π₁ ∘ (f ⁂ g) ≈ f ∘ π₁ π₁∘⁂ {f = f} {g} = project₁ π₂∘⁂ : π₂ ∘ (f ⁂ g) ≈ g ∘ π₂ π₂∘⁂ {f = f} {g} = project₂ ⁂-cong₂ : f ≈ g → h ≈ i → f ⁂ h ≈ g ⁂ i ⁂-cong₂ = [ product ⇒ product ]×-cong₂ ⁂∘⟨⟩ : (f ⁂ g) ∘ ⟨ f′ , g′ ⟩ ≈ ⟨ f ∘ f′ , g ∘ g′ ⟩ ⁂∘⟨⟩ = [ product ⇒ product ]×∘⟨⟩ first∘⟨⟩ : first f ∘ ⟨ f′ , g′ ⟩ ≈ ⟨ f ∘ f′ , g′ ⟩ first∘⟨⟩ = [ product ⇒ product ]×id∘⟨⟩ second∘⟨⟩ : second g ∘ ⟨ f′ , g′ ⟩ ≈ ⟨ f′ , g ∘ g′ ⟩ second∘⟨⟩ = [ product ⇒ product ]id×∘⟨⟩ ⁂∘⁂ : (f ⁂ g) ∘ (f′ ⁂ g′) ≈ (f ∘ f′) ⁂ (g ∘ g′) ⁂∘⁂ = [ product ⇒ product ⇒ product ]×∘× ⟨⟩∘ : ⟨ f , g ⟩ ∘ h ≈ ⟨ f ∘ h , g ∘ h ⟩ ⟨⟩∘ = [ product ]⟨⟩∘ first∘first : ∀ {C} → first {C = C} f ∘ first g ≈ first (f ∘ g) first∘first = [ product ⇒ product ⇒ product ]×id∘×id second∘second : ∀ {A} → second {A = A} f ∘ second g ≈ second (f ∘ g) second∘second = [ product ⇒ product ⇒ product ]id×∘id× first↔second : first f ∘ second g ≈ second g ∘ first f first↔second = [ product ⇒ product , product ⇒ product ]first↔second firstid : ∀ {f : A ⇒ A} (g : A ⇒ C) → first {C = C} f ≈ id → f ≈ id firstid {f = f} g eq = begin f ≈˘⟨ elimʳ project₁ ⟩ f ∘ π₁ ∘ ⟨ id , g ⟩ ≈⟨ pullˡ fπ₁≈π₁ ⟩ π₁ ∘ ⟨ id , g ⟩ ≈⟨ project₁ ⟩ id ∎ where fπ₁≈π₁ = begin f ∘ π₁ ≈˘⟨ project₁ ⟩ π₁ ∘ first f ≈⟨ refl⟩∘⟨ eq ⟩ π₁ ∘ id ≈⟨ identityʳ ⟩ π₁ ∎ swap∘⟨⟩ : swap ∘ ⟨ f , g ⟩ ≈ ⟨ g , f ⟩ swap∘⟨⟩ {f = f} {g = g} = begin ⟨ π₂ , π₁ ⟩ ∘ ⟨ f , g ⟩ ≈⟨ ⟨⟩∘ ⟩ ⟨ π₂ ∘ ⟨ f , g ⟩ , π₁ ∘ ⟨ f , g ⟩ ⟩ ≈⟨ ⟨⟩-cong₂ project₂ project₁ ⟩ ⟨ g , f ⟩ ∎ swap∘⁂ : swap ∘ (f ⁂ g) ≈ (g ⁂ f) ∘ swap swap∘⁂ {f = f} {g = g} = begin swap ∘ (f ⁂ g) ≈⟨ swap∘⟨⟩ ⟩ ⟨ g ∘ π₂ , f ∘ π₁ ⟩ ≈⟨ sym ⁂∘⟨⟩ ⟩ (g ⁂ f) ∘ swap ∎ swap∘swap : (swap {A}{B}) ∘ (swap {B}{A}) ≈ id swap∘swap = trans swap∘⟨⟩ η assocʳ∘⟨⟩ : assocʳ ∘ ⟨ f , ⟨ g , h ⟩ ⟩ ≈ ⟨ ⟨ f , g ⟩ , h ⟩ assocʳ∘⟨⟩ {f = f} {g = g} {h = h} = begin assocʳ ∘ ⟨ f , ⟨ g , h ⟩ ⟩ ≈⟨ ⟨⟩∘ ⟩ ⟨ ⟨ π₁ , π₁ ∘ π₂ ⟩ ∘ ⟨ f , ⟨ g , h ⟩ ⟩ , (π₂ ∘ π₂) ∘ ⟨ f , ⟨ g , h ⟩ ⟩ ⟩ ≈⟨ ⟨⟩-cong₂ ⟨⟩∘ (pullʳ project₂) ⟩ ⟨ ⟨ π₁ ∘ ⟨ f , ⟨ g , h ⟩ ⟩ , (π₁ ∘ π₂) ∘ ⟨ f , ⟨ g , h ⟩ ⟩ ⟩ , π₂ ∘ ⟨ g , h ⟩ ⟩ ≈⟨ ⟨⟩-cong₂ (⟨⟩-cong₂ project₁ (trans (pullʳ project₂) project₁)) project₂ ⟩ ⟨ ⟨ f , g ⟩ , h ⟩ ∎ assocˡ∘⟨⟩ : assocˡ ∘ ⟨ ⟨ f , g ⟩ , h ⟩ ≈ ⟨ f , ⟨ g , h ⟩ ⟩ assocˡ∘⟨⟩ {f = f} {g = g} {h = h} = begin assocˡ ∘ ⟨ ⟨ f , g ⟩ , h ⟩ ≈⟨ sym (refl ⟩∘⟨ assocʳ∘⟨⟩) ⟩ assocˡ ∘ assocʳ ∘ ⟨ f , ⟨ g , h ⟩ ⟩ ≈⟨ cancelˡ assocˡ∘assocʳ ⟩ ⟨ f , ⟨ g , h ⟩ ⟩ ∎ assocʳ∘⁂ : assocʳ ∘ (f ⁂ (g ⁂ h)) ≈ ((f ⁂ g) ⁂ h) ∘ assocʳ assocʳ∘⁂ {f = f} {g = g} {h = h} = begin assocʳ ∘ (f ⁂ (g ⁂ h)) ≈⟨ refl⟩∘⟨ ⟨⟩-congˡ ⟨⟩∘ ⟩ assocʳ ∘ ⟨ f ∘ π₁ , ⟨ (g ∘ π₁) ∘ π₂ , (h ∘ π₂) ∘ π₂ ⟩ ⟩ ≈⟨ assocʳ∘⟨⟩ ⟩ ⟨ ⟨ f ∘ π₁ , (g ∘ π₁) ∘ π₂ ⟩ , (h ∘ π₂) ∘ π₂ ⟩ ≈⟨ ⟨⟩-cong₂ (⟨⟩-congˡ assoc) assoc ⟩ ⟨ ⟨ f ∘ π₁ , g ∘ π₁ ∘ π₂ ⟩ , h ∘ π₂ ∘ π₂ ⟩ ≈˘⟨ ⟨⟩-congʳ ⁂∘⟨⟩ ⟩ ⟨ (f ⁂ g) ∘ ⟨ π₁ , π₁ ∘ π₂ ⟩ , h ∘ π₂ ∘ π₂ ⟩ ≈˘⟨ ⁂∘⟨⟩ ⟩ ((f ⁂ g) ⁂ h) ∘ assocʳ ∎ assocˡ∘⁂ : assocˡ ∘ ((f ⁂ g) ⁂ h) ≈ (f ⁂ (g ⁂ h)) ∘ assocˡ assocˡ∘⁂ {f = f} {g = g} {h = h} = begin assocˡ ∘ ((f ⁂ g) ⁂ h) ≈⟨ refl⟩∘⟨ ⟨⟩-congʳ ⟨⟩∘ ⟩ assocˡ ∘ ⟨ ⟨ (f ∘ π₁) ∘ π₁ , (g ∘ π₂) ∘ π₁ ⟩ , h ∘ π₂ ⟩ ≈⟨ assocˡ∘⟨⟩ ⟩ ⟨ (f ∘ π₁) ∘ π₁ , ⟨ (g ∘ π₂) ∘ π₁ , h ∘ π₂ ⟩ ⟩ ≈⟨ ⟨⟩-cong₂ assoc (⟨⟩-congʳ assoc) ⟩ ⟨ f ∘ π₁ ∘ π₁ , ⟨ g ∘ π₂ ∘ π₁ , h ∘ π₂ ⟩ ⟩ ≈˘⟨ ⟨⟩-congˡ ⁂∘⟨⟩ ⟩ ⟨ f ∘ π₁ ∘ π₁ , (g ⁂ h) ∘ ⟨ π₂ ∘ π₁ , π₂ ⟩ ⟩ ≈˘⟨ ⁂∘⟨⟩ ⟩ (f ⁂ (g ⁂ h)) ∘ assocˡ ∎ -×- : Bifunctor 𝒞 𝒞 𝒞 -×- = record { F₀ = uncurry _×_ ; F₁ = uncurry _⁂_ ; identity = id×id product ; homomorphism = sym ⁂∘⁂ ; F-resp-≈ = uncurry [ product ⇒ product ]×-cong₂ } -×_ : Obj → Functor 𝒞 𝒞 -×_ = appʳ -×- _×- : Obj → Functor 𝒞 𝒞 _×- = appˡ -×- -- Cartesian monoidal category record Cartesian : Set (levelOfTerm 𝒞) where field terminal : Terminal products : BinaryProducts module terminal = Terminal terminal module products = BinaryProducts products open terminal public open products public ⊤×A≅A : ⊤ × A ≅ A ⊤×A≅A = record { from = π₂ ; to = ⟨ ! , id ⟩ ; iso = record { isoˡ = begin ⟨ ! , id ⟩ ∘ π₂ ≈˘⟨ unique !-unique₂ (cancelˡ project₂) ⟩ ⟨ π₁ , π₂ ⟩ ≈⟨ η ⟩ id ∎ ; isoʳ = project₂ } } A×⊤≅A : A × ⊤ ≅ A A×⊤≅A = record { from = π₁ ; to = ⟨ id , ! ⟩ ; iso = record { isoˡ = begin ⟨ id , ! ⟩ ∘ π₁ ≈˘⟨ unique (cancelˡ project₁) !-unique₂ ⟩ ⟨ π₁ , π₂ ⟩ ≈⟨ η ⟩ id ∎ ; isoʳ = project₁ } } ⊤×--id : NaturalIsomorphism (⊤ ×-) idF ⊤×--id = record { F⇒G = ntHelper record { η = λ _ → π₂ ; commute = λ _ → project₂ } ; F⇐G = ntHelper record { η = λ _ → ⟨ ! , id ⟩ ; commute = λ f → begin ⟨ ! , id ⟩ ∘ f ≈⟨ ⟨⟩∘ ⟩ ⟨ ! ∘ f , id ∘ f ⟩ ≈⟨ ⟨⟩-cong₂ (sym (!-unique _)) identityˡ ⟩ ⟨ ! , f ⟩ ≈˘⟨ ⟨⟩-cong₂ identityˡ identityʳ ⟩ ⟨ id ∘ ! , f ∘ id ⟩ ≈˘⟨ ⟨⟩-cong₂ (pullʳ project₁) (pullʳ project₂) ⟩ ⟨ (id ∘ π₁) ∘ ⟨ ! , id ⟩ , (f ∘ π₂) ∘ ⟨ ! , id ⟩ ⟩ ≈˘⟨ ⟨⟩∘ ⟩ ⟨ id ∘ π₁ , f ∘ π₂ ⟩ ∘ ⟨ ! , id ⟩ ∎ } ; iso = λ _ → _≅_.iso ⊤×A≅A } -×⊤-id : NaturalIsomorphism (-× ⊤) idF -×⊤-id = record { F⇒G = ntHelper record { η = λ _ → π₁ ; commute = λ _ → project₁ } ; F⇐G = ntHelper record { η = λ _ → ⟨ id , ! ⟩ ; commute = λ f → begin ⟨ id , ! ⟩ ∘ f ≈⟨ ⟨⟩∘ ⟩ ⟨ id ∘ f , ! ∘ f ⟩ ≈⟨ ⟨⟩-cong₂ identityˡ (sym (!-unique _)) ⟩ ⟨ f , ! ⟩ ≈˘⟨ ⟨⟩-cong₂ identityʳ identityˡ ⟩ ⟨ f ∘ id , id ∘ ! ⟩ ≈˘⟨ ⟨⟩-cong₂ (pullʳ project₁) (pullʳ project₂) ⟩ ⟨ (f ∘ π₁) ∘ ⟨ id , ! ⟩ , (id ∘ π₂) ∘ ⟨ id , ! ⟩ ⟩ ≈˘⟨ ⟨⟩∘ ⟩ ⟨ f ∘ π₁ , id ∘ π₂ ⟩ ∘ ⟨ id , ! ⟩ ∎ } ; iso = λ _ → _≅_.iso A×⊤≅A } monoidal : Monoidal 𝒞 monoidal = record { ⊗ = -×- ; unit = ⊤ ; unitorˡ = ⊤×A≅A ; unitorʳ = A×⊤≅A ; associator = ≅.sym ×-assoc ; unitorˡ-commute-from = project₂ ; unitorˡ-commute-to = let open NaturalIsomorphism ⊤×--id in ⇐.commute _ ; unitorʳ-commute-from = project₁ ; unitorʳ-commute-to = let open NaturalIsomorphism -×⊤-id in ⇐.commute _ ; assoc-commute-from = assocˡ∘⁂ ; assoc-commute-to = assocʳ∘⁂ ; triangle = begin (id ⁂ π₂) ∘ assocˡ ≈⟨ ⁂∘⟨⟩ ⟩ ⟨ id ∘ π₁ ∘ π₁ , π₂ ∘ ⟨ π₂ ∘ π₁ , π₂ ⟩ ⟩ ≈⟨ ⟨⟩-cong₂ (pullˡ identityˡ) (project₂ ○ (⟺ identityˡ)) ⟩ π₁ ⁂ id ∎ ; pentagon = begin (id ⁂ assocˡ) ∘ assocˡ ∘ (assocˡ ⁂ id) ≈⟨ pullˡ [ product ⇒ product ]id×∘⟨⟩ ⟩ ⟨ π₁ ∘ π₁ , assocˡ ∘ ⟨ π₂ ∘ π₁ , π₂ ⟩ ⟩ ∘ (assocˡ ⁂ id) ≈⟨ ⟨⟩∘ ⟩ ⟨ (π₁ ∘ π₁) ∘ (assocˡ ⁂ id) , (assocˡ ∘ ⟨ π₂ ∘ π₁ , π₂ ⟩) ∘ (assocˡ ⁂ id) ⟩ ≈⟨ ⟨⟩-cong₂ (pullʳ project₁) (pullʳ ⟨⟩∘) ⟩ ⟨ π₁ ∘ assocˡ ∘ π₁ , assocˡ ∘ ⟨ (π₂ ∘ π₁) ∘ (assocˡ ⁂ id) , π₂ ∘ (assocˡ ⁂ id) ⟩ ⟩ ≈⟨ ⟨⟩-cong₂ (pullˡ project₁) (∘-resp-≈ʳ (⟨⟩-cong₂ (pullʳ project₁) project₂)) ⟩ ⟨ (π₁ ∘ π₁) ∘ π₁ , assocˡ ∘ ⟨ π₂ ∘ assocˡ ∘ π₁ , id ∘ π₂ ⟩ ⟩ ≈⟨ ⟨⟩-cong₂ assoc (∘-resp-≈ʳ (⟨⟩-cong₂ (pullˡ project₂) identityˡ)) ⟩ ⟨ π₁ ∘ π₁ ∘ π₁ , assocˡ ∘ ⟨ ⟨ π₂ ∘ π₁ , π₂ ⟩ ∘ π₁ , π₂ ⟩ ⟩ ≈⟨ ⟨⟩-congˡ ⟨⟩∘ ⟩ ⟨ π₁ ∘ π₁ ∘ π₁ , ⟨ (π₁ ∘ π₁) ∘ ⟨ ⟨ π₂ ∘ π₁ , π₂ ⟩ ∘ π₁ , π₂ ⟩ , ⟨ π₂ ∘ π₁ , π₂ ⟩ ∘ ⟨ ⟨ π₂ ∘ π₁ , π₂ ⟩ ∘ π₁ , π₂ ⟩ ⟩ ⟩ ≈⟨ ⟨⟩-congˡ (⟨⟩-cong₂ (pullʳ project₁) ⟨⟩∘) ⟩ ⟨ π₁ ∘ π₁ ∘ π₁ , ⟨ π₁ ∘ ⟨ π₂ ∘ π₁ , π₂ ⟩ ∘ π₁ , ⟨ (π₂ ∘ π₁) ∘ ⟨ ⟨ π₂ ∘ π₁ , π₂ ⟩ ∘ π₁ , π₂ ⟩ , π₂ ∘ ⟨ ⟨ π₂ ∘ π₁ , π₂ ⟩ ∘ π₁ , π₂ ⟩ ⟩ ⟩ ⟩ ≈⟨ ⟨⟩-congˡ (⟨⟩-cong₂ (pullˡ project₁) (⟨⟩-cong₂ (pullʳ project₁) project₂)) ⟩ ⟨ π₁ ∘ π₁ ∘ π₁ , ⟨ (π₂ ∘ π₁) ∘ π₁ , ⟨ π₂ ∘ ⟨ π₂ ∘ π₁ , π₂ ⟩ ∘ π₁ , π₂ ⟩ ⟩ ⟩ ≈⟨ ⟨⟩-congˡ (⟨⟩-cong₂ assoc (⟨⟩-congʳ (pullˡ project₂))) ⟩ ⟨ π₁ ∘ π₁ ∘ π₁ , ⟨ π₂ ∘ π₁ ∘ π₁ , ⟨ π₂ ∘ π₁ , π₂ ⟩ ⟩ ⟩ ≈˘⟨ ⟨⟩-congˡ (⟨⟩-cong₂ (pullʳ project₁) project₂) ⟩ ⟨ π₁ ∘ π₁ ∘ π₁ , ⟨ (π₂ ∘ π₁) ∘ assocˡ , π₂ ∘ assocˡ ⟩ ⟩ ≈˘⟨ ⟨⟩-cong₂ (pullʳ project₁) ⟨⟩∘ ⟩ ⟨ (π₁ ∘ π₁) ∘ assocˡ , ⟨ π₂ ∘ π₁ , π₂ ⟩ ∘ assocˡ ⟩ ≈˘⟨ ⟨⟩∘ ⟩ assocˡ ∘ assocˡ ∎ } module monoidal = Monoidal monoidal open monoidal using (_⊗₁_) open Sym monoidal symmetric : Symmetric symmetric = symmetricHelper record { braiding = record { F⇒G = ntHelper record { η = λ _ → swap ; commute = λ _ → swap∘⁂ } ; F⇐G = ntHelper record { η = λ _ → swap ; commute = λ _ → swap∘⁂ } ; iso = λ _ → record { isoˡ = swap∘swap ; isoʳ = swap∘swap } } ; commutative = swap∘swap ; hexagon = begin id ⊗₁ swap ∘ assocˡ ∘ swap ⊗₁ id ≈⟨ refl⟩∘⟨ refl⟩∘⟨ ⟨⟩-congʳ ⟨⟩∘ ⟩ id ⊗₁ swap ∘ assocˡ ∘ ⟨ ⟨ π₂ ∘ π₁ , π₁ ∘ π₁ ⟩ , id ∘ π₂ ⟩ ≈⟨ refl⟩∘⟨ assocˡ∘⟨⟩ ⟩ id ⊗₁ swap ∘ ⟨ π₂ ∘ π₁ , ⟨ π₁ ∘ π₁ , id ∘ π₂ ⟩ ⟩ ≈⟨ ⁂∘⟨⟩ ⟩ ⟨ id ∘ π₂ ∘ π₁ , swap ∘ ⟨ π₁ ∘ π₁ , id ∘ π₂ ⟩ ⟩ ≈⟨ ⟨⟩-cong₂ identityˡ swap∘⟨⟩ ⟩ ⟨ π₂ ∘ π₁ , ⟨ id ∘ π₂ , π₁ ∘ π₁ ⟩ ⟩ ≈⟨ ⟨⟩-congˡ (⟨⟩-congʳ identityˡ) ⟩ ⟨ π₂ ∘ π₁ , ⟨ π₂ , π₁ ∘ π₁ ⟩ ⟩ ≈˘⟨ assocˡ∘⟨⟩ ⟩ assocˡ ∘ ⟨ ⟨ π₂ ∘ π₁ , π₂ ⟩ , π₁ ∘ π₁ ⟩ ≈˘⟨ refl ⟩∘⟨ swap∘⟨⟩ ⟩ assocˡ ∘ swap ∘ assocˡ ∎ } module symmetric = Symmetric symmetric open symmetric public
34.289125
142
0.418968
2e6a28a38cffcf7181ab89e205ea66509b6cd46c
720
agda
Agda
test/Fail/Issue4637.agda
mdimjasevic/agda
8fb548356b275c7a1e79b768b64511ae937c738b
[ "BSD-3-Clause" ]
1,989
2015-01-09T23:51:16.000Z
2022-03-30T18:20:48.000Z
test/Fail/Issue4637.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
4,066
2015-01-10T11:24:51.000Z
2022-03-31T21:14:49.000Z
test/Fail/Issue4637.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
371
2015-01-03T14:04:08.000Z
2022-03-30T19:00:30.000Z
-- Andreas, 2020-05-08, issue #4637 -- Print record pattern (in with-function) in termination error. -- {-# OPTIONS -v reify:60 #-} record R : Set where pattern; inductive field foo : R postulate bar : R → R test : R → R test r with bar r test r | record { foo = x } with bar x test r | record { foo = x } | _ = test x -- WAS: -- Termination checking failed for the following functions: -- test -- Problematic calls: -- test r | bar r -- Issue4637.with-14 r (recCon-NOT-PRINTED x) -- | bar x -- test x -- EXPECTED: -- Termination checking failed for the following functions: -- test -- Problematic calls: -- test r | bar r -- Issue4637.with-14 r (record { foo = x }) -- | bar x -- test x
20.571429
64
0.625
2e9d8c38fc50164c72d6944fed168843e8286afe
357
agda
Agda
test/interaction/Issue2273.agda
mdimjasevic/agda
8fb548356b275c7a1e79b768b64511ae937c738b
[ "BSD-3-Clause" ]
1,989
2015-01-09T23:51:16.000Z
2022-03-30T18:20:48.000Z
test/interaction/Issue2273.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
4,066
2015-01-10T11:24:51.000Z
2022-03-31T21:14:49.000Z
test/interaction/Issue2273.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
371
2015-01-03T14:04:08.000Z
2022-03-30T19:00:30.000Z
-- Jesper, 2018-10-16: When solving constraints, unsolved metas should -- be turned into interaction holes. Metas that refer to an existing -- interaction hole should be printed as _ instead. postulate _==_ : {A : Set} (a b : A) → Set P : Set → Set f : {A : Set} {a : A} {b : A} → P (a == b) x : P {!!} x = f y : P {!!} y = f {a = {!!}} {b = {!!}}
23.8
70
0.557423
1ae2e0ba4d639994f72b276946faf787b51c695d
7,180
agda
Agda
src/Web/Semantic/Util.agda
bblfish/agda-web-semantic
38fbc3af7062ba5c3d7d289b2b4bcfb995d99057
[ "MIT" ]
1
2022-02-22T09:43:23.000Z
2022-02-22T09:43:23.000Z
src/Web/Semantic/Util.agda
bblfish/agda-web-semantic
38fbc3af7062ba5c3d7d289b2b4bcfb995d99057
[ "MIT" ]
null
null
null
src/Web/Semantic/Util.agda
bblfish/agda-web-semantic
38fbc3af7062ba5c3d7d289b2b4bcfb995d99057
[ "MIT" ]
null
null
null
{-# OPTIONS --universe-polymorphism #-} open import Data.Bool using ( Bool ; true ; false ; _∧_ ) open import Data.Empty using () open import Data.List using ( List ; [] ; _∷_ ; _++_ ; map ) open import Data.List.Relation.Unary.Any using ( here ; there ) open import Data.List.Membership.Propositional using () open import Data.Sum using ( _⊎_ ; inj₁ ; inj₂ ) open import Data.Product using ( ∃ ; ∄ ; _×_ ; _,_ ) open import Data.Unit using () open import Level using ( zero ) open import Relation.Binary using () open import Relation.Binary.PropositionalEquality using ( _≡_ ; refl ) open import Relation.Nullary using ( Dec ; yes ; no ) open import Relation.Unary using ( _∈_ ; _⊆_ ) module Web.Semantic.Util where infixr 9 _∘_ id : ∀ {X : Set} → X → X id x = x _∘_ : ∀ {X Y Z : Set} → (Y → Z) → (X → Y) → (X → Z) (f ∘ g) = λ x → f (g x) Setoid : Set₁ Setoid = Relation.Binary.Setoid zero zero -- Why use Subset rather than Pred from Relation.Unary of stdlib -- https://agda.github.io/agda-stdlib/Relation.Unary.html -- Does the code require using with-K which is the default ? Subset : Set → Set₁ Subset X = X → Set -- ⁅ x ⁆ the singleton set -- a similar construct is available in Relation.Unary stdlib as {_} -- used in order to find provably equivalent representations ⁅_⁆ : ∀ {X} → X → Subset X ⁅ x ⁆ y = x ≡ y ⊆-refl : ∀ {X} (P : Subset X) → (P ⊆ P) ⊆-refl P x∈P = x∈P _⁻¹ : ∀ {X Y : Set} → Subset (X × Y) → Subset (Y × X) (R ⁻¹) (y , x) = R (x , y) -- Some proofs are classical, and depend on excluded middle. ExclMiddle : Set₁ ExclMiddle = ∀ (X : Set) → Dec X ExclMiddle₁ : Set₂ ExclMiddle₁ = ∀ (X : Set₁) → Dec X smaller-excl-middle : ExclMiddle₁ → ExclMiddle smaller-excl-middle excl-middle₁ X = X? where data Large : Set₁ where large : X → Large X? : Dec X X? with excl-middle₁ Large X? | yes (large x) = yes x X? | no ¬x = no (λ x → ¬x (large x)) -- Some nameclashes between the standard library and semantic web terminology: -- ⊤ and ⊥ are used for concepts, and T is used to range over T-Boxes. open Data.Bool public using () renaming ( T to □ ) open Data.Empty public using () renaming ( ⊥ to False ; ⊥-elim to elim ) open Data.Unit public using ( tt ) renaming ( ⊤ to True ) □-proj₁ : ∀ {b c} → □(b ∧ c) → □ b □-proj₁ {true} □c = tt □-proj₁ {false} () □-proj₂ : ∀ {b c} → □(b ∧ c) → □ c □-proj₂ {true} □c = □c □-proj₂ {false} () -- Convert back and forth from Dec and Bool. is : ∀ {ℓ} {X : Set ℓ} → Dec X → Bool is (yes _) = true is (no _) = false is✓ : ∀ {ℓ} {X : Set ℓ} {x : Dec X} → □(is x) → X is✓ {ℓ} {X} {yes x} _ = x is✓ {ℓ} {X} {no _} () is! : ∀ {ℓ} {X : Set ℓ} {x : Dec X} → X → □(is x) is! {ℓ} {X} {yes _} x = tt is! {ℓ} {X} {no ¬x} x = ¬x x -- Finite sets are ones backed by a list open Data.List.Membership.Propositional public using () renaming ( _∈_ to _∈ˡ_ ) -- A Finite Set backed by a List Finite : Set → Set Finite X = ∃ λ xs → ∀ (x : X) → (x ∈ˡ xs) False∈Fin : False ∈ Finite False∈Fin = ([] , λ ()) ⊎-resp-Fin : ∀ {X Y} → (X ∈ Finite) → (Y ∈ Finite) → ((X ⊎ Y) ∈ Finite) ⊎-resp-Fin {X} {Y} (xs , ∀x∙x∈xs) (ys , ∀y∙y∈ys) = ((map inj₁ xs ++ map inj₂ ys) , lemma) where lemma₁ : ∀ {x : X} {xs : List X} → (x ∈ˡ xs) → (inj₁ x ∈ˡ (map inj₁ xs ++ map inj₂ ys)) lemma₁ (here refl) = here refl lemma₁ (there x∈xs) = there (lemma₁ x∈xs) lemma₂ : ∀ (xs : List X) {y : Y} {ys : List Y} → (y ∈ˡ ys) → (inj₂ y ∈ˡ (map inj₁ xs ++ map inj₂ ys)) lemma₂ [] (here refl) = here refl lemma₂ [] (there y∈ys) = there (lemma₂ [] y∈ys) lemma₂ (x ∷ xs) y∈ys = there (lemma₂ xs y∈ys) lemma : ∀ x → (x ∈ˡ (map inj₁ xs ++ map inj₂ ys)) lemma (inj₁ x) = lemma₁ (∀x∙x∈xs x) lemma (inj₂ y) = lemma₂ xs (∀y∙y∈ys y) -- symmetric monoidal structure of sum _⟨⊎⟩_ : ∀ {W X Y Z : Set} → (W → X) → (Y → Z) → (W ⊎ Y) → (X ⊎ Z) _⟨⊎⟩_ f g (inj₁ x) = inj₁ (f x) _⟨⊎⟩_ f g (inj₂ y) = inj₂ (g y) _≡⊎≡_ : ∀ {X Y Z : Set} {f g : (X ⊎ Y) → Z} → (∀ x → (f (inj₁ x) ≡ g (inj₁ x))) → (∀ x → (f (inj₂ x) ≡ g (inj₂ x))) → ∀ x → (f x ≡ g x) (f₁≡g₁ ≡⊎≡ f₂≡g₂) (inj₁ x) = f₁≡g₁ x (f₁≡g₁ ≡⊎≡ f₂≡g₂) (inj₂ y) = f₂≡g₂ y ⊎-swap : ∀ {X Y : Set} → (X ⊎ Y) → (Y ⊎ X) ⊎-swap (inj₁ x) = inj₂ x ⊎-swap (inj₂ y) = inj₁ y ⊎-assoc : ∀ {X Y Z : Set} → ((X ⊎ Y) ⊎ Z) → (X ⊎ (Y ⊎ Z)) ⊎-assoc (inj₁ (inj₁ x)) = inj₁ x ⊎-assoc (inj₁ (inj₂ y)) = inj₂ (inj₁ y) ⊎-assoc (inj₂ z) = inj₂ (inj₂ z) ⊎-assoc⁻¹ : ∀ {X Y Z : Set} → (X ⊎ (Y ⊎ Z)) → ((X ⊎ Y) ⊎ Z) ⊎-assoc⁻¹ (inj₁ x) = inj₁ (inj₁ x) ⊎-assoc⁻¹ (inj₂ (inj₁ y)) = inj₁ (inj₂ y) ⊎-assoc⁻¹ (inj₂ (inj₂ z)) = inj₂ z ⊎-unit₁ : ∀ {X : Set} → (False ⊎ X) → X ⊎-unit₁ (inj₁ ()) ⊎-unit₁ (inj₂ x) = x ⊎-unit₂ : ∀ {X : Set} → (X ⊎ False) → X ⊎-unit₂ (inj₁ x) = x ⊎-unit₂ (inj₂ ()) inj⁻¹ : ∀ {X : Set} → (X ⊎ X) → X inj⁻¹ (inj₁ x) = x inj⁻¹ (inj₂ x) = x infix 6 _⊕_⊕_ {- A division of nodes X used in an ABox into three types. See "Integrity Constraints for Linked Data" + the Imported nodes of an ABox i.e. URIs or URLs defined in another ABox + the Blank Nodes (that cannot be referenced externally) + the Exported Nodes (in RDF those that can be written as relative URLs) -} data _⊕_⊕_ (X V Y : Set) : Set where inode : (x : X) → (X ⊕ V ⊕ Y) -- Imported node bnode : (v : V) → (X ⊕ V ⊕ Y) -- Blank node enode : (y : Y) → (X ⊕ V ⊕ Y) -- Exported node _⟨⊕⟩_⟨⊕⟩_ : ∀ {U V W X Y Z} → (W → X) → (U → V) → (Y → Z) → (W ⊕ U ⊕ Y) → (X ⊕ V ⊕ Z) (f ⟨⊕⟩ g ⟨⊕⟩ h) (inode w) = inode (f w) (f ⟨⊕⟩ g ⟨⊕⟩ h) (bnode u) = bnode (g u) (f ⟨⊕⟩ g ⟨⊕⟩ h) (enode y) = enode (h y) _[⊕]_[⊕]_ : ∀ {X V Y Z : Set} → (X → Z) → (V → Z) → (Y → Z) → (X ⊕ V ⊕ Y) → Z (f [⊕] g [⊕] h) (inode x) = f x (f [⊕] g [⊕] h) (bnode v) = g v (f [⊕] g [⊕] h) (enode y) = h y left : ∀ {V W X Y Z} → (X ⊕ V ⊕ Y) → (X ⊕ (V ⊕ Y ⊕ W) ⊕ Z) left (inode x) = inode x left (bnode v) = bnode (inode v) left (enode y) = bnode (bnode y) right : ∀ {V W X Y Z} → (Y ⊕ W ⊕ Z) → (X ⊕ (V ⊕ Y ⊕ W) ⊕ Z) right (inode y) = bnode (bnode y) right (bnode w) = bnode (enode w) right (enode z) = enode z hmerge : ∀ {V W X Y Z A : Set} → ((X ⊕ V ⊕ Y) → A) → ((Y ⊕ W ⊕ Z) → A) → (X ⊕ (V ⊕ Y ⊕ W) ⊕ Z) → A hmerge f g (inode x) = f (inode x) hmerge f g (bnode (inode v)) = f (bnode v) hmerge f g (bnode (bnode y)) = g (inode y) hmerge f g (bnode (enode w)) = g (bnode w) hmerge f g (enode z) = g (enode z) →-dist-⊕ : ∀ {V X Y Z : Set} → ((X ⊕ V ⊕ Y) → Z) → ((X → Z) × (V → Z) × (Y → Z)) →-dist-⊕ i = ((i ∘ inode) , (i ∘ bnode) , (i ∘ enode)) up : ∀ {V₁ V₂ X₁ X₂ Y₁ Y₂} → (X₁ ⊕ V₁ ⊕ Y₁) → ((X₁ ⊎ X₂) ⊕ (V₁ ⊎ V₂) ⊕ (Y₁ ⊎ Y₂)) up (inode x) = inode (inj₁ x) up (bnode v) = bnode (inj₁ v) up (enode y) = enode (inj₁ y) down : ∀ {V₁ V₂ X₁ X₂ Y₁ Y₂} → (X₂ ⊕ V₂ ⊕ Y₂) → ((X₁ ⊎ X₂) ⊕ (V₁ ⊎ V₂) ⊕ (Y₁ ⊎ Y₂)) down (inode x) = inode (inj₂ x) down (bnode v) = bnode (inj₂ v) down (enode y) = enode (inj₂ y) vmerge : ∀ {V₁ V₂ X₁ X₂ Y₁ Y₂ A : Set} → ((X₁ ⊕ V₁ ⊕ Y₁) → A) → ((X₂ ⊕ V₂ ⊕ Y₂) → A) → ((X₁ ⊎ X₂) ⊕ (V₁ ⊎ V₂) ⊕ (Y₁ ⊎ Y₂)) → A vmerge j k (inode (inj₁ x)) = j (inode x) vmerge j k (inode (inj₂ x)) = k (inode x) vmerge j k (bnode (inj₁ v)) = j (bnode v) vmerge j k (bnode (inj₂ v)) = k (bnode v) vmerge j k (enode (inj₁ y)) = j (enode y) vmerge j k (enode (inj₂ y)) = k (enode y)
30.683761
81
0.533844
1208cfc56c1649cf80a549c833e6932b2f9f9609
1,942
agda
Agda
src/Categories/Category/Finite/Fin/Construction/Discrete.agda
jaykru/agda-categories
a4053cf700bcefdf73b857c3352f1eae29382a60
[ "MIT" ]
279
2019-06-01T14:36:40.000Z
2022-03-22T00:40:14.000Z
src/Categories/Category/Finite/Fin/Construction/Discrete.agda
seanpm2001/agda-categories
d9e4f578b126313058d105c61707d8c8ae987fa8
[ "MIT" ]
236
2019-06-01T14:53:54.000Z
2022-03-28T14:31:43.000Z
src/Categories/Category/Finite/Fin/Construction/Discrete.agda
seanpm2001/agda-categories
d9e4f578b126313058d105c61707d8c8ae987fa8
[ "MIT" ]
64
2019-06-02T16:58:15.000Z
2022-03-14T02:00:59.000Z
{-# OPTIONS --without-K --safe #-} module Categories.Category.Finite.Fin.Construction.Discrete where open import Data.Nat.Base using (ℕ) open import Data.Fin.Base using (Fin; suc) open import Data.Fin.Patterns open import Relation.Binary.PropositionalEquality.Core as ≡ using (_≡_ ; refl) open import Categories.Category.Finite.Fin open import Categories.Category.Core using (Category) private card : ∀ {n} (j k : Fin n) → ℕ card {ℕ.suc n} 0F 0F = 1 card {ℕ.suc n} 0F (suc k) = 0 card {ℕ.suc n} (suc j) 0F = 0 card {ℕ.suc n} (suc j) (suc k) = card j k id : ∀ {n} (a : Fin n) → Fin (card a a) id {ℕ.suc n} 0F = 0F id {ℕ.suc n} (suc a) = id a comp : ∀ n {a b c : Fin n} → Fin (card b c) → Fin (card a b) → Fin (card a c) comp (ℕ.suc n) {0F} {0F} {0F} f g = 0F comp (ℕ.suc n) {suc a} {suc b} {suc c} f g = comp n f g assoc : ∀ n {a b c d : Fin n} {f : Fin (card a b)} {g : Fin (card b c)} {h : Fin (card c d)} → (comp n (comp n h g) f) ≡ comp n h (comp n g f) assoc (ℕ.suc n) {0F} {0F} {0F} {0F} {f} {g} {h} = refl assoc (ℕ.suc n) {suc a} {suc b} {suc c} {suc d} {f} {g} {h} = assoc n identityˡ : ∀ n {a b : Fin n} {f : Fin (card a b)} → comp n (id b) f ≡ f identityˡ (ℕ.suc n) {0F} {0F} {0F} = refl identityˡ (ℕ.suc n) {suc a} {suc b} {f} = identityˡ n identityʳ : ∀ n {a b : Fin n} {f : Fin (card a b)} → comp n f (id a) ≡ f identityʳ (ℕ.suc n) {0F} {0F} {0F} = refl identityʳ (ℕ.suc n) {suc a} {suc b} {f} = identityʳ n module _ (n : ℕ) where DiscreteShape : FinCatShape DiscreteShape = shapeHelper record { size = n ; ∣_⇒_∣ = card {n} ; id = id {n} _ ; _∘_ = comp n ; assoc = assoc n ; identityˡ = identityˡ n ; identityʳ = identityʳ n } Discrete : ∀ n → Category _ _ _ Discrete n = FinCategory (DiscreteShape n) module Discrete n = Category (Discrete n)
32.915254
79
0.549434
2946f41ff48068156969fd2d2ee891a64e79f978
1,954
agda
Agda
test/Succeed/Issue1323.agda
pthariensflame/agda
222c4c64b2ccf8e0fc2498492731c15e8fef32d4
[ "BSD-3-Clause" ]
3
2015-03-28T14:51:03.000Z
2015-12-07T20:14:00.000Z
test/Succeed/Issue1323.agda
Blaisorblade/Agda
802a28aa8374f15fe9d011ceb80317fdb1ec0949
[ "BSD-3-Clause" ]
null
null
null
test/Succeed/Issue1323.agda
Blaisorblade/Agda
802a28aa8374f15fe9d011ceb80317fdb1ec0949
[ "BSD-3-Clause" ]
1
2019-03-05T20:02:38.000Z
2019-03-05T20:02:38.000Z
data _≡_ {A : Set} (x : A) : A → Set where refl : x ≡ x data Maybe (A : Set) : Set where nothing : Maybe A just : A → Maybe A postulate String : Set {-# BUILTIN STRING String #-} infix 1000 ♯_ postulate ∞ : ∀ {a} (A : Set a) → Set a ♯_ : ∀ {a} {A : Set a} → A → ∞ A ♭ : ∀ {a} {A : Set a} → ∞ A → A {-# BUILTIN INFINITY ∞ #-} {-# BUILTIN SHARP ♯_ #-} {-# BUILTIN FLAT ♭ #-} infixr 5 _∷_ data Colist (A : Set) : Set where [] : Colist A _∷_ : (x : A) (xs : ∞ (Colist A)) → Colist A postulate Char : Set {-# BUILTIN CHAR Char #-} Costring : Set Costring = Colist Char data ℕ : Set where zero : ℕ suc : ℕ → ℕ {-# BUILTIN NATURAL ℕ #-} data List {a} (A : Set a) : Set a where [] : List A _∷_ : (x : A) (xs : List A) → List A {-# BUILTIN LIST List #-} {-# BUILTIN NIL [] #-} {-# BUILTIN CONS _∷_ #-} private primitive primStringAppend : String → String → String primStringToList : String → List Char primStringFromList : List Char → String infixr 5 _++_ _++_ : String → String → String _++_ = primStringAppend toList : String → List Char toList = primStringToList fromList : List Char → String fromList = primStringFromList fromListToColist : {A : Set} → List A → Colist A fromListToColist [] = [] fromListToColist (x ∷ xs) = x ∷ ♯ fromListToColist xs toCostring : String → Costring toCostring s = fromListToColist (toList s) ------------------------------------------------------------------------ costringToString : Costring → ℕ → Maybe String costringToString [] _ = just "" costringToString (x ∷ xs) 0 with ♭ xs ... | [] = just (fromList (x ∷ [])) ... | _ ∷ _ = nothing costringToString (x ∷ xs) (suc n) with costringToString (♭ xs) n ... | nothing = nothing ... | just xs′ = just (fromList (x ∷ []) ++ xs′) test0 : costringToString (toCostring "") 0 ≡ just "" test0 = refl test1 : costringToString (toCostring "apa") 3 ≡ just "apa" test1 = refl
21.23913
72
0.56653
501745672a19245df3927451a938cae7e97bb2e2
1,317
agda
Agda
benchmark/ac/Bool.agda
mdimjasevic/agda
8fb548356b275c7a1e79b768b64511ae937c738b
[ "BSD-3-Clause" ]
1,989
2015-01-09T23:51:16.000Z
2022-03-30T18:20:48.000Z
benchmark/ac/Bool.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
4,066
2015-01-10T11:24:51.000Z
2022-03-31T21:14:49.000Z
benchmark/ac/Bool.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
371
2015-01-03T14:04:08.000Z
2022-03-30T19:00:30.000Z
module Bool where import Logic open Logic data Bool : Set where false : Bool true : Bool {-# BUILTIN BOOL Bool #-} {-# BUILTIN FALSE false #-} {-# BUILTIN TRUE true #-} infixr 5 _&&_ _&&_ : Bool -> Bool -> Bool true && x = x false && _ = false not : Bool -> Bool not true = false not false = true IsTrue : Bool -> Set IsTrue true = True IsTrue false = False IsFalse : Bool -> Set IsFalse x = IsTrue (not x) module BoolEq where _==_ : Bool -> Bool -> Bool true == x = x false == x = not x subst : {x y : Bool}(P : Bool -> Set) -> IsTrue (x == y) -> P x -> P y subst {true}{true} _ _ px = px subst {false}{false} _ _ px = px subst {true}{false} _ () _ subst {false}{true} _ () _ isTrue== : {x : Bool} -> IsTrue x -> IsTrue (x == true) isTrue== {true} _ = tt isTrue== {false} () infix 1 if_then_else_ if_then_else_ : {A : Set} -> Bool -> A -> A -> A if true then x else y = x if false then x else y = y open BoolEq if'_then_else_ : {A : Set} -> (x : Bool) -> (IsTrue x -> A) -> (IsFalse x -> A) -> A if' true then f else g = f tt if' false then f else g = g tt isTrue&&₁ : {x y : Bool} -> IsTrue (x && y) -> IsTrue x isTrue&&₁ {true} _ = tt isTrue&&₁ {false} () isTrue&&₂ : {x y : Bool} -> IsTrue (x && y) -> IsTrue y isTrue&&₂ {true} p = p isTrue&&₂ {false} ()
19.367647
84
0.563402
507084a9a4a8429e83bf0ae87ace97cf134f1389
300
agda
Agda
test/Succeed/Issue1810.agda
mdimjasevic/agda
8fb548356b275c7a1e79b768b64511ae937c738b
[ "BSD-3-Clause" ]
1,989
2015-01-09T23:51:16.000Z
2022-03-30T18:20:48.000Z
test/Succeed/Issue1810.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
4,066
2015-01-10T11:24:51.000Z
2022-03-31T21:14:49.000Z
test/Succeed/Issue1810.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
371
2015-01-03T14:04:08.000Z
2022-03-30T19:00:30.000Z
postulate Bool : Set D : Bool → Set f : (a : Bool) → D a ⟦_⟧ : ∀ {a} → D a → Bool record State : Set where field bool : Bool open State {{...}} postulate guard : {S : Set} → ({{_ : S}} → Bool) → S test : State test = guard ⟦ f bool ⟧ -- doesn't work, used to work in agda 2.4
16.666667
65
0.523333
d0a1ec46683e5c0e77962e4bff6853f8d583b065
1,158
agda
Agda
examples/Sized/SelfRef.agda
agda/ooAgda
7cc45e0148a4a508d20ed67e791544c30fecd795
[ "MIT" ]
23
2016-06-19T12:57:55.000Z
2020-10-12T23:15:25.000Z
examples/Sized/SelfRef.agda
agda/ooAgda
7cc45e0148a4a508d20ed67e791544c30fecd795
[ "MIT" ]
null
null
null
examples/Sized/SelfRef.agda
agda/ooAgda
7cc45e0148a4a508d20ed67e791544c30fecd795
[ "MIT" ]
2
2018-09-01T15:02:37.000Z
2022-03-12T11:41:00.000Z
module Sized.SelfRef where open import Data.Product open import Data.String.Base open import Size open import SizedIO.Object open import SizedIO.IOObject open import SizedIO.ConsoleObject open import SizedIO.Base open import SizedIO.Console hiding (main) open import NativeIO data AMethod : Set where print : AMethod m1 : AMethod m2 : AMethod AResult : (c : AMethod) → Set AResult _ = Unit aI : Interface Method aI = AMethod Result aI = AResult aC : (i : Size) → Set aC i = ConsoleObject i aI -- -- Self Referential: method 'm1' calls method 'm2' -- {-# NON_TERMINATING #-} aP : ∀{i} (s : String) → aC i method (aP s) print = exec1 (putStrLn s) >> return (_ , aP s) method (aP s) m1 = exec1 (putStrLn s) >> method (aP s) m2 >>= λ{ (_ , c₀) → return (_ , c₀) } method (aP s) m2 = return (_ , aP (s ++ "->m2")) program : String → IOConsole ∞ Unit program arg = let c₀ = aP ("start̄") in method c₀ m1 >>= λ{ (_ , c₁) → --- ===> m1 called, then m2 prints out text method c₁ print >>= λ{ (_ , c₂) → exec1 (putStrLn "end") }} main : NativeIO Unit main = translateIOConsole (program "")
19.627119
79
0.626079
4138bf0f38771843719bdf47746869e4e0a0d890
2,123
agda
Agda
test/Succeed/Issue89.agda
mdimjasevic/agda
8fb548356b275c7a1e79b768b64511ae937c738b
[ "BSD-3-Clause" ]
1,989
2015-01-09T23:51:16.000Z
2022-03-30T18:20:48.000Z
test/Succeed/Issue89.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
4,066
2015-01-10T11:24:51.000Z
2022-03-31T21:14:49.000Z
test/Succeed/Issue89.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
371
2015-01-03T14:04:08.000Z
2022-03-30T19:00:30.000Z
{-# OPTIONS --guardedness #-} -- {-# OPTIONS --show-implicit #-} module Issue89 where open import Common.Coinduction renaming (∞ to ∞_) ------------------------------------------------------------------------ -- Streams infixr 5 _≺_ data Stream (A : Set) : Set where _≺_ : (x : A) (xs : ∞ (Stream A)) -> Stream A head : forall {A} -> Stream A -> A head (x ≺ xs) = x tail : forall {A} -> Stream A -> Stream A tail (x ≺ xs) = ♭ xs ------------------------------------------------------------------------ -- Stream programs infix 8 _∞ infixr 5 _⋎_ infix 4 ↓_ mutual data Stream′ A : Set1 where _≺_ : (x : A) (xs : ∞ (StreamProg A)) -> Stream′ A data StreamProg (A : Set) : Set1 where ↓_ : (xs : Stream′ A) -> StreamProg A _∞ : (x : A) -> StreamProg A _⋎_ : (xs ys : StreamProg A) -> StreamProg A head′ : ∀ {A} → Stream′ A → A head′ (x ≺ xs) = x tail′ : ∀ {A} → Stream′ A → StreamProg A tail′ (x ≺ xs) = ♭ xs P⇒′ : forall {A} -> StreamProg A -> Stream′ A P⇒′ (↓ xs) = xs P⇒′ (x ∞) = x ≺ ♯ (x ∞) P⇒′ (xs ⋎ ys) with P⇒′ xs P⇒′ (xs ⋎ ys) | xs′ = head′ xs′ ≺ ♯ (ys ⋎ tail′ xs′) mutual ′⇒ : forall {A} -> Stream′ A -> Stream A ′⇒ (x ≺ xs) = x ≺ ♯ P⇒ (♭ xs) P⇒ : forall {A} -> StreamProg A -> Stream A P⇒ xs = ′⇒ (P⇒′ xs) ------------------------------------------------------------------------ -- Stream equality infix 4 _≡_ _≈_ _≊_ data _≡_ {a : Set} (x : a) : a -> Set where ≡-refl : x ≡ x data _≈_ {A} (xs ys : Stream A) : Set where _≺_ : (x≡ : head xs ≡ head ys) (xs≈ : ∞ (tail xs ≈ tail ys)) -> xs ≈ ys _≊_ : forall {A} (xs ys : StreamProg A) -> Set xs ≊ ys = P⇒ xs ≈ P⇒ ys foo : forall {A} (x : A) -> x ∞ ⋎ x ∞ ≊ x ∞ foo x = ≡-refl ≺ ♯ foo x -- The first goal has goal type -- head (′⇒ (x ≺ x ∞ ⋎ x ∞)) ≡ head (′⇒ (x ≺ x ∞)). -- The normal form of the left-hand side is x, and the normal form of -- the right-hand side is x (both according to Agda), but ≡-refl is -- not accepted by the type checker: -- x != head (′⇒ (P⇒′ (x ∞))) of type .A -- when checking that the expression ≡-refl has type -- (head (P⇒ (x ∞ ⋎ x ∞)) ≡ head (P⇒ (x ∞)))
24.976471
72
0.461611
4de2b378cd81099f3a4b144a121025d624a95453
14,114
agda
Agda
a2b.agda
felixwellen/adventOfCode
834bc9e291a76bdbcd58cbff9805161f1b1cfe71
[ "MIT" ]
null
null
null
a2b.agda
felixwellen/adventOfCode
834bc9e291a76bdbcd58cbff9805161f1b1cfe71
[ "MIT" ]
null
null
null
a2b.agda
felixwellen/adventOfCode
834bc9e291a76bdbcd58cbff9805161f1b1cfe71
[ "MIT" ]
null
null
null
{- Day 2, 2nd part -} module a2b where open import Agda.Builtin.IO using (IO) open import Agda.Builtin.Unit using (⊤) open import Agda.Builtin.String using (String; primShowNat; primStringAppend) open import Agda.Builtin.Equality open import Data.Nat open import Data.Bool using (if_then_else_) open import Data.List open import Data.Maybe renaming (map to maybeMap) postulate putStrLn : String → IO ⊤ {-# FOREIGN GHC import qualified Data.Text as T #-} {-# COMPILE GHC putStrLn = putStrLn . T.unpack #-} -- helper shopMaybeNat : Maybe ℕ → String shopMaybeNat (just n) = primShowNat n shopMaybeNat nothing = "nothing" data Command : Set where forward : ℕ → Command up : ℕ → Command down : ℕ → Command record Position : Set where constructor pos field h : ℕ d : ℕ {- Alignment of the submarine, i.e. position and aim -} record Alignment : Set where constructor state field h : ℕ d : ℕ aim : ℕ open Position apply : Command → Alignment → Maybe Alignment apply (forward x) (state h d aim) = just (state (h + x) (d + (x * aim)) aim) apply (up x) (state h d aim) = if aim <ᵇ x then nothing else just (state h d ∣ aim - x ∣) apply (down x) (state h d aim) = just (state h d (aim + x)) iterate : List Command → Alignment → Maybe Alignment iterate [] a = just a iterate (command ∷ list) a with apply command a ... | just a' = iterate list a' ... | nothing = nothing doTask : List Command → Maybe ℕ doTask list = let maybeResult = iterate list (state 0 0 0) in maybeMap multiplyComponents maybeResult where multiplyComponents : Alignment → ℕ multiplyComponents (state h d aim) = h * d input : List Command input = forward 2 ∷ forward 3 ∷ forward 5 ∷ forward 6 ∷ down 7 ∷ forward 8 ∷ forward 4 ∷ forward 7 ∷ forward 5 ∷ forward 5 ∷ down 4 ∷ down 9 ∷ forward 8 ∷ forward 5 ∷ up 5 ∷ down 5 ∷ forward 3 ∷ down 4 ∷ down 8 ∷ forward 9 ∷ down 1 ∷ up 9 ∷ down 7 ∷ up 7 ∷ up 1 ∷ forward 1 ∷ down 1 ∷ down 4 ∷ down 4 ∷ down 8 ∷ down 4 ∷ up 3 ∷ down 1 ∷ down 3 ∷ forward 7 ∷ down 6 ∷ forward 3 ∷ forward 5 ∷ forward 2 ∷ up 9 ∷ forward 7 ∷ up 5 ∷ down 3 ∷ forward 1 ∷ forward 2 ∷ down 3 ∷ down 8 ∷ down 3 ∷ forward 8 ∷ up 5 ∷ down 5 ∷ forward 3 ∷ down 5 ∷ forward 9 ∷ down 3 ∷ down 4 ∷ down 9 ∷ down 7 ∷ up 3 ∷ down 9 ∷ up 9 ∷ up 1 ∷ forward 3 ∷ up 4 ∷ down 3 ∷ forward 7 ∷ forward 7 ∷ up 7 ∷ forward 6 ∷ down 7 ∷ down 6 ∷ forward 2 ∷ forward 9 ∷ down 5 ∷ forward 4 ∷ up 6 ∷ down 1 ∷ down 9 ∷ down 9 ∷ forward 4 ∷ down 1 ∷ forward 6 ∷ down 1 ∷ down 5 ∷ down 4 ∷ down 4 ∷ forward 4 ∷ forward 9 ∷ up 1 ∷ down 2 ∷ down 8 ∷ down 5 ∷ down 8 ∷ down 8 ∷ up 2 ∷ forward 8 ∷ up 1 ∷ forward 4 ∷ down 5 ∷ down 1 ∷ up 2 ∷ forward 6 ∷ forward 9 ∷ forward 2 ∷ forward 6 ∷ forward 9 ∷ up 6 ∷ forward 9 ∷ up 4 ∷ down 7 ∷ up 6 ∷ forward 2 ∷ down 1 ∷ up 3 ∷ forward 1 ∷ forward 8 ∷ down 6 ∷ down 8 ∷ down 8 ∷ forward 8 ∷ forward 2 ∷ forward 2 ∷ down 2 ∷ up 1 ∷ down 9 ∷ up 9 ∷ down 9 ∷ up 3 ∷ forward 9 ∷ up 4 ∷ up 7 ∷ up 6 ∷ down 9 ∷ forward 1 ∷ down 3 ∷ down 4 ∷ forward 8 ∷ down 3 ∷ down 9 ∷ up 3 ∷ forward 2 ∷ up 5 ∷ down 3 ∷ forward 8 ∷ up 3 ∷ down 3 ∷ forward 2 ∷ forward 9 ∷ down 1 ∷ down 9 ∷ down 4 ∷ up 7 ∷ down 4 ∷ up 6 ∷ forward 5 ∷ down 6 ∷ forward 3 ∷ down 2 ∷ forward 1 ∷ forward 8 ∷ down 4 ∷ forward 1 ∷ up 7 ∷ forward 6 ∷ up 9 ∷ forward 6 ∷ down 3 ∷ forward 2 ∷ down 4 ∷ forward 6 ∷ down 3 ∷ down 6 ∷ down 1 ∷ down 1 ∷ down 5 ∷ forward 3 ∷ forward 9 ∷ forward 8 ∷ down 3 ∷ forward 7 ∷ up 9 ∷ forward 9 ∷ up 2 ∷ forward 4 ∷ up 3 ∷ forward 1 ∷ up 6 ∷ up 8 ∷ down 5 ∷ down 6 ∷ up 9 ∷ down 6 ∷ down 9 ∷ up 9 ∷ down 4 ∷ forward 5 ∷ up 2 ∷ down 3 ∷ up 3 ∷ down 1 ∷ forward 3 ∷ down 5 ∷ forward 7 ∷ down 6 ∷ down 7 ∷ down 5 ∷ forward 2 ∷ up 6 ∷ down 9 ∷ down 4 ∷ down 3 ∷ forward 9 ∷ up 8 ∷ forward 2 ∷ down 2 ∷ forward 4 ∷ up 6 ∷ down 4 ∷ up 8 ∷ down 7 ∷ down 2 ∷ up 6 ∷ up 4 ∷ down 2 ∷ forward 5 ∷ up 4 ∷ down 8 ∷ forward 3 ∷ forward 1 ∷ down 7 ∷ forward 8 ∷ forward 7 ∷ down 7 ∷ up 4 ∷ forward 8 ∷ down 5 ∷ up 9 ∷ forward 1 ∷ forward 4 ∷ forward 9 ∷ forward 7 ∷ down 9 ∷ up 9 ∷ down 1 ∷ down 7 ∷ forward 7 ∷ down 7 ∷ down 7 ∷ down 3 ∷ down 5 ∷ forward 3 ∷ down 2 ∷ forward 6 ∷ down 9 ∷ up 5 ∷ up 3 ∷ forward 5 ∷ down 6 ∷ down 1 ∷ forward 4 ∷ down 3 ∷ forward 8 ∷ down 7 ∷ forward 7 ∷ forward 7 ∷ up 7 ∷ up 2 ∷ up 3 ∷ forward 9 ∷ down 5 ∷ up 2 ∷ forward 5 ∷ up 5 ∷ forward 2 ∷ forward 2 ∷ down 8 ∷ forward 2 ∷ up 4 ∷ forward 1 ∷ forward 3 ∷ up 8 ∷ up 9 ∷ forward 5 ∷ down 1 ∷ up 8 ∷ down 4 ∷ down 8 ∷ up 4 ∷ forward 9 ∷ down 6 ∷ down 8 ∷ up 2 ∷ up 3 ∷ down 7 ∷ down 4 ∷ forward 5 ∷ down 6 ∷ forward 3 ∷ forward 3 ∷ forward 8 ∷ down 1 ∷ down 7 ∷ down 9 ∷ down 2 ∷ down 7 ∷ forward 7 ∷ down 7 ∷ down 6 ∷ up 6 ∷ forward 8 ∷ forward 5 ∷ up 5 ∷ down 2 ∷ up 8 ∷ up 4 ∷ down 9 ∷ up 2 ∷ forward 5 ∷ up 2 ∷ down 4 ∷ up 4 ∷ forward 2 ∷ forward 4 ∷ forward 9 ∷ forward 9 ∷ up 4 ∷ up 5 ∷ down 1 ∷ down 6 ∷ down 1 ∷ down 4 ∷ down 5 ∷ down 3 ∷ forward 3 ∷ down 9 ∷ forward 6 ∷ down 3 ∷ down 9 ∷ down 2 ∷ up 2 ∷ down 2 ∷ down 7 ∷ forward 9 ∷ down 3 ∷ down 3 ∷ down 2 ∷ down 3 ∷ forward 2 ∷ down 9 ∷ down 9 ∷ up 5 ∷ up 3 ∷ forward 4 ∷ up 7 ∷ forward 8 ∷ up 6 ∷ forward 7 ∷ down 7 ∷ down 1 ∷ forward 5 ∷ down 2 ∷ up 1 ∷ down 8 ∷ up 3 ∷ forward 2 ∷ up 9 ∷ down 1 ∷ down 3 ∷ down 6 ∷ down 2 ∷ down 7 ∷ up 2 ∷ forward 5 ∷ forward 7 ∷ down 2 ∷ forward 5 ∷ forward 4 ∷ forward 5 ∷ down 3 ∷ forward 7 ∷ down 7 ∷ forward 8 ∷ down 3 ∷ down 2 ∷ up 1 ∷ forward 6 ∷ down 4 ∷ down 2 ∷ forward 7 ∷ up 3 ∷ down 4 ∷ forward 2 ∷ up 6 ∷ down 3 ∷ up 6 ∷ up 8 ∷ down 9 ∷ up 6 ∷ forward 8 ∷ forward 9 ∷ forward 4 ∷ forward 7 ∷ down 2 ∷ forward 9 ∷ down 7 ∷ up 9 ∷ down 5 ∷ down 6 ∷ up 5 ∷ down 4 ∷ forward 8 ∷ forward 4 ∷ forward 4 ∷ down 6 ∷ forward 3 ∷ forward 6 ∷ down 9 ∷ down 9 ∷ up 2 ∷ forward 7 ∷ down 8 ∷ down 9 ∷ down 9 ∷ forward 7 ∷ forward 3 ∷ down 7 ∷ down 8 ∷ forward 8 ∷ down 6 ∷ down 5 ∷ down 9 ∷ down 3 ∷ forward 1 ∷ down 5 ∷ forward 2 ∷ forward 8 ∷ down 2 ∷ forward 6 ∷ forward 3 ∷ down 7 ∷ down 4 ∷ forward 8 ∷ forward 1 ∷ down 6 ∷ forward 9 ∷ forward 6 ∷ up 1 ∷ up 3 ∷ down 8 ∷ forward 1 ∷ up 5 ∷ down 4 ∷ forward 7 ∷ up 3 ∷ down 2 ∷ forward 1 ∷ forward 9 ∷ down 9 ∷ down 7 ∷ forward 8 ∷ down 4 ∷ up 3 ∷ down 4 ∷ forward 2 ∷ forward 6 ∷ down 7 ∷ forward 6 ∷ down 6 ∷ down 4 ∷ down 1 ∷ up 9 ∷ down 4 ∷ down 7 ∷ up 4 ∷ down 9 ∷ forward 6 ∷ down 3 ∷ forward 2 ∷ down 4 ∷ forward 3 ∷ down 5 ∷ up 9 ∷ forward 8 ∷ up 7 ∷ up 6 ∷ up 4 ∷ forward 1 ∷ down 1 ∷ forward 4 ∷ up 6 ∷ forward 5 ∷ forward 4 ∷ forward 5 ∷ up 6 ∷ down 1 ∷ forward 3 ∷ up 7 ∷ down 9 ∷ up 9 ∷ down 5 ∷ forward 6 ∷ forward 4 ∷ up 1 ∷ down 4 ∷ up 1 ∷ forward 3 ∷ forward 1 ∷ down 3 ∷ forward 7 ∷ down 2 ∷ forward 3 ∷ up 2 ∷ forward 8 ∷ down 3 ∷ up 9 ∷ down 5 ∷ forward 6 ∷ down 1 ∷ down 8 ∷ down 5 ∷ forward 1 ∷ down 6 ∷ up 2 ∷ forward 6 ∷ down 2 ∷ down 1 ∷ up 6 ∷ up 7 ∷ down 5 ∷ forward 7 ∷ forward 6 ∷ forward 6 ∷ down 7 ∷ forward 4 ∷ down 5 ∷ up 5 ∷ down 1 ∷ up 8 ∷ down 8 ∷ down 2 ∷ down 2 ∷ down 9 ∷ up 9 ∷ forward 2 ∷ forward 7 ∷ down 7 ∷ down 4 ∷ down 4 ∷ down 8 ∷ forward 5 ∷ forward 2 ∷ up 9 ∷ down 9 ∷ forward 7 ∷ up 9 ∷ down 2 ∷ down 7 ∷ up 2 ∷ up 8 ∷ forward 8 ∷ down 4 ∷ forward 3 ∷ forward 4 ∷ forward 6 ∷ forward 2 ∷ down 1 ∷ down 2 ∷ forward 2 ∷ up 1 ∷ down 1 ∷ forward 5 ∷ up 3 ∷ up 3 ∷ down 3 ∷ down 1 ∷ down 4 ∷ up 5 ∷ up 6 ∷ forward 5 ∷ up 7 ∷ forward 6 ∷ down 4 ∷ down 7 ∷ up 8 ∷ forward 1 ∷ down 5 ∷ up 4 ∷ up 3 ∷ up 5 ∷ down 1 ∷ up 5 ∷ forward 3 ∷ up 5 ∷ forward 2 ∷ forward 2 ∷ forward 5 ∷ forward 2 ∷ up 9 ∷ forward 4 ∷ down 1 ∷ down 3 ∷ down 5 ∷ up 2 ∷ down 8 ∷ forward 8 ∷ forward 9 ∷ down 1 ∷ down 3 ∷ forward 8 ∷ forward 2 ∷ down 2 ∷ down 1 ∷ up 7 ∷ forward 2 ∷ forward 8 ∷ down 9 ∷ forward 1 ∷ forward 4 ∷ down 7 ∷ down 4 ∷ up 7 ∷ down 3 ∷ down 1 ∷ down 4 ∷ up 7 ∷ down 6 ∷ forward 7 ∷ down 8 ∷ up 2 ∷ up 4 ∷ up 6 ∷ down 9 ∷ down 9 ∷ down 8 ∷ forward 6 ∷ up 3 ∷ up 1 ∷ forward 9 ∷ forward 6 ∷ up 4 ∷ up 2 ∷ up 7 ∷ forward 5 ∷ up 9 ∷ up 9 ∷ forward 9 ∷ up 6 ∷ down 1 ∷ down 3 ∷ forward 3 ∷ down 2 ∷ down 2 ∷ down 6 ∷ down 9 ∷ forward 3 ∷ forward 7 ∷ up 3 ∷ forward 3 ∷ down 5 ∷ forward 9 ∷ up 6 ∷ down 2 ∷ forward 8 ∷ down 3 ∷ up 5 ∷ down 6 ∷ forward 9 ∷ down 5 ∷ down 2 ∷ down 6 ∷ forward 8 ∷ forward 6 ∷ down 1 ∷ forward 6 ∷ up 1 ∷ up 7 ∷ down 4 ∷ down 7 ∷ forward 4 ∷ forward 7 ∷ down 4 ∷ forward 8 ∷ down 8 ∷ down 7 ∷ forward 9 ∷ down 1 ∷ down 3 ∷ down 6 ∷ forward 7 ∷ forward 6 ∷ forward 3 ∷ forward 8 ∷ down 5 ∷ down 3 ∷ up 1 ∷ down 9 ∷ down 8 ∷ forward 3 ∷ down 6 ∷ down 1 ∷ forward 5 ∷ forward 5 ∷ forward 9 ∷ up 5 ∷ down 6 ∷ up 9 ∷ down 7 ∷ down 6 ∷ up 1 ∷ forward 5 ∷ forward 7 ∷ forward 8 ∷ forward 7 ∷ forward 6 ∷ forward 3 ∷ forward 1 ∷ forward 2 ∷ up 4 ∷ forward 3 ∷ forward 4 ∷ forward 5 ∷ up 2 ∷ up 3 ∷ forward 4 ∷ down 9 ∷ up 4 ∷ forward 7 ∷ down 6 ∷ down 6 ∷ down 1 ∷ forward 2 ∷ down 2 ∷ forward 2 ∷ down 3 ∷ forward 7 ∷ forward 8 ∷ down 4 ∷ up 7 ∷ forward 7 ∷ down 7 ∷ forward 7 ∷ forward 9 ∷ down 7 ∷ up 2 ∷ down 3 ∷ forward 7 ∷ down 1 ∷ forward 8 ∷ forward 2 ∷ up 9 ∷ down 3 ∷ forward 2 ∷ up 4 ∷ forward 9 ∷ down 4 ∷ down 4 ∷ forward 4 ∷ down 2 ∷ down 9 ∷ forward 4 ∷ down 2 ∷ down 6 ∷ forward 9 ∷ forward 2 ∷ up 1 ∷ forward 2 ∷ forward 3 ∷ down 5 ∷ up 8 ∷ down 4 ∷ down 4 ∷ forward 7 ∷ down 2 ∷ up 6 ∷ down 9 ∷ forward 9 ∷ up 1 ∷ forward 3 ∷ down 5 ∷ forward 3 ∷ down 3 ∷ forward 4 ∷ up 3 ∷ down 6 ∷ down 7 ∷ down 4 ∷ down 8 ∷ down 4 ∷ down 5 ∷ up 9 ∷ up 1 ∷ down 7 ∷ up 3 ∷ up 3 ∷ down 3 ∷ up 4 ∷ up 6 ∷ forward 8 ∷ down 1 ∷ forward 7 ∷ forward 4 ∷ down 9 ∷ down 1 ∷ forward 7 ∷ forward 9 ∷ forward 1 ∷ down 3 ∷ down 2 ∷ forward 3 ∷ forward 2 ∷ down 7 ∷ forward 9 ∷ forward 6 ∷ up 9 ∷ down 2 ∷ forward 9 ∷ up 6 ∷ forward 8 ∷ up 1 ∷ down 5 ∷ down 8 ∷ forward 1 ∷ down 1 ∷ forward 9 ∷ up 1 ∷ forward 9 ∷ forward 1 ∷ forward 1 ∷ down 7 ∷ forward 3 ∷ forward 6 ∷ down 5 ∷ forward 7 ∷ forward 1 ∷ down 7 ∷ down 6 ∷ down 6 ∷ forward 5 ∷ up 6 ∷ down 6 ∷ forward 8 ∷ up 2 ∷ down 8 ∷ down 3 ∷ up 5 ∷ up 8 ∷ down 6 ∷ forward 4 ∷ forward 2 ∷ up 3 ∷ forward 5 ∷ forward 3 ∷ up 8 ∷ forward 6 ∷ up 8 ∷ forward 1 ∷ up 8 ∷ up 7 ∷ up 6 ∷ forward 2 ∷ down 9 ∷ down 9 ∷ forward 3 ∷ down 7 ∷ forward 3 ∷ down 6 ∷ forward 9 ∷ up 5 ∷ down 1 ∷ forward 7 ∷ down 1 ∷ down 5 ∷ down 9 ∷ forward 8 ∷ forward 9 ∷ forward 7 ∷ down 9 ∷ up 4 ∷ forward 5 ∷ down 5 ∷ forward 5 ∷ down 9 ∷ forward 9 ∷ forward 3 ∷ up 5 ∷ forward 8 ∷ up 5 ∷ down 1 ∷ forward 8 ∷ down 3 ∷ forward 6 ∷ up 9 ∷ forward 8 ∷ down 4 ∷ forward 3 ∷ down 5 ∷ forward 8 ∷ forward 9 ∷ forward 2 ∷ down 1 ∷ down 6 ∷ down 4 ∷ forward 9 ∷ up 2 ∷ down 3 ∷ down 6 ∷ down 3 ∷ down 9 ∷ down 1 ∷ up 6 ∷ down 2 ∷ down 7 ∷ up 5 ∷ forward 5 ∷ up 1 ∷ down 7 ∷ forward 6 ∷ up 6 ∷ down 2 ∷ down 3 ∷ forward 3 ∷ down 5 ∷ forward 8 ∷ down 9 ∷ down 7 ∷ down 8 ∷ up 7 ∷ down 1 ∷ forward 1 ∷ forward 1 ∷ down 2 ∷ up 4 ∷ forward 2 ∷ down 3 ∷ up 2 ∷ down 3 ∷ down 2 ∷ forward 7 ∷ down 1 ∷ up 7 ∷ down 2 ∷ down 1 ∷ forward 6 ∷ down 9 ∷ up 9 ∷ down 4 ∷ down 6 ∷ up 9 ∷ forward 7 ∷ forward 9 ∷ forward 7 ∷ down 4 ∷ down 1 ∷ forward 7 ∷ down 4 ∷ down 7 ∷ down 3 ∷ down 5 ∷ forward 3 ∷ down 8 ∷ forward 8 ∷ forward 7 ∷ forward 8 ∷ down 4 ∷ down 9 ∷ forward 2 ∷ forward 7 ∷ up 8 ∷ forward 4 ∷ down 6 ∷ up 8 ∷ down 2 ∷ forward 3 ∷ down 6 ∷ down 8 ∷ forward 8 ∷ forward 2 ∷ forward 9 ∷ up 6 ∷ forward 7 ∷ down 3 ∷ down 5 ∷ forward 8 ∷ forward 9 ∷ down 3 ∷ forward 3 ∷ forward 2 ∷ forward 3 ∷ down 8 ∷ up 9 ∷ up 5 ∷ up 2 ∷ up 6 ∷ up 1 ∷ up 1 ∷ up 5 ∷ forward 3 ∷ forward 2 ∷ down 3 ∷ forward 4 ∷ [] main : IO ⊤ main = putStrLn (shopMaybeNat (doTask input)) private -- checks from the exercise text _ : apply (forward 5) (state 0 0 0) ≡ just (state 5 0 0) _ = refl _ : apply (down 5) (state 5 0 0) ≡ just (state 5 0 5) _ = refl _ : apply (forward 8) (state 5 0 5) ≡ just (state 13 (8 * 5) 5) _ = refl _ : apply (up 3) (state 13 40 5) ≡ just (state 13 40 2) _ = refl _ : apply (down 8) (state 13 40 2) ≡ just (state 13 40 10) _ = refl _ : apply (forward 2) (state 13 40 10) ≡ just (state 15 60 10) _ = refl -- submarine does not 'fly' _ : apply (up 7) (state 13 2 2) ≡ nothing _ = refl
12.830909
77
0.508431
2ff939c66b1bb3cfe2c9e8178eab6d9e439760f1
4,290
agda
Agda
TotalParserCombinators/Laws/KleeneAlgebra.agda
yurrriq/parser-combinators
b396d35cc2cb7e8aea50b982429ee385f001aa88
[ "MIT" ]
7
2016-12-13T05:23:14.000Z
2021-06-22T05:35:31.000Z
TotalParserCombinators/Laws/KleeneAlgebra.agda
nad/parser-combinators
76774f54f466cfe943debf2da731074fe0c33644
[ "MIT" ]
1
2018-01-22T22:21:41.000Z
2018-01-24T16:39:37.000Z
TotalParserCombinators/Laws/KleeneAlgebra.agda
nad/parser-combinators
76774f54f466cfe943debf2da731074fe0c33644
[ "MIT" ]
null
null
null
------------------------------------------------------------------------ -- Do the parser combinators form a Kleene algebra? ------------------------------------------------------------------------ module TotalParserCombinators.Laws.KleeneAlgebra where open import Algebra open import Data.List open import Data.List.Properties open import Data.Nat using (ℕ) open import Data.Product using (_,_; proj₂) open import Function using (_$_) open import Function.Equality using (_⟨$⟩_) open import Function.Equivalence using (_⇔_; equivalence; module Equivalence) import Relation.Binary.PropositionalEquality as P open import Relation.Nullary open import TotalParserCombinators.Lib open import TotalParserCombinators.Parser open import TotalParserCombinators.Semantics hiding (_>>=_) renaming (return to return′; _⊛_ to _⊛′_) ------------------------------------------------------------------------ -- A variant of _≲_ infix 4 _≲′_ -- The AdditiveMonoid module shows that _∣_ can be viewed as the join -- operation of a join-semilattice (if language equivalence is used). -- This means that the following definition of order is natural. _≲′_ : ∀ {Tok R xs₁ xs₂} → Parser Tok R xs₁ → Parser Tok R xs₂ → Set₁ p₁ ≲′ p₂ = p₁ ∣ p₂ ≈ p₂ -- This order coincides with _≲_. ≲⇔≲′ : ∀ {Tok R xs₁ xs₂} (p₁ : Parser Tok R xs₁) (p₂ : Parser Tok R xs₂) → p₁ ≲ p₂ ⇔ p₁ ≲′ p₂ ≲⇔≲′ {xs₁ = xs₁} p₁ p₂ = equivalence (λ (p₁≲p₂ : p₁ ≲ p₂) {x s} → equivalence (helper p₁≲p₂) (∣-right xs₁)) (λ (p₁≲′p₂ : p₁ ≲′ p₂) s∈p₁ → Equivalence.to p₁≲′p₂ ⟨$⟩ ∣-left s∈p₁) where helper : p₁ ≲ p₂ → p₁ ∣ p₂ ≲ p₂ helper p₁≲p₂ (∣-left s∈p₁) = p₁≲p₂ s∈p₁ helper p₁≲p₂ (∣-right .xs₁ s∈p₂) = s∈p₂ ------------------------------------------------------------------------ -- A limited notion of *-continuity -- Least upper bounds. record _LeastUpperBoundOf_ {Tok R xs} {f : ℕ → List R} (lub : Parser Tok R xs) (p : (n : ℕ) → Parser Tok R (f n)) : Set₁ where field upper-bound : ∀ n → p n ≲ lub least : ∀ {ys} {ub : Parser Tok R ys} → (∀ n → p n ≲ ub) → lub ≲ ub -- For argument parsers which are not nullable we can prove that the -- Kleene star operator is *-continuous. *-continuous : ∀ {Tok R₁ R₂ R₃ fs xs} (p₁ : Parser Tok (List R₁ → R₂ → R₃) fs) (p₂ : Parser Tok R₁ []) (p₃ : Parser Tok R₂ xs) → (p₁ ⊛ p₂ ⋆ ⊛ p₃) LeastUpperBoundOf (λ n → p₁ ⊛ p₂ ↑ n ⊛ p₃) *-continuous {Tok} {R₁ = R₁} {R₃ = R₃} {fs} {xs} p₁ p₂ p₃ = record { upper-bound = upper-bound; least = least } where upper-bound : ∀ n → p₁ ⊛ p₂ ↑ n ⊛ p₃ ≲ p₁ ⊛ p₂ ⋆ ⊛ p₃ upper-bound n (∈p₁ ⊛′ ∈p₂ⁿ ⊛′ ∈p₃) = [ ○ - ○ ] [ ○ - ○ ] ∈p₁ ⊛ Exactly.↑≲⋆ n ∈p₂ⁿ ⊛ ∈p₃ least : ∀ {ys} {p : Parser Tok R₃ ys} → (∀ i → p₁ ⊛ p₂ ↑ i ⊛ p₃ ≲ p) → p₁ ⊛ p₂ ⋆ ⊛ p₃ ≲ p least ub (∈p₁ ⊛′ ∈p₂⋆ ⊛′ ∈p₃) with Exactly.⋆≲∃↑ ∈p₂⋆ ... | (n , ∈p₂ⁿ) = ub n ([ ○ - ○ ] [ ○ - ○ ] ∈p₁ ⊛ ∈p₂ⁿ ⊛ ∈p₃) ------------------------------------------------------------------------ -- The parser combinators do not form a Kleene algebra -- If we allow arbitrary argument parsers, then we cannot prove the -- following (variant of a) Kleene algebra axiom. not-Kleene-algebra : ∀ {Tok} → Tok → (f : ∀ {R xs} → Parser Tok R xs → List (List R)) → (_⋆′ : ∀ {R xs} (p : Parser Tok R xs) → Parser Tok (List R) (f p)) → ¬ (∀ {R xs} {p : Parser Tok R xs} → return [] ∣ (p >>= λ x → (p ⋆′) >>= λ xs → return (x ∷ xs)) ≲ (p ⋆′)) not-Kleene-algebra {Tok} t f _⋆′ fold = KleeneStar.unrestricted-incomplete t f _⋆′ ⋆′-complete where ⋆′-complete : ∀ {xs ys s} {p : Parser Tok Tok ys} → xs ∈[ p ]⋆· s → xs ∈ p ⋆′ · s ⋆′-complete [] = fold (∣-left return′) ⋆′-complete (∈p ∷ ∈p⋆) = fold (∣-right [ [] ] ([ ○ - ○ ] ∈p >>= fix ([ ○ - ○ ] ⋆′-complete ∈p⋆ >>= return′))) where fix = cast∈ P.refl P.refl $ ++-identityʳ _ -- This shows that the parser combinators do not form a Kleene -- algebra (interpreted liberally) using _⊛_ for composition, return -- for unit, etc. However, it should be straightforward to build a -- recogniser library, based on the parser combinators, which does -- satisfy the Kleene algebra axioms (see -- TotalRecognisers.LeftRecursion.KleeneAlgebra).
36.355932
72
0.540793
4d3b6241f22dc3f0ed0ae80e9279f910f28b0d23
1,246
agda
Agda
test/Succeed/fol-theorems/Where3.agda
asr/apia
a66c5ddca2ab470539fd68c42c4fbd45f720d682
[ "MIT" ]
10
2015-09-03T20:54:16.000Z
2019-12-03T13:44:25.000Z
test/Succeed/fol-theorems/Where3.agda
asr/apia
a66c5ddca2ab470539fd68c42c4fbd45f720d682
[ "MIT" ]
121
2015-01-25T13:22:12.000Z
2018-04-22T06:01:44.000Z
test/Succeed/fol-theorems/Where3.agda
asr/apia
a66c5ddca2ab470539fd68c42c4fbd45f720d682
[ "MIT" ]
4
2016-05-10T23:06:19.000Z
2016-08-03T03:54:55.000Z
------------------------------------------------------------------------------ -- Testing the conjectures inside a @where@ clause ------------------------------------------------------------------------------ {-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} module Where3 where infixl 6 _+_ infix 4 _≡_ postulate D : Set zero : D succ : D → D _≡_ : D → D → Set data N : D → Set where nzero : N zero nsucc : ∀ {n} → N n → N (succ n) N-ind : (A : D → Set) → A zero → (∀ {n} → A n → A (succ n)) → ∀ {n} → N n → A n N-ind A A0 h nzero = A0 N-ind A A0 h (nsucc Nn) = h (N-ind A A0 h Nn) postulate _+_ : D → D → D +-0x : ∀ n → zero + n ≡ n +-Sx : ∀ m n → succ m + n ≡ succ (m + n) {-# ATP axioms +-0x +-Sx #-} -- Using @module Helper where@ instead of @where@ clauses. +-rightIdentity : ∀ {n} → N n → n + zero ≡ n +-rightIdentity Nn = N-ind A A0 is Nn module Helper where A : D → Set A i = i + zero ≡ i postulate A0 : zero + zero ≡ zero {-# ATP prove A0 #-} postulate is : ∀ {i} → i + zero ≡ i → succ i + zero ≡ succ i {-# ATP prove is #-}
24.92
78
0.432584
d0a1950b8a839432ab7b8c50695684f14ab1e2b8
8,027
agda
Agda
Categories/Category/Construction/Functors.agda
rei1024/agda-categories
89d163f72caa7deeac9413f27bc1b4ed7f9e025b
[ "MIT" ]
null
null
null
Categories/Category/Construction/Functors.agda
rei1024/agda-categories
89d163f72caa7deeac9413f27bc1b4ed7f9e025b
[ "MIT" ]
null
null
null
Categories/Category/Construction/Functors.agda
rei1024/agda-categories
89d163f72caa7deeac9413f27bc1b4ed7f9e025b
[ "MIT" ]
null
null
null
{-# OPTIONS --without-K --safe #-} module Categories.Category.Construction.Functors where -- the "Functor Category", often denoted [ C , D ] open import Level open import Data.Product using (_,_; proj₁; uncurry′) open import Categories.Category using (Category; _[_∘_]) open import Categories.Category.Equivalence using (StrongEquivalence) open import Categories.Category.Product using (_※ⁿ_) renaming (Product to _×_) open import Categories.Functor using (Functor; _∘F_) open import Categories.Functor.Bifunctor open import Categories.Functor.Construction.Constant using (constNat) open import Categories.NaturalTransformation using (NaturalTransformation; _∘ᵥ_; _∘ˡ_; _∘ₕ_) renaming (id to idN) open import Categories.NaturalTransformation.Equivalence using (_≃_; ≃-isEquivalence) open import Categories.NaturalTransformation.NaturalIsomorphism using (NaturalIsomorphism) import Categories.Morphism.Reasoning as MR private variable o ℓ e o′ ℓ′ e′ : Level C D C₁ C₂ : Category o ℓ e -- The reason the proofs below are so easy is that _∘ᵥ_ 'computes' all the way down into -- expressions in D, from which the properties follow. Functors : Category o ℓ e → Category o′ ℓ′ e′ → Category (o ⊔ ℓ ⊔ e ⊔ o′ ⊔ ℓ′ ⊔ e′) (o ⊔ ℓ ⊔ ℓ′ ⊔ e′) (o ⊔ e′) Functors C D = record { Obj = Functor C D ; _⇒_ = NaturalTransformation ; _≈_ = _≃_ ; id = idN ; _∘_ = _∘ᵥ_ ; assoc = assoc ; sym-assoc = sym-assoc ; identityˡ = identityˡ ; identityʳ = identityʳ ; identity² = identity² ; equiv = ≃-isEquivalence ; ∘-resp-≈ = λ eq eq′ → ∘-resp-≈ eq eq′ } where module C = Category C module D = Category D open D -- Part of the proof that Cats is a CCC: eval : Bifunctor (Functors C D) C D eval {C = C} {D = D} = record { F₀ = uncurry′ Functor.F₀ ; F₁ = λ where {F , _} {_ , B} (α , f) → let open NaturalTransformation α open Functor F in η B ∘ F₁ f ; identity = λ where {F , _} → elimʳ (Functor.identity F) ; homomorphism = λ where {F , _} {G , B} {_ , C} {α , f} {β , g} → let open NaturalTransformation open Functor in begin (η β C ∘ η α C) ∘ F₁ F (g C.∘ f) ≈⟨ refl ⟩∘⟨ homomorphism F ⟩ (η β C ∘ η α C) ∘ F₁ F g ∘ F₁ F f ≈⟨ assoc ⟩ η β C ∘ η α C ∘ F₁ F g ∘ F₁ F f ≈⟨ refl ⟩∘⟨ pullˡ (commute α g) ⟩ η β C ∘ (F₁ G g ∘ η α B) ∘ F₁ F f ≈⟨ refl ⟩∘⟨ assoc ⟩ η β C ∘ F₁ G g ∘ η α B ∘ F₁ F f ≈˘⟨ assoc ⟩ (η β C ∘ F₁ G g) ∘ η α B ∘ F₁ F f ∎ ; F-resp-≈ = λ where {F , _} (comm , eq) → ∘-resp-≈ comm (Functor.F-resp-≈ F eq) } where module C = Category C module D = Category D open D open MR D open HomReasoning -- Currying induces a functor between functor categories -- another -- part of the proof that Cats is a catesian closed (bi)category. curry : Functor (Functors (C₁ × C₂) D) (Functors C₁ (Functors C₂ D)) curry {C₁ = C₁} {C₂ = C₂} {D = D} = record { F₀ = curry₀ ; F₁ = curry₁ ; identity = Equiv.refl D ; homomorphism = Equiv.refl D ; F-resp-≈ = λ F≈G {x₁} {x₂} → F≈G {x₁ , x₂} } where open Category curry₀ : Bifunctor C₁ C₂ D → Functor C₁ (Functors C₂ D) curry₀ F = record { F₀ = λ c → appˡ F c ; F₁ = λ f → F ∘ˡ (constNat f ※ⁿ idN) ; identity = identity ; homomorphism = λ {_} {_} {_} {f} {g} → begin F₁ (C₁ [ g ∘ f ] , id C₂) ≈˘⟨ F-resp-≈ (Equiv.refl C₁ , identityˡ C₂) ⟩ F₁ (C₁ [ g ∘ f ] , C₂ [ id C₂ ∘ id C₂ ]) ≈⟨ homomorphism ⟩ D [ F₁ (g , id C₂) ∘ F₁ (f , id C₂) ] ∎ ; F-resp-≈ = λ f≈g → F-resp-≈ (f≈g , Equiv.refl C₂) } where open Functor F open HomReasoning D curry₁ : {F G : Bifunctor C₁ C₂ D} → NaturalTransformation F G → NaturalTransformation (curry₀ F) (curry₀ G) curry₁ α = record { η = λ c → record { η = λ a → η α (c , a) ; commute = λ f → commute α (id C₁ , f) ; sym-commute = λ f → sym-commute α (id C₁ , f) } ; commute = λ f → commute α (f , id C₂) ; sym-commute = λ f → sym-commute α (f , id C₂) } where open NaturalTransformation module curry {o₁ e₁ ℓ₁} {C₁ : Category o₁ e₁ ℓ₁} {o₂ e₂ ℓ₂} {C₂ : Category o₂ e₂ ℓ₂} {o′ e′ ℓ′} {D : Category o′ e′ ℓ′} where open Functor (curry {C₁ = C₁} {C₂ = C₂} {D = D}) public open Category open NaturalIsomorphism -- Currying preserves natural isos. -- This makes |curry.F₀| a map between the hom-setoids of Cats. resp-NI : {F G : Bifunctor C₁ C₂ D} → NaturalIsomorphism F G → NaturalIsomorphism (F₀ F) (F₀ G) resp-NI α = record { F⇒G = F₁ (F⇒G α) ; F⇐G = F₁ (F⇐G α) ; iso = λ x → record { isoˡ = iso.isoˡ α (x , _) ; isoʳ = iso.isoʳ α (x , _) } } -- Godement product ? product : {A B C : Category o ℓ e} → Bifunctor (Functors B C) (Functors A B) (Functors A C) product {A = A} {B = B} {C = C} = record { F₀ = uncurry′ _∘F_ ; F₁ = uncurry′ _∘ₕ_ ; identity = λ {f} → identityʳ ○ identity {D = C} (proj₁ f) ; homomorphism = λ { {_ , F₂} {G₁ , G₂} {H₁ , _} {f₁ , f₂} {g₁ , g₂} {x} → begin F₁ H₁ (η g₂ x B.∘ η f₂ x) ∘ η g₁ (F₀ F₂ x) ∘ η f₁ (F₀ F₂ x) ≈⟨ ∘-resp-≈ˡ (homomorphism H₁) ○ assoc ○ ∘-resp-≈ʳ (⟺ assoc) ⟩ F₁ H₁ (η g₂ x) ∘ (F₁ H₁ (η f₂ x) ∘ η g₁ (F₀ F₂ x)) ∘ η f₁ (F₀ F₂ x) ≈⟨ ⟺ ( refl⟩∘⟨ ( commute g₁ (η f₂ x) ⟩∘⟨refl) ) ⟩ F₁ H₁ (η g₂ x) ∘ (η g₁ (F₀ G₂ x) ∘ F₁ G₁ (η f₂ x)) ∘ η f₁ (F₀ F₂ x) ≈⟨ ∘-resp-≈ʳ assoc ○ ⟺ assoc ⟩ (F₁ H₁ (η g₂ x) ∘ η g₁ (F₀ G₂ x)) ∘ F₁ G₁ (η f₂ x) ∘ η f₁ (F₀ F₂ x) ∎ } ; F-resp-≈ = λ { {_} {g₁ , _} (≈₁ , ≈₂) → ∘-resp-≈ (F-resp-≈ g₁ ≈₂) ≈₁ } } where open Category C open HomReasoning open Functor module B = Category B open NaturalTransformation -- op induces a Functor on the Functors category. -- This is an instance where the proof-irrelevant version is simpler because (op op C) is -- just C. Here we rather need to be more explicit. opF⇒ : {A : Category o ℓ e} {B : Category o′ ℓ′ e′} → Functor (Category.op (Functors (Category.op A) (Category.op B))) (Functors A B) opF⇒ {A = A} {B} = record { F₀ = Functor.op ; F₁ = NaturalTransformation.op ; identity = Equiv.refl ; homomorphism = Equiv.refl ; F-resp-≈ = λ eq → eq } where open Category B opF⇐ : {A : Category o ℓ e} {B : Category o′ ℓ′ e′} → Functor (Functors A B) (Category.op (Functors (Category.op A) (Category.op B))) opF⇐ {A = A} {B} = record { F₀ = Functor.op ; F₁ = NaturalTransformation.op ; identity = Equiv.refl ; homomorphism = Equiv.refl ; F-resp-≈ = λ eq → eq } where open Category B Functorsᵒᵖ-equiv : {A : Category o ℓ e} {B : Category o′ ℓ′ e′} → StrongEquivalence (Category.op (Functors (Category.op A) (Category.op B))) (Functors A B) Functorsᵒᵖ-equiv {B = B} = record { F = opF⇒ ; G = opF⇐ ; weak-inverse = record { F∘G≈id = record { F⇒G = record { η = λ _ → idN ; commute = λ _ → id-comm-sym ; sym-commute = λ _ → id-comm } ; F⇐G = record { η = λ _ → idN ; commute = λ _ → id-comm-sym ; sym-commute = λ _ → id-comm } ; iso = λ _ → record { isoˡ = identityˡ ; isoʳ = identityˡ } } ; G∘F≈id = record { F⇒G = record { η = λ _ → idN ; commute = λ _ → id-comm-sym ; sym-commute = λ _ → id-comm } ; F⇐G = record { η = λ _ → idN ; commute = λ _ → id-comm-sym ; sym-commute = λ _ → id-comm } ; iso = λ _ → record { isoˡ = identityˡ ; isoʳ = identityˡ } } } } where open Category B open HomReasoning open MR B
33.726891
110
0.535567
add326a2fcf64cfb76d89fccc7b06b28d25b2577
295
agda
Agda
test/fail/ATPRepeteadConjecture.agda
asr/eagda
7220bebfe9f64297880ecec40314c0090018fdd0
[ "BSD-3-Clause" ]
1
2016-03-17T01:45:59.000Z
2016-03-17T01:45:59.000Z
test/fail/ATPRepeteadConjecture.agda
asr/eagda
7220bebfe9f64297880ecec40314c0090018fdd0
[ "BSD-3-Clause" ]
null
null
null
test/fail/ATPRepeteadConjecture.agda
asr/eagda
7220bebfe9f64297880ecec40314c0090018fdd0
[ "BSD-3-Clause" ]
1
2019-03-05T20:02:38.000Z
2019-03-05T20:02:38.000Z
module ATPRepeteadConjecture where -- This error is detected by TypeChecking.Monad.Signature. postulate D : Set _≡_ : D → D → Set p : ∀ d e → d ≡ e -- The conjecture foo is rejected because it is repetead. postulate foo : ∀ d e → d ≡ e {-# ATP prove foo #-} {-# ATP prove foo p #-}
21.071429
58
0.637288
1afd70eb3edd3dc8f8106a2004bd13a0ea23f3f7
452
agda
Agda
doc/icfp20/code/Main.agda
halfaya/MusicTools
04896c61b603d46011b7d718fcb47dd756e66021
[ "MIT" ]
28
2017-04-21T09:08:52.000Z
2022-03-04T18:04:07.000Z
doc/icfp20/code/Main.agda
halfaya/MusicTools
04896c61b603d46011b7d718fcb47dd756e66021
[ "MIT" ]
1
2020-11-13T01:26:20.000Z
2020-11-17T00:58:55.000Z
doc/icfp20/code/Main.agda
halfaya/MusicTools
04896c61b603d46011b7d718fcb47dd756e66021
[ "MIT" ]
3
2019-01-12T17:02:36.000Z
2020-11-10T04:04:40.000Z
{-# OPTIONS --without-K #-} module Main where open import Data.List open import Midi open import Note open import Frog open import Piston main : IO Unit main = let channel = 0 ticksPerBeat = 4 -- 16th notes file = "/tmp/test.mid" -- counterpoint song = cfcpTracks1 -- song = cfcpTracks2 -- harmony -- song = testHTracks in exportTracks file ticksPerBeat (map track→htrack song)
18.833333
59
0.617257
2e4d95f1d41b3e2db52b7d9808710a916de34645
10,930
agda
Agda
Cubical/Algebra/CommRing/RadicalIdeal.agda
barrettj12/cubical
7b41b9171f90473efc98487cb2ea7a4d02320cb2
[ "MIT" ]
null
null
null
Cubical/Algebra/CommRing/RadicalIdeal.agda
barrettj12/cubical
7b41b9171f90473efc98487cb2ea7a4d02320cb2
[ "MIT" ]
null
null
null
Cubical/Algebra/CommRing/RadicalIdeal.agda
barrettj12/cubical
7b41b9171f90473efc98487cb2ea7a4d02320cb2
[ "MIT" ]
null
null
null
{-# OPTIONS --safe --experimental-lossy-unification #-} module Cubical.Algebra.CommRing.RadicalIdeal where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Equiv open import Cubical.Foundations.Function open import Cubical.Foundations.Powerset using (⊆-isProp) open import Cubical.Foundations.HLevels open import Cubical.Data.Sigma open import Cubical.Data.Sum hiding (map) open import Cubical.Data.FinData hiding (elim) open import Cubical.Data.Nat renaming ( _+_ to _+ℕ_ ; _·_ to _·ℕ_ ; +-comm to +ℕ-comm ; ·-assoc to ·ℕ-assoc ; ·-comm to ·ℕ-comm ; _choose_ to _ℕchoose_ ; snotz to ℕsnotz) open import Cubical.Data.Nat.Order open import Cubical.HITs.PropositionalTruncation as PT open import Cubical.Algebra.CommRing open import Cubical.Algebra.CommRing.Ideal open import Cubical.Algebra.CommRing.FGIdeal open import Cubical.Algebra.CommRing.BinomialThm open import Cubical.Algebra.Ring.Properties open import Cubical.Algebra.Ring.BigOps open import Cubical.Algebra.RingSolver.ReflectionSolving private variable ℓ : Level module RadicalIdeal (R' : CommRing ℓ) where private R = fst R' 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 isCommIdeal √ : CommIdeal → CommIdeal fst (√ I) x = (∃[ n ∈ ℕ ] x ^ n ∈ I) , isPropPropTrunc +Closed (snd (√ I)) {x = x} {y = y} = map2 +ClosedΣ where +ClosedΣ : Σ[ n ∈ ℕ ] x ^ n ∈ I → Σ[ n ∈ ℕ ] y ^ n ∈ I → Σ[ n ∈ ℕ ] (x + y) ^ n ∈ I +ClosedΣ (n , xⁿ∈I) (m , yᵐ∈I) = (n +ℕ m) , subst-∈ I (sym (BinomialThm (n +ℕ m) _ _)) ∑Binomial∈I where binomialCoeff∈I : ∀ i → ((n +ℕ m) choose toℕ i) · x ^ toℕ i · y ^ (n +ℕ m ∸ toℕ i) ∈ I binomialCoeff∈I i with ≤-+-split n m (toℕ i) (pred-≤-pred (toℕ<n i)) ... | inl n≤i = subst-∈ I (sym path) (·Closed (I .snd) _ xⁿ∈I) where useSolver : ∀ a b c d → a · (b · c) · d ≡ a · b · d · c useSolver = solve R' path : ((n +ℕ m) choose toℕ i) · x ^ toℕ i · y ^ (n +ℕ m ∸ toℕ i) ≡ ((n +ℕ m) choose toℕ i) · x ^ (toℕ i ∸ n) · y ^ (n +ℕ m ∸ toℕ i) · x ^ n path = ((n +ℕ m) choose toℕ i) · x ^ toℕ i · y ^ (n +ℕ m ∸ toℕ i) ≡⟨ cong (λ k → ((n +ℕ m) choose toℕ i) · x ^ k · y ^ (n +ℕ m ∸ toℕ i)) (sym (≤-∸-+-cancel n≤i)) ⟩ ((n +ℕ m) choose toℕ i) · x ^ ((toℕ i ∸ n) +ℕ n) · y ^ (n +ℕ m ∸ toℕ i) ≡⟨ cong (λ z → ((n +ℕ m) choose toℕ i) · z · y ^ (n +ℕ m ∸ toℕ i)) (sym (·-of-^-is-^-of-+ x (toℕ i ∸ n) n)) ⟩ ((n +ℕ m) choose toℕ i) · (x ^ (toℕ i ∸ n) · x ^ n) · y ^ (n +ℕ m ∸ toℕ i) ≡⟨ useSolver _ _ _ _ ⟩ ((n +ℕ m) choose toℕ i) · x ^ (toℕ i ∸ n) · y ^ (n +ℕ m ∸ toℕ i) · x ^ n ∎ ... | inr m≤n+m-i = subst-∈ I (sym path) (·Closed (I .snd) _ yᵐ∈I) where path : ((n +ℕ m) choose toℕ i) · x ^ toℕ i · y ^ (n +ℕ m ∸ toℕ i) ≡ ((n +ℕ m) choose toℕ i) · x ^ toℕ i · y ^ ((n +ℕ m ∸ toℕ i) ∸ m) · y ^ m path = ((n +ℕ m) choose toℕ i) · x ^ toℕ i · y ^ (n +ℕ m ∸ toℕ i) ≡⟨ cong (λ k → ((n +ℕ m) choose toℕ i) · x ^ toℕ i · y ^ k) (sym (≤-∸-+-cancel m≤n+m-i)) ⟩ ((n +ℕ m) choose toℕ i) · x ^ toℕ i · y ^ (((n +ℕ m ∸ toℕ i) ∸ m) +ℕ m) ≡⟨ cong (((n +ℕ m) choose toℕ i) · x ^ toℕ i ·_) (sym (·-of-^-is-^-of-+ y ((n +ℕ m ∸ toℕ i) ∸ m) m)) ⟩ ((n +ℕ m) choose toℕ i) · x ^ toℕ i · (y ^ ((n +ℕ m ∸ toℕ i) ∸ m) · y ^ m) ≡⟨ ·Assoc _ _ _ ⟩ ((n +ℕ m) choose toℕ i) · x ^ toℕ i · y ^ ((n +ℕ m ∸ toℕ i) ∸ m) · y ^ m ∎ ∑Binomial∈I : ∑ (BinomialVec (n +ℕ m) x y) ∈ I ∑Binomial∈I = ∑Closed I (BinomialVec (n +ℕ m) _ _) binomialCoeff∈I contains0 (snd (√ I)) = ∣ 1 , subst-∈ I (sym (0LeftAnnihilates 1r)) ((I .snd) .contains0) ∣ ·Closed (snd (√ I)) r = map λ { (n , xⁿ∈I) → n , subst-∈ I (sym (^-ldist-· r _ n)) ((I .snd) .·Closed (r ^ n) xⁿ∈I) } ^∈√→∈√ : ∀ (I : CommIdeal) (x : R) (n : ℕ) → x ^ n ∈ √ I → x ∈ √ I ^∈√→∈√ I x n = map (λ { (m , [xⁿ]ᵐ∈I) → (n ·ℕ m) , subst-∈ I (sym (^-rdist-·ℕ x n m)) [xⁿ]ᵐ∈I }) ∈→∈√ : ∀ (I : CommIdeal) (x : R) → x ∈ I → x ∈ √ I ∈→∈√ I _ x∈I = ∣ 1 , subst-∈ I (sym (·Rid _)) x∈I ∣ -- important lemma for characterization of the Zariski lattice open KroneckerDelta (CommRing→Ring R') √FGIdealCharLImpl : {n : ℕ} (V : FinVec R n) (I : CommIdeal) → √ ⟨ V ⟩[ R' ] ⊆ √ I → (∀ i → V i ∈ √ I) √FGIdealCharLImpl V I √⟨V⟩⊆√I i = √⟨V⟩⊆√I _ (∈→∈√ ⟨ V ⟩[ R' ] (V i) ∣ (λ j → δ i j) , sym (∑Mul1r _ _ i) ∣) √FGIdealCharRImpl : {n : ℕ} (V : FinVec R n) (I : CommIdeal) → (∀ i → V i ∈ √ I) → √ ⟨ V ⟩[ R' ] ⊆ √ I √FGIdealCharRImpl V I ∀i→Vi∈√I x = PT.elim (λ _ → √ I .fst x .snd) λ { (n , xⁿ∈⟨V⟩) → ^∈√→∈√ I x n (elimHelper _ xⁿ∈⟨V⟩) } where elimHelper : ∀ (y : R) → y ∈ ⟨ V ⟩[ R' ] → y ∈ √ I elimHelper y = PT.elim (λ _ → √ I .fst y .snd) λ { (α , y≡∑αV) → subst-∈ (√ I) (sym y≡∑αV) (∑Closed (√ I) (λ i → α i · V i) (λ i → √ I .snd .·Closed (α i) (∀i→Vi∈√I i))) } √FGIdealChar : {n : ℕ} (V : FinVec R n) (I : CommIdeal) → √ ⟨ V ⟩[ R' ] ⊆ √ I ≃ (∀ i → V i ∈ √ I) √FGIdealChar V I = propBiimpl→Equiv (⊆-isProp (√ ⟨ V ⟩[ R' ] .fst) (√ I .fst)) (isPropΠ (λ _ → √ I .fst _ .snd)) (√FGIdealCharLImpl V I) (√FGIdealCharRImpl V I) √+RContrLIncl : (I J : CommIdeal) → √ (I +i √ J) ⊆ √ (I +i J) √+RContrLIncl I J x = PT.elim (λ _ → isPropPropTrunc) (uncurry (λ n → PT.elim (λ _ → isPropPropTrunc) (uncurry3 (curriedIncl1 n)))) where curriedIncl1 : (n : ℕ) (y : R × R) → (y .fst ∈ I) → (y . snd ∈ √ J) → (x ^ n ≡ y .fst + y .snd) → x ∈ √ (I +i J) curriedIncl1 n (y , z) y∈I = PT.elim (λ _ → isPropΠ λ _ → isPropPropTrunc) Σhelper where yVec : (m : ℕ) → FinVec R m yVec m = (BinomialVec m y z) ∘ suc ∑yVec∈I : ∀ m → ∑ (yVec m) ∈ I ∑yVec∈I zero = I .snd .contains0 ∑yVec∈I (suc m) = ∑Closed I (yVec (suc m)) λ _ → subst-∈ I (useSolver _ _ _ _) (I .snd .·Closed _ y∈I) where useSolver : (bc y y^i z^m-i : R) → (bc · y^i · z^m-i) · y ≡ bc · (y · y^i) · z^m-i useSolver = solve R' path : (m : ℕ) → x ^ n ≡ y + z → x ^ (n ·ℕ m) ≡ ∑ (yVec m) + z ^ m path m p = x ^ (n ·ℕ m) ≡⟨ ^-rdist-·ℕ x n m ⟩ (x ^ n) ^ m ≡⟨ cong (_^ m) p ⟩ (y + z) ^ m ≡⟨ BinomialThm m y z ⟩ ∑ (BinomialVec m y z) ≡⟨ useSolver _ _ ⟩ ∑ (yVec m) + z ^ m ∎ where useSolver : (zm ∑yVec : R) → 1r · 1r · zm + ∑yVec ≡ ∑yVec + zm useSolver = solve R' Σhelper : Σ[ m ∈ ℕ ] (z ^ m ∈ J) → x ^ n ≡ y + z → x ∈ √ (I +i J) Σhelper (m , z^m∈J) x^n≡y+z = ∣ n ·ℕ m , ∣ (∑ (yVec m) , z ^ m) , ∑yVec∈I m , z^m∈J , path m x^n≡y+z ∣ ∣ √+RContrRIncl : (I J : CommIdeal) → √ (I +i J) ⊆ √ (I +i √ J) √+RContrRIncl I J x = PT.elim (λ _ → isPropPropTrunc) (uncurry curriedIncl2) where curriedIncl2 : (n : ℕ) → (x ^ n ∈ (I +i J)) → x ∈ √ ((I +i √ J)) curriedIncl2 n = map λ ((y , z) , y∈I , z∈J , x≡y+z) → n , ∣ (y , z) , y∈I , ∈→∈√ J z z∈J , x≡y+z ∣ √+RContr : (I J : CommIdeal) → √ (I +i √ J) ≡ √ (I +i J) √+RContr I J = CommIdeal≡Char (√+RContrLIncl I J) (√+RContrRIncl I J) √+LContr : (I J : CommIdeal) → √ (√ I +i J) ≡ √ (I +i J) √+LContr I J = cong √ (+iComm (√ I) J) ∙∙ √+RContr J I ∙∙ cong √ (+iComm J I) √·RContrLIncl : (I J : CommIdeal) → √ (I ·i √ J) ⊆ √ (I ·i J) √·RContrLIncl I J x = PT.elim (λ _ → isPropPropTrunc) (uncurry (λ n → PT.elim (λ _ → isPropPropTrunc) (uncurry4 (curriedIncl1 n)))) where curriedIncl1 : (n m : ℕ) (α : FinVec R m × FinVec R m) → (∀ i → α .fst i ∈ I) → (∀ i → α .snd i ∈ √ J) → (x ^ n ≡ linearCombination R' (α .fst) (α .snd)) → x ∈ √ (I ·i J) curriedIncl1 n m (α , β) α∈I β∈√J xⁿ≡∑αβ = ^∈√→∈√ (I ·i J) x n (subst-∈ (√ (I ·i J)) (sym xⁿ≡∑αβ) (∑Closed (√ (I ·i J)) (λ i → α i · β i) λ i → prodHelper i (β∈√J i))) where curriedHelper : ∀ x y → x ∈ I → ∀ l → y ^ l ∈ J → (x · y) ∈ √ (I ·i J) curriedHelper x y x∈I zero 1∈J = subst (λ K → (x · y) ∈ √ K) (sym (·iRContains1id I J 1∈J)) --1∈J → √J ≡ √ ⊃ I (∈→∈√ I _ (·RClosed (I .snd) y x∈I)) curriedHelper x y x∈I (suc l) y^l+1∈J = -- (xy)^l+1 ≡ x^l · x (∈I) · y^l+1 (∈J) ∣ suc l , subst-∈ (I ·i J) (sym (^-ldist-· _ _ (suc l))) (prodInProd I J _ _ (subst-∈ I (·-comm _ _) (I .snd .·Closed (x ^ l) x∈I)) y^l+1∈J) ∣ prodHelper : ∀ i → β i ∈ √ J → α i · β i ∈ √ (I ·i J) prodHelper i = PT.elim (λ _ → isPropPropTrunc) (uncurry (curriedHelper (α i) (β i) (α∈I i))) √·RContrRIncl : (I J : CommIdeal) → √ (I ·i J) ⊆ √ (I ·i √ J) √·RContrRIncl I J x = PT.elim (λ _ → isPropPropTrunc) (uncurry curriedIncl2) where curriedIncl2 : (n : ℕ) → x ^ n ∈ (I ·i J) → x ∈ √ (I ·i √ J) curriedIncl2 n = map λ (m , (α , β) , α∈I , β∈J , xⁿ≡∑αβ) → n , ∣ m , (α , β) , α∈I , (λ i → ∈→∈√ J (β i) (β∈J i)) , xⁿ≡∑αβ ∣ √·RContr : (I J : CommIdeal) → √ (I ·i √ J) ≡ √ (I ·i J) √·RContr I J = CommIdeal≡Char (√·RContrLIncl I J) (√·RContrRIncl I J) √·LContr : (I J : CommIdeal) → √ (√ I ·i J) ≡ √ (I ·i J) √·LContr I J = cong √ (·iComm (√ I) J) ∙∙ √·RContr J I ∙∙ cong √ (·iComm J I) √·IdemLIncl : ∀ (I : CommIdeal) → √ (I ·i I) ⊆ √ I √·IdemLIncl I x = map λ (n , x^n∈II) → (n , ·iLincl I I _ x^n∈II) √·IdemRIncl : ∀ (I : CommIdeal) → √ I ⊆ √ (I ·i I) √·IdemRIncl I x = map λ (n , x^n∈I) → (n +ℕ n , subst-∈ (I ·i I) (·-of-^-is-^-of-+ x n n) -- x²ⁿ≡xⁿ (∈I) · xⁿ (∈I) (prodInProd I I _ _ x^n∈I x^n∈I)) √·Idem : ∀ (I : CommIdeal) → √ (I ·i I) ≡ √ I √·Idem I = CommIdeal≡Char (√·IdemLIncl I) (√·IdemRIncl I) √·Absorb+LIncl : ∀ (I J : CommIdeal) → √ (I ·i (I +i J)) ⊆ √ I √·Absorb+LIncl I J x = map λ (n , x^n∈I[I+J]) → (n , ·iLincl I (I +i J) _ x^n∈I[I+J]) √·Absorb+RIncl : ∀ (I J : CommIdeal) → √ I ⊆ √ (I ·i (I +i J)) √·Absorb+RIncl I J x = map λ (n , x^n∈I) → (n +ℕ n , subst-∈ (I ·i (I +i J)) (·-of-^-is-^-of-+ x n n) -- x²ⁿ≡xⁿ (∈I) · xⁿ (∈I⊆I+J) (prodInProd I (I +i J) _ _ x^n∈I (+iLincl I J _ x^n∈I))) √·Absorb+ : ∀ (I J : CommIdeal) → √ (I ·i (I +i J)) ≡ √ I √·Absorb+ I J = CommIdeal≡Char (√·Absorb+LIncl I J) (√·Absorb+RIncl I J)
46.313559
96
0.451418
ad4da7f550d20f00277bf7289df850162ccfa8f7
2,704
agda
Agda
Rings/Cosets.agda
Smaug123/agdaproofs
0f4230011039092f58f673abcad8fb0652e6b562
[ "MIT" ]
4
2019-08-08T12:44:19.000Z
2022-01-28T06:04:15.000Z
Rings/Cosets.agda
Smaug123/agdaproofs
0f4230011039092f58f673abcad8fb0652e6b562
[ "MIT" ]
14
2019-01-06T21:11:59.000Z
2020-04-11T11:03:39.000Z
Rings/Cosets.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 Functions.Definition open import Groups.Definition open import Rings.Homomorphisms.Definition open import Setoids.Setoids open import Rings.Definition open import Sets.EquivalenceRelations open import Groups.Lemmas open import Rings.Ideals.Definition module Rings.Cosets {a b c : _} {A : Set a} {S : Setoid {a} {b} A} {_+_ _*_ : A → A → A} (R : Ring S _+_ _*_) {pred : A → Set c} (ideal : Ideal R pred) where open Ring R open import Rings.Lemmas R open import Groups.Subgroups.Normal.Lemmas open import Groups.Cosets additiveGroup (Ideal.isSubgroup ideal) open Setoid S open Equivalence eq open Ideal ideal open Group additiveGroup cosetRing : Ring cosetSetoid _+_ _*_ Ring.additiveGroup cosetRing = cosetGroup (abelianGroupSubgroupIsNormal (Ideal.isSubgroup ideal) abelianUnderlyingGroup) Ring.*WellDefined cosetRing {r} {s} {t} {u} r=t s=u = need where r=t' : pred ((inverse t + r) * u) r=t' = accumulatesTimes r=t s=u' : pred ((inverse u + s) * r) s=u' = accumulatesTimes s=u need : pred (inverse (t * u) + (r * s)) need = isSubset (transitive (+WellDefined (*DistributesOver+') *DistributesOver+') (transitive +Associative (+WellDefined (transitive (symmetric +Associative) (transitive (+WellDefined ringMinusExtracts' (transitive (+WellDefined reflexive (transitive ringMinusExtracts' (inverseWellDefined additiveGroup *Commutative))) invRight)) identRight)) *Commutative))) (closedUnderPlus r=t' s=u') Ring.1R cosetRing = 1R Ring.groupIsAbelian cosetRing = isSubset (transitive (symmetric invLeft) (+WellDefined (inverseWellDefined additiveGroup groupIsAbelian) reflexive)) containsIdentity Ring.*Associative cosetRing = isSubset (transitive (symmetric invLeft) (+WellDefined (inverseWellDefined additiveGroup *Associative) reflexive)) containsIdentity Ring.*Commutative cosetRing {a} {b} = isSubset (transitive (symmetric invLeft) (+WellDefined (inverseWellDefined additiveGroup *Commutative) reflexive)) containsIdentity Ring.*DistributesOver+ cosetRing = isSubset (symmetric (transitive (+WellDefined (inverseWellDefined additiveGroup (symmetric *DistributesOver+)) reflexive) invLeft)) containsIdentity Ring.identIsIdent cosetRing = isSubset (symmetric (transitive (Group.+WellDefined additiveGroup reflexive identIsIdent) invLeft)) containsIdentity cosetRingHom : RingHom R cosetRing id RingHom.preserves1 cosetRingHom = isSubset (symmetric invLeft) (Ideal.containsIdentity ideal) RingHom.ringHom cosetRingHom = isSubset (symmetric invLeft) (Ideal.containsIdentity ideal) RingHom.groupHom cosetRingHom = cosetGroupHom (abelianGroupSubgroupIsNormal (Ideal.isSubgroup ideal) abelianUnderlyingGroup)
58.782609
392
0.781065
31fed3d08e43dd0d75a124ee56aa491b8809518f
15,545
agda
Agda
theorems/homotopy/blakersmassey/CoherenceData.agda
mikeshulman/HoTT-Agda
e7d663b63d89f380ab772ecb8d51c38c26952dbb
[ "MIT" ]
null
null
null
theorems/homotopy/blakersmassey/CoherenceData.agda
mikeshulman/HoTT-Agda
e7d663b63d89f380ab772ecb8d51c38c26952dbb
[ "MIT" ]
null
null
null
theorems/homotopy/blakersmassey/CoherenceData.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 hiding (left; right) import homotopy.WedgeExtension as WedgeExt module homotopy.blakersmassey.CoherenceData {i j k} {A : Type i} {B : Type j} (Q : A → B → Type k) m (f-conn : ∀ a → is-connected (S m) (Σ B (λ b → Q a b))) n (g-conn : ∀ b → is-connected (S n) (Σ A (λ a → Q a b))) where open import homotopy.blakersmassey.Pushout Q {- goal : Trunc (m +2+ n) (hfiber (λ q₁₀ → bmglue q₀₀ ∙' ! (bmglue q₁₀) ∙' bmglue q₁₁) r) ≃ Trunc (m +2+ n) (hfiber bmglue r) -} private swap-level : (m +2+ n) -Type (lmax i (lmax j k)) → (n +2+ m) -Type (lmax i (lmax j k)) swap-level (X , level) = X , new-level where abstract new-level = transport (λ o → has-level o X) (+2+-comm m n) level α₁=α₁α₂⁻¹α₂ : ∀ {p₁ p₂ p₃ : BMPushout} (α₁ : p₁ == p₂) (α₂ : p₃ == p₂) → α₁ == α₁ ∙' ! α₂ ∙' α₂ α₁=α₁α₂⁻¹α₂ _ idp = idp α₁=α₂α₂⁻¹α₁ : ∀ {p₁ p₂ p₃ : BMPushout} (α₁ : p₁ == p₂) (α₂ : p₁ == p₃) → α₁ == α₂ ∙' ! α₂ ∙' α₁ α₁=α₂α₂⁻¹α₁ idp α₂ = ! (!-inv'-r α₂) private path-lemma₁ : ∀ {a₀ a₁ b} (q₀ : Q a₀ b) (q₁ : Q a₁ b) → bmglue q₀ == bmglue q₀ ∙' ! (bmglue q₁) ∙' bmglue q₁ path-lemma₁ q₀ q₁ = α₁=α₁α₂⁻¹α₂ (bmglue q₀) (bmglue q₁) path-lemma₂ : ∀ {a b₀ b₁} (q₀ : Q a b₀) (q₁ : Q a b₁) → bmglue q₀ == bmglue q₁ ∙' ! (bmglue q₁) ∙' bmglue q₀ path-lemma₂ q₀ q₁ = α₁=α₂α₂⁻¹α₁ (bmglue q₀) (bmglue q₁) abstract path-coherence : ∀ {a b} (q : Q a b) → path-lemma₁ q q == path-lemma₂ q q path-coherence q = lemma (bmglue q) where lemma : ∀ {p₀ p₁ : BMPushout} (path : p₀ == p₁) → α₁=α₁α₂⁻¹α₂ path path == α₁=α₂α₂⁻¹α₁ path path lemma idp = idp module To {a₁ b₀} (q₁₀ : Q a₁ b₀) where U = Σ A λ a → Q a b₀ u₀ : U u₀ = (a₁ , q₁₀) V = Σ B λ b → Q a₁ b v₀ : V v₀ = (b₀ , q₁₀) P : U → V → Type (lmax i (lmax j k)) P u v = (r : bmleft (fst u) == bmright (fst v)) → bmglue (snd u) ∙' ! (bmglue q₁₀) ∙' bmglue (snd v) == r → Trunc (m +2+ n) (hfiber bmglue r) template : ∀ (u : U) (v : V) → (r : bmleft (fst u) == bmright (fst v)) → (shift : bmglue (snd u) ∙' ! (bmglue q₁₀) ∙' bmglue (snd v) == r) → ∀ q₀₁ → bmglue q₀₁ == bmglue (snd u) ∙' ! (bmglue q₁₀) ∙' bmglue (snd v) → Trunc (m +2+ n) (hfiber bmglue r) template u v r shift q₀₁ path = [ q₀₁ , path ∙' shift ] f = λ u r shift → template u v₀ r shift (snd u) (path-lemma₁ (snd u) q₁₀) g = λ v r shift → template u₀ v r shift (snd v) (path-lemma₂ (snd v) q₁₀) p' = λ r shift → ap (template u₀ v₀ r shift q₁₀) (path-coherence q₁₀) p = λ= λ r → λ= λ shift → p' r shift args : WedgeExt.args {A = U} {a₀ = u₀} {B = V} {b₀ = v₀} args = record { n = n; m = m; cA = g-conn b₀; cB = f-conn a₁; P = λ u v → swap-level $ P u v , Π-level λ _ → Π-level λ _ → Trunc-level; f = f; g = g; p = p} ext : ∀ u v → P u v ext = WedgeExt.ext args β-l : ∀ u r shift → ext u v₀ r shift == f u r shift β-l u r shift = app= (app= (WedgeExt.β-l u) r) shift β-r : ∀ v r shift → ext u₀ v r shift == g v r shift β-r v r shift = app= (app= (WedgeExt.β-r v) r) shift abstract coh : ∀ r shift → ! (β-l u₀ r shift) ∙ β-r v₀ r shift == p' r shift coh r shift = ! (β-l u₀ r shift) ∙ β-r v₀ r shift =⟨ ap (_∙ β-r v₀ r shift) (!-ap (_$ shift) (app= (WedgeExt.β-l u₀) r)) ∙ ∙-ap (_$ shift) (! (app= (WedgeExt.β-l {r = args} u₀) r)) (app= (WedgeExt.β-r {r = args} v₀) r) ∙ ap (λ p → app= p shift) ( ap (_∙ app= (WedgeExt.β-r {r = args} v₀) r) (!-ap (_$ r) (WedgeExt.β-l {r = args} u₀)) ∙ ∙-ap (_$ r) (! (WedgeExt.β-l {r = args} u₀)) (WedgeExt.β-r {r = args} v₀)) ⟩ app= (app= (! (WedgeExt.β-l {r = args} u₀) ∙ WedgeExt.β-r {r = args} v₀) r) shift =⟨ ap (λ p → app= (app= p r) shift) (WedgeExt.coh {r = args}) ⟩ app= (app= (λ= λ r → λ= λ shift → p' r shift) r) shift =⟨ ap (λ p → app= p shift) (app=-β (λ r → λ= λ shift → p' r shift) r) ∙ app=-β (λ shift → p' r shift) shift ⟩ p' r shift =∎ to' : ∀ {a₀ a₁ b₀ b₁} (q₀₀ : Q a₀ b₀) (q₁₁ : Q a₁ b₁) → (r : bmleft a₀ == bmright b₁) → hfiber (λ q₁₀ → bmglue q₀₀ ∙' ! (bmglue q₁₀) ∙' bmglue q₁₁) r → Trunc (m +2+ n) (hfiber bmglue r) to' q₀₀ q₁₁ r (q₁₀ , shift) = To.ext q₁₀ (_ , q₀₀) (_ , q₁₁) r shift to : ∀ {a₀ a₁ b₀ b₁} (q₀₀ : Q a₀ b₀) (q₁₁ : Q a₁ b₁) → (r : bmleft a₀ == bmright b₁) → Trunc (m +2+ n) (hfiber (λ q₁₀ → bmglue q₀₀ ∙' ! (bmglue q₁₀) ∙' bmglue q₁₁) r) → Trunc (m +2+ n) (hfiber bmglue r) to q₀₀ q₁₁ r = Trunc-rec Trunc-level (to' q₀₀ q₁₁ r) module From {a₀ b₁} (q₀₁ : Q a₀ b₁) where U = Σ A λ a → Q a b₁ u₀ : U u₀ = (a₀ , q₀₁) V = Σ B λ b → Q a₀ b v₀ : V v₀ = (b₁ , q₀₁) P : U → V → Type (lmax i (lmax j k)) P u v = (r : bmleft a₀ == bmright b₁) → bmglue q₀₁ == r → Trunc (m +2+ n) (hfiber (λ q₁₀ → bmglue (snd v) ∙' ! (bmglue q₁₀) ∙' bmglue (snd u)) r) template : ∀ (u : U) (v : V) → (r : bmleft a₀ == bmright b₁) → (shift : bmglue q₀₁ == r) → ∀ q₁₀ → bmglue q₀₁ == bmglue (snd v) ∙' ! (bmglue q₁₀) ∙' bmglue (snd u) → Trunc (m +2+ n) (hfiber (λ q₁₀ → bmglue (snd v) ∙' ! (bmglue q₁₀) ∙' bmglue (snd u)) r) template u v r shift q₁₀ path = [ q₁₀ , ! path ∙' shift ] f = λ u r shift → template u v₀ r shift (snd u) (path-lemma₁ q₀₁ (snd u)) g = λ v r shift → template u₀ v r shift (snd v) (path-lemma₂ q₀₁ (snd v)) p' = λ r shift → ap (template u₀ v₀ r shift q₀₁) (path-coherence q₀₁) p = λ= λ r → λ= λ shift → p' r shift args : WedgeExt.args {A = U} {a₀ = u₀} {B = V} {b₀ = v₀} args = record { n = n; m = m; cA = g-conn b₁; cB = f-conn a₀; P = λ u v → swap-level $ P u v , Π-level λ _ → Π-level λ _ → Trunc-level; f = f; g = g; p = p} ext : ∀ u v → P u v ext = WedgeExt.ext args β-l : ∀ u r shift → ext u v₀ r shift == f u r shift β-l u r shift = app= (app= (WedgeExt.β-l u) r) shift β-r : ∀ v r shift → ext u₀ v r shift == g v r shift β-r v r shift = app= (app= (WedgeExt.β-r v) r) shift abstract coh : ∀ r shift → ! (β-l u₀ r shift) ∙ β-r v₀ r shift == p' r shift coh r shift = ! (β-l u₀ r shift) ∙ β-r v₀ r shift =⟨ ap (_∙ β-r v₀ r shift) (!-ap (_$ shift) (app= β-l' r)) ∙ ∙-ap (_$ shift) (! (app= β-l' r)) (app= β-r' r) ∙ ap (λ p → app= p shift) ( ap (_∙ app= β-r' r) (!-ap (_$ r) β-l') ∙ ∙-ap (_$ r) (! β-l') β-r') ⟩ app= (app= (! β-l' ∙ β-r') r) shift =⟨ ap (λ p → app= (app= p r) shift) (WedgeExt.coh {r = args}) ⟩ app= (app= (λ= λ r → λ= λ shift → p' r shift) r) shift =⟨ ap (λ p → app= p shift) (app=-β (λ r → λ= λ shift → p' r shift) r) ∙ app=-β (λ shift → p' r shift) shift ⟩ p' r shift =∎ where β-l' = WedgeExt.β-l {r = args} u₀ β-r' = WedgeExt.β-r {r = args} v₀ from' : ∀ {a₀ a₁ b₀ b₁} (q₀₀ : Q a₀ b₀) (q₁₁ : Q a₁ b₁) → (r : bmleft a₀ == bmright b₁) → hfiber bmglue r → Trunc (m +2+ n) (hfiber (λ q₁₀ → bmglue q₀₀ ∙' ! (bmglue q₁₀) ∙' bmglue q₁₁) r) from' q₀₀ q₁₁ r (q₀₁ , shift) = From.ext q₀₁ (_ , q₁₁) (_ , q₀₀) r shift from : ∀ {a₀ a₁ b₀ b₁} (q₀₀ : Q a₀ b₀) (q₁₁ : Q a₁ b₁) → (r : bmleft a₀ == bmright b₁) → Trunc (m +2+ n) (hfiber bmglue r) → Trunc (m +2+ n) (hfiber (λ q₁₀ → bmglue q₀₀ ∙' ! (bmglue q₁₀) ∙' bmglue q₁₁) r) from q₀₀ q₁₁ r = Trunc-rec Trunc-level (from' q₀₀ q₁₁ r) -- Equivalence {- First step: Pack relevant rules into records. -} record βPair {a₀ a₁ b₀ b₁} (q₀₀ : Q a₀ b₀) (q₁₁ : Q a₁ b₁) (q₀₁ : Q a₀ b₁) (q₁₀ : Q a₁ b₀) (r : bmleft a₀ == bmright b₁) : Type (lmax i (lmax j k)) where constructor βpair field path : bmglue q₀₁ == bmglue q₀₀ ∙' ! (bmglue q₁₀) ∙' bmglue q₁₁ to-β : ∀ shift → To.ext q₁₀ (_ , q₀₀) (_ , q₁₁) r shift == To.template q₁₀ (_ , q₀₀) (_ , q₁₁) r shift q₀₁ path from-β : ∀ shift → From.ext q₀₁ (_ , q₁₁) (_ , q₀₀) r shift == From.template q₀₁ (_ , q₁₁) (_ , q₀₀) r shift q₁₀ path βpair-bmleft : ∀ {a₀ a₁ b} (q₀ : Q a₀ b) (q₁ : Q a₁ b) r → βPair q₀ q₁ q₀ q₁ r βpair-bmleft q₀ q₁ r = record { path = path-lemma₁ q₀ q₁ ; to-β = To.β-l q₁ (_ , q₀) r ; from-β = From.β-l q₀ (_ , q₁) r } βpair-bmright : ∀ {a b₀ b₁} (q₀ : Q a b₀) (q₁ : Q a b₁) r → βPair q₀ q₁ q₁ q₀ r βpair-bmright q₀ q₁ r = record { path = path-lemma₂ q₁ q₀ ; to-β = To.β-r q₀ (_ , q₁) r ; from-β = From.β-r q₁ (_ , q₀) r } abstract βpair= : ∀ {a₀ a₁} {b₀ b₁} (q₀₀ : Q a₀ b₀) (q₁₁ : Q a₁ b₁) (q₀₁ : Q a₀ b₁) (q₁₀ : Q a₁ b₀) (r : bmleft a₀ == bmright b₁) {p₁ p₂ : bmglue q₀₁ == bmglue q₀₀ ∙' ! (bmglue q₁₀) ∙' bmglue q₁₁} (p= : p₁ == p₂) {toβ₁} {toβ₂} (toβ= : ∀ shift → toβ₁ shift ∙ ap (To.template q₁₀ (_ , q₀₀) (_ , q₁₁) r shift q₀₁) p= == toβ₂ shift) {fromβ₁} {fromβ₂} (fromβ= : ∀ shift → fromβ₁ shift ∙ ap (From.template q₀₁ (_ , q₁₁) (_ , q₀₀) r shift q₁₀) p= == fromβ₂ shift) → βpair p₁ toβ₁ fromβ₁ == βpair p₂ toβ₂ fromβ₂ βpair= q₀₀ q₁₁ q₀₁ q₁₀ r {p} idp toβ= fromβ= = lemma (λ= λ shift → ! (∙-unit-r _) ∙ toβ= shift) (λ= λ shift → ! (∙-unit-r _) ∙ fromβ= shift) where lemma : ∀ {toβ₁} {toβ₂} (toβ= : toβ₁ == toβ₂) {fromβ₁} {fromβ₂} (fromβ= : fromβ₁ == fromβ₂) → βpair p toβ₁ fromβ₁ == βpair p toβ₂ fromβ₂ lemma idp idp = idp abstract βpair-glue : ∀ {a} {b} (q : Q a b) r → βpair-bmleft q q r == βpair-bmright q q r βpair-glue q r = βpair= q q q q r (path-coherence q) (λ shift → To.β-l q (_ , q) r shift ∙ To.p' q r shift =⟨ ! $ ap (To.β-l q (_ , q) r shift ∙_) (To.coh q r shift) ⟩ To.β-l q (_ , q) r shift ∙ ! (To.β-l q (_ , q) r shift) ∙ To.β-r q (_ , q) r shift =⟨ ! (∙-assoc (To.β-l q (_ , q) r shift) (! (To.β-l q (_ , q) r shift)) (To.β-r q (_ , q) r shift)) ∙ ap (_∙ To.β-r q (_ , q) r shift) (!-inv-r (To.β-l q (_ , q) r shift)) ⟩ To.β-r q (_ , q) r shift ∎) (λ shift → From.β-l q (_ , q) r shift ∙ From.p' q r shift =⟨ ! $ ap (From.β-l q (_ , q) r shift ∙_) (From.coh q r shift) ⟩ From.β-l q (_ , q) r shift ∙ ! (From.β-l q (_ , q) r shift) ∙ From.β-r q (_ , q) r shift =⟨ ! (∙-assoc (From.β-l q (_ , q) r shift) (! (From.β-l q (_ , q) r shift)) (From.β-r q (_ , q) r shift)) ∙ ap (_∙ From.β-r q (_ , q) r shift) (!-inv-r (From.β-l q (_ , q) r shift)) ⟩ From.β-r q (_ , q) r shift ∎) -- Lemmas private abstract to-from-template : ∀ {a₀ a₁ b₀ b₁} {q₀₀ : Q a₀ b₀} {q₁₁ : Q a₁ b₁} {q₀₁ : Q a₀ b₁} {q₁₀ : Q a₁ b₀} {r} (params : βPair q₀₀ q₁₁ q₀₁ q₁₀ r) shift → to q₀₀ q₁₁ r (from q₀₀ q₁₁ r [ q₀₁ , shift ]) == [ q₀₁ , shift ] to-from-template {q₀₀ = q₀₀} {q₁₁} {q₀₁} {q₁₀} {r} params shift = to q₀₀ q₁₁ r (from q₀₀ q₁₁ r [ q₀₁ , shift ]) =⟨ ap (to q₀₀ q₁₁ r) $ from-β shift ⟩ to q₀₀ q₁₁ r [ q₁₀ , ! path ∙' shift ] =⟨ to-β (! path ∙' shift) ⟩ [ q₀₁ , path ∙' ! path ∙' shift ] =⟨ ap (λ p → [ q₀₁ , p ]) $ ! (∙'-assoc path (! path) shift) ∙ ap (_∙' shift) (!-inv'-r path) ∙ ∙'-unit-l shift ⟩ [ q₀₁ , shift ] =∎ where open βPair params module FromTo {a₁ b₀} (q₁₀ : Q a₁ b₀) where -- upper U = To.U q₁₀ u₀ = To.u₀ q₁₀ -- lower V = To.V q₁₀ v₀ = To.v₀ q₁₀ P : U → V → Type (lmax i (lmax j k)) P u v = (r : bmleft (fst u) == bmright (fst v)) → (shift : bmglue (snd u) ∙' ! (bmglue q₁₀) ∙' bmglue (snd v) == r) → from (snd u) (snd v) r (to (snd u) (snd v) r [ q₁₀ , shift ]) == [ q₁₀ , shift ] abstract template : ∀ (u : U) (v : V) r shift q₀₁ → βPair (snd u) (snd v) q₀₁ q₁₀ r → from (snd u) (snd v) r (to (snd u) (snd v) r [ q₁₀ , shift ]) == [ q₁₀ , shift ] template (_ , q₀₀) (_ , q₁₁) r shift q₀₁ params = from q₀₀ q₁₁ r (to q₀₀ q₁₁ r [ q₁₀ , shift ]) =⟨ ap (from q₀₀ q₁₁ r) $ to-β shift ⟩ from q₀₀ q₁₁ r [ q₀₁ , path ∙' shift ] =⟨ from-β (path ∙' shift) ⟩ [ q₁₀ , ! path ∙' path ∙' shift ] =⟨ ap (λ p → [ q₁₀ , p ]) $ ! (∙'-assoc (! path) path shift) ∙ ap (_∙' shift) (!-inv'-l path) ∙ ∙'-unit-l shift ⟩ [ q₁₀ , shift ] =∎ where open βPair params f = λ u r shift → template u v₀ r shift (snd u) (βpair-bmleft (snd u) q₁₀ r) g = λ v r shift → template u₀ v r shift (snd v) (βpair-bmright q₁₀ (snd v) r) abstract p : f u₀ == g v₀ p = λ= λ r → λ= λ shift → ap (template u₀ v₀ r shift q₁₀) (βpair-glue q₁₀ r) args : WedgeExt.args {A = U} {a₀ = u₀} {B = V} {b₀ = v₀} args = record { n = n; m = m; cA = g-conn b₀; cB = f-conn a₁; P = λ u v → swap-level $ P u v , Π-level λ _ → Π-level λ _ → =-preserves-level Trunc-level; f = f; g = g; p = p} abstract ext : ∀ u v → P u v ext = WedgeExt.ext args abstract from-to' : ∀ {a₀ a₁ b₀ b₁} (q₀₀ : Q a₀ b₀) (q₁₁ : Q a₁ b₁) r fiber → from q₀₀ q₁₁ r (to' q₀₀ q₁₁ r fiber) == [ fiber ] from-to' q₀₀ q₁₁ r (q₁₀ , shift) = FromTo.ext q₁₀ (_ , q₀₀) (_ , q₁₁) r shift from-to : ∀ {a₀ a₁ b₀ b₁} (q₀₀ : Q a₀ b₀) (q₁₁ : Q a₁ b₁) r fiber → from q₀₀ q₁₁ r (to q₀₀ q₁₁ r fiber) == fiber from-to q₀₀ q₁₁ r = Trunc-elim (λ _ → =-preserves-level Trunc-level) (from-to' q₀₀ q₁₁ r) module ToFrom {a₀ b₁} (q₀₁ : Q a₀ b₁) where -- upper U = From.U q₀₁ u₀ = From.u₀ q₀₁ -- lower V = From.V q₀₁ v₀ = From.v₀ q₀₁ P : U → V → Type (lmax i (lmax j k)) P u v = (r : bmleft a₀ == bmright b₁) → (shift : bmglue q₀₁ == r) → to (snd v) (snd u) r (from (snd v) (snd u) r [ q₀₁ , shift ]) == [ q₀₁ , shift ] abstract template : ∀ (u : U) (v : V) r shift q₁₀ → βPair (snd v) (snd u) q₀₁ q₁₀ r → to (snd v) (snd u) r (from (snd v) (snd u) r [ q₀₁ , shift ]) == [ q₀₁ , shift ] template (_ , q₁₁) (_ , q₀₀) r shift q₁₀ params = to q₀₀ q₁₁ r (from q₀₀ q₁₁ r [ q₀₁ , shift ]) =⟨ ap (to q₀₀ q₁₁ r) $ from-β shift ⟩ to q₀₀ q₁₁ r [ q₁₀ , ! path ∙' shift ] =⟨ to-β (! path ∙' shift) ⟩ [ q₀₁ , path ∙' ! path ∙' shift ] =⟨ ap (λ p → [ q₀₁ , p ]) $ ! (∙'-assoc path (! path) shift) ∙ ap (_∙' shift) (!-inv'-r path) ∙ ∙'-unit-l shift ⟩ [ q₀₁ , shift ] =∎ where open βPair params f = λ u r shift → template u v₀ r shift (snd u) (βpair-bmleft q₀₁ (snd u) r) g = λ v r shift → template u₀ v r shift (snd v) (βpair-bmright (snd v) q₀₁ r) abstract p : f u₀ == g v₀ p = λ= λ r → λ= λ shift → ap (template u₀ v₀ r shift q₀₁) (βpair-glue q₀₁ r) args : WedgeExt.args {A = U} {a₀ = u₀} {B = V} {b₀ = v₀} args = record { n = n; m = m; cA = g-conn b₁; cB = f-conn a₀; P = λ u v → swap-level $ P u v , Π-level λ _ → Π-level λ _ → =-preserves-level Trunc-level; f = f; g = g; p = p} abstract ext : ∀ u v → P u v ext = WedgeExt.ext args abstract to-from' : ∀ {a₀ a₁ b₀ b₁} (q₀₀ : Q a₀ b₀) (q₁₁ : Q a₁ b₁) r fiber → to q₀₀ q₁₁ r (from' q₀₀ q₁₁ r fiber) == [ fiber ] to-from' q₀₀ q₁₁ r (q₀₁ , shift) = ToFrom.ext q₀₁ (_ , q₁₁) (_ , q₀₀) r shift to-from : ∀ {a₀ a₁ b₀ b₁} (q₀₀ : Q a₀ b₀) (q₁₁ : Q a₁ b₁) r fiber → to q₀₀ q₁₁ r (from q₀₀ q₁₁ r fiber) == fiber to-from q₀₀ q₁₁ r = Trunc-elim (λ _ → =-preserves-level Trunc-level) (to-from' q₀₀ q₁₁ r) eqv : ∀ {a₀ a₁ b₀ b₁} (q₀₀ : Q a₀ b₀) (q₁₁ : Q a₁ b₁) r → Trunc (m +2+ n) (hfiber (λ q₁₀ → bmglue q₀₀ ∙' ! (bmglue q₁₀) ∙' bmglue q₁₁) r) ≃ Trunc (m +2+ n) (hfiber bmglue r) eqv q₀₀ q₁₁ r = equiv (to q₀₀ q₁₁ r) (from q₀₀ q₁₁ r) (to-from q₀₀ q₁₁ r) (from-to q₀₀ q₁₁ r)
37.822384
121
0.508652
4150d4175acdfb7e145bcdea63358635199fb3b8
3,141
agda
Agda
src/Categories/Diagram/Colimit.agda
jaykru/agda-categories
a4053cf700bcefdf73b857c3352f1eae29382a60
[ "MIT" ]
279
2019-06-01T14:36:40.000Z
2022-03-22T00:40:14.000Z
src/Categories/Diagram/Colimit.agda
seanpm2001/agda-categories
d9e4f578b126313058d105c61707d8c8ae987fa8
[ "MIT" ]
236
2019-06-01T14:53:54.000Z
2022-03-28T14:31:43.000Z
src/Categories/Diagram/Colimit.agda
seanpm2001/agda-categories
d9e4f578b126313058d105c61707d8c8ae987fa8
[ "MIT" ]
64
2019-06-02T16:58:15.000Z
2022-03-14T02:00:59.000Z
{-# OPTIONS --without-K --safe #-} open import Categories.Category open import Categories.Functor hiding (id) -- Coimit of a Cocone over a Functor F : J → C module Categories.Diagram.Colimit {o ℓ e} {o′ ℓ′ e′} {C : Category o ℓ e} {J : Category o′ ℓ′ e′} (F : Functor J C) where private module C = Category C module J = Category J open C open HomReasoning open Equiv open Functor F open import Level open import Data.Product using (proj₂) open import Categories.Category.Construction.Cocones F renaming (Cocone⇒ to _⇨_) open import Categories.Object.Initial as I hiding (up-to-iso; transport-by-iso) open import Categories.Morphism.Reasoning C open import Categories.Morphism C open import Categories.Morphism Cocones as MC using () renaming (_≅_ to _⇔_) private variable K K′ : Cocone A B : J.Obj X Y Z : Obj q : K ⇨ K′ -- A Colimit is an Initial object in the category of Cocones -- (This could be unpacked...) record Colimit : Set (o ⊔ ℓ ⊔ e ⊔ o′ ⊔ ℓ′ ⊔ e′) where field initial : Initial Cocones module initial = Initial initial open initial using () renaming (⊥ to colimit) public open Cocone colimit hiding (coapex) renaming (N to coapex; ψ to proj; commute to colimit-commute) public rep-cocone : ∀ K → colimit ⇨ K rep-cocone K = initial.! {K} rep : ∀ K → coapex ⇒ Cocone.N K rep K = arr where open _⇨_ (rep-cocone K) unrep : coapex ⇒ X → Cocone unrep f = record { coapex = record { ψ = λ A → f ∘ proj A ; commute = λ g → pullʳ (colimit-commute g) } } coconify : (f : coapex ⇒ X) → colimit ⇨ unrep f coconify f = record { arr = f ; commute = refl } commute : rep K ∘ proj A ≈ Cocone.ψ K A commute {K = K} = _⇨_.commute (rep-cocone K) unrep-cone : (colimit ⇨ K) → Cocone unrep-cone f = unrep (_⇨_.arr f) g-η : ∀ {f : coapex ⇒ X} → rep (unrep f) ≈ f g-η {f = f} = initial.!-unique (coconify f) η-cocone : Cocones [ rep-cocone colimit ≈ Category.id Cocones ] η-cocone = initial.⊥-id (rep-cocone colimit) η : rep colimit ≈ id η = η-cocone rep-cocone∘ : Cocones [ Cocones [ q ∘ rep-cocone K ] ≈ rep-cocone K′ ] rep-cocone∘ {K = K} {q = q} = Equiv.sym (initial.!-unique (Cocones [ q ∘ rep-cocone K ])) rep∘ : ∀ {q : K ⇨ K′} → _⇨_.arr q ∘ rep K ≈ rep K′ rep∘ {q = q} = rep-cocone∘ {q = q} rep-cone-self-id : Cocones [ rep-cocone colimit ≈ Cocones.id ] rep-cone-self-id = initial.!-unique ( Cocones.id ) rep-self-id : rep colimit ≈ id rep-self-id = rep-cone-self-id open Colimit up-to-iso-cone : (L₁ L₂ : Colimit) → colimit L₁ ⇔ colimit L₂ up-to-iso-cone L₁ L₂ = I.up-to-iso Cocones (initial L₁) (initial L₂) up-to-iso : (L₁ L₂ : Colimit) → coapex L₁ ≅ coapex L₂ up-to-iso L₁ L₂ = iso-cocone⇒iso-coapex (up-to-iso-cone L₁ L₂) transport-by-iso-cocone : (C : Colimit) → colimit C ⇔ K → Colimit transport-by-iso-cocone C C⇿K = record { initial = I.transport-by-iso Cocones (initial C) C⇿K } transport-by-iso : (C : Colimit) → coapex C ≅ X → Colimit transport-by-iso C C≅X = transport-by-iso-cocone C (proj₂ p) where p = cocone-resp-iso (colimit C) C≅X
28.816514
106
0.633875
5963aaae30787d38262a0deae2134e3d6bab7a95
460
agda
Agda
vendor/stdlib/src/Category/Functor.agda
isabella232/Lemmachine
8ef786b40e4a9ab274c6103dc697dcb658cf3db3
[ "MIT" ]
56
2015-01-20T02:11:42.000Z
2021-12-21T17:02:19.000Z
vendor/stdlib/src/Category/Functor.agda
larrytheliquid/Lemmachine
8ef786b40e4a9ab274c6103dc697dcb658cf3db3
[ "MIT" ]
1
2022-03-12T12:17:51.000Z
2022-03-12T12:17:51.000Z
vendor/stdlib/src/Category/Functor.agda
isabella232/Lemmachine
8ef786b40e4a9ab274c6103dc697dcb658cf3db3
[ "MIT" ]
3
2015-07-21T16:37:58.000Z
2022-03-12T11:54:10.000Z
------------------------------------------------------------------------ -- Functors ------------------------------------------------------------------------ -- Note that currently the functor laws are not included here. module Category.Functor where open import Data.Function record RawFunctor (f : Set → Set) : Set₁ where infixl 4 _<$>_ _<$_ field _<$>_ : ∀ {a b} → (a → b) → f a → f b _<$_ : ∀ {a b} → a → f b → f a x <$ y = const x <$> y
24.210526
72
0.393478
d003353582228dec49108bd7bf0dd769c8009935
318
agda
Agda
archive/agda-3/src/Test/SubstitunctionPropId.agda
m0davis/oscar
52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb
[ "RSA-MD" ]
null
null
null
archive/agda-3/src/Test/SubstitunctionPropId.agda
m0davis/oscar
52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb
[ "RSA-MD" ]
1
2019-04-29T00:35:04.000Z
2019-05-11T23:33:04.000Z
archive/agda-3/src/Test/SubstitunctionPropId.agda
m0davis/oscar
52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb
[ "RSA-MD" ]
null
null
null
open import Everything module Test.SubstitunctionPropId {𝔭} (𝔓 : Ø 𝔭) where open Substitunction 𝔓 relpropid-Substitunction : ∀ {m n ℓ} {f : Substitunction m n} (P : LeftExtensionṖroperty ℓ Substitunction Proposextensequality m) (let P₀ = π₀ (π₀ P)) → P₀ f → P₀ (ε ∙ f) relpropid-Substitunction P pf = hmap _ P pf
31.8
171
0.72327
59d34030e3c027ac7a820564057131655e15b902
1,425
agda
Agda
Cats/Category/Constructions/Terminal.agda
JLimperg/cats
1ad7b243acb622d46731e9ae7029408db6e561f1
[ "MIT" ]
24
2017-11-03T15:18:57.000Z
2021-08-06T05:00:46.000Z
Cats/Category/Constructions/Terminal.agda
JLimperg/cats
1ad7b243acb622d46731e9ae7029408db6e561f1
[ "MIT" ]
null
null
null
Cats/Category/Constructions/Terminal.agda
JLimperg/cats
1ad7b243acb622d46731e9ae7029408db6e561f1
[ "MIT" ]
1
2019-03-18T15:35:07.000Z
2019-03-18T15:35:07.000Z
{-# OPTIONS --without-K --safe #-} module Cats.Category.Constructions.Terminal where open import Data.Product using (proj₁ ; proj₂) open import Level open import Cats.Category.Base import Cats.Category.Constructions.Iso as Iso import Cats.Category.Constructions.Unique as Unique module Build {lo la l≈} (Cat : Category lo la l≈) where open Category Cat open Iso.Build Cat open Unique.Build Cat IsTerminal : Obj → Set (lo ⊔ la ⊔ l≈) IsTerminal ⊤ = ∀ X → ∃! X ⊤ record HasTerminal : Set (lo ⊔ la ⊔ l≈) where field ⊤ : Obj isTerminal : IsTerminal ⊤ ! : ∀ X → X ⇒ ⊤ ! X = ∃!′.arr (isTerminal X) !-unique : ∀ {X} (f : X ⇒ ⊤) → ! X ≈ f !-unique {X} f = ∃!′.unique (isTerminal X) _ ⇒⊤-unique : ∀ {X} (f g : X ⇒ ⊤) → f ≈ g ⇒⊤-unique f g = ≈.trans (≈.sym (!-unique f)) (!-unique g) ⊤-unique : ∀ {X} → IsTerminal X → X ≅ ⊤ ⊤-unique {X} term = record { forth = ! X ; back = term ⊤ .∃!′.arr ; back-forth = ≈.trans (≈.sym (term X .∃!′.unique _)) (term X .∃!′.unique _) ; forth-back = ⇒⊤-unique _ _ } terminal-unique : ∀ {X Y} → IsTerminal X → IsTerminal Y → X ≅ Y terminal-unique X-term Y-term = HasTerminal.⊤-unique (record { isTerminal = Y-term }) X-term open Build public using (HasTerminal) private open module Build′ {lo la l≈} {C : Category lo la l≈} = Build C public using (IsTerminal ; terminal-unique)
23.360656
82
0.580351
5998309b4ff1b739b700fb6625265b5e05f29721
3,043
agda
Agda
AgdaMiscEverything.agda
rei1024/agda-misc
37200ea91d34a6603d395d8ac81294068303f577
[ "MIT" ]
3
2020-04-07T17:49:42.000Z
2020-04-21T00:03:43.000Z
AgdaMiscEverything.agda
rei1024/agda-misc
37200ea91d34a6603d395d8ac81294068303f577
[ "MIT" ]
null
null
null
AgdaMiscEverything.agda
rei1024/agda-misc
37200ea91d34a6603d395d8ac81294068303f577
[ "MIT" ]
null
null
null
------------------------------------------------------------------------ -- agda-misc -- All modules ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} module AgdaMiscEverything where ------------------------------------------------------------------------ -- Algorithms -- Insertion sort import Algorithms.List.Sort.Insertion import Algorithms.List.Sort.Insertion.Properties -- Quicksort import Algorithms.List.Sort.Quick import Algorithms.List.Sort.Quick.Properties ------------------------------------------------------------------------ -- Constructive mathematics -- Definitions of Axioms that are nonconstructive import Constructive.Axiom import Constructive.Axiom.Properties import Constructive.Axiom.Properties.Base import Constructive.Axiom.Properties.Base.Lemma import Constructive.Axiom.Properties.Bool import Constructive.Axiom.Properties.Transport -- Alternative proof of LLPO => MP∨ import Constructive.Axiom.Properties.Alternative -- Combinators for reasoning import Constructive.Combinators import Constructive.Common -- Searchable set import Constructive.Searchable -- Experiment -- Category theory import Experiment.Categories.Solver.Category import Experiment.Categories.Solver.Category.Example import Experiment.Categories.Solver.Category.Cartesian import Experiment.Categories.Solver.Category.Cartesian.Example import Experiment.Categories.Solver.Functor import Experiment.Categories.Solver.Functor.Example import Experiment.Categories.Solver.MultiFunctor import Experiment.Categories.Solver.MultiFunctor.Example ------------------------------------------------------------------------ -- Formal language import Math.FormalLanguage ------------------------------------------------------------------------ -- Googology import Math.Googology.Function import Math.Googology.Function.Properties ------------------------------------------------------------------------ -- Number theory -- Fibonacci number import Math.NumberTheory.Fibonacci.Generic import Math.NumberTheory.Fibonacci.Nat import Math.NumberTheory.Fibonacci.Nat.Properties -- Summation import Math.NumberTheory.Summation.Generic import Math.NumberTheory.Summation.Generic.Properties import Math.NumberTheory.Summation.Nat import Math.NumberTheory.Summation.Nat.Properties -- Product import Math.NumberTheory.Product.Generic import Math.NumberTheory.Product.Generic.Properties import Math.NumberTheory.Product.Nat import Math.NumberTheory.Product.Nat.Properties ------------------------------------------------------------------------ -- Type theory -- Natural number import TypeTheory.Nat.Operations import TypeTheory.Nat.Properties import TypeTheory.Nat.Instance -- Homotopy Type Theory import TypeTheory.HoTT.Base import TypeTheory.HoTT.Data.Empty.Properties import TypeTheory.HoTT.Data.Sum.Properties import TypeTheory.HoTT.Function.Properties import TypeTheory.HoTT.Relation.Nullary.Negation.Properties -- Identity type import TypeTheory.Identity
23.05303
72
0.671706
5059f9abced38d46ff8dea01f0c4a9e8d89fd4d9
2,102
agda
Agda
Agda/Mult3.agda
Brethland/LEARNING-STUFF
eb2cef0556efb9a4ce11783f8516789ea48cc344
[ "MIT" ]
2
2020-02-03T05:05:52.000Z
2020-03-11T10:35:42.000Z
Agda/Mult3.agda
Brethland/LEARNING-STUFF
eb2cef0556efb9a4ce11783f8516789ea48cc344
[ "MIT" ]
null
null
null
Agda/Mult3.agda
Brethland/LEARNING-STUFF
eb2cef0556efb9a4ce11783f8516789ea48cc344
[ "MIT" ]
1
2019-12-13T04:50:46.000Z
2019-12-13T04:50:46.000Z
{-# OPTIONS --without-K --safe #-} module Mult3 where open import Data.Nat open import Data.Nat.Properties open import Relation.Binary.PropositionalEquality data Mult3 : ℕ → Set where 0-mult : Mult3 0 SSS-mult : ∀ n → Mult3 n → Mult3 (suc (suc (suc n))) data Mult3' : ℕ → Set where 30-mult : Mult3' 30 21-mult : Mult3' 21 sum-mult : ∀ n m → Mult3' n → Mult3' m → Mult3' (n + m) diff-mult : ∀ l n m → Mult3' n → Mult3' m → l + n ≡ m → Mult3' l silly3 : Mult3' 3 silly3 = diff-mult 3 9 12 (diff-mult 9 21 30 21-mult 30-mult refl) (diff-mult 12 9 21 (diff-mult 9 21 30 21-mult 30-mult refl) 21-mult refl) refl lemma-plus : ∀ {n m : ℕ} → Mult3 n → Mult3 m → Mult3 (n + m) lemma-plus 0-mult m = m lemma-plus {m = m₁} (SSS-mult n n₁) m = SSS-mult (n + m₁) (lemma-plus n₁ m) lemma-minus : ∀ {l n : ℕ} → Mult3 n → Mult3 (n + l) → Mult3 l lemma-minus {l} {.0} 0-mult m₁ = m₁ lemma-minus {l} {.(suc (suc (suc n)))} (SSS-mult n n₁) (SSS-mult .(n + l) m₁) = lemma-minus n₁ m₁ lemma-silly : ∀ {m n : ℕ} → Mult3 m → m ≡ n → Mult3 n lemma-silly m eq rewrite eq = m mult-imp-mult' : ∀ {n : ℕ} → Mult3 n → Mult3' n mult-imp-mult' 0-mult = diff-mult zero 30 30 30-mult 30-mult refl mult-imp-mult' (SSS-mult n M) = sum-mult 3 n silly3 (mult-imp-mult' M) mult'-imp-mult : ∀ {n : ℕ} → Mult3' n → Mult3 n mult'-imp-mult 30-mult = SSS-mult 27 (SSS-mult 24 (SSS-mult 21 (SSS-mult 18 (SSS-mult 15 (SSS-mult 12 (SSS-mult 9 (SSS-mult 6 (SSS-mult 3 (SSS-mult zero 0-mult))))))))) mult'-imp-mult 21-mult = SSS-mult 18 (SSS-mult 15 (SSS-mult 12 (SSS-mult 9 (SSS-mult 6 (SSS-mult 3 (SSS-mult zero 0-mult)))))) mult'-imp-mult (sum-mult n m M M₁) = lemma-plus (mult'-imp-mult M) (mult'-imp-mult M₁) mult'-imp-mult (diff-mult l n m M M₁ x) rewrite +-comm l n = lemma-minus {l} {n} (mult'-imp-mult M) (lemma-silly {m} {n + l} (mult'-imp-mult M₁) (sym x))
42.04
153
0.543292
3d771ab14a1e1e41dc2bacdf5a4bb9b453dc4764
115
agda
Agda
Cubical/Algebra/CommMonoid.agda
hyleIndex/cubical
ce5c2820ecb2e0fd8dce74fb0247856cdbf034c4
[ "MIT" ]
301
2018-10-17T18:00:24.000Z
2022-03-24T02:10:47.000Z
Cubical/Algebra/CommMonoid.agda
hyleIndex/cubical
ce5c2820ecb2e0fd8dce74fb0247856cdbf034c4
[ "MIT" ]
584
2018-10-15T09:49:02.000Z
2022-03-30T12:09:17.000Z
Cubical/Algebra/CommMonoid.agda
hyleIndex/cubical
ce5c2820ecb2e0fd8dce74fb0247856cdbf034c4
[ "MIT" ]
134
2018-11-16T06:11:03.000Z
2022-03-23T16:22:13.000Z
{-# OPTIONS --safe #-} module Cubical.Algebra.CommMonoid where open import Cubical.Algebra.CommMonoid.Base public
23
50
0.782609
23b20157b089ab6daa18109ed28d06b85ad9431c
1,023
agda
Agda
src/SizedIO/Console.agda
agda/ooAgda
7cc45e0148a4a508d20ed67e791544c30fecd795
[ "MIT" ]
23
2016-06-19T12:57:55.000Z
2020-10-12T23:15:25.000Z
src/SizedIO/Console.agda
agda/ooAgda
7cc45e0148a4a508d20ed67e791544c30fecd795
[ "MIT" ]
null
null
null
src/SizedIO/Console.agda
agda/ooAgda
7cc45e0148a4a508d20ed67e791544c30fecd795
[ "MIT" ]
2
2018-09-01T15:02:37.000Z
2022-03-12T11:41:00.000Z
module SizedIO.Console where open import Level using () renaming (zero to lzero) open import Size open import NativeIO open import SizedIO.Base data ConsoleCommand : Set where putStrLn : String → ConsoleCommand getLine : ConsoleCommand ConsoleResponse : ConsoleCommand → Set ConsoleResponse (putStrLn s) = Unit ConsoleResponse getLine = String consoleI : IOInterface Command consoleI = ConsoleCommand Response consoleI = ConsoleResponse IOConsole : Size → Set → Set IOConsole i = IO consoleI i IOConsole+ : Size → Set → Set IOConsole+ i = IO+ consoleI i translateIOConsoleLocal : (c : ConsoleCommand) → NativeIO (ConsoleResponse c) translateIOConsoleLocal (putStrLn s) = nativePutStrLn s translateIOConsoleLocal getLine = nativeGetLine translateIOConsole : {A : Set} → IOConsole ∞ A → NativeIO A translateIOConsole = translateIO translateIOConsoleLocal postulate translateIOConsoleTODO : {A : Set} → (i : Size) → IOConsole i A → NativeIO A main : NativeIO Unit main = nativePutStrLn "Console"
26.230769
86
0.767351
29d701af0dcb0bcb99af4a71dcd200a5b9f5d8cb
1,717
agda
Agda
theorems/stash/CoverClassificationCat.agda
AntoineAllioux/HoTT-Agda
1037d82edcf29b620677a311dcfd4fc2ade2faa6
[ "MIT" ]
294
2015-01-09T16:23:23.000Z
2022-03-20T13:54:45.000Z
theorems/stash/CoverClassificationCat.agda
AntoineAllioux/HoTT-Agda
1037d82edcf29b620677a311dcfd4fc2ade2faa6
[ "MIT" ]
31
2015-03-05T20:09:00.000Z
2021-10-03T19:15:25.000Z
theorems/stash/CoverClassificationCat.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.RibbonCover import homotopy.CoverClassification module experimental.CoverClassificationCat {i} (A∙ : Ptd i) (A-conn : is-connected 0 (fst A∙)) where open Cover open Gset open homotopy.CoverClassification A∙ A-conn private A : Type i A = fst A∙ a₁ : A a₁ = snd A∙ π1A = fundamental-group A∙ -- A covering space constructed from a G-set. cover-hom-to-gset-hom : ∀ {j} → {cov₁ cov₂ : Cover A j} → CoverHom cov₁ cov₂ → GsetHom (cover-to-gset cov₁) (cover-to-gset cov₂) cover-hom-to-gset-hom {cov₁ = cov₁}{cov₂} f = record { f = f a₁ ; pres-act = λ l x → lemma₂ x l } where lemma₁ : ∀ x {a₂} (p : a₁ == a₂) → f a₂ (transport (Fiber cov₁) p x) == transport (Fiber cov₂) p (f a₁ x) lemma₁ _ idp = idp lemma₂ : ∀ x {a₂} (p : a₁ =₀ a₂) → f a₂ (transport₀ (Fiber cov₁) (Fiber-level cov₁ a₂) p x) == transport₀ (Fiber cov₂) (Fiber-level cov₂ a₂) p (f a₁ x) lemma₂ x {a₂} = Trunc-elim (λ p → =-preserves-set (Fiber-level cov₂ a₂)) (lemma₁ x {a₂}) gset-hom-to-cover-hom : ∀ {j} → {gset₁ gset₂ : Gset π1A j} → GsetHom gset₁ gset₂ → CoverHom (gset-to-cover gset₁) (gset-to-cover gset₂) gset-hom-to-cover-hom {gset₁ = gset₁}{gset₂} (gset-hom f pres-act) a₂ = Ribbon-rec {P = Ribbon A∙ gset₂ a₂} Ribbon-level (λ el p → trace (f el) p) (λ el loop p → trace (f (act gset₁ el loop)) p =⟨ pres-act loop el |in-ctx (λ x → trace x p) ⟩ trace (act gset₂ (f el) loop) p =⟨ paste (f el) loop p ⟩ trace (f el) (loop ∙₀ p) ∎)
29.101695
73
0.567851
c79cd90dfd672a4c5438f3672b04dada9ab98bdf
2,121
agda
Agda
BasicIPC/Metatheory/Hilbert-KripkeConcrete.agda
mietek/hilbert-gentzen
fcd187db70f0a39b894fe44fad0107f61849405c
[ "X11" ]
29
2016-07-03T18:51:56.000Z
2022-01-01T10:29:18.000Z
BasicIPC/Metatheory/Hilbert-KripkeConcrete.agda
mietek/hilbert-gentzen
fcd187db70f0a39b894fe44fad0107f61849405c
[ "X11" ]
1
2018-06-10T09:11:22.000Z
2018-06-10T09:11:22.000Z
BasicIPC/Metatheory/Hilbert-KripkeConcrete.agda
mietek/hilbert-gentzen
fcd187db70f0a39b894fe44fad0107f61849405c
[ "X11" ]
null
null
null
module BasicIPC.Metatheory.Hilbert-KripkeConcrete where open import BasicIPC.Syntax.Hilbert public open import BasicIPC.Semantics.KripkeConcrete public -- Soundness with respect to all models, or evaluation. eval : ∀ {A Γ} → Γ ⊢ A → Γ ⊨ A eval (var i) γ = lookup i γ eval (app {A} {B} t u) γ = _⟪$⟫_ {A} {B} (eval t γ) (eval u γ) eval ci γ = K I eval (ck {A} {B}) γ = K (⟪K⟫ {A} {B}) eval (cs {A} {B} {C}) γ = K (⟪S⟫′ {A} {B} {C}) eval (cpair {A} {B}) γ = K (_⟪,⟫′_ {A} {B}) eval cfst γ = K π₁ eval csnd γ = K π₂ eval unit γ = ∙ -- TODO: Correctness of evaluation with respect to conversion. -- The canonical model. private instance canon : Model canon = record { _⊩ᵅ_ = λ w P → unwrap w ⊢ α P ; mono⊩ᵅ = λ ξ t → mono⊢ (unwrap≤ ξ) t } -- Soundness and completeness with respect to the canonical model. mutual reflectᶜ : ∀ {A w} → unwrap w ⊢ A → w ⊩ A reflectᶜ {α P} t = t reflectᶜ {A ▻ B} t = λ ξ a → reflectᶜ (app (mono⊢ (unwrap≤ ξ) t) (reifyᶜ a)) reflectᶜ {A ∧ B} t = reflectᶜ (fst t) , reflectᶜ (snd t) reflectᶜ {⊤} t = ∙ reifyᶜ : ∀ {A w} → w ⊩ A → unwrap w ⊢ A reifyᶜ {α P} s = s reifyᶜ {A ▻ B} s = lam (reifyᶜ (s weak≤ (reflectᶜ {A} v₀))) reifyᶜ {A ∧ B} s = pair (reifyᶜ (π₁ s)) (reifyᶜ (π₂ s)) reifyᶜ {⊤} s = unit reflectᶜ⋆ : ∀ {Ξ w} → unwrap w ⊢⋆ Ξ → w ⊩⋆ Ξ reflectᶜ⋆ {∅} ∙ = ∙ reflectᶜ⋆ {Ξ , A} (ts , t) = reflectᶜ⋆ ts , reflectᶜ t reifyᶜ⋆ : ∀ {Ξ w} → w ⊩⋆ Ξ → unwrap w ⊢⋆ Ξ reifyᶜ⋆ {∅} ∙ = ∙ reifyᶜ⋆ {Ξ , A} (ts , t) = reifyᶜ⋆ ts , reifyᶜ t -- Reflexivity and transitivity. refl⊩⋆ : ∀ {w} → w ⊩⋆ unwrap w refl⊩⋆ = reflectᶜ⋆ refl⊢⋆ trans⊩⋆ : ∀ {w w′ w″} → w ⊩⋆ unwrap w′ → w′ ⊩⋆ unwrap w″ → w ⊩⋆ unwrap w″ 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⊩⋆) -- Normalisation by evaluation. norm : ∀ {A Γ} → Γ ⊢ A → Γ ⊢ A norm = quot ∘ eval -- TODO: Correctness of normalisation with respect to conversion.
26.185185
78
0.540783
22c7187d0dbd8705989eca12068fdb360fa681f2
1,101
agda
Agda
test/lib-succeed/Issue846/Imports.agda
larrytheliquid/agda
477c8c37f948e6038b773409358fd8f38395f827
[ "MIT" ]
1
2018-10-10T17:08:44.000Z
2018-10-10T17:08:44.000Z
test/lib-succeed/Issue846/Imports.agda
masondesu/agda
70c8a575c46f6a568c7518150a1a64fcd03aa437
[ "MIT" ]
null
null
null
test/lib-succeed/Issue846/Imports.agda
masondesu/agda
70c8a575c46f6a568c7518150a1a64fcd03aa437
[ "MIT" ]
1
2022-03-12T11:35:18.000Z
2022-03-12T11:35:18.000Z
module Issue846.Imports where open import Data.Nat public using (ℕ; zero; suc; _≤_; _∸_) open import Data.List public using (List; []; _∷_) open import Data.Bool public using (Bool; true; false; not) open import Data.Nat.DivMod public using (_mod_) open import Data.Fin public using (Fin; toℕ; zero; suc) open import Relation.Binary.PropositionalEquality public using (_≡_; _≢_; cong) open import Relation.Binary public using (nonEmpty) -- this is the bad guy open import Issue846.DivModUtils public using (1'; lem-sub-p) record Move : Set where constructor pick field picked : ℕ 1≤n : 1 ≤ picked n≤6 : picked ≤ 6 open Move using (picked) Strategy = ℕ → Move {-# NO_TERMINATION_CHECK #-} play : ℕ → Strategy → Strategy → List ℕ play 0 _ _ = [] play n p1 p2 = n ∷ play (n ∸ picked (p1 n)) p2 p1 postulate opt : Strategy evenList : {A : Set} → List A → Bool evenList [] = true evenList (_ ∷ xs) = not (evenList xs) winner : ℕ → Strategy → Strategy → Bool winner n p1 p2 = evenList (play n p1 p2) postulate opt-is-opt : ∀ n s → n mod 7 ≢ 1' → winner n opt s ≡ true ‌‌
26.853659
79
0.675749
067819b5d0a7593cb62f46c2690e10a73d80a989
2,469
agda
Agda
src/Data/QuadTree/LensProofs/Valid-LensAtLocation.agda
JonathanBrouwer/research-project
4959a3c9cd8563a1726e0e968e6a179008cd4d9f
[ "Unlicense" ]
1
2021-05-25T09:10:20.000Z
2021-05-25T09:10:20.000Z
src/Data/QuadTree/LensProofs/Valid-LensAtLocation.agda
JonathanBrouwer/research-project
4959a3c9cd8563a1726e0e968e6a179008cd4d9f
[ "Unlicense" ]
null
null
null
src/Data/QuadTree/LensProofs/Valid-LensAtLocation.agda
JonathanBrouwer/research-project
4959a3c9cd8563a1726e0e968e6a179008cd4d9f
[ "Unlicense" ]
null
null
null
-- {-# OPTIONS --show-implicit --show-irrelevant #-} module Data.QuadTree.LensProofs.Valid-LensAtLocation where open import Haskell.Prelude renaming (zero to Z; suc to S) open import Data.Lens.Lens open import Data.Logic open import Data.QuadTree.InternalAgda open import Agda.Primitive open import Data.Lens.Proofs.LensLaws open import Data.Lens.Proofs.LensPostulates open import Data.Lens.Proofs.LensComposition open import Data.QuadTree.LensProofs.Valid-LensLeaf open import Data.QuadTree.LensProofs.Valid-LensWrappedTree open import Data.QuadTree.LensProofs.Valid-LensA open import Data.QuadTree.LensProofs.Valid-LensBCD open import Data.QuadTree.LensProofs.Valid-LensGo open import Data.QuadTree.Implementation.QuadrantLenses open import Data.QuadTree.Implementation.Definition open import Data.QuadTree.Implementation.ValidTypes open import Data.QuadTree.Implementation.SafeFunctions open import Data.QuadTree.Implementation.PublicFunctions open import Data.QuadTree.Implementation.DataLenses ---- Lens laws for go ValidLens-AtLocation-ViewSet : {t : Set} {{eqT : Eq t}} -> (loc : Nat × Nat) -> (dep : Nat) -> {ins : IsTrue (isInsidePow loc dep)} -> ViewSet (atLocation {t} loc dep {ins}) ValidLens-AtLocation-ViewSet (x , y) dep {ins} v s = trans refl (prop-Composition-ViewSet (ValidLens-WrappedTree) (ValidLens-go (x , y) dep {ins}) v s) ValidLens-AtLocation-SetView : {t : Set} {{eqT : Eq t}} -> (loc : Nat × Nat) -> (dep : Nat) -> {ins : IsTrue (isInsidePow loc dep)} -> SetView (atLocation {t} loc dep {ins}) ValidLens-AtLocation-SetView (x , y) dep {ins} s = trans refl (prop-Composition-SetView (ValidLens-WrappedTree) (ValidLens-go (x , y) dep {ins}) s) ValidLens-AtLocation-SetSet : {t : Set} {{eqT : Eq t}} -> (loc : Nat × Nat) -> (dep : Nat) -> {ins : IsTrue (isInsidePow loc dep)} -> SetSet (atLocation {t} loc dep {ins}) ValidLens-AtLocation-SetSet (x , y) dep {ins} v1 v2 s = trans refl (prop-Composition-SetSet (ValidLens-WrappedTree) (ValidLens-go (x , y) dep {ins}) v1 v2 s) ValidLens-AtLocation : {t : Set} {{eqT : Eq t}} -> (loc : Nat × Nat) -> (dep : Nat) -> {ins : IsTrue (isInsidePow loc dep)} -> ValidLens (VQuadTree t {dep}) t ValidLens-AtLocation {t} {{eqT}} (x , y) dep {ins} = CValidLens (atLocation (x , y) dep {ins}) (ValidLens-AtLocation-ViewSet (x , y) dep {ins}) (ValidLens-AtLocation-SetView (x , y) dep {ins}) (ValidLens-AtLocation-SetSet (x , y) dep {ins})
46.584906
240
0.710004
2e7ce4693f21bb89b5e8b421a381ebeb45f7e457
1,768
agda
Agda
Partial/InfConj.agda
hbasold/Sandbox
8fc7a6cd878f37f9595124ee8dea62258da28aa4
[ "MIT" ]
null
null
null
Partial/InfConj.agda
hbasold/Sandbox
8fc7a6cd878f37f9595124ee8dea62258da28aa4
[ "MIT" ]
null
null
null
Partial/InfConj.agda
hbasold/Sandbox
8fc7a6cd878f37f9595124ee8dea62258da28aa4
[ "MIT" ]
null
null
null
module InfConj where open import Data.Bool open import Data.Sum open import Relation.Binary.PropositionalEquality record Stream (A : Set) : Set where coinductive constructor _∷_ field hd : A tl : Stream A open Stream public -- | Partial elements record D (A : Set) : Set where coinductive field step : A ⊎ D A open D public -- | Lift ⊎ to relations data _⊎'_ {A B : Set} (R : A → A → Set) (S : B → B → Set) : A ⊎ B → A ⊎ B → Set where inj₁' : {x y : A} → R x y → (R ⊎' S) (inj₁ x) (inj₁ y) inj₂' : {x y : B} → S x y → (R ⊎' S) (inj₂ x) (inj₂ y) -- | Bisimilarity for partial elements record _~_ {A : Set} (x y : D A) : Set where coinductive field step~ : (_≡_ ⊎' _~_) (x .step) (y .step) open _~_ public -- | Injection into D η : {A : Set} → A → D A η a .step = inj₁ a -- | Conjunction for partial Booleans _∧'_ : D Bool → D Bool → D Bool (x ∧' y) .step with x .step | y .step (x ∧' y) .step | inj₁ false | v = inj₁ false (x ∧' y) .step | inj₁ true | v = v (x ∧' y) .step | inj₂ x' | inj₁ false = inj₁ false (x ∧' y) .step | inj₂ x' | inj₁ true = inj₂ x' (x ∧' y) .step | inj₂ x' | inj₂ y' = inj₂ (x' ∧' y') -- | Infinite conjunction ⋀∞ : Stream Bool → D Bool ⋀∞ s .step with s .hd ⋀∞ s .step | false = inj₁ false ⋀∞ s .step | true = inj₂ (⋀∞ (s .tl)) -- | Constant stream K : {A : Set} → A → Stream A K a .hd = a K a .tl = K a -- | Non-terminating computation ⊥ : {A : Set} → D A ⊥ .step = inj₂ ⊥ -- | Infinite conjunction of constant stream does not terminate prop : ⋀∞ (K true) ~ ⊥ prop .step~ = inj₂' prop -- | If there is an entry "false" in the stream, then the infinite conjunction -- terminates. Here is just an example. ex : ⋀∞ (false ∷ K true) ~ η false ex .step~ = inj₁' refl
26
85
0.570701
571ad7520cf6b23cc4dd44ef866f3802ce2aeb3d
902
agda
Agda
src/Web/Semantic/DL/Concept.agda
bblfish/agda-web-semantic
38fbc3af7062ba5c3d7d289b2b4bcfb995d99057
[ "MIT" ]
1
2022-02-22T09:43:23.000Z
2022-02-22T09:43:23.000Z
src/Web/Semantic/DL/Concept.agda
bblfish/agda-web-semantic
38fbc3af7062ba5c3d7d289b2b4bcfb995d99057
[ "MIT" ]
null
null
null
src/Web/Semantic/DL/Concept.agda
bblfish/agda-web-semantic
38fbc3af7062ba5c3d7d289b2b4bcfb995d99057
[ "MIT" ]
null
null
null
open import Web.Semantic.DL.Role using ( Role ) open import Web.Semantic.DL.Signature using ( Signature ; CN ; RN ) module Web.Semantic.DL.Concept where infixr 9 ∀[_]_ infixr 8 ∃⟨_⟩_ infixl 7 _⊓_ infixl 6 _⊔_ -- Concept grammar data Concept (Σ : Signature) : Set where ⟨_⟩ : (c : CN Σ) → Concept Σ ¬⟨_⟩ : (c : CN Σ) → Concept Σ ⊤ : Concept Σ ⊥ : Concept Σ _⊓_ : (C D : Concept Σ) → Concept Σ _⊔_ : (C D : Concept Σ) → Concept Σ ∀[_]_ : (R : Role Σ) (C : Concept Σ) → Concept Σ ∃⟨_⟩_ : (R : Role Σ) (C : Concept Σ) → Concept Σ ≤1 : (R : Role Σ) → Concept Σ >1 : (R : Role Σ) → Concept Σ neg : ∀ {Σ} (C : Concept Σ) → Concept Σ neg ⟨ c ⟩ = ¬⟨ c ⟩ neg ¬⟨ c ⟩ = ⟨ c ⟩ neg ⊤ = ⊥ neg ⊥ = ⊤ neg (C ⊓ D) = neg C ⊔ neg D neg (C ⊔ D) = neg C ⊓ neg D neg (∀[ R ] C) = ∃⟨ R ⟩ neg C neg (∃⟨ R ⟩ C) = ∀[ R ] neg C neg (≤1 R) = >1 R neg (>1 R) = ≤1 R
25.771429
67
0.504435
220f60dc55507517fc5c8ddbd0fb98e8d997a998
343
agda
Agda
src/data/lib/prim/Agda/Builtin/Cubical/Path.agda
alex-mckenna/agda
78b62cd24bbd570271a7153e44ad280e52ef3e29
[ "BSD-3-Clause" ]
1
2021-07-07T10:49:57.000Z
2021-07-07T10:49:57.000Z
src/data/lib/prim/Agda/Builtin/Cubical/Path.agda
andersk/agda
56928ff709dcb931cb9a48c4790e5ed3739e3032
[ "BSD-3-Clause" ]
null
null
null
src/data/lib/prim/Agda/Builtin/Cubical/Path.agda
andersk/agda
56928ff709dcb931cb9a48c4790e5ed3739e3032
[ "BSD-3-Clause" ]
null
null
null
{-# OPTIONS --cubical #-} module Agda.Builtin.Cubical.Path where open import Agda.Primitive.Cubical postulate PathP : ∀ {ℓ} (A : I → Set ℓ) → A i0 → A i1 → Set ℓ {-# BUILTIN PATHP PathP #-} infix 4 _≡_ _≡_ : ∀ {ℓ} {A : Set ℓ} → A → A → Set ℓ _≡_ {A = A} = PathP (λ _ → A) {-# BUILTIN PATH _≡_ #-}
21.4375
55
0.501458
c76e5affcf60fed8769a67fdd93916d006348551
1,893
agda
Agda
src/LibraBFT/Impl/Types/Waypoint.agda
LaudateCorpus1/bft-consensus-agda
a4674fc473f2457fd3fe5123af48253cfb2404ef
[ "UPL-1.0" ]
null
null
null
src/LibraBFT/Impl/Types/Waypoint.agda
LaudateCorpus1/bft-consensus-agda
a4674fc473f2457fd3fe5123af48253cfb2404ef
[ "UPL-1.0" ]
null
null
null
src/LibraBFT/Impl/Types/Waypoint.agda
LaudateCorpus1/bft-consensus-agda
a4674fc473f2457fd3fe5123af48253cfb2404ef
[ "UPL-1.0" ]
null
null
null
{- Byzantine Fault Tolerant Consensus Verification in Agda, version 0.9. Copyright (c) 2021, Oracle and/or its affiliates. Licensed under the Universal Permissive License v 1.0 as shown at https://opensource.oracle.com/licenses/upl -} open import LibraBFT.Base.Types open import LibraBFT.Impl.OBM.Logging.Logging import LibraBFT.Impl.Types.Ledger2WaypointConverter as Ledger2WaypointConverter open import LibraBFT.ImplShared.Consensus.Types import LibraBFT.ImplShared.Util.Crypto as Crypto open import Optics.All open import Util.Hash open import Util.Prelude module LibraBFT.Impl.Types.Waypoint where newAny : LedgerInfo → Waypoint newAny ledgerInfo = let converter = Ledger2WaypointConverter.new ledgerInfo in Waypoint∙new (ledgerInfo ^∙ liVersion) (Crypto.hashL2WC converter) newEpochBoundary : LedgerInfo → Either ErrLog Waypoint newEpochBoundary ledgerInfo = if ledgerInfo ^∙ liEndsEpoch then pure (newAny ledgerInfo) else Left fakeErr -- ["newEpochBoundary", "no validator set"] verify : Waypoint → LedgerInfo → Either ErrLog Unit verify self ledgerInfo = do lcheck (self ^∙ wVersion == ledgerInfo ^∙ liVersion) ("Waypoint" ∷ "version mismatch" ∷ []) --show (self^.wVersion), show (ledgerInfo^.liVersion)] let converter = Ledger2WaypointConverter.new ledgerInfo lcheck (self ^∙ wValue == Crypto.hashL2WC converter) ("Waypoint" ∷ "value mismatch" ∷ []) --show (self^.wValue), show (Crypto.hashL2WC converter)] pure unit epochChangeVerificationRequired : Waypoint → Epoch → Bool epochChangeVerificationRequired _self _epoch = true isLedgerInfoStale : Waypoint → LedgerInfo → Bool isLedgerInfoStale self ledgerInfo = ⌊ (ledgerInfo ^∙ liVersion) <?-Version (self ^∙ wVersion) ⌋ verifierVerify : Waypoint → LedgerInfoWithSignatures → Either ErrLog Unit verifierVerify self liws = verify self (liws ^∙ liwsLedgerInfo)
41.152174
111
0.762282
5934f78cdb3ea6c9c4cb99278bbffa5ffaf2d11d
845
agda
Agda
Logic/Propositional/Equiv.agda
Lolirofle/stuff-in-agda
70f4fba849f2fd779c5aaa5af122ccb6a5b271ba
[ "MIT" ]
6
2020-04-07T17:58:13.000Z
2022-02-05T06:53:22.000Z
Logic/Propositional/Equiv.agda
Lolirofle/stuff-in-agda
70f4fba849f2fd779c5aaa5af122ccb6a5b271ba
[ "MIT" ]
null
null
null
Logic/Propositional/Equiv.agda
Lolirofle/stuff-in-agda
70f4fba849f2fd779c5aaa5af122ccb6a5b271ba
[ "MIT" ]
null
null
null
module Logic.Propositional.Equiv where import Lvl open import Logic open import Logic.Propositional import Logic.Propositional.Theorems as Theorems open import Structure.Relator.Equivalence open import Structure.Relator.Properties open import Structure.Setoid open import Type private variable ℓ ℓ₁ ℓ₂ ℓₑ ℓₑ₁ ℓₑ₂ : Lvl.Level private variable T A B : Type{ℓ} instance [↔]-reflexivity : Reflexivity{ℓ₂ = ℓ}(_↔_) [↔]-reflexivity = intro Theorems.[↔]-reflexivity instance [↔]-symmetry : Symmetry{ℓ₂ = ℓ}(_↔_) [↔]-symmetry = intro Theorems.[↔]-symmetry instance [↔]-transitivity : Transitivity{ℓ₂ = ℓ}(_↔_) [↔]-transitivity = intro Theorems.[↔]-transitivity instance [↔]-equivalence : Equivalence{ℓ₂ = ℓ}(_↔_) [↔]-equivalence = intro instance [↔]-equiv : Equiv(Stmt{ℓ}) [↔]-equiv = intro(_↔_) ⦃ [↔]-equivalence ⦄
24.852941
52
0.707692
29cfb40cad5b5df951155924e8f4dd1db2c7317b
3,303
agda
Agda
Cubical/Homotopy/Loopspace.agda
ByteBucket123/cubical
aeaa15fb846a3e8bda73635dc7462ae3813b4b1b
[ "MIT" ]
null
null
null
Cubical/Homotopy/Loopspace.agda
ByteBucket123/cubical
aeaa15fb846a3e8bda73635dc7462ae3813b4b1b
[ "MIT" ]
null
null
null
Cubical/Homotopy/Loopspace.agda
ByteBucket123/cubical
aeaa15fb846a3e8bda73635dc7462ae3813b4b1b
[ "MIT" ]
null
null
null
{-# OPTIONS --safe #-} module Cubical.Homotopy.Loopspace where open import Cubical.Core.Everything open import Cubical.Data.Nat open import Cubical.Foundations.Prelude open import Cubical.Foundations.Pointed open import Cubical.Foundations.HLevels open import Cubical.Foundations.GroupoidLaws open import Cubical.HITs.SetTruncation open import Cubical.HITs.Truncation hiding (elim2) renaming (rec to trRec) open import Cubical.Foundations.Isomorphism open import Cubical.Foundations.Equiv.HalfAdjoint open Iso {- loop space of a pointed type -} Ω : {ℓ : Level} → Pointed ℓ → Pointed ℓ Ω (_ , a) = ((a ≡ a) , refl) {- n-fold loop space of a pointed type -} Ω^_ : ∀ {ℓ} → ℕ → Pointed ℓ → Pointed ℓ (Ω^ 0) p = p (Ω^ (suc n)) p = Ω ((Ω^ n) p) {- homotopy Group -} π : ∀ {ℓ} (n : ℕ) (A : Pointed ℓ) → Type ℓ π n A = ∥ typ ((Ω^ n) A) ∥ 2 {- loop space map -} Ω→ : ∀ {ℓA ℓB} {A : Pointed ℓA} {B : Pointed ℓB} (f : A →∙ B) → (Ω A →∙ Ω B) Ω→ (f , f∙) = (λ p → (sym f∙ ∙ cong f p) ∙ f∙) , cong (λ q → q ∙ f∙) (sym (rUnit (sym f∙))) ∙ lCancel f∙ {- Commutativity of loop spaces -} isComm∙ : ∀ {ℓ} (A : Pointed ℓ) → Type ℓ isComm∙ A = (p q : typ (Ω A)) → p ∙ q ≡ q ∙ p Eckmann-Hilton : ∀ {ℓ} {A : Pointed ℓ} (n : ℕ) → isComm∙ ((Ω^ (suc n)) A) Eckmann-Hilton n α β = transport (λ i → cong (λ x → rUnit x (~ i)) α ∙ cong (λ x → lUnit x (~ i)) β ≡ cong (λ x → lUnit x (~ i)) β ∙ cong (λ x → rUnit x (~ i)) α) λ i → (λ j → α (j ∧ ~ i) ∙ β (j ∧ i)) ∙ λ j → α (~ i ∨ j) ∙ β (i ∨ j) isCommA→isCommTrunc : ∀ {ℓ} {A : Pointed ℓ} (n : ℕ) → isComm∙ A → isOfHLevel (suc n) (typ A) → isComm∙ (∥ typ A ∥ (suc n) , ∣ pt A ∣) isCommA→isCommTrunc {A = (A , a)} n comm hlev p q = ((λ i j → (leftInv (truncIdempotentIso (suc n) hlev) ((p ∙ q) j) (~ i))) ∙∙ (λ i → cong {B = λ _ → ∥ A ∥ (suc n) } (λ x → ∣ x ∣) (cong (trRec hlev (λ x → x)) (p ∙ q))) ∙∙ (λ i → cong {B = λ _ → ∥ A ∥ (suc n) } (λ x → ∣ x ∣) (congFunct {A = ∥ A ∥ (suc n)} {B = A} (trRec hlev (λ x → x)) p q i))) ∙ ((λ i → cong {B = λ _ → ∥ A ∥ (suc n) } (λ x → ∣ x ∣) (comm (cong (trRec hlev (λ x → x)) p) (cong (trRec hlev (λ x → x)) q) i)) ∙∙ (λ i → cong {B = λ _ → ∥ A ∥ (suc n) } (λ x → ∣ x ∣) (congFunct {A = ∥ A ∥ (suc n)} {B = A} (trRec hlev (λ x → x)) q p (~ i))) ∙∙ (λ i j → (leftInv (truncIdempotentIso (suc n) hlev) ((q ∙ p) j) i))) ptdIso→comm : ∀ {ℓ ℓ'} {A : Pointed ℓ} {B : Type ℓ'} (e : Iso (typ A) B) → isComm∙ A → isComm∙ (B , fun e (pt A)) ptdIso→comm {A = (A , a)} {B = B} e comm p q = sym (rightInv (congIso e) (p ∙ q)) ∙∙ (cong (fun (congIso e)) ((invCongFunct e p q) ∙∙ (comm (inv (congIso e) p) (inv (congIso e) q)) ∙∙ (sym (invCongFunct e q p)))) ∙∙ rightInv (congIso e) (q ∙ p) {- Homotopy group version -} π-comp : ∀ {ℓ} {A : Pointed ℓ} (n : ℕ) → ∥ typ ((Ω^ (suc n)) A) ∥₂ → ∥ typ ((Ω^ (suc n)) A) ∥₂ → ∥ typ ((Ω^ (suc n)) A) ∥₂ π-comp n = elim2 (λ _ _ → isSetSetTrunc) λ p q → ∣ p ∙ q ∣₂ Eckmann-Hilton-π : ∀ {ℓ} {A : Pointed ℓ} (n : ℕ) (p q : ∥ typ ((Ω^ (2 + n)) A) ∥₂) → π-comp (1 + n) p q ≡ π-comp (1 + n) q p Eckmann-Hilton-π n = elim2 (λ x y → isOfHLevelPath 2 isSetSetTrunc _ _) λ p q → cong ∣_∣₂ (Eckmann-Hilton n p q)
44.635135
130
0.50772
ad94f9803b80452e85540a2e0c887e4628e975a0
2,640
agda
Agda
Cubical/HITs/Rationals/HITQ/Base.agda
guilhermehas/cubical
ce3120d3f8d692847b2744162bcd7a01f0b687eb
[ "MIT" ]
1
2021-10-31T17:32:49.000Z
2021-10-31T17:32:49.000Z
Cubical/HITs/Rationals/HITQ/Base.agda
guilhermehas/cubical
ce3120d3f8d692847b2744162bcd7a01f0b687eb
[ "MIT" ]
null
null
null
Cubical/HITs/Rationals/HITQ/Base.agda
guilhermehas/cubical
ce3120d3f8d692847b2744162bcd7a01f0b687eb
[ "MIT" ]
null
null
null
{-# OPTIONS --safe #-} module Cubical.HITs.Rationals.HITQ.Base where open import Cubical.Foundations.Prelude open import Cubical.Foundations.HLevels open import Cubical.Foundations.Function open import Cubical.Relation.Nullary open import Cubical.Data.Int open import Cubical.Data.Nat as ℕ hiding (_·_) open import Cubical.Data.NatPlusOne open import Cubical.Data.Sigma -- ℚ as a higher inductive type data ℚ : Type₀ where con : (u : ℤ) (a : ℤ) → ¬ (a ≡ 0) → ℚ path : ∀ u a v b {p q} → (u · b) ≡ (v · a) → con u a p ≡ con v b q trunc : isSet ℚ [_] : ℤ × ℕ₊₁ → ℚ [ a , 1+ b ] = con a (pos (suc b)) (ℕ.snotz ∘ cong abs) module Elim {ℓ} {B : ℚ → Type ℓ} (con* : ∀ u a (p : ¬ (a ≡ 0)) → B (con u a p)) (path* : ∀ u a v b {p q} (eq : (u · b) ≡ (v · a)) → PathP (λ i → B (path u a v b {p} {q} eq i)) (con* u a p) (con* v b q)) (trunc* : (q : ℚ) → isSet (B q)) where f : (q : ℚ) → B q f (con u a x) = con* u a x f (path u a v b x i) = path* u a v b x i f (trunc xs ys p q i j) = isOfHLevel→isOfHLevelDep 2 trunc* (f xs) (f ys) (cong f p) (cong f q) (trunc xs ys p q) i j module ElimProp {ℓ} {B : ℚ → Type ℓ} {BProp : {q : ℚ} → isProp (B q)} (con* : ∀ u a (p : ¬ (a ≡ 0)) → B (con u a p)) where f : (q : ℚ) → B q f = Elim.f con* (λ u a v b {p} {q} eq → toPathP (BProp (transport (λ i → B (path u a v b eq i)) (con* u a p)) (con* v b q))) λ q → isProp→isSet BProp module Rec {ℓ} {B : Type ℓ} {BType : isSet B} (con* : ∀ u a (p : ¬ (a ≡ 0)) → B) (path* : ∀ u a v b {p q} (eq : (u · b) ≡ (v · a)) → con* u a p ≡ con* v b q) where f : ℚ → B f = Elim.f con* path* λ _ → BType module Rec2 {ℓ} {B : Type ℓ} {BType : isSet B} (con* : ∀ u a (p : ¬ (a ≡ 0)) v b (q : ¬ (b ≡ 0)) → B) (path*₁ : ∀ u₁ a₁ {p₁} u₂ a₂ v₂ b₂ {p₂ q₂} (eq₁ : (u₁ · b₂) ≡ (v₂ · a₁)) → con* u₁ a₁ p₁ u₂ a₂ p₂ ≡ con* v₂ b₂ q₂ u₂ a₂ p₂) (path*₂ : ∀ u₁ a₁ {p₁} u₂ a₂ v₂ b₂ {p₂ q₂} (eq₂ : (u₂ · b₂) ≡ (v₂ · a₂)) → con* u₁ a₁ p₁ u₂ a₂ p₂ ≡ con* u₁ a₁ p₁ v₂ b₂ q₂) where f : ℚ → ℚ → B f = Rec.f {BType = λ x y p q i j w → BType (x w) (y w) (λ k → p k w) (λ k → q k w) i j} (λ u a p → Rec.f {BType = BType} (con* u a p) (path*₂ u a {p})) λ u a v b eq → funExt (ElimProp.f {BProp = BType _ _} λ u₂ a₂ p₂ → path*₁ _ _ _ _ _ _ eq) --- Natural number and negative integer literals for ℚ open import Cubical.Data.Nat.Literals public instance fromNatℚ : HasFromNat ℚ fromNatℚ = record { Constraint = λ _ → Unit ; fromNat = λ n → [ pos n , 1 ] } instance fromNegℚ : HasFromNeg ℚ fromNegℚ = record { Constraint = λ _ → Unit ; fromNeg = λ n → [ neg n , 1 ] }
30.344828
96
0.529924
0bb163bfaaaa736f26fd16d380016cb0dcf20278
4,610
agda
Agda
Cubical/HITs/KleinBottle/Properties.agda
FernandoLarrain/cubical
9acdecfa6437ec455568be4e5ff04849cc2bc13b
[ "MIT" ]
301
2018-10-17T18:00:24.000Z
2022-03-24T02:10:47.000Z
Cubical/HITs/KleinBottle/Properties.agda
FernandoLarrain/cubical
9acdecfa6437ec455568be4e5ff04849cc2bc13b
[ "MIT" ]
584
2018-10-15T09:49:02.000Z
2022-03-30T12:09:17.000Z
Cubical/HITs/KleinBottle/Properties.agda
FernandoLarrain/cubical
9acdecfa6437ec455568be4e5ff04849cc2bc13b
[ "MIT" ]
134
2018-11-16T06:11:03.000Z
2022-03-23T16:22:13.000Z
{- Definition of the Klein bottle as a HIT -} {-# OPTIONS --safe #-} module Cubical.HITs.KleinBottle.Properties where open import Cubical.Core.Everything open import Cubical.Foundations.Prelude open import Cubical.Foundations.Equiv open import Cubical.Foundations.Isomorphism open import Cubical.Foundations.GroupoidLaws open import Cubical.Foundations.HLevels open import Cubical.Foundations.Transport open import Cubical.Foundations.Univalence open import Cubical.Data.Int open import Cubical.Data.Sigma open import Cubical.HITs.S1 open import Cubical.HITs.PropositionalTruncation as PropTrunc open import Cubical.HITs.KleinBottle.Base loop1 : S¹ → KleinBottle loop1 base = point loop1 (loop i) = line1 i invS¹Loop : S¹ → Type invS¹Loop base = S¹ invS¹Loop (loop i) = invS¹Path i loop1Inv : (s : S¹) → loop1 (invLooper s) ≡ loop1 s loop1Inv base = line2 loop1Inv (loop i) = square i twist : (s : S¹) → PathP (λ i → invS¹Path i) s (invLooper s) twist s i = glue (λ {(i = i0) → s; (i = i1) → invLooper s}) (invLooper s) twistBaseLoop : (s : S¹) → invS¹Loop s twistBaseLoop base = base twistBaseLoop (loop i) = twist base i kleinBottle≃Σ : KleinBottle ≃ Σ S¹ invS¹Loop kleinBottle≃Σ = isoToEquiv (iso fro to froTo toFro) where fro : KleinBottle → Σ S¹ invS¹Loop fro point = (base , base) fro (line1 i) = (base , loop i) fro (line2 j) = (loop (~ j) , twist base (~ j)) fro (square i j) = (loop (~ j) , twist (loop i) (~ j)) toLoopFiller : (j : I) → ua invS¹Equiv j → I → KleinBottle toLoopFiller j g l = hfill (λ l → λ { (j = i0) → loop1Inv g l ; (j = i1) → loop1 g }) (inS (loop1 (unglue (j ∨ ~ j) g))) l to : Σ S¹ invS¹Loop → KleinBottle to (base , s) = loop1 s to (loop j , g) = toLoopFiller j g i1 toFro : (a : KleinBottle) → to (fro a) ≡ a toFro point = refl toFro (line1 i) = refl toFro (line2 j) k = lUnit line2 (~ k) j toFro (square i j) k = lUnit (square i) (~ k) j froLoop1 : (s : S¹) → fro (loop1 s) ≡ (base , s) froLoop1 base = refl froLoop1 (loop i) = refl froLoop1Inv : PathP (λ k → (s : S¹) → froLoop1 (invLooper s) k ≡ froLoop1 s k) (λ s l → fro (loop1Inv s l)) (λ s l → loop (~ l) , twist s (~ l)) froLoop1Inv k base l = loop (~ l) , twist base (~ l) froLoop1Inv k (loop i) l = loop (~ l) , twist (loop i) (~ l) froTo : (a : Σ S¹ invS¹Loop) → fro (to a) ≡ a froTo (base , s) = froLoop1 s froTo (loop j , g) k = hcomp (λ l → λ { (j = i0) → froLoop1Inv k g l ; (j = i1) → froLoop1 g k ; (k = i0) → fro (toLoopFiller j g l) ; (k = i1) → ( loop (j ∨ ~ l) , glue (λ { (j = i0) (l = i1) → g ; (j = i1) → g ; (l = i0) → unglue (j ∨ ~ j) g }) (unglue (j ∨ ~ j) g) ) }) (froLoop1 (unglue (j ∨ ~ j) g) k) isGroupoidKleinBottle : isGroupoid KleinBottle isGroupoidKleinBottle = transport (λ i → isGroupoid (ua kleinBottle≃Σ (~ i))) (isOfHLevelΣ 3 isGroupoidS¹ (λ s → PropTrunc.rec (isPropIsOfHLevel 3) (λ p → subst (λ s → isGroupoid (invS¹Loop s)) p isGroupoidS¹) (isConnectedS¹ s))) -- Transport across the following is too slow :( ΩKlein≡ℤ² : Path KleinBottle point point ≡ ℤ × ℤ ΩKlein≡ℤ² = Path KleinBottle point point ≡⟨ (λ i → basePath i ≡ basePath i) ⟩ Path (Σ S¹ invS¹Loop) (base , base) (base , base) ≡⟨ sym ΣPath≡PathΣ ⟩ Σ ΩS¹ (λ p → PathP (λ j → invS¹Loop (p j)) base base) ≡⟨ (λ i → Σ ΩS¹ (λ p → PathP (λ j → invS¹Loop (p (j ∨ i))) (twistBaseLoop (p i)) base)) ⟩ ΩS¹ × ΩS¹ ≡⟨ (λ i → ΩS¹≡ℤ i × ΩS¹≡ℤ i) ⟩ ℤ × ℤ ∎ where basePath : PathP (λ i → ua kleinBottle≃Σ i) point (base , base) basePath i = glue (λ {(i = i0) → point; (i = i1) → base , base}) (base , base) -- We can at least define the winding function directly and get results on small examples windingKlein : Path KleinBottle point point → ℤ × ℤ windingKlein p = (z₀ , z₁) where step₀ : Path (Σ S¹ invS¹Loop) (base , base) (base , base) step₀ = (λ i → kleinBottle≃Σ .fst (p i)) z₀ : ℤ z₀ = winding (λ i → kleinBottle≃Σ .fst (p i) .fst) z₁ : ℤ z₁ = winding (transport (λ i → PathP (λ j → invS¹Loop (step₀ (j ∨ i) .fst)) (twistBaseLoop (step₀ i .fst)) base) (cong snd step₀)) _ : windingKlein line1 ≡ (pos 0 , pos 1) _ = refl _ : windingKlein line2 ≡ (negsuc 0 , pos 0) _ = refl _ : windingKlein (line1 ∙ line2) ≡ (negsuc 0 , negsuc 0) _ = refl _ : windingKlein (line1 ∙ line2 ∙ line1) ≡ (negsuc 0 , pos 0) _ = refl
28.8125
94
0.593275
2ee24fd191f7c5a1b38c2929e1b5e818511c9a4a
352
agda
Agda
app/bee2.agda
semenov-vladyslav/bee2-agda
22682afc8d488e3812307e104785d2b8dc8b9d4a
[ "MIT" ]
null
null
null
app/bee2.agda
semenov-vladyslav/bee2-agda
22682afc8d488e3812307e104785d2b8dc8b9d4a
[ "MIT" ]
null
null
null
app/bee2.agda
semenov-vladyslav/bee2-agda
22682afc8d488e3812307e104785d2b8dc8b9d4a
[ "MIT" ]
null
null
null
module bee2 where open import Bee2.Crypto.Belt open import Data.ByteString.Utf8 open import Data.ByteString.IO open import Data.String using (toList) open import Data.Product using (proj₁) open import IO -- beltPBKDF : Password → ℕ → Salt → Kek main = run (writeBinaryFile "pbkdf2" (proj₁ (beltPBKDF (packStrict "zed") 1000 (packStrict "salt"))))
23.466667
101
0.752841
1a4e1ff86a1cdf6c44d6905aeae83f2e19fbe157
4,223
agda
Agda
src/fot/FOTC/Program/Division/ConversionRulesI.agda
asr/fotc
2fc9f2b81052a2e0822669f02036c5750371b72d
[ "MIT" ]
11
2015-09-03T20:53:42.000Z
2021-09-12T16:09:54.000Z
src/fot/FOTC/Program/Division/ConversionRulesI.agda
asr/fotc
2fc9f2b81052a2e0822669f02036c5750371b72d
[ "MIT" ]
2
2016-10-12T17:28:16.000Z
2017-01-01T14:34:26.000Z
src/fot/FOTC/Program/Division/ConversionRulesI.agda
asr/fotc
2fc9f2b81052a2e0822669f02036c5750371b72d
[ "MIT" ]
3
2016-09-19T14:18:30.000Z
2018-03-14T08:50:00.000Z
------------------------------------------------------------------------------ -- Conversion rules for the division ------------------------------------------------------------------------------ {-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} module FOTC.Program.Division.ConversionRulesI where open import Common.FOL.Relation.Binary.EqReasoning open import FOTC.Base open import FOTC.Data.Nat open import FOTC.Data.Nat.Inequalities open import FOTC.Program.Division.Division ------------------------------------------------------------------------------ -- Division properties private -- Before to prove some properties for div it is convenient -- to have a proof for each possible execution step. -- Initially, we define the possible states (div-s₁, div-s₂, ...) -- and after that, we write down the proof for the execution step -- from the state p to the state q, e.g. -- -- proof₂₋₃ : ∀ i j → div-s₂ i j ≡ div-s₃ i j. -- Initially, the conversion rule div-eq is applied. div-s₁ : D → D → D div-s₁ i j = if (lt i j) then zero else succ₁ (div (i ∸ j) j) -- lt i j ≡ true. div-s₂ : D → D → D div-s₂ i j = if true then zero else succ₁ (div (i ∸ j) j) -- lt i j ≡ false. div-s₃ : D → D → D div-s₃ i j = if false then zero else succ₁ (div (i ∸ j) j) -- The conditional is true. div-s₄ : D div-s₄ = zero -- The conditional is false. div-s₅ : D → D → D div-s₅ i j = succ₁ (div (i ∸ j) j) {- To prove the execution steps, e.g. proof₃₋₄ : ∀ i j → div-s₃ i j → divh_s₄ i j, we usually need to prove that ... m ... ≡ ... n ... (1) given that m ≡ n, (2) where (2) is a conversion rule usually. We prove (1) using subst : ∀ {x y} (A : D → Set) → x ≡ y → A x → A y where • P is given by \m → ... m ... ≡ ... n ..., • x ≡ y is given n ≡ m (actually, we use ≡-sym (m ≡ n)) and • P x is given by ... n ... ≡ ... n ... (i.e. ≡-refl) -} -- From div i j to div-s₁ using the equation div-eq. proof₀₋₁ : ∀ i j → div i j ≡ div-s₁ i j proof₀₋₁ i j = div-eq i j -- From div-s₁ to div-s₂ using the proof i<j. proof₁₋₂ : ∀ i j → i < j → div-s₁ i j ≡ div-s₂ i j proof₁₋₂ i j i<j = subst (λ t → (if t then zero else succ₁ (div (i ∸ j) j)) ≡ (if true then zero else succ₁ (div (i ∸ j) j)) ) (sym i<j) refl -- From div-s₁ to div-s₃ using the proof i≮j. proof₁₋₃ : ∀ i j → i ≮ j → div-s₁ i j ≡ div-s₃ i j proof₁₋₃ i j i≮j = subst (λ t → (if t then zero else succ₁ (div (i ∸ j) j)) ≡ (if false then zero else succ₁ (div (i ∸ j) j)) ) (sym i≮j) refl -- From div-s₂ to div-s₄ using the conversion rule if-true. proof₂₋₄ : ∀ i j → div-s₂ i j ≡ div-s₄ proof₂₋₄ i j = if-true zero -- From div-s₃ to div-s₅ using the conversion rule if-false. proof₃₋₅ : ∀ i j → div-s₃ i j ≡ div-s₅ i j proof₃₋₅ i j = if-false (succ₁ (div (i ∸ j) j)) ---------------------------------------------------------------------- -- The division result when the dividend is minor than the -- the divisor. div-x<y : ∀ {i j} → i < j → div i j ≡ zero div-x<y {i} {j} i<j = div i j ≡⟨ proof₀₋₁ i j ⟩ div-s₁ i j ≡⟨ proof₁₋₂ i j i<j ⟩ div-s₂ i j ≡⟨ proof₂₋₄ i j ⟩ div-s₄ ∎ ---------------------------------------------------------------------- -- The division result when the dividend is greater or equal than the -- the divisor. div-x≮y : ∀ {i j} → i ≮ j → div i j ≡ succ₁ (div (i ∸ j) j) div-x≮y {i} {j} i≮j = div i j ≡⟨ proof₀₋₁ i j ⟩ div-s₁ i j ≡⟨ proof₁₋₃ i j i≮j ⟩ div-s₃ i j ≡⟨ proof₃₋₅ i j ⟩ div-s₅ i j ∎
29.950355
78
0.443997
4dd0098ee2d33ca69e56eb1bce168863ec0c4c17
306
agda
Agda
archive/agda-3/src/Oscar/Class/Bind.agda
m0davis/oscar
52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb
[ "RSA-MD" ]
null
null
null
archive/agda-3/src/Oscar/Class/Bind.agda
m0davis/oscar
52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb
[ "RSA-MD" ]
1
2019-04-29T00:35:04.000Z
2019-05-11T23:33:04.000Z
archive/agda-3/src/Oscar/Class/Bind.agda
m0davis/oscar
52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb
[ "RSA-MD" ]
null
null
null
open import Oscar.Prelude module Oscar.Class.Bind where module _ (𝔉 : ∀ {𝔣} → Ø 𝔣 → Ø 𝔣) 𝔬₁ 𝔬₂ where 𝓫ind = ∀ {𝔒₁ : Ø 𝔬₁} {𝔒₂ : Ø 𝔬₂} → 𝔉 𝔒₁ → (𝔒₁ → 𝔉 𝔒₂) → 𝔉 𝔒₂ record 𝓑ind : Ø ↑̂ (𝔬₁ ∙̂ 𝔬₂) where infixl 6 bind field bind : 𝓫ind syntax bind m f = f =<< m open 𝓑ind ⦃ … ⦄ public
19.125
62
0.542484
1a7e035c73e8412830568f4f6147d65c2c8c6a01
295
agda
Agda
test/Datatypes.agda
JonathanBrouwer/agda2hs
dcf63cc7ce51a325a97ac58bdd0aeace24c08b15
[ "MIT" ]
55
2020-10-20T13:36:25.000Z
2022-03-26T21:57:56.000Z
test/Datatypes.agda
SNU-2D/agda2hs
160478a51bc78b0fdab07b968464420439f9fed6
[ "MIT" ]
63
2020-10-22T05:19:27.000Z
2022-02-25T15:47:30.000Z
test/Datatypes.agda
SNU-2D/agda2hs
160478a51bc78b0fdab07b968464420439f9fed6
[ "MIT" ]
18
2020-10-21T22:19:09.000Z
2022-03-12T11:42:52.000Z
open import Agda.Builtin.Bool data Test : Set where CTest : Bool -> {Bool} -> Test {-# COMPILE AGDA2HS Test #-} getTest : Test → Bool getTest (CTest b) = b {-# COMPILE AGDA2HS getTest #-} putTest : Bool → Test → Test putTest b (CTest _ {b'}) = CTest b {b'} {-# COMPILE AGDA2HS putTest #-}
19.666667
39
0.637288
2e125944cff3420ece1e06f8986063b563e03e83
2,347
agda
Agda
src/MLib/Algebra/PropertyCode/Dependent.agda
bch29/agda-matrices
e26ae2e0aa7721cb89865aae78625a2f3fd2b574
[ "MIT" ]
null
null
null
src/MLib/Algebra/PropertyCode/Dependent.agda
bch29/agda-matrices
e26ae2e0aa7721cb89865aae78625a2f3fd2b574
[ "MIT" ]
null
null
null
src/MLib/Algebra/PropertyCode/Dependent.agda
bch29/agda-matrices
e26ae2e0aa7721cb89865aae78625a2f3fd2b574
[ "MIT" ]
null
null
null
open import MLib.Algebra.PropertyCode module MLib.Algebra.PropertyCode.Dependent {k c ℓ} {code : Code k} (struct : Struct code c ℓ) where open import MLib.Prelude open import MLib.Algebra.PropertyCode.Core open import Function.Equivalence using (Equivalence) open Struct struct private module FuncBased {c′ ℓ′} (depRawStruct : RawStruct K c′ ℓ′) (props : ∀ π → Maybe (∃ λ deps → ⦃ _ : Hasₚ deps ⦄ → ⟦ π ⟧P depRawStruct)) where Π′ : Properties code Π′ = properties λ π → case props π of λ { (just (deps , _)) → implies deps Π ; nothing → false } Π′-prop : ∀ {π} → π ∈ₚ Π′ → ∃ λ x → props π ≡ just x Π′-prop {π} π∈Π′ with props π | ≡.inspect props π Π′-prop {π} π∈Π′ | just x | _ = x , ≡.refl Π′-prop {π} (fromTruth truth) | nothing | ≡.[ eq ] rewrite eq = ⊥-elim truth reify′ : ∀ {π} → π ∈ₚ Π′ → ⟦ π ⟧P depRawStruct reify′ {π} π∈Π′ with Π′-prop π∈Π′ | hasProperty Π′ π | ≡.inspect (hasProperty Π′) π reify′ {_} (fromTruth truth) | (deps , f) , eq | false | ≡.[ eq₁ ] rewrite eq | eq₁ = ⊥-elim truth reify′ {_} (fromTruth truth) | (deps , f) , eq | true | ≡.[ eq₁ ] rewrite eq = f ⦃ fromTruth truth ⦄ dependentStruct : Struct code c′ ℓ′ dependentStruct = record { rawStruct = depRawStruct ; Π = Π′ ; reify = reify′ } module ListBased {c′ ℓ′} (depRawStruct : RawStruct K c′ ℓ′) (props : List (∃₂ λ π deps → ⦃ _ : Hasₚ deps ⦄ → ⟦ π ⟧P depRawStruct)) where Func = ∀ π → Maybe (∃ (λ deps → ⦃ _ : Hasₚ deps ⦄ → ⟦ π ⟧P depRawStruct)) singleFunc : (∃₂ λ π deps → ⦃ _ : Hasₚ deps ⦄ → ⟦ π ⟧P depRawStruct) → Func singleFunc (π , deps , f) π′ with π Property.≟ π′ singleFunc (π , deps , f) π′ | yes p rewrite Property.≈⇒≡ p = just (deps , f) singleFunc (π , deps , f) π′ | no _ = nothing combineFuncs : Func → Func → Func combineFuncs f g π = case f π of λ { (just r) → just r ; nothing → case g π of λ { (just r) → just r ; nothing → nothing } } propsF : ∀ π → Maybe (∃ (λ deps → ⦃ _ : Hasₚ deps ⦄ → ⟦ π ⟧P depRawStruct)) propsF = List.foldr combineFuncs (λ _ → nothing) (List.map singleFunc props) dependentStruct : Struct code c′ ℓ′ dependentStruct = FuncBased.dependentStruct depRawStruct propsF open ListBased using (dependentStruct) public
36.671875
142
0.583724
29c8bedb577464246d7b576cea0216cf9bef35e8
3,236
agda
Agda
src/Categories/Category/Finite/Fin/Instance/Triangle.agda
jaykru/agda-categories
a4053cf700bcefdf73b857c3352f1eae29382a60
[ "MIT" ]
279
2019-06-01T14:36:40.000Z
2022-03-22T00:40:14.000Z
src/Categories/Category/Finite/Fin/Instance/Triangle.agda
seanpm2001/agda-categories
d9e4f578b126313058d105c61707d8c8ae987fa8
[ "MIT" ]
236
2019-06-01T14:53:54.000Z
2022-03-28T14:31:43.000Z
src/Categories/Category/Finite/Fin/Instance/Triangle.agda
seanpm2001/agda-categories
d9e4f578b126313058d105c61707d8c8ae987fa8
[ "MIT" ]
64
2019-06-02T16:58:15.000Z
2022-03-14T02:00:59.000Z
{-# OPTIONS --without-K --safe #-} module Categories.Category.Finite.Fin.Instance.Triangle where open import Data.Nat.Base using (ℕ) open import Data.Fin.Base using (Fin) open import Data.Fin.Patterns open import Relation.Binary.PropositionalEquality.Core as ≡ open import Categories.Category.Finite.Fin open import Categories.Category.Core private variable a b c d : Fin 3 -- the diagram is the following: -- -- 0 -- | \ -- | \ -- | \ -- | \ -- v v -- 1 ---> 2 -- -- all morphisms are 0 (because there is at most one morphism between each pair of objects). TriangleShape : FinCatShape TriangleShape = shapeHelper record { size = 3 ; ∣_⇒_∣ = morph ; id = id ; _∘_ = _∘_ ; assoc = assoc ; identityˡ = identityˡ ; identityʳ = identityʳ } where morph : Fin 3 → Fin 3 → ℕ morph 0F 0F = 1 morph 0F 1F = 1 morph 0F 2F = 1 morph 1F 1F = 1 morph 1F 2F = 1 morph 2F 2F = 1 morph _ _ = 0 id : Fin (morph a a) id {0F} = 0F id {1F} = 0F id {2F} = 0F _∘_ : ∀ {a b c} → Fin (morph b c) → Fin (morph a b) → Fin (morph a c) _∘_ {0F} {0F} {0F} 0F 0F = 0F _∘_ {0F} {0F} {1F} 0F 0F = 0F _∘_ {0F} {0F} {2F} 0F 0F = 0F _∘_ {0F} {1F} {1F} 0F 0F = 0F _∘_ {0F} {1F} {2F} 0F 0F = 0F _∘_ {0F} {2F} {2F} 0F 0F = 0F _∘_ {1F} {1F} {1F} 0F 0F = 0F _∘_ {1F} {1F} {2F} 0F 0F = 0F _∘_ {1F} {2F} {2F} 0F 0F = 0F _∘_ {2F} {2F} {2F} 0F 0F = 0F assoc : ∀ {f : Fin (morph a b)} {g : Fin (morph b c)} {h : Fin (morph c d)} → ((h ∘ g) ∘ f) ≡ (h ∘ (g ∘ f)) assoc {0F} {0F} {0F} {0F} {0F} {0F} {0F} = refl assoc {0F} {0F} {0F} {1F} {0F} {0F} {0F} = refl assoc {0F} {0F} {0F} {2F} {0F} {0F} {0F} = refl assoc {0F} {0F} {1F} {1F} {0F} {0F} {0F} = refl assoc {0F} {0F} {1F} {2F} {0F} {0F} {0F} = refl assoc {0F} {0F} {2F} {2F} {0F} {0F} {0F} = refl assoc {0F} {1F} {1F} {1F} {0F} {0F} {0F} = refl assoc {0F} {1F} {1F} {2F} {0F} {0F} {0F} = refl assoc {0F} {1F} {2F} {2F} {0F} {0F} {0F} = refl assoc {0F} {2F} {2F} {2F} {0F} {0F} {0F} = refl assoc {1F} {1F} {1F} {1F} {0F} {0F} {0F} = refl assoc {1F} {1F} {1F} {2F} {0F} {0F} {0F} = refl assoc {1F} {1F} {2F} {2F} {0F} {0F} {0F} = refl assoc {1F} {2F} {2F} {2F} {0F} {0F} {0F} = refl assoc {2F} {2F} {2F} {2F} {0F} {0F} {0F} = refl identityˡ : ∀ {f : Fin (morph a b)} → (id ∘ f) ≡ f identityˡ {0F} {0F} {0F} = refl identityˡ {0F} {1F} {0F} = refl identityˡ {0F} {2F} {0F} = refl identityˡ {1F} {1F} {0F} = refl identityˡ {1F} {2F} {0F} = refl identityˡ {2F} {2F} {0F} = refl identityʳ : ∀ {f : Fin (morph a b)} → (f ∘ id) ≡ f identityʳ {0F} {0F} {0F} = refl identityʳ {0F} {1F} {0F} = refl identityʳ {0F} {2F} {0F} = refl identityʳ {1F} {1F} {0F} = refl identityʳ {1F} {2F} {0F} = refl identityʳ {2F} {2F} {0F} = refl Triangle : Category _ _ _ Triangle = FinCategory TriangleShape module Triangle = Category Triangle
31.72549
92
0.480532
add8e5047e088c7a4f538e965f78623c4b241e88
591
agda
Agda
agda-stdlib-0.9/src/Data/Star/Fin.agda
qwe2/try-agda
9d4c43b1609d3f085636376fdca73093481ab882
[ "Apache-2.0" ]
1
2016-10-20T15:52:05.000Z
2016-10-20T15:52:05.000Z
agda-stdlib-0.9/src/Data/Star/Fin.agda
qwe2/try-agda
9d4c43b1609d3f085636376fdca73093481ab882
[ "Apache-2.0" ]
null
null
null
agda-stdlib-0.9/src/Data/Star/Fin.agda
qwe2/try-agda
9d4c43b1609d3f085636376fdca73093481ab882
[ "Apache-2.0" ]
null
null
null
------------------------------------------------------------------------ -- The Agda standard library -- -- Finite sets defined in terms of Data.Star ------------------------------------------------------------------------ module Data.Star.Fin where open import Data.Star open import Data.Star.Nat as ℕ using (ℕ) open import Data.Star.Pointer open import Data.Unit -- Finite sets are undecorated pointers into natural numbers. Fin : ℕ → Set Fin = Any (λ _ → ⊤) (λ _ → ⊤) -- "Constructors". zero : ∀ {n} → Fin (ℕ.suc n) zero = this tt suc : ∀ {n} → Fin n → Fin (ℕ.suc n) suc = that tt
22.730769
72
0.500846
1a8b245772bf61994694fff6bae9d6d9863d95fa
9,780
agda
Agda
Cubical/Algebra/AbGroup/Base.agda
anuyts/cubical
2868ce7542c0b63f185344cffbd90c1cc033027c
[ "MIT" ]
null
null
null
Cubical/Algebra/AbGroup/Base.agda
anuyts/cubical
2868ce7542c0b63f185344cffbd90c1cc033027c
[ "MIT" ]
null
null
null
Cubical/Algebra/AbGroup/Base.agda
anuyts/cubical
2868ce7542c0b63f185344cffbd90c1cc033027c
[ "MIT" ]
null
null
null
{-# OPTIONS --safe #-} module Cubical.Algebra.AbGroup.Base where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Equiv open import Cubical.Foundations.Equiv.HalfAdjoint open import Cubical.Foundations.HLevels open import Cubical.Foundations.Isomorphism open import Cubical.Foundations.Univalence open import Cubical.Foundations.Transport open import Cubical.Foundations.SIP open import Cubical.Data.Sigma open import Cubical.Data.Unit open import Cubical.Algebra.Semigroup open import Cubical.Algebra.Monoid open import Cubical.Algebra.CommMonoid open import Cubical.Algebra.Group open import Cubical.Algebra.Group.Morphisms open import Cubical.Algebra.Group.MorphismProperties open import Cubical.Algebra.Group.DirProd open import Cubical.Displayed.Base open import Cubical.Displayed.Auto open import Cubical.Displayed.Record open import Cubical.Displayed.Universe open Iso private variable ℓ ℓ' : Level record IsAbGroup {G : Type ℓ} (0g : G) (_+_ : G → G → G) (-_ : G → G) : Type ℓ where constructor isabgroup field isGroup : IsGroup 0g _+_ -_ comm : (x y : G) → x + y ≡ y + x open IsGroup isGroup public record AbGroupStr (A : Type ℓ) : Type (ℓ-suc ℓ) where constructor abgroupstr field 0g : A _+_ : A → A → A -_ : A → A isAbGroup : IsAbGroup 0g _+_ -_ infix 8 -_ infixr 7 _+_ open IsAbGroup isAbGroup public AbGroup : ∀ ℓ → Type (ℓ-suc ℓ) AbGroup ℓ = TypeWithStr ℓ AbGroupStr makeIsAbGroup : {G : Type ℓ} {0g : G} {_+_ : G → G → G} { -_ : G → G} (is-setG : isSet G) (assoc : (x y z : G) → x + (y + z) ≡ (x + y) + z) (rid : (x : G) → x + 0g ≡ x) (rinv : (x : G) → x + (- x) ≡ 0g) (comm : (x y : G) → x + y ≡ y + x) → IsAbGroup 0g _+_ -_ makeIsAbGroup is-setG assoc rid rinv comm = isabgroup (makeIsGroup is-setG assoc rid (λ x → comm _ _ ∙ rid x) rinv (λ x → comm _ _ ∙ rinv x)) comm makeAbGroup : {G : Type ℓ} (0g : G) (_+_ : G → G → G) (-_ : G → G) (is-setG : isSet G) (assoc : (x y z : G) → x + (y + z) ≡ (x + y) + z) (rid : (x : G) → x + 0g ≡ x) (rinv : (x : G) → x + (- x) ≡ 0g) (comm : (x y : G) → x + y ≡ y + x) → AbGroup ℓ makeAbGroup 0g _+_ -_ is-setG assoc rid rinv comm = _ , abgroupstr 0g _+_ -_ (makeIsAbGroup is-setG assoc rid rinv comm) open GroupStr open AbGroupStr open IsAbGroup AbGroupStr→GroupStr : {G : Type ℓ} → AbGroupStr G → GroupStr G AbGroupStr→GroupStr A .1g = A .0g AbGroupStr→GroupStr A ._·_ = A ._+_ AbGroupStr→GroupStr A .inv = A .-_ AbGroupStr→GroupStr A .isGroup = A .isAbGroup .isGroup AbGroup→Group : AbGroup ℓ → Group ℓ fst (AbGroup→Group A) = fst A snd (AbGroup→Group A) = AbGroupStr→GroupStr (snd A) Group→AbGroup : (G : Group ℓ) → ((x y : fst G) → _·_ (snd G) x y ≡ _·_ (snd G) y x) → AbGroup ℓ fst (Group→AbGroup G comm) = fst G AbGroupStr.0g (snd (Group→AbGroup G comm)) = 1g (snd G) AbGroupStr._+_ (snd (Group→AbGroup G comm)) = _·_ (snd G) AbGroupStr.- snd (Group→AbGroup G comm) = inv (snd G) IsAbGroup.isGroup (AbGroupStr.isAbGroup (snd (Group→AbGroup G comm))) = isGroup (snd G) IsAbGroup.comm (AbGroupStr.isAbGroup (snd (Group→AbGroup G comm))) = comm AbGroup→CommMonoid : AbGroup ℓ → CommMonoid ℓ AbGroup→CommMonoid (_ , abgroupstr _ _ _ G) = _ , commmonoidstr _ _ (iscommmonoid (IsAbGroup.isMonoid G) (IsAbGroup.comm G)) isSetAbGroup : (A : AbGroup ℓ) → isSet ⟨ A ⟩ isSetAbGroup A = isSetGroup (AbGroup→Group A) AbGroupHom : (G : AbGroup ℓ) (H : AbGroup ℓ') → Type (ℓ-max ℓ ℓ') AbGroupHom G H = GroupHom (AbGroup→Group G) (AbGroup→Group H) AbGroupIso : (G : AbGroup ℓ) (H : AbGroup ℓ') → Type (ℓ-max ℓ ℓ') AbGroupIso G H = GroupIso (AbGroup→Group G) (AbGroup→Group H) IsAbGroupEquiv : {A : Type ℓ} {B : Type ℓ'} (G : AbGroupStr A) (e : A ≃ B) (H : AbGroupStr B) → Type (ℓ-max ℓ ℓ') IsAbGroupEquiv G e H = IsGroupHom (AbGroupStr→GroupStr G) (e .fst) (AbGroupStr→GroupStr H) AbGroupEquiv : (G : AbGroup ℓ) (H : AbGroup ℓ') → Type (ℓ-max ℓ ℓ') AbGroupEquiv G H = Σ[ e ∈ (G .fst ≃ H .fst) ] IsAbGroupEquiv (G .snd) e (H .snd) isPropIsAbGroup : {G : Type ℓ} (0g : G) (_+_ : G → G → G) (- : G → G) → isProp (IsAbGroup 0g _+_ -) isPropIsAbGroup 0g _+_ -_ (isabgroup GG GC) (isabgroup HG HC) = λ i → isabgroup (isPropIsGroup _ _ _ GG HG i) (isPropComm GC HC i) where isSetG : isSet _ isSetG = GG .IsGroup.isMonoid .IsMonoid.isSemigroup .IsSemigroup.is-set isPropComm : isProp ((x y : _) → x + y ≡ y + x) isPropComm = isPropΠ2 λ _ _ → isSetG _ _ 𝒮ᴰ-AbGroup : DUARel (𝒮-Univ ℓ) AbGroupStr ℓ 𝒮ᴰ-AbGroup = 𝒮ᴰ-Record (𝒮-Univ _) IsAbGroupEquiv (fields: data[ _+_ ∣ autoDUARel _ _ ∣ pres· ] data[ 0g ∣ autoDUARel _ _ ∣ pres1 ] data[ -_ ∣ autoDUARel _ _ ∣ presinv ] prop[ isAbGroup ∣ (λ _ _ → isPropIsAbGroup _ _ _) ]) where open AbGroupStr open IsGroupHom -- Extract the characterization of equality of groups AbGroupPath : (G H : AbGroup ℓ) → (AbGroupEquiv G H) ≃ (G ≡ H) AbGroupPath = ∫ 𝒮ᴰ-AbGroup .UARel.ua -- TODO: Induced structure results are temporarily inconvenient while we transition between algebra -- representations module _ (G : AbGroup ℓ) {A : Type ℓ} (m : A → A → A) (e : ⟨ G ⟩ ≃ A) (p· : ∀ x y → e .fst (G .snd ._+_ x y) ≡ m (e .fst x) (e .fst y)) where private module G = AbGroupStr (G .snd) FamilyΣ : Σ[ B ∈ Type ℓ ] (B → B → B) → Type ℓ FamilyΣ (B , n) = Σ[ e ∈ B ] Σ[ i ∈ (B → B) ] IsAbGroup e n i inducedΣ : FamilyΣ (A , m) inducedΣ = subst FamilyΣ (UARel.≅→≡ (autoUARel (Σ[ B ∈ Type ℓ ] (B → B → B))) (e , p·)) (G.0g , G.-_ , G.isAbGroup) InducedAbGroup : AbGroup ℓ InducedAbGroup .fst = A InducedAbGroup .snd ._+_ = m InducedAbGroup .snd .0g = inducedΣ .fst InducedAbGroup .snd .-_ = inducedΣ .snd .fst InducedAbGroup .snd .isAbGroup = inducedΣ .snd .snd InducedAbGroupPath : G ≡ InducedAbGroup InducedAbGroupPath = AbGroupPath _ _ .fst (e , makeIsGroupHom p·) open IsMonoid open IsSemigroup open IsGroup dirProdAb : AbGroup ℓ → AbGroup ℓ' → AbGroup (ℓ-max ℓ ℓ') dirProdAb A B = Group→AbGroup (DirProd (AbGroup→Group A) (AbGroup→Group B)) λ p q → ΣPathP (comm (isAbGroup (snd A)) _ _ , comm (isAbGroup (snd B)) _ _) trivialAbGroup : ∀ {ℓ} → AbGroup ℓ fst trivialAbGroup = Unit* 0g (snd trivialAbGroup) = tt* _+_ (snd trivialAbGroup) _ _ = tt* (- snd trivialAbGroup) _ = tt* is-set (isSemigroup (isMonoid (isGroup (isAbGroup (snd trivialAbGroup))))) = isProp→isSet isPropUnit* assoc (isSemigroup (isMonoid (isGroup (isAbGroup (snd trivialAbGroup))))) _ _ _ = refl identity (isMonoid (isGroup (isAbGroup (snd trivialAbGroup)))) _ = refl , refl inverse (isGroup (isAbGroup (snd trivialAbGroup))) _ = refl , refl comm (isAbGroup (snd trivialAbGroup)) _ _ = refl -- useful lemma move4 : ∀ {ℓ} {A : Type ℓ} (x y z w : A) (_+_ : A → A → A) → ((x y z : A) → x + (y + z) ≡ (x + y) + z) → ((x y : A) → x + y ≡ y + x) → (x + y) + (z + w) ≡ ((x + z) + (y + w)) move4 x y z w _+_ assoc comm = sym (assoc x y (z + w)) ∙∙ cong (x +_) (assoc y z w ∙∙ cong (_+ w) (comm y z) ∙∙ sym (assoc z y w)) ∙∙ assoc x z (y + w) ---- The type of homomorphisms A → B is an AbGroup if B is ----- module _ {ℓ ℓ' : Level} (AGr : Group ℓ) (BGr : AbGroup ℓ') where private strA = snd AGr strB = snd BGr _* = AbGroup→Group A = fst AGr B = fst BGr open IsGroupHom open AbGroupStr strB renaming (_+_ to _+B_ ; -_ to -B_ ; 0g to 0B ; rid to ridB ; lid to lidB ; assoc to assocB ; comm to commB ; invr to invrB ; invl to invlB) open GroupStr strA renaming (_·_ to _∙A_ ; inv to -A_ ; 1g to 1A ; rid to ridA) trivGroupHom : GroupHom AGr (BGr *) fst trivGroupHom x = 0B snd trivGroupHom = makeIsGroupHom λ _ _ → sym (ridB 0B) compHom : GroupHom AGr (BGr *) → GroupHom AGr (BGr *) → GroupHom AGr (BGr *) fst (compHom f g) x = fst f x +B fst g x snd (compHom f g) = makeIsGroupHom λ x y → cong₂ _+B_ (pres· (snd f) x y) (pres· (snd g) x y) ∙ move4 (fst f x) (fst f y) (fst g x) (fst g y) _+B_ assocB commB invHom : GroupHom AGr (BGr *) → GroupHom AGr (BGr *) fst (invHom (f , p)) x = -B f x snd (invHom (f , p)) = makeIsGroupHom λ x y → cong -B_ (pres· p x y) ∙∙ GroupTheory.invDistr (BGr *) (f x) (f y) ∙∙ commB _ _ open AbGroupStr open IsAbGroup open IsGroup open IsMonoid open IsSemigroup HomGroup : AbGroup (ℓ-max ℓ ℓ') fst HomGroup = GroupHom AGr (BGr *) 0g (snd HomGroup) = trivGroupHom AbGroupStr._+_ (snd HomGroup) = compHom AbGroupStr.- snd HomGroup = invHom is-set (isSemigroup (isMonoid (isGroup (isAbGroup (snd HomGroup))))) = isSetGroupHom assoc (isSemigroup (isMonoid (isGroup (isAbGroup (snd HomGroup))))) (f , p) (g , q) (h , r) = Σ≡Prop (λ _ → isPropIsGroupHom _ _) (funExt λ x → assocB _ _ _) fst (identity (isMonoid (isGroup (isAbGroup (snd HomGroup)))) (f , p)) = Σ≡Prop (λ _ → isPropIsGroupHom _ _) (funExt λ y → ridB _) snd (identity (isMonoid (isGroup (isAbGroup (snd HomGroup)))) (f , p)) = Σ≡Prop (λ _ → isPropIsGroupHom _ _) (funExt λ x → lidB _) fst (inverse (isGroup (isAbGroup (snd HomGroup))) (f , p)) = Σ≡Prop (λ _ → isPropIsGroupHom _ _) (funExt λ x → invrB (f x)) snd (inverse (isGroup (isAbGroup (snd HomGroup))) (f , p)) = Σ≡Prop (λ _ → isPropIsGroupHom _ _) (funExt λ x → invlB (f x)) comm (isAbGroup (snd HomGroup)) (f , p) (g , q) = Σ≡Prop (λ _ → isPropIsGroupHom _ _) (funExt λ x → commB _ _)
34.315789
104
0.608282
dc6b4fe94c74a0cca7002482eb15b84a02124e95
529
agda
Agda
Cubical/Experiments/Everything.agda
kiana-S/univalent-foundations
8bdb0766260489f9c89a14f4c0f2ad26e5190dec
[ "MIT" ]
null
null
null
Cubical/Experiments/Everything.agda
kiana-S/univalent-foundations
8bdb0766260489f9c89a14f4c0f2ad26e5190dec
[ "MIT" ]
1
2022-01-27T02:07:48.000Z
2022-01-27T02:07:48.000Z
Cubical/Experiments/Everything.agda
kiana-S/univalent-foundations
8bdb0766260489f9c89a14f4c0f2ad26e5190dec
[ "MIT" ]
1
2021-11-22T02:02:01.000Z
2021-11-22T02:02:01.000Z
-- Export only the experiments that are expected to compile (without -- any holes) {-# OPTIONS --cubical --no-import-sorts #-} module Cubical.Experiments.Everything where open import Cubical.Experiments.Brunerie public open import Cubical.Experiments.EscardoSIP public open import Cubical.Experiments.Generic public open import Cubical.Experiments.NatMinusTwo open import Cubical.Experiments.Problem open import Cubical.Experiments.FunExtFromUA public open import Cubical.Experiments.HoTT-UF open import Cubical.Experiments.Rng
37.785714
68
0.833648
3d7188c2480a8e439931c246ee4e86295b33f501
8,224
agda
Agda
Categories/NaturalTransformation/Dinatural.agda
rei1024/agda-categories
89d163f72caa7deeac9413f27bc1b4ed7f9e025b
[ "MIT" ]
null
null
null
Categories/NaturalTransformation/Dinatural.agda
rei1024/agda-categories
89d163f72caa7deeac9413f27bc1b4ed7f9e025b
[ "MIT" ]
null
null
null
Categories/NaturalTransformation/Dinatural.agda
rei1024/agda-categories
89d163f72caa7deeac9413f27bc1b4ed7f9e025b
[ "MIT" ]
null
null
null
{-# OPTIONS --without-K --safe #-} module Categories.NaturalTransformation.Dinatural where open import Level open import Data.Product open import Relation.Binary using (Rel; IsEquivalence; Setoid) open import Categories.Category open import Categories.NaturalTransformation as NT hiding (_∘ʳ_) open import Categories.Functor open import Categories.Functor.Construction.Constant open import Categories.Functor.Bifunctor open import Categories.Category.Product import Categories.Morphism.Reasoning as MR private variable o ℓ e : Level C D E : Category o ℓ e record DinaturalTransformation (F G : Bifunctor (Category.op C) C D) : Set (levelOfTerm F) where eta-equality private module C = Category C module D = Category D module F = Functor F module G = Functor G open D hiding (op) open Commutation field α : ∀ X → D [ F.F₀ (X , X) , G.F₀ (X , X) ] commute : ∀ {X Y} (f : C [ X , Y ]) → [ F.F₀ (Y , X) ⇒ G.F₀ (X , Y) ]⟨ F.F₁ (f , C.id) ⇒⟨ F.F₀ (X , X) ⟩ α X ⇒⟨ G.F₀ (X , X) ⟩ G.F₁ (C.id , f) ≈ F.F₁ (C.id , f) ⇒⟨ F.F₀ (Y , Y) ⟩ α Y ⇒⟨ G.F₀ (Y , Y) ⟩ G.F₁ (f , C.id) ⟩ -- We add this extra proof, because, again, we want to ensure the opposite of the -- opposite of dinatural transformation is definitionally equal to itself. op-commute : ∀ {X Y} (f : C [ X , Y ]) → [ F.F₀ (Y , X) ⇒ G.F₀ (X , Y) ]⟨ F.F₁ (C.id , f) ⇒⟨ F.F₀ (Y , Y) ⟩ (α Y ⇒⟨ G.F₀ (Y , Y) ⟩ G.F₁ (f , C.id)) ≈ F.F₁ (f , C.id) ⇒⟨ F.F₀ (X , X) ⟩ (α X ⇒⟨ G.F₀ (X , X) ⟩ G.F₁ (C.id , f)) ⟩ op : DinaturalTransformation G.op F.op op = record { α = α ; commute = op-commute ; op-commute = commute } -- to reduce the burden of constructing a DinaturalTransformation, we introduce -- another helper. record DTHelper (F G : Bifunctor (Category.op C) C D) : Set (levelOfTerm F) where private module C = Category C module D = Category D module F = Functor F module G = Functor G open D hiding (op) open Commutation field α : ∀ X → D [ F.F₀ (X , X) , G.F₀ (X , X) ] commute : ∀ {X Y} (f : C [ X , Y ]) → [ F.F₀ (Y , X) ⇒ G.F₀ (X , Y) ]⟨ F.F₁ (f , C.id) ⇒⟨ F.F₀ (X , X) ⟩ α X ⇒⟨ G.F₀ (X , X) ⟩ G.F₁ (C.id , f) ≈ F.F₁ (C.id , f) ⇒⟨ F.F₀ (Y , Y) ⟩ α Y ⇒⟨ G.F₀ (Y , Y) ⟩ G.F₁ (f , C.id) ⟩ dtHelper : ∀ {F G : Bifunctor (Category.op C) C D} → DTHelper F G → DinaturalTransformation F G dtHelper {D = D} θ = record { α = α ; commute = commute ; op-commute = λ f → assoc ○ ⟺ (commute f) ○ sym-assoc } where open DTHelper θ open Category D open HomReasoning module _ {F G H : Bifunctor (Category.op C) C D} where private module C = Category C open Category D open HomReasoning open Functor open MR D infixr 9 _<∘_ infixl 9 _∘>_ _<∘_ : NaturalTransformation G H → DinaturalTransformation F G → DinaturalTransformation F H θ <∘ β = dtHelper record { α = λ X → η (X , X) ∘ α X ; commute = λ {X Y} f → begin F₁ H (C.id , f) ∘ (η (X , X) ∘ α X) ∘ F₁ F (f , C.id) ≈˘⟨ pushˡ (pushˡ (θ.commute (C.id , f))) ⟩ ((η (X , Y) ∘ F₁ G (C.id , f)) ∘ α X) ∘ F₁ F (f , C.id) ≈⟨ assoc ○ pullʳ (β.commute f) ⟩ η (X , Y) ∘ F₁ G (f , C.id) ∘ α Y ∘ F₁ F (C.id , f) ≈⟨ pullˡ (θ.commute (f , C.id)) ○ pullʳ (⟺ assoc) ⟩ F₁ H (f , C.id) ∘ (η (Y , Y) ∘ α Y) ∘ F₁ F (C.id , f) ∎ } where module θ = NaturalTransformation θ module β = DinaturalTransformation β open θ open β _∘>_ : DinaturalTransformation G H → NaturalTransformation F G → DinaturalTransformation F H β ∘> θ = dtHelper record { α = λ X → α X ∘ η (X , X) ; commute = λ {X Y} f → begin F₁ H (C.id , f) ∘ (α X ∘ η (X , X)) ∘ F₁ F (f , C.id) ≈⟨ refl⟩∘⟨ pullʳ (θ.commute (f , C.id)) ⟩ F₁ H (C.id , f) ∘ α X ∘ F₁ G (f , C.id) ∘ η (Y , X) ≈˘⟨ assoc ○ ∘-resp-≈ʳ assoc ⟩ (F₁ H (C.id , f) ∘ α X ∘ F₁ G (f , C.id)) ∘ η (Y , X) ≈⟨ β.commute f ⟩∘⟨refl ⟩ (F₁ H (f , C.id) ∘ α Y ∘ F₁ G (C.id , f)) ∘ η (Y , X) ≈˘⟨ pushʳ (assoc ○ pushʳ (θ.commute (C.id , f))) ⟩ F₁ H (f , C.id) ∘ (α Y ∘ η (Y , Y)) ∘ F₁ F (C.id , f) ∎ } where module θ = NaturalTransformation θ module β = DinaturalTransformation β open θ open β module _ {F G : Bifunctor (Category.op C) C D} where private module C = Category C open Category D open HomReasoning open Functor open MR D infixl 9 _∘ʳ_ _∘ʳ_ : ∀ {E : Category o ℓ e} → DinaturalTransformation F G → (K : Functor E C) → DinaturalTransformation (F ∘F ((Functor.op K) ⁂ K)) (G ∘F ((Functor.op K) ⁂ K)) _∘ʳ_ {E = E} β K = dtHelper record { α = λ X → α (F₀ K X) ; commute = λ {X Y} f → begin F₁ G (F₁ K E.id , F₁ K f) ∘ α (F₀ K X) ∘ F₁ F (F₁ K f , F₁ K E.id) ≈⟨ F-resp-≈ G (identity K , C.Equiv.refl) ⟩∘⟨ refl ⟩∘⟨ F-resp-≈ F (C.Equiv.refl , identity K) ⟩ F₁ G (C.id , F₁ K f) ∘ α (F₀ K X) ∘ F₁ F (F₁ K f , C.id) ≈⟨ commute (F₁ K f) ⟩ F₁ G (F₁ K f , C.id) ∘ α (F₀ K Y) ∘ F₁ F (C.id , F₁ K f) ≈˘⟨ F-resp-≈ G (C.Equiv.refl , identity K) ⟩∘⟨ refl ⟩∘⟨ F-resp-≈ F (identity K , C.Equiv.refl) ⟩ F₁ G (F₁ K f , F₁ K E.id) ∘ α (F₀ K Y) ∘ F₁ F (F₁ K E.id , F₁ K f) ∎ } where module β = DinaturalTransformation β module E = Category E open β infix 4 _≃_ _≃_ : Rel (DinaturalTransformation F G) _ β ≃ δ = ∀ {X} → α β X ≈ α δ X where open DinaturalTransformation ≃-isEquivalence : IsEquivalence _≃_ ≃-isEquivalence = record { refl = refl ; sym = λ eq → sym eq ; trans = λ eq eq′ → trans eq eq′ } ≃-setoid : Setoid _ _ ≃-setoid = record { Carrier = DinaturalTransformation F G ; _≈_ = _≃_ ; isEquivalence = ≃-isEquivalence } -- for convenience, the following are some helpers for the cases -- in which the bifunctor on the right is extranatural. Extranaturalʳ : ∀ {C : Category o ℓ e} → Category.Obj D → (F : Bifunctor (Category.op C) C D) → Set _ Extranaturalʳ A F = DinaturalTransformation (const A) F Extranaturalˡ : ∀ {C : Category o ℓ e} → (F : Bifunctor (Category.op C) C D) → Category.Obj D → Set _ Extranaturalˡ F A = DinaturalTransformation F (const A) module _ {F : Bifunctor (Category.op C) C D} where open Category D private module C = Category C variable A : Obj X Y : C.Obj f : X C.⇒ Y open Functor F open HomReasoning open MR D extranaturalʳ : (a : ∀ X → A ⇒ F₀ (X , X)) → (∀ {X X′ f} → F₁ (C.id , f) ∘ a X ≈ F₁ (f , C.id) ∘ a X′) → Extranaturalʳ A F extranaturalʳ a comm = dtHelper record { α = a ; commute = λ f → ∘-resp-≈ʳ identityʳ ○ comm ○ ∘-resp-≈ʳ (⟺ identityʳ) } open DinaturalTransformation extranatural-commʳ : (β : DinaturalTransformation (const A) F) → F₁ (C.id , f) ∘ α β X ≈ F₁ (f , C.id) ∘ α β Y extranatural-commʳ {f = f} β = ∘-resp-≈ʳ (⟺ identityʳ) ○ commute β f ○ ∘-resp-≈ʳ identityʳ -- the dual case, the bifunctor on the left is extranatural. extranaturalˡ : (a : ∀ X → F₀ (X , X) ⇒ A) → (∀ {X X′ f} → a X ∘ F₁ (f , C.id) ≈ a X′ ∘ F₁ (C.id , f)) → Extranaturalˡ F A extranaturalˡ a comm = dtHelper record { α = a ; commute = λ f → pullˡ identityˡ ○ comm ○ ⟺ (pullˡ identityˡ) } extranatural-commˡ : (β : DinaturalTransformation F (const A)) → α β X ∘ F₁ (f , C.id) ≈ α β Y ∘ F₁ (C.id , f) extranatural-commˡ {f = f} β = ⟺ (pullˡ identityˡ) ○ commute β f ○ pullˡ identityˡ
35.601732
140
0.504499
c78514245fb6ca43e8a45dade87c615b086fa04c
657
agda
Agda
test/Fail/Issue4704-fail.agda
cagix/agda
cc026a6a97a3e517bb94bafa9d49233b067c7559
[ "BSD-2-Clause" ]
1,989
2015-01-09T23:51:16.000Z
2022-03-30T18:20:48.000Z
test/Fail/Issue4704-fail.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
4,066
2015-01-10T11:24:51.000Z
2022-03-31T21:14:49.000Z
test/Fail/Issue4704-fail.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
371
2015-01-03T14:04:08.000Z
2022-03-30T19:00:30.000Z
open import Agda.Builtin.List open import Agda.Builtin.Nat infixl 6 _∷ʳ_ _∷ʳ_ : {A : Set} → List A → A → List A [] ∷ʳ x = x ∷ [] (hd ∷ tl) ∷ʳ x = hd ∷ tl ∷ʳ x infixl 5 _∷ʳ′_ data InitLast {A : Set} : List A → Set where [] : InitLast [] _∷ʳ′_ : (xs : List A) (x : A) → InitLast (xs ∷ʳ x) initLast : {A : Set} (xs : List A) → InitLast xs initLast [] = [] initLast (x ∷ xs) with initLast xs ... | [] = [] ∷ʳ′ x ... | ys ∷ʳ′ y = (x ∷ ys) ∷ʳ′ y f : (xs : List Nat) → Set f xs with initLast xs f xs | [] = {!!} f xs | xs ∷ʳ′ x = {!!} -- ^ Shadowing a variable that is bound explicitly before the `|` isn't allowed
23.464286
79
0.509893