Search is not available for this dataset
text
string
meta
dict
module TakeDropDec where import Relation.Binary.PropositionalEquality as Eq open Eq using (_≡_; refl; sym; trans; cong; cong₂; _≢_) open import Data.Empty using (⊥; ⊥-elim) open import Data.List using (List; []; _∷_) open import Data.List.All using (All; []; _∷_) open import Data.Bool using (Bool; true; false; T) open import Data.Unit using (⊤; tt) open import Relation.Nullary using (¬_; Dec; yes; no) open import Relation.Nullary.Decidable using () open import Function using (_∘_) module TakeDrop {A : Set} {P : A → Set} (P? : ∀ (x : A) → Dec (P x)) where takeWhile : List A → List A takeWhile [] = [] takeWhile (x ∷ xs) with P? x ... | yes _ = x ∷ takeWhile xs ... | no _ = [] dropWhile : List A → List A dropWhile [] = [] dropWhile (x ∷ xs) with P? x ... | yes _ = dropWhile xs ... | no _ = x ∷ xs Head : (A → Set) → List A → Set Head P [] = ⊥ Head P (x ∷ xs) = P x takeWhile-lemma : ∀ (xs : List A) → All P (takeWhile xs) takeWhile-lemma [] = [] takeWhile-lemma (x ∷ xs) with P? x ... | yes px = px ∷ takeWhile-lemma xs ... | no _ = [] dropWhile-lemma : ∀ (xs : List A) → ¬ Head P (dropWhile xs) dropWhile-lemma [] = λ() dropWhile-lemma (x ∷ xs) with P? x ... | yes _ = dropWhile-lemma xs ... | no ¬px = ¬px open TakeDrop open import Data.Nat using (ℕ; zero; suc; _≟_) _ : takeWhile (0 ≟_) (0 ∷ 0 ∷ 1 ∷ []) ≡ (0 ∷ 0 ∷ []) _ = refl _ : dropWhile (0 ≟_) (0 ∷ 0 ∷ 1 ∷ []) ≡ (1 ∷ []) _ = refl
{ "alphanum_fraction": 0.4850230415, "avg_line_length": 31.5636363636, "ext": "agda", "hexsha": "859e35d47ee1eae931ec295ea4df5de675af807a", "lang": "Agda", "max_forks_count": 304, "max_forks_repo_forks_event_max_datetime": "2022-03-28T11:35:02.000Z", "max_forks_repo_forks_event_min_datetime": "2018-07-16T18:24:59.000Z", "max_forks_repo_head_hexsha": "8a2c2ace545092fd0e04bf5831ed458267f18ae4", "max_forks_repo_licenses": [ "CC-BY-4.0" ], "max_forks_repo_name": "manikdv/plfa.github.io", "max_forks_repo_path": "extra/extra/TakeDropDec.agda", "max_issues_count": 323, "max_issues_repo_head_hexsha": "8a2c2ace545092fd0e04bf5831ed458267f18ae4", "max_issues_repo_issues_event_max_datetime": "2022-03-30T07:42:57.000Z", "max_issues_repo_issues_event_min_datetime": "2018-07-05T22:34:34.000Z", "max_issues_repo_licenses": [ "CC-BY-4.0" ], "max_issues_repo_name": "manikdv/plfa.github.io", "max_issues_repo_path": "extra/extra/TakeDropDec.agda", "max_line_length": 74, "max_stars_count": 1003, "max_stars_repo_head_hexsha": "8a2c2ace545092fd0e04bf5831ed458267f18ae4", "max_stars_repo_licenses": [ "CC-BY-4.0" ], "max_stars_repo_name": "manikdv/plfa.github.io", "max_stars_repo_path": "extra/extra/TakeDropDec.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-27T07:03:28.000Z", "max_stars_repo_stars_event_min_datetime": "2018-07-05T18:15:14.000Z", "num_tokens": 577, "size": 1736 }
module PLRTree.Compound {A : Set} where open import PLRTree {A} data Compound : PLRTree → Set where compound : {t : Tag}{x : A}{l r : PLRTree} → Compound (node t x l r)
{ "alphanum_fraction": 0.6514285714, "avg_line_length": 25, "ext": "agda", "hexsha": "142abe1c55651a113c9f37d52e2bfa1147ebb0a4", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "bgbianchi/sorting", "max_forks_repo_path": "agda/PLRTree/Compound.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "bgbianchi/sorting", "max_issues_repo_path": "agda/PLRTree/Compound.agda", "max_line_length": 70, "max_stars_count": 6, "max_stars_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "bgbianchi/sorting", "max_stars_repo_path": "agda/PLRTree/Compound.agda", "max_stars_repo_stars_event_max_datetime": "2021-08-24T22:11:15.000Z", "max_stars_repo_stars_event_min_datetime": "2015-05-21T12:50:35.000Z", "num_tokens": 61, "size": 175 }
module Class.Monoid where open import Level open import Data.List using (List; []; _∷_) record Monoid {a} (M : Set a) : Set (suc a) where infixl 6 _+_ field mzero : M _+_ : M -> M -> M open Monoid {{...}} public concat : ∀ {a} {M : Set a} {{_ : Monoid M}} -> List M -> M concat [] = mzero concat (x ∷ l) = x + concat l
{ "alphanum_fraction": 0.5671641791, "avg_line_length": 19.7058823529, "ext": "agda", "hexsha": "a3ff58d476e605927aa1005d4b356ac221835ab6", "lang": "Agda", "max_forks_count": 2, "max_forks_repo_forks_event_max_datetime": "2021-10-20T10:46:20.000Z", "max_forks_repo_forks_event_min_datetime": "2019-06-27T23:12:48.000Z", "max_forks_repo_head_hexsha": "62fa6f36e4555360d94041113749bbb6d291691c", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "WhatisRT/meta-cedille", "max_forks_repo_path": "stdlib-exts/Class/Monoid.agda", "max_issues_count": 10, "max_issues_repo_head_hexsha": "62fa6f36e4555360d94041113749bbb6d291691c", "max_issues_repo_issues_event_max_datetime": "2020-04-25T15:29:17.000Z", "max_issues_repo_issues_event_min_datetime": "2019-06-13T17:44:43.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "WhatisRT/meta-cedille", "max_issues_repo_path": "stdlib-exts/Class/Monoid.agda", "max_line_length": 58, "max_stars_count": 35, "max_stars_repo_head_hexsha": "62fa6f36e4555360d94041113749bbb6d291691c", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "WhatisRT/meta-cedille", "max_stars_repo_path": "stdlib-exts/Class/Monoid.agda", "max_stars_repo_stars_event_max_datetime": "2021-10-12T22:59:10.000Z", "max_stars_repo_stars_event_min_datetime": "2019-06-13T07:44:50.000Z", "num_tokens": 124, "size": 335 }
module Oscar.Data.Nat where open import Agda.Builtin.Nat public using (Nat; zero; suc)
{ "alphanum_fraction": 0.7640449438, "avg_line_length": 17.8, "ext": "agda", "hexsha": "30e13c94b33f428d3665b174bb4922c25b436e06", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_forks_repo_licenses": [ "RSA-MD" ], "max_forks_repo_name": "m0davis/oscar", "max_forks_repo_path": "archive/agda-2/Oscar/Data/Nat.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_issues_repo_issues_event_max_datetime": "2019-05-11T23:33:04.000Z", "max_issues_repo_issues_event_min_datetime": "2019-04-29T00:35:04.000Z", "max_issues_repo_licenses": [ "RSA-MD" ], "max_issues_repo_name": "m0davis/oscar", "max_issues_repo_path": "archive/agda-2/Oscar/Data/Nat.agda", "max_line_length": 58, "max_stars_count": null, "max_stars_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_stars_repo_licenses": [ "RSA-MD" ], "max_stars_repo_name": "m0davis/oscar", "max_stars_repo_path": "archive/agda-2/Oscar/Data/Nat.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 25, "size": 89 }
{-# OPTIONS --without-K --safe #-} open import Categories.Category module Categories.Category.Slice.Properties {o ℓ e} (C : Category o ℓ e) where open import Categories.Category.Equivalence using (StrongEquivalence) open import Categories.Functor open import Categories.Object.Product open import Categories.Diagram.Pullback open import Categories.Morphism.Reasoning C open import Categories.Object.Terminal C import Categories.Category.Slice as S private module C = Category C module _ {A : C.Obj} where open S C open Category (Slice A) open SliceObj open Slice⇒ open C.HomReasoning product⇒pullback : ∀ {X Y : Obj} → Product (Slice A) X Y → Pullback C (arr X) (arr Y) product⇒pullback p = record { p₁ = h π₁ ; p₂ = h π₂ ; commute = △ π₁ ○ ⟺ (△ π₂) ; universal = λ eq → h ⟨ slicearr eq , slicearr refl ⟩ ; unique = λ {_ _ _ _ eq} eq′ eq″ → ⟺ (unique {h = slicearr (pushˡ (⟺ (△ π₁)) ○ C.∘-resp-≈ʳ eq′ ○ eq)} eq′ eq″) ; p₁∘universal≈h₁ = project₁ ; p₂∘universal≈h₂ = project₂ } where open Product (Slice A) p pullback⇒product : ∀ {X Y : Obj} → Pullback C (arr X) (arr Y) → Product (Slice A) X Y pullback⇒product {X} {Y} p = record { A×B = sliceobj (arr Y C.∘ p₂) ; π₁ = slicearr commute ; π₂ = slicearr refl ; ⟨_,_⟩ = λ f g → slicearr (pullʳ (p₂∘universal≈h₂ {eq = △ f ○ ⟺ (△ g)}) ○ △ g) ; project₁ = p₁∘universal≈h₁ ; project₂ = p₂∘universal≈h₂ ; unique = λ eq eq′ → ⟺ (unique eq eq′) } where open Pullback p module _ (t : Terminal) where open S C open Terminal t open Category (Slice ⊤) open SliceObj open Slice⇒ open C.HomReasoning lift : ∀ {A B : C.Obj} (f : A C.⇒ B) → Slice⇒ (sliceobj (! {A})) (sliceobj (! {B})) lift f = slicearr {h = f} !-unique₂ pullback⇒product′ : ∀ {X Y : Obj} → Pullback C (arr X) (arr Y) → Product (Slice ⊤) X Y pullback⇒product′ {X} {Y} p = record { A×B = sliceobj ! ; π₁ = slicearr {h = p₁} !-unique₂ ; π₂ = slicearr {h = p₂} !-unique₂ ; ⟨_,_⟩ = λ f g → slicearr {h = universal (△ f ○ ⟺ (△ g))} !-unique₂ ; project₁ = p₁∘universal≈h₁ ; project₂ = p₂∘universal≈h₂ ; unique = λ eq eq′ → ⟺ (unique eq eq′) } where open Pullback p -- slice of slice module _ {A B} (f : A C.⇒ B) where private C/B : Category _ _ _ C/B = S.Slice C B module C/B = Category C/B C/A : Category _ _ _ C/A = S.Slice C A module C/A = Category C/A open C.HomReasoning slice-slice⇒slice : Functor (S.Slice C/B (S.sliceobj f)) C/A slice-slice⇒slice = record { F₀ = λ { (S.sliceobj (S.slicearr {h} △)) → S.sliceobj h } ; F₁ = λ { (S.slicearr △) → S.slicearr △ } ; identity = refl ; homomorphism = refl ; F-resp-≈ = λ eq → eq } slice⇒slice-slice : Functor C/A (S.Slice C/B (S.sliceobj f)) slice⇒slice-slice = record { F₀ = λ { (S.sliceobj arr) → S.sliceobj (S.slicearr {h = arr} refl) } ; F₁ = λ { (S.slicearr △) → S.slicearr {h = S.slicearr (pullʳ △)} △ } ; identity = refl ; homomorphism = refl ; F-resp-≈ = λ eq → eq } slice-slice≃slice : StrongEquivalence C/A (S.Slice C/B (S.sliceobj f)) slice-slice≃slice = record { F = slice⇒slice-slice ; G = slice-slice⇒slice ; weak-inverse = record { F∘G≈id = record { F⇒G = record { η = λ { (S.sliceobj (S.slicearr △)) → S.slicearr {h = S.slicearr (C.identityʳ ○ ⟺ △)} C.identityʳ } ; commute = λ _ → id-comm-sym ; sym-commute = λ _ → id-comm } ; F⇐G = record { η = λ { (S.sliceobj (S.slicearr △)) → S.slicearr {h = S.slicearr (C.identityʳ ○ △)} C.identityʳ } ; commute = λ _ → id-comm-sym ; sym-commute = λ _ → id-comm } ; iso = λ _ → record { isoˡ = C.identity² ; isoʳ = C.identity² } } ; G∘F≈id = record { F⇒G = record { η = λ { (S.sliceobj arr) → S.slicearr C.identityʳ } ; commute = λ _ → id-comm-sym ; sym-commute = λ _ → id-comm } ; F⇐G = record { η = λ { (S.sliceobj arr) → S.slicearr C.identityʳ } ; commute = λ _ → id-comm-sym ; sym-commute = λ _ → id-comm } ; iso = λ _ → record { isoˡ = C.identity² ; isoʳ = C.identity² } } } }
{ "alphanum_fraction": 0.5213043478, "avg_line_length": 32.3943661972, "ext": "agda", "hexsha": "7b23db7b408abb075ae6672831623b871ae71dba", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "58e5ec015781be5413bdf968f7ec4fdae0ab4b21", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "MirceaS/agda-categories", "max_forks_repo_path": "src/Categories/Category/Slice/Properties.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "58e5ec015781be5413bdf968f7ec4fdae0ab4b21", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "MirceaS/agda-categories", "max_issues_repo_path": "src/Categories/Category/Slice/Properties.agda", "max_line_length": 124, "max_stars_count": null, "max_stars_repo_head_hexsha": "58e5ec015781be5413bdf968f7ec4fdae0ab4b21", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "MirceaS/agda-categories", "max_stars_repo_path": "src/Categories/Category/Slice/Properties.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1677, "size": 4600 }
module Generic.Lib.Prelude where open import Generic.Lib.Intro public open import Generic.Lib.Equality.Propositional public open import Generic.Lib.Equality.Coerce public open import Generic.Lib.Equality.Heteroindexed public open import Generic.Lib.Equality.Congn public open import Generic.Lib.Decidable public open import Generic.Lib.Category public open import Generic.Lib.Data.Nat public open import Generic.Lib.Data.String public open import Generic.Lib.Data.Maybe public open import Generic.Lib.Data.Sum public open import Generic.Lib.Data.Product public open import Generic.Lib.Data.List public open import Generic.Lib.Data.Pow public open import Generic.Lib.Data.Sets public open import Generic.Lib.Reflection.Core public open import Generic.Lib.Reflection.Fold public
{ "alphanum_fraction": 0.6890756303, "avg_line_length": 47.6, "ext": "agda", "hexsha": "193e987fdb6c7656dcb081e11e5810b343f499c8", "lang": "Agda", "max_forks_count": 4, "max_forks_repo_forks_event_max_datetime": "2021-01-27T12:57:09.000Z", "max_forks_repo_forks_event_min_datetime": "2017-07-17T07:23:39.000Z", "max_forks_repo_head_hexsha": "e102b0ec232f2796232bd82bf8e3906c1f8a93fe", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "turion/Generic", "max_forks_repo_path": "src/Generic/Lib/Prelude.agda", "max_issues_count": 9, "max_issues_repo_head_hexsha": "e102b0ec232f2796232bd82bf8e3906c1f8a93fe", "max_issues_repo_issues_event_max_datetime": "2022-01-04T15:43:14.000Z", "max_issues_repo_issues_event_min_datetime": "2017-04-06T18:58:09.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "turion/Generic", "max_issues_repo_path": "src/Generic/Lib/Prelude.agda", "max_line_length": 53, "max_stars_count": 30, "max_stars_repo_head_hexsha": "e102b0ec232f2796232bd82bf8e3906c1f8a93fe", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "turion/Generic", "max_stars_repo_path": "src/Generic/Lib/Prelude.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-05T10:19:38.000Z", "max_stars_repo_stars_event_min_datetime": "2016-07-19T21:10:54.000Z", "num_tokens": 172, "size": 952 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Properties of the pointwise lifting of a predicate to a binary tree ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} module Data.Tree.Binary.Relation.Unary.All.Properties where open import Level open import Data.Tree.Binary as Tree using (Tree; leaf; node) open import Data.Tree.Binary.Relation.Unary.All open import Relation.Unary private variable a b p q : Level A : Set a B : Set b module _ {P : B → Set p} where map⁺ : (f : A → B) → ∀[ All (f ⊢ P) ⇒ Tree.map f ⊢ All P ] map⁺ f leaf = leaf map⁺ f (node l m r) = node (map⁺ f l) m (map⁺ f r)
{ "alphanum_fraction": 0.5174262735, "avg_line_length": 27.6296296296, "ext": "agda", "hexsha": "631353c91032ccfa4760c2a3132998af9f96e538", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "DreamLinuxer/popl21-artifact", "max_forks_repo_path": "agda-stdlib/src/Data/Tree/Binary/Relation/Unary/All/Properties.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "DreamLinuxer/popl21-artifact", "max_issues_repo_path": "agda-stdlib/src/Data/Tree/Binary/Relation/Unary/All/Properties.agda", "max_line_length": 72, "max_stars_count": 5, "max_stars_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "DreamLinuxer/popl21-artifact", "max_stars_repo_path": "agda-stdlib/src/Data/Tree/Binary/Relation/Unary/All/Properties.agda", "max_stars_repo_stars_event_max_datetime": "2020-10-10T21:41:32.000Z", "max_stars_repo_stars_event_min_datetime": "2020-10-07T12:07:53.000Z", "num_tokens": 189, "size": 746 }
{-# OPTIONS --guarded #-} module _ where primitive primLockUniv : _ postulate A B : primLockUniv c : A → B foo : (@tick x y : B) → Set bar : (@tick x y : A) → Set bar x y = foo (c x) (c y)
{ "alphanum_fraction": 0.56, "avg_line_length": 14.2857142857, "ext": "agda", "hexsha": "532b05fbd3a5cf816aca504f165c2b62ab682c62", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cruhland/agda", "max_forks_repo_path": "test/Succeed/TickConstants.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "cruhland/agda", "max_issues_repo_path": "test/Succeed/TickConstants.agda", "max_line_length": 29, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/Succeed/TickConstants.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 75, "size": 200 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Core definition of divisibility ------------------------------------------------------------------------ -- The definition of divisibility is split out from -- `Data.Nat.Divisibility` to avoid a dependency cycle with -- `Data.Nat.DivMod`. {-# OPTIONS --without-K --safe #-} module Data.Nat.Divisibility.Core where open import Data.Nat.Base using (ℕ; _*_) open import Data.Nat.Properties open import Level using (0ℓ) open import Relation.Nullary using (¬_) open import Relation.Binary using (Rel) open import Relation.Binary.PropositionalEquality using (_≡_; refl; sym) ------------------------------------------------------------------------ -- Definition -- -- m ∣ n is inhabited iff m divides n. Some sources, like Hardy and -- Wright's "An Introduction to the Theory of Numbers", require m to -- be non-zero. However, some things become a bit nicer if m is -- allowed to be zero. For instance, _∣_ becomes a partial order, and -- the gcd of 0 and 0 becomes defined. infix 4 _∣_ _∤_ record _∣_ (m n : ℕ) : Set where constructor divides field quotient : ℕ equality : n ≡ quotient * m open _∣_ using (quotient) public _∤_ : Rel ℕ 0ℓ m ∤ n = ¬ (m ∣ n)
{ "alphanum_fraction": 0.5870413739, "avg_line_length": 30.5, "ext": "agda", "hexsha": "72c1f94abb9e994d5305523815d413b81bcce22b", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "DreamLinuxer/popl21-artifact", "max_forks_repo_path": "agda-stdlib/src/Data/Nat/Divisibility/Core.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "DreamLinuxer/popl21-artifact", "max_issues_repo_path": "agda-stdlib/src/Data/Nat/Divisibility/Core.agda", "max_line_length": 72, "max_stars_count": 5, "max_stars_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "DreamLinuxer/popl21-artifact", "max_stars_repo_path": "agda-stdlib/src/Data/Nat/Divisibility/Core.agda", "max_stars_repo_stars_event_max_datetime": "2020-10-10T21:41:32.000Z", "max_stars_repo_stars_event_min_datetime": "2020-10-07T12:07:53.000Z", "num_tokens": 311, "size": 1281 }
{-# OPTIONS --without-K --safe #-} -- We do not parameterize this module since we do not have access to _+_ or _*_ -- for the fields that we want (real numbers) open import Level using (Level) open import Relation.Binary.PropositionalEquality hiding (Extensionality) open ≡-Reasoning open import Data.Nat using (ℕ) renaming (_+_ to _+ᴺ_) open import Data.Nat.Properties open import Data.Vec using (Vec; []; _∷_; _++_; take; drop; map; replicate) open import Data.Vec.Properties open import Function using (id) open import FLA.Algebra.Structures open import FLA.Algebra.Properties.Field open import FLA.Algebra.LinearAlgebra open import FLA.Algebra.LinearAlgebra.Properties module FLA.Algebra.LinearMap where private variable ℓ : Level A : Set ℓ m n p q : ℕ -- A linear map from one vector field to another record _⊸_ {ℓ : Level} {A : Set ℓ} ⦃ F : Field A ⦄ (m n : ℕ) : Set ℓ where field f : (Vec A m → Vec A n) -- Additivity f[u+v]≡f[u]+f[v] : (u v : Vec A m) → f (u +ⱽ v) ≡ f u +ⱽ f v -- Homogeneity f[c*v]≡c*f[v] : (c : A) → (v : Vec A m) → f (c ∘ⱽ v) ≡ c ∘ⱽ (f v) infixr 1 _⊸_ -- A convenient syntax if a particular set needs to be specified. _—_⊸_ : {ℓ : Level} (m : ℕ) (A : Set ℓ) (n : ℕ) ⦃ F : Field A ⦄ → Set ℓ m — A ⊸ n = _⊸_ {A = A} m n infixr 1 _—_⊸_ module _ ⦃ F : Field A ⦄ where open Field F open _⊸_ _·ˡᵐ_ : m ⊸ n → Vec A m → Vec A n _·ˡᵐ_ LM = f LM private +ˡᵐ-linearity : (g h : m ⊸ n) → (u v x y : Vec A m) → g ·ˡᵐ (u +ⱽ v) +ⱽ h ·ˡᵐ (x +ⱽ y) ≡ g ·ˡᵐ u +ⱽ h ·ˡᵐ x +ⱽ (g ·ˡᵐ v +ⱽ h ·ˡᵐ y) +ˡᵐ-linearity g h u v x y rewrite f[u+v]≡f[u]+f[v] g u v | f[u+v]≡f[u]+f[v] h x y | (+ⱽ-assoc (g ·ˡᵐ u) (g ·ˡᵐ v) (h ·ˡᵐ x +ⱽ h ·ˡᵐ y)) | sym (+ⱽ-assoc (g ·ˡᵐ v) (h ·ˡᵐ x) (h ·ˡᵐ y)) | +ⱽ-comm (g ·ˡᵐ v) (h ·ˡᵐ x) | (+ⱽ-assoc (h ·ˡᵐ x) (g ·ˡᵐ v) (h ·ˡᵐ y)) | sym (+ⱽ-assoc (g ·ˡᵐ u) (h ·ˡᵐ x) (g ·ˡᵐ v +ⱽ h ·ˡᵐ y)) = refl +-homogeneity : (g h : m ⊸ n) → (c : A) (u v : Vec A m) → g ·ˡᵐ (c ∘ⱽ u) +ⱽ h ·ˡᵐ (c ∘ⱽ v) ≡ c ∘ⱽ (g ·ˡᵐ u +ⱽ h ·ˡᵐ v) +-homogeneity g h c u v rewrite f[c*v]≡c*f[v] g c u | f[c*v]≡c*f[v] h c v | sym (∘ⱽ-distr-+ⱽ c (g ·ˡᵐ u) (h ·ˡᵐ v)) = refl _+ˡᵐ_ : m ⊸ n → m ⊸ n → m ⊸ n g +ˡᵐ h = record { f = λ v → g ·ˡᵐ v +ⱽ h ·ˡᵐ v ; f[u+v]≡f[u]+f[v] = λ u v → +ˡᵐ-linearity g h u v u v ; f[c*v]≡c*f[v] = λ c v → +-homogeneity g h c v v } _-ˡᵐ_ : m ⊸ n → m ⊸ n → m ⊸ n g -ˡᵐ h = record { f = λ v → g ·ˡᵐ v -ⱽ h ·ˡᵐ v ; f[u+v]≡f[u]+f[v] = f[u+v]≡f[u]+f[v]' g h ; f[c*v]≡c*f[v] = f[c*v]≡c*f[v]' g h } where f[u+v]≡f[u]+f[v]' : (g h : m ⊸ n) → (u v : Vec A m) → g ·ˡᵐ (u +ⱽ v) -ⱽ h ·ˡᵐ (u +ⱽ v) ≡ g ·ˡᵐ u -ⱽ h ·ˡᵐ u +ⱽ (g ·ˡᵐ v -ⱽ h ·ˡᵐ v) f[u+v]≡f[u]+f[v]' g h u v = begin g ·ˡᵐ (u +ⱽ v) -ⱽ h ·ˡᵐ (u +ⱽ v) ≡⟨ cong (g ·ˡᵐ (u +ⱽ v) +ⱽ_) (-ⱽ≡-1ᶠ∘ⱽ (h ·ˡᵐ (u +ⱽ v))) ⟩ g ·ˡᵐ (u +ⱽ v) +ⱽ (- 1ᶠ) ∘ⱽ (h ·ˡᵐ (u +ⱽ v)) ≡⟨ cong (λ x → g ·ˡᵐ (u +ⱽ v) +ⱽ (- 1ᶠ) ∘ⱽ x) (f[u+v]≡f[u]+f[v] h u v) ⟩ g ·ˡᵐ (u +ⱽ v) +ⱽ (- 1ᶠ) ∘ⱽ (h ·ˡᵐ u +ⱽ h ·ˡᵐ v) ≡⟨ cong (g ·ˡᵐ (u +ⱽ v) +ⱽ_) (∘ⱽ-distr-+ⱽ (- 1ᶠ) (h ·ˡᵐ u) (h ·ˡᵐ v)) ⟩ g ·ˡᵐ (u +ⱽ v) +ⱽ ((- 1ᶠ) ∘ⱽ h ·ˡᵐ u +ⱽ (- 1ᶠ) ∘ⱽ h ·ˡᵐ v) ≡⟨ cong₂ (λ x y → g ·ˡᵐ (u +ⱽ v) +ⱽ (x +ⱽ y)) (sym (f[c*v]≡c*f[v] h (- 1ᶠ) u)) (sym (f[c*v]≡c*f[v] h (- 1ᶠ) v)) ⟩ g ·ˡᵐ (u +ⱽ v) +ⱽ (h ·ˡᵐ ((- 1ᶠ) ∘ⱽ u) +ⱽ h ·ˡᵐ ((- 1ᶠ) ∘ⱽ v)) ≡⟨ cong (g ·ˡᵐ (u +ⱽ v) +ⱽ_) (sym (f[u+v]≡f[u]+f[v] h ((- 1ᶠ) ∘ⱽ u) ((- 1ᶠ) ∘ⱽ v))) ⟩ g ·ˡᵐ (u +ⱽ v) +ⱽ (h ·ˡᵐ ((- 1ᶠ) ∘ⱽ u +ⱽ (- 1ᶠ) ∘ⱽ v)) ≡⟨ +ˡᵐ-linearity g h u v ((- 1ᶠ) ∘ⱽ u) ((- 1ᶠ) ∘ⱽ v) ⟩ g ·ˡᵐ u +ⱽ h ·ˡᵐ ((- 1ᶠ) ∘ⱽ u) +ⱽ (g ·ˡᵐ v +ⱽ h ·ˡᵐ ((- 1ᶠ) ∘ⱽ v)) ≡⟨ cong₂ (λ x y → g ·ˡᵐ u +ⱽ x +ⱽ (g ·ˡᵐ v +ⱽ y)) (trans (f[c*v]≡c*f[v] h ((- 1ᶠ)) u) (sym (-ⱽ≡-1ᶠ∘ⱽ (h ·ˡᵐ u)))) (trans (f[c*v]≡c*f[v] h ((- 1ᶠ)) v) (sym (-ⱽ≡-1ᶠ∘ⱽ (h ·ˡᵐ v)))) ⟩ g ·ˡᵐ u -ⱽ h ·ˡᵐ u +ⱽ (g ·ˡᵐ v -ⱽ h ·ˡᵐ v) ∎ f[c*v]≡c*f[v]' : (g h : m ⊸ n) → (c : A) (v : Vec A m) → g ·ˡᵐ (c ∘ⱽ v) -ⱽ h ·ˡᵐ (c ∘ⱽ v) ≡ c ∘ⱽ (g ·ˡᵐ v -ⱽ h ·ˡᵐ v) f[c*v]≡c*f[v]' g h c v = begin g ·ˡᵐ (c ∘ⱽ v) -ⱽ h ·ˡᵐ (c ∘ⱽ v) ≡⟨ cong (g ·ˡᵐ (c ∘ⱽ v) +ⱽ_) (trans (-ⱽ≡-1ᶠ∘ⱽ (h ·ˡᵐ (c ∘ⱽ v))) (sym (f[c*v]≡c*f[v] h (- 1ᶠ) (c ∘ⱽ v)))) ⟩ g ·ˡᵐ (c ∘ⱽ v) +ⱽ h ·ˡᵐ ((- 1ᶠ) ∘ⱽ (c ∘ⱽ v)) ≡⟨ cong (λ x → g ·ˡᵐ (c ∘ⱽ v) +ⱽ h ·ˡᵐ x) (∘ⱽ-comm (- 1ᶠ) c v) ⟩ g ·ˡᵐ (c ∘ⱽ v) +ⱽ h ·ˡᵐ (c ∘ⱽ ((- 1ᶠ) ∘ⱽ v)) ≡⟨ +-homogeneity g h c v ((- 1ᶠ) ∘ⱽ v) ⟩ c ∘ⱽ (g ·ˡᵐ v +ⱽ h ·ˡᵐ ((- 1ᶠ) ∘ⱽ v)) ≡⟨ cong (λ x → c ∘ⱽ (g ·ˡᵐ v +ⱽ x)) (trans (f[c*v]≡c*f[v] h (- 1ᶠ) v) (sym (-ⱽ≡-1ᶠ∘ⱽ (h ·ˡᵐ v)))) ⟩ c ∘ⱽ (g ·ˡᵐ v -ⱽ h ·ˡᵐ v) ∎ _*ˡᵐ_ : n ⊸ p → m ⊸ n → m ⊸ p g *ˡᵐ h = record { f = λ v → g ·ˡᵐ (h ·ˡᵐ v) ; f[u+v]≡f[u]+f[v] = f[u+v]≡f[u]+f[v]' g h ; f[c*v]≡c*f[v] = f[c*v]≡c*f[v]' g h } where f[u+v]≡f[u]+f[v]' : (g : n ⊸ p) (h : m ⊸ n) → (u v : Vec A m) → g ·ˡᵐ (h ·ˡᵐ (u +ⱽ v)) ≡ g ·ˡᵐ (h ·ˡᵐ u) +ⱽ g ·ˡᵐ (h ·ˡᵐ v) f[u+v]≡f[u]+f[v]' g h u v rewrite f[u+v]≡f[u]+f[v] h u v | f[u+v]≡f[u]+f[v] g (f h u) (f h v) = refl f[c*v]≡c*f[v]' : (g : n ⊸ p) (h : m ⊸ n) → (c : A) (v : Vec A m) → g ·ˡᵐ (h ·ˡᵐ (c ∘ⱽ v)) ≡ c ∘ⱽ g ·ˡᵐ (h ·ˡᵐ v) f[c*v]≡c*f[v]' g h c v rewrite f[c*v]≡c*f[v] h c v | f[c*v]≡c*f[v] g c (h ·ˡᵐ v) = refl -- vertical stack forward operator _—ˡᵐ_ : p ⊸ m → p ⊸ n → p ⊸ (m +ᴺ n) T —ˡᵐ B = record { f = λ v → T ·ˡᵐ v ++ B ·ˡᵐ v ; f[u+v]≡f[u]+f[v] = f[u+v]≡f[u]+f[v]' T B ; f[c*v]≡c*f[v] = f[c*v]≡c*f[v]' T B } where f[u+v]≡f[u]+f[v]' : (T : p ⊸ m) (B : p ⊸ n) → (u v : Vec A p) → T ·ˡᵐ (u +ⱽ v) ++ B ·ˡᵐ (u +ⱽ v) ≡ (T ·ˡᵐ u ++ B ·ˡᵐ u) +ⱽ (T ·ˡᵐ v ++ B ·ˡᵐ v) f[u+v]≡f[u]+f[v]' T B u v rewrite f[u+v]≡f[u]+f[v] T u v | f[u+v]≡f[u]+f[v] B u v | +ⱽ-flip-++ (T ·ˡᵐ u) (T ·ˡᵐ v) (B ·ˡᵐ u) (B ·ˡᵐ v) = refl f[c*v]≡c*f[v]' : (T : p ⊸ m) (B : p ⊸ n) → (c : A) → (v : Vec A p) → T ·ˡᵐ (c ∘ⱽ v) ++ B ·ˡᵐ (c ∘ⱽ v) ≡ c ∘ⱽ (T ·ˡᵐ v ++ B ·ˡᵐ v) f[c*v]≡c*f[v]' T B c v rewrite f[c*v]≡c*f[v] T c v | f[c*v]≡c*f[v] B c v | ∘ⱽ-distr-++ c (T ·ˡᵐ v) (B ·ˡᵐ v) = refl -- horizontal stack forward operator _|ˡᵐ_ : m ⊸ p → n ⊸ p → (m +ᴺ n) ⊸ p _|ˡᵐ_ {m} {n} {p} T B = record { f = λ v → T ·ˡᵐ (take m v) +ⱽ B ·ˡᵐ (drop m v) ; f[u+v]≡f[u]+f[v] = f[u+v]≡f[u]+f[v]' T B ; f[c*v]≡c*f[v] = f[c*v]≡c*f[v]' T B } where f[u+v]≡f[u]+f[v]' : {m n p : ℕ} → (T : m ⊸ p) (B : n ⊸ p) → (u v : Vec A (m +ᴺ n)) → T ·ˡᵐ take m (u +ⱽ v) +ⱽ B ·ˡᵐ drop m (u +ⱽ v) ≡ T ·ˡᵐ take m u +ⱽ B ·ˡᵐ drop m u +ⱽ (T ·ˡᵐ take m v +ⱽ B ·ˡᵐ drop m v) f[u+v]≡f[u]+f[v]' {m} T B u v = begin T ·ˡᵐ (take m (u +ⱽ v)) +ⱽ B ·ˡᵐ (drop m (u +ⱽ v)) ≡⟨ cong₂ (λ x y → T ·ˡᵐ x +ⱽ B ·ˡᵐ y) (take-distr-zipWith _+_ u v) (drop-distr-zipWith _+_ u v)⟩ T ·ˡᵐ (take m u +ⱽ take m v) +ⱽ B ·ˡᵐ (drop m u +ⱽ drop m v) ≡⟨ cong₂ _+ⱽ_ (f[u+v]≡f[u]+f[v] T (take m u) (take m v)) (f[u+v]≡f[u]+f[v] B (drop m u) (drop m v)) ⟩ T ·ˡᵐ take m u +ⱽ T ·ˡᵐ take m v +ⱽ (B ·ˡᵐ drop m u +ⱽ B ·ˡᵐ drop m v) ≡⟨ sym (+ⱽ-assoc (T ·ˡᵐ take m u +ⱽ T ·ˡᵐ take m v) (B ·ˡᵐ drop m u) (B ·ˡᵐ drop m v)) ⟩ T ·ˡᵐ take m u +ⱽ T ·ˡᵐ take m v +ⱽ B ·ˡᵐ drop m u +ⱽ B ·ˡᵐ drop m v ≡⟨ cong (_+ⱽ B ·ˡᵐ drop m v) (+ⱽ-assoc (T ·ˡᵐ take m u) (T ·ˡᵐ take m v) (B ·ˡᵐ drop m u)) ⟩ T ·ˡᵐ take m u +ⱽ (T ·ˡᵐ take m v +ⱽ B ·ˡᵐ drop m u) +ⱽ B ·ˡᵐ drop m v ≡⟨ cong (λ x → (T ·ˡᵐ take m u +ⱽ x) +ⱽ B ·ˡᵐ drop m v) (+ⱽ-comm (T ·ˡᵐ take m v) (B ·ˡᵐ drop m u)) ⟩ (T ·ˡᵐ take m u +ⱽ ((B ·ˡᵐ drop m u +ⱽ T ·ˡᵐ take m v))) +ⱽ B ·ˡᵐ drop m v ≡⟨ cong (_+ⱽ B ·ˡᵐ drop m v) (sym (+ⱽ-assoc (T ·ˡᵐ take m u) (B ·ˡᵐ drop m u) (T ·ˡᵐ take m v))) ⟩ (T ·ˡᵐ take m u +ⱽ B ·ˡᵐ drop m u +ⱽ T ·ˡᵐ take m v) +ⱽ B ·ˡᵐ drop m v ≡⟨ +ⱽ-assoc (T ·ˡᵐ take m u +ⱽ B ·ˡᵐ drop m u) (T ·ˡᵐ take m v) (B ·ˡᵐ drop m v) ⟩ T ·ˡᵐ take m u +ⱽ B ·ˡᵐ drop m u +ⱽ (T ·ˡᵐ take m v +ⱽ B ·ˡᵐ drop m v) ∎ f[c*v]≡c*f[v]' : {m n p : ℕ} → (T : m ⊸ p) → (B : n ⊸ p) → (c : A) (v : Vec A (m +ᴺ n)) → T ·ˡᵐ take m (c ∘ⱽ v) +ⱽ B ·ˡᵐ drop m (c ∘ⱽ v) ≡ c ∘ⱽ (T ·ˡᵐ take m v +ⱽ B ·ˡᵐ drop m v) f[c*v]≡c*f[v]' {m} T B c v = begin T ·ˡᵐ take m (c ∘ⱽ v) +ⱽ B ·ˡᵐ drop m (c ∘ⱽ v) ≡⟨ cong₂ (λ x y → T ·ˡᵐ x +ⱽ B ·ˡᵐ y) (take-distr-map (c *_) m v) (drop-distr-map (c *_) m v) ⟩ T ·ˡᵐ (c ∘ⱽ take m v) +ⱽ B ·ˡᵐ (c ∘ⱽ drop m v) ≡⟨ cong₂ _+ⱽ_ (f[c*v]≡c*f[v] T c (take m v)) (f[c*v]≡c*f[v] B c (drop m v)) ⟩ c ∘ⱽ (T ·ˡᵐ take m v) +ⱽ c ∘ⱽ (B ·ˡᵐ drop m v) ≡⟨ sym (∘ⱽ-distr-+ⱽ c (T ·ˡᵐ take m v) (B ·ˡᵐ drop m v)) ⟩ c ∘ⱽ (T ·ˡᵐ take m v +ⱽ B ·ˡᵐ drop m v) ∎ -- block diagonal forward and adjoint operator _/ˡᵐ_ : m ⊸ n → p ⊸ q → (m +ᴺ p) ⊸ (n +ᴺ q) _/ˡᵐ_ {m} {n} {p} {q} T B = record { f = λ v → T ·ˡᵐ (take m v) ++ B ·ˡᵐ (drop m v) ; f[u+v]≡f[u]+f[v] = f[u+v]≡f[u]+f[v]' T B ; f[c*v]≡c*f[v] = f[c*v]≡c*f[v]' T B } where f[u+v]≡f[u]+f[v]' : {m n p q : ℕ} → (T : m ⊸ n) (B : p ⊸ q) → (u v : Vec A (m +ᴺ p)) → T ·ˡᵐ (take m (u +ⱽ v)) ++ B ·ˡᵐ (drop m (u +ⱽ v)) ≡ (T ·ˡᵐ (take m u) ++ B ·ˡᵐ (drop m u)) +ⱽ (T ·ˡᵐ (take m v) ++ B ·ˡᵐ (drop m v)) f[u+v]≡f[u]+f[v]' {m} T B u v = begin T ·ˡᵐ take m (u +ⱽ v) ++ B ·ˡᵐ drop m (u +ⱽ v) ≡⟨ cong₂ (λ x y → T ·ˡᵐ x ++ B ·ˡᵐ y) (take-distr-zipWith _+_ u v) (drop-distr-zipWith _+_ u v)⟩ T ·ˡᵐ (take m u +ⱽ take m v) ++ B ·ˡᵐ (drop m u +ⱽ drop m v) ≡⟨ cong₂ _++_ (f[u+v]≡f[u]+f[v] T (take m u) (take m v)) (f[u+v]≡f[u]+f[v] B (drop m u) (drop m v)) ⟩ (T ·ˡᵐ take m u +ⱽ T ·ˡᵐ take m v) ++ (B ·ˡᵐ drop m u +ⱽ B ·ˡᵐ drop m v) ≡⟨ sym (+ⱽ-flip-++ (T ·ˡᵐ take m u) (T ·ˡᵐ take m v) (B ·ˡᵐ drop m u) (B ·ˡᵐ drop m v)) ⟩ (T ·ˡᵐ take m u ++ B ·ˡᵐ drop m u) +ⱽ (T ·ˡᵐ take m v ++ B ·ˡᵐ drop m v) ∎ f[c*v]≡c*f[v]' : {m n p q : ℕ} → (T : m ⊸ n) (B : p ⊸ q) → (c : A) (v : Vec A (m +ᴺ p)) → T ·ˡᵐ (take m (c ∘ⱽ v)) ++ B ·ˡᵐ (drop m (c ∘ⱽ v)) ≡ c ∘ⱽ (T ·ˡᵐ (take m v) ++ B ·ˡᵐ (drop m v)) f[c*v]≡c*f[v]' {m} T B c v = begin T ·ˡᵐ take m (c ∘ⱽ v) ++ B ·ˡᵐ drop m (c ∘ⱽ v) ≡⟨ cong₂ (λ x y → T ·ˡᵐ x ++ B ·ˡᵐ y) (take-distr-map (c *_) m v) (drop-distr-map (c *_) m v) ⟩ T ·ˡᵐ (c ∘ⱽ take m v) ++ B ·ˡᵐ (c ∘ⱽ (drop m v)) ≡⟨ cong₂ _++_ (f[c*v]≡c*f[v] T c (take m v)) (f[c*v]≡c*f[v] B c (drop m v)) ⟩ c ∘ⱽ (T ·ˡᵐ take m v) ++ c ∘ⱽ (B ·ˡᵐ drop m v) ≡⟨ sym (∘ⱽ-distr-++ c (T ·ˡᵐ take m v) (B ·ˡᵐ drop m v)) ⟩ c ∘ⱽ (T ·ˡᵐ take m v ++ B ·ˡᵐ drop m v) ∎ -- Multiply by a constant _∘ˡᵐ_ : A → n ⊸ m → n ⊸ m c ∘ˡᵐ m = record { f = λ v → c ∘ⱽ m ·ˡᵐ v ; f[u+v]≡f[u]+f[v] = λ u v → trans (cong (c ∘ⱽ_) (f[u+v]≡f[u]+f[v] m u v)) (∘ⱽ-distr-+ⱽ c (m ·ˡᵐ u) (m ·ˡᵐ v)) ; f[c*v]≡c*f[v] = λ c₁ v → trans (cong (c ∘ⱽ_) (f[c*v]≡c*f[v] m c₁ v)) (∘ⱽ-comm c c₁ (f m v)) } -- Choose 20 since function application is assumed higher than almost anything infixr 20 _·ˡᵐ_ infixl 2 _—ˡᵐ_ infixl 3 _|ˡᵐ_ infixl 4 _/ˡᵐ_ infixl 6 _+ˡᵐ_ infixl 6 _-ˡᵐ_ infixl 7 _*ˡᵐ_ infixl 10 _∘ˡᵐ_ -- Example LinearMap values --------------------------------------------------- module _ ⦃ F : Field A ⦄ where open Field F idₗₘ : n ⊸ n idₗₘ = record { f = id ; f[u+v]≡f[u]+f[v] = λ u v → refl ; f[c*v]≡c*f[v] = λ c v → refl } diagₗₘ : Vec A n → n ⊸ n diagₗₘ d = record { f = d *ⱽ_ ; f[u+v]≡f[u]+f[v] = *ⱽ-distr-+ⱽ d ; f[c*v]≡c*f[v] = λ c v → *ⱽ∘ⱽ≡∘ⱽ*ⱽ c d v } 1ₗₘ : n ⊸ m 1ₗₘ = record { f = λ v → replicate (sum v) ; f[u+v]≡f[u]+f[v] = f[u+v]≡f[u]+f[v] ; f[c*v]≡c*f[v] = f[c*v]≡c*f[v] } where f[u+v]≡f[u]+f[v] : (u v : Vec A n) → replicate (sum (u +ⱽ v)) ≡ replicate (sum u) +ⱽ replicate (sum v) f[u+v]≡f[u]+f[v] u v = begin replicate (sum (u +ⱽ v)) ≡⟨ cong replicate (sum-distr-+ⱽ u v) ⟩ replicate ((sum u) + (sum v)) ≡⟨ replicate-distr-+ (sum u) (sum v) ⟩ replicate (sum u) +ⱽ replicate (sum v) ∎ f[c*v]≡c*f[v] : (c : A) (v : Vec A n) → replicate (sum (c ∘ⱽ v)) ≡ c ∘ⱽ replicate (sum v) f[c*v]≡c*f[v] c v = begin replicate (sum (c ∘ⱽ v)) ≡⟨ cong replicate (sum[c∘ⱽv]≡c*sum[v] c v) ⟩ replicate (c * sum v) ≡⟨ replicate[a*b]≡a∘ⱽreplicate[b] c (sum v) ⟩ c ∘ⱽ replicate (sum v) ∎ -- This could be defined as 0ᶠ ∘ˡᵐ allonesₗₘ, but then that would make -- some later proofs more difficult, since they would then have more than -- just replicate 0ᶠ to replace zerosₗₘ with. 0ₗₘ : n ⊸ m 0ₗₘ = record { f = λ v → replicate 0ᶠ ; f[u+v]≡f[u]+f[v] = λ u v → sym (trans (zipWith-replicate _+_ 0ᶠ 0ᶠ) (cong replicate 0ᶠ+0ᶠ≡0ᶠ)) ; f[c*v]≡c*f[v] = λ c v → sym (c∘ⱽ0ᶠⱽ≡0ᶠⱽ c) }
{ "alphanum_fraction": 0.3769870303, "avg_line_length": 39.8806366048, "ext": "agda", "hexsha": "872227c44aa2e420b8c6c0a30af4e64f00de9d52", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2021-09-07T19:55:59.000Z", "max_forks_repo_forks_event_min_datetime": "2021-04-12T20:34:17.000Z", "max_forks_repo_head_hexsha": "375475a2daa57b5995ceb78b4bffcbfcbb5d8898", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "turion/functional-linear-algebra", "max_forks_repo_path": "src/FLA/Algebra/LinearMap.agda", "max_issues_count": 6, "max_issues_repo_head_hexsha": "375475a2daa57b5995ceb78b4bffcbfcbb5d8898", "max_issues_repo_issues_event_max_datetime": "2022-01-07T05:27:53.000Z", "max_issues_repo_issues_event_min_datetime": "2020-09-01T01:42:12.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "turion/functional-linear-algebra", "max_issues_repo_path": "src/FLA/Algebra/LinearMap.agda", "max_line_length": 80, "max_stars_count": 21, "max_stars_repo_head_hexsha": "375475a2daa57b5995ceb78b4bffcbfcbb5d8898", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "turion/functional-linear-algebra", "max_stars_repo_path": "src/FLA/Algebra/LinearMap.agda", "max_stars_repo_stars_event_max_datetime": "2022-01-07T05:28:00.000Z", "max_stars_repo_stars_event_min_datetime": "2020-09-22T20:49:34.000Z", "num_tokens": 8174, "size": 15035 }
-- Occurs when different mixfix patterns use similar names. module Issue147b where data X : Set where f : X -> X f_ : X -> X x : X bad : X -> X bad (f x) = x bad _ = x
{ "alphanum_fraction": 0.5824175824, "avg_line_length": 15.1666666667, "ext": "agda", "hexsha": "4fa7038b80b00274718d9a81f6bed5c34fe0dcfc", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cruhland/agda", "max_forks_repo_path": "test/Fail/Issue147b.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "cruhland/agda", "max_issues_repo_path": "test/Fail/Issue147b.agda", "max_line_length": 59, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/Fail/Issue147b.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 66, "size": 182 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Bisimilarity for M-types ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe --sized-types #-} module Codata.M.Bisimilarity where open import Level open import Size open import Codata.Thunk open import Codata.M open import Data.Container.Core open import Data.Container.Relation.Binary.Pointwise using (Pointwise; _,_) open import Data.Product using (_,_) open import Function open import Relation.Binary import Relation.Binary.PropositionalEquality as P data Bisim {s p} (C : Container s p) (i : Size) : Rel (M C ∞) (s ⊔ p) where inf : ∀ {t u} → Pointwise C (Thunk^R (Bisim C) i) t u → Bisim C i (inf t) (inf u) module _ {s p} {C : Container s p} where -- unfortunately the proofs are a lot nicer if we do not use the combinators -- C.refl, C.sym and C.trans refl : ∀ {i} → Reflexive (Bisim C i) refl {x = inf t} = inf (P.refl , λ where p .force → refl) sym : ∀ {i} → Symmetric (Bisim C i) sym (inf (P.refl , f)) = inf (P.refl , λ where p .force → sym (f p .force)) trans : ∀ {i} → Transitive (Bisim C i) trans (inf (P.refl , f)) (inf (P.refl , g)) = inf (P.refl , λ where p .force → trans (f p .force) (g p .force)) isEquivalence : ∀ {i} → IsEquivalence (Bisim C i) isEquivalence = record { refl = refl ; sym = sym ; trans = trans } setoid : {i : Size} → Setoid (s ⊔ p) (s ⊔ p) setoid {i} = record { isEquivalence = isEquivalence {i} }
{ "alphanum_fraction": 0.5743458839, "avg_line_length": 30.7254901961, "ext": "agda", "hexsha": "5d82efa08f8cd51a430e95ad2eba41b1482e9ff8", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "omega12345/agda-mode", "max_forks_repo_path": "test/asset/agda-stdlib-1.0/Codata/M/Bisimilarity.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "omega12345/agda-mode", "max_issues_repo_path": "test/asset/agda-stdlib-1.0/Codata/M/Bisimilarity.agda", "max_line_length": 83, "max_stars_count": 5, "max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "omega12345/agda-mode", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Codata/M/Bisimilarity.agda", "max_stars_repo_stars_event_max_datetime": "2020-10-10T21:41:32.000Z", "max_stars_repo_stars_event_min_datetime": "2020-10-07T12:07:53.000Z", "num_tokens": 480, "size": 1567 }
------------------------------------------------------------------------ -- Least upper bounds ------------------------------------------------------------------------ {-# OPTIONS --sized-types #-} module Delay-monad.Least-upper-bound where open import Equality.Propositional open import Prelude hiding (_⊔_) open import Prelude.Size open import Nat equality-with-J open import Delay-monad open import Delay-monad.Partial-order module _ {a} {A : Type a} where -- Least upper bounds (if they exist). infix 10 _⊔_ _⊔_ : ∀ {i} → Delay A i → Delay A i → Delay A i now x ⊔ _ = now x later x ⊔ now y = now y later x ⊔ later y = later λ { .force → force x ⊔ force y } -- The computation x ⊔ y is smaller than or equal to every upper -- bound of x and y. ⊔-least-upper-bound : ∀ {i x y z} → [ i ] x ⊑ z → [ i ] y ⊑ z → [ i ] x ⊔ y ⊑ z ⊔-least-upper-bound now _ = now ⊔-least-upper-bound (laterʳ p) q = laterʳ (⊔-least-upper-bound p (laterʳ⁻¹ q)) ⊔-least-upper-bound {y = now y} (laterˡ _) q = q ⊔-least-upper-bound {y = later y} (laterˡ p) q = laterˡ λ { .force → ⊔-least-upper-bound (force p) (laterˡ⁻¹ q) } -- If x and y have a lower bound, then this is also a lower bound of -- x ⊔ y. ⊔-lower-bound : ∀ {i x y z} → [ i ] z ⊑ x → [ i ] z ⊑ y → [ i ] z ⊑ x ⊔ y ⊔-lower-bound now _ = now ⊔-lower-bound (laterˡ p) q = laterˡ λ { .force → ⊔-lower-bound (force p) (laterˡ⁻¹ q) } ⊔-lower-bound {y = now y} (laterʳ _) q = q ⊔-lower-bound {y = later y} (laterʳ p) q = laterʳ (⊔-lower-bound p (laterʳ⁻¹ q)) -- If x and y have an upper bound, then x ⊔ y is an upper bound -- of y. ⊔-upper-boundʳ : ∀ {i x y z} → [ i ] x ⊑ z → [ i ] y ⊑ z → [ i ] y ⊑ x ⊔ y ⊔-upper-boundʳ now q = q ⊔-upper-boundʳ (laterʳ p) q = ⊔-upper-boundʳ p (laterʳ⁻¹ q) ⊔-upper-boundʳ {y = now y} (laterˡ _) _ = now ⊔-upper-boundʳ {y = later y} (laterˡ p) q = later-cong λ { .force → ⊔-upper-boundʳ (force p) (laterˡ⁻¹ q) } -- If x and y have an upper bound, then x ⊔ y is an upper bound -- of x. ⊔-upper-boundˡ : ∀ {i x y z} → [ i ] x ⊑ z → [ i ] y ⊑ z → [ i ] x ⊑ x ⊔ y ⊔-upper-boundˡ now q = now ⊔-upper-boundˡ (laterʳ p) q = ⊔-upper-boundˡ p (laterʳ⁻¹ q) ⊔-upper-boundˡ {y = later y} (laterˡ p) q = later-cong λ { .force → ⊔-upper-boundˡ (force p) (laterˡ⁻¹ q) } ⊔-upper-boundˡ {y = now y} (laterˡ p) q = laterˡ λ { .force → ⊔-upper-boundʳ q (force p) } -- A variant of the lower/upper bound lemmas. ⊔-lower-upper-bound : ∀ {i x y z} → x ⊑ y → [ i ] y ⊑ z → [ i ] y ⊑ x ⊔ z ⊔-lower-upper-bound now _ = now ⊔-lower-upper-bound (laterʳ p) q = laterˡ λ { .force → ⊔-lower-upper-bound p (laterˡ⁻¹ q) } ⊔-lower-upper-bound (laterˡ p) (laterʳ q) = laterʳ (⊔-lower-upper-bound (force p) q) ⊔-lower-upper-bound {z = now z} (laterˡ _) q = q ⊔-lower-upper-bound {z = later z} (laterˡ p) (laterˡ q) = later-cong λ { .force → ⊔-lower-upper-bound (laterʳ⁻¹ (force p)) (laterʳ⁻¹ (force q)) } -- If x terminates, then x ⊔ y also terminates. ⊔-⇓ˡ : ∀ {i x y} {z : A} → Terminates i x z → ∃ λ z′ → Terminates i (x ⊔ y) z′ ⊔-⇓ˡ now = _ , now ⊔-⇓ˡ {y = now y} (laterʳ p) = _ , now ⊔-⇓ˡ {y = later y} (laterʳ p) = Σ-map id laterʳ (⊔-⇓ˡ p) -- If y terminates, then x ⊔ y also terminates. ⊔-⇓ʳ : ∀ {i} x {y} {z : A} → Terminates i y z → ∃ λ z′ → Terminates i (x ⊔ y) z′ ⊔-⇓ʳ (now x) _ = _ , now ⊔-⇓ʳ (later x) now = _ , now ⊔-⇓ʳ (later x) (laterʳ p) = Σ-map id laterʳ (⊔-⇓ʳ (force x) p) -- Increasing sequences. Increasing-sequence : ∀ {a} → Type a → Type a Increasing-sequence A = ∃ λ (f : ℕ → Delay A ∞) → ∀ n → f n ⊑ f (suc n) module _ {a} {A : Type a} where -- The tail of an increasing sequence. tailˢ : Increasing-sequence A → Increasing-sequence A tailˢ = Σ-map (_∘ suc) (_∘ suc) -- Later sequence elements are larger. later-larger : (s : Increasing-sequence A) → ∀ {m n} → m ≤ n → proj₁ s m ⊑ proj₁ s n later-larger s (≤-refl′ refl) = reflexive _ later-larger s (≤-step′ p refl) = transitive (later-larger s p) (proj₂ s _) -- Least upper bounds of increasing sequences. ⨆ : ∀ {i} → Increasing-sequence A → Delay A i ⨆ s = proj₁ s 0 ⊔ later λ { .force → ⨆ (tailˢ s) } -- ⨆ s is smaller than or equal to every upper bound of s. ⨆-least-upper-bound : ∀ {i} (s : Increasing-sequence A) ub → (∀ n → [ i ] proj₁ s n ⊑ ub) → [ i ] ⨆ s ⊑ ub ⨆-least-upper-bound s ub is-ub = ⊔-least-upper-bound (is-ub 0) (laterˡ λ { .force → ⨆-least-upper-bound (tailˢ s) ub (is-ub ∘ suc) }) -- If every element in s terminates with a given value, then ⨆ s -- terminates with the same value. ⨆-⇓ : ∀ {i x} (s : Increasing-sequence A) → (∀ n → proj₁ s n ⇓ x) → Terminates i (⨆ s) x ⨆-⇓ s s-⇓ = ⊑now→⇓→⇓ (⨆-least-upper-bound s _ (λ n → symmetric (s-⇓ n))) (proj₂ (⊔-⇓ˡ (s-⇓ 0))) -- If s has a lower bound, then this is also a lower bound of ⨆ s. ⨆-lower-bound : ∀ {i} (s : Increasing-sequence A) lb → (∀ n → lb ⊑ proj₁ s n) → [ i ] lb ⊑ ⨆ s ⨆-lower-bound s (now x) is-lb = ⨆-⇓ s is-lb ⨆-lower-bound s (later lb) is-lb = ⊔-lower-bound (is-lb 0) (later-cong λ { .force → ⨆-lower-bound (tailˢ s) (force lb) λ n → laterˡ⁻¹ (transitive (is-lb n) (proj₂ s n)) }) -- ⨆ s is an upper bound of s. ⨆-upper-bound : ∀ {i} (s : Increasing-sequence A) → ∀ n → [ i ] proj₁ s n ⊑ ⨆ s ⨆-upper-bound s zero = ⨆-lower-bound s (proj₁ s 0) (λ n → later-larger s (zero≤ n)) ⨆-upper-bound s (suc n) = ⊔-lower-upper-bound (later-larger s (zero≤ (suc n))) (laterʳ (⨆-upper-bound (tailˢ s) n))
{ "alphanum_fraction": 0.4659574468, "avg_line_length": 38.7058823529, "ext": "agda", "hexsha": "e9c98f914bf03d636301f545cda71e3777eb32d9", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "495f9996673d0f1f34ce202902daaa6c39f8925e", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "nad/delay-monad", "max_forks_repo_path": "src/Delay-monad/Least-upper-bound.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "495f9996673d0f1f34ce202902daaa6c39f8925e", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "nad/delay-monad", "max_issues_repo_path": "src/Delay-monad/Least-upper-bound.agda", "max_line_length": 102, "max_stars_count": null, "max_stars_repo_head_hexsha": "495f9996673d0f1f34ce202902daaa6c39f8925e", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "nad/delay-monad", "max_stars_repo_path": "src/Delay-monad/Least-upper-bound.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 2413, "size": 6580 }
module Normalize where open import Data.List open import Data.Product open import PiLevel0 -- We are going to use all the coherence as follows; make the right -- hand side canonical and rewrite the left hand side to the right -- hand side. Brute force below cannot work! -- Use the same structure as -- https://agda.github.io/agda-stdlib/Algebra.Monoid-solver.html ?? {-# NO_TERMINATION_CHECK #-} normalize : {t₁ t₂ : U} → (t₁ ⟷ t₂) → (t₁ ⟷ t₂) normalize unite₊ = {!!} normalize uniti₊ = {!!} normalize swap₊ = {!!} normalize assocl₊ = {!!} normalize assocr₊ = {!!} normalize unite⋆ = {!!} normalize uniti⋆ = {!!} normalize swap⋆ = {!!} normalize assocl⋆ = {!!} normalize assocr⋆ = {!!} normalize absorbr = {!!} normalize absorbl = {!!} normalize factorzr = {!!} normalize factorzl = {!!} normalize dist = {!!} normalize factor = {!!} normalize id⟷ = {!!} normalize (c ◎ id⟷) = normalize c normalize (unite₊ ◎ c₁) = {!!} normalize (uniti₊ ◎ c₁) = {!!} normalize (swap₊ ◎ c₁) = {!!} normalize (assocl₊ ◎ c₁) = {!!} normalize (assocr₊ ◎ c₁) = {!!} normalize (unite⋆ ◎ c₁) = {!!} normalize (uniti⋆ ◎ c₁) = {!!} normalize (swap⋆ ◎ c₁) = {!!} normalize (assocl⋆ ◎ c₁) = {!!} normalize (assocr⋆ ◎ c₁) = {!!} normalize (absorbr ◎ c₁) = {!!} normalize (absorbl ◎ c₁) = {!!} normalize (factorzr ◎ c₁) = {!!} normalize (factorzl ◎ c₁) = {!!} normalize (dist ◎ c₁) = {!!} normalize (factor ◎ c₁) = {!!} normalize (id⟷ ◎ c₁) = normalize c₁ normalize ((c ◎ c₁) ◎ c₂) = normalize (c ◎ (c₁ ◎ c₂)) normalize ((c ⊕ c₁) ◎ c₂) = {!!} normalize ((c ⊗ c₁) ◎ c₂) = {!!} normalize (c ⊕ unite₊) = {!!} normalize (c ⊕ uniti₊) = {!!} normalize (c ⊕ swap₊) = {!!} normalize (c ⊕ assocl₊) = {!!} normalize (c ⊕ assocr₊) = {!!} normalize (c ⊕ unite⋆) = {!!} normalize (c ⊕ uniti⋆) = {!!} normalize (c ⊕ swap⋆) = {!!} normalize (c ⊕ assocl⋆) = {!!} normalize (c ⊕ assocr⋆) = {!!} normalize (c ⊕ absorbr) = {!!} normalize (c ⊕ absorbl) = {!!} normalize (c ⊕ factorzr) = {!!} normalize (c ⊕ factorzl) = {!!} normalize (c ⊕ dist) = {!!} normalize (c ⊕ factor) = {!!} normalize (c ⊕ id⟷) = {!!} normalize (c ⊕ c₁ ◎ c₂) = {!!} normalize (c ⊕ (c₁ ⊕ c₂)) = {!!} normalize (c ⊕ (c₁ ⊗ c₂)) = {!!} normalize (c ⊗ c₁) = {!!}
{ "alphanum_fraction": 0.5752737226, "avg_line_length": 28.4675324675, "ext": "agda", "hexsha": "262d1a935a2b2b3649586616c4436523fff0cfb9", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2019-09-10T09:47:13.000Z", "max_forks_repo_forks_event_min_datetime": "2016-05-29T01:56:33.000Z", "max_forks_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_forks_repo_licenses": [ "BSD-2-Clause" ], "max_forks_repo_name": "JacquesCarette/pi-dual", "max_forks_repo_path": "Univalence/Normalize.agda", "max_issues_count": 4, "max_issues_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_issues_repo_issues_event_max_datetime": "2021-10-29T20:41:23.000Z", "max_issues_repo_issues_event_min_datetime": "2018-06-07T16:27:41.000Z", "max_issues_repo_licenses": [ "BSD-2-Clause" ], "max_issues_repo_name": "JacquesCarette/pi-dual", "max_issues_repo_path": "Univalence/Normalize.agda", "max_line_length": 67, "max_stars_count": 14, "max_stars_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_stars_repo_licenses": [ "BSD-2-Clause" ], "max_stars_repo_name": "JacquesCarette/pi-dual", "max_stars_repo_path": "Univalence/Normalize.agda", "max_stars_repo_stars_event_max_datetime": "2021-05-05T01:07:57.000Z", "max_stars_repo_stars_event_min_datetime": "2015-08-18T21:40:15.000Z", "num_tokens": 817, "size": 2192 }
module Prelude.Maybe where open import Prelude.Unit open import Prelude.Empty open import Prelude.Function open import Prelude.Functor open import Prelude.Applicative open import Prelude.Monad open import Prelude.Equality open import Prelude.Decidable data Maybe {a} (A : Set a) : Set a where nothing : Maybe A just : A → Maybe A {-# FOREIGN GHC type AgdaMaybe l = Maybe #-} {-# COMPILE GHC Maybe = data MAlonzo.Code.Prelude.Maybe.AgdaMaybe (Nothing | Just) #-} maybe : ∀ {a b} {A : Set a} {B : Set b} → B → (A → B) → Maybe A → B maybe z f nothing = z maybe z f (just x) = f x {-# INLINE maybe #-} fromMaybe : ∀ {a} {A : Set a} → A → Maybe A → A fromMaybe z = maybe z id {-# INLINE fromMaybe #-} IsJust : ∀ {a} {A : Set a} → Maybe A → Set IsJust = maybe ⊥ (const ⊤) FromJust : ∀ {a} {A : Set a} → Maybe A → Set a FromJust {A = A} = maybe ⊤′ (const A) fromJust : ∀ {a} {A : Set a} (m : Maybe A) → FromJust m fromJust nothing = _ fromJust (just x) = x maybeYes : ∀ {a} {A : Set a} → Dec A → Maybe A maybeYes (yes x) = just x maybeYes (no _) = nothing --- Equality --- just-inj : ∀ {a} {A : Set a} {x y : A} → just x ≡ just y → x ≡ y just-inj refl = refl instance EqMaybe : ∀ {a} {A : Set a} {{EqA : Eq A}} → Eq (Maybe A) _==_ {{EqMaybe}} nothing nothing = yes refl _==_ {{EqMaybe}} nothing (just x) = no λ () _==_ {{EqMaybe}} (just x) nothing = no λ () _==_ {{EqMaybe}} (just x) (just y) with x == y ... | yes eq = yes (just $≡ eq) ... | no neq = no (λ eq → neq (just-inj eq)) --- Monad --- instance FunctorMaybe : ∀ {a} → Functor (Maybe {a}) fmap {{FunctorMaybe}} f m = maybe nothing (just ∘ f) m ApplicativeMaybe : ∀ {a} → Applicative (Maybe {a}) pure {{ApplicativeMaybe}} = just _<*>_ {{ApplicativeMaybe}} mf mx = maybe nothing (λ f → fmap f mx) mf MonadMaybe : ∀ {a} → Monad {a} Maybe _>>=_ {{MonadMaybe}} m f = maybe nothing f m FunctorMaybe′ : ∀ {a b} → Functor′ {a} {b} Maybe fmap′ {{FunctorMaybe′}} f m = maybe nothing (just ∘ f) m ApplicativeMaybe′ : ∀ {a b} → Applicative′ {a} {b} Maybe _<*>′_ {{ApplicativeMaybe′}} (just f) (just x) = just (f x) _<*>′_ {{ApplicativeMaybe′}} _ _ = nothing MonadMaybe′ : ∀ {a b} → Monad′ {a} {b} Maybe _>>=′_ {{MonadMaybe′}} m f = maybe nothing f m
{ "alphanum_fraction": 0.5896536607, "avg_line_length": 28.8734177215, "ext": "agda", "hexsha": "318c164701914e2387cd07a394605d514538b9a1", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "75016b4151ed601e28f4462cd7b6b1aaf5d0d1a6", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "lclem/agda-prelude", "max_forks_repo_path": "src/Prelude/Maybe.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "75016b4151ed601e28f4462cd7b6b1aaf5d0d1a6", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "lclem/agda-prelude", "max_issues_repo_path": "src/Prelude/Maybe.agda", "max_line_length": 86, "max_stars_count": null, "max_stars_repo_head_hexsha": "75016b4151ed601e28f4462cd7b6b1aaf5d0d1a6", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "lclem/agda-prelude", "max_stars_repo_path": "src/Prelude/Maybe.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 808, "size": 2281 }
{-# OPTIONS --without-K --safe #-} module Categories.Functor.Properties where -- Properties valid of all Functors open import Level open import Data.Product using (proj₁; proj₂; _,_) open import Function.Surjection using (Surjective) open import Function.Equivalence using (Equivalence) open import Function.Equality hiding (_∘_) open import Categories.Category open import Categories.Functor.Core open import Categories.Functor open import Categories.Morphism as Morphism import Categories.Morphism.Reasoning as Reas open import Categories.Morphism.IsoEquiv as IsoEquiv open import Categories.Morphism.Isomorphism open import Relation.Binary using (_Preserves_⟶_) private variable o ℓ e : Level C D : Category o ℓ e -- a series of [ Functor ]-respects-Thing combinators (with respects -> resp) module _ (F : Functor C D) where private module C = Category C module D = Category D module IsoC = IsoEquiv C module IsoD = IsoEquiv D open C hiding (_∘_) open Functor F private variable A B E : Obj f g h i : A ⇒ B [_]-resp-∘ : C [ C [ f ∘ g ] ≈ h ] → D [ D [ F₁ f ∘ F₁ g ] ≈ F₁ h ] [_]-resp-∘ {f = f} {g = g} {h = h} eq = begin F₁ f ∘ F₁ g ≈˘⟨ homomorphism ⟩ F₁ (C [ f ∘ g ]) ≈⟨ F-resp-≈ eq ⟩ F₁ h ∎ where open D open D.HomReasoning [_]-resp-square : C.CommutativeSquare f g h i → D.CommutativeSquare (F₁ f) (F₁ g) (F₁ h) (F₁ i) [_]-resp-square {f = f} {g = g} {h = h} {i = i} sq = begin F₁ h ∘ F₁ f ≈˘⟨ homomorphism ⟩ F₁ (C [ h ∘ f ]) ≈⟨ F-resp-≈ sq ⟩ F₁ (C [ i ∘ g ]) ≈⟨ homomorphism ⟩ F₁ i ∘ F₁ g ∎ where open D open D.HomReasoning [_]-resp-Iso : Iso C f g → Iso D (F₁ f) (F₁ g) [_]-resp-Iso {f = f} {g = g} iso = record { isoˡ = begin F₁ g ∘ F₁ f ≈⟨ [ isoˡ ]-resp-∘ ⟩ F₁ C.id ≈⟨ identity ⟩ D.id ∎ ; isoʳ = begin F₁ f ∘ F₁ g ≈⟨ [ isoʳ ]-resp-∘ ⟩ F₁ C.id ≈⟨ identity ⟩ D.id ∎ } where open Iso iso open D open D.HomReasoning [_]-resp-≅ : F₀ Preserves _≅_ C ⟶ _≅_ D [_]-resp-≅ i≅j = record { from = F₁ from ; to = F₁ to ; iso = [ iso ]-resp-Iso } where open _≅_ i≅j [_]-resp-≃ : ∀ {f g : _≅_ C A B} → f IsoC.≃ g → [ f ]-resp-≅ IsoD.≃ [ g ]-resp-≅ [_]-resp-≃ ⌞ eq ⌟ = ⌞ F-resp-≈ eq ⌟ homomorphismᵢ : ∀ {f : _≅_ C B E} {g : _≅_ C A B} → [ _∘ᵢ_ C f g ]-resp-≅ IsoD.≃ (_∘ᵢ_ D [ f ]-resp-≅ [ g ]-resp-≅ ) homomorphismᵢ = ⌞ homomorphism ⌟ -- Uses a strong version of Essential Surjectivity. EssSurj×Full×Faithful⇒Invertible : EssentiallySurjective F → Full F → Faithful F → Functor D C EssSurj×Full×Faithful⇒Invertible surj full faith = record { F₀ = λ d → proj₁ (surj d) ; F₁ = λ {A} {B} f → let (a , sa) = surj A in let (b , sb) = surj B in let module S = Surjective (full {a} {b}) in S.from ⟨$⟩ (_≅_.to sb) ∘ f ∘ (_≅_.from sa) ; identity = λ {A} → let (a , sa) = surj A in begin from full ⟨$⟩ _≅_.to sa ∘ D.id ∘ _≅_.from sa ≈⟨ cong (from full) (D.∘-resp-≈ʳ D.identityˡ D.HomReasoning.○ _≅_.isoˡ sa) ⟩ from full ⟨$⟩ D.id ≈˘⟨ cong (from full) identity ⟩ from full ⟨$⟩ F₁ C.id ≈⟨ faith _ _ (right-inverse-of full (F₁ C.id)) ⟩ C.id ∎ ; homomorphism = λ {X} {Y} {Z} {f} {g} → let (x , sx) = surj X in let (y , sy) = surj Y in let (z , sz) = surj Z in let open Morphism._≅_ in faith _ _ (E.begin F₁ (from full ⟨$⟩ to sz ∘ (g ∘ f) ∘ from sx) E.≈⟨ right-inverse-of full _ ⟩ (to sz ∘ (g ∘ f) ∘ from sx) E.≈⟨ D.∘-resp-≈ʳ (D.∘-resp-≈ˡ (D.∘-resp-≈ʳ (introˡ (isoʳ sy)))) ⟩ (to sz ∘ (g ∘ (from sy ∘ to sy) ∘ f) ∘ from sx) E.≈˘⟨ D.assoc ⟩ (to sz ∘ g ∘ ((from sy ∘ to sy) ∘ f)) ∘ from sx E.≈⟨ D.∘-resp-≈ˡ (D.∘-resp-≈ʳ (D.∘-resp-≈ʳ D.assoc)) ⟩ (to sz ∘ g ∘ (from sy ∘ (to sy ∘ f))) ∘ from sx E.≈˘⟨ D.∘-resp-≈ˡ D.assoc ⟩ ((to sz ∘ g) ∘ (from sy ∘ (to sy ∘ f))) ∘ from sx E.≈˘⟨ D.∘-resp-≈ˡ D.assoc ⟩ (((to sz ∘ g) ∘ from sy) ∘ (to sy ∘ f)) ∘ from sx E.≈⟨ D.assoc ⟩ ((to sz ∘ g) ∘ from sy) ∘ ((to sy ∘ f) ∘ from sx) E.≈⟨ D.∘-resp-≈ D.assoc D.assoc ⟩ (to sz ∘ g ∘ from sy) ∘ (to sy ∘ f ∘ from sx) E.≈˘⟨ D.∘-resp-≈ (right-inverse-of full _) (right-inverse-of full _) ⟩ F₁ (from full ⟨$⟩ to sz ∘ g ∘ from sy) ∘ F₁ (from full ⟨$⟩ to sy ∘ f ∘ from sx) E.≈˘⟨ homomorphism ⟩ F₁ ((from full ⟨$⟩ to sz ∘ g ∘ from sy) C.∘ (from full ⟨$⟩ to sy ∘ f ∘ from sx)) E.∎) ; F-resp-≈ = λ f≈g → cong (from full) (D.∘-resp-≈ʳ (D.∘-resp-≈ˡ f≈g)) } where open Morphism D open Reas D open Category D open Surjective open C.HomReasoning module E = D.HomReasoning -- Functor Composition is Associative and the unit laws are found in -- NaturalTransformation.NaturalIsomorphism, reified as associator, unitorˡ and unitorʳ.
{ "alphanum_fraction": 0.5042589438, "avg_line_length": 40.0227272727, "ext": "agda", "hexsha": "590b444ab136537b99e796ba9ba7a8d09dc68266", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "6ebc1349ee79669c5c496dcadd551d5bbefd1972", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Taneb/agda-categories", "max_forks_repo_path": "Categories/Functor/Properties.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "6ebc1349ee79669c5c496dcadd551d5bbefd1972", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Taneb/agda-categories", "max_issues_repo_path": "Categories/Functor/Properties.agda", "max_line_length": 155, "max_stars_count": null, "max_stars_repo_head_hexsha": "6ebc1349ee79669c5c496dcadd551d5bbefd1972", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Taneb/agda-categories", "max_stars_repo_path": "Categories/Functor/Properties.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 2131, "size": 5283 }
module Experiment.Expr.Expr where open import Data.Fin open import Data.Empty open import Level open import Data.Bool open import Data.Nat hiding (_⊔_) open import Data.Product open import Data.List as List hiding (or; and) data Expr {v} (V : Set v) : Set v where var : V -> Expr V or and : Expr V -> Expr V -> Expr V neg : Expr V -> Expr V foldExpr : ∀ {a v} {V : Set v} {A : Set a} → (V → A) → (A → A → A) → (A → A → A) → (A → A) → Expr V → A foldExpr v o a n (var v′) = v v′ foldExpr v o a n (or e₁ e₂) = o (foldExpr v o a n e₁) (foldExpr v o a n e₂) foldExpr v o a n (and e₁ e₂) = a (foldExpr v o a n e₁) (foldExpr v o a n e₂) foldExpr v o a n (neg e) = n (foldExpr v o a n e) evalExpr : ∀ {v} {V : Set v} → (V → Bool) → Expr V → Bool evalExpr v = foldExpr v _∨_ _∧_ not data Sign : Set where pos : Sign neg : Sign Literal : ∀ {a} → Set a → Set a Literal V = Sign × V data NNF {v} (V : Set v) : Set v where lit : Literal V → NNF V and or : NNF V → NNF V → NNF V data GExpr {v t₁ t₂ tₙ} (T₁ : Set t₁) (T₂ : Set t₂) (Tₙ : Set tₙ) (V : Set v) : Set (v ⊔ t₁ ⊔ t₂ ⊔ tₙ) where var : (v : V) → GExpr T₁ T₂ Tₙ V op₁ : T₁ → (e : GExpr T₁ T₂ Tₙ V) → GExpr T₁ T₂ Tₙ V op₂ : T₂ → (e₁ e₂ : GExpr T₁ T₂ Tₙ V) → GExpr T₁ T₂ Tₙ V opₙ : Tₙ → (es : List (GExpr T₁ T₂ Tₙ V)) → GExpr T₁ T₂ Tₙ V data AndOr : Set where and : AndOr or : AndOr data Neg : Set where neg : Neg ExprAndOrNeg : ℕ → Set ExprAndOrNeg n = GExpr AndOr Neg ⊥ (Fin n) evalAndOr : AndOr → Bool → Bool → Bool evalAndOr and = _∧_ evalAndOr or = _∨_ module _ {v t₁ t₂ tₙ a} {V : Set v} {T₁ : Set t₁} {T₂ : Set t₂} {Tₙ : Set tₙ} {A : Set a} (var* : V → A) (op₁* : T₁ → A → A) (op₂* : T₂ → A → A → A) (opₙ* : Tₙ → List A → A) where foldGExpr : GExpr T₁ T₂ Tₙ V → A foldGExpr (var v) = var* v foldGExpr (op₁ t₁ e) = op₁* t₁ (foldGExpr e) foldGExpr (op₂ t₂ e₁ e₂) = op₂* t₂ (foldGExpr e₁) (foldGExpr e₂) foldGExpr (opₙ tₙ es) = opₙ* tₙ (List.map foldGExpr es)
{ "alphanum_fraction": 0.568598316, "avg_line_length": 29.2608695652, "ext": "agda", "hexsha": "0f2d77f959590615d58b08897b83a3d0d85d8ed1", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "37200ea91d34a6603d395d8ac81294068303f577", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "rei1024/agda-misc", "max_forks_repo_path": "Experiment/Expr/Expr.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "37200ea91d34a6603d395d8ac81294068303f577", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "rei1024/agda-misc", "max_issues_repo_path": "Experiment/Expr/Expr.agda", "max_line_length": 77, "max_stars_count": 3, "max_stars_repo_head_hexsha": "37200ea91d34a6603d395d8ac81294068303f577", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "rei1024/agda-misc", "max_stars_repo_path": "Experiment/Expr/Expr.agda", "max_stars_repo_stars_event_max_datetime": "2020-04-21T00:03:43.000Z", "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:49:42.000Z", "num_tokens": 892, "size": 2019 }
module UniDB.Subst.Sum where open import UniDB.Subst.Core open import UniDB.Morph.Sum -------------------------------------------------------------------------------- module _ (T : STX) {{vrT : Vr T}} {{wkT : Wk T}} (X : STX) {{wkX : Wk X}} {{apTX : Ap T X}} {{apRelTX : ApRel T X}} (Ξ : MOR) {{lkTΞ : Lk T Ξ}} {{upΞ : Up Ξ}} (Ζ : MOR) {{lkTΖ : Lk T Ζ}} {{upΖ : Up Ζ}} where ap-inl : {γ₁ γ₂ : Dom} (ξ : Ξ γ₁ γ₂) (x : X γ₁) → ap {T} {X} {Sum Ξ Ζ} (inl ξ) x ≡ ap {T} ξ x ap-inl ξ = ap-rel≅ {T} (≃-to-≅` lem) where lem : (δ : Dom) → [ T ] inl {Ξ} {Ζ} ξ ↑ δ ≃ ξ ↑ δ lk≃ (lem δ) i rewrite inl-↑ Ξ Ζ ξ δ = refl ap-inr : {γ₁ γ₂ : Dom} (ζ : Ζ γ₁ γ₂) (x : X γ₁) → ap {T} {X} {Sum Ξ Ζ} (inr ζ) x ≡ ap {T} ζ x ap-inr ζ = ap-rel≅ {T} (≃-to-≅` lem) where lem : (δ : Dom) → [ T ] inr {Ξ} {Ζ} ζ ↑ δ ≃ ζ ↑ δ lk≃ (lem δ) i rewrite inr-↑ Ξ Ζ ζ δ = refl --------------------------------------------------------------------------------
{ "alphanum_fraction": 0.3846938776, "avg_line_length": 32.6666666667, "ext": "agda", "hexsha": "13eb113a07bff8e1dc765a22c90db749c543f640", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "7ae52205db44ad4f463882ba7e5082120fb76349", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "skeuchel/unidb-agda", "max_forks_repo_path": "UniDB/Subst/Sum.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "7ae52205db44ad4f463882ba7e5082120fb76349", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "skeuchel/unidb-agda", "max_issues_repo_path": "UniDB/Subst/Sum.agda", "max_line_length": 80, "max_stars_count": null, "max_stars_repo_head_hexsha": "7ae52205db44ad4f463882ba7e5082120fb76349", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "skeuchel/unidb-agda", "max_stars_repo_path": "UniDB/Subst/Sum.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 445, "size": 980 }
open import Prelude open import Reflection renaming (Term to AgTerm; Type to AgType) open import Data.String using (String) open import RW.Language.RTerm open import RW.Language.RTermUtils open import RW.Language.FinTerm open import RW.Language.GoalGuesser 1 open import RW.Strategy module RW.RW (db : TStratDB) where open import RW.Utils.Monads open import RW.Utils.Error open Monad {{...}} open IsError {{...}} ------------------ -- Housekeeping -- ------------------ -- We need to bring our instances into scope explicitely, -- to make Agda happy. private instance ErrErr = IsError-StratErr ErrMonad = MonadError unarg : {A : Set} → Arg A → A unarg (arg _ x) = x -- We need to translate types to FinTerms, so we know how many variables -- we're expecting to guess from instantiation. Ag2RTypeFin : AgType → ∃ FinTerm Ag2RTypeFin = R2FinType ∘ lift-ivar ∘ η ∘ Ag2RType -- TODO: fix the duality: "number of ivar's lifted to ovar's vs. parameters we need to guess" make-RWData : Name → AgTerm → List (Arg AgType) → Err StratErr RWData make-RWData act goal ctx with η (Ag2RTerm goal) | Ag2RTypeFin (type act) | map (Ag2RType ∘ unarg) ctx ...| g' | tyℕ , ty | ctx' with forceBinary g' | forceBinary (typeResult ty) ...| just g | just a = return (rw-data g tyℕ a ctx') ...| just _ | nothing = throwError (Custom "Something strange happened with the action") ...| nothing | just _ = throwError (Custom "Something strange happened with the goal") ...| nothing | nothing = throwError (Custom "My brain just exploded.") -- Given a goal and a list of actions to apply to such goal, return -- a list l₁ ⋯ lₙ such that ∀ 0 < i ≤ n . tyᵢ : p1 lᵢ → p1 lᵢ₊₁ Ag2RTypeFin* : RTerm ⊥ → List AgType → Maybe (List (RBinApp ⊥ × ∃ (RBinApp ∘ Fin))) Ag2RTypeFin* (rapp n (g₁ ∷ g₂ ∷ [])) tys = mapM (return ∘ Ag2RTypeFin) tys >>= mapM (λ v → forceBinary (typeResult (p2 v)) >>= (return ∘ (_,_ $ p1 v))) >>= λ tys' → (divideGoal (n , g₁ , g₂) tys' >>= assemble) >>= λ gs → return (zip gs tys') where assemble : {A : Set} → List (RTerm A) → Maybe (List (RBinApp A)) assemble (x1 ∷ x2 ∷ []) = just ((n , x1 , x2) ∷ []) assemble (x1 ∷ x2 ∷ l) = assemble (x2 ∷ l) >>= return ∘ (_∷_ (n , x1 , x2)) assemble _ = nothing Ag2RTypeFin* _ _ = nothing -- Produces a list of RWData, one for each 'guessed' step. make-RWData* : List Name → AgTerm → List (Arg AgType) → Err StratErr (List RWData) make-RWData* acts goal ctx with Ag2RTerm goal | map type acts | map (Ag2RType ∘ unarg) ctx ...| g' | tys | ctx' with Ag2RTypeFin* g' tys ...| nothing = throwError (Custom "Are you sure you can apply those steps?") ...| just r = i2 (map (λ x → rw-data (p1 x) (p1 (p2 x)) (p2 (p2 x)) ctx') r) postulate RW-error : ∀{a}{A : Set a} → String → A RWerr : Name → RWData → Err StratErr (RWData × UData × RTerm ⊥) RWerr act d = runUStrats d >>= λ u → runTStrats db d act u >>= λ v → return (d , u , v) -- A variant with less information, more suitable to be map'ed. RWerr-less : Name → RWData → Err StratErr (RTerm ⊥) RWerr-less act d = RWerr act d >>= return ∘ p2 ∘ p2 ---------------- -- By Tactics -- ---------------- -- Standard debugging version. by' : Name → List (Arg AgType) → AgTerm → (RWData × UData × RTerm ⊥) by' act ctx goal with runErr (make-RWData act goal ctx >>= RWerr act) ...| i1 err = RW-error err ...| i2 term = term -- This function is only beeing used to pass the context -- given by the 'tactic' keyword around. by : Name → List (Arg AgType) → AgTerm → AgTerm by act ctx goal = R2AgTerm ∘ p2 ∘ p2 $ (by' act ctx goal) -- Handling multiple actions, naive way. -- by+ is pretty much foldM (<|>) error (by ⋯), -- where (<|>) is the usual alternative from Error Monad. by+ : List Name → List (Arg AgType) → AgTerm → AgTerm by+ [] _ _ = RW-error "No suitable action" by+ (a ∷ as) ctx goal with runErr (make-RWData a goal ctx >>= RWerr a) ...| i1 _ = by+ as ctx goal ...| i2 t = R2AgTerm ∘ p2 ∘ p2 $ t join-tr : Name → List (RTerm ⊥) → RTerm ⊥ join-tr _ [] = ivar 0 join-tr tr (x ∷ l) = foldr (λ h r → rapp (rdef tr) (r ∷ h ∷ [])) x l -- Handling multiple goals. by*-err : Name → List Name → List (Arg AgType) → AgTerm → Err StratErr AgTerm by*-err tr acts ctx goal = make-RWData* acts goal ctx >>= λ l → mapM (uncurry RWerr-less) (zip acts l) >>= return ∘ R2AgTerm ∘ join-tr tr where unzip : {A B : Set} → List (A × B) → List A × List B unzip [] = [] , [] unzip ((a , b) ∷ l) with unzip l ...| la , lb = a ∷ la , b ∷ lb by*-tactic : Set by*-tactic = List Name → List (Arg AgType) → AgTerm → AgTerm by* : Name → by*-tactic by* tr acts ctx goal with runErr (by*-err tr acts ctx goal) ...| i1 err = RW-error err ...| i2 res = res ------------------------------ -- Adding Tries to the cake -- ------------------------------ -- The proper way to handle multiple actions. open import RW.Data.RTrie module Auto (bt : RTrie) -- which trie to use, (newHd : RTermName → RTermName) -- given the goal head, how to build the head for the action. where open import RW.Language.RTermTrie our-strategy : RTermName → Name → UData → Err StratErr (RTerm ⊥) our-strategy goal = maybe TStrat.how (const $ const $ i1 no-strat) $ filter-db db where no-strat : StratErr no-strat = NoTStrat goal (newHd goal) filter-db : TStratDB → Maybe TStrat filter-db [] = nothing filter-db (s ∷ ss) with TStrat.when s goal (newHd goal) ...| false = filter-db ss ...| true = just s auto-internal : List (Arg AgType) → AgTerm → Err StratErr AgTerm auto-internal _ goal with forceBinary $ Ag2RTerm goal ...| nothing = i1 $ Custom "non-binary goal" ...| just (hd , g₁ , g₂) = let options = search-action (newHd hd) (hd , g₁ , g₂) bt strat = uncurry $ our-strategy hd err = Custom "No option was succesful" in try-all strat err options >>= return ∘ R2AgTerm auto : List (Arg AgType) → AgTerm → AgTerm auto ctx goal with runErr (auto-internal ctx goal) ...| i1 err = RW-error err ...| i2 r = r
{ "alphanum_fraction": 0.5878220141, "avg_line_length": 36.3920454545, "ext": "agda", "hexsha": "50e8b091cc4666b4fb34c02034c931a032d8a1d5", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "2856afd12b7dbbcc908482975638d99220f38bf2", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "VictorCMiraldo/agda-rw", "max_forks_repo_path": "RW/RW.agda", "max_issues_count": 4, "max_issues_repo_head_hexsha": "2856afd12b7dbbcc908482975638d99220f38bf2", "max_issues_repo_issues_event_max_datetime": "2015-05-28T14:48:03.000Z", "max_issues_repo_issues_event_min_datetime": "2015-02-06T15:03:33.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "VictorCMiraldo/agda-rw", "max_issues_repo_path": "RW/RW.agda", "max_line_length": 103, "max_stars_count": 16, "max_stars_repo_head_hexsha": "2856afd12b7dbbcc908482975638d99220f38bf2", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "VictorCMiraldo/agda-rw", "max_stars_repo_path": "RW/RW.agda", "max_stars_repo_stars_event_max_datetime": "2019-10-24T17:38:20.000Z", "max_stars_repo_stars_event_min_datetime": "2015-02-09T15:43:38.000Z", "num_tokens": 2103, "size": 6405 }
{-# OPTIONS --cubical --safe #-} module Cardinality.Finite.SplitEnumerable.Inductive where open import Data.List public open import Data.List.Membership open import Prelude ℰ! : Type a → Type a ℰ! A = Σ[ xs ⦂ List A ] ((x : A) → x ∈ xs)
{ "alphanum_fraction": 0.6875, "avg_line_length": 21.8181818182, "ext": "agda", "hexsha": "77d18e9612791059b5215accfeb71844bb174a9f", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-01-05T14:05:30.000Z", "max_forks_repo_forks_event_min_datetime": "2021-01-05T14:05:30.000Z", "max_forks_repo_head_hexsha": "3c176d4690566d81611080e9378f5a178b39b851", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "oisdk/combinatorics-paper", "max_forks_repo_path": "agda/Cardinality/Finite/SplitEnumerable/Inductive.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "3c176d4690566d81611080e9378f5a178b39b851", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "oisdk/combinatorics-paper", "max_issues_repo_path": "agda/Cardinality/Finite/SplitEnumerable/Inductive.agda", "max_line_length": 57, "max_stars_count": 4, "max_stars_repo_head_hexsha": "3c176d4690566d81611080e9378f5a178b39b851", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "oisdk/combinatorics-paper", "max_stars_repo_path": "agda/Cardinality/Finite/SplitEnumerable/Inductive.agda", "max_stars_repo_stars_event_max_datetime": "2021-01-05T15:32:14.000Z", "max_stars_repo_stars_event_min_datetime": "2021-01-05T14:07:44.000Z", "num_tokens": 72, "size": 240 }
{-# OPTIONS --cubical --no-import-sorts --safe #-} open import Cubical.Core.Everything open import Cubical.Relation.Binary.Raw module Cubical.Relation.Binary.Reasoning.Equivalence {c ℓ} {A : Type c} (E : Equivalence A ℓ) where open Equivalence E ------------------------------------------------------------------------ -- Reasoning combinators open import Cubical.Relation.Binary.Reasoning.PartialEquivalence partialEquivalence public hiding (_∎⟨_⟩) open import Cubical.Relation.Binary.Reasoning.Base.Single _≈_ isPreorder public using (_∎)
{ "alphanum_fraction": 0.6727272727, "avg_line_length": 32.3529411765, "ext": "agda", "hexsha": "02460bd74a5aaa82cec19e7134e1199a9cb19cf0", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "737f922d925da0cd9a875cb0c97786179f1f4f61", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "bijan2005/univalent-foundations", "max_forks_repo_path": "Cubical/Relation/Binary/Reasoning/Equivalence.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "737f922d925da0cd9a875cb0c97786179f1f4f61", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "bijan2005/univalent-foundations", "max_issues_repo_path": "Cubical/Relation/Binary/Reasoning/Equivalence.agda", "max_line_length": 99, "max_stars_count": null, "max_stars_repo_head_hexsha": "737f922d925da0cd9a875cb0c97786179f1f4f61", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "bijan2005/univalent-foundations", "max_stars_repo_path": "Cubical/Relation/Binary/Reasoning/Equivalence.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 135, "size": 550 }
{-# OPTIONS --without-K #-} open import HoTT open import homotopy.OneSkeleton module homotopy.ConstantToSetFactorization {i j} {A : Type i} {B : Type j} (B-is-set : is-set B) (f : A → B) (f-is-const : ∀ a₁ a₂ → f a₁ == f a₂) where private Skel : Type i Skel = Trunc ⟨0⟩ (OneSkeleton f) abstract Skel-has-all-paths : has-all-paths Skel Skel-has-all-paths = Trunc-elim (λ _ → Π-is-set λ _ → =-preserves-set Trunc-level) (OneSkeleton-elim {P = λ s₁ → ∀ [s₂] → [ s₁ ] == [s₂]} (λ a₁ → Trunc-elim (λ _ → =-preserves-set Trunc-level) (OneSkeleton-elim {P = λ s₂ → [ point a₁ ] == [ s₂ ]} (λ a₂ → ap [_] $ link a₁ a₂ $ f-is-const a₁ a₂) (λ _ _ _ → prop-has-all-paths-↓ (Trunc-level {n = ⟨0⟩} _ _)))) (λ a₁ a₂ p → ↓-cst→app-in λ s₂ → prop-has-all-paths-↓ (Trunc-level {n = ⟨0⟩} _ _))) Skel-is-prop : is-prop Skel Skel-is-prop = all-paths-is-prop Skel-has-all-paths cst-extend : Trunc ⟨-1⟩ A → B cst-extend = Trunc-rec B-is-set OneSkeleton-lift ∘ Trunc-rec Skel-is-prop ([_] ∘ point) -- The beta rule. -- This is definitionally true, so you don't need it. cst-extend-β : cst-extend ∘ [_] == f cst-extend-β = idp
{ "alphanum_fraction": 0.5474509804, "avg_line_length": 34.4594594595, "ext": "agda", "hexsha": "82f0edb7353d162802e5e7753abd93521a02f6ec", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "1695a7f3dc60177457855ae846bbd86fcd96983e", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "danbornside/HoTT-Agda", "max_forks_repo_path": "homotopy/ConstantToSetFactorization.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "1695a7f3dc60177457855ae846bbd86fcd96983e", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "danbornside/HoTT-Agda", "max_issues_repo_path": "homotopy/ConstantToSetFactorization.agda", "max_line_length": 78, "max_stars_count": null, "max_stars_repo_head_hexsha": "1695a7f3dc60177457855ae846bbd86fcd96983e", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "danbornside/HoTT-Agda", "max_stars_repo_path": "homotopy/ConstantToSetFactorization.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 454, "size": 1275 }
{-# OPTIONS --safe #-} open import Definition.Typed.EqualityRelation module Definition.LogicalRelation.Substitution.Introductions.Id {{eqrel : EqRelSet}} where open EqRelSet {{...}} open import Definition.Untyped open import Definition.Untyped.Properties open import Definition.Typed open import Definition.Typed.Properties import Definition.Typed.Weakening as Twk open import Definition.Typed.EqualityRelation open import Definition.Typed.RedSteps open import Definition.LogicalRelation open import Definition.LogicalRelation.Properties.Escape open import Definition.LogicalRelation.Irrelevance open import Definition.LogicalRelation.ShapeView open import Definition.LogicalRelation.Properties open import Definition.LogicalRelation.Application open import Definition.LogicalRelation.Substitution import Definition.LogicalRelation.Weakening as Lwk open import Definition.LogicalRelation.Substitution.Properties import Definition.LogicalRelation.Substitution.Irrelevance as S open import Definition.LogicalRelation.Substitution.Reflexivity open import Definition.LogicalRelation.Substitution.Weakening -- open import Definition.LogicalRelation.Substitution.Introductions.Nat open import Definition.LogicalRelation.Substitution.Introductions.Empty open import Definition.LogicalRelation.Substitution.Introductions.Pi open import Definition.LogicalRelation.Substitution.Introductions.Idlemmas open import Definition.LogicalRelation.Substitution.Introductions.IdUniv open import Definition.LogicalRelation.Substitution.Introductions.IdNat open import Definition.LogicalRelation.Substitution.MaybeEmbed -- open import Definition.LogicalRelation.Substitution.Introductions.SingleSubst open import Definition.LogicalRelation.Substitution.Introductions.Universe open import Tools.Product open import Tools.Empty import Tools.Unit as TU import Tools.PropositionalEquality as PE import Data.Nat as Nat [Id] : ∀ {A t u Γ l lA} (⊢Γ : ⊢ Γ) ([A] : Γ ⊩⟨ l ⟩ A ^ [ ! , ι lA ]) ([t] : Γ ⊩⟨ l ⟩ t ∷ A ^ [ ! , ι lA ] / [A]) ([u] : Γ ⊩⟨ l ⟩ u ∷ A ^ [ ! , ι lA ] / [A]) → Γ ⊩⟨ l ⟩ Id A t u ^ [ % , ι lA ] [IdExt] : ∀ {A B t v u w Γ l l' lA} (⊢Γ : ⊢ Γ) ([A] : Γ ⊩⟨ l ⟩ A ^ [ ! , ι lA ]) ([B] : Γ ⊩⟨ l' ⟩ B ^ [ ! , ι lA ]) ([A≡B] : Γ ⊩⟨ l ⟩ A ≡ B ^ [ ! , ι lA ] / [A]) ([t] : Γ ⊩⟨ l ⟩ t ∷ A ^ [ ! , ι lA ] / [A]) ([v] : Γ ⊩⟨ l' ⟩ v ∷ B ^ [ ! , ι lA ] / [B]) ([t≡v] : Γ ⊩⟨ l ⟩ t ≡ v ∷ A ^ [ ! , ι lA ] / [A]) ([u] : Γ ⊩⟨ l ⟩ u ∷ A ^ [ ! , ι lA ] / [A]) ([w] : Γ ⊩⟨ l' ⟩ w ∷ B ^ [ ! , ι lA ] / [B]) ([u≡w] : Γ ⊩⟨ l ⟩ u ≡ w ∷ A ^ [ ! , ι lA ] / [A]) → Γ ⊩⟨ l ⟩ Id A t u ≡ Id B v w ^ [ % , ι lA ] / [Id] ⊢Γ [A] [t] [u] [IdExtShape] : ∀ {A B t v u w Γ l l' lA} (⊢Γ : ⊢ Γ) ([A] : Γ ⊩⟨ l ⟩ A ^ [ ! , ι lA ]) ([B] : Γ ⊩⟨ l' ⟩ B ^ [ ! , ι lA ]) (ShapeA : ShapeView Γ l l' A B [ ! , ι lA ] [ ! , ι lA ] [A] [B]) ([A≡B] : Γ ⊩⟨ l ⟩ A ≡ B ^ [ ! , ι lA ] / [A]) ([t] : Γ ⊩⟨ l ⟩ t ∷ A ^ [ ! , ι lA ] / [A]) ([v] : Γ ⊩⟨ l' ⟩ v ∷ B ^ [ ! , ι lA ] / [B]) ([t≡v] : Γ ⊩⟨ l ⟩ t ≡ v ∷ A ^ [ ! , ι lA ] / [A]) ([u] : Γ ⊩⟨ l ⟩ u ∷ A ^ [ ! , ι lA ] / [A]) ([w] : Γ ⊩⟨ l' ⟩ w ∷ B ^ [ ! , ι lA ] / [B]) ([u≡w] : Γ ⊩⟨ l ⟩ u ≡ w ∷ A ^ [ ! , ι lA ] / [A]) → Γ ⊩⟨ l ⟩ Id A t u ≡ Id B v w ^ [ % , ι lA ] / [Id] ⊢Γ [A] [t] [u] [Id] ⊢Γ (ℕᵣ [[ ⊢A , ⊢B , D ]]) [t] [u] = [Id]ℕGen ⊢Γ [[ ⊢A , ⊢B , D ]] [t] [u] [Id] ⊢Γ (Uᵣ (Uᵣ r ¹ l< () d)) [t] [u] [Id] {A} {t} {u} {Γ} {ι .¹} {.¹} ⊢Γ (Uᵣ (Uᵣ rU ⁰ emb< PE.refl [[ ⊢A , ⊢B , D ]])) [t] [u] = [Id]UGen {A} {t} {u} {Γ} ⊢Γ (Uᵣ rU ⁰ emb< PE.refl [[ ⊢A , ⊢B , D ]]) [t] [u] [Id] {A} {t} {u} {Γ} {l} {lA} ⊢Γ (ne′ K [[ ⊢A , ⊢B , D ]] neK K≡K) [t] [u] = let [A] = ne′ K [[ ⊢A , ⊢B , D ]] neK K≡K ⊢tA = escapeTerm {l = l} [A] [t] ⊢uA = escapeTerm {l = l} [A] [u] [K] = neu {l = l} neK ⊢B K≡K [A]′ , [A≡K] = redSubst* D [K] [t:K] = convTerm₁ [A]′ [K] [A≡K] (irrelevanceTerm [A] [A]′ [t]) [u:K] = convTerm₁ [A]′ [K] [A≡K] (irrelevanceTerm [A] [A]′ [u]) t≡t = escapeTermEq [K] (reflEqTerm [K] [t:K]) u≡u = escapeTermEq [K] (reflEqTerm [K] [u:K]) in ne′ (Id K t u) (redSProp (IdRed*Term ⊢tA ⊢uA [[ ⊢A , ⊢B , D ]])) (Idₙ neK) (~-Id K≡K t≡t u≡u) [Id] {A} {t} {u} {Γ} {l} {lA} ⊢Γ (Πᵣ′ rF lF lG lF≤ lG≤ F G [[ ⊢A , ⊢B , D ]] ⊢F ⊢G A≡A [F] [G] G-ext) (f , [[ ⊢t , ⊢f , Df ]] , funf , f≡f , [fext] , [f]) (g , [[ ⊢u , ⊢g , Dg ]] , fung , g≡g , [gext] , [g]) = let ⊢tA = conv ⊢t (sym (subset* D)) ⊢uA = conv ⊢u (sym (subset* D)) [F0] : Γ ⊩⟨ l ⟩ F ^ [ rF , ι lF ] [F0] = PE.subst (λ X → Γ ⊩⟨ l ⟩ X ^ [ rF , ι lF ]) (wk-id F) ([F] Twk.id ⊢Γ) ⊢idG : Γ ∙ F ^ [ rF , ι lF ] ⊢ Id G (wk1 t ∘ var 0 ^ lA) (wk1 u ∘ var 0 ^ lA) ^ [ % , ι lG ] ⊢idG = let ⊢t∘0 = PE.subst (λ X → _ ⊢ wk1 t ∘ var 0 ^ _ ∷ X ^ [ ! , ι lG ]) (wkSingleSubstId G) (Twk.wkTerm (Twk.step Twk.id) (⊢Γ ∙ ⊢F) ⊢t ∘ⱼ var (⊢Γ ∙ ⊢F) here) ⊢u∘0 = PE.subst (λ X → _ ⊢ wk1 u ∘ var 0 ^ _ ∷ X ^ [ ! , ι lG ]) (wkSingleSubstId G) (Twk.wkTerm (Twk.step Twk.id) (⊢Γ ∙ ⊢F) ⊢u ∘ⱼ var (⊢Γ ∙ ⊢F) here) in univ (Idⱼ (un-univ ⊢G) ⊢t∘0 ⊢u∘0) ⊢funext : Γ ⊢ Π F ^ rF ° lF ▹ (Id G ((wk1 t) ∘ (var 0) ^ lA) ((wk1 u) ∘ (var 0) ^ lA)) ° lG ° lA ^ [ % , ι lA ] ⊢funext = univ (Πⱼ lF≤ ▹ lG≤ ▹ un-univ ⊢F ▹ un-univ ⊢idG) Did : Γ ⊢ Id A t u ⇒* Π F ^ rF ° lF ▹ (Id G ((wk1 t) ∘ (var 0) ^ lA) ((wk1 u) ∘ (var 0) ^ lA)) ° lG ° lA ^ [ % , ι lA ] Did = IdRed* ⊢tA ⊢uA D ⇨* (univ (Id-Π lF≤ lG≤ (un-univ ⊢F) (un-univ ⊢G) ⊢t ⊢u) ⇨ id ⊢funext) [idG] : ∀ {ρ Δ a} → ([ρ] : Twk._∷_⊆_ ρ Δ Γ) → (⊢Δ : ⊢ Δ) → (Δ ⊩⟨ l ⟩ a ∷ wk ρ F ^ [ rF , ι lF ] / [F] [ρ] ⊢Δ) → Δ ⊩⟨ l ⟩ wk (lift ρ) (Id G (wk1 t ∘ var 0 ^ lA) (wk1 u ∘ var 0 ^ lA)) [ a ] ^ [ % , ι lG ] [idG] {ρ} {Δ} {a} [ρ] ⊢Δ [a] = let [t∘a] : Δ ⊩⟨ l ⟩ wk ρ t ∘ a ^ lA ∷ wk (lift ρ) G [ a ] ^ [ ! , ι lG ] / [G] [ρ] ⊢Δ [a] [t∘a] = proj₁ (redSubst*Term (appRed* (escapeTerm ([F] [ρ] ⊢Δ) [a]) (Twk.wkRed*Term [ρ] ⊢Δ Df)) ([G] [ρ] ⊢Δ [a]) ([f] [ρ] ⊢Δ [a])) [u∘a] : Δ ⊩⟨ l ⟩ wk ρ u ∘ a ^ lA ∷ wk (lift ρ) G [ a ] ^ [ ! , ι lG ] / [G] [ρ] ⊢Δ [a] [u∘a] = proj₁ (redSubst*Term (appRed* (escapeTerm ([F] [ρ] ⊢Δ) [a]) (Twk.wkRed*Term [ρ] ⊢Δ Dg)) ([G] [ρ] ⊢Δ [a]) ([g] [ρ] ⊢Δ [a])) [Id] : Δ ⊩⟨ l ⟩ (Id (wk (lift ρ) G [ a ]) (wk ρ t ∘ a ^ lA) (wk ρ u ∘ a ^ lA)) ^ [ % , ι lG ] [Id] = [Id] ⊢Δ ([G] [ρ] ⊢Δ [a]) [t∘a] [u∘a] in PE.subst₂ (λ X Y → Δ ⊩⟨ l ⟩ (Id _ (X ∘ a ^ lA) (Y ∘ a ^ lA)) ^ [ % , ι lG ]) (PE.sym (irrelevant-subst′ ρ t a)) (PE.sym (irrelevant-subst′ ρ u a)) [Id] [idG0] : Γ ∙ F ^ [ rF , ι lF ] ⊩⟨ l ⟩ (Id G (wk1 t ∘ var 0 ^ lA) (wk1 u ∘ var 0 ^ lA)) ^ [ % , ι lG ] [idG0] = PE.subst₃ (λ X Y Z → _ ⊩⟨ l ⟩ (Id X (Y ∘ var 0 ^ lA) (Z ∘ var 0 ^ lA)) ^ _) (wkSingleSubstId G) (wkSingleSubstId (wk1 t)) (wkSingleSubstId (wk1 u)) ([idG] {step id} {Γ ∙ F ^ [ rF , ι lF ]} {var 0} (Twk.step Twk.id) (⊢Γ ∙ ⊢F) (neuTerm ([F] (Twk.step Twk.id) (⊢Γ ∙ ⊢F)) (var 0) (var (⊢Γ ∙ ⊢F) here) (~-var (var (⊢Γ ∙ ⊢F) here)))) [idGext] : ∀ {ρ Δ a b} → ([ρ] : Twk._∷_⊆_ ρ Δ Γ) → (⊢Δ : ⊢ Δ) → ([a] : Δ ⊩⟨ l ⟩ a ∷ wk ρ F ^ [ rF , ι lF ] / [F] [ρ] ⊢Δ) → ([b] : Δ ⊩⟨ l ⟩ b ∷ wk ρ F ^ [ rF , ι lF ] / [F] [ρ] ⊢Δ) → ([a≡b] : Δ ⊩⟨ l ⟩ a ≡ b ∷ wk ρ F ^ [ rF , ι lF ] / [F] [ρ] ⊢Δ) → Δ ⊩⟨ l ⟩ wk (lift ρ) (Id G (wk1 t ∘ var 0 ^ lA) (wk1 u ∘ var 0 ^ lA)) [ a ] ≡ wk (lift ρ) (Id G (wk1 t ∘ var 0 ^ lA) (wk1 u ∘ var 0 ^ lA)) [ b ] ^ [ % , ι lG ] / [idG] [ρ] ⊢Δ [a] [idGext] {ρ} {Δ} {a} {b} [ρ] ⊢Δ [a] [b] [a≡b] = let [Ga] = [G] [ρ] ⊢Δ [a] [Gb] = [G] [ρ] ⊢Δ [b] [t∘a] , [ta≡fa] = redSubst*Term (appRed* (escapeTerm ([F] [ρ] ⊢Δ) [a]) (Twk.wkRed*Term [ρ] ⊢Δ Df)) [Ga] ([f] [ρ] ⊢Δ [a]) [u∘a] , [ua≡ga] = redSubst*Term (appRed* (escapeTerm ([F] [ρ] ⊢Δ) [a]) (Twk.wkRed*Term [ρ] ⊢Δ Dg)) [Ga] ([g] [ρ] ⊢Δ [a]) [Ga≡Gb] : Δ ⊩⟨ l ⟩ wk (lift ρ) G [ a ] ≡ wk (lift ρ) G [ b ] ^ [ ! , ι lG ] / [Ga] [Ga≡Gb] = G-ext [ρ] ⊢Δ [a] [b] [a≡b] [t∘b:Gb] , [tb≡fb:Gb] = redSubst*Term (appRed* (escapeTerm ([F] [ρ] ⊢Δ) [b]) (Twk.wkRed*Term [ρ] ⊢Δ Df)) [Gb] ([f] [ρ] ⊢Δ [b]) [t∘b] : Δ ⊩⟨ l ⟩ wk ρ t ∘ b ^ lA ∷ wk (lift ρ) G [ a ] ^ [ ! , ι lG ] / [Ga] [t∘b] = convTerm₂ [Ga] [Gb] [Ga≡Gb] [t∘b:Gb] [u∘b:Gb] , [ub≡gb:Gb] = redSubst*Term (appRed* (escapeTerm ([F] [ρ] ⊢Δ) [b]) (Twk.wkRed*Term [ρ] ⊢Δ Dg)) [Gb] ([g] [ρ] ⊢Δ [b]) [u∘b] : Δ ⊩⟨ l ⟩ wk ρ u ∘ b ^ lA ∷ wk (lift ρ) G [ a ] ^ [ ! , ι lG ] / [Ga] [u∘b] = convTerm₂ [Ga] [Gb] [Ga≡Gb] [u∘b:Gb] [ta≡tb] : Δ ⊩⟨ l ⟩ wk ρ t ∘ a ^ lA ≡ wk ρ t ∘ b ^ lA ∷ wk (lift ρ) G [ a ] ^ [ ! , ι lG ] / [Ga] [ta≡tb] = transEqTerm [Ga] (transEqTerm [Ga] [ta≡fa] ([fext] [ρ] ⊢Δ [a] [b] [a≡b])) (symEqTerm [Ga] (convEqTerm₂ [Ga] [Gb] [Ga≡Gb] [tb≡fb:Gb])) [ua≡ub] : Δ ⊩⟨ l ⟩ wk ρ u ∘ a ^ lA ≡ wk ρ u ∘ b ^ lA ∷ wk (lift ρ) G [ a ] ^ [ ! , ι lG ] / [Ga] [ua≡ub] = transEqTerm [Ga] (transEqTerm [Ga] [ua≡ga] ([gext] [ρ] ⊢Δ [a] [b] [a≡b])) (symEqTerm [Ga] (convEqTerm₂ [Ga] [Gb] [Ga≡Gb] [ub≡gb:Gb])) [IdExtG] : Δ ⊩⟨ l ⟩ (Id (wk (lift ρ) G [ a ]) (wk ρ t ∘ a ^ lA) (wk ρ u ∘ a ^ lA)) ≡ (Id (wk (lift ρ) G [ b ]) (wk ρ t ∘ b ^ lA) (wk ρ u ∘ b ^ lA)) ^ [ % , ι lG ] / [Id] ⊢Δ [Ga] [t∘a] [u∘a] [IdExtG] = [IdExt] ⊢Δ [Ga] [Gb] [Ga≡Gb] [t∘a] [t∘b:Gb] [ta≡tb] [u∘a] [u∘b:Gb] [ua≡ub] in irrelevanceEq″ (PE.cong₂ (λ X Y → Id _ (X ∘ a ^ lA) (Y ∘ a ^ lA)) (PE.sym (irrelevant-subst′ ρ t a)) (PE.sym (irrelevant-subst′ ρ u a))) (PE.cong₂ (λ X Y → Id _ (X ∘ b ^ lA) (Y ∘ b ^ lA)) (PE.sym (irrelevant-subst′ ρ t b)) (PE.sym (irrelevant-subst′ ρ u b))) PE.refl PE.refl ([Id] ⊢Δ [Ga] [t∘a] [u∘a]) ([idG] [ρ] ⊢Δ [a]) [IdExtG] in Πᵣ (Πᵣ rF lF lG lF≤ lG≤ F (Id G ((wk1 t) ∘ (var 0) ^ lA) ((wk1 u) ∘ (var 0) ^ lA)) [[ univ (Idⱼ (un-univ ⊢A) ⊢tA ⊢uA) , ⊢funext , Did ]] ⊢F ⊢idG (≅-univ (≅ₜ-Π-cong lF≤ lG≤ ⊢F (≅-un-univ (escapeEqRefl [F0])) (≅-un-univ (escapeEqRefl [idG0])))) [F] [idG] [idGext]) [Id] ⊢Γ (emb {l′ = ι ⁰} emb< [A]) [t] [u] = emb emb< ([Id] ⊢Γ [A] [t] [u]) [Id] ⊢Γ (emb {l′ = ι ¹} ∞< [A]) [t] [u] = emb ∞< ([Id] ⊢Γ [A] [t] [u]) [IdExtShape] {A} {B} {t} {v} {u} {w} {Γ} {.(ι ¹)} {.(ι ¹)} {lA} ⊢Γ (Uᵣ (Uᵣ rU ⁰ emb< PE.refl d)) (Uᵣ (Uᵣ r₁ ⁰ emb< PE.refl d₁)) (Uᵥ ._ ._) [A≡B] [t] [v] [t≡v] [u] [w] [u≡w] = [IdExt]UGen {A} {B} {t} {v} {u} {w} {Γ} ⊢Γ (Uᵣ rU ⁰ emb< PE.refl d) (Uᵣ r₁ ⁰ emb< PE.refl d₁) [A≡B] [t] [v] [t≡v] [u] [w] [u≡w] [IdExtShape] {A} {B} {t} {v} {u} {w} {Γ} {l} {l'} {lA} ⊢Γ (ne′ K [[ ⊢A , ⊢B , D ]] neK K≡K) (ne neB) (ne ._ .neB) (ne₌ M [[ ⊢A′ , ⊢B′ , D′ ]] neM K≡M) [t] [t′] [t≡t′] [u] [u′] [u≡u′] = let [A] = (ne′ K [[ ⊢A , ⊢B , D ]] neK K≡K) ⊢t′A′ = escapeTerm {l = l'} (ne neB) [t′] ⊢u′A′ = escapeTerm {l = l'} (ne neB) [u′] A≡K = subset* D t≡t′ : Γ ⊢ t ≅ v ∷ K ^ [ ! , ι lA ] t≡t′ = ≅-conv (escapeTermEq {l = l} [A] [t≡t′]) A≡K u≡u′ = ≅-conv (escapeTermEq {l = l} [A] [u≡u′]) A≡K in ne₌ (Id M v w) (univ:⇒*: (IdRed*Term ⊢t′A′ ⊢u′A′ [[ ⊢A′ , ⊢B′ , D′ ]])) (Idₙ neM) (~-Id K≡M t≡t′ u≡u′) [IdExtShape] {A} {B} {t} {v} {u} {w} {Γ} {l} {l'} ⊢Γ (ℕᵣ [[ ⊢A , ⊢B , D ]]) (ℕᵣ [[ ⊢A₁ , ⊢B₁ , D₁ ]]) (ℕᵥ ._ ._) [A≡B] [t] [v] [t≡v] [u] [w] [u≡w] = [IdExt]ℕGen {A} {B} {t} {v} {u} {w} {Γ} {l} {l'} ⊢Γ [[ ⊢A , ⊢B , D ]] [[ ⊢A₁ , ⊢B₁ , D₁ ]] [A≡B] [t] [v] [t≡v] [u] [w] [u≡w] [IdExtShape] {A} {A′} {t} {t′} {u} {u′} {Γ} {l} {l'} {lA} ⊢Γ (Πᵣ′ rF lF lG lF≤ lG≤ F G D ⊢F ⊢G A≡A [F] [G] G-ext) (Πᵣ′ rF′ lF′ lG′ lF≤′ lG≤′ F′ G′ [[ ⊢A′ , ⊢B′ , D′ ]] ⊢F′ ⊢G′ A′≡A′ [F′] [G′] G′-ext) (Πᵥ .(Πᵣ rF lF lG lF≤ lG≤ F G D ⊢F ⊢G A≡A [F] [G] G-ext) .(Πᵣ rF′ lF′ lG′ lF≤′ lG≤′ F′ G′ [[ ⊢A′ , ⊢B′ , D′ ]] ⊢F′ ⊢G′ A′≡A′ [F′] [G′] G′-ext)) (Π₌ F′₀ G′₀ D′₀ A≡B [F≡F′₀] [G≡G′₀]) [t] [t′] (f₀ , f′₀ , [[ ⊢t , ⊢f₀ , Df₀ ]] , [[ ⊢t′ , ⊢f′₀ , Df′₀ ]] , funf₀ , funf′₀ , f₀≡f′₀ , [t]′ , [t′]′ , [f₀≡f′₀]) [u] [u′] (g₀ , g′₀ , [[ ⊢u , ⊢g₀ , Dg₀ ]] , [[ ⊢u′ , ⊢g′₀ , Dg′₀ ]] , fung₀ , fung′₀ , g₀≡g′₀ , [u]′ , [u′]′ , [g₀≡g′₀]) = let F′≡F′₀ , rF′≡rF , lF′≡lF , G′≡G′₀ , lG′≡lG , _ = Π-PE-injectivity (whrDet* (D′ , Whnf.Πₙ) (D′₀ , Whnf.Πₙ)) [F≡F′] = PE.subst (λ X → ∀ {ρ} {Δ} ([ρ] : ρ Twk.∷ Δ ⊆ Γ) → (⊢Δ : ⊢ Δ) → Δ ⊩⟨ l ⟩ wk ρ F ≡ wk ρ X ^ [ rF , _ ] / [F] [ρ] ⊢Δ) (PE.sym F′≡F′₀) [F≡F′₀] [G≡G′] = PE.subst (λ X → ∀ {ρ} {Δ} {a} ([ρ] : ρ Twk.∷ Δ ⊆ Γ) → (⊢Δ : ⊢ Δ) → ([a] : _) → Δ ⊩⟨ l ⟩ wk (lift ρ) G [ a ] ≡ wk (lift ρ) X [ a ] ^ [ _ , _ ] / [G] [ρ] ⊢Δ [a]) (PE.sym G′≡G′₀) [G≡G′₀] f , [[ ⊢t , _ , Df ]] , funf , _ , _ , [f] = [t] f₀≡f = whrDet*Term (Df₀ , functionWhnf funf₀) (Df , functionWhnf funf) f′ , [[ ⊢t′ , _ , Df′ ]] , funf′ , _ , _ , [f′] = [t′] f′₀≡f′ = whrDet*Term (Df′₀ , functionWhnf funf′₀) (Df′ , functionWhnf funf′) g , [[ ⊢u , _ , Dg ]] , fung , _ , _ , [g] = [u] g₀≡g = whrDet*Term (Dg₀ , functionWhnf fung₀) (Dg , functionWhnf fung) g′ , [[ ⊢u′ , _ , Dg′ ]] , fung′ , _ , _ , [g′] = [u′] g′₀≡g′ = whrDet*Term (Dg′₀ , functionWhnf fung′₀) (Dg′ , functionWhnf fung′) [text] = λ {ρ} {Δ} {a} ([ρ] : ρ Twk.∷ Δ ⊆ Γ) (⊢Δ : ⊢ Δ) ([a] : Δ ⊩⟨ l ⟩ a ∷ wk ρ F ^ [ rF , ι lF ] / [F] [ρ] ⊢Δ) → redSubst*Term (appRed* (escapeTerm ([F] [ρ] ⊢Δ) [a]) (Twk.wkRed*Term [ρ] ⊢Δ Df)) ([G] [ρ] ⊢Δ [a]) ([f] [ρ] ⊢Δ [a]) [t′ext] = λ {ρ} {Δ} {a} ([ρ] : ρ Twk.∷ Δ ⊆ Γ) (⊢Δ : ⊢ Δ) ([a] : Δ ⊩⟨ l' ⟩ a ∷ wk ρ F′ ^ [ rF′ , ι lF′ ] / [F′] [ρ] ⊢Δ) → redSubst*Term (appRed* (escapeTerm ([F′] [ρ] ⊢Δ) [a]) (Twk.wkRed*Term [ρ] ⊢Δ Df′)) ([G′] [ρ] ⊢Δ [a]) ([f′] [ρ] ⊢Δ [a]) [uext] = λ {ρ} {Δ} {a} ([ρ] : ρ Twk.∷ Δ ⊆ Γ) (⊢Δ : ⊢ Δ) ([a] : Δ ⊩⟨ l ⟩ a ∷ wk ρ F ^ [ rF , ι lF ] / [F] [ρ] ⊢Δ) → redSubst*Term (appRed* (escapeTerm ([F] [ρ] ⊢Δ) [a]) (Twk.wkRed*Term [ρ] ⊢Δ Dg)) ([G] [ρ] ⊢Δ [a]) ([g] [ρ] ⊢Δ [a]) [u′ext] = λ {ρ} {Δ} {a} ([ρ] : ρ Twk.∷ Δ ⊆ Γ) (⊢Δ : ⊢ Δ) ([a] : Δ ⊩⟨ l' ⟩ a ∷ wk ρ F′ ^ [ rF′ , ι lF′ ] / [F′] [ρ] ⊢Δ) → redSubst*Term (appRed* (escapeTerm ([F′] [ρ] ⊢Δ) [a]) (Twk.wkRed*Term [ρ] ⊢Δ Dg′)) ([G′] [ρ] ⊢Δ [a]) ([g′] [ρ] ⊢Δ [a]) [idG] = λ {ρ} {Δ} {a} ([ρ] : ρ Twk.∷ Δ ⊆ Γ) (⊢Δ : ⊢ Δ) ([a] : Δ ⊩⟨ l ⟩ a ∷ wk ρ F ^ [ rF , ι lF ] / [F] [ρ] ⊢Δ) → PE.subst₂ (λ X Y → Δ ⊩⟨ l ⟩ Id (subst (sgSubst a) (wk (lift ρ) G)) (X ∘ a ^ lA) (Y ∘ a ^ lA) ^ [ % , ι lG ]) (PE.sym (irrelevant-subst′ ρ t a)) (PE.sym (irrelevant-subst′ ρ u a)) ([Id] ⊢Δ ([G] [ρ] ⊢Δ [a]) (proj₁ ([text] [ρ] ⊢Δ [a])) (proj₁ ([uext] [ρ] ⊢Δ [a]))) [idG≡idG′] : ∀ {ρ Δ a} → ([ρ] : Twk._∷_⊆_ ρ Δ Γ) → (⊢Δ : ⊢ Δ) → ([a] : Δ ⊩⟨ l ⟩ a ∷ wk ρ F ^ [ rF , ι lF ] / [F] [ρ] ⊢Δ) → Δ ⊩⟨ l ⟩ wk (lift ρ) (Id G (wk1 t ∘ var 0 ^ lA) (wk1 u ∘ var 0 ^ lA)) [ a ] ≡ wk (lift ρ) (Id G′ (wk1 t′ ∘ var 0 ^ lA) (wk1 u′ ∘ var 0 ^ lA)) [ a ] ^ [ % , ι lG ] / [idG] [ρ] ⊢Δ [a] [idG≡idG′] {ρ} {Δ} {a} [ρ] ⊢Δ [a] = let [aF′] = convTerm₁′ (PE.sym rF′≡rF) (PE.cong ι (PE.sym lF′≡lF)) ([F] [ρ] ⊢Δ) ([F′] [ρ] ⊢Δ) ([F≡F′] [ρ] ⊢Δ) [a] [Ga] = [G] [ρ] ⊢Δ [a] [G′a] = [G′] [ρ] ⊢Δ [aF′] [Ga≡G′a] : Δ ⊩⟨ l ⟩ wk (lift ρ) G [ a ] ≡ wk (lift ρ) G′ [ a ] ^ [ ! , ι lG ] / [Ga] [Ga≡G′a] = [G≡G′] [ρ] ⊢Δ [a] [t∘a] , [ta≡fa] = [text] [ρ] ⊢Δ [a] [t′∘a] , [t′a≡f′a] = [t′ext] [ρ] ⊢Δ [aF′] [fa≡f′a] = PE.subst₂ (λ X Y → Δ ⊩⟨ l ⟩ wk ρ X ∘ a ^ lA ≡ wk ρ Y ∘ a ^ lA ∷ wk (lift ρ) G [ a ] ^ [ ! , ι lG ] / [Ga]) f₀≡f f′₀≡f′ ([f₀≡f′₀] [ρ] ⊢Δ [a]) [ta≡t′a] : Δ ⊩⟨ l ⟩ wk ρ t ∘ a ^ lA ≡ wk ρ t′ ∘ a ^ lA ∷ wk (lift ρ) G [ a ] ^ [ ! , ι lG ] / [Ga] [ta≡t′a] = transEqTerm [Ga] (transEqTerm [Ga] [ta≡fa] [fa≡f′a]) (symEqTerm [Ga] (convEqTerm₂′ PE.refl (PE.cong ι (PE.sym lG′≡lG)) [Ga] [G′a] [Ga≡G′a] [t′a≡f′a])) [u∘a] , [ua≡ga] = [uext] [ρ] ⊢Δ [a] [u′∘a] , [u′a≡g′a] = [u′ext] [ρ] ⊢Δ [aF′] [ga≡g′a] = PE.subst₂ (λ X Y → Δ ⊩⟨ l ⟩ wk ρ X ∘ a ^ lA ≡ wk ρ Y ∘ a ^ lA ∷ wk (lift ρ) G [ a ] ^ [ ! , ι lG ] / [Ga]) g₀≡g g′₀≡g′ ([g₀≡g′₀] [ρ] ⊢Δ [a]) [ua≡u′a] : Δ ⊩⟨ l ⟩ wk ρ u ∘ a ^ lA ≡ wk ρ u′ ∘ a ^ lA ∷ wk (lift ρ) G [ a ] ^ [ ! , ι lG ] / [Ga] [ua≡u′a] = transEqTerm [Ga] (transEqTerm [Ga] [ua≡ga] [ga≡g′a]) (symEqTerm [Ga] (convEqTerm₂′ PE.refl (PE.cong ι (PE.sym lG′≡lG)) [Ga] [G′a] [Ga≡G′a] [u′a≡g′a])) [G′a]′ = irrelevance′′ PE.refl PE.refl (PE.cong ι lG′≡lG) [G′a] [t′∘a]′ = irrelevanceTerm′ PE.refl PE.refl (PE.cong ι lG′≡lG) [G′a] [G′a]′ [t′∘a] [u′∘a]′ = irrelevanceTerm′ PE.refl PE.refl (PE.cong ι lG′≡lG) [G′a] [G′a]′ [u′∘a] [idG≡idG′]′ : Δ ⊩⟨ l ⟩ Id (wk (lift ρ) G [ a ]) (wk ρ t ∘ a ^ lA) (wk ρ u ∘ a ^ lA) ≡ Id (wk (lift ρ) G′ [ a ]) (wk ρ t′ ∘ a ^ lA) (wk ρ u′ ∘ a ^ lA) ^ [ % , ι lG ] / [Id] ⊢Δ [Ga] [t∘a] [u∘a] [idG≡idG′]′ = [IdExt] ⊢Δ [Ga] [G′a]′ [Ga≡G′a] [t∘a] [t′∘a]′ [ta≡t′a] [u∘a] [u′∘a]′ [ua≡u′a] in irrelevanceEq″ (PE.cong₂ (λ X Y → Id (wk (lift ρ) G [ a ]) (X ∘ a ^ lA) (Y ∘ a ^ lA)) (PE.sym (irrelevant-subst′ ρ t a)) (PE.sym (irrelevant-subst′ ρ u a))) (PE.cong₂ (λ X Y → Id (wk (lift ρ) G′ [ a ]) (X ∘ a ^ lA) (Y ∘ a ^ lA)) (PE.sym (irrelevant-subst′ ρ t′ a)) (PE.sym (irrelevant-subst′ ρ u′ a))) PE.refl PE.refl ([Id] ⊢Δ [Ga] [t∘a] [u∘a]) ([idG] [ρ] ⊢Δ [a]) [idG≡idG′]′ [var0] = neuTerm ([F] (Twk.step Twk.id) (⊢Γ ∙ ⊢F)) (var 0) (var (⊢Γ ∙ ⊢F) here) (~-var (var (⊢Γ ∙ ⊢F) here)) ⊢idG≡idG′₀ : Γ ∙ F ^ [ rF , ι lF ] ⊢ (Id G (wk1 t ∘ var 0 ^ lA) (wk1 u ∘ var 0 ^ lA)) ≅ (Id G′ (wk1 t′ ∘ var 0 ^ lA) (wk1 u′ ∘ var 0 ^ lA)) ^ [ % , ι lG ] ⊢idG≡idG′₀ = PE.subst₃ (λ X Y Z → _ ⊢ (Id X (Y ∘ var 0 ^ lA) (Z ∘ var 0 ^ lA)) ≅ _ ^ _) (wkSingleSubstId G) (wkSingleSubstId (wk1 t)) (wkSingleSubstId (wk1 u)) (PE.subst₃ (λ X Y Z → _ ⊢ _ ≅ (Id X (Y ∘ var 0 ^ lA) (Z ∘ var 0 ^ lA)) ^ _) (wkSingleSubstId G′) (wkSingleSubstId (wk1 t′)) (wkSingleSubstId (wk1 u′)) (escapeEq ([idG] (Twk.step Twk.id) (⊢Γ ∙ ⊢F) [var0]) ([idG≡idG′] {step id} {Γ ∙ F ^ [ rF , ι lF ]} {var 0} (Twk.step Twk.id) (⊢Γ ∙ ⊢F) [var0]))) ⊢F≡F′ = PE.subst₂ (λ X Y → _ ⊢ X ≅ Y ^ _) (wk-id F) (PE.trans (wk-id F′₀) (PE.sym F′≡F′₀)) (escapeEq ([F] Twk.id ⊢Γ) ([F≡F′₀] Twk.id ⊢Γ)) [A′] = (Πᵣ′ rF′ lF′ lG′ lF≤′ lG≤′ F′ G′ [[ ⊢A′ , ⊢B′ , D′ ]] ⊢F′ ⊢G′ A′≡A′ [F′] [G′] G′-ext) ⊢t′A′ = escapeTerm {l = l'} [A′] [t′] ⊢u′A′ = escapeTerm {l = l'} [A′] [u′] ⊢t′∘a = PE.subst (λ X → _ ⊢ wk1 t′ ∘ var 0 ^ lA ∷ X ^ [ ! , ι lG′ ]) (wkSingleSubstId G′) (Twk.wkTerm (Twk.step Twk.id) (⊢Γ ∙ ⊢F′) ⊢t′ ∘ⱼ var (⊢Γ ∙ ⊢F′) here) ⊢u′∘a = PE.subst (λ X → _ ⊢ wk1 u′ ∘ var 0 ^ lA ∷ X ^ [ ! , ι lG′ ]) (wkSingleSubstId G′) (Twk.wkTerm (Twk.step Twk.id) (⊢Γ ∙ ⊢F′) ⊢u′ ∘ⱼ var (⊢Γ ∙ ⊢F′) here) ⊢funext′ : Γ ⊢ Π F′ ^ rF′ ° lF′ ▹ Id G′ (wk1 t′ ∘ var 0 ^ lA) (wk1 u′ ∘ var 0 ^ lA) ° lG′ ° lA ^ [ % , ι lA ] ⊢funext′ = univ (Πⱼ lF≤′ ▹ lG≤′ ▹ un-univ ⊢F′ ▹ Idⱼ (un-univ ⊢G′) ⊢t′∘a ⊢u′∘a) Did : Γ ⊢ Id A′ t′ u′ ⇒* Π F′ ^ rF′ ° lF′ ▹ (Id G′ ((wk1 t′) ∘ (var 0) ^ lA) ((wk1 u′) ∘ (var 0) ^ lA)) ° lG′ ° lA ^ [ % , ι lA ] Did = IdRed* ⊢t′A′ ⊢u′A′ D′ ⇨* ((univ (Id-Π lF≤′ lG≤′ (un-univ ⊢F′) (un-univ ⊢G′) ⊢t′ ⊢u′)) ⇨ id ⊢funext′) in Π₌ F′ (Id G′ ((wk1 t′) ∘ (var 0) ^ lA) ((wk1 u′) ∘ (var 0) ^ lA)) (PE.subst (λ X → Γ ⊢ Id A′ t′ u′ ⇒* Π F′ ^ rF ° lF ▹ _ ° X ° lA ^ [ % , ι lA ]) lG′≡lG (PE.subst (λ X → Γ ⊢ Id A′ t′ u′ ⇒* Π F′ ^ rF ° X ▹ _ ° lG′ ° lA ^ [ % , ι lA ]) lF′≡lF (PE.subst (λ X → Γ ⊢ Id A′ t′ u′ ⇒* Π F′ ^ X ° lF′ ▹ _ ° lG′ ° lA ^ [ % , ι lA ]) rF′≡rF Did))) (≅-univ (≅ₜ-Π-cong lF≤ lG≤ ⊢F (≅-un-univ ⊢F≡F′) (≅-un-univ ⊢idG≡idG′₀))) [F≡F′] [idG≡idG′] [IdExtShape] {A} {B} {t} {t′} {u} {u′} {Γ} ⊢Γ (emb emb< [A]) [B] (emb⁰¹ {p = .[A]} ShapeA) [A≡B] [t] [v] [t≡v] [u] [w] [u≡w] = [IdExtShape] ⊢Γ [A] [B] ShapeA [A≡B] [t] [v] [t≡v] [u] [w] [u≡w] [IdExtShape] {A} {B} {t} {t′} {u} {u′} {Γ} ⊢Γ [A] (emb emb< [B]) (emb¹⁰ {q = .[B]} ShapeA) [A≡B] [t] [v] [t≡v] [u] [w] [u≡w] = [IdExtShape] ⊢Γ [A] [B] ShapeA [A≡B] [t] [v] [t≡v] [u] [w] [u≡w] [IdExtShape] {A} {B} {t} {t′} {u} {u′} {Γ} ⊢Γ (emb ∞< [A]) [B] (emb¹∞ {p = .[A]} ShapeA) [A≡B] [t] [v] [t≡v] [u] [w] [u≡w] = [IdExtShape] ⊢Γ [A] [B] ShapeA [A≡B] [t] [v] [t≡v] [u] [w] [u≡w] [IdExtShape] {A} {B} {t} {t′} {u} {u′} {Γ} ⊢Γ [A] (emb ∞< [B]) (emb∞¹ {q = .[B]} ShapeA) [A≡B] [t] [v] [t≡v] [u] [w] [u≡w] = [IdExtShape] ⊢Γ [A] [B] ShapeA [A≡B] [t] [v] [t≡v] [u] [w] [u≡w] [IdExt] {A} {A′} {t} {t′} {u} {u′} {Γ} ⊢Γ [A] [A′] [A≡A′] [t] [t′] [t≡t′] [u] [u′] [u≡u′] = [IdExtShape] {A} {A′} {t} {t′} {u} {u′} {Γ} ⊢Γ [A] [A′] (goodCases [A] [A′] [A≡A′]) [A≡A′] [t] [t′] [t≡t′] [u] [u′] [u≡u′] Idᵛ-min : ∀ {A t u Γ l} ([Γ] : ⊩ᵛ Γ) ([A] : Γ ⊩ᵛ⟨ ι l ⟩ A ^ [ ! , ι l ] / [Γ]) ([t] : Γ ⊩ᵛ⟨ ι l ⟩ t ∷ A ^ [ ! , ι l ] / [Γ] / [A]) ([u] : Γ ⊩ᵛ⟨ ι l ⟩ u ∷ A ^ [ ! , ι l ] / [Γ] / [A]) → Γ ⊩ᵛ⟨ ι l ⟩ Id A t u ^ [ % , ι l ] / [Γ] Idᵛ-min [Γ] [A] [t] [u] ⊢Δ [σ] = ([Id] ⊢Δ (proj₁ ([A] ⊢Δ [σ])) (proj₁ ([t] ⊢Δ [σ])) (proj₁ ([u] ⊢Δ [σ]))) , (λ [σ′] [σ≡σ′] → [IdExt] ⊢Δ (proj₁ ([A] ⊢Δ [σ])) (proj₁ ([A] ⊢Δ [σ′])) (proj₂ ([A] ⊢Δ [σ]) [σ′] [σ≡σ′]) (proj₁ ([t] ⊢Δ [σ])) (proj₁ ([t] ⊢Δ [σ′])) (proj₂ ([t] ⊢Δ [σ]) [σ′] [σ≡σ′]) (proj₁ ([u] ⊢Δ [σ])) (proj₁ ([u] ⊢Δ [σ′])) (proj₂ ([u] ⊢Δ [σ]) [σ′] [σ≡σ′])) Idᵛ : ∀ {A t u Γ l} ([Γ] : ⊩ᵛ Γ) ([A] : Γ ⊩ᵛ⟨ ∞ ⟩ A ^ [ ! , ι l ] / [Γ]) ([t] : Γ ⊩ᵛ⟨ ∞ ⟩ t ∷ A ^ [ ! , ι l ] / [Γ] / [A]) ([u] : Γ ⊩ᵛ⟨ ∞ ⟩ u ∷ A ^ [ ! , ι l ] / [Γ] / [A]) → Γ ⊩ᵛ⟨ ∞ ⟩ Id A t u ^ [ % , ι l ] / [Γ] Idᵛ [Γ] [A] [t] [u] ⊢Δ [σ] = ([Id] ⊢Δ (proj₁ ([A] ⊢Δ [σ])) (proj₁ ([t] ⊢Δ [σ])) (proj₁ ([u] ⊢Δ [σ]))) , (λ [σ′] [σ≡σ′] → [IdExt] ⊢Δ (proj₁ ([A] ⊢Δ [σ])) (proj₁ ([A] ⊢Δ [σ′])) (proj₂ ([A] ⊢Δ [σ]) [σ′] [σ≡σ′]) (proj₁ ([t] ⊢Δ [σ])) (proj₁ ([t] ⊢Δ [σ′])) (proj₂ ([t] ⊢Δ [σ]) [σ′] [σ≡σ′]) (proj₁ ([u] ⊢Δ [σ])) (proj₁ ([u] ⊢Δ [σ′])) (proj₂ ([u] ⊢Δ [σ]) [σ′] [σ≡σ′])) Idᵗᵛ-min : ∀ {A t u Γ l} ([Γ] : ⊩ᵛ Γ) ([A] : Γ ⊩ᵛ⟨ ι l ⟩ A ^ [ ! , ι l ] / [Γ]) ([t] : Γ ⊩ᵛ⟨ ι l ⟩ t ∷ A ^ [ ! , ι l ] / [Γ] / [A]) ([u] : Γ ⊩ᵛ⟨ ι l ⟩ u ∷ A ^ [ ! , ι l ] / [Γ] / [A]) → Γ ⊩ᵛ⟨ next l ⟩ Id A t u ∷ SProp l ^ [ ! , next l ] / [Γ] / Uᵛgen (≡is≤ PE.refl) <next [Γ] Idᵗᵛ-min {A} {t} {u} {_} {l} [Γ] [A] [t] [u] = let [U] = Uᵛgen (≡is≤ PE.refl) <next [Γ] in un-univᵛ {A = Id A t u} [Γ] [U] (Idᵛ-min {A} {t} {u} [Γ] [A] [t] [u]) Idᵗᵛ : ∀ {A t u Γ l} ([Γ] : ⊩ᵛ Γ) → let [UA] = maybeEmbᵛ {A = U _} [Γ] (Uᵛ <next [Γ]) [U] = maybeEmbᵛ {A = SProp _} [Γ] (Uᵛ <next [Γ]) in ([A] : Γ ⊩ᵛ⟨ ∞ ⟩ A ^ [ ! , ι l ] / [Γ]) ([t] : Γ ⊩ᵛ⟨ ∞ ⟩ t ∷ A ^ [ ! , ι l ] / [Γ] / [A]) ([u] : Γ ⊩ᵛ⟨ ∞ ⟩ u ∷ A ^ [ ! , ι l ] / [Γ] / [A]) ([A]t : Γ ⊩ᵛ⟨ ∞ ⟩ A ∷ Univ ! l ^ [ ! , next l ] / [Γ] / [UA]) → Γ ⊩ᵛ⟨ ∞ ⟩ Id A t u ∷ SProp l ^ [ ! , next l ] / [Γ] / [U] Idᵗᵛ {A} {t} {u} {_} {l} [Γ] [A] [t] [u] [A]t = let [UA] = maybeEmbᵛ {A = U _} [Γ] (Uᵛ <next [Γ]) [A]' = univᵛ {A = A} [Γ] (≡is≤ PE.refl) [UA] [A]t [t]' = S.irrelevanceTerm {A = A} {t = t} [Γ] [Γ] [A] [A]' [t] [u]' = S.irrelevanceTerm {A = A} {t = u} [Γ] [Γ] [A] [A]' [u] [Id] = Idᵗᵛ-min {A} {t} {u} [Γ] [A]' [t]' [u]' in maybeEmbTermᵛ {l = next l} {A = SProp _} {t = Id A t u} [Γ] (Uᵛgen (≡is≤ PE.refl) <next [Γ]) [Id] Id-congᵛ-min : ∀ {A A' t t' u u' Γ l} ([Γ] : ⊩ᵛ Γ) ([A] : Γ ⊩ᵛ⟨ ι l ⟩ A ^ [ ! , ι l ] / [Γ]) ([t] : Γ ⊩ᵛ⟨ ι l ⟩ t ∷ A ^ [ ! , ι l ] / [Γ] / [A]) ([u] : Γ ⊩ᵛ⟨ ι l ⟩ u ∷ A ^ [ ! , ι l ] / [Γ] / [A]) ([A'] : Γ ⊩ᵛ⟨ ι l ⟩ A' ^ [ ! , ι l ] / [Γ]) ([t'] : Γ ⊩ᵛ⟨ ι l ⟩ t' ∷ A' ^ [ ! , ι l ] / [Γ] / [A']) ([u'] : Γ ⊩ᵛ⟨ ι l ⟩ u' ∷ A' ^ [ ! , ι l ] / [Γ] / [A']) ([A≡A'] : Γ ⊩ᵛ⟨ ι l ⟩ A ≡ A' ^ [ ! , ι l ] / [Γ] / [A]) ([t≡t'] : Γ ⊩ᵛ⟨ ι l ⟩ t ≡ t' ∷ A ^ [ ! , ι l ] / [Γ] / [A]) ([u≡u'] : Γ ⊩ᵛ⟨ ι l ⟩ u ≡ u' ∷ A ^ [ ! , ι l ] / [Γ] / [A]) → Γ ⊩ᵛ⟨ ι l ⟩ Id A t u ≡ Id A' t' u' ^ [ % , ι l ] / [Γ] / Idᵛ-min {A} {t} {u} [Γ] [A] [t] [u] Id-congᵛ-min [Γ] [A] [t] [u] [A'] [t'] [u'] [A≡A'] [t≡t'] [u≡u'] ⊢Δ [σ] = [IdExt] ⊢Δ (proj₁ ([A] ⊢Δ [σ])) (proj₁ ([A'] ⊢Δ [σ])) ([A≡A'] ⊢Δ [σ]) (proj₁ ([t] ⊢Δ [σ])) (proj₁ ([t'] ⊢Δ [σ])) ([t≡t'] ⊢Δ [σ]) (proj₁ ([u] ⊢Δ [σ])) (proj₁ ([u'] ⊢Δ [σ])) ([u≡u'] ⊢Δ [σ]) Id-cong-minᵗᵛ : ∀ {A A' t t' u u' Γ l} ([Γ] : ⊩ᵛ Γ) ([A] : Γ ⊩ᵛ⟨ ι l ⟩ A ^ [ ! , ι l ] / [Γ]) ([t] : Γ ⊩ᵛ⟨ ι l ⟩ t ∷ A ^ [ ! , ι l ] / [Γ] / [A]) ([u] : Γ ⊩ᵛ⟨ ι l ⟩ u ∷ A ^ [ ! , ι l ] / [Γ] / [A]) ([A'] : Γ ⊩ᵛ⟨ ι l ⟩ A' ^ [ ! , ι l ] / [Γ]) ([t'] : Γ ⊩ᵛ⟨ ι l ⟩ t' ∷ A' ^ [ ! , ι l ] / [Γ] / [A']) ([u'] : Γ ⊩ᵛ⟨ ι l ⟩ u' ∷ A' ^ [ ! , ι l ] / [Γ] / [A']) ([A≡A'] : Γ ⊩ᵛ⟨ ι l ⟩ A ≡ A' ^ [ ! , ι l ] / [Γ] / [A]) ([t≡t'] : Γ ⊩ᵛ⟨ ι l ⟩ t ≡ t' ∷ A ^ [ ! , ι l ] / [Γ] / [A]) ([u≡u'] : Γ ⊩ᵛ⟨ ι l ⟩ u ≡ u' ∷ A ^ [ ! , ι l ] / [Γ] / [A]) → Γ ⊩ᵛ⟨ next l ⟩ Id A t u ≡ Id A' t' u' ∷ SProp l ^ [ ! , next l ] / [Γ] / Uᵛgen (≡is≤ PE.refl) <next [Γ] Id-cong-minᵗᵛ {A} {A'} {t} {t'} {u} {u'} [Γ] [A] [t] [u] [A'] [t'] [u'] [A≡A'] [t≡t'] [u≡u'] = let [U] = Uᵛgen (≡is≤ PE.refl) <next [Γ] in un-univEqᵛ {A = Id A t u} {B = Id A' t' u'} [Γ] [U] (Idᵛ-min {A} {t} {u} [Γ] [A] [t] [u]) (Idᵛ-min {A'} {t'} {u'} [Γ] [A'] [t'] [u']) (Id-congᵛ-min {A} {A'} {t} {t'} {u} {u'} [Γ] [A] [t] [u] [A'] [t'] [u'] [A≡A'] [t≡t'] [u≡u']) Id-congᵗᵛ : ∀ {A A' t t' u u' Γ l} ([Γ] : ⊩ᵛ Γ) → let [UA] = maybeEmbᵛ {A = U _} [Γ] (Uᵛ <next [Γ]) [U] = maybeEmbᵛ {A = SProp _} [Γ] (Uᵛ <next [Γ]) in ([A] : Γ ⊩ᵛ⟨ ∞ ⟩ A ^ [ ! , ι l ] / [Γ]) ([t] : Γ ⊩ᵛ⟨ ∞ ⟩ t ∷ A ^ [ ! , ι l ] / [Γ] / [A]) ([u] : Γ ⊩ᵛ⟨ ∞ ⟩ u ∷ A ^ [ ! , ι l ] / [Γ] / [A]) ([A]t : Γ ⊩ᵛ⟨ ∞ ⟩ A ∷ Univ ! l ^ [ ! , next l ] / [Γ] / [UA]) ([A'] : Γ ⊩ᵛ⟨ ∞ ⟩ A' ^ [ ! , ι l ] / [Γ]) ([t'] : Γ ⊩ᵛ⟨ ∞ ⟩ t' ∷ A' ^ [ ! , ι l ] / [Γ] / [A']) ([u'] : Γ ⊩ᵛ⟨ ∞ ⟩ u' ∷ A' ^ [ ! , ι l ] / [Γ] / [A']) ([A']t : Γ ⊩ᵛ⟨ ∞ ⟩ A' ∷ Univ ! l ^ [ ! , next l ] / [Γ] / [UA]) ([A≡A']t : Γ ⊩ᵛ⟨ ∞ ⟩ A ≡ A' ∷ Univ ! l ^ [ ! , next l ] / [Γ] / [UA]) ([t≡t'] : Γ ⊩ᵛ⟨ ∞ ⟩ t ≡ t' ∷ A ^ [ ! , ι l ] / [Γ] / [A]) ([u≡u'] : Γ ⊩ᵛ⟨ ∞ ⟩ u ≡ u' ∷ A ^ [ ! , ι l ] / [Γ] / [A]) → Γ ⊩ᵛ⟨ ∞ ⟩ Id A t u ≡ Id A' t' u' ∷ SProp l ^ [ ! , next l ] / [Γ] / [U] Id-congᵗᵛ {A} {A'} {t} {t'} {u} {u'} {_} {l} [Γ] [A] [t] [u] [A]t [A'] [t'] [u'] [A']t [A≡A']t [t≡t'] [u≡u'] = let [UA] = maybeEmbᵛ {A = U _} [Γ] (Uᵛ <next [Γ]) [A]' = univᵛ {A = A} [Γ] (≡is≤ PE.refl) [UA] [A]t [t]' = S.irrelevanceTerm {A = A} {t = t} [Γ] [Γ] [A] [A]' [t] [u]' = S.irrelevanceTerm {A = A} {t = u} [Γ] [Γ] [A] [A]' [u] [A']' = univᵛ {A = A'} [Γ] (≡is≤ PE.refl) [UA] [A']t [t']' = S.irrelevanceTerm {A = A'} {t = t'} [Γ] [Γ] [A'] [A']' [t'] [u']' = S.irrelevanceTerm {A = A'} {t = u'} [Γ] [Γ] [A'] [A']' [u'] [A≡A']' = univEqᵛ {A = A} {B = A'} [Γ] [UA] [A]' [A≡A']t [t≡t']' = S.irrelevanceEqTerm {A = A} {t = t} {u = t'} [Γ] [Γ] [A] [A]' [t≡t'] [u≡u']' = S.irrelevanceEqTerm {A = A} {t = u} {u = u'} [Γ] [Γ] [A] [A]' [u≡u'] [Id] = Id-cong-minᵗᵛ {A} {A'} {t} {t'} {u} {u'} [Γ] [A]' [t]' [u]' [A']' [t']' [u']' [A≡A']' [t≡t']' [u≡u']' in maybeEmbEqTermᵛ {l = next l} {A = SProp _} {t = Id A t u} {u = Id A' t' u'} [Γ] (Uᵛgen (≡is≤ PE.refl) <next [Γ]) [Id]
{ "alphanum_fraction": 0.3870142965, "avg_line_length": 62.2623318386, "ext": "agda", "hexsha": "fa855ccbf44b99bae097d41cd1d8e5a8a3fe3113", "lang": "Agda", "max_forks_count": 2, "max_forks_repo_forks_event_max_datetime": "2022-02-15T19:42:19.000Z", "max_forks_repo_forks_event_min_datetime": "2022-01-26T14:55:51.000Z", "max_forks_repo_head_hexsha": "e0eeebc4aa5ed791ce3e7c0dc9531bd113dfcc04", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "CoqHott/logrel-mltt", "max_forks_repo_path": "Definition/LogicalRelation/Substitution/Introductions/Id.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "e0eeebc4aa5ed791ce3e7c0dc9531bd113dfcc04", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "CoqHott/logrel-mltt", "max_issues_repo_path": "Definition/LogicalRelation/Substitution/Introductions/Id.agda", "max_line_length": 199, "max_stars_count": 2, "max_stars_repo_head_hexsha": "e0eeebc4aa5ed791ce3e7c0dc9531bd113dfcc04", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "CoqHott/logrel-mltt", "max_stars_repo_path": "Definition/LogicalRelation/Substitution/Introductions/Id.agda", "max_stars_repo_stars_event_max_datetime": "2022-01-17T16:13:53.000Z", "max_stars_repo_stars_event_min_datetime": "2018-06-21T08:39:01.000Z", "num_tokens": 16313, "size": 27769 }
{-# OPTIONS --cubical --safe #-} open import Algebra module Control.Monad.Weighted {ℓ} (rng : Semiring ℓ) where open import Control.Monad.Weighted.Definition rng public open import Control.Monad.Weighted.Union rng using (_∪_) public open import Control.Monad.Weighted.Cond rng using (_⋊_) public open import Control.Monad.Weighted.Monad rng using (_>>=_; pure; _>>_; _<*>_) public import Control.Monad.Weighted.Expect using (∫) module Expect = Control.Monad.Weighted.Expect rng
{ "alphanum_fraction": 0.7334669339, "avg_line_length": 33.2666666667, "ext": "agda", "hexsha": "8148512d1a4d118ccae1433bdde1a7a539d75dfe", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-11T12:30:21.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-11T12:30:21.000Z", "max_forks_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "oisdk/agda-playground", "max_forks_repo_path": "Control/Monad/Weighted.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "oisdk/agda-playground", "max_issues_repo_path": "Control/Monad/Weighted.agda", "max_line_length": 89, "max_stars_count": 6, "max_stars_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "oisdk/agda-playground", "max_stars_repo_path": "Control/Monad/Weighted.agda", "max_stars_repo_stars_event_max_datetime": "2021-11-16T08:11:34.000Z", "max_stars_repo_stars_event_min_datetime": "2020-09-11T17:45:41.000Z", "num_tokens": 122, "size": 499 }
{-# OPTIONS --without-K --rewriting #-} open import HoTT module homotopy.TruncationLoopLadder where ⊙Ω-Trunc : ∀ {i} {n : ℕ₋₂} (X : Ptd i) → ⊙Ω (⊙Trunc (S n) X) ⊙≃ ⊙Trunc n (⊙Ω X) ⊙Ω-Trunc X = ≃-to-⊙≃ (Trunc=-equiv [ pt X ] [ pt X ]) idp step : ∀ {i j} n {X : Ptd i} {Y : Ptd j} (f : X ⊙→ Y) → ⊙CommSquareEquiv (⊙Ω-fmap (⊙Trunc-fmap {n = S n} f)) (⊙Trunc-fmap {n = n} (⊙Ω-fmap f)) (⊙–> (⊙Ω-Trunc X)) (⊙–> (⊙Ω-Trunc Y)) step n (f , idp) = ⊙comm-sqr (Trunc=-equiv-nat _ _ _ , idp) , snd (⊙Ω-Trunc _) , snd (⊙Ω-Trunc _) rail : ∀ m {i} (X : Ptd i) → ⊙Ω^' m (⊙Trunc ⟨ m ⟩ X) ⊙→ ⊙Trunc 0 (⊙Ω^' m X) rail O X = ⊙idf _ rail (S m) X = rail m (⊙Ω X) ⊙∘ ⊙Ω^'-fmap m (⊙–> (⊙Ω-Trunc X)) ladder : ∀ {i j} m {X : Ptd i} {Y : Ptd j} (f : X ⊙→ Y) → ⊙CommSquareEquiv (⊙Ω^'-fmap m (⊙Trunc-fmap {n = ⟨ m ⟩} f)) (⊙Trunc-fmap {n = 0} (⊙Ω^'-fmap m f)) (rail m X) (rail m Y) ladder O f = ⊙comm-sqr (⊙∘-unit-l _) , idf-is-equiv _ , idf-is-equiv _ ladder (S m) f = ⊙CommSquareEquiv-∘v (ladder m (⊙Ω-fmap f)) (⊙Ω^'-csemap m (step ⟨ m ⟩ f))
{ "alphanum_fraction": 0.463176575, "avg_line_length": 33.1470588235, "ext": "agda", "hexsha": "7dbbcd3deb641808892e0950655facb4c970fe68", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "timjb/HoTT-Agda", "max_forks_repo_path": "theorems/homotopy/TruncationLoopLadder.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "timjb/HoTT-Agda", "max_issues_repo_path": "theorems/homotopy/TruncationLoopLadder.agda", "max_line_length": 82, "max_stars_count": null, "max_stars_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "timjb/HoTT-Agda", "max_stars_repo_path": "theorems/homotopy/TruncationLoopLadder.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 608, "size": 1127 }
open import Relation.Binary.PropositionalEquality using (_≡_; refl; sym; cong; cong₂) open import Data.Nat using (ℕ; zero; suc; _≤_; z≤n; s≤s) open import Data.Nat.Properties using (≤-total) open import Data.Fin using (Fin; zero; suc) open import Data.Product using (∃; ∃-syntax; _×_; _,_) open import Data.Sum using ([_,_]) open import DeBruijn open import Substitution using (rename-subst-commute; subst-commute; extensionality) open import Beta open import BetaSubstitutivity using (sub-betas) open import Takahashi infix 8 _*⁽_⁾ _*⁽_⁾ : ∀ {n} → Term n → ℕ → Term n M *⁽ zero ⁾ = M M *⁽ suc k ⁾ = (M *) *⁽ k ⁾ data _—↠⁽_⁾_ : ∀ {n} → Term n → ℕ → Term n → Set where _∎ : ∀ {n} (M : Term n) -------------- → M —↠⁽ zero ⁾ M _—→⁽⁾⟨_⟩_ : ∀ {n} {N L : Term n} {k : ℕ} (M : Term n) → M —→ L → L —↠⁽ k ⁾ N --------------- → M —↠⁽ suc k ⁾ N lemma3-2 : ∀ {n} {M : Term n} → M —↠ M * lemma3-2 {M = # x} = # x ∎ lemma3-2 {M = ƛ _} = —↠-cong-ƛ lemma3-2 lemma3-2 {M = # _ · _} = —↠-congᵣ lemma3-2 lemma3-2 {M = _ · _ · _} = —↠-cong lemma3-2 lemma3-2 lemma3-2 {M = (ƛ M) · N} = (ƛ M) · N —→⟨ —→-β ⟩ sub-betas {M = M} lemma3-2 lemma3-2 lemma3-3 : ∀ {n} {M N : Term n} → M —→ N -------- → N —↠ M * lemma3-3 {M = # _} () lemma3-3 {M = ƛ M} (—→-ƛ M—→M′) = —↠-cong-ƛ (lemma3-3 M—→M′) lemma3-3 {M = # _ · N} (—→-ξᵣ N—→N′) = —↠-congᵣ (lemma3-3 N—→N′) lemma3-3 {M = _ · _ · N} (—→-ξᵣ N—→N′) = —↠-cong lemma3-2 (lemma3-3 N—→N′) lemma3-3 {M = M₁ · M₂ · _} (—→-ξₗ M—↠M′) = —↠-cong (lemma3-3 M—↠M′) lemma3-2 lemma3-3 {M = (ƛ M) · N} —→-β = sub-betas {M = M} lemma3-2 lemma3-2 lemma3-3 {M = (ƛ M) · N} (—→-ξᵣ {N′ = N′} N—→N′) = (ƛ M ) · N′ —→⟨ —→-β ⟩ sub-betas {M = M} lemma3-2 (lemma3-3 N—→N′) lemma3-3 {M = (ƛ M) · N} (—→-ξₗ (—→-ƛ {M′ = M′} M—→M′)) = (ƛ M′) · N —→⟨ —→-β ⟩ sub-betas {N = N} (lemma3-3 M—→M′) lemma3-2 _*ˢ : ∀ {n m} → Subst n m → Subst n m σ *ˢ = λ x → (σ x) * rename-* : ∀ {n m} (ρ : Rename n m) (M : Term n) → rename ρ (M *) ≡ (rename ρ M) * rename-* ρ (# _) = refl rename-* ρ (ƛ M) = cong ƛ_ (rename-* (ext ρ) M) rename-* ρ (# _ · N) = cong₂ _·_ refl (rename-* ρ N) rename-* ρ (M₁ · M₂ · N) = cong₂ _·_ (rename-* ρ (M₁ · M₂)) (rename-* ρ N) rename-* ρ ((ƛ M) · N) rewrite sym (rename-subst-commute {N = M *}{M = N *}{ρ = ρ}) | rename-* (ext ρ) M | rename-* ρ N = refl exts-ts-commute : ∀ {n m} (σ : Subst n m) → exts (σ *ˢ) ≡ (exts σ) *ˢ exts-ts-commute {n} σ = extensionality exts-ts-commute′ where exts-ts-commute′ : (x : Fin (suc n)) → (exts (σ *ˢ)) x ≡ ((exts σ) *ˢ) x exts-ts-commute′ zero = refl exts-ts-commute′ (suc x) = rename-* suc (σ x) app-*-join : ∀ {n} (M N : Term n) → M * · N * —↠ (M · N) * app-*-join (# x) N = # x · N * ∎ app-*-join (ƛ M) N = (ƛ M *) · N * —→⟨ —→-β ⟩ subst (subst-zero (N *)) (M *) ∎ app-*-join (M₁ · M₂) N = (M₁ · M₂) * · N * ∎ subst-ts : ∀ {n m} (σ : Subst n m) (M : Term n) → subst (σ *ˢ) (M *) —↠ (subst σ M) * subst-ts σ (# x) = σ x * ∎ subst-ts σ (ƛ M) rewrite exts-ts-commute σ = —↠-cong-ƛ (subst-ts (exts σ) M) subst-ts σ (# x · N) = —↠-trans (—↠-congᵣ (subst-ts σ N)) (app-*-join (σ x) (subst σ N)) subst-ts σ (M₁ · M₂ · N) = —↠-cong (subst-ts σ (M₁ · M₂)) (subst-ts σ N) subst-ts σ ((ƛ M) · N) rewrite sym (subst-commute {N = M *}{M = N *}{σ = σ *ˢ}) | exts-ts-commute σ = sub-betas (subst-ts (exts σ) M) (subst-ts σ N) subst-zero-ts : ∀ {n} {N : Term n} → subst-zero (N *) ≡ (subst-zero N) *ˢ subst-zero-ts = extensionality (λ { zero → refl ; (suc x) → refl }) lemma3-4 : ∀ {n} (M : Term (suc n)) (N : Term n) → M * [ N * ] —↠ (M [ N ]) * lemma3-4 M N rewrite subst-zero-ts {N = N} = subst-ts (subst-zero N) M lemma3-5 : ∀ {n} {M N : Term n} → M —→ N ---------- → M * —↠ N * lemma3-5 {M = # x} () lemma3-5 {M = ƛ M} (—→-ƛ M—→M′) = —↠-cong-ƛ (lemma3-5 M—→M′) lemma3-5 {M = # _ · N} (—→-ξᵣ M₂—→M′) = —↠-congᵣ (lemma3-5 M₂—→M′) lemma3-5 {M = (ƛ M) · N} —→-β = lemma3-4 M N lemma3-5 {M = (ƛ M) · N} (—→-ξₗ (—→-ƛ M—→M′)) = sub-betas (lemma3-5 M—→M′) (N * ∎) lemma3-5 {M = (ƛ M) · N} (—→-ξᵣ N—→N′) = sub-betas (M * ∎) (lemma3-5 N—→N′) lemma3-5 {M = M₁ · M₂ · _} (—→-ξᵣ N—→N′) = —↠-congᵣ (lemma3-5 N—→N′) lemma3-5 {M = M₁ · M₂ · _} (—→-ξₗ {M′ = # x} M₁M₂—→#x) = —↠-congₗ (lemma3-5 M₁M₂—→#x) lemma3-5 {M = M₁ · M₂ · _} (—→-ξₗ {M′ = M′₁ · M′₂} M₁M₂—→M′₁M′₂) = —↠-congₗ (lemma3-5 M₁M₂—→M′₁M′₂) lemma3-5 {M = M₁ · M₂ · N} (—→-ξₗ {M′ = ƛ M′} M₁M₂—→ƛM′) = —↠-trans (—↠-congₗ (lemma3-5 M₁M₂—→ƛM′)) ((ƛ M′ *) · N * —→⟨ —→-β ⟩ subst (subst-zero (N *)) (M′ *) ∎) corollary3-6 : ∀ {n} {M N : Term n} → M —↠ N ---------- → M * —↠ N * corollary3-6 (M ∎) = M * ∎ corollary3-6 (M —→⟨ M—→L ⟩ L—↠N) = —↠-trans (lemma3-5 M—→L) (corollary3-6 L—↠N) corollary3-7 : ∀ {n} {M N : Term n} (m : ℕ) → M —↠ N -------------------- → M *⁽ m ⁾ —↠ N *⁽ m ⁾ corollary3-7 zero M—↠N = M—↠N corollary3-7 (suc m) M—↠N = corollary3-7 m (corollary3-6 M—↠N) theorem3-8 : ∀ {n} {M N : Term n} {m : ℕ} → M —↠⁽ m ⁾ N ------------- → N —↠ M *⁽ m ⁾ theorem3-8 {m = zero} (M ∎) = M ∎ theorem3-8 {m = suc m} (M —→⁽⁾⟨ M—→L ⟩ L—↠ᵐN) = —↠-trans (theorem3-8 L—↠ᵐN) (corollary3-7 m (lemma3-3 M—→L)) unnamed-named : ∀ {n} {M N : Term n} → M —↠ N -------------------- → ∃[ m ] (M —↠⁽ m ⁾ N) unnamed-named (M ∎) = zero , (M ∎) unnamed-named (M —→⟨ M—→L ⟩ L—↠N) with unnamed-named L—↠N ... | m′ , L—↠ᵐ′N = suc m′ , (M —→⁽⁾⟨ M—→L ⟩ L—↠ᵐ′N) lift-* : ∀ {n} (M : Term n) (m : ℕ) → M —↠ M *⁽ m ⁾ lift-* M zero = M ∎ lift-* M (suc m) = —↠-trans lemma3-2 (lift-* (M *) m) complete-* : ∀ {k} (M : Term k) {n m : ℕ} → n ≤ m -------------------- → M *⁽ n ⁾ —↠ M *⁽ m ⁾ complete-* M {m = m} z≤n = lift-* M m complete-* M (s≤s k) = complete-* (M *) k theorem3-9 : ∀ {n} {M A B : Term n} → M —↠ A → M —↠ B ------------------------ → ∃[ N ] (A —↠ N × B —↠ N) theorem3-9 {M = M} M—↠A M—↠B = let n , M—↠ⁿA = unnamed-named M—↠A m , M—↠ᵐB = unnamed-named M—↠B A—↠M*ⁿ = theorem3-8 M—↠ⁿA B—↠M*ᵐ = theorem3-8 M—↠ᵐB in [ (λ n≤m → let M*ⁿ—↠M*ᵐ : M *⁽ n ⁾ —↠ M *⁽ m ⁾ M*ⁿ—↠M*ᵐ = complete-* M n≤m in M *⁽ m ⁾ , —↠-trans A—↠M*ⁿ M*ⁿ—↠M*ᵐ , B—↠M*ᵐ) , (λ m≤n → let M*ᵐ—↠M*ⁿ : M *⁽ m ⁾ —↠ M *⁽ n ⁾ M*ᵐ—↠M*ⁿ = complete-* M m≤n in M *⁽ n ⁾ , A—↠M*ⁿ , —↠-trans B—↠M*ᵐ M*ᵐ—↠M*ⁿ) ] (≤-total n m)
{ "alphanum_fraction": 0.4220884124, "avg_line_length": 34.5634517766, "ext": "agda", "hexsha": "20d7acbde7557038e8bb6ea8dc641ce98c193eae", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "2fa17f7738cc7da967375be928137adc4be38696", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "iwilare/church-rosser", "max_forks_repo_path": "ConfluenceTakahashi.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "2fa17f7738cc7da967375be928137adc4be38696", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "iwilare/church-rosser", "max_issues_repo_path": "ConfluenceTakahashi.agda", "max_line_length": 126, "max_stars_count": 5, "max_stars_repo_head_hexsha": "2fa17f7738cc7da967375be928137adc4be38696", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "iwilare/church-rosser", "max_stars_repo_path": "ConfluenceTakahashi.agda", "max_stars_repo_stars_event_max_datetime": "2021-11-22T01:43:09.000Z", "max_stars_repo_stars_event_min_datetime": "2020-06-02T07:27:54.000Z", "num_tokens": 3462, "size": 6809 }
{-# OPTIONS --without-K --rewriting #-} open import HoTT module groups.Image where module _ {i j k} {G : Group i} {H : Group j} {K : Group k} (φ : H →ᴳ K) (ψ : G →ᴳ H) where abstract im-sub-im-∘ : is-surjᴳ ψ → im-propᴳ φ ⊆ᴳ im-propᴳ (φ ∘ᴳ ψ) im-sub-im-∘ ψ-is-surj k = Trunc-rec Trunc-level (λ{(h , φh=k) → Trunc-rec Trunc-level (λ{(g , ψg=h) → [ g , ap (GroupHom.f φ) ψg=h ∙ φh=k ]}) (ψ-is-surj h)}) im-∘-sub-im : im-propᴳ (φ ∘ᴳ ψ) ⊆ᴳ im-propᴳ φ im-∘-sub-im k = Trunc-rec Trunc-level (λ{(g , φψg=k) → [ GroupHom.f ψ g , φψg=k ]}) im-iso-im-pre∘ : is-surjᴳ ψ → Im φ ≃ᴳ Im (φ ∘ᴳ ψ) im-iso-im-pre∘ ψ-is-surj = Subgroup-emap-r (im-propᴳ φ) (im-propᴳ (φ ∘ᴳ ψ)) (im-sub-im-∘ ψ-is-surj) im-∘-sub-im
{ "alphanum_fraction": 0.5316622691, "avg_line_length": 30.32, "ext": "agda", "hexsha": "702b0d307be35589dc1dd33b48e3f9a0a82b4813", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2018-12-26T21:31:57.000Z", "max_forks_repo_forks_event_min_datetime": "2018-12-26T21:31:57.000Z", "max_forks_repo_head_hexsha": "e7d663b63d89f380ab772ecb8d51c38c26952dbb", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "mikeshulman/HoTT-Agda", "max_forks_repo_path": "theorems/groups/Image.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "e7d663b63d89f380ab772ecb8d51c38c26952dbb", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "mikeshulman/HoTT-Agda", "max_issues_repo_path": "theorems/groups/Image.agda", "max_line_length": 63, "max_stars_count": null, "max_stars_repo_head_hexsha": "e7d663b63d89f380ab772ecb8d51c38c26952dbb", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "mikeshulman/HoTT-Agda", "max_stars_repo_path": "theorems/groups/Image.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 380, "size": 758 }
{-# OPTIONS --allow-unsolved-metas #-} open import Everything module Test.ProblemWithLevelZero where module _ (𝔓 : Ø₀) where open Substitunction 𝔓 open Term 𝔓 fails : ∀ {m n} (f : Substitunction m n) → Substitunction m n fails f = transitivity f ε -- FIXME refl-works : ∀ {m} → Substitunction m m refl-works = ε solution-1o solution-1a solution-2o solution-2a : ∀ {m n} (f : Substitunction m n) → Substitunction m n solution-1o f = transitivity {𝔒 = ¶} f ε solution-1a f = transitivity[ Substitunction ] f ε solution-2o f = transitivity {𝔒 = Ø₀} f ε solution-2a f = transitivity[ Function ] f ε transitivity-hole : ∀ {m n} (f : Substitunction m n) → Substitunction m n transitivity-hole f = transitivity ⦃ {!!!} -- FIXME does not resolve instance ⦄ f {!!}
{ "alphanum_fraction": 0.6460606061, "avg_line_length": 25, "ext": "agda", "hexsha": "eee2062f07f14c1f6e72c316a221b5d9634a7b49", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_forks_repo_licenses": [ "RSA-MD" ], "max_forks_repo_name": "m0davis/oscar", "max_forks_repo_path": "archive/agda-3/src/Test/ProblemWithLevelZero.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_issues_repo_issues_event_max_datetime": "2019-05-11T23:33:04.000Z", "max_issues_repo_issues_event_min_datetime": "2019-04-29T00:35:04.000Z", "max_issues_repo_licenses": [ "RSA-MD" ], "max_issues_repo_name": "m0davis/oscar", "max_issues_repo_path": "archive/agda-3/src/Test/ProblemWithLevelZero.agda", "max_line_length": 75, "max_stars_count": null, "max_stars_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_stars_repo_licenses": [ "RSA-MD" ], "max_stars_repo_name": "m0davis/oscar", "max_stars_repo_path": "archive/agda-3/src/Test/ProblemWithLevelZero.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 281, "size": 825 }
{-# OPTIONS --safe #-} module Cubical.HITs.Bouquet where open import Cubical.HITs.Bouquet.Base public open import Cubical.HITs.Bouquet.FundamentalGroupProof public
{ "alphanum_fraction": 0.8012048193, "avg_line_length": 23.7142857143, "ext": "agda", "hexsha": "c1427eb4c5aed0e1dabe0de2c4feae968cd36681", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "thomas-lamiaux/cubical", "max_forks_repo_path": "Cubical/HITs/Bouquet.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "thomas-lamiaux/cubical", "max_issues_repo_path": "Cubical/HITs/Bouquet.agda", "max_line_length": 61, "max_stars_count": 1, "max_stars_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "thomas-lamiaux/cubical", "max_stars_repo_path": "Cubical/HITs/Bouquet.agda", "max_stars_repo_stars_event_max_datetime": "2021-10-31T17:32:49.000Z", "max_stars_repo_stars_event_min_datetime": "2021-10-31T17:32:49.000Z", "num_tokens": 46, "size": 166 }
module Issue224 where data Maybe (A : Set) : Set where nothing : Maybe A just : A → Maybe A data D (A : Set) : Maybe A → Set where d₁ : (x : A) → D A (just x) d₂ : ∀ {x} → D A x → D A x data S : ∀ {A x} → D A x → Set₁ where s : ∀ {A x} {d : D A x} → S d → S (d₂ d) foo : {A : Set} → S (d₂ (d₁ (nothing {A}))) → Set₁ foo (s _) = Set -- Bug.agda:19,6-9 -- Panic: Pattern match failure in do expression at -- src/full/Agda/TypeChecking/Rules/LHS/Unify.hs:331:2-5 -- when checking that the pattern s _ has type S (d₂ (d₁ nothing))
{ "alphanum_fraction": 0.5714285714, "avg_line_length": 24.8181818182, "ext": "agda", "hexsha": "761a3d31e239bab6d41b92c028d462e29e28e2f6", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cruhland/agda", "max_forks_repo_path": "test/Succeed/Issue224.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "cruhland/agda", "max_issues_repo_path": "test/Succeed/Issue224.agda", "max_line_length": 66, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/Succeed/Issue224.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 218, "size": 546 }
module Issue133 where data Nat : Set where zz : Nat ss : Nat → Nat data _==_ {X : Set}(x : X) : X → Set where refl : x == x data Zero : Set where data Eq? (x : Nat) : Nat → Set where same : Eq? x x diff : {y : Nat} → (x == y → Zero) → Eq? x y -- This failed before due to absurd lambda checking not getting -- postponed. ioo : {y : Nat} → Eq? zz (ss y) ioo {y} = diff λ () foo : {y : Nat} → zz == ss y → Zero foo () goo : {y : Nat} → zz == ss y → Zero goo = λ () hoo : {y : Nat}{X : Set} → ((zz == ss y → Zero) → X) → X hoo boo = boo λ ()
{ "alphanum_fraction": 0.5205724508, "avg_line_length": 18.0322580645, "ext": "agda", "hexsha": "1c2f030b97274f8c50775b169eba2f6f1df89364", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cruhland/agda", "max_forks_repo_path": "test/Succeed/Issue133.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "cruhland/agda", "max_issues_repo_path": "test/Succeed/Issue133.agda", "max_line_length": 63, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/Succeed/Issue133.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 210, "size": 559 }
-- Andreas, 2017-01-18, issue #2408 -- DLubs were not serialized, thus, there was a problem with -- level dependent on irrelevant values. {-# OPTIONS --show-irrelevant #-} -- {-# OPTIONS -v tc:70 #-} open import Agda.Primitive postulate A : Set l : .(a : A) → Level F : .(a : A) → Set (l a) -- checked type signature -- F : .(a : A) → Set (l a) -- of sort dLub Set (λ a → Set (lsuc (l a)))
{ "alphanum_fraction": 0.5872235872, "avg_line_length": 20.35, "ext": "agda", "hexsha": "8fa7466973f3df97d172f9d4a7959ebfa35d926f", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_path": "test/Succeed/Issue2408.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "shlevy/agda", "max_issues_repo_path": "test/Succeed/Issue2408.agda", "max_line_length": 60, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "test/Succeed/Issue2408.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 140, "size": 407 }
{-# OPTIONS --without-K #-} module hott.functions where open import hott.core.universe open import hott.core.equality -- Composition of functions. _∘_ : ∀ {ℓ₀ ℓ₁ ℓ₂ : Level} → {A : Type ℓ₀} {B : Type ℓ₁} {C : Type ℓ₂} → (B → C) → (A → B) → A → C f ∘ g = λ x → f (g x) -- The identity function. id : ∀{ℓ} {A : Type ℓ} → A → A id x = x -- Change the order of arguments in a bivariate function. flip : {a b c : Level}{A : Type a}{B : Type b}{C : Type c} → (A → B → C) → (B → A → C) flip f b a = f a b -- We want compostion to have very high precedence. infixr 100 _∘_ -- The constant function. constant : ∀ {ℓ₀ ℓ₁}{A : Type ℓ₀}{B : Type ℓ₁} → A → B → A constant a b = a -- Alternate syntax for dependent function type. Π : ∀{ℓ₀ ℓ₁}{A : Type ℓ₀}(B : A → Type ℓ₁) → Type (ℓ₀ ⊔ ℓ₁) Π {_}{_}{A} B = (a : A) → B(a) -- One should use f ~ g to mean that f and g are homotopic. _~_ : ∀{ℓ₀ ℓ₁}{A : Type ℓ₀}{B : Type ℓ₁} (f g : A → B) → Type (ℓ₁ ⊔ ℓ₀) f ~ g = Π λ x → f x ≡ g x infixr 1 _~_
{ "alphanum_fraction": 0.5608782435, "avg_line_length": 26.3684210526, "ext": "agda", "hexsha": "48b72ee03e36c26b43bc08ffae3a1899d0a0385b", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "876ecdcfddca1abf499e8f00db321c6dc3d5b2bc", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "piyush-kurur/hott", "max_forks_repo_path": "agda/hott/functions.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "876ecdcfddca1abf499e8f00db321c6dc3d5b2bc", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "piyush-kurur/hott", "max_issues_repo_path": "agda/hott/functions.agda", "max_line_length": 73, "max_stars_count": null, "max_stars_repo_head_hexsha": "876ecdcfddca1abf499e8f00db321c6dc3d5b2bc", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "piyush-kurur/hott", "max_stars_repo_path": "agda/hott/functions.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 418, "size": 1002 }
-- Non-indexed (plain) monads in form of Kleisli triple, presented in point-free style. module Control.Monad.KleisliTriple where open import Function using (id) renaming (_∘′_ to _∘_) open import Relation.Binary.PropositionalEquality open ≡-Reasoning open import Axiom.FunctionExtensionality open import Control.Functor record IsKleisliTriple (M : Set → Set) : Set₁ where -- Methods. field return : ∀ {A } → A → M A bind′ : ∀ {A B} → (A → M B) → M A → M B -- Laws. field bind′-β : ∀ {A B} {k : A → M B} → bind′ k ∘ return ≡ k bind′-η : ∀ {A} → bind′ {A = A} return ≡ id bind′-∘ : ∀ {A B C} {k : A → M B} {l : B → M C} → bind′ (bind′ l ∘ k) ≡ bind′ l ∘ bind′ k -- Notations for bind′. -- Postfix category-theoretical notation. _✶ = bind′ -- Infix Haskell notation. infixl 6 _=<<_ _=<<_ = bind′ -- Kleisli composition. infixl 6 _<=<_ _<=<_ : ∀ {A B C : Set} (l : B → M C) (k : A → M B) → (A → M C) l <=< k = bind′ l ∘ k -- Functoriality. isFunctor : IsFunctor M isFunctor = record { ops = record { map = map } ; laws = record { map-id = bind′-η ; map-∘ = sym (map-∘-sym _ _) } } where map : ∀ {A B} → (A → B) → M A → M B map f = bind′ (return ∘ f) map-∘-sym : ∀ {A B C} (f : A → B) (g : B → C) → map g ∘ map f ≡ map (g ∘ f) map-∘-sym f g = begin map g ∘ map f ≡⟨⟩ bind′ (return ∘ g) ∘ bind′ (return ∘ f) ≡⟨ sym bind′-∘ ⟩ bind′ (bind′ (return ∘ g) ∘ return ∘ f) ≡⟨ cong (λ z → bind′ (z ∘ f)) bind′-β ⟩ bind′ (return ∘ g ∘ f) ≡⟨⟩ map (g ∘ f) ∎ open IsFunctor isFunctor public -- Monads in Kleisli Triple presentation. record KleisliTriple : Set₁ where field M : Set → Set M! : IsKleisliTriple M open IsKleisliTriple M! public
{ "alphanum_fraction": 0.5110759494, "avg_line_length": 23.4074074074, "ext": "agda", "hexsha": "0dcafef2870545554ebb21e5efb1a4bc36e37798", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "914f655c7c0417754c2ffe494d3f6ea7a357b1c3", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "andreasabel/cubical", "max_forks_repo_path": "src/Control/Monad/KleisliTriple.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "914f655c7c0417754c2ffe494d3f6ea7a357b1c3", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "andreasabel/cubical", "max_issues_repo_path": "src/Control/Monad/KleisliTriple.agda", "max_line_length": 88, "max_stars_count": null, "max_stars_repo_head_hexsha": "914f655c7c0417754c2ffe494d3f6ea7a357b1c3", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "andreasabel/cubical", "max_stars_repo_path": "src/Control/Monad/KleisliTriple.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 722, "size": 1896 }
------------------------------------------------------------------------ -- The Agda standard library -- -- An either-or-both data type ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} module Data.These where open import Level open import Data.Sum.Base using (_⊎_; [_,_]′) open import Function data These {a b} (A : Set a) (B : Set b) : Set (a ⊔ b) where this : A → These A B that : B → These A B these : A → B → These A B module _ {a b} {A : Set a} {B : Set b} where fromSum : A ⊎ B → These A B fromSum = [ this , that ]′ -- map map : ∀ {a₁ a₂ b₁ b₂} {A₁ : Set a₁} {A₂ : Set a₂} {B₁ : Set b₁} {B₂ : Set b₂} (f : A₁ → A₂) (g : B₁ → B₂) → These A₁ B₁ → These A₂ B₂ map f g (this a) = this (f a) map f g (that b) = that (g b) map f g (these a b) = these (f a) (g b) map₁ : ∀ {a₁ a₂ b} {A₁ : Set a₁} {A₂ : Set a₂} {B : Set b} (f : A₁ → A₂) → These A₁ B → These A₂ B map₁ f = map f id map₂ : ∀ {a b₁ b₂} {A : Set a} {B₁ : Set b₁} {B₂ : Set b₂} (g : B₁ → B₂) → These A B₁ → These A B₂ map₂ = map id module _ {a b} {A : Set a} {B : Set b} where -- fold fold : ∀ {c} {C : Set c} → (A → C) → (B → C) → (A → B → C) → These A B → C fold l r lr (this a) = l a fold l r lr (that b) = r b fold l r lr (these a b) = lr a b -- swap swap : These A B → These B A swap = fold that this (flip these) -- align module _ {a b c d} {A : Set a} {B : Set b} {C : Set c} {D : Set d} where alignWith : ∀ {e f} {E : Set e} {F : Set f} → (These A C → E) → (These B D → F) → These A B → These C D → These E F alignWith f g (this a) (this c) = this (f (these a c)) alignWith f g (this a) (that d) = these (f (this a)) (g (that d)) alignWith f g (this a) (these c d) = these (f (these a c)) (g (that d)) alignWith f g (that b) (this c) = these (f (that c)) (g (this b)) alignWith f g (that b) (that d) = that (g (these b d)) alignWith f g (that b) (these c d) = these (f (that c)) (g (these b d)) alignWith f g (these a b) (this c) = these (f (these a c)) (g (this b)) alignWith f g (these a b) (that d) = these (f (this a)) (g (these b d)) alignWith f g (these a b) (these c d) = these (f (these a c)) (g (these b d)) align : These A B → These C D → These (These A C) (These B D) align = alignWith id id module _ {a} {A : Set a} where -- Projections. leftMost : These A A → A leftMost = fold id id const rightMost : These A A → A rightMost = fold id id (flip const) mergeThese : (A → A → A) → These A A → A mergeThese = fold id id
{ "alphanum_fraction": 0.5026676829, "avg_line_length": 30.1609195402, "ext": "agda", "hexsha": "3aaff8adf35e09ed95d04c68bf35a45ec5f3f5da", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "omega12345/agda-mode", "max_forks_repo_path": "test/asset/agda-stdlib-1.0/Data/These.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "omega12345/agda-mode", "max_issues_repo_path": "test/asset/agda-stdlib-1.0/Data/These.agda", "max_line_length": 79, "max_stars_count": null, "max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "omega12345/agda-mode", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Data/These.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1001, "size": 2624 }
{-# OPTIONS --cubical --safe #-} module Cubical.HITs.Nullification.Properties where open import Cubical.Foundations.Everything open isPathSplitEquiv open import Cubical.Modalities.Everything open Modality open import Cubical.HITs.Localization renaming (rec to Localize-rec) open import Cubical.Data.Unit open import Cubical.HITs.Nullification.Base rec : ∀ {ℓ ℓ' ℓ''} {S : Type ℓ} {A : Type ℓ'} {B : Type ℓ''} → (nB : isNull S B) → (A → B) → Null S A → B rec nB g ∣ x ∣ = g x rec nB g (hub f) = fst (sec nB) (λ s → rec nB g (f s)) rec nB g (spoke f s i) = snd (sec nB) (λ s → rec nB g (f s)) i s rec nB g (≡hub {x} {y} p i) = fst (secCong nB (rec nB g x) (rec nB g y)) (λ i s → rec nB g (p s i)) i rec nB g (≡spoke {x} {y} p s i j) = snd (secCong nB (rec nB g x) (rec nB g y)) (λ i s → rec nB g (p s i)) i j s toPathP⁻ : ∀ {ℓ} (A : I → Type ℓ) {x : A i0} {y : A i1} → x ≡ transport⁻ (λ i → A i) y → PathP A x y toPathP⁻ A p i = toPathP {A = λ i → A (~ i)} (sym p) (~ i) toPathP⁻-sq : ∀ {ℓ} {A : Type ℓ} (x : A) → Square (toPathP⁻ (λ _ → A) (λ _ → transport refl x)) refl (transportRefl x) refl toPathP⁻-sq x j i = hcomp (λ l → λ { (i = i0) → transportRefl x j ; (i = i1) → x ; (j = i1) → x }) (transportRefl x (i ∨ j)) module _ {ℓ ℓ' ℓ''} {S : Type ℓ} {A : Type ℓ'} {B : Null S A → Type ℓ''} where private secCongDep' : ∀ (nB : (x : Null S A) → isNull S (B x)) {x y : Null S A} (p : x ≡ y) → (∀ (bx : B x) (by : B y) → hasSection (cong₂ (λ x (b : B x) (_ : S) → b) p)) secCongDep' nB p = secCongDep (λ _ → const) p (λ a → secCong (nB a)) elim : (nB : (x : Null S A) → isNull S (B x)) → ((a : A) → B ∣ a ∣) → (x : Null S A) → B x elim nB g ∣ x ∣ = g x elim nB g (hub f) = fst (sec (nB (hub f))) (λ s → transport (λ i → B (spoke f s (~ i))) (elim nB g (f s))) elim nB g (spoke f s i) = toPathP⁻ (λ i → B (spoke f s i)) (funExt⁻ ( snd (sec (nB (hub f))) (λ s → transport (λ i → B (spoke f s (~ i))) (elim nB g (f s))) ) s) i elim nB g (≡hub {x} {y} p i) = hcomp (λ k → λ { (i = i0) → transportRefl (elim nB g x) k ; (i = i1) → transportRefl (elim nB g y) k }) (fst (secCongDep' nB (≡hub p) (transport refl (elim nB g x)) (transport refl (elim nB g y))) (λ i s → transport (λ j → B (≡spoke p s (~ j) i)) (elim nB g (p s i))) i) elim nB g (≡spoke {x} {y} p s j i) = hcomp (λ k → λ { (i = i0) → toPathP⁻-sq (elim nB g x) k j ; (i = i1) → toPathP⁻-sq (elim nB g y) k j ; (j = i1) → elim nB g (p s i) }) (q₂ j i) where q₁ : Path (PathP (λ i → B (≡hub p i)) (transport refl (elim nB g x)) (transport refl (elim nB g y))) (fst (secCongDep' nB (≡hub p) (transport refl (elim nB g x)) (transport refl (elim nB g y))) (λ i s → transport (λ j → B (≡spoke p s (~ j) i)) (elim nB g (p s i)))) (λ i → transport (λ j → B (≡spoke p s (~ j) i)) (elim nB g (p s i))) q₁ j i = snd (secCongDep' nB (≡hub p) (transport refl (elim nB g x)) (transport refl (elim nB g y))) (λ i s → transport (λ j → B (≡spoke p s (~ j) i)) (elim nB g (p s i))) j i s q₂ : PathP (λ j → PathP (λ i → B (≡spoke p s j i)) (toPathP⁻ (λ _ → B x) (λ _ → transport refl (elim nB g x)) j) (toPathP⁻ (λ _ → B y) (λ _ → transport refl (elim nB g y)) j)) (fst (secCongDep' nB (≡hub p) (transport refl (elim nB g x)) (transport refl (elim nB g y))) (λ i s → transport (λ j → B (≡spoke p s (~ j) i)) (elim nB g (p s i)))) (λ i → elim nB g (p s i)) q₂ j i = toPathP⁻ (λ j → B (≡spoke p s j i)) (λ j → q₁ j i) j -- nullification is a modality NullModality : ∀ {ℓ} (S : Type ℓ) → Modality ℓ isModal (NullModality S) = isNull S isModalIsProp (NullModality S) = isPropIsPathSplitEquiv _ ◯ (NullModality S) = Null S ◯-isModal (NullModality S) = isNull-Null η (NullModality S) = ∣_∣ ◯-elim (NullModality S) = elim ◯-elim-β (NullModality S) = λ _ _ _ → refl ◯-=-isModal (NullModality S) x y = fromIsEquiv _ e where e : isEquiv (λ (p : x ≡ y) → const {B = S} p) e = transport (λ i → isEquiv {B = funExtPath {A = S} {f = const x} {g = const y} (~ i)} (λ p → ua-gluePath funExtEquiv {x = const p} {y = cong const p} refl (~ i))) (isEquivCong (_ , toIsEquiv _ isNull-Null)) idemNull : ∀ {ℓ} (S A : Type ℓ) → isNull S A → A ≃ Null S A idemNull S A nA = ∣_∣ , isModalToIsEquiv (NullModality S) nA -- nullification is localization at a map (S → 1) module Null-iso-Localize {ℓ ℓ'} (S : Type ℓ) (A : Type ℓ') where to : Null S A → Localize {A = Unit} (λ _ → const {B = S} tt) A to ∣ x ∣ = ∣ x ∣ to (hub f) = ext tt (to ∘ f) tt to (spoke f s i) = isExt tt (to ∘ f) s i to (≡hub {x} {y} p i) = ≡ext tt (const (to x)) (const (to y)) (cong to ∘ p) tt i to (≡spoke {x} {y} p s i j) = ≡isExt tt (const (to x)) (const (to y)) (cong to ∘ p) s i j from : Localize {A = Unit} (λ _ → const {B = S} tt) A → Null S A from ∣ x ∣ = ∣ x ∣ from (ext tt f tt) = hub (from ∘ f) from (isExt tt f s i) = spoke (from ∘ f) s i from (≡ext tt g h p tt i) = ≡hub {x = from (g tt)} {from (h tt)} (cong from ∘ p) i from (≡isExt tt g h p s i j) = ≡spoke {x = from (g tt)} {from (h tt)} (cong from ∘ p) s i j to-from : ∀ (x : Localize {A = Unit} (λ _ → const {B = S} tt) A) → to (from x) ≡ x to-from ∣ x ∣ k = ∣ x ∣ to-from (ext tt f tt) k = ext tt (λ s → to-from (f s) k) tt to-from (isExt tt f s i) k = isExt tt (λ s → to-from (f s) k) s i to-from (≡ext tt g h p tt i) k = ≡ext tt (λ _ → to-from (g tt) k) (λ _ → to-from (h tt) k) (λ s j → to-from (p s j) k) tt i to-from (≡isExt tt g h p s i j) k = ≡isExt tt (λ _ → to-from (g tt) k) (λ _ → to-from (h tt) k) (λ s j → to-from (p s j) k) s i j from-to : ∀ (x : Null S A) → from (to x) ≡ x from-to ∣ x ∣ k = ∣ x ∣ from-to (hub f) k = hub (λ s → from-to (f s) k) from-to (spoke f s i) k = spoke (λ s → from-to (f s) k) s i from-to (≡hub {x} {y} p i) k = ≡hub {x = from-to x k} {from-to y k} (λ s j → from-to (p s j) k) i from-to (≡spoke {x} {y} p s i j) k = ≡spoke {x = from-to x k} {from-to y k} (λ s j → from-to (p s j) k) s i j isom : Iso (Null S A) (Localize {A = Unit} (λ _ → const {B = S} tt) A) isom = iso to from to-from from-to Null≃Localize : ∀ {ℓ ℓ'} (S : Type ℓ) (A : Type ℓ') → Null S A ≃ Localize (λ _ → const tt) A Null≃Localize S A = isoToEquiv (Null-iso-Localize.isom S A)
{ "alphanum_fraction": 0.4934645322, "avg_line_length": 52.3769230769, "ext": "agda", "hexsha": "38b58e4573b6d367ca153ecb867e8ba0d59dbc9c", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "cefeb3669ffdaea7b88ae0e9dd258378418819ca", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "borsiemir/cubical", "max_forks_repo_path": "Cubical/HITs/Nullification/Properties.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "cefeb3669ffdaea7b88ae0e9dd258378418819ca", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "borsiemir/cubical", "max_issues_repo_path": "Cubical/HITs/Nullification/Properties.agda", "max_line_length": 131, "max_stars_count": null, "max_stars_repo_head_hexsha": "cefeb3669ffdaea7b88ae0e9dd258378418819ca", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "borsiemir/cubical", "max_stars_repo_path": "Cubical/HITs/Nullification/Properties.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 2826, "size": 6809 }
{-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.HITs.DunceCap.Properties where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Function open import Cubical.Foundations.GroupoidLaws open import Cubical.Foundations.Isomorphism open import Cubical.Foundations.Equiv open import Cubical.Foundations.Univalence open import Cubical.HITs.S1 using (S¹; base; decodeEncode) import Cubical.HITs.S1 as S¹ open import Cubical.HITs.MappingCones open import Cubical.HITs.DunceCap.Base -- DunceCone is contractible (easy) Disk : Type₀ Disk = Cone (idfun S¹) isContr-Disk : isContr Disk fst isContr-Disk = hub snd isContr-Disk (inj x) i = spoke x i snd isContr-Disk hub i = hub snd isContr-Disk (spoke x j) i = spoke x (i ∧ j) dunceMap≡id : dunceMap ≡ idfun S¹ dunceMap≡id i base = base dunceMap≡id i (S¹.loop j) = p i j where p : S¹.loop ⁻¹ ∙∙ S¹.loop ∙∙ S¹.loop ≡ S¹.loop p = sym (decodeEncode base (S¹.loop ⁻¹ ∙∙ S¹.loop ∙∙ S¹.loop)) ∙ sym (lUnit S¹.loop) isContr-DunceCone : isContr DunceCone isContr-DunceCone = subst isContr (cong Cone (sym dunceMap≡id)) isContr-Disk -- Dunce is contractible (harder) contrDunce : (d : Dunce) → d ≡ base contrDunce base k = loop k contrDunce (loop i) k = surf k i contrDunce (surf i j) k = hcomp (λ l → λ { (i = i0) → surf k j ; (i = i1) → cube l ; (j = i0) → cube l ; (j = i1) → cube l ; (k = i0) → surf i j ; (k = i1) → base }) (surf (k ∨ i) j) where cube : I → Dunce cube l = hfill (λ i → λ { (k = i0) → loop i ; (k = i1) → base ; (l = i0) → loop (k ∨ i) ; (l = i1) → surf k i }) (inS (loop k)) i isContr-Dunce : isContr Dunce fst isContr-Dunce = base snd isContr-Dunce = sym ∘ contrDunce Dunce≡DunceCone : Dunce ≡ DunceCone Dunce≡DunceCone = ua (isContr→Equiv isContr-Dunce isContr-DunceCone)
{ "alphanum_fraction": 0.6039312039, "avg_line_length": 31.3076923077, "ext": "agda", "hexsha": "0d4abc3e9cc1ada272c0ec5541d3e4335dd5d280", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-22T02:02:01.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-22T02:02:01.000Z", "max_forks_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "dan-iel-lee/cubical", "max_forks_repo_path": "Cubical/HITs/DunceCap/Properties.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_issues_repo_issues_event_max_datetime": "2022-01-27T02:07:48.000Z", "max_issues_repo_issues_event_min_datetime": "2022-01-27T02:07:48.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "dan-iel-lee/cubical", "max_issues_repo_path": "Cubical/HITs/DunceCap/Properties.agda", "max_line_length": 92, "max_stars_count": null, "max_stars_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "dan-iel-lee/cubical", "max_stars_repo_path": "Cubical/HITs/DunceCap/Properties.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 697, "size": 2035 }
{-# OPTIONS --safe #-} module Definition.Typed.Consequences.Syntactic where open import Definition.Untyped open import Definition.Typed open import Definition.Typed.Properties open import Definition.Typed.EqRelInstance open import Definition.LogicalRelation open import Definition.LogicalRelation.Substitution open import Definition.LogicalRelation.Substitution.Escape open import Definition.LogicalRelation.Fundamental open import Definition.Typed.Consequences.Injectivity open import Tools.Product -- the `with` syntax does not work -- Syntactic validity of type equality. syntacticEq : ∀ {A B rA Γ} → Γ ⊢ A ≡ B ^ rA → Γ ⊢ A ^ rA × Γ ⊢ B ^ rA syntacticEq {A} {B} {rA} {Γ} A≡B = let X = fundamentalEq A≡B [Γ] = proj₁ X [A] = proj₁ (proj₂ X) [B] = proj₁ (proj₂ (proj₂ X)) in escapeᵛ [Γ] [A] , escapeᵛ [Γ] [B] -- Syntactic validity of terms. syntacticTerm : ∀ {t A rA Γ} → Γ ⊢ t ∷ A ^ rA → Γ ⊢ A ^ rA syntacticTerm t = let X = fundamentalTerm t [Γ] = proj₁ X [A] = proj₁ (proj₂ X) [t] = proj₂ (proj₂ X) in escapeᵛ [Γ] [A] -- Syntactic validity of term equality. syntacticEqTerm : ∀ {t u A rA Γ} → Γ ⊢ t ≡ u ∷ A ^ rA → Γ ⊢ A ^ rA × (Γ ⊢ t ∷ A ^ rA × Γ ⊢ u ∷ A ^ rA) syntacticEqTerm t≡u with fundamentalTermEq t≡u syntacticEqTerm t≡u | [Γ] , modelsTermEq [A] [t] [u] [t≡u] = escapeᵛ [Γ] [A] , escapeTermᵛ [Γ] [A] [t] , escapeTermᵛ [Γ] [A] [u] -- Syntactic validity of type reductions. syntacticRed : ∀ {A B rA Γ} → Γ ⊢ A ⇒* B ^ rA → Γ ⊢ A ^ rA × Γ ⊢ B ^ rA syntacticRed D = let X = fundamentalEq (subset* D) [Γ] = proj₁ X [A] = proj₁ (proj₂ X) [B] = proj₁ (proj₂ (proj₂ X)) in escapeᵛ [Γ] [A] , escapeᵛ [Γ] [B] -- Syntactic validity of term reductions. syntacticRedTerm : ∀ {t u A Γ l} → Γ ⊢ t ⇒* u ∷ A ^ l → Γ ⊢ A ^ [ ! , l ] × (Γ ⊢ t ∷ A ^ [ ! , l ] × Γ ⊢ u ∷ A ^ [ ! , l ]) syntacticRedTerm d with fundamentalTermEq (subset*Term d) syntacticRedTerm d | [Γ] , modelsTermEq [A] [t] [u] [t≡u] = escapeᵛ [Γ] [A] , escapeTermᵛ [Γ] [A] [t] , escapeTermᵛ [Γ] [A] [u] -- Syntactic validity of Π-types. syntacticΠ : ∀ {Γ F G rF lF lG rΠ lΠ} → Γ ⊢ Π F ^ rF ° lF ▹ G ° lG ° lΠ ^ [ rΠ , ι lΠ ] → Γ ⊢ F ^ [ rF , ι lF ] × Γ ∙ F ^ [ rF , ι lF ] ⊢ G ^ [ rΠ , ι lG ] syntacticΠ ΠFG with injectivity (refl ΠFG) syntacticΠ ΠFG | F≡F , rF≡rF , lF≡lF , lG≡lG , G≡G = proj₁ (syntacticEq F≡F) , proj₁ (syntacticEq G≡G)
{ "alphanum_fraction": 0.6098993289, "avg_line_length": 35.5820895522, "ext": "agda", "hexsha": "909b573f1cb496f2a8200405df1992777867c977", "lang": "Agda", "max_forks_count": 2, "max_forks_repo_forks_event_max_datetime": "2022-02-15T19:42:19.000Z", "max_forks_repo_forks_event_min_datetime": "2022-01-26T14:55:51.000Z", "max_forks_repo_head_hexsha": "e0eeebc4aa5ed791ce3e7c0dc9531bd113dfcc04", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "CoqHott/logrel-mltt", "max_forks_repo_path": "Definition/Typed/Consequences/Syntactic.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "e0eeebc4aa5ed791ce3e7c0dc9531bd113dfcc04", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "CoqHott/logrel-mltt", "max_issues_repo_path": "Definition/Typed/Consequences/Syntactic.agda", "max_line_length": 155, "max_stars_count": 2, "max_stars_repo_head_hexsha": "e0eeebc4aa5ed791ce3e7c0dc9531bd113dfcc04", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "CoqHott/logrel-mltt", "max_stars_repo_path": "Definition/Typed/Consequences/Syntactic.agda", "max_stars_repo_stars_event_max_datetime": "2022-01-17T16:13:53.000Z", "max_stars_repo_stars_event_min_datetime": "2018-06-21T08:39:01.000Z", "num_tokens": 1013, "size": 2384 }
-- Andreas, 2012-03-15, example by Ulf -- {-# OPTIONS -v tc.meta:20 #-} module Issue479 where import Common.Level open import Common.Equality data ⊥ : Set where data Bool : Set where true false : Bool X : Bool X=true : X ≡ true X≠false : X ≡ false → ⊥ X = _ X≠false () X=true = refl -- The emptyness check for X ≡ false should be postponed until -- X has been solved to true.
{ "alphanum_fraction": 0.661498708, "avg_line_length": 19.35, "ext": "agda", "hexsha": "31d016568af6bb255bf3b84be4f7b96609a49fca", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cruhland/agda", "max_forks_repo_path": "test/Succeed/Issue479.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "cruhland/agda", "max_issues_repo_path": "test/Succeed/Issue479.agda", "max_line_length": 62, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/Succeed/Issue479.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 122, "size": 387 }
-- Andreas, 2017-10-02, issue #2785, reported by ... -- {-# OPTIONS -v scope.extendedLambda:100 #-} {-# OPTIONS --allow-unsolved-metas #-} foo : _ foo = {!foo λ {x y → foo}!} -- C-c C-r -- Upon refine (C-c C-r), error was: -- -- An internal error has occurred. Please report this as a bug. -- Location of the error: src/full/Agda/Syntax/Translation/ConcreteToAbstract.hs:721 -- Now: unsolved metas and constraints.
{ "alphanum_fraction": 0.6603325416, "avg_line_length": 26.3125, "ext": "agda", "hexsha": "c25856d26cccff5679b9c6562fa7604a9511d639", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_path": "test/interaction/Issue2785.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "shlevy/agda", "max_issues_repo_path": "test/interaction/Issue2785.agda", "max_line_length": 84, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "test/interaction/Issue2785.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 125, "size": 421 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Properties related to All ------------------------------------------------------------------------ module Data.List.All.Properties where open import Data.Bool open import Data.Bool.Properties open import Data.Empty open import Data.List as List import Data.List.Any as Any; open Any.Membership-≡ open import Data.List.All as All using (All; []; _∷_) open import Data.List.Any using (Any; here; there) open import Data.Product as Prod open import Function open import Function.Equality using (_⟨$⟩_) open import Function.Equivalence using (_⇔_; module Equivalence) open import Function.Inverse using (_↔_) open import Function.Surjection using (_↠_) open import Relation.Binary.PropositionalEquality as P using (_≡_) open import Relation.Nullary open import Relation.Unary using (Decidable) renaming (_⊆_ to _⋐_) -- Functions can be shifted between the predicate and the list. All-map : ∀ {a b p} {A : Set a} {B : Set b} {P : B → Set p} {f : A → B} {xs} → All (P ∘ f) xs → All P (List.map f xs) All-map [] = [] All-map (p ∷ ps) = p ∷ All-map ps map-All : ∀ {a b p} {A : Set a} {B : Set b} {P : B → Set p} {f : A → B} {xs} → All P (List.map f xs) → All (P ∘ f) xs map-All {xs = []} [] = [] map-All {xs = _ ∷ _} (p ∷ ps) = p ∷ map-All ps -- A variant of All.map. gmap : ∀ {a b p q} {A : Set a} {B : Set b} {P : A → Set p} {Q : B → Set q} {f : A → B} → P ⋐ Q ∘ f → All P ⋐ All Q ∘ List.map f gmap g = All-map ∘ All.map g -- All and all are related via T. All-all : ∀ {a} {A : Set a} (p : A → Bool) {xs} → All (T ∘ p) xs → T (all p xs) All-all p [] = _ All-all p (px ∷ pxs) = Equivalence.from T-∧ ⟨$⟩ (px , All-all p pxs) all-All : ∀ {a} {A : Set a} (p : A → Bool) xs → T (all p xs) → All (T ∘ p) xs all-All p [] _ = [] all-All p (x ∷ xs) px∷xs with Equivalence.to (T-∧ {p x}) ⟨$⟩ px∷xs all-All p (x ∷ xs) px∷xs | (px , pxs) = px ∷ all-All p xs pxs -- All is anti-monotone. anti-mono : ∀ {a p} {A : Set a} {P : A → Set p} {xs ys} → xs ⊆ ys → All P ys → All P xs anti-mono xs⊆ys pys = All.tabulate (All.lookup pys ∘ xs⊆ys) -- all is anti-monotone. all-anti-mono : ∀ {a} {A : Set a} (p : A → Bool) {xs ys} → xs ⊆ ys → T (all p ys) → T (all p xs) all-anti-mono p xs⊆ys = All-all p ∘ anti-mono xs⊆ys ∘ all-All p _ -- All P (xs ++ ys) is isomorphic to All P xs and All P ys. private ++⁺ : ∀ {a p} {A : Set a} {P : A → Set p} {xs ys : List A} → All P xs → All P ys → All P (xs ++ ys) ++⁺ [] pys = pys ++⁺ (px ∷ pxs) pys = px ∷ ++⁺ pxs pys ++⁻ : ∀ {a p} {A : Set a} {P : A → Set p} (xs : List A) {ys} → All P (xs ++ ys) → All P xs × All P ys ++⁻ [] p = [] , p ++⁻ (x ∷ xs) (px ∷ pxs) = Prod.map (_∷_ px) id $ ++⁻ _ pxs ++⁺∘++⁻ : ∀ {a p} {A : Set a} {P : A → Set p} xs {ys} (p : All P (xs ++ ys)) → uncurry′ ++⁺ (++⁻ xs p) ≡ p ++⁺∘++⁻ [] p = P.refl ++⁺∘++⁻ (x ∷ xs) (px ∷ pxs) = P.cong (_∷_ px) $ ++⁺∘++⁻ xs pxs ++⁻∘++⁺ : ∀ {a p} {A : Set a} {P : A → Set p} {xs ys} (p : All P xs × All P ys) → ++⁻ xs (uncurry ++⁺ p) ≡ p ++⁻∘++⁺ ([] , pys) = P.refl ++⁻∘++⁺ (px ∷ pxs , pys) rewrite ++⁻∘++⁺ (pxs , pys) = P.refl ++↔ : ∀ {a p} {A : Set a} {P : A → Set p} {xs ys} → (All P xs × All P ys) ↔ All P (xs ++ ys) ++↔ {P = P} {xs = xs} = record { to = P.→-to-⟶ $ uncurry ++⁺ ; from = P.→-to-⟶ $ ++⁻ xs ; inverse-of = record { left-inverse-of = ++⁻∘++⁺ ; right-inverse-of = ++⁺∘++⁻ xs } } -- Three lemmas relating Any, All and negation. ¬Any↠All¬ : ∀ {a p} {A : Set a} {P : A → Set p} {xs} → ¬ Any P xs ↠ All (¬_ ∘ P) xs ¬Any↠All¬ {P = P} = record { to = P.→-to-⟶ (to _) ; surjective = record { from = P.→-to-⟶ from ; right-inverse-of = to∘from } } where to : ∀ xs → ¬ Any P xs → All (¬_ ∘ P) xs to [] ¬p = [] to (x ∷ xs) ¬p = ¬p ∘ here ∷ to xs (¬p ∘ there) from : ∀ {xs} → All (¬_ ∘ P) xs → ¬ Any P xs from [] () from (¬p ∷ _) (here p) = ¬p p from (_ ∷ ¬p) (there p) = from ¬p p to∘from : ∀ {xs} (¬p : All (¬_ ∘ P) xs) → to xs (from ¬p) ≡ ¬p to∘from [] = P.refl to∘from (¬p ∷ ¬ps) = P.cong₂ _∷_ P.refl (to∘from ¬ps) -- If equality of functions were extensional, then the surjection -- could be strengthened to a bijection. from∘to : P.Extensionality _ _ → ∀ xs → (¬p : ¬ Any P xs) → from (to xs ¬p) ≡ ¬p from∘to ext [] ¬p = ext λ () from∘to ext (x ∷ xs) ¬p = ext λ { (here p) → P.refl ; (there p) → P.cong (λ f → f p) $ from∘to ext xs (¬p ∘ there) } Any¬→¬All : ∀ {a p} {A : Set a} {P : A → Set p} {xs} → Any (¬_ ∘ P) xs → ¬ All P xs Any¬→¬All (here ¬p) = ¬p ∘ All.head Any¬→¬All (there ¬p) = Any¬→¬All ¬p ∘ All.tail Any¬⇔¬All : ∀ {a p} {A : Set a} {P : A → Set p} {xs} → Decidable P → Any (¬_ ∘ P) xs ⇔ ¬ All P xs Any¬⇔¬All {P = P} dec = record { to = P.→-to-⟶ Any¬→¬All ; from = P.→-to-⟶ (from _) } where from : ∀ xs → ¬ All P xs → Any (¬_ ∘ P) xs from [] ¬∀ = ⊥-elim (¬∀ []) from (x ∷ xs) ¬∀ with dec x ... | yes p = there (from xs (¬∀ ∘ _∷_ p)) ... | no ¬p = here ¬p -- If equality of functions were extensional, then the logical -- equivalence could be strengthened to a surjection. to∘from : P.Extensionality _ _ → ∀ {xs} (¬∀ : ¬ All P xs) → Any¬→¬All (from xs ¬∀) ≡ ¬∀ to∘from ext ¬∀ = ext (⊥-elim ∘ ¬∀)
{ "alphanum_fraction": 0.4688164422, "avg_line_length": 33.5952380952, "ext": "agda", "hexsha": "9752b202bc77dc89e2757211d0fefec1417a846a", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_forks_repo_licenses": [ "Apache-2.0" ], "max_forks_repo_name": "qwe2/try-agda", "max_forks_repo_path": "agda-stdlib-0.9/src/Data/List/All/Properties.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "Apache-2.0" ], "max_issues_repo_name": "qwe2/try-agda", "max_issues_repo_path": "agda-stdlib-0.9/src/Data/List/All/Properties.agda", "max_line_length": 72, "max_stars_count": 1, "max_stars_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_stars_repo_licenses": [ "Apache-2.0" ], "max_stars_repo_name": "qwe2/try-agda", "max_stars_repo_path": "agda-stdlib-0.9/src/Data/List/All/Properties.agda", "max_stars_repo_stars_event_max_datetime": "2016-10-20T15:52:05.000Z", "max_stars_repo_stars_event_min_datetime": "2016-10-20T15:52:05.000Z", "num_tokens": 2308, "size": 5644 }
open import slots.imports open import slots.defs module slots.bruteforce {cfg : config}(g : game cfg) where open config cfg open game g total : ℕ total = V.foldl _ (λ i r → i * L.length r) 1 reels lineWin : Line → Win/Bet lineWin [] = 0 lineWin (f₀ ∷ fs) = lineWin′ w ws fs where winLine = V.lookup f₀ winTable w = V.head winLine ws = V.tail winLine lineWin′ : ∀ {n} → Win/Bet → Vec Win/Bet n → Vec Fruit n → Win/Bet lineWin′ w [] [] = w lineWin′ w (w′ ∷ ws) (f ∷ fs) with f₀ F.≟ f ... | yes p = lineWin′ w′ ws fs ... | no ¬p = w allLines : List Line allLines = V.foldr (List ∘ Vec Fruit) (λ r → L.concatMap λ l → L.map (_∷ l) r) ([] ∷ []) reels win : ℕ win = L.sum ∘ L.map lineWin $ allLines rtp : ℕ × ℕ rtp = win , total
{ "alphanum_fraction": 0.5960264901, "avg_line_length": 20.9722222222, "ext": "agda", "hexsha": "ec85fc20b43364ae076176b33966b7b9d940a60b", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "86d777ade14f63032c46bd168b76ac60d6bdf9b9", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "semenov-vladyslav/slots-agda", "max_forks_repo_path": "src/slots/bruteforce.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "86d777ade14f63032c46bd168b76ac60d6bdf9b9", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "semenov-vladyslav/slots-agda", "max_issues_repo_path": "src/slots/bruteforce.agda", "max_line_length": 58, "max_stars_count": null, "max_stars_repo_head_hexsha": "86d777ade14f63032c46bd168b76ac60d6bdf9b9", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "semenov-vladyslav/slots-agda", "max_stars_repo_path": "src/slots/bruteforce.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 292, "size": 755 }
{-# OPTIONS --without-K #-} module ConcretePermutationProperties where open import Relation.Binary.PropositionalEquality using (_≡_; refl; sym; trans; cong; module ≡-Reasoning; proof-irrelevance) -- -- open import FinVecProperties using (∘̂-assoc; ∘̂-lid; ∘̂-rid) open import ConcretePermutation ------------------------------------------------------------------------------ -- Properties of vectors where are only used to prove some properties -- of concrete permutations -> do not export them. private open import Data.Nat using (ℕ) open import Data.Fin using (Fin) open import Data.Vec using (Vec) open import Data.Vec.Properties using (lookup-allFin) open import Proofs using (finext; lookupassoc; _!!_) ∘̂-assoc : {m₁ m₂ m₃ m₄ : ℕ} → (a : Vec (Fin m₂) m₁) (b : Vec (Fin m₃) m₂) (c : Vec (Fin m₄) m₃) → a ∘̂ (b ∘̂ c) ≡ (a ∘̂ b) ∘̂ c ∘̂-assoc a b c = finext (lookupassoc a b c) ∘̂-rid : {m n : ℕ} → (π : Vec (Fin m) n) → π ∘̂ 1C ≡ π ∘̂-rid π = trans (finext (λ i → lookup-allFin (π !! i))) (cauchyext π) ∘̂-lid : {m n : ℕ} → (π : Vec (Fin m) n) → 1C ∘̂ π ≡ π ∘̂-lid π = trans (finext (λ i → cong (_!!_ π) (lookup-allFin i))) (cauchyext π) ------------------------------------------------------------------------------ -- Properties of concrete permutations that are needed to show that -- this is also a symmetric rig groupoid -- If the forward components are equal, then so are the backward ones πᵒ≡ : ∀ {m n} → (π₁ π₂ : CPerm m n) → (CPerm.π π₁ ≡ CPerm.π π₂) → (CPerm.πᵒ π₁ ≡ CPerm.πᵒ π₂) πᵒ≡ {n} (cp π πᵒ αp βp) (cp .π πᵒ₁ αp₁ βp₁) refl = begin ( πᵒ ≡⟨ sym (∘̂-rid πᵒ) ⟩ πᵒ ∘̂ 1C ≡⟨ cong (_∘̂_ πᵒ) (sym αp₁) ⟩ πᵒ ∘̂ (π ∘̂ πᵒ₁) ≡⟨ ∘̂-assoc πᵒ π πᵒ₁ ⟩ (πᵒ ∘̂ π) ∘̂ πᵒ₁ ≡⟨ cong (λ x → x ∘̂ πᵒ₁) βp ⟩ 1C ∘̂ πᵒ₁ ≡⟨ ∘̂-lid πᵒ₁ ⟩ πᵒ₁ ∎) where open ≡-Reasoning -- If the forward components are equal, then so are the entire -- concrete permutations p≡ : ∀ {m n} → {π₁ π₂ : CPerm m n} → (CPerm.π π₁ ≡ CPerm.π π₂) → π₁ ≡ π₂ p≡ {m} {n} {cp π πᵒ αp βp} {cp .π πᵒ₁ αp₁ βp₁} refl with πᵒ≡ (cp π πᵒ αp βp) (cp π πᵒ₁ αp₁ βp₁) refl p≡ {m} {n} {cp π πᵒ αp βp} {cp .π .πᵒ αp₁ βp₁} refl | refl with proof-irrelevance αp αp₁ | proof-irrelevance βp βp₁ p≡ {m} {n} {cp π πᵒ αp βp} {cp .π .πᵒ .αp .βp} refl | refl | refl | refl = refl ------------------------------------------------------------------------------
{ "alphanum_fraction": 0.5251328157, "avg_line_length": 39.4677419355, "ext": "agda", "hexsha": "16caec11276f30601bf73e1b061b62cbc46b3fc2", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2019-09-10T09:47:13.000Z", "max_forks_repo_forks_event_min_datetime": "2016-05-29T01:56:33.000Z", "max_forks_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_forks_repo_licenses": [ "BSD-2-Clause" ], "max_forks_repo_name": "JacquesCarette/pi-dual", "max_forks_repo_path": "Univalence/ConcretePermutationProperties.agda", "max_issues_count": 4, "max_issues_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_issues_repo_issues_event_max_datetime": "2021-10-29T20:41:23.000Z", "max_issues_repo_issues_event_min_datetime": "2018-06-07T16:27:41.000Z", "max_issues_repo_licenses": [ "BSD-2-Clause" ], "max_issues_repo_name": "JacquesCarette/pi-dual", "max_issues_repo_path": "Univalence/ConcretePermutationProperties.agda", "max_line_length": 81, "max_stars_count": 14, "max_stars_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_stars_repo_licenses": [ "BSD-2-Clause" ], "max_stars_repo_name": "JacquesCarette/pi-dual", "max_stars_repo_path": "Univalence/ConcretePermutationProperties.agda", "max_stars_repo_stars_event_max_datetime": "2021-05-05T01:07:57.000Z", "max_stars_repo_stars_event_min_datetime": "2015-08-18T21:40:15.000Z", "num_tokens": 1043, "size": 2447 }
------------------------------------------------------------------------ -- An implementation of the Thue-Morse sequence ------------------------------------------------------------------------ -- This module is a variant of ThueMorse. The difference is that, in -- this module, the cast operation takes an inequality instead of an -- equality, and that this module does not contain any correctness -- proofs. module ThueMorseLeq where open import Codata.Musical.Notation open import Codata.Musical.Stream using (Stream; _≈_) open Codata.Musical.Stream.Stream open import Data.Bool using (Bool; not); open Data.Bool.Bool open import Data.Nat using (ℕ); open Data.Nat.ℕ open import Data.Vec using (Vec; _∷ʳ_); open Data.Vec.Vec ------------------------------------------------------------------------ -- Chunks -- A value of type Chunks describes how a stream is generated. Note -- that an infinite sequence of empty chunks is not allowed. data Chunks : Set where -- Start the next chunk. next : (m : Chunks) → Chunks -- Cons an element to the current chunk. cons : (m : ∞ Chunks) → Chunks -- Inequality of chunks. infix 4 _≥C_ data _≥C_ : Chunks → Chunks → Set where next : ∀ {m m′} (m≥m′ : m ≥C m′ ) → next m ≥C next m′ cons : ∀ {m m′} (m≥m′ : ∞ (♭ m ≥C ♭ m′)) → cons m ≥C cons m′ consˡ : ∀ {m m′} (m≥m′ : ♭ m ≥C m′ ) → cons m ≥C m′ ------------------------------------------------------------------------ -- Chunk transformers tailC : Chunks → Chunks tailC (next m) = next (tailC m) tailC (cons m) = ♭ m mutual evensC : Chunks → Chunks evensC (next m) = next (evensC m) evensC (cons m) = cons (♯ oddsC (♭ m)) oddsC : Chunks → Chunks oddsC (next m) = next (oddsC m) oddsC (cons m) = evensC (♭ m) infixr 5 _⋎C_ -- Note that care is taken to create as few and large chunks as -- possible (see also _⋎W_). _⋎C_ : Chunks → Chunks → Chunks next m ⋎C next m′ = next (m ⋎C m′) -- Two chunks in, one out. next m ⋎C cons m′ = next (m ⋎C cons m′) cons m ⋎C m′ = cons (♯ (m′ ⋎C ♭ m)) ------------------------------------------------------------------------ -- Stream programs -- StreamP m A encodes programs which generate streams with chunk -- sizes given by m. infixr 5 _∷_ _⋎_ data StreamP : Chunks → Set → Set₁ where [_] : ∀ {m A} (xs : ∞ (StreamP m A)) → StreamP (next m) A _∷_ : ∀ {m A} (x : A) (xs : StreamP (♭ m) A) → StreamP (cons m) A tail : ∀ {m A} (xs : StreamP m A) → StreamP (tailC m) A evens : ∀ {m A} (xs : StreamP m A) → StreamP (evensC m) A odds : ∀ {m A} (xs : StreamP m A) → StreamP (oddsC m) A _⋎_ : ∀ {m m′ A} (xs : StreamP m A) (ys : StreamP m′ A) → StreamP (m ⋎C m′) A map : ∀ {m A B} (f : A → B) (xs : StreamP m A) → StreamP m B cast : ∀ {m m′ A} (ok : m ≥C m′) (xs : StreamP m A) → StreamP m′ A data StreamW : Chunks → Set → Set₁ where [_] : ∀ {m A} (xs : StreamP m A) → StreamW (next m) A _∷_ : ∀ {m A} (x : A) (xs : StreamW (♭ m) A) → StreamW (cons m) A program : ∀ {m A} → StreamW m A → StreamP m A program [ xs ] = [ ♯ xs ] program (x ∷ xs) = x ∷ program xs tailW : ∀ {m A} → StreamW m A → StreamW (tailC m) A tailW [ xs ] = [ tail xs ] tailW (x ∷ xs) = xs mutual evensW : ∀ {m A} → StreamW m A → StreamW (evensC m) A evensW [ xs ] = [ evens xs ] evensW (x ∷ xs) = x ∷ oddsW xs oddsW : ∀ {m A} → StreamW m A → StreamW (oddsC m) A oddsW [ xs ] = [ odds xs ] oddsW (x ∷ xs) = evensW xs infixr 5 _⋎W_ -- Note: Uses swapping of arguments. _⋎W_ : ∀ {m m′ A} → StreamW m A → StreamW m′ A → StreamW (m ⋎C m′) A [ xs ] ⋎W [ ys ] = [ xs ⋎ ys ] [ xs ] ⋎W (y ∷ ys) = [ xs ⋎ program (y ∷ ys) ] (x ∷ xs) ⋎W ys = x ∷ ys ⋎W xs mapW : ∀ {m A B} → (A → B) → StreamW m A → StreamW m B mapW f [ xs ] = [ map f xs ] mapW f (x ∷ xs) = f x ∷ mapW f xs module Cast where infixr 6 _+_ infixr 5 _++_ _+_ : ℕ → Chunks → Chunks zero + m = m suc n + m = cons (♯ (n + m)) _++_ : ∀ {A n m} → Vec A n → StreamP m A → StreamP (n + m) A [] ++ ys = ys (x ∷ xs) ++ ys = x ∷ (xs ++ ys) +ˡ : ∀ {m m′} n → m ≥C m′ → n + m ≥C m′ +ˡ zero m≥m′ = m≥m′ +ˡ (suc n) m≥m′ = consˡ (+ˡ n m≥m′) castW : ∀ {n m m′ A} → m ≥C m′ → Vec A n → StreamW m A → StreamW m′ A castW {n} (next m≥m′) xs [ ys ] = [ cast (+ˡ n m≥m′) (xs ++ ys) ] castW (cons m≥m′) [] (y ∷ ys) = y ∷ castW (♭ m≥m′) [] ys castW (cons m≥m′) (x ∷ xs) (y ∷ ys) = x ∷ castW (♭ m≥m′) (xs ∷ʳ y) ys castW (consˡ m≥m′) xs (y ∷ ys) = castW m≥m′ (xs ∷ʳ y) ys whnf : ∀ {m A} → StreamP m A → StreamW m A whnf [ xs ] = [ ♭ xs ] whnf (x ∷ xs) = x ∷ whnf xs whnf (tail xs) = tailW (whnf xs) whnf (evens xs) = evensW (whnf xs) whnf (odds xs) = oddsW (whnf xs) whnf (xs ⋎ ys) = whnf xs ⋎W whnf ys whnf (map f xs) = mapW f (whnf xs) whnf (cast m≥m′ xs) = Cast.castW m≥m′ [] (whnf xs) mutual ⟦_⟧W : ∀ {m A} → StreamW m A → Stream A ⟦ [ xs ] ⟧W = ⟦ xs ⟧P ⟦ x ∷ xs ⟧W = x ∷ ♯ ⟦ xs ⟧W ⟦_⟧P : ∀ {m A} → StreamP m A → Stream A ⟦ xs ⟧P = ⟦ whnf xs ⟧W ------------------------------------------------------------------------ -- The Thue-Morse sequence [ccn]ω : Chunks [ccn]ω = cons (♯ cons (♯ next [ccn]ω)) [cn]²[ccn]ω : Chunks [cn]²[ccn]ω = cons (♯ next (cons (♯ next [ccn]ω))) [cn]³[ccn]ω : Chunks [cn]³[ccn]ω = cons (♯ next [cn]²[ccn]ω) lemma₁ : oddsC [ccn]ω ⋎C [ccn]ω ≥C [ccn]ω lemma₁ = cons (♯ cons (♯ next (cons (♯ cons (♯ next lemma₁))))) lemma : evensC [cn]³[ccn]ω ⋎C tailC [cn]³[ccn]ω ≥C [cn]²[ccn]ω lemma = cons (♯ next (cons (♯ next (cons (♯ cons (♯ next lemma₁)))))) thueMorse : StreamP [cn]³[ccn]ω Bool thueMorse = false ∷ [ ♯ cast lemma (map not (evens thueMorse) ⋎ tail thueMorse) ]
{ "alphanum_fraction": 0.5019157088, "avg_line_length": 31.2065217391, "ext": "agda", "hexsha": "986e860917f273202933829c90bf0efc88eccd5d", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "1b90445566df0d3b4ba6e31bd0bac417b4c0eb0e", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "nad/codata", "max_forks_repo_path": "ThueMorseLeq.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "1b90445566df0d3b4ba6e31bd0bac417b4c0eb0e", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "nad/codata", "max_issues_repo_path": "ThueMorseLeq.agda", "max_line_length": 76, "max_stars_count": 1, "max_stars_repo_head_hexsha": "1b90445566df0d3b4ba6e31bd0bac417b4c0eb0e", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "nad/codata", "max_stars_repo_path": "ThueMorseLeq.agda", "max_stars_repo_stars_event_max_datetime": "2021-02-13T14:48:45.000Z", "max_stars_repo_stars_event_min_datetime": "2021-02-13T14:48:45.000Z", "num_tokens": 2381, "size": 5742 }
{-# OPTIONS --warning=error #-} module UnknownNameInFixityDecl where infix 40 _+_ infixr 60 _*_
{ "alphanum_fraction": 0.7422680412, "avg_line_length": 16.1666666667, "ext": "agda", "hexsha": "0d3b45ecd693f1052e5d3d1e39f9d7ba764b6966", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cruhland/agda", "max_forks_repo_path": "test/Fail/UnknownNameInFixityDecl.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "cruhland/agda", "max_issues_repo_path": "test/Fail/UnknownNameInFixityDecl.agda", "max_line_length": 36, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/Fail/UnknownNameInFixityDecl.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 31, "size": 97 }
module Structure.Relator.Function.Multi where open import Data.Tuple.RaiseTypeᵣ import Data.Tuple.RaiseTypeᵣ.Functions as RaiseType open import Function.Multi import Function.Multi.Functions as Multi import Lvl import Lvl.MultiFunctions as Lvl open import Logic open import Logic.Predicate open import Logic.Predicate.Multi open import Functional open import Numeral.Natural import Structure.Function.Multi as Multi open import Structure.Setoid open import Type private variable ℓ ℓₑ : Lvl.Level module _ (n : ℕ) {ℓ𝓈}{ℓ₁ ℓ₂} {Xs : Types{n}(ℓ𝓈)}{Y : Type{ℓ₁}} where module Names where -- A relator is total when every LHS have at least one RHS in which the relation holds. Total : (Xs ⇉ (Y → Stmt{ℓ₂})) → Stmt Total(φ) = ∀₊(n)(Multi.compose(n) ∃ φ) module _ ⦃ equiv-Y : Equiv{ℓₑ}(Y) ⦄ where -- A relator is a function when every LHS have at least one RHS in which the relation holds. Function : ∀{ℓ𝓈ₑ} → (RaiseType.mapWithLvls(\X ℓₑ → Equiv{ℓₑ}(X)) Xs ℓ𝓈ₑ) ⇉ᵢₙₛₜ ((Xs ⇉ (Y → Type{ℓ₂})) → Stmt) Function = Multi.expl-to-inst(n) (Multi.compose(n) (_$₂_) (Multi.inst-to-expl(n) (Multi.Names.RelationReplacement(f ↦ g ↦ ∀{y₁ y₂} → f(y₁) → g(y₂) → (y₁ ≡ y₂))(n)))) record Total(φ : Xs ⇉ (Y → Stmt{ℓ₂})) : Stmt{ℓ₁ Lvl.⊔ ℓ₂ Lvl.⊔ (Lvl.⨆ ℓ𝓈)} where constructor intro field proof : Names.Total(φ)
{ "alphanum_fraction": 0.6786500367, "avg_line_length": 40.0882352941, "ext": "agda", "hexsha": "9eb2096aa6b201dee66ec139b6b4fadc65f89d01", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_path": "Structure/Relator/Function/Multi.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_path": "Structure/Relator/Function/Multi.agda", "max_line_length": 171, "max_stars_count": 6, "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_path": "Structure/Relator/Function/Multi.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "num_tokens": 491, "size": 1363 }
{-# OPTIONS --without-K --safe #-} module Categories.Category.Instance.Rels where open import Data.Product open import Function open import Level open import Relation.Binary open import Relation.Binary.Construct.Composition open import Relation.Binary.PropositionalEquality open import Categories.Category.Core -- the category whose objects are sets and whose morphisms are binary relations. Rels : ∀ o ℓ → Category (suc o) (suc (o ⊔ ℓ)) (o ⊔ ℓ) Rels o ℓ = record { Obj = Set o ; _⇒_ = λ A B → REL A B (o ⊔ ℓ) ; _≈_ = λ _L_ _R_ → ∀ x y → (x L y → x R y) × (x R y → x L y) ; id = λ x y → Lift ℓ (x ≡ y) ; _∘_ = λ L R → R ; L ; assoc = λ x y → (λ { (b , fxb , c , gbc , hcy) → c , (b , fxb , gbc) , hcy }) , (λ { (c , (b , fxb , gbc) , hcy) → b , fxb , c , gbc , hcy }) ; sym-assoc = λ x y → (λ { (c , (b , fxb , gbc) , hcy) → b , fxb , c , gbc , hcy }) , (λ { (b , fxb , c , gbc , hcy) → c , (b , fxb , gbc) , hcy }) ; identityˡ = λ x y → (λ { (.y , fxy , lift refl) → fxy }) , λ fxy → y , fxy , lift refl ; identityʳ = λ x y → (λ { (.x , lift refl , fxy) → fxy }) , λ fxy → x , lift refl , fxy ; identity² = λ x y → (λ { (_ , lift refl , lift refl) → lift refl }) , (λ { (lift refl) → _ , lift refl , lift refl }) ; equiv = record { refl = λ _ _ → id , id ; sym = λ p x y → swap (p x y) ; trans = λ p q x y → zip (flip _∘′_) _∘′_ (p x y) (q x y) } ; ∘-resp-≈ = λ p q x y → (λ { (b , gxb , fby) → b , proj₁ (q x b) gxb , proj₁ (p b y) fby }) , (λ { (b , ixb , hby) → b , proj₂ (q x b) ixb , proj₂ (p b y) hby }) }
{ "alphanum_fraction": 0.5150943396, "avg_line_length": 38.7804878049, "ext": "agda", "hexsha": "bf095bca062df4acb5e45cdafa48b39267692626", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "b813fa3e685eb4713bace6204b8084a343d549a3", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "bolt12/agda-categories", "max_forks_repo_path": "src/Categories/Category/Instance/Rels.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "b813fa3e685eb4713bace6204b8084a343d549a3", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "bolt12/agda-categories", "max_issues_repo_path": "src/Categories/Category/Instance/Rels.agda", "max_line_length": 90, "max_stars_count": null, "max_stars_repo_head_hexsha": "b813fa3e685eb4713bace6204b8084a343d549a3", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "bolt12/agda-categories", "max_stars_repo_path": "src/Categories/Category/Instance/Rels.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 645, "size": 1590 }
module Imports.Issue5198 (Y : Set₁) where record R : Set₂ where constructor mkR field A : Set₁
{ "alphanum_fraction": 0.6857142857, "avg_line_length": 13.125, "ext": "agda", "hexsha": "1f9efb478283ad0805396f122a411f234517371a", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cruhland/agda", "max_forks_repo_path": "test/Succeed/Imports/Issue5198.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "cruhland/agda", "max_issues_repo_path": "test/Succeed/Imports/Issue5198.agda", "max_line_length": 41, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/Succeed/Imports/Issue5198.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 36, "size": 105 }
module Formalization.SKICombinatorCalculus where import Lvl import Function open import Functional using (_∘_) open import Type open import Structure.Relator.Properties open import Syntax.Transitivity data Term : Type{Lvl.𝟎} where S : Term -- Fusion K : Term -- Constant _·_ : Term → Term → Term infixl 30 _·_ pattern B = S · (K · S) · K -- Composition pattern C = S · (S · (K · B) · S) · (K · K) -- Swapped application pattern I = S · K · K -- Identity of operation pattern SA = (S · I) · I -- Self application pattern W = S · S · (S · K) -- pattern Ω = SA · SA -- pattern SW = S · (K · (S · I)) · K -- Swapped operation T = C Z = B -- Z = C · (C · (B · N · (S · I · I)) · Ω) · I {- TODO: Is this possible? term-fn-type : ∀{ℓ} → Term → Type{Lvl.𝐒(ℓ)} term-fn-type {ℓ} S = ∀{X Y Z : Type{ℓ}} → (X → (Y → Z)) → (X → Y) → (X → Z) term-fn-type {ℓ} K = ∀{X Y : Type{ℓ}} → Y → X → Y term-fn-type {ℓ} (x · y) = {!term-fn-type {ℓ} x!} -} module Derivation where -- TODO: But there are no base cases? data deriv : Term → Type{Lvl.𝟎} where constant : ∀{α β γ ι} → deriv(α · ((K · β) · γ) · ι) → deriv(α · β · ι) fuse : ∀{α β γ δ ι} → deriv(α · (((S · β) · γ) · δ) · ι) → deriv(α · ((β · δ) · (γ · δ)) · ι) _⇒_ : Term → Term → Type a ⇒ b = ∀{α ι} → deriv(α · a · ι) → deriv(α · b · ι) identity : ∀{β} → ((I · β) ⇒ β) identity = constant ∘ fuse -- composition : ∀{α ι a b c} → deriv(α · (B · a · b · c) · ι) → deriv(α · ((a · (b · c))) · ι) -- composition = {!!} -- TODO: Is this really correct? Should be similar to deriv data _⟶_ : Term → Term → Type{Lvl.𝟎} where -- TODO: Use reflexive-transitive closure instead constant : ∀{c t} → (((K · c) · t) ⟶ c) fuse : ∀{a b c} → ((((S · a) · b) · c) ⟶ ((a · c) · (b · c))) comp : ∀{a₁ a₂ b₁ b₂} → (a₁ ⟶ a₂) → (b₁ ⟶ b₂) → ((a₁ · b₁) ⟶ (a₂ · b₂)) refl : ∀{a} → (a ⟶ a) trans : ∀{a b c} → (a ⟶ b) → (b ⟶ c) → (a ⟶ c) infixl 29 _⟶_ instance [⟶]-reflexivity : Reflexivity(_⟶_) [⟶]-reflexivity = intro refl instance [⟶]-transitivity : Transitivity(_⟶_) [⟶]-transitivity = intro trans -- identity : ∀{t} → ((I · t) ⟶ t) pattern identity = trans fuse constant -- compₗ : ∀{a₁ a₂ b} → (a₁ ⟶ a₂) → ((a₁ · b) ⟶ (a₂ · b)) pattern compₗ p = comp p refl -- compᵣ : ∀{a b₁ b₂} → (b₁ ⟶ b₂) → ((a · b₁) ⟶ (a · b₂)) pattern compᵣ p = comp refl p composition : ∀{a b c} → ((B · a · b · c) ⟶ (a · (b · c))) composition {a}{b}{c} = B · a · b · c 🝖-[ refl ] ((S · (K · S) · K · a) · b) · c 🝖-[ compₗ (compₗ fuse) ] (((K · S · a) · (K · a)) · b) · c 🝖-[ compₗ (compₗ (compₗ constant)) ] ((S · (K · a)) · b) · c 🝖-[ fuse ] (K · a · c) · (b · c) 🝖-[ compₗ constant ] a · (b · c) 🝖-end swapped-application : ∀{a b c} → ((C · a · b · c) ⟶ ((a · c) · b)) swapped-application {a}{b}{c} = C · a · b · c 🝖-[ refl ] S · (S · (K · B) · S) · (K · K) · a · b · c 🝖-[ compₗ (compₗ fuse) ] (S · (K · B) · S · a) · (K · K · a) · b · c 🝖-[ compₗ (compₗ (comp fuse constant)) ] (K · B · a · (S · a)) · K · b · c 🝖-[ compₗ (compₗ (compₗ (compₗ constant))) ] (B · (S · a)) · K · b · c 🝖-[ compₗ composition ] (S · a) · (K · b) · c 🝖-[ fuse ] (a · c) · (K · b · c) 🝖-[ compᵣ constant ] (a · c) · b 🝖-end apply-self : ∀{t} → ((SA · t) ⟶ (t · t)) apply-self = trans fuse (comp identity identity) swapping : ∀{a b} → ((SW · a · b) ⟶ (b · a)) swapping {a}{b} = S · (K · (S · I)) · K · a · b 🝖-[ compₗ fuse ] (K · (S · I) · a) · (K · a) · b 🝖-[ compₗ (compₗ constant) ] (S · I) · (K · a) · b 🝖-[ fuse ] I · b · (K · a · b) 🝖-[ comp identity constant ] b · a 🝖-end module Boolean where TRUE = K -- True FALSE = S · K -- False NOT = FALSE · TRUE -- Not (Negation) OR = TRUE -- Or (Disjunction) AND = FALSE -- And (Conjunction) IsTrue : Term → Type{Lvl.𝟎} IsTrue(a) = ∀{t f} → ((a · t · f) ⟶ t) IsFalse : Term → Type{Lvl.𝟎} IsFalse(a) = ∀{t f} → ((a · t · f) ⟶ f) reduce-true-is-true : ∀{t} → (t ⟶ TRUE) → IsTrue(t) reduce-true-is-true tT = (compₗ (compₗ tT)) 🝖 constant reduce-false-is-false : ∀{t} → (t ⟶ FALSE) → IsFalse(t) reduce-false-is-false tT = (compₗ (compₗ tT)) 🝖 identity true : IsTrue(TRUE) true = constant false : IsFalse(FALSE) false = identity not-true-is-false : ∀{t} → IsTrue(t) → IsFalse(t · NOT) not-true-is-false t-true = (compₗ t-true) 🝖 fuse 🝖 constant {-not-false-is-true : ∀{t} → IsFalse(t) → IsTrue(t · NOT) not-false-is-true {term} t-false {t}{f} = term · NOT · t · f 🝖-[ refl ] term · (S · K · K) · t · f 🝖-[ {!!} ] f · (S · K · K) · t · f 🝖-[ {!!} ] t 🝖-end -} not-true : IsFalse(TRUE · NOT) not-true {t}{f} = not-true-is-false constant {-TRUE · NOT · t · f 🝖-[ refl ] TRUE · (FALSE · TRUE) · t · f 🝖-[ refl ] K · (S · K · K) · t · f 🝖-[ compₗ constant ] S · K · K · f 🝖-[ fuse ] K · f · (K · f) 🝖-[ constant ] f 🝖-end-} {- not-false : IsTrue(FALSE · NOT) not-false {t}{f} = FALSE · NOT · t · f 🝖-[ refl ] FALSE · (FALSE · TRUE) · t · f 🝖-[ refl ] S · K · (S · K · K) · t · f 🝖-[ compₗ fuse ] K · t · (S · K · K · t) · f 🝖-[ compₗ constant ] t · f 🝖-[ {!!} ] -- TODO: ??? t 🝖-end -- not-false-is-true identity -} or-true-true : IsTrue(TRUE · OR · TRUE) or-true-true = reduce-true-is-true constant or-true-false : IsTrue(TRUE · OR · FALSE) or-true-false = reduce-true-is-true constant or-false-true : IsTrue(FALSE · OR · TRUE) or-false-true = reduce-true-is-true(fuse 🝖 constant) or-false-true2 : IsTrue(FALSE · OR · TRUE) or-false-true2 = reduce-true-is-true(fuse 🝖 constant) or-false-false : IsFalse(FALSE · OR · FALSE) or-false-false = reduce-false-is-false(fuse 🝖 constant) and-true-true : IsTrue(TRUE · TRUE · AND) and-true-true = reduce-true-is-true(constant) and-true-false : IsFalse(TRUE · FALSE · AND) and-true-false = reduce-false-is-false(constant) and-false-true : IsFalse(FALSE · TRUE · AND) and-false-true = reduce-false-is-false(identity) and-false-false : IsFalse(FALSE · FALSE · AND) and-false-false = reduce-false-is-false(fuse 🝖 constant)
{ "alphanum_fraction": 0.4647172908, "avg_line_length": 34.9114583333, "ext": "agda", "hexsha": "7c91eabfdf8b0232a16763061110567ce6f60211", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_path": "Formalization/SKICombinatorCalculus.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_path": "Formalization/SKICombinatorCalculus.agda", "max_line_length": 101, "max_stars_count": 6, "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_path": "Formalization/SKICombinatorCalculus.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "num_tokens": 2632, "size": 6703 }
{-# OPTIONS --cubical #-} module Cubical.Foundations.Equiv.Fiberwise where open import Cubical.Core.Everything open import Cubical.Foundations.Everything module _ {a p q} {A : Type a} (P : A → Type p) (Q : A → Type q) (f : ∀ x → P x → Q x) where private total : (Σ A P) → (Σ A Q) total = (\ p → p .fst , f (p .fst) (p .snd)) -- Thm 4.7.6 fibers-total : ∀ {xv} → Iso (fiber total (xv)) (fiber (f (xv .fst)) (xv .snd)) fibers-total {xv} = iso h g h-g g-h where h : ∀ {xv} → fiber total xv → fiber (f (xv .fst)) (xv .snd) h {xv} (p , eq) = J (\ xv eq → fiber (f (xv .fst)) (xv .snd)) ((p .snd) , refl) eq g : ∀ {xv} → fiber (f (xv .fst)) (xv .snd) → fiber total xv g {xv} (p , eq) = (xv .fst , p) , (\ i → _ , eq i) h-g : ∀ {xv} y → h {xv} (g {xv} y) ≡ y h-g {x , v} (p , eq) = J (λ _ eq₁ → h (g (p , eq₁)) ≡ (p , eq₁)) (JRefl (λ xv₁ eq₁ → fiber (f (xv₁ .fst)) (xv₁ .snd)) ((p , refl))) (eq) g-h : ∀ {xv} y → g {xv} (h {xv} y) ≡ y g-h {xv} ((a , p) , eq) = J (λ _ eq₁ → g (h ((a , p) , eq₁)) ≡ ((a , p) , eq₁)) (cong g (JRefl (λ xv₁ eq₁ → fiber (f (xv₁ .fst)) (xv₁ .snd)) (p , refl))) eq -- half of Thm 4.7.7 (fiberwise equivalences) fiberEquiv : ([tf] : isEquiv total) → ∀ x → isEquiv (f x) fiberEquiv [tf] x .equiv-proof y = retractIsContr (fibers-total .Iso.inv) (fibers-total .Iso.fun) (fibers-total .Iso.rightInv) ([tf] .equiv-proof (x , y)) module _ {ℓ : Level} {U : Type ℓ} {ℓr} (_~_ : U → U → Type ℓr) (idTo~ : ∀ {A B} → A ≡ B → A ~ B) (c : ∀ A → isContr (Σ U \ X → A ~ X)) where isContrToUniv : ∀ {A B} → isEquiv (idTo~ {A} {B}) isContrToUniv {A} {B} = fiberEquiv (λ z → A ≡ z) (λ z → A ~ z) (\ B → idTo~ {A} {B}) (λ { .equiv-proof y → isContrSigma ((_ , refl) , (\ z → contrSingl (z .snd))) \ a → isContrPath (c A) _ _ }) B
{ "alphanum_fraction": 0.4386385427, "avg_line_length": 42.5714285714, "ext": "agda", "hexsha": "24c09bb2fa559d128c93657781934e4d334afaaa", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "df4ef7edffd1c1deb3d4ff342c7178e9901c44f1", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "limemloh/cubical", "max_forks_repo_path": "Cubical/Foundations/Equiv/Fiberwise.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "df4ef7edffd1c1deb3d4ff342c7178e9901c44f1", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "limemloh/cubical", "max_issues_repo_path": "Cubical/Foundations/Equiv/Fiberwise.agda", "max_line_length": 140, "max_stars_count": null, "max_stars_repo_head_hexsha": "df4ef7edffd1c1deb3d4ff342c7178e9901c44f1", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "limemloh/cubical", "max_stars_repo_path": "Cubical/Foundations/Equiv/Fiberwise.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 828, "size": 2086 }
{-# OPTIONS --without-K #-} open import HoTT {- Useful lemmas for computing the effect of transporting a function - across an equivalence in the domain or codomain -} module cohomology.FunctionOver where {- transporting a function along an equivalcence or path in the domain -} module _ {i} {j} {B : Type i} {C : Type j} (g : B → C) where domain-over-path : {A : Type i} (p : A == B) → g ∘ coe p == g [ (λ D → (D → C)) ↓ p ] domain-over-path idp = idp domain-over-equiv : {A : Type i} (e : A ≃ B) → g ∘ –> e == g [ (λ D → (D → C)) ↓ ua e ] domain-over-equiv e = ↓-app→cst-in $ λ q → ap g (↓-idf-ua-out e q) module _ {i} {j} {A : Type i} {C : Type j} (f : A → C) where domain!-over-path : {B : Type i} (p : A == B) → f == f ∘ coe! p [ (λ D → (D → C)) ↓ p ] domain!-over-path idp = idp domain!-over-equiv : {B : Type i} (e : A ≃ B) → f == f ∘ <– e [ (λ D → (D → C)) ↓ ua e ] domain!-over-equiv e = ↓-app→cst-in $ λ q → ap f (! (<–-inv-l e _) ∙ ap (<– e) (↓-idf-ua-out e q)) {- transporting a ptd function along a equivalence or path in the domain -} module _ {i} {j} {Y : Ptd i} {Z : Ptd j} (g : fst (Y ⊙→ Z)) where domain-over-⊙path : {X : Ptd i} (p : fst X == fst Y) (q : coe p (snd X) == snd Y) → g ⊙∘ (coe p , q) == g [ (λ W → fst (W ⊙→ Z)) ↓ pair= p (↓-idf-in p q) ] domain-over-⊙path idp idp = idp domain-over-⊙equiv : {X : Ptd i} (e : fst X ≃ fst Y) (q : –> e (snd X) == snd Y) → g ⊙∘ ⊙–> e q == g [ (λ W → fst (W ⊙→ Z)) ↓ ⊙ua e q ] domain-over-⊙equiv {X = X} e q = ap (λ w → g ⊙∘ w) lemma ◃ domain-over-⊙path (ua e) (coe-β e (snd X) ∙ q) where lemma : Path {A = fst (X ⊙→ Y)}  (⊙–> e q) (coe (ua e) , coe-β e (snd X) ∙ q) lemma = ! $ ⊙λ= (coe-β e) idp module _ {i} {j} {X : Ptd i} {Z : Ptd j} (f : fst (X ⊙→ Z)) where domain!-over-⊙path : {Y : Ptd i} (p : fst X == fst Y) (q : coe p (snd X) == snd Y) → f == f ⊙∘ (coe! p , ap (coe! p) (! q) ∙ coe!-inv-l p (snd X)) [ (λ W → fst (W ⊙→ Z)) ↓ pair= p (↓-idf-in p q) ] domain!-over-⊙path idp idp = idp domain!-over-⊙equiv : {Y : Ptd i} (e : fst X ≃ fst Y) (q : –> e (snd X) == snd Y) → f == f ⊙∘ (⊙<– e q) [ (λ W → fst (W ⊙→ Z)) ↓ ⊙ua e q ] domain!-over-⊙equiv {Y = Y} e q = (ap (λ w → f ⊙∘ w) (lemma e q) ∙ ! (⊙∘-assoc f _ (–> e , q))) ◃ domain-over-⊙equiv (f ⊙∘ (<– e , ap (<– e) (! q) ∙ <–-inv-l e (snd X))) e q where lemma : {X Y : Ptd i} (e : fst X ≃ fst Y) (q : –> e (snd X) == snd Y) → ⊙idf X == ((<– e , ap (<– e) (! q) ∙ <–-inv-l e (snd X)) ⊙∘ (–> e , q)) lemma {X = X} e idp = ! $ ⊙λ= (<–-inv-l e) (! (∙-unit-r _)) {- transporting a function along an equivalence or path in the codomain -} module _ {i} {j} {A : Type i} {B : Type j} (f : A → B) where codomain-over-path : {C : Type j} (p : B == C) → f == coe p ∘ f [ (λ D → (A → D)) ↓ p ] codomain-over-path idp = idp codomain-over-equiv : {C : Type j} (e : B ≃ C) → f == –> e ∘ f [ (λ D → (A → D)) ↓ ua e ] codomain-over-equiv e = ↓-cst→app-in $ λ _ → ↓-idf-ua-in e idp module _ {i} {j} {A : Type i} {C : Type j} (g : A → C) where codomain!-over-path : {B : Type j} (p : B == C) → coe! p ∘ g == g [ (λ D → (A → D)) ↓ p ] codomain!-over-path idp = idp codomain!-over-equiv : {B : Type j} (e : B ≃ C) → <– e ∘ g == g [ (λ D → (A → D)) ↓ ua e ] codomain!-over-equiv e = ↓-cst→app-in $ λ _ → ↓-idf-ua-in e (<–-inv-r e _) {- transporting a ptd function along a equivalence or path in the codomain -} module _ {i} {j} {X : Ptd i} {Y : Ptd j} (f : fst (X ⊙→ Y)) where codomain-over-⊙path : {Z : Ptd j} (p : fst Y == fst Z) (q : coe p (snd Y) == snd Z) → f == (coe p , q) ⊙∘ f [ (λ W → fst (X ⊙→ W)) ↓ pair= p (↓-idf-in p q) ] codomain-over-⊙path idp idp = pair= idp (! (∙-unit-r _ ∙ ap-idf (snd f))) codomain-over-⊙equiv : {Z : Ptd j} (e : fst Y ≃ fst Z) (q : –> e (snd Y) == snd Z) → f == (–> e , q) ⊙∘ f [ (λ W → fst (X ⊙→ W)) ↓ ⊙ua e q ] codomain-over-⊙equiv {Z = Z} e q = codomain-over-⊙path (ua e) (coe-β e (snd Y) ∙ q) ▹ ap (λ w → w ⊙∘ f) lemma where lemma : Path {A = fst (Y ⊙→ Z)} (coe (ua e) , coe-β e (snd Y) ∙ q) (–> e , q) lemma = ⊙λ= (coe-β e) idp module _ {i} {j} {X : Ptd i} {Z : Ptd j} (g : fst (X ⊙→ Z)) where codomain!-over-⊙path : {Y : Ptd j} (p : fst Y == fst Z) (q : coe p (snd Y) == snd Z) → (coe! p , ap (coe! p) (! q) ∙ coe!-inv-l p (snd Y)) ⊙∘ g == g [ (λ W → fst (X ⊙→ W)) ↓ pair= p (↓-idf-in p q) ] codomain!-over-⊙path idp idp = pair= idp (∙-unit-r _ ∙ ap-idf (snd g)) codomain!-over-⊙equiv : {Y : Ptd j} (e : fst Y ≃ fst Z) (q : –> e (snd Y) == snd Z) → (⊙<– e q) ⊙∘ g == g [ (λ W → fst (X ⊙→ W)) ↓ ⊙ua e q ] codomain!-over-⊙equiv {Y = Y} e q = codomain-over-⊙equiv ((<– e , ap (<– e) (! q) ∙ <–-inv-l e (snd Y)) ⊙∘ g) e q ▹ (! (⊙∘-assoc (–> e , q) _ g) ∙ ap (λ w → w ⊙∘ g) (lemma e q) ∙ ⊙∘-unit-l g) where lemma : {Y Z : Ptd j} (e : fst Y ≃ fst Z) (q : –> e (snd Y) == snd Z) → ((–> e , q) ⊙∘ (<– e , ap (<– e) (! q) ∙ <–-inv-l e (snd Y))) == ⊙idf Z lemma {Y = Y} e idp = ⊙λ= (<–-inv-r e) (ap (λ w → w ∙ idp) (<–-inv-adj e (snd Y))) {- transporting a group homomorphism along an isomorphism -} domain-over-iso : ∀ {i j} {G H : Group i} {K : Group j} (φ : G →ᴳ H) (ie : is-equiv (GroupHom.f φ)) (ψ : G →ᴳ K) (χ : H →ᴳ K) → GroupHom.f ψ == GroupHom.f χ [ (λ A → A → Group.El K) ↓ ua (GroupHom.f φ , ie) ] → ψ == χ [ (λ J → J →ᴳ K) ↓ group-ua (φ , ie) ] domain-over-iso {K = K} φ ie ψ χ p = hom=-↓ _ _ $ ↓-ap-out _ Group.El _ $ transport (λ q → GroupHom.f ψ == GroupHom.f χ [ (λ A → A → Group.El K) ↓ q ]) (! (group-ua-el (φ , ie))) p codomain-over-iso : ∀ {i j} {G : Group i} {H K : Group j} (φ : H →ᴳ K) (ie : is-equiv (GroupHom.f φ)) (ψ : G →ᴳ H) (χ : G →ᴳ K) → GroupHom.f ψ == GroupHom.f χ [ (λ A → Group.El G → A) ↓ ua (GroupHom.f φ , ie) ] → ψ == χ [ (λ J → G →ᴳ J) ↓ group-ua (φ , ie) ] codomain-over-iso {G = G} φ ie ψ χ p = hom=-↓ _ _ $ ↓-ap-out _ Group.El _ $ transport (λ q → GroupHom.f ψ == GroupHom.f χ [ (λ A → Group.El G → A) ↓ q ]) (! (group-ua-el (φ , ie))) p
{ "alphanum_fraction": 0.4611164892, "avg_line_length": 39.7307692308, "ext": "agda", "hexsha": "1e691f3c08acf9c561e14ae222ef7c765d961f76", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "1695a7f3dc60177457855ae846bbd86fcd96983e", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "danbornside/HoTT-Agda", "max_forks_repo_path": "cohomology/FunctionOver.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "1695a7f3dc60177457855ae846bbd86fcd96983e", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "danbornside/HoTT-Agda", "max_issues_repo_path": "cohomology/FunctionOver.agda", "max_line_length": 79, "max_stars_count": null, "max_stars_repo_head_hexsha": "1695a7f3dc60177457855ae846bbd86fcd96983e", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "danbornside/HoTT-Agda", "max_stars_repo_path": "cohomology/FunctionOver.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 2840, "size": 6198 }
module Issue396b where import Common.Irrelevance data A : Set where -- just an irrelevant field record PrfA : Set where field .f : A Foo : Set -> Set1 Foo R = (P : R → Set) → ((x : R) → P x → P x) → (x y : R) → P x → P y foo : Foo PrfA foo P hyp x y = hyp x -- Error was: -- x != y of type ⊤ -- when checking that the expression hyp x has type P x → P y record Top : Set where -- only singleton components record R : Set where field p1 : PrfA .p2 : A p3 : Top bla : Foo R bla P hyp x y = hyp x
{ "alphanum_fraction": 0.5685557587, "avg_line_length": 17.09375, "ext": "agda", "hexsha": "0053e15fad3a1fecda2e8b4ea4704120293a48ee", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "masondesu/agda", "max_forks_repo_path": "test/succeed/Issue396b.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "masondesu/agda", "max_issues_repo_path": "test/succeed/Issue396b.agda", "max_line_length": 61, "max_stars_count": 1, "max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/agda-kanso", "max_stars_repo_path": "test/succeed/Issue396b.agda", "max_stars_repo_stars_event_max_datetime": "2019-11-27T04:41:05.000Z", "max_stars_repo_stars_event_min_datetime": "2019-11-27T04:41:05.000Z", "num_tokens": 188, "size": 547 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Maybe-related properties ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} module Data.Maybe.Properties where open import Algebra import Algebra.Structures as Structures import Algebra.FunctionProperties as FunctionProperties open import Data.Maybe.Base open import Data.Maybe.Relation.Unary.All using (All; just; nothing) open import Data.Product using (_,_) open import Function open import Relation.Binary using (Decidable) open import Relation.Binary.PropositionalEquality open import Relation.Nullary using (yes; no) ------------------------------------------------------------------------ -- Equality module _ {a} {A : Set a} where just-injective : ∀ {x y} → (Maybe A ∋ just x) ≡ just y → x ≡ y just-injective refl = refl ≡-dec : Decidable _≡_ → Decidable {A = Maybe A} _≡_ ≡-dec _≟_ nothing nothing = yes refl ≡-dec _≟_ (just x) nothing = no λ() ≡-dec _≟_ nothing (just y) = no λ() ≡-dec _≟_ (just x) (just y) with x ≟ y ... | yes refl = yes refl ... | no x≢y = no (x≢y ∘ just-injective) ------------------------------------------------------------------------ -- map map-id : map id ≗ id {A = Maybe A} map-id (just x) = refl map-id nothing = refl map-id₂ : ∀ {f : A → A} {mx} → All (λ x → f x ≡ x) mx → map f mx ≡ mx map-id₂ (just eq) = cong just eq map-id₂ nothing = refl module _ {a b} {A : Set a} {B : Set b} where map-<∣>-commute : ∀ (f : A → B) mx my → map f (mx <∣> my) ≡ map f mx <∣> map f my map-<∣>-commute f (just x) my = refl map-<∣>-commute f nothing my = refl map-cong : {f g : A → B} → f ≗ g → map f ≗ map g map-cong f≗g (just x) = cong just (f≗g x) map-cong f≗g nothing = refl map-cong₂ : ∀ {f g : A → B} {mx} → All (λ x → f x ≡ g x) mx → map f mx ≡ map g mx map-cong₂ (just eq) = cong just eq map-cong₂ nothing = refl module _ {a b c} {A : Set a} {B : Set b} {C : Set c} where map-compose : {g : B → C} {f : A → B} → map (g ∘ f) ≗ map g ∘ map f map-compose (just x) = refl map-compose nothing = refl ------------------------------------------------------------------------ -- maybe module _ {a b} {A : Set a} {B : Set b} where maybe-map : ∀ {c} {C : Maybe B → Set c} (j : (x : B) → C (just x)) (n : C nothing) (f : A → B) ma → maybe {B = C} j n (map f ma) ≡ maybe {B = C ∘ map f} (j ∘ f) n ma maybe-map j n f (just x) = refl maybe-map j n f nothing = refl maybe′-map : ∀ {c} {C : Set c} j (n : C) (f : A → B) ma → maybe′ j n (map f ma) ≡ maybe′ (j ∘′ f) n ma maybe′-map = maybe-map ------------------------------------------------------------------------ -- _<∣>_ module _ {a} {A : Set a} where open FunctionProperties {A = Maybe A} _≡_ <∣>-assoc : Associative _<∣>_ <∣>-assoc (just x) y z = refl <∣>-assoc nothing y z = refl <∣>-identityˡ : LeftIdentity nothing _<∣>_ <∣>-identityˡ (just x) = refl <∣>-identityˡ nothing = refl <∣>-identityʳ : RightIdentity nothing _<∣>_ <∣>-identityʳ (just x) = refl <∣>-identityʳ nothing = refl <∣>-identity : Identity nothing _<∣>_ <∣>-identity = <∣>-identityˡ , <∣>-identityʳ module _ {a} (A : Set a) where open Structures {A = Maybe A} _≡_ <∣>-isMagma : IsMagma _<∣>_ <∣>-isMagma = record { isEquivalence = isEquivalence ; ∙-cong = cong₂ _<∣>_ } <∣>-isSemigroup : IsSemigroup _<∣>_ <∣>-isSemigroup = record { isMagma = <∣>-isMagma ; assoc = <∣>-assoc } <∣>-isMonoid : IsMonoid _<∣>_ nothing <∣>-isMonoid = record { isSemigroup = <∣>-isSemigroup ; identity = <∣>-identity } <∣>-semigroup : Semigroup a a <∣>-semigroup = record { isSemigroup = <∣>-isSemigroup } <∣>-monoid : Monoid a a <∣>-monoid = record { isMonoid = <∣>-isMonoid }
{ "alphanum_fraction": 0.5048247842, "avg_line_length": 28.3309352518, "ext": "agda", "hexsha": "695f684cef5a1f5012ed3808c3fccf5166157cbc", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "omega12345/agda-mode", "max_forks_repo_path": "test/asset/agda-stdlib-1.0/Data/Maybe/Properties.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "omega12345/agda-mode", "max_issues_repo_path": "test/asset/agda-stdlib-1.0/Data/Maybe/Properties.agda", "max_line_length": 79, "max_stars_count": null, "max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "omega12345/agda-mode", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Data/Maybe/Properties.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1391, "size": 3938 }
-- 2014-05-26 Andrea & Andreas, AIM XIX -- Too eager pruning module succeed.Issue1147 where open import Common.Equality open import Common.Product open import Common.Prelude postulate A : Set if_then_else1_ : ∀ {A : Set1} → Bool → A → A → A if true then t else1 f = t if false then t else1 f = f test1 : let H : Set; H = _; M : Bool -> Set → Set; M = _ in {z : Set} → H ≡ (M true z) × M ≡ (\ b z → if b then A else1 z) test1 = refl , refl test2 : let H : Set; H = _; M : (Bool -> Bool) -> Set → Set; M = _ in {z : Set} → H ≡ (M (\ _ -> true) z) × M ≡ (\ b z → if b true then A else1 z) test2 = refl , refl test3 : let H : Set; H = _; M : (Bool × Bool) -> Set → Set; M = _ in {z : Set} {b : Bool} → H ≡ (M (true , b) z) × M ≡ (\ b z → if proj₁ b then A else1 z) test3 = refl , refl -- Also for defined functions fun : Bool → Bool fun true = true fun false = false works4 : let H : Set; H = _; M : (Bool -> Bool) -> Set → Set; M = _ in {z : Set} → M ≡ (\ b z → if b true then A else1 z) × H ≡ (M fun z) works4 = refl , refl test4 : let H : Set; H = _; M : (Bool -> Bool) -> Set → Set; M = _ in {z : Set} → H ≡ (M fun z) × M ≡ (\ b z → if b true then A else1 z) test4 = refl , refl
{ "alphanum_fraction": 0.5548117155, "avg_line_length": 31.4473684211, "ext": "agda", "hexsha": "0d9688bb9573c684b5d6f5911aa9ece2ac7c88b1", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_forks_event_min_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "masondesu/agda", "max_forks_repo_path": "test/succeed/Issue1147.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "masondesu/agda", "max_issues_repo_path": "test/succeed/Issue1147.agda", "max_line_length": 154, "max_stars_count": 1, "max_stars_repo_head_hexsha": "477c8c37f948e6038b773409358fd8f38395f827", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "larrytheliquid/agda", "max_stars_repo_path": "test/succeed/Issue1147.agda", "max_stars_repo_stars_event_max_datetime": "2018-10-10T17:08:44.000Z", "max_stars_repo_stars_event_min_datetime": "2018-10-10T17:08:44.000Z", "num_tokens": 459, "size": 1195 }
------------------------------------------------------------------------------ -- Well-founded relation on lists ------------------------------------------------------------------------------ {-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} module FOT.FOTC.Data.List.WellFoundedRelationsSL {A : Set} where open import Data.Product open import Data.List hiding ( length ) open import Data.Nat open import Induction.Nat open import Induction.WellFounded open import Relation.Binary.PropositionalEquality ------------------------------------------------------------------------------ -- We use our own version of the function length because we have -- better reductions. length : List A → ℕ length [] = 0 length (x ∷ xs) = 1 + length xs open module II = Induction.WellFounded.Inverse-image {_<_ = _<′_} length -- Well-founded relation on lists based on their length. LTL : List A → List A → Set LTL xs ys = length xs <′ length ys -- The relation LTL is well-founded (using the image inverse -- combinator). wfLTL : Well-founded LTL wfLTL = II.well-founded <′-well-founded -- Well-founded relation on lists based on their structure. LTC : List A → List A → Set LTC xs ys = Σ A (λ a → ys ≡ a ∷ xs) LTC→LTL : ∀ {xs ys} → LTC xs ys → LTL xs ys LTC→LTL (x , refl) = ≤′-refl open module S = Induction.WellFounded.Subrelation {_<₁_ = LTC} LTC→LTL -- The relation LTC is well-founded (using the subrelation combinator). wfLTC : Well-founded LTC wfLTC = S.well-founded wfLTL
{ "alphanum_fraction": 0.5838006231, "avg_line_length": 31.4705882353, "ext": "agda", "hexsha": "3670fc640cd2937c820ee43f81ad0a8cd56c1199", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "asr/fotc", "max_forks_repo_path": "notes/FOT/FOTC/Data/List/WellFoundedRelationsSL.agda", "max_issues_count": 2, "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "asr/fotc", "max_issues_repo_path": "notes/FOT/FOTC/Data/List/WellFoundedRelationsSL.agda", "max_line_length": 78, "max_stars_count": 11, "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/fotc", "max_stars_repo_path": "notes/FOT/FOTC/Data/List/WellFoundedRelationsSL.agda", "max_stars_repo_stars_event_max_datetime": "2021-09-12T16:09:54.000Z", "max_stars_repo_stars_event_min_datetime": "2015-09-03T20:53:42.000Z", "num_tokens": 389, "size": 1605 }
module Issue486 where record ⊤ : Set where constructor tt record Pub (A : Set) : Set where field fi : A abstract abs : ⊤ abs = fi where open Pub record {fi = tt}
{ "alphanum_fraction": 0.6174863388, "avg_line_length": 12.2, "ext": "agda", "hexsha": "808c3aa8902c4159bc1f5e3410128eed75c46303", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "masondesu/agda", "max_forks_repo_path": "test/succeed/Issue486.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "masondesu/agda", "max_issues_repo_path": "test/succeed/Issue486.agda", "max_line_length": 35, "max_stars_count": 1, "max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/agda-kanso", "max_stars_repo_path": "test/succeed/Issue486.agda", "max_stars_repo_stars_event_max_datetime": "2019-11-27T04:41:05.000Z", "max_stars_repo_stars_event_min_datetime": "2019-11-27T04:41:05.000Z", "num_tokens": 59, "size": 183 }
------------------------------------------------------------------------ -- A definability result: A "closed value" is the semantics of a -- closed term if and only if it satisfies all "Kripke predicates" ------------------------------------------------------------------------ -- This module is based on parts of Frederik Ramcke's (at the time of -- writing forthcoming) MSc thesis, "On Definability and Normalization -- by Evaluation in the Logical Framework". I have not followed -- Ramcke's development to the letter, but I have taken inspiration -- from it. Ramcke seems to in turn have taken inspiration from Jung -- and Tiuryn's "A New Characterization of Lambda Definability". import Axiom.Extensionality.Propositional as E open import Level using (Level) open import Data.Universe -- The code makes use of the assumption that propositional equality is -- extensional for functions. module README.DependentlyTyped.Definability (Uni₀ : Universe Level.zero Level.zero) (ext : E.Extensionality Level.zero Level.zero) where open import Data.Product as Prod renaming (curry to c) open import Function.Base hiding (_∋_) renaming (const to k) open import Function.Equality using (_⟨$⟩_) open import Function.Equivalence using (_⇔_; module Equivalence; equivalence) open import README.DependentlyTyped.NBE Uni₀ ext open import README.DependentlyTyped.NormalForm Uni₀ open import README.DependentlyTyped.Term Uni₀ open import Relation.Binary.PropositionalEquality as P using (_≡_) -- Predicates. Predicate : Set₁ Predicate = ∀ {Γ σ} → Value Γ σ → Set private variable Γ Δ : Ctxt Γ₊ : Ctxt₊ Γ σ τ : Type Γ P : Predicate -- Kripke predicates. record Kripke (P : Predicate) : Set where field -- Single-step weakening. weaken₁ : {v : Value Γ σ} → P v → P (v /̂Val ŵk[ τ ]) -- For π-types Kripke predicates have to be defined in a certain -- way (up to logical equivalence). definition-for-π : ∀ {σ τ} {f : Value Γ (Type-π σ τ)} → P f ⇔ (∀ (Γ₊ : Ctxt₊ Γ) {v : Value (Γ ++₊ Γ₊) (σ /̂ ŵk₊ Γ₊)} → P v → P ((f /̂Val ŵk₊ Γ₊) ˢ v)) -- Weakening. weaken : {v : Value Γ σ} (Γ₊ : Ctxt₊ Γ) → P v → P (v /̂Val ŵk₊ Γ₊) weaken ε = id weaken (σ ◅ Γ₊) = weaken Γ₊ ∘ weaken₁ -- A "fundamental theorem" for Kripke predicates. fundamental : {ρ̂ : Γ ⇨̂ Δ} → (∀ {σ} (x : Γ ∋ σ) → P (x /̂∋ ρ̂)) → (t : Γ ⊢ σ) → P (⟦ t ⟧ /̂Val ρ̂) fundamental hyp (var x) = hyp x fundamental hyp (t₁ · t₂) = (Equivalence.to definition-for-π ⟨$⟩ fundamental hyp t₁) ε (fundamental hyp t₂) fundamental hyp (ƛ t) = Equivalence.from definition-for-π ⟨$⟩ λ Δ₊ p → fundamental (λ { zero → p ; (suc x) → weaken Δ₊ (hyp x) }) t -- A special case for closed terms. fundamental-closed : {σ : Type ε} → (t : ε ⊢ σ) → P ⟦ t ⟧ fundamental-closed = fundamental (λ ()) open Kripke -- A predicate based on V̌alue. ∃-V̌alue : Predicate ∃-V̌alue {Γ = Γ} {σ = σ} v = ∃ λ (v̌ : V̌alue Γ σ) → v ≅-Value ⟦̌ v̌ ⟧ -- ∃-V̌alue is a Kripke predicate. ∃-V̌alue-Kripke : Kripke ∃-V̌alue weaken₁ ∃-V̌alue-Kripke = Prod.map ([_⟶_].function w̌eaken _) (λ { P.refl → [_⟶_].corresponds w̌eaken _ _ }) definition-for-π ∃-V̌alue-Kripke {Γ = Γ} {σ = σ} {τ = τ} {f = f} = equivalence (λ { (f , P.refl) Γ₊ (v , P.refl) → proj₁ f Γ₊ v , proj₂ f Γ₊ v }) (λ hyp → let g : V̌alue-π Γ _ _ (IType-π σ τ) g = λ Γ₊ v → proj₁ (hyp Γ₊ (v , P.refl)) lemma : f ≅-Value ⟦̌ _ ∣ g ⟧-π lemma = [ f ] ≡⟨⟩ [ c ((f /̂Val ŵk₊ (_ ◅ ε)) ˢ ⟦ var zero ⟧n) ] ≡⟨ curry-cong (ˢ-cong (P.refl {x = [ f /̂Val _ ]}) (P.sym $ ňeutral-to-normal-identity _ _)) ⟩ [ c ((f /̂Val ŵk₊ (_ ◅ ε)) ˢ ⟦ ňeutral-to-normal _ (var zero) ⟧n) ] ≡⟨⟩ [ c ((f /̂Val ŵk₊ (_ ◅ ε)) ˢ ⟦̌ řeflect _ (var zero) ⟧) ] ≡⟨ curry-cong (proj₂ (hyp _ _)) ⟩ [ c ⟦̌ g (_ ◅ ε) (řeflect _ (var zero)) ⟧ ] ≡⟨ P.sym (unfold-⟦̌∣⟧-π _ g) ⟩ [ ⟦̌ _ ∣ g ⟧-π ] ∎ in ( g , (λ Γ₊ v → [ (⟦̌ _ ∣ g ⟧-π /̂Val ŵk₊ Γ₊) ˢ ⟦̌ v ⟧ ] ≡⟨ ˢ-cong (/̂Val-cong (P.sym lemma) P.refl) P.refl ⟩ [ (f /̂Val ŵk₊ Γ₊) ˢ ⟦̌ v ⟧ ] ≡⟨ proj₂ (hyp _ _) ⟩ [ ⟦̌ g Γ₊ v ⟧ ] ∎) ) , lemma ) where open P.≡-Reasoning -- The definability result. definability : {σ : Type ε} {v : Value ε σ} → (∃ λ (t : ε ⊢ σ) → v ≡ ⟦ t ⟧) ⇔ ({P : Predicate} → Kripke P → P v) definability = equivalence (λ { (t , P.refl) kripke → fundamental-closed kripke t }) (λ hyp → Prod.map ([_⟶_].function V̌al-subst.trans _) ≅-Value-⇒-≡ (hyp ∃-V̌alue-Kripke))
{ "alphanum_fraction": 0.5078988942, "avg_line_length": 32.4615384615, "ext": "agda", "hexsha": "eeb7da04ca16a278f8a1bfef0edfc9fb2197953d", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "498f8aefc570f7815fd1d6616508eeb92c52abce", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "nad/dependently-typed-syntax", "max_forks_repo_path": "README/DependentlyTyped/Definability.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "498f8aefc570f7815fd1d6616508eeb92c52abce", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "nad/dependently-typed-syntax", "max_issues_repo_path": "README/DependentlyTyped/Definability.agda", "max_line_length": 134, "max_stars_count": 5, "max_stars_repo_head_hexsha": "498f8aefc570f7815fd1d6616508eeb92c52abce", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "nad/dependently-typed-syntax", "max_stars_repo_path": "README/DependentlyTyped/Definability.agda", "max_stars_repo_stars_event_max_datetime": "2020-07-08T22:51:36.000Z", "max_stars_repo_stars_event_min_datetime": "2020-04-16T12:14:44.000Z", "num_tokens": 1820, "size": 5064 }
module UntypedLambda where open import Basics open import Pr open import Nom import Syntacticosmos data Tag : Set where lamT : Tag appT : Tag open module ULam = Syntacticosmos TT TT (\_ -> Tag) LAM : Kind LAM = Ty _ SigLAM : Kind SigLAM = Pi _ conk where conk : Tag -> Kind conk lamT = (LAM |> LAM) |> LAM conk appT = LAM |> LAM |> LAM Lam : Cxt -> Set Lam G = G [! SigLAM !]- LAM lam : {G : Cxt}(x : Nom){Gx : [| G Hasn't x |]} -> Lam ((G [ x - LAM ]) {Gx}) -> Lam G lam x {Gx} b = G[ lamT G^ G\\ (bind x {Gx} b) G& Gnil ] app : {G : Cxt} -> Lam G -> Lam G -> Lam G app f s = G[ appT G^ f G& s G& Gnil ] moo : Lam EC moo = lam Ze (lam (Su Ze) (var Ze)) noo : Lam EC noo = lam (Su Ze) (lam Ze (var (Su Ze))) coo : Id moo noo coo = refl
{ "alphanum_fraction": 0.5665796345, "avg_line_length": 17.4090909091, "ext": "agda", "hexsha": "87282ad3c340d2903e5382c1104e0b1a6c28982d", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "masondesu/agda", "max_forks_repo_path": "benchmark/Syntacticosmos/UntypedLambda.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "masondesu/agda", "max_issues_repo_path": "benchmark/Syntacticosmos/UntypedLambda.agda", "max_line_length": 55, "max_stars_count": 1, "max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/agda-kanso", "max_stars_repo_path": "benchmark/Syntacticosmos/UntypedLambda.agda", "max_stars_repo_stars_event_max_datetime": "2019-11-27T04:41:05.000Z", "max_stars_repo_stars_event_min_datetime": "2019-11-27T04:41:05.000Z", "num_tokens": 315, "size": 766 }
{-# OPTIONS --warning=error --safe --without-K #-} open import LogicalFormulae open import Numbers.Naturals.Semiring -- for length open import Numbers.Naturals.Order open import Semirings.Definition open import Maybe module Lists.Lists where open import Lists.Definition public open import Lists.Length public open import Lists.Concat public open import Lists.Map.Map public open import Lists.Reversal.Reversal public open import Lists.Monad public open import Lists.Filter.AllTrue public open import Lists.Fold.Fold public replicate : {a : _} {A : Set a} (n : ℕ) (x : A) → List A replicate zero x = [] replicate (succ n) x = x :: replicate n x head : {a : _} {A : Set a} (l : List A) (pr : 0 <N length l) → A head [] (le x ()) head (x :: l) pr = x lengthRev : {a : _} {A : Set a} (l : List A) → length (rev l) ≡ length l lengthRev [] = refl lengthRev (x :: l) rewrite lengthConcat (rev l) (x :: []) | lengthRev l | Semiring.commutative ℕSemiring (length l) 1 = refl listLast : {a : _} {A : Set a} (l : List A) → Maybe A listLast [] = no listLast (x :: []) = yes x listLast (x :: y :: l) = listLast (y :: l) listZip : {a b c : _} {A : Set a} {B : Set b} {C : Set c} (f : A → B → C) → (f1 : A → C) → (f2 : B → C) →(l1 : List A) (l2 : List B) → List C listZip f f1 f2 [] l2 = map f2 l2 listZip f f1 f2 (x :: l1) [] = map f1 (x :: l1) listZip f f1 f2 (x :: l1) (y :: l2) = (f x y) :: listZip f f1 f2 l1 l2 contains : {a : _} {A : Set a} (l : List A) (needle : A) → Set a contains [] needle = False' contains (x :: l) needle = (x ≡ needle) || contains l needle containsMap : {a b : _} {A : Set a} {B : Set b} (f : A → B) (l : List A) (needle : A) → (contains l needle) → contains (map f l) (f needle) containsMap f (x :: l) needle (inl cont) = inl (applyEquality f cont) containsMap f (x :: l) needle (inr cont) = inr (containsMap f l needle cont) containsAppend : {a : _} {A : Set a} (l1 l2 : List A) (needle : A) → (contains (l1 ++ l2) needle) → (contains l1 needle) || (contains l2 needle) containsAppend [] l2 needle cont = inr cont containsAppend (x :: l1) l2 needle (inl pr) = inl (inl pr) containsAppend (x :: l1) l2 needle (inr pr) with containsAppend l1 l2 needle pr containsAppend (x :: l1) l2 needle (inr pr) | inl ans = inl (inr ans) containsAppend (x :: l1) l2 needle (inr pr) | inr ans = inr ans containsAppend' : {a : _} {A : Set a} (l1 l2 : List A) (needle : A) → (contains l1 needle) || (contains l2 needle) → contains (l1 ++ l2) needle containsAppend' (x :: l1) l2 needle (inl (inl pr)) = inl pr containsAppend' (x :: l1) l2 needle (inl (inr pr)) = inr (containsAppend' l1 l2 needle (inl pr)) containsAppend' [] l2 needle (inr pr) = pr containsAppend' (x :: l1) l2 needle (inr pr) = inr (containsAppend' l1 l2 needle (inr pr)) containsCons : {a : _} {A : Set a} (x : A) (l : List A) (needle : A) → (contains (x :: l) needle) → (x ≡ needle) || (contains l needle) containsCons x l needle pr = pr containsCons' : {a : _} {A : Set a} (x : A) (l : List A) (needle : A) → (x ≡ needle) || (contains l needle) → (contains (x :: l) needle) containsCons' x l needle pr = pr containsDecidable : {a : _} {A : Set a} (decidableEquality : (x y : A) → (x ≡ y) || ((x ≡ y) → False)) → (l : List A) → (needle : A) → (contains l needle) || ((contains l needle) → False) containsDecidable decide [] needle = inr λ () containsDecidable decide (x :: l) needle with decide x needle containsDecidable decide (x :: l) .x | inl refl = inl (inl refl) containsDecidable decide (x :: l) needle | inr x!=n with containsDecidable decide l needle containsDecidable decide (x :: l) needle | inr x!=n | inl isIn = inl (inr isIn) containsDecidable decide (x :: l) needle | inr x!=n | inr notIn = inr t where t : ((x ≡ needle) || contains l needle) → False t (inl x) = x!=n x t (inr x) = notIn x filter' : {a b : _} {A : Set a} {pred : A → Set b} → (dec : (a : A) → pred a || (pred a → False)) → List A → List A filter' dec [] = [] filter' dec (x :: l) with dec x ... | inl _ = x :: filter' dec l ... | inr _ = filter' dec l
{ "alphanum_fraction": 0.6168525403, "avg_line_length": 46.9186046512, "ext": "agda", "hexsha": "6d4440d00e1b0200194921f345c6576cf147d211", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-29T13:23:07.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-29T13:23:07.000Z", "max_forks_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Smaug123/agdaproofs", "max_forks_repo_path": "Lists/Lists.agda", "max_issues_count": 14, "max_issues_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_issues_repo_issues_event_max_datetime": "2020-04-11T11:03:39.000Z", "max_issues_repo_issues_event_min_datetime": "2019-01-06T21:11:59.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Smaug123/agdaproofs", "max_issues_repo_path": "Lists/Lists.agda", "max_line_length": 187, "max_stars_count": 4, "max_stars_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Smaug123/agdaproofs", "max_stars_repo_path": "Lists/Lists.agda", "max_stars_repo_stars_event_max_datetime": "2022-01-28T06:04:15.000Z", "max_stars_repo_stars_event_min_datetime": "2019-08-08T12:44:19.000Z", "num_tokens": 1451, "size": 4035 }
module CTL.Proof.EG where open import CTL.Modalities.EG open import FStream.Bisimulation open import FStream.Core open import FStream.FVec open import Library infixr 5 _▻EG_ infix 6 ⟨_▻EG infix 7 _⟩EG infixr 5 _▻EGᵢ_ infix 7 _⟩EGᵢ data proofEG {ℓ₁ ℓ₂} {C : Container ℓ₁} : {n : ℕ} → (props : FVec C (Set ℓ₂) n) → Set (ℓ₁ ⊔ ℓ₂) where []EG : proofEG FNil ConsEG : ∀ {n} {props : ⟦ C ⟧ (Set ℓ₂ × FVec C (Set ℓ₂) n)} → E (fmap (λ x → (proj₁ x) × (proofEG (proj₂ x))) props) → proofEG (FCons props) _pre⟨_▻EG : ∀ {i} {ℓ₁ ℓ₂} {C : Container ℓ₁} {m n} {props : FVec C (Set ℓ₂) m} {props' : FVec C (Set ℓ₂) (suc n)} → proofEG props → proofEG props' → EG {i} (props pre⟨ props' ▻⋯) proj₁ ([]EG pre⟨ ConsEG (pos , _) ▻EG) = pos nowE (proj₂ ([]EG pre⟨ ConsEG (_ , proof , _) ▻EG)) = proof laterE (proj₂ ([]EG pre⟨ ConsEG (pos , proof , proofs) ▻EG)) = proofs pre⟨ ConsEG (pos , proof , proofs) ▻EG proj₁ (ConsEG (pos , _) pre⟨ _ ▻EG) = pos nowE (proj₂ (ConsEG (pos , proof , proofs) pre⟨ _ ▻EG)) = proof laterE (proj₂ (ConsEG (_ , _ , proofs) pre⟨ v ▻EG)) = proofs pre⟨ v ▻EG -- TODO It's worth a thought whether we want to roll our own Sigma types -- in order to have more meaningful projector names than projᵢ ⟨_▻EG : ∀ {i} {ℓ₁ ℓ₂} {C : Container ℓ₁} {n} {props : FVec C (Set ℓ₂) (suc n)} → proofEG props → EG {i} (FNil pre⟨ props ▻⋯) ⟨_▻EG = []EG pre⟨_▻EG _⟩EG : ∀ {ℓ₁ ℓ₂} {C : Container ℓ₁} {prop : ⟦ C ⟧ (Set ℓ₂)} → E prop → proofEG (FCons (fmap (_, FNil) prop)) (pos , proof) ⟩EG = ConsEG (pos , (proof , []EG)) _⟩EGᵢ : ∀ {ℓ₁ ℓ₂} {C : Container ℓ₁} {prop : ⟦ C ⟧ (Set ℓ₂)} {pos : Position C (proj₁ prop)} → proj₂ prop pos → proofEG (FCons (fmap (_, FNil) prop)) _⟩EGᵢ {pos = pos} proof = ConsEG (pos , (proof , []EG)) _▻EG_ : ∀ {ℓ₁ ℓ₂} {C : Container ℓ₁} {prop : ⟦ C ⟧ (Set ℓ₂)} {n} {props : FVec C (Set ℓ₂) n} → E prop → proofEG props → proofEG (FCons (fmap (_, props) prop)) (pos , proof) ▻EG proofs = ConsEG (pos , (proof , proofs)) _▻EGᵢ_ : ∀ {ℓ₁ ℓ₂} {C : Container ℓ₁} {prop : ⟦ C ⟧ (Set ℓ₂)} {n} {props : FVec C (Set ℓ₂) n} {pos : Position C (proj₁ prop)} → proj₂ prop pos → proofEG props → proofEG (FCons (fmap (_, props) prop)) _▻EGᵢ_ {pos = pos} proof proofs = ConsEG (pos , (proof , proofs)) mapEGlemma : ∀ {i} {ℓ₁ ℓ₂ ℓ₃} {C : Container ℓ₁} {A : Set ℓ₂} {f : A → Set ℓ₃} {m n} → (v : FVec C A m) → (v' : FVec C A (suc n)) → EG {i} (vmap f v pre⟨ vmap f v' ▻⋯) → EG {i} (map f (v pre⟨ v' ▻⋯)) proj₁ (mapEGlemma FNil (FCons x) (pos , proof)) = pos nowE (proj₂ (mapEGlemma FNil (FCons x) (pos , proofs))) = nowE proofs laterE (proj₂ (mapEGlemma {f = f} FNil (FCons (shape , vals)) (pos , proof))) with vals pos ... | a , v = mapEGlemma v (FCons (shape , vals)) (laterE proof) proj₁ (mapEGlemma (FCons (proj₃ , proj₄)) v' (pos , proofs)) = pos nowE (proj₂ (mapEGlemma (FCons x) v' (pos , proofs))) = nowE proofs laterE (proj₂ (mapEGlemma (FCons (shape , vals)) v' (pos , proofs))) with vals pos ... | a , v = mapEGlemma v v' (laterE proofs) mapEG : ∀ {i} {ℓ₁ ℓ₂ ℓ₃} {C : Container ℓ₁} {A : Set ℓ₂} {f : A → Set ℓ₃} {m n} {v : FVec C A m} {v' : FVec C A (suc n)} → EG {i} ((vmap f v pre⟨ vmap f v' ▻⋯)) → EG {i} (map f (v pre⟨ v' ▻⋯)) mapEG {v = v} {v' = v'} proofs = mapEGlemma v v' proofs mutual -- TODO Rename to ∼EG? bisimEG : ∀ {i} {ℓ₁ ℓ₂} {C : Container ℓ₁} {s₁ s₂ : FStream C (Set ℓ₂)} → s₁ ~ s₂ → EG {i} s₁ → EG {i} s₂ proj₁ (bisimEG {C = C} bs (pos , proofs)) = subst (Position C) (sameInitShapes bs) pos proj₂ (bisimEG bs (pos , proofs)) = bisimEG' (bisim bs pos) proofs bisimEG' : ∀ {i} {ℓ₁ ℓ₂} {C : Container ℓ₁} {s₁ s₂ : FStream' C (Set ℓ₂)} → s₁ ~' s₂ → EG' {i} s₁ → EG' {i} s₂ -- TODO This subst trick must already exist in stdlib somewhere nowE (bisimEG' bs proof) = subst (λ x → x) (hd∼ bs) (nowE proof) laterE (bisimEG' {C = C} bs proof) = bisimEG (tl∼ bs) (laterE proof)
{ "alphanum_fraction": 0.5540408958, "avg_line_length": 36.6785714286, "ext": "agda", "hexsha": "4e030fe1d3c47f6c877f70c151970a11cd2dd751", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2019-12-13T15:56:38.000Z", "max_forks_repo_forks_event_min_datetime": "2019-12-13T15:56:38.000Z", "max_forks_repo_head_hexsha": "64d95885579395f641e9a9cb1b9487cf79280446", "max_forks_repo_licenses": [ "Unlicense" ], "max_forks_repo_name": "zimbatm/condatis", "max_forks_repo_path": "CTL/Proof/EG.agda", "max_issues_count": 5, "max_issues_repo_head_hexsha": "64d95885579395f641e9a9cb1b9487cf79280446", "max_issues_repo_issues_event_max_datetime": "2020-09-01T16:52:07.000Z", "max_issues_repo_issues_event_min_datetime": "2017-06-03T20:02:22.000Z", "max_issues_repo_licenses": [ "Unlicense" ], "max_issues_repo_name": "zimbatm/condatis", "max_issues_repo_path": "CTL/Proof/EG.agda", "max_line_length": 78, "max_stars_count": 1, "max_stars_repo_head_hexsha": "64d95885579395f641e9a9cb1b9487cf79280446", "max_stars_repo_licenses": [ "Unlicense" ], "max_stars_repo_name": "Aerate/condatis", "max_stars_repo_path": "CTL/Proof/EG.agda", "max_stars_repo_stars_event_max_datetime": "2019-12-13T16:52:28.000Z", "max_stars_repo_stars_event_min_datetime": "2019-12-13T16:52:28.000Z", "num_tokens": 1751, "size": 4108 }
module Point where data Nat : Set where zero : Nat suc : Nat -> Nat record Point : Set where field x : Nat y : Nat data _==_ {A : Set}(x : A) : A -> Set where refl : x == x open Point renaming (x to getX; y to getY) <_,_> : Nat -> Nat -> Point < x , y > = record { x = x; y = y } η : (p : Point) -> p == record { x = getX p; y = getY p } η p = refl swap : Point -> Point swap p = < getY p , getX p > swap-idem : (p : Point) -> swap (swap p) == p swap-idem p = refl
{ "alphanum_fraction": 0.5284552846, "avg_line_length": 16.4, "ext": "agda", "hexsha": "86cb465e23c7cdd401840557723da329b04daaa1", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cruhland/agda", "max_forks_repo_path": "test/Succeed/Point.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "cruhland/agda", "max_issues_repo_path": "test/Succeed/Point.agda", "max_line_length": 57, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/Succeed/Point.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 175, "size": 492 }
open import Nat open import Prelude open import aasubsume-min open import contexts open import judgemental-erase open import lemmas-matching open import statics-core open import synth-unicity module determinism where -- since we do not specify the name of newly inserted hole names, -- we only have determinism up to renaming of holes. we don't -- need to consider alpha equivalence for binders, since the -- -- the same action applied to the same type makes the same type actdet-type : {t t' t'' : ztyp} {α : action} → (t + α +> t') → (t + α +> t'') → (t' == t'') actdet-type TMArrChild1 TMArrChild1 = refl actdet-type TMArrChild2 TMArrChild2 = refl actdet-type TMArrParent1 TMArrParent1 = refl actdet-type TMArrParent1 (TMArrZip1 ()) actdet-type TMArrParent2 TMArrParent2 = refl actdet-type TMArrParent2 (TMArrZip2 ()) actdet-type TMDel TMDel = refl actdet-type TMConArrow TMConArrow = refl actdet-type TMConNum TMConNum = refl actdet-type (TMArrZip1 ()) TMArrParent1 actdet-type (TMArrZip1 p1) (TMArrZip1 p2) with actdet-type p1 p2 ... | refl = refl actdet-type (TMArrZip2 ()) TMArrParent2 actdet-type (TMArrZip2 p1) (TMArrZip2 p2) with actdet-type p1 p2 ... | refl = refl actdet-type TMPlusChild1 TMPlusChild1 = refl actdet-type TMPlusChild2 TMPlusChild2 = refl actdet-type TMPlusParent1 TMPlusParent1 = refl actdet-type (TMPlusZip1 ()) TMPlusParent1 actdet-type TMPlusParent2 TMPlusParent2 = refl actdet-type (TMPlusZip2 ()) TMPlusParent2 actdet-type TMConPlus TMConPlus = refl actdet-type TMPlusParent1 (TMPlusZip1 ()) actdet-type (TMPlusZip1 x) (TMPlusZip1 y) with actdet-type x y ... | refl = refl actdet-type TMPlusParent2 (TMPlusZip2 ()) actdet-type (TMPlusZip2 x) (TMPlusZip2 y) with actdet-type x y ... | refl = refl actdet-type TMProdChild1 TMProdChild1 = refl actdet-type TMProdChild2 TMProdChild2 = refl actdet-type TMProdParent1 TMProdParent1 = refl actdet-type TMProdParent1 (TMProdZip1 ()) actdet-type TMProdParent2 TMProdParent2 = refl actdet-type TMProdParent2 (TMProdZip2 ()) actdet-type TMConProd TMConProd = refl actdet-type (TMProdZip1 ()) TMProdParent1 actdet-type (TMProdZip1 x) (TMProdZip1 y) with actdet-type x y ... | refl = refl actdet-type (TMProdZip2 ()) TMProdParent2 actdet-type (TMProdZip2 x) (TMProdZip2 y) with actdet-type x y ... | refl = refl -- all expressions only move to one other expression movedet : {e e' e'' : zexp} {δ : direction} → (e + move δ +>e e') → (e + move δ +>e e'') → e' == e'' movedet EMAscChild1 EMAscChild1 = refl movedet EMAscChild2 EMAscChild2 = refl movedet EMAscParent1 EMAscParent1 = refl movedet EMAscParent2 EMAscParent2 = refl movedet EMLamChild1 EMLamChild1 = refl movedet EMLamParent EMLamParent = refl movedet EMHalfLamChild1 EMHalfLamChild1 = refl movedet EMHalfLamChild2 EMHalfLamChild2 = refl movedet EMHalfLamParent1 EMHalfLamParent1 = refl movedet EMHalfLamParent2 EMHalfLamParent2 = refl movedet EMPlusChild1 EMPlusChild1 = refl movedet EMPlusChild2 EMPlusChild2 = refl movedet EMPlusParent1 EMPlusParent1 = refl movedet EMPlusParent2 EMPlusParent2 = refl movedet EMApChild1 EMApChild1 = refl movedet EMApChild2 EMApChild2 = refl movedet EMApParent1 EMApParent1 = refl movedet EMApParent2 EMApParent2 = refl movedet EMNEHoleChild1 EMNEHoleChild1 = refl movedet EMNEHoleParent EMNEHoleParent = refl movedet EMInlChild1 EMInlChild1 = refl movedet EMInlParent EMInlParent = refl movedet EMInrChild1 EMInrChild1 = refl movedet EMInrParent EMInrParent = refl movedet EMCaseParent1 EMCaseParent1 = refl movedet EMCaseParent2 EMCaseParent2 = refl movedet EMCaseParent3 EMCaseParent3 = refl movedet EMCaseChild1 EMCaseChild1 = refl movedet EMCaseChild2 EMCaseChild2 = refl movedet EMCaseChild3 EMCaseChild3 = refl movedet EMPairChild1 EMPairChild1 = refl movedet EMPairChild2 EMPairChild2 = refl movedet EMPairParent1 EMPairParent1 = refl movedet EMPairParent2 EMPairParent2 = refl movedet EMFstChild1 EMFstChild1 = refl movedet EMFstParent EMFstParent = refl movedet EMSndChild1 EMSndChild1 = refl movedet EMSndParent EMSndParent = refl -- non-movement lemmas; theses show up pervasively throughout and save a -- lot of pattern matching. lem-nomove-part : ∀ {t t'} → ▹ t ◃ + move parent +> t' → ⊥ lem-nomove-part () lem-nomove-pars : ∀{Γ e t e' t'} → Γ ⊢ ▹ e ◃ => t ~ move parent ~> e' => t' → ⊥ lem-nomove-pars (SAMove ()) lem-nomove-para : ∀{Γ e t e'} → Γ ⊢ ▹ e ◃ ~ move parent ~> e' ⇐ t → ⊥ lem-nomove-para (AASubsume e x x₁ x₂) = lem-nomove-pars x₁ lem-nomove-para (AAMove ()) -- if a move action on a synthetic action makes a new form, it's unique synthmovedet : {Γ : tctx} {e e' e'' : zexp} {t' t'' : htyp} {δ : direction} → Γ ⊢ e => t' ~ move δ ~> e'' => t'' → e + move δ +>e e' → e'' == e' synthmovedet (SAMove m1) m2 = movedet m1 m2 -- all these cases lead to absurdities based on movement synthmovedet (SAZipAsc1 x) EMAscParent1 = abort (lem-nomove-para x) synthmovedet (SAZipAsc2 x _ _ _) EMAscParent2 = abort (lem-nomove-part x) synthmovedet (SAZipApArr _ _ _ x _) EMApParent1 = abort (lem-nomove-pars x) synthmovedet (SAZipApAna _ _ x) EMApParent2 = abort (lem-nomove-para x) synthmovedet (SAZipPlus1 x) EMPlusParent1 = abort (lem-nomove-para x) synthmovedet (SAZipPlus2 x) EMPlusParent2 = abort (lem-nomove-para x) synthmovedet (SAZipNEHole _ _ x) EMNEHoleParent = abort (lem-nomove-pars x) synthmovedet (SAZipPair1 _ _ x _) EMPairParent1 = abort (lem-nomove-pars x) synthmovedet (SAZipPair2 _ _ _ x) EMPairParent2 = abort (lem-nomove-pars x) synthmovedet (SAZipFst _ _ _ _ x) EMFstParent = abort (lem-nomove-pars x) synthmovedet (SAZipSnd _ _ _ _ x) EMSndParent = abort (lem-nomove-pars x) synthmovedet (SAZipLam1 _ _ _ x _ _) EMHalfLamParent1 = abort (lem-nomove-part x) synthmovedet (SAZipLam2 _ _ _ x) EMHalfLamParent2 = abort (lem-nomove-pars x) anamovedet : {Γ : tctx} {e e' e'' : zexp} {t : htyp} {δ : direction} → Γ ⊢ e ~ move δ ~> e'' ⇐ t → e + move δ +>e e' → e'' == e' anamovedet (AASubsume x₂ x x₃ x₁) m = synthmovedet x₃ m anamovedet (AAMove x) m = movedet x m anamovedet (AAZipLam x₁ x₂ d) EMLamParent = abort (lem-nomove-para d) anamovedet (AAZipInl x d) EMInlParent = abort (lem-nomove-para d) anamovedet (AAZipInr x d) EMInrParent = abort (lem-nomove-para d) anamovedet (AAZipCase1 x₁ x₂ x₃ x₄ x₅ x₆ x₇ x₈) EMCaseParent1 = abort (lem-nomove-pars x₅) anamovedet (AAZipCase2 x₁ x₂ x₃ x₄ d) EMCaseParent2 = abort (lem-nomove-para d) anamovedet (AAZipCase3 x₁ x₂ x₃ x₄ d) EMCaseParent3 = abort (lem-nomove-para d) lem-plusholematch : ∀ {t t1 t2} → t ~̸ (⦇-⦈ ⊕ ⦇-⦈) → t ~ ⦇-⦈ → t ▸sum (t1 ⊕ t2) → ⊥ lem-plusholematch a TCRefl MSHole = a TCHole2 lem-plusholematch a TCHole1 MSHole = a TCHole2 lem-plusholematch a TCHole1 MSSum = a (TCSum TCHole1 TCHole1) lem-plusholematch a TCHole2 MSHole = a TCHole2 lem-prodholematch : ∀ {t t1 t2} → t ~̸ (⦇-⦈ ⊠ ⦇-⦈) → t ~ ⦇-⦈ → t ▸prod (t1 ⊠ t2) → ⊥ lem-prodholematch a TCRefl MPHole = a TCHole2 lem-prodholematch a TCHole1 MPHole = a TCHole2 lem-prodholematch a TCHole1 MPProd = a (TCProd TCHole1 TCHole1) lem-prodholematch a TCHole2 MPHole = a TCHole2 mutual -- an action on an expression in a synthetic position produces one -- resultant expression and type. actdet-synth : {Γ : tctx} {e e' e'' : zexp} {e◆ : hexp} {t t' t'' : htyp} {α : action} → (E : erase-e e e◆) → (Γ ⊢ e◆ => t) → (d1 : Γ ⊢ e => t ~ α ~> e' => t') → (d2 : Γ ⊢ e => t ~ α ~> e'' => t'') → {p1 : aasubmin-synth d1} → {p2 : aasubmin-synth d2} → (e' == e'' × t' == t'') actdet-synth er wt (SAMove x₁) (SAMove x₂) = movedet x₁ x₂ , refl actdet-synth er wt SADel SADel = refl , refl actdet-synth er wt SAConAsc SAConAsc = refl , refl actdet-synth er wt (SAConPlus1 x₁) (SAConPlus1 x₂) = refl , refl actdet-synth er wt (SAConPlus1 x₁) (SAConPlus2 x₂) = abort (x₂ x₁) actdet-synth er wt (SAConPlus2 x₁) (SAConPlus1 x₂) = abort (x₁ x₂) actdet-synth er wt (SAConPlus2 x₁) (SAConPlus2 x₂) = refl , refl actdet-synth er wt (SAConApArr x₁) (SAConApArr x₂) with ▸arr-unicity x₁ x₂ ... | refl = refl , refl actdet-synth er wt (SAConApArr x₁) (SAConApOtw x₂) = abort (x₂ (▸arr-consist-hole x₁)) actdet-synth er wt (SAConApOtw x₁) (SAConApArr x₂) = abort (x₁ (▸arr-consist-hole x₂)) actdet-synth er wt (SAConApOtw x₁) (SAConApOtw x₂) = refl , refl actdet-synth er wt SAConNEHole SAConNEHole = refl , refl actdet-synth (EEAscL E) (SAsc x) (SAMove EMAscParent1) (SAZipAsc1 x₂) = abort (lem-nomove-para x₂) actdet-synth (EEAscL E) (SAsc x) (SAZipAsc1 x₁) (SAMove EMAscParent1) = abort (lem-nomove-para x₁) actdet-synth (EEAscL E) (SAsc x) (SAZipAsc1 x₁) (SAZipAsc1 x₂) {p1} {p2} with actdet-ana E x x₁ x₂ {p1} {p2} ... | refl = refl , refl actdet-synth (EEAscR x) (SAsc x₁) (SAMove EMAscParent2) (SAZipAsc2 a _ _ _) = abort (lem-nomove-part a) actdet-synth (EEAscR x) (SAsc x₁) (SAZipAsc2 a _ _ _) (SAMove EMAscParent2) = abort (lem-nomove-part a) actdet-synth (EEAscR x) (SAsc x₂) (SAZipAsc2 a e1 _ _) (SAZipAsc2 b e2 _ _) with actdet-type a b ... | refl = refl , eraset-det e1 e2 actdet-synth (EEHalfLamL x) (SLam x₁ wt) (SAMove EMHalfLamParent1) (SAZipLam1 x₃ x₄ x₅ x₆ x₇ x₈) = abort (lem-nomove-part x₆) actdet-synth (EEHalfLamL x) (SLam x₁ wt) (SAZipLam1 x₂ x₃ x₄ x₅ x₆ x₇) (SAMove EMHalfLamParent1) = abort (lem-nomove-part x₅) actdet-synth (EEHalfLamL x) (SLam x₁ wt) (SAZipLam1 x₂ x₃ x₄ x₅ x₆ x₇) (SAZipLam1 x₈ x₉ x₁₀ x₁₁ x₁₂ x₁₃) with actdet-type x₅ x₁₁ ... | refl with eraset-det x₄ x₁₀ ... | refl with synthunicity x₇ x₁₃ ... | refl = refl , refl actdet-synth (EEHalfLamR er) (SLam x wt) (SAMove EMHalfLamParent2) (SAZipLam2 x₂ x₃ x₄ y) = abort (lem-nomove-pars y) actdet-synth (EEHalfLamR er) (SLam x wt) (SAZipLam2 x₁ x₂ x₃ x₄) (SAMove EMHalfLamParent2) = abort (lem-nomove-pars x₄) actdet-synth (EEHalfLamR er) (SLam x wt) (SAZipLam2 x₁ x₂ x₃ d1) (SAZipLam2 x₅ x₆ x₇ d2) {p1} {p2} with erasee-det x₂ x₆ ... | refl with actdet-synth x₂ x₃ d1 d2 {p1} {p2} ... | refl , refl = refl , refl actdet-synth (EEApL E) (SAp m wt x) (SAMove EMApParent1) (SAZipApArr _ x₂ x₃ d2 x₄) = abort (lem-nomove-pars d2) actdet-synth (EEApL E) (SAp m wt x) (SAZipApArr _ x₁ x₂ d1 x₃) (SAMove EMApParent1) = abort (lem-nomove-pars d1) actdet-synth (EEApL E) (SAp m wt x) (SAZipApArr a x₁ x₂ d1 x₃) (SAZipApArr b x₄ x₅ d2 x₆) {p1} {p2} with erasee-det x₁ x₄ ... | refl with synthunicity x₂ x₅ ... | refl with erasee-det E x₁ ... | refl with actdet-synth E x₅ d1 d2 {p1} {p2} ... | refl , refl with ▸arr-unicity a b ... | refl = refl , refl actdet-synth (EEApR E) (SAp m wt x) (SAMove EMApParent2) (SAZipApAna x₂ x₃ x₄) = abort (lem-nomove-para x₄) actdet-synth (EEApR E) (SAp m wt x) (SAZipApAna x₁ x₂ x₃) (SAMove EMApParent2) = abort (lem-nomove-para x₃) actdet-synth (EEApR E) (SAp m wt x) (SAZipApAna x₁ x₂ d1) (SAZipApAna x₄ x₅ d2) {p1} {p2} with synthunicity m x₂ ... | refl with ▸arr-unicity x₁ wt ... | refl with synthunicity m x₅ ... | refl with ▸arr-unicity x₄ wt ... | refl with actdet-ana E x d1 d2 {p1} {p2} ... | refl = refl , refl actdet-synth (EEPlusL E) (SPlus x x₁) (SAMove EMPlusParent1) (SAZipPlus1 d2) = abort (lem-nomove-para d2) actdet-synth (EEPlusL E) (SPlus x x₁) (SAZipPlus1 x₂) (SAMove EMPlusParent1) = abort (lem-nomove-para x₂) actdet-synth (EEPlusL E) (SPlus x x₁) (SAZipPlus1 x₂) (SAZipPlus1 x₃) {p1} {p2} = ap1 (λ x₄ → x₄ ·+₁ _) (actdet-ana E x x₂ x₃ {p1} {p2}) , refl actdet-synth (EEPlusR E) (SPlus x x₁) (SAMove EMPlusParent2) (SAZipPlus2 x₃) = abort (lem-nomove-para x₃) actdet-synth (EEPlusR E) (SPlus x x₁) (SAZipPlus2 x₂) (SAMove EMPlusParent2) = abort (lem-nomove-para x₂) actdet-synth (EEPlusR E) (SPlus x x₁) (SAZipPlus2 x₂) (SAZipPlus2 x₃) {p1} {p2} = ap1 (_·+₂_ _) (actdet-ana E x₁ x₂ x₃ {p1} {p2}) , refl actdet-synth EETop SEHole (SAConVar {Γ = G} p) (SAConVar p₁) = refl , (ctxunicity {Γ = G} p p₁) actdet-synth EETop SEHole (SAConLam x₁) (SAConLam x₂) = refl , refl actdet-synth EETop SEHole SAConNumlit SAConNumlit = refl , refl actdet-synth EETop (SNEHole wt) (SAFinish x) (SAFinish x₁) = refl , synthunicity x x₁ actdet-synth (EENEHole E) (SNEHole wt) (SAMove EMNEHoleParent) (SAZipNEHole _ x₁ d2) = abort (lem-nomove-pars d2) actdet-synth (EENEHole E) (SNEHole wt) (SAZipNEHole _ x d1) (SAMove EMNEHoleParent) = abort (lem-nomove-pars d1) actdet-synth (EENEHole E) (SNEHole wt) (SAZipNEHole a x d1) (SAZipNEHole b x₁ d2) {p1} {p2} with erasee-det a b ... | refl with synthunicity x x₁ ... | refl with actdet-synth a x d1 d2 {p1} {p2} ... | refl , refl = refl , refl -- new cases for sums actdet-synth EETop SEHole SAConInl SAConInl = refl , refl actdet-synth EETop SEHole SAConInr SAConInr = refl , refl actdet-synth er wt (SAConCase1 x₁ x₂ x₃) (SAConCase1 x₄ x₅ x₆) = refl , refl actdet-synth er wt (SAConCase1 x₁ x₂ MSHole) (SAConCase2 x₄ x₅ x₆) = abort (x₆ TCHole2) actdet-synth EETop wt (SAConCase1 x₁ x₂ MSSum) (SAConCase2 x₄ x₅ x₆) = abort (x₆ (TCSum TCHole1 TCHole1)) actdet-synth EETop wt (SAConCase2 x₁ x₂ x₃) (SAConCase1 x₄ x₅ MSHole) = abort (x₃ TCHole2) actdet-synth EETop wt (SAConCase2 x₁ x₂ x₃) (SAConCase1 x₄ x₅ MSSum) = abort (x₃ (TCSum TCHole1 TCHole1)) actdet-synth er wt (SAConCase2 x₁ x₂ x₃) (SAConCase2 x₄ x₅ x₆) = refl , refl -- new cases for products actdet-synth EETop wt (SAConFst1 x) (SAConFst1 x₁) with ▸prod-unicity x x₁ ... | refl = refl , refl actdet-synth EETop wt (SAConFst1 x) (SAConFst2 x₁) = abort (x₁ (▸prod-consist-hole x)) actdet-synth EETop wt (SAConFst2 x) (SAConFst1 x₁) = abort (x (▸prod-consist-hole x₁)) actdet-synth EETop wt (SAConFst2 x) (SAConFst2 x₁) = refl , refl actdet-synth EETop wt (SAConSnd1 x) (SAConSnd1 x₁) with ▸prod-unicity x x₁ ... | refl = refl , refl actdet-synth EETop wt (SAConSnd1 x) (SAConSnd2 x₁) = abort (x₁ (▸prod-consist-hole x)) actdet-synth EETop wt (SAConSnd2 x) (SAConSnd1 x₁) = abort (x (▸prod-consist-hole x₁)) actdet-synth EETop wt (SAConSnd2 x) (SAConSnd2 x₁) = refl , refl actdet-synth EETop SEHole SAConPair SAConPair = refl , refl actdet-synth (EEPairL er) (SPair wt wt₁) (SAMove EMPairParent1) (SAZipPair1 er₁ wt₂ d wt₃) = abort (lem-nomove-pars d) actdet-synth (EEPairL er) (SPair wt wt₁) (SAZipPair1 er₁ wt₂ d wt₃) (SAMove EMPairParent1) = abort (lem-nomove-pars d) actdet-synth (EEPairL er) (SPair wt wt₁) (SAZipPair1 er₁ wt₂ d₁ wt₃) (SAZipPair1 er₂ wt₄ d₂ wt₅) {p1} {p2} with actdet-synth er₁ wt₂ d₁ d₂ {p1} {p2} ... | refl , refl = refl , refl actdet-synth (EEPairR er) (SPair wt wt₁) (SAMove EMPairParent2) (SAZipPair2 wt₂ er₁ wt₃ d) = abort (lem-nomove-pars d) actdet-synth (EEPairR er) (SPair wt wt₁) (SAZipPair2 wt₂ er₁ wt₃ d) (SAMove EMPairParent2) = abort (lem-nomove-pars d) actdet-synth (EEPairR er) (SPair wt wt₁) (SAZipPair2 wt₂ er₁ wt₃ d₁) (SAZipPair2 wt₄ er₂ wt₅ d₂) {p1} {p2} with actdet-synth er₁ wt₃ d₁ d₂ {p1} {p2} ... | refl , refl = refl , refl actdet-synth (EEFst er) (SFst wt x₁) (SAMove EMFstParent) (SAZipFst pr pr₁ er₁ wt₁ d) = abort (lem-nomove-pars d) actdet-synth (EEFst er) (SFst wt x₁) (SAZipFst pr pr₁ er₁ wt₁ d) (SAMove EMFstParent) = abort (lem-nomove-pars d) actdet-synth (EEFst er) (SFst wt x₁) (SAZipFst pr pr₁ er₁ wt₁ d₁) (SAZipFst pr₂ pr₃ er₂ wt₂ d₂) {p1} {p2} with erasee-det er₁ er₂ ... | refl with synthunicity wt₁ wt₂ ... | refl with actdet-synth er₁ wt₁ d₁ d₂ {p1} {p2} ... | refl , refl with ▸prod-unicity pr₁ pr₃ ... | refl = refl , refl actdet-synth (EESnd er) (SSnd wt x₁) (SAMove EMSndParent) (SAZipSnd pr pr₁ er₁ wt₁ d) = abort (lem-nomove-pars d) actdet-synth (EESnd er) (SSnd wt x₁) (SAZipSnd pr pr₁ er₁ wt₁ d) (SAMove EMSndParent) = abort (lem-nomove-pars d) actdet-synth (EESnd er) (SSnd wt x₁) (SAZipSnd pr pr₁ er₁ wt₁ d₁) (SAZipSnd pr₂ pr₃ er₂ wt₂ d₂) {p1} {p2} with erasee-det er₁ er₂ ... | refl with synthunicity wt₁ wt₂ ... | refl with actdet-synth er₁ wt₁ d₁ d₂ {p1} {p2} ... | refl , refl with ▸prod-unicity pr₁ pr₃ ... | refl = refl , refl -- an action on an expression in an analytic position produces one -- resultant expression and type. actdet-ana : {Γ : tctx} {e e' e'' : zexp} {e◆ : hexp} {t : htyp} {α : action} → erase-e e e◆ → Γ ⊢ e◆ <= t → (d1 : Γ ⊢ e ~ α ~> e' ⇐ t) → (d2 : Γ ⊢ e ~ α ~> e'' ⇐ t) → {p1 : aasubmin-ana d1} → {p2 : aasubmin-ana d2} → e' == e'' -- lambda cases first -- an erased lambda can't be typechecked with subsume actdet-ana (EELam _) (ASubsume () _) _ _ -- for things paired with movements, punt to the move determinism case actdet-ana _ _ D (AAMove y) = anamovedet D y actdet-ana _ _ (AAMove y) D = ! (anamovedet D y) -- lambdas never match with subsumption actions, because it won't be well typed. actdet-ana EETop (ALam x₁ x₂ wt) (AASubsume EETop () x₅ x₆) _ actdet-ana (EELam _) (ALam x₁ x₂ wt) (AASubsume (EELam x₃) () x₅ x₆) _ actdet-ana EETop (ALam x₁ x₂ wt) _ (AASubsume EETop () x₅ x₆) actdet-ana (EELam _) (ALam x₁ x₂ wt) _ (AASubsume (EELam x₃) () x₅ x₆) -- with the cursor at the top, there are only two possible actions actdet-ana EETop (ALam x₁ x₂ wt) AADel AADel = refl actdet-ana EETop (ALam x₁ x₂ wt) AAConAsc AAConAsc = refl -- and for the remaining case, recurr on the smaller derivations actdet-ana (EELam er) (ALam x₁ x₂ wt) (AAZipLam x₃ x₄ d1) (AAZipLam x₅ x₆ d2) {p1} {p2} with ▸arr-unicity x₄ x₆ ... | refl with ▸arr-unicity x₄ x₂ ... | refl with actdet-ana er wt d1 d2 {p1} {p2} ... | refl = refl -- now the subsumption cases -- subsume / subsume, so pin things down then recurr actdet-ana er (ASubsume a b) (AASubsume x x₁ x₂ x₃) (AASubsume x₄ x₅ x₆ x₇) {p1} {p2} with erasee-det x₄ x ... | refl with erasee-det er x₄ ... | refl with synthunicity x₅ x₁ ... | refl = π1 (actdet-synth x x₅ x₂ x₆ {min-ana-lem x₂ p1} {min-ana-lem x₆ p2}) -- (these are all repeated below, irritatingly.) actdet-ana EETop (ASubsume a b) (AASubsume EETop x SADel x₁) AADel = refl actdet-ana EETop (ASubsume a b) (AASubsume EETop x SAConAsc x₁) AAConAsc {p1} = abort p1 actdet-ana EETop (ASubsume SEHole b) (AASubsume EETop SEHole (SAConVar {Γ = Γ} p) x₂) (AAConVar x₅ p₁) with ctxunicity {Γ = Γ} p p₁ ... | refl = abort (x₅ x₂) actdet-ana EETop (ASubsume SEHole b) (AASubsume EETop SEHole (SAConLam x₄) x₂) (AAConLam1 x₅ m) {p1} = abort p1 actdet-ana EETop (ASubsume a b) (AASubsume EETop x₁ (SAConLam x₃) x₂) (AAConLam2 x₅ x₆) = abort (x₆ x₂) actdet-ana EETop (ASubsume a b) (AASubsume EETop x₁ SAConNumlit x₂) (AAConNumlit x₄) = abort (x₄ x₂) actdet-ana EETop (ASubsume a b) (AASubsume EETop x (SAFinish x₂) x₁) (AAFinish x₄) = refl -- subsume / del actdet-ana er (ASubsume a b) AADel (AASubsume x x₁ SADel x₃) = refl actdet-ana er (ASubsume a b) AADel AADel = refl -- subsume / conasc actdet-ana EETop (ASubsume a b) AAConAsc (AASubsume EETop x₁ SAConAsc x₃) {p2 = p2} = abort p2 actdet-ana er (ASubsume a b) AAConAsc AAConAsc = refl -- subsume / convar actdet-ana EETop (ASubsume SEHole b) (AAConVar x₁ p) (AASubsume EETop SEHole (SAConVar {Γ = Γ} p₁) x₅) with ctxunicity {Γ = Γ} p p₁ ... | refl = abort (x₁ x₅) actdet-ana er (ASubsume a b) (AAConVar x₁ p) (AAConVar x₂ p₁) = refl -- subsume / conlam1 actdet-ana EETop (ASubsume SEHole b) (AAConLam1 x₁ x₂) (AASubsume EETop SEHole (SAConLam x₃) x₆) {p2 = p2} = abort p2 actdet-ana er (ASubsume a b) (AAConLam1 x₁ MAHole) (AAConLam2 x₃ x₄) = abort (x₄ TCHole2) actdet-ana er (ASubsume a b) (AAConLam1 x₁ MAArr) (AAConLam2 x₃ x₄) = abort (x₄ (TCArr TCHole1 TCHole1)) actdet-ana er (ASubsume a b) (AAConLam1 x₁ x₂) (AAConLam1 x₃ x₄) = refl -- subsume / conlam2 actdet-ana EETop (ASubsume SEHole TCRefl) (AAConLam2 x₁ x₂) (AASubsume EETop SEHole x₅ x₆) = abort (x₂ TCHole2) actdet-ana EETop (ASubsume SEHole TCHole1) (AAConLam2 x₁ x₂) (AASubsume EETop SEHole (SAConLam x₃) x₆) = abort (x₂ x₆) actdet-ana EETop (ASubsume SEHole TCHole2) (AAConLam2 x₁ x₂) (AASubsume EETop SEHole x₅ x₆) = abort (x₂ TCHole2) actdet-ana EETop (ASubsume a b) (AAConLam2 x₂ x₁) (AAConLam1 x₃ MAHole) = abort (x₁ TCHole2) actdet-ana EETop (ASubsume a b) (AAConLam2 x₂ x₁) (AAConLam1 x₃ MAArr) = abort (x₁ (TCArr TCHole1 TCHole1)) actdet-ana er (ASubsume a b) (AAConLam2 x₂ x) (AAConLam2 x₃ x₄) = refl -- subsume / numlit actdet-ana er (ASubsume a b) (AAConNumlit x) (AASubsume x₁ x₂ SAConNumlit x₄) = abort (x x₄) actdet-ana er (ASubsume a b) (AAConNumlit x) (AAConNumlit x₁) = refl -- subsume / finish actdet-ana er (ASubsume a b) (AAFinish x) (AASubsume x₁ x₂ (SAFinish x₃) x₄) = refl actdet-ana er (ASubsume a b) (AAFinish x) (AAFinish x₁) = refl -- new cases for sums -- injections and cases, like lambdas, only check. so they can't be -- part of a subsume or a subsume action. so a lot of these cases -- just fall out immediately. actdet-ana (EEInl _) (ASubsume () _) _ _ actdet-ana (EEInr _) (ASubsume () _) _ _ actdet-ana (EECase1 _) (ASubsume () _) _ _ actdet-ana (EECase2 _) (ASubsume () _) _ _ actdet-ana (EECase3 _) (ASubsume () _) _ _ actdet-ana EETop (AInl x wt) (AASubsume EETop () _ x₄) _ actdet-ana EETop (AInl x wt) _ (AASubsume EETop () _ x₄) actdet-ana EETop (AInr x wt) (AASubsume EETop () _ x₄) _ actdet-ana EETop (AInr x wt) _ (AASubsume EETop () _ x₄) actdet-ana EETop (ACase _ _ _ _ _ _) _ (AASubsume EETop () _ x₄) actdet-ana EETop (ACase _ _ _ _ _ _) (AASubsume EETop () _ x₄) _ actdet-ana (EEInr er) (AInr x wt) (AASubsume (EEInr x₁) () x₃ x₄) _ actdet-ana (EEInr er) (AInr x wt) _ (AASubsume (EEInr x₁) () x₃ x₄) actdet-ana (EEInl er) (AInl x wt) (AASubsume (EEInl x₁) () x₃ x₄) _ actdet-ana (EEInl er) (AInl x wt) _ (AASubsume (EEInl x₁) () x₃ x₄) actdet-ana (EECase1 er) (ACase x₁ x₂ x₃ x₄ wt wt₁) _ (AASubsume (EECase1 x₉) () x₁₁ x₁₂) actdet-ana (EECase2 er) (ACase x₁ x₂ x₃ x₄ wt wt₁) _ (AASubsume (EECase2 x₉) () x₁₁ x₁₂) actdet-ana (EECase3 er) (ACase x₁ x₂ x₃ x₄ wt wt₁) _ (AASubsume (EECase3 x₉) () x₁₁ x₁₂) actdet-ana (EECase1 er) (ACase x₁ x₂ x₃ x₄ wt wt₁) (AASubsume (EECase1 x₉) () x₁₁ x₁₂) _ actdet-ana (EECase2 er) (ACase x₁ x₂ x₃ x₄ wt wt₁) (AASubsume (EECase2 x₉) () x₁₁ x₁₂) _ actdet-ana (EECase3 er) (ACase x₁ x₂ x₃ x₄ wt wt₁) (AASubsume (EECase3 x₉) () x₁₁ x₁₂) _ actdet-ana EETop (ASubsume SEHole x₂) (AAConCase x₃ x₄) (AASubsume EETop SEHole (SAConCase1 x₁ x₅ MSHole) x₈) {p2 = p2} = abort p2 actdet-ana EETop (ASubsume SEHole x₂) (AAConCase x₃ x₄) (AASubsume EETop SEHole (SAConCase2 x₁ x₅ x₆) x₈) = abort (x₆ TCHole2) actdet-ana EETop (ASubsume SEHole x₂) (AASubsume EETop SEHole (SAConCase1 x₁ x₃ MSHole) x₆) (AAConCase x₇ x₈) {p1} = abort p1 actdet-ana EETop (ASubsume SEHole x₂) (AASubsume EETop SEHole (SAConCase2 x₁ x₃ x₄) x₆) (AAConCase x₇ x₈) = abort (x₄ TCHole2) -- the cases where the derivations match just go through actdet-ana er (ASubsume x x₁) (AAConInl1 x₂) (AAConInl1 x₃) = refl actdet-ana EETop (ASubsume SEHole x₁) (AAConInl2 x₂) (AAConInl2 x₃) = refl actdet-ana er (ASubsume x x₁) (AAConInr1 x₂) (AAConInr1 x₃) = refl actdet-ana er (ASubsume x x₁) (AAConInr2 x₂) (AAConInr2 x₃) = refl actdet-ana EETop (ASubsume SEHole x₂) (AAConCase x₃ x₄) (AAConCase x₅ x₆) = refl actdet-ana er (AInl x wt) AADel AADel = refl actdet-ana er (AInl x wt) AAConAsc AAConAsc = refl actdet-ana er (AInr x wt) AADel AADel = refl actdet-ana er (AInr x wt) AAConAsc AAConAsc = refl actdet-ana er (ACase x₁ x₂ x₃ x₄ wt wt₁) AADel AADel = refl actdet-ana er (ACase x₁ x₂ x₃ x₄ wt wt₁) AAConAsc AAConAsc = refl -- everything else we need to argue a little bit more carefully -- matching zipper cases; these cause us to recurr actdet-ana (EEInl er) (AInl x wt) (AAZipInl x₁ d1) (AAZipInl x₂ d2) {p1} {p2} with ▸sum-unicity x₂ x₁ ... | refl with ▸sum-unicity x x₁ ... | refl = ap1 inl (actdet-ana er wt d1 d2 {p1} {p2}) actdet-ana (EEInr er) (AInr x wt) (AAZipInr x₁ d1) (AAZipInr x₂ d2) {p1} {p2} with ▸sum-unicity x₂ x₁ ... | refl with ▸sum-unicity x x₁ ... | refl = ap1 inr (actdet-ana er wt d1 d2 {p1} {p2}) actdet-ana (EECase1 er) (ACase x₂ x₃ x₄ x₅ wt wt₁) (AAZipCase1 x₆ x₇ x₈ x₉ x₁₀ x₁₁ x₁₂ x₁₃) (AAZipCase1 x₁₄ x₁₅ x₁₆ x₁₇ x₁₈ x₁₉ x₂₀ x₂₁) {p1} {p2} with erasee-det x₈ x₁₆ ... | refl with synthunicity x₁₇ x₉ ... | refl with actdet-synth x₈ x₉ x₁₈ x₁₀ {p2} {p1} ... | refl , refl = refl actdet-ana (EECase2 er) (ACase x₂ x₃ x₄ x₅ wt wt₁) (AAZipCase2 x₆ x₇ x₈ x₉ d1) (AAZipCase2 x₁₁ x₁₂ x₁₃ x₁₄ d2) {p1} {p2} with synthunicity x₅ x₈ ... | refl with synthunicity x₅ x₁₃ ... | refl with ▸sum-unicity x₁₄ x₉ ... | refl with ▸sum-unicity x₉ x₄ ... | refl with actdet-ana er wt d1 d2 {p1} {p2} ... | refl = refl actdet-ana (EECase3 er) (ACase x₂ x₃ x₄ x₅ wt wt₁) (AAZipCase3 x₆ x₇ x₈ x₉ d1) (AAZipCase3 x₁₁ x₁₂ x₁₃ x₁₄ d2) {p1} {p2} with synthunicity x₈ x₁₃ ... | refl with synthunicity x₈ x₅ ... | refl with ▸sum-unicity x₄ x₉ ... | refl with ▸sum-unicity x₄ x₁₄ ... | refl with actdet-ana er wt₁ d1 d2 {p1} {p2} ... | refl = refl actdet-ana EETop (ASubsume SEHole x₁) (AASubsume EETop SEHole SAConInl x₅) (AAConInl1 x₆) {p1} = abort p1 actdet-ana EETop (ASubsume SEHole x₁) (AASubsume EETop SEHole SAConInl x₅) (AAConInl2 x₆) = abort (x₆ x₅) actdet-ana EETop (ASubsume SEHole x₁) (AASubsume EETop SEHole SAConInr x₅) (AAConInr1 x₆) {p1} = abort p1 actdet-ana EETop (ASubsume SEHole x₁) (AASubsume EETop SEHole SAConInr x₅) (AAConInr2 x₆) = abort (x₆ x₅) actdet-ana EETop (ASubsume SEHole x₁) (AAConInl1 x₂) (AASubsume EETop SEHole SAConInl x₆) {p2 = p2} = abort p2 actdet-ana EETop (ASubsume SEHole x₁) (AAConInr1 x₂) (AASubsume EETop SEHole SAConInr c) {p2 = p2} = abort p2 actdet-ana EETop (ASubsume SEHole x₁) (AAConInl1 q) (AAConInl2 x₃) = abort (lem-plusholematch x₃ x₁ q) actdet-ana EETop (ASubsume SEHole x₁) (AAConInl2 x₂) (AASubsume EETop SEHole SAConInl x₆) = abort (x₂ x₆) actdet-ana EETop (ASubsume SEHole x₁) (AAConInl2 x₂) (AAConInl1 q) = abort (lem-plusholematch x₂ x₁ q) actdet-ana EETop (ASubsume SEHole x₁) (AAConInr1 x₂) (AAConInr2 x₃) = abort (lem-plusholematch x₃ x₁ x₂) actdet-ana EETop (ASubsume SEHole x₁) (AAConInr2 x₂) (AASubsume EETop x₄ SAConInr x₆) = abort (x₂ x₆) actdet-ana EETop (ASubsume SEHole x₁) (AAConInr2 x₂) (AAConInr1 x₃) = abort (lem-plusholematch x₂ x₁ x₃)
{ "alphanum_fraction": 0.642433444, "avg_line_length": 49.8626760563, "ext": "agda", "hexsha": "993019d440da1aaa6f84cfba6b2e13cfad919442", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "a3640d7b0f76cdac193afd382694197729ed6d57", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "hazelgrove/hazelnut-agda", "max_forks_repo_path": "determinism.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "a3640d7b0f76cdac193afd382694197729ed6d57", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "hazelgrove/hazelnut-agda", "max_issues_repo_path": "determinism.agda", "max_line_length": 96, "max_stars_count": null, "max_stars_repo_head_hexsha": "a3640d7b0f76cdac193afd382694197729ed6d57", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "hazelgrove/hazelnut-agda", "max_stars_repo_path": "determinism.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 11890, "size": 28322 }
open import Agda.Builtin.Bool module Issue4166.Import {b : Bool} where instance i : Bool i = b
{ "alphanum_fraction": 0.6893203883, "avg_line_length": 10.3, "ext": "agda", "hexsha": "ac13dbf5353aac7f306ca4fc036e17735a6916de", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "cc026a6a97a3e517bb94bafa9d49233b067c7559", "max_forks_repo_licenses": [ "BSD-2-Clause" ], "max_forks_repo_name": "cagix/agda", "max_forks_repo_path": "test/Succeed/Issue4166/Import.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "cc026a6a97a3e517bb94bafa9d49233b067c7559", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "BSD-2-Clause" ], "max_issues_repo_name": "cagix/agda", "max_issues_repo_path": "test/Succeed/Issue4166/Import.agda", "max_line_length": 40, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "cc026a6a97a3e517bb94bafa9d49233b067c7559", "max_stars_repo_licenses": [ "BSD-2-Clause" ], "max_stars_repo_name": "cagix/agda", "max_stars_repo_path": "test/Succeed/Issue4166/Import.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 33, "size": 103 }
{-# OPTIONS --without-K #-} module SEquivSCPermEquiv where -- Data types from standard library open import Level using (zero) open import Data.Nat using (ℕ; _+_) open import Data.Fin using (Fin; inject+; raise) open import Data.Sum using (inj₁; inj₂) open import Data.Product using (_,_; proj₁; proj₂) open import Data.Vec using (tabulate) renaming (_++_ to _++V_) open import Function using (_∘_; id) -- Properties from standard library open import Data.Vec.Properties using (lookup∘tabulate) open import Relation.Binary using (Setoid) open import Function.Equality using (_⇨_; _⟨$⟩_; _⟶_) renaming (_∘_ to _⊚_; id to id⊚) open import Relation.Binary.PropositionalEquality using (_≡_; refl; sym; trans; cong; cong₂; setoid; →-to-⟶; module ≡-Reasoning) -- Next are imports from our libraries of Proofs (FiniteFunctions and -- VectorLemmas) open import Proofs using (finext; _!!_; tabulate-split) -- Next we import our notions of equivalences open import Equiv using (_∼_; module qinv; mkqinv; _≃_) -- Next we import sets equipped with equivalence relations and -- specialize to our notions of equivalence open import SetoidEquiv using ( ≃S-Setoid; -- statement of thm2 _≃S_; -- statement of thm2 module _≃S_; -- proof of thm2 module _≋_; -- proof of thm2 equiv; -- proof of thm2 equivS; -- proof of thm2 _≋_ -- proof of thm2 -- id≃S -- 0≃S; -- _≃S≡_; -- _⊎≃S_ ) -- Finally we import our definition of permutations. We start with Vec -- (Fin m) n for arbitrary m and n which---if well-formed---would -- define a permutation in the Cauchy representation. These vectors -- assume a canonical enumeration of the finite sets which we make -- explicit in the module Enumeration. To ensure these vectors are -- well-formed, we define a concrete permutation as a pair of two such -- vectors with two proofs that they compose to the identity -- permutation. open import FinVec using (_∘̂_; 1C) open import FinVecProperties using (~⇒≡; !!⇒∘̂; 1C!!i≡i; cauchyext) open import EnumEquiv using (Enum; 0E; _⊕e_; eval-left; eval-right) open import FiniteType using (FiniteType; ∣_∣) open import ConcretePermutation -- using (CPerm; cp; p≡; 0p; idp; _⊎p_) -- ; SCPerm) open import ConcretePermutationProperties -- using (CPerm; cp; p≡; 0p; idp; _⊎p_) -- ; SCPerm) ------------------------------------------------------------------------------ -- The big (semantic) theorem! thm2 : ∀ {A B : Set} → (a : FiniteType A) → (b : FiniteType B) → (≃S-Setoid A B) ≃S (SCPerm ∣ b ∣ ∣ a ∣) thm2 {A} {B} (n , (enumA , mkqinv labelA αA βA)) (m , (enumB , mkqinv labelB αB βB)) = equiv fwd' bwd' α β where open ≡-Reasoning AS = setoid A BS = setoid B A≃Fn : A ≃ Fin n A≃Fn = (enumA , mkqinv labelA αA βA) B≃Fn : B ≃ Fin m B≃Fn = (enumB , mkqinv labelB αB βB) CP⇨ = SCPerm m n ⇨ SCPerm m n fwd : (AS ≃S BS) → CPerm m n fwd A≃B = cp (tabulate f) (tabulate g) (~⇒≡ β) (~⇒≡ α) where module A≃SB = _≃S_ A≃B f : Fin n → Fin m f j = enumB (A≃SB.f ⟨$⟩ labelA j) g : Fin m → Fin n g j = enumA (A≃SB.g ⟨$⟩ labelB j) α : f ∘ g ∼ id α i = begin (enumB (A≃SB.f ⟨$⟩ (labelA (enumA (A≃SB.g ⟨$⟩ labelB i)))) ≡⟨ cong (λ x → enumB (A≃SB.f ⟨$⟩ x)) (βA ((A≃SB.g ⟨$⟩ labelB i))) ⟩ enumB (A≃SB.f ⟨$⟩ (A≃SB.g ⟨$⟩ labelB i)) ≡⟨ cong enumB (A≃SB.α refl) ⟩ enumB (labelB i) ≡⟨ αB i ⟩ i ∎) β : g ∘ f ∼ id β i = begin ( enumA (A≃SB.g ⟨$⟩ labelB (enumB (A≃SB.f ⟨$⟩ labelA i))) ≡⟨ cong (λ x → enumA (A≃SB.g ⟨$⟩ x)) (βB _) ⟩ enumA (A≃SB.g ⟨$⟩ (A≃SB.f ⟨$⟩ labelA i)) ≡⟨ cong enumA (A≃SB.β refl) ⟩ enumA (labelA i) ≡⟨ αA i ⟩ i ∎) fwd' : ≃S-Setoid A B ⟶ setoid (CPerm m n) fwd' = record { _⟨$⟩_ = fwd ; cong = λ {i} {j} i≋j → p≡ (finext (λ k → cong enumB (f≡ i≋j (labelA k)) )) } where open _≋_ bwd : CPerm m n → (AS ≃S BS) bwd (cp p₁ p₂ αp βp) = equiv f g α β where f : AS ⟶ BS f = →-to-⟶ (λ a → labelB (p₁ !! enumA a)) g : BS ⟶ AS g = →-to-⟶ (λ b → labelA (p₂ !! (enumB b))) α : Setoid._≈_ (BS ⇨ BS) (f ⊚ g) id⊚ α {b} {.b} refl = begin ( labelB (p₁ !! (enumA (labelA (p₂ !! (enumB b))))) ≡⟨ cong (λ x → labelB (p₁ !! x)) (αA _) ⟩ labelB (p₁ !! (p₂ !! enumB b)) ≡⟨ cong labelB (!!⇒∘̂ _ _ (enumB b)) ⟩ labelB ((p₂ ∘̂ p₁) !! enumB b) ≡⟨ cong (λ x → (labelB (x !! enumB b))) βp ⟩ labelB (1C !! enumB b) ≡⟨ cong labelB 1C!!i≡i ⟩ labelB (enumB b) ≡⟨ βB b ⟩ b ∎) β : Setoid._≈_ (AS ⇨ AS) (g ⊚ f) id⊚ β {a} {.a} refl = begin ( labelA (p₂ !! (enumB (labelB (p₁ !! enumA a)))) ≡⟨ cong (λ x → labelA (p₂ !! x)) (αB _) ⟩ labelA (p₂ !! (p₁ !! enumA a)) ≡⟨ cong labelA (!!⇒∘̂ _ _ (enumA a)) ⟩ labelA ((p₁ ∘̂ p₂) !! enumA a) ≡⟨ cong (λ x → labelA (x !! enumA a)) αp ⟩ labelA (1C !! enumA a) ≡⟨ cong labelA 1C!!i≡i ⟩ labelA (enumA a) ≡⟨ βA a ⟩ a ∎) bwd' : setoid (CPerm m n) ⟶ ≃S-Setoid A B bwd' = record { _⟨$⟩_ = bwd ; cong = λ { {π} {.π} refl → equivS (λ _ → refl) (λ _ → refl) } } α : Setoid._≈_ CP⇨ (fwd' ⊚ bwd') id⊚ α {cp π πᵒ αp βp} refl = p≡ (trans (finext pf₁) (cauchyext π)) where pf₁ : (j : Fin n) → enumB (labelB (π !! enumA (labelA j))) ≡ π !! j pf₁ j = begin ( enumB (labelB (π !! enumA (labelA j))) ≡⟨ αB _ ⟩ π !! enumA (labelA j) ≡⟨ cong (_!!_ π) (αA _) ⟩ π !! j ∎) β : {x y : AS ≃S BS} → x ≋ y → ((bwd' ⊚ fwd') ⟨$⟩ x) ≋ y β {equiv f g α β} {equiv f₁ g₁ α₁ β₁} (equivS f≡ g≡) = equivS (λ a → trans (pf₁ a) (f≡ a)) (λ b → trans (pf₂ b) (g≡ b)) where pf₁ : ∀ a → labelB (tabulate (λ j → enumB (f ⟨$⟩ labelA j)) !! (enumA a)) ≡ f ⟨$⟩ a pf₁ a = begin ( labelB (tabulate (λ j → enumB (f ⟨$⟩ labelA j)) !! enumA a) ≡⟨ cong labelB (lookup∘tabulate _ (enumA a)) ⟩ labelB (enumB (f ⟨$⟩ labelA (enumA a))) ≡⟨ βB _ ⟩ f ⟨$⟩ labelA (enumA a) ≡⟨ cong (_⟨$⟩_ f) (βA _) ⟩ f ⟨$⟩ a ∎) pf₂ : ∀ b → labelA (tabulate (λ j → enumA (g ⟨$⟩ labelB j)) !! (enumB b)) ≡ g ⟨$⟩ b pf₂ b = begin ( labelA (tabulate (λ j → enumA (g ⟨$⟩ labelB j)) !! enumB b) ≡⟨ cong labelA (lookup∘tabulate _ (enumB b)) ⟩ labelA (enumA (g ⟨$⟩ labelB (enumB b))) ≡⟨ βA _ ⟩ g ⟨$⟩ labelB (enumB b) ≡⟨ cong (_⟨$⟩_ g) (βB _) ⟩ g ⟨$⟩ b ∎ ) -- Start proving some of the transport lemmas. -- Need to do: -- 1. prove that we have a bijective morphism of carriers: done, this is thm2 (fwd is the morphism) -- 2. prove that it preserves: -- a. id (done) -- b. 0 (done) -- c. + (done) -- d. * {-- Is this still important or has it been subsumed by the categorical work ??? Still important, I believe. It will be used in proving the categorical components of CPermCat. open _≃S_ lemma_1a : ∀ {n} {A : Set} → (EA : Enum A n) → f (thm2 EA EA) ⟨$⟩ id≃S ≡ idp lemma_1a (f' , mkqinv g α _) = p≡ (trans (finext α) F.reveal1C) -- this is redundant, as it follows from lemma_1a. lemma_1b : ∀ {n} {A : Set} → (EA : Enum A n) → (g (thm2 EA EA) ⟨$⟩ idp) ≋ id≃S lemma_1b (enumA , mkqinv g _ β) = equivS (λ x → trans (cong g 1C!!i≡i) (β x)) (λ x → trans (cong g 1C!!i≡i) (β x)) lemma2 : f (thm2 0E 0E) ⟨$⟩ 0≃S ≡ 0p lemma2 = p≡ F.reveal0C -- p≡ refl lemma3 : ∀ {n₁ n₂} {A B C D : Set} {EA : Enum A n₁} {EB : Enum B n₁} {EC : Enum C n₂} {ED : Enum D n₂} → (x : A ≃S≡ B) → (y : C ≃S≡ D) → f (thm2 (EA ⊕e EC) (EB ⊕e ED)) ⟨$⟩ (x ⊎≃S y) ≡ (f (thm2 EA EB) ⟨$⟩ x) ⊎p (f (thm2 EC ED) ⟨$⟩ y) lemma3 {n₁} {n₂} {EA = EA} {EB} {EC} {ED} (equiv f₄ g₄ α₄ β₄) (equiv f₅ g₅ α₅ β₅) = p≡ ( begin ( CPerm.π (f (thm2 (EA ⊕e EC) (EB ⊕e ED)) ⟨$⟩ (x ⊎≃S y)) ≡⟨ refl ⟩ -- inline f, fwd and π tabulate {n₁ + n₂} (λ j → enumBD (x⊎y.f ⟨$⟩ qAC.g j)) ≡⟨ tabulate-split {n₁} {n₂} {f = λ j → enumBD (x⊎y.f ⟨$⟩ qAC.g j)} ⟩ tabulate {n₁} (λ j → enumBD (x⊎y.f ⟨$⟩ qAC.g (inject+ n₂ j))) ++V tabulate {n₂} (λ j → enumBD (x⊎y.f ⟨$⟩ qAC.g (raise n₁ j))) ≡⟨ cong₂ _++V_ (finext {n₁} pf₁) (finext pf₂) ⟩ tabulate {n₁} (λ j → inject+ n₂ (tabulate (λ i → enumB (f₄ ⟨$⟩ qA.g i)) !! j)) ++V tabulate {n₂} (λ j → raise n₁ (tabulate (λ i → enumD (f₅ ⟨$⟩ qC.g i)) !! j)) ≡⟨ sym F.reveal⊎c ⟩ -- going up, inline f, fwd, ⊎p and π CPerm.π ((f (thm2 EA EB) ⟨$⟩ x) ⊎p (f (thm2 EC ED) ⟨$⟩ y)) ∎)) where open ≡-Reasoning x = equiv f₄ g₄ α₄ β₄ y = equiv f₅ g₅ α₅ β₅ enumB = proj₁ EB enumD = proj₁ ED enumAC = proj₁ (EA ⊕e EC) module qAC = qinv (proj₂ (EA ⊕e EC)) module qA = qinv (proj₂ EA) module qC = qinv (proj₂ EC) enumBD = proj₁ (EB ⊕e ED) module x⊎y = _≃S_ (x ⊎≃S y) pf₁ : (i : Fin n₁) → enumBD (x⊎y.f ⟨$⟩ qAC.g (inject+ n₂ i)) ≡ inject+ n₂ (tabulate (λ i₁ → enumB (f₄ ⟨$⟩ qA.g i₁)) !! i) pf₁ i = begin ( enumBD (x⊎y.f ⟨$⟩ qAC.g (inject+ n₂ i)) ≡⟨ cong (λ j → enumBD (x⊎y.f ⟨$⟩ j)) (eval-left {eA = EA} {EC} i) ⟩ enumBD (x⊎y.f ⟨$⟩ inj₁ (qA.g i)) ≡⟨ refl ⟩ -- once the inj₁ is exposed, the rest happens by β-reduction inject+ n₂ (enumB (f₄ ⟨$⟩ qA.g i)) ≡⟨ cong (inject+ n₂) (sym (lookup∘tabulate _ i)) ⟩ inject+ n₂ (tabulate (λ j → enumB (f₄ ⟨$⟩ qA.g j)) !! i) ∎) pf₂ : (i : Fin n₂) → enumBD (x⊎y.f ⟨$⟩ qAC.g (raise n₁ i)) ≡ raise n₁ (tabulate (λ i₁ → enumD (f₅ ⟨$⟩ qC.g i₁)) !! i) pf₂ i = begin ( enumBD (x⊎y.f ⟨$⟩ qAC.g (raise n₁ i)) ≡⟨ cong (λ j → enumBD (x⊎y.f ⟨$⟩ j)) (eval-right {eA = EA} {EC} i) ⟩ enumBD (x⊎y.f ⟨$⟩ inj₂ (qC.g i)) ≡⟨ refl ⟩ raise n₁ (enumD (f₅ ⟨$⟩ qC.g i)) ≡⟨ cong (raise n₁) (sym (lookup∘tabulate _ i)) ⟩ raise n₁ (tabulate (λ i₁ → enumD (f₅ ⟨$⟩ qC.g i₁)) !! i) ∎) -}
{ "alphanum_fraction": 0.4729630983, "avg_line_length": 37.1118644068, "ext": "agda", "hexsha": "c324779bed6ad94716ea92a40a2fdf20c3ba851d", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2019-09-10T09:47:13.000Z", "max_forks_repo_forks_event_min_datetime": "2016-05-29T01:56:33.000Z", "max_forks_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_forks_repo_licenses": [ "BSD-2-Clause" ], "max_forks_repo_name": "JacquesCarette/pi-dual", "max_forks_repo_path": "Univalence/Obsolete/SEquivSCPermEquiv2.agda", "max_issues_count": 4, "max_issues_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_issues_repo_issues_event_max_datetime": "2021-10-29T20:41:23.000Z", "max_issues_repo_issues_event_min_datetime": "2018-06-07T16:27:41.000Z", "max_issues_repo_licenses": [ "BSD-2-Clause" ], "max_issues_repo_name": "JacquesCarette/pi-dual", "max_issues_repo_path": "Univalence/Obsolete/SEquivSCPermEquiv2.agda", "max_line_length": 100, "max_stars_count": 14, "max_stars_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_stars_repo_licenses": [ "BSD-2-Clause" ], "max_stars_repo_name": "JacquesCarette/pi-dual", "max_stars_repo_path": "Univalence/Obsolete/SEquivSCPermEquiv2.agda", "max_stars_repo_stars_event_max_datetime": "2021-05-05T01:07:57.000Z", "max_stars_repo_stars_event_min_datetime": "2015-08-18T21:40:15.000Z", "num_tokens": 4368, "size": 10948 }
module OlderBasicILP.Direct.Hilbert.Nested where open import Common.Context public -- Propositions of intuitionistic logic of proofs, without ∨, ⊥, or +. mutual infixr 10 _⦂_ infixl 9 _∧_ infixr 7 _▻_ data Ty : Set where α_ : Atom → Ty _▻_ : Ty → Ty → Ty _⦂_ : Box → Ty → Ty _∧_ : Ty → Ty → Ty ⊤ : Ty record Box : Set where inductive constructor [_] field {/A} : Ty t : ∅ ⊢ /A -- Derivations, as Hilbert-style combinator trees. infix 3 _⊢_ data _⊢_ (Γ : Cx Ty) : Ty → Set where var : ∀ {A} → A ∈ Γ → Γ ⊢ A app : ∀ {A B} → Γ ⊢ A ▻ B → Γ ⊢ A → Γ ⊢ B ci : ∀ {A} → Γ ⊢ A ▻ A ck : ∀ {A B} → Γ ⊢ A ▻ B ▻ A cs : ∀ {A B C} → Γ ⊢ (A ▻ B ▻ C) ▻ (A ▻ B) ▻ A ▻ C box : ∀ {A} → (t : ∅ ⊢ A) → Γ ⊢ [ t ] ⦂ A cdist : ∀ {A B} {t : ∅ ⊢ A ▻ B} {u : ∅ ⊢ A} → Γ ⊢ [ t ] ⦂ (A ▻ B) ▻ [ u ] ⦂ A ▻ [ app t u ] ⦂ B cup : ∀ {A} {t : ∅ ⊢ A} → Γ ⊢ [ t ] ⦂ A ▻ [ box t ] ⦂ [ t ] ⦂ A cdown : ∀ {A} {t : ∅ ⊢ A} → Γ ⊢ [ t ] ⦂ A ▻ A cpair : ∀ {A B} → Γ ⊢ A ▻ B ▻ A ∧ B cfst : ∀ {A B} → Γ ⊢ A ∧ B ▻ A csnd : ∀ {A B} → Γ ⊢ A ∧ B ▻ B unit : Γ ⊢ ⊤ infix 3 _⊢⋆_ _⊢⋆_ : Cx Ty → Cx Ty → Set Γ ⊢⋆ ∅ = 𝟙 Γ ⊢⋆ Ξ , A = Γ ⊢⋆ Ξ × Γ ⊢ A infix 7 _▻◅_ _▻◅_ : Ty → Ty → Ty A ▻◅ B = (A ▻ B) ∧ (B ▻ A) -- Additional useful propositions. _⦂⋆_ : ∀ {n} → VCx Box n → VCx Ty n → Cx Ty ∅ ⦂⋆ ∅ = ∅ (ts , t) ⦂⋆ (Ξ , A) = (ts ⦂⋆ Ξ) , (t ⦂ A) -- Monotonicity with respect to context inclusion. mono⊢ : ∀ {A Γ Γ′} → Γ ⊆ Γ′ → Γ ⊢ A → Γ′ ⊢ A mono⊢ η (var i) = var (mono∈ η i) mono⊢ η (app t u) = app (mono⊢ η t) (mono⊢ η u) mono⊢ η ci = ci mono⊢ η ck = ck mono⊢ η cs = cs mono⊢ η (box t) = box t mono⊢ η cdist = cdist mono⊢ η cup = cup mono⊢ η cdown = cdown mono⊢ η cpair = cpair mono⊢ η cfst = cfst mono⊢ η csnd = csnd mono⊢ η unit = unit mono⊢⋆ : ∀ {Ξ Γ Γ′} → Γ ⊆ Γ′ → Γ ⊢⋆ Ξ → Γ′ ⊢⋆ Ξ mono⊢⋆ {∅} η ∙ = ∙ mono⊢⋆ {Ξ , A} η (ts , t) = mono⊢⋆ η ts , mono⊢ η t -- Shorthand for variables. 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₂ -- Reflexivity. refl⊢⋆ : ∀ {Γ} → Γ ⊢⋆ Γ refl⊢⋆ {∅} = ∙ refl⊢⋆ {Γ , A} = mono⊢⋆ weak⊆ refl⊢⋆ , v₀ -- Deduction theorem. lam : ∀ {A B Γ} → Γ , A ⊢ B → Γ ⊢ A ▻ B lam (var top) = ci lam (var (pop i)) = app ck (var i) lam (app t u) = app (app cs (lam t)) (lam u) lam ci = app ck ci lam ck = app ck ck lam cs = app ck cs lam (box t) = app ck (box t) lam cdist = app ck cdist lam cup = app ck cup lam cdown = app ck cdown lam cpair = app ck cpair lam cfst = app ck cfst lam csnd = app ck csnd lam unit = app ck unit -- Detachment theorem. det : ∀ {A B Γ} → Γ ⊢ A ▻ B → Γ , A ⊢ B det t = app (mono⊢ weak⊆ t) v₀ -- Cut and multicut. cut : ∀ {A B Γ} → Γ ⊢ A → Γ , A ⊢ B → Γ ⊢ B cut t u = app (lam u) t multicut : ∀ {Ξ A Γ} → Γ ⊢⋆ Ξ → Ξ ⊢ A → Γ ⊢ A multicut {∅} ∙ u = mono⊢ bot⊆ u multicut {Ξ , B} (ts , t) u = app (multicut ts (lam u)) t -- Transitivity. trans⊢⋆ : ∀ {Γ″ Γ′ Γ} → Γ ⊢⋆ Γ′ → Γ′ ⊢⋆ Γ″ → Γ ⊢⋆ Γ″ trans⊢⋆ {∅} ts ∙ = ∙ trans⊢⋆ {Γ″ , A} ts (us , u) = trans⊢⋆ ts us , multicut ts u -- Contraction. ccont : ∀ {A B Γ} → Γ ⊢ (A ▻ A ▻ B) ▻ A ▻ B ccont = lam (lam (app (app v₁ v₀) v₀)) cont : ∀ {A B Γ} → Γ , A , A ⊢ B → Γ , A ⊢ B cont t = det (app ccont (lam (lam t))) -- Exchange, or Schönfinkel’s C combinator. cexch : ∀ {A B C Γ} → Γ ⊢ (A ▻ B ▻ C) ▻ B ▻ A ▻ C cexch = lam (lam (lam (app (app v₂ v₀) v₁))) exch : ∀ {A B C Γ} → Γ , A , B ⊢ C → Γ , B , A ⊢ C exch t = det (det (app cexch (lam (lam t)))) -- Composition, or Schönfinkel’s B combinator. ccomp : ∀ {A B C Γ} → Γ ⊢ (B ▻ C) ▻ (A ▻ B) ▻ A ▻ C ccomp = lam (lam (lam (app v₂ (app v₁ v₀)))) comp : ∀ {A B C Γ} → Γ , B ⊢ C → Γ , A ⊢ B → Γ , A ⊢ C comp t u = det (app (app ccomp (lam t)) (lam u)) -- Useful theorems in functional form. dist : ∀ {A B Γ} {t : ∅ ⊢ A ▻ B} {u : ∅ ⊢ A} → Γ ⊢ [ t ] ⦂ (A ▻ B) → Γ ⊢ [ u ] ⦂ A → Γ ⊢ [ app t u ] ⦂ B dist t u = app (app cdist t) u up : ∀ {A Γ} {t : ∅ ⊢ A} → Γ ⊢ [ t ] ⦂ A → Γ ⊢ [ box t ] ⦂ [ t ] ⦂ A up t = app cup t down : ∀ {A Γ} {t : ∅ ⊢ A} → Γ ⊢ [ t ] ⦂ A → Γ ⊢ A down t = app cdown t distup : ∀ {A B Γ} {u : ∅ ⊢ A} {t : ∅ ⊢ [ u ] ⦂ A ▻ B} → Γ ⊢ [ t ] ⦂ ([ u ] ⦂ A ▻ B) → Γ ⊢ [ u ] ⦂ A → Γ ⊢ [ app t (box u) ] ⦂ B distup t u = dist t (up u) unbox : ∀ {A C Γ} {t : ∅ ⊢ A} {u : ∅ ⊢ C} → Γ ⊢ [ t ] ⦂ A → Γ , [ t ] ⦂ A ⊢ [ u ] ⦂ C → Γ ⊢ [ u ] ⦂ C unbox t u = app (lam u) t -- FIXME ↓ FIXME ↓ FIXME ----------------------------------------------------- -- -- ??? distup′ : ∀ {A B Γ} {u : ∅ ⊢ A} {t : ∅ , [ u ] ⦂ A ⊢ B} → Γ ⊢ [ lam t ] ⦂ ([ u ] ⦂ A ▻ B) → Γ ⊢ [ u ] ⦂ A → Γ ⊢ [ app (lam t) (box u) ] ⦂ B distup′ t u = dist t (up u) -- multibox : ∀ {n A Γ} {[ss] : VCx Box n} {Ξ : VCx Ty n} -- → Γ ⊢⋆ [ss] ⦂⋆ Ξ → (u : [ss] ⦂⋆ Ξ ⊢ A) -- → Γ ⊢ {!!} ⦂ A -- multibox {[ss] = ∅} {∅} ∙ u = box u -- multibox {[ss] = [ss] , [ s ]} {Ξ , B} (ts , t) u = {!!} -- FIXME ↑ FIXME ↑ FIXME ----------------------------------------------------- pair : ∀ {A B Γ} → Γ ⊢ A → Γ ⊢ B → Γ ⊢ A ∧ B pair t u = app (app cpair t) u fst : ∀ {A B Γ} → Γ ⊢ A ∧ B → Γ ⊢ A fst t = app cfst t snd : ∀ {A B Γ} → Γ ⊢ A ∧ B → Γ ⊢ B snd t = app csnd t -- Closure under context concatenation. concat : ∀ {A B Γ} Γ′ → Γ , A ⊢ B → Γ′ ⊢ A → Γ ⧺ Γ′ ⊢ B concat Γ′ t u = app (mono⊢ (weak⊆⧺₁ Γ′) (lam t)) (mono⊢ weak⊆⧺₂ u)
{ "alphanum_fraction": 0.3935384087, "avg_line_length": 24.974248927, "ext": "agda", "hexsha": "54de04e800f2006e586415d48828a723ee06e3b2", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "fcd187db70f0a39b894fe44fad0107f61849405c", "max_forks_repo_licenses": [ "X11" ], "max_forks_repo_name": "mietek/hilbert-gentzen", "max_forks_repo_path": "OlderBasicILP/Direct/Hilbert/Nested.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "fcd187db70f0a39b894fe44fad0107f61849405c", "max_issues_repo_issues_event_max_datetime": "2018-06-10T09:11:22.000Z", "max_issues_repo_issues_event_min_datetime": "2018-06-10T09:11:22.000Z", "max_issues_repo_licenses": [ "X11" ], "max_issues_repo_name": "mietek/hilbert-gentzen", "max_issues_repo_path": "OlderBasicILP/Direct/Hilbert/Nested.agda", "max_line_length": 82, "max_stars_count": 29, "max_stars_repo_head_hexsha": "fcd187db70f0a39b894fe44fad0107f61849405c", "max_stars_repo_licenses": [ "X11" ], "max_stars_repo_name": "mietek/hilbert-gentzen", "max_stars_repo_path": "OlderBasicILP/Direct/Hilbert/Nested.agda", "max_stars_repo_stars_event_max_datetime": "2022-01-01T10:29:18.000Z", "max_stars_repo_stars_event_min_datetime": "2016-07-03T18:51:56.000Z", "num_tokens": 2848, "size": 5819 }
open import Agda.Builtin.Equality record Box (B : Set) : Set₁ where constructor box field unbox : B -- here: .unbox is a valid forced pattern =box : {B : Set} {Γ₀ Γ₁ : Box B} → Box.unbox Γ₀ ≡ Box.unbox Γ₁ → Γ₀ ≡ Γ₁ =box {Γ₀ = box unbox} {box r} p = ? open Box public -- here: .unbox is now the name of a projection and should therefore -- not be generated =box' : {B : Set} {Γ₀ Γ₁ : Box B} → unbox Γ₀ ≡ unbox Γ₁ → Γ₀ ≡ Γ₁ =box' {Γ₀ = box unbox} {box r} p = ?
{ "alphanum_fraction": 0.6168421053, "avg_line_length": 23.75, "ext": "agda", "hexsha": "1cbfd89472a49c8e0de042bf09ea0dca1341a81a", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cruhland/agda", "max_forks_repo_path": "test/interaction/Issue3491.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "cruhland/agda", "max_issues_repo_path": "test/interaction/Issue3491.agda", "max_line_length": 72, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/interaction/Issue3491.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 187, "size": 475 }
module UnSized.SimpleCell where open import Data.Product open import Data.String.Base open import UnSizedIO.Object open import UnSizedIO.IOObject open import UnSizedIO.ConsoleObject open import UnSizedIO.Base hiding (main) open import UnSizedIO.Console hiding (main) open import NativeIO data CellMethod A : Set where get : CellMethod A put : A → CellMethod A CellResult : ∀{A} → CellMethod A → Set CellResult {A} get = A CellResult (put _) = Unit -- cellI is the interface of the object of a simple cell cellI : (A : Set) → Interface Method (cellI A) = CellMethod A Result (cellI A) m = CellResult m -- cellC is the type of consoleObjects with interface (cellI String) CellC : Set CellC = ConsoleObject (cellI String) -- cellO is a program for a simple cell which -- when get is called writes "getting s" for the string s of the object -- and when putting s writes "putting s" for the string -- cellP is constructor for the consoleObject for interface (cellI String) cellP : (s : String) → CellC force (method (cellP s) get) = exec' (putStrLn ("getting (" ++ s ++ ")")) λ _ → delay (return' (s , cellP s)) force (method (cellP s) (put x)) = exec' (putStrLn ("putting (" ++ x ++ ")")) λ _ → delay (return' (_ , (cellP x))) -- Program is another program program : String → IOConsole Unit program arg = let c₀ = cellP "Start" in method c₀ get >>= λ{ (s , c₁) → exec1 (putStrLn s) >> method c₁ (put arg) >>= λ{ (_ , c₂) → method c₂ get >>= λ{ (s' , c₃) → exec1 (putStrLn s') }}} main : NativeIO Unit main = translateIOConsole (program "hello")
{ "alphanum_fraction": 0.6681087763, "avg_line_length": 27.4237288136, "ext": "agda", "hexsha": "ea6793f3b0fdd4972fd0c1174d6976133cd50ad8", "lang": "Agda", "max_forks_count": 2, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:41:00.000Z", "max_forks_repo_forks_event_min_datetime": "2018-09-01T15:02:37.000Z", "max_forks_repo_head_hexsha": "7cc45e0148a4a508d20ed67e791544c30fecd795", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "agda/ooAgda", "max_forks_repo_path": "examples/UnSized/SimpleCell.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "7cc45e0148a4a508d20ed67e791544c30fecd795", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "agda/ooAgda", "max_issues_repo_path": "examples/UnSized/SimpleCell.agda", "max_line_length": 74, "max_stars_count": 23, "max_stars_repo_head_hexsha": "7cc45e0148a4a508d20ed67e791544c30fecd795", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "agda/ooAgda", "max_stars_repo_path": "examples/UnSized/SimpleCell.agda", "max_stars_repo_stars_event_max_datetime": "2020-10-12T23:15:25.000Z", "max_stars_repo_stars_event_min_datetime": "2016-06-19T12:57:55.000Z", "num_tokens": 491, "size": 1618 }
{-# OPTIONS --without-K #-} module PiLevel1Alternative where open import Relation.Binary.PropositionalEquality open import Data.Nat open import Data.Vec open import FinVec open F open import ConcretePermutation ------------------------------------------------------------------------------ -- Equivalences between permutations -- Objects are level 0 permutations ⟷ -- Morphisms are equivalences between these permutations factorial : ℕ → ℕ factorial 0 = 1 factorial (suc n) = n * factorial n record EquivBetweenPerm {values : ℕ} {size : ℕ} (p₁ p₂ : CPerm values size) : Set where constructor ebp module p₁ = CPerm p₁ module p₂ = CPerm p₂ field -- first we have a permutation on the underlying finite sets π : FinVec values size πᵒ : FinVec size values αp : π ∘̂ πᵒ ≡ F.1C βp : πᵒ ∘̂ π ≡ F.1C -- then we have a permutation on these maps are consistent with p₁.π, p₂.π, etc. ππ : Vec (FinVec values size) (factorial size) -- ??? NO -- and so on -- and apply {-- Ex: the two underlying permutations p₁ and p₂ are: values = {A,B,C} size = 3 p₁.π = { A <=> C, B <=> A, C <=> B } represented as {C,A,B} p₂.π = { A <=> C, B <=> A, C <=> B } represented as {C,A,B} one equivalence between these permutations is 'id'; another has: π = { A <=> B, B <=> C, C <=> A } ππ = { (A <=> C) <=> (B <=> A), (B <=> A) <=> (C <=> B), (C <=> B) <=> (A <=> C) } represented as p₁.πᵒ ??? --} ------------------------------------------------------------------------------
{ "alphanum_fraction": 0.537428023, "avg_line_length": 28.4181818182, "ext": "agda", "hexsha": "c5945ede4389948ed9282c37f21a1d5c65c68528", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2019-09-10T09:47:13.000Z", "max_forks_repo_forks_event_min_datetime": "2016-05-29T01:56:33.000Z", "max_forks_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_forks_repo_licenses": [ "BSD-2-Clause" ], "max_forks_repo_name": "JacquesCarette/pi-dual", "max_forks_repo_path": "Univalence/Obsolete/PiLevel1Alternative.agda", "max_issues_count": 4, "max_issues_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_issues_repo_issues_event_max_datetime": "2021-10-29T20:41:23.000Z", "max_issues_repo_issues_event_min_datetime": "2018-06-07T16:27:41.000Z", "max_issues_repo_licenses": [ "BSD-2-Clause" ], "max_issues_repo_name": "JacquesCarette/pi-dual", "max_issues_repo_path": "Univalence/Obsolete/PiLevel1Alternative.agda", "max_line_length": 88, "max_stars_count": 14, "max_stars_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_stars_repo_licenses": [ "BSD-2-Clause" ], "max_stars_repo_name": "JacquesCarette/pi-dual", "max_stars_repo_path": "Univalence/Obsolete/PiLevel1Alternative.agda", "max_stars_repo_stars_event_max_datetime": "2021-05-05T01:07:57.000Z", "max_stars_repo_stars_event_min_datetime": "2015-08-18T21:40:15.000Z", "num_tokens": 461, "size": 1563 }
module Naturals where import Relation.Binary.PropositionalEquality as Eq open Eq using (_≡_ ; refl ; cong ) open Eq.≡-Reasoning using (begin_; _≡⟨⟩_; _∎ ) data ℕ : Set where zero : ℕ suc : ℕ → ℕ {-# BUILTIN NATURAL ℕ #-} infixl 6 _+_ _+_ : ℕ → ℕ → ℕ zero + x = x (suc a) + x = suc (a + x) -- Exercise: Write the reasoning chain of 3 + 4 _ : 3 + 4 ≡ 7 _ = begin 3 + 4 ≡⟨⟩ suc (2 + 4) ≡⟨⟩ suc (suc (1 + 4)) ≡⟨⟩ suc (suc (suc (0 + 4))) ≡⟨⟩ suc (suc (suc 4)) ≡⟨⟩ 7 ∎ infixl 7 _*_ _*_ : ℕ → ℕ → ℕ zero * y = zero suc x * y = y + (x * y) _ : 3 * 4 ≡ 12 _ = begin 3 * 4 ≡⟨⟩ 4 + (2 * 4) ≡⟨⟩ 4 + (4 + (1 * 4)) ≡⟨⟩ 4 + (4 + (4 + (0 * 4))) ≡⟨⟩ 4 + (4 + (4 + (0 * 4))) ≡⟨⟩ 4 + (4 + (4 + 0)) ≡⟨⟩ 12 ∎ _^_ : ℕ → ℕ → ℕ x ^ zero = 1 x ^ suc y = x * (x ^ y) -- Kinda like minus, but not exactly infixl 6 _monus_ _monus_ : ℕ → ℕ → ℕ zero monus y = zero suc x monus zero = suc x suc x monus suc y = x monus y _ : 5 monus 3 ≡ 2 _ = begin 5 monus 3 ≡⟨⟩ 4 monus 2 ≡⟨⟩ 3 monus 1 ≡⟨⟩ 2 monus 0 ≡⟨⟩ 2 ∎ _ : 3 monus 5 ≡ 0 _ = begin 2 monus 4 ≡⟨⟩ 1 monus 3 ≡⟨⟩ 0 monus 2 ≡⟨⟩ 0 ∎ {-# BUILTIN NATPLUS _+_ #-} {-# BUILTIN NATTIMES _*_ #-} {-# BUILTIN NATMINUS _monus_ #-} data Bin : Set where -- Empty bitstring ⟨⟩ : Bin -- Append a zero _O : Bin → Bin -- Append a one _I : Bin → Bin inc : Bin → Bin inc ⟨⟩ = ⟨⟩ I inc (b O) = b I inc (b I) = (inc b) O to : ℕ → Bin to zero = ⟨⟩ O to (suc n) = inc (to n) from : Bin → ℕ from ⟨⟩ = zero from (b O) = from b * 2 from (b I) = from b * 2 + 1 -- I tried to prove these things doing some basic stuff but sadly got nowhere -- I probably should just read the next chapter! (lol) --multCommutes : (a : ℕ) → (b : ℕ) → a * b ≡ b * a --multCommutes zero zero = refl --multCommutes zero (suc b) = multCommutes zero b --multCommutes (suc a) zero = multCommutes a zero --multCommutes (suc a) (suc b) = {! cong (multCommutes a b) !} --multIsAssociative : (a : ℕ) → (b : ℕ) → (c : ℕ) → (a * b) * c ≡ a * (b * c) --multIsAssociative zero b c = refl --multIsAssociative (suc a) zero c = refl --multIsAssociative (suc a) (suc b) zero = refl --multIsAssociative (suc a) (suc b) (suc c) = {! multIsAssociative a b c !}
{ "alphanum_fraction": 0.5128540305, "avg_line_length": 17.2556390977, "ext": "agda", "hexsha": "3a38d0b8aee32e452ebdce7ddc3a38b821096d38", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "9f81052c4c872f0e19677bf6e9710350d3acf0e5", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "GustavoMF31/upgraded-happiness", "max_forks_repo_path": "Naturals.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "9f81052c4c872f0e19677bf6e9710350d3acf0e5", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "GustavoMF31/upgraded-happiness", "max_issues_repo_path": "Naturals.agda", "max_line_length": 77, "max_stars_count": null, "max_stars_repo_head_hexsha": "9f81052c4c872f0e19677bf6e9710350d3acf0e5", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "GustavoMF31/upgraded-happiness", "max_stars_repo_path": "Naturals.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1073, "size": 2295 }
module OpAppP where data Bool : Set where false : Bool true : Bool _&&_ : Bool → Bool → Bool false && _ = false true && b = b
{ "alphanum_fraction": 0.5159235669, "avg_line_length": 7.1363636364, "ext": "agda", "hexsha": "6ec4a0f18ef4ceb9ae47116db71168ea2365ff02", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2022-03-01T16:38:14.000Z", "max_forks_repo_forks_event_min_datetime": "2022-03-01T16:38:14.000Z", "max_forks_repo_head_hexsha": "f327f9aab8dcb07022b857736d8201906bba02e9", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "msuperdock/agda-unused", "max_forks_repo_path": "data/pattern/OpAppP.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "f327f9aab8dcb07022b857736d8201906bba02e9", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "msuperdock/agda-unused", "max_issues_repo_path": "data/pattern/OpAppP.agda", "max_line_length": 19, "max_stars_count": 6, "max_stars_repo_head_hexsha": "f327f9aab8dcb07022b857736d8201906bba02e9", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "msuperdock/agda-unused", "max_stars_repo_path": "data/pattern/OpAppP.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-01T16:38:05.000Z", "max_stars_repo_stars_event_min_datetime": "2020-10-29T09:38:43.000Z", "num_tokens": 60, "size": 157 }
module SizedIO.coIOIOObject where open import Data.Unit.Base open import Data.Product open import Data.String.Base open import Size open import SizedIO.Object open import SizedIO.Base open import SizedIO.Console open import SizedIO.coIOIO -- open import SizedIO.IOObject record IOObject' (i : Size) (iface : Interface)(C : Set)(R : C → Set) : Set where coinductive field method : ∀{j : Size< i} (m : Method iface) → IO j C R (Response iface m × IOObject' j iface C R) open IOObject' public -- An IO object is like a simple object, -- but the method returns IO applied to the result type of a simple object -- which means the method returns an IO program which when terminating -- returns the result of the simple object record coIO²Object (i : Size) (iface : Interface) (Cin : Set)(Rin : Cin → Set) (Cext : Set)(Rext : Cext → Set) : Set where coinductive field method' : ∀{j : Size< i} (m : Method iface) → coIO²∞ ∞ Cin Rin Cext Rext (Response iface m × coIO²Object j iface Cin Rin Cext Rext) open coIO²Object public selfrefIOObject : (i : Size) (iface : Interface) (Cext : Set) (Rext : Cext → Set) → Set selfrefIOObject i iface Cext Rext = coIO²Object i iface (Method iface) (Response iface) Cext Rext mutual compileSelfRef : (i : Size) (iface : Interface) (Cext : Set) (Rext : Cext → Set) (obj : selfrefIOObject i iface Cext Rext) → IOObject' i iface Cext Rext IO.force (method (compileSelfRef i iface Cext Rext obj) {i'} m) {j} = compileSelfRefaux i' j iface Cext Rext (Response iface m) (coIO²∞.force (method' obj {i'} m) j) compileSelfRefaux : (i : Size) (j : Size< i) (iface : Interface) (let M = Method iface) (let R = Response iface) (Cext : Set) (Rext : Cext → Set) (A : Set) (coObj : coIO² ∞ j M R Cext Rext (A × coIO²Object i iface M R Cext Rext)) → IO' j Cext Rext (A × IOObject' i iface Cext Rext) compileSelfRefaux i j iface Cext Rext A (coIO².return (r , obj)) = return' (r , compileSelfRef i iface Cext Rext obj) compileSelfRefaux i j iface Cext Rext A (dof i' m f) = {! >>=!} compileSelfRefaux i j iface Cext Rext A (do∞ c f) = do' c (λ r → compileSelfRefaux'' i j iface Cext Rext A (f r)) compileSelfRefaux'' : (i : Size) (j : Size< i) (iface : Interface) (let M = Method iface) (let R = Response iface) (Cext : Set) (Rext : Cext → Set) (A : Set) (coObj : coIO²∞ j M R Cext Rext (A × coIO²Object i iface M R Cext Rext)) → IO j Cext Rext (A × IOObject' i iface Cext Rext) IO.force (compileSelfRefaux'' i j iface Cext Rext A coObj) {j''} = compileSelfRefaux i j'' iface Cext Rext A (coIO²∞.force coObj j'') -- compileSelfRefaux'' i' j iface Cext Rext A coObj -- = compileSelfRefaux' i' j iface Cext Rext A (coIO²∞.force coObj {!!}) {- compileSelfRefaux' : (i' : Size) (j : Size< i') (iface : Interface) (let M = Methods iface) (let R = Responses iface) (Cext : Set) (Rext : Cext → Set) (A : Set) (coObj : coIO² ∞ j M R Cext Rext (A × coIO²Object i' iface M R Cext Rext)) → IO j Cext Rext (A × IOObject' i' iface Cext Rext) IO.force (compileSelfRefaux' i' j iface Cext Rext A coObj) = compileSelfRefaux i' j iface Cext Rext A coObj -} {- 123;456hallo789 123;456hallo789 123;789hallo456 123;789hallo456 123;789456 123;789456 123;456789 123;456789 123;456789 123;456789 C-x r k -- kill rectangle C-x r y -- yank rectangle C-x r t -- text rectangle -} {- M-x abbrev-mode C-x ail crosss → \ -} -- method' obj {j'} m {- compileSelfRefaux : (j' : Size) (iface : Interface) (Cext : Set) (Rext : Cext → Set) (m : Methods iface) ( p : coIO²∞ ∞ (Methods iface) (Responses iface) Cext Rext (Responses iface m × coIO²Object j' iface (Methods iface) (Responses iface) Cext Rext)) → IO' j' Cext Rext (Responses iface m × IOObject' j iface Cext Rext)IO' j' Cext Rext (Responses iface m × IOObject' j iface Cext Rext) -}
{ "alphanum_fraction": 0.5826362198, "avg_line_length": 32.0507246377, "ext": "agda", "hexsha": "390a0078c4784b5644517431d823e544f181632e", "lang": "Agda", "max_forks_count": 2, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:41:00.000Z", "max_forks_repo_forks_event_min_datetime": "2018-09-01T15:02:37.000Z", "max_forks_repo_head_hexsha": "7cc45e0148a4a508d20ed67e791544c30fecd795", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "agda/ooAgda", "max_forks_repo_path": "src/SizedIO/coIOIOObject.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "7cc45e0148a4a508d20ed67e791544c30fecd795", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "agda/ooAgda", "max_issues_repo_path": "src/SizedIO/coIOIOObject.agda", "max_line_length": 135, "max_stars_count": 23, "max_stars_repo_head_hexsha": "7cc45e0148a4a508d20ed67e791544c30fecd795", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "agda/ooAgda", "max_stars_repo_path": "src/SizedIO/coIOIOObject.agda", "max_stars_repo_stars_event_max_datetime": "2020-10-12T23:15:25.000Z", "max_stars_repo_stars_event_min_datetime": "2016-06-19T12:57:55.000Z", "num_tokens": 1397, "size": 4423 }
{-# OPTIONS --omega-in-omega --no-termination-check --overlapping-instances #-} module Light.Library.Data.Empty where open import Light.Level using (Level ; Setω) open import Light.Variable.Sets record Dependencies : Setω where record Library (dependencies : Dependencies) : Setω where field ℓ : Level Empty : Set ℓ eliminate : Empty → 𝕒 open Library ⦃ ... ⦄ public
{ "alphanum_fraction": 0.6674757282, "avg_line_length": 25.75, "ext": "agda", "hexsha": "56b55a0903abd93889606f11277f640020dd2fe9", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "44b1c724f2de95d3a9effe87ca36ef9eca8b4756", "max_forks_repo_licenses": [ "0BSD" ], "max_forks_repo_name": "Zambonifofex/lightlib", "max_forks_repo_path": "Light/Library/Data/Empty.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "44b1c724f2de95d3a9effe87ca36ef9eca8b4756", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "0BSD" ], "max_issues_repo_name": "Zambonifofex/lightlib", "max_issues_repo_path": "Light/Library/Data/Empty.agda", "max_line_length": 79, "max_stars_count": 1, "max_stars_repo_head_hexsha": "44b1c724f2de95d3a9effe87ca36ef9eca8b4756", "max_stars_repo_licenses": [ "0BSD" ], "max_stars_repo_name": "zamfofex/lightlib", "max_stars_repo_path": "Light/Library/Data/Empty.agda", "max_stars_repo_stars_event_max_datetime": "2019-12-20T21:33:05.000Z", "max_stars_repo_stars_event_min_datetime": "2019-12-20T21:33:05.000Z", "num_tokens": 98, "size": 412 }
open import Everything module Test.Test6 where module TestReflexivity where postulate X : Set F : X → X → Set instance ReflexivityF : Reflexivity.class F test : ∀ {y} → F y y test {y = y} = reflexivity {- Goal: F y y Have: {𝔬 : Ł} {𝔒 : Set 𝔬} {𝔯 : Ł} {_∼_ : 𝔒 → 𝔒 → Set 𝔯} {{r : 𝓡eflexivity {𝔬} {𝔒} {𝔯} _∼_}} {x : 𝔒} → x ∼ x ———————————————————————————————————————————————————————————— y : X _𝔬1 : Ł _𝔒1 : Set _𝔬1 _𝔯1 : Ł __∼1_ : _𝔒1 → _𝔒1 → Set _𝔯1 _r1 : 𝓡eflexivity {_𝔬1} {_𝔒1} {_𝔯1} __∼1_ _x1 : _𝔒1 __∼1_ _x1 _x1 = F y y __∼1_ := λ s t → F s t _x1 := y __∼1_ := λ s t → F t s _x1 := y __∼1_ := λ s t → F y y λ {𝔬} {𝔒} {𝔯} {_∼_} → 𝓡eflexivity.reflexivity -} module _Indexed where record I (M : Set) (N : M → Set) : Set where field f : ∀ {m} → N m open I ⦃ … ⦄ postulate A : Set B : A → Set instance iB : I A B test : ∀ {a} → B a test {a = a} = f module IndexedTotal1Var where record Indexed (M : Set) (N : M → Set) : Set where field fooI : ∀ {m} → N m open Indexed ⦃ … ⦄ record Total (N : Set) : Set where field fooT : N open Total ⦃ … ⦄ postulate A : Set B : A → Set B' : A → Set instance iIndexed : Indexed A B instance iTotal : ∀ {x} → Total (B x) instance iIndexed' : Indexed A B' instance iTotal' : ∀ {x} → Total (B' x) testIndexed : ∀ {a} → B a testIndexed {a = a} = fooI testTotal : ∀ {a} → B a testTotal {a = a} = fooT {- Goal: B a Have: {M : Set} {N : M → Set} {{r : R M N}} {m : M} → N m ———————————————————————————————————————————————————————————— a : A _M : Set _N : _M → Set _r : R _M _N _m : _M _N _m = B a no unconstrained metavariables in type of _r because _M occurs in the type of _N and _N _m = B a candidate#1 _r := iR : R A B _M = A _M := A _N = B _N := B now we can solve for _m: _N := B _N _m = B a B _m = B a _m = a _m := a -} module Indexed≡Total2Prop where open import Oscar.Data.Proposequality record Indexed {M : Set} (N : M → Set) (s : ∀ {m} → N m → N m) (S : ∀ {m} → N m → N m → Set) {F : ∀ {m} (n : N m) → Set} ⦃ _ : (λ {m} (n : N m) → S n (s n)) ≡ F ⦄ : Set where field fooI : ∀ {m} {n : N m} → S n (s n) open Indexed ⦃ … ⦄ record Total {N : Set} (s : N → N) (S : N → N → Set) : Set where field fooT : ∀ n → S n (s n) open Total ⦃ … ⦄ postulate A : Set B : A → Set f : ∀ {x} → B x → B x F : ∀ {x} → B x → B x → Set instance iIndexed : Indexed B f F ⦃ ∅ ⦄ instance iTotal : ∀ {x} → Total (f {x}) (F {x}) testIndexed : ∀ {a} {b : B a} → F b (f b) testIndexed = fooI ⦃ ∅ ⦄ testTotal : ∀ {a} (b : B a) → F b (f b) testTotal = fooT {S = F} module Indexed≡Total1Prop where open import Oscar.Data.Proposequality record Indexed {M : Set} (N : M → Set) (s : ∀ {m} → N m → N m) (S : ∀ {m} → N m → Set) {F : ∀ {m} (n : N m) → Set} ⦃ _ : (λ {m} (n : N m) → S (s n)) ≡ F ⦄ : Set where field fooI : ∀ {m} {n : N m} → S (s n) open Indexed ⦃ … ⦄ record Total {N : Set} (s : N → N) (S : N → Set) : Set where field fooT : ∀ n → S (s n) open Total ⦃ … ⦄ postulate A : Set B : A → Set f : ∀ {x} → B x → B x F : ∀ {x} → B x → Set instance iIndexed : Indexed B f F ⦃ ∅ ⦄ instance iTotal : ∀ {x} → Total (f {x}) (F {x}) testIndexed : ∀ {a} {b : B a} → F (f b) testIndexed = fooI ⦃ ∅ ⦄ testTotal : ∀ {a} (b : B a) → F (f b) testTotal = fooT {S = F} module Indexed≡Total1Prop<Constraint where open import Oscar.Data.Proposequality data Luft {a} {A : Set a} (x : A) : Set where instance ∅ : Luft x record Indexed {M : Set} (N : M → Set) (s : ∀ {m} → N m → N m) (S : ∀ {m} → N m → Set) ⦃ _ : Luft (λ {m} → s {m}) ⦄ : Set where field fooI : ∀ {m} {n : N m} → S (s n) open Indexed ⦃ … ⦄ record Total {N : Set} (s : N → N) (S : N → Set) : Set where field fooT : ∀ n → S (s n) open Total ⦃ … ⦄ postulate A : Set B : A → Set f : ∀ {x} → B x → B x F : ∀ {x} → B x → Set instance iIndexed : Indexed B f F instance iTotal : ∀ {x} → Total (f {x}) (F {x}) testIndexed : ∀ {a} {b : B a} → F (f b) testIndexed = fooI ⦃ ∅ ⦄ testTotal : ∀ {a} (b : B a) → F (f b) testTotal = fooT {S = F} module Indexed≡Total2Prop<Constraint-Multi where open import Oscar.Data.Proposequality data Luft {a} {A : Set a} (x : A) : Set where instance ∅ : Luft x record Indexed {M : Set} (N : M → Set) (s : ∀ {m} → N m → N m) (S : ∀ {m} → N m → N m → Set) ⦃ _ : Luft (λ {m} → s {m}) ⦄ : Set where field fooI : ∀ {m} {n : N m} → S n (s n) open Indexed ⦃ … ⦄ record Total {N : Set} (s : N → N) (S : N → N → Set) : Set where field fooT : ∀ n → S n (s n) open Total ⦃ … ⦄ postulate A : Set B : A → Set f f' : ∀ {x} → B x → B x F F' : ∀ {x} → B x → B x → Set instance _ : Indexed B f F instance _ : Indexed B f' F instance _ : Indexed B f F' instance _ : Indexed B f' F' instance _ : ∀ {x} → Total (f {x}) (F {x}) testIndexed : ∀ {a} {b : B a} → F b (f b) testIndexed = fooI ⦃ ∅ ⦄ testIndexed2 : ∀ {a} {b : B a} → F (f b) (f (f b)) testIndexed2 = fooI ⦃ ∅ ⦄ testTotal : ∀ {a} (b : B a) → F b (f b) testTotal = fooT {S = F} module Indexed≡Total2Prop<Constraint-Multi-2Fun where open import Oscar.Data.Proposequality data Luft {a} {A : Set a} (x : A) : Set where instance ∅ : Luft x record Indexed {M : Set} (N : M → Set) (s t : ∀ {m} → N m → N m) (S : ∀ {m} → N m → N m → Set) ⦃ _ : Luft (λ {m} → s {m}) ⦄ ⦃ _ : Luft (λ {m} → t {m}) ⦄ : Set where field fooI : ∀ {m} {n : N m} → S (t n) (s n) fooI : {M : Set} {N : M → Set} {s t : ∀ {m} → N m → N m} {S : ∀ {m} → N m → N m → Set} ⦃ _ : Indexed N s t S ⦄ → ∀ {m} {n : N m} → S (t n) (s n) fooI ⦃ I ⦄ = Indexed.fooI I -- equivalently, fooI = Indexed.fooI ⦃ ∅ ⦄ ⦃ ∅ ⦄ ! record Total {N : Set} (s t : N → N) (S : N → N → Set) ⦃ _ : Luft s ⦄ ⦃ _ : Luft t ⦄ : Set where field fooT : ∀ {n} → S (t n) (s n) fooT : {N : Set} {s t : N → N} {S : N → N → Set} ⦃ _ : Total s t S ⦄ → ∀ {n : N} → S (t n) (s n) fooT ⦃ I ⦄ = Total.fooT I IndexedTotal : {M : Set} (N : M → Set) (s t : ∀ {m} → N m → N m) (S : ∀ {m} → N m → N m → Set) → Set IndexedTotal _ s t S = ∀ {x} → Total (s {x}) (t {x}) (S {x}) postulate A : Set B : A → Set f f' : ∀ {x} → B x → B x g g' : ∀ {x} → B x → B x F F' : ∀ {x} → B x → B x → Set instance _ : Indexed B f f F instance _ : Indexed B f' g F instance _ : Indexed B f g F' instance _ : Indexed B f' g F' instance _ : IndexedTotal B f f F instance _ : IndexedTotal B f' g F instance _ : IndexedTotal B f g F' instance _ : IndexedTotal B f' g F' instance _ : Indexed B f g F -- instance _ : Indexed B (λ b → f (g' b)) (λ b → g (g' b)) F -- this would overlap with the above instance _ : ∀ {x} → Total (f {x}) (g {x}) (F {x}) testIndexed : ∀ {a} {b : B a} → F (g b) (f b) testIndexed = fooI testIndexed2 : ∀ {a} {b : B a} → F (g (g' b)) (f (g' b)) testIndexed2 = fooI testIndexed3 : ∀ {a} {b : B a} → F (f (g' b)) (f (g' b)) testIndexed3 = fooI testTotal : ∀ {a} {b : B a} → F (g b) (f b) testTotal = fooT module Indexed≡Total2Prop<Constraint-Multi-2Fun-NoIndexedRecord where open import Oscar.Data.Proposequality data Luft {a} {A : Set a} (x : A) : Set where instance ∅ : Luft x record Total {N : Set} (s t : N → N) (S : N → N → Set) ⦃ _ : Luft s ⦄ ⦃ _ : Luft t ⦄ : Set where field fooT : ∀ {n} → S (t n) (s n) fooT : {N : Set} {s t : N → N} {S : N → N → Set} ⦃ _ : Total s t S ⦄ → ∀ {n : N} → S (t n) (s n) fooT ⦃ I ⦄ = Total.fooT I Indexed : {M : Set} (N : M → Set) (s t : ∀ {m} → N m → N m) (S : ∀ {m} → N m → N m → Set) (x : M) → Set Indexed _ s t S x = Total (s {x}) (t {x}) (S {x}) IndexedTotal : {M : Set} (N : M → Set) (s t : ∀ {m} → N m → N m) (S : ∀ {m} → N m → N m → Set) → Set IndexedTotal _ s t S = ∀ {x} → Total (s {x}) (t {x}) (S {x}) fooI : {M : Set} {N : M → Set} {s t : ∀ {m} → N m → N m} {S : ∀ {m} → N m → N m → Set} ⦃ _ : IndexedTotal N s t S ⦄ → ∀ {m} {n : N m} → S (t n) (s n) fooI = fooT fooI' : {M : Set} {N : M → Set} → ∀ {m} {s t : N m → N m} {S : N m → N m → Set} ⦃ _ : Total s t S ⦄ → {n : N m} → S (t n) (s n) fooI' = fooT postulate A : Set B : A → Set f f' : ∀ {x} → B x → B x g g' : ∀ {x} → B x → B x F F' : ∀ {x} → B x → B x → Set instance _ : IndexedTotal B f f F instance _ : IndexedTotal B f' g F instance _ : IndexedTotal B f g F' instance _ : IndexedTotal B f' g F' instance _ : IndexedTotal B f g F -- instance _ : Indexed B (λ b → f (g' b)) (λ b → g (g' b)) F -- this would overlap with the above -- instance _ : ∀ {x} → Total (f {x}) (g {x}) (F {x}) module _ {a a' : A} (b : B a) (b' : B a') where postulate instance _ : Total (g {a'}) f' F postulate instance i2 : Indexed B g f' F a testTotal' : F (g _) (f _) testTotal' = fooT {n = b} testTotal'2 : F (f' _) (g _) testTotal'2 = fooT {n = b'} testTotal'2I : F (f' b') (g _) testTotal'2I = fooI {m = a'} -- use fooI when instance given by Total testTotal'2I' : F (f' b') (g b') testTotal'2I' = fooI' {N = B} testTotal'3 : F (f' b) (g b) testTotal'3 = fooI {m = a} -- or by Indexed testTotal'3' : F (f' b) (g b) testTotal'3' = fooI' {N = B} testTotalLhs : ∀ {a} {b : B a} → _ testTotalLhs {a} {b} = fooT {s = f'} {S = F'} {n = b} testIndexed : ∀ {a} {b : B a} → F (g b) (f b) testIndexed {a} {b} = fooI {S = λ {x} → F {x}} -- use fooI when instance given by IndexedTotal {- Have: {M : Set} {N : M → Set} {s t : {m : M} → N m → N m} {S : {m : M} → N m → N m → Set} {{_ : Indexed {M} N s t S {{∅}} {{∅}}}} {m : M} {n : N m} → S {m} (t {m} n) (s {m} n) Have: {N : Set} {s t : N → N} {S : N → N → Set} {{_ : Total {N} s t S {{∅}} {{∅}}}} {n : N} → S (t n) (s n) -} testIndexed2 : ∀ {a} {b : B a} → F (g (g' b)) (f (g' b)) testIndexed2 = fooT testIndexed3 : ∀ {a} {b : B a} → F (f (g' b)) (f (g' b)) testIndexed3 = fooT testTotal : ∀ {a} {b : B a} → F (g b) (f b) testTotal = fooT module Indexed≡Total1Prop+Data where open import Oscar.Data.Proposequality data [_/_/_]≡_ {M : Set} (N : M → Set) (s : ∀ {m} → N m → N m) (S : ∀ {m} → N m → Set) (F : ∀ {m} (n : N m) → Set) : Set where instance ∅ : [ N / s / S ]≡ F record Indexed {M : Set} (N : M → Set) (s : ∀ {m} → N m → N m) (S : ∀ {m} → N m → Set) ⦃ _ : [ N / s / S ]≡ λ {m} (n : N m) → S (s n) ⦄ : Set where field fooI : ∀ {m} {n : N m} → S (s n) open Indexed ⦃ … ⦄ record Total {N : Set} (s : N → N) (S : N → Set) : Set where field fooT : ∀ n → S (s n) open Total ⦃ … ⦄ postulate A : Set B : A → Set f : ∀ {x} → B x → B x F : ∀ {x} → B x → Set instance iIndexed : Indexed B f F ⦃ ∅ ⦄ instance iTotal : ∀ {x} → Total (f {x}) (F {x}) testIndexed : ∀ {a} {b : B a} → F (f b) testIndexed = fooI ⦃ ∅ ⦄ testTotal : ∀ {a} (b : B a) → F (f b) testTotal = fooT {S = F} module Indexed≡Total1Prop+Data2 where open import Oscar.Data.Proposequality data [_/_] {M : Set} (N : M → Set) (s : ∀ {m} → N m → N m) : Set where instance ∅ : [ N / s ] record Indexed {M : Set} (N : M → Set) (s : ∀ {m} → N m → N m) (S : ∀ {m} → N m → Set) ⦃ _ : [ N / s ] ⦄ : Set where field fooI : ∀ {m} {n : N m} → S (s n) open Indexed ⦃ … ⦄ record Total {N : Set} (s : N → N) (S : N → Set) : Set where field fooT : ∀ n → S (s n) open Total ⦃ … ⦄ postulate A : Set B : A → Set f : ∀ {x} → B x → B x F : ∀ {x} → B x → Set instance iIndexed : Indexed B f F ⦃ ∅ ⦄ instance iTotal : ∀ {x} → Total (f {x}) (F {x}) testIndexed : ∀ {a} {b : B a} → F (f b) testIndexed = fooI ⦃ ∅ ⦄ testTotal : ∀ {a} (b : B a) → F (f b) testTotal = fooT {S = F}
{ "alphanum_fraction": 0.4672576733, "avg_line_length": 26.6302895323, "ext": "agda", "hexsha": "0a43900422bd57df70b523eb0870104ed497560d", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_forks_repo_licenses": [ "RSA-MD" ], "max_forks_repo_name": "m0davis/oscar", "max_forks_repo_path": "archive/agda-3/src/Test/Test6.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_issues_repo_issues_event_max_datetime": "2019-05-11T23:33:04.000Z", "max_issues_repo_issues_event_min_datetime": "2019-04-29T00:35:04.000Z", "max_issues_repo_licenses": [ "RSA-MD" ], "max_issues_repo_name": "m0davis/oscar", "max_issues_repo_path": "archive/agda-3/src/Test/Test6.agda", "max_line_length": 176, "max_stars_count": null, "max_stars_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_stars_repo_licenses": [ "RSA-MD" ], "max_stars_repo_name": "m0davis/oscar", "max_stars_repo_path": "archive/agda-3/src/Test/Test6.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 5340, "size": 11957 }
{-# OPTIONS --cubical-compatible --rewriting -v rewriting:50 #-} open import Agda.Primitive using (Level; _⊔_; Setω; lzero; lsuc) module Issue4020 where data _≡_ {ℓ : Level} {A : Set ℓ} (a : A) : A → Set ℓ where refl : a ≡ a {-# BUILTIN REWRITE _≡_ #-} ap : ∀ {a b} {A : Set a} {B : Set b} (f : A → B) {a₁ a₂} → a₁ ≡ a₂ → f a₁ ≡ f a₂ ap f refl = refl ap-const-Set : ∀ {a b} {A : Set a} {a₁ a₂ : A} (p : a₁ ≡ a₂) → ap (\ _ → Set b) p ≡ refl ap-const-Set refl = refl {-# REWRITE ap-const-Set #-} {- /home/jason/bug.agda:18,1-29 ap-const-Set is not a legal rewrite rule, since the following variables are not bound by the left hand side: b when checking the pragma REWRITE ap-const-Set -}
{ "alphanum_fraction": 0.6111908178, "avg_line_length": 31.6818181818, "ext": "agda", "hexsha": "e5ca363e57fb6c9c77dcb38cfd9008b5a32e5804", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "98c9382a59f707c2c97d75919e389fc2a783ac75", "max_forks_repo_licenses": [ "BSD-2-Clause" ], "max_forks_repo_name": "KDr2/agda", "max_forks_repo_path": "test/Succeed/Issue4020.agda", "max_issues_count": 6, "max_issues_repo_head_hexsha": "98c9382a59f707c2c97d75919e389fc2a783ac75", "max_issues_repo_issues_event_max_datetime": "2021-11-24T08:31:10.000Z", "max_issues_repo_issues_event_min_datetime": "2021-10-18T08:12:24.000Z", "max_issues_repo_licenses": [ "BSD-2-Clause" ], "max_issues_repo_name": "KDr2/agda", "max_issues_repo_path": "test/Succeed/Issue4020.agda", "max_line_length": 112, "max_stars_count": null, "max_stars_repo_head_hexsha": "98c9382a59f707c2c97d75919e389fc2a783ac75", "max_stars_repo_licenses": [ "BSD-2-Clause" ], "max_stars_repo_name": "KDr2/agda", "max_stars_repo_path": "test/Succeed/Issue4020.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 274, "size": 697 }
{-# OPTIONS --without-K #-} module PComp where open import Data.Empty open import Data.Sum open import Data.Nat as Nat open import Data.Nat.Properties.Simple open import Data.Nat.Properties open import Data.Product open import Data.Bool renaming (Bool to 𝔹) open import Data.Bool.Properties open import Relation.Nullary open import Relation.Binary.PropositionalEquality open import Relation.Binary open DecTotalOrder ≤-decTotalOrder using () renaming (refl to ≤-refl; trans to ≤-trans) -- open import Size -- record D {i : Size} (A : Set) : Set where -- coinductive -- field step : {j : Size< i} → A ⊎ D {j} A -- open D public -- μ' : ∀{i} → (ℕ → 𝔹) → ℕ → D {i} ℕ -- μ' p n .step = if p n then inj₁ n else inj₂ (μ' p (suc n)) primRec : {X Y : Set} → (X → Y) → (ℕ → Y → X → Y) → ℕ → X → Y primRec f g zero x = f x primRec f g (suc n) x = g n (primRec f g n x) x record D (A : Set) : Set where coinductive field step : A ⊎ D A open D public μ' : (ℕ → 𝔹) → ℕ → D ℕ c : (ℕ → 𝔹) → ℕ → 𝔹 → ℕ ⊎ (D ℕ) μ' p n .step = c p n (p n) c p n false = inj₂ (μ' p (1 + n)) c p n true = inj₁ n μ : (ℕ → 𝔹) → D ℕ μ p = μ' p 0 isEven : ℕ → 𝔹 isEven zero = true isEven (suc zero) = false isEven (suc (suc n)) = isEven n data _↓_ {A : Set} (d : D A) (a : A) : Set where now : d .step ≡ inj₁ a → d ↓ a later : {d' : D A} → d .step ≡ inj₂ d' → d' ↓ a → d ↓ a foo : μ' isEven 3 ↓ 4 foo = later (cong inj₂ refl) (now refl) μ-finds-tt : ∀{p : ℕ → 𝔹} {m n : ℕ} → μ' p m ↓ n → p n ≡ true μ-finds-tt {p} {m} (now q) with p m | inspect p m μ-finds-tt {p} {m} (now ()) | false | _ μ-finds-tt {p} {m} (now refl) | true | [ eq ] = eq μ-finds-tt {p} {m} (later q t) with p m μ-finds-tt {p} {m} (later refl t) | false = μ-finds-tt t μ-finds-tt {p} {m} (later () t) | true -- | Compute the number of steps taken to obtain p n = tt. μ-dist : ∀{p : ℕ → 𝔹} {m n : ℕ} → μ' p m ↓ n → ∃ λ k → n ≡ m + k μ-dist {p} {m} (now q) with p m μ-dist {p} {m} (now ()) | false μ-dist {p} {m} (now refl) | true = (0 , sym (+-identityʳ m)) μ-dist {p} {m} (later q t) with p m μ-dist {p} {m} (later refl t) | false = let (k , e) = μ-dist t in (1 + k , trans e (sym (+-suc m k))) μ-dist {p} {m} (later () t) | true empty-interval : ∀ {m k} → m ≤ k → k < m → ⊥ empty-interval z≤n () empty-interval (s≤s p) (s≤s q) = empty-interval p q suc≤⇒≤ : ∀ m n → suc m ≤ n → m ≤ n suc≤⇒≤ m zero () suc≤⇒≤ .0 (suc n) (s≤s z≤n) = z≤n suc≤⇒≤ .(suc _) (suc .(suc _)) (s≤s (s≤s p)) = s≤s (suc≤⇒≤ _ _ (s≤s p)) -- | The proof proceeds by induction on the termination proof t : μ' p m ↓ n. -- In the process, we first distinguishing whether m = k or m < k. -- Next, we check whether the computation has termination, that is, whether -- t = now ... or t = later. -- Finally, we distinguish on the values of p m, which allows us to make -- a computation step with μ'. The other cases follow then from there. μ-min : ∀{p : ℕ → 𝔹} {m n : ℕ} → μ' p m ↓ n → ∀ k → m ≤′ k → k < n → p k ≡ false -- m = k ---- t = now μ-min {p} {.m} (now q) m ≤′-refl u with p m μ-min {p} {.m} (now q) m ≤′-refl u | false = refl μ-min {p} {.m} (now refl) m ≤′-refl u | true = ⊥-elim (1+n≰n u) -- m = k ---- t = later μ-min {p} {.m} (later q t) m ≤′-refl u with p m μ-min {p} {.m} (later q t) m ≤′-refl u | false = refl μ-min {p} {.m} (later () t) m ≤′-refl u | true -- m < k ---- t = now μ-min {p} {m} (now q) .(suc _) (≤′-step l) u with p m μ-min {p} {m} (now ()) .(suc _) (≤′-step l) u | false μ-min {p} {.(suc _)} (now refl) .(suc _) (≤′-step l) (s≤s u) | true = ⊥-elim (empty-interval (suc≤⇒≤ _ _ (≤′⇒≤ l)) u) -- m < k ---- t = later μ-min {p} {m} (later q t) .(suc _) (≤′-step {k'} l) u with p m μ-min {p} {m} (later refl t) .(suc _) (≤′-step {k'} l) u | false = μ-min t (suc k') (s≤′s l) u μ-min {p} {m} (later () t) .(suc n) (≤′-step {n} l) u | true Min : (ℕ → Set) → ℕ → Set Min P n = P n × ∀ k → k < n → ¬ (P k) -- | Definition of partial correctness for the μ-operator. -- This states that if μ p terminates with n as result, then n is the -- minimal number, for which p n ≡ true. PartialCorrectness : Set PartialCorrectness = ∀{p : ℕ → 𝔹} {n : ℕ} → μ p ↓ n → Min (λ k → p k ≡ true) n μ-pcorrect : PartialCorrectness μ-pcorrect t = (μ-finds-tt t , (λ k u → not-¬ (μ-min t k (z≤′n) u))) -- Correctness : Set -- Correctness = ∀{p : ℕ → 𝔹} → -- ¬(∃ λ n → μ p ↓ n) → ∀ n → ¬(p n ≡ true) -- find-min' : ∀{p : ℕ → 𝔹} → ∀ n → p n ≡ true → (m : ℕ) → m ≤ n → -- (∃ λ k → k ≤ n × p k ≡ true) -- find-min' {p} last pt zero l with p 0 | inspect p 0 -- find-min' {p} last pt zero l | false | e = (last , ≤-refl , pt) -- find-min' {p} last pt zero l | true | [ e ] = (zero , l , e) -- find-min' {p} last pt (suc m) l with p m | inspect p m -- find-min' {p} last pt (suc m) l | false | e = -- find-min' last pt m (suc≤⇒≤ m last l) -- find-min' {p} last pt (suc m) l | true | [ e ] = -- let (k , k≤last , q) = find-min' {p} m e m ≤-refl -- in (k , ≤-trans k≤last (suc≤⇒≤ m last l) , q) -- find-min : ∀{p : ℕ → 𝔹} → ∀ n → p n ≡ true → (∃ λ k → k ≤ n × p k ≡ true) -- find-min {p} n pt = find-min' {p} n pt n ≤-refl -- min-terminate : ∀{p : ℕ → 𝔹} → ∀ n (e : p n ≡ true) (m : ℕ) → m ≤ n → ∃ λ k → μ p ↓ k -- min-terminate {p} last pt zero m≤n with p 0 | inspect p 0 -- min-terminate {p} last pt zero m≤n | false | e = {!!} , {!!} -- min-terminate {p} last pt zero m≤n | true | e = {!!} -- min-terminate {p} last pt (suc m) m≤n = {!!} -- lem : ∀{p : ℕ → 𝔹} → ∀ n → p n ≡ true → ∃ λ k → μ p ↓ k -- lem {p} zero q with p 0 | inspect p 0 -- lem {p} zero () | false | _ -- lem {p} zero q | true | [ e ] = (0 , now (cong (c p 0) e)) -- lem {p} (suc n) q with p (suc n) | inspect p (suc n) -- lem {p} (suc n) () | false | e -- lem {p} (suc n) q | true | e = -- let (k , t) = lem n {!!} -- in (suc n , now {!!}) -- μ-correct : Correctness -- μ-correct q n pt = q (lem n pt)
{ "alphanum_fraction": 0.505536275, "avg_line_length": 34.3806818182, "ext": "agda", "hexsha": "b224d39af4524d84974218bae4a8974af27c6b0e", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "8fc7a6cd878f37f9595124ee8dea62258da28aa4", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "hbasold/Sandbox", "max_forks_repo_path": "Partial/PComp.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "8fc7a6cd878f37f9595124ee8dea62258da28aa4", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "hbasold/Sandbox", "max_issues_repo_path": "Partial/PComp.agda", "max_line_length": 88, "max_stars_count": null, "max_stars_repo_head_hexsha": "8fc7a6cd878f37f9595124ee8dea62258da28aa4", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "hbasold/Sandbox", "max_stars_repo_path": "Partial/PComp.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 2604, "size": 6051 }
{-# BUILTIN NATURAL ℕ #-} ------------------------------------------------------------------------ -- The Integers -- -- or an extension of the Naturals (see the-naturals.agda) ------------------------------------------------------------------------ module the-integer where open import Data.Nat as ℕ using (ℕ) renaming (_+_ to _ℕ+_; _*_ to _ℕ*_) import Data.Nat.Show as ℕ import Relation.Nullary.Decidable as Dec open import Relation.Binary open import Relation.Binary.PropositionalEquality as PropEq using (_≡_; refl; sym; cong; cong₂) open PropEq.≡-Reasoning
{ "alphanum_fraction": 0.5500878735, "avg_line_length": 29.9473684211, "ext": "agda", "hexsha": "9280cbe30d9b8ab3f59c7fd32cb67a9ccbd9f141", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "9fd9fbf9f265bf526a2ec83e9442dedc7106b80c", "max_forks_repo_licenses": [ "CC0-1.0" ], "max_forks_repo_name": "seanwestfall/agda_explorations", "max_forks_repo_path": "src/the-integers.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "9fd9fbf9f265bf526a2ec83e9442dedc7106b80c", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "CC0-1.0" ], "max_issues_repo_name": "seanwestfall/agda_explorations", "max_issues_repo_path": "src/the-integers.agda", "max_line_length": 72, "max_stars_count": null, "max_stars_repo_head_hexsha": "9fd9fbf9f265bf526a2ec83e9442dedc7106b80c", "max_stars_repo_licenses": [ "CC0-1.0" ], "max_stars_repo_name": "seanwestfall/agda_explorations", "max_stars_repo_path": "src/the-integers.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 130, "size": 569 }
-- {-# OPTIONS -v tc.lhs.unify.flexflex:100 -v tc.lhs.unify.assign:100 -v tc.lhs:100 #-} module Multisplit where postulate Level : Set lzero : Level lsuc : Level → Level _⊔_ : Level → Level → Level {-# BUILTIN LEVEL Level #-} {-# BUILTIN LEVELZERO lzero #-} {-# BUILTIN LEVELSUC lsuc #-} {-# BUILTIN LEVELMAX _⊔_ #-} data Bool : Set where true false : Bool data ℕ : Set where zero : ℕ suc : ℕ → ℕ data Fin : ℕ → Set where zero : ∀ {n} → Fin (suc n) suc : ∀ {n} → Fin n → Fin (suc n) data Vec {a} (A : Set a) : ℕ → Set a where [] : Vec A zero _∷_ : ∀ {n} (x : A) → Vec A n → Vec A (suc n) data Fin∘suc : ℕ → Set where zero : ∀ {n} → Fin∘suc n suc : ∀ {n} → Fin∘suc n → Fin∘suc (suc n) _==_ : Bool → Bool → Bool b₁ == b₂ = {!b₁ b₂!} lookup : ∀ {a n} {A : Set a} → Vec A n → Fin n → A lookup xs i = {!xs i!} 32-cases : Bool → Bool → Bool → Bool → Bool → Bool 32-cases a b c d e = {!a b c d e!} No-splits-after-absurd-pattern-encountered : (n : ℕ) → Fin n → Fin n → Set No-splits-after-absurd-pattern-encountered n i j = {!n i j!} Dotted-patterns-are-not-split : ∀ n → Fin∘suc n → Set Dotted-patterns-are-not-split n i = {!i n!}
{ "alphanum_fraction": 0.567315834, "avg_line_length": 24.1020408163, "ext": "agda", "hexsha": "0f0ddf3903313eac0bcbf9482e1dfe0346111910", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "20596e9dd9867166a64470dd24ea68925ff380ce", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "np/agda-git-experiment", "max_forks_repo_path": "test/interaction/Multisplit.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "20596e9dd9867166a64470dd24ea68925ff380ce", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "np/agda-git-experiment", "max_issues_repo_path": "test/interaction/Multisplit.agda", "max_line_length": 88, "max_stars_count": 1, "max_stars_repo_head_hexsha": "20596e9dd9867166a64470dd24ea68925ff380ce", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "np/agda-git-experiment", "max_stars_repo_path": "test/interaction/Multisplit.agda", "max_stars_repo_stars_event_max_datetime": "2019-11-27T04:41:05.000Z", "max_stars_repo_stars_event_min_datetime": "2019-11-27T04:41:05.000Z", "num_tokens": 465, "size": 1181 }
{-# OPTIONS -v tc.meta:20 #-} -- Andreas, 2011-04-15 -- source: Conor's post "foldl Miller magic" on the Agda list (2008) module Issue325b where data Nat : Set where zero : Nat suc : Nat -> Nat data Vec (X : Set) : Nat -> Set where [] : Vec X zero cons : (n : Nat) -> X -> Vec X n -> Vec X (suc n) foldl : (S : Set)(T : Nat -> Set) -> ((n : Nat) -> T n -> S -> T (suc n)) -> T zero -> (n : Nat) -> Vec S n -> T n foldl S T0 f t ._ [] = t foldl S Tsn f t ._ (cons m s ss) = foldl S _ -- (\ n -> Tsn (suc n)) -- (\ n -> f _) (f _ t s) _ ss _ (f zero t s) _ ss -- (\ n -> f (suc n)) (f zero t s) _ ss {- PROTOCOL: term _43 S Tsn f t m s ss zero := suc zero term _43 S Tsn f t m s ss (suc n) := suc (_43 S Tsn f t m s ss n) term _43 S Tsn f t m s ss m := suc m Pruning could give us: _43 m zero := suc zero _43 m (suc n) := suc (_43 m n) _43 m m := suc m We could then try a) _43 x y := suc x failing b) _43 x y := suc y succeeding but this only complete in the absence of recursion. -}
{ "alphanum_fraction": 0.5171455051, "avg_line_length": 23.4565217391, "ext": "agda", "hexsha": "1b5b584eb1ec3d928b8cf117897a949b0d0ec21b", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_forks_event_min_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "alhassy/agda", "max_forks_repo_path": "test/bugs/Issue325b.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "alhassy/agda", "max_issues_repo_path": "test/bugs/Issue325b.agda", "max_line_length": 68, "max_stars_count": 3, "max_stars_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "alhassy/agda", "max_stars_repo_path": "test/bugs/Issue325b.agda", "max_stars_repo_stars_event_max_datetime": "2015-12-07T20:14:00.000Z", "max_stars_repo_stars_event_min_datetime": "2015-03-28T14:51:03.000Z", "num_tokens": 401, "size": 1079 }
{-# OPTIONS --without-K --safe #-} module Definition.Typed.Consequences.Inversion where open import Definition.Untyped open import Definition.Typed open import Definition.Typed.Properties open import Definition.Typed.Consequences.Syntactic open import Definition.Typed.Consequences.Substitution open import Definition.Typed.Consequences.Inequality open import Tools.Product open import Tools.Empty using (⊥; ⊥-elim) -- Inversion of U (it has no type). inversion-U : ∀ {Γ C} → Γ ⊢ U ∷ C → ⊥ inversion-U (conv x x₁) = inversion-U x -- Inversion of natural number type. inversion-ℕ : ∀ {Γ C} → Γ ⊢ ℕ ∷ C → Γ ⊢ C ≡ U inversion-ℕ (ℕⱼ x) = refl (Uⱼ x) inversion-ℕ (conv x x₁) = trans (sym x₁) (inversion-ℕ x) -- Inversion of Empty. inversion-Empty : ∀ {Γ C} → Γ ⊢ Empty ∷ C → Γ ⊢ C ≡ U inversion-Empty (Emptyⱼ x) = refl (Uⱼ x) inversion-Empty (conv x x₁) = trans (sym x₁) (inversion-Empty x) -- Inversion of Unit. inversion-Unit : ∀ {Γ C} → Γ ⊢ Unit ∷ C → Γ ⊢ C ≡ U inversion-Unit (Unitⱼ x) = refl (Uⱼ x) inversion-Unit (conv x x₁) = trans (sym x₁) (inversion-Unit x) -- Inversion of Π-types. inversion-Π : ∀ {F G Γ C} → Γ ⊢ Π F ▹ G ∷ C → Γ ⊢ F ∷ U × Γ ∙ F ⊢ G ∷ U × Γ ⊢ C ≡ U inversion-Π (Πⱼ x ▹ x₁) = x , x₁ , refl (Uⱼ (wfTerm x)) inversion-Π (conv x x₁) = let a , b , c = inversion-Π x in a , b , trans (sym x₁) c inversion-Σ : ∀ {F G Γ C} → Γ ⊢ Σ F ▹ G ∷ C → Γ ⊢ F ∷ U × Γ ∙ F ⊢ G ∷ U × Γ ⊢ C ≡ U inversion-Σ (Σⱼ x ▹ x₁) = x , x₁ , refl (Uⱼ (wfTerm x)) inversion-Σ (conv x x₁) = let a , b , c = inversion-Σ x in a , b , trans (sym x₁) c -- Inversion of zero. inversion-zero : ∀ {Γ C} → Γ ⊢ zero ∷ C → Γ ⊢ C ≡ ℕ inversion-zero (zeroⱼ x) = refl (ℕⱼ x) inversion-zero (conv x x₁) = trans (sym x₁) (inversion-zero x) -- Inversion of successor. inversion-suc : ∀ {Γ t C} → Γ ⊢ suc t ∷ C → Γ ⊢ t ∷ ℕ × Γ ⊢ C ≡ ℕ inversion-suc (sucⱼ x) = x , refl (ℕⱼ (wfTerm x)) inversion-suc (conv x x₁) = let a , b = inversion-suc x in a , trans (sym x₁) b -- Inversion of natural recursion. inversion-natrec : ∀ {Γ c g n A C} → Γ ⊢ natrec C c g n ∷ A → (Γ ∙ ℕ ⊢ C) × Γ ⊢ c ∷ C [ zero ] × Γ ⊢ g ∷ Π ℕ ▹ (C ▹▹ C [ suc (var 0) ]↑) × Γ ⊢ n ∷ ℕ × Γ ⊢ A ≡ C [ n ] inversion-natrec (natrecⱼ x d d₁ n) = x , d , d₁ , n , refl (substType x n) inversion-natrec (conv d x) = let a , b , c , d , e = inversion-natrec d in a , b , c , d , trans (sym x) e -- Inversion of application. inversion-app : ∀ {Γ f a A} → Γ ⊢ (f ∘ a) ∷ A → ∃₂ λ F G → Γ ⊢ f ∷ Π F ▹ G × Γ ⊢ a ∷ F × Γ ⊢ A ≡ G [ a ] inversion-app (d ∘ⱼ d₁) = _ , _ , d , d₁ , refl (substTypeΠ (syntacticTerm d) d₁) inversion-app (conv d x) = let a , b , c , d , e = inversion-app d in a , b , c , d , trans (sym x) e -- Inversion of lambda. inversion-lam : ∀ {t A Γ} → Γ ⊢ lam t ∷ A → ∃₂ λ F G → Γ ⊢ F × (Γ ∙ F ⊢ t ∷ G × Γ ⊢ A ≡ Π F ▹ G) inversion-lam (lamⱼ x x₁) = _ , _ , x , x₁ , refl (Πⱼ x ▹ (syntacticTerm x₁)) inversion-lam (conv x x₁) = let a , b , c , d , e = inversion-lam x in a , b , c , d , trans (sym x₁) e -- Inversion of products. inversion-prod : ∀ {t u A Γ} → Γ ⊢ prod t u ∷ A → ∃₂ λ F G → Γ ⊢ F × (Γ ∙ F ⊢ G × (Γ ⊢ t ∷ F × Γ ⊢ u ∷ G [ t ] × Γ ⊢ A ≡ Σ F ▹ G)) inversion-prod (prodⱼ ⊢F ⊢G ⊢t ⊢u) = -- NOTE fundamental theorem not required since prodⱼ has inversion built-in. _ , _ , ⊢F , ⊢G , ⊢t , ⊢u , refl (Σⱼ ⊢F ▹ ⊢G ) inversion-prod (conv x x₁) = let F , G , a , b , c , d , e = inversion-prod x in F , G , a , b , c , d , trans (sym x₁) e -- Inversion of star. inversion-star : ∀ {Γ C} → Γ ⊢ star ∷ C → Γ ⊢ C ≡ Unit inversion-star (starⱼ x) = refl (Unitⱼ x) inversion-star (conv x x₁) = trans (sym x₁) (inversion-star x) -- Inversion of products in WHNF. whnfProduct : ∀ {Γ p F G} → Γ ⊢ p ∷ Σ F ▹ G → Whnf p → Product p whnfProduct x prodₙ = prodₙ whnfProduct x (ne pNe) = ne pNe whnfProduct x Uₙ = ⊥-elim (inversion-U x) whnfProduct x Πₙ = let _ , _ , Σ≡U = inversion-Π x in ⊥-elim (U≢Σ (sym Σ≡U)) whnfProduct x Σₙ = let _ , _ , Σ≡U = inversion-Σ x in ⊥-elim (U≢Σ (sym Σ≡U)) whnfProduct x ℕₙ = ⊥-elim (U≢Σ (sym (inversion-ℕ x))) whnfProduct x Unitₙ = ⊥-elim (U≢Σ (sym (inversion-Unit x))) whnfProduct x Emptyₙ = ⊥-elim (U≢Σ (sym (inversion-Empty x))) whnfProduct x lamₙ = let _ , _ , _ , _ , Σ≡Π = inversion-lam x in ⊥-elim (Π≢Σ (sym Σ≡Π)) whnfProduct x zeroₙ = ⊥-elim (ℕ≢Σ (sym (inversion-zero x))) whnfProduct x sucₙ = let _ , A≡ℕ = inversion-suc x in ⊥-elim (ℕ≢Σ (sym A≡ℕ)) whnfProduct x starₙ = ⊥-elim (Unit≢Σⱼ (sym (inversion-star x)))
{ "alphanum_fraction": 0.5612554113, "avg_line_length": 37.2580645161, "ext": "agda", "hexsha": "b89bb48ec96ee96911485d84a130c4a8d5905763", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "4746894adb5b8edbddc8463904ee45c2e9b29b69", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Vtec234/logrel-mltt", "max_forks_repo_path": "Definition/Typed/Consequences/Inversion.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "4746894adb5b8edbddc8463904ee45c2e9b29b69", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Vtec234/logrel-mltt", "max_issues_repo_path": "Definition/Typed/Consequences/Inversion.agda", "max_line_length": 82, "max_stars_count": null, "max_stars_repo_head_hexsha": "4746894adb5b8edbddc8463904ee45c2e9b29b69", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Vtec234/logrel-mltt", "max_stars_repo_path": "Definition/Typed/Consequences/Inversion.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 2030, "size": 4620 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Interleavings of lists using propositional equality ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} open import Relation.Binary using (Setoid) module Data.List.Relation.Ternary.Interleaving.Propositional {a} {A : Set a} where open import Level using (_⊔_) open import Data.List.Base as List using (List; []; _∷_; _++_) open import Data.List.Relation.Binary.Pointwise as Pw using () open import Data.List.Relation.Ternary.Interleaving.Properties open import Data.List.Relation.Binary.Permutation.Inductive as Perm using (_↭_) open import Data.List.Relation.Binary.Permutation.Inductive.Properties using (shift) import Data.List.Relation.Ternary.Interleaving.Setoid as General open import Relation.Binary.PropositionalEquality using (setoid; refl) open Perm.PermutationReasoning ------------------------------------------------------------------------ -- Re-export the basic combinators open General hiding (Interleaving) public ------------------------------------------------------------------------ -- Definition Interleaving : List A → List A → List A → Set a Interleaving = General.Interleaving (setoid A) pattern consˡ xs = refl ∷ˡ xs pattern consʳ xs = refl ∷ʳ xs ------------------------------------------------------------------------ -- New combinators toPermutation : ∀ {l r as} → Interleaving l r as → as ↭ l ++ r toPermutation [] = Perm.refl toPermutation (consˡ sp) = Perm.prep _ (toPermutation sp) toPermutation {l} {r ∷ rs} {a ∷ as} (consʳ sp) = begin a ∷ as ↭⟨ Perm.prep a (toPermutation sp) ⟩ a ∷ l ++ rs ↭⟨ Perm.↭-sym (shift a l rs) ⟩ l ++ a ∷ rs ∎
{ "alphanum_fraction": 0.5761177136, "avg_line_length": 37.5957446809, "ext": "agda", "hexsha": "6e640def66d77fa852dcc8680ec14691e898aa1f", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "omega12345/agda-mode", "max_forks_repo_path": "test/asset/agda-stdlib-1.0/Data/List/Relation/Ternary/Interleaving/Propositional.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "omega12345/agda-mode", "max_issues_repo_path": "test/asset/agda-stdlib-1.0/Data/List/Relation/Ternary/Interleaving/Propositional.agda", "max_line_length": 84, "max_stars_count": null, "max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "omega12345/agda-mode", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Data/List/Relation/Ternary/Interleaving/Propositional.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 428, "size": 1767 }
open import Agda.Builtin.Nat data Tree : Set where ` : Nat → Tree _`+_ : Tree → Tree → Tree ⟦_⟧ : Tree → Nat ⟦ ` n ⟧ = n ⟦ t `+ u ⟧ = ⟦ t ⟧ + ⟦ u ⟧ data Target : Tree → Set where 0+_ : ∀ e → Target (` 0 `+ e) _+0 : ∀ e → Target (e `+ ` 0) [_] : ∀ e → Target e target : ∀ e → Target e target (` 0 `+ e) = 0+ e target (e `+ ` 0) = e +0 target e = [ e ] optimise : Tree → Tree structural : Tree → Tree optimise t with {structural t} | target (structural t) ... | 0+ e = e ... | e +0 = e ... | [ e ] = e structural (` n) = ` n structural (e `+ f) = optimise e `+ optimise f open import Agda.Builtin.Equality suc-cong : ∀ {m n} → m ≡ n → suc m ≡ suc n suc-cong refl = refl +-cong : ∀ {m n p q} → m ≡ n → p ≡ q → m + p ≡ n + q +-cong refl refl = refl trans : {m n p : Nat} → m ≡ n → n ≡ p → m ≡ p trans refl eq = eq m≡m+0 : ∀ m → m ≡ m + 0 m≡m+0 0 = refl m≡m+0 (suc m) = suc-cong (m≡m+0 m) optimise-sound : ∀ t → ⟦ optimise t ⟧ ≡ ⟦ t ⟧ structural-sound : ∀ t → ⟦ structural t ⟧ ≡ ⟦ t ⟧ optimise-sound t with {structural t} | target (structural t) | structural-sound t ... | 0+ e | eq = eq ... | e +0 | eq = trans (m≡m+0 ⟦ e ⟧) eq ... | [ e ] | eq = eq structural-sound (` n) = refl structural-sound (e `+ f) = +-cong (optimise-sound e) (optimise-sound f)
{ "alphanum_fraction": 0.5057295646, "avg_line_length": 22.9649122807, "ext": "agda", "hexsha": "3c42c769c2fc5fd0d85ad202726b090b37069acf", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cruhland/agda", "max_forks_repo_path": "test/Succeed/implicit-with.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "cruhland/agda", "max_issues_repo_path": "test/Succeed/implicit-with.agda", "max_line_length": 81, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/Succeed/implicit-with.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 565, "size": 1309 }
{- Groupoid quotients: -} {-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.HITs.GroupoidQuotients.Properties where open import Cubical.HITs.GroupoidQuotients.Base open import Cubical.Core.Everything open import Cubical.Foundations.Prelude open import Cubical.Foundations.Isomorphism open import Cubical.Foundations.Equiv open import Cubical.Foundations.HLevels open import Cubical.Functions.Surjection open import Cubical.Data.Sigma open import Cubical.Relation.Nullary open import Cubical.Relation.Binary.Base open import Cubical.HITs.PropositionalTruncation as PropTrunc using (∥_∥₁; ∣_∣₁; squash₁) open import Cubical.HITs.SetTruncation as SetTrunc using (∥_∥₂; ∣_∣₂; squash₂) -- Type quotients private variable ℓA ℓR ℓ : Level A : Type ℓA R : A → A → Type ℓR elimSet : (Rt : BinaryRelation.isTrans R) → {B : A // Rt → Type ℓ} → ((x : A // Rt) → isSet (B x)) → (f : (a : A) → B [ a ]) → ({a b : A} (r : R a b) → PathP (λ i → B (eq// r i)) (f a) (f b)) → (x : A // Rt) → B x elimSet Rt Bset f feq [ a ] = f a elimSet Rt Bset f feq (eq// r i) = feq r i elimSet Rt Bset f feq (comp// {a} {b} {c} r s i j) = isSet→SquareP (λ i j → Bset (comp// r s i j)) (λ j → feq r j) (λ j → feq (Rt a b c r s) j) (λ i → f a) (λ i → feq s i) i j elimSet Rt Bset f feq (squash// x y p q r s i j k) = isOfHLevel→isOfHLevelDep 3 (λ x → isSet→isGroupoid (Bset x)) _ _ _ _ (λ j k → g (r j k)) (λ j k → g (s j k)) (squash// x y p q r s) i j k where g = elimSet Rt Bset f feq elimProp : (Rt : BinaryRelation.isTrans R) → {B : A // Rt → Type ℓ} → ((x : A // Rt) → isProp (B x)) → ((a : A) → B [ a ]) → (x : A // Rt) → B x elimProp Rt Brop f x = elimSet Rt (λ x → isProp→isSet (Brop x)) f (λ r → isProp→PathP (λ i → Brop (eq// r i)) (f _) (f _)) x elimProp2 : (Rt : BinaryRelation.isTrans R) → {C : A // Rt → A // Rt → Type ℓ} → ((x y : A // Rt) → isProp (C x y)) → ((a b : A) → C [ a ] [ b ]) → (x y : A // Rt) → C x y elimProp2 Rt Cprop f = elimProp Rt (λ x → isPropΠ (λ y → Cprop x y)) (λ x → elimProp Rt (λ y → Cprop [ x ] y) (f x)) isSurjective[] : (Rt : BinaryRelation.isTrans R) → isSurjection (λ a → [ a ]) isSurjective[] Rt = elimProp Rt (λ x → squash₁) (λ a → ∣ a , refl ∣₁) elim : (Rt : BinaryRelation.isTrans R) → {B : A // Rt → Type ℓ} → ((x : A // Rt) → isGroupoid (B x)) → (f : (a : A) → B [ a ]) → (feq : {a b : A} (r : R a b) → PathP (λ i → B (eq// r i)) (f a) (f b)) → ({a b c : A} (r : R a b) (s : R b c) → SquareP (λ i j → B (comp// r s i j)) (feq r) (feq (Rt a b c r s)) (λ j → f a) (feq s)) → (x : A // Rt) → B x elim Rt Bgpd f feq fcomp [ a ] = f a elim Rt Bgpd f feq fcomp (eq// r i) = feq r i elim Rt Bgpd f feq fcomp (comp// r s i j) = fcomp r s i j elim Rt Bgpd f feq fcomp (squash// x y p q r s i j k) = isOfHLevel→isOfHLevelDep 3 Bgpd _ _ _ _ (λ j k → g (r j k)) (λ j k → g (s j k)) (squash// x y p q r s) i j k where g = elim Rt Bgpd f feq fcomp rec : (Rt : BinaryRelation.isTrans R) → {B : Type ℓ} → isGroupoid B → (f : A → B) → (feq : {a b : A} (r : R a b) → f a ≡ f b) → ({a b c : A} (r : R a b) (s : R b c) → Square (feq r) (feq (Rt a b c r s)) refl (feq s)) → (x : A // Rt) → B rec Rt Bgpd = elim Rt (λ _ → Bgpd)
{ "alphanum_fraction": 0.5247553253, "avg_line_length": 32.4672897196, "ext": "agda", "hexsha": "6ca1bf5db7c7eee67f2a3849f410fe6e6dc714bf", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "thomas-lamiaux/cubical", "max_forks_repo_path": "Cubical/HITs/GroupoidQuotients/Properties.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "thomas-lamiaux/cubical", "max_issues_repo_path": "Cubical/HITs/GroupoidQuotients/Properties.agda", "max_line_length": 103, "max_stars_count": 1, "max_stars_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "thomas-lamiaux/cubical", "max_stars_repo_path": "Cubical/HITs/GroupoidQuotients/Properties.agda", "max_stars_repo_stars_event_max_datetime": "2021-10-31T17:32:49.000Z", "max_stars_repo_stars_event_min_datetime": "2021-10-31T17:32:49.000Z", "num_tokens": 1396, "size": 3474 }
-- {-# OPTIONS -v tc.lhs.problem:10 #-} -- Do not normalize goals! module Issue734 where id : Set → Set id A = A g : (A : Set) → id A g A = {!!} -- goal should be displayed as "id A", not as "A"
{ "alphanum_fraction": 0.578680203, "avg_line_length": 17.9090909091, "ext": "agda", "hexsha": "b86bd0b7f51d340be3c06bbf83173d023798e9c9", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_path": "test/interaction/Issue734.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "shlevy/agda", "max_issues_repo_path": "test/interaction/Issue734.agda", "max_line_length": 49, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "test/interaction/Issue734.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 66, "size": 197 }
-- Solutions to ExerciseSession3 {-# OPTIONS --cubical #-} module SolutionsSession3 where open import Part1 open import Part2 open import Part3 open import Part4 hiding (ℤ) open import ExerciseSession1 hiding (B) open import Cubical.Foundations.Isomorphism open import Cubical.Data.Nat open import Cubical.Data.Int hiding (neg) -- Exercise 1 assoc-++ : (xs ys zs : FMSet A) → xs ++ (ys ++ zs) ≡ (xs ++ ys) ++ zs assoc-++ [] ys zs = refl assoc-++ (x ∷ xs) ys zs j = x ∷ assoc-++ xs ys zs j assoc-++ (comm x y xs i) ys zs j = comm x y (assoc-++ xs ys zs j) i assoc-++ (trunc xs xs' p q i k) ys zs j = trunc (assoc-++ xs ys zs j) (assoc-++ xs' ys zs j) (λ l → assoc-++ (p l) ys zs j) (λ l → assoc-++ (q l) ys zs j) i k -- Exercise 2 data ℤ : Type₀ where pos : (n : ℕ) → ℤ neg : (n : ℕ) → ℤ posneg : pos 0 ≡ neg 0 -- Exercise 3 Int→ℤ : Int → ℤ Int→ℤ (pos n) = pos n Int→ℤ (negsuc n) = neg (suc n) ℤ→Int : ℤ → Int ℤ→Int (pos n) = pos n ℤ→Int (neg zero) = pos 0 ℤ→Int (neg (suc n)) = negsuc n ℤ→Int (posneg _) = pos 0 ℤ→Int→ℤ : ∀ (n : ℤ) → Int→ℤ (ℤ→Int n) ≡ n ℤ→Int→ℤ (pos n) _ = pos n ℤ→Int→ℤ (neg zero) i = posneg i ℤ→Int→ℤ (neg (suc n)) _ = neg (suc n) ℤ→Int→ℤ (posneg j) i = posneg (j ∧ i) Int→ℤ→Int : ∀ (n : Int) → ℤ→Int (Int→ℤ n) ≡ n Int→ℤ→Int (pos n) _ = pos n Int→ℤ→Int (negsuc n) _ = negsuc n Int≡ℤ : Int ≡ ℤ Int≡ℤ = isoToPath (iso Int→ℤ ℤ→Int ℤ→Int→ℤ Int→ℤ→Int) isSetℤ : isSet ℤ isSetℤ = subst isSet Int≡ℤ isSetInt -- Exercise 4 isSurjection : (A → B) → Type _ isSurjection {A = A} {B = B} f = (b : B) → ∃ A (λ a → f a ≡ b) isPropIsSurjection : (f : A → B) → isProp (isSurjection f) isPropIsSurjection f = isPropΠ (λ _ → squash) isSurjectionInc : isSurjection {A = A} ∣_∣ isSurjectionInc x = rec squash (λ y → ∣ (y , squash ∣ y ∣ x) ∣) x -- Exercise 5 intLoop : Int → ΩS¹ intLoop (pos zero) = refl intLoop (pos (suc n)) = intLoop (pos n) ∙ loop intLoop (negsuc zero) = sym loop intLoop (negsuc (suc n)) = intLoop (negsuc n) ∙ sym loop windingIntLoop : (n : Int) → winding (intLoop n) ≡ n windingIntLoop (pos zero) = refl windingIntLoop (pos (suc n)) = cong sucInt (windingIntLoop (pos n)) windingIntLoop (negsuc zero) = refl windingIntLoop (negsuc (suc n)) = cong predInt (windingIntLoop (negsuc n)) -- Exercise 6 data Susp (A : Type ℓ) : Type ℓ where north : Susp A south : Susp A merid : (a : A) → north ≡ south SuspBool→S¹ : Susp Bool → S¹ SuspBool→S¹ north = base SuspBool→S¹ south = base SuspBool→S¹ (merid false i) = loop i SuspBool→S¹ (merid true i) = base S¹→SuspBool : S¹ → Susp Bool S¹→SuspBool base = north S¹→SuspBool (loop i) = (merid false ∙ sym (merid true)) i SuspBool→S¹→SuspBool : (x : Susp Bool) → Path _ (S¹→SuspBool (SuspBool→S¹ x)) x SuspBool→S¹→SuspBool north = refl SuspBool→S¹→SuspBool south = merid true SuspBool→S¹→SuspBool (merid false i) j = hcomp (λ k → (λ { (j = i1) → merid false i ; (i = i0) → north ; (i = i1) → merid true (j ∨ ~ k)})) (merid false i) SuspBool→S¹→SuspBool (merid true i) j = merid true (i ∧ j) S¹→SuspBool→S¹ : (x : S¹) → SuspBool→S¹ (S¹→SuspBool x) ≡ x S¹→SuspBool→S¹ base = refl S¹→SuspBool→S¹ (loop i) j = hfill (λ k → λ { (i = i0) → base ; (i = i1) → base }) (inS (loop i)) (~ j) S¹≡SuspBool : S¹ ≡ Susp Bool S¹≡SuspBool = isoToPath (iso S¹→SuspBool SuspBool→S¹ SuspBool→S¹→SuspBool S¹→SuspBool→S¹)
{ "alphanum_fraction": 0.5737250554, "avg_line_length": 31.1034482759, "ext": "agda", "hexsha": "b2333271a6188a802f31cbfec66b991d03cd39b5", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-08-02T16:16:34.000Z", "max_forks_repo_forks_event_min_datetime": "2021-08-02T16:16:34.000Z", "max_forks_repo_head_hexsha": "19d72759e18e05d2c509f62d23a998573270140c", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "williamdemeo/EPIT-2020", "max_forks_repo_path": "04-cubical-type-theory/material/SolutionsSession3.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "19d72759e18e05d2c509f62d23a998573270140c", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "williamdemeo/EPIT-2020", "max_issues_repo_path": "04-cubical-type-theory/material/SolutionsSession3.agda", "max_line_length": 93, "max_stars_count": null, "max_stars_repo_head_hexsha": "19d72759e18e05d2c509f62d23a998573270140c", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "williamdemeo/EPIT-2020", "max_stars_repo_path": "04-cubical-type-theory/material/SolutionsSession3.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1447, "size": 3608 }
module subst where open import constants open import cedille-types open import ctxt-types open import free-vars open import rename open import general-util open import syntax-util open import type-util substh-ret-t : Set → Set substh-ret-t T = ctxt → renamectxt → trie (Σi exprd ⟦_⟧) → T → T {-# TERMINATING #-} substh : ∀ {ed} → substh-ret-t ⟦ ed ⟧ substh-arg : substh-ret-t arg substh-args : substh-ret-t args substh-params' : ctxt → renamectxt → trie (Σi exprd ⟦_⟧) → params → params × ctxt × renamectxt × trie (Σi exprd ⟦_⟧) substh-indices : substh-ret-t indices substh-params : substh-ret-t params substh-case : substh-ret-t case substh-cases : substh-ret-t cases substh-case-args : ctxt → renamectxt → trie (Σi exprd ⟦_⟧) → case-args → case-args × renamectxt × ctxt × trie (Σi exprd ⟦_⟧) substh-datatype-info : substh-ret-t datatype-info subst-rename-var-if : ∀ {ed} → ctxt → renamectxt → var → trie (Σi exprd ⟦_⟧) → ⟦ ed ⟧ → var subst-rename-var-if Γ ρ ignored-var σ t = if is-free-in ignored-var t then fresh-h (λ s → ctxt-binds-var Γ s || trie-contains σ s || renamectxt-in-field ρ s) "x" else ignored-var subst-rename-var-if Γ ρ x σ _ = {- rename bound variable x iff it is one of the vars being substituted for, or if x occurs free in one of the terms we are substituting for vars, or if it is the renamed version of any variable -} if trie-contains σ x {-|| trie-any (λ {(,_ {ed} t) → is-free-in x t}) σ-} || renamectxt-in-range ρ x || ctxt-binds-var Γ x then fresh-h (λ s → ctxt-binds-var Γ s || trie-contains σ s || renamectxt-in-field ρ s) x else x substh {TERM} Γ ρ σ (App t t') = App (substh Γ ρ σ t) (substh Γ ρ σ t') substh {TERM} Γ ρ σ (AppE t tT) = AppE (substh Γ ρ σ t) (substh Γ ρ σ -tT tT) substh {TERM} Γ ρ σ (Lam me x oc t) = let x' = subst-rename-var-if Γ ρ x σ t in Lam me x' (substh Γ ρ σ -tk_ <$> oc) (substh (ctxt-var-decl x' Γ) (renamectxt-insert ρ x x') σ t) substh {TERM} Γ ρ σ (LetTm me x T t t') = let x' = subst-rename-var-if Γ ρ x σ t' in LetTm me x' (substh Γ ρ σ <$> T) (substh Γ ρ σ t) (substh (ctxt-var-decl x' Γ) (renamectxt-insert ρ x x') σ t') substh {TERM} Γ ρ σ (LetTp x k T t) = let x' = subst-rename-var-if Γ ρ x σ t in LetTp x' (substh Γ ρ σ k) (substh Γ ρ σ T) (substh (ctxt-var-decl x' Γ) (renamectxt-insert ρ x x') σ t) substh {TERM} Γ ρ σ (Var x) = let x' = renamectxt-rep ρ x in case trie-lookup σ x' of λ where (just (,_ {TERM} t)) → t _ → Var x' substh {TERM} Γ ρ σ (Hole pi) = Hole pi -- Retain position, so jumping to hole works substh {TERM} Γ ρ σ (Beta t t') = Beta (substh Γ ρ σ t) (substh Γ ρ σ t') substh {TERM} Γ ρ σ (IotaPair t₁ t₂ x T) = let x' = subst-rename-var-if Γ ρ x σ T in IotaPair (substh Γ ρ σ t₁) (substh Γ ρ σ t₂) x' (substh (ctxt-var-decl x' Γ) (renamectxt-insert ρ x x') σ T) substh {TERM} Γ ρ σ (IotaProj t n) = IotaProj (substh Γ ρ σ t) n substh {TERM} Γ ρ σ (Sigma t) = Sigma (substh Γ ρ σ t) substh {TERM} Γ ρ σ (Phi t t₁ t₂) = Phi (substh Γ ρ σ t) (substh Γ ρ σ t₁) (substh Γ ρ σ t₂) substh {TERM} Γ ρ σ (Rho tₑ x T t) = let x' = subst-rename-var-if Γ ρ x σ T in Rho (substh Γ ρ σ tₑ) x' (substh (ctxt-var-decl x' Γ) (renamectxt-insert ρ x x') σ T) (substh Γ ρ σ t) substh {TERM} Γ ρ σ (Delta b? T t) = Delta (b? >>=c λ t₁ t₂ → just (substh Γ ρ σ t₁ , substh Γ ρ σ t₂)) (substh Γ ρ σ T) (substh Γ ρ σ t) substh {TERM} Γ ρ σ (Mu (inj₂ x) t T t~ ms) = let fv = λ x → trie-contains σ x || ctxt-binds-var Γ x || renamectxt-in-field ρ x x' = fresh-h (λ x → fv x || fv (mu-Type/ x) || fv (mu-isType/ x)) (if x =string ignored-var then "x" else x) ρ' = renamectxt-insert ρ x x' ρ' = renamectxt-insert ρ' (mu-Type/ x) (mu-Type/ x') ρ' = renamectxt-insert ρ' (mu-isType/ x) (mu-isType/ x') Γ' = ctxt-var-decl x' Γ Γ' = ctxt-var-decl (mu-Type/ x') Γ' Γ' = ctxt-var-decl (mu-isType/ x') Γ' in Mu (inj₂ x') (substh Γ ρ σ t) (substh (ctxt-var-decl (mu-Type/ x') Γ) (renamectxt-insert ρ (mu-Type/ x) (mu-Type/ x')) σ <$> T) (substh-datatype-info Γ ρ σ t~) (substh-cases Γ' ρ' σ ms) substh {TERM} Γ ρ σ (Mu (inj₁ tᵢ) t' T t~ ms) = Mu (inj₁ (substh Γ ρ σ <$> tᵢ)) (substh Γ ρ σ t') (substh Γ ρ σ <$> T) (substh-datatype-info Γ ρ σ t~) (substh-cases Γ ρ σ ms) substh {TYPE} Γ ρ σ (TpAbs me x tk t) = let x' = subst-rename-var-if Γ ρ x σ t in TpAbs me x' (substh Γ ρ σ -tk tk) (substh (ctxt-var-decl x' Γ) (renamectxt-insert ρ x x') σ t) substh {TYPE} Γ ρ σ (TpLam x tk t) = let x' = subst-rename-var-if Γ ρ x σ t in TpLam x' (substh Γ ρ σ -tk tk) (substh (ctxt-var-decl x' Γ) (renamectxt-insert ρ x x') σ t) substh {TYPE} Γ ρ σ (TpIota x T₁ T₂) = let x' = subst-rename-var-if Γ ρ x σ T₂ in TpIota x' (substh Γ ρ σ T₁) (substh (ctxt-var-decl x' Γ) (renamectxt-insert ρ x x') σ T₂) substh {TYPE} Γ ρ σ (TpApp tp tT) = TpApp (substh Γ ρ σ tp) (substh Γ ρ σ -tT tT) substh {TYPE} Γ ρ σ (TpEq t₁ t₂) = TpEq (substh Γ ρ σ t₁) (substh Γ ρ σ t₂) substh {TYPE} Γ ρ σ (TpVar x) = let x' = renamectxt-rep ρ x in case trie-lookup σ x' of λ where (just (,_ {TYPE} T)) → T _ → TpVar x' substh {TYPE} Γ ρ σ (TpHole pi) = TpHole pi -- Retain position, so jumping to hole works substh {KIND} Γ ρ σ (KdAbs x tk k) = let x' = subst-rename-var-if Γ ρ x σ k in KdAbs x' (substh Γ ρ σ -tk tk) (substh (ctxt-var-decl x' Γ) (renamectxt-insert ρ x x') σ k) substh {KIND} Γ ρ σ (KdHole pi) = KdHole pi -- Retain position, so jumping to hole works substh {KIND} Γ ρ σ KdStar = KdStar substh-datatype-info Γ ρ σ (mk-data-info X Xₒ asₚ asᵢ ps kᵢ k cs csₚₛ gds eds) = let Γ' = foldr (λ { (Param me x tk) Γ → ctxt-var-decl x Γ }) Γ ps ρ' = foldr (λ { (Param me x tk) ρ → renamectxt-insert ρ x x }) ρ ps σ' = foldr (λ { (Param me x tk) σ → trie-remove σ x }) σ ps in mk-data-info (renamectxt-rep ρ X) (renamectxt-rep ρ Xₒ) (substh Γ ρ σ -arg_ <$> asₚ) (substh Γ ρ σ -tT_ <$> asᵢ) ps (substh Γ' ρ' σ' kᵢ) (substh Γ' ρ' σ' k) (map-snd (substh Γ' ρ' σ') <$> cs) (map-snd (substh Γ ρ σ) <$> csₚₛ) gds eds substh-arg Γ ρ σ = substh Γ ρ σ -arg_ substh-args Γ ρ σ = substh-arg Γ ρ σ <$>_ substh-params' Γ ρ σ ((Param me x tk) :: ps) = map-fst (Param me x (substh Γ ρ σ -tk tk) ::_) (substh-params' Γ (renamectxt-insert ρ x x) (trie-remove σ x) ps) substh-params' Γ ρ σ [] = [] , Γ , ρ , σ substh-params Γ ρ σ ps = fst (substh-params' Γ ρ σ ps) substh-indices Γ ρ σ = params-to-indices ∘' substh-params Γ ρ σ ∘' indices-to-params substh-case Γ ρ σ (Case x as t asₜₚ) = case (substh-case-args Γ ρ σ as) of λ where (as' , ρ' , Γ' , σ') → Case x as' (substh Γ' ρ' σ' t) (substh Γ' ρ' σ' -tT_ <$> asₜₚ) substh-cases Γ ρ σ = map (substh-case Γ ρ σ) substh-case-args Γ ρ σ as = foldr (λ where (CaseArg e x tk) f ρ Γ σ → let x' = subst-rename-var-if Γ ρ x σ (Var x) in map-fst (CaseArg e x' (substh Γ ρ σ -tk_ <$> tk) ::_) (f (renamectxt-insert ρ x x') (ctxt-var-decl x' Γ) (trie-remove σ x))) (λ ρ Γ σ → [] , ρ , Γ , σ) as ρ Γ σ subst-ret-t : Set → Set subst-ret-t T = {ed : exprd} → ctxt → ⟦ ed ⟧ → var → T → T subst : ∀ {ed} → subst-ret-t ⟦ ed ⟧ subst Γ t x = substh Γ empty-renamectxt (trie-single x (, t)) subst-cases : subst-ret-t cases subst-cases Γ t x = substh-cases Γ empty-renamectxt (trie-single x (, t)) subst-params : subst-ret-t params subst-params Γ t x = substh-params Γ empty-renamectxt (trie-single x (, t)) subst-renamectxt : ∀ {ed : exprd} → ctxt → renamectxt → ⟦ ed ⟧ → ⟦ ed ⟧ subst-renamectxt Γ ρ = substh Γ ρ empty-trie rename-var : ∀ {ed} → ctxt → var → var → ⟦ ed ⟧ → ⟦ ed ⟧ rename-var Γ x x' = subst-renamectxt Γ (renamectxt-single x x') substs-ret-t : Set → Set substs-ret-t T = ctxt → trie (Σi exprd ⟦_⟧) → T → T substs : ∀ {ed} → substs-ret-t ⟦ ed ⟧ substs = flip substh empty-renamectxt substs-args : substs-ret-t args substs-args = flip substh-args empty-renamectxt substs-params : substs-ret-t params substs-params = flip substh-params empty-renamectxt substs-cases : substs-ret-t cases substs-cases = flip substh-cases empty-renamectxt subst-params-args : params → args → trie (Σi exprd ⟦_⟧) × params × args subst-params-args ps as = subst-params-args' ps as empty-trie where subst-params-args' : params → args → trie (Σi exprd ⟦_⟧) → trie (Σi exprd ⟦_⟧) × params × args subst-params-args' (Param me x tk :: ps) (Arg t :: as) σ = subst-params-args' ps as (trie-insert σ x (, t)) subst-params-args' (Param me x tk :: ps) (ArgE (inj₁ t) :: as) σ = subst-params-args' ps as (trie-insert σ x (, t)) subst-params-args' (Param me x tk :: ps) (ArgE (inj₂ T) :: as) σ = subst-params-args' ps as (trie-insert σ x (, T)) subst-params-args' ps as σ = σ , ps , as subst-params-args' : ctxt → params → args → ∀ {ed} → ⟦ ed ⟧ → ⟦ ed ⟧ × params × args subst-params-args' Γ ps as t = map-fst (λ σ → substs Γ σ t) (subst-params-args ps as) infixr 3 [_-_/_]_ [_-_/_]_ : ∀ {ed ed'} → ctxt → ⟦ ed ⟧ → var → ⟦ ed' ⟧ → ⟦ ed' ⟧ [ Γ - t / x ] t' = subst Γ t x t' subst-unqual : ∀ {ed} → ctxt → 𝕃 (posinfo × var) → ⟦ ed ⟧ → ⟦ ed ⟧ subst-unqual Γ xs t = subst-renamectxt Γ (foldr (uncurry λ pi x xs → renamectxt-insert xs (pi % x) x) empty-renamectxt xs) t -- Given the parameters (32@x : ...) (41@y : ...32@x...), -- returns (x : ...) (y : ...x...) × (32@x → x, 41@y → y) unqual-params : ctxt → params → params × renamectxt unqual-params = h empty-renamectxt where h : renamectxt → ctxt → params → params × renamectxt h ρ Γ [] = [] , ρ h ρ Γ (Param me qx atk :: ps) = let x = unqual-local qx in map-fst (Param me x (subst-renamectxt Γ ρ -tk atk) ::_) (h (renamectxt-insert ρ qx x) (ctxt-var-decl x Γ) ps)
{ "alphanum_fraction": 0.6048321048, "avg_line_length": 43.0308370044, "ext": "agda", "hexsha": "b7752cf8d9b447fc3aad07863c20d9de947dba10", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "9df4b85b55b57f97466242fdbb499adbd3bca893", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "zmthy/cedille", "max_forks_repo_path": "src/subst.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "9df4b85b55b57f97466242fdbb499adbd3bca893", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "zmthy/cedille", "max_issues_repo_path": "src/subst.agda", "max_line_length": 189, "max_stars_count": null, "max_stars_repo_head_hexsha": "9df4b85b55b57f97466242fdbb499adbd3bca893", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "zmthy/cedille", "max_stars_repo_path": "src/subst.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 3914, "size": 9768 }
{-# OPTIONS --safe --warning=error --without-K #-} open import Groups.Definition open import Setoids.Setoids open import LogicalFormulae open import Sets.EquivalenceRelations open import Groups.Homomorphisms.Definition open import Groups.Homomorphisms.Lemmas open import Groups.Isomorphisms.Definition open import Groups.Subgroups.Definition open import Groups.Lemmas module Groups.FirstIsomorphismTheorem {a b c d : _} {A : Set a} {B : Set b} {S : Setoid {a} {c} A} {T : Setoid {b} {d} B} {_+G_ : A → A → A} {_+H_ : B → B → B} {G : Group S _+G_} {H : Group T _+H_} {f : A → B} (fHom : GroupHom G H f) where open import Groups.Homomorphisms.Image fHom open import Groups.Homomorphisms.Kernel fHom open import Groups.Cosets G groupKernelIsSubgroup open import Groups.QuotientGroup.Definition G fHom open Setoid T open Equivalence eq open import Setoids.Subset T groupFirstIsomorphismTheoremWellDefined : {x y : A} → groupKernelPred (Group.inverse G y +G x) → Setoid._∼_ (subsetSetoid imageGroupSubset) (f x , (x , reflexive)) (f y , (y , reflexive)) groupFirstIsomorphismTheoremWellDefined {x} {y} pr = transitive (symmetric (invTwice H _)) (transitive (symmetric u) (invTwice H _)) where t : Setoid._∼_ T (Group.inverse H (f y) +H (f x)) (Group.0G H) t = transitive (transitive (Group.+WellDefined H (symmetric (homRespectsInverse fHom)) reflexive) (symmetric (GroupHom.groupHom fHom))) pr u : Setoid._∼_ T (Group.inverse H (Group.inverse H (f y))) (Group.inverse H (Group.inverse H (f x))) u = inverseWellDefined H (transferToRight' H t) groupFirstIsomorphismTheorem : GroupsIsomorphic (cosetGroup groupKernelIsNormalSubgroup) (subgroupIsGroup H imageGroupSubgroup) GroupsIsomorphic.isomorphism groupFirstIsomorphismTheorem x = f x , (x , reflexive) GroupHom.groupHom (GroupIso.groupHom (GroupsIsomorphic.proof groupFirstIsomorphismTheorem)) {x} {y} = GroupHom.groupHom fHom GroupHom.wellDefined (GroupIso.groupHom (GroupsIsomorphic.proof groupFirstIsomorphismTheorem)) {x} {y} = groupFirstIsomorphismTheoremWellDefined {x} {y} SetoidInjection.wellDefined (SetoidBijection.inj (GroupIso.bij (GroupsIsomorphic.proof groupFirstIsomorphismTheorem))) = groupFirstIsomorphismTheoremWellDefined SetoidInjection.injective (SetoidBijection.inj (GroupIso.bij (GroupsIsomorphic.proof groupFirstIsomorphismTheorem))) fx=fy = transitive (GroupHom.groupHom fHom) (transitive (Group.+WellDefined H reflexive fx=fy) (transitive (symmetric (GroupHom.groupHom fHom)) (transitive (GroupHom.wellDefined fHom (Group.invLeft G)) (imageOfIdentityIsIdentity fHom)))) SetoidSurjection.wellDefined (SetoidBijection.surj (GroupIso.bij (GroupsIsomorphic.proof groupFirstIsomorphismTheorem))) = groupFirstIsomorphismTheoremWellDefined SetoidSurjection.surjective (SetoidBijection.surj (GroupIso.bij (GroupsIsomorphic.proof groupFirstIsomorphismTheorem))) {b , (a , fa=b)} = a , fa=b groupFirstIsomorphismTheoremWellDefined' : {x y : A} → f (x +G (Group.inverse G y)) ∼ Group.0G H → Setoid._∼_ (subsetSetoid imageGroupSubset) (f x , (x , reflexive)) (f y , (y , reflexive)) groupFirstIsomorphismTheoremWellDefined' {x} {y} pr = transferToRight H (transitive (symmetric (transitive (GroupHom.groupHom fHom) (Group.+WellDefined H reflexive (homRespectsInverse fHom)))) pr) groupFirstIsomorphismTheorem' : GroupsIsomorphic (quotientGroupByHom) (subgroupIsGroup H imageGroupSubgroup) GroupsIsomorphic.isomorphism groupFirstIsomorphismTheorem' a = f a , (a , reflexive) GroupHom.groupHom (GroupIso.groupHom (GroupsIsomorphic.proof groupFirstIsomorphismTheorem')) {x} {y} = GroupHom.groupHom fHom GroupHom.wellDefined (GroupIso.groupHom (GroupsIsomorphic.proof groupFirstIsomorphismTheorem')) {x} {y} = groupFirstIsomorphismTheoremWellDefined' SetoidInjection.wellDefined (SetoidBijection.inj (GroupIso.bij (GroupsIsomorphic.proof groupFirstIsomorphismTheorem'))) {x} {y} = groupFirstIsomorphismTheoremWellDefined' {x} {y} SetoidInjection.injective (SetoidBijection.inj (GroupIso.bij (GroupsIsomorphic.proof groupFirstIsomorphismTheorem'))) {x} {y} fx=fy = transitive (GroupHom.groupHom fHom) (transitive (Group.+WellDefined H reflexive (homRespectsInverse fHom)) (transferToRight'' H fx=fy)) SetoidSurjection.wellDefined (SetoidBijection.surj (GroupIso.bij (GroupsIsomorphic.proof groupFirstIsomorphismTheorem'))) {x} {y} = groupFirstIsomorphismTheoremWellDefined' SetoidSurjection.surjective (SetoidBijection.surj (GroupIso.bij (GroupsIsomorphic.proof groupFirstIsomorphismTheorem'))) {b , (a , fa=b)} = a , fa=b
{ "alphanum_fraction": 0.7865542489, "avg_line_length": 86.6730769231, "ext": "agda", "hexsha": "d01d8f32909e72df3ea23d1c33933750c88f0926", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-29T13:23:07.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-29T13:23:07.000Z", "max_forks_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Smaug123/agdaproofs", "max_forks_repo_path": "Groups/FirstIsomorphismTheorem.agda", "max_issues_count": 14, "max_issues_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_issues_repo_issues_event_max_datetime": "2020-04-11T11:03:39.000Z", "max_issues_repo_issues_event_min_datetime": "2019-01-06T21:11:59.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Smaug123/agdaproofs", "max_issues_repo_path": "Groups/FirstIsomorphismTheorem.agda", "max_line_length": 354, "max_stars_count": 4, "max_stars_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Smaug123/agdaproofs", "max_stars_repo_path": "Groups/FirstIsomorphismTheorem.agda", "max_stars_repo_stars_event_max_datetime": "2022-01-28T06:04:15.000Z", "max_stars_repo_stars_event_min_datetime": "2019-08-08T12:44:19.000Z", "num_tokens": 1383, "size": 4507 }
{-# OPTIONS --without-K --safe #-} module Categories.Category.Construction.Presheaves where -- The Category of Presheaves over a Category C, i.e. -- the Functor Category [ C.op , Setoids ] -- Again, the levels are made explicit to show the generality and constraints. open import Level open import Categories.Category open import Categories.Category.Construction.Functors open import Categories.Category.Instance.Setoids using (Setoids) Presheaves : ∀ {o ℓ e o′ ℓ′ : Level} → Category o ℓ e → Category (o ⊔ ℓ ⊔ e ⊔ suc (o′ ⊔ ℓ′)) (o ⊔ ℓ ⊔ o′ ⊔ ℓ′) (o ⊔ o′ ⊔ ℓ′) Presheaves {o} {ℓ} {e} {o′} {ℓ′} C = Functors (Category.op C) (Setoids o′ ℓ′)
{ "alphanum_fraction": 0.6868217054, "avg_line_length": 40.3125, "ext": "agda", "hexsha": "5131bbfb2ffe74a32b5345429b462add10aa6a20", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "6ebc1349ee79669c5c496dcadd551d5bbefd1972", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Taneb/agda-categories", "max_forks_repo_path": "Categories/Category/Construction/Presheaves.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "6ebc1349ee79669c5c496dcadd551d5bbefd1972", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Taneb/agda-categories", "max_issues_repo_path": "Categories/Category/Construction/Presheaves.agda", "max_line_length": 78, "max_stars_count": null, "max_stars_repo_head_hexsha": "6ebc1349ee79669c5c496dcadd551d5bbefd1972", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Taneb/agda-categories", "max_stars_repo_path": "Categories/Category/Construction/Presheaves.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 209, "size": 645 }
{-# OPTIONS --without-K #-} module FinEquivEquivPlusTimes where open import Data.Product using (_×_; proj₁; proj₂) open import Equiv using (refl∼; sym∼; sym≃; _⊎≃_; id≃; _≃_; _●_; _×≃_; qinv) open import FinEquivPlusTimes using (F0≃⊥; module Plus; module Times) open Plus using (⊎≃+; +≃⊎) open Times using (×≃*; *≃×) open import FinEquivTypeEquiv using (_fin≃_; module PlusE; module TimesE; module PlusTimesE) open PlusE using (_+F_; unite+; uniti+; unite+r; uniti+r; assocr+; assocl+; swap+; sswap+) open TimesE using (_*F_; unite*; uniti*; unite*r; uniti*r; assocr*; assocl*; swap*; sswap*) open PlusTimesE using (distz; factorz; distzr; factorzr; dist; factor; distl; factorl) open import EquivEquiv open import TypeEquiv using (unite₊equiv; unite₊′equiv; assocl₊equiv) open import Data.Empty using (⊥) open import Data.Unit using (⊤) open import Data.Nat using (ℕ; _+_; _*_) open import Data.Fin using (Fin) open import Data.Sum using (_⊎_) open import Data.Product using (_,_) import Relation.Binary.PropositionalEquality as P using (refl) import TypeEquivEquiv as T using ( -- much lower down 0×0≃0) ------------------------------------------------------------------------------ -- Equivalences for distributivity distl-nat : {m n o m' n' o' : ℕ} {f : m fin≃ m'} {g : n fin≃ n'} {h : o fin≃ o'} → distl {m'} {n'} {o'} ● (f *F (g +F h)) ≋ ((f *F g) +F (f *F h)) ● distl {m} {n} {o} distl-nat = {!!} factorl-nat : {m n o m' n' o' : ℕ} {f : m fin≃ m'} {g : n fin≃ n'} {h : o fin≃ o'} → factorl {m'} {n'} {o'} ● ((f *F g) +F (f *F h)) ≋ (f *F (g +F h)) ● factorl {m} {n} {o} factorl-nat = {!!} dist-nat : {m n o m' n' o' : ℕ} {f : m fin≃ m'} {g : n fin≃ n'} {h : o fin≃ o'} → dist {m'} {n'} {o'} ● ((f +F g) *F h) ≋ ((f *F h) +F (g *F h)) ● dist {m} {n} {o} dist-nat = {!!} factor-nat : {m n o m' n' o' : ℕ} {f : m fin≃ m'} {g : n fin≃ n'} {h : o fin≃ o'} → factor {m'} {n'} {o'} ● ((f *F h) +F (g *F h)) ≋ ((f +F g) *F h) ● factor {m} {n} {o} factor-nat = {!!} distzr-nat : {m n : ℕ} {f : m fin≃ n} {g : 0 fin≃ 0} → distzr {n} ● (f *F g) ≋ g ● distzr {m} distzr-nat = {!!} factorzr-nat : {m n : ℕ} {f : m fin≃ n} {g : 0 fin≃ 0} → factorzr {n} ● g ≋ (f *F g) ● factorzr {m} factorzr-nat = {!!} distz-nat : {m n : ℕ} → {f : m fin≃ n} → {g : 0 fin≃ 0} → distz {n} ● (g *F f) ≋ g ● distz {m} distz-nat = {!!} factorz-nat : {m n : ℕ} → {f : m fin≃ n} → {g : 0 fin≃ 0} → factorz {n} ● g ≋ (g *F f) ● factorz {m} factorz-nat = {!!} A×[B⊎C]≃[A×C]⊎[A×B] : {m n o : ℕ} → distl {m} {o} {n} ● (id≃ {A = Fin m} *F swap+ {n} {o}) ≋ swap+ {m * n} {m * o} ● distl {m} {n} {o} A×[B⊎C]≃[A×C]⊎[A×B] = {!!} [A⊎B]×C≃[C×A]⊎[C×B] : {m n o : ℕ} → (swap* {m} {o} +F swap* {n} {o}) ● dist {m} {n} {o} ≋ distl {o} {m} {n} ● swap* {m + n} {o} [A⊎B]×C≃[C×A]⊎[C×B] = {!!} [A⊎B⊎C]×D≃[A×D⊎B×D]⊎C×D : {m n o p : ℕ} → (dist {m} {n} {p} +F id≃ {A = Fin (o * p)}) ● dist {m + n} {o} {p} ● (assocl+ {m} {n} {o} *F id≃ {A = Fin p}) ≋ assocl+ {m * p} {n * p} {o * p} ● (id≃ {A = Fin (m * p)} +F dist {n} {o} {p}) ● dist {m} {n + o} {p} [A⊎B⊎C]×D≃[A×D⊎B×D]⊎C×D = {!!} A×B×[C⊎D]≃[A×B]×C⊎[A×B]×D : {m n o p : ℕ} → distl {m * n} {o} {p} ● assocl* {m} {n} {o + p} ≋ (assocl* {m} {n} {o} +F assocl* {m} {n} {p}) ● distl {m} {n * o} {n * p} ● (id≃ {A = Fin m} *F distl {n} {o} {p}) A×B×[C⊎D]≃[A×B]×C⊎[A×B]×D = {!!} [A⊎B]×[C⊎D]≃[[A×C⊎B×C]⊎A×D]⊎B×D : {m n o p : ℕ} → assocl+ {(m * o) + (n * o)} {m * p} {n * p} ● (dist {m} {n} {o} +F dist {m} {n} {p}) ● distl {m + n} {o} {p} ≋ (assocl+ {m * o} {n * o} {m * p} +F id≃ {A = Fin (n * p)}) ● ((id≃ {A = Fin (m * o)} +F swap+ {m * p} {n * o}) +F id≃ {A = Fin (n * p)}) ● (assocr+ {m * o} {m * p} {n * o} +F id≃ {A = Fin (n * p)}) ● assocl+ {(m * o) + (m * p)} {n * o} {n * p} ● (distl {m} {o} {p} +F distl {n} {o} {p}) ● dist {m} {n} {o + p} [A⊎B]×[C⊎D]≃[[A×C⊎B×C]⊎A×D]⊎B×D = {!!} -- can't be done via equational reasoning!?!? -- cannot even dig into T.0×0≃0 as f≋ is abstract 0×0≃0 : distz {0} ≋ distzr {0} 0×0≃0 = eq (λ {()}) (λ {()}) -- wow, talk about low-level reasoning! 0×[A⊎B]≃0 : {m n : ℕ} → distz {m + n} ≋ unite+ ● (distz {m} +F distz {n}) ● distl {0} {m} {n} 0×[A⊎B]≃0 = {!!} 0×1≃0 : unite*r ≋ distz {1} 0×1≃0 = {!!} A×0≃0 : {m : ℕ} → distzr {m} ≋ distz {m} ● swap* {m} {0} A×0≃0 = {!!} 0×A×B≃0 : {m n : ℕ} → distz {m * n} ≋ distz {n} ● (distz {m} *F id≃ {A = Fin n}) ● assocl* {0} {m} {n} 0×A×B≃0 = {!!} A×0×B≃0 : {m n : ℕ} → distzr {m} ● (id≃ {A = Fin m} *F distz {n}) ≋ distz {n} ● (distzr {m} *F id≃ {A = Fin n}) ● assocl* {m} {0} {n} A×0×B≃0 = {!!} A×[0+B]≃A×B : {m n : ℕ} → (id≃ {A = Fin m} *F unite+ {n}) ≋ unite+ ● (distzr {m} +F id≃) ● distl {m} {0} {n} A×[0+B]≃A×B = {!!} 1×[A⊎B]≃A⊎B : {m n : ℕ} → unite* ≋ (unite* {m} +F unite* {n}) ● distl {1} {m} {n} 1×[A⊎B]≃A⊎B = {!!} ------------------------------------------------------------------------------
{ "alphanum_fraction": 0.4317914543, "avg_line_length": 34.0133333333, "ext": "agda", "hexsha": "a0029b462db9ecac743633ac015f71b72ee97954", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2019-09-10T09:47:13.000Z", "max_forks_repo_forks_event_min_datetime": "2016-05-29T01:56:33.000Z", "max_forks_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_forks_repo_licenses": [ "BSD-2-Clause" ], "max_forks_repo_name": "JacquesCarette/pi-dual", "max_forks_repo_path": "Univalence/FinEquivEquivPlusTimes.agda", "max_issues_count": 4, "max_issues_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_issues_repo_issues_event_max_datetime": "2021-10-29T20:41:23.000Z", "max_issues_repo_issues_event_min_datetime": "2018-06-07T16:27:41.000Z", "max_issues_repo_licenses": [ "BSD-2-Clause" ], "max_issues_repo_name": "JacquesCarette/pi-dual", "max_issues_repo_path": "Univalence/FinEquivEquivPlusTimes.agda", "max_line_length": 83, "max_stars_count": 14, "max_stars_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_stars_repo_licenses": [ "BSD-2-Clause" ], "max_stars_repo_name": "JacquesCarette/pi-dual", "max_stars_repo_path": "Univalence/FinEquivEquivPlusTimes.agda", "max_stars_repo_stars_event_max_datetime": "2021-05-05T01:07:57.000Z", "max_stars_repo_stars_event_min_datetime": "2015-08-18T21:40:15.000Z", "num_tokens": 2638, "size": 5102 }
open import MJ.Types as Types import MJ.Classtable.Core as Core module MJ.Semantics.Values {c}(Ct : Core.Classtable c) where open import Prelude open import Level renaming (suc to lsuc; zero to lzero) open import Data.List hiding (null) open import Data.List.Membership.Propositional open import Data.List.Prefix open Core c open Classtable Ct open import MJ.Classtable.Membership Ct open import MJ.LexicalScope c open import Common.Weakening {- MJ inherits the values of STLC+Ref. In contrast to STCL+Ref, MJ also has null-pointers; which we add as a constructor to our value type Val. The value constructed by null is typed with an arbitrary reference type as it can be used in place of any proper reference. -} data Val (W : World c) : Ty c → Set where num : ℕ → Val W int unit : Val W void null : ∀ {C} → Val W (ref C) ref : ∀ {C P} → (obj C) ∈ W → Σ ⊢ C <: P → Val W (ref P) {- We can construct default values out of thin air for every type -} default : ∀ {W} → (a : Ty c) → Val W a default void = unit default int = num 0 default (ref x) = null {- Value weakening -} weaken-val : ∀ {a}{W W' : World c} → W ⊒ W' → Val W' a → Val W a weaken-val ext (num n) = num n weaken-val ext unit = unit weaken-val ext null = null weaken-val ext (ref x sub) = ref (∈-⊒ x ext) sub instance val-weakenable : ∀ {a} → Weakenable (λ W → Val W a) val-weakenable = record { wk = weaken-val }
{ "alphanum_fraction": 0.6892857143, "avg_line_length": 26.9230769231, "ext": "agda", "hexsha": "4f5a51ec1713df87a1129e5bf78e421bb4befeac", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-12-28T17:38:05.000Z", "max_forks_repo_forks_event_min_datetime": "2021-12-28T17:38:05.000Z", "max_forks_repo_head_hexsha": "0c096fea1716d714db0ff204ef2a9450b7a816df", "max_forks_repo_licenses": [ "Apache-2.0" ], "max_forks_repo_name": "metaborg/mj.agda", "max_forks_repo_path": "src/MJ/Semantics/Values.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "0c096fea1716d714db0ff204ef2a9450b7a816df", "max_issues_repo_issues_event_max_datetime": "2020-10-14T13:41:58.000Z", "max_issues_repo_issues_event_min_datetime": "2019-01-13T13:03:47.000Z", "max_issues_repo_licenses": [ "Apache-2.0" ], "max_issues_repo_name": "metaborg/mj.agda", "max_issues_repo_path": "src/MJ/Semantics/Values.agda", "max_line_length": 79, "max_stars_count": 10, "max_stars_repo_head_hexsha": "0c096fea1716d714db0ff204ef2a9450b7a816df", "max_stars_repo_licenses": [ "Apache-2.0" ], "max_stars_repo_name": "metaborg/mj.agda", "max_stars_repo_path": "src/MJ/Semantics/Values.agda", "max_stars_repo_stars_event_max_datetime": "2021-09-24T08:02:33.000Z", "max_stars_repo_stars_event_min_datetime": "2017-11-17T17:10:36.000Z", "num_tokens": 441, "size": 1400 }
module _ where data D .(A : Set) : Set -- The dot should not be repeated here data D .A where mkD : D A
{ "alphanum_fraction": 0.6330275229, "avg_line_length": 12.1111111111, "ext": "agda", "hexsha": "8c8b2bf96e15c19674b6aa73f136ea47bc4a5569", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cruhland/agda", "max_forks_repo_path": "test/Fail/Issue1886-relevance.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "cruhland/agda", "max_issues_repo_path": "test/Fail/Issue1886-relevance.agda", "max_line_length": 38, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/Fail/Issue1886-relevance.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 38, "size": 109 }
{-# OPTIONS --warning=error #-} module UselessPrivateImport where private open import Common.Prelude
{ "alphanum_fraction": 0.7619047619, "avg_line_length": 15, "ext": "agda", "hexsha": "c339fe2ef329de7fa13568b946e3623b5fe35e8e", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_path": "test/Fail/UselessPrivateImport.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "shlevy/agda", "max_issues_repo_path": "test/Fail/UselessPrivateImport.agda", "max_line_length": 33, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "test/Fail/UselessPrivateImport.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 23, "size": 105 }
{- 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.ImplShared.Consensus.Types open import Util.Encode open import Util.PKCS as PKCS hiding (sign; verify) open import Util.Prelude module LibraBFT.Impl.OBM.Crypto where ------------------------------------------------------------------------------ -- keys postulate -- TODO-1 : makePK makePK : SK → PK ------------------------------------------------------------------------------ postulate -- TODO-1: implement obmHashVersion obmHashVersion : Version → HashValue ------------------------------------------------------------------------------ -- sign and verify record CryptoHash (A : Set) : Set where field sign : SK → A → Signature verify : {-Text-} PK → Signature → A → Either ErrLog Unit ⦃ encodeA ⦄ : Encoder A open CryptoHash ⦃ ... ⦄ public instance CryptoHashBlockData : CryptoHash BlockData CryptoHashBlockData = record { sign = λ sk bd → PKCS.sign-raw (encode bd) sk ; verify = λ pk sig bd → if PKCS.verify (encode bd) sig pk then Right unit else Left fakeErr } instance CryptoHashLedgerInfo : CryptoHash LedgerInfo CryptoHashLedgerInfo = record { sign = λ sk li → PKCS.sign-raw (encode li) sk ; verify = λ pk sig li → if PKCS.verify (encode li) sig pk then Right unit else Left fakeErr } instance CryptoHashTimeout : CryptoHash Timeout CryptoHashTimeout = record { sign = λ sk to → PKCS.sign-raw (encode to) sk ; verify = λ pk sig to → if PKCS.verify (encode to) sig pk then Right unit else Left fakeErr }
{ "alphanum_fraction": 0.5420231505, "avg_line_length": 33.6779661017, "ext": "agda", "hexsha": "dab389ea0a86cc84bacfae31370027304e96b855", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "a4674fc473f2457fd3fe5123af48253cfb2404ef", "max_forks_repo_licenses": [ "UPL-1.0" ], "max_forks_repo_name": "LaudateCorpus1/bft-consensus-agda", "max_forks_repo_path": "src/LibraBFT/Impl/OBM/Crypto.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "a4674fc473f2457fd3fe5123af48253cfb2404ef", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "UPL-1.0" ], "max_issues_repo_name": "LaudateCorpus1/bft-consensus-agda", "max_issues_repo_path": "src/LibraBFT/Impl/OBM/Crypto.agda", "max_line_length": 111, "max_stars_count": null, "max_stars_repo_head_hexsha": "a4674fc473f2457fd3fe5123af48253cfb2404ef", "max_stars_repo_licenses": [ "UPL-1.0" ], "max_stars_repo_name": "LaudateCorpus1/bft-consensus-agda", "max_stars_repo_path": "src/LibraBFT/Impl/OBM/Crypto.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 464, "size": 1987 }
{-# OPTIONS --safe #-} module Cubical.Algebra.AbGroup.Properties where open import Cubical.Foundations.Prelude open import Cubical.Algebra.AbGroup.Base private variable ℓ : Level module AbGroupTheory (A'@(A , Ar) : AbGroup ℓ) where open AbGroupStr Ar comm-4 : (a b c d : A) → ((a + b) + (c + d) ≡ (a + c) + (b + d)) comm-4 a b c d = ((a + b) + (c + d) ≡⟨ +Assoc (a + b) c d ⟩ (((a + b) + c) + d) ≡⟨ cong (λ X → X + d) (sym (+Assoc a b c)) ⟩ ((a + (b + c)) + d) ≡⟨ cong (λ X → (a + X) + d) (+Comm b c) ⟩ ((a + (c + b)) + d) ≡⟨ cong (λ X → X + d) (+Assoc a c b) ⟩ (((a + c) + b) + d) ≡⟨ sym (+Assoc (a + c) b d) ⟩ ((a + c) + (b + d)) ∎)
{ "alphanum_fraction": 0.4262734584, "avg_line_length": 32.4347826087, "ext": "agda", "hexsha": "8c0c455789adf8fe62511b8eed1069ed304b41c8", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "thomas-lamiaux/cubical", "max_forks_repo_path": "Cubical/Algebra/AbGroup/Properties.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "thomas-lamiaux/cubical", "max_issues_repo_path": "Cubical/Algebra/AbGroup/Properties.agda", "max_line_length": 83, "max_stars_count": null, "max_stars_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "thomas-lamiaux/cubical", "max_stars_repo_path": "Cubical/Algebra/AbGroup/Properties.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 298, "size": 746 }
module BBHeap.Complete.Base {A : Set}(_≤_ : A → A → Set) where open import BBHeap _≤_ open import BBHeap.Complete.Alternative _≤_ renaming (lemma-bbheap-complete to lemma-bbheap-complete') open import BTree.Complete.Alternative.Correctness {A} open import BTree.Complete.Base {A} open import Bound.Lower A open import Function using (_∘_) lemma-bbheap-complete : {b : Bound}(h : BBHeap b) → Complete (forget h) lemma-bbheap-complete = lemma-complete'-complete ∘ lemma-bbheap-complete'
{ "alphanum_fraction": 0.7551020408, "avg_line_length": 40.8333333333, "ext": "agda", "hexsha": "99ed5a0d5426009aab6be8a7a4ca261737dd0c79", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "bgbianchi/sorting", "max_forks_repo_path": "agda/BBHeap/Complete/Base.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "bgbianchi/sorting", "max_issues_repo_path": "agda/BBHeap/Complete/Base.agda", "max_line_length": 102, "max_stars_count": 6, "max_stars_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "bgbianchi/sorting", "max_stars_repo_path": "agda/BBHeap/Complete/Base.agda", "max_stars_repo_stars_event_max_datetime": "2021-08-24T22:11:15.000Z", "max_stars_repo_stars_event_min_datetime": "2015-05-21T12:50:35.000Z", "num_tokens": 140, "size": 490 }
------------------------------------------------------------------------------ -- Bisimulation on unbounded lists ------------------------------------------------------------------------------ {-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} -- In FOTC, we won't use the bisimulation functional on unbounded -- lists. This module is only for illustrative purposes. module FOTC.Relation.Binary.Bisimilarity.Bisimulation where open import FOTC.Base open import FOTC.Base.List open import FOTC.Relation.Binary.Bisimilarity.Type open import FOTC.Relation.Binary.Bisimilarity.PropertiesI ---------------------------------------------------------------------------- -- The bisimilarity relation _≈_ on unbounded lists is the greatest -- post-fixed point of Bisimulation (by post-fp and gpfp). -- The bisimulation functional on unbounded lists (adapted from Dybjer -- and Sander 1989, p. 310 and Jacobs and Rutten 1997, p. 30). BisimulationF : (D → D → Set) → D → D → Set BisimulationF B xs ys = ∃[ x' ] ∃[ xs' ] ∃[ ys' ] xs ≡ x' ∷ xs' ∧ ys ≡ x' ∷ ys' ∧ B xs' ys' -- The bisimilarity relation _≈_ on unbounded lists is a post-fixed -- point of Bisimulation, i.e. -- -- _≈_ ≤ Bisimulation _≈_. post-fp : ∀ {xs ys} → xs ≈ ys → BisimulationF _≈_ xs ys post-fp = ≈-out -- The bisimilarity relation _≈_ on unbounded lists is the greatest -- post-fixed point of Bisimulation, i.e. -- -- ∀ B. B ≤ Bisimulation B ⇒ B ≤ _≈_. greatest-post-fp : (B : D → D → Set) → -- B is a post-fixed point of Bisimulation. (∀ {xs} {ys} → B xs ys → BisimulationF B xs ys) → -- _≈_ is greater than B. ∀ {xs} {ys} → B xs ys → xs ≈ ys greatest-post-fp = ≈-coind -- Because a greatest post-fixed point is a fixed-point, the -- bisimilarity relation _≈_ on unbounded lists is also a pre-fixed -- point of Bisimulation, i.e. -- -- Bisimulation _≈_ ≤ _≈_. pre-fp : ∀ {xs} {ys} → BisimulationF _≈_ xs ys → xs ≈ ys pre-fp = ≈-in ---------------------------------------------------------------------------- -- References -- -- Dybjer, Peter and Sander, Herbert P. (1989). A Functional -- Programming Approach to the Specification and Verification of -- Concurrent Systems. Formal Aspects of Computing 1, pp. 303–319. -- -- Jacobs, Bart and Rutten, Jan (1997). A Tutorial on (Co)Algebras and -- (Co)Induction. EATCS Bulletin 62, pp. 222–259.
{ "alphanum_fraction": 0.5832310838, "avg_line_length": 37.0454545455, "ext": "agda", "hexsha": "e771fb14e53bcf466ad048a607bd955186095201", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "asr/fotc", "max_forks_repo_path": "src/fot/FOTC/Relation/Binary/Bisimilarity/Bisimulation.agda", "max_issues_count": 2, "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "asr/fotc", "max_issues_repo_path": "src/fot/FOTC/Relation/Binary/Bisimilarity/Bisimulation.agda", "max_line_length": 78, "max_stars_count": 11, "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/fotc", "max_stars_repo_path": "src/fot/FOTC/Relation/Binary/Bisimilarity/Bisimulation.agda", "max_stars_repo_stars_event_max_datetime": "2021-09-12T16:09:54.000Z", "max_stars_repo_stars_event_min_datetime": "2015-09-03T20:53:42.000Z", "num_tokens": 694, "size": 2445 }
open import Issue3188.Issue3188a B : Set B = Set
{ "alphanum_fraction": 0.74, "avg_line_length": 10, "ext": "agda", "hexsha": "13f811fd6743112d4ea908ef91398ebd2e201f86", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cruhland/agda", "max_forks_repo_path": "test/Fail/Issue3188.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "cruhland/agda", "max_issues_repo_path": "test/Fail/Issue3188.agda", "max_line_length": 32, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/Fail/Issue3188.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 19, "size": 50 }
module Oscar.Class.Functor where open import Oscar.Class.Monoid open import Oscar.Data.Equality open import Oscar.Data.Product open import Oscar.Level open import Oscar.Relation open import Oscar.Function record Functor {a} {A : Set a} {b} (_↠_ : A → A → Set b) ⦃ _ : Monoid _↠_ ⦄ {c} (C : A → Set c) : Set (a ⊔ b ⊔ c) where field _◃_ : ∀ {m n} → m ↠ n → m ⟨ C ⟩→ n ◃-identity : ∀ {m} → (x : C m) → ε ◃ x ≡ x ◃-associativity : ∀ {l m n} (f : l ↠ m) (g : m ↠ n) → (g ◇ f) ◃_ ≡̇ g ◃_ ∘ f ◃_ ◃-extensionality : ∀ {m n} {f g : m ↠ n} → f ≡ g → f ◃_ ≡ g ◃_ open Functor ⦃ … ⦄ public open import Data.List open import Oscar.Function instance MonoidFunction : ∀ {a} → Monoid {A = Set a} (λ m n → m → n) Monoid.ε MonoidFunction = λ x → x Monoid._◇_ MonoidFunction g f = g ∘ f Monoid.◇-left-identity MonoidFunction _ = refl Monoid.◇-right-identity MonoidFunction _ = refl Monoid.◇-associativity MonoidFunction _ _ _ = refl instance FunctorList : ∀ {a} → Functor _ ⦃ MonoidFunction {a} ⦄ List Functor._◃_ FunctorList {m} {n} f [] = [] Functor._◃_ FunctorList {m} {n} f (x ∷ xs) = f x ∷ f ◃ xs Functor.◃-identity FunctorList = {!!} Functor.◃-associativity FunctorList = {!!} Functor.◃-extensionality FunctorList = {!!}
{ "alphanum_fraction": 0.6196269262, "avg_line_length": 34.25, "ext": "agda", "hexsha": "154291f85f43b2b0bd636424af885217d8bdab9b", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_forks_repo_licenses": [ "RSA-MD" ], "max_forks_repo_name": "m0davis/oscar", "max_forks_repo_path": "archive/agda-2/Oscar/Class/Functor.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_issues_repo_issues_event_max_datetime": "2019-05-11T23:33:04.000Z", "max_issues_repo_issues_event_min_datetime": "2019-04-29T00:35:04.000Z", "max_issues_repo_licenses": [ "RSA-MD" ], "max_issues_repo_name": "m0davis/oscar", "max_issues_repo_path": "archive/agda-2/Oscar/Class/Functor.agda", "max_line_length": 119, "max_stars_count": null, "max_stars_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_stars_repo_licenses": [ "RSA-MD" ], "max_stars_repo_name": "m0davis/oscar", "max_stars_repo_path": "archive/agda-2/Oscar/Class/Functor.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 492, "size": 1233 }
-- There was a bug when scope checking with clauses. module WithScopeError where data Nat : Set where zero : Nat suc : Nat -> Nat f : Nat -> Nat f n with y where y = suc n f n | x = y x
{ "alphanum_fraction": 0.637755102, "avg_line_length": 15.0769230769, "ext": "agda", "hexsha": "446f53107fd6307077700019165e76a188a289dd", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cruhland/agda", "max_forks_repo_path": "test/Fail/WithScopeError.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "cruhland/agda", "max_issues_repo_path": "test/Fail/WithScopeError.agda", "max_line_length": 52, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/Fail/WithScopeError.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 62, "size": 196 }
{-# OPTIONS --without-K #-} module Deltaplus where {- Chapter 9.2: Semi-Simplicial Types This file contains the definition of the index category for semi-simplicial with judgmental categorical laws: Δ₊ In other words, we check Proposition 9.2.1. We want to keep it independent of the other files, so we do not import anything. -} {- For simplicity, we only use the lowest universe (totally sufficient) -} Type = Set -- the empty type data Empty : Type where -- the unit type data ⊤ : Type where * : ⊤ -- the natural numbers data ℕ : Type where O : ℕ S : (n : ℕ) → ℕ {- Finite types: these are the === OBJECTS of Δ₊ === -} data Fin : ℕ → Type where fz : {n : ℕ} → Fin (S n) fs : {n : ℕ} → Fin n → Fin (S n) -- >-relation on finite types _>fin_ : {n : ℕ} → (i j : Fin n) → Set fz >fin i = Empty fs j >fin fz = ⊤ fs j >fin fs i = j >fin i {- the proposition [we do not need to prove propositionality here, but we could prove it easily] that a function is increasing; this is the tricky part: it needs to be done in a way which ensures that composition will behave nicely (strictly associative etc) later -} is-increasing : {m n : ℕ} → (Fin m → Fin n) → Type is-increasing {m} {n} f = {j i : Fin m} → (j >fin i) → ((f j) >fin (f i)) infixr 1 _,_ record Σ (A : Type) (B : A → Type) : Type where constructor _,_ field fst : A snd : B fst {- Strictly increasing maps: these are the === MORPHISMS of Δ₊ === -} _⇒+_ : ℕ → ℕ → Set m ⇒+ n = Σ (Fin m → Fin n) is-increasing _∘+_ : {l m n : ℕ} → (m ⇒+ n) → (l ⇒+ m) → (l ⇒+ n) (g , p₂) ∘+ (f , p₁) = (λ i → g(f(i))) , (λ p → p₂ (p₁ p)) -- === IDENTITY MORPHISMS of Δ₊ === idΔ₊ : ∀ {n} → n ⇒+ n idΔ₊ = (λ x → x) , (λ p → p) {- Now, let us check that the categorical laws hold judgmentally. To do this, we use the usual notion of equality. -} infix 3 _==_ data _==_ {A : Type} (a : A) : A → Type where idp : a == a -- === IDENTITY LAWS === id-comp : ∀ {m n} → (f : m ⇒+ n) → (idΔ₊ ∘+ f) == f id-comp f = idp comp-id : ∀ {m n} → (f : m ⇒+ n) → (f ∘+ idΔ₊) == f comp-id f = idp -- === ASSOCIATIVITY LAW === comp-assoc : ∀ {i j m n} → (f : i ⇒+ j) → (g : j ⇒+ m) → (h : m ⇒+ n) → h ∘+ (g ∘+ f) == (h ∘+ g) ∘+ f comp-assoc f g h = idp
{ "alphanum_fraction": 0.557261957, "avg_line_length": 22.3431372549, "ext": "agda", "hexsha": "a43fce35decf6a9336397cddec40c98af84095b3", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "939a2d83e090fcc924f69f7dfa5b65b3b79fe633", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "nicolaikraus/HoTT-Agda", "max_forks_repo_path": "nicolai/thesis/Deltaplus.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "939a2d83e090fcc924f69f7dfa5b65b3b79fe633", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "nicolaikraus/HoTT-Agda", "max_issues_repo_path": "nicolai/thesis/Deltaplus.agda", "max_line_length": 74, "max_stars_count": 1, "max_stars_repo_head_hexsha": "939a2d83e090fcc924f69f7dfa5b65b3b79fe633", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "nicolaikraus/HoTT-Agda", "max_stars_repo_path": "nicolai/thesis/Deltaplus.agda", "max_stars_repo_stars_event_max_datetime": "2021-06-30T00:17:55.000Z", "max_stars_repo_stars_event_min_datetime": "2021-06-30T00:17:55.000Z", "num_tokens": 856, "size": 2279 }
----------------------------------------------------------------------- -- This file defines Dial₂(Sets) and its SMC structure. -- ----------------------------------------------------------------------- module Dial2Sets where open import prelude -- The objects: Obj : Set₁ Obj = Σ[ U ∈ Set ] (Σ[ X ∈ Set ] (U → X → Set)) -- The morphisms: Hom : Obj → Obj → Set Hom (U , X , α) (V , Y , β) = Σ[ f ∈ (U → V) ] (Σ[ F ∈ (Y → X) ] (∀{u : U}{y : Y} → α u (F y) → β (f u) y)) -- Composition: comp : {A B C : Obj} → Hom A B → Hom B C → Hom A C comp {(U , X , α)} {(V , Y , β)} {(W , Z , γ)} (f , F , p₁) (g , G , p₂) = (g ∘ f , F ∘ G , (λ {u z} p-α → p₂ (p₁ p-α))) infixl 5 _○_ _○_ = comp -- The contravariant hom-functor: Homₐ : {A' A B B' : Obj} → Hom A' A → Hom B B' → Hom A B → Hom A' B' Homₐ f h g = comp f (comp g h) -- The identity function: id : {A : Obj} → Hom A A id {(U , V , α)} = (id-set , id-set , id-set) -- In this formalization we will only worry about proving that the -- data of morphisms are equivalent, and not worry about the morphism -- conditions. This will make proofs shorter and faster. -- -- If we have parallel morphisms (f,F) and (g,G) in which we know that -- f = g and F = G, then the condition for (f,F) will imply the -- condition of (g,G) and vice versa. Thus, we can safly ignore it. infix 4 _≡h_ _≡h_ : {A B : Obj} → (f g : Hom A B) → Set _≡h_ {(U , X , α)}{(V , Y , β)} (f , F , p₁) (g , G , p₂) = f ≡ g × F ≡ G ≡h-refl : {A B : Obj}{f : Hom A B} → f ≡h f ≡h-refl {U , X , α}{V , Y , β}{f , F , _} = refl , refl ≡h-trans : ∀{A B}{f g h : Hom A B} → f ≡h g → g ≡h h → f ≡h h ≡h-trans {U , X , α}{V , Y , β}{f , F , _}{g , G , _}{h , H , _} (p₁ , p₂) (p₃ , p₄) rewrite p₁ | p₂ | p₃ | p₄ = refl , refl ≡h-sym : ∀{A B}{f g : Hom A B} → f ≡h g → g ≡h f ≡h-sym {U , X , α}{V , Y , β}{f , F , _}{g , G , _} (p₁ , p₂) rewrite p₁ | p₂ = refl , refl ≡h-subst-○ : ∀{A B C}{f₁ f₂ : Hom A B}{g₁ g₂ : Hom B C}{j : Hom A C} → f₁ ≡h f₂ → g₁ ≡h g₂ → f₂ ○ g₂ ≡h j → f₁ ○ g₁ ≡h j ≡h-subst-○ {U , X , α} {V , Y , β} {W , Z , γ} {f₁ , F₁ , _} {f₂ , F₂ , _} {g₁ , G₁ , _} {g₂ , G₂ , _} {j , J , _} (p₅ , p₆) (p₇ , p₈) (p₉ , p₁₀) rewrite p₅ | p₆ | p₇ | p₈ | p₉ | p₁₀ = refl , refl ○-assoc : ∀{A B C D}{f : Hom A B}{g : Hom B C}{h : Hom C D} → f ○ (g ○ h) ≡h (f ○ g) ○ h ○-assoc {U , X , α}{V , Y , β}{W , Z , γ}{S , T , ι} {f , F , _}{g , G , _}{h , H , _} = refl , refl ○-idl : ∀{A B}{f : Hom A B} → id ○ f ≡h f ○-idl {U , X , _}{V , Y , _}{f , F , _} = refl , refl ○-idr : ∀{A B}{f : Hom A B} → f ○ id ≡h f ○-idr {U , X , _}{V , Y , _}{f , F , _} = refl , refl ----------------------------------------------------------------------- -- Dial₂(Sets) is a SMC -- ----------------------------------------------------------------------- -- The tensor functor: ⊗ _⊗ᵣ_ : ∀{U X V Y : Set} → (U → X → Set) → (V → Y → Set) → ((U × V) → ((V → X) × (U → Y)) → Set) _⊗ᵣ_ α β (u , v) (f , g) = (α u (f v)) × (β v (g u)) _⊗ₒ_ : (A B : Obj) → Obj (U , X , α) ⊗ₒ (V , Y , β) = ((U × V) , ((V → X) × (U → Y)) , α ⊗ᵣ β) F⊗ : ∀{S Z W T V X U Y : Set}{f : U → W}{F : Z → X}{g : V → S}{G : T → Y} → (S → Z) × (W → T) → (V → X) × (U → Y) F⊗ {f = f}{F}{g}{G} (h₁ , h₂) = (λ v → F(h₁ (g v))) , (λ u → G(h₂ (f u))) _⊗ₐ_ : {A B C D : Obj} → Hom A C → Hom B D → Hom (A ⊗ₒ B) (C ⊗ₒ D) _⊗ₐ_ {(U , X , α)}{(V , Y , β)}{(W , Z , γ)}{(S , T , δ)} (f , F , p₁) (g , G , p₂) = ⟨ f , g ⟩ , F⊗ {f = f}{F}{g}{G} , p where p : {u : U × V} {y : (S → Z) × (W → T)} → (α ⊗ᵣ β) u ((F⊗ {f = f}{F}{g}{G}) y) → (γ ⊗ᵣ δ) (⟨ f , g ⟩ u) y p {(u , v)} {(h₁ , h₂)} (p-α , p-β) = p₁ p-α , p₂ p-β -- The unit for tensor: ι : ⊤ {lzero} → ⊤ {lzero} → Set ι triv triv = ⊤ I : Obj I = (⊤ , ⊤ , ι) J : Obj J = (⊤ , ⊤ , (λ x y → ⊥)) -- The left-unitor: λ⊗-p : ∀{U X α}{u : ⊤ × U} {x : X} → (ι ⊗ᵣ α) u ((λ _ → triv) , (λ _ → x)) → α (snd u) x λ⊗-p {U}{X}{α}{(triv , u)}{x} (triv , p-α) = p-α λ⊗ : ∀{A : Obj} → Hom (I ⊗ₒ A) A λ⊗ {(U , X , α)} = snd , (λ x → (λ _ → triv) , (λ _ → x)) , λ⊗-p λ⁻¹⊗ : ∀{A : Obj} → Hom A (I ⊗ₒ A) λ⁻¹⊗ {(U , X , α)} = (λ u → triv , u) , ((λ x → snd x triv) , λ⁻¹⊗-p) where λ⁻¹⊗-p : ∀{U X α} → {u : U} {y : (U → ⊤) × (⊤ → X)} → α u (snd y triv) → (ι ⊗ᵣ α) (triv , u) y λ⁻¹⊗-p {U}{X}{α}{u}{(h₁ , h₂)} p-α with h₁ u ... | triv = triv , p-α -- The right-unitor: ρ⊗ : ∀{A : Obj} → Hom (A ⊗ₒ I) A ρ⊗ {(U , X , α)} = fst , (λ x → (λ x₁ → x) , (λ x₁ → triv)) , ρ⊗-p where ρ⊗-p : ∀{U X α}{u : U × ⊤}{x : X} → (α ⊗ᵣ ι) u ((λ _ → x) , (λ _ → triv)) → α (fst u) x ρ⊗-p {U}{X}{α}{(u , triv)}{x} (p-α , triv) = p-α ρ⊗-inv : ∀{A : Obj} → Hom A (A ⊗ₒ I) ρ⊗-inv {(U , X , α)} = (λ x → x , triv) , (λ x → fst x triv) , ρ⊗-p-inv where ρ⊗-p-inv : ∀{U X α}{u : U} {y : Σ (⊤ → X) (λ x → U → ⊤)} → α u (fst y triv) → (α ⊗ᵣ ι) (u , triv) y ρ⊗-p-inv {U}{X}{α}{u}{(f , g)} p-α rewrite single-range {g = g}{u} = p-α , triv -- Symmetry: β⊗ : ∀{A B : Obj} → Hom (A ⊗ₒ B) (B ⊗ₒ A) β⊗ {(U , X , α)}{(V , Y , β)} = twist-× , twist-× , β⊗-p where β⊗-p : ∀{U V Y X α β} → {u : U × V} {y : (U → Y) × (V → X)} → (α ⊗ᵣ β) u (twist-× y) → (β ⊗ᵣ α) (twist-× u) y β⊗-p {U}{V}{Y}{X}{α}{β}{(u , v)}{(h₁ , h₂)} p-α = twist-× p-α -- The associator: α⊗-inv : ∀{A B C : Obj} → Hom (A ⊗ₒ (B ⊗ₒ C)) ((A ⊗ₒ B) ⊗ₒ C) α⊗-inv {(U , X , α)}{(V , Y , β)}{(W , Z , γ)} = rl-assoc-× , Fα-inv , α-inv-cond where Fα-inv : (W → (V → X) × (U → Y)) × (U × V → Z) → (V × W → X) × (U → (W → Y) × (V → Z)) Fα-inv = (λ p → (λ p' → fst ((fst p) (snd p')) (fst p')) , (λ u → (λ w → snd (fst p w) u) , (λ v → (snd p) (u , v)))) α-inv-cond : ∀{u : U × V × W} {y : (W → (V → X) × (U → Y)) × (U × V → Z)} → (α ⊗ᵣ (β ⊗ᵣ γ)) u (Fα-inv y) → ((α ⊗ᵣ β) ⊗ᵣ γ) (rl-assoc-× u) y α-inv-cond {(u , v , w)} {(h₁ , h₂)} (p₁ , p₂ , p₃) with h₁ w ... | (a , b) = (p₁ , p₂) , p₃ Fα : ∀{V W X Y U V Z : Set} → Σ (Σ V (λ x → W) → X) (λ x → U → Σ (W → Y) (λ x₁ → V → Z)) → Σ (W → Σ (V → X) (λ x → U → Y)) (λ x → Σ U (λ x₁ → V) → Z) Fα (f , g) = (λ x → (λ x₁ → f ((x₁ , x))) , (λ x₁ → fst (g x₁) x)) , (λ x → snd (g (fst x)) (snd x)) α⊗ : ∀{A B C : Obj} → Hom ((A ⊗ₒ B) ⊗ₒ C) (A ⊗ₒ (B ⊗ₒ C)) α⊗ {(U , X , α)}{(V , Y , β)}{(W , Z , γ)} = (lr-assoc-× , Fα {V} , α-cond) where α-cond : {u : Σ (Σ U (λ x → V)) (λ x → W)}{y : Σ (Σ V (λ x → W) → X) (λ x → U → Σ (W → Y) (λ x₁ → V → Z))} → ((α ⊗ᵣ β) ⊗ᵣ γ) u (Fα {V} y) → (α ⊗ᵣ (β ⊗ᵣ γ)) (lr-assoc-× u) y α-cond {(u , v) , w}{(f , g)} ((p₁ , p₂) , p₃) with g u ... | (h₁ , h₂) = p₁ , p₂ , p₃ α⊗-id₁ : ∀{A B C} → (α⊗ {A}{B}{C}) ○ α⊗-inv ≡h id α⊗-id₁ {U , X , α}{V , Y , β}{W , Z , γ} = ext-set aux , ext-set aux' where aux : {a : Σ (Σ U (λ x → V)) (λ x → W)} → rl-assoc-× (lr-assoc-× a) ≡ a aux {(u , v) , w} = refl aux' : {a : Σ (W → Σ (V → X) (λ x → U → Y)) (λ x → Σ U (λ x₁ → V) → Z)} → ((λ x → (λ x₁ → fst (fst a x) x₁) , (λ x₁ → snd (fst a x) x₁)) , (λ x → snd a (fst x , snd x))) ≡ a aux' {j₁ , j₂} = eq-× (ext-set aux'') (ext-set aux''') where aux'' : {a : W} → (fst (j₁ a) , snd (j₁ a)) ≡ j₁ a aux'' {w} with j₁ w ... | h₁ , h₂ = refl aux''' : {a : Σ U (λ x₁ → V)} → j₂ (fst a , snd a) ≡ j₂ a aux''' {u , v} = refl α⊗-id₂ : ∀{A B C} → (α⊗-inv {A}{B}{C}) ○ α⊗ ≡h id α⊗-id₂ {U , X , α}{V , Y , β}{W , Z , γ} = ext-set aux , ext-set aux' where aux : {a : Σ U (λ x → Σ V (λ x₁ → W))} → lr-assoc-× (rl-assoc-× a) ≡ a aux {u , (v , w)} = refl aux' : {a : Σ (Σ V (λ x → W) → X) (λ x → U → Σ (W → Y) (λ x₁ → V → Z))} → ((λ p' → fst (fst (Fα {V} {W} {X} {Y} {U} {V} {Z} a) (snd p')) (fst p')) , (λ u → (λ w → snd (fst (Fα {V} {W} {X} {Y} {U} {V} {Z} a) w) u) , (λ v → snd (Fα {V} {W} {X} {Y} {U} {V} {Z} a) (u , v)))) ≡ a aux' {j₁ , j₂} = eq-× (ext-set aux'') (ext-set aux''') where aux'' : {a : Σ V (λ x → W)} → j₁ (fst a , snd a) ≡ j₁ a aux'' {v , w} = refl aux''' : {a : U} → ((λ w → fst (j₂ a) w) , (λ v → snd (j₂ a) v)) ≡ j₂ a aux''' {u} with j₂ u ... | h₁ , h₂ = refl -- Internal hom: ⊸-cond : ∀{U V X Y : Set} → (U → X → Set) → (V → Y → Set) → (U → V) × (Y → X) → U × Y → Set ⊸-cond α β (f , g) (u , y) = α u (g y) → β (f u) y _⊸ₒ_ : Obj → Obj → Obj (U , X , α) ⊸ₒ (V , Y , β) = ((U → V) × (Y → X)) , (U × Y) , ⊸-cond α β _⊸ₐ_ : {A B C D : Obj} → Hom C A → Hom B D → Hom (A ⊸ₒ B) (C ⊸ₒ D) _⊸ₐ_ {(U , X , α)}{(V , Y , β)}{(W , Z , γ)}{(S , T , δ)} (f , F , p₁) (g , G , p₂) = h , H , p₃ where h : Σ (U → V) (λ x → Y → X) → Σ (W → S) (λ x → T → Z) h (h₁ , h₂) = (λ w → g (h₁ (f w))) , (λ t → F (h₂ (G t))) H : Σ W (λ x → T) → Σ U (λ x → Y) H (w , t) = f w , G t p₃ : {u : Σ (U → V) (λ x → Y → X)} {y : Σ W (λ x → T)} → ⊸-cond α β u (H y) → ⊸-cond γ δ (h u) y p₃ {h₁ , h₂}{w , t} c c' = p₂ (c (p₁ c')) cur : {A B C : Obj} → Hom (A ⊗ₒ B) C → Hom A (B ⊸ₒ C) cur {U , X , α}{V , Y , β}{W , Z , γ} (f , F , p₁) = (λ u → (λ v → f (u , v)) , (λ z → snd (F z) u)) , (λ p → fst (F (snd p)) (fst p)) , cur-cond where cur-cond : ∀{u : U}{y : Σ V (λ x → Z)} → α u (fst (F (snd y)) (fst y)) → ⊸-cond β γ ((λ v → f (u , v)) , (λ z → snd (F z) u)) y cur-cond {u}{v , z} p₂ p₃ with p₁ {u , v}{z} ... | p₁' with F z ... | (j₁ , j₂) = p₁' (p₂ , p₃) cur-≡h : ∀{A B C}{f₁ f₂ : Hom (A ⊗ₒ B) C} → f₁ ≡h f₂ → cur f₁ ≡h cur f₂ cur-≡h {U , X , α}{V , Y , β}{W , Z , γ} {f₁ , F₁ , p₁}{f₂ , F₂ , p₂} (p₃ , p₄) rewrite p₃ | p₄ = refl , refl cur-cong : ∀{A B C}{f₁ f₂ : Hom (A ⊗ₒ B) C} → f₁ ≡h f₂ → cur f₁ ≡h cur f₂ cur-cong {(U , X , α)} {(V , Y , β)} {(W , Z , γ)}{f₁ , F₁ , _}{f₂ , F₂ , _} (p₁ , p₂) rewrite p₁ | p₂ = refl , refl uncur : {A B C : Obj} → Hom A (B ⊸ₒ C) → Hom (A ⊗ₒ B) C uncur {U , X , α}{V , Y , β}{W , Z , γ} (f , F , p₁) = (λ p → fst (f (fst p)) (snd p)) , (λ z → (λ v → F (v , z)) , (λ u → snd (f u) z)) , uncur-cond where uncur-cond : ∀{u : Σ U (λ x → V)} {y : Z} → (α ⊗ᵣ β) u ((λ v → F (v , y)) , (λ u₁ → snd (f u₁) y)) → γ (fst (f (fst u)) (snd u)) y uncur-cond {u , v}{z} (p₂ , p₃) with p₁ {u}{v , z} p₂ ... | p₁' with f u ... | (j₁ , j₂) = p₁' p₃ cur-uncur-bij₁ : ∀{A B C}{f : Hom (A ⊗ₒ B) C} → uncur (cur f) ≡h f cur-uncur-bij₁ {U , X , α}{V , Y , β}{W , Z , γ}{f , F , p₁} = ext-set aux₁ , ext-set aux₂ where aux₁ : {a : Σ U (λ x → V)} → f (fst a , snd a) ≡ f a aux₁ {u , v} = refl aux₂ : {a : Z} → ((λ v → fst (F a) v) , (λ u → snd (F a) u)) ≡ F a aux₂ {z} with F z ... | j₁ , j₂ = refl cur-uncur-bij₂ : ∀{A B C}{g : Hom A (B ⊸ₒ C)} → cur (uncur g) ≡h g cur-uncur-bij₂ {U , X , α}{V , Y , β}{W , Z , γ}{g , G , p₁} = ext-set aux₁ , ext-set aux₂ where aux₁ : {a : U} → ((λ v → fst (g a) v) , (λ z → snd (g a) z)) ≡ g a aux₁ {u} with g u ... | (j₁ , j₂) = refl aux₂ : {a : Σ V (λ x → Z)} → G (fst a , snd a) ≡ G a aux₂ {v , z} = refl -- The of-course exponential: !ₒ-cond : ∀{U X : Set} → (U → X → Set) → U → (U → X *) → Set !ₒ-cond α u f = all-pred (α u) (f u) !ₒ : Obj → Obj !ₒ (U , X , α) = U , (U → X *) , !ₒ-cond α !-cta : {V Y U X : Set} → (Y → X) → (U → V) → (V → Y *) → (U → X *) !-cta F f g = λ u → list-funct F (g (f u)) !ₐ-cond : ∀{U V Y X : Set}{F : Y → X}{f : U → V} → (α : U → X → Set) → (β : V → Y → Set) → (p : {u : U} {y : Y} → α u (F y) → β (f u) y) {u : U}{l : Y *} → all-pred (α u) (list-funct F l) → all-pred (β (f u)) l !ₐ-cond _ _ _ {l = []} _ = triv !ₐ-cond α β p {u}{x :: xs} (p' , p'') = p p' , !ₐ-cond α β p p'' !ₐ : {A B : Obj} → Hom A B → Hom (!ₒ A) (!ₒ B) !ₐ {U , X , α}{V , Y , β} (f , F , p) = f , !-cta F f , !ₐ-cond α β p -- Of-course is a comonad: ε : ∀{A} → Hom (!ₒ A) A ε {U , X , α} = id-set , (λ x y → [ x ]) , fst δ-cta : {U X : Set} → (U → 𝕃 (U → 𝕃 X)) → U → 𝕃 X δ-cta g u = foldr (λ f rest → (f u) ++ rest) [] (g u) δ : ∀{A} → Hom (!ₒ A) (!ₒ (!ₒ A)) δ {U , X , α} = id-set , δ-cta , δ-cond where δ-cond : {u : U} {l : 𝕃 (U → 𝕃 X)} → all-pred (α u) (foldr (λ f → _++_ (f u)) [] l) → all-pred (λ f → all-pred (α u) (f u)) l δ-cond {l = []} _ = triv δ-cond {u}{l = x :: l'} p with all-pred-append {X}{α u} {x u} {foldr (λ f → _++_ (f u)) [] l'} ∧-unit ∧-assoc ... | p' rewrite p' = fst p , δ-cond {u} {l'} (snd p) -- These diagrams can be found on page 22 of the report. {- comonand-diag₁ : ∀{A} → (δ {A}) ○ (!ₐ (δ {A})) ≡h (δ {A}) ○ (δ { !ₒ A}) comonand-diag₁ {U , X , α} = refl , ext-set (λ {a} → ext-set (λ {a₁} → aux {a₁}{a a₁})) where aux : ∀{a₁ : U}{l : 𝕃 (U → 𝕃 (U → 𝕃 X))} → foldr (λ f → _++_ (f a₁)) [] (map (λ g u → foldr (λ f → _++_ (f u)) [] (g u)) l) ≡ foldr (λ f → _++_ (f a₁)) [] (foldr (λ f → _++_ (f a₁)) [] l) aux {a}{[]} = refl aux {a}{x :: l} rewrite sym (foldr-append {l₁ = x a}{foldr (λ f → _++_ (f a)) [] l}{a}) = cong2 {a = foldr (λ f → _++_ (f a)) [] (x a)} _++_ refl (aux {a}{l}) comonand-diag₂ : ∀{A} → (δ {A}) ○ (ε { !ₒ A}) ≡h (δ {A}) ○ (!ₐ (ε {A})) comonand-diag₂ {U , X , α} = refl , ext-set (λ {f} → ext-set (λ {a} → aux {a}{f a})) where aux : ∀{a : U}{l : X *} → l ++ [] ≡ foldr (λ f₁ → _++_ (f₁ a)) [] (map (λ x y → x :: []) l) aux {a}{[]} = refl aux {a}{x :: l} with aux {a}{l} ... | IH rewrite ++[] l = cong2 {a = x} {x} {l} {foldr (λ f₁ → _++_ (f₁ a)) [] (map (λ x₁ y → x₁ :: []) l)} _::_ refl IH -} module Cartesian where π₁ : {U X V Y : Set} → {α : U → X → Set} → {β : V → Y → Set} → Hom ((!ₒ (U , X , α)) ⊗ₒ (!ₒ (V , Y , β))) (!ₒ (U , X , α)) π₁ {U}{X}{V}{Y}{α}{β} = fst , (λ f → (λ v u → f u) , (λ u v → [])) , π₁-cond where π₁-cond : ∀{u : Σ U (λ x → V)} {y : U → 𝕃 X} → ((λ u₁ f → all-pred (α u₁) (f u₁)) ⊗ᵣ (λ u₁ f → all-pred (β u₁) (f u₁))) u ((λ v u₁ → y u₁) , (λ u₁ v → [])) → all-pred (α (fst u)) (y (fst u)) π₁-cond {u , v}{f} (p₁ , p₂) = p₁ π₂ : {U X V Y : Set} → {α : U → X → Set} → {β : V → Y → Set} → Hom ((!ₒ (U , X , α)) ⊗ₒ (!ₒ (V , Y , β))) (!ₒ (V , Y , β)) π₂ {U}{X}{V}{Y}{α}{β} = snd , (λ f → (λ v u → []) , (λ u v → f v)) , π₂-cond where π₂-cond : ∀{u : Σ U (λ x → V)} {y : V → 𝕃 Y} → ((λ u₁ f → all-pred (α u₁) (f u₁)) ⊗ᵣ (λ u₁ f → all-pred (β u₁) (f u₁))) u ((λ v u₁ → []) , (λ u₁ v → y v)) → all-pred (β (snd u)) (y (snd u)) π₂-cond {u , v}{f} (p₁ , p₂) = p₂ cart-ar-crt : {U X V Y W Z : Set} → {α : U → X → Set} → {β : V → Y → Set} → {γ : W → Z → Set} → Hom (!ₒ (W , Z , γ)) (!ₒ (U , X , α)) → Hom (!ₒ (W , Z , γ)) (!ₒ (V , Y , β)) → Σ (V → U → 𝕃 X) (λ x → U → V → 𝕃 Y) → W → 𝕃 Z cart-ar-crt (f , F , p₁) (g , G , p₂) (j₁ , j₂) w = F (j₁ (g w)) w ++ G (j₂ (f w)) w cart-ar : {U X V Y W Z : Set} → {α : U → X → Set} → {β : V → Y → Set} → {γ : W → Z → Set} → Hom (!ₒ (W , Z , γ)) (!ₒ (U , X , α)) → Hom (!ₒ (W , Z , γ)) (!ₒ (V , Y , β)) → Hom (!ₒ (W , Z , γ)) ((!ₒ (U , X , α)) ⊗ₒ (!ₒ (V , Y , β))) cart-ar {U}{X}{V}{Y}{W}{Z}{α}{β}{γ} (f , F , p₁) (g , G , p₂) = (λ w → f w , g w) , cart-ar-crt {α = α}{β} (f , F , p₁) (g , G , p₂) , cart-ar-cond where cart-ar-cond : ∀{u : W} {y : Σ (V → U → 𝕃 X) (λ x → U → V → 𝕃 Y)} → all-pred (γ u) (cart-ar-crt {α = α}{β} (f , F , p₁) (g , G , p₂) y u) → ((λ u₁ f₁ → all-pred (α u₁) (f₁ u₁)) ⊗ᵣ (λ u₁ f₁ → all-pred (β u₁) (f₁ u₁))) (f u , g u) y cart-ar-cond {w}{j₁ , j₂} p rewrite all-pred-append {f = γ w}{F (j₁ (g w)) w}{G (j₂ (f w)) w} ∧-unit ∧-assoc with p ... | (a , b) = p₁ a , p₂ b cart-diag₁ : {U X V Y W Z : Set} → {α : U → X → Set} → {β : V → Y → Set} → {γ : W → Z → Set} → {f : Hom (W , Z , γ) (U , X , α)} → {g : Hom (W , Z , γ) (V , Y , β)} → _≡h_ { !ₒ (W , Z , γ)}{ !ₒ (U , X , α)} (!ₐ {W , Z , γ}{U , X , α} f) (comp { !ₒ (W , Z , γ)} {((!ₒ (U , X , α)) ⊗ₒ (!ₒ (V , Y , β)))} { !ₒ (U , X , α)} (cart-ar {α = α}{β}{γ} (!ₐ {W , Z , γ}{U , X , α} f) (!ₐ {W , Z , γ}{V , Y , β} g)) π₁) cart-diag₁ {f = f , F , p₁}{g , G , p₂} = refl , ext-set (λ {j} → ext-set (λ {w} → sym (++[] (map F (j (f w)))))) cart-diag₂ : {U X V Y W Z : Set} → {α : U → X → Set} → {β : V → Y → Set} → {γ : W → Z → Set} → {f : Hom (W , Z , γ) (U , X , α)} → {g : Hom (W , Z , γ) (V , Y , β)} → _≡h_ { !ₒ (W , Z , γ)}{ !ₒ (V , Y , β)} (!ₐ {W , Z , γ}{V , Y , β} g) (comp { !ₒ (W , Z , γ)} {((!ₒ (U , X , α)) ⊗ₒ (!ₒ (V , Y , β)))} { !ₒ (V , Y , β)} (cart-ar {α = α}{β}{γ} (!ₐ {W , Z , γ}{U , X , α} f) (!ₐ {W , Z , γ}{V , Y , β} g)) π₂) cart-diag₂ {f = f , F , p₁}{g , G , p₂} = refl , ext-set (λ {j} → ext-set (λ {w} → refl))
{ "alphanum_fraction": 0.3625483985, "avg_line_length": 37.5462555066, "ext": "agda", "hexsha": "ffea21277b076f74835e77b8ce6e57939c60cfd0", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "b33c6a59d664aed46cac8ef77d34313e148fecc2", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "heades/AUGL", "max_forks_repo_path": "dialectica-cats/Dial2Sets.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "b33c6a59d664aed46cac8ef77d34313e148fecc2", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "heades/AUGL", "max_issues_repo_path": "dialectica-cats/Dial2Sets.agda", "max_line_length": 142, "max_stars_count": null, "max_stars_repo_head_hexsha": "b33c6a59d664aed46cac8ef77d34313e148fecc2", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "heades/AUGL", "max_stars_repo_path": "dialectica-cats/Dial2Sets.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 8747, "size": 17046 }