Search is not available for this dataset
text
string
meta
dict
{-# OPTIONS --without-K #-} module CPermCat where open import Level using (zero) open import Data.Nat using (ℕ; _+_; _*_) open import Data.Fin using () renaming (zero to 0F) open import Data.Product using (_,_; uncurry) import Relation.Binary.PropositionalEquality as P using (_≡_; refl; sym; cong₂; isEquivalence) open import Categories.Category using (Category) open import Categories.Groupoid using (Groupoid) open import Categories.Monoidal using (Monoidal) open import Categories.Monoidal.Helpers using (module MonoidalHelperFunctors) open import Categories.Bifunctor using (Bifunctor) open import Categories.NaturalIsomorphism using (NaturalIsomorphism) open import Categories.Monoidal.Braided using (Braided) open import Categories.Monoidal.Symmetric using (Symmetric) open import Categories.RigCategory using (RigCategory; module BimonoidalHelperFunctors) -- open import ConcretePermutation using (CPerm) open import Permutation using (idp; symp; _●p_; _⊎p_; _×p_) open import PermutationProperties using (assocp; lidp; ridp; rinv; linv; 1p⊎1p≡1p; ⊎p●p≡●p⊎p) ------------------------------------------------------------------------------ -- CPerm is is a category -- Permutations can be compared by strict propositional equality CPermCat : Category zero zero zero CPermCat = record { Obj = ℕ ; _⇒_ = CPerm ; _≡_ = P._≡_ ; id = idp ; _∘_ = _●p_ ; assoc = λ {_} {_} {_} {_} {f} {g} {h} → assocp {p₁ = h} {g} {f} ; identityˡ = lidp ; identityʳ = ridp ; equiv = P.isEquivalence ; ∘-resp-≡ = λ { {_} {_} {_} {f} {.f} {g} {.g} P.refl P.refl → P.refl} } -- ... and a groupoid CPermGroupoid : Groupoid CPermCat CPermGroupoid = record { _⁻¹ = symp ; iso = λ {_} {_} {f} → record { isoˡ = linv f ; isoʳ = rinv f } } -- additive bifunctor and monoidal structure ⊎p-bifunctor : Bifunctor CPermCat CPermCat CPermCat ⊎p-bifunctor = record { F₀ = uncurry _+_ ; F₁ = uncurry _⊎p_ ; identity = 1p⊎1p≡1p -- perhaps the weird order below means the underlying combinators should be fixed? ; homomorphism = λ { {_} {_} {_} {p₁ , p₂} {q₁ , q₂} → ⊎p●p≡●p⊎p {f = q₁} {q₂} {p₁} {p₂}} ; F-resp-≡ = uncurry (P.cong₂ _⊎p_) } -- the 0 below is the id from CPermMonoidal module ⊎h = MonoidalHelperFunctors CPermCat ⊎p-bifunctor 0 {- these are all commented out because unite+p and companions are no longer defined! 0⊕x≡x : NaturalIsomorphism ⊎h.id⊗x ⊎h.x 0⊕x≡x = record { F⇒G = record { η = λ _ → unite+p ; commute = λ f → unite+p∘[0⊎x]≡x∘unite+p (f 0F) } ; F⇐G = record { η = λ _ → uniti+p ; commute = λ f → uniti+p∘x≡[0⊎x]∘uniti+p (f 0F) } ; iso = λ X → record { isoˡ = linv uniti+p ; isoʳ = linv unite+p } } x⊕0≡x : NaturalIsomorphism ⊎h.x⊗id ⊎h.x x⊕0≡x = record { F⇒G = record { η = λ _ → uniti+rp ; commute = λ f → uniti+rp∘[x⊎0]≡x∘uniti+rp (f 0F) } ; F⇐G = record { η = λ _ → unite+rp ; commute = λ f → unite+rp∘[x⊎0]≡x∘unite+rp (f 0F) } ; iso = λ X → record { isoˡ = linv unite+rp ; isoʳ = linv uniti+rp } } -} {-- [x⊕y]⊕z≡x⊕[y⊕z] : NaturalIsomorphism ⊎h.[x⊗y]⊗z ⊎h.x⊗[y⊗z] [x⊕y]⊕z≡x⊕[y⊕z] = record { F⇒G = record { η = {!!} ; commute = {!!} } ; F⇐G = record { η = {!!} ; commute = {!!} } ; iso = λ X → record { isoˡ = {!!} ; isoʳ = {!!} } } -- and a monoidal category (additive) M⊕ : Monoidal CPermCat M⊕ = record { ⊗ = ⊎p-bifunctor ; id = 0 ; identityˡ = 0⊕x≡x ; identityʳ = x⊕0≡x ; assoc = [x⊕y]⊕z≡x⊕[y⊕z] ; triangle = {!!} ; pentagon = {!!} } -- multiplicative bifunctor and monoidal structure ×p-bifunctor : Bifunctor CPermCat CPermCat CPermCat ×p-bifunctor = record { F₀ = λ { (m , n) → m * n} ; F₁ = λ { (p₁ , p₂) → p₁ ×p p₂ } ; identity = λ { {m , n} → 1p×1p≡1p {m} } ; homomorphism = λ { {_} {_} {_} {p₁ , p₂} {q₁ , q₂} → ×p-distrib {p₁ = q₁} {q₂} {p₁} {p₂}} ; F-resp-≡ = λ {(p₁≡p₃ , p₂≡p₄) → P.cong₂ _×p_ p₁≡p₃ p₂≡p₄ } } module ×h = MonoidalHelperFunctors CPermCat ×p-bifunctor 1 1⊗x≡x : NaturalIsomorphism ×h.id⊗x ×h.x 1⊗x≡x = record { F⇒G = record { η = {!!} ; commute = {!!} } ; F⇐G = record { η = {!!} ; commute = {!!} } ; iso = λ X → record { isoˡ = {!!} ; isoʳ = {!!} } } x⊗1≡x : NaturalIsomorphism ×h.x⊗id ×h.x x⊗1≡x = record { F⇒G = record { η = {!!} ; commute = {!!} } ; F⇐G = record { η = {!!} ; commute = {!!} } ; iso = λ X → record { isoˡ = {!!} ; isoʳ = {!!} } } [x⊗y]⊗z≡x⊗[y⊗z] : NaturalIsomorphism ×h.[x⊗y]⊗z ×h.x⊗[y⊗z] [x⊗y]⊗z≡x⊗[y⊗z] = record { F⇒G = record { η = {!!} ; commute = {!!} } ; F⇐G = record { η = {!!} ; commute = {!!} } ; iso = λ X → record { isoˡ = {!!} ; isoʳ = {!!} } } -- and a monoidal category (multiplicative) M⊗ : Monoidal CPermCat M⊗ = record { ⊗ = ×p-bifunctor ; id = 1 ; identityˡ = 1⊗x≡x ; identityʳ = x⊗1≡x ; assoc = [x⊗y]⊗z≡x⊗[y⊗z] ; triangle = {!!} ; pentagon = {!!} } x⊕y≡y⊕x : NaturalIsomorphism ⊎h.x⊗y ⊎h.y⊗x x⊕y≡y⊕x = record { F⇒G = record { η = {!!} ; commute = {!!} } ; F⇐G = record { η = {!!} ; commute = {!!} } ; iso = λ X → record { isoˡ = {!!} ; isoʳ = {!!} } } BM⊕ : Braided M⊕ BM⊕ = record { braid = x⊕y≡y⊕x ; hexagon₁ = {!!} ; hexagon₂ = {!!} } x⊗y≡y⊗x : NaturalIsomorphism ×h.x⊗y ×h.y⊗x x⊗y≡y⊗x = record { F⇒G = record { η = {!!} ; commute = {!!} } ; F⇐G = record { η = {!!} ; commute = {!!} } ; iso = λ X → record { isoˡ = {!!} ; isoʳ = {!!} } } BM⊗ : Braided M⊗ BM⊗ = record { braid = x⊗y≡y⊗x ; hexagon₁ = {!!} ; hexagon₂ = {!!} } -- with both monoidal structures being symmetric SBM⊕ : Symmetric BM⊕ SBM⊕ = record { symmetry = {!!} } SBM⊗ : Symmetric BM⊗ SBM⊗ = record { symmetry = {!!} } module r = BimonoidalHelperFunctors BM⊕ BM⊗ x⊗0≡0 : NaturalIsomorphism r.x⊗0 r.0↑ x⊗0≡0 = record { F⇒G = record { η = {!!} ; commute = {!!} } ; F⇐G = record { η = {!!} ; commute = {!!} } ; iso = λ X → record { isoˡ = {!!} ; isoʳ = {!!} } } 0⊗x≡0 : NaturalIsomorphism r.0⊗x r.0↑ 0⊗x≡0 = record { F⇒G = record { η = {!!} ; commute = {!!} } ; F⇐G = record { η = {!!} ; commute = {!!} } ; iso = λ X → record { isoˡ = {!!} ; isoʳ = {!!} } } x⊗[y⊕z]≡[x⊗y]⊕[x⊗z] : NaturalIsomorphism r.x⊗[y⊕z] r.[x⊗y]⊕[x⊗z] x⊗[y⊕z]≡[x⊗y]⊕[x⊗z] = record { F⇒G = record { η = {!!} ; commute = {!!} } ; F⇐G = record { η = {!!} ; commute = {!!} } ; iso = λ X → record { isoˡ = {!!} ; isoʳ = {!!} } } [x⊕y]⊗z≡[x⊗z]⊕[y⊗z] : NaturalIsomorphism r.[x⊕y]⊗z r.[x⊗z]⊕[y⊗z] [x⊕y]⊗z≡[x⊗z]⊕[y⊗z] = record { F⇒G = record { η = {!!} ; commute = {!!} } ; F⇐G = record { η = {!!} ; commute = {!!} } ; iso = λ X → record { isoˡ = {!!} ; isoʳ = {!!} } } -- and the multiplicative structure distributing over the additive one Pi1Rig : RigCategory SBM⊕ SBM⊗ Pi1Rig = record { distribₗ = x⊗[y⊕z]≡[x⊗y]⊕[x⊗z] ; distribᵣ = [x⊕y]⊗z≡[x⊗z]⊕[y⊗z] ; annₗ = 0⊗x≡0 ; annᵣ = x⊗0≡0 ; laplazaI = {!!} ; laplazaII = {!!} ; laplazaIV = {!!} ; laplazaVI = {!!} ; laplazaIX = {!!} ; laplazaX = {!!} ; laplazaXI = {!!} ; laplazaXIII = {!!} ; laplazaXV = {!!} ; laplazaXVI = {!!} ; laplazaXVII = {!!} ; laplazaXIX = {!!} ; laplazaXXIII = {!!} } --} ------------------------------------------------------------------------------
{ "alphanum_fraction": 0.5191680261, "avg_line_length": 25.7202797203, "ext": "agda", "hexsha": "f4008d65f6bf7a5a68a7b7e94eac344f228f167e", "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/CPermCat.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/CPermCat.agda", "max_line_length": 91, "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/CPermCat.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": 3398, "size": 7356 }
open import Common.Prelude hiding (_>>=_) open import Common.Reflection open import Common.Equality record Functor (F : Set → Set) : Set₁ where field fmap : ∀ {A B} → (A → B) → F A → F B IdF : Functor (λ A → A) unquoteDef IdF = defineFun IdF (clause (vArg (projP (quote Functor.fmap)) ∷ vArg (var "f") ∷ vArg (var "x") ∷ []) (var 1 (vArg (var 0 []) ∷ [])) ∷ []) check : ∀ {A B} (f : A → B) (x : A) → Functor.fmap IdF f x ≡ f x check f x = refl open Functor {{...}} instance InstF : Functor (λ A → A) unquoteDef InstF = defineFun InstF (clause (iArg (projP (quote fmap)) ∷ vArg (var "f") ∷ vArg (var "x") ∷ []) (var 1 (vArg (var 0 []) ∷ [])) ∷ []) check₁ : ∀ {A B} (f : A → B) (x : A) → fmap f x ≡ f x check₁ f x = refl
{ "alphanum_fraction": 0.5194968553, "avg_line_length": 27.4137931034, "ext": "agda", "hexsha": "facc12d00ab687d1a30a80c8e9aef1a6d6be7dc6", "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": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_path": "test/Succeed/ReflectionCopatterns.agda", "max_issues_count": 3, "max_issues_repo_head_hexsha": "aac88412199dd4cbcb041aab499d8a6b7e3f4a2e", "max_issues_repo_issues_event_max_datetime": "2019-04-01T19:39:26.000Z", "max_issues_repo_issues_event_min_datetime": "2018-11-14T15:31:44.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "hborum/agda", "max_issues_repo_path": "test/Succeed/ReflectionCopatterns.agda", "max_line_length": 98, "max_stars_count": 3, "max_stars_repo_head_hexsha": "aac88412199dd4cbcb041aab499d8a6b7e3f4a2e", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "hborum/agda", "max_stars_repo_path": "test/Succeed/ReflectionCopatterns.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": 293, "size": 795 }
{-# OPTIONS --without-K --safe #-} open import Categories.Category.Core module Categories.Morphism.Regular.Properties {o ℓ e} (𝒞 : Category o ℓ e) where open import Categories.Morphism 𝒞 open import Categories.Morphism.Regular 𝒞 open import Categories.Diagram.Equalizer 𝒞 open import Categories.Diagram.Equalizer.Properties 𝒞 open import Categories.Diagram.Coequalizer.Properties 𝒞 open Category 𝒞 private variable A B : Obj f g : A ⇒ B Section⇒RegularMono : f SectionOf g → RegularMono f Section⇒RegularMono {f = f} {g = g} g∘f≈id = record { g = id ; h = f ∘ g ; equalizer = section-equalizer g∘f≈id } Retract⇒RegularEpi : f RetractOf g → RegularEpi f Retract⇒RegularEpi {f = f} {g = g} f∘g≈id = record { h = g ∘ f ; g = id ; coequalizer = retract-coequalizer f∘g≈id }
{ "alphanum_fraction": 0.702366127, "avg_line_length": 24.3333333333, "ext": "agda", "hexsha": "38e485ca67430844f1bbac66f265ded754615c85", "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": "8f3c844d929508040dfa21f681fa260056214b73", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "maxsnew/agda-categories", "max_forks_repo_path": "src/Categories/Morphism/Regular/Properties.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "8f3c844d929508040dfa21f681fa260056214b73", "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": "maxsnew/agda-categories", "max_issues_repo_path": "src/Categories/Morphism/Regular/Properties.agda", "max_line_length": 80, "max_stars_count": null, "max_stars_repo_head_hexsha": "8f3c844d929508040dfa21f681fa260056214b73", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "maxsnew/agda-categories", "max_stars_repo_path": "src/Categories/Morphism/Regular/Properties.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 282, "size": 803 }
module Categories.Monad.Algebra where
{ "alphanum_fraction": 0.8684210526, "avg_line_length": 19, "ext": "agda", "hexsha": "ccd04907407df7bae1ebe0ec905711ce5b9b233b", "lang": "Agda", "max_forks_count": 23, "max_forks_repo_forks_event_max_datetime": "2021-11-11T13:50:56.000Z", "max_forks_repo_forks_event_min_datetime": "2015-02-05T13:03:09.000Z", "max_forks_repo_head_hexsha": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "p-pavel/categories", "max_forks_repo_path": "Categories/Monad/Algebra.agda", "max_issues_count": 19, "max_issues_repo_head_hexsha": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2", "max_issues_repo_issues_event_max_datetime": "2019-08-09T16:31:40.000Z", "max_issues_repo_issues_event_min_datetime": "2015-05-23T06:47:10.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "p-pavel/categories", "max_issues_repo_path": "Categories/Monad/Algebra.agda", "max_line_length": 37, "max_stars_count": 98, "max_stars_repo_head_hexsha": "36f4181d751e2ecb54db219911d8c69afe8ba892", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "copumpkin/categories", "max_stars_repo_path": "Categories/Monad/Algebra.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-08T05:20:36.000Z", "max_stars_repo_stars_event_min_datetime": "2015-04-15T14:57:33.000Z", "num_tokens": 7, "size": 38 }
{-# OPTIONS --without-K --rewriting #-} open import HoTT open import homotopy.PtdAdjoint open import groups.FromSusp open import groups.ToOmega module groups.SuspAdjointLoop {i} where import homotopy.SuspAdjointLoop {i} as A module _ (X Y : Ptd i) where private pres-comp : preserves-comp (GroupStructure.comp (⊙→Ω-group-structure (⊙Susp X) Y)) (GroupStructure.comp (⊙→Ω-group-structure X (⊙Ω Y))) (–> (A.eq X (⊙Ω Y))) abstract pres-comp h₁ h₂ = B.nat-cod h₁ h₂ ⊙Ω-∙ ∙ ap (_⊙∘ ⊙fanout (–> (A.eq X (⊙Ω Y)) h₁) (–> (A.eq X (⊙Ω Y)) h₂)) arr2-lemma where module A× = RightAdjoint× A.hadj module B = RightAdjointBinary A.hadj ap2-lemma : ∀ {i j k} {A : Type i} {B : Type j} {C : Type k} (f : A × B → C) {r s : A × B} (p : r == s) → ap f p == ap2 (curry f) (ap fst p) (ap snd p) ap2-lemma f idp = idp ⊙ap2-lemma : ∀ {i j k} {X : Ptd i} {Y : Ptd j} {Z : Ptd k} (f : X ⊙× Y ⊙→ Z) → ⊙Ω-fmap f == ⊙Ω-fmap2 f ⊙∘ ⊙fanout (⊙Ω-fmap ⊙fst) (⊙Ω-fmap ⊙snd) ⊙ap2-lemma (f , idp) = ⊙λ=' (ap2-lemma f) idp arr2-lemma : B.arr2 ⊙Ω-∙ == ⊙Ω-∙ arr2-lemma = ⊙Ω-fmap ⊙Ω-∙ ⊙∘ A×.⊙out _ _ =⟨ ⊙ap2-lemma ⊙Ω-∙ |in-ctx _⊙∘ A×.⊙out _ _ ⟩ (⊙Ω-fmap2 ⊙Ω-∙ ⊙∘ A×.⊙into _ _) ⊙∘ A×.⊙out _ _ =⟨ ⊙λ= $ ⊙∘-assoc (⊙Ω-fmap2 ⊙Ω-∙) (A×.⊙into _ _) (A×.⊙out _ _) ⟩ ⊙Ω-fmap2 ⊙Ω-∙ ⊙∘ (A×.⊙into _ _ ⊙∘ A×.⊙out _ _) =⟨ A×.⊙into-out _ _ |in-ctx ⊙Ω-fmap2 ⊙Ω-∙ ⊙∘_ ⟩ ⊙Ω-fmap2 ⊙Ω-∙ =⟨ ⊙Ω-fmap2-∙ ⟩ ⊙Ω-∙ ∎ ⊙→Ω-iso-⊙→Ω : ⊙→Ω-group-structure (⊙Susp X) Y ≃ᴳˢ ⊙→Ω-group-structure X (⊙Ω Y) ⊙→Ω-iso-⊙→Ω = ≃-to-≃ᴳˢ (A.eq X (⊙Ω Y)) pres-comp Trunc-⊙→Ω-iso-Trunc-⊙→Ω : Trunc-⊙→Ω-group (⊙Susp X) Y ≃ᴳ Trunc-⊙→Ω-group X (⊙Ω Y) Trunc-⊙→Ω-iso-Trunc-⊙→Ω = Trunc-group-emap ⊙→Ω-iso-⊙→Ω abstract Trunc-⊙→Ω-iso-Trunc-⊙→Ω-nat-dom : {X Y : Ptd i} (f : X ⊙→ Y) (Z : Ptd i) → fst (Trunc-⊙→Ω-iso-Trunc-⊙→Ω X Z) ∘ᴳ Trunc-⊙→Ω-group-fmap-dom (⊙Susp-fmap f) Z == Trunc-⊙→Ω-group-fmap-dom f (⊙Ω Z) ∘ᴳ fst (Trunc-⊙→Ω-iso-Trunc-⊙→Ω Y Z) Trunc-⊙→Ω-iso-Trunc-⊙→Ω-nat-dom f Z = group-hom= $ λ= $ Trunc-elim (λ g → ap [_] (! (A.nat-dom f (⊙Ω Z) g))) module _ (X Y : Ptd i) where private pres-comp'' : ∀ h₀ h₁ → fst (<– (A.eq X Y) (GroupStructure.comp (⊙→Ω-group-structure X Y) (–> (A.eq X Y) h₀) (–> (A.eq X Y) h₁))) ∼ fst (GroupStructure.comp (Susp⊙→-group-structure X Y) h₀ h₁) abstract pres-comp'' (h₀ , idp) (h₁ , h₁-pt) = Susp-elim idp (! h₁-pt ∙ ap h₁ (merid (pt X))) (λ x → ↓-='-in' $ ap (fst (⊙Wedge-rec (h₀ , idp) (h₁ , h₁-pt)) ∘ pinch X) (merid x) =⟨ ap-∘ (fst (⊙Wedge-rec (h₀ , idp) (h₁ , h₁-pt))) (pinch X) (merid x) ⟩ ap (fst (⊙Wedge-rec (h₀ , idp) (h₁ , h₁-pt))) (ap (pinch X) (merid x)) =⟨ ap (ap (fst (⊙Wedge-rec (h₀ , idp) (h₁ , h₁-pt)))) (Pinch.merid-β X x) ⟩ ap (fst (⊙Wedge-rec (h₀ , idp) (h₁ , h₁-pt))) (ap winl (σloop X x) ∙ wglue ∙ ap winr (merid x)) =⟨ ap-∙∙ (fst (⊙Wedge-rec (h₀ , idp) (h₁ , h₁-pt))) (ap winl (σloop X x)) wglue (ap winr (merid x)) ⟩ ap (fst (⊙Wedge-rec (h₀ , idp) (h₁ , h₁-pt))) (ap winl (σloop X x)) ∙ ap (fst (⊙Wedge-rec (h₀ , idp) (h₁ , h₁-pt))) wglue ∙ ap (fst (⊙Wedge-rec (h₀ , idp) (h₁ , h₁-pt))) (ap winr (merid x)) =⟨ ap3 (λ p q r → p ∙ q ∙ r) (∘-ap (fst (⊙Wedge-rec (h₀ , idp) (h₁ , h₁-pt))) winl (σloop X x)) (⊙WedgeRec.glue-β (h₀ , idp) (h₁ , h₁-pt)) (∘-ap (fst (⊙Wedge-rec (h₀ , idp) (h₁ , h₁-pt))) winr (merid x)) ⟩ ap h₀ (σloop X x) ∙ ! h₁-pt ∙ ap h₁ (merid x) =⟨ lemma h₁ (ap h₀ (σloop X x)) h₁-pt (merid x) (merid (pt X)) h₁-pt ⟩ (ap h₀ (σloop X x) ∙ (! h₁-pt ∙ ap h₁ (σloop X x) ∙' h₁-pt)) ∙' (! h₁-pt ∙ ap h₁ (merid (pt X))) =⟨ ap (λ p → p ∙' (! h₁-pt ∙ ap h₁ (merid (pt X)))) $ ap h₀ (σloop X x) ∙ (! h₁-pt ∙ ap h₁ (σloop X x) ∙' h₁-pt) =⟨ ! $ ap (ap h₀ (σloop X x) ∙_) (Ω-fmap-β (h₁ , h₁-pt) (σloop X x)) ⟩ ap h₀ (σloop X x) ∙ Ω-fmap (h₁ , h₁-pt) (σloop X x) =⟨ ! $ A.Eta.merid-β Y (ap h₀ (σloop X x) ∙ Ω-fmap (h₁ , h₁-pt) (σloop X x)) ⟩ ap (fst (A.ε Y)) (merid (ap h₀ (σloop X x) ∙ Ω-fmap (h₁ , h₁-pt) (σloop X x))) =⟨ ! $ ap (ap (fst (A.ε Y))) (SuspFmap.merid-β (λ x → ap h₀ (σloop X x) ∙ Ω-fmap (h₁ , h₁-pt) (σloop X x)) x) ⟩ ap (fst (A.ε Y)) (ap (Susp-fmap (λ x → ap h₀ (σloop X x) ∙ Ω-fmap (h₁ , h₁-pt) (σloop X x))) (merid x)) =⟨ ∘-ap (fst (A.ε Y)) (Susp-fmap (λ x → ap h₀ (σloop X x) ∙ Ω-fmap (h₁ , h₁-pt) (σloop X x))) (merid x) ⟩ ap (fst (A.ε Y) ∘ Susp-fmap (λ x → ap h₀ (σloop X x) ∙ Ω-fmap (h₁ , h₁-pt) (σloop X x))) (merid x) =∎ ⟩ ap (fst (A.ε Y) ∘ Susp-fmap (λ x → ap h₀ (σloop X x) ∙ Ω-fmap (h₁ , h₁-pt) (σloop X x))) (merid x) ∙' (! h₁-pt ∙ ap h₁ (merid (pt X))) =∎) where lemma : ∀ {i j} {A : Type i} {B : Type j} (f : A → B) {a₀ a₁ a₂ : A} {b₀ b₁ b₂ : B} (p₀ : b₀ == b₁) (p₁ : f a₀ == b₁) (p₂ : a₀ == a₁) (p₃ : a₂ == a₁) (p₄ : f a₂ == b₂) → p₀ ∙ ! p₁ ∙ ap f p₂ == (p₀ ∙ (! p₁ ∙ ap f (p₂ ∙ ! p₃) ∙' p₄)) ∙' (! p₄ ∙ ap f p₃) lemma f idp idp idp idp idp = idp private pres-comp' : ∀ h₀ h₁ → <– (A.eq X Y) (GroupStructure.comp (⊙→Ω-group-structure X Y) (–> (A.eq X Y) h₀) (–> (A.eq X Y) h₁)) ⊙∼ GroupStructure.comp (Susp⊙→-group-structure X Y) h₀ h₁ abstract pres-comp' (h₀ , idp) (h₁ , h₁-pt) = pres-comp'' (h₀ , idp) (h₁ , h₁-pt) , idp private pres-comp : preserves-comp (GroupStructure.comp (Susp⊙→-group-structure X Y)) (GroupStructure.comp (⊙→Ω-group-structure X Y)) (–> (A.eq X Y)) abstract pres-comp h₀ h₁ = –> (A.eq X Y) (GroupStructure.comp (Susp⊙→-group-structure X Y) h₀ h₁) =⟨ ! (ap (–> (A.eq X Y)) (⊙λ= (pres-comp' h₀ h₁))) ⟩ –> (A.eq X Y) (<– (A.eq X Y) (GroupStructure.comp (⊙→Ω-group-structure X Y) (–> (A.eq X Y) h₀) (–> (A.eq X Y) h₁))) =⟨ <–-inv-r (A.eq X Y) (GroupStructure.comp (⊙→Ω-group-structure X Y) (–> (A.eq X Y) h₀) (–> (A.eq X Y) h₁)) ⟩ GroupStructure.comp (⊙→Ω-group-structure X Y) (–> (A.eq X Y) h₀) (–> (A.eq X Y) h₁) =∎ Susp⊙→-iso-⊙→Ω : Susp⊙→-group-structure X Y ≃ᴳˢ ⊙→Ω-group-structure X Y Susp⊙→-iso-⊙→Ω = ≃-to-≃ᴳˢ (A.eq X Y) pres-comp Trunc-Susp⊙→-iso-Trunc-⊙→Ω : Trunc-Susp⊙→-group X Y ≃ᴳ Trunc-⊙→Ω-group X Y Trunc-Susp⊙→-iso-Trunc-⊙→Ω = Trunc-group-emap Susp⊙→-iso-⊙→Ω module _ (X Y : Ptd i) where private pres-comp : preserves-comp (GroupStructure.comp (Susp⊙→-group-structure X Y)) (GroupStructure.comp (Susp⊙→-group-structure (⊙Susp X) (⊙Susp Y))) (⊙Susp-fmap :> ((⊙Susp X ⊙→ Y) → _)) abstract pres-comp = ∼-preserves-preserves-comp (GroupStructure.comp (Susp⊙→-group-structure X Y)) (GroupStructure.comp (Susp⊙→-group-structure (⊙Susp X) (⊙Susp Y))) (λ f → <– (A.eq (⊙Susp X) (⊙Susp Y)) (<– (A.eq X (⊙Ω (⊙Susp Y))) (⊙Ω-fmap (A.η Y) ⊙∘ –> (A.eq X Y) f)) =⟨ ap (<– (A.eq (⊙Susp X) (⊙Susp Y)) ∘ <– (A.eq X (⊙Ω (⊙Susp Y)))) $ A.nat-cod X (A.η Y) f ⟩ <– (A.eq (⊙Susp X) (⊙Susp Y)) (<– (A.eq X (⊙Ω (⊙Susp Y))) (–> (A.eq X (⊙Ω (⊙Susp Y))) (A.η Y ⊙∘ f))) =⟨ ap (<– (A.eq (⊙Susp X) (⊙Susp Y))) $ <–-inv-l (A.eq X (⊙Ω (⊙Susp Y))) (A.η Y ⊙∘ f) ⟩ <– (A.eq (⊙Susp X) (⊙Susp Y)) (A.η Y ⊙∘ f) =⟨ ap (<– (A.eq (⊙Susp X) (⊙Susp Y))) $ A.η-natural f ⟩ <– (A.eq (⊙Susp X) (⊙Susp Y)) (–> (A.eq (⊙Susp X) (⊙Susp Y)) (⊙Susp-fmap f)) =⟨ <–-inv-l (A.eq (⊙Susp X) (⊙Susp Y)) (⊙Susp-fmap f) ⟩ ⊙Susp-fmap f =∎) (GroupStructureHom.pres-comp $ GroupStructureIso.g-shom (Susp⊙→-iso-⊙→Ω (⊙Susp X) (⊙Susp Y)) ∘ᴳˢ GroupStructureIso.g-shom (⊙→Ω-iso-⊙→Ω X (⊙Susp Y)) ∘ᴳˢ ⊙→Ω-group-structure-fmap-codom X (A.η Y) ∘ᴳˢ GroupStructureIso.f-shom (Susp⊙→-iso-⊙→Ω X Y)) Susp⊙→-Susp-fmap-shom : Susp⊙→-group-structure X Y →ᴳˢ Susp⊙→-group-structure (⊙Susp X) (⊙Susp Y) Susp⊙→-Susp-fmap-shom = group-structure-hom ⊙Susp-fmap pres-comp Trunc-Susp⊙→-Susp-fmap-hom : Trunc-Susp⊙→-group X Y →ᴳ Trunc-Susp⊙→-group (⊙Susp X) (⊙Susp Y) Trunc-Susp⊙→-Susp-fmap-hom = Trunc-group-fmap Susp⊙→-Susp-fmap-shom
{ "alphanum_fraction": 0.4643060458, "avg_line_length": 50.7687861272, "ext": "agda", "hexsha": "55f68a1f643714c568a122d2e52c20505e6cded3", "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/groups/SuspAdjointLoop.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/groups/SuspAdjointLoop.agda", "max_line_length": 131, "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/groups/SuspAdjointLoop.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 4256, "size": 8783 }
open import Relation.Binary.Core module BHeap.Everything {A : Set} (_≤_ : A → A → Set) (tot≤ : Total _≤_) where open import BHeap.Heap _≤_ open import BHeap.Height _≤_ tot≤
{ "alphanum_fraction": 0.5781990521, "avg_line_length": 23.4444444444, "ext": "agda", "hexsha": "a3a5c36a1a661c041210a0b7e04f1159b84a5058", "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/BHeap/Everything.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/BHeap/Everything.agda", "max_line_length": 42, "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/BHeap/Everything.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": 65, "size": 211 }
{-# OPTIONS --cubical-compatible --show-implicit #-} module WithoutK3 where -- Homogeneous equality. data _≡_ {A : Set} (x : A) : A → Set where refl : x ≡ x -- The J rule. J : {A : Set} (P : {x y : A} → x ≡ y → Set) → (∀ x → P (refl {x = x})) → ∀ {x y} (x≡y : x ≡ y) → P x≡y J P p refl = p _ -- Heterogeneous equality. data _≅_ {A : Set} (x : A) : {B : Set} → B → Set₁ where refl : x ≅ x -- Substitutivity. subst : {A : Set} {x y : A} (P : A → Set) → x ≅ y → P x → P y subst P refl p = p -- The K rule. (The implementation is based on a construction in Conor -- McBride's PhD thesis.) K : {A : Set} {x : A} (P : {x : A} → x ≡ x → Set) → (∀ x → P (refl {x = x})) → ∀ {x} (p : x ≡ x) → P p K P p x≡x = J (λ {x y} (p : x ≡ y) → (x≡x : x ≡ x) → p ≅ x≡x → P x≡x) (λ x x≡x refl≅x≡x → subst P refl≅x≡x (p x)) x≡x x≡x refl
{ "alphanum_fraction": 0.4742990654, "avg_line_length": 23.1351351351, "ext": "agda", "hexsha": "eb55c72084bbb2a1b97ef1107ee7db4b06f2b207", "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/Fail/WithoutK3.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/Fail/WithoutK3.agda", "max_line_length": 70, "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/Fail/WithoutK3.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 394, "size": 856 }
{-# OPTIONS --without-K #-} module Data.ByteString where import Data.ByteString.Primitive as Prim import Data.ByteString.Utf8 as Utf8 open import Data.Word8 using (Word8) open import Data.Nat using (ℕ) open import Data.Colist using (Colist) open import Data.List using (List) open import Data.String using (String) open import Data.Bool using (Bool; true; false) open import Data.Product using (_×_) open import Data.Tuple using (Pair→×) open import Relation.Nullary using (yes; no) open import Relation.Nullary.Decidable using (⌊_⌋) open import Relation.Binary using (Decidable) open import Relation.Binary.PropositionalEquality as PropEq using (_≡_) open import Relation.Binary.PropositionalEquality.TrustMe using (trustMe) data ByteStringKind : Set where Lazy Strict : ByteStringKind ByteString : ByteStringKind → Set ByteString Lazy = Prim.ByteStringLazy ByteString Strict = Prim.ByteStringStrict empty : ∀ {k} → ByteString k empty {Lazy} = Prim.emptyLazy empty {Strict} = Prim.emptyStrict null : ∀ {k} → ByteString k → Bool null {Lazy} = Prim.nullLazy null {Strict} = Prim.nullStrict length : ∀ {k} → ByteString k → ℕ length {Lazy} bs = Prim.int64Toℕ (Prim.lengthLazy bs) length {Strict} bs = Prim.IntToℕ (Prim.lengthStrict bs) unsafeHead : ∀ {k} → ByteString k → Word8 unsafeHead {Lazy} = Prim.headLazy unsafeHead {Strict} = Prim.headStrict unsafeTail : ∀ {k} → ByteString k → ByteString k unsafeTail {Lazy} = Prim.tailLazy unsafeTail {Strict} = Prim.tailStrict unsafeIndex : ∀ {k} → ByteString k → ℕ → Word8 unsafeIndex {Lazy} bs ix = Prim.indexLazy bs (Prim.ℕToInt64 ix) unsafeIndex {Strict} bs ix = Prim.indexStrict bs (Prim.ℕToInt ix) unsafeSplitAt : ∀ {k} → ℕ → ByteString k → (ByteString k) × (ByteString k) unsafeSplitAt {Lazy} ix bs = Pair→× (Prim.splitAtLazy (Prim.ℕToInt64 ix) bs) unsafeSplitAt {Strict} ix bs = Pair→× (Prim.splitAtStrict (Prim.ℕToInt ix) bs) ByteStringRep : ByteStringKind → Set ByteStringRep Lazy = Colist Word8 ByteStringRep Strict = List Word8 unpack : ∀ {k} → ByteString k → ByteStringRep k unpack {Lazy} = Prim.Colist←Lazy unpack {Strict} = Prim.List←Strict pack : ∀ {k} → ByteStringRep k → ByteString k pack {Lazy} = Prim.Colist→Lazy pack {Strict} = Prim.List→Strict infix 4 _≟_ _≟_ : ∀ {k} → Decidable {A = ByteString k} _≡_ _≟_ {Lazy} s₁ s₂ with Prim.lazy≟lazy s₁ s₂ ... | true = yes trustMe ... | false = no whatever where postulate whatever : _ _≟_ {Strict} s₁ s₂ with Prim.strict≟strict s₁ s₂ ... | true = yes trustMe ... | false = no whatever where postulate whatever : _ -- behind _==_ is the same idea as in Data.String infix 4 _==_ _==_ : ∀ {k} → ByteString k → ByteString k → Bool _==_ {k} s₁ s₂ = ⌊ s₁ ≟ s₂ ⌋ _++_ : ByteString Lazy → ByteString Lazy → ByteString Lazy _++_ = Prim.appendLazy fromChunks : List (ByteString Strict) → ByteString Lazy fromChunks = Prim.fromChunks toChunks : ByteString Lazy → List (ByteString Strict) toChunks = Prim.toChunks toLazy : ByteString Strict → ByteString Lazy toLazy = Prim.toLazy toStrict : ByteString Lazy → ByteString Strict toStrict = Prim.toStrict
{ "alphanum_fraction": 0.7279220779, "avg_line_length": 29.3333333333, "ext": "agda", "hexsha": "189861b0384510ca3c80c7c7d6c82af5a8e9d0e8", "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": "98a53f35fca27e3379cf851a9a6bdfe5bd8c9626", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "semenov-vladyslav/bytes-agda", "max_forks_repo_path": "src/Data/ByteString.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "98a53f35fca27e3379cf851a9a6bdfe5bd8c9626", "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/bytes-agda", "max_issues_repo_path": "src/Data/ByteString.agda", "max_line_length": 78, "max_stars_count": null, "max_stars_repo_head_hexsha": "98a53f35fca27e3379cf851a9a6bdfe5bd8c9626", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "semenov-vladyslav/bytes-agda", "max_stars_repo_path": "src/Data/ByteString.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 895, "size": 3080 }
module Base.Free where -- Reexport definitions from Agda's standard library that are needed by the -- generated code. open import Function using (case_of_) public open import Data.Bool using (if_then_else_) public open import Size using (Size; ↑_) public -- The `Free` monad over a container with shapes `S` and postions `P`. data Free (S : Set) (P : S → Set) (A : Set) : Set where pure : A → Free S P A impure : (s : S) → (pf : P s → Free S P A) → Free S P A infixl 1 _>>=_ _>>=_ : {S : Set} {P : S → Set} {A : Set} {B : Set} → Free S P A → (A → Free S P B) → Free S P B pure x >>= k = k x impure s pf >>= k = impure s λ p → pf p >>= k
{ "alphanum_fraction": 0.5732758621, "avg_line_length": 36.6315789474, "ext": "agda", "hexsha": "49a0a6401a5b0084959032913e989effb54c64ca", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2021-05-14T07:48:41.000Z", "max_forks_repo_forks_event_min_datetime": "2020-04-08T11:23:46.000Z", "max_forks_repo_head_hexsha": "6931b9ca652a185a92dd824373f092823aea4ea9", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "FreeProving/free-compiler", "max_forks_repo_path": "base/agda/Base/Free.agda", "max_issues_count": 120, "max_issues_repo_head_hexsha": "6931b9ca652a185a92dd824373f092823aea4ea9", "max_issues_repo_issues_event_max_datetime": "2020-12-08T07:46:01.000Z", "max_issues_repo_issues_event_min_datetime": "2020-04-09T09:40:39.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "FreeProving/free-compiler", "max_issues_repo_path": "base/agda/Base/Free.agda", "max_line_length": 96, "max_stars_count": 36, "max_stars_repo_head_hexsha": "6931b9ca652a185a92dd824373f092823aea4ea9", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "FreeProving/free-compiler", "max_stars_repo_path": "base/agda/Base/Free.agda", "max_stars_repo_stars_event_max_datetime": "2021-08-21T13:38:23.000Z", "max_stars_repo_stars_event_min_datetime": "2020-02-06T11:03:34.000Z", "num_tokens": 227, "size": 696 }
{-# OPTIONS --without-K --safe #-} module Cats.Category.Presheaves.Facts where open import Cats.Category.Presheaves.Facts.Exponential public using ( hasExponentials ) open import Cats.Category open import Cats.Category.Presheaves import Cats.Category.Fun.Facts as Fun import Cats.Category.Setoids.Facts module _ {lo la l≈} {C : Category lo la l≈} {l l′} where -- We don't just re-export the following definitions from Fun because -- we want to fill in their instance arguments. instance hasBinaryProducts : HasBinaryProducts (Presheaves C l l′) hasBinaryProducts = Fun.hasBinaryProducts hasTerminal : HasTerminal (Presheaves C l l′) hasTerminal = Fun.hasTerminal hasFiniteProducts : HasFiniteProducts (Presheaves C l l′) hasFiniteProducts = Fun.hasFiniteProducts isCCC : ∀ {l} {C : Category l l l} → IsCCC (Presheaves C l l) isCCC = record { hasFiniteProducts = Fun.hasFiniteProducts } -- record {} complains about ambiguity. Don't know if this is my fault or a bug.
{ "alphanum_fraction": 0.7391304348, "avg_line_length": 28.9142857143, "ext": "agda", "hexsha": "1f494170c7ccfeb2eb933859fdaaa62399fd455b", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2019-03-18T15:35:07.000Z", "max_forks_repo_forks_event_min_datetime": "2019-03-18T15:35:07.000Z", "max_forks_repo_head_hexsha": "1ad7b243acb622d46731e9ae7029408db6e561f1", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "JLimperg/cats", "max_forks_repo_path": "Cats/Category/Presheaves/Facts.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "1ad7b243acb622d46731e9ae7029408db6e561f1", "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": "JLimperg/cats", "max_issues_repo_path": "Cats/Category/Presheaves/Facts.agda", "max_line_length": 80, "max_stars_count": 24, "max_stars_repo_head_hexsha": "1ad7b243acb622d46731e9ae7029408db6e561f1", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "JLimperg/cats", "max_stars_repo_path": "Cats/Category/Presheaves/Facts.agda", "max_stars_repo_stars_event_max_datetime": "2021-08-06T05:00:46.000Z", "max_stars_repo_stars_event_min_datetime": "2017-11-03T15:18:57.000Z", "num_tokens": 264, "size": 1012 }
open import Relation.Binary.Core module PLRTree.Drop.Heap {A : Set} (_≤_ : A → A → Set) (tot≤ : Total _≤_) (trans≤ : Transitive _≤_) where open import PLRTree {A} open import PLRTree.Compound {A} open import PLRTree.Drop _≤_ tot≤ open import PLRTree.DropLast.Heap _≤_ tot≤ open import PLRTree.Heap _≤_ open import PLRTree.Order.Properties {A} open import PLRTree.Push.Heap _≤_ tot≤ trans≤ lemma-drop-heap : {t : PLRTree} → Heap t → Heap (drop t) lemma-drop-heap leaf = leaf lemma-drop-heap (node {t} {x} (lf≤* .x) (lf≤* .x) leaf leaf) = leaf lemma-drop-heap (node {t} {x} {r = node t' x' l' r'} (lf≤* .x) (nd≤* x≤x' x≤*l' x≤*r') leaf (node x'≤*l' x'≤*r' hl' hr')) with dropLast (node t x leaf (node t' x' l' r')) | lemma-dropLast-heap (node {t} (lf≤* x) (nd≤* {t'} x≤x' x≤*l' x≤*r') leaf (node x'≤*l' x'≤*r' hl' hr')) ... | leaf | leaf = leaf ... | node t'' x'' l'' r'' | node x''≤*l'' x''≤*r'' hl'' hr'' = let z = last (node t x leaf (node t' x' l' r')) compound in lemma-push-heap t'' z hl'' hr'' (≺-wf (node t'' z l'' r'')) lemma-drop-heap (node {t} {x} {l = node t' x' l' r'} {r} (nd≤* x≤x' x≤*l' x≤*r') x≤*r (node x'≤*l' x'≤*r' hl' hr') hr) with dropLast (node t x (node t' x' l' r') r) | lemma-dropLast-heap (node {t} (nd≤* {t'} x≤x' x≤*l' x≤*r') x≤*r (node x'≤*l' x'≤*r' hl' hr') hr) ... | leaf | leaf = leaf ... | node t'' x'' l'' r'' | node x''≤*l'' x''≤*r'' hl'' hr'' = let z = last (node t x (node t' x' l' r') r) compound in lemma-push-heap t'' z hl'' hr'' (≺-wf (node t'' z l'' r''))
{ "alphanum_fraction": 0.5119852489, "avg_line_length": 52.4838709677, "ext": "agda", "hexsha": "c6d0b84e3b62ede95e26c3b576c7e4b470fda263", "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/Drop/Heap.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/Drop/Heap.agda", "max_line_length": 159, "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/Drop/Heap.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": 713, "size": 1627 }
module explore where import Explore.BigDistr import Explore.BinTree import Explore.Core import Explore.Dice import Explore.Examples import Explore.Explorable import Explore.Fin import Explore.Group import Explore.GuessingGameFlipping import Explore.Isomorphism import Explore.Monad import Explore.One import Explore.Product import Explore.Properties import Explore.README import Explore.Subset import Explore.Sum import Explore.Summable import Explore.Two import Explore.Universe import Explore.Universe.Base import Explore.Universe.FromE import Explore.Universe.Type import Explore.Zero -- BROKEN import Explore.Explorable.Fun -- BROKEN import Explore.Function.Fin
{ "alphanum_fraction": 0.8588588589, "avg_line_length": 23.7857142857, "ext": "agda", "hexsha": "f408edf7b26b5b931f26735da1a7c90a480d0494", "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": "16bc8333503ff9c00d47d56f4ec6113b9269a43e", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "crypto-agda/explore", "max_forks_repo_path": "explore.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "16bc8333503ff9c00d47d56f4ec6113b9269a43e", "max_issues_repo_issues_event_max_datetime": "2019-03-16T14:24:04.000Z", "max_issues_repo_issues_event_min_datetime": "2019-03-16T14:24:04.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "crypto-agda/explore", "max_issues_repo_path": "explore.agda", "max_line_length": 39, "max_stars_count": 2, "max_stars_repo_head_hexsha": "16bc8333503ff9c00d47d56f4ec6113b9269a43e", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "crypto-agda/explore", "max_stars_repo_path": "explore.agda", "max_stars_repo_stars_event_max_datetime": "2017-06-28T19:19:29.000Z", "max_stars_repo_stars_event_min_datetime": "2016-06-05T09:25:32.000Z", "num_tokens": 149, "size": 666 }
module Bool where data Bool : Set where false : Bool true : Bool data IsTrue : Bool -> Set where isTrue : IsTrue true open import Vec open import All allEnvs : {n : Nat} -> List (Vec Bool n) allEnvs {zero } = ε :: [] allEnvs {suc n} = map (_►_ false) allEnvs ++ map (_►_ true) allEnvs ∈++left : {A : Set}{x : A}{xs ys : List A} -> x ∈ xs -> x ∈ (xs ++ ys) ∈++left (hd p) = hd p ∈++left (tl q) = tl (∈++left q) ∈++right : {A : Set}{x : A}{xs ys : List A} -> x ∈ ys -> x ∈ (xs ++ ys) ∈++right {xs = []} p = p ∈++right {xs = x :: xs} p = tl (∈++right {xs = xs} p) ∈map : {A B : Set}{f : A -> B}{x : A}{xs : List A} -> x ∈ xs -> f x ∈ map f xs ∈map (hd refl) = hd refl ∈map (tl q) = tl (∈map q) covered : {n : Nat} -> (xs : Vec Bool n) -> xs ∈ allEnvs covered ε = hd refl covered (false ► xs) = ∈++left (∈map (covered xs)) covered (true ► xs) = ∈++right {xs = map (_►_ false) allEnvs} (∈map (covered xs)) Sat : {A : Set} -> (A -> Bool) -> A -> Set Sat f x = IsTrue (f x) lem₁ : {n : Nat}(f : Vec Bool n -> Bool) -> All (Sat f) allEnvs -> (xs : Vec Bool n) -> Sat f xs lem₁ f p xs with p ! covered xs ... | (.xs , p , refl) = p data False : Set where ¬_ : Set -> Set ¬ P = P -> False data _∨_ (A B : Set) : Set where inl : A -> A ∨ B inr : B -> A ∨ B ¬IsTrue-false : ¬ IsTrue false ¬IsTrue-false () decide : {A : Set}(p : A -> Bool)(x : A) -> Sat p x ∨ ¬ Sat p x decide p x with p x ... | true = inl isTrue ... | false = inr ¬IsTrue-false all : {A : Set}(p : A -> Bool)(xs : List A) -> All (Sat p) xs ∨ Some (\x -> ¬ Sat p x) xs all p [] = inl ∅ all p (x :: xs) with decide p x ... | inr ¬px = inr (hd ¬px) ... | inl px with all p xs ... | inl ps = inl (px ▹ ps) ... | inr q = inr (tl q) data NoProof : Set where no-proof : NoProof Proof : {n : Nat} -> (Vec Bool n -> Bool) -> Set Proof {n} f with all f allEnvs ... | inl _ = (xs : Vec Bool n) -> Sat f xs ... | inr _ = NoProof prove : {n : Nat}(f : Vec Bool n -> Bool) -> Proof f prove f with all f allEnvs ... | inl ps = lem₁ f ps ... | inr _ = no-proof
{ "alphanum_fraction": 0.5011820331, "avg_line_length": 25.4819277108, "ext": "agda", "hexsha": "2f41756f64def9e877e832f70b543ecc8bfb5b8a", "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": "examples/outdated-and-incorrect/tactics/bool/Bool.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": "examples/outdated-and-incorrect/tactics/bool/Bool.agda", "max_line_length": 78, "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": "examples/outdated-and-incorrect/tactics/bool/Bool.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": 832, "size": 2115 }
open import Nat open import Prelude open import dynamics-core open import contexts open import lemmas-consistency open import lemmas-disjointness open import lemmas-matching open import weakening module typed-elaboration where mutual typed-elaboration-synth : {Γ : tctx} {e : hexp} {τ : htyp} {d : ihexp} {Δ : hctx} → Γ ⊢ e ⇒ τ ~> d ⊣ Δ → Δ , Γ ⊢ d :: τ typed-elaboration-synth ESNum = TANum typed-elaboration-synth (ESPlus dis apt x₁ x₂) with typed-elaboration-ana x₁ | typed-elaboration-ana x₂ ... | con1 , ih1 | con2 , ih2 = TAPlus (TACast (weaken-ta-Δ1 apt ih1) con1) (TACast (weaken-ta-Δ2 apt ih2) con2) typed-elaboration-synth (ESVar x₁) = TAVar x₁ typed-elaboration-synth (ESLam x₁ ex) = TALam x₁ (typed-elaboration-synth ex) typed-elaboration-synth (ESAp {Δ1 = Δ1} _ d x₁ x₂ x₃ x₄) with typed-elaboration-ana x₃ | typed-elaboration-ana x₄ ... | con1 , ih1 | con2 , ih2 = TAAp (TACast (weaken-ta-Δ1 d ih1) con1) (TACast (weaken-ta-Δ2 {Δ1 = Δ1} d ih2) con2) typed-elaboration-synth (ESEHole {Γ = Γ} {u = u}) with natEQ u u ... | Inr u≠u = abort (u≠u refl) ... | Inl refl = TAEHole (x∈■ u (Γ , ⦇-⦈)) (STAId (λ x τ z → z)) typed-elaboration-synth (ESNEHole {Γ = Γ} {τ = τ} {u = u} {Δ = Δ} (d1 , d2) ex) with typed-elaboration-synth ex ... | ih1 = TANEHole {Δ = Δ ,, (u , Γ , ⦇-⦈)} (ctx-top Δ u (Γ , ⦇-⦈) (d2 u (lem-domsingle _ _))) (weaken-ta-Δ2 (d2 , d1) ih1) (STAId (λ x τ₁ z → z)) typed-elaboration-synth (ESAsc x) with typed-elaboration-ana x ... | con , ih = TACast ih con typed-elaboration-synth (ESPair x x₁ x₂ x₃) with typed-elaboration-synth x₂ | typed-elaboration-synth x₃ ... | ih1 | ih2 = TAPair (weaken-ta-Δ1 x₁ ih1) (weaken-ta-Δ2 x₁ ih2) typed-elaboration-synth (ESFst x x₁ x₂) with typed-elaboration-ana x₂ ... | con , ih = TAFst (TACast ih con) typed-elaboration-synth (ESSnd x x₁ x₂) with typed-elaboration-ana x₂ ... | con , ih = TASnd (TACast ih con) typed-elaboration-ana : {Γ : tctx} {e : hexp} {τ τ' : htyp} {d : ihexp} {Δ : hctx} → Γ ⊢ e ⇐ τ ~> d :: τ' ⊣ Δ → (τ' ~ τ) × (Δ , Γ ⊢ d :: τ') typed-elaboration-ana (EALam x₁ MAHole ex) with typed-elaboration-ana ex ... | con , D = TCHole1 , TALam x₁ D typed-elaboration-ana (EALam x₁ MAArr ex) with typed-elaboration-ana ex ... | con , D = TCArr TCRefl con , TALam x₁ D typed-elaboration-ana (EASubsume x x₁ x₂ x₃) = ~sym x₃ , typed-elaboration-synth x₂ typed-elaboration-ana (EAEHole {Γ = Γ} {u = u}) = TCRefl , TAEHole (x∈■ u (Γ , _)) (STAId (λ x τ z → z)) typed-elaboration-ana (EANEHole {Γ = Γ} {u = u} {τ = τ} {Δ = Δ} (d1 , d2) x) with typed-elaboration-synth x ... | ih1 = TCRefl , TANEHole {Δ = Δ ,, (u , Γ , τ)} (ctx-top Δ u (Γ , τ) (d2 u (lem-domsingle _ _)) ) (weaken-ta-Δ2 (d2 , d1) ih1) (STAId (λ x₁ τ₁ z → z)) typed-elaboration-ana (EAInl MSHole x₁) with typed-elaboration-ana x₁ ... | con , D = TCHole1 , TAInl D typed-elaboration-ana (EAInl MSSum x₁) with typed-elaboration-ana x₁ ... | con , D = TCSum con TCRefl , TAInl D typed-elaboration-ana (EAInr MSHole x₁) with typed-elaboration-ana x₁ ... | con , D = TCHole1 , TAInr D typed-elaboration-ana (EAInr MSSum x₁) with typed-elaboration-ana x₁ ... | con , D = TCSum TCRefl con , TAInr D typed-elaboration-ana (EACase x x₁ x₂ x₃ x₄ x₅ x₆ x₇ x₈ x₉ x₁₀ x₁₁) with typed-elaboration-synth x₈ | typed-elaboration-ana x₁₀ | typed-elaboration-ana x₁₁ ... | D | con1 , D1 | con2 , D2 = let Δ##Δ1∪Δ2 = ##-comm (disjoint-parts (##-comm x₃) (##-comm x₄)) in let wtd = TACast (weaken-ta-Δ1 Δ##Δ1∪Δ2 D) (▸sum-consist x₉) in let wtd1 = TACast (weaken-ta-Δ2 Δ##Δ1∪Δ2 (weaken-ta-Δ1 x₅ D1)) con1 in let wtd2 = TACast (weaken-ta-Δ2 Δ##Δ1∪Δ2 (weaken-ta-Δ2 x₅ D2)) con2 in let wt = TACase wtd x₆ wtd1 x₇ wtd2 in TCRefl , wt
{ "alphanum_fraction": 0.587631386, "avg_line_length": 51.7848101266, "ext": "agda", "hexsha": "3980488e59af79655d05ed09085b6bc72a18f024", "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": "typed-elaboration.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": "typed-elaboration.agda", "max_line_length": 159, "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": "typed-elaboration.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1718, "size": 4091 }
{-# OPTIONS --without-K --safe #-} -- Adjoint Functor Theorem module Categories.Adjoint.AFT where open import Level open import Data.Product open import Data.Product using (Σ) open import Categories.Category open import Categories.Category.Complete open import Categories.Category.Complete.Properties open import Categories.Category.Construction.Cones open import Categories.Category.Construction.Comma open import Categories.Functor open import Categories.Functor.Limits open import Categories.Functor.Properties open import Categories.Adjoint open import Categories.Adjoint.Properties open import Categories.Diagram.Limit as Lim open import Categories.Diagram.Cone.Properties open import Categories.Morphism as Mor open import Categories.Morphism.Universal import Categories.Adjoint.AFT.SolutionSet as SS import Categories.Morphism.Reasoning as MR private variable o ℓ e : Level C D : Category o ℓ e module _ {R : Functor C D} where private module C = Category C module D = Category D module R = Functor R o-level : Level o-level = C.o-level ⊔ C.ℓ-level ⊔ D.ℓ-level ⊔ D.e-level ℓ-level : Level ℓ-level = C.o-level ⊔ C.ℓ-level ⊔ D.ℓ-level ⊔ D.e-level e-level : Level e-level = C.o-level ⊔ C.ℓ-level ⊔ D.ℓ-level ⊔ D.e-level open SS R using (SolutionSet′) module _ {L : Functor D C} (L⊣R : L ⊣ R) where private module L = Functor L open Adjoint L⊣R L⊣R⇒solutionSet′ : SolutionSet′ L⊣R⇒solutionSet′ = record { S₀ = λ {_ X} _ → L.₀ X ; S₁ = Radjunct ; ϕ = λ _ → unit.η _ ; commute = λ _ → LRadjunct≈id } module _ (Com : Complete o-level ℓ-level e-level C) (Rcon : Continuous o-level ℓ-level e-level R) (s : SolutionSet′) where open SolutionSet′ s open D.Equiv open D.HomReasoning open MR D private module _ X where X↙R : Category (C.o-level ⊔ D.ℓ-level) (C.ℓ-level ⊔ D.e-level) C.e-level X↙R = X ↙ R module X↙R = Category X↙R s′ : SolutionSet X↙R s′ = record { D = D′ ; arr = arr′ } where D′ : X↙R.Obj → X↙R.Obj D′ Z = record { f = ϕ Z.f } where module Z = CommaObj Z arr′ : ∀ Z → X↙R [ D′ Z , Z ] arr′ Z = record { h = S₁ Z.f ; commute = commute _ ○ ⟺ D.identityʳ } where module Z = CommaObj Z open D.HomReasoning module _ {J : Category o-level ℓ-level e-level} (F : Functor J X↙R) where module J = Category J module F = Functor F F′ : Functor J C F′ = Cod _ _ ∘F F LimF′ : Limit F′ LimF′ = Com F′ module LimF′ = Limit LimF′ RLimF′ : Cone (R ∘F F′) RLimF′ = F-map-Coneˡ R LimF′.limit module RLimF′ = Cone _ RLimF′ LimRF′ : Limit (R ∘F F′) LimRF′ = record { terminal = record { ⊤ = RLimF′ ; ⊤-is-terminal = Rcon LimF′ } } module LimRF′ = Limit LimRF′ coneF : Cone (R ∘F F′) coneF = record { N = X ; apex = record { ψ = λ j → CommaObj.f (F.₀ j) ; commute = λ f → Comma⇒.commute (F.₁ f) ○ D.identityʳ } } ⊤-arr : Cone⇒ (R ∘F F′) coneF RLimF′ ⊤-arr = LimRF′.rep-cone coneF module ⊤-arr = Cone⇒ (R ∘F F′) ⊤-arr ⊤ : Cone F ⊤ = record { N = record { f = ⊤-arr.arr } ; apex = record { ψ = λ j → record { h = LimF′.proj j ; commute = begin R.₁ (LimF′.proj j) D.∘ ⊤-arr.arr ≈⟨ ⊤-arr.commute ⟩ CommaObj.f (F.₀ j) ≈˘⟨ D.identityʳ ⟩ CommaObj.f (F.₀ j) D.∘ D.id ∎ } ; commute = λ f → -, LimF′.limit-commute f } } K-conv : Cone F → Cone F′ K-conv = F-map-Coneˡ (Cod _ _) K-conv′ : Cone F → Cone (R ∘F F′) K-conv′ K = F-map-Coneˡ R (K-conv K) ! : (K : Cone F) → Cones F [ K , ⊤ ] ! K = record { arr = record { h = LimF′.rep (K-conv K) ; commute = ⟺ (LimRF′.terminal.!-unique (record { arr = R.₁ (LimF′.rep (K-conv K)) D.∘ CommaObj.f N ; commute = λ {j} → begin LimRF′.proj j D.∘ R.₁ (LimF′.rep (K-conv K)) D.∘ CommaObj.f N ≈⟨ pullˡ ([ R ]-resp-∘ LimF′.commute) ⟩ R.₁ (Comma⇒.h (ψ j)) D.∘ CommaObj.f N ≈⟨ Comma⇒.commute (ψ j) ⟩ CommaObj.f (F.F₀ j) D.∘ D.id ≈⟨ D.identityʳ ⟩ CommaObj.f (F.₀ j) ∎ })) ○ ⟺ D.identityʳ } ; commute = -, LimF′.commute } where open Cone _ K !-unique : {K : Cone F} (f : Cones F [ K , ⊤ ]) → Cones F [ ! K ≈ f ] !-unique f = -, LimF′.terminal.!-unique record { arr = Comma⇒.h f.arr ; commute = proj₂ f.commute } where module f = Cone⇒ _ f complete : Limit F complete = record { terminal = record { ⊤ = ⊤ ; ⊤-is-terminal = record { ! = ! _ ; !-unique = !-unique } } } solutionSet′⇒universalMorphism : UniversalMorphism X R solutionSet′⇒universalMorphism = record { initial = SolutionSet⇒Initial {o′ = 0ℓ} {0ℓ} {0ℓ} {C = X ↙ R} complete s′ } solutionSet⇒adjoint : Σ (Functor D C) (λ L → L ⊣ R) solutionSet⇒adjoint = universalMophisms⇒adjoint solutionSet′⇒universalMorphism
{ "alphanum_fraction": 0.4709150327, "avg_line_length": 30.297029703, "ext": "agda", "hexsha": "19d378cebdddfb5e5bad83cdfed9f424ddc89b59", "lang": "Agda", "max_forks_count": 64, "max_forks_repo_forks_event_max_datetime": "2022-03-14T02:00:59.000Z", "max_forks_repo_forks_event_min_datetime": "2019-06-02T16:58:15.000Z", "max_forks_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Code-distancing/agda-categories", "max_forks_repo_path": "src/Categories/Adjoint/AFT.agda", "max_issues_count": 236, "max_issues_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_issues_repo_issues_event_max_datetime": "2022-03-28T14:31:43.000Z", "max_issues_repo_issues_event_min_datetime": "2019-06-01T14:53:54.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Code-distancing/agda-categories", "max_issues_repo_path": "src/Categories/Adjoint/AFT.agda", "max_line_length": 85, "max_stars_count": 279, "max_stars_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Trebor-Huang/agda-categories", "max_stars_repo_path": "src/Categories/Adjoint/AFT.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-22T00:40:14.000Z", "max_stars_repo_stars_event_min_datetime": "2019-06-01T14:36:40.000Z", "num_tokens": 1919, "size": 6120 }
{-# OPTIONS --cubical --safe #-} module Equiv where open import Agda.Builtin.Cubical.Glue public using ( isEquiv ; equiv-proof ; _≃_) open import Cubical.Foundations.Everything public using (ua) open import Cubical.Foundations.Equiv public using (equivToIso; isPropIsEquiv) renaming (compEquiv to trans-≃; invEquiv to sym-≃)
{ "alphanum_fraction": 0.7171428571, "avg_line_length": 25, "ext": "agda", "hexsha": "e72900c11f9017396ebd1b92e345693e43f13651", "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/Equiv.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/Equiv.agda", "max_line_length": 60, "max_stars_count": 6, "max_stars_repo_head_hexsha": "3c176d4690566d81611080e9378f5a178b39b851", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "oisdk/combinatorics-paper", "max_stars_repo_path": "agda/Equiv.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": 107, "size": 350 }
open import Agda.Builtin.Equality open import Agda.Builtin.Nat data ⊥ : Set where data Zero : Set where zero : Zero data One : Set where suc : Zero → One one : One one = suc zero data _≤_ : One → Zero → Set where leq : ∀ m n → Nat → Nat → m ≤ n → ⊥ leq (suc m) zero = λ i j () test : Nat → one ≤ zero → ⊥ test = leq one zero 5 -- Normalise: test -- Expected: λ j ()
{ "alphanum_fraction": 0.6052631579, "avg_line_length": 14.6153846154, "ext": "agda", "hexsha": "506948505ddaf8057e5aec22499bca16da888694", "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/Issue3002.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/Issue3002.agda", "max_line_length": 35, "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/Issue3002.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": 136, "size": 380 }
{-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.Categories.Functor where open import Cubical.Categories.Functor.Base public open import Cubical.Categories.Functor.Properties public open import Cubical.Categories.Functor.Compose public
{ "alphanum_fraction": 0.8117647059, "avg_line_length": 31.875, "ext": "agda", "hexsha": "3e7ddc0cca7a24fe079ff1deedffeaf9839218f8", "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": "5de11df25b79ee49d5c084fbbe6dfc66e4147a2e", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Edlyr/cubical", "max_forks_repo_path": "Cubical/Categories/Functor.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "5de11df25b79ee49d5c084fbbe6dfc66e4147a2e", "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": "Edlyr/cubical", "max_issues_repo_path": "Cubical/Categories/Functor.agda", "max_line_length": 56, "max_stars_count": null, "max_stars_repo_head_hexsha": "5de11df25b79ee49d5c084fbbe6dfc66e4147a2e", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Edlyr/cubical", "max_stars_repo_path": "Cubical/Categories/Functor.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 56, "size": 255 }
module Oscar.Data.Maybe.properties where open import Data.Maybe public using (maybe)
{ "alphanum_fraction": 0.8045977011, "avg_line_length": 17.4, "ext": "agda", "hexsha": "550b76125d6ec13c7a5c8992a7e3f96cc3a142f9", "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/Maybe/properties.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/Maybe/properties.agda", "max_line_length": 43, "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/Maybe/properties.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 17, "size": 87 }
module STLC2.Kovacs.Convertibility where open import STLC2.Kovacs.Substitution public -------------------------------------------------------------------------------- -- Convertibility (_~_ ; ~refl ; _~⁻¹ ; lam ; app ; β ; η) infix 3 _∼_ data _∼_ : ∀ {Γ A} → Γ ⊢ A → Γ ⊢ A → Set where refl∼ : ∀ {Γ A} → {M : Γ ⊢ A} → M ∼ M _⁻¹∼ : ∀ {Γ A} → {M₁ M₂ : Γ ⊢ A} → (p : M₁ ∼ M₂) → M₂ ∼ M₁ _⦙∼_ : ∀ {Γ A} → {M₁ M₂ M₃ : Γ ⊢ A} → (p : M₁ ∼ M₂) (q : M₂ ∼ M₃) → M₁ ∼ M₃ ƛ∼ : ∀ {Γ A B} → {M₁ M₂ : Γ , A ⊢ B} → (p : M₁ ∼ M₂) → ƛ M₁ ∼ ƛ M₂ _∙∼_ : ∀ {Γ A B} → {M₁ M₂ : Γ ⊢ A ⇒ B} {N₁ N₂ : Γ ⊢ A} → (p : M₁ ∼ M₂) (q : N₁ ∼ N₂) → M₁ ∙ N₁ ∼ M₂ ∙ N₂ _,∼_ : ∀ {Γ A B} → {M₁ M₂ : Γ ⊢ A} {N₁ N₂ : Γ ⊢ B} → (p : M₁ ∼ M₂) (q : N₁ ∼ N₂) → M₁ , N₁ ∼ M₂ , N₂ π₁∼ : ∀ {Γ A B} → {M₁ M₂ : Γ ⊢ A ⩕ B} → (p : M₁ ∼ M₂) → π₁ M₁ ∼ π₁ M₂ π₂∼ : ∀ {Γ A B} → {M₁ M₂ : Γ ⊢ A ⩕ B} → (p : M₁ ∼ M₂) → π₂ M₁ ∼ π₂ M₂ φ∼ : ∀ {Γ C} → {M₁ M₂ : Γ ⊢ ⫫} → (p : M₁ ∼ M₂) → φ {C = C} M₁ ∼ φ M₂ ι₁∼ : ∀ {Γ A B} → {M₁ M₂ : Γ ⊢ A} → (p : M₁ ∼ M₂) → ι₁ {B = B} M₁ ∼ ι₁ M₂ ι₂∼ : ∀ {Γ A B} → {M₁ M₂ : Γ ⊢ B} → (p : M₁ ∼ M₂) → ι₂ {A = A} M₁ ∼ ι₂ M₂ _⁇∼_∥∼_ : ∀ {Γ A B C} → {M₁ M₂ : Γ ⊢ A ⩖ B} {N₁₁ N₁₂ : Γ , A ⊢ C} {N₂₁ N₂₂ : Γ , B ⊢ C} → (p : M₁ ∼ M₂) (q₁ : N₁₁ ∼ N₁₂) (q₂ : N₂₁ ∼ N₂₂) → M₁ ⁇ N₁₁ ∥ N₂₁ ∼ M₂ ⁇ N₁₂ ∥ N₂₂ red⇒ : ∀ {Γ A B} → (M : Γ , A ⊢ B) (N : Γ ⊢ A) → (ƛ M) ∙ N ∼ cut N M red⩕₁ : ∀ {Γ A B} → (M : Γ ⊢ A) (N : Γ ⊢ B) → π₁ (M , N) ∼ M red⩕₂ : ∀ {Γ A B} → (M : Γ ⊢ A) (N : Γ ⊢ B) → π₂ (M , N) ∼ N red⩖₁ : ∀ {Γ A B C} → (M : Γ ⊢ A) (N₁ : Γ , A ⊢ C) (N₂ : Γ , B ⊢ C) → ι₁ M ⁇ N₁ ∥ N₂ ∼ cut M N₁ red⩖₂ : ∀ {Γ A B C} → (M : Γ ⊢ B) (N₁ : Γ , A ⊢ C) (N₂ : Γ , B ⊢ C) → ι₂ M ⁇ N₁ ∥ N₂ ∼ cut M N₂ exp⇒ : ∀ {Γ A B} → (M : Γ ⊢ A ⇒ B) → M ∼ ƛ (wk M ∙ 0) exp⩕ : ∀ {Γ A B} → (M : Γ ⊢ A ⩕ B) → M ∼ π₁ M , π₂ M exp⫪ : ∀ {Γ} → (M : Γ ⊢ ⫪) → M ∼ τ exp⩖ : ∀ {Γ A B} → (M : Γ ⊢ A ⩖ B) → M ∼ M ⁇ ι₁ 0 ∥ ι₂ 0 comm⫫∙ : ∀ {Γ A B} → (M : Γ ⊢ ⫫) (N : Γ ⊢ A) → _∙_ {A = A} {B} (φ M) N ∼ φ M comm⫫π₁ : ∀ {Γ A B} → (M : Γ ⊢ ⫫) → π₁ {A = A} {B} (φ M) ∼ φ M comm⫫π₂ : ∀ {Γ A B} → (M : Γ ⊢ ⫫) → π₂ {A = A} {B} (φ M) ∼ φ M comm⫫φ : ∀ {Γ C} → (M : Γ ⊢ ⫫) → φ {C = C} (φ M) ∼ φ M comm⫫⁇∥ : ∀ {Γ A B C} → (M : Γ ⊢ ⫫) (N₁ : Γ , A ⊢ C) (N₂ : Γ , B ⊢ C) → φ M ⁇ N₁ ∥ N₂ ∼ φ M comm⩖∙ : ∀ {Γ A B C D} → (M : Γ ⊢ A ⩖ B) (N₁ : Γ , A ⊢ C ⇒ D) (N₂ : Γ , B ⊢ C ⇒ D) (O : Γ ⊢ C) → (M ⁇ N₁ ∥ N₂) ∙ O ∼ M ⁇ (N₁ ∙ wk O) ∥ (N₂ ∙ wk O) comm⩖π₁ : ∀ {Γ A B C D} → (M : Γ ⊢ A ⩖ B) (N₁ : Γ , A ⊢ C ⩕ D) (N₂ : Γ , B ⊢ C ⩕ D) → π₁ (M ⁇ N₁ ∥ N₂) ∼ M ⁇ (π₁ N₁) ∥ (π₁ N₂) comm⩖π₂ : ∀ {Γ A B C D} → (M : Γ ⊢ A ⩖ B) (N₁ : Γ , A ⊢ C ⩕ D) (N₂ : Γ , B ⊢ C ⩕ D) → π₂ (M ⁇ N₁ ∥ N₂) ∼ M ⁇ (π₂ N₁) ∥ (π₂ N₂) comm⩖φ : ∀ {Γ A B C} → (M : Γ ⊢ A ⩖ B) (N₁ : Γ , A ⊢ ⫫) (N₂ : Γ , B ⊢ ⫫) → φ {C = C} (M ⁇ N₁ ∥ N₂) ∼ M ⁇ (φ N₁) ∥ (φ N₂) comm⩖⁇∥ : ∀ {Γ A B C D E} → (M : Γ ⊢ A ⩖ B) (N₁ : Γ , A ⊢ C ⩖ D) (N₂ : Γ , B ⊢ C ⩖ D) (O₁ : Γ , C ⊢ E) (O₂ : Γ , D ⊢ E) → (M ⁇ N₁ ∥ N₂) ⁇ O₁ ∥ O₂ ∼ M ⁇ (N₁ ⁇ liftwk O₁ ∥ liftwk O₂) ∥ (N₂ ⁇ liftwk O₁ ∥ liftwk O₂) ≡→∼ : ∀ {Γ A} → {M₁ M₂ : Γ ⊢ A} → M₁ ≡ M₂ → M₁ ∼ M₂ ≡→∼ refl = refl∼ instance per∼ : ∀ {Γ A} → PER (Γ ⊢ A) _∼_ per∼ = record { _⁻¹ = _⁻¹∼ ; _⦙_ = _⦙∼_ } -------------------------------------------------------------------------------- renwk : ∀ {Γ Γ′ A B} → (η : Γ′ ⊇ Γ) (M : Γ ⊢ A) → (wk {B} ∘ ren η) M ≡ (ren (liftₑ η) ∘ wk) M renwk η M = ren○ (wkₑ idₑ) η M ⁻¹ ⦙ (λ η′ → ren (wkₑ η′) M) & ( rid○ η ⦙ lid○ η ⁻¹ ) ⦙ ren○ (liftₑ η) (wkₑ idₑ) M renliftwk : ∀ {Γ Γ′ A B C} → (η : Γ′ ⊇ Γ) (M : Γ , A ⊢ B) → (liftwk {C} ∘ ren (liftₑ η)) M ≡ (ren (liftₑ (liftₑ η)) ∘ liftwk) M renliftwk η M = ren○ (liftₑ (wkₑ idₑ)) (liftₑ η) M ⁻¹ ⦙ (λ η′ → ren (liftₑ (wkₑ η′)) M) & ( rid○ η ⦙ lid○ η ⁻¹ ) ⦙ ren○ (liftₑ (liftₑ η)) (liftₑ (wkₑ idₑ)) M rencut : ∀ {Γ Γ′ A B} → (η : Γ′ ⊇ Γ) (M : Γ ⊢ A) (N : Γ , A ⊢ B) → (cut (ren η M) ∘ ren (liftₑ η)) N ≡ (ren η ∘ cut M) N rencut η M N = sub◑ (idₛ , ren η M) (liftₑ η) N ⁻¹ ⦙ (λ σ → sub (σ , ren η M) N) & ( rid◑ η ⦙ lid◐ η ⁻¹ ) ⦙ sub◐ η (idₛ , M) N -- (~ₑ) ren∼ : ∀ {Γ Γ′ A} → {M₁ M₂ : Γ ⊢ A} → (η : Γ′ ⊇ Γ) → M₁ ∼ M₂ → ren η M₁ ∼ ren η M₂ ren∼ η refl∼ = refl∼ ren∼ η (p ⁻¹∼) = ren∼ η p ⁻¹ ren∼ η (p ⦙∼ q) = ren∼ η p ⦙ ren∼ η q ren∼ η (ƛ∼ p) = ƛ∼ (ren∼ (liftₑ η) p) ren∼ η (p ∙∼ q) = ren∼ η p ∙∼ ren∼ η q ren∼ η (p ,∼ q) = ren∼ η p ,∼ ren∼ η q ren∼ η (π₁∼ p) = π₁∼ (ren∼ η p) ren∼ η (π₂∼ p) = π₂∼ (ren∼ η p) ren∼ η (φ∼ p) = φ∼ (ren∼ η p) ren∼ η (ι₁∼ p) = ι₁∼ (ren∼ η p) ren∼ η (ι₂∼ p) = ι₂∼ (ren∼ η p) ren∼ η (p ⁇∼ q₁ ∥∼ q₂) = ren∼ η p ⁇∼ ren∼ (liftₑ η) q₁ ∥∼ ren∼ (liftₑ η) q₂ ren∼ η (red⇒ M N) = coe (((ƛ (ren (liftₑ η) M) ∙ ren η N) ∼_) & rencut η N M) (red⇒ (ren (liftₑ η) M) (ren η N)) ren∼ η (red⩕₁ M N) = red⩕₁ (ren η M) (ren η N) ren∼ η (red⩕₂ M N) = red⩕₂ (ren η M) (ren η N) ren∼ η (red⩖₁ M N₁ N₂) = coe (((ι₁ (ren η M) ⁇ ren (liftₑ η) N₁ ∥ ren (liftₑ η) N₂) ∼_) & rencut η M N₁) (red⩖₁ (ren η M) (ren (liftₑ η) N₁) (ren (liftₑ η) N₂)) ren∼ η (red⩖₂ M N₁ N₂) = coe (((ι₂ (ren η M) ⁇ ren (liftₑ η) N₁ ∥ ren (liftₑ η) N₂) ∼_) & rencut η M N₂) (red⩖₂ (ren η M) (ren (liftₑ η) N₁) (ren (liftₑ η) N₂)) ren∼ η (exp⇒ M) = coe ((λ M′ → ren η M ∼ ƛ (M′ ∙ 0)) & renwk η M) (exp⇒ (ren η M)) ren∼ η (exp⩕ M) = exp⩕ (ren η M) ren∼ η (exp⫪ M) = exp⫪ (ren η M) ren∼ η (exp⩖ M) = exp⩖ (ren η M) ren∼ η (comm⫫∙ M N) = comm⫫∙ (ren η M) (ren η N) ren∼ η (comm⫫π₁ M) = comm⫫π₁ (ren η M) ren∼ η (comm⫫π₂ M) = comm⫫π₂ (ren η M) ren∼ η (comm⫫φ M) = comm⫫φ (ren η M) ren∼ η (comm⫫⁇∥ M N₁ N₂) = comm⫫⁇∥ (ren η M) (ren (liftₑ η) N₁) (ren (liftₑ η) N₂) ren∼ η (comm⩖∙ M N₁ N₂ O) = coe ((((ren η M ⁇ ren (liftₑ η) N₁ ∥ ren (liftₑ η) N₂) ∙ ren η O ) ∼_) & ((λ N₁′ N₂′ → ren η M ⁇ N₁′ ∥ N₂′) & ((λ O′ → ren (liftₑ η) N₁ ∙ O′) & renwk η O) ⊗ ((λ O′ → ren (liftₑ η) N₂ ∙ O′) & renwk η O))) (comm⩖∙ (ren η M) (ren (liftₑ η) N₁) (ren (liftₑ η) N₂) (ren η O)) ren∼ η (comm⩖π₁ M N₁ N₂) = comm⩖π₁ (ren η M) (ren (liftₑ η) N₁) (ren (liftₑ η) N₂) ren∼ η (comm⩖π₂ M N₁ N₂) = comm⩖π₂ (ren η M) (ren (liftₑ η) N₁) (ren (liftₑ η) N₂) ren∼ η (comm⩖φ M N₁ N₂) = comm⩖φ (ren η M) (ren (liftₑ η) N₁) (ren (liftₑ η) N₂) ren∼ η (comm⩖⁇∥ M N₁ N₂ O₁ O₂) = coe ((((ren η M ⁇ ren (liftₑ η) N₁ ∥ ren (liftₑ η) N₂) ⁇ ren (liftₑ η) O₁ ∥ ren (liftₑ η) O₂) ∼_) & ((λ N₁′ N₂′ → ren η M ⁇ N₁′ ∥ N₂′) & ((λ O₁′ O₂′ → ren (liftₑ η) N₁ ⁇ O₁′ ∥ O₂′) & renliftwk η O₁ ⊗ renliftwk η O₂) ⊗ ((λ O₁′ O₂′ → ren (liftₑ η) N₂ ⁇ O₁′ ∥ O₂′) & renliftwk η O₁ ⊗ renliftwk η O₂))) (comm⩖⁇∥ (ren η M) (ren (liftₑ η) N₁) (ren (liftₑ η) N₂) (ren (liftₑ η) O₁) (ren (liftₑ η) O₂)) --------------------------------------------------------------------------------
{ "alphanum_fraction": 0.2577934135, "avg_line_length": 35.6550522648, "ext": "agda", "hexsha": "214ceefe248fe68560db0bd300f13e7fa1a106d9", "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": "bd626509948fbf8503ec2e31c1852e1ac6edcc79", "max_forks_repo_licenses": [ "X11" ], "max_forks_repo_name": "mietek/coquand-kovacs", "max_forks_repo_path": "src/STLC2/Kovacs/Convertibility.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "bd626509948fbf8503ec2e31c1852e1ac6edcc79", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "X11" ], "max_issues_repo_name": "mietek/coquand-kovacs", "max_issues_repo_path": "src/STLC2/Kovacs/Convertibility.agda", "max_line_length": 80, "max_stars_count": null, "max_stars_repo_head_hexsha": "bd626509948fbf8503ec2e31c1852e1ac6edcc79", "max_stars_repo_licenses": [ "X11" ], "max_stars_repo_name": "mietek/coquand-kovacs", "max_stars_repo_path": "src/STLC2/Kovacs/Convertibility.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 4491, "size": 10233 }
module Algebra.Dioid where record Dioid A (_≡_ : A -> A -> Set) : Set where field zero : A one : A _+_ : A -> A -> A _*_ : A -> A -> A reflexivity : ∀ {r : A} -> r ≡ r symmetry : ∀ {r s : A} -> r ≡ s -> s ≡ r transitivity : ∀ {r s t : A} -> r ≡ s -> s ≡ t -> r ≡ t +left-congruence : ∀ {r s t : A} -> r ≡ s -> (r + t) ≡ (s + t) -- +right-congruence holds but as a theorem, please see below *left-congruence : ∀ {r s t : A} -> r ≡ s -> (r * t) ≡ (s * t) *right-congruence : ∀ {r s t : A} -> r ≡ s -> (t * r) ≡ (t * s) +idempotence : ∀ {r : A} -> (r + r) ≡ r +commutativity : ∀ {r s : A} -> (r + s) ≡ (s + r) +associativity : ∀ {r s t : A} -> (r + (s + t)) ≡ ((r + s) + t) +zero-identity : ∀ {r : A} -> (r + zero) ≡ r *associativity : ∀ {r s t : A} -> (r * (s * t)) ≡ ((r * s) * t) *left-zero : ∀ {r : A} -> (zero * r) ≡ zero *right-zero : ∀ {r : A} -> (r * zero) ≡ zero *left-identity : ∀ {r : A} -> (one * r) ≡ r *right-identity : ∀ {r : A} -> (r * one) ≡ r left-distributivity : ∀ {r s t : A} -> (r * (s + t)) ≡ ((r * s) + (r * t)) right-distributivity : ∀ {r s t : A} -> ((r + s) * t) ≡ ((r * t) + (s * t)) -- For convenience to avoid `Dioid._+_ d r s` plus : A -> A -> A plus x y = x + y times : A -> A -> A times x y = x * y +right-congruence : ∀ {D eq} {d : Dioid D eq} {r s t : D} -> eq r s -> eq (Dioid.plus d t r) (Dioid.plus d t s) +right-congruence {_} {_} {d} {r} {s} {t} e = trans commut (trans (Dioid.+left-congruence d e) commut) where trans = Dioid.transitivity d commut = Dioid.+commutativity d
{ "alphanum_fraction": 0.4163802978, "avg_line_length": 38.8, "ext": "agda", "hexsha": "fdb959123b24fa66fbb299406cebe83e7a0ecdb7", "lang": "Agda", "max_forks_count": 6, "max_forks_repo_forks_event_max_datetime": "2019-05-09T23:53:28.000Z", "max_forks_repo_forks_event_min_datetime": "2017-12-17T20:48:20.000Z", "max_forks_repo_head_hexsha": "0fdb96c0233d9be83eba637f0434d0fd22aefb1d", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "snowleopard/alga-proofs", "max_forks_repo_path": "src/Algebra/Dioid.agda", "max_issues_count": 3, "max_issues_repo_head_hexsha": "0fdb96c0233d9be83eba637f0434d0fd22aefb1d", "max_issues_repo_issues_event_max_datetime": "2018-06-23T13:54:02.000Z", "max_issues_repo_issues_event_min_datetime": "2018-04-12T16:25:13.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "snowleopard/alga-proofs", "max_issues_repo_path": "src/Algebra/Dioid.agda", "max_line_length": 111, "max_stars_count": 60, "max_stars_repo_head_hexsha": "0fdb96c0233d9be83eba637f0434d0fd22aefb1d", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "snowleopard/alga-proofs", "max_stars_repo_path": "src/Algebra/Dioid.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-22T23:05:29.000Z", "max_stars_repo_stars_event_min_datetime": "2017-12-27T14:57:04.000Z", "num_tokens": 736, "size": 1746 }
------------------------------------------------------------------------ -- Pointers to results from the paper ------------------------------------------------------------------------ module README.Pointers-to-results-from-the-paper where open import Prelude using (Type) open import Prelude.Size using (∞) import Colist import Conat import Omniscience import Delay-monad import Delay-monad.Bisimilarity import Delay-monad.Monad import Delay-monad.Quantitative-weak-bisimilarity import Only-allocation import Unbounded-space import Upper-bounds import Lambda.Compiler import Lambda.Compiler-correctness import Lambda.Compiler-correctness.Sizes-match import Lambda.Compiler-correctness.Steps-match import Lambda.Delay-crash import Lambda.Delay-crash-trace import Lambda.Interpreter import Lambda.Interpreter.Stack-sizes import Lambda.Interpreter.Stack-sizes.Counterexample import Lambda.Interpreter.Stack-sizes.Example import Lambda.Interpreter.Steps import Lambda.Interpreter.Steps.Counterexample import Lambda.Virtual-machine import Lambda.Virtual-machine.Instructions import Lambda.Syntax ------------------------------------------------------------------------ -- Section 2 -- Conatural numbers. Conat = Conat.Conat Conat′ = Conat.Conat′ -- Infinity. infinity = Conat.infinity -- Ordering. [_]_≤_ = Conat.[_]_≤_ [_]_≤′_ = Conat.[_]_≤′_ -- Bisimilarity. [_]_∼N_ = Conat.[_]_∼_ ------------------------------------------------------------------------ -- Section 3 -- Programs. Stmt = Only-allocation.Stmt Program = Only-allocation.Program -- Colists. Colist = Colist.Colist -- The interpreter. modify = Unbounded-space.modify ⟦_⟧₁ = Unbounded-space.⟦_⟧ ⟦_⟧′ = Unbounded-space.⟦_⟧′ -- Upper bounds. [_]_⊑_ = Upper-bounds.[_]_⊑_ [_]_⊑′_ = Upper-bounds.[_]_⊑′_ -- The □ predicate. □ = Colist.□ -- Least upper bounds. LUB = Upper-bounds.LUB -- Least upper bounds are unique up to bisimilarity. lub-unique = Upper-bounds.lub-unique -- Antisymmetry for conatural numbers. antisymmetric = Conat.antisymmetric-≤ -- WLPO. WLPO = Omniscience.WLPO -- WLPO is classically valid: it follows from excluded middle and -- extensionality for functions. LEM→WLPO = Omniscience.LEM→WLPO -- WLPO is logically equivalent to one formulation of "least upper -- bounds exist for every colist". wlpo⇔lub = Unbounded-space.wlpo⇔lub -- Maximum heap usage. Heap-usage = Unbounded-space.Heap-usage -- This was not mentioned in the paper, but WLPO is also logically -- equivalent to one formulation of "maximum heap usages exist for -- every program". wlpo⇔max = Unbounded-space.wlpo⇔max -- The maximum heap usage is unique up to bisimilarity. max-unique = Unbounded-space.max-unique -- Some examples. bounded = Only-allocation.bounded bounded₂ = Only-allocation.bounded₂ unbounded = Only-allocation.unbounded _∷′_ = Colist._∷′_ -- The example programs have infinitely long traces. bounded-loops = Unbounded-space.bounded-loops bounded₂-loops = Unbounded-space.bounded₂-loops unbounded-loops = Unbounded-space.unbounded-loops -- Properties showing that the example programs have certain maximum -- heap usages. max-bounded-1 = Unbounded-space.max-bounded-1 max-bounded₂-2 = Unbounded-space.max-bounded₂-2 max-unbounded-∞ = Unbounded-space.max-unbounded-∞ -- If no natural number is an upper bound of the heap usage of p, then -- the maximum heap usage of p is infinity. no-finite-max→infinite-max = Unbounded-space.no-finite-max→infinite-max -- If no natural number is an upper bound of ms, but the conatural -- number m is, then m is bisimilar to infinity. no-finite→infinite = Upper-bounds.no-finite→infinite ------------------------------------------------------------------------ -- Section 4 -- The optimiser. opt = Unbounded-space.opt -- The optimiser improves the space complexity of at least one -- program. opt-improves = Unbounded-space.opt-improves -- The semantics of optimise bounded-space₂ matches that of -- bounded-space. opt-bounded₂∼bounded = Unbounded-space.opt-bounded₂∼bounded -- Bisimilarity of colists. [_]_∼L_ = Colist.[_]_∼_ -- The maximum heap usage of an optimised program is at most as high -- as that of the original program (assuming that these maximums -- exist). opt-correct = Unbounded-space.opt-correct -- The [_]_≲_ relation. [_]_≲_ = Upper-bounds.[_]_≲_ [_]_≲′_ = Upper-bounds.[_]_≲′_ -- If ms has the least upper bound m, and ns has the least upper bound -- n, then ms is bounded by ns if and only if m is bounded by n. ≲⇔least-upper-bounds-≤ = Upper-bounds.≲⇔least-upper-bounds-≤ -- Four combinators that can be used to prove that one colist is -- bounded by another. []≲ = Upper-bounds.[]≲ consʳ-≲ = Upper-bounds.consʳ-≲ consˡ-≲ = Upper-bounds.consˡ-≲ cons′-≲ = Upper-bounds.cons′-≲ Bounded = Upper-bounds.Bounded -- If consʳ-≲ had taken the primed variant of the relation as an -- argument instead, then one could have proved that any colist was -- bounded by any infinite colist, and this leads to a contradiction. consʳ-≲′→≲-infinite = Upper-bounds.consʳ-≲′→≲-infinite ¬-consʳ-≲′ = Upper-bounds.¬-consʳ-≲′ -- The [_]_≲_ relation is a preorder. (The transitivity result has a -- type signature that differs slightly from that given in the paper.) reflexive-≲ = Upper-bounds._□≲ transitive-≲ = Upper-bounds.step-≲ -- Transitivity cannot be made size-preserving in the second argument. ¬-transitivity-size-preservingʳ = Upper-bounds.¬-transitivity-size-preservingʳ -- A size-preserving variant of transitivity. (This result has a -- type signature that differs slightly from that given in the paper.) transitive-∼≲ = Upper-bounds.step-∼≲ -- The main lemma used to prove that the maximum heap usage of an -- optimised program is at most as high as that of the original -- program (assuming that these maximums exist). opt-correct-≲ = Unbounded-space.opt-correct-≲ ------------------------------------------------------------------------ -- Section 5 -- The delay monad. Delay = Delay-monad.Delay -- The non-terminating computation never. never = Delay-monad.never -- Monad instance. monad-instance₁ = Delay-monad.Monad.delay-raw-monad -- Strong bisimilarity. [_]_∼D_ = Delay-monad.Bisimilarity.[_]_∼_ -- Monad laws. left-identity₁ = Delay-monad.Monad.left-identity′ right-identity₁ = Delay-monad.Monad.right-identity′ associativity₁ = Delay-monad.Monad.associativity′ -- Weak bisimilarity. (This relation is not defined in exactly the -- same way as in the paper.) [_]_≈D_ = Delay-monad.Bisimilarity.[_]_≈_ ------------------------------------------------------------------------ -- Section 6 -- Terms. Tm = Lambda.Syntax.Tm -- Environments and values. (The code uses a definition which is -- parametrised by the type of terms. The same definition is used also -- for virtual machine environments and values.) Env = Lambda.Syntax.Closure.Env Value = Lambda.Syntax.Closure.Value -- DelayC (called Delay-crash in the code) and crash. DelayC = Lambda.Delay-crash.Delay-crash crash : {A : Type} → DelayC A ∞ crash = Lambda.Delay-crash.crash -- The computation crash (in fact, any computation of the form now x) -- is not weakly bisimilar to never. now≉never = Delay-monad.Bisimilarity.now≉never -- The interpreter. _∙_ = Lambda.Interpreter._∙_ ⟦_⟧₂ = Lambda.Interpreter.⟦_⟧ ⟦if⟧ = Lambda.Interpreter.⟦if⟧ ------------------------------------------------------------------------ -- Section 7 -- DelayCT (called Delay-crash-trace in the code). DelayCT = Lambda.Delay-crash-trace.Delay-crash-trace trace = Lambda.Delay-crash-trace.trace delayC = Lambda.Delay-crash-trace.delay-crash -- Monad instance. monad-instance₂ = Lambda.Delay-crash-trace.raw-monad -- Strong bisimilarity. [_]_∼DCT_ = Lambda.Delay-crash-trace.[_]_∼_ -- Monad laws. left-identity₂ = Lambda.Delay-crash-trace.left-identity right-identity₂ = Lambda.Delay-crash-trace.right-identity associativity₂ = Lambda.Delay-crash-trace.associativity -- Instructions and code. Instr = Lambda.Virtual-machine.Instructions.Instr Code = Lambda.Virtual-machine.Instructions.Code -- Environments and values. (The code uses a definition which is -- parametrised by the type of terms. The same definition is used also -- for the interpreter's environments and values.) VM-Env = Lambda.Syntax.Closure.Env VM-Value = Lambda.Syntax.Closure.Value -- Stack elements and stacks. Stack-element = Lambda.Virtual-machine.Instructions.Stack-element Stack = Lambda.Virtual-machine.Instructions.Stack -- States. State = Lambda.Virtual-machine.Instructions.State -- The virtual machine. Result = Lambda.Virtual-machine.Instructions.Result step = Lambda.Virtual-machine.step exec⁺ = Lambda.Virtual-machine.exec⁺ exec⁺′ = Lambda.Virtual-machine.exec⁺′ exec = Lambda.Virtual-machine.exec stack-sizes = Lambda.Virtual-machine.stack-sizes ------------------------------------------------------------------------ -- Section 8 -- Tail context information. In-tail-context = Lambda.Compiler.In-tail-context -- The compilation functions. comp = Lambda.Compiler.comp comp-body = Lambda.Compiler.comp-body comp-name = Lambda.Compiler.comp-name comp-env = Lambda.Compiler.comp-env comp-val = Lambda.Compiler.comp-val comp₀ = Lambda.Compiler.comp₀ -- Compiler correctness. compiler-correct = Lambda.Compiler-correctness.correct -- The key lemma used to prove compiler correctness. key-lemma₁ = Lambda.Compiler-correctness.⟦⟧-correct Cont-OK = Lambda.Compiler-correctness.Cont-OK Stack-OK = Lambda.Compiler-correctness.Stack-OK ------------------------------------------------------------------------ -- Section 9 -- The instrumented interpreter. [_,_]_∙S_ = Lambda.Interpreter.Stack-sizes.[_,_]_∙_ ⟦_⟧S = Lambda.Interpreter.Stack-sizes.⟦_⟧ δ = Lambda.Interpreter.Stack-sizes.δ ⟦if⟧S = Lambda.Interpreter.Stack-sizes.⟦if⟧ scanl = Colist.scanl numbers = Lambda.Interpreter.Stack-sizes.numbers stack-sizesS = Lambda.Interpreter.Stack-sizes.stack-sizes -- The instrumented semantics produces computations that are strongly -- bisimilar to those produced by the other semantics. ⟦⟧∼⟦⟧ = Lambda.Interpreter.Stack-sizes.⟦⟧∼⟦⟧ -- If the trace of stack sizes produced by the instrumented semantics -- has the least upper bound i, and the corresponding trace produced -- by the virtual machine has the least upper bound v, then i and v -- are bisimilar. maximum-stack-sizes-match = Lambda.Compiler-correctness.Sizes-match.maximum-stack-sizes-match -- The trace of stack sizes produced by the virtual machine is not -- necessarily bisimilar to that produced by the instrumented -- interpreter. stack-sizes-not-bisimilar = Lambda.Interpreter.Stack-sizes.Counterexample.stack-sizes-not-bisimilar -- The trace of stack sizes produced by the virtual machine and that -- produced by the instrumented interpreter are upper bounds of each -- other. stack-sizes-related = Lambda.Compiler-correctness.Sizes-match.stack-sizes-related -- The [_]_≂_ relation. [_]_≂_ = Upper-bounds.[_]_≂_ [_]_≂′_ = Upper-bounds.[_]_≂′_ -- Colists that are related by this relation have the same least upper -- bounds (if any). LUB-cong = Upper-bounds.LUB-cong -- Some combinators that can be used to prove that two colists are -- bounded by each other. consʳ-≂ = Upper-bounds.consʳ-≂ consˡ-≂ = Upper-bounds.consˡ-≂ cons-≂ = Upper-bounds.cons-≂ cons′-≂ = Upper-bounds.cons′-≂ -- The [_]_≂_ relation is an equivalence relation. (The -- transitivity-like results have type signatures that differ slightly -- from those given in the paper.) reflexive-≂ = Upper-bounds._□≂ symmetric-≂ = Upper-bounds.symmetric-≂ transitive-≂ = Upper-bounds.step-≂ transitive-∼≂ = Upper-bounds.step-∼≂ transitive-≂∼ = Upper-bounds.step-≂∼ -- The [_]_≂″_ relation. [_]_≂″_ = Upper-bounds.[_]_≂″_ -- [_]_≂′_ and [_]_≂″_ are pointwise logically equivalent. ≂′⇔≂″ = Upper-bounds.≂′⇔≂″ -- This was not mentioned in the paper, but a corresponding relation -- can also be defined for [_]_≲′_. [_]_≲″_ = Upper-bounds.[_]_≲″_ ≲′⇔≲″ = Upper-bounds.≲′⇔≲″ -- The key lemma used to prove correctness. key-lemma₂ = Lambda.Compiler-correctness.Sizes-match.⟦⟧-correct -- A non-terminating program that requires unbounded stack space. Ω = Lambda.Syntax.Ω Ω-loops = Lambda.Interpreter.Ω-loops′ Ω-requires-unbounded-space = Lambda.Interpreter.Stack-sizes.Ω-requires-unbounded-space -- A non-terminating program that runs in bounded stack space. go = Lambda.Interpreter.Stack-sizes.Example.go go-loops = Lambda.Interpreter.Stack-sizes.Example.go-loops go-bounded-stack = Lambda.Interpreter.Stack-sizes.Example.go-bounded-stack ------------------------------------------------------------------------ -- Section 10 -- The uninstrumented interpreter does not provide a suitable cost -- measure, in the sense that there is a family of programs for which -- the running "time" (number of steps) of the corresponding compiled -- programs on the virtual machine is not linear in the running time -- on the interpreter. not-suitable-cost-measure = Lambda.Interpreter.Steps.Counterexample.not-suitable-cost-measure -- The instrumented interpreter. ✓_ = Lambda.Interpreter.Steps.✓_ _∙T_ = Lambda.Interpreter.Steps._∙_ ⟦_⟧T = Lambda.Interpreter.Steps.⟦_⟧ ⟦if⟧T = Lambda.Interpreter.Steps.⟦if⟧ -- The cost measure provided by the instrumented interpreter is -- "suitable", in the sense that the cost of running a compiled -- program on the virtual machine is linear in the cost of running the -- corresponding source program on the interpreter, and vice versa. the-cost-measure-is-suitable = Lambda.Compiler-correctness.Steps-match.steps-match -- Quantitative weak bisimilarity. [_∣_∣_∣_∣_]_≈D_ = Delay-monad.Quantitative-weak-bisimilarity.[_∣_∣_∣_∣_]_≈_ -- A characterisation of quantitative weak bisimilarity. ≈⇔≈×steps≤steps² = Delay-monad.Quantitative-weak-bisimilarity.≈⇔≈×steps≤steps² -- The left-to-right direction of the characterisation can be made -- size-preserving. ≈→≈×steps≤steps² = Delay-monad.Quantitative-weak-bisimilarity.≈→≈×steps≤steps² -- The right-to-left direction of the characterisation can be made -- size-preserving if and only if the carrier type is uninhabited -- (assuming that Agda is not buggy). ≈×steps≤steps²→≈⇔uninhabited = Delay-monad.Quantitative-weak-bisimilarity.≈×steps≤steps²→≈⇔uninhabited -- Weakening. weaken = Delay-monad.Quantitative-weak-bisimilarity.weaken -- Two transitivity-like results. transitive-≳∼ = Delay-monad.Quantitative-weak-bisimilarity.transitive-≳∼ transitive-≈∼ = Delay-monad.Quantitative-weak-bisimilarity.transitive-≈∼ transitive-∼≈ = Delay-monad.Quantitative-weak-bisimilarity.transitive-∼≈ -- The key lemma used to prove that the cost measure is "suitable". key-lemma₃ = Lambda.Compiler-correctness.Steps-match.⟦⟧-correct
{ "alphanum_fraction": 0.6999130958, "avg_line_length": 27.9085820896, "ext": "agda", "hexsha": "19c0610c5c60cdea32e4c66749d50700efae9f78", "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": "dec8cd2d2851340840de25acb0feb78f7b5ffe96", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "nad/definitional-interpreters", "max_forks_repo_path": "README/Pointers-to-results-from-the-paper.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "dec8cd2d2851340840de25acb0feb78f7b5ffe96", "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/definitional-interpreters", "max_issues_repo_path": "README/Pointers-to-results-from-the-paper.agda", "max_line_length": 73, "max_stars_count": null, "max_stars_repo_head_hexsha": "dec8cd2d2851340840de25acb0feb78f7b5ffe96", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "nad/definitional-interpreters", "max_stars_repo_path": "README/Pointers-to-results-from-the-paper.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 4116, "size": 14959 }
module Data.Lens.Proofs.LensPostulates where open import Haskell.Prelude renaming (zero to Z; suc to S) open import Data.Lens.Lens open import Data.Logic open import Agda.Primitive open import Data.Lens.Proofs.LensLaws ---- Lens postulates -- These are provable using the isomorphism to the getter+setter style -- However, defining this isomorphism is quite a bit of work, so I didn't do it for now postulate -- view (l1 ∘ l2) ≡ view l2 ∘ view l1 -- This is clearly true from how view works prop-view-compose : {a b c : Set} -> (l1 : ValidLens a b) -> (l2 : ValidLens b c) -> (v : a) -> (view ((toLens l1) ∘ (toLens l2))) v ≡ (view (toLens l2) ∘ view (toLens l1)) v -- set (l1 ∘ l2) ≡ over l1 (set l2 t) v -- This is clearly true from how set works prop-set-compose : {a b c : Set} -> (l1 : ValidLens a b) -> (l2 : ValidLens b c) -> (v : a) (t : c) -> (set ((toLens l1) ∘ (toLens l2))) t v ≡ over (toLens l1) (set (toLens l2) t) v -- over l ≡ set l (view l v) v -- This is clearly true from how over works prop-over-is-setget : {a b : Set} -> (l : ValidLens a b) -> (f : b -> b) (v : a) -> over (toLens l) f v ≡ set (toLens l) (f (view (toLens l) v)) v -- We can merge postulate 2 and 3 prop-set-compose-dir : {a b c : Set} -> (l1 : ValidLens a b) -> (l2 : ValidLens b c) -> (v : a) (t : c) -> (set ((toLens l1) ∘ (toLens l2))) t v ≡ set (toLens l1) ((set (toLens l2) t) (view (toLens l1) v)) v prop-set-compose-dir vl1@(CValidLens l1 vs1 sv1 ss1) vl2@(CValidLens l2 vs2 sv2 ss2) v t = begin set (l1 ∘ l2) t v =⟨ prop-set-compose vl1 vl2 v t ⟩ over l1 (set l2 t) v =⟨ prop-over-is-setget vl1 (set l2 t) v ⟩ set l1 ((set l2 t) (view l1 v)) v end
{ "alphanum_fraction": 0.5692475463, "avg_line_length": 37.4285714286, "ext": "agda", "hexsha": "f4fdc1bae61c5a3a0744c92ba3bde1e0252e8c73", "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": "4959a3c9cd8563a1726e0e968e6a179008cd4d9f", "max_forks_repo_licenses": [ "Unlicense" ], "max_forks_repo_name": "JonathanBrouwer/research-project", "max_forks_repo_path": "src/Data/Lens/Proofs/LensPostulates.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "4959a3c9cd8563a1726e0e968e6a179008cd4d9f", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "Unlicense" ], "max_issues_repo_name": "JonathanBrouwer/research-project", "max_issues_repo_path": "src/Data/Lens/Proofs/LensPostulates.agda", "max_line_length": 107, "max_stars_count": 1, "max_stars_repo_head_hexsha": "4959a3c9cd8563a1726e0e968e6a179008cd4d9f", "max_stars_repo_licenses": [ "Unlicense" ], "max_stars_repo_name": "JonathanBrouwer/research-project", "max_stars_repo_path": "src/Data/Lens/Proofs/LensPostulates.agda", "max_stars_repo_stars_event_max_datetime": "2021-05-25T09:10:20.000Z", "max_stars_repo_stars_event_min_datetime": "2021-05-25T09:10:20.000Z", "num_tokens": 673, "size": 1834 }
module examplesPaperJFP.Collatz where open import Data.Nat.Base open import Data.Nat.DivMod open import Data.Fin using (Fin; zero; suc) open import examplesPaperJFP.Colists collatzStep : ℕ → ListF ℕ ℕ collatzStep 1 = nil collatzStep n with n divMod 2 ... | result q zero _ = cons n q ... | _ = cons n (1 + 3 * n) collatzSequence : ℕ → Colist ℕ collatzSequence = unfold collatzStep open Colist open import Data.List displayList : Colist ℕ → ℕ → List ℕ displayList s 0 = [] displayList s (suc m) with force s ... | nil = [] ... | (cons k s′) = k ∷ displayList s′ m displayCollatz : ℕ → ℕ → List ℕ displayCollatz n m = displayList (collatzSequence n) m
{ "alphanum_fraction": 0.6479663394, "avg_line_length": 23.7666666667, "ext": "agda", "hexsha": "6da90d2653fa6b7e8e9b103ea3be79826f242a21", "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/examplesPaperJFP/Collatz.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/examplesPaperJFP/Collatz.agda", "max_line_length": 54, "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/examplesPaperJFP/Collatz.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": 226, "size": 713 }
import Lvl open import Type module Type.Univalence where open import Functional import Logic.Predicate import Relator.Equals import Relator.Equals.Proofs import Type.Cardinality import Type.Cardinality.Proofs import Type.Functions import Type.Functions.Inverse module _ {ℓₗ ℓₒ : Lvl.Level} where open Logic.Predicate open Relator.Equals{ℓₗ Lvl.⊔ ℓₒ}{Lvl.𝐒(ℓₒ)} open Type.Cardinality {ℓₗ} open Type.Cardinality.Proofs {ℓₗ} open Type.Functions UnivalenceAxiom : Type{ℓₗ Lvl.⊔ Lvl.𝐒(ℓₒ)} UnivalenceAxiom = ∀{X Y : Type{ℓₒ}} → Bijective{ℓₗ Lvl.⊔ Lvl.𝐒(ℓₒ)} ([≡]-to-[≍] {ℓₒ} {X}{Y}) module _ {ℓₗ ℓₒ : Lvl.Level} {univalence : UnivalenceAxiom} where open Logic.Predicate open Relator.Equals open Relator.Equals.Proofs open Type.Cardinality open Type.Cardinality.Proofs open Type.Functions.Inverse instance [≡][≍]-bijection : ∀{X Y} → ((X ≡ Y) ≍ (X ≍ Y)) [≡][≍]-bijection {X}{Y} = [∃]-intro ([≡]-to-[≍] {ℓₗ}{ℓₒ} {X}{Y}) ⦃ univalence{X}{Y} ⦄ [≍]-to-[≡] : ∀{X Y : Type{ℓₒ}} → (X ≍ Y) → (X ≡ Y) [≍]-to-[≡] {X}{Y} = inv([≡]-to-[≍] {ℓₗ}{ℓₒ} {X}{Y}) ⦃ univalence {X}{Y} ⦄ module _ {ℓₗ ℓₒ₁ ℓₒ₂ : Lvl.Level} {univalence : UnivalenceAxiom {ℓₗ Lvl.⊔ Lvl.𝐒(ℓₒ₁)}{ℓₒ₁}} where open Logic.Predicate open Relator.Equals open Relator.Equals.Proofs open Type.Cardinality {ℓₗ Lvl.⊔ Lvl.𝐒(ℓₒ₁)} open Type.Cardinality.Proofs {ℓₗ Lvl.⊔ Lvl.𝐒(ℓₒ₁)} open Type.Functions _≡₂_ = _≡_ {ℓₗ}{ℓₒ₂} _≡ₗ_ = _≡_ {ℓₗ} -- For any type function P from an universe Type{ℓₒ₁} to Type{ℓₒ₂} -- where subst, a substitution for P holds using (_≍_) -- and where the substitution by reflexivity using (_≍_) gives the exact same proof (is a identity function), -- then this substitution will give the same results as the standard substitution rule for equalities (_≡_) for this P. postulate transport-theorem : ∀{P : Type{ℓₒ₁} → Type{ℓₒ₂}} → (subst : (∀{X Y} → (X ≍ Y) → P(X) → P(Y))) → (subst-id : (∀{X} → (px : P(X)) → (subst([≍]-reflexivity) (px) ≡₂ px))) → ∀{X Y} → (xy : (X ≍ Y)) → (px : P(X)) → (subst(xy) (px) ≡₂ [≡]-substitutionᵣ {ℓₗ Lvl.⊔ Lvl.𝐒(ℓₒ₁)}{Lvl.𝐒(ℓₒ₁)} ([≍]-to-[≡] {ℓₗ Lvl.⊔ Lvl.𝐒(ℓₒ₁)}{ℓₒ₁} {univalence} (xy)) {P} px) -- transport-theorem {P} (subst) (subst-id) ([∃]-intro bijection ⦃ bijective ⦄) px = -- subst(xy) (px) -- = subst(inv bijection (bijection xy)) (px) -- = [≡]-substitutionᵣ (bijection xy) {P} (px) postulate substitution-is-bijective : ∀{P : Type{ℓₒ₁} → Type{ℓₒ₂}} → (subst : (∀{X Y} → (X ≍ Y) → P(X) → P(Y))) → (subst-id : (∀{X} → (px : P(X)) → (subst([≍]-reflexivity) (px) ≡₂ px))) → ∀{X Y}{xy : (X ≍ Y)} → Bijective{ℓₗ Lvl.⊔ Lvl.𝐒(ℓₒ₂)} (subst(xy)) -- TODO: univalence should probably have other level parameters from this point on postulate [∘]ₗ-bijective : ∀{ℓₒ₃}{X : Type{ℓₒ₁}}{Y : Type{ℓₒ₂}}{Z : Type{ℓₒ₃}}{g : X → Y} → Bijective{ℓₗ}(g) → Bijective{ℓₗ}(\(f : Y → Z) → f ∘ g) postulate [∘]ₗ-cancellationᵣ : ∀{ℓₒ₃}{X : Type{ℓₒ₁}}{Y : Type{ℓₒ₂}}{Z : Type{ℓₒ₃}}{f g : Y → Z}{h : X → Y} → Bijective{ℓₗ}(h) → (f ∘ h ≡ₗ g ∘ h) → (f ≡ₗ g) -- subst{T} P {x}{y} xy fx = [≡]-substitutionᵣ{T}{x}{y} (xy) {P} fx
{ "alphanum_fraction": 0.5644871026, "avg_line_length": 42.2025316456, "ext": "agda", "hexsha": "1e2fddf3d258456942a79b2f494dd2bfb061d0b3", "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": "old/Type/Univalence.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": "old/Type/Univalence.agda", "max_line_length": 160, "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": "old/Type/Univalence.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": 1489, "size": 3334 }
module static where open import Data.Nat using (ℕ; _+_; zero; suc) open import Data.Fin using (Fin; toℕ; zero; suc) open import Data.Vec using (lookup; _∷_; []) open import Data.Bool using (Bool; true; false) open import LSsyntax open import Relation.Binary.PropositionalEquality -- using (_≡_; refl) -- inference rules for typed terms data STyped {n} (Γ : Ctx n) : GType → Set where Sx : ∀ {S} (v : Fin n) → S ≡ lookup v Γ → STyped Γ S Sb : Bool → (ℓ : Label) → STyped Γ (bool ℓ) _S∧_ : ∀ {t₁ t₂} → STyped Γ t₁ → STyped Γ t₂ → STyped Γ (bool (getLabel t₁ ~⋎~ getLabel t₂)) _S∨_ : ∀ {t₁ t₂} → STyped Γ t₁ → STyped Γ t₂ → STyped Γ (bool (getLabel t₁ ~⋎~ getLabel t₂)) Sif : ∀ {t t₁ t₂} → STyped Γ t → STyped Γ t₁ → STyped Γ t₂ → STyped Γ (bool (getLabel (t₁ :∨: t₂) ~⋎~ getLabel t)) S∙ : ∀ {t₁ ℓ t₂ t₃} → STyped Γ ((t₁ ⇒ ℓ) t₂) → STyped Γ t₃ → t₃ ≾ t₁ → STyped Γ (bool ((getLabel t₂) ~⋎~ ℓ)) Sλ : ∀ t₁ {t₂} ℓ → STyped (t₁ ∷ Γ) t₂ → STyped Γ ((t₁ ⇒ ℓ) t₂) erase : ∀ {n} {Γ : Ctx n} {t} → STyped Γ t → Term erase (Sx v x) = var (toℕ v) erase (Sb b ℓ) = litBool b ℓ erase (t₁ S∧ t₂) = (erase t₁) ∧ erase t₂ erase (t₁ S∨ t₂) = (erase t₁) ∨ (erase t₂) erase (Sif b t₁ t₂) = if (erase b) then (erase t₁) else (erase t₂) erase (S∙ t₁ t₂ _) = (erase t₁) ∙ (erase t₂) erase (Sλ t₁ ℓ t) = lam t₁ (erase t) ℓ data Fromℕ (n : ℕ) : ℕ → Set where yes : (m : Fin n) → Fromℕ n (toℕ m) no : (m : ℕ) → Fromℕ n (n + m) fromℕ : ∀ n m → Fromℕ n m fromℕ zero m = no m fromℕ (suc n) zero = yes zero fromℕ (suc n) (suc m) with fromℕ n m fromℕ (suc n) (suc .(toℕ m)) | yes m = yes (suc m) fromℕ (suc n) (suc .(n + m)) | no m = no m data Check {n} (Γ : Ctx n) : Term → Set where yes : (τ : GType) (t : STyped Γ τ) → Check Γ (erase t) no : {e : Term} → Check Γ e staticCheck : ∀ {n} (Γ : Ctx n) (t : Term) → Check Γ t staticCheck {n} Γ (var v) with fromℕ n v staticCheck {n} Γ (var .(toℕ m)) | yes m = yes (lookup m Γ) (Sx m refl) staticCheck {n} Γ (var .(n + m)) | no m = no staticCheck Γ (litBool x ℓ) = yes (bool ℓ) (Sb x ℓ) staticCheck Γ (lam x t ℓ) with staticCheck (x ∷ Γ) t staticCheck Γ (lam x .(erase t) ℓ) | yes τ t = yes ((x ⇒ ℓ) τ) (Sλ x ℓ t) staticCheck Γ (lam x t ℓ) | no = no staticCheck Γ (t ∧ t₁) with staticCheck Γ t | staticCheck Γ t₁ staticCheck Γ (.(erase t₁) ∧ .(erase t)) | yes τ₁ t₁ | (yes τ t) = yes (bool (getLabel τ₁ ~⋎~ getLabel τ)) (t₁ S∧ t) staticCheck Γ (.(erase t) ∧ t₁) | yes τ t | no = no staticCheck Γ (t₁ ∧ .(erase t)) | no | yes τ t = no staticCheck Γ (t ∧ t₁) | no | no = no staticCheck Γ (t ∨ t₁) with staticCheck Γ t | staticCheck Γ t₁ staticCheck Γ (.(erase t₁) ∨ .(erase t)) | yes τ₁ t₁ | (yes τ t) = yes (bool (getLabel τ₁ ~⋎~ getLabel τ)) (t₁ S∨ t) staticCheck Γ (.(erase t) ∨ t₁) | yes τ t | no = no staticCheck Γ (t₁ ∨ .(erase t)) | no | yes τ t = no staticCheck Γ (t ∨ t₁) | no | no = no staticCheck Γ (t ∙ t₁) with staticCheck Γ t | staticCheck Γ t₁ staticCheck Γ (.(erase t) ∙ .(erase t₁)) | yes ((τ ⇒ ℓ) τ₂) t | (yes τ₁ t₁) with τ₁ ≾? τ staticCheck Γ (.(erase t) ∙ .(erase t₁)) | yes ((τ ⇒ ℓ) τ₂) t | (yes τ₁ t₁) | (yes .τ₁ .τ) = yes (bool (getLabel τ₂ ~⋎~ ℓ)) (S∙ t t₁ (yes τ₁ τ)) staticCheck Γ (.(erase t) ∙ .(erase t₁)) | yes ((τ ⇒ ℓ) τ₂) t | (yes τ₁ t₁) | (no .τ₁ .τ) = no staticCheck Γ (.(erase t) ∙ .(erase t₁)) | yes err t | (yes τ₁ t₁) = no staticCheck Γ (.(erase t) ∙ .(erase t₁)) | yes (bool x) t | (yes τ₁ t₁) = no staticCheck Γ (.(erase t) ∙ t₁) | yes τ t | no = no staticCheck Γ (t₁ ∙ .(erase t)) | no | yes τ t = no staticCheck Γ (t ∙ t₁) | no | no = no staticCheck Γ (if b then t₁ else t₂) with staticCheck Γ b staticCheck Γ (if .(erase t) then t₁ else t₂) | yes τ t with staticCheck Γ t₁ | staticCheck Γ t₂ staticCheck Γ (if .(erase t₂) then .(erase t₁) else .(erase t)) | yes τ₂ t₂ | (yes τ₁ t₁) | (yes τ t) = yes (bool (getLabel (τ₁ :∨: τ) ~⋎~ getLabel τ₂)) (Sif t₂ t₁ t) staticCheck Γ (if .(erase t₁) then .(erase t) else t₂) | yes τ₁ t₁ | (yes τ t) | no = no staticCheck Γ (if .(erase t₂) then t₁ else .(erase t)) | yes τ₁ t₂ | no | (yes τ t) = no staticCheck Γ (if .(erase t) then t₁ else t₂) | yes τ t | no | no = no staticCheck Γ (if b then t₁ else t₂) | no = no staticCheck Γ error = no -- examples from Section 3.5 -- Type : yes ((bool ⊥ ⇒ ⊥) (bool ⊥)) (Sλ (bool ⊥) ⊥ (Sx zero refl S∧ Sx zero refl)) f : Term f = lam (bool ⊥) (var 0 ∨ var 0) ⊥ -- Type : yes ((bool ✭ ⇒ ⊥) (bool ✭)) (Sλ (bool ✭) ⊥ (Sx zero refl S∨ Sx zero refl)) g : Term g = lam (bool ✭) (var 0 ∧ var 0) ⊥ -- Type : yes (bool ⊤) (Sb false ⊤) v : Term v = litBool false ⊤ test₁ : staticCheck [] (f ∙ v) ≡ no test₁ = refl
{ "alphanum_fraction": 0.5643417426, "avg_line_length": 44.5, "ext": "agda", "hexsha": "89667b112220afb00a2fc42bfaf67548f6ecf557", "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": "acf5a153e14a7bdc0c9332fa602fa369fe7add46", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "kellino/TypeSystems", "max_forks_repo_path": "Agda/Gradual Security/static.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "acf5a153e14a7bdc0c9332fa602fa369fe7add46", "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": "kellino/TypeSystems", "max_issues_repo_path": "Agda/Gradual Security/static.agda", "max_line_length": 166, "max_stars_count": 2, "max_stars_repo_head_hexsha": "acf5a153e14a7bdc0c9332fa602fa369fe7add46", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "kellino/TypeSystems", "max_stars_repo_path": "Agda/Gradual Security/static.agda", "max_stars_repo_stars_event_max_datetime": "2017-05-26T23:06:17.000Z", "max_stars_repo_stars_event_min_datetime": "2016-10-27T08:05:40.000Z", "num_tokens": 2046, "size": 4717 }
module sets.nat.core where open import level open import decidable open import equality.core open import function.core open import function.isomorphism.core open import sets.empty infixr 8 _^_ infixl 7 _*_ infixl 6 _+_ data ℕ : Set where zero : ℕ suc : ℕ → ℕ {-# BUILTIN NATURAL ℕ #-} pred : ℕ → ℕ pred zero = zero pred (suc n) = n _+_ : ℕ → ℕ → ℕ zero + n = n suc m + n = suc (m + n) _*_ : ℕ → ℕ → ℕ 0 * n = zero suc m * n = n + m * n _^_ : ℕ → ℕ → ℕ n ^ 0 = 1 n ^ (suc m) = n * (n ^ m) suc-inj : injective suc suc-inj = ap pred _≟_ : (a b : ℕ) → Dec (a ≡ b) zero ≟ zero = yes refl zero ≟ suc _ = no (λ ()) suc _ ≟ zero = no (λ ()) suc a ≟ suc b with a ≟ b suc a ≟ suc b | yes a≡b = yes $ ap suc a≡b suc a ≟ suc b | no ¬a≡b = no $ (λ sa≡sb → ¬a≡b (ap pred sa≡sb))
{ "alphanum_fraction": 0.5618686869, "avg_line_length": 16.8510638298, "ext": "agda", "hexsha": "669a079c1e2d4c5c41cdbcde36c49bd2da367b0e", "lang": "Agda", "max_forks_count": 4, "max_forks_repo_forks_event_max_datetime": "2019-02-26T06:17:38.000Z", "max_forks_repo_forks_event_min_datetime": "2015-04-11T17:19:12.000Z", "max_forks_repo_head_hexsha": "beebe176981953ab48f37de5eb74557cfc5402f4", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "HoTT/M-types", "max_forks_repo_path": "sets/nat/core.agda", "max_issues_count": 2, "max_issues_repo_head_hexsha": "beebe176981953ab48f37de5eb74557cfc5402f4", "max_issues_repo_issues_event_max_datetime": "2015-02-11T15:20:34.000Z", "max_issues_repo_issues_event_min_datetime": "2015-02-11T11:14:59.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "HoTT/M-types", "max_issues_repo_path": "sets/nat/core.agda", "max_line_length": 63, "max_stars_count": 27, "max_stars_repo_head_hexsha": "beebe176981953ab48f37de5eb74557cfc5402f4", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "HoTT/M-types", "max_stars_repo_path": "sets/nat/core.agda", "max_stars_repo_stars_event_max_datetime": "2022-01-09T07:26:57.000Z", "max_stars_repo_stars_event_min_datetime": "2015-04-14T15:47:03.000Z", "num_tokens": 340, "size": 792 }
module _ where module First where postulate C : Set → Set it : {A : Set} ⦃ _ : C A ⦄ → A X : Set module Second where open First postulate instance iCX : C X module Nested where open First x : X x = it -- Second.iCX is in scope
{ "alphanum_fraction": 0.5984555985, "avg_line_length": 14.3888888889, "ext": "agda", "hexsha": "26ed20577ea662c16d48dd60ad126e6ad5b7e761", "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/Issue2489.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/Issue2489.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/Succeed/Issue2489.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": 92, "size": 259 }
-- Andreas, 2016-07-08 -- Better error message for private modules module _ where module M where private module Private where module ShouldFail = M.Private -- Current: -- No such module M.Private -- Better: -- M.Private is not in scope since it is declared as private -- Or (simpler): -- M.Private exists but is not in scope here
{ "alphanum_fraction": 0.7240356083, "avg_line_length": 18.7222222222, "ext": "agda", "hexsha": "94f3468a9dfcb057b7ea31984f29f11167beaf44", "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/Issue2089.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/Issue2089.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/Fail/Issue2089.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": 85, "size": 337 }
{-# OPTIONS --without-K #-} open import Base open import Homotopy.TruncatedHIT open import Integers module Algebra.FreeGroup {i} (A : Set i) where {- The definition is the following (0)data freegroup : Set i where e : freegroup _·_ : A → freegroup → freegroup _⁻¹·_ : A → freegroup → freegroup right-inverse-· : (x : A) (u : freegroup) → x · (x ⁻¹· u) ≡ u left-inverse-· : (x : A) (u : freegroup) → x ⁻¹· (x · u) ≡ u ("(0)data" means that it’s a higher inductive 0-truncated type) -} private data #freegroup : Set i where #e : #freegroup #· : A → #freegroup → #freegroup #⁻¹· : A → #freegroup → #freegroup #top : (f : hSⁿ ⟨0⟩ → #freegroup) → #freegroup freegroup : Set i freegroup = #freegroup e : freegroup e = #e _·_ : A → freegroup → freegroup _·_ = #· _⁻¹·_ : A → freegroup → freegroup _⁻¹·_ = #⁻¹· postulate -- HIT right-inverse-· : (x : A) (u : freegroup) → x · (x ⁻¹· u) ≡ u left-inverse-· : (x : A) (u : freegroup) → x ⁻¹· (x · u) ≡ u top : (f : hSⁿ ⟨0⟩ → freegroup) → freegroup top = #top postulate -- HIT rays : (f : hSⁿ ⟨0⟩ → freegroup) (x : hSⁿ ⟨0⟩) → top f ≡ f x #freegroup-rec : ∀ {j} (P : freegroup → Set j) (base : P e) (g : (x : A) (u : freegroup) → P u → P (x · u)) (g' : (x : A) (u : freegroup) → P u → P (x ⁻¹· u)) (gg' : (x : A) (u : freegroup) (t : P u) → transport P (right-inverse-· x u) (g x _ (g' x u t)) ≡ t) (g'g : (x : A) (u : freegroup) (t : P u) → transport P (left-inverse-· x u) (g' x _ (g x u t)) ≡ t) (top* : (f : hSⁿ ⟨0⟩ → freegroup) (p : (x : hSⁿ ⟨0⟩) → P (f x)) → P (top f)) (rays* : (f : hSⁿ ⟨0⟩ → freegroup) (p : (x : hSⁿ ⟨0⟩) → P (f x)) (x : hSⁿ ⟨0⟩) → transport P (rays f x) (top* f p) ≡ p x) → ((t : freegroup) → P t) #freegroup-rec P base g g' gg' g'g top* rays* #e = base #freegroup-rec P base g g' gg' g'g top* rays* (#· x u) = g x u (#freegroup-rec P base g g' gg' g'g top* rays* u) #freegroup-rec P base g g' gg' g'g top* rays* (#⁻¹· x u) = g' x u (#freegroup-rec P base g g' gg' g'g top* rays* u) #freegroup-rec P base g g' gg' g'g top* rays* (#top f) = top* f (λ x → #freegroup-rec P base g g' gg' g'g top* rays* (f x)) #freegroup-rec-nondep : ∀ {j} (B : Set j) (base : B) (g : A → B → B) (g' : A → B → B) (gg' : (x : A) (u : B) → (g x (g' x u)) ≡ u) (g'g : (x : A) (u : B) → (g' x (g x u)) ≡ u) (top* : (f : hSⁿ ⟨0⟩ → freegroup) (p : hSⁿ ⟨0⟩ → B) → B) (rays* : (f : hSⁿ ⟨0⟩ → freegroup) (p : hSⁿ ⟨0⟩ → B) (x : hSⁿ ⟨0⟩) → top* f p ≡ p x) → freegroup → B #freegroup-rec-nondep P base g g' gg' g'g top* rays* #e = base #freegroup-rec-nondep P base g g' gg' g'g top* rays* (#· x u) = g x (#freegroup-rec-nondep P base g g' gg' g'g top* rays* u) #freegroup-rec-nondep P base g g' gg' g'g top* rays* (#⁻¹· x u) = g' x (#freegroup-rec-nondep P base g g' gg' g'g top* rays* u) #freegroup-rec-nondep P base g g' gg' g'g top* rays* (#top f) = top* f (λ x → #freegroup-rec-nondep P base g g' gg' g'g top* rays* (f x)) freegroup-rec : ∀ {j} (P : freegroup → Set j) (base : P e) (g : (x : A) (u : freegroup) → P u → P (x · u)) (g' : (x : A) (u : freegroup) → P u → P (x ⁻¹· u)) (gg' : (x : A) (u : freegroup) (t : P u) → transport P (right-inverse-· x u) (g x _ (g' x u t)) ≡ t) (g'g : (x : A) (u : freegroup) (t : P u) → transport P (left-inverse-· x u) (g' x _ (g x u t)) ≡ t) (p : (u : freegroup) → is-set (P u)) → ((t : freegroup) → P t) freegroup-rec P base g g' gg' g'g p = #freegroup-rec P base g g' gg' g'g (λ f p₁ → π₁ (u f p₁)) (λ f p₁ → π₂ (u f p₁)) where u = truncated-has-filling-dep freegroup P ⟨0⟩ (λ ()) (λ f → (top f , rays f)) freegroup-rec-nondep : ∀ {j} (B : Set j) (base : B) (g : A → B → B) (g' : A → B → B) (gg' : (x : A) (u : B) → (g x (g' x u)) ≡ u) (g'g : (x : A) (u : B) → (g' x (g x u)) ≡ u) (p : is-set B) → freegroup → B freegroup-rec-nondep B base g g' gg' g'g p = #freegroup-rec-nondep B base g g' gg' g'g (λ _ p → π₁ (u p)) (λ _ p → π₂ (u p)) where u = truncated-has-spheres-filled ⟨0⟩ _ p
{ "alphanum_fraction": 0.4966426859, "avg_line_length": 35.0420168067, "ext": "agda", "hexsha": "d9a275e4baf8b1426707d80299eb488f3568f520", "lang": "Agda", "max_forks_count": 50, "max_forks_repo_forks_event_max_datetime": "2022-02-14T03:03:25.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-10T01:48:08.000Z", "max_forks_repo_head_hexsha": "939a2d83e090fcc924f69f7dfa5b65b3b79fe633", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "nicolaikraus/HoTT-Agda", "max_forks_repo_path": "old/Algebra/FreeGroup.agda", "max_issues_count": 31, "max_issues_repo_head_hexsha": "939a2d83e090fcc924f69f7dfa5b65b3b79fe633", "max_issues_repo_issues_event_max_datetime": "2021-10-03T19:15:25.000Z", "max_issues_repo_issues_event_min_datetime": "2015-03-05T20:09:00.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "nicolaikraus/HoTT-Agda", "max_issues_repo_path": "old/Algebra/FreeGroup.agda", "max_line_length": 80, "max_stars_count": 294, "max_stars_repo_head_hexsha": "f8fa68bf753d64d7f45556ca09d0da7976709afa", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "UlrikBuchholtz/HoTT-Agda", "max_stars_repo_path": "old/Algebra/FreeGroup.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-20T13:54:45.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T16:23:23.000Z", "num_tokens": 1833, "size": 4170 }
{-# OPTIONS --cubical --safe --postfix-projections #-} module Data.List.Relation.Binary.Permutation where open import Prelude open import Data.List open import Data.Fin open import Data.Fin.Properties open import Data.List.Membership open import Cubical.Foundations.Equiv import Function.Isomorphism as Isomorphism open import Relation.Binary open import Cubical.Foundations.Prelude using (J; _∧_) open import Cubical.Foundations.Transport using (isSet-subst) open import Cubical.Data.Sigma.Properties open import Data.Nat.Properties using (znots; snotz) infixr 0 _↝_ _↝_ : {A : Type a} (xs ys : List A) → Type a xs ↝ ys = ∀ x → x ∈ xs → x ∈ ys infix 4 _↭_ _↭_ : {A : Type a} (xs ys : List A) → Type a xs ↭ ys = ∀ x → (x ∈ xs) ⇔ (x ∈ ys) reflₚ : ∀ {xs : List A} → xs ↭ xs reflₚ _ = Isomorphism.refl-⇔ symₚ : {xs ys : List A} → xs ↭ ys → ys ↭ xs symₚ xs↭ys x = Isomorphism.sym-⇔ (xs↭ys x) transₚ : {xs ys zs : List A} → xs ↭ ys → ys ↭ zs → xs ↭ zs transₚ xs↭ys ys↭zs x = Isomorphism.trans-⇔ (xs↭ys x) (ys↭zs x) consₚ : ∀ x {xs ys : List A} → xs ↭ ys → x ∷ xs ↭ x ∷ ys consₚ _ xs↭ys _ .fun (f0 , x≡x ) = f0 , x≡x consₚ _ xs↭ys _ .fun (fs n , x∈xs) = push (xs↭ys _ .fun (n , x∈xs)) consₚ _ xs↭ys _ .inv (f0 , x≡x ) = f0 , x≡x consₚ _ xs↭ys _ .inv (fs n , x∈xs) = push (xs↭ys _ .inv (n , x∈xs)) consₚ _ xs↭ys _ .leftInv (f0 , x≡x) = refl consₚ _ xs↭ys _ .leftInv (fs n , x∈xs) i = push (xs↭ys _ .leftInv (n , x∈xs) i) consₚ _ xs↭ys _ .rightInv (f0 , x≡x) = refl consₚ _ xs↭ys _ .rightInv (fs n , x∈xs) i = push (xs↭ys _ .rightInv (n , x∈xs) i) swapₚ-to : ∀ (x₁ x₂ : A) xs → x₁ ∷ x₂ ∷ xs ↝ x₂ ∷ x₁ ∷ xs swapₚ-to _ _ _ _ (f0 , x≡x₁) = fs f0 , x≡x₁ swapₚ-to _ _ _ _ (fs f0 , x≡x₂) = f0 , x≡x₂ swapₚ-to _ _ _ _ (fs (fs n) , x∈xs) = fs (fs n) , x∈xs swapₚ-inv : ∀ (x₁ x₂ : A) xs x x∈xs → swapₚ-to x₂ x₁ xs x (swapₚ-to x₁ x₂ xs x x∈xs) ≡ x∈xs swapₚ-inv _ _ _ _ (f0 , x≡x₁) = refl swapₚ-inv _ _ _ _ (fs f0 , x≡x₂) = refl swapₚ-inv _ _ _ _ (fs (fs n) , x∈xs) = refl swapₚ : ∀ x₁ x₂ (xs : List A) → x₁ ∷ x₂ ∷ xs ↭ x₂ ∷ x₁ ∷ xs swapₚ x₁ x₂ xs x .fun = swapₚ-to x₁ x₂ xs x swapₚ x₁ x₂ xs x .inv = swapₚ-to x₂ x₁ xs x swapₚ x₁ x₂ xs x .leftInv = swapₚ-inv x₁ x₂ xs x swapₚ x₁ x₂ xs x .rightInv = swapₚ-inv x₂ x₁ xs x Fin-length : (xs : List A) → ∃ x × (x ∈ xs) ⇔ Fin (length xs) Fin-length xs .inv n = xs ! n , n , refl Fin-length xs .fun (x , n , p) = n Fin-length xs .leftInv (x , n , p) i .fst = p i Fin-length xs .leftInv (x , n , p) i .snd .fst = n Fin-length xs .leftInv (x , n , p) i .snd .snd j = p (i ∧ j) Fin-length xs .rightInv n = refl Fin-length-cong : (xs ys : List A) → xs ↭ ys → Fin (length xs) ⇔ Fin (length ys) Fin-length-cong xs ys xs↭ys = sym-⇔ (Fin-length xs) ⟨ trans-⇔ ⟩ iso-Σ xs↭ys ⟨ trans-⇔ ⟩ Fin-length ys index-commutes : ∀ (x : A) xs ys → (xs↭ys : xs ↭ ys) (x∈xs : x ∈ xs) → fst (xs↭ys x .fun x∈xs) ≡ Fin-length-cong xs ys xs↭ys .fun (x∈xs .fst) index-commutes x xs ys xs↭ys (n , p) = J (λ y y∈xs → xs↭ys y .fun (n , y∈xs) .fst ≡ xs↭ys (xs ! n) .fun (n , refl) .fst) refl p index-equality-preserved : ∀ (x : A) xs ys (p q : x ∈ xs) → (xs↭ys : xs ↭ ys) → fst p ≡ fst q → xs↭ys x .fun p .fst ≡ xs↭ys x .fun q .fst index-equality-preserved x xs ys p q xs↭ys ip≡iq = xs↭ys x .fun p .fst ≡⟨ index-commutes x xs ys xs↭ys p ⟩ Fin-length-cong xs ys xs↭ys .fun (p .fst) ≡⟨ cong (Fin-length-cong xs ys xs↭ys .fun) ip≡iq ⟩ Fin-length-cong xs ys xs↭ys .fun (q .fst) ≡˘⟨ index-commutes x xs ys xs↭ys q ⟩ xs↭ys x .fun q .fst ∎ where open import Path.Reasoning perm-inj : ∀ (x : A) xs ys n → (xs↭ys : x ∷ xs ↭ x ∷ ys) → ∀ z (z∈ys : x ≡ z) (x∈ys : x ≡ z) (z∈xs : xs ! n ≡ z) (p₁ : xs↭ys z .fun (fs n , z∈xs) ≡ (f0 , z∈ys)) (p₂ : xs↭ys z .fun (f0 , z∈ys) ≡ (f0 , x∈ys)) → ⊥ perm-inj x xs ys n xs↭ys z z∈ys x∈ys z∈xs p₁ p₂ = znots (cong FinToℕ p₆) where open import Path.Reasoning p₃ = fs n , z∈xs ≡˘⟨ xs↭ys z .leftInv (fs n , z∈xs) ⟩ xs↭ys z .inv (xs↭ys z .fun (fs n , z∈xs)) ≡⟨ cong (xs↭ys z .inv) p₁ ⟩ xs↭ys z .inv (f0 , z∈ys) ∎ p₄ = f0 , z∈ys ≡˘⟨ xs↭ys z .leftInv (f0 , z∈ys) ⟩ xs↭ys z .inv (xs↭ys z .fun (f0 , z∈ys)) ≡⟨ cong (xs↭ys z .inv) p₂ ⟩ xs↭ys z .inv (f0 , x∈ys) ∎ p₅ = index-equality-preserved z (x ∷ ys) (x ∷ xs) (f0 , x∈ys) (f0 , z∈ys) (sym-⇔ ∘ xs↭ys) refl p₆ = f0 ≡⟨ cong fst p₄ ⟩ xs↭ys z .inv (f0 , x∈ys) .fst ≡⟨ p₅ ⟩ xs↭ys z .inv (f0 , z∈ys) .fst ≡˘⟨ cong fst p₃ ⟩ fs n ∎ tailₚ-to : ∀ x (xs ys : List A) → x ∷ xs ↭ x ∷ ys → ∀ z → z ∈ xs → z ∈ ys tailₚ-to x xs ys xs↭ys z (n , z∈xs) with xs↭ys z .fun (fs n , z∈xs) | inspect (xs↭ys z .fun) (fs n , z∈xs) ... | fs m , z∈ys | _ = m , z∈ys ... | f0 , z∈ys | 〖 p₁ 〗 with xs↭ys z .fun (f0 , z∈ys) | inspect (xs↭ys z .fun) (f0 , z∈ys) ... | fs o , x∈ys | _ = o , x∈ys ... | f0 , x∈ys | 〖 p₂ 〗 = ⊥-elim (perm-inj x xs ys n xs↭ys z z∈ys x∈ys z∈xs p₁ p₂) pred-∈-eq : ∀ (x y : A) xs i j → (x∈xs₁ : xs ! i ≡ x) → (x∈xs₂ : xs ! j ≡ x) → Path (x ∈ y ∷ xs) (fs i , x∈xs₁) (fs j , x∈xs₂) → (i , x∈xs₁) ≡ (j , x∈xs₂) pred-∈-eq x y xs i j x∈xs₁ x∈xs₂ = J (λ { (fs n , x∈xs₃) _ → (i , x∈xs₁) ≡ (n , x∈xs₃) ; (f0 , x∈xs₃) → ⊥-elim ∘ snotz ∘ cong FinToℕ ∘ cong fst }) refl open import Path.Reasoning tailₚ-inv : ∀ x (xs ys : List A) → (xs↭ys : x ∷ xs ↭ x ∷ ys) → ∀ z (i : z ∈ ys) → tailₚ-to x xs ys xs↭ys z (tailₚ-to x ys xs (sym-⇔ ∘ xs↭ys) z i) ≡ i tailₚ-inv x xs ys xs↭ys z (n , z∈ys) with xs↭ys z .inv (fs n , z∈ys) | inspect (xs↭ys z .inv) (fs n , z∈ys) ... | fs m , z∈xs | 〖 p₁ 〗 with xs↭ys z .fun (fs m , z∈xs) | inspect (xs↭ys z .fun) (fs m , z∈xs) ... | fs o , z∈ys₂ | 〖 p₂ 〗 = pred-∈-eq z x ys o n z∈ys₂ z∈ys p₃ where p₃ = fs o , z∈ys₂ ≡˘⟨ p₂ ⟩ xs↭ys z .fun (fs m , z∈xs) ≡˘⟨ cong (xs↭ys z .fun) p₁ ⟩ xs↭ys z .fun (xs↭ys z .inv (fs n , z∈ys)) ≡⟨ xs↭ys z .rightInv (fs n , z∈ys) ⟩ fs n , z∈ys ∎ ... | f0 , z∈ys₂ | 〖 p₂ 〗 with xs↭ys z .fun (f0 , z∈ys₂) | inspect (xs↭ys z .fun) (f0 , z∈ys₂) ... | f0 , x∈ys₃ | 〖 p₃ 〗 = ⊥-elim (perm-inj x xs ys m xs↭ys z z∈ys₂ x∈ys₃ z∈xs p₂ p₃) ... | fs o , x∈ys₃ | 〖 p₃ 〗 = ⊥-elim (snotz (cong (FinToℕ ∘ fst) p₄)) where p₄ = fs n , z∈ys ≡˘⟨ xs↭ys z .rightInv (fs n , z∈ys) ⟩ xs↭ys z .fun (xs↭ys z .inv (fs n , z∈ys)) ≡⟨ cong (xs↭ys z .fun) p₁ ⟩ xs↭ys z .fun (fs m , z∈xs) ≡⟨ p₂ ⟩ f0 , z∈ys₂ ∎ tailₚ-inv x xs ys xs↭ys z (n , z∈ys) | f0 , z∈xs | 〖 p₁ 〗 with xs↭ys z .inv (f0 , z∈xs) | inspect (xs↭ys z .inv) (f0 , z∈xs) ... | f0 , z∈ys₂ | 〖 p₂ 〗 = ⊥-elim (perm-inj x ys xs n (sym-⇔ ∘ xs↭ys) z z∈xs z∈ys₂ z∈ys p₁ p₂) ... | fs o , z∈ys₂ | 〖 p₂ 〗 with xs↭ys z .fun (fs o , z∈ys₂) | inspect (xs↭ys z .fun) (fs o , z∈ys₂) ... | fs m , z∈ys₃ | 〖 p₃ 〗 = ⊥-elim (snotz (cong (FinToℕ ∘ fst) p₄)) where p₄ = fs m , z∈ys₃ ≡˘⟨ p₃ ⟩ xs↭ys z .fun (fs o , z∈ys₂) ≡˘⟨ cong (xs↭ys z .fun) p₂ ⟩ xs↭ys z .fun (xs↭ys z .inv (f0 , z∈xs)) ≡⟨ xs↭ys z .rightInv (f0 , z∈xs) ⟩ f0 , z∈xs ∎ ... | f0 , z∈ys₃ | 〖 p₃ 〗 with xs↭ys z .fun (f0 , z∈ys₃) | inspect (xs↭ys z .fun) (f0 , z∈ys₃) ... | f0 , z∈ys₄ | 〖 p₄ 〗 = ⊥-elim (perm-inj x xs ys o xs↭ys z z∈ys₃ z∈ys₄ z∈ys₂ p₃ p₄) ... | fs l , z∈ys₄ | 〖 p₄ 〗 = pred-∈-eq z x ys l n z∈ys₄ z∈ys p₇ where p₅ : Path (z ∈ x ∷ ys) (f0 , z∈xs) (f0 , z∈ys₃) p₅ = (f0 , z∈xs) ≡˘⟨ xs↭ys z .rightInv (f0 , z∈xs) ⟩ xs↭ys z .fun (xs↭ys z .inv (f0 , z∈xs)) ≡⟨ cong (xs↭ys z .fun) p₂ ⟩ xs↭ys z .fun (fs o , z∈ys₂) ≡⟨ p₃ ⟩ (f0 , z∈ys₃) ∎ p₆ = z∈xs ≡˘⟨ isSet-subst {B = λ n → (x ∷ ys) ! n ≡ z} (Discrete→isSet discreteFin) (cong fst p₅) z∈xs ⟩ subst (λ n → (x ∷ ys) ! n ≡ z) (cong fst p₅) z∈xs ≡⟨ PathΣ→ΣPathTransport (f0 , z∈xs) (f0 , z∈ys₃) p₅ .snd ⟩ z∈ys₃ ∎ p₇ = fs l , z∈ys₄ ≡˘⟨ p₄ ⟩ xs↭ys z .fun (f0 , z∈ys₃) ≡˘⟨ cong (xs↭ys z .fun ∘ _,_ f0) p₆ ⟩ xs↭ys z .fun (f0 , z∈xs) ≡˘⟨ cong (xs↭ys z .fun) p₁ ⟩ xs↭ys z .fun (xs↭ys z .inv (fs n , z∈ys)) ≡⟨ xs↭ys z .rightInv (fs n , z∈ys) ⟩ fs n , z∈ys ∎ tailₚ : ∀ x (xs ys : List A) → x ∷ xs ↭ x ∷ ys → xs ↭ ys tailₚ x xs ys x∷xs↭x∷ys k .fun = tailₚ-to x xs ys x∷xs↭x∷ys k tailₚ x xs ys x∷xs↭x∷ys k .inv = tailₚ-to x ys xs (sym-⇔ ∘ x∷xs↭x∷ys) k tailₚ x xs ys x∷xs↭x∷ys k .rightInv = tailₚ-inv x xs ys x∷xs↭x∷ys k tailₚ x xs ys x∷xs↭x∷ys k .leftInv v = cong (λ z → tailₚ-to x ys xs (sym-⇔ ∘ x∷xs↭x∷ys) k (tailₚ-to x xs ys z k v)) (funExt (λ h → sym (sym-sym-iso (x∷xs↭x∷ys h)) )) ; tailₚ-inv x ys xs (sym-⇔ ∘ x∷xs↭x∷ys) k v
{ "alphanum_fraction": 0.5027926593, "avg_line_length": 43.6467661692, "ext": "agda", "hexsha": "6d8503a129094445d956bd7a91b5b70bec566148", "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": "Data/List/Relation/Binary/Permutation.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": "Data/List/Relation/Binary/Permutation.agda", "max_line_length": 211, "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": "Data/List/Relation/Binary/Permutation.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": 4630, "size": 8773 }
module ImportTests.ExtractFunction where open import ExtractFunction open import Data.Nat open import Data.Bool checkFunction1 : ℕ checkFunction1 = function1 2 3 checkFunction2 : ℕ checkFunction2 = function2 4 true
{ "alphanum_fraction": 0.8256880734, "avg_line_length": 18.1666666667, "ext": "agda", "hexsha": "1fa0c5fa4d35cd42dc85eaa2c152e5d87ccff87c", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2019-01-31T08:40:41.000Z", "max_forks_repo_forks_event_min_datetime": "2019-01-31T08:40:41.000Z", "max_forks_repo_head_hexsha": "52d1034aed14c578c9e077fb60c3db1d0791416b", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "omega12345/RefactorAgda", "max_forks_repo_path": "RefactorAgdaEngine/Test/Tests/output/ImportTests/ExtractFunction.agda", "max_issues_count": 3, "max_issues_repo_head_hexsha": "52d1034aed14c578c9e077fb60c3db1d0791416b", "max_issues_repo_issues_event_max_datetime": "2019-02-05T12:53:36.000Z", "max_issues_repo_issues_event_min_datetime": "2019-01-31T08:03:07.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "omega12345/RefactorAgda", "max_issues_repo_path": "RefactorAgdaEngine/Test/Tests/output/ImportTests/ExtractFunction.agda", "max_line_length": 40, "max_stars_count": 5, "max_stars_repo_head_hexsha": "52d1034aed14c578c9e077fb60c3db1d0791416b", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "omega12345/RefactorAgda", "max_stars_repo_path": "RefactorAgdaEngine/Test/Tests/output/ImportTests/ExtractFunction.agda", "max_stars_repo_stars_event_max_datetime": "2019-05-03T10:03:36.000Z", "max_stars_repo_stars_event_min_datetime": "2019-01-31T14:10:18.000Z", "num_tokens": 57, "size": 218 }
@0 F : @0 Set → Set F A = λ { → A }
{ "alphanum_fraction": 0.3611111111, "avg_line_length": 12, "ext": "agda", "hexsha": "a2963a4ea0e4a0cbb09f20a3535de85a2d92d231", "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/Fail/Issue4525c.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/Fail/Issue4525c.agda", "max_line_length": 19, "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/Fail/Issue4525c.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": 18, "size": 36 }
{-# OPTIONS --safe #-} module Cubical.HITs.FreeComMonoids.Base where open import Cubical.Foundations.Prelude open import Cubical.Foundations.HLevels open import Cubical.Foundations.Function private variable ℓ : Level A : Type ℓ data FreeComMonoid (A : Type ℓ) : Type ℓ where ⟦_⟧ : A → FreeComMonoid A ε : FreeComMonoid A _·_ : FreeComMonoid A → FreeComMonoid A → FreeComMonoid A comm : ∀ x y → x · y ≡ y · x identityᵣ : ∀ x → x · ε ≡ x identityₗ : ∀ x → ε · x ≡ x assoc : ∀ x y z → x · (y · z) ≡ (x · y) · z trunc : isSet (FreeComMonoid A) module Elim {ℓ'} {B : FreeComMonoid A → Type ℓ'} (⟦_⟧* : (x : A) → B ⟦ x ⟧) (ε* : B ε) (_·*_ : ∀ {x y} → B x → B y → B (x · y)) (comm* : ∀ {x y} → (xs : B x) (ys : B y) → PathP (λ i → B (comm x y i)) (xs ·* ys) (ys ·* xs)) (identityᵣ* : ∀ {x} → (xs : B x) → PathP (λ i → B (identityᵣ x i)) (xs ·* ε*) xs) (identityₗ* : ∀ {x} → (xs : B x) → PathP (λ i → B (identityₗ x i)) (ε* ·* xs) xs) (assoc* : ∀ {x y z} → (xs : B x) (ys : B y) (zs : B z) → PathP (λ i → B (assoc x y z i)) (xs ·* (ys ·* zs)) ((xs ·* ys) ·* zs)) (trunc* : ∀ xs → isSet (B xs)) where f : (xs : FreeComMonoid A) → B xs f ⟦ x ⟧ = ⟦ x ⟧* f ε = ε* f (xs · ys) = f xs ·* f ys f (comm xs ys i) = comm* (f xs) (f ys) i f (identityᵣ xs i) = identityᵣ* (f xs) i f (identityₗ xs i) = identityₗ* (f xs) i f (assoc xs ys zs i) = assoc* (f xs) (f ys) (f zs) i f (trunc xs ys p q i j) = isOfHLevel→isOfHLevelDep 2 trunc* (f xs) (f ys) (cong f p) (cong f q) (trunc xs ys p q) i j module ElimProp {ℓ'} {B : FreeComMonoid A → Type ℓ'} (BProp : {xs : FreeComMonoid A} → isProp (B xs)) (⟦_⟧* : (x : A) → B ⟦ x ⟧) (ε* : B ε) (_·*_ : ∀ {x y} → B x → B y → B (x · y)) where f : (xs : FreeComMonoid A) → B xs f = Elim.f ⟦_⟧* ε* _·*_ (λ {x y} xs ys → toPathP (BProp (transport (λ i → B (comm x y i)) (xs ·* ys)) (ys ·* xs))) (λ {x} xs → toPathP (BProp (transport (λ i → B (identityᵣ x i)) (xs ·* ε*)) xs)) (λ {x} xs → toPathP (BProp (transport (λ i → B (identityₗ x i)) (ε* ·* xs)) xs)) (λ {x y z} xs ys zs → toPathP (BProp (transport (λ i → B (assoc x y z i)) (xs ·* (ys ·* zs))) ((xs ·* ys) ·* zs))) (λ _ → (isProp→isSet BProp)) module Rec {ℓ'} {B : Type ℓ'} (BType : isSet B) (⟦_⟧* : (x : A) → B) (ε* : B) (_·*_ : B → B → B) (comm* : (x y : B) → x ·* y ≡ y ·* x) (identityᵣ* : (x : B) → x ·* ε* ≡ x) (identityₗ* : (x : B) → ε* ·* x ≡ x) (assoc* : (x y z : B) → x ·* (y ·* z) ≡ (x ·* y) ·* z) where f : FreeComMonoid A → B f = Elim.f ⟦_⟧* ε* _·*_ comm* identityᵣ* identityₗ* assoc* (const BType)
{ "alphanum_fraction": 0.4699057288, "avg_line_length": 37.2702702703, "ext": "agda", "hexsha": "cd002b66d3ffc2df78eb3e0a3f0553f499a06070", "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/FreeComMonoids/Base.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/FreeComMonoids/Base.agda", "max_line_length": 118, "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/FreeComMonoids/Base.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": 1248, "size": 2758 }
--{-# OPTIONS --allow-unsolved-metas #-} module Theorem1 where open import OscarPrelude open import HasSatisfaction open import HasSubstantiveDischarge open import LiteralFormula open import 𝑱udgement open import HasSalvation open import Membership open import Interpretation open import HasNegation open import IsLiteralFormula Theorem1 : (Φ : 𝑱udgement LiteralFormula) → ⊨ Φ ↔ ▷ Φ Theorem1 Φ@(χs ⊢ ι) = Theorem1a , Theorem1b where Theorem1a : ⊨ Φ → ▷ Φ Theorem1a ⊨Φ with ▷? Φ … | yes ▷Φ = ▷Φ … | no ⋫Φ = let I , I⊨χs , I⊭ι = Lemma1a in ⊥-elim ∘ I⊭ι $ ⊨Φ I I⊨χs where Lemma1a : ∃ λ I → I ⊨ χs × I ⊭ ι Lemma1a = {!!} {- To construct the interpretation, consider a unique list, τ₀, τ₁, …, τₙ, of terms in ι ∷ χs. For each term, τ, we find <TODO> interpretations, 𝓘, such that for any I ∈ 𝓘, and any i ∈ 0, …, n, τ⟦ I ⟧ τᵢ = i. For each formula φ ∈ ι ∷ χs, we find <TODO> an interpretation I ∈ 𝓘 such that 𝑃⟦ I ⟧ φ = true when φ ∈ χs and 𝑃⟦ I ⟧ φ = false when φ = ι. For all terms in ι ∷ χs, find a coding into Nat that uniquely determines each term. To do this, compute the maximum functional depth of terms, D, the maximal arity of terms, A, the maximal function name, F, and the maximal variable name, V. Each term can then be coded into Fin V + (D₀ = F + F * V + F * V ^ 2 + ... + F * V ^ A) + (D₀ ... Encode each term in a discrimination network. Each new term stored is assigned a unique id -} Theorem1b : ▷ Φ → ⊨ Φ Theorem1b (left ◁χs) I I⊨χs = {!!} Theorem1b (right χs≽ι) I I⊨χs = {!!}
{ "alphanum_fraction": 0.655396619, "avg_line_length": 36.619047619, "ext": "agda", "hexsha": "9f6793ee90517c45c0a0e160a4377b3c0b465daf", "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-1/Theorem1.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-1/Theorem1.agda", "max_line_length": 344, "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-1/Theorem1.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 593, "size": 1538 }
-- Andreas, 2011-04-15 module NotStronglyRigidOccurrence where data Nat : Set where zero : Nat suc : Nat -> Nat data _≡_ {A : Set}(a : A) : A -> Set where refl : a ≡ a -- Jason C. Read, PhD thesis, p. 109 test : (k : Nat) -> let X : (Nat -> Nat) -> Nat X = _ in (f : Nat -> Nat) -> X f ≡ suc (f (X (\ x -> k))) test k f = refl -- {a = suc (f (suc k))} -- leads to _30 : _22 k f ≡ suc (f (_22 k (λ x → k))) -- this should give yellow, because above solution for _22 exists
{ "alphanum_fraction": 0.5324165029, "avg_line_length": 26.7894736842, "ext": "agda", "hexsha": "bd32ad5d2524be628ca0a4c553e006b0b54f3fb7", "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/fail/NotStronglyRigidOccurrence.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/fail/NotStronglyRigidOccurrence.agda", "max_line_length": 65, "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/fail/NotStronglyRigidOccurrence.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": 187, "size": 509 }
{-# OPTIONS --rewriting #-} module Oscar.AgdaRewriting where open import Agda.Builtin.Equality {-# BUILTIN REWRITE _≡_ #-} record ⊤ : Set where constructor tt data List (A : Set) : Set where ∅ : List A _∷_ : A → List A → List A Nat = List ⊤ pattern ‼ xs = tt ∷ xs syntax ‼ xs = ! xs open import Agda.Builtin.Nat using (zero; suc) renaming (Nat to ℕ; _+_ to _+ℕ_) toNat : ℕ → Nat toNat zero = ∅ toNat (suc x) = tt ∷ toNat x toℕ : Nat → ℕ toℕ ∅ = zero toℕ (x ∷ x₁) = suc (toℕ x₁) ℕ-iso : ∀ n → toℕ (toNat n) ≡ n ℕ-iso zero = refl ℕ-iso (suc n) rewrite ℕ-iso n = refl Nat-iso : ∀ n → toNat (toℕ n) ≡ n Nat-iso ∅ = refl Nat-iso (x ∷ n) rewrite Nat-iso n = refl --{-# REWRITE ℕ-iso #-} infixl 6 _+Nat_ _+Nat_ : Nat → Nat → Nat m +Nat n = toNat (toℕ m +ℕ toℕ n) infixl 7 _*Nat_ _*Nat_ : Nat → Nat → Nat ∅ *Nat _ = ∅ _ *Nat ∅ = ∅ (_ ∷ m) *Nat (_ ∷ n) = _ ∷ m +Nat n +Nat m *Nat n NatComputation : Nat NatComputation = toNat 5 *Nat toNat 7 butnowinℕ : ℕ butnowinℕ = toℕ NatComputation showme : ℕ showme = {!!} -- postulate -- Nat≡ℕ : Nat ≡ ℕ -- {-# REWRITE Nat≡ℕ #-} -- data Fin : Nat → Set where -- ∅ : ∀ {n} → Fin (! n) -- ! : ∀ {n} → Fin n → Fin (! n) -- -- record ⊤ : Set where -- -- constructor tt -- -- data List (A : Set) : Set where -- -- ∅ : List A -- -- _∷_ : A → List A → List A -- -- Nat = List ⊤ -- -- pattern ‼ xs = tt ∷ xs -- -- data Fin : Nat → Set where -- -- ∅ : ∀ {n} → Fin (‼ n) -- -- ! : ∀ {n} → Fin n → Fin (‼ n)
{ "alphanum_fraction": 0.5380434783, "avg_line_length": 18.4, "ext": "agda", "hexsha": "4607cef012160e0fcbf0fc1340786afb4b7b5ba2", "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/AgdaRewriting.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/AgdaRewriting.agda", "max_line_length": 79, "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/AgdaRewriting.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 632, "size": 1472 }
{-# OPTIONS --without-K --safe #-} open import Algebra module Data.FingerTree.Reasoning {r m} (ℳ : Monoid r m) where open Monoid ℳ renaming (Carrier to 𝓡) open import Data.FingerTree.MonoidSolver ℳ using (solve-macro) open import Data.Unit using (⊤) open import Reflection using (TC; Term) macro _↯ : Term → Term → TC ⊤ _↯ = solve-macro infixr 2 ∙≫_ ≪∙_ ∙≫_ : ∀ {x y z} → x ≈ y → z ∙ x ≈ z ∙ y ∙≫_ = ∙-cong refl ≪∙_ : ∀ {x y z} → x ≈ y → x ∙ z ≈ y ∙ z ≪∙ x = ∙-cong x refl infixl 1 _⍮_ _⍮_ : ∀ {x y z} → x ≈ y → y ≈ z → x ≈ z _⍮_ = trans infixl 1 trans⁻¹ trans⁻¹ : ∀ {x y z : 𝓡} → y ≈ z → x ≈ y → x ≈ z trans⁻¹ x y = trans y x syntax trans⁻¹ y≈z x≈y = x≈y ⍮′ y≈z infixr 2 _↢_ ↣-syntax ↣↣-syntax _↢_ : ∀ x {y} → x ≈ y → x ≈ y _ ↢ x≈y = x≈y ↣-syntax : ∀ {x} y → x ≈ y → x ≈ y ↣-syntax _ x≈y = x≈y syntax ↣-syntax y x≈y = x≈y ↣ y ↣↣-syntax : ∀ x y → x ≈ y → x ≈ y ↣↣-syntax _ _ x≈y = x≈y syntax ↣↣-syntax x y x≈y = x ↣⟨ x≈y ⟩↣ y infixl 6 _∙>_ _<∙_ _∙>_ : ∀ x {y z} → y ≈ z → x ∙ y ≈ x ∙ z _ ∙> y≈z = ∙≫ y≈z _<∙_ : ∀ {x y} → x ≈ y → ∀ z → x ∙ z ≈ y ∙ z x≈y <∙ _ = ≪∙ x≈y
{ "alphanum_fraction": 0.496803653, "avg_line_length": 18.8793103448, "ext": "agda", "hexsha": "943f2e6c1f95e7f2a649ceb6e839ec1f77eae565", "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": "39c3d96937384b052b782ffddf4fdec68c5d139f", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "oisdk/agda-indexed-fingertree", "max_forks_repo_path": "src/Data/FingerTree/Reasoning.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "39c3d96937384b052b782ffddf4fdec68c5d139f", "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-indexed-fingertree", "max_issues_repo_path": "src/Data/FingerTree/Reasoning.agda", "max_line_length": 62, "max_stars_count": 1, "max_stars_repo_head_hexsha": "39c3d96937384b052b782ffddf4fdec68c5d139f", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "oisdk/agda-indexed-fingertree", "max_stars_repo_path": "src/Data/FingerTree/Reasoning.agda", "max_stars_repo_stars_event_max_datetime": "2019-02-26T07:04:54.000Z", "max_stars_repo_stars_event_min_datetime": "2019-02-26T07:04:54.000Z", "num_tokens": 622, "size": 1095 }
module BBHeap.Perfect {A : Set}(_≤_ : A → A → Set) where open import BBHeap _≤_ open import Bound.Lower A open import Bound.Lower.Order _≤_ data Perfect {b : Bound} : BBHeap b → Set where plf : Perfect (leaf {b}) pnd : {x : A}{l r : BBHeap (val x)}(b≤x : LeB b (val x))(l⋘r : l ⋘ r) → l ≃ r → Perfect (left b≤x l⋘r)
{ "alphanum_fraction": 0.6068111455, "avg_line_length": 32.3, "ext": "agda", "hexsha": "3aae729b80de704b304a946684194951a74c16c6", "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/Perfect.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/Perfect.agda", "max_line_length": 104, "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/Perfect.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": 135, "size": 323 }
module Issue478 where record Ko (Q : Set) : Set₁ where field T : Set module Bo (P : Set) (ko : Ko P) where open Ko ko err : T err = Set {- The error message was: Set₁ !=< T P ko of type Set₂ when checking that the expression Set has type T P ko We now get the desired error message: Set₁ !=< T of type Set₂ when checking that the expression Set has type T -}
{ "alphanum_fraction": 0.6520618557, "avg_line_length": 15.52, "ext": "agda", "hexsha": "a4b22f8220a24e0058a4b0007c0ae830cf0d383a", "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": "4383a3d20328a6c43689161496cee8eb479aca08", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "dagit/agda", "max_forks_repo_path": "test/fail/Issue478.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "4383a3d20328a6c43689161496cee8eb479aca08", "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": "dagit/agda", "max_issues_repo_path": "test/fail/Issue478.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": "test/fail/Issue478.agda", "max_stars_repo_stars_event_max_datetime": "2019-11-27T07:26:06.000Z", "max_stars_repo_stars_event_min_datetime": "2019-11-27T07:26:06.000Z", "num_tokens": 121, "size": 388 }
{-# OPTIONS --cubical --safe #-} module Ag08 where open import Cubical.Core.Everything open import Cubical.Foundations.Everything open import Cubical.Data.Everything -- maybe helpful when case splitting record Reveal_·_is_ {a b} {A : Set a} {B : A → Set b} (f : (x : A) → B x) (x : A) (y : B x) : Set (ℓ-max a b) where constructor [_] field eq : f x ≡ y inspect : ∀ {a b} {A : Set a} {B : A → Set b} (f : (x : A) → B x) (x : A) → Reveal f · x is f x inspect f x = [ refl ] -- Lift is necessary for Bool and Bool ≡ Bool are of different level. :-P Bool≡[Bool≡Bool] : Lift Bool ≡ (Bool ≡ Bool) Bool≡[Bool≡Bool] = {!!}
{ "alphanum_fraction": 0.5674074074, "avg_line_length": 29.347826087, "ext": "agda", "hexsha": "9238320af9fd203ff2d16c3552536077ed7cd200", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2019-12-13T04:50:46.000Z", "max_forks_repo_forks_event_min_datetime": "2019-12-13T04:50:46.000Z", "max_forks_repo_head_hexsha": "eb2cef0556efb9a4ce11783f8516789ea48cc344", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Brethland/LEARNING-STUFF", "max_forks_repo_path": "Agda/Ag08.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "eb2cef0556efb9a4ce11783f8516789ea48cc344", "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": "Brethland/LEARNING-STUFF", "max_issues_repo_path": "Agda/Ag08.agda", "max_line_length": 73, "max_stars_count": 2, "max_stars_repo_head_hexsha": "eb2cef0556efb9a4ce11783f8516789ea48cc344", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Brethland/LEARNING-STUFF", "max_stars_repo_path": "Agda/Ag08.agda", "max_stars_repo_stars_event_max_datetime": "2020-03-11T10:35:42.000Z", "max_stars_repo_stars_event_min_datetime": "2020-02-03T05:05:52.000Z", "num_tokens": 233, "size": 675 }
{-# OPTIONS --without-K #-} open import Data.Nat open import Data.Two open import Data.Zero open import Data.Fin.NP open import Type open import Function open import Relation.Binary.PropositionalEquality.NP import Explore.Universe.Base open import Explore.Core open import Explore.Zero open import Explore.One open import Explore.Two open import Explore.Universe.Type -- Exploring Fin comes in two flavors Regular & Custom -- We recommend Regular if you want to work for arbitrary values of n. -- We recommend Custom if you want to work for particular values of n (2, 6...). module Explore.Fin where module Regular n = Explore.Universe.Base (≃ᵁ (Finᵁ n) (Fin n) (Finᵁ≃Fin n)) module Custom where module _ n where open Explore.Universe.Base (≃ᵁ (Finᵁ' n) (Fin n) (Finᵁ'≃Fin n)) public Finᵉ0-𝟘ᵉ : (λ {M : ★₀} (ε : M) op f → explore 0 ε op (f ∘ Fin▹𝟘)) ≡ 𝟘ᵉ Finᵉ0-𝟘ᵉ = refl Finᵉ1-𝟙ᵉ : (λ {M : ★₀} (ε : M) op f → explore 1 ε op (f ∘ Fin▹𝟙)) ≡ 𝟙ᵉ Finᵉ1-𝟙ᵉ = refl Finᵉ2-𝟚ᵉ : (λ {M : ★₀} (ε : M) op f → explore 2 ε op (f ∘ Fin▹𝟚)) ≡ 𝟚ᵉ Finᵉ2-𝟚ᵉ = refl module ByHand {ℓ} where Finᵉ' : ∀ n → Explore ℓ (Fin n) Finᵉ' zero z _⊕_ f = z Finᵉ' (suc n) z _⊕_ f = f zero ⊕ Finᵉ' n z _⊕_ (f ∘ suc) -- Finᵉ and Finᵉ' are extensionally equal. -- Moreover the simplicity of the proof shows that the two functions are computing -- in the same way. Finᵉ-Finᵉ' : ∀ n {M} (ε : M) (_⊕_ : M → M → M) (f : Fin n → M) → Regular.explore n ε _⊕_ f ≡ Finᵉ' n ε _⊕_ f Finᵉ-Finᵉ' zero ε _⊕_ f = idp Finᵉ-Finᵉ' (suc n) ε _⊕_ f = ap (_⊕_ (f zero)) (Finᵉ-Finᵉ' n ε _⊕_ (f ∘ suc))
{ "alphanum_fraction": 0.6318042813, "avg_line_length": 32.7, "ext": "agda", "hexsha": "a752e85d8b9f4a9659b441fe04d576a2d816a12e", "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": "16bc8333503ff9c00d47d56f4ec6113b9269a43e", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "crypto-agda/explore", "max_forks_repo_path": "lib/Explore/Fin.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "16bc8333503ff9c00d47d56f4ec6113b9269a43e", "max_issues_repo_issues_event_max_datetime": "2019-03-16T14:24:04.000Z", "max_issues_repo_issues_event_min_datetime": "2019-03-16T14:24:04.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "crypto-agda/explore", "max_issues_repo_path": "lib/Explore/Fin.agda", "max_line_length": 110, "max_stars_count": 2, "max_stars_repo_head_hexsha": "16bc8333503ff9c00d47d56f4ec6113b9269a43e", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "crypto-agda/explore", "max_stars_repo_path": "lib/Explore/Fin.agda", "max_stars_repo_stars_event_max_datetime": "2017-06-28T19:19:29.000Z", "max_stars_repo_stars_event_min_datetime": "2016-06-05T09:25:32.000Z", "num_tokens": 715, "size": 1635 }
------------------------------------------------------------------------ -- Preimages ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} -- Partly based on Voevodsky's work on so-called univalent -- foundations. open import Equality module Preimage {reflexive} (eq : ∀ {a p} → Equality-with-J a p reflexive) where open import Bijection eq as Bijection hiding (id; _∘_) open Derived-definitions-and-properties eq open import H-level eq as H-level open import Injection eq hiding (id; _∘_) open import Logical-equivalence using (module _⇔_) open import Prelude open import Surjection eq hiding (id; _∘_) -- The preimage of y under f is denoted by f ⁻¹ y. infix 5 _⁻¹_ _⁻¹_ : ∀ {a b} {A : Type a} {B : Type b} → (A → B) → B → Type (a ⊔ b) f ⁻¹ y = ∃ λ x → f x ≡ y -- Preimages under the identity function are contractible. (Note that -- Singleton x is equal to id ⁻¹ x.) id⁻¹-contractible : ∀ {a} {A : Type a} (y : A) → Contractible (id ⁻¹ y) id⁻¹-contractible = singleton-contractible -- _⁻¹_ respects extensional equality of functions. respects-extensional-equality : ∀ {a b} {A : Type a} {B : Type b} {f g : A → B} {y} → (∀ x → f x ≡ g x) → (f ⁻¹ y) ↔ (g ⁻¹ y) respects-extensional-equality {f = f} {g} {y} f≡g = record { surjection = record { logical-equivalence = record { to = to′ ; from = from′ } ; right-inverse-of = right-inverse-of } ; left-inverse-of = left-inverse-of } where to′ : f ⁻¹ y → g ⁻¹ y to′ (x , fx≡y) = x , ( g x ≡⟨ sym $ f≡g x ⟩ f x ≡⟨ fx≡y ⟩∎ y ∎) from′ : g ⁻¹ y → f ⁻¹ y from′ (x , gx≡y) = x , ( f x ≡⟨ f≡g x ⟩ g x ≡⟨ gx≡y ⟩∎ y ∎) abstract right-inverse-of : ∀ p → to′ (from′ p) ≡ p right-inverse-of = λ g⁻¹y → cong (_,_ (proj₁ g⁻¹y)) ( let p = f≡g (proj₁ g⁻¹y); q = proj₂ g⁻¹y in trans (sym p) (trans p q) ≡⟨ sym $ trans-assoc _ _ _ ⟩ trans (trans (sym p) p) q ≡⟨ cong (λ p → trans p q) (trans-symˡ _) ⟩ trans (refl _) q ≡⟨ trans-reflˡ _ ⟩∎ q ∎) left-inverse-of : ∀ p → from′ (to′ p) ≡ p left-inverse-of = λ f⁻¹y → cong (_,_ (proj₁ f⁻¹y)) let p = f≡g (proj₁ f⁻¹y); q = proj₂ f⁻¹y in trans p (trans (sym p) q) ≡⟨ sym $ trans-assoc _ _ _ ⟩ trans (trans p (sym p)) q ≡⟨ cong (λ p → trans p q) (trans-symʳ _) ⟩ trans (refl _) q ≡⟨ trans-reflˡ _ ⟩∎ q ∎ -- Split surjections can be lifted to preimages. lift-surjection : ∀ {a b} {A : Type a} {B : Type b} (A↠B : A ↠ B) → let open _↠_ A↠B in ∀ {y} → (from ∘ to ⁻¹ y) ↠ (from ⁻¹ y) lift-surjection {A = A} {B} A↠B {y} = record { logical-equivalence = record { to = drop-∘ ; from = add-∘ } ; right-inverse-of = right-inv } where open _↠_ A↠B -- Given a preimage under (f ∘ g) a preimage under f can be -- constructed. drop-∘ : (from ∘ to) ⁻¹ y → from ⁻¹ y drop-∘ = Σ-map to id -- If f is a left inverse of g then the other direction also -- holds. abstract add-∘-lemma : ∀ {x} → from x ≡ y → from (to (from x)) ≡ y add-∘-lemma {x} from-x≡y = from (to (from x)) ≡⟨ cong from (right-inverse-of x) ⟩ from x ≡⟨ from-x≡y ⟩∎ y ∎ add-∘ : from ⁻¹ y → (from ∘ to) ⁻¹ y add-∘ (x , from-x≡y) = (from x , add-∘-lemma from-x≡y) abstract -- add-∘ is a right inverse of drop-∘. right-inv : (from⁻¹y : from ⁻¹ y) → drop-∘ (add-∘ from⁻¹y) ≡ from⁻¹y right-inv (x , from-x≡y) = (to (from x) , trans (cong from (right-inverse-of x)) from-x≡y) ≡⟨ sym $ lemma (right-inverse-of x) from-x≡y ⟩∎ (x , from-x≡y) ∎ where lemma : ∀ {x y z} {f : B → A} (y≡x : y ≡ x) (p : f x ≡ z) → _≡_ {A = f ⁻¹ z} (x , p) (y , trans (cong f y≡x) p) lemma {z = z} {f} = elim (λ {y x} y≡x → (p : f x ≡ z) → _≡_ {A = f ⁻¹ z} (x , p) (y , trans (cong f y≡x) p)) (λ x p → cong (_,_ x) ( p ≡⟨ sym $ trans-reflˡ _ ⟩ trans (refl (f x)) p ≡⟨ cong (λ q → trans q p) (sym (cong-refl f)) ⟩∎ trans (cong f (refl x)) p ∎)) -- A consequence of the lemmas above is that preimages under a -- bijection are contractible. bijection⁻¹-contractible : ∀ {a b} {A : Type a} {B : Type b} (A↔B : A ↔ B) → let open _↔_ A↔B in ∀ y → Contractible (to ⁻¹ y) bijection⁻¹-contractible A↔B = H-level.respects-surjection surj 0 ∘ id⁻¹-contractible where open _↔_ (Bijection.inverse A↔B) surj : ∀ {y} → id ⁻¹ y ↠ from ⁻¹ y surj {y} = id ⁻¹ y ↠⟨ _↔_.surjection $ respects-extensional-equality (sym ∘ left-inverse-of) ⟩ from ∘ to ⁻¹ y ↠⟨ lift-surjection surjection ⟩□ from ⁻¹ y □ abstract -- Preimages under an injection into a set are propositional. injection⁻¹-propositional : ∀ {a b} {A : Type a} {B : Type b} (A↣B : A ↣ B) → let open _↣_ A↣B in Is-set B → ∀ y → Is-proposition (to ⁻¹ y) injection⁻¹-propositional A↣B B-set y (x₁ , tox₁≡y) (x₂ , tox₂≡y) = Σ-≡,≡→≡ (injective (to x₁ ≡⟨ tox₁≡y ⟩ y ≡⟨ sym tox₂≡y ⟩∎ to x₂ ∎)) (subst (λ x → to x ≡ y) (injective (trans tox₁≡y (sym tox₂≡y))) tox₁≡y ≡⟨ B-set _ _ ⟩∎ tox₂≡y ∎) where open _↣_ A↣B
{ "alphanum_fraction": 0.4851573677, "avg_line_length": 32.323699422, "ext": "agda", "hexsha": "f6dd092e7f97dcf5550f9c52a0d9f960e607ba22", "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": "402b20615cfe9ca944662380d7b2d69b0f175200", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "nad/equality", "max_forks_repo_path": "src/Preimage.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "402b20615cfe9ca944662380d7b2d69b0f175200", "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/equality", "max_issues_repo_path": "src/Preimage.agda", "max_line_length": 120, "max_stars_count": 3, "max_stars_repo_head_hexsha": "402b20615cfe9ca944662380d7b2d69b0f175200", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "nad/equality", "max_stars_repo_path": "src/Preimage.agda", "max_stars_repo_stars_event_max_datetime": "2021-09-02T17:18:15.000Z", "max_stars_repo_stars_event_min_datetime": "2020-05-21T22:58:50.000Z", "num_tokens": 2191, "size": 5592 }
module Money where import Agda.Builtin.IO as Builtin using (IO) import Data.Rational as ℚ using (_+_; _*_) open import Codata.Musical.Notation using (♯_) open import Data.Nat using (ℕ; suc) open import Data.Integer as ℤ using (+_) open import Data.List using (List; []; _∷_) open import Data.Rational as ℚ using (ℚ; 0ℚ; _/_) open import Data.String using (String) open import Data.Unit using (⊤) open import Function using (_∘_) renaming (_$_ to _$$_) open import IO using (putStrLn; IO; _>>_; run; sequence) open import Relation.Binary.PropositionalEquality using (_≡_; refl; _≢_) open import Relation.Binary using (Decidable) open import Relation.Nullary using (yes; no) open import Codata.Musical.Colist as Colist using (fromList) open Colist renaming (_∷_ to _::_) data Currency : Set where € : Currency £ : Currency $ : Currency ¥ : Currency data Money : Currency → Set where mkMoney : {c : Currency} → ℚ → Money c noMoney : Money $ noMoney = mkMoney (+ 0 / 1) _+_ : {c : Currency} → Money c → Money c → Money c mkMoney x₁ + mkMoney x₂ = mkMoney (x₁ ℚ.+ x₂) infix 30 _+_ _*_ : {c : Currency} → ℚ → Money c → Money c x * mkMoney y = mkMoney (x ℚ.* y) record SomeMoney : Set where field currency : Currency money : Money currency mkSomeMoney : Currency → ℚ → SomeMoney mkSomeMoney currency amount = record { currency = currency; money = mkMoney amount } record Trade : Set where constructor mkTrade field tPrice : SomeMoney tQty : ℚ data Equal? (c₁ c₂ : Currency) : Set where eq : c₁ ≡ c₂ → Equal? c₁ c₂ neq : c₁ ≢ c₂ → Equal? c₁ c₂ infix 4 _≟_ _≟_ : Decidable {A = Currency} _≡_ € ≟ € = yes refl € ≟ £ = no (λ ()) € ≟ $ = no (λ ()) € ≟ ¥ = no (λ ()) £ ≟ € = no (λ ()) £ ≟ £ = yes refl £ ≟ $ = no (λ ()) £ ≟ ¥ = no (λ ()) $ ≟ € = no (λ ()) $ ≟ £ = no (λ ()) $ ≟ $ = yes refl $ ≟ ¥ = no (λ ()) ¥ ≟ € = no (λ ()) ¥ ≟ £ = no (λ ()) ¥ ≟ $ = no (λ ()) ¥ ≟ ¥ = yes refl sumNotions : {c : Currency} → List Trade → Money c sumNotions [] = mkMoney 0ℚ sumNotions {c} (record { tPrice = record { currency = currency; money = money }; tQty = tQty } ∷ xs) with c ≟ currency ... | yes refl = (tQty * money) + sumNotions xs ... | no _ = sumNotions xs _/1 : ℕ → ℚ n /1 = + n / 1 testTrades : List Trade testTrades = mkTrade (mkSomeMoney £ (1 /1)) (100 /1) ∷ mkTrade (mkSomeMoney £ (2 /1)) (200 /1) ∷ mkTrade (mkSomeMoney $ (3 /1)) (300 /1) ∷ mkTrade (mkSomeMoney ¥ (5 /1)) (50 /1) ∷ [] open import Text.Printf using (printf) showℚ : ℚ → String showℚ record {numerator = n; denominator-1 = 0} = printf "%d" n showℚ record {numerator = n; denominator-1 = d} = printf "%d/%u" n (suc d) showCurrency : Currency → String showCurrency € = "€" showCurrency £ = "£" showCurrency $ = "$" showCurrency ¥ = "¥" showMoney : {c : Currency} → Money c → String showMoney {c} (mkMoney amount) = (printf "%s %s") (showCurrency c) (showℚ amount) main : Builtin.IO (Colist ⊤) main = run ∘ sequence ∘ fromList $$ putStrLn "Hello, World!" ∷ putStrLn (showMoney $$ sumNotions {€} testTrades) ∷ putStrLn (showMoney $$ sumNotions {£} testTrades) ∷ putStrLn (showMoney $$ sumNotions {$} testTrades) ∷ putStrLn (showMoney $$ sumNotions {¥} testTrades) ∷ []
{ "alphanum_fraction": 0.6219169529, "avg_line_length": 27.6120689655, "ext": "agda", "hexsha": "1a7c130749c9b12ca483c231615717c043beb905", "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": "f875dfb5f191e6a4a041a8aa4d08f98acdc5ab53", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "neosimsim/money-typed", "max_forks_repo_path": "Money.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "f875dfb5f191e6a4a041a8aa4d08f98acdc5ab53", "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": "neosimsim/money-typed", "max_issues_repo_path": "Money.agda", "max_line_length": 119, "max_stars_count": null, "max_stars_repo_head_hexsha": "f875dfb5f191e6a4a041a8aa4d08f98acdc5ab53", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "neosimsim/money-typed", "max_stars_repo_path": "Money.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1118, "size": 3203 }
import cedille-options module elab-util (options : cedille-options.options) where open import general-util open import cedille-types open import syntax-util open import type-util open import ctxt open import conversion open import constants open import instances open import subst open import rename open import rewriting open import free-vars open import toplevel-state options {IO} open import datatype-util open import bohm-out rename-validify : string → string rename-validify = 𝕃char-to-string ∘ (h ∘ string-to-𝕃char) where validify-char : char → 𝕃 char validify-char '/' = [ '-' ] validify-char '.' = [ '-' ] validify-char c with (c =char 'a') || (c =char 'z') || (c =char 'A') || (c =char 'Z') || (c =char '\'') || (c =char '-') || (c =char '_') || is-digit c || (c =char qual-local-chr) || (('a' <char c) && (c <char 'z')) || (('A' <char c) && (c <char 'Z')) ...| tt = [ c ] ...| ff = 'Z' :: string-to-𝕃char (ℕ-to-string (toNat c)) ++ [ 'Z' ] h : 𝕃 char → 𝕃 char h [] = [] h (c :: cs) = validify-char c ++ h cs -- Returns a fresh variable name by adding primes and replacing invalid characters fresh-var' : string → (string → 𝔹) → string fresh-var' x f = fresh-h f (rename-validify x) rename-new_from_for_ : ∀ {X : Set} → var → ctxt → (var → X) → X rename-new ignored-var from Γ for f = f $ fresh-var' "x" (ctxt-binds-var Γ) rename-new x from Γ for f = f $ fresh-var' x (ctxt-binds-var Γ) rename_from_for_ : ∀ {X : Set} → var → ctxt → (var → X) → X rename ignored-var from Γ for f = f ignored-var rename x from Γ for f = f $ fresh-var' x (ctxt-binds-var Γ) get-renaming : renamectxt → var → var → var × renamectxt get-renaming ρₓ xₒ x = let x' = fresh-var' x (renamectxt-in-field ρₓ) in x' , renamectxt-insert ρₓ xₒ x' rename_-_from_for_ : ∀ {X : Set} → var → var → renamectxt → (var → renamectxt → X) → X rename xₒ - ignored-var from ρₓ for f = f ignored-var ρₓ rename xₒ - x from ρₓ for f = uncurry f $ get-renaming ρₓ xₒ x rename_-_lookup_for_ : ∀ {X : Set} → var → var → renamectxt → (var → renamectxt → X) → X rename xₒ - x lookup ρₓ for f with renamectxt-lookup ρₓ xₒ ...| nothing = rename xₒ - x from ρₓ for f ...| just x' = f x' ρₓ rename_from_and_for_ : ∀ {X : Set} → var → ctxt → renamectxt → (var → ctxt → renamectxt → X) → X rename ignored-var from Γ and ρ for f = f ignored-var Γ ρ rename x from Γ and ρ for f = let x' = fresh-var' x (λ x → ctxt-binds-var Γ x || renamectxt-in-field ρ x) in f x' (ctxt-var-decl x' Γ) (renamectxt-insert ρ x x') module reindexing (Γ : ctxt) (D I mn : var) (isₒ : indices) (psₜ : params) where rnm : Set rnm = qualif × stringset rnm-insert : rnm → var → var → rnm rnm-insert (q , s) xₒ xₙ = trie-insert q xₒ (xₙ , []) , stringset-insert s xₙ rnm-add : rnm → var → var → args → rnm rnm-add (q , s) xₒ xₙ as = trie-insert q xₒ (xₙ , as) , stringset-insert s xₙ rnm-binds : rnm → var → 𝔹 rnm-binds (q , s) x = trie-contains q x || trie-contains s x reindex-fresh-var : rnm → trie indices → var → var reindex-fresh-var ρₓ is ignored-var = ignored-var reindex-fresh-var ρₓ is x = fresh-h (λ x' → ctxt-binds-var Γ x' || trie-contains is x' || rnm-binds ρₓ x') x rename-indices' : rnm → trie indices → indices rename-indices' ρₓ is = foldr {B = renamectxt → rnm → indices} (λ {(Index x atk) f r ρₓ → let x' = reindex-fresh-var ρₓ is x in Index x' (substh Γ r empty-trie -tk atk) :: f (renamectxt-insert r x x') (rnm-insert ρₓ x x')}) (λ r ρₓ → []) isₒ empty-renamectxt ρₓ reindex-t : Set → Set reindex-t X = rnm → trie indices → X → X {-# TERMINATING #-} reindex : ∀ {ed} → reindex-t ⟦ ed ⟧ rc-is : rnm → indices → rnm rc-is = foldr λ {(Index x atk) ρₓ → rnm-insert ρₓ x x} is-index-var : maybe tpkd → 𝔹 is-index-var (just (Tkt (TpVar x))) = x =string I is-index-var _ = ff reindex {TERM} ρₓ is (AppEr t (Var x)) with trie-lookup is x ...| nothing = AppEr (reindex ρₓ is t) $ reindex ρₓ is $ Var x ...| just is' = indices-to-apps is' $ reindex ρₓ is t reindex {TERM} ρₓ is (App t t') = App (reindex ρₓ is t) (reindex ρₓ is t') reindex {TERM} ρₓ is (AppE t tT) = AppE (reindex ρₓ is t) (reindex ρₓ is -tT tT) reindex {TERM} ρₓ is (Beta t t') = Beta (reindex ρₓ is t) (reindex ρₓ is t') reindex {TERM} ρₓ is (Delta b? T t) = Delta (b? >>=c λ t₁ t₂ → just (reindex ρₓ is t₁ , reindex ρₓ is t₂)) (reindex ρₓ is T) (reindex ρₓ is t) reindex {TERM} ρₓ is (Hole pi) = Hole pi reindex {TERM} ρₓ is (IotaPair t₁ t₂ x Tₓ) = let x' = reindex-fresh-var ρₓ is x in IotaPair (reindex ρₓ is t₁) (reindex ρₓ is t₂) x' (reindex (rnm-insert ρₓ x x') is Tₓ) reindex {TERM} ρₓ is (IotaProj t n) = IotaProj (reindex ρₓ is t) n reindex {TERM} ρₓ is (Lam me x tk? t) with is-index-var tk? ...| ff = let x' = reindex-fresh-var ρₓ is x in Lam me x' (reindex ρₓ is -tk_ <$> tk?) (reindex (rnm-insert ρₓ x x') is t) ...| tt with rename-indices' ρₓ is ...| isₙ = indices-to-lams isₙ $ reindex (rc-is ρₓ isₙ) (trie-insert is x isₙ) t reindex {TERM} ρₓ is (LetTm me x T? t t') = let x' = reindex-fresh-var ρₓ is x in LetTm me x' (reindex ρₓ is <$> T?) (reindex ρₓ is t) (reindex (rnm-insert ρₓ x x') is t') reindex {TERM} ρₓ is (LetTp x k T t) = let x' = reindex-fresh-var ρₓ is x in LetTp x' (reindex ρₓ is k) (reindex ρₓ is T) (reindex (rnm-insert ρₓ x x') is t) reindex {TERM} ρₓ is (Phi t₌ t₁ t₂) = Phi (reindex ρₓ is t₌) (reindex ρₓ is t₁) (reindex ρₓ is t₂) reindex {TERM} ρₓ is (Rho t₌ x Tₓ t) = let x' = reindex-fresh-var ρₓ is x in Rho (reindex ρₓ is t) x' (reindex (rnm-insert ρₓ x x') is Tₓ) (reindex ρₓ is t) reindex {TERM} ρₓ is (VarSigma t) = VarSigma (reindex ρₓ is t) reindex {TERM} ρₓ is (Var x) = maybe-else' (trie-lookup (fst ρₓ) x) (Var x) (uncurry (apps-term ∘ Var)) reindex {TERM} ρₓ is (Mu μ t Tₘ? f~ cs) = Var "template-mu-not-allowed" reindex {TERM} ρₓ is (Sigma μ t Tₘ? f~ cs) = Var "template-sigma-not-allowed" reindex {TYPE} ρₓ is (TpAbs me x atk T) with is-index-var (just atk) ...| ff = let x' = reindex-fresh-var ρₓ is x in TpAbs me x' (reindex ρₓ is -tk atk) (reindex (rnm-insert ρₓ x x') is T) ...| tt = let isₙ = rename-indices' ρₓ is in indices-to-alls isₙ $ reindex (rc-is ρₓ isₙ) (trie-insert is x isₙ) T reindex {TYPE} ρₓ is (TpEq t₁ t₂) = TpEq (reindex ρₓ is t₁) (reindex ρₓ is t₂) reindex {TYPE} ρₓ is (TpIota x T T') = let x' = reindex-fresh-var ρₓ is x in TpIota x' (reindex ρₓ is T) (reindex (rnm-insert ρₓ x x') is T') reindex {TYPE} ρₓ is (TpAppTm T (Var x)) with trie-lookup is x ...| nothing = TpAppTm (reindex ρₓ is T) $ reindex ρₓ is $ Var x ...| just is' = indices-to-tpapps is' $ reindex ρₓ is T reindex {TYPE} ρₓ is (TpApp T tT) = TpApp (reindex ρₓ is T) (reindex ρₓ is -tT tT) reindex {TYPE} ρₓ is (TpHole pi) = TpHole pi reindex {TYPE} ρₓ is (TpLam x atk T) with is-index-var (just atk) ...| ff = let x' = reindex-fresh-var ρₓ is x in TpLam x' (reindex ρₓ is -tk atk) (reindex (rnm-insert ρₓ x x') is T) ...| tt = let isₙ = rename-indices' ρₓ is in indices-to-tplams isₙ $ reindex (rc-is ρₓ isₙ) (trie-insert is x isₙ) T reindex {TYPE} ρₓ is (TpVar x) = maybe-else' (trie-lookup (fst ρₓ) x) (TpVar x) (uncurry (apps-type ∘ TpVar)) reindex {KIND} ρₓ is (KdAbs x atk k) with is-index-var (just atk) ...| ff = let x' = reindex-fresh-var ρₓ is x in KdAbs x' (reindex ρₓ is -tk atk) (reindex (rnm-insert ρₓ x x') is k) ...| tt = let isₙ = rename-indices' ρₓ is in indices-to-kind isₙ $ reindex (rc-is ρₓ isₙ) (trie-insert is x isₙ) k reindex {KIND} ρₓ is (KdHole pi) = KdHole pi reindex {KIND} ρₓ is KdStar = KdStar reindex-cmd : rnm → trie indices → cmd → cmd × rnm reindex-cmd ρₓ is (CmdImport (Import p? fp mnᵢ q? as)) = CmdImport (Import p? fp mnᵢ q? (reindex ρₓ is -arg_ <$> as)) , ρₓ reindex-cmd ρₓ is (CmdDefTerm x t) = let x' = D ^ "/" ^ x in CmdDefTerm x' (lam-expand-term psₜ $ reindex ρₓ is t) , rnm-add ρₓ (mn # x) (ctxt.mn Γ # x') (params-to-args psₜ) reindex-cmd ρₓ is (CmdDefType x k T) = let x' = D ^ "/" ^ x in CmdDefType x' (abs-expand-kind psₜ $ reindex ρₓ is k) (lam-expand-type psₜ $ reindex ρₓ is T) , rnm-add ρₓ (mn # x) (ctxt.mn Γ # x') (params-to-args psₜ) reindex-cmd ρₓ is (CmdDefKind x ps k) = CmdDefKind x ps k , ρₓ reindex-cmd ρₓ is (CmdDefData es x ps k cs) = CmdDefData es x ps k cs , ρₓ reindex-cmds : cmds → cmds reindex-cmds cs = foldr {B = rnm → cmds} (λ c rec ρₓ → elim reindex-cmd ρₓ empty-trie c for λ c ρₓ → c :: rec ρₓ) (λ ρₓ → []) cs (empty-trie , empty-stringset) {- we have to erase params to work around a situation like data MyData (x : {β ≃ β}) : ★ = | MyCtr : MyData. erased-problem : ∀ x : {β ≃ β}. MyData x ➔ MyData β{λ x. x} = Λ x. λ d. μ' d { MyCtr ➔ MyCtr β{λ x. x} }. ^----------------------------------------^ ... because the indicated term would elaborate to something like Λ x. λ d. FixInd x ·MyData d ... ^-^ ^ and "x" is bound by an erased lambda, but is an unerased arg to FixInd! (similar situations arise with fix-in/fix-out and with module parameters) -} reindex-file : ctxt → (D I modname : var) → indices → params → cmds → cmds reindex-file Γ D I mn is ps cs = let ps' = params-set-erased Erased (ctxt.ps Γ ++ ps) open reindexing (add-params-to-ctxt ps' Γ) D I mn is ps' in reindex-cmds cs mendler-elab-mu : ctxt → datatype-info → var → term → type → cases → term mendler-elab-mu-pure : ctxt → datatype-info → var → term → cases → term mendler-elab-sigma : ctxt → datatype-info → maybe term → term → type → cases → term mendler-elab-sigma-pure : ctxt → datatype-info → maybe term → term → cases → term -- Maps over expression, elaborating all mu-terms {-# TERMINATING #-} choose-mu : ∀ {ed} → ctxt → renamectxt → ⟦ ed ⟧ → ⟦ ed ⟧ choose-mu {TERM} Γ ρ (App tm tm') = App (choose-mu Γ ρ tm) (choose-mu Γ ρ tm') choose-mu {TERM} Γ ρ (AppE tm tT) = AppE (choose-mu Γ ρ tm) (choose-mu Γ ρ -tT tT) choose-mu {TERM} Γ ρ (Beta tm tm') = Beta (choose-mu Γ ρ tm) (choose-mu Γ ρ tm') choose-mu {TERM} Γ ρ (Delta b? tp tm) = maybe-else' (b? >>=c λ t₁ t₂ → make-contradiction (hnf Γ unfold-all (choose-mu Γ ρ t₁)) (hnf Γ unfold-all (choose-mu Γ ρ t₂))) (Delta nothing (choose-mu Γ ρ tp) (choose-mu Γ ρ tm)) λ f → rename "x" from Γ and ρ for λ x' _ _ → Delta (just (tt-term , ff-term)) (choose-mu Γ ρ tp) (Rho (choose-mu Γ ρ tm) x' (TpEq (App f (Var x')) ff-term) (Beta ff-term id-term)) choose-mu {TERM} Γ ρ (Hole pi) = Hole pi choose-mu {TERM} Γ ρ (IotaPair tm₁ tm₂ x Tₓ) = rename x from Γ and ρ for λ x' Γ' ρ' → IotaPair (choose-mu Γ ρ tm₁) (choose-mu Γ ρ tm₂) x' (choose-mu Γ' ρ' Tₓ) choose-mu {TERM} Γ ρ (IotaProj tm n) = IotaProj (choose-mu Γ ρ tm) n choose-mu {TERM} Γ ρ (Lam e x tk? tm) = rename x from Γ and ρ for λ x' Γ' ρ' → Lam e x' (choose-mu Γ ρ -tk_ <$> tk?) (choose-mu Γ' ρ' tm) choose-mu {TERM} Γ ρ (LetTm e x tp? tm tm') = rename x from Γ and ρ for λ x' Γ' ρ' → LetTm e x' (choose-mu Γ ρ <$> tp?) (choose-mu Γ ρ tm) (choose-mu Γ' ρ' tm') choose-mu {TERM} Γ ρ (LetTp x k T t) = rename x from Γ and ρ for λ x' Γ' ρ' → LetTp x' (choose-mu Γ ρ k) (choose-mu Γ ρ T) (choose-mu Γ' ρ' t) choose-mu {TERM} Γ ρ (Phi tm₌ tm₁ tm₂) = Phi (choose-mu Γ ρ tm₌) (choose-mu Γ ρ tm₁) (choose-mu Γ ρ tm₂) choose-mu {TERM} Γ ρ (Rho tm₌ x Tₓ tm) = rename x from Γ and ρ for λ x' Γ' ρ' → Rho (choose-mu Γ ρ tm₌) x' (choose-mu Γ' ρ' Tₓ) (choose-mu Γ ρ tm) choose-mu {TERM} Γ ρ (VarSigma tm) = VarSigma (choose-mu Γ ρ tm) choose-mu {TERM} Γ ρ (Mu x t tp? t~ ms) = choose-mu Γ ρ (maybe-else' tp? (mendler-elab-mu-pure Γ t~ x t ms) (λ tp → mendler-elab-mu Γ t~ x t tp ms)) choose-mu {TERM} Γ ρ (Sigma mt t tp? t~ ms) = choose-mu Γ ρ (maybe-else' tp? (mendler-elab-sigma-pure Γ t~ mt t ms) (λ tp → mendler-elab-sigma Γ t~ mt t tp ms)) choose-mu {TERM} Γ ρ (Var x) = Var (renamectxt-rep ρ x) choose-mu {TYPE} Γ ρ (TpAbs e x tk tp) = rename x from Γ and ρ for λ x' Γ' ρ' → TpAbs e x' (choose-mu Γ ρ -tk tk) (choose-mu Γ' ρ' tp) choose-mu {TYPE} Γ ρ (TpIota x tp₁ tp₂) = rename x from Γ and ρ for λ x' Γ' ρ' → TpIota x' (choose-mu Γ ρ tp₁) (choose-mu Γ' ρ' tp₂) choose-mu {TYPE} Γ ρ (TpApp tp tT) = TpApp (choose-mu Γ ρ tp) (choose-mu Γ ρ -tT tT) choose-mu {TYPE} Γ ρ (TpEq tmₗ tmᵣ) = TpEq (choose-mu Γ ρ tmₗ) (choose-mu Γ ρ tmᵣ) choose-mu {TYPE} Γ ρ (TpHole pi) = TpHole pi choose-mu {TYPE} Γ ρ (TpLam x tk tp) = rename x from Γ and ρ for λ x' Γ' ρ' → TpLam x' (choose-mu Γ ρ -tk tk) (choose-mu Γ' ρ' tp) choose-mu {TYPE} Γ ρ (TpVar x) = TpVar (renamectxt-rep ρ x) choose-mu {KIND} Γ ρ (KdAbs x tk kd) = rename x from Γ and ρ for λ x' Γ' ρ' → KdAbs x' (choose-mu Γ ρ -tk tk) (choose-mu Γ' ρ' kd) choose-mu {KIND} Γ ρ (KdHole pi) = KdHole pi choose-mu {KIND} Γ ρ KdStar = KdStar -- Adds all Dₓ's encoding defs to the ctxt ctxt-open-encoding-defs : var → ctxt → maybe ctxt ctxt-open-encoding-defs Dₓ Γ = trie-lookup (ctxt.μ~ Γ) Dₓ >>=r λ xs → let tmd = λ t → term-def nothing opacity-open (just t) (TpHole pi-gen) tpd = λ T → type-def nothing opacity-open (just T) (KdHole pi-gen) in record Γ { i = foldr (uncurry λ x tT i → trie-insert i x (either-else' tT (tmd ∘ hnf (record Γ {i = i}) unfold-head) (tpd ∘ hnf (record Γ {i = i}) unfold-head-elab) , missing-location)) (ctxt.i Γ) xs } ctxt-open-all-encoding-defs : ctxt → ctxt ctxt-open-all-encoding-defs Γ = foldr (λ Dₓ Γ → maybe-else Γ id $ ctxt-open-encoding-defs Dₓ Γ) Γ (trie-strings (ctxt.μ~ Γ)) mk-ctr-fmap-t : Set → Set mk-ctr-fmap-t X = ctxt → (var × type × term) → X {-# TERMINATING #-} mk-ctr-fmap-η+ : mk-ctr-fmap-t (term → type → term) mk-ctr-fmap-η- : mk-ctr-fmap-t (term → type → term) mk-ctr-fmap-η? : 𝔹 → mk-ctr-fmap-t (term → type → term) mk-ctr-fmap-η= : 𝔹 → mk-ctr-fmap-t (term → type → term) mk-ctr-fmapₖ-η+ : mk-ctr-fmap-t (type → kind → type) mk-ctr-fmapₖ-η- : mk-ctr-fmap-t (type → kind → type) mk-ctr-fmapₖ-η? : 𝔹 → mk-ctr-fmap-t (type → kind → type) -- TODO: Join fmap+ and fmap- into one function, to handle this for both strictly positive and strictly negative parameter occurrences in other datatypes mk-ctr-fmap-η= f Γ x @ (Aₓ , Bₓ , castₓ) body T with decompose-ctr-type Γ T ...| TpVar x'' , as , rs = maybe-else' (data-lookup (add-params-to-ctxt as Γ) x'' rs) ((if f then mk-ctr-fmap-η+ else mk-ctr-fmap-η-) Γ x body T) λ where d @ (mk-data-info X _ asₚ asᵢ ps kᵢ k cs csₚₛ eds gds) → params-to-lams (if f then as else (substh-params Γ empty-renamectxt (trie-single Aₓ (, Bₓ)) as)) $ let Γ' = add-params-to-ctxt as Γ recₓ = fresh-var Γ' "fmap" Γ' = ctxt-var-decl recₓ Γ' is = kind-to-indices Γ k uₓ = fresh-var (add-indices-to-ctxt is Γ') "u" vₓ = fresh-var (add-indices-to-ctxt is Γ') "v" Γ'' = ctxt-var-decl vₓ $ ctxt-var-decl uₓ $ add-indices-to-ctxt is Γ' in LetTm tt uₓ nothing (Mu recₓ (foldl (λ {(Param me x'' (Tkt T)) body → (if me then AppEr body else App body) $ mk-ctr-fmap-η? (~ f) Γ' x (Var x'') T; (Param _ x'' (Tkk k)) body → AppTp body $ mk-ctr-fmapₖ-η? (~ f) Γ' x (TpVar x'') k}) body as) (just (indices-to-tplams is $ TpLam uₓ (Tkt $ indices-to-tpapps is $ recompose-tpapps (args-to-tmtps asₚ) (TpVar X)) $ TpIota vₓ (subst Γ'' Bₓ Aₓ (recompose-tpapps (args-to-tmtps asₚ) (TpVar X))) (TpEq (Var vₓ) (Var uₓ)))) d $ flip map (map-snd (rename-var Γ'' (mu-Type/ recₓ) X) <$> inst-ctrs Γ'' ps asₚ cs) $ uncurry λ cₓ T → case decompose-ctr-type Γ T of λ where (Tₕ , as , rs) → Case cₓ (map (λ {(Param me x tk) → CaseArg me x (just tk)}) as) (let Xₚₛ = recompose-tpapps (args-to-tmtps asₚ) (TpVar X) cg = mu-Type/ recₓ , Xₚₛ , (indices-to-lams is $ Lam ff vₓ (just (Tkt (indices-to-tpapps is (TpVar (mu-Type/ recₓ))))) (Phi (IotaProj (App (indices-to-apps is (Var recₓ)) (Var vₓ)) ι2) (IotaProj (App (indices-to-apps is (Var recₓ)) (Var vₓ)) ι1) (Var vₓ))) t = foldl (λ {(Param me x'' (Tkt T)) body → (if me then AppEr body else App body) $ mk-ctr-fmap-η? f Γ' x (mk-ctr-fmap-η? ff Γ' cg (Var x'') T) (subst Γ'' Xₚₛ (mu-Type/ recₓ) T); (Param _ x'' (Tkk k)) body → AppTp body $ mk-ctr-fmapₖ-η? f Γ' x (mk-ctr-fmapₖ-η? ff Γ' cg (TpVar x'') k) (subst Γ'' Xₚₛ (mu-Type/ recₓ) k)}) (subst (add-params-to-ctxt as Γ) Bₓ Aₓ (recompose-apps asₚ (Var cₓ))) as tₑ = erase t in IotaPair t (Beta tₑ tₑ) vₓ (TpEq (Var vₓ) tₑ)) rs) (Phi (IotaProj (Var uₓ) ι2) (IotaProj (Var uₓ) ι1) (erase (params-to-apps as body))) -- maybe-else' (ctxt-open-encoding-defs x'' Γ) (f Γ x body T) -- λ Γ → f Γ x body (hnf-ctr Γ (fst x) T) ...| _ = (if f then mk-ctr-fmap-η+ else mk-ctr-fmap-η-) Γ x body T mk-ctr-fmap-η? f Γ x body T with is-free-in (fst x) T ...| tt = mk-ctr-fmap-η= f Γ x body T ...| ff = body mk-ctr-fmapₖ-η? f Γ x body k with is-free-in (fst x) k ...| tt = (if f then mk-ctr-fmapₖ-η+ else mk-ctr-fmapₖ-η-) Γ x body k ...| ff = body mk-ctr-fmap-η+ Γ x @ (Aₓ , Bₓ , _) body T with decompose-ctr-type Γ T ...| Tₕ , as , _ = params-to-lams as $ let Γ' = add-params-to-ctxt as Γ tₓ' = case Tₕ of λ where (TpIota x'' T₁ T₂) body → let t₁ = mk-ctr-fmap-η+ Γ' x (IotaProj body ι1) T₁ t₂ = mk-ctr-fmap-η+ Γ' x (IotaProj body ι2) (subst Γ' t₁ x'' T₂) in IotaPair t₁ t₂ x'' T₂ _ body → body in tₓ' $ foldl (λ {(Param me x'' (Tkt T)) body → (if me then AppEr body else App body) $ mk-ctr-fmap-η? ff Γ' x (Var x'') T; (Param _ x'' (Tkk k)) body → AppTp body $ mk-ctr-fmapₖ-η? ff Γ' x (TpVar x'') k}) body as mk-ctr-fmap-η- Γ xₒ @ (Aₓ , Bₓ , castₓ) body T with decompose-ctr-type Γ T ...| TpVar x'' , as , rs = params-to-lams (substh-params Γ empty-renamectxt (trie-single Aₓ (, Bₓ)) as) $ let Γ' = add-params-to-ctxt as Γ in if x'' =string Aₓ then App (recompose-apps (tmtps-to-args Erased rs) castₓ) else id $ foldl (λ {(Param me x'' (Tkt T)) body → (if me then AppEr body else App body) $ mk-ctr-fmap-η? tt Γ' xₒ (Var x'') T; (Param me x'' (Tkk k)) body → AppTp body $ mk-ctr-fmapₖ-η? tt Γ' xₒ (TpVar x'') k}) body as ...| TpIota x'' T₁ T₂ , as , [] = let Γ' = add-params-to-ctxt as Γ tₒ = foldl (λ where (Param me x'' (Tkt T)) body → (if me then AppEr body else App body) $ mk-ctr-fmap-η? tt Γ' xₒ (Var x'') T (Param me x'' (Tkk k)) body → AppTp body $ mk-ctr-fmapₖ-η? tt Γ' xₒ (TpVar x'') k ) body as t₁ = mk-ctr-fmap-η? ff Γ' xₒ (IotaProj tₒ ι1) T₁ t₂ = mk-ctr-fmap-η? ff Γ' xₒ (IotaProj tₒ ι2) ([ Γ' - t₁ / x'' ] T₂) in params-to-lams (substh-params Γ empty-renamectxt (trie-single Aₓ (, Bₓ)) as) $ IotaPair t₁ t₂ x'' (subst (ctxt-var-decl x'' Γ') Bₓ Aₓ T₂) ...| Tₕ , as , rs = body mk-ctr-fmapₖ-η+ Γ xₒ @ (Aₓ , Bₓ , castₓ) body k = let is = kind-to-indices Γ k in indices-to-tplams is $ let Γ' = add-indices-to-ctxt is Γ in foldl (λ {(Index x'' (Tkt T)) → flip TpAppTm $ mk-ctr-fmap-η? ff Γ' xₒ (Var x'') T; (Index x'' (Tkk k)) → flip TpAppTp $ mk-ctr-fmapₖ-η? ff Γ' xₒ (TpVar x'') k}) body is mk-ctr-fmapₖ-η- Γ xₒ @ (Aₓ , Bₓ , castₓ) body k with kind-to-indices Γ k ...| is = indices-to-tplams is $ let Γ' = add-indices-to-ctxt is Γ in foldl (λ {(Index x'' (Tkt T)) → flip TpAppTm $ mk-ctr-fmap-η? tt Γ' xₒ (Var x'') T; (Index x'' (Tkk k)) → flip TpApp $ Ttp $ mk-ctr-fmapₖ-η? tt Γ' xₒ (TpVar x'') k}) body is mk-def : term → term mk-def t = Phi (Beta t id-term) t (erase t) top-type : type top-type = TpEq id-term id-term -- Index telescoping parameter pattern IdxTele Iₓ = Param tt Iₓ (Tkk KdStar) :: [] pattern EncArgIdx I = ArgTp I pattern EncArgCast Cast = ArgTp Cast pattern EncArgCastIn cast-in = Arg cast-in pattern EncArgCastOut cast-out = Arg cast-out pattern EncArgCastIs cast-is = Arg cast-is pattern EncArgFunctor Functor = ArgTp Functor pattern EncArgFunctorIn functor-in = Arg functor-in pattern EncArgFunctorOut functor-out = Arg functor-out pattern EncArgFix Fix = ArgTp Fix pattern EncArgFixIn fix-in = Arg fix-in pattern EncArgFixOut fix-out = Arg fix-out pattern EncArgLambek1 lambek1 = Arg lambek1 pattern EncArgLambek2 lambek2 = Arg lambek2 pattern EncArgFixInd fix-ind = Arg fix-ind pattern EncArgs I Cast cast-in cast-out cast-is Functor functor-in functor-out Fix fix-in fix-out lambek1 lambek2 fix-ind = EncArgIdx I :: EncArgCast Cast :: EncArgCastIn cast-in :: EncArgCastOut cast-out :: EncArgCastIs cast-is :: EncArgFunctor Functor :: EncArgFunctorIn functor-in :: EncArgFunctorOut functor-out :: EncArgFix Fix :: EncArgFixIn fix-in :: EncArgFixOut fix-out :: EncArgLambek1 lambek1 :: EncArgLambek2 lambek2 :: EncArgFixInd fix-ind :: [] pattern EncImp fp I Cast cast-in cast-out cast-is Functor functor-in functor-out Fix fix-in fix-out lambek1 lambek2 fix-ind = CmdImport (Import _ fp _ _ (EncArgs I Cast cast-in cast-out cast-is Functor functor-in functor-out Fix fix-in fix-out lambek1 lambek2 fix-ind)) encode-datatype : ctxt → encoding-defs → datatype → encoding-defs encode-datatype Γ eds @ (mk-enc-defs ecs _ Cast cast-in cast-out cast-is Functor functor-in functor-out Fix fix-in fix-out lambek1 lambek2 fix-ind) (Data Dₓ' ps is cs) = record eds {gcs = [: TypeF-cmd ⌟ IndF-cmd ⌟ fmap-cmd ⌟ D-cmd ⌟ Is-cmd ⌟ is-cmd ⌟ to-cmd ⌟ map ctr-cmd cs~ :] } where Γₚₛ = ctxt.ps Γ psₜ = params-set-erased Erased (Γₚₛ ++ ps) app-ps = params-to-apps psₜ ∘ Var tpapp-ps = params-to-tpapps psₜ ∘ TpVar -- Cast = tpapp-ps Castₓ -- cast-in = app-ps cast-inₓ -- cast-out = app-ps cast-outₓ -- cast-is = app-ps cast-isₓ -- Functor = tpapp-ps Functorₓ -- functor-in = app-ps functor-inₓ -- functor-out = app-ps functor-outₓ -- Fix = tpapp-ps Fixₓ -- fix-in = app-ps fix-inₓ -- fix-out = app-ps fix-outₓ -- lambek1 = app-ps lambek1ₓ -- lambek2 = app-ps lambek2ₓ -- fix-ind = app-ps fix-indₓ mn = ctxt.mn Γ Γ' = add-params-to-ctxt psₜ Γ Dₓ = mn # Dₓ' cs~ = map-snd (subst Γ' (params-to-tpapps psₜ (TpVar Dₓ)) Dₓ) <$> cs cs' = map-snd (rename-var Γ' Dₓ Dₓ') <$> cs topᵢ = indices-to-kind is $ KdAbs ignored-var (Tkt top-type) KdStar mk-ctr-eterm : params → ctr → term mk-ctr-eterm ps (Ctr x _) = let xs = erase-params ps in Beta id-term $ foldr mlam (foldl (flip App ∘ Var) (Var x) xs) (map fst cs) mk-ctr-etype : ctxt → ctr → var → type mk-ctr-etype Γ (Ctr x T) X with decompose-ctr-type (ctxt-var-decl X Γ) T ...| Tₕ , as , rs = params-to-alls as $ let rs' = if length rs =ℕ length psₜ + length is then drop (length psₜ) rs else rs in TpAppTm (recompose-tpapps rs' $ TpVar X) $ mk-ctr-eterm as (Ctr x T) {- for the datatype data Dₓ (p₁ : P₁) (p₂ : P₂)... : Π i₁ : I₁. Π i₂ : I₂. ... ★ = | c₁ : Π/∀ a₁ : A₁. Π/∀ a₂ : A₂. ... (Dₓ r₁ r₂...) | c₂ : ... . produce the functor type ∀ X : Π i₁ : I₁. Π i₂ : I₂. ... Π _ : Top. ★. (Π/∀ a₁ : A₁. Π/∀ a₂ : A₂. ... (X r₁ r₂ β<λ x. x>{λ c₁. λ c₂. ... |c₁ a₁ a₂...|})) → ... → X i₁ i₂... ιₓ -} mk-ftype2 : ctxt → (asᵢ : 𝕃 tmtp) → (ιₓ : var) → ctrs → type mk-ftype2 Γ asᵢ ιₓ cs = let Γ = ctxt-var-decl ιₓ Γ in rename "X" from Γ for λ X → TpAbs tt X (Tkk topᵢ) $ foldr (λ c → TpAbs ff ignored-var $ Tkt $ mk-ctr-etype Γ c X) (TpAppTm (recompose-tpapps asᵢ $ TpVar X) $ Var ιₓ) cs mk-ctr-fterm : ctxt → ctr → ctrs → (as : params) → (rs : 𝕃 tmtp) → term mk-ctr-fterm Γ' (Ctr x' T) cs as rs = let Γ' = add-params-to-ctxt as Γ' in rename "X" from Γ' for λ Xₓ → rename "x" from Γ' for λ xₓ → let tkₓ = just (Tkk (indices-to-kind is (KdAbs ignored-var (Tkt top-type) KdStar))) fₜ = λ x T → Lam ff x (just (Tkt (mk-ctr-etype (ctxt-var-decl Xₓ Γ') (Ctr x T) Xₓ))) t = Lam tt Xₓ tkₓ (foldr (uncurry fₜ) (params-to-apps as (Var x')) cs) in IotaPair (Beta id-term (erase t)) t xₓ (mk-ftype2 (ctxt-var-decl xₓ Γ') rs xₓ cs) mk-ctr-ftype : ctxt → ctr → ctrs → var → type mk-ctr-ftype Γ (Ctr x T) cs X with decompose-ctr-type (ctxt-var-decl X Γ) T ...| Tₕ , as , rs = params-to-alls as $ TpAppTm (recompose-tpapps rs $ TpVar X) $ mk-ctr-fterm (ctxt-var-decl X Γ) (Ctr x T) cs as rs Is/D = tpapp-ps (data-Is/ Dₓ) is/D = app-ps (data-is/ Dₓ) to/D = app-ps (data-to/ Dₓ) TypeF/D = tpapp-ps (data-TypeF/ Dₓ) IndF/D = tpapp-ps (data-IndF/ Dₓ) fmap/D = app-ps (data-fmap/ Dₓ) D = tpapp-ps Dₓ kᵢ = indices-to-kind is KdStar tkᵢ = Tkk kᵢ jtkᵢ = just tkᵢ decl-Γ : ctxt → 𝕃 var → ctxt decl-Γ = foldr ctxt-var-decl {- λ p₁ : P₁. λ p₂ : P₂. ... λ Dₓ : Π i₁ : I₁. Π i₂ : I₂. ... ★. λ i₁ : I₁. λ i₂ : I₂. ... ι ιₓ : Top. mk-ftype2 (ctxt-var-decl ιₓ Γ') ιₓ cs. -} TypeF-cmd = CmdDefType (data-TypeF/ Dₓ') (params-to-kind psₜ $ KdAbs ignored-var tkᵢ kᵢ) $ let Γ' = add-indices-to-ctxt is Γ' in rename "x" from Γ' for λ ιₓ → params-to-tplams psₜ $ TpLam Dₓ' (Tkk $ indices-to-kind is KdStar) $ indices-to-tplams is $ TpIota ιₓ top-type $ mk-ftype2 (ctxt-var-decl ιₓ Γ') (indices-to-tmtps is) ιₓ cs' fmap-cmd = CmdDefTerm (data-fmap/ Dₓ') $ let Γ' = add-indices-to-ctxt is Γ' in rename "A" from Γ' for λ Aₓ → rename "B" from Γ' for λ Bₓ → rename "c" from Γ' for λ cₓ → rename "x" from Γ' for λ xₓ → rename "X" from Γ' for λ Xₓ → params-to-lams psₜ $ let cs-a = map-snd (rename-var Γ' Dₓ Aₓ) <$> cs cs-b = map-snd (rename-var Γ' Dₓ Bₓ) <$> cs in AppEr (AppTp functor-in TypeF/D) $ Lam tt Aₓ jtkᵢ $ Lam tt Bₓ jtkᵢ $ Lam tt cₓ (just (Tkt (TpAppTp (TpAppTp Cast (TpVar Aₓ)) (TpVar Bₓ)))) $ AppEr (AppEr (AppTp (AppTp cast-in (TpAppTp TypeF/D (TpVar Aₓ))) (TpAppTp TypeF/D (TpVar Bₓ))) (indices-to-lams is $ Lam ff xₓ (just (Tkt (indices-to-tpapps is (TpAppTp TypeF/D (TpVar Aₓ))))) $ IotaPair (IotaProj (Var xₓ) ι1) (Lam tt Xₓ (just (Tkk topᵢ)) $ flip (foldr $ uncurry λ x T → Lam ff x (just (Tkt (mk-ctr-etype (decl-Γ Γ' [: Aₓ ⌟ Bₓ ⌟ cₓ ⌟ xₓ ⌟ Xₓ :]) (x , T) Xₓ)))) cs-b $ foldl (flip App ∘ uncurry (λ bodyₓ T → mk-ctr-fmap-η? tt (decl-Γ Γ' [: Aₓ ⌟ Bₓ ⌟ cₓ ⌟ xₓ ⌟ Xₓ :]) (Aₓ , TpVar Bₓ , AppEr (AppTp (AppTp cast-out (TpVar Aₓ)) (TpVar Bₓ)) (Var cₓ)) (Var bodyₓ) (hnf-ctr (decl-Γ Γ' [: Aₓ ⌟ Bₓ ⌟ cₓ ⌟ xₓ ⌟ Xₓ :]) Aₓ T))) (AppTp (IotaProj (Var xₓ) ι2) (TpVar Xₓ)) cs-a) xₓ (mk-ftype2 (decl-Γ Γ' [: Aₓ ⌟ Bₓ ⌟ cₓ ⌟ xₓ :]) (indices-to-tmtps is) xₓ cs-b))) (Beta id-term id-term) IndF-cmd = CmdDefTerm (data-IndF/ Dₓ') $ params-to-lams psₜ $ Lam tt Dₓ' jtkᵢ $ indices-to-lams is $ let Γ' = add-indices-to-ctxt is Γ' in rename "x" from Γ' for λ xₓ → rename "y" from Γ' for λ yₓ → rename "e" from Γ' for λ eₓ → rename "X" from Γ' for λ Xₓ → let T = indices-to-tpapps is (TpAppTp TypeF/D (TpVar Dₓ')) Γ' = ctxt-var-decl xₓ (ctxt-var-decl Xₓ Γ') in Lam ff xₓ (just $ Tkt T) $ Lam tt Xₓ (just $ Tkk $ indices-to-kind is $ KdAbs ignored-var (Tkt T) KdStar) $ flip (foldr λ c → Lam ff (fst c) (just (Tkt (mk-ctr-ftype Γ' c cs' Xₓ)))) cs' $ flip AppEr (Beta (Var xₓ) id-term) $ flip AppEr (Var xₓ) $ let Γ' = decl-Γ Γ' [: xₓ ⌟ yₓ ⌟ eₓ ⌟ Xₓ :] in flip (foldl $ uncurry λ x' T' → case decompose-ctr-type Γ' T' of λ where (Tₕ , as , rs) → flip App $ params-to-lams as $ Lam tt yₓ (just (Tkt (recompose-tpapps rs (TpAppTp TypeF/D Tₕ)))) $ Lam tt eₓ (just (Tkt (TpEq (Var yₓ) (mk-ctr-eterm as (Ctr x' T'))))) $ params-to-apps as $ Var x') cs' $ AppTp (IotaProj (Var xₓ) ι2) $ indices-to-tplams is $ TpLam xₓ (Tkt top-type) $ TpAbs tt yₓ (Tkt T) $ TpAbs tt eₓ (Tkt $ TpEq (Var yₓ) (Var xₓ)) $ TpAppTm (indices-to-tpapps is $ TpVar Xₓ) $ Phi (Var eₓ) (Var yₓ) (Var xₓ) D-cmd = CmdDefType Dₓ' (params-to-kind (Γₚₛ ++ ps) kᵢ) $ params-to-tplams (Γₚₛ ++ ps) $ TpAppTm (TpApp Fix (Ttp TypeF/D)) fmap/D is-projn : ctxt → type → type → term → type is-projn Γ Tₘ Tₙ t = rename "i" from Γ for λ iₓ → TpIota iₓ (indices-to-alls is (TpAbs ff ignored-var (Tkt (indices-to-tpapps is Tₘ)) (indices-to-tpapps is Tₙ))) (TpEq (Var iₓ) t) is-proj1 = λ Γ T → is-projn Γ T D id-term is-proj2 = λ Γ T → is-projn Γ T (TpAppTp TypeF/D T) fix-out is-proj' : ctxt → var → term → term is-proj' Γ Xₓ mu = rename "c" from Γ for λ cₓ → rename "o" from Γ for λ oₓ → let t = App (AppTp mu (is-proj1 (decl-Γ Γ (cₓ :: oₓ :: [])) (TpVar Xₓ))) (Lam ff cₓ (just (Tkt (is-proj1 (decl-Γ Γ (cₓ :: oₓ :: [])) (TpVar Xₓ)))) (Lam ff oₓ (just (Tkt (is-proj2 (decl-Γ Γ (cₓ :: oₓ :: [])) (TpVar Xₓ)))) (Var cₓ))) in Phi (IotaProj t ι2) (IotaProj t ι1) id-term Is-cmd = CmdDefType (data-Is/ Dₓ') (params-to-kind (Γₚₛ ++ ps) $ KdAbs ignored-var tkᵢ KdStar) $ params-to-tplams (Γₚₛ ++ ps) $ rename "X" from Γ' for λ Xₓ → rename "Y" from Γ' for λ Yₓ → TpLam Xₓ tkᵢ $ TpAbs tt Yₓ (Tkk KdStar) $ TpAbs ff ignored-var (Tkt (TpAbs ff ignored-var (Tkt (is-proj1 (decl-Γ Γ' (Xₓ :: Yₓ :: [])) (TpVar Xₓ))) $ TpAbs ff ignored-var (Tkt (is-proj2 (decl-Γ Γ' (Xₓ :: Yₓ :: [])) (TpVar Xₓ))) $ TpVar Yₓ)) (TpVar Yₓ) is-cmd = CmdDefTerm (data-is/ Dₓ') $ params-to-lams (Γₚₛ ++ ps) $ rename "Y" from Γ' for λ Yₓ → rename "f" from Γ' for λ fₓ → rename "x" from Γ' for λ xₓ → let pair = λ t → IotaPair t (Beta (erase t) (erase t)) xₓ (TpEq (Var xₓ) (erase t)) in Lam tt Yₓ (just (Tkk KdStar)) $ Lam ff fₓ (just (Tkt (TpAbs ff ignored-var (Tkt (is-proj1 (ctxt-var-decl Yₓ Γ') D)) $ TpAbs ff ignored-var (Tkt (is-proj2 (ctxt-var-decl Yₓ Γ') D)) $ TpVar Yₓ))) $ App (App (Var fₓ) (pair (indices-to-lams is (Lam ff xₓ (just (Tkt (indices-to-tpapps is D))) (Var xₓ))))) (pair (AppEr (AppTp fix-out TypeF/D) fmap/D)) to-cmd = CmdDefTerm (data-to/ Dₓ') $ rename "Y" from Γ' for λ Yₓ → rename "mu" from Γ' for λ muₓ → params-to-lams (Γₚₛ ++ ps) $ Lam tt Yₓ jtkᵢ $ Lam tt muₓ (just (Tkt (TpApp Is/D (Ttp (TpVar Yₓ))))) $ is-proj' (decl-Γ Γ' (Yₓ :: muₓ :: [])) Yₓ (Var muₓ) ctr-cmd : ctr → cmd ctr-cmd (Ctr x' T) with subst Γ' D Dₓ' T ...| T' with decompose-ctr-type Γ' T' ...| Tₕ , as , rs = CmdDefTerm x' $ let Γ' = add-params-to-ctxt as Γ' rs = drop (length (Γₚₛ ++ ps)) rs in params-to-lams (Γₚₛ ++ ps) $ params-to-lams as $ App (recompose-apps (tmtps-to-args tt rs) $ AppEr (AppTp fix-in TypeF/D) fmap/D) $ mk-ctr-fterm Γ' (Ctr x' T) cs~ as rs init-encoding : ctxt → file → datatype → string ⊎ encoding-defs init-encoding Γ (Module mn (IdxTele Iₓ) mcs) d @ (Data Dₓ ps is cs) = case reverse (reindex-file Γ Dₓ Iₓ mn is ps mcs) of λ where (EncImp fp Iₓ' Cast cast-in cast-out cast-is Functor functor-in functor-out Fix fix-in fix-out lambek1 lambek2 fix-ind :: mcs) → err⊎-guard (~ conv-type Γ Iₓ' (TpVar Iₓ)) "Index telescoping argument to last import differs from the parameter" >> return (encode-datatype Γ (mk-enc-defs (reverse mcs) [] Cast cast-in cast-out cast-is Functor functor-in functor-out Fix fix-in fix-out lambek1 lambek2 fix-ind) d) (CmdImport (Import p? fn mn q? as) :: mcsᵣ) → inj₁ $ "Expected 14 import args, but got" ^ rope-to-string (strRun Γ (args-to-string as)) mcsᵣ → inj₁ "Datatype encodings must end with import ~/.cedille/Template.ced" where open import to-string options init-encoding Γ (Module mn mps mcs) (Data Dₓ ps is cs) = inj₁ $ "Datatype encodings must have a single module parameter of kind star, " ^ "for index telescoping" mendler-elab-mu-pure Γ (mk-data-info _ _ _ _ _ _ _ _ _ eds ecs) xₒ t ms = let fix-ind = erase (encoding-defs.fix-ind eds) msf = λ t → foldl (λ {(Case mₓ cas mₜ asₜₚ) t → App t (case-args-to-lams cas mₜ)}) t ms in rename xₒ from Γ for λ x → rename "y" from Γ for λ yₓ → let subst-msf = subst-renamectxt Γ (renamectxt-insert* empty-renamectxt ((xₒ , x) :: (yₓ , yₓ) :: [])) ∘ msf in App (App fix-ind t) (Lam ff x nothing $ Lam ff yₓ nothing $ subst-msf (Var yₓ)) mendler-elab-mu Γ (mk-data-info X Xₒ asₚ asᵢ ps kᵢ k cs csₚₛ (mk-enc-defs ecs gcs Cast cast-in cast-out cast-is Functor functor-in functor-out Fix fix-in fix-out lambek1 lambek2 fix-ind) (mk-encd-defs Is/Dₓ is/Dₓ to/Dₓ TypeF/Dₓ indF/Dₓ fmap/Dₓ)) x t Tₘ ms = let is = kind-to-indices Γ k Γᵢₛ = add-indices-to-ctxt is $ add-params-to-ctxt ps $ add-params-to-ctxt (ctxt.ps Γ) Γ is/X? = unless (X =string Xₒ) (Var (mu-isType/' Xₒ)) app-ps = recompose-apps (args-set-erased tt asₚ) ∘ Var tpapp-ps = recompose-tpapps (args-to-tmtps asₚ) ∘ TpVar app-ps' = inst-term Γ ps asₚ tpapp-ps' = inst-type Γ ps asₚ fmap/D = app-ps fmap/Dₓ TypeF/D = tpapp-ps TypeF/Dₓ indF/D = app-ps indF/Dₓ Cast = tpapp-ps' Cast cast-out = app-ps' cast-out Functor = tpapp-ps' Functor functor-in = app-ps' functor-in functor-out = app-ps' functor-out Fix = tpapp-ps' Fix fix-in = app-ps' fix-in fix-out = app-ps' fix-out lambek1 = app-ps' lambek1 fix-ind = app-ps' fix-ind Xₜₚ = recompose-tpapps (args-to-tmtps asₚ) (TpVar X) Xₒₜₚ = if Xₒ =string X then Xₜₚ else TpVar Xₒ toₓ = rename "to" from Γᵢₛ for id outₓ = rename "out" from Γᵢₛ for id to-tp = λ R → TpAppTp (TpAppTp Cast R) Xₜₚ out-tp = λ R → TpIota outₓ (indices-to-alls is (TpAbs ff ignored-var (Tkt (indices-to-tpapps is R)) (indices-to-tpapps is (TpAppTp TypeF/D R)))) (TpEq (Var outₓ) fix-out) ms' : trie term ms' = foldr (λ c σ → case c of λ {(Case x cas t asₜₚ) → let Γ' = add-caseArgs-to-ctxt cas Γᵢₛ in trie-insert σ x $ rename "y" from Γ' for λ yₓ → rename "e" from Γ' for λ eₓ → rename "x" from Γ' for λ xₓ → case-args-to-lams cas $ Lam tt yₓ (just (Tkt (recompose-tpapps (drop (length asₚ) asₜₚ) Xₜₚ))) $ Lam tt eₓ (just (Tkt (TpEq (App fix-in (foldr (uncurry λ x T → Lam ff (snd (split-var x)) nothing) (foldl (λ ca t → case ca of λ {(CaseArg ff x _) → App t (Var (snd (split-var x))); _ → t}) (Var (snd (split-var x))) cas) cs)) (Var yₓ)))) $ Rho (VarSigma (Var eₓ)) xₓ (TpAppTm (recompose-tpapps (drop (length asₚ) asₜₚ) Tₘ) (Var xₓ)) t}) empty-trie ms in-fix = λ is/X? T asᵢ t → (App (recompose-apps asᵢ (AppEr (AppTp fix-in TypeF/D) fmap/D)) (maybe-else' is/X? t λ is/X → App (recompose-apps asᵢ (AppEr (AppTp (AppTp cast-out (TpAppTp TypeF/D T)) (TpAppTp TypeF/D Xₜₚ)) (AppEr (AppTp (AppTp fmap/D T) Xₜₚ) (App (AppTp is/X (to-tp T)) (Lam ff "to" (just (Tkt (to-tp T))) $ Lam ff "out" (just (Tkt (out-tp T))) $ Var "to"))))) t)) app-lambek = λ is/X? t T asᵢ body → AppEr (AppEr body (in-fix is/X? T asᵢ t)) (App (recompose-apps asᵢ (AppEr (AppTp lambek1 TypeF/D) fmap/D)) (in-fix is/X? T asᵢ t)) in rename "x" from Γᵢₛ for λ xₓ → rename "y" from Γᵢₛ for λ yₓ → rename "y'" from ctxt-var-decl yₓ Γᵢₛ for λ y'ₓ → rename "z" from Γᵢₛ for λ zₓ → rename "e" from Γᵢₛ for λ eₓ → rename "X" from Γᵢₛ for λ Xₓ → maybe-else (Var "1") id $ foldl {B = maybe (term → term)} -- Agda hangs without this implicit argument...? (uncurry λ x Tₓ rec → rec >>= λ rec → trie-lookup ms' x >>= λ t → just λ tₕ → App (rec tₕ) t) (just λ t → t) cs >>= λ msf → maybe-else (just $ Var "2") just $ just (let Rₓ = mu-Type/ x isRₓ = mu-isType/ x fcₜ = AppEr (AppTp (AppTp cast-out (TpAppTp TypeF/D (TpVar Rₓ))) (TpAppTp TypeF/D Xₜₚ)) (AppEr (AppTp (AppTp fmap/D (TpVar Rₓ)) Xₜₚ) (Var toₓ)) Tₘₐ = TpLam Rₓ (Tkk (indices-to-kind is KdStar)) Tₘ Tₘ-fmap = rename "A" from Γᵢₛ for λ Aₓ → rename "B" from Γᵢₛ for λ Bₓ → rename "c" from Γᵢₛ for λ cₓ → rename "d" from Γᵢₛ for λ dₓ → rename "q" from Γᵢₛ for λ qₓ → let Γ' = foldr ctxt-var-decl Γ (Aₓ :: Bₓ :: cₓ :: dₓ :: qₓ :: []) Tₘₐ' = TpAppTm (indices-to-tpapps is (TpAppTp Tₘₐ (TpVar Aₓ))) (Var dₓ) Tₘₐₕ = hnf-ctr Γ' Aₓ Tₘₐ' in Lam tt Aₓ (just (Tkk k)) $ Lam tt Bₓ (just (Tkk k)) $ Lam tt cₓ (just (Tkt (TpAppTp (TpAppTp Cast (TpVar Aₓ)) (TpVar Bₓ)))) $ indices-to-lams is $ Lam tt dₓ (just (Tkt (indices-to-tpapps is Xₜₚ))) $ IotaPair (Lam ff qₓ (just (Tkt Tₘₐ')) (mk-ctr-fmap-η? ff Γ' (Aₓ , TpVar Bₓ , AppEr (AppTp (AppTp cast-out (TpVar Aₓ)) (TpVar Bₓ)) (Var cₓ)) (Var qₓ) Tₘₐₕ)) (Beta id-term id-term) qₓ (TpEq (Var qₓ) id-term) in App (AppEr (AppTp (App (recompose-apps (tmtps-to-args tt asᵢ) (AppEr (AppTp fix-ind TypeF/D) fmap/D)) t) Tₘₐ) Tₘ-fmap) (Lam tt Rₓ (just (Tkk k)) $ Lam tt toₓ (just (Tkt (to-tp (TpVar Rₓ)))) $ Lam tt outₓ (just (Tkt (out-tp (TpVar Rₓ)))) $ Lam ff x (just (Tkt (indices-to-alls is (TpAbs ff xₓ (Tkt (indices-to-tpapps is (TpVar Rₓ))) (TpAppTm (indices-to-tpapps is Tₘ) (App (indices-to-apps is (AppEr (AppTp (AppTp cast-out (TpVar Rₓ)) Xₜₚ) (Var toₓ))) (Var xₓ))))))) $ indices-to-lams is $ Lam ff yₓ (just (Tkt (indices-to-tpapps is (TpAppTp TypeF/D (TpVar Rₓ))))) $ LetTm tt isRₓ nothing (Lam tt Xₓ (just (Tkk KdStar)) $ Lam ff xₓ (just (Tkt (TpAbs ff ignored-var (Tkt (to-tp (TpVar Rₓ))) (TpAbs ff ignored-var (Tkt (out-tp (TpVar Rₓ))) (TpVar Xₓ))))) $ App (App (Var xₓ) (Var toₓ)) (Var outₓ)) (app-lambek (just $ Var isRₓ) (Var yₓ) (TpVar Rₓ) (indices-to-args is) $ msf (AppTp (Phi (Beta (Var yₓ) id-term) (App (indices-to-apps is (AppTp indF/D (TpVar Rₓ))) (Var yₓ)) (Var yₓ)) (indices-to-tplams is $ TpLam yₓ (Tkt $ indices-to-tpapps is (TpAppTp TypeF/D (TpVar Rₓ))) $ TpAbs tt y'ₓ (Tkt $ indices-to-tpapps is Xₜₚ) $ TpAbs tt eₓ (Tkt $ TpEq (App fix-in (Var yₓ)) (Var y'ₓ)) $ TpAppTm (indices-to-tpapps is Tₘ) (Phi (Var eₓ) (App (indices-to-apps is (AppEr (AppTp fix-in TypeF/D) fmap/D)) (App (indices-to-apps is fcₜ) (Var yₓ))) (Var y'ₓ))))))) mendler-elab-sigma-pure Γ (mk-data-info _ _ _ _ _ _ _ _ _ eds ecs) x? t ms = let fix-out = erase (encoding-defs.fix-out eds) msf = λ t → foldl (λ {(Case mₓ cas mₜ asₜₚ) t → App t (case-args-to-lams cas mₜ)}) t ms in msf (App fix-out t) mendler-elab-sigma Γ (mk-data-info X Xₒ asₚ asᵢ ps kᵢ k cs csₚₛ (mk-enc-defs ecs gcs Cast cast-in cast-out cast-is Functor functor-in functor-out Fix fix-in fix-out lambek1 lambek2 fix-ind) (mk-encd-defs Is/Dₓ is/Dₓ to/Dₓ TypeF/Dₓ indF/Dₓ fmap/Dₓ)) mt t Tₘ ms = let is = kind-to-indices Γ k Γᵢₛ = add-indices-to-ctxt is $ add-params-to-ctxt ps $ add-params-to-ctxt (ctxt.ps Γ) Γ is/X? = mt app-ps = recompose-apps (args-set-erased tt asₚ) ∘ Var tpapp-ps = recompose-tpapps (args-to-tmtps asₚ) ∘ TpVar app-ps' = inst-term Γ ps asₚ tpapp-ps' = inst-type Γ ps asₚ fmap/D = app-ps fmap/Dₓ TypeF/D = tpapp-ps TypeF/Dₓ to/D = recompose-apps asₚ (Var to/Dₓ) indF/D = app-ps indF/Dₓ Cast = tpapp-ps' Cast cast-out = app-ps' cast-out functor-out = app-ps' functor-out Fix = tpapp-ps' Fix fix-in = app-ps' fix-in fix-out = app-ps' fix-out lambek1 = app-ps' lambek1 Xₜₚ = recompose-tpapps (args-to-tmtps asₚ) (TpVar X) Xₒₜₚ = if Xₒ =string X then Xₜₚ else TpVar Xₒ toₓ = rename "to" from Γᵢₛ for id outₓ = rename "out" from Γᵢₛ for id to-tp = λ R → TpAppTp (TpAppTp Cast R) Xₜₚ out-tp = λ R → TpIota outₓ (indices-to-alls is (TpAbs ff ignored-var (Tkt (indices-to-tpapps is R)) (indices-to-tpapps is (TpAppTp TypeF/D R)))) (TpEq (Var outₓ) fix-out) ms' : trie term ms' = foldr (λ c σ → case c of λ {(Case x cas t asₜₚ) → let Γ' = add-caseArgs-to-ctxt cas Γᵢₛ in trie-insert σ x $ rename "y" from Γ' for λ yₓ → rename "e" from Γ' for λ eₓ → rename "x" from Γ' for λ xₓ → case-args-to-lams cas $ Lam tt yₓ (just (Tkt (recompose-tpapps (drop (length asₚ) asₜₚ) Xₜₚ))) $ Lam tt eₓ (just (Tkt (TpEq (App fix-in (foldr (uncurry λ x T → Lam ff (snd (split-var x)) nothing) (foldl (λ ca t → case ca of λ {(CaseArg ff x _) → App t (Var (snd (split-var x))); _ → t}) (Var (snd (split-var x))) cas) cs)) (Var yₓ)))) $ Rho (VarSigma (Var eₓ)) xₓ (TpAppTm (recompose-tpapps (drop (length asₚ) asₜₚ) Tₘ) (Var xₓ)) t}) empty-trie ms in-fix = λ is/X? T asᵢ t → (maybe-else' (is/X? ||-maybe mt) t λ is/X → App (recompose-apps asᵢ (AppEr (AppTp (AppTp cast-out T) Xₜₚ) (App (AppTp is/X (to-tp T)) (Lam ff "to" (just (Tkt (to-tp T))) $ Lam ff "out" (just (Tkt (out-tp T))) $ Var "to")))) t) app-lambek = λ is/X? t T asᵢ body → AppEr (AppEr body (in-fix is/X? T asᵢ t)) (App (recompose-apps asᵢ (AppEr (AppTp lambek1 TypeF/D) fmap/D)) (in-fix is/X? T asᵢ t)) in rename "x" from Γᵢₛ for λ xₓ → rename "y" from Γᵢₛ for λ yₓ → rename "y'" from ctxt-var-decl yₓ Γᵢₛ for λ y'ₓ → rename "z" from Γᵢₛ for λ zₓ → rename "e" from Γᵢₛ for λ eₓ → rename "X" from Γᵢₛ for λ Xₓ → maybe-else (Var "1") id $ foldl {B = maybe (term → term)} -- Agda hangs without this implicit argument...? (uncurry λ x Tₓ rec → rec >>= λ rec → trie-lookup ms' x >>= λ t → just λ tₕ → App (rec tₕ) t) (just λ t → t) cs >>= λ msf → maybe-else (just $ Var "2") just $ just $ (app-lambek is/X? t Xₒₜₚ (tmtps-to-args tt asᵢ) (msf (let Tₛ = maybe-else' is/X? Xₜₚ λ _ → Xₒₜₚ fcₜ = maybe-else' is/X? id λ is/X → App $ indices-to-apps is $ AppEr (AppTp (AppTp cast-out (TpAppTp TypeF/D Tₛ)) (TpAppTp TypeF/D Xₜₚ)) (AppEr (AppTp (AppTp (AppEr (AppTp functor-out TypeF/D) fmap/D) Tₛ) Xₜₚ) (App (AppTp is/X (to-tp Tₛ)) (Lam ff "to" (just (Tkt (to-tp Tₛ))) $ Lam ff "out" (just (Tkt (out-tp Tₛ))) $ Var "to"))) out = maybe-else' is/X? (AppEr (AppTp fix-out TypeF/D) fmap/D) λ is/X → let i = App (AppTp is/X (TpIota xₓ (indices-to-alls is (TpAbs ff ignored-var (Tkt (indices-to-tpapps is Tₛ)) (indices-to-tpapps is (TpAppTp TypeF/D Tₛ)))) (TpEq (Var xₓ) fix-out))) (Lam ff "to" (just (Tkt (to-tp Tₛ))) $ Lam ff "out" (just (Tkt (out-tp Tₛ))) $ Var "out") in Phi (IotaProj i ι2) (IotaProj i ι1) fix-out in AppTp (App (recompose-apps (tmtps-to-args tt asᵢ) (AppTp indF/D Tₛ)) (App (recompose-apps (tmtps-to-args tt asᵢ) out) t)) (indices-to-tplams is $ TpLam yₓ (Tkt $ indices-to-tpapps is (TpAppTp TypeF/D Tₛ)) $ TpAbs tt y'ₓ (Tkt $ indices-to-tpapps is Xₜₚ) $ TpAbs tt eₓ (Tkt (TpEq (App fix-in (Var yₓ)) (Var y'ₓ))) $ TpAppTm (indices-to-tpapps is Tₘ) (Phi (Var eₓ) (App (indices-to-apps is (AppEr (AppTp fix-in TypeF/D) fmap/D)) (fcₜ (Var yₓ))) (Var y'ₓ)))))) {- ################################ IO ################################ -} -- set show-qualified-vars to tt to show if there are bugs in parameter code, because -- they should always be captured by the scope and unqualified as a binder name open import to-string (record options {during-elaboration = tt; show-qualified-vars = tt; erase-types = ff; pretty-print = tt}) {-# TERMINATING #-} cmds-to-string : (newline-before-after : 𝔹) → params → cmds → strM cmd-to-string : params → cmd → strM cmd-to-string ps (CmdDefTerm x t) = strBreak 2 0 [ strVar x >>str strAdd " =" ] 2 [ to-stringh (lam-expand-term ps t) >>str strAdd "." ] cmd-to-string ps (CmdDefType x k T) = strBreak 3 0 [ strVar x >>str strAdd " :" ] (3 + string-length x) [ to-stringh (abs-expand-kind ps k) >>str strAdd " =" ] 2 [ to-stringh (lam-expand-type ps T) >>str strAdd "." ] cmd-to-string ps (CmdDefKind x psₖ k) = strBreak 2 0 [ strVar x ] 2 [ params-to-string'' (ps ++ psₖ) (to-stringh k) >>str strAdd "." ] cmd-to-string ps (CmdDefData eds x psₓ k cs) = cmds-to-string ff ps (encoding-defs.ecs eds) >>str strList 2 (strBreak 2 0 [ strAdd "data " >>str strVar x ] (5 + string-length x) [ params-to-string'' (ps ++ psₓ) (strAdd ": " >>str to-stringh k) ] :: map (uncurry λ x T → strBreak 2 0 [ strAdd "| " >>str strVar x >>str strAdd " :" ] (5 + string-length x) [ to-stringh T ]) cs) >>str strAdd "." cmd-to-string ps (CmdImport (Import p? fp mn q? as)) = strAdd "import " >>str strAdd mn >>str maybe-else' q? strEmpty (λ x → strAdd " as " >>str strAdd x) >>str args-to-string as >>str strAdd "." cmds-to-string b-a ps = let b-a-tt : cmd → strM → strM b-a-tt = λ c cs → strLine >>str strLine >>str cmd-to-string ps c >>str cs b-a-ff : cmd → strM → strM b-a-ff = λ c cs → cmd-to-string ps c >>str cs >>str strLine >>str strLine in foldr (if b-a then b-a-tt else b-a-ff) strEmpty file-to-string : file → strM file-to-string (Module mn ps cs) = strAdd "module " >>str strAdd mn >>str strAdd "." >>str cmds-to-string tt [] cs --cmds-to-string tt ps cs record elab-info : Set where constructor mk-elab-info field τ : toplevel-state ρ : renamectxt φ : renamectxt × trie file ν : trie stringset -- dependency mapping new-elab-info : toplevel-state → elab-info new-elab-info ts = mk-elab-info ts empty-renamectxt (empty-renamectxt , empty-trie) empty-trie ts-def : toplevel-state → var → tmtp → toplevel-state ts-def ts x tT = let Γ = toplevel-state.Γ ts i = ctxt.i Γ d = either-else' tT (λ t → term-def nothing opacity-open (just t) (TpHole pi-gen)) (λ T → type-def nothing opacity-open (just T) (KdHole pi-gen)) in record ts { Γ = record Γ { i = trie-insert i x (d , missing-location) } } add-dep : elab-info → var → elab-info add-dep (mk-elab-info τ ρ φ ν) mnᵢ = let fp = ctxt.fn (toplevel-state.Γ τ) mnᵢ-is = stringset-strings (trie-lookup-else empty-trie ν mnᵢ) mn-is = trie-lookup-else empty-trie ν fp in mk-elab-info τ ρ φ (trie-insert ν fp (foldr (flip stringset-insert) (stringset-insert mn-is mnᵢ) mnᵢ-is)) set-fn : elab-info → filepath → elab-info set-fn (mk-elab-info τ ρ φ ν) fn = mk-elab-info (record τ { Γ = record (toplevel-state.Γ τ) { fn = fn } }) ρ φ ν set-mn : elab-info → var → elab-info set-mn (mk-elab-info τ ρ φ ν) mn = mk-elab-info (record τ { Γ = record (toplevel-state.Γ τ) { mn = mn } }) ρ φ ν get-fn : elab-info → filepath get-fn = ctxt.fn ∘' toplevel-state.Γ ∘' elab-info.τ get-mn : elab-info → var get-mn = ctxt.mn ∘' toplevel-state.Γ ∘' elab-info.τ get-deps : elab-info → filepath → file → file get-deps (mk-elab-info τ ρ φ ν) fp (Module mn ps es) = Module mn ps (foldr (λ x → CmdImport (Import ff x (renamectxt-rep (fst φ) x) nothing []) ::_) es (stringset-strings (trie-lookup-else empty-stringset ν fp))) {-# TERMINATING #-} elab-file : elab-info → filepath → elab-info × var elab-cmds : elab-info → params → cmds → elab-info × cmds elab-cmds ei ps [] = ei , [] elab-cmds ei@(mk-elab-info τ ρ φ ν) ps (CmdDefTerm x t :: csᵣ) = rename (get-mn ei # x) - x from ρ for λ x' ρ' → let t' = choose-mu (toplevel-state.Γ τ) ρ (params-to-lams ps t) in elim elab-cmds (mk-elab-info (ts-def τ x' (Ttm t')) ρ' φ ν) ps csᵣ for λ ei csᵣ → ei , CmdDefTerm x' t' :: csᵣ elab-cmds ei@(mk-elab-info τ ρ φ ν) ps (CmdDefType x k T :: csᵣ) = rename (get-mn ei # x) - x from ρ for λ x' ρ' → let k' = choose-mu (toplevel-state.Γ τ) ρ (params-to-kind ps k) T' = choose-mu (toplevel-state.Γ τ) ρ (params-to-tplams ps T) in elim elab-cmds (mk-elab-info (ts-def τ x' (Ttp T')) ρ' φ ν) ps csᵣ for λ ei csᵣ → ei , CmdDefType x' k' T' :: csᵣ elab-cmds ei ps (CmdDefKind x psₖ k :: csᵣ) = elab-cmds ei ps csᵣ elab-cmds ei ps (CmdDefData es x psₓ k cs :: csᵣ) = elim elab-cmds ei [] (encoding-defs.ecs es) for λ ei ecs → elim elab-cmds ei [] (encoding-defs.gcs es) for λ ei gcs → elim elab-cmds ei ps csᵣ for λ ei rcs → ei , ecs ++ gcs ++ rcs elab-cmds ei ps (CmdImport (Import p? fp mn' q? as) :: csᵣ) = let fpₒ = get-fn ei; mnₒ = get-mn ei in elim elab-file ei fp for λ ei mn'' → elab-cmds (add-dep (set-mn (set-fn ei fpₒ) mnₒ) fp) ps csᵣ elab-file ei @ (mk-elab-info τ ρ φ ν) fp with trie-contains (snd φ) fp ...| tt = ei , renamectxt-rep (fst φ) fp ...| ff with get-include-elt-if τ fp >>= include-elt.ast~ ...| nothing = ei , "error" ...| just (Module mn ps es) = let p = elab-cmds (record (set-mn (set-fn ei fp) mn) { ν = trie-insert (elab-info.ν ei) fp empty-trie }) ps es (mk-elab-info τ ρ φ ν) = fst p es' = snd p τ = record τ { Γ = record (toplevel-state.Γ τ) { ps = ps } } in rename fp - mn from fst φ for λ mn' φ' → mk-elab-info τ ρ (φ' , trie-insert (snd φ) fp (Module mn' ps es')) ν , mn' elab-write-all : elab-info → (to : filepath) → IO ⊤ elab-write-all ei@(mk-elab-info τ ρ φ ν) to = let Γ = toplevel-state.Γ τ print = strRun Γ ∘ file-to-string in foldr' (createDirectoryIfMissing ff to) (uncurry λ fₒ fₛ io → let fₘ = renamectxt-rep (fst φ) fₒ fₙ = combineFileNames to (fₘ ^ ".cdle") in io >> writeRopeToFile fₙ (print (get-deps ei fₒ fₛ))) (trie-mappings (snd φ)) elab-all : toplevel-state → (from to : filepath) → IO ⊤ elab-all ts fm to = elab-write-all (fst (elab-file (new-elab-info ts) fm)) to >> putStrLn ("0")
{ "alphanum_fraction": 0.5742395751, "avg_line_length": 44.8938207137, "ext": "agda", "hexsha": "b548c9e25e7c9cece9d9c9219c19a29a168a748d", "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": "bf62d3d338809a30bc21a1affed07936b1ac60ac", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "ice1k/cedille", "max_forks_repo_path": "src/elab-util.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "bf62d3d338809a30bc21a1affed07936b1ac60ac", "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": "ice1k/cedille", "max_issues_repo_path": "src/elab-util.agda", "max_line_length": 286, "max_stars_count": null, "max_stars_repo_head_hexsha": "bf62d3d338809a30bc21a1affed07936b1ac60ac", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "ice1k/cedille", "max_stars_repo_path": "src/elab-util.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 20523, "size": 51583 }
open import Nat open import Prelude open import List open import core open import judgemental-erase open import checks module constructability where -- we construct expressions and types by induction on their -- structure. for each sub term, we call the relevant theorem, then -- assemble the results with carefully chosen lists of actions that allow -- us to call the appropriate zipper lemmas and maintain well-typedness -- at every stage of the contruction. -- -- the proof term at each stage except subsumption is, morally, just the -- mapping of the fragment of the action semantics used by the constructs -- in the list in the current formation context into the list monoid. -- construction of types construct-type : (t : τ̇) → Σ[ L ∈ List action ] runtype (▹ ⦇-⦈ ◃) L (▹ t ◃) construct-type num = [ construct num ] , DoType TMConNum DoRefl construct-type ⦇-⦈ = [ del ] , DoType TMDel DoRefl construct-type (t1 ==> t2) with construct-type t1 | construct-type t2 ... | (l1 , ih1) | (l2 , ih2) = l1 ++ construct arrow :: l2 ++ [ move parent ] , runtype++ ih1 (DoType TMConArrow (runtype++ (ziplem-tmarr2 ih2) (DoType TMArrParent2 DoRefl))) mutual -- construction of expressions in synthetic positions construct-synth : {Γ : ·ctx} {t : τ̇} {e : ė} → (Γ ⊢ e => t) → Σ[ L ∈ List action ] runsynth Γ ▹ ⦇-⦈ ◃ ⦇-⦈ L ▹ e ◃ t -- the three base cases construct-synth (SVar x) = [ construct (var _) ] , DoSynth (SAConVar x) DoRefl construct-synth SNum = [ construct (numlit _) ] , DoSynth SAConNumlit DoRefl construct-synth SEHole = [ del ] , DoSynth SADel DoRefl -- the inductive cases construct-synth {t = t} (SAsc x) with construct-type t | construct-ana x ... | (l1 , ih1) | (l2 , ih2) = construct asc :: (l1 ++ move parent :: move (child 1) :: (l2 ++ [ move parent ])) , DoSynth SAConAsc (runsynth++ (ziplem-asc2 ETTop ETTop ih1) (DoSynth (SAMove EMAscParent2) (DoSynth (SAMove EMAscChild1) (runsynth++ (ziplem-asc1 ih2) (DoSynth (SAMove EMAscParent1) DoRefl))))) construct-synth (SAp e1 m e2) with construct-synth e1 | construct-ana e2 ... | (l1 , ih1) | (l2 , ih2) = l1 ++ construct ap :: (l2 ++ [ move parent ]) , runsynth++ ih1 (DoSynth (SAConApArr m) (runsynth++ (ziplem-ap2 e1 m ih2) (DoSynth (SAMove EMApParent2) DoRefl))) construct-synth (SPlus e1 e2 ) with construct-ana e1 | construct-ana e2 ... | (l1 , ih1) | (l2 , ih2) = construct plus :: (l2 ++ move parent :: move (child 1) :: (l1 ++ [ move parent ])) , DoSynth (SAConPlus1 TCHole2) (runsynth++ (ziplem-plus2 ih2) (DoSynth (SAMove EMPlusParent2) (DoSynth (SAMove EMPlusChild1) (runsynth++ (ziplem-plus1 ih1) (DoSynth (SAMove EMPlusParent1) DoRefl))))) construct-synth (SNEHole wt) with construct-synth wt ... | (l , ih) = l ++ construct nehole :: move parent :: [] , runsynth++ ih (DoSynth SAConNEHole (DoSynth (SAMove EMNEHoleParent) DoRefl)) -- construction of expressions in analytic positions construct-ana : {Γ : ·ctx} {t : τ̇} {e : ė} → (Γ ⊢ e <= t) → Σ[ L ∈ List action ] runana Γ ▹ ⦇-⦈ ◃ L ▹ e ◃ t construct-ana (ASubsume x c) with construct-synth x ... | (l , ih) = construct nehole :: l ++ (move parent :: finish :: []) , DoAna (AASubsume EETop SEHole SAConNEHole TCHole1) (runana++ (ziplem-nehole-b SEHole c ih) (DoAna (AAMove EMNEHoleParent) (DoAna (AAFinish (ASubsume x c)) DoRefl))) construct-ana (ALam a m e) with construct-ana e ... | (l , ih) = construct (lam _) :: (l ++ [ move parent ]) , DoAna (AAConLam1 a m) (runana++ (ziplem-lam a m ih) (DoAna (AAMove EMLamParent) DoRefl))
{ "alphanum_fraction": 0.4953917051, "avg_line_length": 54.8735632184, "ext": "agda", "hexsha": "28609445dd5ad3ec714e1daea084645b55335831", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-07-03T03:45:07.000Z", "max_forks_repo_forks_event_min_datetime": "2021-07-03T03:45:07.000Z", "max_forks_repo_head_hexsha": "db3d21a1e3f17ef77ad557ed12374979f381b6b7", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "hazelgrove/agda-popl17", "max_forks_repo_path": "constructability.agda", "max_issues_count": 37, "max_issues_repo_head_hexsha": "db3d21a1e3f17ef77ad557ed12374979f381b6b7", "max_issues_repo_issues_event_max_datetime": "2016-11-09T18:13:55.000Z", "max_issues_repo_issues_event_min_datetime": "2016-07-07T16:23:11.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "hazelgrove/agda-popl17", "max_issues_repo_path": "constructability.agda", "max_line_length": 120, "max_stars_count": 14, "max_stars_repo_head_hexsha": "db3d21a1e3f17ef77ad557ed12374979f381b6b7", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "hazelgrove/agda-popl17", "max_stars_repo_path": "constructability.agda", "max_stars_repo_stars_event_max_datetime": "2019-07-11T12:30:50.000Z", "max_stars_repo_stars_event_min_datetime": "2016-07-01T22:44:11.000Z", "num_tokens": 1302, "size": 4774 }
-- Andreas, 2015-05-02 Integrate copatterns with with. {-# OPTIONS --copatterns #-} open import Common.Prelude hiding (map) open import Common.Product open import Common.Equality dup : {A : Set} → A → A × A proj₁ (dup a) = a proj₂ (dup a) with a proj₂ (dup a) | x = x record Stream (A : Set) : Set where coinductive constructor delay field force : A × Stream A open Stream map : ∀{A B} → (A → B) → Stream A → Stream B force (map f s) with force s ... | a , as = f a , map f as zipWith : ∀{A B C} → (A → B → C) → Stream A → Stream B → Stream C force (zipWith f s t) with force s | force t ... | a , as | b , bs = f a b , zipWith f as bs interleave : ∀{A} (s t : Stream A) → Stream A force (interleave s t) with force s ... | a , as = a , interleave t as mutual evens : ∀{A} (s : Stream A) → Stream A force (evens s) with force s ... | a , as = a , odds as odds : ∀{A} (s : Stream A) → Stream A odds s with force s ... | a , as = evens as take : ∀{A} (n : Nat) (s : Stream A) → List A take 0 s = [] take (suc n) s with force s ... | a , as = a ∷ take n as record Bisim {A B} (R : A → B → Set) (s : Stream A) (t : Stream B) : Set where coinductive constructor ~delay field ~force : let a , as = force s b , bs = force t in R a b × Bisim R as bs open Bisim SEq : ∀{A} (s t : Stream A) → Set SEq = Bisim (_≡_) ~refl : ∀{A} (s : Stream A) → SEq s s ~force (~refl s) with force s ... | a , as = refl , ~refl as ~sym : ∀{A}{s t : Stream A} → SEq s t → SEq t s ~force (~sym p) with ~force p ... | q , r = sym q , ~sym r ~sym' : ∀{A} {s t : Stream A} → SEq s t → SEq t s ~force (~sym' {s = s} {t} p) with force s | force t | ~force p ... | a , as | b , bs | r , q rewrite r = refl , ~sym' q -- ~sym' : ∀{A} {s t : Stream A} → SEq s t → SEq t s -- ~force (~sym' {s = s} {t} p) with force s | force t | ~force p -- ... | x | y | q , r = {!x!} -- C-c C-c prints internal with-name ~trans : ∀{A}{r s t : Stream A} → SEq r s → SEq s t → SEq r t ~force (~trans p q) with ~force p | ~force q ... | ph , pt | qh , qt = trans ph qh , ~trans pt qt ~take : ∀{A} (s t : Stream A) (p : SEq s t) (n : Nat) → take n s ≡ take n t ~take s t p zero = refl ~take s t p (suc n) with force s | force t | ~force p ~take s t p (suc n) | a , as | .a , bs | refl , q rewrite ~take as bs q n = refl
{ "alphanum_fraction": 0.5389196087, "avg_line_length": 27.9880952381, "ext": "agda", "hexsha": "799c77f007eba9ea0f8112223694e721daca52b2", "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/Succeed/CopatternsWith.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/Succeed/CopatternsWith.agda", "max_line_length": 80, "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/Succeed/CopatternsWith.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": 922, "size": 2351 }
{-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.Data.FinData.Base where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Function import Cubical.Data.Empty as ⊥ open import Cubical.Data.Nat using (ℕ; zero; suc) open import Cubical.Data.Bool.Base open import Cubical.Relation.Nullary private variable ℓ : Level A B : Type ℓ data Fin : ℕ → Type₀ where zero : {n : ℕ} → Fin (suc n) suc : {n : ℕ} (i : Fin n) → Fin (suc n) toℕ : ∀ {n} → Fin n → ℕ toℕ zero = 0 toℕ (suc i) = suc (toℕ i) fromℕ : (n : ℕ) → Fin (suc n) fromℕ zero = zero fromℕ (suc n) = suc (fromℕ n) ¬Fin0 : ¬ Fin 0 ¬Fin0 () _==_ : ∀ {n} → Fin n → Fin n → Bool zero == zero = true zero == suc _ = false suc _ == zero = false suc m == suc n = m == n predFin : {n : ℕ} → Fin (suc (suc n)) → Fin (suc n) predFin zero = zero predFin (suc x) = x foldrFin : ∀ {n} → (A → B → B) → B → (Fin n → A) → B foldrFin {n = zero} _ b _ = b foldrFin {n = suc n} f b l = f (l zero) (foldrFin f b (l ∘ suc)) elim : ∀(P : ∀{k} → Fin k → Type ℓ) → (∀{k} → P {suc k} zero) → (∀{k} → {fn : Fin k} → P fn → P (suc fn)) → {k : ℕ} → (fn : Fin k) → P fn elim P fz fs {zero} = ⊥.rec ∘ ¬Fin0 elim P fz fs {suc k} zero = fz elim P fz fs {suc k} (suc fj) = fs (elim P fz fs fj) rec : ∀{k} → (a0 aS : A) → Fin k → A rec a0 aS zero = a0 rec a0 aS (suc x) = aS
{ "alphanum_fraction": 0.5603197674, "avg_line_length": 22.9333333333, "ext": "agda", "hexsha": "eae4309f9369664a7992896cb409095510842237", "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": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "dan-iel-lee/cubical", "max_forks_repo_path": "Cubical/Data/FinData/Base.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/Data/FinData/Base.agda", "max_line_length": 64, "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/Data/FinData/Base.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 585, "size": 1376 }
------------------------------------------------------------------------ -- Semi-heterogeneous vector equality ------------------------------------------------------------------------ module Data.Vec.Equality where open import Data.Vec open import Data.Nat using (suc) open import Data.Function open import Relation.Binary open import Relation.Binary.PropositionalEquality as PropEq using (_≡_) module Equality (S : Setoid) where private open module SS = Setoid S using () renaming (_≈_ to _≊_; carrier to A) infix 4 _≈_ data _≈_ : ∀ {n¹} → Vec A n¹ → ∀ {n²} → Vec A n² → Set where []-cong : [] ≈ [] _∷-cong_ : ∀ {x¹ n¹} {xs¹ : Vec A n¹} {x² n²} {xs² : Vec A n²} (x¹≈x² : x¹ ≊ x²) (xs¹≈xs² : xs¹ ≈ xs²) → x¹ ∷ xs¹ ≈ x² ∷ xs² length-equal : ∀ {n¹} {xs¹ : Vec A n¹} {n²} {xs² : Vec A n²} → xs¹ ≈ xs² → n¹ ≡ n² length-equal []-cong = PropEq.refl length-equal (_ ∷-cong eq₂) = PropEq.cong suc $ length-equal eq₂ refl : ∀ {n} (xs : Vec A n) → xs ≈ xs refl [] = []-cong refl (x ∷ xs) = SS.refl ∷-cong refl xs sym : ∀ {n m} {xs : Vec A n} {ys : Vec A m} → xs ≈ ys → ys ≈ xs sym []-cong = []-cong sym (x¹≡x² ∷-cong xs¹≈xs²) = SS.sym x¹≡x² ∷-cong sym xs¹≈xs² trans : ∀ {n m l} {xs : Vec A n} {ys : Vec A m} {zs : Vec A l} → xs ≈ ys → ys ≈ zs → xs ≈ zs trans []-cong []-cong = []-cong trans (x≈y ∷-cong xs≈ys) (y≈z ∷-cong ys≈zs) = SS.trans x≈y y≈z ∷-cong trans xs≈ys ys≈zs _++-cong_ : ∀ {n₁¹ n₂¹} {xs₁¹ : Vec A n₁¹} {xs₂¹ : Vec A n₂¹} {n₁² n₂²} {xs₁² : Vec A n₁²} {xs₂² : Vec A n₂²} → xs₁¹ ≈ xs₁² → xs₂¹ ≈ xs₂² → xs₁¹ ++ xs₂¹ ≈ xs₁² ++ xs₂² []-cong ++-cong eq₃ = eq₃ (eq₁ ∷-cong eq₂) ++-cong eq₃ = eq₁ ∷-cong (eq₂ ++-cong eq₃) module DecidableEquality (D : DecSetoid) where private module DS = DecSetoid D open DS using () renaming (_≟_ to _≟′_ ; carrier to A) open Equality DS.setoid open import Relation.Nullary _≟_ : ∀ {n m} (xs : Vec A n) (ys : Vec A m) → Dec (xs ≈ ys) _≟_ [] [] = yes []-cong _≟_ [] (y ∷ ys) = no (λ()) _≟_ (x ∷ xs) [] = no (λ()) _≟_ (x ∷ xs) (y ∷ ys) with xs ≟ ys | x ≟′ y ... | yes xs≈ys | yes x≊y = yes (x≊y ∷-cong xs≈ys) ... | no ¬xs≈ys | _ = no helper where helper : ¬ (x ∷ xs ≈ y ∷ ys) helper (_ ∷-cong xs≈ys) = ¬xs≈ys xs≈ys ... | _ | no ¬x≊y = no helper where helper : ¬ (x ∷ xs ≈ y ∷ ys) helper (x≊y ∷-cong _) = ¬x≊y x≊y module HeterogeneousEquality {A : Set} where open import Relation.Binary.HeterogeneousEquality as HetEq using (_≅_) open Equality (PropEq.setoid A) to-≅ : ∀ {n m} {xs : Vec A n} {ys : Vec A m} → xs ≈ ys → xs ≅ ys to-≅ []-cong = HetEq.refl to-≅ (PropEq.refl ∷-cong xs¹≈xs²) with length-equal xs¹≈xs² ... | PropEq.refl = HetEq.cong (_∷_ _) $ to-≅ xs¹≈xs²
{ "alphanum_fraction": 0.4806483626, "avg_line_length": 33.5888888889, "ext": "agda", "hexsha": "174907047a161fd236757c0c3214199e4bc016e0", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:54:10.000Z", "max_forks_repo_forks_event_min_datetime": "2015-07-21T16:37:58.000Z", "max_forks_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "isabella232/Lemmachine", "max_forks_repo_path": "vendor/stdlib/src/Data/Vec/Equality.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3", "max_issues_repo_issues_event_max_datetime": "2022-03-12T12:17:51.000Z", "max_issues_repo_issues_event_min_datetime": "2022-03-12T12:17:51.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "larrytheliquid/Lemmachine", "max_issues_repo_path": "vendor/stdlib/src/Data/Vec/Equality.agda", "max_line_length": 72, "max_stars_count": 56, "max_stars_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "isabella232/Lemmachine", "max_stars_repo_path": "vendor/stdlib/src/Data/Vec/Equality.agda", "max_stars_repo_stars_event_max_datetime": "2021-12-21T17:02:19.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-20T02:11:42.000Z", "num_tokens": 1246, "size": 3023 }
module test where open import cry.gfp open import cry.ec {- -- open import IO.Primitive -- open import Foreign.Haskell open import Agda.Builtin.List using (List; []; _∷_) open import Agda.Builtin.Char using (Char) renaming (primCharToNat to toNat) open import Agda.Builtin.String using (String) renaming (primStringAppend to _++_; primStringToList to toList) open import Agda.Builtin.Unit using (⊤) -} open import Data.Char using (Char; toNat) open import Data.Nat as N using (ℕ; zero) open import Data.Nat.Show using (show) open import Data.List using (List; []; _∷_) -- open import Data.Product using (_×_; _,_; proj₁) open import Data.String using (String; _++_; toList) open import Relation.Nullary using (yes; no) open import IO using (IO; run; putStrLn) open import Coinduction using (♯_) open import Function using (_∘_; _$_) -- open import Agda.Builtin.IO public using (IO) _>>=_ : ∀ {a} {A B : Set a} → IO A → (A → IO B) → IO B m >>= f = ♯ m IO.>>= λ a → ♯ f a _>>_ : ∀ {a} {A B : Set a} → IO A → IO B → IO B m >> n = ♯ m IO.>> ♯ n open cry.ec using (module test-ec) open test-ec showElem : 𝔽 → String showElem n = show n read₁₀ : ℕ → List Char → ℕ × List Char read₁₀ n [] = n , [] read₁₀ n (c ∷ cs) with toNat '0' N.≤? toNat c ... | no _ = n , cs ... | yes _ with toNat c N.≤? toNat '9' ... | no _ = n , cs ... | yes _ = read₁₀ (10 N.* n N.+ (toNat c N.∸ toNat '0')) cs readsElem : List Char → 𝔽 × List Char readsElem cs with read₁₀ 0 cs ... | n , cs′ = n , cs′ where readElem : String → 𝔽 readElem = proj₁ ∘ readsElem ∘ toList showPoint : Point → String showPoint (x ∶ y ∶ z) = showElem x ++ ":" ++ showElem y ++ ":" ++ showElem z readsPoint : List Char → Point × List Char readsPoint s with readsElem s ... | x , s′ with readsElem s′ ... | y , s″ with readsElem s″ ... | z , s‴ = (x ∶ y ∶ z) , s‴ where readPoint : String → Point readPoint = proj₁ ∘ readsPoint ∘ toList showPoint′ : Point → String showPoint′ p = showPoint p ++ " = " ++ showPoint (aff p) main′ : IO _ main′ = do let p = readPoint "4:2:1" 2p = dbl p 3p = add 2p p 3p′ = add p 2p 4p = dbl 2p 4p′ = add p 3p 4p″ = add p 3p′ 5p = add 4p p 5p′ = add 2p 3p 5p+0 = add 5p 𝕆 6p = dbl 3p 6p′ = add 5p p 6p″ = add p 5p putStrLn ("p = " ++ showPoint′ p) putStrLn ("2p = " ++ showPoint′ 2p) putStrLn ("3p = " ++ showPoint′ 3p) putStrLn ("3p′ = " ++ showPoint′ 3p′) putStrLn ("4p = " ++ showPoint′ 4p) putStrLn ("4p′ = " ++ showPoint′ 4p′) putStrLn ("4p″ = " ++ showPoint′ 4p″) putStrLn ("5p = " ++ showPoint′ 5p) putStrLn ("5p′ = " ++ showPoint′ 5p′) putStrLn ("5p+0 = " ++ showPoint′ 5p+0) putStrLn ("6p = " ++ showPoint′ 6p) putStrLn ("6p′ = " ++ showPoint′ 6p′) putStrLn ("6p″ = " ++ showPoint′ 6p″) main = run main′
{ "alphanum_fraction": 0.5994256999, "avg_line_length": 27.0485436893, "ext": "agda", "hexsha": "6020b79ab39fb3b0ac231e71a2c15ebe6be61a0a", "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": "44297e5099d12dea7f3165c1f1d53924736ec058", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "semenov-vladyslav/cry-agda", "max_forks_repo_path": "app/test.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "44297e5099d12dea7f3165c1f1d53924736ec058", "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/cry-agda", "max_issues_repo_path": "app/test.agda", "max_line_length": 110, "max_stars_count": null, "max_stars_repo_head_hexsha": "44297e5099d12dea7f3165c1f1d53924736ec058", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "semenov-vladyslav/cry-agda", "max_stars_repo_path": "app/test.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1062, "size": 2786 }
module GUIgeneric.GUIFeaturesPart2 where open import GUIgeneric.Prelude renaming (addButton to addButton') open import GUIgeneric.GUIDefinitions renaming (add to add'; add' to add) open import GUIgeneric.GUI open import GUIgeneric.GUIExampleLib open import StateSizedIO.GUI.WxGraphicsLibLevel3 renaming (addButton to addButton') open import GUIgeneric.GUIFeatures open import GUIgeneric.GUIExample using (propOneBtn; propTwoBtn ; black ; oneColumnLayout) open import Data.Product open import Data.Fin data ReturnTypeₛ (S : Set) : Set where noChange : ReturnTypeₛ S changedState : (snew : S) → ReturnTypeₛ S -- handler GUI interface with separte state (i.e. state is a separte set instead of GUI) -- We might later separte State into a gui state and property state i.e. have -- GuiState : Set -- AttrState : GuiState → Set -- s2GUI : GuiState → GUI -- s2prop : (g : GuiState)(prop : AttrState g) → properties (s2GUI g) handlerGUIInterfₛ : (S : Set) (s2GUI : (s : S) → Frame) → Interfaceˢ handlerGUIInterfₛ S s2GUI .Stateˢ = S handlerGUIInterfₛ S s2GUI .Methodˢ s = methodsG (s2GUI s) handlerGUIInterfₛ S s2GUI .Resultˢ s m = ReturnTypeₛ S handlerGUIInterfₛ S s2GUI .nextˢ s m noChange = s handlerGUIInterfₛ S s2GUI .nextˢ s m (changedState snew) = snew handlerGUIObjectₛ : (i : Size)(S : Set) (s2GUI : (s : S) → Frame)(s : S) → Set handlerGUIObjectₛ i S s2GUI s = IOObjectˢ- GuiLev1Interface (handlerGUIInterfₛ S s2GUI) i s mutual hGuiObjₛ2ord : (i : Size)(S : Set) (s2GUI : (s : S) → Frame) (s2prop : (s : S) → properties (s2GUI s)) (obj : (s : S) → handlerGUIObjectₛ i S s2GUI s) (s : S) → HandlerObject i (s2GUI s) method (hGuiObjₛ2ord i S s2GUI s2prop obj s) {j} m = hGuiObjₛ2ordaux ∞ j S s2GUI s s2prop obj m (method (obj s) m ) hGuiObjₛ2ordaux' : (j : Size)(j' : Size)(S : Set) (s2GUI : (s : S) → Frame)(s : S) (s2prop : (s : S) → properties (s2GUI s)) (obj : (s : S) → handlerGUIObjectₛ j' S s2GUI s) (m : methodsG (s2GUI s)) (prog : IO' GuiLev1Interface j (ReturnTypeₛ S)) → IO' GuiLev1Interface j ( Σ[ r ∈ returnType (s2GUI s) ] (IOObjectˢ GuiLev1Interface handlerInterface j' (nextˢ handlerInterface (s2GUI s) m r))) hGuiObjₛ2ordaux' j j' S s2GUI s s2prop obj m (do' c f) = do' c (λ r → hGuiObjₛ2ordaux j j' S s2GUI s s2prop obj m (f r) ) hGuiObjₛ2ordaux' j j' S s2GUI s s2prop obj m (return' noChange ) = return' (noChange , hGuiObjₛ2ord j' S s2GUI s2prop obj s {-obj'-}) hGuiObjₛ2ordaux' j j' S s2GUI s s2prop obj m (return' (changedState snew)) = return' (changedGUI (s2GUI snew) (s2prop snew) , hGuiObjₛ2ord j' S s2GUI s2prop obj snew {- obj'-}) hGuiObjₛ2ordaux : (j : Size)(j' : Size)(S : Set) (s2GUI : (s : S) → Frame)(s : S) (s2prop : (s : S) → properties (s2GUI s)) (obj : (s : S) → handlerGUIObjectₛ j' S s2GUI s) (m : methodsG (s2GUI s)) (prog : IO GuiLev1Interface j (ReturnTypeₛ S)) → IO GuiLev1Interface j ( Σ[ r ∈ returnType (s2GUI s) ] (IOObjectˢ GuiLev1Interface handlerInterface j' (nextˢ handlerInterface (s2GUI s) m r))) force (hGuiObjₛ2ordaux j j' S s2GUI s s2prop obj m pr) {j''} = hGuiObjₛ2ordaux' j'' j' S s2GUI s s2prop obj m (force pr) {- *** STATE MACHINES **** -} sMachineHdl : (S : Set)(s : S) (f : Frame) → Set sMachineHdl S s f = (m : methodsG f) → IO GuiLev1Interface ∞ (ReturnTypeₛ S) record SMachineState (S : Set)(s : S) : Set where field fSM : Frame propSM : properties fSM handlSM : sMachineHdl S s fSM SMachine : Set → Set SMachine S = (s : S) → SMachineState S s open SMachineState public SMachine2HandlerGuiObjectₛ : (S : Set) (sm : SMachine S) (s : S) → handlerGUIObjectₛ ∞ S (λ s → sm s .fSM) s method (SMachine2HandlerGuiObjectₛ S sm s) = sm s .handlSM stateMachine2Obj : (S : Set) (sm : SMachine S) (s : S) → HandlerObject ∞ (sm s .fSM) stateMachine2Obj S sm = hGuiObjₛ2ord ∞ S (λ s → sm s .fSM) (λ s → sm s .propSM) (λ s → SMachine2HandlerGuiObjectₛ S sm s) stateMachine2GUI : (S : Set) (sm : SMachine S) (s : S) → GUI stateMachine2GUI S sm s .defFrame = sm s .fSM stateMachine2GUI S sm s .property = sm s .propSM stateMachine2GUI S sm s .obj = stateMachine2Obj S sm s compileSMachine : {S : Set} (sm : SMachine S) (s : S) → NativeIO Unit compileSMachine {S} sm s = compileGUI (stateMachine2GUI S sm s) {- **************** FEATURE MACHINE **** -} -- an example of a feature machine wihout additional states: record FeatureVMVers1 : Set₁ where field Features : Set State : Set GUIF : (f : Features) → SMachine State record FMachine (BaseSt : Set) : Set₁ where field Features : Set AddStateF : Set GUIF : (f : Features) → SMachine (BaseSt ⊎ AddStateF) State : Set State = BaseSt ⊎ AddStateF open FMachine public featureVMFull2GUI : (BaseSt : Set) (vm : FMachine BaseSt) (f : vm .Features) (s : State vm) → GUI featureVMFull2GUI BaseSt vm f s = stateMachine2GUI (BaseSt ⊎ vm .AddStateF) (vm .GUIF f) s featureVMFull2IOˢprog : {BaseSt : Set} (vm : FMachine BaseSt) (f : vm .Features) (s : State vm) → IOˢ GuiLev3Interface ∞ (λ _ → Unit) [] featureVMFull2IOˢprog {BaseSt} vm f s = guiFull2IOˢprog (featureVMFull2GUI BaseSt vm f s) compileFeatureVM : {BaseSt : Set} (vm : FMachine BaseSt) (f : vm .Features) (s : State vm) → NativeIO Unit compileFeatureVM {BaseSt} vm f s = compileGUI (featureVMFull2GUI BaseSt vm f s) {- methodsREduce creates from a method for the frame (addButon s g) a method for g -} mutual methodsReduce : (g : Frame)(str : String)(m : MethodsStruct) (u : methodsStruct2Method (addButton str g notOptimzed) m) → methodsStruct2Method g m methodsReduce g str (fficom) (ffibtn , gcomp) = gcomp methodsReduce g str (⊥^) () methodsReduce g str (m ⊎^unoptimized m₁) (inj₁ x) = inj₁ (methodsReduce g str m x) methodsReduce g str (m ⊎^unoptimized m₁) (inj₂ y) = inj₂ (methodsReduce g str m₁ y) methodsReduce g str (m ⊎^ m₁) x = methodsReduceaux g str m m₁ (methodsUnivIsEmpty m) (methodsUnivIsEmpty m₁) x methodsReduceaux : (g : Frame)(str : String)(m : MethodsStruct) (m₁ : MethodsStruct) (s : SemiDec (λ g' → methodsStruct2Method g' m)) (s₁ : SemiDec (λ g' → methodsStruct2Method g' m₁)) (u : methodsStruct2Methodaux (addButton str g notOptimzed) m m₁ s s₁) → methodsStruct2Methodaux g m m₁ s s₁ methodsReduceaux g str m m₁ s (isEmpty s₁) u = methodsReduce g str m u methodsReduceaux g str m m₁ (isEmpty x) posNonEmpty u = methodsReduce g str m₁ u methodsReduceaux g str m m₁ posNonEmpty posNonEmpty (inj₁ x) = inj₁ (methodsReduce g str m x) methodsReduceaux g str m m₁ posNonEmpty posNonEmpty (inj₂ y) = inj₂ (methodsReduce g str m₁ y) subMethodToFullMethod : (btnStr : String) (fr : Frame) (m : methodsStruct2Method (addButton btnStr fr notOptimzed) (methodStruct fr )) → methodsG fr subMethodToFullMethod btnStr fr m = methodsReduce fr btnStr (methodStruct fr ) m simpleAttr1Btn : (btnStr : String) → properties (addButton btnStr create-frame notOptimzed) simpleAttr1Btn btnStr = black , oneColumnLayout simpleSMState : {S : Set} (btnStr : String) {start : S} (end : S) → SMachineState S start simpleSMState btnStr end .fSM = addButton btnStr create-frame notOptimzed simpleSMState btnStr end .propSM = simpleAttr1Btn btnStr simpleSMState btnStr end .handlSM m .force = return' (changedState end) baseF : FMachine StateV baseF .Features = ⊤ baseF .AddStateF = ⊥ baseF .GUIF f (inj₁ s0) = simpleSMState "1Euro" (inj₁ s1) baseF .GUIF f (inj₁ s1) = simpleSMState "Get Change" (inj₁ s2) baseF .GUIF f (inj₁ s2) = simpleSMState "Soda" (inj₁ s0) baseF .GUIF f (inj₂ ()) addBtn2StateMachine : {S : Set}{s : S}(sm : SMachineState S s) (btnStr : String)(end : S) → SMachineState S s addBtn2StateMachine sm btnStr end .fSM = addButton btnStr (sm .fSM) notOptimzed addBtn2StateMachine sm btnStr end .propSM = black , sm .propSM addBtn2StateMachine sm btnStr end .handlSM (inj₁ x) .force = return' (changedState end) addBtn2StateMachine sm btnStr end .handlSM (inj₂ m) = sm .handlSM (subMethodToFullMethod btnStr (sm .fSM) m) simpleCancel : FMachine StateV → FMachine StateV simpleCancel vm .Features = vm .Features × FeatureCancel simpleCancel vm .AddStateF = vm .AddStateF simpleCancel vm .GUIF (f , yesCancel) (inj₁ s1) = addBtn2StateMachine (vm .GUIF f (inj₁ s1)) "Cancel" (inj₁ s0) simpleCancel vm .GUIF (f , _) s = vm .GUIF f s simpleCancelBase : FMachine StateV simpleCancelBase = simpleCancel baseF main1 : NativeIO Unit main1 = compileFeatureVM baseF _ (inj₁ s0) -- main : NativeIO Unit main = compileFeatureVM simpleCancelBase (_ , yesCancel) (inj₁ s0) --
{ "alphanum_fraction": 0.5861764706, "avg_line_length": 38.202247191, "ext": "agda", "hexsha": "4b0dd628c7d294c4bd9bf78d3929b7b9e5028188", "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": "2bc84cb14a568b560acb546c440cbe0ddcbb2a01", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "stephanadls/state-dependent-gui", "max_forks_repo_path": "examples/GUIgeneric/GUIFeaturesPart2.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "2bc84cb14a568b560acb546c440cbe0ddcbb2a01", "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": "stephanadls/state-dependent-gui", "max_issues_repo_path": "examples/GUIgeneric/GUIFeaturesPart2.agda", "max_line_length": 178, "max_stars_count": 2, "max_stars_repo_head_hexsha": "2bc84cb14a568b560acb546c440cbe0ddcbb2a01", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "stephanadls/state-dependent-gui", "max_stars_repo_path": "examples/GUIgeneric/GUIFeaturesPart2.agda", "max_stars_repo_stars_event_max_datetime": "2020-07-31T17:20:59.000Z", "max_stars_repo_stars_event_min_datetime": "2020-07-31T15:37:39.000Z", "num_tokens": 3150, "size": 10200 }
open import Agda.Builtin.Equality open import Agda.Builtin.Nat record Eta : Set where constructor _,_ field fst : Nat snd : Nat open Eta data ⊥ : Set where hard-fail : (a : Eta) (x : Nat) → (fst a , x) ≡ a → ⊥ hard-fail a x () -- Should be error (refl is valid) loop : ⊥ loop = hard-fail (0 , 0) 0 refl
{ "alphanum_fraction": 0.6149068323, "avg_line_length": 16.9473684211, "ext": "agda", "hexsha": "2cc552abad6370c9ec5cceece5b2eeb231d5a214", "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/Issue4484a.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/Issue4484a.agda", "max_line_length": 53, "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/Issue4484a.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": 118, "size": 322 }
{-# OPTIONS --without-K --safe #-} open import Agda.Builtin.Bool open import Data.Maybe.Base using (just; nothing) open import Relation.Binary.PropositionalEquality open import Relation.Nullary open import Data.Integer.Base open import Data.Integer.Properties using (+-*-commutativeRing) open import Tactic.RingSolver.Core.AlmostCommutativeRing using (fromCommutativeRing) open import Tactic.RingSolver.NonReflective (fromCommutativeRing +-*-commutativeRing λ { +0 -> just refl; _ -> nothing}) public
{ "alphanum_fraction": 0.7972166998, "avg_line_length": 41.9166666667, "ext": "agda", "hexsha": "1169f70468a9a6f44a1cd32127016c6eab9eac45", "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": "6fbaca08b1d63b5765d184f6284fb0e58c9f5e52", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "z-murray/AnalysisAgda", "max_forks_repo_path": "NonReflectiveZ.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "6fbaca08b1d63b5765d184f6284fb0e58c9f5e52", "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": "z-murray/AnalysisAgda", "max_issues_repo_path": "NonReflectiveZ.agda", "max_line_length": 127, "max_stars_count": null, "max_stars_repo_head_hexsha": "6fbaca08b1d63b5765d184f6284fb0e58c9f5e52", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "z-murray/AnalysisAgda", "max_stars_repo_path": "NonReflectiveZ.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 119, "size": 503 }
{-# OPTIONS --universe-polymorphism #-} module Categories.Fibration where open import Level hiding (lift) open import Data.Product open import Categories.Category open import Categories.Functor hiding (_∘_; _≡_) open import Categories.Morphism.Cartesian import Categories.Morphisms as Morphisms record CartesianLifting {o₀ ℓ₀ e₀} {o₁ ℓ₁ e₁} {E : Category o₀ ℓ₀ e₀} {B : Category o₁ ℓ₁ e₁} (p : Functor E B) {a e} (f : B [ a , Functor.F₀ p e ]) : Set (o₀ ⊔ ℓ₀ ⊔ e₀ ⊔ o₁ ⊔ ℓ₁ ⊔ e₁) where private module E = Category E private module B = Category B open B using (_∘_; _≡_) open Functor p renaming (F₀ to p₀; F₁ to p₁) open Morphisms B field e′ : E.Obj φ : E [ e′ , e ] proof : ∃ \ (h : a ≅ p₀ e′) → f ∘ _≅_.g h ≡ p₁ φ φ-cartesian : Cartesian p φ record Fibration {o₀ ℓ₀ e₀} {o₁ ℓ₁ e₁} (E : Category o₀ ℓ₀ e₀) (B : Category o₁ ℓ₁ e₁) : Set (o₀ ⊔ ℓ₀ ⊔ e₀ ⊔ o₁ ⊔ ℓ₁ ⊔ e₁) where private module E = Category E private module B = Category B open B using (_∘_; _≡_) field p : Functor E B open Functor p renaming (F₀ to p₀; F₁ to p₁) open Morphisms B field lift : ∀ {a} e → (f : B [ a , p₀ e ]) → CartesianLifting p f
{ "alphanum_fraction": 0.622278057, "avg_line_length": 27.7674418605, "ext": "agda", "hexsha": "200d8f3f53894bac975413cd00b6cd1bc44a706a", "lang": "Agda", "max_forks_count": 23, "max_forks_repo_forks_event_max_datetime": "2021-11-11T13:50:56.000Z", "max_forks_repo_forks_event_min_datetime": "2015-02-05T13:03:09.000Z", "max_forks_repo_head_hexsha": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "p-pavel/categories", "max_forks_repo_path": "Categories/Fibration.agda", "max_issues_count": 19, "max_issues_repo_head_hexsha": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2", "max_issues_repo_issues_event_max_datetime": "2019-08-09T16:31:40.000Z", "max_issues_repo_issues_event_min_datetime": "2015-05-23T06:47:10.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "p-pavel/categories", "max_issues_repo_path": "Categories/Fibration.agda", "max_line_length": 128, "max_stars_count": 98, "max_stars_repo_head_hexsha": "36f4181d751e2ecb54db219911d8c69afe8ba892", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "copumpkin/categories", "max_stars_repo_path": "Categories/Fibration.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-08T05:20:36.000Z", "max_stars_repo_stars_event_min_datetime": "2015-04-15T14:57:33.000Z", "num_tokens": 449, "size": 1194 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Convenient syntax for "equational reasoning" using a preorder ------------------------------------------------------------------------ -- Example uses: -- -- u∼y : u ∼ y -- u∼y = begin -- u ≈⟨ u≈v ⟩ -- v ≡⟨ v≡w ⟩ -- w ∼⟨ w∼y ⟩ -- y ≈⟨ z≈y ⟩ -- z ∎ -- -- u≈w : u ≈ w -- u≈w = begin-equality -- u ≈⟨ u≈v ⟩ -- v ≡⟨ v≡w ⟩ -- w ≡˘⟨ x≡w ⟩ -- x ∎ {-# OPTIONS --without-K --safe #-} open import Relation.Binary module Relation.Binary.Reasoning.Preorder {p₁ p₂ p₃} (P : Preorder p₁ p₂ p₃) where open Preorder P ------------------------------------------------------------------------ -- Publicly re-export the contents of the base module open import Relation.Binary.Reasoning.Base.Double isPreorder public ------------------------------------------------------------------------ -- DEPRECATED NAMES ------------------------------------------------------------------------ -- Please use the new names as continuing support for the old names is -- not guaranteed. -- Version 1.0 infixr 2 _≈⟨⟩_ _≈⟨⟩_ = _≡⟨⟩_ {-# WARNING_ON_USAGE _≈⟨⟩_ "Warning: _≈⟨⟩_ was deprecated in v1.0. Please use _≡⟨⟩_ instead." #-}
{ "alphanum_fraction": 0.4099766173, "avg_line_length": 23.7592592593, "ext": "agda", "hexsha": "c9501aedfa2dec1ece7ee1b59f96f27480c95484", "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/Relation/Binary/Reasoning/Preorder.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/Relation/Binary/Reasoning/Preorder.agda", "max_line_length": 72, "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/Relation/Binary/Reasoning/Preorder.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": 381, "size": 1283 }
{-# OPTIONS --rewriting -v rewriting:80 #-} open import Agda.Builtin.Equality {-# BUILTIN REWRITE _≡_ #-} postulate A : Set f : A → A h : .A → A → A rew : ∀ {x} → h x x ≡ x {-# REWRITE rew #-} test2 : (x y : A) → h x y ≡ y test2 x y = refl postulate r : .A → A s : .A → A rewr : ∀ x → r x ≡ s x {-# REWRITE rewr #-}
{ "alphanum_fraction": 0.5044776119, "avg_line_length": 15.2272727273, "ext": "agda", "hexsha": "6c9d2f5f8f42343893d860d65d06783f74b8188f", "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/Succeed/Issue2300.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/Succeed/Issue2300.agda", "max_line_length": 43, "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/Succeed/Issue2300.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": 138, "size": 335 }
module PrettyPrinter where open import Agda.Builtin.IO using (IO) open import Agda.Builtin.Int using (pos) open import Agda.Builtin.Unit using (⊤) open import FFI.IO using (getContents; putStrLn; _>>=_; _>>_) open import FFI.Data.Aeson using (Value; eitherDecode) open import FFI.Data.Either using (Left; Right) open import FFI.Data.String using (String; _++_) open import FFI.Data.Text.Encoding using (encodeUtf8) open import FFI.System.Exit using (exitWith; ExitFailure) open import Luau.Syntax using (Block) open import Luau.Syntax.FromJSON using (blockFromJSON) open import Luau.Syntax.ToString using (blockToString) runBlock : ∀ {a} → Block a → IO ⊤ runBlock block = putStrLn (blockToString block) runJSON : Value → IO ⊤ runJSON value with blockFromJSON(value) runJSON value | (Left err) = putStrLn ("Luau error: " ++ err) >> exitWith (ExitFailure (pos 1)) runJSON value | (Right block) = runBlock block runString : String → IO ⊤ runString txt with eitherDecode (encodeUtf8 txt) runString txt | (Left err) = putStrLn ("JSON error: " ++ err) >> exitWith (ExitFailure (pos 1)) runString txt | (Right value) = runJSON value main : IO ⊤ main = getContents >>= runString
{ "alphanum_fraction": 0.7419354839, "avg_line_length": 35.696969697, "ext": "agda", "hexsha": "fdad32d6a95835df3288059fb7f9a4f3d0921355", "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": "cd18adc20ecb805b8eeb770a9e5ef8e0cd123734", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Tr4shh/Roblox-Luau", "max_forks_repo_path": "prototyping/PrettyPrinter.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "cd18adc20ecb805b8eeb770a9e5ef8e0cd123734", "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": "Tr4shh/Roblox-Luau", "max_issues_repo_path": "prototyping/PrettyPrinter.agda", "max_line_length": 95, "max_stars_count": null, "max_stars_repo_head_hexsha": "cd18adc20ecb805b8eeb770a9e5ef8e0cd123734", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Tr4shh/Roblox-Luau", "max_stars_repo_path": "prototyping/PrettyPrinter.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 322, "size": 1178 }
{-# OPTIONS --without-K #-} module hott.core.equality where open import hott.core.universe -- | The equality type. In hott we think of the equality type as paths -- between two points in the space A. To simplify the types we first -- fix the common parameters. module common {a : Level}{A : Type a} where data _≡_ (x : A) : (y : A) → Type a where refl : x ≡ x -- Induction principle for ≡ type. induction≡ : {ℓ : Level} → (D : {x y : A} (p : x ≡ y) → Type ℓ) → (d : {x : A} → D {x} {x} refl) → {x y : A} → (p : x ≡ y) → D p induction≡ D d refl = d -- In hott view point, this function takes the inverse of the path -- from x to y. As a relation you are proving that ≡ is symmetric. _⁻¹ : ∀{x y} → x ≡ y → y ≡ x refl ⁻¹ = refl -- The path composition. This means transitivity of the ≡ relation. _∙_ : ∀ {x y z} → x ≡ y → y ≡ z → x ≡ z refl ∙ refl = refl infixr 1 _≡_ -- Precedence of multiplication infixl 70 _∙_ -- Precedence of exponentiation. infixl 90 _⁻¹ -- Equational reasoning -- To prove x_0 = x_n by a sequence of proofs -- x_0 = x_1 -- x_1 = x_2 -- ... you can use the following syntax -- -- begin x_0 ≅ x_1 by p1 -- ≅ x_2 by p2 -- .... -- ≅ x_n by pn -- ∎ -- -- In equational proofs, it is more readable to use by definition -- than by refl definition : ∀{x} → x ≡ x definition = refl begin_ : (x : A) → x ≡ x begin_ x = refl _≡_by_ : ∀ {x y : A} → x ≡ y → (z : A) → y ≡ z → x ≡ z p ≡ z by q = p ∙ q _∎ : ∀{x y : A} → (x ≡ y) → (x ≡ y) proof ∎ = proof infixl 2 begin_ infixl 1 _≡_by_ infixl 0 _∎ -- We now capture path transportation in the following submodule. module Transport {ℓ : Level} where -- Path transportation. transport : ∀ {x y : A} → x ≡ y → {P : A → Type ℓ} → P x → P y transport refl = λ z → z -- Another symbol for transport. Use it when you do not want to -- specify P. _⋆ : {P : A → Type ℓ} → {x y : A} → x ≡ y → P x → P y p ⋆ = transport p open Transport public open common public {-# BUILTIN EQUALITY _≡_ #-} {-# BUILTIN REFL refl #-} -- The functional congruence, i.e. likes gives likes on application of -- a function. In the HoTT perspective this says that functions are -- functors. ap : ∀ {a b : Level} {A : Type a}{B : Type b} {x y : A} → (f : A → B) → x ≡ y → (f x) ≡ (f y) ap f refl = refl -- The dependent version of ap. This requires transport for its -- definition. apd : ∀{a b : Level }{A : Type a}{B : A → Type b} → (f : (a : A) → B a) → {x y : A} → (p : x ≡ y) → (p ⋆) (f x) ≡ f y apd f refl = refl -- Better syntax fro ap in equational reasoning. applying_on_ : ∀{ℓ₀ ℓ₁}{A : Type ℓ₀}{B : Type ℓ₁} → (f : A → B) → {x y : A} → (p : x ≡ y) → f x ≡ f y applying_on_ f a = ap f a -- Better syntax for dependent version of applying on both sides. transporting_over_ : ∀{ℓ₀ ℓ₁}{A : Type ℓ₀}{B : A → Type ℓ₁} → (f : (a : A) → B(a)){x y : A} → (p : x ≡ y) → (p ⋆) (f x) ≡ f y transporting f over p = apd f p infixr 2 applying_on_ infixr 2 transporting_over_
{ "alphanum_fraction": 0.5146493045, "avg_line_length": 23.9645390071, "ext": "agda", "hexsha": "7dea982a49fdd794a714b131416a6423396c5b21", "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/core/equality.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/core/equality.agda", "max_line_length": 70, "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/core/equality.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1207, "size": 3379 }
{-# OPTIONS --cubical --safe #-} module Cubical.Data.Empty where open import Cubical.Data.Empty.Base public open import Cubical.Data.Empty.Properties public
{ "alphanum_fraction": 0.7735849057, "avg_line_length": 22.7142857143, "ext": "agda", "hexsha": "a72500f2459390af5f74a761c5715dc409403674", "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/Data/Empty.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/Data/Empty.agda", "max_line_length": 48, "max_stars_count": 1, "max_stars_repo_head_hexsha": "df4ef7edffd1c1deb3d4ff342c7178e9901c44f1", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "limemloh/cubical", "max_stars_repo_path": "Cubical/Data/Empty.agda", "max_stars_repo_stars_event_max_datetime": "2020-03-23T23:52:11.000Z", "max_stars_repo_stars_event_min_datetime": "2020-03-23T23:52:11.000Z", "num_tokens": 34, "size": 159 }
open import Agda.Builtin.Equality open import Agda.Builtin.Nat data D (A : Set) : Set → Set₁ where c₁ : {B : Set} → D A B c₂ : D A A record P {A B : Set} (p : D A B) : Set₁ where constructor c field d : D A B Q : {A B₁ B₂ C : Set} {x : D A (B₁ → C)} {y : D A B₂} → P x → P y → B₁ ≡ B₂ → Nat Q (c c₁) _ refl = 0 Q _ (c c₁) refl = 1 Q _ _ _ = 2 module _ {A B C : Set} where checkQ₀ : {x : D A (B → C)} {y : D A B} (px : P x) (py : P y) → Q {x = x} {y = y} (c c₁) py refl ≡ 0 checkQ₀ _ _ = refl checkQ₁ : {x : D (A → B) (A → B)} {y : D (A → B) A} (px : P x) (py : P y) → Q {x = x} {y = y} (c c₂) (c c₁) refl ≡ 1 checkQ₁ _ _ = refl checkQ₂ : {x : D (A → B) (A → B)} {y : D (A → B) (A → B)} (px : P x) (py : P y) (eq : A ≡ (A → B)) → Q {x = x} {y = y} (c c₂) (c c₂) eq ≡ 2 checkQ₂ _ _ _ = refl R : {A B₁ B₂ C : Set} {x : D A (B₁ → C)} {y : D A B₂} → P x → P y → B₁ ≡ B₂ → Nat R (c c₂) _ refl = 0 R _ (c c₂) refl = 1 R _ _ _ = 2 module _ {A B C : Set} where checkR₀ : ∀ {B C} {x : D (B → C) (B → C)} {y : D (B → C) B} (px : P x) (py : P y) → R {x = x} {y = y} (c c₂) py refl ≡ 0 checkR₀ _ _ = refl checkR₁ : ∀ {A B} {x : D A (A → B)} {y : D A A} (px : P x) (py : P y) → R {x = x} {y = y} (c c₁) (c c₂) refl ≡ 1 checkR₁ _ _ = refl checkR₂ : ∀ {A B C} {x : D A (B → C)} {y : D A B} (px : P x) (py : P y) → R {x = x} {y = y} (c c₁) (c c₁) refl ≡ 2 checkR₂ _ _ = refl
{ "alphanum_fraction": 0.4007782101, "avg_line_length": 29.0943396226, "ext": "agda", "hexsha": "2ca41112885ebc1f101aa02cf411cec7cbee6a6a", "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/Issue4254.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/Issue4254.agda", "max_line_length": 102, "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/Issue4254.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": 768, "size": 1542 }
module List.Order.Simple.Properties {A : Set} (_≤_ : A → A → Set) (trans≤ : {x y z : A} → x ≤ y → y ≤ z → x ≤ z) where open import Data.List open import List.Order.Simple _≤_ open import List.Sorted _≤_ lemma-≤-*≤ : {x y : A}{xs : List A} → xs *≤ y → y ≤ x → xs *≤ x lemma-≤-*≤ lenx y≤x = lenx lemma-≤-*≤ (lecx z≤y zs≤y) y≤x = lecx (trans≤ z≤y y≤x) (lemma-≤-*≤ zs≤y y≤x) lemma-++-*≤ : {x y : A}{xs ys : List A} → y ≤ x → xs *≤ y → ys *≤ x → (xs ++ (y ∷ ys)) *≤ x lemma-++-*≤ y≤x lenx ys≤x = lecx y≤x ys≤x lemma-++-*≤ y≤x (lecx z≤y zs≤y) ys≤x = lecx (trans≤ z≤y y≤x) (lemma-++-*≤ y≤x zs≤y ys≤x) lemma-≤-≤* : {x y : A}{xs : List A} → x ≤ y → y ≤* xs → x ≤* xs lemma-≤-≤* x≤y genx = genx lemma-≤-≤* x≤y (gecx y≤z y≤zs) = gecx (trans≤ x≤y y≤z) (lemma-≤-≤* x≤y y≤zs) lemma-≤*-++ : {x y : A}{xs ys : List A} → x ≤ y → x ≤* xs → y ≤* ys → x ≤* (xs ++ (y ∷ ys)) lemma-≤*-++ x≤y genx y≤ys = gecx x≤y (lemma-≤-≤* x≤y y≤ys) lemma-≤*-++ x≤y (gecx x≤z x≤zs) y≤ys = gecx x≤z (lemma-≤*-++ x≤y x≤zs y≤ys) lemma-sorted++ : {x : A}{xs ys : List A} → xs *≤ x → x ≤* ys → Sorted xs → Sorted ys → Sorted (xs ++ (x ∷ ys)) lemma-sorted++ {x = x} lenx genx _ _ = singls x lemma-sorted++ lenx (gecx u≤y _) _ sys = conss u≤y sys lemma-sorted++ (lecx x≤u xs≤*u) u*≤ys (singls x) sys = conss x≤u (lemma-sorted++ xs≤*u u*≤ys nils sys) lemma-sorted++ (lecx x≤u xs≤*u) u*≤ys (conss x≤z sxs) sys = conss x≤z (lemma-sorted++ xs≤*u u*≤ys sxs sys)
{ "alphanum_fraction": 0.4989775051, "avg_line_length": 47.3225806452, "ext": "agda", "hexsha": "f0bd43056802e7785156f1613a6a6a2dab65fcdb", "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/List/Order/Simple/Properties.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/List/Order/Simple/Properties.agda", "max_line_length": 110, "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/List/Order/Simple/Properties.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": 779, "size": 1467 }
-- Andreas, 2020-03-21, issue #4456 {-# OPTIONS --safe #-} postulate A : Set
{ "alphanum_fraction": 0.6075949367, "avg_line_length": 13.1666666667, "ext": "agda", "hexsha": "50b6d0335bf8f5a4728a84025943c1217162cabc", "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/HighlightSafePostulate.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/HighlightSafePostulate.agda", "max_line_length": 35, "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/HighlightSafePostulate.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": 27, "size": 79 }
{-# OPTIONS --without-K --safe #-} open import Categories.Category module Categories.Category.Instance.Simplex where open import Level open import Data.Product open import Data.Fin open import Data.Nat using (ℕ) open import Function renaming (id to idF; _∘_ to _∙_) open import Relation.Binary open import Relation.Binary.PropositionalEquality Δ : Category 0ℓ 0ℓ 0ℓ Δ = record { Obj = ℕ ; _⇒_ = λ m n → Σ (Fin m → Fin n) (λ f → _≤_ =[ f ]⇒ _≤_) ; _≈_ = λ { (f , mf) (g , mg) → ∀ x → f x ≡ g x } ; id = idF , idF ; _∘_ = λ { (f , mf) (g , mg) → f ∙ g , mf ∙ mg } ; assoc = λ _ → refl ; sym-assoc = λ _ → refl ; identityˡ = λ _ → refl ; identityʳ = λ _ → refl ; identity² = λ _ → refl ; equiv = record { refl = λ _ → refl ; sym = λ eq x → sym (eq x) ; trans = λ eq₁ eq₂ x → trans (eq₁ x) (eq₂ x) } ; ∘-resp-≈ = λ {_ _ _ f g h i} eq₁ eq₂ x → trans (cong (λ t → proj₁ f t) (eq₂ x)) (eq₁ (proj₁ i x)) }
{ "alphanum_fraction": 0.5465587045, "avg_line_length": 28.2285714286, "ext": "agda", "hexsha": "228a7bd4c7426eeb1f8c2bb0d79dd633d99b761e", "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/Instance/Simplex.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/Instance/Simplex.agda", "max_line_length": 102, "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/Instance/Simplex.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 385, "size": 988 }
postulate admit : ∀ {i} {X : Set i} → X X Y Z : Set data Id (z : Z) : Z → Set where refl : Id z z record Square : Set₁ where field U : Set u : U open Square record RX : Set where field x : X open RX record R : Set where -- This definition isn't used; without it, -- the internal error disappears. r : Square r .U = admit r .u = admit module M (z₀ z₁ : Z) where f : Id z₀ z₁ → RX f refl = {!λ where .x → ?!}
{ "alphanum_fraction": 0.5631929047, "avg_line_length": 15.5517241379, "ext": "agda", "hexsha": "ca49f0740d04ebcba20adc498a44d299d34eaf0d", "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/Issue4256.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/Issue4256.agda", "max_line_length": 44, "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/Issue4256.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": 165, "size": 451 }
open import Agda.Builtin.Nat record Pointed (A : Set) : Set where field point : A it : ∀ {A : Set} {{x : A}} → A it {{x}} = x instance _ = record { point = 3 - 4 } _ : Pointed Nat _ = {!!}
{ "alphanum_fraction": 0.5515463918, "avg_line_length": 14.9230769231, "ext": "agda", "hexsha": "b9757d2fbd34fe93fe5f9388a738d188bb37edc3", "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/Issue2700.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/Issue2700.agda", "max_line_length": 37, "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/Issue2700.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": 72, "size": 194 }
{-# OPTIONS --without-K --safe #-} -- This is more a pair of constructions that a property... -- but show that one can build a Cone for the Twisted Arrow functor from a Wedge -- and vice-versa. open import Categories.Category open import Categories.Functor.Bifunctor module Categories.Diagram.Wedge.Properties {o ℓ e o′ ℓ′ e′} {C : Category o ℓ e} {D : Category o′ ℓ′ e′} (F : Bifunctor (Category.op C) C D) where private module C = Category C module D = Category D open D open HomReasoning variable A : Obj open import Level open import Data.Product using (Σ; _,_) open import Categories.Category.Construction.TwistedArrow open import Categories.Category.Equivalence using (StrongEquivalence) open import Categories.Category.Construction.Cones using (Cones) open import Categories.Category.Construction.Wedges open import Categories.Diagram.Cone open import Categories.Diagram.Wedge F open import Categories.Functor hiding (id) open import Categories.Functor.Bifunctor.Properties open import Categories.Functor.Construction.Constant open import Categories.Functor.Instance.Twisted C D import Categories.Morphism as M open import Categories.Morphism.Reasoning D open import Categories.NaturalTransformation.Dinatural open import Categories.NaturalTransformation.NaturalIsomorphism using (niHelper) open Functor F -- There is a construction that builds a Cone (Twist F) from a Wedge module _ (w : Wedge) where open Wedge w open DinaturalTransformation open Morphism open Morphism⇒ private Wedge-to-Cone′ : {C C′ : C.Obj} (f : C C.⇒ C′) → Wedge.E w ⇒ F₀ (C , C′) Wedge-to-Cone′ {C} {C′} f = F₁ (C.id , f) ∘ α dinatural C Wedge-to-Cone : Cone (Twist F) Wedge-to-Cone = record { N = E ; apex = record { ψ = λ Tw → Wedge-to-Cone′ (arr Tw) ; commute = λ { {record { dom = dom₁ ; cod = cod₁ ; arr = arr₁ }} {record { dom = dom ; cod = cod ; arr = arr }} (record { dom⇐ = dom⇐₁ ; cod⇒ = cod⇒₁; square = square₁}) → begin F₁ (dom⇐₁ , cod⇒₁) ∘ F₁ (C.id , arr₁) ∘ dinatural.α dom₁ ≈⟨ pullˡ (Equiv.sym homomorphism) ⟩ F₁ (C.id C.∘ dom⇐₁ , cod⇒₁ C.∘ arr₁) ∘ dinatural.α dom₁ ≈⟨ ([ F ]-decompose₁ ⟩∘⟨refl) ⟩ (F₁ (C.id C.∘ dom⇐₁ , C.id) ∘ F₁ (C.id , cod⇒₁ C.∘ arr₁)) ∘ dinatural.α dom₁ ≈⟨ (F-resp-≈ (C.identityˡ , C.Equiv.refl) ⟩∘⟨refl ⟩∘⟨refl) ⟩ (F₁ (dom⇐₁ , C.id) ∘ F₁ (C.id , cod⇒₁ C.∘ arr₁)) ∘ dinatural.α dom₁ ≈⟨ pullʳ (extranatural-commʳ dinatural) ⟩ F₁ (dom⇐₁ , C.id) ∘ (F₁ (cod⇒₁ C.∘ arr₁ , C.id) ∘ dinatural.α cod) ≈⟨ pullˡ (Equiv.sym homomorphism) ⟩ F₁ ((cod⇒₁ C.∘ arr₁) C.∘ dom⇐₁ , C.id C.∘ C.id) ∘ dinatural.α cod ≈⟨ (F-resp-≈ (C.assoc , C.identity²) ⟩∘⟨refl) ⟩ F₁ (cod⇒₁ C.∘ arr₁ C.∘ dom⇐₁ , C.id) ∘ dinatural.α cod ≈⟨ (F-resp-≈ (square₁ , C.Equiv.refl) ⟩∘⟨refl) ⟩ F₁ (arr , C.id) ∘ dinatural.α cod ≈˘⟨ extranatural-commʳ dinatural ⟩ F₁ (C.id , arr) ∘ dinatural.α dom ∎ } } } -- And a construction that builds a Wedge from a Cone (Twist F) module _ (c : Cone (Twist F)) where open Cone c open DinaturalTransformation private fam : {A B : C.Obj} (f : A C.⇒ B) → N ⇒ F₀ (A , B) fam f = ψ record { arr = f } id² : {A B : C.Obj} (f : A C.⇒ B) → f C.∘ C.id C.∘ C.id C.≈ f id² f = C.∘-resp-≈ʳ C.identity² HR.○ C.identityʳ where module HR = C.HomReasoning Cone-to-Wedge : Wedge Cone-to-Wedge = record { E = N ; dinatural = dtHelper record { α = λ _ → fam C.id ; commute = λ f → begin F₁ (C.id , f) ∘ fam C.id ∘ id ≈⟨ pullˡ (Cone.commute c (mor⇒ (id² f))) ⟩ ψ (record { arr = f }) ∘ id ≈⟨ pushˡ (Equiv.sym (Cone.commute c (mor⇒ (C.identityˡ C.HomReasoning.○ C.identityˡ)))) ⟩ F₁ (f , C.id) ∘ fam C.id ∘ id ∎ } } ConeTwist⇒WedgeF : Functor (Cones (Twist F)) (Wedges F) ConeTwist⇒WedgeF = record { F₀ = Cone-to-Wedge ; F₁ = λ c⇒ → record { u = Cone⇒.arr c⇒ ; commute = Cone⇒.commute c⇒ } ; identity = Equiv.refl ; homomorphism = Equiv.refl ; F-resp-≈ = λ f≈g → f≈g } Wedge⇒ConeTwistF : Functor (Wedges F) (Cones (Twist F)) Wedge⇒ConeTwistF = record { F₀ = Wedge-to-Cone ; F₁ = λ {A} {B} f → record { arr = u f ; commute = pullʳ (commute f) } ; identity = Equiv.refl ; homomorphism = Equiv.refl ; F-resp-≈ = λ f≈g → f≈g } where open Wedge-Morphism ConesTwist≅Wedges : StrongEquivalence (Cones (Twist F)) (Wedges F) ConesTwist≅Wedges = record { F = ConeTwist⇒WedgeF ; G = Wedge⇒ConeTwistF ; weak-inverse = record { F∘G≈id = niHelper record { η = λ _ → record { u = id ; commute = id-comm ○ (Equiv.sym identity ⟩∘⟨refl) } ; η⁻¹ = λ _ → record { u = id ; commute = assoc ○ identity ⟩∘⟨refl ○ (identityˡ ○ identityʳ) } ; commute = λ _ → id-comm-sym ; iso = λ X → record { isoˡ = identity² ; isoʳ = identity² } } ; G∘F≈id = niHelper record { η = λ Co → record { arr = id ; commute = λ {X} → let m = record { dom⇐ = C.id; cod⇒ = Morphism.arr X; square = (C.∘-resp-≈ʳ C.identity²) C.HomReasoning.○ C.identityʳ} a = record { arr = C.id } in begin ψ (apex Co) X ∘ id ≈⟨ identityʳ ⟩ ψ (apex Co) X ≈˘⟨ commute Co m ⟩ F₁ (C.id , arr X) ∘ ψ (apex Co) a ∎ -- } ; η⁻¹ = λ Co → record { arr = id ; commute = λ {X} → let m = record { dom⇐ = C.id; cod⇒ = Morphism.arr X; square = (C.∘-resp-≈ʳ C.identity²) C.HomReasoning.○ C.identityʳ} a = record { arr = C.id } in begin (F₁ (C.id , arr X) ∘ ψ (apex Co) a) ∘ id ≈⟨ identityʳ ⟩ F₁ (C.id , arr X) ∘ ψ (apex Co) a ≈⟨ commute Co m ⟩ ψ (apex Co) X ∎ } ; commute = λ f → id-comm-sym ; iso = λ X → record { isoˡ = identity² ; isoʳ = identity² } } } } where open Cone open Apex open Morphism
{ "alphanum_fraction": 0.5684470008, "avg_line_length": 37.7950310559, "ext": "agda", "hexsha": "f9457e46c46e076926bce14820bee264abf73136", "lang": "Agda", "max_forks_count": 64, "max_forks_repo_forks_event_max_datetime": "2022-03-14T02:00:59.000Z", "max_forks_repo_forks_event_min_datetime": "2019-06-02T16:58:15.000Z", "max_forks_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Code-distancing/agda-categories", "max_forks_repo_path": "src/Categories/Diagram/Wedge/Properties.agda", "max_issues_count": 236, "max_issues_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_issues_repo_issues_event_max_datetime": "2022-03-28T14:31:43.000Z", "max_issues_repo_issues_event_min_datetime": "2019-06-01T14:53:54.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Code-distancing/agda-categories", "max_issues_repo_path": "src/Categories/Diagram/Wedge/Properties.agda", "max_line_length": 146, "max_stars_count": 279, "max_stars_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Trebor-Huang/agda-categories", "max_stars_repo_path": "src/Categories/Diagram/Wedge/Properties.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-22T00:40:14.000Z", "max_stars_repo_stars_event_min_datetime": "2019-06-01T14:36:40.000Z", "num_tokens": 2351, "size": 6085 }
{-# OPTIONS --safe --cubical #-} module Erased-cubical.Cubical where open import Agda.Builtin.Cubical.Path data ∥_∥ (A : Set) : Set where ∣_∣ : A → ∥ A ∥ trivial : (x y : ∥ A ∥) → x ≡ y data D′ : Set where @0 c′ : D′
{ "alphanum_fraction": 0.5584415584, "avg_line_length": 17.7692307692, "ext": "agda", "hexsha": "a54b71013857a956f089320004a368b797ee5d91", "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/Erased-cubical/Cubical.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/Erased-cubical/Cubical.agda", "max_line_length": 37, "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/Erased-cubical/Cubical.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": 97, "size": 231 }
-- Andreas, 2015-12-01, test case to trigger error ModuleArityMismatch EmptyTel module _ where module M where module M′ = M Set
{ "alphanum_fraction": 0.7388059701, "avg_line_length": 19.1428571429, "ext": "agda", "hexsha": "5e36b9caea6185a9a6f3b0a5afcbf3b9ebefc2a0", "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/ModuleArityMismatchEmptyTel.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/ModuleArityMismatchEmptyTel.agda", "max_line_length": 79, "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/ModuleArityMismatchEmptyTel.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": 40, "size": 134 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Properties of vector's Any ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} module Data.Vec.Relation.Unary.Any.Properties where open import Function open import Function.Inverse using (_↔_; inverse) renaming (_∘_ to _∘↔_; id to id↔) open import Data.Vec using ( Vec; []; _∷_; _++_; [_]; _>>=_ ; toList; fromList; map; concat; tabulate; lookup ) open import Data.Vec.Relation.Unary.Any as Any using (Any; here; there) open import Data.Nat using (suc; zero) open import Data.Fin using (Fin) renaming (suc to fsuc; zero to fzero) open import Data.Empty using (⊥) open import Data.Sum as Sum using (_⊎_; inj₁; inj₂; [_,_]′) open import Data.Sum.Function.Propositional using (_⊎-cong_) open import Data.Product as Prod using (∃; ∃₂; _×_; _,_; proj₁; proj₂) open import Relation.Nullary using (¬_) open import Relation.Unary hiding (_∈_) open import Relation.Binary open import Relation.Binary.PropositionalEquality as P using (_≡_; _≗_; refl) ------------------------------------------------------------------------ -- Equality properties module _ {a p ℓ} {A : Set a} {P : A → Set p} {_≈_ : Rel A ℓ} where open import Data.Vec.Relation.Binary.Pointwise.Inductive using (Pointwise; []; _∷_) lift-resp : ∀ {n} → P Respects _≈_ → (Any P {n}) Respects (Pointwise _≈_) lift-resp resp [] () lift-resp resp (x∼y ∷ xs∼ys) (here px) = here (resp x∼y px) lift-resp resp (x∼y ∷ xs∼ys) (there pxs) = there (lift-resp resp xs∼ys pxs) module _ {a p} {A : Set a} {P : Pred A p} where here-injective : ∀ {n x xs} {p q : P x} → here {P = P} {n = n} {xs = xs} p ≡ here q → p ≡ q here-injective refl = refl there-injective : ∀ {n x xs} {p q : Any P xs} → there {n = n} {x = x} p ≡ there q → p ≡ q there-injective refl = refl ------------------------------------------------------------------------ -- Misc ¬Any[] : ¬ Any P [] ¬Any[] () lookup-index : ∀ {m} {xs : Vec A m} (p : Any P xs) → P (lookup xs (Any.index p)) lookup-index (here px) = px lookup-index (there p) = lookup-index p ------------------------------------------------------------------------ -- Convert from/to List.Any open import Data.List.Relation.Unary.Any as List using (here; there) open import Data.List using ([]; _∷_) fromList⁺ : ∀ {xs} → List.Any P xs → Any P (fromList xs) fromList⁺ (here px) = here px fromList⁺ (there v) = there (fromList⁺ v) fromList⁻ : ∀ {xs} → Any P (fromList xs) → List.Any P xs fromList⁻ {[]} () fromList⁻ {x ∷ xs} (here px) = here px fromList⁻ {x ∷ xs} (there pxs) = there (fromList⁻ pxs) toList⁺ : ∀ {n} {xs : Vec A n} → Any P xs → List.Any P (toList xs) toList⁺ (here px) = here px toList⁺ (there v) = there (toList⁺ v) toList⁻ : ∀ {n} {xs : Vec A n} → List.Any P (toList xs) → Any P xs toList⁻ {xs = []} () toList⁻ {xs = x ∷ xs} (here px) = here px toList⁻ {xs = x ∷ xs} (there pxs) = there (toList⁻ pxs) ------------------------------------------------------------------------ -- map map-id : ∀ {a p} {A : Set a} {P : A → Set p} (f : P ⊆ P) {n xs} → (∀ {x} (p : P x) → f p ≡ p) → (p : Any P {n} xs) → Any.map f p ≡ p map-id f hyp (here p) = P.cong here (hyp p) map-id f hyp (there p) = P.cong there $ map-id f hyp p map-∘ : ∀ {a p q r} {A : Set a} {P : A → Set p} {Q : A → Set q} {R : A → Set r} (f : Q ⊆ R) (g : P ⊆ Q) {n xs} (p : Any P {n} xs) → Any.map (f ∘ g) p ≡ Any.map f (Any.map g p) map-∘ f g (here p) = refl map-∘ f g (there p) = P.cong there $ map-∘ f g p ------------------------------------------------------------------------ -- Swapping module _ {a b ℓ} {A : Set a} {B : Set b} {P : A → B → Set ℓ} where swap : ∀ {n m} {xs : Vec A n} {ys : Vec B m} → Any (λ x → Any (P x) ys) xs → Any (λ y → Any (flip P y) xs) ys swap (here pys) = Any.map here pys swap (there pxys) = Any.map there (swap pxys) swap-there : ∀ {n m x xs ys} → (any : Any (λ x → Any (P x) {n} ys) {m} xs) → swap (Any.map (there {x = x}) any) ≡ there (swap any) swap-there (here pys) = refl swap-there (there pxys) = P.cong (Any.map there) (swap-there pxys) module _ {a b ℓ} {A : Set a} {B : Set b} {P : A → B → Set ℓ} where swap-invol : ∀ {n m} {xs : Vec A n} {ys : Vec B m} → (any : Any (λ x → Any (P x) ys) xs) → swap (swap any) ≡ any swap-invol (here (here _)) = refl swap-invol (here (there pys)) = P.cong (Any.map there) (swap-invol (here pys)) swap-invol (there pxys) = P.trans (swap-there (swap pxys)) $ P.cong there (swap-invol pxys) module _ {a b ℓ} {A : Set a} {B : Set b} {P : A → B → Set ℓ} where swap↔ : ∀ {n m} {xs : Vec A n} {ys : Vec B m} → Any (λ x → Any (P x) ys) xs ↔ Any (λ y → Any (flip P y) xs) ys swap↔ = inverse swap swap swap-invol swap-invol ------------------------------------------------------------------------ -- Lemmas relating Any to ⊥ ⊥↔Any⊥ : ∀ {a} {A : Set a} {n} {xs : Vec A n} → ⊥ ↔ Any (const ⊥) xs ⊥↔Any⊥ = inverse (λ ()) (λ p → from p) (λ ()) (λ p → from p) where from : ∀ {n xs} → Any (const ⊥) {n} xs → ∀ {b} {B : Set b} → B from (here ()) from (there p) = from p ⊥↔Any[] : ∀ {a p} {A : Set a} {P : A → Set p} → ⊥ ↔ Any P [] ⊥↔Any[] = inverse (λ()) (λ()) (λ()) (λ()) ------------------------------------------------------------------------ -- Sums commute with Any module _ {a p q} {A : Set a} {P : A → Set p} {Q : A → Set q} where Any-⊎⁺ : ∀ {n} {xs : Vec A n} → Any P xs ⊎ Any Q xs → Any (λ x → P x ⊎ Q x) xs Any-⊎⁺ = [ Any.map inj₁ , Any.map inj₂ ]′ Any-⊎⁻ : ∀ {n} {xs : Vec A n} → Any (λ x → P x ⊎ Q x) xs → Any P xs ⊎ Any Q xs Any-⊎⁻ (here (inj₁ p)) = inj₁ (here p) Any-⊎⁻ (here (inj₂ q)) = inj₂ (here q) Any-⊎⁻ (there p) = Sum.map there there (Any-⊎⁻ p) ⊎↔ : ∀ {n} {xs : Vec A n} → (Any P xs ⊎ Any Q xs) ↔ Any (λ x → P x ⊎ Q x) xs ⊎↔ = inverse Any-⊎⁺ Any-⊎⁻ from∘to to∘from where from∘to : ∀ {n} {xs : Vec A n} (p : Any P xs ⊎ Any Q xs) → Any-⊎⁻ (Any-⊎⁺ p) ≡ p from∘to (inj₁ (here p)) = refl from∘to (inj₁ (there p)) rewrite from∘to (inj₁ p) = refl from∘to (inj₂ (here q)) = refl from∘to (inj₂ (there q)) rewrite from∘to (inj₂ q) = refl to∘from : ∀ {n} {xs : Vec A n} (p : Any (λ x → P x ⊎ Q x) xs) → Any-⊎⁺ (Any-⊎⁻ p) ≡ p to∘from (here (inj₁ p)) = refl to∘from (here (inj₂ q)) = refl to∘from (there p) with Any-⊎⁻ p | to∘from p to∘from (there .(Any.map inj₁ p)) | inj₁ p | refl = refl to∘from (there .(Any.map inj₂ q)) | inj₂ q | refl = refl ------------------------------------------------------------------------ -- Products "commute" with Any. module _ {a b p q} {A : Set a} {B : Set b} {P : Pred A p} {Q : Pred B q} where open import Data.Vec.Membership.Propositional using (_∈_; find; lose) Any-×⁺ : ∀ {n m} {xs : Vec A n} {ys : Vec B m} → Any P xs × Any Q ys → Any (λ x → Any (λ y → P x × Q y) ys) xs Any-×⁺ (p , q) = Any.map (λ p → Any.map (p ,_) q) p Any-×⁻ : ∀ {n m} {xs : Vec A n} {ys : Vec B m} → Any (λ x → Any (λ y → P x × Q y) ys) xs → Any P xs × Any Q ys Any-×⁻ pq with find pq ... | x , x∈xs , pxys with find pxys ... | y , y∈ys , px , py = lose x∈xs px , lose y∈ys py ------------------------------------------------------------------------ -- Invertible introduction (⁺) and elimination (⁻) rules for various -- vector functions ------------------------------------------------------------------------ -- Singleton ([_]) module _ {a p} {A : Set a} {P : Pred A p} where singleton⁺ : ∀ {x} → P x → Any P [ x ] singleton⁺ Px = here Px singleton⁻ : ∀ {x} → Any P [ x ] → P x singleton⁻ (here Px) = Px singleton⁻ (there ()) singleton⁺∘singleton⁻ : ∀ {x} (p : Any P [ x ]) → singleton⁺ (singleton⁻ p) ≡ p singleton⁺∘singleton⁻ (here px) = refl singleton⁺∘singleton⁻ (there ()) singleton⁻∘singleton⁺ : ∀ {x} (p : P x) → singleton⁻ (singleton⁺ p) ≡ p singleton⁻∘singleton⁺ p = refl singleton↔ : ∀ {x} → P x ↔ Any P [ x ] singleton↔ = inverse singleton⁺ singleton⁻ singleton⁻∘singleton⁺ singleton⁺∘singleton⁻ ------------------------------------------------------------------------ -- map module _ {a b} {A : Set a} {B : Set b} {f : A → B} where map⁺ : ∀ {p} {P : B → Set p} {n} {xs : Vec A n} → Any (P ∘ f) xs → Any P (map f xs) map⁺ (here p) = here p map⁺ (there p) = there $ map⁺ p map⁻ : ∀ {p} {P : B → Set p} {n} {xs : Vec A n} → Any P (map f xs) → Any (P ∘ f) xs map⁻ {xs = []} () map⁻ {xs = x ∷ xs} (here p) = here p map⁻ {xs = x ∷ xs} (there p) = there $ map⁻ p map⁺∘map⁻ : ∀ {p} {P : B → Set p} {n} {xs : Vec A n} → (p : Any P (map f xs)) → map⁺ (map⁻ p) ≡ p map⁺∘map⁻ {xs = []} () map⁺∘map⁻ {xs = x ∷ xs} (here p) = refl map⁺∘map⁻ {xs = x ∷ xs} (there p) = P.cong there (map⁺∘map⁻ p) map⁻∘map⁺ : ∀ {p} (P : B → Set p) {n} {xs : Vec A n} → (p : Any (P ∘ f) xs) → map⁻ {P = P} (map⁺ p) ≡ p map⁻∘map⁺ P (here p) = refl map⁻∘map⁺ P (there p) = P.cong there (map⁻∘map⁺ P p) map↔ : ∀ {p} {P : B → Set p} {n} {xs : Vec A n} → Any (P ∘ f) xs ↔ Any P (map f xs) map↔ = inverse map⁺ map⁻ (map⁻∘map⁺ _) map⁺∘map⁻ ------------------------------------------------------------------------ -- _++_ module _ {a p} {A : Set a} {P : A → Set p} where ++⁺ˡ : ∀ {n m} {xs : Vec A n} {ys : Vec A m} → Any P xs → Any P (xs ++ ys) ++⁺ˡ (here p) = here p ++⁺ˡ (there p) = there (++⁺ˡ p) ++⁺ʳ : ∀ {n m} (xs : Vec A n) {ys : Vec A m} → Any P ys → Any P (xs ++ ys) ++⁺ʳ [] p = p ++⁺ʳ (x ∷ xs) p = there (++⁺ʳ xs p) ++⁻ : ∀ {n m} (xs : Vec A n) {ys : Vec A m} → Any P (xs ++ ys) → Any P xs ⊎ Any P ys ++⁻ [] p = inj₂ p ++⁻ (x ∷ xs) (here p) = inj₁ (here p) ++⁻ (x ∷ xs) (there p) = Sum.map there id (++⁻ xs p) ++⁺∘++⁻ : ∀ {n m} (xs : Vec A n) {ys : Vec A m} (p : Any P (xs ++ ys)) → [ ++⁺ˡ , ++⁺ʳ xs ]′ (++⁻ xs p) ≡ p ++⁺∘++⁻ [] p = refl ++⁺∘++⁻ (x ∷ xs) (here p) = refl ++⁺∘++⁻ (x ∷ xs) (there p) with ++⁻ xs p | ++⁺∘++⁻ xs p ++⁺∘++⁻ (x ∷ xs) (there p) | inj₁ p′ | ih = P.cong there ih ++⁺∘++⁻ (x ∷ xs) (there p) | inj₂ p′ | ih = P.cong there ih ++⁻∘++⁺ : ∀ {n m} (xs : Vec A n) {ys : Vec A m} (p : Any P xs ⊎ Any P ys) → ++⁻ xs ([ ++⁺ˡ , ++⁺ʳ xs ]′ p) ≡ p ++⁻∘++⁺ [] (inj₁ ()) ++⁻∘++⁺ [] (inj₂ p) = refl ++⁻∘++⁺ (x ∷ xs) (inj₁ (here p)) = refl ++⁻∘++⁺ (x ∷ xs) {ys} (inj₁ (there p)) rewrite ++⁻∘++⁺ xs {ys} (inj₁ p) = refl ++⁻∘++⁺ (x ∷ xs) (inj₂ p) rewrite ++⁻∘++⁺ xs (inj₂ p) = refl ++↔ : ∀ {n m} {xs : Vec A n} {ys : Vec A m} → (Any P xs ⊎ Any P ys) ↔ Any P (xs ++ ys) ++↔ {xs = xs} = inverse [ ++⁺ˡ , ++⁺ʳ xs ]′ (++⁻ xs) (++⁻∘++⁺ xs) (++⁺∘++⁻ xs) ++-comm : ∀ {n m} (xs : Vec A n) (ys : Vec A m) → Any P (xs ++ ys) → Any P (ys ++ xs) ++-comm xs ys = [ ++⁺ʳ ys , ++⁺ˡ ]′ ∘ ++⁻ xs ++-comm∘++-comm : ∀ {n m} (xs : Vec A n) {ys : Vec A m} (p : Any P (xs ++ ys)) → ++-comm ys xs (++-comm xs ys p) ≡ p ++-comm∘++-comm [] {ys} p rewrite ++⁻∘++⁺ ys {ys = []} (inj₁ p) = refl ++-comm∘++-comm (x ∷ xs) {ys} (here p) rewrite ++⁻∘++⁺ ys {ys = x ∷ xs} (inj₂ (here p)) = refl ++-comm∘++-comm (x ∷ xs) (there p) with ++⁻ xs p | ++-comm∘++-comm xs p ++-comm∘++-comm (x ∷ xs) {ys} (there .([ ++⁺ʳ xs , ++⁺ˡ ]′ (++⁻ ys (++⁺ʳ ys p)))) | inj₁ p | refl rewrite ++⁻∘++⁺ ys (inj₂ p) | ++⁻∘++⁺ ys (inj₂ $ there {x = x} p) = refl ++-comm∘++-comm (x ∷ xs) {ys} (there .([ ++⁺ʳ xs , ++⁺ˡ ]′ (++⁻ ys (++⁺ˡ p)))) | inj₂ p | refl rewrite ++⁻∘++⁺ ys {ys = xs} (inj₁ p) | ++⁻∘++⁺ ys {ys = x ∷ xs} (inj₁ p) = refl ++↔++ : ∀ {n m} (xs : Vec A n) (ys : Vec A m) → Any P (xs ++ ys) ↔ Any P (ys ++ xs) ++↔++ xs ys = inverse (++-comm xs ys) (++-comm ys xs) (++-comm∘++-comm xs) (++-comm∘++-comm ys) ++-insert : ∀ {n m x} (xs : Vec A n) {ys : Vec A m} → P x → Any P (xs ++ [ x ] ++ ys) ++-insert xs Px = ++⁺ʳ xs (++⁺ˡ (singleton⁺ Px)) ------------------------------------------------------------------------ -- concat module _ {a p} {A : Set a} {P : A → Set p} where concat⁺ : ∀ {n m} {xss : Vec (Vec A n) m} → Any (Any P) xss → Any P (concat xss) concat⁺ (here p) = ++⁺ˡ p concat⁺ (there {x = xs} p) = ++⁺ʳ xs (concat⁺ p) concat⁻ : ∀ {n m} (xss : Vec (Vec A n) m) → Any P (concat xss) → Any (Any P) xss concat⁻ [] () concat⁻ (xs ∷ xss) p = [ here , there ∘ concat⁻ xss ]′ (++⁻ xs p) concat⁻∘++⁺ˡ : ∀ {n m xs} (xss : Vec (Vec A n) m) (p : Any P xs) → concat⁻ (xs ∷ xss) (++⁺ˡ p) ≡ here p concat⁻∘++⁺ˡ xss p rewrite ++⁻∘++⁺ _ {concat xss} (inj₁ p) = refl concat⁻∘++⁺ʳ : ∀ {n m} xs (xss : Vec (Vec A n) m) (p : Any P (concat xss)) → concat⁻ (xs ∷ xss) (++⁺ʳ xs p) ≡ there (concat⁻ xss p) concat⁻∘++⁺ʳ xs xss p rewrite ++⁻∘++⁺ xs (inj₂ p) = refl concat⁺∘concat⁻ : ∀ {n m} (xss : Vec (Vec A n) m) (p : Any P (concat xss)) → concat⁺ (concat⁻ xss p) ≡ p concat⁺∘concat⁻ [] () concat⁺∘concat⁻ (xs ∷ xss) p with ++⁻ xs p | P.inspect (++⁻ xs) p ... | inj₁ pxs | P.[ p=inj₁ ] = P.trans (P.cong [ ++⁺ˡ , ++⁺ʳ xs ]′ (P.sym p=inj₁)) $ ++⁺∘++⁻ xs p ... | inj₂ pxss | P.[ p=inj₂ ] rewrite concat⁺∘concat⁻ xss pxss = P.trans (P.cong [ ++⁺ˡ , ++⁺ʳ xs ]′ (P.sym p=inj₂)) $ ++⁺∘++⁻ xs p concat⁻∘concat⁺ : ∀ {n m} {xss : Vec (Vec A n) m} (p : Any (Any P) xss) → concat⁻ xss (concat⁺ p) ≡ p concat⁻∘concat⁺ {xss = xs ∷ xss} (here p) rewrite ++⁻∘++⁺ xs {concat xss} (inj₁ p) = refl concat⁻∘concat⁺ {xss = xs ∷ xss} (there p) rewrite ++⁻∘++⁺ xs {concat xss} (inj₂ (concat⁺ p)) | concat⁻∘concat⁺ p = refl concat↔ : ∀ {n m} {xss : Vec (Vec A n) m} → Any (Any P) xss ↔ Any P (concat xss) concat↔ {xss = xss} = inverse concat⁺ (concat⁻ xss) concat⁻∘concat⁺ (concat⁺∘concat⁻ xss) ------------------------------------------------------------------------ -- tabulate module _ {a p} {A : Set a} {P : A → Set p} where tabulate⁺ : ∀ {n} {f : Fin n → A} i → P (f i) → Any P (tabulate f) tabulate⁺ fzero p = here p tabulate⁺ (fsuc i) p = there (tabulate⁺ i p) tabulate⁻ : ∀ {n} {f : Fin n → A} → Any P (tabulate f) → ∃ λ i → P (f i) tabulate⁻ {zero} () tabulate⁻ {suc n} (here p) = fzero , p tabulate⁻ {suc n} (there p) = Prod.map fsuc id (tabulate⁻ p) ------------------------------------------------------------------------ -- mapWith∈ module _ {a b p} {A : Set a} {B : Set b} {P : B → Set p} where open import Data.Vec.Membership.Propositional using (_∈_; mapWith∈) mapWith∈⁺ : ∀ {n} {xs : Vec A n} (f : ∀ {x} → x ∈ xs → B) → (∃₂ λ x (x∈xs : x ∈ xs) → P (f x∈xs)) → Any P (mapWith∈ xs f) mapWith∈⁺ f (_ , here refl , p) = here p mapWith∈⁺ f (_ , there x∈xs , p) = there $ mapWith∈⁺ (f ∘ there) (_ , x∈xs , p) mapWith∈⁻ : ∀ {n} (xs : Vec A n) (f : ∀ {x} → x ∈ xs → B) → Any P (mapWith∈ xs f) → ∃₂ λ x (x∈xs : x ∈ xs) → P (f x∈xs) mapWith∈⁻ [] f () mapWith∈⁻ (y ∷ xs) f (here p) = (y , here refl , p) mapWith∈⁻ (y ∷ xs) f (there p) = Prod.map id (Prod.map there id) $ mapWith∈⁻ xs (f ∘ there) p mapWith∈↔ : ∀ {n} {xs : Vec A n} {f : ∀ {x} → x ∈ xs → B} → (∃₂ λ x (x∈xs : x ∈ xs) → P (f x∈xs)) ↔ Any P (mapWith∈ xs f) mapWith∈↔ = inverse (mapWith∈⁺ _) (mapWith∈⁻ _ _) (from∘to _) (to∘from _ _) where from∘to : ∀ {n} {xs : Vec A n} (f : ∀ {x} → x ∈ xs → B) (p : ∃₂ λ x (x∈xs : x ∈ xs) → P (f x∈xs)) → mapWith∈⁻ xs f (mapWith∈⁺ f p) ≡ p from∘to f (_ , here refl , p) = refl from∘to f (_ , there x∈xs , p) rewrite from∘to (f ∘ there) (_ , x∈xs , p) = refl to∘from : ∀ {n} (xs : Vec A n) (f : ∀ {x} → x ∈ xs → B) (p : Any P (mapWith∈ xs f)) → mapWith∈⁺ f (mapWith∈⁻ xs f p) ≡ p to∘from [] f () to∘from (y ∷ xs) f (here p) = refl to∘from (y ∷ xs) f (there p) = P.cong there $ to∘from xs (f ∘ there) p ------------------------------------------------------------------------ -- _∷_ module _ {a p} {A : Set a} where ∷↔ : ∀ {n} (P : Pred A p) {x} {xs : Vec A n} → (P x ⊎ Any P xs) ↔ Any P (x ∷ xs) ∷↔ P {x} {xs} = ++↔ ∘↔ (singleton↔ ⊎-cong id↔) ------------------------------------------------------------------------ -- _>>=_ module _ {ℓ p} {A B : Set ℓ} {P : B → Set p} {m} {f : A → Vec B m} where >>=↔ : ∀ {n} {xs : Vec A n} → Any (Any P ∘ f) xs ↔ Any P (xs >>= f) >>=↔ = concat↔ ∘↔ map↔
{ "alphanum_fraction": 0.4341934724, "avg_line_length": 39.1105990783, "ext": "agda", "hexsha": "b5608435d95ba3928e46794623e37b9e601e357f", "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/Vec/Relation/Unary/Any/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/Vec/Relation/Unary/Any/Properties.agda", "max_line_length": 91, "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/Vec/Relation/Unary/Any/Properties.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 7035, "size": 16974 }
{-# OPTIONS --cubical --no-import-sorts --safe #-} open import Cubical.Core.Everything open import Cubical.Foundations.HLevels module Cubical.Algebra.Magma.Construct.Right {ℓ} (Aˢ : hSet ℓ) where open import Cubical.Foundations.Prelude open import Cubical.Algebra.Magma private A = ⟨ Aˢ ⟩ isSetA = Aˢ .snd _▸_ : Op₂ A x ▸ y = y ------------------------------------------------------------------------ -- Properties ▸-identityˡ : ∀ x → LeftIdentity x _▸_ ▸-identityˡ _ _ = refl ▸-zeroʳ : ∀ x → RightZero x _▸_ ▸-zeroʳ _ _ = refl ------------------------------------------------------------------------ -- Magma definition Right-isMagma : IsMagma A _▸_ Right-isMagma = record { is-set = isSetA } RightMagma : Magma ℓ RightMagma = record { isMagma = Right-isMagma }
{ "alphanum_fraction": 0.5628205128, "avg_line_length": 21.0810810811, "ext": "agda", "hexsha": "f0758d96474a9fb717659caca9265084795aa261", "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/Algebra/Magma/Construct/Right.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/Algebra/Magma/Construct/Right.agda", "max_line_length": 72, "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/Algebra/Magma/Construct/Right.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 236, "size": 780 }
module Foundation.Equivalence where open import Foundation.Primitive record IsEquivalence {a} {A : Set a} {ℓ} (_≈_ : A → A → Set ℓ) : ℞ a ⊔ ℓ where field reflexivity : ∀ x → x ≈ x symmetry : ∀ x y → x ≈ y → y ≈ x transitivity : ∀ x y z → x ≈ y → y ≈ z → x ≈ z open IsEquivalence ⦃ … ⦄ public record Equivalence {a} (A : Set a) ℓ : ℞ a ⊔ ⟰ ℓ where infix 4 _≈_ field _≈_ : A → A → Set ℓ instance ⦃ isEquivalence ⦄ : IsEquivalence _≈_ open Equivalence ⦃ … ⦄ public open import Foundation.Bottom infix 4 _≉_ _≉_ : ∀ {a} {A : Set a} {ℓ} ⦃ _ : Equivalence A ℓ ⦄ {b} ⦃ _ : Bottom b ℓ ⦄ → A → A → Set (b ⊔ ℓ) _≉_ {ℓ = ℓ} x y = ¬ (x ≈ y)
{ "alphanum_fraction": 0.5572289157, "avg_line_length": 24.5925925926, "ext": "agda", "hexsha": "482ab72bd90bd605ed53bf5fb6222704ac8ca636", "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-1/Foundation/Equivalence.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-1/Foundation/Equivalence.agda", "max_line_length": 97, "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-1/Foundation/Equivalence.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 299, "size": 664 }
{-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.Categories.Morphism where open import Cubical.Foundations.Prelude open import Cubical.Data.Sigma open import Cubical.Categories.Category private variable ℓ ℓ' : Level module _ {C : Precategory ℓ ℓ'} where open Precategory C private variable x y z w : ob isMonic : (Hom[ x , y ]) → Type (ℓ-max ℓ ℓ') isMonic {x} {y} f = ∀ {z : ob} {a a' : Hom[ z , x ]} → (f ∘ a ≡ f ∘ a') → (a ≡ a') isEpic : (Hom[ x , y ]) → Type (ℓ-max ℓ ℓ') isEpic {x} {y} g = ∀ {z : ob} {b b' : Hom[ y , z ]} → (b ∘ g ≡ b' ∘ g) → (b ≡ b') -- A morphism is split monic if it has a *retraction* isSplitMon : (Hom[ x , y ]) → Type ℓ' isSplitMon {x} {y} f = ∃[ r ∈ Hom[ y , x ] ] r ∘ f ≡ id x -- A morphism is split epic if it has a *section* isSplitEpi : (Hom[ x , y ]) → Type ℓ' isSplitEpi {x} {y} g = ∃[ s ∈ Hom[ y , x ] ] g ∘ s ≡ id y record areInv (f : Hom[ x , y ]) (g : Hom[ y , x ]) : Type ℓ' where field sec : g ⋆ f ≡ id y ret : f ⋆ g ≡ id x open areInv symAreInv : ∀ {f : Hom[ x , y ]} {g : Hom[ y , x ]} → areInv f g → areInv g f symAreInv record { sec = sec ; ret = ret } = record { sec = ret ; ret = sec } -- equational reasoning with inverses invMoveR : ∀ {f : Hom[ x , y ]} {g : Hom[ y , x ]} {h : Hom[ z , x ]} {k : Hom[ z , y ]} → areInv f g → h ⋆ f ≡ k → h ≡ k ⋆ g invMoveR {f = f} {g} {h} {k} ai p = h ≡⟨ sym (⋆IdR _) ⟩ (h ⋆ id _) ≡⟨ cong (h ⋆_) (sym (ai .ret)) ⟩ (h ⋆ (f ⋆ g)) ≡⟨ sym (⋆Assoc _ _ _) ⟩ ((h ⋆ f) ⋆ g) ≡⟨ cong (_⋆ g) p ⟩ k ⋆ g ∎ invMoveL : ∀ {f : Hom[ x , y ]} {g : Hom[ y , x ]} {h : Hom[ y , z ]} {k : Hom[ x , z ]} → areInv f g → f ⋆ h ≡ k → h ≡ g ⋆ k invMoveL {f = f} {g} {h} {k} ai p = h ≡⟨ sym (⋆IdL _) ⟩ id _ ⋆ h ≡⟨ cong (_⋆ h) (sym (ai .sec)) ⟩ (g ⋆ f) ⋆ h ≡⟨ ⋆Assoc _ _ _ ⟩ g ⋆ (f ⋆ h) ≡⟨ cong (g ⋆_) p ⟩ (g ⋆ k) ∎ record isIso (f : Hom[ x , y ]) : Type ℓ' where field inv : Hom[ y , x ] sec : inv ⋆ f ≡ id y ret : f ⋆ inv ≡ id x open isIso isIso→areInv : ∀ {f : Hom[ x , y ]} → (isI : isIso f) → areInv f (isI .inv) isIso→areInv record { inv = inv ; sec = sec ; ret = ret } = record { sec = sec ; ret = ret } open CatIso -- isIso agrees with CatIso isIso→CatIso : ∀ {f : C [ x , y ]} → isIso f → CatIso {C = C} x y isIso→CatIso {f = f} record { inv = f⁻¹ ; sec = sec ; ret = ret } = catiso f f⁻¹ sec ret CatIso→isIso : (cIso : CatIso {C = C} x y) → isIso (cIso .mor) CatIso→isIso (catiso mor inv sec ret) = record { inv = inv ; sec = sec ; ret = ret } CatIso→areInv : (cIso : CatIso {C = C} x y) → areInv (cIso .mor) (cIso .inv) CatIso→areInv cIso = isIso→areInv (CatIso→isIso cIso) -- reverse of an iso is also an iso symCatIso : ∀ {x y} → CatIso {C = C} x y → CatIso {C = C} y x symCatIso (catiso mor inv sec ret) = catiso inv mor ret sec
{ "alphanum_fraction": 0.4605678233, "avg_line_length": 27.8070175439, "ext": "agda", "hexsha": "0b0b3cd4157eb2397de86eb04ab0596df4bcf880", "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": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "dan-iel-lee/cubical", "max_forks_repo_path": "Cubical/Categories/Morphism.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "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": "dan-iel-lee/cubical", "max_issues_repo_path": "Cubical/Categories/Morphism.agda", "max_line_length": 94, "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/Categories/Morphism.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1350, "size": 3170 }
module Structure.Real where import Lvl open import Data.Boolean open import Data.Boolean.Proofs import Data.Either as Either open import Functional open import Logic open import Logic.Classical open import Logic.Propositional open import Logic.Predicate open import Numeral.Natural using (ℕ) import Numeral.Natural.Relation.Order as ℕ open import Relator.Ordering open import Structure.Setoid open import Structure.Function.Ordering open import Structure.Operator.Field open import Structure.Operator.Monoid open import Structure.Operator.Group open import Structure.Operator.Proofs open import Structure.Operator.Properties open import Structure.Relator.Ordering open Structure.Relator.Ordering.Weak.Properties open import Structure.Relator.Properties open import Structure.OrderedField import Structure.OrderedField.AbsoluteValue open import Syntax.Transitivity open import Type private variable ℓ ℓ₁ ℓ₂ ℓₑ : Lvl.Level -- Theory defining the axioms of ℝ in classical logic. -- The axioms are the following: -- • An ordered field. -- • Monotone convergence. record RealTheory {R : Type{ℓ₁}} ⦃ equiv-R : Equiv{ℓₑ}(R) ⦄ (_+_ _⋅_ : R → R → R) (_≤_ : R → R → Stmt{ℓ₂}) ⦃ classical : ∀{ℓ}{P : Stmt{ℓ}} → Classical(P) ⦄ : Type{ℓ₁ Lvl.⊔ ℓ₂ Lvl.⊔ ℓₑ} where field ⦃ orderedField ⦄ : OrderedField(_+_)(_⋅_)(_≤_) open OrderedField(orderedField) public open Structure.OrderedField.AbsoluteValue(_+_)(_⋅_)(_≤_) field sup-fn : (f : ℕ → R) → ⦃ Increasing(ℕ._≤_)(_≤_)(f) ⦄ → ⦃ UpperBounded(ℕ._≤_)(_≤_)(f) ⦄ → R monotone-convergence : ∀{f} → ⦃ inc : Increasing(ℕ._≤_)(_≤_)(f) ⦄ → ⦃ bound : UpperBounded(ℕ._≤_)(_≤_)(f) ⦄ → ∃{Obj = R → ℕ}(N ↦ ∀{ε} → (ε > 𝟎) → ∀{n} → (n ℕ.> N(ε)) → (‖ f(n) − sup-fn (f) ⦃ inc ⦄ ⦃ bound ⦄ ‖ < ε)) -- TODO: Consider adding something that relates addition and multiplication so that it conform to the axioms of arithmetic and their definitions of addition and multiplication. This is so that one should be able to prove (x + x ≡ 𝐒(𝐒(𝟎)) ⋅ x) or (2.5 ⋅ x = x + x + x/2) (when 𝐒, the successor function is defined as (1 +_)) for easier to write statements. In other words: add ((1 + x) ⋅ y = x + (x ⋅ y)) as an axiom. (20201210 Is this TODO outdated?)
{ "alphanum_fraction": 0.7032025259, "avg_line_length": 46.1875, "ext": "agda", "hexsha": "ba295b28bf4d05889377d8672d654cff7b0e9993", "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/Real.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/Real.agda", "max_line_length": 452, "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/Real.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": 743, "size": 2217 }
Id₁ Id₂ Id₃ : {A B : Set} → (A → B) → A → B Id₁ F = F Id₂ = Id₁ Id₃ = Id₁ syntax Id₁ (λ X → B) = ƛ X ⟶ B syntax Id₂ (λ X → B) = X ↦ B syntax Id₃ (λ X → B) = X ↦ B • postulate A : Set a : A module One where example₀ : (A → A) → A example₀ = ƛ _ ⟶ a example₁ : A → A example₁ = ƛ !_! ⟶ (!_!) example₂ : A → A example₂ = ƛ !_!_ ⟶ (!_!_) example₃ : A → A example₃ = ƛ _!_! ⟶ (_!_!) example₄ : A → A example₄ = ƛ _!_!_!_ ⟶ (_!_!_!_) example₅ : (A → A) → (A → A) example₅ = ƛ !_! ⟶ λ a → ! a ! example₆ : (A → A → A) → (A → A → A) example₆ = ƛ !_!_ ⟶ λ a b → ! a ! b example₇ : (A → A → A) → (A → A → A) example₇ = ƛ _!_! ⟶ λ a b → a ! b ! example₈ : (A → A → A → A → A) → (A → A → A → A → A) example₈ = ƛ _!_!_!_ ⟶ λ a b c → a !_! b ! c example₉ : (A → A) → A example₉ = ƛ !_! ⟶ (! a !) example₁₀ : (A → A → A) → A example₁₀ = ƛ !_!_ ⟶ (! a ! a) example₁₁ : (A → A → A) → A example₁₁ = ƛ _!_! ⟶ (a ! a !) example₁₂ : (A → A → A → A → A) → (A → A) example₁₂ = ƛ _!_!_!_ ⟶ (a ! a !_! a) module Two where example₀ : (A → A) → A example₀ = _ ↦ a example₁ : A → A example₁ = !_! ↦ (!_!) example₂ : A → A example₂ = !_!_ ↦ (!_!_) example₃ : A → A example₃ = _!_! ↦ (_!_!) example₄ : A → A example₄ = _!_!_!_ ↦ (_!_!_!_) example₅ : (A → A) → (A → A) example₅ = !_! ↦ λ a → ! a ! example₆ : (A → A → A) → (A → A → A) example₆ = !_!_ ↦ λ a b → ! a ! b example₇ : (A → A → A) → (A → A → A) example₇ = _!_! ↦ λ a b → a ! b ! example₈ : (A → A → A → A → A) → (A → A → A → A → A) example₈ = _!_!_!_ ↦ λ a b c → a !_! b ! c example₉ : (A → A) → A example₉ = !_! ↦ (! a !) example₁₀ : (A → A → A) → A example₁₀ = !_!_ ↦ (! a ! a) example₁₁ : (A → A → A) → A example₁₁ = _!_! ↦ (a ! a !) example₁₂ : (A → A → A → A → A) → (A → A) example₁₂ = _!_!_!_ ↦ (a ! a !_! a) module Three where example₀ : (A → A) → A example₀ = _ ↦ a • example₁ : A → A example₁ = !_! ↦ (!_!) • example₂ : A → A example₂ = !_!_ ↦ (!_!_) • example₃ : A → A example₃ = _!_! ↦ (_!_!) • example₄ : A → A example₄ = _!_!_!_ ↦ (_!_!_!_) • example₅ : (A → A) → (A → A) example₅ = !_! ↦ (λ a → ! a !) • example₆ : (A → A → A) → (A → A → A) example₆ = !_!_ ↦ (λ a b → ! a ! b) • example₇ : (A → A → A) → (A → A → A) example₇ = _!_! ↦ (λ a b → a ! b !) • example₈ : (A → A → A → A → A) → (A → A → A → A → A) example₈ = _!_!_!_ ↦ (λ a b c → a !_! b ! c) • example₉ : (A → A) → A example₉ = !_! ↦ (! a !) • example₁₀ : (A → A → A) → A example₁₀ = !_!_ ↦ (! a ! a) • example₁₁ : (A → A → A) → A example₁₁ = _!_! ↦ (a ! a !) • example₁₂ : (A → A → A → A → A) → (A → A) example₁₂ = _!_!_!_ ↦ (a ! a !_! a) •
{ "alphanum_fraction": 0.4221818182, "avg_line_length": 20.2205882353, "ext": "agda", "hexsha": "955aa3edd90be75b422334197fc5bf25ef35f78c", "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/Issue1951.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/Issue1951.agda", "max_line_length": 54, "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/Issue1951.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": 1417, "size": 2750 }
{-# OPTIONS --universe-polymorphism #-} -- Support stuff mostly stolen or adapted from the Agda standard library module Support where data Level : Set where zero : Level suc : (i : Level) → Level {-# BUILTIN LEVEL Level #-} {-# BUILTIN LEVELZERO zero #-} {-# BUILTIN LEVELSUC suc #-} -- Maximum. infixl 6 _⊔_ infixr 2 _×_ _⊔_ : Level → Level → Level zero ⊔ j = j suc i ⊔ zero = suc i suc i ⊔ suc j = suc (i ⊔ j) {-# BUILTIN LEVELMAX _⊔_ #-} infix 4 _≣_ data _≣_ {ℓ} {A : Set ℓ} (x : A) : A → Set ℓ where ≣-refl : x ≣ x {-# BUILTIN EQUALITY _≣_ #-} {-# BUILTIN REFL ≣-refl #-} ≣-trans : ∀ {a} {A : Set a} → ∀ {x y z : A} → y ≣ z → x ≣ y → x ≣ z ≣-trans ≣-refl ≣-refl = ≣-refl ≣-sym : ∀ {a} {A : Set a} → ∀ {x y : A} → x ≣ y → y ≣ x ≣-sym ≣-refl = ≣-refl ≣-subst : ∀ {a p} {A : Set a} → (P : A → Set p) → ∀ {x y} → x ≣ y → P x → P y ≣-subst P ≣-refl x = x ≣-subst₂ : ∀ {a b p} {A : Set a} {B : Set b} (P : A → B → Set p) {x₁ x₂ y₁ y₂} → x₁ ≣ x₂ → y₁ ≣ y₂ → P x₁ y₁ → P x₂ y₂ ≣-subst₂ P ≣-refl ≣-refl p = p ≣-cong : ∀ {a b} {A : Set a} {B : Set b} (f : A → B) {x y} → x ≣ y → f x ≣ f y ≣-cong f ≣-refl = ≣-refl ≣-cong₂ : ∀ {a b c} {A : Set a} {B : Set b} {C : Set c} (f : A → B → C) {x y u v} → x ≣ y → u ≣ v → f x u ≣ f y v ≣-cong₂ f ≣-refl ≣-refl = ≣-refl infixr 4 _,_ record Σ {a b} (A : Set a) (B : A → Set b) : Set (a ⊔ b) where constructor _,_ field proj₁ : A proj₂ : B proj₁ open Σ public ∃ : ∀ {a b} {A : Set a} → (A → Set b) → Set (a ⊔ b) ∃ = Σ _ ∃₂ : ∀ {a b c} {A : Set a} {B : A → Set b} (C : (x : A) → B x → Set c) → Set (a ⊔ b ⊔ c) ∃₂ C = ∃ λ a → ∃ λ b → C a b record Σ′ {a b} (A : Set a) (B : A → Set b) : Set (a ⊔ b) where constructor _,_ field proj₁′ : A .proj₂′ : B proj₁′ open Σ′ public ∃′ : ∀ {a b} {A : Set a} → (A → Set b) → Set (a ⊔ b) ∃′ = Σ′ _ ∃₂′ : ∀ {a b c} {A : Set a} {B : A → Set b} (C : (x : A) → B x → Set c) → Set (a ⊔ b ⊔ c) ∃₂′ C = ∃ λ a → ∃′ λ b → C a b record _×_ {a b} (A : Set a) (B : Set b) : Set (a ⊔ b) where constructor _,_ field fst : A snd : B open _×_ public ⟨_,_⟩ : ∀ {a b c d} {A : Set a} {B : Set b} {C : Set c} {D : Set d} → (A → B) → (C → D) → A × C → B × D ⟨ f , g ⟩ (x , y) = f x , g y ⟨_&_⟩ : ∀ {a b d} {A : Set a} {B : Set b} {D : Set d} → (A → B) → (A → D) → A → B × D ⟨ f & g ⟩ x = f x , g x _∙_ : ∀ {a b c} {A : Set a} {B : A → Set b} {C : {x : A} → B x → Set c} → (∀ {x} (y : B x) → C y) → (g : (x : A) → B x) → ((x : A) → C (g x)) f ∙ g = λ x → f (g x) ∙-assoc : ∀ {a b c d} {A : Set a} {B : A → Set b} {C : {x : A} → B x → Set c} {D : {x : A} {y : B x} → C y → Set d} → (f : ∀ {x} {y : B x} (z : C y) → D z) → (g : ∀ {x} (y : B x) → C y) → (h : (x : A) → B x) → {x : A} → (f ∙ (g ∙ h)) x ≣ ((f ∙ g) ∙ h) x ∙-assoc f g h {x} = ≣-refl _∙′_ : ∀ {a b c} {A : Set a} {B : Set b} {C : Set c} → (B → C) → (A → B) → (A → C) f ∙′ g = _∙_ f g _∙₂_ : ∀ {a b c d} {A : Set a} {B : A → Set b} {C : {x : A} → B x → Set c} {D : {x : A} {y : B x} → C y → Set d} → (∀ {x} {y : B x} (z : C y) → D z) → (g : (x : A) (y : B x) → C y) → ((x : A) (y : B x) → D (g x y)) f ∙₂ g = λ x y → f (g x y) _∙₃_ : ∀ {a b c d e} {A : Set a} {B : A → Set b} {C : {x : A} → B x → Set c} {D : {x : A} {y : B x} → C y → Set d} {E : {x : A} {y : B x} {z : C y} → D z → Set e} → (∀ {x} {y : B x} {z : C y} (w : D z) → E w) → (g : (x : A) (y : B x) (z : C y) → D z) → ((x : A) (y : B x) (z : C y) → E (g x y z)) f ∙₃ g = λ x y z → f (g x y z) flip : ∀ {a b c} {A : Set a} {B : Set b} {C : A → B → Set c} → ((x : A) (y : B) → C x y) → ((y : B) (x : A) → C x y) flip f = λ x y → f y x _$↑_ : ∀ {a b c} {A : Set a} {B : A → Set b} {C : {x : A} → B x → Set c} → (∀ {x} (y : B x) → C y) → (g : (x : A) → B x) → ((x : A) → C (g x)) _$↑_ = _∙_ _$⇈_ : ∀ {ℓ a b} {T : Set ℓ} {A : T → Set a} {B : (i : T) → (x : A i) → Set b} → (f : (i : T) → ∀ (x : A i) → B i x) → (x : (i : T) → A i) → ((i : T) → B i (x i)) f $⇈ x = λ i → f i (x i) {- John Major equality would be nice for stating this result ... -} $⇈-obs : ∀ {ℓ a b} {T : Set ℓ} {A : T → Set a} {B : (i : T) → (x : A i) → Set b} → {f f′ : (i : T) → ∀ (x : A i) → B i x} (eq-f : ∀ {i} {x : A i} → f i x ≣ f′ i x) → {x x′ : (i : T) → A i} (eq-x : ∀ {i} → x i ≣ x′ i) → ∀ {i} → (≣-subst (B i) (eq-x {i}) ((f $⇈ x) i) ≣ (f′ $⇈ x′) i) $⇈-obs eq-f {x} {x′} eq-x {i} rewrite eq-x {i} | eq-f {i} {x′ i} = ≣-refl lift↑ : ∀ {ℓ a b} {T : Set ℓ} {A : T → Set a} {B : (i : T) → A i → Set b} → (f : ∀ {i} (x : A i) → B i x) → (x : (i : T) → A i) → ((i : T) → B i (x i)) lift↑ = _$↑_ lift↑₂ : ∀ {ℓ a b c} {T : Set ℓ} {A : T → Set a} {B : (i : T) → Set b} {C : (i : T) → A i → B i → Set c} → (f : ∀ {i} (x : A i) (y : B i) → C i x y) → (x : (i : T) → A i) (y : (i : T) → B i) → ((i : T) → C i (x i) (y i)) lift↑₂ = λ f x y → (lift↑ f x) $⇈ y Rel : ∀ {a} → Set a → (ℓ : Level) → Set (a ⊔ suc ℓ) Rel A ℓ = A → A → Set ℓ private _⇒_ : ∀ {a ℓ₁ ℓ₂} {A : Set a} → Rel A ℓ₁ → Rel A ℓ₂ → Set _ P ⇒ Q = ∀ {i j} → P i j → Q i j _Respects_ : ∀ {a ℓ₁ ℓ₂} {A : Set a} → (A → Set ℓ₁) → Rel A ℓ₂ → Set _ P Respects _∼_ = ∀ {x y} → x ∼ y → P x → P y _Respects₂_ : ∀ {a ℓ₁ ℓ₂} {A : Set a} → Rel A ℓ₁ → Rel A ℓ₂ → Set _ P Respects₂ _∼_ = (∀ {x} → P x Respects _∼_) × (∀ {y} → flip P y Respects _∼_) record IsEquivalence {a ℓ} {A : Set a} (_≈_ : Rel A ℓ) : Set (a ⊔ ℓ) where field refl : ∀ {x} → x ≈ x sym : ∀ {x y} → x ≈ y → y ≈ x trans : ∀ {x y z} → x ≈ y → y ≈ z → x ≈ z -- a helper to promote propositional equality to equivalence .prop : ∀ {x y} → x ≣ y → x ≈ y prop ≣-refl = refl record IsPreorder {a ℓ₁ ℓ₂} {A : Set a} (_≈_ : Rel A ℓ₁) -- The underlying equality. (_∼_ : Rel A ℓ₂) -- The relation. : Set (a ⊔ ℓ₁ ⊔ ℓ₂) where field isEquivalence : IsEquivalence _≈_ -- Reflexivity is expressed in terms of an underlying equality: reflexive : _≈_ ⇒ _∼_ trans : ∀ {x y z} → x ∼ y → y ∼ z → x ∼ z module Eq = IsEquivalence isEquivalence refl : ∀ {x} → x ∼ x refl = reflexive Eq.refl ∼-resp-≈ : _∼_ Respects₂ _≈_ ∼-resp-≈ = (λ x≈y z∼x → trans z∼x (reflexive x≈y)) , (λ x≈y x∼z → trans (reflexive (Eq.sym x≈y)) x∼z) record Preorder c ℓ₁ ℓ₂ : Set (suc (c ⊔ ℓ₁ ⊔ ℓ₂)) where infix 4 _≈_ _∼_ field Carrier : Set c _≈_ : Rel Carrier ℓ₁ -- The underlying equality. _∼_ : Rel Carrier ℓ₂ -- The relation. isPreorder : IsPreorder _≈_ _∼_ open IsPreorder isPreorder public record Setoid c ℓ : Set (suc (c ⊔ ℓ)) where infix 4 _≈_ field Carrier : Set c _≈_ : Rel Carrier ℓ .isEquivalence : IsEquivalence _≈_ record SetoidFunction {c ℓ c′ ℓ′} (X : Setoid c ℓ) (Y : Setoid c′ ℓ′) : Set (c ⊔ ℓ ⊔ c′ ⊔ ℓ′) where field F : Setoid.Carrier X → Setoid.Carrier Y .cong : ∀ {x y} → Setoid._≈_ X x y → Setoid._≈_ Y (F x) (F y) module SetoidReasoning {s₁ s₂} (S : Setoid s₁ s₂) where open Setoid S infix 4 _IsRelatedTo_ infix 2 _∎ infixr 2 _≈⟨_⟩_ infixr 2 _↓⟨_⟩_ infixr 2 _↑⟨_⟩_ infixr 2 _↓≣⟨_⟩_ infixr 2 _↑≣⟨_⟩_ infixr 2 _↕_ infix 1 begin_ -- This seemingly unnecessary type is used to make it possible to -- infer arguments even if the underlying equality evaluates. data _IsRelatedTo_ (x y : Carrier) : Set s₂ where relTo : (x∼y : x ≈ y) → x IsRelatedTo y .begin_ : ∀ {x y} → x IsRelatedTo y → x ≈ y begin relTo x∼y = x∼y ._↓⟨_⟩_ : ∀ x {y z} → x ≈ y → y IsRelatedTo z → x IsRelatedTo z _ ↓⟨ x∼y ⟩ relTo y∼z = relTo (trans x∼y y∼z) where open IsEquivalence isEquivalence ._↑⟨_⟩_ : ∀ x {y z} → y ≈ x → y IsRelatedTo z → x IsRelatedTo z _ ↑⟨ y∼x ⟩ relTo y∼z = relTo (trans (sym y∼x) y∼z) where open IsEquivalence isEquivalence -- the syntax of the ancients, for compatibility ._≈⟨_⟩_ : ∀ x {y z} → x ≈ y → y IsRelatedTo z → x IsRelatedTo z _≈⟨_⟩_ = _↓⟨_⟩_ ._↓≣⟨_⟩_ : ∀ x {y z} → x ≣ y → y IsRelatedTo z → x IsRelatedTo z _ ↓≣⟨ ≣-refl ⟩ y∼z = y∼z ._↑≣⟨_⟩_ : ∀ x {y z} → y ≣ x → y IsRelatedTo z → x IsRelatedTo z _ ↑≣⟨ ≣-refl ⟩ y∼z = y∼z ._↕_ : ∀ x {z} → x IsRelatedTo z → x IsRelatedTo z _ ↕ x∼z = x∼z ._∎ : ∀ x → x IsRelatedTo x _∎ _ = relTo refl where open IsEquivalence isEquivalence ≣-is-equivalence : ∀ {ℓ} (A : Set ℓ) → IsEquivalence (_≣_ {A = A}) ≣-is-equivalence A = record { refl = λ {x} → ≣-refl ; sym = λ {x} {y} → ≣-sym ; trans = λ {x} {y} {z} → flip ≣-trans } SetAsSetoid : ∀ {ℓ} (A : Set ℓ) → Setoid ℓ ℓ SetAsSetoid A = record { Carrier = A ; _≈_ = _≣_ ; isEquivalence = ≣-is-equivalence A } module ≣-reasoning {ℓ} (S : Set ℓ) where infix 4 _IsRelatedTo_ infix 2 _∎ infixr 2 _≈⟨_⟩_ infixr 2 _↓⟨_⟩_ infixr 2 _↑⟨_⟩_ infixr 2 _↕_ infix 1 begin_ -- This seemingly unnecessary type is used to make it possible to -- infer arguments even if the underlying equality evaluates. data _IsRelatedTo_ (x y : S) : Set ℓ where relTo : (x∼y : x ≣ y) → x IsRelatedTo y begin_ : ∀ {x y} → x IsRelatedTo y → x ≣ y begin relTo x∼y = x∼y -- the syntax of the ancients, for compatibility _≈⟨_⟩_ : ∀ x {y z} → x ≣ y → y IsRelatedTo z → x IsRelatedTo z _ ≈⟨ x∼y ⟩ relTo y∼z = relTo (≣-trans y∼z x∼y) _↓⟨_⟩_ : ∀ x {y z} → x ≣ y → y IsRelatedTo z → x IsRelatedTo z _ ↓⟨ x∼y ⟩ relTo y∼z = relTo (≣-trans y∼z x∼y) _↑⟨_⟩_ : ∀ x {y z} → y ≣ x → y IsRelatedTo z → x IsRelatedTo z _ ↑⟨ y∼x ⟩ relTo y∼z = relTo (≣-trans y∼z (≣-sym y∼x)) _↕_ : ∀ x {z} → x IsRelatedTo z → x IsRelatedTo z _ ↕ x∼z = x∼z _∎ : ∀ x → x IsRelatedTo x _∎ _ = relTo ≣-refl data ℕ : Set where zero : ℕ suc : ℕ → ℕ {-# BUILTIN NATURAL ℕ #-} {-# BUILTIN ZERO zero #-} {-# BUILTIN SUC suc #-} data Fin : ℕ → Set where zero : ∀ {n} → Fin (suc n) suc : ∀ {n} → Fin n → Fin (suc n) data ⊥ : Set where ¬_ : ∀ {a} (A : Set a) → Set a ¬ A = A → ⊥ record ⊤ {ℓ} : Set ℓ where constructor tt type-signature : ∀ {a} (A : Set a) → A → A type-signature A x = x syntax type-signature A x = x ∶ A data Either {l r : Level} (L : Set l) (R : Set r) : Set (l ⊔ r) where inl : L → Either L R inr : R → Either L R either₀ : ∀ {l r ℓ : Level} {L : Set l} {R : Set r} {A : Set ℓ} (f : L → A) (g : R → A) (v : Either L R) → A either₀ f _ (inl x) = f x either₀ _ g (inr y) = g y ∙-dist-either₀ : ∀ {l r ℓ ℓ′} {L : Set l} {R : Set r} {A : Set ℓ} {A′ : Set ℓ′} (f : L → A) (g : R → A) (h : A → A′) {v : Either L R} → (h ∙ either₀ f g) v ≣ either₀ (h ∙ f) (h ∙ g) v ∙-dist-either₀ f g h {inl y} = ≣-refl ∙-dist-either₀ f g h {inr y} = ≣-refl either₀-obsˡ : ∀ {l r ℓ : Level} {L : Set l} {R : Set r} {A : Set ℓ} {f : L → A} {f′ : L → A} (eq : ∀ {x} → f x ≣ f′ x) (g : R → A) → ∀ {v} → (either₀ f g v ≣ either₀ f′ g v) either₀-obsˡ eq g {inl y} = eq either₀-obsˡ eq g {inr y} = ≣-refl either₀-obsʳ : ∀ {l r ℓ : Level} {L : Set l} {R : Set r} {A : Set ℓ} {g : R → A} {g′ : R → A} (f : L → A) (eq : ∀ {x} → g x ≣ g′ x) → ∀ {v} → (either₀ f g v ≣ either₀ f g′ v) either₀-obsʳ f eq {inl y} = ≣-refl either₀-obsʳ f eq {inr y} = eq either₀-correlate : ∀ {l r ℓ ℓ′ : Level} {L : Set l} {R : Set r} {A : Set ℓ} {A′ : Set ℓ′ } (f : L → A′ → A) (g : R → A′ → A) (f′ : L → A′) (g′ : R → A′) (v : Either L R) → either₀ (either₀ f g v ∙ f′) (either₀ f g v ∙ g′) v ≣ either₀ (f $⇈ f′) (g $⇈ g′) v either₀-correlate f g f′ g′ (inl v) = ≣-refl either₀-correlate f g f′ g′ (inr v) = ≣-refl either : ∀ {l r ℓ} {L : Set l} {R : Set r} {L′ : L → Set ℓ} {R′ : R → Set ℓ} (f : (x : L) → L′ x) (g : (y : R) → R′ y) (v : Either L R) → either₀ L′ R′ v either f _ (inl x) = f x either _ g (inr y) = g y either′ : ∀ {l r ℓ} {L : Set l} {R : Set r} {A : Either L R → Set ℓ} (f : (x : L) → A (inl x)) (g : (y : R) → A (inr y)) (v : Either L R) → A v either′ f _ (inl x) = f x either′ _ g (inr y) = g y left : ∀ {l l′ r} {L : Set l} {R : Set r} {L′ : Set l′} (f : L → L′) (v : Either L R) → Either L′ R left f (inl x) = inl (f x) left _ (inr y) = inr y right : ∀ {l r r′} {L : Set l} {R : Set r} {R′ : Set r′} (g : R → R′) (v : Either L R) → Either L R′ right _ (inl x) = inl x right g (inr y) = inr (g y) _+++_ : ∀ {l l′} {L : Set l} {L′ : Set l′} (f : L → L′) {r r′} {R : Set r} {R′ : Set r′} (g : R → R′) (v : Either L R) → Either L′ R′ (f +++ _) (inl x) = inl (f x) (_ +++ g) (inr y) = inr (g y) uncurry₀ : ∀ {x y z} {X : Set x} {Y : Set y} {Z : Set z} (f : X → Y → Z) → X × Y → Z uncurry₀ f (x , y) = f x y ∙-commute-uncurry₀ : ∀ {x y z z′} {X : Set x} {Y : Set y} {Z : Set z} {Z′ : Set z′} (g : Z → Z′) (f : X → Y → Z) → (g ∙ uncurry₀ f) ≣ uncurry₀ (g ∙₂ f) ∙-commute-uncurry₀ g f = ≣-refl ∙₂-commute-uncurry₀ : ∀ {x y z w w′} {X : Set x} {Y : Set y} {Z : Set z} {W : Set w} {W′ : Set w′} (g : W → W′) (f : X → Y → Z → W) → (g ∙₂ uncurry₀ f) ≣ uncurry₀ (g ∙₃ f) ∙₂-commute-uncurry₀ g f = ≣-refl uncurry₀-obs : ∀ {x y z} {X : Set x} {Y : Set y} {Z : Set z} {f : X → Y → Z} → (f-obs : ∀ {x x′ y y′} → x ≣ x′ → y ≣ y′ → f x y ≣ f x′ y′) {x,y x,y′ : X × Y} (eq : x,y ≣ x,y′) → uncurry₀ f x,y ≣ uncurry₀ f x,y′ uncurry₀-obs f-obs eq rewrite f-obs (≣-cong fst eq) (≣-cong snd eq) = ≣-refl uncurry₀-obs′₁ : ∀ {x y z w} {X : Set x} {Y : Set y} {Z : Set z} {W : Z → Set w} {f f′ : X → Y → (c : Z) → W c} → (∀ a b c → f a b c ≣ f′ a b c) → ∀ a,b c → uncurry₀ f a,b c ≣ uncurry₀ f′ a,b c uncurry₀-obs′₁ f-obs a,b c rewrite f-obs (fst a,b) (snd a,b) c = ≣-refl uncurry : ∀ {x y z} {X : Set x} {Y : Set y} {Z : X → Y → Set z} (f : (x : X) → (y : Y) → Z x y) → (x,y : X × Y) → uncurry₀ Z x,y uncurry f (x , y) = f x y prop→obs : ∀ {a b} {A : Set a} {B : A → Set b} {f : (x : A) → B x} {g : (x : A) → B x} (eq : f ≣ g) → ∀ {x} → f x ≣ g x prop→obs ≣-refl {x} = ≣-refl
{ "alphanum_fraction": 0.4478002546, "avg_line_length": 33.0327102804, "ext": "agda", "hexsha": "b04cbf42645f22d83d28dd645720d8697794e4db", "lang": "Agda", "max_forks_count": 23, "max_forks_repo_forks_event_max_datetime": "2021-11-11T13:50:56.000Z", "max_forks_repo_forks_event_min_datetime": "2015-02-05T13:03:09.000Z", "max_forks_repo_head_hexsha": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "p-pavel/categories", "max_forks_repo_path": "Categories/Support.agda", "max_issues_count": 19, "max_issues_repo_head_hexsha": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2", "max_issues_repo_issues_event_max_datetime": "2019-08-09T16:31:40.000Z", "max_issues_repo_issues_event_min_datetime": "2015-05-23T06:47:10.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "p-pavel/categories", "max_issues_repo_path": "Categories/Support.agda", "max_line_length": 256, "max_stars_count": 98, "max_stars_repo_head_hexsha": "36f4181d751e2ecb54db219911d8c69afe8ba892", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "copumpkin/categories", "max_stars_repo_path": "Categories/Support.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-08T05:20:36.000Z", "max_stars_repo_stars_event_min_datetime": "2015-04-15T14:57:33.000Z", "num_tokens": 6919, "size": 14138 }
{-# OPTIONS --without-K --safe #-} open import Algebra module Data.FingerTree.Cons {r m} (ℳ : Monoid r m) where open import Data.Product open import Data.FingerTree.Measures ℳ open import Data.FingerTree.Structures ℳ open import Data.FingerTree.Reasoning ℳ open σ ⦃ ... ⦄ open Monoid ℳ renaming (Carrier to 𝓡) infixr 5 _◂_ infixl 5 _▸_ _◂_ : ∀ {a} {Σ : Set a} ⦃ _ : σ Σ ⦄ → (x : Σ) → (xs : Tree Σ) → μ⟨ Tree Σ ⟩≈ (μ x ∙ μ xs) a ◂ empty = single a ⇑[ ℳ ↯ ] a ◂ single b = deep ⟪ D₁ a & empty & D₁ b ⇓⟫ ⇑[ ℳ ↯ ] a ◂ deep (𝓂 ↤ D₁ b & m & rs ⇑[ 𝓂≈ ]) = deep (μ a ∙ 𝓂 ↤ D₂ a b & m & rs ⇑[ assoc _ _ _ ⍮ ∙≫ 𝓂≈ ]) ⇑ a ◂ deep (𝓂 ↤ D₂ b c & m & rs ⇑[ 𝓂≈ ]) = deep (μ a ∙ 𝓂 ↤ D₃ a b c & m & rs ⇑[ assoc _ _ _ ⍮ ∙≫ 𝓂≈ ]) ⇑ a ◂ deep (𝓂 ↤ D₃ b c d & m & rs ⇑[ 𝓂≈ ]) = deep (μ a ∙ 𝓂 ↤ D₄ a b c d & m & rs ⇑[ assoc _ _ _ ⍮ ∙≫ 𝓂≈ ]) ⇑ a ◂ deep (𝓂 ↤ D₄ b c d e & m & rs ⇑[ 𝓂≈ ]) with ⟪ N₃ c d e ⇓⟫ ◂ m ... | m′ ⇑[ m′≈ ] = deep (μ a ∙ 𝓂 ↤ D₂ a b & m′ & rs ⇑[ ∙≫ ≪∙ m′≈ ] ≈[ ℳ ↯ ] ≈[ ∙≫ 𝓂≈ ]′) ⇑ _▸_ : ∀ {a} {Σ : Set a} ⦃ _ : σ Σ ⦄ → (xs : Tree Σ) → (x : Σ) → μ⟨ Tree Σ ⟩≈ (μ xs ∙ μ x) empty ▸ a = single a ⇑[ ℳ ↯ ] single a ▸ b = deep ⟪ D₁ a & empty & D₁ b ⇓⟫ ⇑[ ℳ ↯ ] deep (𝓂 ↤ ls & m & D₁ a ⇑[ 𝓂≈ ]) ▸ b = deep (𝓂 ∙ μ b ↤ ls & m & D₂ a b ⇑[ ℳ ↯ ⍮′ ≪∙ 𝓂≈ ]) ⇑ deep (𝓂 ↤ ls & m & D₂ a b ⇑[ 𝓂≈ ]) ▸ c = deep (𝓂 ∙ μ c ↤ ls & m & D₃ a b c ⇑[ ℳ ↯ ⍮′ ≪∙ 𝓂≈ ]) ⇑ deep (𝓂 ↤ ls & m & D₃ a b c ⇑[ 𝓂≈ ]) ▸ d = deep (𝓂 ∙ μ d ↤ ls & m & D₄ a b c d ⇑[ ℳ ↯ ⍮′ ≪∙ 𝓂≈ ]) ⇑ deep (𝓂 ↤ ls & m & D₄ a b c d ⇑[ 𝓂≈ ]) ▸ e with m ▸ ⟪ N₃ a b c ⇓⟫ ... | m′ ⇑[ m′≈ ] = deep (𝓂 ∙ μ e ↤ ls & m′ & D₂ d e ⇑[ ∙≫ ≪∙ m′≈ ] ≈[ ℳ ↯ ] ≈[ ≪∙ 𝓂≈ ]′) ⇑ open import Data.List as List using (List; _∷_; []) listToTree : ∀ {a} {Σ : Set a} ⦃ _ : σ Σ ⦄ → (xs : List Σ) → μ⟨ Tree Σ ⟩≈ (μ xs) listToTree [] = empty ⇑ listToTree (x ∷ xs) = [ ℳ ↯ ]≈ do ys ← listToTree xs [ μ x ∙> s ⟿ s ] x ◂ ys
{ "alphanum_fraction": 0.4279661017, "avg_line_length": 39.3333333333, "ext": "agda", "hexsha": "b136681a5b999760985f16c38a27c5c03555b3d8", "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": "39c3d96937384b052b782ffddf4fdec68c5d139f", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "oisdk/agda-indexed-fingertree", "max_forks_repo_path": "src/Data/FingerTree/Cons.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "39c3d96937384b052b782ffddf4fdec68c5d139f", "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-indexed-fingertree", "max_issues_repo_path": "src/Data/FingerTree/Cons.agda", "max_line_length": 108, "max_stars_count": 1, "max_stars_repo_head_hexsha": "39c3d96937384b052b782ffddf4fdec68c5d139f", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "oisdk/agda-indexed-fingertree", "max_stars_repo_path": "src/Data/FingerTree/Cons.agda", "max_stars_repo_stars_event_max_datetime": "2019-02-26T07:04:54.000Z", "max_stars_repo_stars_event_min_datetime": "2019-02-26T07:04:54.000Z", "num_tokens": 1135, "size": 1888 }
-- Check that we can solve level inequalities involving three variables. module _ where open import Agda.Primitive open import Agda.Builtin.Equality data Constraint : Set where mkConstraint : (a b : Level) → a ≡ b → Constraint infix 0 _:=_ pattern _:=_ x y = mkConstraint x y refl postulate l : Level mutual-block : Set a b c : Level a = _ b = _ c = _ _ = a := a ⊔ b ⊔ c _ = b := a ⊔ b ⊔ c _ = c := a ⊔ b ⊔ c _ = l := a ⊔ b ⊔ c -- to actually solve it mutual-block = Level
{ "alphanum_fraction": 0.6344969199, "avg_line_length": 16.2333333333, "ext": "agda", "hexsha": "00849f6bb6fcfb3c32b53c89fe8e4b4413fc39bd", "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/LevelTriplets.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/LevelTriplets.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/Succeed/LevelTriplets.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": 164, "size": 487 }
{-# OPTIONS --without-K --safe #-} module Categories.Category.Instance.Posets where -- The category of partially ordered sets and order-preserving maps. open import Level open import Relation.Binary using (Poset; IsEquivalence; _Preserves_⟶_) open import Relation.Binary.Morphism using (IsOrderHomomorphism) open import Relation.Binary.Morphism.Bundles using (PosetHomomorphism) import Relation.Binary.Morphism.Construct.Identity as Id import Relation.Binary.Morphism.Construct.Composition as Comp open import Categories.Category open Poset renaming (_≈_ to ₍_₎_≈_; _≤_ to ₍_₎_≤_) open PosetHomomorphism using (⟦_⟧; cong) private variable a₁ a₂ a₃ b₁ b₂ b₃ : Level A B C : Poset a₁ a₂ a₃ module _ {A : Poset a₁ a₂ a₃} {B : Poset b₁ b₂ b₃} where infix 4 _≗_ -- Pointwise equality (on order preserving maps). _≗_ : (f g : PosetHomomorphism A B) → Set (a₁ ⊔ b₂) f ≗ g = ∀ {x} → ₍ B ₎ ⟦ f ⟧ x ≈ ⟦ g ⟧ x ≗-isEquivalence : IsEquivalence _≗_ ≗-isEquivalence = record { refl = Eq.refl B ; sym = λ f≈g → Eq.sym B f≈g ; trans = λ f≈g g≈h → Eq.trans B f≈g g≈h } module ≗ = IsEquivalence ≗-isEquivalence -- The category of posets and order-preserving maps. Posets : ∀ c ℓ₁ ℓ₂ → Category (suc (c ⊔ ℓ₁ ⊔ ℓ₂)) (c ⊔ ℓ₁ ⊔ ℓ₂) (c ⊔ ℓ₁) Posets c ℓ₁ ℓ₂ = record { Obj = Poset c ℓ₁ ℓ₂ ; _⇒_ = PosetHomomorphism ; _≈_ = _≗_ ; id = λ {A} → Id.posetHomomorphism A ; _∘_ = λ f g → Comp.posetHomomorphism g f ; assoc = λ {_ _ _ D} → Eq.refl D ; sym-assoc = λ {_ _ _ D} → Eq.refl D ; identityˡ = λ {_ B} → Eq.refl B ; identityʳ = λ {_ B} → Eq.refl B ; identity² = λ {A} → Eq.refl A ; equiv = ≗-isEquivalence ; ∘-resp-≈ = λ {_ _ C _ h} f≈h g≈i → Eq.trans C f≈h (cong h g≈i) }
{ "alphanum_fraction": 0.6283783784, "avg_line_length": 30.6206896552, "ext": "agda", "hexsha": "3bf4e753f45908252a465c932caf58d22388b59a", "lang": "Agda", "max_forks_count": 64, "max_forks_repo_forks_event_max_datetime": "2022-03-14T02:00:59.000Z", "max_forks_repo_forks_event_min_datetime": "2019-06-02T16:58:15.000Z", "max_forks_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Code-distancing/agda-categories", "max_forks_repo_path": "src/Categories/Category/Instance/Posets.agda", "max_issues_count": 236, "max_issues_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_issues_repo_issues_event_max_datetime": "2022-03-28T14:31:43.000Z", "max_issues_repo_issues_event_min_datetime": "2019-06-01T14:53:54.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Code-distancing/agda-categories", "max_issues_repo_path": "src/Categories/Category/Instance/Posets.agda", "max_line_length": 72, "max_stars_count": 279, "max_stars_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Trebor-Huang/agda-categories", "max_stars_repo_path": "src/Categories/Category/Instance/Posets.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-22T00:40:14.000Z", "max_stars_repo_stars_event_min_datetime": "2019-06-01T14:36:40.000Z", "num_tokens": 701, "size": 1776 }
{-# OPTIONS --without-K #-} open import Type open import Data.Zero open import Data.Fin using (Fin; zero; suc; #_) open import Relation.Binary.PropositionalEquality.NP using (_≡_; refl) open import HoTT open Equivalences open import Explore.Core open import Explore.Properties open import Explore.Explorable open import Explore.Universe.Type {𝟘} open import Explore.Universe.Base module Explore.Dice where data Dice : ★₀ where ⚀ ⚁ ⚂ ⚃ ⚄ ⚅ : Dice module ByHand where exploreDice : ∀ {m} → Explore m Dice exploreDice ε _∙_ f = f ⚀ ∙ (f ⚁ ∙ (f ⚂ ∙ (f ⚃ ∙ (f ⚄ ∙ f ⚅)))) exploreDice-ind : ∀ {m p} → ExploreInd p (exploreDice {m}) exploreDice-ind P ε _∙_ f = f ⚀ ∙ (f ⚁ ∙ (f ⚂ ∙ (f ⚃ ∙ (f ⚄ ∙ f ⚅)))) open FromExploreInd exploreDice-ind public using () renaming (sum to sumDice; product to productDice; reify to reifyDice; unfocus to unfocusDice) Dice≃Fin6 : Dice ≃ Fin 6 Dice≃Fin6 = equiv (⇒) (⇐) ⇒⇐ ⇐⇒ module Dice≃Fin6 where S = Dice T = Fin 6 ⇒ : S → T ⇒ ⚀ = # 0 ⇒ ⚁ = # 1 ⇒ ⚂ = # 2 ⇒ ⚃ = # 3 ⇒ ⚄ = # 4 ⇒ ⚅ = # 5 ⇐ : T → S ⇐ zero = ⚀ ⇐ (suc zero) = ⚁ ⇐ (suc (suc zero)) = ⚂ ⇐ (suc (suc (suc zero))) = ⚃ ⇐ (suc (suc (suc (suc zero)))) = ⚄ ⇐ (suc (suc (suc (suc (suc zero))))) = ⚅ ⇐ (suc (suc (suc (suc (suc (suc ())))))) ⇐⇒ : ∀ x → ⇐ (⇒ x) ≡ x ⇐⇒ ⚀ = refl ⇐⇒ ⚁ = refl ⇐⇒ ⚂ = refl ⇐⇒ ⚃ = refl ⇐⇒ ⚄ = refl ⇐⇒ ⚅ = refl ⇒⇐ : ∀ x → ⇒ (⇐ x) ≡ x ⇒⇐ zero = refl ⇒⇐ (suc zero) = refl ⇒⇐ (suc (suc zero)) = refl ⇒⇐ (suc (suc (suc zero))) = refl ⇒⇐ (suc (suc (suc (suc zero)))) = refl ⇒⇐ (suc (suc (suc (suc (suc zero))))) = refl ⇒⇐ (suc (suc (suc (suc (suc (suc ())))))) -- By using FinU' instead of FinU one get a special case for Fin 1 thus avoiding -- a final ε in the exploration function. module DiceE = Explore.Universe.Base (≃ᵁ (Finᵁ' 6) Dice (Finᵁ'≃Fin 6 ≃-∙ ≃-! Dice≃Fin6)) module _ {m} where open ByHand _≡ᵉ_ : (e₀ e₁ : Explore m Dice) → ★_ _ _≡ᵉ_ = _≡_ same-as-by-hand : exploreDice ≡ᵉ DiceE.explore same-as-by-hand = refl
{ "alphanum_fraction": 0.5377672209, "avg_line_length": 26.9871794872, "ext": "agda", "hexsha": "8015a0d4f3678884951b2771539cfe376fa71235", "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": "16bc8333503ff9c00d47d56f4ec6113b9269a43e", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "crypto-agda/explore", "max_forks_repo_path": "lib/Explore/Dice.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "16bc8333503ff9c00d47d56f4ec6113b9269a43e", "max_issues_repo_issues_event_max_datetime": "2019-03-16T14:24:04.000Z", "max_issues_repo_issues_event_min_datetime": "2019-03-16T14:24:04.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "crypto-agda/explore", "max_issues_repo_path": "lib/Explore/Dice.agda", "max_line_length": 99, "max_stars_count": 2, "max_stars_repo_head_hexsha": "16bc8333503ff9c00d47d56f4ec6113b9269a43e", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "crypto-agda/explore", "max_stars_repo_path": "lib/Explore/Dice.agda", "max_stars_repo_stars_event_max_datetime": "2017-06-28T19:19:29.000Z", "max_stars_repo_stars_event_min_datetime": "2016-06-05T09:25:32.000Z", "num_tokens": 971, "size": 2105 }
------------------------------------------------------------------------------ -- First-order Peano arithmetic ------------------------------------------------------------------------------ {-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} module PA.README where ------------------------------------------------------------------------------ -- Description -- Two formalizations of first-order Peano arithmetic using axioms and -- inductive definitions. ------------------------------------------------------------------------------ -- Axiomatic PA open import PA.Axiomatic.Standard.README -- Inductive PA open import PA.Inductive.README
{ "alphanum_fraction": 0.3877284595, "avg_line_length": 31.9166666667, "ext": "agda", "hexsha": "d713d623205320d53aaf15fd13704b505d0f851c", "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/PA/README.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/PA/README.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/PA/README.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": 106, "size": 766 }
module Issue3879 where open import Issue3879.Fin using (Fin ; zero ; suc) open import Agda.Builtin.Nat using (Nat ; zero ; suc) foo : Nat → Nat → Nat foo zero m = {!!} foo (suc n) m = {!!} -- WAS: case-splitting on m produces Issue3879.Fin.0F patterns -- WANT: unqualified 0F is not in scope: do not resugar!
{ "alphanum_fraction": 0.6793650794, "avg_line_length": 26.25, "ext": "agda", "hexsha": "f2d296cec1042f2615a57d0f53af07b3f248bc21", "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/Issue3879.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/Issue3879.agda", "max_line_length": 62, "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/Issue3879.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": 99, "size": 315 }
---------------------------------------------------------------------------- -- Well-founded induction on the natural numbers ---------------------------------------------------------------------------- {-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} module FOTC.Data.Nat.Induction.NonAcc.WF-I where open import FOTC.Base open import FOTC.Data.Nat.Inequalities open import FOTC.Data.Nat.Inequalities.EliminationPropertiesI open import FOTC.Data.Nat.Inequalities.PropertiesI open import FOTC.Data.Nat.Type ------------------------------------------------------------------------------ -- Well-founded induction on the natural numbers. -- Adapted from http://code.haskell.org/~dolio/agda-share/induction/. module WFInd where <-wfind : (A : D → Set) → (∀ {n} → N n → (∀ {m} → N m → m < n → A m) → A n) → ∀ {n} → N n → A n <-wfind A h Nn = h Nn (helper Nn) where helper : ∀ {n m} → N n → N m → m < n → A m helper nzero Nm m<0 = ⊥-elim (x<0→⊥ Nm m<0) helper (nsucc _) nzero 0<Sn = h nzero (λ Nm' m'<0 → ⊥-elim (x<0→⊥ Nm' m'<0)) helper (nsucc {n} Nn) (nsucc {m} Nm) Sm<Sn = h (nsucc Nm) (λ {m'} Nm' m'<Sm → let Sm'≤Sm : succ₁ m' ≤ succ₁ m Sm'≤Sm = x<y→Sx≤y Nm' (nsucc Nm) m'<Sm Sm≤n : succ₁ m ≤ n Sm≤n = Sx≤Sy→x≤y (x<y→Sx≤y (nsucc Nm) (nsucc Nn) Sm<Sn) Sm'≤n : succ₁ m' ≤ n Sm'≤n = ≤-trans (nsucc Nm') (nsucc Nm) Nn Sm'≤Sm Sm≤n m'<n : m' < n m'<n = Sx≤y→x<y Nm' Nn Sm'≤n in helper Nn Nm' m'<n ) ------------------------------------------------------------------------------ -- Well-founded induction on the natural numbers (using different -- properties of inequalities). module WFInd' where <-wfind : (A : D → Set) → (∀ {n} → N n → (∀ {m} → N m → m < n → A m) → A n) → ∀ {n} → N n → A n <-wfind A h Nn = h Nn (helper Nn) where helper : ∀ {n m} → N n → N m → m < n → A m helper nzero Nm m<0 = ⊥-elim (x<0→⊥ Nm m<0) helper (nsucc _) nzero 0<Sn = h nzero (λ Nm' m'<0 → ⊥-elim (x<0→⊥ Nm' m'<0)) helper (nsucc {n} Nn) (nsucc {m} Nm) Sm<Sn = h (nsucc Nm) (λ {m'} Nm' m'<Sm → let m<n : m < n m<n = Sx<Sy→x<y Sm<Sn m'<n : m' < n m'<n = case (λ m'<m → <-trans Nm' Nm Nn m'<m m<n) (λ m'≡m → x≡y→y<z→x<z m'≡m m<n) (x<Sy→x<y∨x≡y Nm' Nm m'<Sm) in helper Nn Nm' m'<n )
{ "alphanum_fraction": 0.4291698401, "avg_line_length": 35.0133333333, "ext": "agda", "hexsha": "bb2c11cfcae64916ef37002848a7f56146abc398", "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/Data/Nat/Induction/NonAcc/WF-I.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/Data/Nat/Induction/NonAcc/WF-I.agda", "max_line_length": 80, "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/Data/Nat/Induction/NonAcc/WF-I.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": 943, "size": 2626 }
module L.Base.Coproduct.Core where open import Agda.Primitive -- Introducing Coproduct types data _+_ {a b} (A : Set a) (B : Set b) : Set (a ⊔ b) where inl : A → A + B inr : B → A + B case : ∀{a b c} {A : Set a} {B : Set b} → (C : A + B → Set c) → ((x : A) → C (inl x)) → ((y : B) → C (inr y)) → (e : A + B) → C e case C c d (inl a) = c a case C c d (inr b) = d b
{ "alphanum_fraction": 0.4732824427, "avg_line_length": 23.1176470588, "ext": "agda", "hexsha": "c847c78ea9fb042d975cfc04666e50bfe16e1474", "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": "83707537b182ba8906228ac0bcb9ccef972eaaa3", "max_forks_repo_licenses": [ "BSD-2-Clause" ], "max_forks_repo_name": "borszag/smallib", "max_forks_repo_path": "src/L/Base/Coproduct/Core.agda", "max_issues_count": 10, "max_issues_repo_head_hexsha": "83707537b182ba8906228ac0bcb9ccef972eaaa3", "max_issues_repo_issues_event_max_datetime": "2020-11-09T16:40:39.000Z", "max_issues_repo_issues_event_min_datetime": "2020-10-19T10:13:16.000Z", "max_issues_repo_licenses": [ "BSD-2-Clause" ], "max_issues_repo_name": "borszag/smallib", "max_issues_repo_path": "src/L/Base/Coproduct/Core.agda", "max_line_length": 58, "max_stars_count": null, "max_stars_repo_head_hexsha": "83707537b182ba8906228ac0bcb9ccef972eaaa3", "max_stars_repo_licenses": [ "BSD-2-Clause" ], "max_stars_repo_name": "borszag/smallib", "max_stars_repo_path": "src/L/Base/Coproduct/Core.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 171, "size": 393 }
{-# OPTIONS --cubical-compatible --rewriting #-} module Generalize where open import Agda.Primitive -- Generalization in definitions module Definitions where variable ℓ : Level A B C : Set ℓ A₀ B₀ : Set a b c : A -- Function signature id : A → A id x = x -- Module signature module M (a : A) where identity = a -- Data parameters and constructors data Eq (a : A) : A → Setω where refl : Eq a a trans : Eq a b → Eq b c → Eq a c record R (a : A) : Set₁ where field fld : B₀ open M a alias = fld K : B → C → B K x _ = x field fld₁ : B₀ -- Original content (postulates only) data _≡_ {ℓ}{A : Set ℓ} (x : A) : A → Set ℓ where refl : x ≡ x infix 4 _≡_ {-# BUILTIN REWRITE _≡_ #-} ------------------------------------------------------------------ postulate Con : Set postulate Ty : (Γ : Con) → Set postulate Tms : (Γ Δ : Con) → Set postulate Tm : (Γ : Con)(A : Ty Γ) → Set ------------------------------------------------------------------ variable {Γ Δ Θ} : Con postulate • : Con -- • is \bub postulate _▹_ : ∀ Γ → Ty Γ → Con -- ▹ is \tw2 infixl 5 _▹_ variable {A B C} : Ty _ postulate _∘ᵀ_ : Ty Δ → Tms Γ Δ → Ty Γ infixl 6 _∘ᵀ_ variable {σ δ ν} : Tms _ _ postulate _∘_ : Tms Θ Δ → Tms Γ Θ → Tms Γ Δ infixr 7 _∘_ postulate id : Tms Γ Γ postulate ε : Tms Γ • postulate _,_ : (σ : Tms Γ Δ) → Tm Γ (A ∘ᵀ σ) → Tms Γ (Δ ▹ A) infixl 5 _,_ postulate π₁ : Tms Γ (Δ ▹ A) → Tms Γ Δ variable {t u v} : Tm _ _ postulate π₂ : (σ : Tms Γ (Δ ▹ A)) → Tm Γ (A ∘ᵀ π₁ σ) postulate _∘ᵗ_ : Tm Δ A → (σ : Tms Γ Δ) → Tm Γ (A ∘ᵀ σ) infixl 6 _∘ᵗ_ postulate ass : (σ ∘ δ) ∘ ν ≡ σ ∘ δ ∘ ν {-# REWRITE ass #-} postulate idl : id ∘ δ ≡ δ {-# REWRITE idl #-} postulate idr : δ ∘ id ≡ δ {-# REWRITE idr #-} postulate εη : δ ≡ ε -- can't rewrite, so we specialize this in the next two cases postulate εηid : id ≡ ε {-# REWRITE εηid #-} postulate εη∘ : ε ∘ δ ≡ ε {-# REWRITE εη∘ #-} postulate ,β₁ : π₁ (δ , t) ≡ δ {-# REWRITE ,β₁ #-} postulate ,β₂ : π₂ (δ , t) ≡ t {-# REWRITE ,β₂ #-} postulate ,η : (π₁ δ , π₂ δ) ≡ δ {-# REWRITE ,η #-} postulate [id]ᵀ : A ∘ᵀ id ≡ A {-# REWRITE [id]ᵀ #-} postulate [∘]ᵀ : A ∘ᵀ δ ∘ᵀ σ ≡ A ∘ᵀ δ ∘ σ {-# REWRITE [∘]ᵀ #-} postulate ,∘ : (δ , t) ∘ σ ≡ δ ∘ σ , t ∘ᵗ σ {-# REWRITE ,∘ #-} postulate [∘]ᵗ : t ∘ᵗ σ ∘ᵗ δ ≡ t ∘ᵗ σ ∘ δ {-# REWRITE [∘]ᵗ #-} postulate π₁∘ : π₁ δ ∘ σ ≡ π₁ (δ ∘ σ) {-# REWRITE π₁∘ #-} postulate π₂∘ : π₂ δ ∘ᵗ σ ≡ π₂ (δ ∘ σ) {-# REWRITE π₂∘ #-} postulate ∘id : t ∘ᵗ id ≡ t {-# REWRITE ∘id #-} _↑_ : ∀ σ A → Tms (Γ ▹ A ∘ᵀ σ) (Δ ▹ A) σ ↑ A = σ ∘ π₁ id , π₂ id ⟨_⟩ : Tm Γ A → Tms Γ (Γ ▹ A) ⟨ t ⟩ = id , t ------------------------------------------------------------------ postulate U : Ty Γ variable {a b c} : Tm _ U postulate El : Tm Γ U → Ty Γ postulate U[] : U ∘ᵀ σ ≡ U {-# REWRITE U[] #-} postulate El[] : El a ∘ᵀ σ ≡ El (a ∘ᵗ σ) {-# REWRITE El[] #-} ------------------------------------------------------------------ postulate Π : (a : Tm Γ U) → Ty (Γ ▹ El a) → Ty Γ postulate Π[] : Π a B ∘ᵀ σ ≡ Π (a ∘ᵗ σ) (B ∘ᵀ σ ↑ El a) {-# REWRITE Π[] #-} postulate app : Tm Γ (Π a B) → Tm (Γ ▹ El a) B postulate app[] : app t ∘ᵗ (σ ↑ El a) ≡ app (t ∘ᵗ σ) {-# REWRITE app[] #-}
{ "alphanum_fraction": 0.4084915612, "avg_line_length": 26.3333333333, "ext": "agda", "hexsha": "3230b9d8230f3af9b94bf11a41102a2abf88dfcd", "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/Generalize.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/Generalize.agda", "max_line_length": 102, "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/Generalize.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1511, "size": 3792 }
open import Relation.Binary.PropositionalEquality using ( _≡_ ; refl ; sym ; trans ; subst ; subst₂ ; cong ; cong₂ ) import AssocFree.STLambdaC.Typ import AssocFree.STLambdaC.Exp import AssocFree.STLambdaC.NF module AssocFree.STLambdaC.Redn (TConst : Set) (Const : AssocFree.STLambdaC.Typ.Typ TConst → Set) where open module Typ = AssocFree.STLambdaC.Typ TConst using ( Typ ; Ctxt ; const ; _⇝_ ; [_] ; [] ; _∷_ ; _++_ ; case ) open module Exp = AssocFree.STLambdaC.Exp TConst Const using ( Exp ; const ; abs ; app ; var ; var₀ ; substn ; weaken ; weaken* ; weaken+ ; weaken-comm ; weaken-substn ; weaken+-var₀ ) open module Redn = AssocFree.STLambdaC.NF TConst Const using ( NF ; Atom ; app ; abs ) -- Small-step reduction data _⇒_ {Γ} : ∀ {T : Typ} → Exp Γ T → Exp Γ T → Set where beta : ∀ {T U} (M : Exp (T ∷ Γ) U) (N : Exp Γ T) → (app (abs {Γ} T M) N) ⇒ substn N M eta : ∀ {T U} (M : Exp Γ (T ⇝ U)) → (M ⇒ (abs {Γ} T (app (weaken T M) (var₀ {Γ})))) lhs : ∀ {T U} {L M : Exp Γ (T ⇝ U)} {N : Exp Γ T} → (L ⇒ M) → (app L N ⇒ app M N) rhs : ∀ {T U} {L : Exp Γ (T ⇝ U)} {M N : Exp Γ T} → (M ⇒ N) → (app L M ⇒ app L N) abs : ∀ T {U} {M N : Exp (T ∷ Γ) U} → (M ⇒ N) → (abs {Γ} T M ⇒ abs {Γ} T N) -- Reduction to normal form data _⇓ {Γ T} (M : Exp Γ T) : Set where nf : NF M → (M ⇓) redn : ∀ {N} → (M ⇒ N) → (N ⇓) → (M ⇓) -- Reduction to atomic form data _⇓′ {Γ T} (M : Exp Γ T) : Set where atom : Atom M → (M ⇓′) redn : ∀ {N} → (M ⇒ N) → (N ⇓′) → (M ⇓′) -- Target of normalization tgt : ∀ {Γ T} {M : Exp Γ T} → (M ⇓) → Exp Γ T tgt {Γ} {T} {M} (nf M⇓) = M tgt (redn M⇒N N⇓) = tgt N⇓ -- Normalization is closed under abstraction and application ⇓abs : ∀ {Γ} T {U} {M : Exp (T ∷ Γ) U} → (M ⇓) → (abs {Γ} T M ⇓) ⇓abs {Γ} T (nf M) = nf (abs {Γ} T M) ⇓abs {Γ} T (redn M⇒N N⇓) = redn (abs T M⇒N) (⇓abs {Γ} T N⇓) ⇓app : ∀ {Γ T U} {M : Exp Γ (T ⇝ U)} {N : Exp Γ T} → (M ⇓′) → (N ⇓) → (app M N ⇓′) ⇓app (atom M) (nf N) = atom (app M N) ⇓app (atom L) (redn L⇒M M⇓) = redn (rhs L⇒M) (⇓app (atom L) M⇓) ⇓app (redn L⇒M M⇓) N⇓ = redn (lhs L⇒M) (⇓app M⇓ N⇓) -- Weakening rweaken+ : ∀ B Γ Δ {T} {M N : Exp (B ++ Δ) T} → (M ⇒ N) → (weaken+ B Γ Δ M ⇒ weaken+ B Γ Δ N) rweaken+ B Γ Δ (beta {T} M N) = subst (λ X → weaken+ B Γ Δ (app (abs {B ++ Δ} T M) N) ⇒ X) (weaken-substn B Γ Δ N M) (beta (weaken+ (T ∷ B) Γ Δ M) (weaken+ B Γ Δ N)) rweaken+ B Γ Δ (eta {T} M) = subst₂ (λ X Y → weaken+ B Γ Δ M ⇒ abs T (app X Y)) (weaken-comm T B Γ Δ M) (sym (weaken+-var₀ B Γ Δ)) (eta (weaken+ B Γ Δ M)) rweaken+ B Γ Δ (lhs M⇒N) = lhs (rweaken+ B Γ Δ M⇒N) rweaken+ B Γ Δ (rhs M⇒N) = rhs (rweaken+ B Γ Δ M⇒N) rweaken+ B Γ Δ (abs T M⇒N) = abs T (rweaken+ (T ∷ B) Γ Δ M⇒N) rweaken* : ∀ Γ {Δ T} {M N : Exp Δ T} → (M ⇒ N) → (weaken* Γ M ⇒ weaken* Γ N) rweaken* Γ {Δ} = rweaken+ [] Γ Δ rweaken : ∀ T {Δ U} {M N : Exp Δ U} → (M ⇒ N) → (weaken T M ⇒ weaken T N) rweaken T = rweaken* [ T ]
{ "alphanum_fraction": 0.5100133511, "avg_line_length": 35.2470588235, "ext": "agda", "hexsha": "bfd5ae18d22b8f2588a13ee0dc1944bae2545b6f", "lang": "Agda", "max_forks_count": 2, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:38:44.000Z", "max_forks_repo_forks_event_min_datetime": "2018-03-03T04:39:31.000Z", "max_forks_repo_head_hexsha": "08337fdb8375137a52cc9b3ade766305191b2394", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "agda/agda-assoc-free", "max_forks_repo_path": "src/AssocFree/STLambdaC/Redn.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "08337fdb8375137a52cc9b3ade766305191b2394", "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/agda-assoc-free", "max_issues_repo_path": "src/AssocFree/STLambdaC/Redn.agda", "max_line_length": 93, "max_stars_count": 3, "max_stars_repo_head_hexsha": "08337fdb8375137a52cc9b3ade766305191b2394", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "agda/agda-assoc-free", "max_stars_repo_path": "src/AssocFree/STLambdaC/Redn.agda", "max_stars_repo_stars_event_max_datetime": "2020-08-27T20:56:20.000Z", "max_stars_repo_stars_event_min_datetime": "2016-11-22T11:48:31.000Z", "num_tokens": 1412, "size": 2996 }
module ModuleDefinedInOtherFile where import Imports.B
{ "alphanum_fraction": 0.8448275862, "avg_line_length": 9.6666666667, "ext": "agda", "hexsha": "f84546622d7f7e68d6d2d219c6e8adf05e1af31d", "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/ModuleDefinedInOtherFile.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/ModuleDefinedInOtherFile.agda", "max_line_length": 37, "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/ModuleDefinedInOtherFile.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": 13, "size": 58 }
module Issue530 where data Unit : Set where unit : Unit postulate A : Set a : A k : A → Unit data P (a : A) : Unit → Set where p : P a (k a) F : (u : Unit) → P a u → Set₁ F unit _ = Set f : F (k a) p f with k a f | _ = ?
{ "alphanum_fraction": 0.5254237288, "avg_line_length": 11.8, "ext": "agda", "hexsha": "ffd162d917b9c5e44ffe6a783002760d0de2114c", "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/fail/Issue530.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/fail/Issue530.agda", "max_line_length": 33, "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/fail/Issue530.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": 99, "size": 236 }
-- WARNING: This file was generated automatically by Vehicle -- and should not be modified manually! -- Metadata -- - Agda version: 2.6.2 -- - AISEC version: 0.1.0.1 -- - Time generated: ??? {-# OPTIONS --allow-exec #-} open import Vehicle open import Vehicle.Data.Tensor open import Data.Product open import Data.Integer as ℤ using (ℤ) open import Data.Rational as ℚ using (ℚ) open import Data.Fin as Fin using (Fin; #_) open import Data.List module windController-temp-output where InputVector : Set InputVector = Tensor ℚ (2 ∷ []) currentSensor : ∀ {_x0 : Set} {{_x1 : HasNatLits _x0}} → _x0 currentSensor = 0 previousSensor : ∀ {_x4 : Set} {{_x5 : HasNatLits _x4}} → _x4 previousSensor = 1 postulate controller : InputVector → Tensor ℚ (1 ∷ []) SafeInput : InputVector → Set SafeInput x = ∀ (i : Fin 2) → ℚ.- (ℤ.+ 13 ℚ./ 4) ℚ.≤ x i × x i ℚ.≤ ℤ.+ 13 ℚ./ 4 SafeOutput : InputVector → Set SafeOutput x = ℚ.- (ℤ.+ 5 ℚ./ 4) ℚ.< (controller x (# 0) ℚ.+ (ℤ.+ 2 ℚ./ 1) ℚ.* x currentSensor) ℚ.- x previousSensor × (controller x (# 0) ℚ.+ (ℤ.+ 2 ℚ./ 1) ℚ.* x currentSensor) ℚ.- x previousSensor ℚ.< ℤ.+ 5 ℚ./ 4 abstract safe : ∀ (x : Tensor ℚ (2 ∷ [])) → SafeInput x → SafeOutput x safe = checkSpecification record { proofCache = "/home/matthew/Code/AISEC/vehicle/proofcache.vclp" }
{ "alphanum_fraction": 0.6531082118, "avg_line_length": 31.7804878049, "ext": "agda", "hexsha": "6b7225766336ddab29b55ea33b9eebb24b4b91a1", "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": "25842faea65b4f7f0f7b1bb11ea6e4bf3f4a59b0", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "vehicle-lang/vehicle", "max_forks_repo_path": "test/Test/Compile/Golden/windController/windController-output.agda", "max_issues_count": 19, "max_issues_repo_head_hexsha": "25842faea65b4f7f0f7b1bb11ea6e4bf3f4a59b0", "max_issues_repo_issues_event_max_datetime": "2022-03-31T20:49:39.000Z", "max_issues_repo_issues_event_min_datetime": "2022-03-07T14:09:13.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "vehicle-lang/vehicle", "max_issues_repo_path": "test/Test/Compile/Golden/windController/windController-output.agda", "max_line_length": 214, "max_stars_count": 9, "max_stars_repo_head_hexsha": "25842faea65b4f7f0f7b1bb11ea6e4bf3f4a59b0", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "vehicle-lang/vehicle", "max_stars_repo_path": "test/Test/Compile/Golden/windController/windController-output.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-17T18:51:05.000Z", "max_stars_repo_stars_event_min_datetime": "2022-02-10T12:56:42.000Z", "num_tokens": 468, "size": 1303 }
{-# OPTIONS --cubical-compatible #-} module Issue765 where infixr 1 _⊎_ infixr 4 _,_ infix 4 _≡_ data ⊥ : Set where ⊥-elim : {A : Set} → ⊥ → A ⊥-elim () data _≡_ {A : Set} (x : A) : A → Set where refl : x ≡ x data _⊎_ (A : Set) (B : Set) : Set where inj₁ : (x : A) → A ⊎ B inj₂ : (y : B) → A ⊎ B [_,_]₁ : ∀ {A : Set} {B : Set} {C : A ⊎ B → Set₁} → ((x : A) → C (inj₁ x)) → ((x : B) → C (inj₂ x)) → ((x : A ⊎ B) → C x) [ f , g ]₁ (inj₁ x) = f x [ f , g ]₁ (inj₂ y) = g y record Σ (A : Set) (B : A → Set) : Set where constructor _,_ field proj₁ : A proj₂ : B proj₁ open Σ public infix 5 _◃_ infixr 1 _⊎C_ record Container : Set₁ where constructor _◃_ field Shape : Set Position : Shape → Set open Container public constC : Set → Container constC X = X ◃ λ _ → ⊥ _⊎C_ : Container → Container → Container S ◃ P ⊎C S′ ◃ P′ = (S ⊎ S′) ◃ [ P , P′ ]₁ data μ (C : Container) : Set where sup : (s : Shape C) (k : Position C s → μ C) → μ C _⋆_ : Container → Set → Set C ⋆ X = μ (constC X ⊎C C) to : ∀ {C X} → C ⋆ X → C ⋆ (C ⋆ X) to m = sup (inj₁ m) ⊥-elim injective : ∀ {C X}{m n : C ⋆ X} → to m ≡ to n → m ≡ n injective refl = refl
{ "alphanum_fraction": 0.5025125628, "avg_line_length": 18.65625, "ext": "agda", "hexsha": "8fe07abc587ec417d6039c7d111e41a2482492f8", "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/Fail/Issue765.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/Fail/Issue765.agda", "max_line_length": 57, "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/Fail/Issue765.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 551, "size": 1194 }
------------------------------------------------------------------------------ -- The unary numbers are FOTC total natural numbers ------------------------------------------------------------------------------ {-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} module FOTC.Data.Nat.UnaryNumbers.TotalityI where open import FOTC.Base open import FOTC.Data.Nat.Type open import FOTC.Data.Nat.UnaryNumbers ------------------------------------------------------------------------------ 0-N : N 0' 0-N = nzero 1-N : N 1' 1-N = nsucc 0-N 2-N : N 2' 2-N = nsucc 1-N
{ "alphanum_fraction": 0.403202329, "avg_line_length": 26.4230769231, "ext": "agda", "hexsha": "c0cb2f21b055ab371d56b2ca172d815b42c3c8da", "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/Data/Nat/UnaryNumbers/TotalityI.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/Data/Nat/UnaryNumbers/TotalityI.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/Data/Nat/UnaryNumbers/TotalityI.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": 139, "size": 687 }
open import Agda.Builtin.Bool open import Agda.Builtin.Nat open import Agda.Builtin.Equality _^_ : Nat → Nat → Nat x ^ zero = 1 x ^ suc y = x * (x ^ y) data Enum : Set where makeEnum : (size : Nat) → (variants : Nat) → .{{ _ : (variants < size) ≡ true }} → Enum five : Enum five = makeEnum (2 ^ 32) 5 data Expr : (t : Enum) → Set where constant : (x : Nat) → Expr five func : ∀ {t} → Expr t → Bool func (constant x) = false
{ "alphanum_fraction": 0.5883668904, "avg_line_length": 20.3181818182, "ext": "agda", "hexsha": "8a371b665d4c820afcc7ffc9a9424f0587bc1fdd", "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/Issue3554.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/Issue3554.agda", "max_line_length": 55, "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/Issue3554.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": 156, "size": 447 }
{-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.Categories.Functor where open import Cubical.Foundations.Prelude open import Cubical.Data.Sigma open import Cubical.Categories.Category private variable ℓC ℓC' ℓD ℓD' : Level record Functor (C : Precategory ℓC ℓC') (D : Precategory ℓD ℓD') : Type (ℓ-max (ℓ-max ℓC ℓC') (ℓ-max ℓD ℓD')) where no-eta-equality open Precategory field F-ob : C .ob → D .ob F-hom : {x y : C .ob} → C [ x , y ] → D [(F-ob x) , (F-ob y)] F-id : {x : C .ob} → F-hom (C .id x) ≡ D .id (F-ob x) F-seq : {x y z : C .ob} (f : C [ x , y ]) (g : C [ y , z ]) → F-hom (f ⋆⟨ C ⟩ g) ≡ (F-hom f) ⋆⟨ D ⟩ (F-hom g) isFull = (x y : _) (F[f] : D [(F-ob x) , (F-ob y)]) → ∃ (C [ x , y ]) (λ f → F-hom f ≡ F[f]) isFaithful = (x y : _) (f g : C [ x , y ]) → F-hom f ≡ F-hom g → f ≡ g -- Functor results module _ (C : Precategory ℓC ℓC') (D : Precategory ℓC ℓC') (F : Functor C D ) where open Precategory open Functor F open CatIso -- functors preserve isomorphisms preserveIsosF : ∀ {x y : C .ob} → CatIso {C = C} x y → CatIso {C = D} (F-ob x) (F-ob y) preserveIsosF {x} {y} (catiso f f⁻¹ sec' ret') = catiso g g⁻¹ -- sec ( (g⁻¹ ⋆⟨ D ⟩ g) ≡⟨ sym (F-seq f⁻¹ f) ⟩ F-hom (f⁻¹ ⋆⟨ C ⟩ f) ≡⟨ cong F-hom sec' ⟩ F-hom (C .id y) ≡⟨ F-id ⟩ D .id y' ∎ ) -- ret ( (g ⋆⟨ D ⟩ g⁻¹) ≡⟨ sym (F-seq f f⁻¹) ⟩ F-hom (f ⋆⟨ C ⟩ f⁻¹) ≡⟨ cong F-hom ret' ⟩ F-hom (C .id x) ≡⟨ F-id ⟩ D .id x' ∎ ) where x' : D .ob x' = F-ob x y' : D .ob y' = F-ob y g : D [ x' , y' ] g = F-hom f g⁻¹ : D [ y' , x' ] g⁻¹ = F-hom f⁻¹
{ "alphanum_fraction": 0.4584511023, "avg_line_length": 25.6376811594, "ext": "agda", "hexsha": "a1c53762ffdc7799e1e087ac60dd2cd867de48ff", "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": "3a9bb56260c25a6f2e9c20af8d278de0fe8d9e05", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "apabepa10/cubical", "max_forks_repo_path": "Cubical/Categories/Functor.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "3a9bb56260c25a6f2e9c20af8d278de0fe8d9e05", "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": "apabepa10/cubical", "max_issues_repo_path": "Cubical/Categories/Functor.agda", "max_line_length": 115, "max_stars_count": null, "max_stars_repo_head_hexsha": "3a9bb56260c25a6f2e9c20af8d278de0fe8d9e05", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "apabepa10/cubical", "max_stars_repo_path": "Cubical/Categories/Functor.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 807, "size": 1769 }
open import Agda.Builtin.Nat bar : Nat → Nat bar n = let _!_ : Nat → Nat → Nat x ! y = 2 * x ! y -- should give scope error in RHS in n ! n
{ "alphanum_fraction": 0.5214723926, "avg_line_length": 20.375, "ext": "agda", "hexsha": "8ca45a8d35bf9fac28ea231e5b6eb1a2db0bb073", "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/Issue917.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/Issue917.agda", "max_line_length": 64, "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/Issue917.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": 56, "size": 163 }
{-# OPTIONS --safe #-} {- Ad-hoc polymorphism -} module AdHoc where open import Data.Char as C open import Data.String as S open import Data.List as L open import Data.Integer as I open import Data.Nat as N open import Data.Bool as B open import Agda.Builtin.Nat renaming (_==_ to natEquals) record Eq {l} (A : Set l) : Set l where field _===_ : A → A → Bool open Eq ⦃ ... ⦄ public _=/=_ : ∀ {l} {A : Set l} ⦃ _ : Eq A ⦄ → A → A → Bool a =/= b = not (a === b) instance eqInt : Eq ℤ _===_ ⦃ eqInt ⦄ (+ m) (+ n) = natEquals m n _===_ ⦃ eqInt ⦄ (-[1+ m ]) (-[1+ n ]) = natEquals m n _===_ ⦃ eqInt ⦄ _ _ = false eqNat : Eq ℕ _===_ ⦃ eqNat ⦄ = natEquals eqChar : Eq Char _===_ ⦃ eqChar ⦄ = C._==_ eqBool : Eq Bool _===_ ⦃ eqBool ⦄ a b = not (a xor b) eqStr : Eq String _===_ ⦃ eqStr ⦄ = S._==_ eqList : ∀ {l} {A : Set l} ⦃ _ : Eq A ⦄ → Eq (List A) _===_ ⦃ eqList ⦄ [] [] = true _===_ ⦃ eqList ⦄ (x ∷ xs) (y ∷ ys) = (x === y) ∧ (xs === ys) _===_ ⦃ eqList ⦄ _ _ = false
{ "alphanum_fraction": 0.5261083744, "avg_line_length": 22.0652173913, "ext": "agda", "hexsha": "c130f0a6a1c31bd89f86aaa021338aabbba051ad", "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": "9576d5b76e6a868992dbe52930712ac67697bed2", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "anqurvanillapy/fpl", "max_forks_repo_path": "agda/AdHoc.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "9576d5b76e6a868992dbe52930712ac67697bed2", "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": "anqurvanillapy/fpl", "max_issues_repo_path": "agda/AdHoc.agda", "max_line_length": 62, "max_stars_count": 1, "max_stars_repo_head_hexsha": "9576d5b76e6a868992dbe52930712ac67697bed2", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "anqurvanillapy/fpl", "max_stars_repo_path": "agda/AdHoc.agda", "max_stars_repo_stars_event_max_datetime": "2019-08-24T22:47:47.000Z", "max_stars_repo_stars_event_min_datetime": "2019-08-24T22:47:47.000Z", "num_tokens": 442, "size": 1015 }
{-# OPTIONS --safe #-} module Cubical.Algebra.AbGroup.Base where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Equiv open import Cubical.Foundations.Equiv.HalfAdjoint open import Cubical.Foundations.HLevels open import Cubical.Foundations.Isomorphism open import Cubical.Foundations.Univalence open import Cubical.Foundations.Transport open import Cubical.Foundations.SIP open import Cubical.Data.Sigma open import Cubical.Data.Unit open import Cubical.Algebra.Semigroup open import Cubical.Algebra.Monoid open import Cubical.Algebra.CommMonoid open import Cubical.Algebra.Group open import Cubical.Algebra.Group.Morphisms open import Cubical.Algebra.Group.MorphismProperties open import Cubical.Algebra.Group.DirProd open import Cubical.Displayed.Base open import Cubical.Displayed.Auto open import Cubical.Displayed.Record open import Cubical.Displayed.Universe open Iso private variable ℓ ℓ' : Level record IsAbGroup {G : Type ℓ} (0g : G) (_+_ : G → G → G) (-_ : G → G) : Type ℓ where constructor isabgroup field isGroup : IsGroup 0g _+_ -_ comm : (x y : G) → x + y ≡ y + x open IsGroup isGroup public record AbGroupStr (A : Type ℓ) : Type (ℓ-suc ℓ) where constructor abgroupstr field 0g : A _+_ : A → A → A -_ : A → A isAbGroup : IsAbGroup 0g _+_ -_ infix 8 -_ infixr 7 _+_ open IsAbGroup isAbGroup public AbGroup : ∀ ℓ → Type (ℓ-suc ℓ) AbGroup ℓ = TypeWithStr ℓ AbGroupStr makeIsAbGroup : {G : Type ℓ} {0g : G} {_+_ : G → G → G} { -_ : G → G} (is-setG : isSet G) (assoc : (x y z : G) → x + (y + z) ≡ (x + y) + z) (rid : (x : G) → x + 0g ≡ x) (rinv : (x : G) → x + (- x) ≡ 0g) (comm : (x y : G) → x + y ≡ y + x) → IsAbGroup 0g _+_ -_ makeIsAbGroup is-setG assoc rid rinv comm = isabgroup (makeIsGroup is-setG assoc rid (λ x → comm _ _ ∙ rid x) rinv (λ x → comm _ _ ∙ rinv x)) comm makeAbGroup : {G : Type ℓ} (0g : G) (_+_ : G → G → G) (-_ : G → G) (is-setG : isSet G) (assoc : (x y z : G) → x + (y + z) ≡ (x + y) + z) (rid : (x : G) → x + 0g ≡ x) (rinv : (x : G) → x + (- x) ≡ 0g) (comm : (x y : G) → x + y ≡ y + x) → AbGroup ℓ makeAbGroup 0g _+_ -_ is-setG assoc rid rinv comm = _ , abgroupstr 0g _+_ -_ (makeIsAbGroup is-setG assoc rid rinv comm) open GroupStr open AbGroupStr open IsAbGroup AbGroupStr→GroupStr : {G : Type ℓ} → AbGroupStr G → GroupStr G AbGroupStr→GroupStr A .1g = A .0g AbGroupStr→GroupStr A ._·_ = A ._+_ AbGroupStr→GroupStr A .inv = A .-_ AbGroupStr→GroupStr A .isGroup = A .isAbGroup .isGroup AbGroup→Group : AbGroup ℓ → Group ℓ fst (AbGroup→Group A) = fst A snd (AbGroup→Group A) = AbGroupStr→GroupStr (snd A) Group→AbGroup : (G : Group ℓ) → ((x y : fst G) → _·_ (snd G) x y ≡ _·_ (snd G) y x) → AbGroup ℓ fst (Group→AbGroup G comm) = fst G AbGroupStr.0g (snd (Group→AbGroup G comm)) = 1g (snd G) AbGroupStr._+_ (snd (Group→AbGroup G comm)) = _·_ (snd G) AbGroupStr.- snd (Group→AbGroup G comm) = inv (snd G) IsAbGroup.isGroup (AbGroupStr.isAbGroup (snd (Group→AbGroup G comm))) = isGroup (snd G) IsAbGroup.comm (AbGroupStr.isAbGroup (snd (Group→AbGroup G comm))) = comm AbGroup→CommMonoid : AbGroup ℓ → CommMonoid ℓ AbGroup→CommMonoid (_ , abgroupstr _ _ _ G) = _ , commmonoidstr _ _ (iscommmonoid (IsAbGroup.isMonoid G) (IsAbGroup.comm G)) isSetAbGroup : (A : AbGroup ℓ) → isSet ⟨ A ⟩ isSetAbGroup A = isSetGroup (AbGroup→Group A) AbGroupHom : (G : AbGroup ℓ) (H : AbGroup ℓ') → Type (ℓ-max ℓ ℓ') AbGroupHom G H = GroupHom (AbGroup→Group G) (AbGroup→Group H) AbGroupIso : (G : AbGroup ℓ) (H : AbGroup ℓ') → Type (ℓ-max ℓ ℓ') AbGroupIso G H = GroupIso (AbGroup→Group G) (AbGroup→Group H) IsAbGroupEquiv : {A : Type ℓ} {B : Type ℓ'} (G : AbGroupStr A) (e : A ≃ B) (H : AbGroupStr B) → Type (ℓ-max ℓ ℓ') IsAbGroupEquiv G e H = IsGroupHom (AbGroupStr→GroupStr G) (e .fst) (AbGroupStr→GroupStr H) AbGroupEquiv : (G : AbGroup ℓ) (H : AbGroup ℓ') → Type (ℓ-max ℓ ℓ') AbGroupEquiv G H = Σ[ e ∈ (G .fst ≃ H .fst) ] IsAbGroupEquiv (G .snd) e (H .snd) isPropIsAbGroup : {G : Type ℓ} (0g : G) (_+_ : G → G → G) (- : G → G) → isProp (IsAbGroup 0g _+_ -) isPropIsAbGroup 0g _+_ -_ (isabgroup GG GC) (isabgroup HG HC) = λ i → isabgroup (isPropIsGroup _ _ _ GG HG i) (isPropComm GC HC i) where isSetG : isSet _ isSetG = GG .IsGroup.isMonoid .IsMonoid.isSemigroup .IsSemigroup.is-set isPropComm : isProp ((x y : _) → x + y ≡ y + x) isPropComm = isPropΠ2 λ _ _ → isSetG _ _ 𝒮ᴰ-AbGroup : DUARel (𝒮-Univ ℓ) AbGroupStr ℓ 𝒮ᴰ-AbGroup = 𝒮ᴰ-Record (𝒮-Univ _) IsAbGroupEquiv (fields: data[ _+_ ∣ autoDUARel _ _ ∣ pres· ] data[ 0g ∣ autoDUARel _ _ ∣ pres1 ] data[ -_ ∣ autoDUARel _ _ ∣ presinv ] prop[ isAbGroup ∣ (λ _ _ → isPropIsAbGroup _ _ _) ]) where open AbGroupStr open IsGroupHom -- Extract the characterization of equality of groups AbGroupPath : (G H : AbGroup ℓ) → (AbGroupEquiv G H) ≃ (G ≡ H) AbGroupPath = ∫ 𝒮ᴰ-AbGroup .UARel.ua -- TODO: Induced structure results are temporarily inconvenient while we transition between algebra -- representations module _ (G : AbGroup ℓ) {A : Type ℓ} (m : A → A → A) (e : ⟨ G ⟩ ≃ A) (p· : ∀ x y → e .fst (G .snd ._+_ x y) ≡ m (e .fst x) (e .fst y)) where private module G = AbGroupStr (G .snd) FamilyΣ : Σ[ B ∈ Type ℓ ] (B → B → B) → Type ℓ FamilyΣ (B , n) = Σ[ e ∈ B ] Σ[ i ∈ (B → B) ] IsAbGroup e n i inducedΣ : FamilyΣ (A , m) inducedΣ = subst FamilyΣ (UARel.≅→≡ (autoUARel (Σ[ B ∈ Type ℓ ] (B → B → B))) (e , p·)) (G.0g , G.-_ , G.isAbGroup) InducedAbGroup : AbGroup ℓ InducedAbGroup .fst = A InducedAbGroup .snd ._+_ = m InducedAbGroup .snd .0g = inducedΣ .fst InducedAbGroup .snd .-_ = inducedΣ .snd .fst InducedAbGroup .snd .isAbGroup = inducedΣ .snd .snd InducedAbGroupPath : G ≡ InducedAbGroup InducedAbGroupPath = AbGroupPath _ _ .fst (e , makeIsGroupHom p·) open IsMonoid open IsSemigroup open IsGroup dirProdAb : AbGroup ℓ → AbGroup ℓ' → AbGroup (ℓ-max ℓ ℓ') dirProdAb A B = Group→AbGroup (DirProd (AbGroup→Group A) (AbGroup→Group B)) λ p q → ΣPathP (comm (isAbGroup (snd A)) _ _ , comm (isAbGroup (snd B)) _ _) trivialAbGroup : ∀ {ℓ} → AbGroup ℓ fst trivialAbGroup = Unit* 0g (snd trivialAbGroup) = tt* _+_ (snd trivialAbGroup) _ _ = tt* (- snd trivialAbGroup) _ = tt* is-set (isSemigroup (isMonoid (isGroup (isAbGroup (snd trivialAbGroup))))) = isProp→isSet isPropUnit* assoc (isSemigroup (isMonoid (isGroup (isAbGroup (snd trivialAbGroup))))) _ _ _ = refl identity (isMonoid (isGroup (isAbGroup (snd trivialAbGroup)))) _ = refl , refl inverse (isGroup (isAbGroup (snd trivialAbGroup))) _ = refl , refl comm (isAbGroup (snd trivialAbGroup)) _ _ = refl -- useful lemma move4 : ∀ {ℓ} {A : Type ℓ} (x y z w : A) (_+_ : A → A → A) → ((x y z : A) → x + (y + z) ≡ (x + y) + z) → ((x y : A) → x + y ≡ y + x) → (x + y) + (z + w) ≡ ((x + z) + (y + w)) move4 x y z w _+_ assoc comm = sym (assoc x y (z + w)) ∙∙ cong (x +_) (assoc y z w ∙∙ cong (_+ w) (comm y z) ∙∙ sym (assoc z y w)) ∙∙ assoc x z (y + w) ---- The type of homomorphisms A → B is an AbGroup if B is ----- module _ {ℓ ℓ' : Level} (AGr : Group ℓ) (BGr : AbGroup ℓ') where private strA = snd AGr strB = snd BGr _* = AbGroup→Group A = fst AGr B = fst BGr open IsGroupHom open AbGroupStr strB renaming (_+_ to _+B_ ; -_ to -B_ ; 0g to 0B ; rid to ridB ; lid to lidB ; assoc to assocB ; comm to commB ; invr to invrB ; invl to invlB) open GroupStr strA renaming (_·_ to _∙A_ ; inv to -A_ ; 1g to 1A ; rid to ridA) trivGroupHom : GroupHom AGr (BGr *) fst trivGroupHom x = 0B snd trivGroupHom = makeIsGroupHom λ _ _ → sym (ridB 0B) compHom : GroupHom AGr (BGr *) → GroupHom AGr (BGr *) → GroupHom AGr (BGr *) fst (compHom f g) x = fst f x +B fst g x snd (compHom f g) = makeIsGroupHom λ x y → cong₂ _+B_ (pres· (snd f) x y) (pres· (snd g) x y) ∙ move4 (fst f x) (fst f y) (fst g x) (fst g y) _+B_ assocB commB invHom : GroupHom AGr (BGr *) → GroupHom AGr (BGr *) fst (invHom (f , p)) x = -B f x snd (invHom (f , p)) = makeIsGroupHom λ x y → cong -B_ (pres· p x y) ∙∙ GroupTheory.invDistr (BGr *) (f x) (f y) ∙∙ commB _ _ open AbGroupStr open IsAbGroup open IsGroup open IsMonoid open IsSemigroup HomGroup : AbGroup (ℓ-max ℓ ℓ') fst HomGroup = GroupHom AGr (BGr *) 0g (snd HomGroup) = trivGroupHom AbGroupStr._+_ (snd HomGroup) = compHom AbGroupStr.- snd HomGroup = invHom is-set (isSemigroup (isMonoid (isGroup (isAbGroup (snd HomGroup))))) = isSetGroupHom assoc (isSemigroup (isMonoid (isGroup (isAbGroup (snd HomGroup))))) (f , p) (g , q) (h , r) = Σ≡Prop (λ _ → isPropIsGroupHom _ _) (funExt λ x → assocB _ _ _) fst (identity (isMonoid (isGroup (isAbGroup (snd HomGroup)))) (f , p)) = Σ≡Prop (λ _ → isPropIsGroupHom _ _) (funExt λ y → ridB _) snd (identity (isMonoid (isGroup (isAbGroup (snd HomGroup)))) (f , p)) = Σ≡Prop (λ _ → isPropIsGroupHom _ _) (funExt λ x → lidB _) fst (inverse (isGroup (isAbGroup (snd HomGroup))) (f , p)) = Σ≡Prop (λ _ → isPropIsGroupHom _ _) (funExt λ x → invrB (f x)) snd (inverse (isGroup (isAbGroup (snd HomGroup))) (f , p)) = Σ≡Prop (λ _ → isPropIsGroupHom _ _) (funExt λ x → invlB (f x)) comm (isAbGroup (snd HomGroup)) (f , p) (g , q) = Σ≡Prop (λ _ → isPropIsGroupHom _ _) (funExt λ x → commB _ _)
{ "alphanum_fraction": 0.6082822086, "avg_line_length": 34.3157894737, "ext": "agda", "hexsha": "1a8b245772bf61994694fff6bae9d6d9863d95fa", "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": "1d9b9691d375659fa8ebd9cbf8b63678955b196b", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "gmagaf/cubical", "max_forks_repo_path": "Cubical/Algebra/AbGroup/Base.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "1d9b9691d375659fa8ebd9cbf8b63678955b196b", "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": "gmagaf/cubical", "max_issues_repo_path": "Cubical/Algebra/AbGroup/Base.agda", "max_line_length": 104, "max_stars_count": null, "max_stars_repo_head_hexsha": "1d9b9691d375659fa8ebd9cbf8b63678955b196b", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "gmagaf/cubical", "max_stars_repo_path": "Cubical/Algebra/AbGroup/Base.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 3741, "size": 9780 }
module _ where data ⊤ : Set where tt : ⊤ pattern id x = x postulate X : Set loops : X loops = tt
{ "alphanum_fraction": 0.6057692308, "avg_line_length": 8, "ext": "agda", "hexsha": "b7f814c4fd494f3e86eea1567a1c679265e4ef0a", "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/Issue2828.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/Issue2828.agda", "max_line_length": 25, "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/Issue2828.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": 104 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Existential lifting of predicates over Vectors ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} module Data.Vec.Functional.Relation.Unary.Any where open import Data.Fin.Base open import Data.Fin.Properties open import Data.Nat.Base open import Data.Product as Σ using (Σ; ∃; _×_; _,_; proj₁; proj₂) open import Data.Vec.Functional as VF hiding (map) open import Function open import Level using (Level) open import Relation.Unary private variable a b p q ℓ : Level A : Set a B : Set b ------------------------------------------------------------------------ -- Definition Any : Pred A ℓ → ∀ {n} → Vector A n → Set ℓ Any P xs = ∃ λ i → P (xs i) ------------------------------------------------------------------------ -- Operations module _ {P : Pred A p} where here : ∀ {x n} {v : Vector A n} → P x → Any P (x ∷ v) here px = zero , px there : ∀ {x n} {v : Vector A n} → Any P v → Any P (x ∷ v) there = Σ.map suc id module _ {P : Pred A p} {Q : Pred A q} where map : P ⊆ Q → ∀ {n} → Any P {n = n} ⊆ Any Q map p⊆q = Σ.map id p⊆q ------------------------------------------------------------------------ -- Properties of predicates preserved by Any module _ {P : Pred A p} where any : Decidable P → ∀ {n} → Decidable (Any P {n = n}) any p? xs = any? λ i → p? (xs i)
{ "alphanum_fraction": 0.4633649932, "avg_line_length": 26.8, "ext": "agda", "hexsha": "e50cb24eeef2146f6431c2ffe7d34d62768e1331", "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/Vec/Functional/Relation/Unary/Any.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/Vec/Functional/Relation/Unary/Any.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/Vec/Functional/Relation/Unary/Any.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": 395, "size": 1474 }
module cfg where open import jarsec using (Parser ; run-parser ; partial-parse ; _>>=_ ; _>>_ ; _<*>_) open import Data.Bool open import Data.List hiding (lookup) open import Data.Vec renaming ([_] to V[_] ; _++_ to _vv_) hiding (_>>=_) open import Data.Fin hiding (_+_) open import Data.Char open import Agda.Builtin.Char renaming ( primCharEquality to charEq ) open import Data.Nat open import Relation.Binary.PropositionalEquality using (_≡_ ; refl) open import Data.Maybe open import Data.Sum hiding (map) open import Data.String hiding (length ; _++_) renaming (primStringToList to 𝕊→𝕃 ; primStringFromList to 𝕃→𝕊) open import Data.Product hiding (map) open import Agda.Builtin.Unit postulate 𝕃⇄𝕊 : ∀ (cs : List Char) → (𝕊→𝕃 (𝕃→𝕊 cs)) ≡ cs _at_ : ∀ {n} {A : Set} → Vec A n → Fin n → A (x ∷ xs) at zero = x (x ∷ xs) at suc i = xs at i A : Set A = Char data Cfg : ℕ → Set where emp : ∀ {n} → Cfg n eps : ∀ {n} → Cfg n lit : ∀ {n} → A → Cfg n var : ∀ {n} → Fin n → Cfg n seq : ∀ {n} → Cfg n → Cfg n → Cfg n alt : ∀ {n} → Cfg n → Cfg n → Cfg n many : ∀ {n} → Cfg n → Cfg n fix : ∀ {n} → Cfg (suc n) → Cfg n Env : ℕ → Set Env n = Vec (Cfg n) n _⊖_ : ∀ (n : ℕ) → Fin n → ℕ (suc n) ⊖ zero = n (suc n) ⊖ suc i = suc (n ⊖ i) _⊕_ : ℕ → ℕ → ℕ zero ⊕ n = n suc m ⊕ n = m ⊕ suc n introd-var : ∀ {n : ℕ} (i : Fin n) → Fin (n ⊖ i) → Fin n introd-var zero x = suc x introd-var (suc i) zero = zero introd-var (suc i) (suc x) = suc (introd-var i x) introd : ∀ {n : ℕ} (i : Fin n) → Cfg (n ⊖ i) → Cfg n introd i emp = emp introd i eps = eps introd i (lit l) = lit l introd i (var x) = var (introd-var i x) introd i (seq e₁ e₂) = seq (introd i e₁) (introd i e₂) introd i (alt e₁ e₂) = alt (introd i e₁) (introd i e₂) introd i (many e) = many (introd i e) introd i (fix e) = fix (introd (suc i) e) -- used in subst introd-var-N : ∀ {n : ℕ} (m : ℕ) → Fin n → Fin (m ⊕ n) introd-var-N zero x = x introd-var-N (suc m) x = introd-var-N m (introd-var zero x) -- used in subst intro : ∀ {n : ℕ} → Cfg n → Cfg (suc n) intro = introd zero subst-var : ∀ {n : ℕ} (m : ℕ) (x : Fin n) → Cfg (m ⊕ (n ⊖ x)) → Fin n → Cfg (m ⊕ (n ⊖ x)) subst-var m zero v zero = v subst-var m zero v (suc y) = var (introd-var-N m y) subst-var m (suc x) v zero = var (introd-var-N m zero) subst-var m (suc x) v (suc y) = subst-var (suc m) x v y subst : ∀ {n : ℕ} (x : Fin n) → Cfg (n ⊖ x) → Cfg n → Cfg (n ⊖ x) subst y v emp = emp subst y v eps = eps subst y v (lit l) = lit l subst y v (var x) = subst-var zero y v x subst y v (seq e₁ e₂) = seq (subst y v e₁) (subst y v e₂) subst y v (alt e₁ e₂) = alt (subst y v e₁) (subst y v e₂) subst y v (many e) = many (subst y v e) subst y v (fix e) = fix (subst (suc y) (intro v) e) sub : ∀ {n : ℕ} → Cfg n → Cfg (suc n) → Cfg n sub = subst zero data _∈[_] : List A → Cfg 0 → Set where eps : [] ∈[ eps ] lit : ∀ (c : A) → [ c ] ∈[ lit c ] seq : ∀ {s₁ s₂ : List A} {cfg₁ cfg₂ : Cfg 0} → s₁ ∈[ cfg₁ ] → s₂ ∈[ cfg₂ ] → (s₁ ++ s₂) ∈[ seq cfg₁ cfg₂ ] alt₁ : {s : List A} {cfg₁ cfg₂ : Cfg 0} → s ∈[ cfg₁ ] → s ∈[ alt cfg₁ cfg₂ ] alt₂ : {s : List A} {cfg₁ cfg₂ : Cfg 0} → s ∈[ cfg₂ ] → s ∈[ alt cfg₁ cfg₂ ] many0 : {cfg : Cfg 0} → [] ∈[ many cfg ] many+ : {s₁ s₂ : List A} {cfg : Cfg 0} → s₁ ∈[ cfg ] → s₂ ∈[ many cfg ] → (s₁ ++ s₂) ∈[ many cfg ] unroll : {s : List A} → {cfg : Cfg 1} → s ∈[ sub (fix cfg) cfg ] → s ∈[ fix cfg ] abstract instance block : ⊤ block = tt unblock : block ≡ tt unblock = refl delayed : ∀ {A : Set} → ⊤ → A → A delayed tt x = x delay : ∀ {A : Set} → A → A delay = delayed block {-# TERMINATING #-} interp : Cfg 0 → Parser (List A) interp emp = Parser.mk-parser (λ _ → []) interp eps = Parser.mk-parser (λ str → [ ([] , str) ]) interp (lit c) = do c′ ← jarsec.satisfy (charEq c) jarsec.unit [ c′ ] interp (var ()) interp (seq cfg₁ cfg₂) = do x ← (interp cfg₁) y ← (interp cfg₂) jarsec.unit (x ++ y) interp (alt cfg₁ cfg₂) = jarsec.combine (interp cfg₁) (interp cfg₂) interp (many cfg) = interp (alt eps (seq cfg (delay (many cfg)))) interp (fix cfg) = interp (sub (fix cfg) cfg) a : Fin 2 a = zero b : Fin 2 b = (suc zero) xX-or-ε : Cfg 0 xX-or-ε = fix (alt (seq (lit 'x') (var zero)) eps) -- _ : interp xX-or-ε ≡ {! !} -- _ = refl _ : (𝕊→𝕃 "xx") ∈[ fix {n = 0} (alt (seq (lit 'x') (var zero)) (eps)) ] _ = unroll (alt₁ (seq (lit 'x') (unroll (alt₁ (seq (lit 'x') (unroll (alt₂ eps))))))) _ : (𝕊→𝕃 "xx") ∈[ xX-or-ε ] _ = unroll (alt₁ (seq (lit 'x') ( unroll (alt₁ (seq (lit 'x') ( unroll (alt₂ eps))))))) _ : ( 'a' ∷ 'a' ∷ []) ∈[ many (lit 'a') ] _ = many+ (lit 'a') (many+ (lit 'a') many0)
{ "alphanum_fraction": 0.5471053194, "avg_line_length": 26.0055555556, "ext": "agda", "hexsha": "1388f0d4fa56af0a65572d9b07d05ca7d5192e1e", "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": "40cca331810f1d3f7dc099614ddca4fa96bd695c", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "jaywunder/jarsec-verified", "max_forks_repo_path": "src/cfg.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "40cca331810f1d3f7dc099614ddca4fa96bd695c", "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": "jaywunder/jarsec-verified", "max_issues_repo_path": "src/cfg.agda", "max_line_length": 109, "max_stars_count": null, "max_stars_repo_head_hexsha": "40cca331810f1d3f7dc099614ddca4fa96bd695c", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "jaywunder/jarsec-verified", "max_stars_repo_path": "src/cfg.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1959, "size": 4681 }
-- 2010-09-06 Andreas module IrrelevantVar where -- type checker should fail and complain that x is irrelevant and cannot be used f : {A : Set} -> .A -> A -> A f x y = x
{ "alphanum_fraction": 0.6647398844, "avg_line_length": 19.2222222222, "ext": "agda", "hexsha": "53c5293ad893060bfcd78d15d7321bc313725bda", "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/IrrelevantVar.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/IrrelevantVar.agda", "max_line_length": 80, "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/IrrelevantVar.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": 53, "size": 173 }
{-# OPTIONS --type-in-type #-} open import Data.Unit open import Data.Product hiding ( curry ; uncurry ) open import Data.List hiding ( concat ) open import Data.String open import Relation.Binary.PropositionalEquality module Spire.Examples.PropositionalLevDesc where ---------------------------------------------------------------------- Label : Set Label = String Enum : Set Enum = List Label data Tag : Enum → Set where here : ∀{l E} → Tag (l ∷ E) there : ∀{l E} → Tag E → Tag (l ∷ E) Cases : (E : Enum) (P : Tag E → Set) → Set Cases [] P = ⊤ Cases (l ∷ E) P = P here × Cases E λ t → P (there t) case : (E : Enum) (P : Tag E → Set) (cs : Cases E P) (t : Tag E) → P t case (l ∷ E) P (c , cs) here = c case (l ∷ E) P (c , cs) (there t) = case E (λ t → P (there t)) cs t UncurriedCases : (E : Enum) (P : Tag E → Set) (X : Set) → Set UncurriedCases E P X = Cases E P → X CurriedCases : (E : Enum) (P : Tag E → Set) (X : Set) → Set CurriedCases [] P X = X CurriedCases (l ∷ E) P X = P here → CurriedCases E (λ t → P (there t)) X curryCases : (E : Enum) (P : Tag E → Set) (X : Set) (f : UncurriedCases E P X) → CurriedCases E P X curryCases [] P X f = f tt curryCases (l ∷ E) P X f = λ c → curryCases E (λ t → P (there t)) X (λ cs → f (c , cs)) uncurryCases : (E : Enum) (P : Tag E → Set) (X : Set) (f : CurriedCases E P X) → UncurriedCases E P X uncurryCases [] P X x tt = x uncurryCases (l ∷ E) P X f (c , cs) = uncurryCases E (λ t → P (there t)) X (f c) cs ---------------------------------------------------------------------- data Desc (I : Set) : Set₁ where `End : (i : I) → Desc I `Rec : (i : I) (D : Desc I) → Desc I `Arg : (A : Set) (B : A → Desc I) → Desc I `RecFun : (A : Set) (B : A → I) (D : Desc I) → Desc I ISet : Set → Set₁ ISet I = I → Set El : (I : Set) (D : Desc I) (X : ISet I) → ISet I El I (`End j) X i = j ≡ i El I (`Rec j D) X i = X j × El I D X i El I (`Arg A B) X i = Σ A (λ a → El I (B a) X i) El I (`RecFun A B D) X i = ((a : A) → X (B a)) × El I D X i Hyps : (I : Set) (D : Desc I) (X : ISet I) (P : (i : I) → X i → Set) (i : I) (xs : El I D X i) → Set Hyps I (`End j) X P i q = ⊤ Hyps I (`Rec j D) X P i (x , xs) = P j x × Hyps I D X P i xs Hyps I (`Arg A B) X P i (a , b) = Hyps I (B a) X P i b Hyps I (`RecFun A B D) X P i (f , xs) = ((a : A) → P (B a) (f a)) × Hyps I D X P i xs ---------------------------------------------------------------------- TagDesc : (I : Set) → Set TagDesc I = Σ Enum (λ E → Cases E (λ _ → Desc I)) toCase : (I : Set) (E,cs : TagDesc I) → Tag (proj₁ E,cs) → Desc I toCase I (E , cs) = case E (λ _ → Desc I) cs toDesc : (I : Set) → TagDesc I → Desc I toDesc I (E , cs) = `Arg (Tag E) (toCase I (E , cs)) ---------------------------------------------------------------------- UncurriedEl : (I : Set) (D : Desc I) (X : ISet I) → Set UncurriedEl I D X = {i : I} → El I D X i → X i CurriedEl : (I : Set) (D : Desc I) (X : ISet I) → Set CurriedEl I (`End i) X = X i CurriedEl I (`Rec j D) X = (x : X j) → CurriedEl I D X CurriedEl I (`Arg A B) X = (a : A) → CurriedEl I (B a) X CurriedEl I (`RecFun A B D) X = ((a : A) → X (B a)) → CurriedEl I D X curryEl : (I : Set) (D : Desc I) (X : ISet I) (cn : UncurriedEl I D X) → CurriedEl I D X curryEl I (`End i) X cn = cn refl curryEl I (`Rec i D) X cn = λ x → curryEl I D X (λ xs → cn (x , xs)) curryEl I (`Arg A B) X cn = λ a → curryEl I (B a) X (λ xs → cn (a , xs)) curryEl I (`RecFun A B D) X cn = λ f → curryEl I D X (λ xs → cn (f , xs)) uncurryEl : (I : Set) (D : Desc I) (X : ISet I) (cn : CurriedEl I D X) → UncurriedEl I D X uncurryEl I (`End i) X cn refl = cn uncurryEl I (`Rec i D) X cn (x , xs) = uncurryEl I D X (cn x) xs uncurryEl I (`Arg A B) X cn (a , xs) = uncurryEl I (B a) X (cn a) xs uncurryEl I (`RecFun A B D) X cn (f , xs) = uncurryEl I D X (cn f) xs ---------------------------------------------------------------------- CasesD : (I : Set) (E : Enum) → Set CasesD I E = Cases E (λ _ → Desc I) Args : (I : Set) (E : Enum) (t : Tag E) (cs : CasesD I E) → Desc I Args I E t cs = case E (λ _ → Desc I) cs t ---------------------------------------------------------------------- data μ (I : Set) (E : Enum) (cs : CasesD I E) : I → Set where con : (t : Tag E) → UncurriedEl I (Args I E t cs) (μ I E cs) con2 : (I : Set) (E : Enum) (cs : CasesD I E) (t : Tag E) → CurriedEl I (Args I E t cs) (μ I E cs) con2 I E cs t = curryEl I (Args I E t cs) (μ I E cs) (con t) ---------------------------------------------------------------------- UncurriedHyps : (I : Set) (D : Desc I) (X : ISet I) (P : (i : I) → X i → Set) (cn : {i : I} → El I D X i → X i) → Set UncurriedHyps I D X P cn = (i : I) (xs : El I D X i) → Hyps I D X P i xs → P i (cn xs) CurriedHyps : (I : Set) (D : Desc I) (X : ISet I) (P : (i : I) → X i → Set) (cn : UncurriedEl I D X) → Set CurriedHyps I (`End i) X P cn = P i (cn refl) CurriedHyps I (`Rec i D) X P cn = (x : X i) → P i x → CurriedHyps I D X P (λ xs → cn (x , xs)) CurriedHyps I (`Arg A B) X P cn = (a : A) → CurriedHyps I (B a) X P (λ xs → cn (a , xs)) CurriedHyps I (`RecFun A B D) X P cn = (f : (a : A) → X (B a)) (ihf : (a : A) → P (B a) (f a)) → CurriedHyps I D X P (λ xs → cn (f , xs)) curryHyps : (I : Set) (D : Desc I) (X : ISet I) (P : (i : I) → X i → Set) (cn : UncurriedEl I D X) (pf : UncurriedHyps I D X P cn) → CurriedHyps I D X P cn curryHyps I (`End i) X P cn pf = pf i refl tt curryHyps I (`Rec i D) X P cn pf = λ x ih → curryHyps I D X P (λ xs → cn (x , xs)) (λ i xs ihs → pf i (x , xs) (ih , ihs)) curryHyps I (`Arg A B) X P cn pf = λ a → curryHyps I (B a) X P (λ xs → cn (a , xs)) (λ i xs ihs → pf i (a , xs) ihs) curryHyps I (`RecFun A B D) X P cn pf = λ f ihf → curryHyps I D X P (λ xs → cn (f , xs)) (λ i xs ihs → pf i (f , xs) (ihf , ihs)) uncurryHyps : (I : Set) (D : Desc I) (X : ISet I) (P : (i : I) → X i → Set) (cn : UncurriedEl I D X) (pf : CurriedHyps I D X P cn) → UncurriedHyps I D X P cn uncurryHyps I (`End .i) X P cn pf i refl tt = pf uncurryHyps I (`Rec j D) X P cn pf i (x , xs) (ih , ihs) = uncurryHyps I D X P (λ ys → cn (x , ys)) (pf x ih) i xs ihs uncurryHyps I (`Arg A B) X P cn pf i (a , xs) ihs = uncurryHyps I (B a) X P (λ ys → cn (a , ys)) (pf a) i xs ihs uncurryHyps I (`RecFun A B D) X P cn pf i (f , xs) (ihf , ihs) = uncurryHyps I D X P (λ ys → cn (f , ys)) (pf f ihf) i xs ihs ---------------------------------------------------------------------- ind : (I : Set) (E : Enum) (cs : CasesD I E) (P : (i : I) → μ I E cs i → Set) (pcon : (t : Tag E) → UncurriedHyps I (Args I E t cs) (μ I E cs) P (con t)) (i : I) (x : μ I E cs i) → P i x hyps : (I : Set) (E : Enum) (cs : CasesD I E) (P : (i : I) → μ I E cs i → Set) (pcon : (t : Tag E) → UncurriedHyps I (Args I E t cs) (μ I E cs) P (con t)) (D : Desc I) (i : I) (xs : El I D (μ I E cs) i) → Hyps I D (μ I E cs) P i xs ind I E cs P pcon i (con t as) = pcon t i as (hyps I E cs P pcon (Args I E t cs) i as) hyps I E cs P pcon (`End j) i q = tt hyps I E cs P pcon (`Rec j A) i (x , xs) = ind I E cs P pcon j x , hyps I E cs P pcon A i xs hyps I E cs P pcon (`Arg A B) i (a , b) = hyps I E cs P pcon (B a) i b hyps I E cs P pcon (`RecFun A B D) i (f , xs) = (λ a → ind I E cs P pcon (B a) (f a)) , hyps I E cs P pcon D i xs ---------------------------------------------------------------------- ind2 : (I : Set) (E : Enum) (cs : CasesD I E) (P : (i : I) → μ I E cs i → Set) (pcon : (t : Tag E) → CurriedHyps I (Args I E t cs) (μ I E cs) P (con t)) (i : I) (x : μ I E cs i) → P i x ind2 I E cs P pcon i x = ind I E cs P (λ t → uncurryHyps I (Args I E t cs) (μ I E cs) P (con t) (pcon t)) i x elim : (I : Set) (E : Enum) (cs : CasesD I E) (P : (i : I) → μ I E cs i → Set) → let Q = λ t → CurriedHyps I (Args I E t cs) (μ I E cs) P (con t) X = (i : I) (x : μ I E cs i) → P i x in UncurriedCases E Q X elim I E cs P ds i x = let Q = λ t → CurriedHyps I (Args I E t cs) (μ I E cs) P (con t) in ind2 I E cs P (case E Q ds) i x elim2 : (I : Set) (E : Enum) (cs : CasesD I E) (P : (i : I) → μ I E cs i → Set) → let Q = λ t → CurriedHyps I (Args I E t cs) (μ I E cs) P (con t) X = (i : I) (x : μ I E cs i) → P i x in CurriedCases E Q X elim2 I E cs P = let Q = λ t → CurriedHyps I (Args I E t cs) (μ I E cs) P (con t) X = (i : I) (x : μ I E cs i) → P i x in curryCases E Q X (elim I E cs P) ---------------------------------------------------------------------- ℕT : Enum ℕT = "zero" ∷ "suc" ∷ [] VecT : Enum VecT = "nil" ∷ "cons" ∷ [] ℕD : CasesD ⊤ ℕT ℕD = `End tt , `Rec tt (`End tt) , tt ℕ : ⊤ → Set ℕ = μ ⊤ ℕT ℕD zero : ℕ tt zero = con here refl suc : ℕ tt → ℕ tt suc n = con (there here) (n , refl) zero2 : ℕ tt zero2 = con2 ⊤ ℕT ℕD here suc2 : ℕ tt → ℕ tt suc2 = con2 ⊤ ℕT ℕD (there here) VecD : (A : Set) → CasesD (ℕ tt) VecT VecD A = `End zero , `Arg (ℕ tt) (λ n → `Arg A λ _ → `Rec n (`End (suc n))) , tt Vec : (A : Set) (n : ℕ tt) → Set Vec A n = μ (ℕ tt) VecT (VecD A) n nil : (A : Set) → Vec A zero nil A = con here refl cons : (A : Set) (n : ℕ tt) (x : A) (xs : Vec A n) → Vec A (suc n) cons A n x xs = con (there here) (n , x , xs , refl) nil2 : (A : Set) → Vec A zero nil2 A = con2 (ℕ tt) VecT (VecD A) here cons2 : (A : Set) (n : ℕ tt) (x : A) (xs : Vec A n) → Vec A (suc n) cons2 A = con2 (ℕ tt) VecT (VecD A) (there here) ---------------------------------------------------------------------- module GenericEliminator where add : ℕ tt → ℕ tt → ℕ tt add = elim2 ⊤ ℕT ℕD _ (λ n → n) (λ m ih n → suc (ih n)) tt mult : ℕ tt → ℕ tt → ℕ tt mult = elim2 ⊤ ℕT ℕD _ (λ n → zero) (λ m ih n → add n (ih n)) tt append : (A : Set) (m : ℕ tt) (xs : Vec A m) (n : ℕ tt) (ys : Vec A n) → Vec A (add m n) append A = elim2 (ℕ tt) VecT (VecD A) _ (λ n ys → ys) (λ m x xs ih n ys → cons A (add m n) x (ih n ys)) concat : (A : Set) (m n : ℕ tt) (xss : Vec (Vec A m) n) → Vec A (mult n m) concat A m = elim2 (ℕ tt) VecT (VecD (Vec A m)) _ (nil A) (λ n xs xss ih → append A m xs (mult n m) ih) ----------------------------------------------------------------------
{ "alphanum_fraction": 0.4754676329, "avg_line_length": 31.613003096, "ext": "agda", "hexsha": "1e12795a1de1b23355a346ad926a900d1c06a654", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2015-08-17T21:00:07.000Z", "max_forks_repo_forks_event_min_datetime": "2015-08-17T21:00:07.000Z", "max_forks_repo_head_hexsha": "3d67f137ee9423b7e6f8593634583998cd692353", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "spire/spire", "max_forks_repo_path": "formalization/agda/Spire/Examples/PropositionalLevDesc.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "3d67f137ee9423b7e6f8593634583998cd692353", "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": "spire/spire", "max_issues_repo_path": "formalization/agda/Spire/Examples/PropositionalLevDesc.agda", "max_line_length": 113, "max_stars_count": 43, "max_stars_repo_head_hexsha": "3d67f137ee9423b7e6f8593634583998cd692353", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "spire/spire", "max_stars_repo_path": "formalization/agda/Spire/Examples/PropositionalLevDesc.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-08T17:10:59.000Z", "max_stars_repo_stars_event_min_datetime": "2015-05-28T23:25:33.000Z", "num_tokens": 4231, "size": 10211 }