Search is not available for this dataset
text
string
meta
dict
-- Andreas, 2017-01-14, issue #2405 reported by m0davis -- Instance not found due to regression introduced by -- parameter-refinement. -- {-# OPTIONS --show-implicit #-} -- {-# OPTIONS -v tc.instance:70 #-} -- {-# OPTIONS -v tc.meta.assign:40 #-} -- {-# OPTIONS -v tc.conv:40 #-} -- {-# OPTIONS -v tc.sig.param:100 #-} postulate R : Set → Set S : (F : Set → Set) ⦃ _ : {A : Set} → R (F A) ⦄ → Set module M1 (X : Set) where postulate F : Set → Set instance Ri : {A : Set} → R (F A) Si-works : S F ⦃ Ri ⦄ Si-test : S F -- WAS: -- No instance of type R (F A) was found in scope. -} -- -- candidate: -- Ri X : (A : Set) → R (F X A) -- Ri 0 : Π Set λ A → R (F 1 0) -- Ri 0 _A : R (F 0 (_A 1 0)) -- goal: -- getMetaType -- ? : (X A : Set) → R (F X A) -- ? : Π Set λ X → Pi Set λ A → R (F 1 0) -- ? : R (F A) -- ? : R (F 1 0) -- Should succeed.
{ "alphanum_fraction": 0.5045045045, "avg_line_length": 24, "ext": "agda", "hexsha": "d61713485b9d05142fdbcdbb2cd07753a3a0f021", "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/Issue2405.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/Issue2405.agda", "max_line_length": 55, "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/Issue2405.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": 350, "size": 888 }
------------------------------------------------------------------------------ -- Co-lists ------------------------------------------------------------------------------ {-# OPTIONS --allow-unsolved-metas #-} {-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} module GFPs.Colist where open import FOTC.Base open import FOTC.Base.List ------------------------------------------------------------------------------ -- Colist is a greatest fixed-point of a functor -- The functor. ListF : (D → Set) → D → Set ListF A xs = xs ≡ [] ∨ (∃[ x' ] ∃[ xs' ] xs ≡ x' ∷ xs' ∧ A xs') -- Colist is the greatest fixed-point of ListF. postulate Colist : D → Set -- Colist is a post-fixed point of ListF, i.e. -- -- Colist ≤ ListF Colist. Colist-out-ho : ∀ {n} → Colist n → ListF Colist n -- Colist is the greatest post-fixed point of ListF, i.e. -- -- ∀ A. A ≤ ListF A ⇒ A ≤ Colist. Colist-coind-ho : (A : D → Set) → -- A is post-fixed point of ListF. (∀ {xs} → A xs → ListF A xs) → -- Colist is greater than A. ∀ {xs} → A xs → Colist xs ------------------------------------------------------------------------------ -- First-order versions Colist-out : ∀ {xs} → Colist xs → xs ≡ [] ∨ (∃[ x' ] ∃[ xs' ] xs ≡ x' ∷ xs' ∧ Colist xs') Colist-out = Colist-out-ho Colist-coind : (A : D → Set) → (∀ {xs} → A xs → xs ≡ [] ∨ (∃[ x' ] ∃[ xs' ] xs ≡ x' ∷ xs' ∧ A xs')) → ∀ {xs} → A xs → Colist xs Colist-coind = Colist-coind-ho ------------------------------------------------------------------------------ -- Because a greatest post-fixed point is a fixed-point, then the -- Colist predicate is also a pre-fixed point of the functional ListF, -- i.e. -- -- ListF Colist ≤ Colist. Colist-in-ho : ∀ {xs} → ListF Colist xs → Colist xs Colist-in-ho h = Colist-coind-ho A h' h where A : D → Set A xs = ListF Colist xs h' : ∀ {xs} → A xs → ListF A xs h' (inj₁ xs≡0) = inj₁ xs≡0 h' (inj₂ (x' , xs' , prf , CLxs' )) = inj₂ (x' , xs' , prf , Colist-out CLxs') -- The first-order version. Colist-in : ∀ {xs} → xs ≡ [] ∨ (∃[ x' ] ∃[ xs' ] xs ≡ x' ∷ xs' ∧ Colist xs') → Colist xs Colist-in = Colist-in-ho ------------------------------------------------------------------------------ -- A stronger co-induction principle -- -- From (Paulson, 1997. p. 16). postulate Colist-coind-stronger-ho : (A : D → Set) → (∀ {xs} → A xs → ListF A xs ∨ Colist xs) → ∀ {xs} → A xs → Colist xs Colist-coind-ho' : (A : D → Set) → (∀ {xs} → A xs → ListF A xs) → ∀ {xs} → A xs → Colist xs Colist-coind-ho' A h Axs = Colist-coind-stronger-ho A (λ Ays → inj₁ (h Ays)) Axs -- The first-order version. Colist-coind-stronger : (A : D → Set) → (∀ {xs} → A xs → (xs ≡ [] ∨ (∃[ x' ] ∃[ xs' ] xs ≡ x' ∷ xs' ∧ A xs')) ∨ Colist xs) → ∀ {xs} → A xs → Colist xs Colist-coind-stronger = Colist-coind-stronger-ho -- 13 January 2014. As expected, we cannot prove -- Colist-coind-stronger-ho from Colist-coind-ho. Colist-coind-stronger-ho' : (A : D → Set) → (∀ {xs} → A xs → ListF A xs ∨ Colist xs) → ∀ {xs} → A xs → Colist xs Colist-coind-stronger-ho' A h {xs} Axs = case prf (λ h' → h') (h Axs) where prf : ListF A xs → Colist xs prf h' = Colist-coind-ho A {!!} Axs ------------------------------------------------------------------------------ -- References -- -- Paulson, L. C. (1997). Mechanizing Coinduction and Corecursion in -- Higher-order Logic. Journal of Logic and Computation 7.2, -- pp. 175–204.
{ "alphanum_fraction": 0.4686641012, "avg_line_length": 29.5772357724, "ext": "agda", "hexsha": "103fe245d3185267679ea35119d6845978523d06", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "asr/fotc", "max_forks_repo_path": "notes/fixed-points/GFPs/Colist.agda", "max_issues_count": 2, "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "asr/fotc", "max_issues_repo_path": "notes/fixed-points/GFPs/Colist.agda", "max_line_length": 78, "max_stars_count": 11, "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/fotc", "max_stars_repo_path": "notes/fixed-points/GFPs/Colist.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": 1196, "size": 3638 }
module Issue561 where open import Common.Prelude hiding (primIsDigit) primitive primIsDigit : Char → Bool main : IO Bool main = return true
{ "alphanum_fraction": 0.7602739726, "avg_line_length": 13.2727272727, "ext": "agda", "hexsha": "64c81dd9df6be0d24388116c0c71446b592302c9", "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/Compiler/simple/Issue561.agda", "max_issues_count": 6, "max_issues_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_issues_repo_issues_event_max_datetime": "2017-02-24T19:38:17.000Z", "max_issues_repo_issues_event_min_datetime": "2017-02-24T19:27:31.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "alhassy/agda", "max_issues_repo_path": "test/Compiler/simple/Issue561.agda", "max_line_length": 47, "max_stars_count": 4, "max_stars_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "alhassy/agda", "max_stars_repo_path": "test/Compiler/simple/Issue561.agda", "max_stars_repo_stars_event_max_datetime": "2019-12-23T04:56:23.000Z", "max_stars_repo_stars_event_min_datetime": "2017-02-24T16:53:22.000Z", "num_tokens": 38, "size": 146 }
------------------------------------------------------------------------ -- The Step function, used to define strong and weak bisimilarity as -- well as expansion ------------------------------------------------------------------------ {-# OPTIONS --sized-types #-} open import Prelude open import Labelled-transition-system module Bisimilarity.Step {ℓ} (lts : LTS ℓ) (open LTS lts) (_[_]↝₁_ _[_]↝₂_ : Proc → Label → Proc → Type ℓ) where open import Equality.Propositional open import Logical-equivalence using (_⇔_) open import Bijection equality-with-J using (_↔_) import Equivalence equality-with-J as Eq open import Function-universe equality-with-J as F hiding (_∘_) open import H-level.Closure equality-with-J import Similarity.Step lts as One-sided open import Indexed-container hiding (⟨_⟩) open import Indexed-container.Combinators hiding (_∘_) open import Relation private module Temporarily-private where -- If _[_]↝₁_ and _[_]↝₂_ are instantiated with _[_]⟶_, then this is -- basically the function from Definition 6.3.1 in Pous and -- Sangiorgi's "Enhancements of the bisimulation proof method", -- except that clause (3) is omitted. -- -- Similarly, if the relations are instantiated with _[_]⇒̂_, then -- this is basically the function wb₁, again with the exception that -- clause (3) is omitted. -- -- Finally, if _[_]↝₁_ is instantiated with _[_]⟶̂_ and _[_]↝₂_ is -- instantiated with _[_]⇒_, then we get the expansion relation's -- "step" function. record Step {r} (R : Rel₂ r Proc) (pq : Proc × Proc) : Type (ℓ ⊔ r) where constructor ⟨_,_⟩ private p = proj₁ pq q = proj₂ pq field left-to-right : ∀ {p′ μ} → p [ μ ]⟶ p′ → ∃ λ q′ → q [ μ ]↝₁ q′ × R (p′ , q′) right-to-left : ∀ {q′ μ} → q [ μ ]⟶ q′ → ∃ λ p′ → p [ μ ]↝₂ p′ × R (p′ , q′) open Temporarily-private using (Step) -- The Step function, expressed as an indexed container. StepC : Container (Proc × Proc) (Proc × Proc) StepC = One-sided.StepC _[_]↝₁_ ⟷ One-sided.StepC _[_]↝₂_ -- The strong bisimilarity container presented in the paper, -- generalised to use _[_]↝₁_ and _[_]↝₂_. StepC′ : Container (Proc × Proc) (Proc × Proc) StepC′ = (λ { (p , q) → (∀ {p′ μ} → p [ μ ]⟶ p′ → ∃ λ q′ → q [ μ ]↝₁ q′) × (∀ {q′ μ} → q [ μ ]⟶ q′ → ∃ λ p′ → p [ μ ]↝₂ p′) }) ◁ (λ { {(p , q)} (lr , rl) (p′ , q′) → (∃ λ μ → ∃ λ (p⟶p′ : p [ μ ]⟶ p′) → proj₁ (lr p⟶p′) ≡ q′) ⊎ (∃ λ μ → ∃ λ (q⟶q′ : q [ μ ]⟶ q′) → proj₁ (rl q⟶q′) ≡ p′) }) -- The interpretations of the two containers above are pointwise -- logically equivalent, and in the presence of extensionality they -- are pointwise isomorphic. StepC↔StepC′ : ∀ {k r} {R : Rel₂ r Proc} {pq} → Extensionality? k ℓ (ℓ ⊔ r) → ⟦ StepC ⟧ R pq ↝[ k ] ⟦ StepC′ ⟧ R pq StepC↔StepC′ {pq = p , q} = inverse-ext? λ {k} ext → Σ-cong (inverse $ drop-⊤-left-Σ (One-sided.Magic↔⊤ _) ×-cong drop-⊤-left-Σ (One-sided.Magic↔⊤ _)) λ { (lr , rl) → implicit-∀-cong ext λ { {p′ , q′} → Π-cong (lower-extensionality? k lzero ℓ ext) (F.id ⊎-cong ( (∃ λ μ → ∃ λ (q⟶q′ : q [ μ ]⟶ q′) → proj₁ (rl q⟶q′) ≡ p′) ↝⟨ inverse $ drop-⊤-left-Σ (_⇔_.to contractible⇔↔⊤ (singleton-contractible _)) ⟩ (∃ λ (q′p′≡ : ∃ λ q′p′ → q′p′ ≡ (q′ , p′)) → ∃ λ μ → ∃ λ (q⟶q′ : q [ μ ]⟶ proj₁ (proj₁ q′p′≡)) → proj₁ (rl q⟶q′) ≡ proj₂ (proj₁ q′p′≡)) ↝⟨ inverse Σ-assoc ⟩ (∃ λ q′p′ → q′p′ ≡ (q′ , p′) × ∃ λ μ → ∃ λ (q⟶q′ : q [ μ ]⟶ proj₁ q′p′) → proj₁ (rl q⟶q′) ≡ proj₂ q′p′) ↔⟨ (∃-cong λ _ → (inverse $ Eq.≃-≡ (Eq.↔⇒≃ ×-comm)) ×-cong F.id) ⟩□ (∃ λ q′p′ → swap q′p′ ≡ (p′ , q′) × ∃ λ μ → ∃ λ (q⟶q′ : q [ μ ]⟶ proj₁ q′p′) → proj₁ (rl q⟶q′) ≡ proj₂ q′p′) □)) (λ _ → F.id) }} -- The definition of Step in terms of a container is pointwise -- logically equivalent to the direct definition, and in the presence -- of extensionality it is pointwise isomorphic to the direct -- definition. Step↔StepC : ∀ {k r} {R : Rel₂ r Proc} {pq} → Extensionality? k ℓ (ℓ ⊔ r) → Step R pq ↝[ k ] ⟦ StepC ⟧ R pq Step↔StepC {R = R} {pq} ext = Step R pq ↔⟨ lemma ⟩ One-sided.Step _[_]↝₁_ R pq × One-sided.Step _[_]↝₂_ (R ⁻¹) (swap pq) ↝⟨ One-sided.Step↔StepC _ ext ×-cong One-sided.Step↔StepC _ ext ⟩ ⟦ One-sided.StepC _[_]↝₁_ ⟧ R pq × ⟦ One-sided.StepC _[_]↝₂_ ⟧ (R ⁻¹) (swap pq) ↝⟨ inverse-ext? (λ ext → ⟦⟷⟧↔ ext (One-sided.StepC _[_]↝₁_) (One-sided.StepC _[_]↝₂_)) ext ⟩□ ⟦ StepC ⟧ R pq □ where lemma : _ ↔ _ lemma = record { surjection = record { logical-equivalence = record { to = λ s → One-sided.⟨ Step.left-to-right s ⟩ , One-sided.⟨ Step.right-to-left s ⟩ ; from = λ { (lr , rl) → Temporarily-private.⟨ One-sided.Step.challenge lr , One-sided.Step.challenge rl ⟩ } } ; right-inverse-of = λ _ → refl } ; left-inverse-of = λ _ → refl } -- A variant of the previous lemma, stated for StepC′ instead of -- StepC. Step↔StepC′ : ∀ {k r} {R : Rel₂ r Proc} {pq} → Extensionality? k ℓ (ℓ ⊔ r) → Step R pq ↝[ k ] ⟦ StepC′ ⟧ R pq Step↔StepC′ {R = R} {pq} ext = Step R pq ↝⟨ Step↔StepC ext ⟩ ⟦ StepC ⟧ R pq ↝⟨ StepC↔StepC′ ext ⟩□ ⟦ StepC′ ⟧ R pq □ module StepC {r} {R : Rel₂ r Proc} {p q} where -- A "constructor". ⟨_,_⟩ : (∀ {p′ μ} → p [ μ ]⟶ p′ → ∃ λ q′ → q [ μ ]↝₁ q′ × R (p′ , q′)) → (∀ {q′ μ} → q [ μ ]⟶ q′ → ∃ λ p′ → p [ μ ]↝₂ p′ × R (p′ , q′)) → ⟦ StepC ⟧ R (p , q) ⟨ lr , rl ⟩ = _⇔_.to (Step↔StepC _) Temporarily-private.⟨ lr , rl ⟩ -- Some "projections". left-to-right : ⟦ StepC ⟧ R (p , q) → ∀ {p′ μ} → p [ μ ]⟶ p′ → ∃ λ q′ → q [ μ ]↝₁ q′ × R (p′ , q′) left-to-right = Step.left-to-right ∘ _⇔_.from (Step↔StepC _) right-to-left : ⟦ StepC ⟧ R (p , q) → ∀ {q′ μ} → q [ μ ]⟶ q′ → ∃ λ p′ → p [ μ ]↝₂ p′ × R (p′ , q′) right-to-left = Step.right-to-left ∘ _⇔_.from (Step↔StepC _) open Temporarily-private public
{ "alphanum_fraction": 0.4992969848, "avg_line_length": 33.3385416667, "ext": "agda", "hexsha": "1164873c4326f6d5bd4b1f1b4bdafe9661eb6979", "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": "b936ff85411baf3401ad85ce85d5ff2e9aa0ca14", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "nad/up-to", "max_forks_repo_path": "src/Bisimilarity/Step.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "b936ff85411baf3401ad85ce85d5ff2e9aa0ca14", "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/up-to", "max_issues_repo_path": "src/Bisimilarity/Step.agda", "max_line_length": 141, "max_stars_count": null, "max_stars_repo_head_hexsha": "b936ff85411baf3401ad85ce85d5ff2e9aa0ca14", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "nad/up-to", "max_stars_repo_path": "src/Bisimilarity/Step.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 2458, "size": 6401 }
{-# OPTIONS --without-K --safe #-} module Categories.Adjoint where -- Adjoints open import Level open import Data.Product using (_,_; _×_) open import Function using (_$_) renaming (_∘_ to _∙_) open import Function.Equality using (Π; _⟶_) import Function.Inverse as FI open import Relation.Binary using (Rel; IsEquivalence; Setoid) -- be explicit in imports to 'see' where the information comes from open import Categories.Category.Core using (Category) open import Categories.Category.Product using (Product; _⁂_) open import Categories.Category.Instance.Setoids open import Categories.Morphism open import Categories.Functor using (Functor; _∘F_) renaming (id to idF) open import Categories.Functor.Bifunctor using (Bifunctor) open import Categories.Functor.Hom using (Hom[_][-,-]) open import Categories.Functor.Construction.LiftSetoids open import Categories.NaturalTransformation using (NaturalTransformation; ntHelper; _∘ₕ_; _∘ᵥ_; _∘ˡ_; _∘ʳ_) renaming (id to idN) open import Categories.NaturalTransformation.NaturalIsomorphism using (NaturalIsomorphism; unitorˡ; unitorʳ; associator; _≃_) import Categories.Morphism.Reasoning as MR private variable o o′ o″ ℓ ℓ′ ℓ″ e e′ e″ : Level C D E : Category o ℓ e record Adjoint (L : Functor C D) (R : Functor D C) : Set (levelOfTerm L ⊔ levelOfTerm R) where private module C = Category C module D = Category D module L = Functor L module R = Functor R field unit : NaturalTransformation idF (R ∘F L) counit : NaturalTransformation (L ∘F R) idF module unit = NaturalTransformation unit module counit = NaturalTransformation counit field zig : ∀ {A : C.Obj} → counit.η (L.F₀ A) D.∘ L.F₁ (unit.η A) D.≈ D.id zag : ∀ {B : D.Obj} → R.F₁ (counit.η B) C.∘ unit.η (R.F₀ B) C.≈ C.id private variable A : C.Obj B : D.Obj Ladjunct : L.F₀ A D.⇒ B → A C.⇒ R.F₀ B Ladjunct f = R.F₁ f C.∘ unit.η _ Radjunct : A C.⇒ R.F₀ B → L.F₀ A D.⇒ B Radjunct f = counit.η _ D.∘ L.F₁ f RLadjunct≈id : ∀ {f : L.F₀ A D.⇒ B} → Radjunct (Ladjunct f) D.≈ f RLadjunct≈id {f = f} = begin Radjunct (Ladjunct f) ≈⟨ refl⟩∘⟨ L.homomorphism ⟩ counit.η _ D.∘ L.F₁ (R.F₁ f) D.∘ L.F₁ (unit.η _) ≈⟨ pullˡ (counit.commute f) ⟩ (f D.∘ counit.η _) D.∘ L.F₁ (unit.η _) ≈⟨ pullʳ zig ⟩ f D.∘ D.id ≈⟨ D.identityʳ ⟩ f ∎ where open D.HomReasoning open MR D LRadjunct≈id : ∀ {f : A C.⇒ R.F₀ B} → Ladjunct (Radjunct f) C.≈ f LRadjunct≈id {f = f} = begin Ladjunct (Radjunct f) ≈⟨ R.homomorphism ⟩∘⟨refl ⟩ (R.F₁ (counit.η _) C.∘ R.F₁ (L.F₁ f)) C.∘ unit.η _ ≈˘⟨ pushʳ (unit.commute f) ⟩ R.F₁ (counit.η _) C.∘ unit.η _ C.∘ f ≈⟨ pullˡ zag ⟩ C.id C.∘ f ≈⟨ C.identityˡ ⟩ f ∎ where open C.HomReasoning open MR C Hom[L-,-] : Bifunctor C.op D (Setoids _ _) Hom[L-,-] = Hom[ D ][-,-] ∘F (L.op ⁂ idF) Hom[-,R-] : Bifunctor C.op D (Setoids _ _) Hom[-,R-] = Hom[ C ][-,-] ∘F (idF ⁂ R) module Hom[L-,-] = Functor Hom[L-,-] module Hom[-,R-] = Functor Hom[-,R-] -- Inverse is more 'categorical' than bijection defined via injection/surjection Hom-inverse : ∀ A B → FI.Inverse (Hom[L-,-].F₀ (A , B)) (Hom[-,R-].F₀ (A , B)) Hom-inverse A B = record { to = record { _⟨$⟩_ = Ladjunct {A} {B} ; cong = C.∘-resp-≈ˡ ∙ R.F-resp-≈ } ; from = record { _⟨$⟩_ = Radjunct {A} {B} ; cong = D.∘-resp-≈ʳ ∙ L.F-resp-≈ } ; inverse-of = record { left-inverse-of = λ _ → RLadjunct≈id ; right-inverse-of = λ _ → LRadjunct≈id } } module Hom-inverse {A} {B} = FI.Inverse (Hom-inverse A B) op : Adjoint R.op L.op op = record { unit = counit.op ; counit = unit.op ; zig = zag ; zag = zig } -- naturality condition on the two hom functors. -- these conditions are separated out because a complication due to the -- universe level in Agda. module _ where open C open HomReasoning open MR C Ladjunct-comm : ∀ {X Y A B} {h i : L.F₀ X D.⇒ Y} {f : A ⇒ X} {g : Y D.⇒ B} → h D.≈ i → R.F₁ (g D.∘ h D.∘ L.F₁ f) ∘ unit.η A ≈ R.F₁ g ∘ (R.F₁ i ∘ unit.η X) ∘ f Ladjunct-comm {X} {Y} {A} {B} {h} {i} {f} {g} eq = begin R.F₁ (g D.∘ h D.∘ L.F₁ f) ∘ unit.η A ≈⟨ R.homomorphism ⟩∘⟨refl ⟩ (R.F₁ g ∘ R.F₁ (h D.∘ L.F₁ f)) ∘ unit.η A ≈⟨ (refl⟩∘⟨ R.homomorphism) ⟩∘⟨refl ⟩ (R.F₁ g ∘ R.F₁ h ∘ R.F₁ (L.F₁ f)) ∘ unit.η A ≈⟨ pullʳ assoc ⟩ R.F₁ g ∘ R.F₁ h ∘ R.F₁ (L.F₁ f) ∘ unit.η A ≈˘⟨ refl⟩∘⟨ ⟺ (R.F-resp-≈ eq) ⟩∘⟨ unit.commute f ⟩ R.F₁ g ∘ R.F₁ i ∘ unit.η X ∘ f ≈⟨ refl⟩∘⟨ sym-assoc ⟩ R.F₁ g ∘ (R.F₁ i ∘ unit.η X) ∘ f ∎ Ladjunct-comm′ : ∀ {X A B} {f : A ⇒ X} {g : L.F₀ X D.⇒ B} → Ladjunct (g D.∘ L.F₁ f) ≈ Ladjunct g ∘ f Ladjunct-comm′ = ∘-resp-≈ˡ R.homomorphism ○ (pullʳ (⟺ (unit.commute _))) ○ sym-assoc Ladjunct-resp-≈ : ∀ {A B} {f g : L.F₀ A D.⇒ B} → f D.≈ g → Ladjunct f ≈ Ladjunct g Ladjunct-resp-≈ eq = ∘-resp-≈ˡ (R.F-resp-≈ eq) module _ where open D open HomReasoning open MR D Radjunct-comm : ∀ {X Y A B} {h i : X C.⇒ R.F₀ Y} {f : A C.⇒ X} {g : Y ⇒ B} → h C.≈ i → counit.η B ∘ L.F₁ (R.F₁ g C.∘ h C.∘ f) ≈ g ∘ (counit.η Y ∘ L.F₁ i) ∘ L.F₁ f Radjunct-comm {X} {Y} {A} {B} {h} {i} {f} {g} eq = begin counit.η B ∘ L.F₁ (R.F₁ g C.∘ h C.∘ f) ≈⟨ refl⟩∘⟨ L.homomorphism ⟩ counit.η B ∘ L.F₁ (R.F₁ g) ∘ L.F₁ (h C.∘ f) ≈⟨ pullˡ (counit.commute g) ⟩ (g ∘ counit.η Y) ∘ L.F₁ (h C.∘ f) ≈⟨ refl⟩∘⟨ L.homomorphism ⟩ (g ∘ counit.η Y) ∘ L.F₁ h ∘ L.F₁ f ≈⟨ refl⟩∘⟨ L.F-resp-≈ eq ⟩∘⟨refl ⟩ (g ∘ counit.η Y) ∘ L.F₁ i ∘ L.F₁ f ≈⟨ pullʳ sym-assoc ⟩ g ∘ (counit.η Y ∘ L.F₁ i) ∘ L.F₁ f ∎ Radjunct-comm′ : ∀ {Y A B} {f : A C.⇒ R.F₀ Y} {g : Y ⇒ B} → Radjunct (R.F₁ g C.∘ f) ≈ g ∘ Radjunct f Radjunct-comm′ = ∘-resp-≈ʳ L.homomorphism ○ pullˡ (counit.commute _) ○ assoc Radjunct-resp-≈ : ∀ {A B} {f g : A C.⇒ R.F₀ B} → f C.≈ g → Radjunct f ≈ Radjunct g Radjunct-resp-≈ eq = ∘-resp-≈ʳ (L.F-resp-≈ eq) -- a complication: the two hom functors do not live in the same Setoids, -- so they need to be mapped to the same Setoids first before establishing -- natural isomorphism! module _ where private levelℓ : Category o ℓ e → Level levelℓ {ℓ = ℓ} _ = ℓ levele : Category o ℓ e → Level levele {e = e} _ = e Hom[L-,-]′ : Bifunctor C.op D (Setoids _ _) Hom[L-,-]′ = LiftSetoids (levelℓ C) (levele C) ∘F Hom[ D ][-,-] ∘F (L.op ⁂ idF) Hom[-,R-]′ : Bifunctor C.op D (Setoids _ _) Hom[-,R-]′ = LiftSetoids (levelℓ D) (levele D) ∘F Hom[ C ][-,-] ∘F (idF ⁂ R) Hom-NI : NaturalIsomorphism Hom[L-,-]′ Hom[-,R-]′ Hom-NI = record { F⇒G = ntHelper record { η = λ _ → record { _⟨$⟩_ = λ f → lift (Ladjunct (lower f)) ; cong = λ eq → lift (Ladjunct-resp-≈ (lower eq)) } ; commute = λ _ eq → lift $ Ladjunct-comm (lower eq) } ; F⇐G = ntHelper record { η = λ _ → record { _⟨$⟩_ = λ f → lift (Radjunct (lower f)) ; cong = λ eq → lift (Radjunct-resp-≈ (lower eq)) } ; commute = λ _ eq → lift $ Radjunct-comm (lower eq) } ; iso = λ X → record { isoˡ = λ eq → let open D.HomReasoning in lift (RLadjunct≈id ○ lower eq) ; isoʳ = λ eq → let open C.HomReasoning in lift (LRadjunct≈id ○ lower eq) } } module Hom-NI = NaturalIsomorphism Hom-NI infix 5 _⊣_ _⊣_ = Adjoint ⊣-id : idF {C = C} ⊣ idF {C = C} ⊣-id {C = C} = record { unit = F⇐G unitorˡ ; counit = F⇒G unitorʳ ; zig = identityˡ ; zag = identityʳ } where open Category C open NaturalIsomorphism
{ "alphanum_fraction": 0.5292742927, "avg_line_length": 36.6216216216, "ext": "agda", "hexsha": "5d0ea0981e2e0b0b89ddca997ef613a3647f49e5", "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": "5a49c6ac87cbb7e20511c28f28205163fe69f48f", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "laMudri/agda-categories", "max_forks_repo_path": "src/Categories/Adjoint.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "5a49c6ac87cbb7e20511c28f28205163fe69f48f", "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": "laMudri/agda-categories", "max_issues_repo_path": "src/Categories/Adjoint.agda", "max_line_length": 108, "max_stars_count": null, "max_stars_repo_head_hexsha": "5a49c6ac87cbb7e20511c28f28205163fe69f48f", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "laMudri/agda-categories", "max_stars_repo_path": "src/Categories/Adjoint.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 3351, "size": 8130 }
module main where open import IO main : Main main = run (putStrLn "Hello World!")
{ "alphanum_fraction": 0.7142857143, "avg_line_length": 12, "ext": "agda", "hexsha": "bd4670a480a64dfda52fe1ec89feeed7277b2939", "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": "e258ac3c5645718c6ae7fc3f79c3790996255a11", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "jappeace/agda-nix", "max_forks_repo_path": "src/main.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "e258ac3c5645718c6ae7fc3f79c3790996255a11", "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": "jappeace/agda-nix", "max_issues_repo_path": "src/main.agda", "max_line_length": 36, "max_stars_count": null, "max_stars_repo_head_hexsha": "e258ac3c5645718c6ae7fc3f79c3790996255a11", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "jappeace/agda-nix", "max_stars_repo_path": "src/main.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 22, "size": 84 }
{-# OPTIONS --omega-in-omega --no-termination-check --overlapping-instances #-} module Light.Implementation.Relation.Binary.Equality.Propositional where open import Agda.Builtin.Equality using (_≡_ ; refl) open import Light.Library.Relation.Binary using (SelfSymmetric ; SelfTransitive ; Reflexive ; Binary ; SelfBinary ; Symmetric ; Transitive ; CongruentFor ; Preserved) open import Light.Implementation.Relation.Sets using (base) public open import Light.Library.Relation.Binary.Equality using (SelfEquality ; wrap) open import Light.Variable.Sets open import Light.Variable.Levels open Reflexive open Symmetric open Transitive open Preserved module _ {𝕒 : Set aℓ} where instance relation : SelfBinary 𝕒 relation = record { are = λ a b → a ≡ b } instance reflexive : Reflexive relation reflexive .reflexivity = refl instance symmetric : SelfSymmetric relation symmetric .symmetry refl = refl instance transitive : SelfTransitive relation transitive .transitivity refl refl = refl instance equals : SelfEquality 𝕒 equals = wrap relation instance congruent : ∀ {f : 𝕒 → 𝕓} → CongruentFor f relation relation congruent .preservation refl = refl
{ "alphanum_fraction": 0.731511254, "avg_line_length": 34.5555555556, "ext": "agda", "hexsha": "b219f88a4897d9801c53c7ce78f609f66184b9e3", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "44b1c724f2de95d3a9effe87ca36ef9eca8b4756", "max_forks_repo_licenses": [ "0BSD" ], "max_forks_repo_name": "Zambonifofex/lightlib", "max_forks_repo_path": "Light/Implementation/Relation/Binary/Equality/Propositional.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "44b1c724f2de95d3a9effe87ca36ef9eca8b4756", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "0BSD" ], "max_issues_repo_name": "Zambonifofex/lightlib", "max_issues_repo_path": "Light/Implementation/Relation/Binary/Equality/Propositional.agda", "max_line_length": 130, "max_stars_count": 1, "max_stars_repo_head_hexsha": "44b1c724f2de95d3a9effe87ca36ef9eca8b4756", "max_stars_repo_licenses": [ "0BSD" ], "max_stars_repo_name": "zamfofex/lightlib", "max_stars_repo_path": "Light/Implementation/Relation/Binary/Equality/Propositional.agda", "max_stars_repo_stars_event_max_datetime": "2019-12-20T21:33:05.000Z", "max_stars_repo_stars_event_min_datetime": "2019-12-20T21:33:05.000Z", "num_tokens": 300, "size": 1244 }
{-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.ZCohomology.Groups.Torus where open import Cubical.ZCohomology.Base open import Cubical.ZCohomology.Properties open import Cubical.ZCohomology.Groups.Connected open import Cubical.ZCohomology.MayerVietorisUnreduced open import Cubical.ZCohomology.Groups.Unit open import Cubical.ZCohomology.Groups.Sn open import Cubical.ZCohomology.Groups.Prelims open import Cubical.ZCohomology.KcompPrelims open import Cubical.Foundations.HLevels open import Cubical.Foundations.Function open import Cubical.Foundations.Univalence open import Cubical.Foundations.Prelude open import Cubical.Foundations.Pointed open import Cubical.Foundations.Isomorphism open import Cubical.Foundations.GroupoidLaws open import Cubical.Data.Sigma open import Cubical.Data.Int renaming (_+_ to _+ℤ_; +-comm to +ℤ-comm ; +-assoc to +ℤ-assoc) open import Cubical.Data.Nat open import Cubical.Data.Unit open import Cubical.Algebra.Group open import Cubical.HITs.Pushout open import Cubical.HITs.S1 open import Cubical.HITs.Sn open import Cubical.HITs.Susp open import Cubical.HITs.SetTruncation renaming (rec to sRec ; elim to sElim ; elim2 to sElim2) open import Cubical.HITs.PropositionalTruncation renaming (rec to pRec ; elim2 to pElim2 ; ∣_∣ to ∣_∣₁) open import Cubical.HITs.Nullification open import Cubical.HITs.Truncation renaming (elim to trElim ; elim2 to trElim2 ; map to trMap ; rec to trRec) --------- H⁰(T²) ------------ H⁰-T²≅ℤ : GroupEquiv (coHomGr 0 (S₊ 1 × S₊ 1)) intGroup H⁰-T²≅ℤ = H⁰-connected (north , north) λ (a , b) → pRec propTruncIsProp (λ id1 → pRec propTruncIsProp (λ id2 → ∣ ΣPathP (id1 , id2) ∣₁) (Sn-connected 0 b) ) (Sn-connected 0 a) ------------------ H¹(T²) ------------------------------- H¹-T²≅ℤ×ℤ : GroupEquiv (coHomGr 1 ((S₊ 1) × (S₊ 1))) (dirProd intGroup intGroup) H¹-T²≅ℤ×ℤ = groupequiv (isoToEquiv (setTruncIso (curryIso ⋄ codomainIso S1→K₁≡S1×Int ⋄ toProdIso) ⋄ setTruncOfProdIso)) (sElim2 (λ _ _ → isOfHLevelPath 2 (isOfHLevelΣ 2 setTruncIsSet (λ _ → setTruncIsSet)) _ _) λ f g → ΣPathP ((cong ∣_∣₂ (funExt (λ x → helper (f (x , S¹→S1 base) +ₖ g (x , S¹→S1 base)) ∙ sym (cong₂ (λ x y → x +ₖ y) (helper (f (x , S¹→S1 base))) (helper (g (x , S¹→S1 base))))))) , (cong ∣_∣₂ (funExt (suspToPropRec north (λ _ → isSetInt _ _) (cong winding (basechange-lemma2 (λ x → f (north , S¹→S1 x)) (λ x → g (north , S¹→S1 x)) λ x → S¹map (trMap S1→S¹ x)) ∙∙ winding-hom (basechange2⁻ (S¹map (trMap S1→S¹ (f (north , S¹→S1 base)))) (λ i → S¹map (trMap S1→S¹ (f (north , S¹→S1 (loop i)))))) (basechange2⁻ (S¹map (trMap S1→S¹ (g (north , S¹→S1 base)))) (λ i → S¹map (trMap S1→S¹ (g (north , S¹→S1 (loop i)))))) ∙∙ sym (addLemma (winding (basechange2⁻ (S¹map (trMap S1→S¹ (f (north , S¹→S1 base)))) (λ i → S¹map (trMap S1→S¹ (f (north , S¹→S1 (loop i))))))) (winding (basechange2⁻ (S¹map (trMap S1→S¹ (g (north , S¹→S1 base)))) (λ i → S¹map (trMap S1→S¹ (g (north , S¹→S1 (loop i)))))))))))))) □ dirProdEquiv (invGroupEquiv (Hⁿ-Sⁿ≅ℤ 0)) (H⁰-Sⁿ≅ℤ 0) where helper : (x : hLevelTrunc 3 (S₊ 1)) → ∣ S¹→S1 (S¹map (trMap S1→S¹ x)) ∣ ≡ x helper = trElim (λ _ → isOfHLevelPath 3 (isOfHLevelTrunc 3) _ _) λ a → cong ∣_∣ (S1→S¹-retr a) ------------------------------------------------------------- ----------------------- H²(T²) ------------------------------ open import Cubical.Foundations.Equiv H²-T²≅ℤ : GroupEquiv (coHomGr 2 (S₊ 1 × S₊ 1)) intGroup H²-T²≅ℤ = invGroupEquiv ℤ≅H²-T² where ℤ≅H²-T² : GroupEquiv intGroup (coHomGr 2 (S₊ 1 × S₊ 1)) GroupEquiv.eq ℤ≅H²-T² = compEquiv (isoToEquiv helper') (compEquiv (invEquiv (≃-× (GroupEquiv.eq H²-S¹≅0) (invEquiv (GroupEquiv.eq (Hⁿ-Sⁿ≅ℤ 0))))) (isoToEquiv (invIso setTruncOfProdIso ⋄ invIso (setTruncIso (curryIso ⋄ codomainIso S1→K2≡K2×K1 ⋄ toProdIso))))) where helper' : Iso Int (Unit × Int) Iso.inv helper' = snd Iso.fun helper' x = tt , x Iso.leftInv helper' _ = refl Iso.rightInv helper' _ = refl GroupEquiv.isHom ℤ≅H²-T² a b = (λ i → f (GroupEquiv.isHom (invGroupEquiv (dirProdEquiv H²-S¹≅0 (invGroupEquiv (Hⁿ-Sⁿ≅ℤ 0)))) (_ , a) (_ , b) i)) ∙ ((λ i → f (guyId i , (g a +ₕ g b))) ∙∙ helper (g a) (g b) ∙∙ (λ i → f (guyId2 (~ i) , g a) +ₕ f (guyId2 (~ i) , g b))) where f = Iso.fun (((invIso setTruncOfProdIso ⋄ invIso (setTruncIso (curryIso ⋄ codomainIso S1→K2≡K2×K1 ⋄ toProdIso))))) g = invEq (GroupEquiv.eq (invGroupEquiv (Hⁿ-Sⁿ≅ℤ 0))) isPropH²-S¹ : isProp (coHom 2 (S₊ 1)) isPropH²-S¹ = transport (λ i → isProp (ua (GroupEquiv.eq H²-S¹≅0) (~ i))) isPropUnit guyId : ∣ _ ∣₂ ≡ 0ₕ guyId = isPropH²-S¹ _ _ guyId2 : ∣ _ ∣₂ ≡ 0ₕ guyId2 = isPropH²-S¹ _ _ helper : (x y : ∥ ((S₊ 1) → (hLevelTrunc 3 (S₊ 1) )) ∥₂) → f (0ₕ , x +ₕ y) ≡ f (0ₕ , x) +ₕ f (0ₕ , y) helper = sElim2 (λ _ _ → isOfHLevelPath 2 setTruncIsSet _ _) λ f g i → ∣ (λ x → helper2 (f (fst x)) (g (fst x)) (snd x) i) ∣₂ where helper2 : (x y : coHomK 1) (s : S₊ 1) → Iso.inv S1→K2≡K2×K1 (0ₖ , x +ₖ y) s ≡ (Iso.inv S1→K2≡K2×K1 (0ₖ , x)) s +ₖ (Iso.inv S1→K2≡K2×K1 (0ₖ , y)) s helper2 = trElim2 (λ _ _ → isOfHLevelΠ 3 λ _ → isOfHLevelTrunc 4 _ _) λ a b → λ {north → cong₂ (_+ₖ_) (sym (lUnitₖ 0ₖ)) (sym (lUnitₖ 0ₖ)) ; south → cong₂ (_+ₖ_) (sym (lUnitₖ 0ₖ)) (sym (lUnitₖ 0ₖ)) ; (merid south i) j → hcomp (λ k → λ {(i = i0) → cong₂ (_+ₖ_) (sym (lUnitₖ 0ₖ)) (sym (lUnitₖ 0ₖ)) (j ∧ k) ; (i = i1) → cong₂ (_+ₖ_) (sym (lUnitₖ 0ₖ)) (sym (lUnitₖ 0ₖ)) (j ∧ k) ; (j = i0) → 0ₖ +ₖ Kn→ΩKn+1 1 (∣ a ∣ +ₖ ∣ b ∣) i ; (j = i1) → cong₂ (_+ₖ_) (sym (lUnitₖ (Kn→ΩKn+1 1 ∣ a ∣ i))) (sym (lUnitₖ (Kn→ΩKn+1 1 ∣ b ∣ i))) k}) (helper3 ∣ a ∣ ∣ b ∣ j i) ; (merid north i) → cong₂ (_+ₖ_) (sym (lUnitₖ 0ₖ)) (sym (lUnitₖ 0ₖ)) } where helper3 : (a b : coHomK 1) → cong (0ₖ +ₖ_) (Kn→ΩKn+1 1 (a +ₖ b)) ≡ cong₂ _+ₖ_ (Kn→ΩKn+1 1 a) (Kn→ΩKn+1 1 b) helper3 a b = (cong (cong (0ₖ +ₖ_)) helper4 ∙ congFunct (0ₖ +ₖ_) (Kn→ΩKn+1 1 a) (Kn→ΩKn+1 1 b)) ∙∙ cong (_∙ cong (0ₖ +ₖ_) (Kn→ΩKn+1 1 b)) (helper5 (Kn→ΩKn+1 1 a)) ∙∙ sym (cong₂Funct (_+ₖ_) (Kn→ΩKn+1 1 a) (Kn→ΩKn+1 1 b)) where helper4 : Kn→ΩKn+1 1 (a +ₖ b) ≡ Kn→ΩKn+1 1 a ∙ Kn→ΩKn+1 1 b -- Termination issues unless this is put as a separate lemma... helper4 = +ₖ→∙ 1 a b helper6 : ∀{ℓ} {A : Type ℓ} {a b : A} (p : a ≡ b) → p ≡ (refl ∙ refl) ∙ p ∙ refl ∙ refl helper6 p = (λ i → rUnit p i) ∙∙ (λ i → lUnit (p ∙ rUnit refl i) i) ∙∙ λ i → rUnit refl i ∙ p ∙ refl ∙ refl helper5 : (a : Path (coHomK 2) 0ₖ 0ₖ) → cong (0ₖ +ₖ_) a ≡ cong (_+ₖ 0ₖ) a helper5 a = (((helper6 (cong (0ₖ +ₖ_) a)) ∙∙ (λ i → ((λ j → lUnitₖ 0ₖ (i ∧ j)) ∙ refl) ∙ cong (λ x → lUnitₖ x i) a ∙ refl ∙ λ j → lUnitₖ 0ₖ (i ∧ (~ j))) ∙∙ λ i → (lUnitₖ 0ₖ ∙ λ j → rUnitₖ 0ₖ ((~ i) ∨ (~ j))) ∙ cong (λ x → rUnitₖ x (~ i)) a ∙ (λ j → rUnitₖ 0ₖ (~ i ∨ j)) ∙ sym (lUnitₖ 0ₖ)) ∙∙ (λ i → (lUnitₖ 0ₖ ∙ sym (rUnitₖ 0ₖ)) ∙ isCommΩK-based 2 (0ₖ +ₖ 0ₖ) (cong (_+ₖ 0ₖ) a) (rUnitₖ 0ₖ ∙ sym (lUnitₖ 0ₖ)) i) ∙∙ λ i → assoc (lUnitₖ 0ₖ ∙ sym (rUnitₖ 0ₖ)) (symDistr ((lUnitₖ 0ₖ)) (sym (rUnitₖ 0ₖ)) (~ i)) (cong (_+ₖ 0ₖ) a) i) ∙∙ cong (_∙ (cong (_+ₖ 0ₖ) a)) (rCancel (lUnitₖ 0ₖ ∙ sym (rUnitₖ 0ₖ))) ∙∙ sym (lUnit (cong (_+ₖ 0ₖ) a)) private to₂ : coHom 2 (S₊ 1 × S₊ 1) → Int to₂ = fst (GroupEquiv.eq H²-T²≅ℤ) from₂ : Int → coHom 2 (S₊ 1 × S₊ 1) from₂ = invEq (GroupEquiv.eq H²-T²≅ℤ) to₁ : coHom 1 (S₊ 1 × S₊ 1) → Int × Int to₁ = fst (GroupEquiv.eq H¹-T²≅ℤ×ℤ) from₁ : Int × Int → coHom 1 (S₊ 1 × S₊ 1) from₁ = invEq (GroupEquiv.eq H¹-T²≅ℤ×ℤ) to₀ : coHom 0 (S₊ 1 × S₊ 1) → Int to₀ = fst (GroupEquiv.eq H⁰-T²≅ℤ) from₀ : Int → coHom 0 (S₊ 1 × S₊ 1) from₀ = invEq (GroupEquiv.eq H⁰-T²≅ℤ)
{ "alphanum_fraction": 0.4609343536, "avg_line_length": 51.7291666667, "ext": "agda", "hexsha": "98222404fc59a468eadbdca438818f2dead7810e", "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": "f6771617374bfe65a7043d00731fed5a673aa729", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "knrafto/cubical", "max_forks_repo_path": "Cubical/ZCohomology/Groups/Torus.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "f6771617374bfe65a7043d00731fed5a673aa729", "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": "knrafto/cubical", "max_issues_repo_path": "Cubical/ZCohomology/Groups/Torus.agda", "max_line_length": 154, "max_stars_count": null, "max_stars_repo_head_hexsha": "f6771617374bfe65a7043d00731fed5a673aa729", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "knrafto/cubical", "max_stars_repo_path": "Cubical/ZCohomology/Groups/Torus.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 3776, "size": 9932 }
module Data.List.FunctionsProven where import Lvl open import Data.Boolean open import Data.List as List using (List ; ∅ ; _⊰_) import Data.List.Functions as List open import Data.List.Relation.Membership open import Data.List.Relation.Quantification open import Functional open import Lang.Instance open import Syntax.Function open import Type private variable ℓ : Lvl.Level private variable A B T Result : Type{ℓ} private variable P : T → Type{ℓ} foldₗ : (Result → (x : T) → P(x) → Result) → Result → (l : List(T)) → AllElements(P)(l) → Result foldₗ f result ∅ ∅ = result foldₗ f result (x ⊰ l) (px ⊰ pl) = foldₗ f (f result x px) l pl foldᵣ : ((x : T) → P(x) → Result → Result) → Result → (l : List(T)) → AllElements(P)(l) → Result foldᵣ f init ∅ ∅ = init foldᵣ f init (x ⊰ l) (px ⊰ pl) = f x px (foldᵣ f init l pl) map : ((x : A) → P(x) → B) → ((l : List(A)) → AllElements(P)(l) → List(B)) map f ∅ ∅ = ∅ map f (x ⊰ l) (px ⊰ pl) = (f x px) ⊰ (map f l pl) filter : ((x : T) → P(x) → Bool) → ((l : List(T)) → AllElements(P)(l) → List(T)) filter f ∅ ∅ = ∅ filter f (x ⊰ l) (px ⊰ pl) = (if(f(x) px) then (x List.⊰_) else id) (filter f l pl)
{ "alphanum_fraction": 0.5874587459, "avg_line_length": 36.7272727273, "ext": "agda", "hexsha": "78137d864ecd88a7ab910594d3f97d1a10679cd2", "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": "Data/List/FunctionsProven.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": "Data/List/FunctionsProven.agda", "max_line_length": 96, "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": "Data/List/FunctionsProven.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": 439, "size": 1212 }
{-# OPTIONS --without-K #-} module factorial where open import Type open import Data.Nat.NP open import Data.Product open import Data.Sum.NP open import Data.Zero open import Data.Maybe open import Data.One using (𝟙) open import Data.Fin.NP using (Fin; Fin′; zero; suc; inject₁; inject!; Fin▹ℕ; ℕ▹Fin; [zero:_,suc:_]) open import Function.NP open import Function.Extensionality open import HoTT open Equivalences open import Type.Identities open import Algebra.FunctionProperties.Eq {- open import Function.Related as FR open import Function.Related.TypeIsomorphisms.NP import Function.Inverse.NP as I open I using (_↔_; inverses; module Inverse) renaming (_$₁_ to to; _$₂_ to from) open import Relation.Binary.Product.Pointwise open import Relation.Binary.Sum -} open import Relation.Binary.PropositionalEquality.NP renaming (!_ to ¡_) open ≡-Reasoning -- n ! ≡ product [1..n] module v1 where _! : ℕ → ℕ zero ! = 1 suc n ! = (1 + n) * n ! _!★ : ℕ → ★ zero !★ = 𝟙 suc n !★ = Fin (1 + n) × n !★ module _ {{_ : UA}} where !★≡Fin! : ∀ {n} → n !★ ≡ Fin (n !) !★≡Fin! {zero} = ¡ Fin1≡𝟙 !★≡Fin! {suc n} = ×= idp !★≡Fin! ∙ Fin-×-* module v2 where _! : ℕ → ℕ _+1! : ℕ → ℕ zero ! = 1 suc n ! = n +1! n +1! = n ! + n * n ! _!★ : ℕ → ★ zero !★ = 𝟙 suc n !★ = n !★ ⊎ Fin n × n !★ 1+_!★ : ℕ → ★ 1+ n !★ = n !★ ⊎ Fin n × n !★ module _ {{_ : UA}} where !★≡Fin! : ∀ {n} → n !★ ≡ Fin (n !) !★≡Fin! {zero} = ¡ Fin1≡𝟙 !★≡Fin! {suc n} = ⊎= !★≡Fin! (×= idp !★≡Fin! ∙ Fin-×-*) ∙ Fin-⊎-+ productFin : ∀ n → (Fin n → ℕ) → ℕ productFin zero f = 1 productFin (suc n) f = f zero * productFin n (f ∘ suc) product[0…_] : ℕ → (ℕ → ℕ) → ℕ product[0… n ] f = productFin n (f ∘ Fin▹ℕ) {- product[0… zero ] f = 1 product[0… suc n ] f = f zero * product[0… n ] (f ∘ suc) -} product[1…_] : ℕ → (ℕ → ℕ) → ℕ product[1… zero ] f = 1 product[1… suc n ] f = f 1 * product[1… n ] (f ∘ suc) product[_to_] : ℕ → ℕ → (ℕ → ℕ) → ℕ product[ start to stop ] f = product[0… stop ∸ start ] (f ∘ _+_ start) {- data Bnd (l : ℕ) : (h : ℕ) → Set where low : Bnd l (suc l) suc : ∀ {h} → Bnd l h → Bnd l (suc h) Bnd▹ℕ : {l h : ℕ} → Bnd l h → ℕ Bnd▹ℕ {l} low = l Bnd▹ℕ (suc x) = suc (Bnd▹ℕ x) productBnd : ∀ {l h} → l ≤ h → (Bnd l h → ℕ) → ℕ productBnd z≤n f = {!!} productBnd (s≤s p) f = {!!} productBnd p f = {!f low * productBnd l h (f ∘ suc)!} -} test-product[1…3] : product[1… 3 ] ≡ (λ f → f 1 * (f 2 * (f 3 * 1))) test-product[1…3] = idp open v1 {- adequate1 : ∀ n → n ! ≡ product[1… n ] id adequate1 zero = ≡.refl adequate1 (suc n) rewrite adequate1 n = {!!} Π{x∈1…n}x + n * Π{x∈1…n}x (1 + n) * Π{x∈1…n}x Π{x∈1…n}1+x -} Π[0…_-1] : ℕ → (ℕ → ℕ) → ★ Π[0… n -1] f = Π (Fin n) (Fin ∘ f ∘ Fin▹ℕ) Π[0…_] : ℕ → (ℕ → ℕ) → ★ Π[0… n ] = Π[0… suc n -1] {- Π[1…_] : ℕ → (ℕ → ℕ) → ★ Π[1… 0 ] f = 𝟙 Π[1… suc n ] f = {!!} -} Π[0…_-1]′ : ℕ → (ℕ → ℕ) → ★ Π[0… zero -1]′ f = 𝟙 Π[0… suc n -1]′ f = Fin (f 0) × Π[0… n -1]′ (f ∘ suc) Π[0…_]′ : ℕ → (ℕ → ℕ) → ★ Π[0… n ]′ = Π[0… suc n -1]′ {- Π[1…_]′ : ℕ → (ℕ → ℕ) → ★ Π[1… zero ]′ f = 𝟙 Π[1… suc n ]′ f = Fin (f 1) × Π[1… n ]′ (f ∘ suc) -} [zero:,suc:] = [zero:_,suc:_] syntax [zero:,suc:] z (λ y → s) = [zero: z ,suc y :→ s ] Π! : ℕ → ★ Π! n = Π[0… n ] suc ↺ : ℕ → ★ ↺ n = Fin n → Fin n Π!↺ : ∀ {n} → Π! n → ↺ (suc n) Π!↺ {n} f = inject! ∘ f Π!↺-inj : ∀ {n}(f : Π! n) → Injective (Π!↺ f) Π!↺-inj f {x} {y} e = {!!} -- Move to Type.Identities module _ {{_ : UA}}{{_ : FunExt}} where ΠMaybe : ∀ {A : ★} {F : Maybe A → ★} → Π (Maybe A) F ≡ (F nothing × Π A (F ∘ just)) ΠMaybe {A} {F} = (Π (Maybe A) F) ≡⟨ Π≃ Maybe≃𝟙⊎ (maybe (λ _ → idp) idp) ⟩ (Π (𝟙 ⊎ A) [inl: (λ _ → F nothing) ,inr: F ∘ just ]) ≡⟨ dist-×-Π ⟩ ((𝟙 → F nothing) × Π A (F ∘ just)) ≡⟨ ×= 𝟙→A≡A idp ⟩ (F nothing × Π A (F ∘ just)) ∎ ΠFin0≡𝟙 : ∀ {F : Fin 0 → ★} → Π (Fin 0) F ≡ 𝟙 ΠFin0≡𝟙 = Π= Fin0≡𝟘 (λ()) ∙ Π𝟘-uniq₀ (λ ()) ΠFin1+ : ∀ n {F : Fin (1 + n) → ★} → Π (Fin (1 + n)) F ≡ (F zero × Π (Fin n) (F ∘ suc)) ΠFin1+ n {F} = Π (Fin (1 + n)) F ≡⟨ Π≃ Fin∘suc≃𝟙⊎Fin [zero: idp ,suc _ :→ idp ] ⟩ Π (𝟙 ⊎ Fin n) [inl: (λ _ → F zero) ,inr: F ∘ suc ] ≡⟨ dist-×-Π[] ⟩ ((𝟙 → F zero) × Π (Fin n) (F ∘ suc)) ≡⟨ ×= 𝟙→A≡A idp ⟩ (F zero × Π (Fin n) (F ∘ suc)) ∎ rot : ∀ {n} → Fin (suc n) → Fin (suc n) rot {n} = [zero: ℕ▹Fin n ,suc: inject₁ ] ΠFin1+' : ∀ n {F : Fin (1 + n) → ★} → Π (Fin (1 + n)) F ≡ (F (ℕ▹Fin n) × Π (Fin n) (F ∘ inject₁)) ΠFin1+' n {F} = Π (Fin (1 + n)) F ≡⟨ Π≃ Fin∘suc≃𝟙⊎Fin (λ x → {!WRONG!}) ⟩ Π (𝟙 ⊎ Fin n) [inl: (λ _ → F {!!}) ,inr: F ∘ {!!} ] ≡⟨ {!!} ⟩ Π (𝟙 ⊎ Fin n) [inl: (λ _ → F (ℕ▹Fin n)) ,inr: F ∘ inject₁ ] ≡⟨ dist-×-Π[] ⟩ ((𝟙 → F (ℕ▹Fin n)) × Π (Fin n) (F ∘ inject₁)) ≡⟨ ×= 𝟙→A≡A idp ⟩ (F (ℕ▹Fin n) × Π (Fin n) (F ∘ inject₁)) ∎ {- ΠFin1≡F0 : {F : Fin 1 → ★} → Π (Fin 1) F ≡ F zero ΠFin1≡F0 = ΠFin1+ 0 ∙ ×= idp ΠFin0≡𝟙 ∙ A×𝟙≡A ΠFin2≡F0×F1 : {F : Fin 2 → ★} → Π (Fin 2) F ≡ (F zero × F (suc zero)) ΠFin2≡F0×F1 = ΠFin1+ 1 ∙ ×= idp ΠFin1≡F0 test-Π[0…-1] : ∀ {f} → Π[0… 0 -1] f ≡ 𝟙 test-Π[0…-1] = ΠFin0≡𝟙 test-Π[0…0] : ∀ {f} → Π[0… 0 ] f ≡ Fin (f zero) test-Π[0…0] = ΠFin1≡F0 test-Π[0…1] : ∀ {f} → Π[0… 1 ] f ≡ (Fin (f zero) × Fin (f (suc zero))) test-Π[0…1] = ΠFin2≡F0×F1 ΠFin1+ʳ′ : ∀ n (F : ℕ → ★) → Π (Fin (1 + n)) (F ∘ Fin▹ℕ) ≡ (F n × Π (Fin n) (F ∘ Fin▹ℕ)) ΠFin1+ʳ′ n F = Π (Fin (1 + n)) (F ∘ Fin▹ℕ) ≡⟨ Π=′ (Fin (1 + n)) F∘Fin▹ℕ≗F' ⟩ Π (Fin (1 + n)) F' ≡⟨ ΠFin1+ n ⟩ (F' zero × Π (Fin n) (F' ∘ suc)) ≡⟨by-definition⟩ (F n × Π (Fin n) (F ∘ Fin▹ℕ)) ∎ where F' : (x : Fin (suc n)) → ★₀ F' zero = F n F' (suc x) = F (Fin▹ℕ x) F∘Fin▹ℕ≗F' : F ∘ Fin▹ℕ ≗ F' F∘Fin▹ℕ≗F' zero = {!!} F∘Fin▹ℕ≗F' (suc x₂) = {!!} {-Π (Fin (1 + n)) (F ∘ Fin▹ℕ) ≡⟨ {!!} ⟩ Π (𝟙 ⊎ Fin n) {!!} ≡⟨ {!dist-×-Π!} ⟩ (F n × Π (Fin n) (F ∘ Fin▹ℕ)) ∎ -} module _ {{_ : UA}}{{_ : FunExt}} where Π≡Π′[0…_-1] : ∀ n f → Π[0… n -1]′ f ≡ Π[0… n -1] f Π≡Π′[0… zero -1] f = ¡ ΠFin0≡𝟙 Π≡Π′[0… suc n -1] f = Π[0… 1 + n -1]′ f ≡⟨by-definition⟩ (Fin (f 0) × Π[0… n -1]′ (f ∘ suc)) ≡⟨ ×= idp (Π≡Π′[0… n -1] (f ∘ suc)) ⟩ (Fin (f 0) × Π[0… n -1] (f ∘ suc)) ≡⟨ ¡ ΠFin1+ n ⟩ Π[0… 1 + n -1] f ∎ Π≡Π′[0…_] : ∀ n f → Π[0… n ]′ f ≡ Π[0… n ] f Π≡Π′[0… n ] = Π≡Π′[0… suc n -1] -- (A → B ⊎ C) -- TODO -- adequate! : ∀ n → Fin (suc n) × Fin (n !) ≡ Π (Fin n) (Fin′ ∘ suc) example : ∀ {n} → (2 + n)! ≡ (2 + n) * (1 + n)! example = idp module _ {{_ : UA}}{{_ : FunExt}} where {- -- WRONG adequate! : ∀ {n} → Fin (n !) ≡ Π[0… n -1] suc adequate! {zero} = {!¡ ΠFin1≡F0!} adequate! {suc n} = (Fin ((1 + n)!)) ≡⟨by-definition⟩ Fin ((1 + n) * n !) ≡⟨ ¡ Fin-×-* ⟩ (Fin (1 + n) × Fin (n !)) ≡⟨ ×= idp adequate! ⟩ (Fin (1 + n) × Π[0… n -1] suc) ≡⟨ {!ΠFin1+!} ⟩ (Fin 1 × Π[0… n -1] (_+_ 2)) ≡⟨ ¡ ΠFin1+ n ⟩ Π[0… n ] suc ∎ -} adequate! : ∀ {n} → Fin (n !) ≡ Π[0… n ] suc adequate! {zero} = ¡ ΠFin1≡F0 adequate! {suc n} = (Fin ((1 + n)!)) ≡⟨by-definition⟩ Fin ((1 + n) * n !) ≡⟨ ¡ Fin-×-* ⟩ (Fin (1 + n) × Fin (n !)) ≡⟨ ×= idp adequate! ⟩ (Fin (1 + n) × Π[0… n ] suc) ≡⟨ ¡ ΠFin1+ʳ′ (suc n) _ ⟩ ((x : Fin (2 + n)) → Fin (suc (Fin▹ℕ x))) ≡⟨ idp ⟩ Π[0… 1 + n ] suc ∎ {- adequate! : ∀ {n} → Fin ((1 + n)!) ≡ Π[0… n -1] suc adequate! {zero} = {!idp!} adequate! {suc n} = (Fin ((2 + n)!)) ≡⟨ {!!} ⟩ Fin ((1 + n) * (1 + n)!) ≡⟨ ¡ Fin-×-* ⟩ (Fin (1 + n) × Fin ((1 + n)!)) ≡⟨ ×= idp adequate! ⟩ (Fin (1 + n) × Π[0… n -1] suc) ≡⟨ ¡ (ΠFin1+ʳ′ n (Fin ∘ suc)) ⟩ Π[0… suc n -1] suc ∎ -} {- HI: (n+1)! ≡ Π n suc (n+2)! (n+2) * (n+1)! (n+2) * Π n suc (n+1) * Π n suc + Π n suc (2+n)*(n! * 1+n) (n! * 1+n) + (1+n)*(n! * 1+n) ≡ Π n (2+) ≡ 1 × Π n (2+) (2+n) * Π n suc Π (1+n) suc -- -} -- -} -- -} -- -} -- -}
{ "alphanum_fraction": 0.3881980556, "avg_line_length": 25.7900874636, "ext": "agda", "hexsha": "fa8aa5cff726e4dc2a86b0bb91781ecccb938490", "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": "experimental-examples/factorial.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": "experimental-examples/factorial.agda", "max_line_length": 80, "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": "experimental-examples/factorial.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": 4436, "size": 8846 }
module Ag03 where import Relation.Binary.PropositionalEquality as Eq open Eq using (_≡_; refl; cong; sym) open import Data.Nat using (ℕ; zero; suc; _+_; _*_) open import Data.Nat.Properties using (+-comm; *-comm; +-suc) data _≤_ : ℕ → ℕ → Set where z≤n : ∀ {n : ℕ} → zero ≤ n s≤s : ∀ {m n : ℕ} → m ≤ n → suc m ≤ suc n infix 4 _≤_ inv-s≤s : ∀ {m n : ℕ} → suc m ≤ suc n → m ≤ n inv-s≤s (s≤s m≤n) = m≤n inv-z≤n : ∀ {m : ℕ} → m ≤ zero → m ≡ zero inv-z≤n z≤n = refl ≤-refl : ∀ {n : ℕ} → n ≤ n ≤-refl {0} = z≤n ≤-refl {suc n} = s≤s ≤-refl ≤-trans : ∀ {m n p : ℕ } → m ≤ n → n ≤ p → m ≤ p ≤-trans z≤n _ = z≤n ≤-trans (s≤s m≤n) (s≤s n≤p) = s≤s (≤-trans m≤n n≤p) ≤-antisym : ∀ {m n : ℕ} → m ≤ n → n ≤ m → m ≡ n ≤-antisym z≤n z≤n = refl ≤-antisym (s≤s m≤n) (s≤s n≤m) = cong suc (≤-antisym m≤n n≤m) data Total (m n : ℕ) : Set where forward : m ≤ n → Total m n flipped : n ≤ m → Total m n +-monoʳ-≤ : ∀ (n p q : ℕ) → p ≤ q ------------- → n + p ≤ n + q +-monoʳ-≤ zero p q p≤q = p≤q +-monoʳ-≤ (suc n) p q p≤q = s≤s (+-monoʳ-≤ n p q p≤q) +-monoˡ-≤ : ∀ (m n p : ℕ) → m ≤ n ------------- → m + p ≤ n + p +-monoˡ-≤ m n p m≤n rewrite +-comm m p | +-comm n p = +-monoʳ-≤ p m n m≤n +-mono-≤ : ∀ (m n p q : ℕ) → m ≤ n → p ≤ q ------------- → m + p ≤ n + q +-mono-≤ m n p q m≤n p≤q = ≤-trans (+-monoˡ-≤ m n p m≤n) (+-monoʳ-≤ n p q p≤q) *-mono-ʳ : ∀ (n p q : ℕ) → p ≤ q → n * p ≤ n * q *-mono-ʳ 0 _ _ p≤q = z≤n *-mono-ʳ (suc n) p q p≤q = +-mono-≤ p q (n * p) (n * q) p≤q (*-mono-ʳ n p q p≤q) *-mono-ˡ : ∀ (m n p : ℕ) → m ≤ n → m * p ≤ n * p *-mono-ˡ m n p m≤n rewrite *-comm m p | *-comm n p = *-mono-ʳ p m n m≤n *-mono : ∀ (m n p q : ℕ) → m ≤ n → p ≤ q → m * p ≤ n * q *-mono m n p q m≤n p≤q = ≤-trans (*-mono-ˡ m n p m≤n) (*-mono-ʳ n p q p≤q) infix 4 _⟨_ data _⟨_ : ℕ → ℕ → Set where z⟨s : ∀ {n : ℕ} → 0 ⟨ suc n s⟨s : ∀ {m n : ℕ} → m ⟨ n → suc m ⟨ suc n ⟨-trans : ∀ {m n p : ℕ} → m ⟨ n → n ⟨ p → m ⟨ p ⟨-trans z⟨s (s⟨s n⟨p) = z⟨s ⟨-trans (s⟨s m⟨n) (s⟨s n⟨p) = s⟨s (⟨-trans m⟨n n⟨p) data Total-trichotomy (m n : ℕ) : Set where lt : m ⟨ n → Total-trichotomy m n eq : m ≡ n → Total-trichotomy m n gt : n ⟨ m → Total-trichotomy m n trichotomy : ∀ (m n : ℕ) → Total-trichotomy m n trichotomy zero zero = eq refl trichotomy zero (suc n) = lt z⟨s trichotomy (suc m) zero = gt z⟨s trichotomy (suc m) (suc n) with trichotomy m n ... | lt m⟨n = lt (s⟨s m⟨n) ... | eq m≡n = eq (cong suc m≡n) ... | gt n⟨m = gt (s⟨s n⟨m) +-monoʳ-⟨ : ∀ (n p q : ℕ) → p ⟨ q → n + p ⟨ n + q +-monoʳ-⟨ 0 _ _ p⟨q = p⟨q +-monoʳ-⟨ (suc n) p q p⟨q = s⟨s (+-monoʳ-⟨ n p q p⟨q) +-monoˡ-⟨ : ∀ (m n p : ℕ) → m ⟨ n → m + p ⟨ n + p +-monoˡ-⟨ m n p m⟨n rewrite +-comm m p | +-comm n p = +-monoʳ-⟨ p m n m⟨n +-mono-⟨ : ∀ (m n p q : ℕ) → m ⟨ n → p ⟨ q → m + p ⟨ n + q +-mono-⟨ m n p q m⟨n p⟨q = ⟨-trans (+-monoˡ-⟨ m n p m⟨n) (+-monoʳ-⟨ n p q p⟨q) ≤-iffˡ-⟨ : ∀ (m n : ℕ) → suc m ≤ n → m ⟨ n ≤-iffˡ-⟨ 0 _ (s≤s z≤n) = z⟨s ≤-iffˡ-⟨ (suc m) (suc n) (s≤s sm≤n) = s⟨s (≤-iffˡ-⟨ m n sm≤n) ≤-iffʳ-⟨ : ∀ (m n : ℕ) → m ⟨ n → suc m ≤ n ≤-iffʳ-⟨ .0 .(suc _) z⟨s = s≤s z≤n ≤-iffʳ-⟨ .(suc _) .(suc _) (s⟨s m⟨n) = s≤s (≤-iffʳ-⟨ _ _ m⟨n) data Even : ℕ → Set data Odd : ℕ → Set data Even where zero : --------- Even zero suc : ∀ {n : ℕ} → Odd n ------------ → Even (suc n) data Odd where suc : ∀ {n : ℕ} → Even n ----------- → Odd (suc n) e+e≡e : ∀ {m n : ℕ} → Even m → Even n ------------ → Even (m + n) o+e≡o : ∀ {m n : ℕ} → Odd m → Even n ----------- → Odd (m + n) e+e≡e zero en = en e+e≡e (suc om) en = suc (o+e≡o om en) o+e≡o (suc em) en = suc (e+e≡e em en) o+o≡e : ∀ {m n : ℕ} → Odd m → Odd n → Even (m + n) o+o≡e {m} {suc n} om (suc en) rewrite +-suc m n = suc (o+e≡o om en) e+o≡o : ∀ (m n : ℕ) → Even m → Odd n → Odd(m + n) e+o≡o .0 .(suc _) zero (suc x) = suc x e+o≡o (suc m) (suc n) (suc x) (suc x₁) rewrite +-suc m n = suc (suc (o+e≡o x x₁)) infixl 7 _e*e_ _o*e_ _o*o_ _e*o_ _e*e_ : ∀ {m n : ℕ} → Even m → Even n → Even (m * n) _o*e_ : ∀ {m n : ℕ} → Odd m → Even n → Even (m * n) _o*o_ : ∀ {m n : ℕ} → Odd m → Odd n → Odd (m * n) _e*o_ : ∀ {m n : ℕ} → Even m → Odd n → Even (m * n) zero e*e en = zero suc x e*e en = e+e≡e en (x o*e en) suc x o*e en = e+e≡e en (x e*e en) suc x o*o on = o+e≡o on (x e*o on) zero e*o on = zero suc x e*o on = o+o≡e on (x o*o on)
{ "alphanum_fraction": 0.438172043, "avg_line_length": 25.2203389831, "ext": "agda", "hexsha": "00108afab007036889910cc681c15a7ebce22f2e", "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/Ag03.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/Ag03.agda", "max_line_length": 81, "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/Ag03.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": 2403, "size": 4464 }
------------------------------------------------------------------------------ -- Simple example of a nested recursive function ------------------------------------------------------------------------------ {-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} -- From: Ana Bove and Venanzio Capretta. Nested general recursion and -- partiality in type theory. Vol. 2152 of LNCS. 2001. module FOT.FOTC.Program.Nest.NestConditional where open import FOTC.Base ------------------------------------------------------------------------------ -- The nest function. postulate nest : D → D nest-eq : ∀ n → nest n ≡ (if (iszero₁ n) then zero else (nest (nest (pred₁ n)))) {-# ATP axiom nest-eq #-}
{ "alphanum_fraction": 0.4170454545, "avg_line_length": 35.2, "ext": "agda", "hexsha": "604526ab6eba641cc7a1d045e1a80449d5326f76", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "asr/fotc", "max_forks_repo_path": "notes/FOT/FOTC/Program/Nest/NestConditional.agda", "max_issues_count": 2, "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "asr/fotc", "max_issues_repo_path": "notes/FOT/FOTC/Program/Nest/NestConditional.agda", "max_line_length": 78, "max_stars_count": 11, "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/fotc", "max_stars_repo_path": "notes/FOT/FOTC/Program/Nest/NestConditional.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": 165, "size": 880 }
{-# OPTIONS --guardedness-preserving-type-constructors #-} module Issue602 where infix 1000 ♯_ postulate ∞ : ∀ {a} (A : Set a) → Set a ♯_ : ∀ {a} {A : Set a} → A → ∞ A ♭ : ∀ {a} {A : Set a} → ∞ A → A {-# BUILTIN INFINITY ∞ #-} {-# BUILTIN SHARP ♯_ #-} {-# BUILTIN FLAT ♭ #-} data CoNat : Set0 where z : CoNat s : ∞ CoNat → CoNat record A : Set2 where field f : Set1 record B (a : ∞ A) : Set1 where field f : A.f (♭ a) postulate a : A e : CoNat → A e z = a e (s n) = record { f = B (♯ e (♭ n)) }
{ "alphanum_fraction": 0.4981549815, "avg_line_length": 15.4857142857, "ext": "agda", "hexsha": "4c889dae58ed0477d09fa9a321a6119de92c43b1", "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": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "masondesu/agda", "max_forks_repo_path": "test/succeed/Issue602.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "masondesu/agda", "max_issues_repo_path": "test/succeed/Issue602.agda", "max_line_length": 58, "max_stars_count": 3, "max_stars_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "redfish64/autonomic-agda", "max_stars_repo_path": "test/Succeed/Issue602.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": 232, "size": 542 }
{-# OPTIONS --safe --without-K #-} module Data.Fin.Subset.Dec where open import Data.Nat as ℕ open import Data.Fin as Fin open import Data.Fin.Subset open import Relation.Nullary open import Relation.Unary renaming (Decidable to Decidable₁) using () open import Function using (_∘_) open import Data.Vec using ([]; _∷_) subset : ∀ {n}{p} {P : Fin n → Set p} → Decidable₁ P → Subset n subset {zero} dec = [] subset {suc n} dec with dec (# 0) subset {suc n} dec | yes p0 = inside ∷ subset (dec ∘ Fin.suc) subset {suc n} dec | no ¬p0 = outside ∷ subset (dec ∘ Fin.suc)
{ "alphanum_fraction": 0.6788830716, "avg_line_length": 31.8333333333, "ext": "agda", "hexsha": "9bd8e3010dd8e36a30f6901dcc74b5fdb6bc5301", "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": "abacd166f63582b7395d9cc10b6323c0f69649e5", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "tizmd/agda-finitary", "max_forks_repo_path": "src/Data/Fin/Subset/Dec.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "abacd166f63582b7395d9cc10b6323c0f69649e5", "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": "tizmd/agda-finitary", "max_issues_repo_path": "src/Data/Fin/Subset/Dec.agda", "max_line_length": 70, "max_stars_count": null, "max_stars_repo_head_hexsha": "abacd166f63582b7395d9cc10b6323c0f69649e5", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "tizmd/agda-finitary", "max_stars_repo_path": "src/Data/Fin/Subset/Dec.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 179, "size": 573 }
------------------------------------------------------------------------------ -- Well-founded induction on natural numbers ------------------------------------------------------------------------------ {-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} -- Adapted from -- http://www.iis.sinica.edu.tw/~scm/2008/well-founded-recursion-and-accessibility/ -- and the Agda standard library 0.8.1. module FOT.FOTC.Data.Nat.Induction.Acc.WF-I where open import FOTC.Base open import FOTC.Data.Nat.Inequalities open import FOTC.Data.Nat.Type ------------------------------------------------------------------------------ -- The accessibility predicate: x is accessible if everything which is -- smaller than x is also accessible (inductively). data AccLT : D → Set where accLT : ∀ {x} → N x → (∀ {y} → N y → y < x → AccLT y) → AccLT x accFoldLT : {P : D → Set} → (∀ {x} → N x → (∀ {y} → N y → y < x → P y) → P x) → ∀ {x} → N x → AccLT x → P x accFoldLT f Nx (accLT _ h) = f Nx (λ Ny y<x → accFoldLT f Ny (h Ny y<x)) -- The accessibility predicate encodes what it means to be -- well-founded; if all elements are accessible, then LT is -- well-founded. WellFoundedLT : Set WellFoundedLT = ∀ {x} → N x → AccLT x WellFoundedInductionLT : {P : D → Set} → WellFoundedLT → (∀ {x} → N x → (∀ {y} → N y → y < x → P y) → P x) → ∀ {x} → N x → P x WellFoundedInductionLT wf f Nx = accFoldLT f Nx (wf Nx)
{ "alphanum_fraction": 0.4922696351, "avg_line_length": 37.6046511628, "ext": "agda", "hexsha": "40967f0b096c341a75b1afb54a6e11dd5a8169e2", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "asr/fotc", "max_forks_repo_path": "notes/FOT/FOTC/Data/Nat/Induction/Acc/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": "notes/FOT/FOTC/Data/Nat/Induction/Acc/WF-I.agda", "max_line_length": 83, "max_stars_count": 11, "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/fotc", "max_stars_repo_path": "notes/FOT/FOTC/Data/Nat/Induction/Acc/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": 431, "size": 1617 }
module vector-test-ctors where open import bool open import list open import vector ---------------------------------------------------------------------- -- syntax ---------------------------------------------------------------------- test-vector : 𝕃 (𝕍 𝔹 2) test-vector = (ff :: tt :: []) :: (tt :: ff :: []) :: (tt :: ff :: []) :: []
{ "alphanum_fraction": 0.3265306122, "avg_line_length": 21.4375, "ext": "agda", "hexsha": "869e80f067fd0bbebd8a364ec698c576fee3d4c5", "lang": "Agda", "max_forks_count": 17, "max_forks_repo_forks_event_max_datetime": "2021-11-28T20:13:21.000Z", "max_forks_repo_forks_event_min_datetime": "2018-12-03T22:38:15.000Z", "max_forks_repo_head_hexsha": "f3f0261904577e930bd7646934f756679a6cbba6", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "rfindler/ial", "max_forks_repo_path": "vector-test-ctors.agda", "max_issues_count": 8, "max_issues_repo_head_hexsha": "f3f0261904577e930bd7646934f756679a6cbba6", "max_issues_repo_issues_event_max_datetime": "2022-03-22T03:43:34.000Z", "max_issues_repo_issues_event_min_datetime": "2018-07-09T22:53:38.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "rfindler/ial", "max_issues_repo_path": "vector-test-ctors.agda", "max_line_length": 76, "max_stars_count": 29, "max_stars_repo_head_hexsha": "f3f0261904577e930bd7646934f756679a6cbba6", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "rfindler/ial", "max_stars_repo_path": "vector-test-ctors.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-04T15:05:12.000Z", "max_stars_repo_stars_event_min_datetime": "2019-02-06T13:09:31.000Z", "num_tokens": 67, "size": 343 }
open import Relation.Binary.PropositionalEquality using ( refl ) open import Web.Semantic.DL.Category.Object using ( Object ) open import Web.Semantic.DL.Category.Morphism using ( _≣_ ) open import Web.Semantic.DL.Category.Composition using ( _∙_ ) open import Web.Semantic.DL.Category.Tensor using ( _⊗_ ; _⟨⊗⟩_ ) open import Web.Semantic.DL.Category.Unit using ( I ) open import Web.Semantic.DL.Category.Wiring using ( identity ; symm ; assoc ; assoc⁻¹ ; unit₁ ; unit₁⁻¹ ; unit₂ ; unit₂⁻¹ ) open import Web.Semantic.DL.Category.Properties.Wiring using ( rewriting ; rewrite-compose ; rewrite-tensor ; rewrite-identity ; rewrite-symm ; rewrite-assoc ; rewrite-assoc⁻¹ ; rewrite-unit₁ ; rewrite-unit₁⁻¹ ; rewrite-unit₂ ; rewrite-unit₂⁻¹ ) open import Web.Semantic.DL.Signature using ( Signature ) open import Web.Semantic.DL.TBox using ( TBox ) open import Web.Semantic.Util using ( _≡⊎≡_ ) module Web.Semantic.DL.Category.Properties.Tensor.Isomorphisms {Σ : Signature} {S T : TBox Σ} where symm-iso : ∀ (A₁ A₂ : Object S T) → (symm A₁ A₂ ∙ symm A₂ A₁ ≣ identity (A₁ ⊗ A₂)) symm-iso A₁ A₂ = rewriting (rewrite-compose (rewrite-symm A₁ A₂) (rewrite-symm A₂ A₁)) ((λ x → refl) ≡⊎≡ (λ x → refl)) (rewrite-identity (A₁ ⊗ A₂)) assoc-iso : ∀ (A₁ A₂ A₃ : Object S T) → (assoc A₁ A₂ A₃ ∙ assoc⁻¹ A₁ A₂ A₃ ≣ identity ((A₁ ⊗ A₂) ⊗ A₃)) assoc-iso A₁ A₂ A₃ = rewriting (rewrite-compose (rewrite-assoc A₁ A₂ A₃) (rewrite-assoc⁻¹ A₁ A₂ A₃)) (((λ x → refl) ≡⊎≡ (λ x → refl)) ≡⊎≡ (λ x → refl)) (rewrite-identity ((A₁ ⊗ A₂) ⊗ A₃)) assoc⁻¹-iso : ∀ (A₁ A₂ A₃ : Object S T) → (assoc⁻¹ A₁ A₂ A₃ ∙ assoc A₁ A₂ A₃ ≣ identity (A₁ ⊗ (A₂ ⊗ A₃))) assoc⁻¹-iso A₁ A₂ A₃ = rewriting (rewrite-compose (rewrite-assoc⁻¹ A₁ A₂ A₃) (rewrite-assoc A₁ A₂ A₃)) ((λ x → refl) ≡⊎≡ ((λ x → refl) ≡⊎≡ (λ x → refl))) (rewrite-identity (A₁ ⊗ (A₂ ⊗ A₃))) unit₁-iso : ∀ (A : Object S T) → (unit₁ A ∙ unit₁⁻¹ A ≣ identity (I ⊗ A)) unit₁-iso A = rewriting (rewrite-compose (rewrite-unit₁ A) (rewrite-unit₁⁻¹ A)) ((λ ()) ≡⊎≡ (λ x → refl)) (rewrite-identity (I ⊗ A)) unit₁⁻¹-iso : ∀ (A : Object S T) → (unit₁⁻¹ A ∙ unit₁ A ≣ identity A) unit₁⁻¹-iso A = rewriting (rewrite-compose (rewrite-unit₁⁻¹ A) (rewrite-unit₁ A)) (λ x → refl) (rewrite-identity A) unit₂-iso : ∀ (A : Object S T) → (unit₂ A ∙ unit₂⁻¹ A ≣ identity (A ⊗ I)) unit₂-iso A = rewriting (rewrite-compose (rewrite-unit₂ A) (rewrite-unit₂⁻¹ A)) ((λ x → refl) ≡⊎≡ (λ ())) (rewrite-identity (A ⊗ I)) unit₂⁻¹-iso : ∀ (A : Object S T) → (unit₂⁻¹ A ∙ unit₂ A ≣ identity A) unit₂⁻¹-iso A = rewriting (rewrite-compose (rewrite-unit₂⁻¹ A) (rewrite-unit₂ A)) (λ x → refl) (rewrite-identity A)
{ "alphanum_fraction": 0.6425120773, "avg_line_length": 39, "ext": "agda", "hexsha": "b5e23b3871327e47c209466fad7d215479307dfc", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:40:03.000Z", "max_forks_repo_forks_event_min_datetime": "2017-12-03T14:52:09.000Z", "max_forks_repo_head_hexsha": "38fbc3af7062ba5c3d7d289b2b4bcfb995d99057", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "bblfish/agda-web-semantic", "max_forks_repo_path": "src/Web/Semantic/DL/Category/Properties/Tensor/Isomorphisms.agda", "max_issues_count": 4, "max_issues_repo_head_hexsha": "38fbc3af7062ba5c3d7d289b2b4bcfb995d99057", "max_issues_repo_issues_event_max_datetime": "2021-01-04T20:57:19.000Z", "max_issues_repo_issues_event_min_datetime": "2018-11-14T02:32:28.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "bblfish/agda-web-semantic", "max_issues_repo_path": "src/Web/Semantic/DL/Category/Properties/Tensor/Isomorphisms.agda", "max_line_length": 75, "max_stars_count": 9, "max_stars_repo_head_hexsha": "8ddbe83965a616bff6fc7a237191fa261fa78bab", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "agda/agda-web-semantic", "max_stars_repo_path": "src/Web/Semantic/DL/Category/Properties/Tensor/Isomorphisms.agda", "max_stars_repo_stars_event_max_datetime": "2020-03-14T14:21:08.000Z", "max_stars_repo_stars_event_min_datetime": "2015-09-13T17:46:41.000Z", "num_tokens": 1081, "size": 2691 }
{-# OPTIONS --without-K --safe #-} open import Categories.Category -- Equalizers in a Category C module Categories.Diagram.Equalizer {o ℓ e} (C : Category o ℓ e) where open Category C open HomReasoning open import Level open import Data.Product as Σ open import Function using (_$_) open import Categories.Morphism C open import Categories.Morphism.Reasoning C private variable A B X : Obj h i j k : A ⇒ B record Equalizer (f g : A ⇒ B) : Set (o ⊔ ℓ ⊔ e) where field {obj} : Obj arr : obj ⇒ A equality : f ∘ arr ≈ g ∘ arr equalize : ∀ {h : X ⇒ A} → f ∘ h ≈ g ∘ h → X ⇒ obj universal : ∀ {eq : f ∘ h ≈ g ∘ h} → h ≈ arr ∘ equalize eq unique : ∀ {eq : f ∘ h ≈ g ∘ h} → h ≈ arr ∘ i → i ≈ equalize eq unique′ : (eq eq′ : f ∘ h ≈ g ∘ h) → equalize eq ≈ equalize eq′ unique′ eq eq′ = unique universal id-equalize : id ≈ equalize equality id-equalize = unique (sym identityʳ) equalize-resp-≈ : ∀ {eq : f ∘ h ≈ g ∘ h} {eq′ : f ∘ i ≈ g ∘ i} → h ≈ i → equalize eq ≈ equalize eq′ equalize-resp-≈ {h = h} {i = i} {eq = eq} {eq′ = eq′} h≈i = unique $ begin i ≈˘⟨ h≈i ⟩ h ≈⟨ universal ⟩ arr ∘ equalize eq ∎ equalize-resp-≈′ : (eq : f ∘ h ≈ g ∘ h) → (eq′ : f ∘ i ≈ g ∘ i) → h ≈ i → j ≈ equalize eq → k ≈ equalize eq′ → j ≈ k equalize-resp-≈′ {j = j} {k = k} eq eq′ h≈i eqj eqk = begin j ≈⟨ eqj ⟩ equalize eq ≈⟨ equalize-resp-≈ h≈i ⟩ equalize eq′ ≈˘⟨ eqk ⟩ k ∎ equality-∘ : f ∘ arr ∘ h ≈ g ∘ arr ∘ h equality-∘ {h = h} = begin f ∘ arr ∘ h ≈⟨ pullˡ equality ⟩ (g ∘ arr) ∘ h ≈⟨ assoc ⟩ g ∘ arr ∘ h ∎ unique-diagram : arr ∘ h ≈ arr ∘ i → h ≈ i unique-diagram {h = h} {i = i} eq = begin h ≈⟨ unique (sym eq) ⟩ equalize (extendʳ equality) ≈˘⟨ unique refl ⟩ i ∎ Equalizer⇒Mono : (e : Equalizer h i) → Mono (Equalizer.arr e) Equalizer⇒Mono e f g eq = equalize-resp-≈′ equality-∘ equality-∘ eq (unique refl) (unique refl) where open Equalizer e
{ "alphanum_fraction": 0.5228915663, "avg_line_length": 30.5147058824, "ext": "agda", "hexsha": "cf4261fe6332a612b3a895f8788963f3bdbba8e5", "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/Diagram/Equalizer.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/Diagram/Equalizer.agda", "max_line_length": 76, "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/Diagram/Equalizer.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 853, "size": 2075 }
open import Everything module Test.SubstitunctionPropId {𝔭} (𝔓 : Ø 𝔭) where open Substitunction 𝔓 relpropid-Substitunction : ∀ {m n ℓ} {f : Substitunction m n} (P : LeftExtensionṖroperty ℓ Substitunction Proposextensequality m) (let P₀ = π₀ (π₀ P)) → P₀ f → P₀ (ε ∙ f) relpropid-Substitunction P pf = hmap _ P pf
{ "alphanum_fraction": 0.7232704403, "avg_line_length": 31.8, "ext": "agda", "hexsha": "d003353582228dec49108bd7bf0dd769c8009935", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_forks_repo_licenses": [ "RSA-MD" ], "max_forks_repo_name": "m0davis/oscar", "max_forks_repo_path": "archive/agda-3/src/Test/SubstitunctionPropId.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_issues_repo_issues_event_max_datetime": "2019-05-11T23:33:04.000Z", "max_issues_repo_issues_event_min_datetime": "2019-04-29T00:35:04.000Z", "max_issues_repo_licenses": [ "RSA-MD" ], "max_issues_repo_name": "m0davis/oscar", "max_issues_repo_path": "archive/agda-3/src/Test/SubstitunctionPropId.agda", "max_line_length": 171, "max_stars_count": null, "max_stars_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_stars_repo_licenses": [ "RSA-MD" ], "max_stars_repo_name": "m0davis/oscar", "max_stars_repo_path": "archive/agda-3/src/Test/SubstitunctionPropId.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 123, "size": 318 }
module UniDB.Morph.Depth where open import UniDB.Spec open import Data.Sum -------------------------------------------------------------------------------- data Depth (Ξ : MOR) : MOR where depth : {γ₁ γ₂ : Dom} (ξ : Ξ γ₁ γ₂) (δ : Dom) → Depth Ξ (γ₁ ∪ δ) (γ₂ ∪ δ) Fin-∪ : {γ₁ : Dom} (γ₂ δ : Dom) (i : Ix (γ₁ ∪ δ)) → Ix γ₁ ⊎ Ix (γ₂ ∪ δ) Fin-∪ γ₂ zero i = inj₁ i Fin-∪ γ₂ (suc δ) zero = inj₂ zero Fin-∪ γ₂ (suc δ) (suc i) = map id suc (Fin-∪ γ₂ δ i) instance iLkDepth : {T : STX} {{vrT : Vr T}} {{wkT : Wk T}} {Ξ : MOR} {{lkTΞ : Lk T Ξ}} → Lk T (Depth Ξ) lk {{iLkDepth {T} {Ξ}}} (depth {γ₁} {γ₂} ξ δ) i with Fin-∪ γ₂ δ i ... | inj₁ j = wk δ (lk {T} {Ξ} ξ j) ... | inj₂ j = vr {T = T} j iUpDepth : {Ξ : MOR} → Up (Depth Ξ) _↑₁ {{iUpDepth}} (depth ξ δ) = depth ξ (suc δ) _↑_ {{iUpDepth {Ξ}}} ξ 0 = ξ _↑_ {{iUpDepth {Ξ}}} ξ (suc δ⁺) = ξ ↑ δ⁺ ↑₁ ↑-zero {{iUpDepth}} ξ = refl ↑-suc {{iUpDepth {Ξ}}} ξ δ⁺ = refl iWkmDepth : {Ξ : MOR} {{wkmΞ : Wkm Ξ}} → Wkm (Depth Ξ) wkm {{iWkmDepth {Ξ}}} δ = depth (wkm {Ξ} δ) 0 iLkWkmDepth : {T : STX} {{vrT : Vr T}} {{wkT : Wk T}} {{wkVrT : WkVr T}} {Ξ : MOR} {{lkTΞ : Lk T Ξ}} {{wkmΞ : Wkm Ξ}} {{lkWkmΞ : LkWkm T Ξ}} → LkWkm T (Depth Ξ) lk-wkm {{iLkWkmDepth {T} {Ξ}}} δ i = begin wk 0 (lk {T} {Ξ} (wkm δ) i) ≡⟨ wk-zero (lk {T} {Ξ} (wkm δ) i) ⟩ lk {T} {Ξ} (wkm δ) i ≡⟨ lk-wkm {T} {Ξ} δ i ⟩ vr (wk δ i) ∎ iBetaDepth : {T : STX} {Ξ : MOR} {{betaTΞ : Beta T Ξ}} → Beta T (Depth Ξ) beta {{iBetaDepth {T} {Ξ}}} t = depth (beta {T} {Ξ} t) 0 iLkUpDepth : {T : STX} {{vrT : Vr T}} {{wkT : Wk T}} {{wkVrT : WkVr T}} {Ξ : MOR} {{lkTΞ : Lk T Ξ}} → LkUp T (Depth Ξ) lk-↑₁-zero {{iLkUpDepth {T} {Ξ}}} (depth ξ δ) = refl lk-↑₁-suc {{iLkUpDepth {T} {Ξ}}} (depth {γ₁} {γ₂} ξ δ) i with Fin-∪ γ₂ δ i ... | inj₁ j = wk-suc {T} δ (lk {T} {Ξ} ξ j) ... | inj₂ j = sym (wk₁-vr {T} j) --------------------------------------------------------------------------------
{ "alphanum_fraction": 0.4411177645, "avg_line_length": 33.9661016949, "ext": "agda", "hexsha": "6f89efcf7cdac97feca5e5a77d135c133d77a080", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "7ae52205db44ad4f463882ba7e5082120fb76349", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "skeuchel/unidb-agda", "max_forks_repo_path": "UniDB/Morph/Depth.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "7ae52205db44ad4f463882ba7e5082120fb76349", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "skeuchel/unidb-agda", "max_issues_repo_path": "UniDB/Morph/Depth.agda", "max_line_length": 80, "max_stars_count": null, "max_stars_repo_head_hexsha": "7ae52205db44ad4f463882ba7e5082120fb76349", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "skeuchel/unidb-agda", "max_stars_repo_path": "UniDB/Morph/Depth.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 987, "size": 2004 }
{- NEW TRANSLATION STUFF: same thing but interpret source nat as ♭nat-} open import Preliminaries open import Source open import Pilot module Translation-New where mutual ⟨⟨_⟩⟩ : Tp → CTp ⟨⟨ unit ⟩⟩ = unit ⟨⟨ nat ⟩⟩ = nat ⟨⟨ susp A ⟩⟩ = || A || ⟨⟨ A ->s B ⟩⟩ = ⟨⟨ A ⟩⟩ ->c || B || ⟨⟨ A ×s B ⟩⟩ = ⟨⟨ A ⟩⟩ ×c ⟨⟨ B ⟩⟩ ⟨⟨ list A ⟩⟩ = list ⟨⟨ A ⟩⟩ ⟨⟨ bool ⟩⟩ = bool ||_|| : Tp → CTp || τ || = C ×c ⟨⟨ τ ⟩⟩ ⟨⟨_⟩⟩c : Source.Ctx → Pilot.Ctx ⟨⟨ [] ⟩⟩c = [] ⟨⟨ x :: Γ ⟩⟩c = ⟨⟨ x ⟩⟩ :: ⟨⟨ Γ ⟩⟩c interp-Cost : ∀{Γ} → Cost → Γ Pilot.|- C interp-Cost 0c = 0C interp-Cost 1c = 1C interp-Cost (m +c n) = plusC (interp-Cost m) (interp-Cost n) lookup : ∀{Γ τ} → τ Source.∈ Γ → ⟨⟨ τ ⟩⟩ Pilot.∈ ⟨⟨ Γ ⟩⟩c lookup i0 = i0 lookup (iS x) = iS (lookup x) -- translation from source expressions to complexity expressions ||_||e : ∀{Γ τ} → Γ Source.|- τ → ⟨⟨ Γ ⟩⟩c Pilot.|- || τ || || unit ||e = prod 0C unit || var x ||e = prod 0C (var (lookup x)) || z ||e = prod 0C z || suc e ||e = prod (l-proj (|| e ||e)) (s (r-proj (|| e ||e))) || rec e e0 e1 ||e = (l-proj (|| e ||e)) +C (rec (r-proj || e ||e) (1C +C || e0 ||e) (1C +C || e1 ||e)) || lam e ||e = prod 0C (lam || e ||e) || app e1 e2 ||e = prod (plusC (plusC (l-proj (|| e1 ||e)) (l-proj (|| e2 ||e))) (l-proj (app (r-proj (|| e1 ||e)) (r-proj (|| e2 ||e))))) (r-proj (app (r-proj (|| e1 ||e)) (r-proj (|| e2 ||e)))) || prod e1 e2 ||e = prod (plusC (l-proj (|| e1 ||e)) (l-proj (|| e2 ||e))) (prod (r-proj (|| e1 ||e)) (r-proj (|| e2 ||e))) || delay e ||e = prod 0C (|| e ||e) || force e ||e = prod (plusC (l-proj (|| e ||e)) (l-proj (r-proj || e ||e))) (r-proj (r-proj (|| e ||e))) || split e0 e1 ||e = prod (plusC (l-proj (|| e0 ||e)) (l-proj E1)) (r-proj E1) where E1 = (Pilot.subst || e1 ||e (Pilot.lem4 (l-proj (r-proj || e0 ||e)) (r-proj (r-proj || e0 ||e)))) || nil ||e = prod 0C nil || e ::s e₁ ||e = prod (plusC (l-proj || e ||e) (l-proj || e₁ ||e)) ((r-proj || e ||e) ::c (r-proj || e₁ ||e)) || listrec e e₁ e₂ ||e = l-proj || e ||e +C listrec (r-proj || e ||e) (1C +C || e₁ ||e) (1C +C || e₂ ||e) || true ||e = prod 0C true || false ||e = prod 0C false
{ "alphanum_fraction": 0.4517720951, "avg_line_length": 40.5272727273, "ext": "agda", "hexsha": "ffa99903d57f6299a55ff39b2c82121eb668969f", "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": "2404a6ef2688f879bda89860bb22f77664ad813e", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "benhuds/Agda", "max_forks_repo_path": "complexity/Translation-New.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "2404a6ef2688f879bda89860bb22f77664ad813e", "max_issues_repo_issues_event_max_datetime": "2020-05-12T00:32:45.000Z", "max_issues_repo_issues_event_min_datetime": "2020-03-23T08:39:04.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "benhuds/Agda", "max_issues_repo_path": "complexity/Translation-New.agda", "max_line_length": 140, "max_stars_count": 2, "max_stars_repo_head_hexsha": "2404a6ef2688f879bda89860bb22f77664ad813e", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "benhuds/Agda", "max_stars_repo_path": "complexity/Translation-New.agda", "max_stars_repo_stars_event_max_datetime": "2019-08-08T12:27:18.000Z", "max_stars_repo_stars_event_min_datetime": "2016-04-26T20:22:22.000Z", "num_tokens": 1028, "size": 2229 }
-- Andreas, 2020-03-27, re #3684 record R : Set₁ where _ : R _ = record { f = Set; f = Set } -- Should complain about alien fields rather than duplicate fields -- The record type R does not have the fields f, f -- when checking that the expression record { f = Set ; f = Set } has type R
{ "alphanum_fraction": 0.6712328767, "avg_line_length": 24.3333333333, "ext": "agda", "hexsha": "afe06b2bb4920c45f412ee972fb6d9c806032dd2", "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": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "shlevy/agda", "max_forks_repo_path": "test/Succeed/Issue3684-alien-duplicate-fields.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/Issue3684-alien-duplicate-fields.agda", "max_line_length": 76, "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/Issue3684-alien-duplicate-fields.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": 84, "size": 292 }
------------------------------------------------------------------------------ -- Agda internal syntax ------------------------------------------------------------------------------ {-# OPTIONS --exact-split #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} -- Tested with Agda development version on 25 February 2013. module InternalSyntax where ------------------------------------------------------------------------------ -- Sets postulate A B C : Set -- El {getSort = Type (Max [ClosedLevel 1]), unEl = Sort (Type (Max []))} postulate A₁ : Set₁ -- El {getSort = Type (Max [ClosedLevel 2]), unEl = Sort (Type (Max [ClosedLevel 1]))} ------------------------------------------------------------------------------ -- The term is Def postulate def : A -- El {getSort = Type (Max []), unEl = Def InternalSyntax.A []} ------------------------------------------------------------------------------ -- The term is Pi postulate fun₁ : A → B -- El {getSort = Type (Max []), -- unEl = Pi []r(El {getSort = Type (Max []), unEl = Def InternalSyntax.A []}) -- (NoAbs "_" El {getSort = Type (Max []), unEl = Def InternalSyntax.B []})} postulate fun₂ : A → B → C -- El {getSort = Type (Max []), -- unEl = Pi []r(El {getSort = Type (Max []), unEl = Def InternalSyntax.A []}) -- (NoAbs "_" El {getSort = Type (Max []), -- unEl = Pi []r(El {getSort = Type (Max []), unEl = Def InternalSyntax.B []}) -- (NoAbs "_" El {getSort = Type (Max []), unEl = Def InternalSyntax.C []})})} postulate fun₃ : (a : A) → B -- El (Type (Max [])) -- (Pi r(El (Type (Max [])) -- (Def InternalSyntax.A [])) -- (Abs "a" El (Type (Max [])) -- (Def InternalSyntax.B []))) -- El {getSort = Type (Max []), -- unEl = Pi []r(El {getSort = Type (Max []), unEl = Def InternalSyntax.A []}) -- (NoAbs "a" El {getSort = Type (Max []), unEl = Def InternalSyntax.B []})} postulate P : A → Set -- El {getSort = Type (Max [ClosedLevel 1]), -- unEl = Pi []r(El {getSort = Type (Max []), unEl = Def InternalSyntax.A []}) -- (NoAbs "_" El {getSort = Type (Max [ClosedLevel 1]), unEl = Sort (Type (Max []))})} postulate fun₅ : (a : A) → P a -- El {getSort = Type (Max []), -- unEl = Pi []r(El {getSort = Type (Max []), unEl = Def InternalSyntax.A []}) -- (Abs "a" El {getSort = Type (Max []), unEl = Def InternalSyntax.P [[]r(Var 0 [])]})}
{ "alphanum_fraction": 0.4429477021, "avg_line_length": 35.5492957746, "ext": "agda", "hexsha": "b5e48ac9203e2406c6d9931b5eca1ca42fd7105d", "lang": "Agda", "max_forks_count": 4, "max_forks_repo_forks_event_max_datetime": "2016-08-03T03:54:55.000Z", "max_forks_repo_forks_event_min_datetime": "2016-05-10T23:06:19.000Z", "max_forks_repo_head_hexsha": "a66c5ddca2ab470539fd68c42c4fbd45f720d682", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "asr/apia", "max_forks_repo_path": "notes/InternalSyntax.agda", "max_issues_count": 121, "max_issues_repo_head_hexsha": "a66c5ddca2ab470539fd68c42c4fbd45f720d682", "max_issues_repo_issues_event_max_datetime": "2018-04-22T06:01:44.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-25T13:22:12.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "asr/apia", "max_issues_repo_path": "notes/InternalSyntax.agda", "max_line_length": 105, "max_stars_count": 10, "max_stars_repo_head_hexsha": "a66c5ddca2ab470539fd68c42c4fbd45f720d682", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/apia", "max_stars_repo_path": "notes/InternalSyntax.agda", "max_stars_repo_stars_event_max_datetime": "2019-12-03T13:44:25.000Z", "max_stars_repo_stars_event_min_datetime": "2015-09-03T20:54:16.000Z", "num_tokens": 667, "size": 2524 }
module Graph where import Lvl open import Data.Tuple as Tuple using (_⨯_ ; _,_) open import Functional open import Data.List open import Logic.Propositional{Lvl.𝟎} open import Logic.Predicate{Lvl.𝟎}{Lvl.𝟎} open import Relator.Equals{Lvl.𝟎} open import Data.List.Relation.Membership{Lvl.𝟎} using (_∈_) -- EdgeClass(V)(E) means that E is a type which can represent an edge between vertices of type V. record EdgeClass (V : Set) (Self : Set) : Set where constructor edgeInstance field from : Self → V to : Self → V _withVertices_ : Self → (V ⨯ V) → Self module Edge where open EdgeClass ⦃ ... ⦄ public instance EdgeInstance-Tuple : ∀{V} → EdgeClass(V)(V ⨯ V) Edge.from ⦃ EdgeInstance-Tuple ⦄ (v₁ , v₂) = v₁ Edge.to ⦃ EdgeInstance-Tuple ⦄ (v₁ , v₂) = v₂ Edge._withVertices_ ⦃ EdgeInstance-Tuple ⦄ (v₁ , v₂) (w₁ , w₂) = (w₁ , w₂) record Graph (V : Set) (E : Set) ⦃ _ : EdgeClass(V)(E) ⦄ : Set where constructor graph field edges : List(E) -- Propositions HasEdge[_⟶_] : V → V → Set HasEdge[_⟶_](v₁)(v₂) = ∃(edge ↦ (edge ∈ edges)∧(Edge.from(edge) ≡ v₁)∧(Edge.to(edge) ≡ v₂)) HasEdge[_⟵_] : V → V → Set HasEdge[_⟵_](v₁)(v₂) = HasEdge[_⟶_](v₂)(v₁) HasEdge[_⟷_] : V → V → Set HasEdge[_⟷_](v₁)(v₂) = HasEdge[_⟵_](v₁)(v₂) ∧ HasEdge[_⟶_](v₁)(v₂) data Path : V → V → Set where PathIntro : ∀{v₁ v₂ : V} → HasEdge[ v₁ ⟶ v₂ ] → Path(v₁)(v₂) PathTransitivity : ∀{v₁ v₂ v₃ : V} → Path(v₁)(v₂) → Path(v₂)(v₃) → Path(v₁)(v₃) Connected : V → V → Set Connected(v₁)(v₂) = Path(v₁)(v₂) Disconnected : V → V → Set Disconnected(v₁)(v₂) = ¬(Connected(v₁)(v₂)) -- Constructions mapVertices : ∀{V₂} → ⦃ _ : EdgeClass(V₂)(E) ⦄ → (V → V₂) → Graph(V₂)(E) mapVertices(f) = record{edges = map(edge ↦ (edge Edge.withVertices(f(Edge.from(edge)) , f(Edge.to(edge))))) (edges)} -- Boolean testing -- with-edge -- without-edge -- has-edge -- is-connected -- is-disconnected
{ "alphanum_fraction": 0.6059386009, "avg_line_length": 30.5692307692, "ext": "agda", "hexsha": "f3ef25f4368f0104341d40d7eadad0f4b09097c7", "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/Graph.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/Graph.agda", "max_line_length": 118, "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/Graph.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": 775, "size": 1987 }
-- Andreas, 2017-03-27 fixing regression #2472 -- Auto should be applicable also outside function clauses -- {-# OPTIONS -v auto:100 #-} open import Agda.Primitive test : Set {!!} test = Set -- Auto should succeed on this goal
{ "alphanum_fraction": 0.6982758621, "avg_line_length": 17.8461538462, "ext": "agda", "hexsha": "b72c1681efc4cc5337f9f3f93fcc311072801c3e", "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/Issue2472.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/Issue2472.agda", "max_line_length": 58, "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/Issue2472.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": 60, "size": 232 }
module TermUnification where open import OscarPrelude open import Delay open import VariableName open import FunctionName open import Arity open import Vector open import Term mutual substituteTerm⇑ : VariableName → Term → ∀ {i} → Term → Delay i Term substituteTerm⇑ 𝑥ₛ τₛ τ@(variable 𝑥) = now $ ifYes 𝑥ₛ ≟ 𝑥 then τₛ else τ substituteTerm⇑ 𝑥ₛ τₛ (function 𝑓 τs) = substituteTerms⇑ 𝑥ₛ τₛ τs >>= λ τsₛ → now $ function 𝑓 τsₛ substituteTerms⇑ : VariableName → Term → ∀ {i} → Terms → Delay i Terms substituteTerms⇑ 𝑥ₛ τₛ ⟨ ⟨ [] ⟩ ⟩ = now ⟨ ⟨ [] ⟩ ⟩ substituteTerms⇑ 𝑥ₛ τₛ ⟨ ⟨ τ ∷ τs ⟩ ⟩ = let τs = substituteTerms⇑ 𝑥ₛ τₛ ⟨ ⟨ τs ⟩ ⟩ τ = substituteTerm⇑ 𝑥ₛ τₛ τ in τs >>= λ { ⟨ ⟨ τs ⟩ ⟩ → τ >>= λ { τ → now $ ⟨ ⟨ τ ∷ τs ⟩ ⟩ } } substituteTerms⇓ : (𝑥ₛ : VariableName) → (τₛ : Term) → (τs : Terms) → substituteTerms⇑ 𝑥ₛ τₛ τs ⇓ substituteTerms⇓ 𝑥ₛ τₛ ⟨ ⟨ [] ⟩ ⟩ = _ , now⇓ substituteTerms⇓ 𝑥ₛ τₛ ⟨ ⟨ (variable 𝑥) ∷ τs ⟩ ⟩ = _ , substituteTerms⇓ 𝑥ₛ τₛ ⟨ ⟨ τs ⟩ ⟩ ⇓>>=⇓ now⇓ substituteTerms⇓ 𝑥ₛ τₛ ⟨ ⟨ (function 𝑓 τs₁) ∷ τs ⟩ ⟩ = _ , substituteTerms⇓ 𝑥ₛ τₛ ⟨ ⟨ τs ⟩ ⟩ ⇓>>=⇓ ((substituteTerms⇓ 𝑥ₛ τₛ τs₁ ⇓>>=⇓ now⇓) >>=⇓ now⇓) substituteTerm⇓ : (𝑥ₛ : VariableName) → (τₛ : Term) → (τ : Term) → substituteTerm⇑ 𝑥ₛ τₛ τ ⇓ substituteTerm⇓ 𝑥ₛ τₛ (variable 𝑥) = _ , now⇓ substituteTerm⇓ 𝑥ₛ τₛ (function 𝑓 τs) = _ , substituteTerms⇓ 𝑥ₛ τₛ τs ⇓>>=⇓ now⇓ substitute : VariableName → Term → Term → Term substitute 𝑥ₛ τₛ τ = fst $ substituteTerm⇓ 𝑥ₛ τₛ τ data AListOfSubstitutions : Set where [] : AListOfSubstitutions _∷_ : VariableName × Term → AListOfSubstitutions → AListOfSubstitutions substituteA : AListOfSubstitutions → Term → Term substituteA [] τ = τ substituteA ((𝑥ₛ , τₛ) ∷ as) τ = substituteA as (substitute 𝑥ₛ τₛ τ) record Unifier (τ₁ τ₂ : Term) : Set where field u₁ u₂ : AListOfSubstitutions unifier-law : substituteA u₁ τ₁ ≡ substituteA u₂ τ₂ unify? : (τ₁ τ₂ : Term) → Dec $ Unifier τ₁ τ₂ unify? (variable x) (variable x₁) = {!!} unify? (variable x) (function x₁ x₂) = {!!} unify? (function x x₁) (variable x₂) = {!!} unify? (function 𝑓₁ x₁) (function 𝑓₂ x₃) with 𝑓₁ ≟ 𝑓₂ unify? (function 𝑓₁ x₁) (function .𝑓₁ x₃) | yes refl = {!!} unify? (function 𝑓₁ x₁) (function 𝑓₂ x₃) | no 𝑓₁≢𝑓₂ = no (λ { record { u₁ = u₁ ; u₂ = u₂ ; unifier-law = unifier-law } → {!!}})
{ "alphanum_fraction": 0.6308551783, "avg_line_length": 37.5322580645, "ext": "agda", "hexsha": "75eaf4f30623bdeababbc53e6cb4289d0637c81c", "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/TermUnification.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/TermUnification.agda", "max_line_length": 150, "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/TermUnification.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1098, "size": 2327 }
{- Agda Implementors' Meeting VI Göteborg May 24 - 30, 2007 Hello Agda! Ulf Norell -} -- Let's have a closer look at the module system module Modules where {- Importing and opening modules -} -- You can import a module defined in a different file. import Naturals -- This will bring the module into scope and allows you to -- access its contents using qualified names. plusTwo : Naturals.Nat -> Naturals.Nat plusTwo n = Naturals._+_ n 2 -- To bring everything from a module into scope you can open -- the module. open Naturals z : Nat z = zero -- There's also a short-hand to import and open at the same time open import Bool _&&_ : Bool -> Bool -> Bool x && y = if x then y else false -- Sometimes it's nice to be able to control what is brought -- into scope when you open a module. There are three modifiers -- that affect this: using, hiding and renaming. module DifferentWaysOfOpeningNat where -- nothing but Nat open Naturals using (Nat) -- everything but zero open Naturals hiding (zero) -- everything, but zero and suc under different names open Naturals renaming (zero to ZZ; suc to S_S) two : Nat two = S S ZZ S S -- you can combine using or hiding with renaming, but not using -- with hiding (for obvious reasons). -- To re-export something opened use the public modifier. module A where open Naturals public using (Nat) N = A.Nat -- now Nat is a visible name in module A {- Parameterised modules -} -- A very useful feature is parameterised modules. data Vec (A : Set) : Nat -> Set where [] : Vec A 0 _::_ : {n : Nat} -> A -> Vec A n -> Vec A (suc n) infixr 40 _::_ module Sort {A : Set}(_≤_ : A -> A -> Bool) where insert : {n : Nat} -> A -> Vec A n -> Vec A (suc n) insert x [] = x :: [] insert x (y :: ys) = if x ≤ y then x :: y :: ys else y :: insert x ys sort : {n : Nat} -> Vec A n -> Vec A n sort [] = [] sort (x :: xs) = insert x (sort xs) _≤_ : Nat -> Nat -> Bool zero ≤ m = true suc n ≤ zero = false suc n ≤ suc m = n ≤ m -- When used directly, functions from parameterised modules -- take the parameters as extra arguments. test = Sort.sort _≤_ (6 :: 2 :: 0 :: 4 :: []) -- But, you can also apply the entire module to its arguments. -- Let's open the new module while we're at it. open module SortNat = Sort _≤_ test' = sort (3 :: 2 :: 4 :: 0 :: []) {- Local definitions -} data _==_ {A : Set}(x : A) : A -> Set where refl : x == x subst : {A : Set}(C : A -> Set){x y : A} -> x == y -> C x -> C y subst C refl cx = cx cong : {A B : Set}(f : A -> B){x y : A} -> x == y -> f x == f y cong f refl = refl lem₁ : (n : Nat) -> n + 0 == n lem₁ zero = refl lem₁ (suc n) = cong suc (lem₁ n) lem₂ : (n m : Nat) -> n + suc m == suc n + m lem₂ zero m = refl lem₂ (suc n) m = cong suc (lem₂ n m) -- You can define things locally to a function clause reverse : {A : Set}{n : Nat} -> Vec A n -> Vec A n reverse {A} = \xs -> subst (Vec A) (lem₁ _) (rev xs []) where rev : {n m : Nat} -> Vec A n -> Vec A m -> Vec A (n + m) rev [] ys = ys rev (_::_ {n} x xs) ys = subst (Vec A) (lem₂ n _) (rev xs (x :: ys)) -- More precisely, each clause can have one local module. In the -- example above we didn't bother naming the module. We could've -- said reverse' : {A : Set}{n : Nat} -> Vec A n -> Vec A n reverse' {A}{n} = \xs -> subst (Vec A) (lem₁ n) (rev xs []) module Rev where rev : {m p : Nat} -> Vec A m -> Vec A p -> Vec A (m + p) rev [] ys = ys rev (_::_ {n} x xs) ys = subst (Vec A) (lem₂ n _) (rev xs (x :: ys)) -- Now we can access the local function from inside the module Rev. -- Variables bound in the left hand side of the clause become -- parameters to the module, so since the implicit n argument to -- reverse' is bound implicitly there's an extra argument of type -- Nat which isn't used. test'' = Rev.rev {_}{0} (4 :: 3 :: 2 :: []) (5 :: 6 :: []) {- What's next? -} -- The final thing on the agenda is records. -- Move on to: Records.agda
{ "alphanum_fraction": 0.5789349112, "avg_line_length": 24.2816091954, "ext": "agda", "hexsha": "98d108a614a0f2773dab87f23c4a059415f0404e", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_forks_event_min_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "masondesu/agda", "max_forks_repo_path": "examples/AIM6/HelloAgda/Modules.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": "examples/AIM6/HelloAgda/Modules.agda", "max_line_length": 67, "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": "examples/AIM6/HelloAgda/Modules.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": 1280, "size": 4225 }
{-# OPTIONS --safe #-} open import Definition.Typed.EqualityRelation module Definition.LogicalRelation.Properties.Transitivity {{eqrel : EqRelSet}} where open EqRelSet {{...}} open import Definition.Untyped open import Definition.Untyped.Properties open import Definition.Typed open import Definition.Typed.Properties open import Definition.Typed.Weakening renaming (wk to TWwk) open import Definition.LogicalRelation open import Definition.LogicalRelation.Properties.Escape open import Definition.LogicalRelation.ShapeView open import Definition.LogicalRelation.Irrelevance open import Definition.LogicalRelation.Properties.Conversion open import Tools.Product open import Tools.Empty import Tools.PropositionalEquality as PE import Data.Nat as Nat mutual -- Helper function for transitivity of type equality using shape views. transEqT : ∀ {Γ A B C r l l′ l″} {[A] : Γ ⊩⟨ l ⟩ A ^ r} {[B] : Γ ⊩⟨ l′ ⟩ B ^ r} {[C] : Γ ⊩⟨ l″ ⟩ C ^ r} → ShapeView₃ Γ l l′ l″ A B C r r r [A] [B] [C] → Γ ⊩⟨ l ⟩ A ≡ B ^ r / [A] → Γ ⊩⟨ l′ ⟩ B ≡ C ^ r / [B] → Γ ⊩⟨ l ⟩ A ≡ C ^ r / [A] transEqT (Uᵥ UA UB UC) A≡B B≡C = let U≡U : Univ (LogRel._⊩¹U_^_.r UA) (LogRel._⊩¹U_^_.l′ UA) PE.≡ Univ (LogRel._⊩¹U_^_.r UB) (LogRel._⊩¹U_^_.l′ UB) U≡U = whrDet* (A≡B , Uₙ) ((_⊢_:⇒*:_^_.D (LogRel._⊩¹U_^_.d UB)) , Uₙ) r≡r , l≡l = Univ-PE-injectivity U≡U in PE.subst₂ (λ X Y → _ ⊢ _ ⇒* Univ X Y ^ [ ! , _ ]) (PE.sym r≡r) (PE.sym l≡l) B≡C transEqT (ℕᵥ D D′ D″) A≡B B≡C = B≡C transEqT (Emptyᵥ D D′ D″) A≡B B≡C = B≡C transEqT (ne (ne K [[ ⊢A , ⊢B , D ]] neK K≡K) (ne K₁ D₁ neK₁ _) (ne K₂ D₂ neK₂ _)) (ne₌ M D′ neM K≡M) (ne₌ M₁ D″ neM₁ K≡M₁) rewrite whrDet* (red D₁ , ne neK₁) (red D′ , ne neM) | whrDet* (red D₂ , ne neK₂) (red D″ , ne neM₁) = ne₌ M₁ D″ neM₁ (~-trans K≡M K≡M₁) transEqT {Γ} {r = [ r , ι lΠ ]} {l = l} {l′ = l′} {l″ = l″} (Πᵥ (Πᵣ rF lF lG _ _ F G D ⊢F ⊢G A≡A [F] [G] G-ext) (Πᵣ rF₁ lF₁ lG₁ _ _ F₁ G₁ D₁ ⊢F₁ ⊢G₁ A≡A₁ [F]₁ [G]₁ G-ext₁) (Πᵣ rF₂ lF₂ lG₂ _ _ F₂ G₂ D₂ ⊢F₂ ⊢G₂ A≡A₂ [F]₂ [G]₂ G-ext₂)) (Π₌ F′ G′ D′ A≡B [F≡F′] [G≡G′]) (Π₌ F″ G″ D″ A≡B₁ [F≡F′]₁ [G≡G′]₁) = let ΠF₁G₁≡ΠF′G′ = whrDet* (red D₁ , Πₙ) (D′ , Πₙ) F₁≡F′ , rF₁≡rF′ , lF₁≡lF′ , G₁≡G′ , lG₁≡lG′ , _ = Π-PE-injectivity ΠF₁G₁≡ΠF′G′ F₂≡F″ , rF₂≡rF′ , lF₂≡lF′ , G₂≡G″ , lG₂≡lG″ , _ = Π-PE-injectivity (whrDet* (red D₂ , Πₙ) (D″ , Πₙ)) substLift {Δ} {l} {a} {r} ρ x = Δ ⊩⟨ l ⟩ wk (lift ρ) x [ a ] ^ r [F′] : ∀ {ρ Δ} [ρ] ⊢Δ → Δ ⊩⟨ l′ ⟩ wk ρ F′ ^ [ rF₁ , ι lF₁ ] [F′] {ρ} [ρ] ⊢Δ = PE.subst (λ x → _ ⊩⟨ _ ⟩ wk ρ x ^ _) F₁≡F′ ([F]₁ [ρ] ⊢Δ) [F″] : ∀ {ρ} {Δ} [ρ] ⊢Δ → Δ ⊩⟨ l″ ⟩ wk ρ F″ ^ [ rF₂ , ι lF₂ ] [F″] {ρ} [ρ] ⊢Δ = PE.subst (λ x → _ ⊩⟨ _ ⟩ wk ρ x ^ _) F₂≡F″ ([F]₂ [ρ] ⊢Δ) [F′≡F″] : ∀ {ρ} {Δ} [ρ] ⊢Δ → Δ ⊩⟨ l′ ⟩ wk ρ F′ ≡ wk ρ F″ ^ [ rF₁ , ι lF₁ ] / [F′] [ρ] ⊢Δ [F′≡F″] {ρ} [ρ] ⊢Δ = irrelevanceEq′ (PE.cong (wk ρ) F₁≡F′) PE.refl PE.refl ([F]₁ [ρ] ⊢Δ) ([F′] [ρ] ⊢Δ) ([F≡F′]₁ [ρ] ⊢Δ) [G′] : ∀ {ρ Δ a} [ρ] ⊢Δ → Δ ⊩⟨ l′ ⟩ a ∷ wk ρ F′ ^ [ rF₁ , ι lF₁ ] / [F′] [ρ] ⊢Δ → Δ ⊩⟨ l′ ⟩ wk (lift ρ) G′ [ a ] ^ [ r , ι lG₁ ] [G′] {ρ} [ρ] ⊢Δ [a] = let [a′] = irrelevanceTerm′ (PE.cong (wk ρ) (PE.sym F₁≡F′)) PE.refl PE.refl ([F′] [ρ] ⊢Δ) ([F]₁ [ρ] ⊢Δ) [a] in PE.subst (substLift ρ) G₁≡G′ ([G]₁ [ρ] ⊢Δ [a′]) [G″] : ∀ {ρ Δ a} [ρ] ⊢Δ → Δ ⊩⟨ l″ ⟩ a ∷ wk ρ F″ ^ [ rF₂ , ι lF₂ ] / [F″] [ρ] ⊢Δ → Δ ⊩⟨ l″ ⟩ wk (lift ρ) G″ [ a ] ^ [ r , ι lG₂ ] [G″] {ρ} [ρ] ⊢Δ [a] = let [a″] = irrelevanceTerm′ (PE.cong (wk ρ) (PE.sym F₂≡F″)) PE.refl PE.refl ([F″] [ρ] ⊢Δ) ([F]₂ [ρ] ⊢Δ) [a] in PE.subst (substLift ρ) G₂≡G″ ([G]₂ [ρ] ⊢Δ [a″]) [G′≡G″] : ∀ {ρ Δ a} [ρ] ⊢Δ ([a] : Δ ⊩⟨ l′ ⟩ a ∷ wk ρ F′ ^ [ rF₁ , ι lF₁ ] / [F′] [ρ] ⊢Δ) → Δ ⊩⟨ l′ ⟩ wk (lift ρ) G′ [ a ] ≡ wk (lift ρ) G″ [ a ] ^ [ r , ι lG₁ ] / [G′] [ρ] ⊢Δ [a] [G′≡G″] {ρ} [ρ] ⊢Δ [a′] = let [a]₁ = irrelevanceTerm′ (PE.cong (wk ρ) (PE.sym F₁≡F′)) PE.refl PE.refl ([F′] [ρ] ⊢Δ) ([F]₁ [ρ] ⊢Δ) [a′] in irrelevanceEq′ (PE.cong (λ x → wk (lift ρ) x [ _ ]) G₁≡G′) PE.refl PE.refl ([G]₁ [ρ] ⊢Δ [a]₁) ([G′] [ρ] ⊢Δ [a′]) ([G≡G′]₁ [ρ] ⊢Δ [a]₁) -- Γ ⊢ .C ⇒* Π F″ ^ rF ▹ G″ ^ r in Π₌ F″ G″ (PE.subst₃ _ rF₁≡rF′ lF₁≡lF′ lG₁≡lG′ D″) (PE.subst₃ _ rF₁≡rF′ lF₁≡lF′ lG₁≡lG′ (≅-trans A≡B (PE.subst (λ x → Γ ⊢ x ≅ Π F″ ^ rF₁ ° lF₁ ▹ G″ ° lG₁ ° lΠ ^ [ r , ι lΠ ]) ΠF₁G₁≡ΠF′G′ A≡B₁))) (λ ρ ⊢Δ → transEq′ PE.refl PE.refl (PE.sym rF₁≡rF′) (PE.sym rF₂≡rF′) (PE.cong ι (PE.sym lF₁≡lF′)) (PE.cong ι (PE.sym lF₂≡lF′)) ([F] ρ ⊢Δ) ([F′] ρ ⊢Δ) ([F″] ρ ⊢Δ) ([F≡F′] ρ ⊢Δ) ([F′≡F″] ρ ⊢Δ)) (λ ρ ⊢Δ [a] → let [a′] = convTerm₁′ (PE.sym rF₁≡rF′) (PE.cong ι (PE.sym lF₁≡lF′)) ([F] ρ ⊢Δ) ([F′] ρ ⊢Δ) ([F≡F′] ρ ⊢Δ) [a] [a″] = convTerm₁′ (PE.sym rF₂≡rF′) (PE.cong ι (PE.sym lF₂≡lF′)) ([F′] ρ ⊢Δ) ([F″] ρ ⊢Δ) ([F′≡F″] ρ ⊢Δ) [a′] in transEq′ PE.refl PE.refl PE.refl PE.refl (PE.cong ι (PE.sym lG₁≡lG′)) (PE.cong ι (PE.sym lG₂≡lG″)) ([G] ρ ⊢Δ [a]) ([G′] ρ ⊢Δ [a′]) ([G″] ρ ⊢Δ [a″]) ([G≡G′] ρ ⊢Δ [a]) ([G′≡G″] ρ ⊢Δ [a′])) transEqT {Γ} {r = r} {l = l} {l′ = l′} {l″ = l″} (∃ᵥ (∃ᵣ F G D ⊢F ⊢G A≡A [F] [G] G-ext) (∃ᵣ F₁ G₁ D₁ ⊢F₁ ⊢G₁ A≡A₁ [F]₁ [G]₁ G-ext₁) (∃ᵣ F₂ G₂ D₂ ⊢F₂ ⊢G₂ A≡A₂ [F]₂ [G]₂ G-ext₂)) (∃₌ F′ G′ D′ A≡B [F≡F′] [G≡G′]) (∃₌ F″ G″ D″ A≡B₁ [F≡F′]₁ [G≡G′]₁) = let ∃F₁G₁≡∃F′G′ = whrDet* (red D₁ , ∃ₙ) (D′ , ∃ₙ) F₁≡F′ , G₁≡G′ = ∃-PE-injectivity ∃F₁G₁≡∃F′G′ F₂≡F″ , G₂≡G″ = ∃-PE-injectivity (whrDet* (red D₂ , ∃ₙ) (D″ , ∃ₙ)) substLift {Δ} {l} {a} {r} ρ x = Δ ⊩⟨ l ⟩ wk (lift ρ) x [ a ] ^ r lr = TypeInfo.l r [F′] : ∀ {ρ Δ} [ρ] ⊢Δ → Δ ⊩⟨ l′ ⟩ wk ρ F′ ^ [ % , lr ] [F′] {ρ} [ρ] ⊢Δ = PE.subst (λ x → _ ⊩⟨ _ ⟩ wk ρ x ^ _) F₁≡F′ ([F]₁ [ρ] ⊢Δ) [F″] : ∀ {ρ} {Δ} [ρ] ⊢Δ → Δ ⊩⟨ l″ ⟩ wk ρ F″ ^ [ % , lr ] [F″] {ρ} [ρ] ⊢Δ = PE.subst (λ x → _ ⊩⟨ _ ⟩ wk ρ x ^ _) F₂≡F″ ([F]₂ [ρ] ⊢Δ) [F′≡F″] : ∀ {ρ} {Δ} [ρ] ⊢Δ → Δ ⊩⟨ l′ ⟩ wk ρ F′ ≡ wk ρ F″ ^ [ % , lr ] / [F′] [ρ] ⊢Δ [F′≡F″] {ρ} [ρ] ⊢Δ = irrelevanceEq′ (PE.cong (wk ρ) F₁≡F′) PE.refl PE.refl ([F]₁ [ρ] ⊢Δ) ([F′] [ρ] ⊢Δ) ([F≡F′]₁ [ρ] ⊢Δ) [G′] : ∀ {ρ Δ a} [ρ] ⊢Δ → Δ ⊩⟨ l′ ⟩ a ∷ wk ρ F′ ^ [ % , lr ] / [F′] [ρ] ⊢Δ → Δ ⊩⟨ l′ ⟩ wk (lift ρ) G′ [ a ] ^ r [G′] {ρ} [ρ] ⊢Δ [a] = let [a′] = irrelevanceTerm′ (PE.cong (wk ρ) (PE.sym F₁≡F′)) PE.refl PE.refl ([F′] [ρ] ⊢Δ) ([F]₁ [ρ] ⊢Δ) [a] in PE.subst (substLift ρ) G₁≡G′ ([G]₁ [ρ] ⊢Δ [a′]) [G″] : ∀ {ρ Δ a} [ρ] ⊢Δ → Δ ⊩⟨ l″ ⟩ a ∷ wk ρ F″ ^ [ % , lr ] / [F″] [ρ] ⊢Δ → Δ ⊩⟨ l″ ⟩ wk (lift ρ) G″ [ a ] ^ r [G″] {ρ} [ρ] ⊢Δ [a] = let [a″] = irrelevanceTerm′ (PE.cong (wk ρ) (PE.sym F₂≡F″)) PE.refl PE.refl ([F″] [ρ] ⊢Δ) ([F]₂ [ρ] ⊢Δ) [a] in PE.subst (substLift ρ) G₂≡G″ ([G]₂ [ρ] ⊢Δ [a″]) [G′≡G″] : ∀ {ρ Δ a} [ρ] ⊢Δ ([a] : Δ ⊩⟨ l′ ⟩ a ∷ wk ρ F′ ^ [ % , lr ] / [F′] [ρ] ⊢Δ) → Δ ⊩⟨ l′ ⟩ wk (lift ρ) G′ [ a ] ≡ wk (lift ρ) G″ [ a ] ^ r / [G′] [ρ] ⊢Δ [a] [G′≡G″] {ρ} [ρ] ⊢Δ [a′] = let [a]₁ = irrelevanceTerm′ (PE.cong (wk ρ) (PE.sym F₁≡F′)) PE.refl PE.refl ([F′] [ρ] ⊢Δ) ([F]₁ [ρ] ⊢Δ) [a′] in irrelevanceEq′ (PE.cong (λ x → wk (lift ρ) x [ _ ]) G₁≡G′) PE.refl PE.refl ([G]₁ [ρ] ⊢Δ [a]₁) ([G′] [ρ] ⊢Δ [a′]) ([G≡G′]₁ [ρ] ⊢Δ [a]₁) -- Γ ⊢ .C ⇒* ∃ F″ ^ rF ▹ G″ ^ r in ∃₌ F″ G″ D″ (≅-trans A≡B (PE.subst (λ x → Γ ⊢ x ≅ ∃ F″ ▹ G″ ^ [ % , lr ]) ∃F₁G₁≡∃F′G′ A≡B₁)) (λ ρ ⊢Δ → transEq′ PE.refl PE.refl PE.refl PE.refl PE.refl PE.refl ([F] ρ ⊢Δ) ([F′] ρ ⊢Δ) ([F″] ρ ⊢Δ) ([F≡F′] ρ ⊢Δ) ([F′≡F″] ρ ⊢Δ)) (λ ρ ⊢Δ [a] → let [a′] = convTerm₁′ PE.refl PE.refl ([F] ρ ⊢Δ) ([F′] ρ ⊢Δ) ([F≡F′] ρ ⊢Δ) [a] [a″] = convTerm₁′ PE.refl PE.refl ([F′] ρ ⊢Δ) ([F″] ρ ⊢Δ) ([F′≡F″] ρ ⊢Δ) [a′] in transEq ([G] ρ ⊢Δ [a]) ([G′] ρ ⊢Δ [a′]) ([G″] ρ ⊢Δ [a″]) ([G≡G′] ρ ⊢Δ [a]) ([G′≡G″] ρ ⊢Δ [a′])) transEqT (emb⁰¹¹ S) A≡B B≡C = transEqT S A≡B B≡C transEqT (emb¹⁰¹ S) A≡B B≡C = transEqT S A≡B B≡C transEqT (emb¹¹⁰ S) A≡B B≡C = transEqT S A≡B B≡C transEqT (emb¹∞∞ S) A≡B B≡C = transEqT S A≡B B≡C transEqT (emb∞¹∞ S) A≡B B≡C = transEqT S A≡B B≡C transEqT (emb∞∞¹ S) A≡B B≡C = transEqT S A≡B B≡C -- Transitivty of type equality. transEq : ∀ {Γ A B C r l l′ l″} ([A] : Γ ⊩⟨ l ⟩ A ^ r) ([B] : Γ ⊩⟨ l′ ⟩ B ^ r) ([C] : Γ ⊩⟨ l″ ⟩ C ^ r) → Γ ⊩⟨ l ⟩ A ≡ B ^ r / [A] → Γ ⊩⟨ l′ ⟩ B ≡ C ^ r / [B] → Γ ⊩⟨ l ⟩ A ≡ C ^ r / [A] transEq [A] [B] [C] A≡B B≡C = transEqT (combine (goodCases [A] [B] A≡B) (goodCases [B] [C] B≡C)) A≡B B≡C -- Transitivity of type equality with some propositonally equal types. transEq′ : ∀ {Γ A B B′ C C′ r r' r'' ll ll' ll'' l l′ l″} → B PE.≡ B′ → C PE.≡ C′ → r PE.≡ r' → r' PE.≡ r'' → ll PE.≡ ll' → ll' PE.≡ ll'' → ([A] : Γ ⊩⟨ l ⟩ A ^ [ r , ll ]) ([B] : Γ ⊩⟨ l′ ⟩ B ^ [ r' , ll' ]) ([C] : Γ ⊩⟨ l″ ⟩ C ^ [ r'' , ll'' ]) → Γ ⊩⟨ l ⟩ A ≡ B′ ^ [ r , ll ] / [A] → Γ ⊩⟨ l′ ⟩ B ≡ C′ ^ [ r' , ll' ] / [B] → Γ ⊩⟨ l ⟩ A ≡ C ^ [ r , ll ] / [A] transEq′ PE.refl PE.refl PE.refl PE.refl PE.refl PE.refl [A] [B] [C] A≡B B≡C = transEq [A] [B] [C] A≡B B≡C transEqTermNe : ∀ {Γ n n′ n″ A r} → Γ ⊩neNf n ≡ n′ ∷ A ^ r → Γ ⊩neNf n′ ≡ n″ ∷ A ^ r → Γ ⊩neNf n ≡ n″ ∷ A ^ r transEqTermNe (neNfₜ₌ neK neM k≡m) (neNfₜ₌ neK₁ neM₁ k≡m₁) = neNfₜ₌ neK neM₁ (~-trans k≡m k≡m₁) mutual transEqTermℕ : ∀ {Γ n n′ n″} → Γ ⊩ℕ n ≡ n′ ∷ℕ → Γ ⊩ℕ n′ ≡ n″ ∷ℕ → Γ ⊩ℕ n ≡ n″ ∷ℕ transEqTermℕ (ℕₜ₌ k k′ d d′ t≡u prop) (ℕₜ₌ k₁ k″ d₁ d″ t≡u₁ prop₁) = let k₁Whnf = naturalWhnf (proj₁ (split prop₁)) k′Whnf = naturalWhnf (proj₂ (split prop)) k₁≡k′ = whrDet*Term (redₜ d₁ , k₁Whnf) (redₜ d′ , k′Whnf) prop′ = PE.subst (λ x → [Natural]-prop _ x _) k₁≡k′ prop₁ in ℕₜ₌ k k″ d d″ (≅ₜ-trans t≡u (PE.subst (λ x → _ ⊢ x ≅ _ ∷ _ ^ _) k₁≡k′ t≡u₁)) (transNatural-prop prop prop′) transNatural-prop : ∀ {Γ k k′ k″} → [Natural]-prop Γ k k′ → [Natural]-prop Γ k′ k″ → [Natural]-prop Γ k k″ transNatural-prop (sucᵣ x) (sucᵣ x₁) = sucᵣ (transEqTermℕ x x₁) transNatural-prop (sucᵣ x) (ne (neNfₜ₌ () neM k≡m)) transNatural-prop zeroᵣ prop₁ = prop₁ transNatural-prop prop zeroᵣ = prop transNatural-prop (ne (neNfₜ₌ neK () k≡m)) (sucᵣ x₃) transNatural-prop (ne [k≡k′]) (ne [k′≡k″]) = ne (transEqTermNe [k≡k′] [k′≡k″]) -- Empty transEmpty-prop : ∀ {Γ k k′ k″ l} → [Empty]-prop Γ k k′ l → [Empty]-prop Γ k′ k″ l → [Empty]-prop Γ k k″ l transEmpty-prop (ne a b) (ne c d) = ne a d transEqTermEmpty : ∀ {Γ n n′ n″ l} → Γ ⊩Empty n ≡ n′ ∷Empty^ l → Γ ⊩Empty n′ ≡ n″ ∷Empty^ l → Γ ⊩Empty n ≡ n″ ∷Empty^ l transEqTermEmpty (Emptyₜ₌ (ne a b)) (Emptyₜ₌ (ne c d)) = Emptyₜ₌ (ne a d) -- Transitivity of term equality. transEqTerm⁰ : ∀ {Γ A t u v r} ([A] : Γ ⊩⟨ ι ⁰ ⟩ A ^ r) → Γ ⊩⟨ ι ⁰ ⟩ t ≡ u ∷ A ^ r / [A] → Γ ⊩⟨ ι ⁰ ⟩ u ≡ v ∷ A ^ r / [A] → Γ ⊩⟨ ι ⁰ ⟩ t ≡ v ∷ A ^ r / [A] transEqTerm⁰ (ℕᵣ D) [t≡u] [u≡v] = transEqTermℕ [t≡u] [u≡v] transEqTerm⁰ (Emptyᵣ D) [t≡u] [u≡v] = transEqTermEmpty [t≡u] [u≡v] transEqTerm⁰ {r = [ ! , l ]} (ne′ K D neK K≡K) (neₜ₌ k m d d′ (neNfₜ₌ neK₁ neM k≡m)) (neₜ₌ k₁ m₁ d₁ d″ (neNfₜ₌ neK₂ neM₁ k≡m₁)) = let k₁≡m = whrDet*Term (redₜ d₁ , ne neK₂) (redₜ d′ , ne neM) in neₜ₌ k m₁ d d″ (neNfₜ₌ neK₁ neM₁ (~-trans k≡m (PE.subst (λ x → _ ⊢ x ~ _ ∷ _ ^ _) k₁≡m k≡m₁))) transEqTerm⁰ {r = [ % , l ]} (ne′ K D neK K≡K) (neₜ₌ d d′) (neₜ₌ d₁ d″) = neₜ₌ d d″ transEqTerm⁰ {r = [ ! , l ]} (Πᵣ′ rF lF lG _ _ F G D ⊢F ⊢G A≡A [F] [G] G-ext) (Πₜ₌ f g d d′ funcF funcG f≡g [f] [g] [f≡g]) (Πₜ₌ f₁ g₁ d₁ d₁′ funcF₁ funcG₁ f≡g₁ [f]₁ [g]₁ [f≡g]₁) rewrite whrDet*Term (redₜ d′ , functionWhnf funcG) (redₜ d₁ , functionWhnf funcF₁) = Πₜ₌ f g₁ d d₁′ funcF funcG₁ (≅ₜ-trans f≡g f≡g₁) [f] [g]₁ (λ ρ ⊢Δ [a] → transEqTerm⁰ ([G] ρ ⊢Δ [a]) ([f≡g] ρ ⊢Δ [a]) ([f≡g]₁ ρ ⊢Δ [a])) transEqTerm⁰ {r = [ % , l ]} (Πᵣ′ rF lF lG _ _ F G D ⊢F ⊢G A≡A [F] [G] G-ext) (d , d′) (d₁ , d₁′) = d , d₁′ transEqTerm⁰ {r = [ % , l ]} (∃ᵣ′ F G D ⊢F ⊢G A≡A [F] [G] G-ext) (d , d′) (d₁ , d₁′) = d , d₁′ transEqTerm¹ : ∀ {Γ A t u v r} ([A] : Γ ⊩⟨ ι ¹ ⟩ A ^ r) → Γ ⊩⟨ ι ¹ ⟩ t ≡ u ∷ A ^ r / [A] → Γ ⊩⟨ ι ¹ ⟩ u ≡ v ∷ A ^ r / [A] → Γ ⊩⟨ ι ¹ ⟩ t ≡ v ∷ A ^ r / [A] transEqTerm¹ {Γ} {A} {t} {u} {v} {r} (Uᵣ (Uᵣ rU ⁰ l< eq d)) (Uₜ₌ [t] [u] A≡B [t≡u]) (Uₜ₌ [u]′ [v] B′≡C [u≡v]) = let ti = LogRel._⊩¹U_∷_^_/_.[t] ⊢Γ = wf (_⊢_:⇒*:_^_.⊢A d) B≡B′ = whrDet*Term (_⊢_:⇒*:_∷_^_.d (LogRel._⊩¹U_∷_^_/_.d [u]) , typeWhnf (LogRel._⊩¹U_∷_^_/_.typeK [u])) (_⊢_:⇒*:_∷_^_.d (LogRel._⊩¹U_∷_^_/_.d [u]′) , typeWhnf (LogRel._⊩¹U_∷_^_/_.typeK [u]′)) A≡C = ≅ₜ-trans (PE.subst (λ X → EqRelSet._⊢_≅_∷_^_ eqrel Γ (LogRel._⊩¹U_∷_^_/_.K [t]) X (Univ rU ⁰) ([ ! , ι ¹ ])) B≡B′ A≡B) B′≡C [t≡v] = λ {ρ} {Δ} ([ρ] : ρ ∷ Δ ⊆ Γ) ⊢Δ → transEq (ti [t] [ρ] ⊢Δ) (ti [u] [ρ] ⊢Δ) (ti [v] [ρ] ⊢Δ) ([t≡u] [ρ] ⊢Δ) (irrelevanceEq (ti [u]′ [ρ] ⊢Δ) (ti [u] [ρ] ⊢Δ) ([u≡v] [ρ] ⊢Δ)) in Uₜ₌ [t] [v] A≡C [t≡v] transEqTerm¹ (ℕᵣ D) [t≡u] [u≡v] = transEqTermℕ [t≡u] [u≡v] transEqTerm¹ (Emptyᵣ D) [t≡u] [u≡v] = transEqTermEmpty [t≡u] [u≡v] transEqTerm¹ {r = [ ! , l ]} (ne′ K D neK K≡K) (neₜ₌ k m d d′ (neNfₜ₌ neK₁ neM k≡m)) (neₜ₌ k₁ m₁ d₁ d″ (neNfₜ₌ neK₂ neM₁ k≡m₁)) = let k₁≡m = whrDet*Term (redₜ d₁ , ne neK₂) (redₜ d′ , ne neM) in neₜ₌ k m₁ d d″ (neNfₜ₌ neK₁ neM₁ (~-trans k≡m (PE.subst (λ x → _ ⊢ x ~ _ ∷ _ ^ _) k₁≡m k≡m₁))) transEqTerm¹ {r = [ % , l ]} (ne′ K D neK K≡K) (neₜ₌ d d′) (neₜ₌ d₁ d″) = neₜ₌ d d″ transEqTerm¹ {r = [ ! , l ]} (Πᵣ′ rF lF lG _ _ F G D ⊢F ⊢G A≡A [F] [G] G-ext) (Πₜ₌ f g d d′ funcF funcG f≡g [f] [g] [f≡g]) (Πₜ₌ f₁ g₁ d₁ d₁′ funcF₁ funcG₁ f≡g₁ [f]₁ [g]₁ [f≡g]₁) rewrite whrDet*Term (redₜ d′ , functionWhnf funcG) (redₜ d₁ , functionWhnf funcF₁) = Πₜ₌ f g₁ d d₁′ funcF funcG₁ (≅ₜ-trans f≡g f≡g₁) [f] [g]₁ (λ ρ ⊢Δ [a] → transEqTerm¹ ([G] ρ ⊢Δ [a]) ([f≡g] ρ ⊢Δ [a]) ([f≡g]₁ ρ ⊢Δ [a])) transEqTerm¹ {r = [ % , l ]} (Πᵣ′ rF lF lG _ _ F G D ⊢F ⊢G A≡A [F] [G] G-ext) (d , d′) (d₁ , d₁′) = d , d₁′ transEqTerm¹ {r = [ % , l ]} (∃ᵣ′ F G D ⊢F ⊢G A≡A [F] [G] G-ext) (d , d′) (d₁ , d₁′) = d , d₁′ transEqTerm¹ (emb l< [A]) [t≡u] [u≡v] = transEqTerm⁰ [A] [t≡u] [u≡v] transEqTerm∞ : ∀ {Γ A t u v r} ([A] : Γ ⊩⟨ ∞ ⟩ A ^ r) → Γ ⊩⟨ ∞ ⟩ t ≡ u ∷ A ^ r / [A] → Γ ⊩⟨ ∞ ⟩ u ≡ v ∷ A ^ r / [A] → Γ ⊩⟨ ∞ ⟩ t ≡ v ∷ A ^ r / [A] transEqTerm∞ {Γ} {A} {t} {u} {v} {r} (Uᵣ (Uᵣ rU ⁰ l< eq d)) (Uₜ₌ [t] [u] A≡B [t≡u]) (Uₜ₌ [u]′ [v] B′≡C [u≡v]) = let ti = LogRel._⊩¹U_∷_^_/_.[t] ⊢Γ = wf (_⊢_:⇒*:_^_.⊢A d) B≡B′ = whrDet*Term (_⊢_:⇒*:_∷_^_.d (LogRel._⊩¹U_∷_^_/_.d [u]) , typeWhnf (LogRel._⊩¹U_∷_^_/_.typeK [u])) (_⊢_:⇒*:_∷_^_.d (LogRel._⊩¹U_∷_^_/_.d [u]′) , typeWhnf (LogRel._⊩¹U_∷_^_/_.typeK [u]′)) A≡C = ≅ₜ-trans (PE.subst (λ X → EqRelSet._⊢_≅_∷_^_ eqrel Γ (LogRel._⊩¹U_∷_^_/_.K [t]) X (Univ rU ⁰) ([ ! , ι ¹ ])) B≡B′ A≡B) B′≡C [t≡v] = λ {ρ} {Δ} ([ρ] : ρ ∷ Δ ⊆ Γ) ⊢Δ → transEq (ti [t] [ρ] ⊢Δ) (ti [u] [ρ] ⊢Δ) (ti [v] [ρ] ⊢Δ) ([t≡u] [ρ] ⊢Δ) (irrelevanceEq (ti [u]′ [ρ] ⊢Δ) (ti [u] [ρ] ⊢Δ) ([u≡v] [ρ] ⊢Δ)) in Uₜ₌ [t] [v] A≡C [t≡v] transEqTerm∞ {Γ} {A} {t} {u} {v} {r} (Uᵣ (Uᵣ rU ¹ l< eq d)) (Uₜ₌ [t] [u] A≡B [t≡u]) (Uₜ₌ [u]′ [v] B′≡C [u≡v]) = let ti = LogRel._⊩¹U_∷_^_/_.[t] ⊢Γ = wf (_⊢_:⇒*:_^_.⊢A d) B≡B′ = whrDet*Term (_⊢_:⇒*:_∷_^_.d (LogRel._⊩¹U_∷_^_/_.d [u]) , typeWhnf (LogRel._⊩¹U_∷_^_/_.typeK [u])) (_⊢_:⇒*:_∷_^_.d (LogRel._⊩¹U_∷_^_/_.d [u]′) , typeWhnf (LogRel._⊩¹U_∷_^_/_.typeK [u]′)) A≡C = ≅ₜ-trans (PE.subst (λ X → EqRelSet._⊢_≅_∷_^_ eqrel Γ (LogRel._⊩¹U_∷_^_/_.K [t]) X (Univ rU ¹) ([ ! , ∞ ])) B≡B′ A≡B) B′≡C [t≡v] = λ {ρ} {Δ} ([ρ] : ρ ∷ Δ ⊆ Γ) ⊢Δ → transEq (ti [t] [ρ] ⊢Δ) (ti [u] [ρ] ⊢Δ) (ti [v] [ρ] ⊢Δ) ([t≡u] [ρ] ⊢Δ) (irrelevanceEq (ti [u]′ [ρ] ⊢Δ) (ti [u] [ρ] ⊢Δ) ([u≡v] [ρ] ⊢Δ)) in Uₜ₌ [t] [v] A≡C [t≡v] transEqTerm∞ (ℕᵣ D) [t≡u] [u≡v] = transEqTermℕ [t≡u] [u≡v] transEqTerm∞ (Emptyᵣ D) [t≡u] [u≡v] = transEqTermEmpty [t≡u] [u≡v] transEqTerm∞ {r = [ ! , l ]} (ne′ K D neK K≡K) (neₜ₌ k m d d′ (neNfₜ₌ neK₁ neM k≡m)) (neₜ₌ k₁ m₁ d₁ d″ (neNfₜ₌ neK₂ neM₁ k≡m₁)) = let k₁≡m = whrDet*Term (redₜ d₁ , ne neK₂) (redₜ d′ , ne neM) in neₜ₌ k m₁ d d″ (neNfₜ₌ neK₁ neM₁ (~-trans k≡m (PE.subst (λ x → _ ⊢ x ~ _ ∷ _ ^ _) k₁≡m k≡m₁))) transEqTerm∞ {r = [ % , l ]} (ne′ K D neK K≡K) (neₜ₌ d d′) (neₜ₌ d₁ d″) = neₜ₌ d d″ transEqTerm∞ {r = [ ! , l ]} (Πᵣ′ rF lF lG _ _ F G D ⊢F ⊢G A≡A [F] [G] G-ext) (Πₜ₌ f g d d′ funcF funcG f≡g [f] [g] [f≡g]) (Πₜ₌ f₁ g₁ d₁ d₁′ funcF₁ funcG₁ f≡g₁ [f]₁ [g]₁ [f≡g]₁) rewrite whrDet*Term (redₜ d′ , functionWhnf funcG) (redₜ d₁ , functionWhnf funcF₁) = Πₜ₌ f g₁ d d₁′ funcF funcG₁ (≅ₜ-trans f≡g f≡g₁) [f] [g]₁ (λ ρ ⊢Δ [a] → transEqTerm∞ ([G] ρ ⊢Δ [a]) ([f≡g] ρ ⊢Δ [a]) ([f≡g]₁ ρ ⊢Δ [a])) transEqTerm∞ {r = [ % , l ]} (Πᵣ′ rF lF lG _ _ F G D ⊢F ⊢G A≡A [F] [G] G-ext) (d , d′) (d₁ , d₁′) = d , d₁′ transEqTerm∞ {r = [ % , l ]} (∃ᵣ′ F G D ⊢F ⊢G A≡A [F] [G] G-ext) (d , d′) (d₁ , d₁′) = d , d₁′ transEqTerm∞ (emb {l′ = ι ¹} l< [A]) [t≡u] [u≡v] = transEqTerm¹ [A] [t≡u] [u≡v] transEqTerm : ∀ {l Γ A t u v r} ([A] : Γ ⊩⟨ l ⟩ A ^ r) → Γ ⊩⟨ l ⟩ t ≡ u ∷ A ^ r / [A] → Γ ⊩⟨ l ⟩ u ≡ v ∷ A ^ r / [A] → Γ ⊩⟨ l ⟩ t ≡ v ∷ A ^ r / [A] transEqTerm {l = ι ⁰} = transEqTerm⁰ transEqTerm {l = ι ¹} = transEqTerm¹ transEqTerm {l = ∞} = transEqTerm∞
{ "alphanum_fraction": 0.4051377283, "avg_line_length": 52.6793478261, "ext": "agda", "hexsha": "ce96cd8b783156fb05192e0619d8a5b7d38404ea", "lang": "Agda", "max_forks_count": 2, "max_forks_repo_forks_event_max_datetime": "2022-02-15T19:42:19.000Z", "max_forks_repo_forks_event_min_datetime": "2022-01-26T14:55:51.000Z", "max_forks_repo_head_hexsha": "e0eeebc4aa5ed791ce3e7c0dc9531bd113dfcc04", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "CoqHott/logrel-mltt", "max_forks_repo_path": "Definition/LogicalRelation/Properties/Transitivity.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "e0eeebc4aa5ed791ce3e7c0dc9531bd113dfcc04", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "CoqHott/logrel-mltt", "max_issues_repo_path": "Definition/LogicalRelation/Properties/Transitivity.agda", "max_line_length": 201, "max_stars_count": 2, "max_stars_repo_head_hexsha": "e0eeebc4aa5ed791ce3e7c0dc9531bd113dfcc04", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "CoqHott/logrel-mltt", "max_stars_repo_path": "Definition/LogicalRelation/Properties/Transitivity.agda", "max_stars_repo_stars_event_max_datetime": "2022-01-17T16:13:53.000Z", "max_stars_repo_stars_event_min_datetime": "2018-06-21T08:39:01.000Z", "num_tokens": 10737, "size": 19386 }
{-# OPTIONS --without-K #-} module function.isomorphism.core where open import level using (_⊔_) open import equality.core open import equality.groupoid open import equality.reasoning open import function.core open import function.overloading open import sum open import function.extensionality.core open import overloading.core -- isomorphisms record _≅_ {i j}(X : Set i)(Y : Set j) : Set (i ⊔ j) where constructor iso field to : X → Y from : Y → X iso₁ : (x : X) → from (to x) ≡ x iso₂ : (y : Y) → to (from y) ≡ y infix 5 _≅_ ≅-struct-iso : ∀ {i j}{X : Set i}{Y : Set j} → (X ≅ Y) ≅ ( Σ (X → Y) λ f → Σ (Y → X) λ g → ((x : X) → g (f x) ≡ x) × ((y : Y) → f (g y) ≡ y) ) ≅-struct-iso = record { to = λ { (iso f g α β) → f , g , α , β } ; from = λ { (f , g , α , β) → iso f g α β } ; iso₁ = λ _ → refl ; iso₂ = λ _ → refl } refl≅ : ∀ {i}{X : Set i} → X ≅ X refl≅ = iso id id (λ _ → refl) (λ _ → refl) ≡⇒≅ : ∀ {i}{X Y : Set i} → X ≡ Y → X ≅ Y ≡⇒≅ refl = refl≅ sym≅ : ∀ {i j}{X : Set i}{Y : Set j} → X ≅ Y → Y ≅ X sym≅ (iso f g H K) = iso g f K H trans≅ : ∀ {i j k}{X : Set i}{Y : Set j}{Z : Set k} → X ≅ Y → Y ≅ Z → X ≅ Z trans≅ {X = X}{Z = Z} (iso f g H K) (iso f' g' H' K') = record { to = f' ∘ f ; from = g ∘ g' ; iso₁ = iso₁ ; iso₂ = iso₂ } where abstract iso₁ : (x : X) → g (g' (f' (f x))) ≡ x iso₁ x = ap g (H' (f x)) · H x iso₂ : (z : Z) → f' (f (g (g' z))) ≡ z iso₂ y = ap f' (K (g' y)) · K' y _·≅_ : ∀ {i j k}{X : Set i}{Y : Set j}{Z : Set k} → X ≅ Y → Y ≅ Z → X ≅ Z _·≅_ = trans≅ infixl 9 _·≅_ module ≅-Reasoning where infix 4 _IsRelatedTo_ infix 2 _∎ infixr 2 _≅⟨_⟩_ infixr 2 _≡⟨_⟩_ infix 1 begin_ data _IsRelatedTo_ {i j}(x : Set i)(y : Set j) : Set (i ⊔ j) where relTo : x ≅ y → x IsRelatedTo y begin_ : ∀ {i j}{X : Set i}{Y : Set j} → X IsRelatedTo Y → X ≅ Y begin relTo p = p _≅⟨_⟩_ : ∀ {i j k} (X : Set i) {Y : Set j}{Z : Set k} → X ≅ Y → Y IsRelatedTo Z → X IsRelatedTo Z _ ≅⟨ p ⟩ relTo q = relTo (trans≅ p q) _≡⟨_⟩_ : ∀ {i j} (X : Set i) {Y : Set i} {Z : Set j} → X ≡ Y → Y IsRelatedTo Z → X IsRelatedTo Z _ ≡⟨ p ⟩ relTo q = relTo (trans≅ (≡⇒≅ p) q) _∎ : ∀ {i} (X : Set i) → X IsRelatedTo X _∎ _ = relTo refl≅ injective : ∀ {i j}{X : Set i}{Y : Set j} → (f : X → Y) → Set _ injective f = ∀ {x x'} → f x ≡ f x' → x ≡ x' retraction : ∀ {i j}{X : Set i}{Y : Set j} → (f : X → Y) → Set _ retraction {X = X}{Y = Y} f = (y : Y) → Σ X λ x → f x ≡ y _↣_ : ∀ {i j} → Set i → Set j → Set _ A ↣ B = Σ (A → B) injective -- composition of injections: _∘i_ : ∀ {i j k}{A : Set i}{B : Set j}{C : Set k} → (B ↣ C) → (A ↣ B) → (A ↣ C) (g , p) ∘i (f , q) = g ∘ f , q ∘ p _↠_ : ∀ {i j} → Set i → Set j → Set _ A ↠ B = Σ (A → B) retraction private module properties {i j}{X : Set i}{Y : Set j} where apply≅ : (X ≅ Y) → X → Y apply≅ = _≅_.to invert≅ : (X ≅ Y) → Y → X invert≅ = _≅_.from instance iso-is-fun : Coercion (X ≅ Y) (X → Y) iso-is-fun = record { coerce = _≅_.to } iso-is-iso : Coercion (X ≅ Y) (X ≅ Y) iso-is-iso = coerce-self _ inj-is-fun : Coercion (X ↣ Y) (X → Y) inj-is-fun = record { coerce = proj₁ } srj-is-fun : Coercion (X ↠ Y) (X → Y) srj-is-fun = record { coerce = proj₁ } private module iso-methods {k}{Source : Set k} ⦃ c : Coercion Source (X ≅ Y) ⦄ where private module with-source (source : Source) where private target = coerce c source open _≅_ target public using () renaming (from to invert) open with-source public open iso-methods public iso⇒inj : (iso : X ≅ Y) → injective (apply iso) iso⇒inj f {x}{x'} q = (iso₁ x) ⁻¹ · ap from q · iso₁ x' where open _≅_ f iso⇒retr : (iso : X ≅ Y) → retraction (apply iso) iso⇒retr f y = from y , iso₂ y where open _≅_ f inj+retr⇒iso : (f : X → Y) → injective f → retraction f → X ≅ Y inj+retr⇒iso f inj-f retr-f = iso f g H K where g : Y → X g y = proj₁ (retr-f y) H : (x : X) → g (f x) ≡ x H x = inj-f (proj₂ (retr-f (f x))) K : (y : Y) → f (g y) ≡ y K y = proj₂ (retr-f y) open properties public
{ "alphanum_fraction": 0.4700564972, "avg_line_length": 26.656626506, "ext": "agda", "hexsha": "6473dc10d7f3fe3f5adcf9282776a3897fd66623", "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": "function/isomorphism/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": "function/isomorphism/core.agda", "max_line_length": 68, "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": "function/isomorphism/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": 1893, "size": 4425 }
{-# OPTIONS --without-K --safe #-} open import Algebra.Structures.Bundles.Field module Algebra.Linear.Morphism.Bundles {k ℓᵏ} (K : Field k ℓᵏ) where open import Algebra.FunctionProperties as FP open import Relation.Binary using (Rel; Setoid) open import Level import Algebra.Linear.Structures.Bundles as VS open import Algebra.Linear.Morphism.VectorSpace K open import Function.Equality as FunEq using (_⟶_; _⟨$⟩_; setoid) module _ {a₁ ℓ₁} (From : VS.VectorSpace K a₁ ℓ₁) {a₂ ℓ₂} (To : VS.VectorSpace K a₂ ℓ₂) where private module F = VS.VectorSpace From module T = VS.VectorSpace To K' : Set k K' = Field.Carrier K open F using () renaming ( Carrier to A ; _≈_ to _≈₁_ ; refl to ≈₁-refl ; sym to ≈₁-sym ; setoid to A-setoid ; _+_ to +₁ ; _∙_ to ∙₁ ) open T using () renaming ( Carrier to B ; _≈_ to _≈₂_ ; refl to ≈₂-refl ; sym to ≈₂-sym ; trans to ≈₂-trans ; setoid to B-setoid ; _+_ to +₂ ; _∙_ to ∙₂ ) hom-setoid : ∀ {Carrier} -> (Carrier -> (A-setoid ⟶ B-setoid)) -> Setoid (suc (k ⊔ a₁ ⊔ a₂ ⊔ ℓ₁ ⊔ ℓ₂)) (a₁ ⊔ ℓ₁ ⊔ ℓ₂) hom-setoid {Carrier} app = record { Carrier = Carrier ; _≈_ = λ f g → ∀ {x y} (r : x ≈₁ y) -> (app f ⟨$⟩ x) ≈₂ (app g ⟨$⟩ y) ; isEquivalence = record { refl = λ {f} -> FunEq.cong (app f) ; sym = λ r rₓ → ≈₂-sym (r (≈₁-sym rₓ)) ; trans = λ r₁ r₂ rₓ → ≈₂-trans (r₁ ≈₁-refl) (r₂ rₓ) } } open LinearDefinitions A B _≈₂_ record LinearMap : Set (suc (k ⊔ a₁ ⊔ a₂ ⊔ ℓ₁ ⊔ ℓ₂)) where field ⟦_⟧ : Morphism isLinearMap : IsLinearMap From To ⟦_⟧ infixr 25 _⟪$⟫_ _⟪$⟫_ : A -> B _⟪$⟫_ = ⟦_⟧ open IsLinearMap isLinearMap public linearMap-setoid : Setoid (suc (k ⊔ a₁ ⊔ a₂ ⊔ ℓ₁ ⊔ ℓ₂)) (a₁ ⊔ ℓ₁ ⊔ ℓ₂) linearMap-setoid = hom-setoid {LinearMap} λ f → record { _⟨$⟩_ = λ x → f LinearMap.⟪$⟫ x ; cong = LinearMap.⟦⟧-cong f } record LinearIsomorphism : Set (suc (k ⊔ a₁ ⊔ a₂ ⊔ ℓ₁ ⊔ ℓ₂)) where field ⟦_⟧ : Morphism isLinearIsomorphism : IsLinearIsomorphism From To ⟦_⟧ open IsLinearIsomorphism isLinearIsomorphism public linearMap : LinearMap linearMap = record { ⟦_⟧ = ⟦_⟧ ; isLinearMap = isLinearMap } open LinearMap linearMap public using (_⟪$⟫_) linearIsomorphism-setoid : Setoid (suc (k ⊔ a₁ ⊔ a₂ ⊔ ℓ₁ ⊔ ℓ₂)) (a₁ ⊔ ℓ₁ ⊔ ℓ₂) linearIsomorphism-setoid = hom-setoid {LinearIsomorphism} λ f → record { _⟨$⟩_ = λ x -> f LinearIsomorphism.⟪$⟫ x ; cong = LinearIsomorphism.⟦⟧-cong f } module _ {a ℓ} (V : VS.VectorSpace K a ℓ) where LinearEndomorphism : Set (suc (k ⊔ a ⊔ ℓ)) LinearEndomorphism = LinearMap V V LinearAutomorphism : Set (suc (k ⊔ a ⊔ ℓ)) LinearAutomorphism = LinearIsomorphism V V
{ "alphanum_fraction": 0.5543296556, "avg_line_length": 27.1909090909, "ext": "agda", "hexsha": "067630df9447bfd41a9358cb807979fd2c942d68", "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": "d87c5a1eb5dd0569238272e67bce1899616b789a", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "felko/linear-algebra", "max_forks_repo_path": "src/Algebra/Linear/Morphism/Bundles.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "d87c5a1eb5dd0569238272e67bce1899616b789a", "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": "felko/linear-algebra", "max_issues_repo_path": "src/Algebra/Linear/Morphism/Bundles.agda", "max_line_length": 86, "max_stars_count": 15, "max_stars_repo_head_hexsha": "d87c5a1eb5dd0569238272e67bce1899616b789a", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "felko/linear-algebra", "max_stars_repo_path": "src/Algebra/Linear/Morphism/Bundles.agda", "max_stars_repo_stars_event_max_datetime": "2020-12-30T06:18:08.000Z", "max_stars_repo_stars_event_min_datetime": "2019-11-02T14:11:00.000Z", "num_tokens": 1151, "size": 2991 }
open import Agda.Builtin.Unit open import Agda.Builtin.List open import Agda.Builtin.Nat open import Agda.Builtin.Equality open import Agda.Builtin.Reflection open import Agda.Builtin.Sigma macro @0 trivial : Term → TC ⊤ trivial = unify (con (quote refl) []) test : 42 ≡ 42 test = trivial @0 m : Name → TC ⊤ m F = defineFun F (clause (( "A" , arg (arg-info visible (modality relevant quantity-0)) (agda-sort (lit 0))) ∷ []) (arg (arg-info visible (modality relevant quantity-0)) (var 0) ∷ []) (var 0 []) ∷ []) F : Set → Set unquoteDef F = m F
{ "alphanum_fraction": 0.6227045075, "avg_line_length": 20.6551724138, "ext": "agda", "hexsha": "9f5918de2475b5495f2a90d5601417037eaa2ec3", "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": "b5b3b1657556f720a7310cb7744edb1fac71eaf4", "max_forks_repo_licenses": [ "BSD-2-Clause" ], "max_forks_repo_name": "Seanpm2001-Agda-lang/agda", "max_forks_repo_path": "test/Succeed/ErasedMacro.agda", "max_issues_count": 6, "max_issues_repo_head_hexsha": "b5b3b1657556f720a7310cb7744edb1fac71eaf4", "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": "Seanpm2001-Agda-lang/agda", "max_issues_repo_path": "test/Succeed/ErasedMacro.agda", "max_line_length": 69, "max_stars_count": 1, "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/ErasedMacro.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-05T00:25:14.000Z", "max_stars_repo_stars_event_min_datetime": "2022-03-05T00:25:14.000Z", "num_tokens": 194, "size": 599 }
open import Level using () renaming (_⊔_ to _⊔ˡ_) open import Data.Product using (_,_; proj₁) open import Data.Sum using (_⊎_; inj₁; inj₂) open import Relation.Nullary using (yes; no; ¬_) open import Relation.Nullary.Negation using (contradiction) open import Relation.Binary using (Reflexive; Symmetric; Transitive; Setoid; Tri) open Tri open import Relation.Binary.PropositionalEquality using (_≡_; _≢_) renaming (refl to ≡-refl; sym to ≡-sym) open import Algebra.Bundles using (RawRing) open import AKS.Algebra.Bundles using (DecField) module AKS.Polynomial.Base {c ℓ} (F : DecField c ℓ) where open import Data.Unit using (⊤; tt) open import Agda.Builtin.FromNat using (Number) open import AKS.Nat using (ℕ; _∸_; _≤_; _<_; lte; pred) renaming (_+_ to _+ℕ_; _⊔_ to _⊔ℕ_) open ℕ open import AKS.Nat using (≢⇒¬≟; <-cmp; ≤-totalOrder; m<n⇒n∸m≢0) open import AKS.Nat using (ℕ⁺; ⟅_⇓⟆; ⟅_⇑⟆) open import AKS.Nat.WellFounded using (Acc; acc; <-well-founded) open DecField F using (0#; 1#; _+_; _*_; -_; _-_; _⁻¹; _/_; C/0) renaming (Carrier to C) open DecField F using (_≈_; _≈?_; setoid) open Setoid setoid using (refl; sym; trans) open DecField F using (*-commutativeMonoid; 1#-nonzero; -1#-nonzero; _*-nonzero_; _/-nonzero_) open import AKS.Exponentiation *-commutativeMonoid using (_^_; _^⁺_) data Spine : Set (c ⊔ˡ ℓ) where K : C/0 → Spine _+x^_∙_ : C/0 → ℕ⁺ → Spine → Spine data Polynomial : Set (c ⊔ˡ ℓ) where 0ᵖ : Polynomial x^_∙_ : ℕ → Spine → Polynomial ⟦_⟧ˢ : Spine → C → C ⟦ K c ⟧ˢ x = proj₁ c ⟦ c +x^ n ∙ p ⟧ˢ x = proj₁ c + x ^⁺ n * ⟦ p ⟧ˢ x ⟦_⟧ : Polynomial → C → C ⟦ 0ᵖ ⟧ x = 0# ⟦ x^ n ∙ p ⟧ x = x ^ n * ⟦ p ⟧ˢ x 1ᵖ : Polynomial 1ᵖ = x^ 0 ∙ K 1#-nonzero _+?_ : ∀ (k₁ k₂ : C/0) → (proj₁ k₁ + proj₁ k₂ ≈ 0#) ⊎ C/0 k₁ +? k₂ with proj₁ k₁ + proj₁ k₂ ≈? 0# ... | yes k₁+k₂≈0 = inj₁ k₁+k₂≈0 ... | no k₁+k₂≉0 = inj₂ (proj₁ k₁ + proj₁ k₂ , k₁+k₂≉0) +ᵖ-spine-≡-K : ℕ → C/0 → Spine → Polynomial +ᵖ-spine-≡-K n c₁ (K c₂) with c₁ +? c₂ ... | inj₁ _ = 0ᵖ ... | inj₂ c₁+c₂ = x^ n ∙ K c₁+c₂ +ᵖ-spine-≡-K n c₁ (c₂ +x^ i₂ ∙ q) with c₁ +? c₂ ... | inj₁ _ = x^ (n +ℕ ⟅ i₂ ⇓⟆) ∙ q ... | inj₂ c₁+c₂ = x^ n ∙ (c₁+c₂ +x^ i₂ ∙ q) +ᵖ-spine-≡ : ℕ → Spine → Spine → Polynomial +ᵖ-spine-< : (n : ℕ) → Spine → (m : ℕ) → Spine → n < m → Polynomial +ᵖ-spine : ℕ → Spine → ℕ → Spine → Polynomial +ᵖ-spine-≡ n (K c₁) q = +ᵖ-spine-≡-K n c₁ q +ᵖ-spine-≡ n (c₁ +x^ i₁ ∙ p) (K c₂) = +ᵖ-spine-≡-K n c₂ (c₁ +x^ i₁ ∙ p) +ᵖ-spine-≡ n (c₁ +x^ i₁ ∙ p) (c₂ +x^ i₂ ∙ q) with c₁ +? c₂ ... | inj₁ _ = +ᵖ-spine (n +ℕ ⟅ i₁ ⇓⟆) p (n +ℕ ⟅ i₂ ⇓⟆) q ... | inj₂ c₁+c₂ with +ᵖ-spine ⟅ i₁ ⇓⟆ p ⟅ i₂ ⇓⟆ q ... | 0ᵖ = x^ n ∙ K c₁+c₂ ... | x^ zero ∙ r = +ᵖ-spine-≡-K n c₁+c₂ r ... | x^ suc n₃ ∙ r = x^ n ∙ (c₁+c₂ +x^ ⟅ suc n₃ ⇑⟆ ∙ r) +ᵖ-spine-< n₁ (K c₁) n₂ q n₁<n₂ = x^ n₁ ∙ (c₁ +x^ ⟅ n₂ ∸ n₁ ⇑⟆ {≢⇒¬≟ (m<n⇒n∸m≢0 n₁<n₂)} ∙ q) +ᵖ-spine-< n₁ (c₁ +x^ i₁ ∙ p) n₂ q n₁<n₂ with +ᵖ-spine ⟅ i₁ ⇓⟆ p (n₂ ∸ n₁) q ... | 0ᵖ = x^ n₁ ∙ K c₁ ... | x^ zero ∙ r = +ᵖ-spine-≡-K n₁ c₁ r ... | x^ suc n₃ ∙ r = x^ n₁ ∙ (c₁ +x^ ⟅ suc n₃ ⇑⟆ ∙ r) +ᵖ-spine n₁ p n₂ q with <-cmp n₁ n₂ ... | tri< n₁<n₂ _ _ = +ᵖ-spine-< n₁ p n₂ q n₁<n₂ ... | tri≈ _ n₁≡n₂ _ = +ᵖ-spine-≡ n₁ p q ... | tri> _ _ n₁>n₂ = +ᵖ-spine-< n₂ q n₁ p n₁>n₂ infixl 6 _+ᵖ_ _+ᵖ_ : Polynomial → Polynomial → Polynomial 0ᵖ +ᵖ q = q (x^ n₁ ∙ p) +ᵖ 0ᵖ = x^ n₁ ∙ p (x^ n₁ ∙ p) +ᵖ (x^ n₂ ∙ q) = +ᵖ-spine n₁ p n₂ q _∙𝑋^_ : C/0 → ℕ → Polynomial c ∙𝑋^ n = x^ n ∙ K c 𝑋^_ : ℕ → Polynomial 𝑋^ n = 1#-nonzero ∙𝑋^ n 𝑋 : Polynomial 𝑋 = 𝑋^ 1 𝐾 : C → Polynomial 𝐾 c with c ≈? 0# ... | yes _ = 0ᵖ ... | no c≉0 = (c , c≉0) ∙𝑋^ 0 ∙ᵖ-spine : C/0 → Spine → Spine ∙ᵖ-spine c₁ (K c₂) = K (c₁ *-nonzero c₂) ∙ᵖ-spine c₁ (c₂ +x^ n ∙ p) = (c₁ *-nonzero c₂) +x^ n ∙ (∙ᵖ-spine c₁ p) infixl 7 _∙ᵖ_ _∙ᵖ_ : C/0 → Polynomial → Polynomial c ∙ᵖ 0ᵖ = 0ᵖ c ∙ᵖ (x^ n ∙ p) = x^ n ∙ (∙ᵖ-spine c p) *ᵖ-spine : ℕ → Spine → ℕ → Spine → Polynomial *ᵖ-spine o₁ (K c₁) o₂ q = x^ (o₁ +ℕ o₂) ∙ (∙ᵖ-spine c₁ q) *ᵖ-spine o₁ (c₁ +x^ n₁ ∙ p) o₂ (K c₂) = x^ (o₁ +ℕ o₂) ∙ (∙ᵖ-spine c₂ (c₁ +x^ n₁ ∙ p)) *ᵖ-spine o₁ (c₁ +x^ n₁ ∙ p) o₂ (c₂ +x^ n₂ ∙ q) = x^ (o₁ +ℕ o₂) ∙ K (c₁ *-nonzero c₂) +ᵖ c₁ ∙ᵖ x^ (o₁ +ℕ o₂ +ℕ ⟅ n₂ ⇓⟆) ∙ q +ᵖ c₂ ∙ᵖ (x^ (o₁ +ℕ o₂ +ℕ ⟅ n₁ ⇓⟆) ∙ p) +ᵖ *ᵖ-spine (o₁ +ℕ ⟅ n₁ ⇓⟆) p (o₂ +ℕ ⟅ n₂ ⇓⟆) q -- (c₁ + x ^ n₁ * p[x]) * (c₂ + x ^ n₂ * q[x]) = (c₁ * c₂) + (c₁ * x ^ n₂ * q[x]) + (x ^ n₁ * p[x] * c₂) + (x ^ n₁ * p[x] * x ^ n₂ * q[x]) infixl 7 _*ᵖ_ _*ᵖ_ : Polynomial → Polynomial → Polynomial 0ᵖ *ᵖ q = 0ᵖ (x^ n₁ ∙ p) *ᵖ 0ᵖ = 0ᵖ (x^ n₁ ∙ p) *ᵖ (x^ n₂ ∙ q) = *ᵖ-spine n₁ p n₂ q infix 6 -ᵖ_ -ᵖ_ : Polynomial → Polynomial -ᵖ p = -1#-nonzero ∙ᵖ p infixl 6 _-ᵖ_ _-ᵖ_ : Polynomial → Polynomial → Polynomial p -ᵖ q = p +ᵖ (-ᵖ q) data Polynomialⁱ : Set c where 0ⁱ : Polynomialⁱ _+x∙_ : C → Polynomialⁱ → Polynomialⁱ 1ⁱ : Polynomialⁱ 1ⁱ = 1# +x∙ 0ⁱ infixl 6 _+ⁱ_ _+ⁱ_ : Polynomialⁱ → Polynomialⁱ → Polynomialⁱ 0ⁱ +ⁱ q = q (c₁ +x∙ p) +ⁱ 0ⁱ = c₁ +x∙ p (c₁ +x∙ p) +ⁱ (c₂ +x∙ q) = (c₁ + c₂) +x∙ (p +ⁱ q) infixl 7 _∙ⁱ_ _∙ⁱ_ : C → Polynomialⁱ → Polynomialⁱ a ∙ⁱ 0ⁱ = 0ⁱ a ∙ⁱ (c +x∙ p) = (a * c) +x∙ (a ∙ⁱ p) infix 8 x∙_ x∙_ : Polynomialⁱ → Polynomialⁱ x∙ p = 0# +x∙ p infixl 7 _*ⁱ_ _*ⁱ_ : Polynomialⁱ → Polynomialⁱ → Polynomialⁱ 0ⁱ *ⁱ q = 0ⁱ (c₁ +x∙ p) *ⁱ 0ⁱ = 0ⁱ (c₁ +x∙ p) *ⁱ (c₂ +x∙ q) = (c₁ * c₂) +x∙ (c₁ ∙ⁱ q +ⁱ c₂ ∙ⁱ p +ⁱ x∙ (p *ⁱ q)) -ⁱ_ : Polynomialⁱ → Polynomialⁱ -ⁱ p = (- 1#) ∙ⁱ p infixl 6 _-ⁱ_ _-ⁱ_ : Polynomialⁱ → Polynomialⁱ → Polynomialⁱ p -ⁱ q = p +ⁱ (-ⁱ q) expandˢ : ℕ → Spine → Polynomialⁱ expandˢ zero (K c) = proj₁ c +x∙ 0ⁱ expandˢ zero (c +x^ n ∙ s) = proj₁ c +x∙ expandˢ (pred ⟅ n ⇓⟆) s expandˢ (suc n) s = 0# +x∙ expandˢ n s expand : Polynomial → Polynomialⁱ expand 0ᵖ = 0ⁱ expand (x^ n ∙ p) = expandˢ n p constant : C → Polynomial constant c with c ≈? 0# ... | yes _ = 0ᵖ ... | no c≉0 = (c , c≉0) ∙𝑋^ 0 simplify : Polynomialⁱ → Polynomial simplify 0ⁱ = 0ᵖ simplify (c₁ +x∙ p) with c₁ ≈? 0# | simplify p ... | yes _ | 0ᵖ = 0ᵖ ... | yes _ | x^ n ∙ q = x^ suc n ∙ q ... | no c₁≉0 | 0ᵖ = x^ 0 ∙ (K (c₁ , c₁≉0)) ... | no c₁≉0 | x^ n ∙ q = x^ 0 ∙ ((c₁ , c₁≉0) +x^ ⟅ suc n ⇑⟆ ∙ q) data _≈ˢ_ : Spine → Spine → Set (c ⊔ˡ ℓ) where K≈ : ∀ {c₁ c₂} → proj₁ c₁ ≈ proj₁ c₂ → K c₁ ≈ˢ K c₂ +≈ : ∀ {c₁ c₂} {n₁ n₂} {p q} → proj₁ c₁ ≈ proj₁ c₂ → n₁ ≡ n₂ → p ≈ˢ q → (c₁ +x^ n₁ ∙ p) ≈ˢ (c₂ +x^ n₂ ∙ q) infix 4 _≈ᵖ_ data _≈ᵖ_ : Polynomial → Polynomial → Set (c ⊔ˡ ℓ) where 0ᵖ≈ : 0ᵖ ≈ᵖ 0ᵖ 0ᵖ≉ : ∀ {o₁ o₂} {p q} → o₁ ≡ o₂ → p ≈ˢ q → x^ o₁ ∙ p ≈ᵖ x^ o₂ ∙ q infix 4 _≉ᵖ_ _≉ᵖ_ : Polynomial → Polynomial → Set (c ⊔ˡ ℓ) p ≉ᵖ q = ¬ (p ≈ᵖ q) ≈ᵖ-refl : Reflexive _≈ᵖ_ ≈ᵖ-refl {0ᵖ} = 0ᵖ≈ ≈ᵖ-refl {x^ n ∙ p} = 0ᵖ≉ ≡-refl ≈ˢ-refl where ≈ˢ-refl : Reflexive _≈ˢ_ ≈ˢ-refl {K c} = K≈ refl ≈ˢ-refl {c +x^ n ∙ p} = +≈ refl ≡-refl ≈ˢ-refl ≈ᵖ-sym : Symmetric _≈ᵖ_ ≈ᵖ-sym {0ᵖ} {0ᵖ} 0ᵖ≈ = 0ᵖ≈ ≈ᵖ-sym {x^ n ∙ p} {x^ n ∙ q} (0ᵖ≉ ≡-refl p≈ˢq) = 0ᵖ≉ ≡-refl (≈ˢ-sym p≈ˢq) where ≈ˢ-sym : Symmetric _≈ˢ_ ≈ˢ-sym {K c₁} {K c₂} (K≈ c₁≈c₂) = K≈ (sym c₁≈c₂) ≈ˢ-sym {c₁ +x^ n ∙ p} {c₂ +x^ n ∙ q} (+≈ c₁≈c₂ ≡-refl p≈ˢq) = +≈ (sym c₁≈c₂) ≡-refl (≈ˢ-sym p≈ˢq) ≈ᵖ-trans : Transitive _≈ᵖ_ ≈ᵖ-trans {0ᵖ} {0ᵖ} {0ᵖ} 0ᵖ≈ 0ᵖ≈ = 0ᵖ≈ ≈ᵖ-trans {_} {_} {_} (0ᵖ≉ ≡-refl p≈ˢq) (0ᵖ≉ ≡-refl q≈ˢr) = 0ᵖ≉ ≡-refl (≈ˢ-trans p≈ˢq q≈ˢr) where ≈ˢ-trans : Transitive _≈ˢ_ ≈ˢ-trans (K≈ c₁≈c₂) (K≈ c₂≈c₃) = K≈ (trans c₁≈c₂ c₂≈c₃) ≈ˢ-trans (+≈ c₁≈c₂ ≡-refl p≈ˢq) (+≈ c₂≈c₃ ≡-refl q≈ˢr) = +≈ (trans c₁≈c₂ c₂≈c₃) ≡-refl (≈ˢ-trans p≈ˢq q≈ˢr) infix 4 _≈ⁱ_ data _≈ⁱ_ : Polynomialⁱ → Polynomialⁱ → Set (c ⊔ˡ ℓ) where 0≈0 : 0ⁱ ≈ⁱ 0ⁱ 0≈+ : ∀ {c} {p} → c ≈ 0# → 0ⁱ ≈ⁱ p → 0ⁱ ≈ⁱ c +x∙ p +≈0 : ∀ {c} {p} → c ≈ 0# → 0ⁱ ≈ⁱ p → c +x∙ p ≈ⁱ 0ⁱ +≈+ : ∀ {c₁ c₂} {p q} → c₁ ≈ c₂ → p ≈ⁱ q → c₁ +x∙ p ≈ⁱ c₂ +x∙ q infix 4 _≉ⁱ_ _≉ⁱ_ : Polynomialⁱ → Polynomialⁱ → Set (c ⊔ˡ ℓ) p ≉ⁱ q = ¬ (p ≈ⁱ q) ≈ⁱ-refl : Reflexive _≈ⁱ_ ≈ⁱ-refl {0ⁱ} = 0≈0 ≈ⁱ-refl {c +x∙ p} = +≈+ refl ≈ⁱ-refl ≈ⁱ-sym : Symmetric _≈ⁱ_ ≈ⁱ-sym 0≈0 = 0≈0 ≈ⁱ-sym (0≈+ c≈0 0≈p) = +≈0 c≈0 0≈p ≈ⁱ-sym (+≈0 c≈0 0≈p) = 0≈+ c≈0 0≈p ≈ⁱ-sym (+≈+ c₁≈c₂ p≈q) = +≈+ (sym c₁≈c₂) (≈ⁱ-sym p≈q) ≈ⁱ-trans : Transitive _≈ⁱ_ ≈ⁱ-trans 0≈0 q = q ≈ⁱ-trans (0≈+ c₁≈0 0≈p) (+≈0 c₂≈0 0≈q) = 0≈0 ≈ⁱ-trans (0≈+ c₁≈0 0≈p) (+≈+ c₁≈c₂ p≈q) = 0≈+ (trans (sym c₁≈c₂) c₁≈0) (≈ⁱ-trans 0≈p p≈q) ≈ⁱ-trans (+≈0 c₁≈0 0≈p) 0≈0 = +≈0 c₁≈0 0≈p ≈ⁱ-trans (+≈0 c₁≈0 0≈p) (0≈+ c₂≈0 0≈q) = +≈+ (trans c₁≈0 (sym c₂≈0)) (≈ⁱ-trans (≈ⁱ-sym 0≈p) 0≈q) ≈ⁱ-trans (+≈+ c₁≈c₂ p≈q) (+≈0 c₂≈0 0≈q) = +≈0 (trans c₁≈c₂ c₂≈0) (≈ⁱ-trans 0≈q (≈ⁱ-sym p≈q)) ≈ⁱ-trans (+≈+ c₁≈c₂ p≈q) (+≈+ c₂≈c₃ q≈r) = +≈+ (trans c₁≈c₂ c₂≈c₃) (≈ⁱ-trans p≈q q≈r) +ᵖ-*ᵖ-rawRing : RawRing (c ⊔ˡ ℓ) (c ⊔ˡ ℓ) +ᵖ-*ᵖ-rawRing = record { Carrier = Polynomial ; _≈_ = _≈ᵖ_ ; _+_ = _+ᵖ_ ; _*_ = _*ᵖ_ ; -_ = -ᵖ_ ; 0# = 0ᵖ ; 1# = 1ᵖ } +ⁱ-*ⁱ-rawRing : RawRing c (c ⊔ˡ ℓ) +ⁱ-*ⁱ-rawRing = record { Carrier = Polynomialⁱ ; _≈_ = _≈ⁱ_ ; _+_ = _+ⁱ_ ; _*_ = _*ⁱ_ ; -_ = -ⁱ_ ; 0# = 0ⁱ ; 1# = 1ⁱ } open import AKS.Extended ≤-totalOrder using (module ≤ᵉ-Reasoning) renaming ( Extended to Degree ; _≤ᵉ_ to _≤ᵈ_ ; ≤ᵉ-refl to ≤ᵈ-refl ; ≤ᵉ-trans to ≤ᵈ-trans ) public open Degree public open _≤ᵈ_ public module ≤ᵈ-Reasoning where open ≤ᵉ-Reasoning renaming (_∼⟨_⟩_ to _≤ᵈ⟨_⟩_; _∎ to _∎ᵈ; _≡⟨_⟩_ to _≡ᵈ⟨_⟩_) public instance Degree-number : Number Degree Degree-number = record { Constraint = λ _ → ⊤ ; fromNat = λ n → ⟨ n ⟩ } infixl 5 _⊔ᵈ_ _⊔ᵈ_ : Degree → Degree → Degree -∞ ⊔ᵈ d₂ = d₂ ⟨ d₁ ⟩ ⊔ᵈ -∞ = ⟨ d₁ ⟩ ⟨ d₁ ⟩ ⊔ᵈ ⟨ d₂ ⟩ = ⟨ d₁ ⊔ℕ d₂ ⟩ infixl 5 _+ᵈ_ _+ᵈ_ : Degree → Degree → Degree -∞ +ᵈ d₂ = -∞ ⟨ d₁ ⟩ +ᵈ -∞ = -∞ ⟨ d₁ ⟩ +ᵈ ⟨ d₂ ⟩ = ⟨ d₁ +ℕ d₂ ⟩ degreeˢ : Spine → ℕ degreeˢ (K c) = 0 degreeˢ (c +x^ n ∙ p) = ⟅ n ⇓⟆ +ℕ degreeˢ p degree : Polynomial → Degree degree 0ᵖ = -∞ degree (x^ n ∙ p) = ⟨ n +ℕ degreeˢ p ⟩ deg : ∀ p {p≉0 : p ≉ᵖ 0ᵖ} → ℕ deg 0ᵖ {p≉0} = contradiction ≈ᵖ-refl p≉0 deg (x^ n ∙ p) {p≉0} = n +ℕ degreeˢ p degreeⁱ : Polynomialⁱ → Degree degreeⁱ 0ⁱ = -∞ degreeⁱ (c +x∙ p) with degreeⁱ p ... | ⟨ n ⟩ = ⟨ suc n ⟩ ... | -∞ with c ≈? 0# ... | yes _ = -∞ ... | no _ = 0 open import Data.String using (String; _++_) open import Data.Nat.Show using () renaming (show to show-ℕ) show-Polynomial : (C → String) → Polynomial → String show-Polynomial show-c 0ᵖ = "0" show-Polynomial show-c (x^ n ∙ p) = loop n p where loop : ℕ → Spine → String loop zero (K c) = show-c (proj₁ c) loop zero (c +x^ n ∙ p) = show-c (proj₁ c) ++ " + " ++ loop ⟅ n ⇓⟆ p loop (suc n) (K c) = show-c (proj₁ c) ++ " * X^" ++ show-ℕ (suc n) loop (suc n) (c +x^ m ∙ p) = show-c (proj₁ c) ++ " * X^" ++ show-ℕ (suc n) ++ " + " ++ loop (suc n +ℕ ⟅ m ⇓⟆) p
{ "alphanum_fraction": 0.5269032627, "avg_line_length": 29.5267605634, "ext": "agda", "hexsha": "5283e54464aaa79d0fd12821d9cc1636ba986eca", "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": "ddad4c0d5f384a0219b2177461a68dae06952dde", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "mckeankylej/thesis", "max_forks_repo_path": "proofs/AKS/Polynomial/Base.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "ddad4c0d5f384a0219b2177461a68dae06952dde", "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": "mckeankylej/thesis", "max_issues_repo_path": "proofs/AKS/Polynomial/Base.agda", "max_line_length": 138, "max_stars_count": 1, "max_stars_repo_head_hexsha": "ddad4c0d5f384a0219b2177461a68dae06952dde", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "mckeankylej/thesis", "max_stars_repo_path": "proofs/AKS/Polynomial/Base.agda", "max_stars_repo_stars_event_max_datetime": "2020-12-01T22:38:27.000Z", "max_stars_repo_stars_event_min_datetime": "2020-12-01T22:38:27.000Z", "num_tokens": 6473, "size": 10482 }
{-# OPTIONS --erased-cubical #-} module SMain where open import Data.List using (map) open import Data.Nat using (_*_) open import Data.Unit using (⊤) open import Midi using (IO; exportTracks; track→htrack) open import Soundness using (soundTracks) open import Motif using (multiplier) main : IO ⊤ main = let ticksPerBeat = 4 * multiplier -- (1 = quarter notes; 4 = 16th notes) file = "/Users/leo/Music/MusicTools/test.mid" song = soundTracks in exportTracks file ticksPerBeat (map track→htrack song)
{ "alphanum_fraction": 0.6824817518, "avg_line_length": 27.4, "ext": "agda", "hexsha": "50e6cfcbbd00e73547194f0263511d43bff5a1d4", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2020-11-10T04:05:31.000Z", "max_forks_repo_forks_event_min_datetime": "2020-11-10T04:05:31.000Z", "max_forks_repo_head_hexsha": "5d9a1bbfbe52f55acf33d960763dce0872689c2b", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "halfaya/Music", "max_forks_repo_path": "Soundness/agda/SMain.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "5d9a1bbfbe52f55acf33d960763dce0872689c2b", "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": "halfaya/Music", "max_issues_repo_path": "Soundness/agda/SMain.agda", "max_line_length": 74, "max_stars_count": 1, "max_stars_repo_head_hexsha": "5d9a1bbfbe52f55acf33d960763dce0872689c2b", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "halfaya/Music", "max_stars_repo_path": "Soundness/agda/SMain.agda", "max_stars_repo_stars_event_max_datetime": "2020-11-10T04:05:28.000Z", "max_stars_repo_stars_event_min_datetime": "2020-11-10T04:05:28.000Z", "num_tokens": 149, "size": 548 }
------------------------------------------------------------------------ -- INCREMENTAL λ-CALCULUS -- -- Connecting Parametric.Change.Term and Parametric.Change.Value. ------------------------------------------------------------------------ import Parametric.Syntax.Type as Type import Parametric.Syntax.Term as Term import Parametric.Denotation.Value as Value import Parametric.Denotation.Evaluation as Evaluation import Parametric.Change.Type as ChangeType import Parametric.Change.Term as ChangeTerm import Parametric.Change.Value as ChangeValue module Parametric.Change.Evaluation {Base : Type.Structure} {Const : Term.Structure Base} (⟦_⟧Base : Value.Structure Base) (⟦_⟧Const : Evaluation.Structure Const ⟦_⟧Base) (ΔBase : ChangeType.Structure Base) (apply-base : ChangeTerm.ApplyStructure Const ΔBase) (diff-base : ChangeTerm.DiffStructure Const ΔBase) (nil-base : ChangeTerm.NilStructure Const ΔBase) (⟦apply-base⟧ : ChangeValue.ApplyStructure Const ⟦_⟧Base ΔBase) (⟦diff-base⟧ : ChangeValue.DiffStructure Const ⟦_⟧Base ΔBase) (⟦nil-base⟧ : ChangeValue.NilStructure Const ⟦_⟧Base ΔBase) where open Type.Structure Base open Term.Structure Base Const open Value.Structure Base ⟦_⟧Base open Evaluation.Structure Const ⟦_⟧Base ⟦_⟧Const open ChangeType.Structure Base ΔBase open ChangeTerm.Structure Const ΔBase apply-base diff-base nil-base open ChangeValue.Structure Const ⟦_⟧Base ΔBase ⟦apply-base⟧ ⟦diff-base⟧ ⟦nil-base⟧ open import Relation.Binary.PropositionalEquality open import Base.Denotation.Notation open import Postulate.Extensionality -- Extension point 1: Relating ⊕ and its value on base types ApplyStructure : Set ApplyStructure = ∀ ι {Γ} → {t : Term Γ (base ι)} {Δt : Term Γ (ΔType (base ι))} {ρ : ⟦ Γ ⟧} → ⟦ t ⟧ ρ ⟦⊕₍ base ι ₎⟧ ⟦ Δt ⟧ ρ ≡ ⟦ t ⊕₍ base ι ₎ Δt ⟧ ρ -- Extension point 2: Relating ⊝ and its value on base types DiffStructure : Set DiffStructure = ∀ ι {Γ} → {s : Term Γ (base ι)} {t : Term Γ (base ι)} {ρ : ⟦ Γ ⟧} → ⟦ s ⟧ ρ ⟦⊝₍ base ι ₎⟧ ⟦ t ⟧ ρ ≡ ⟦ s ⊝₍ base ι ₎ t ⟧ ρ -- Extension point 3: Relating nil-term and its value on base types NilStructure : Set NilStructure = ∀ ι {Γ} → {t : Term Γ (base ι)} {ρ : ⟦ Γ ⟧} → ⟦nil₍ base ι ₎⟧ (⟦ t ⟧ ρ) ≡ ⟦ onil₍ base ι ₎ t ⟧ ρ module Structure (meaning-⊕-base : ApplyStructure) (meaning-⊝-base : DiffStructure) (meaning-onil-base : NilStructure) where -- unique names with unambiguous types -- to help type inference figure things out private module Disambiguation where infixr 9 _⋆_ _⋆_ : Type → Context → Context _⋆_ = _•_ -- We provide: Relating ⊕ and ⊝ and their values on arbitrary types. meaning-⊕ : ∀ {τ Γ} {t : Term Γ τ} {Δt : Term Γ (ΔType τ)} {ρ : ⟦ Γ ⟧} → ⟦ t ⟧ ρ ⟦⊕₍ τ ₎⟧ ⟦ Δt ⟧ ρ ≡ ⟦ t ⊕₍ τ ₎ Δt ⟧ ρ meaning-⊝ : ∀ {τ Γ} {s : Term Γ τ} {t : Term Γ τ} {ρ : ⟦ Γ ⟧} → ⟦ s ⟧ ρ ⟦⊝₍ τ ₎⟧ ⟦ t ⟧ ρ ≡ ⟦ s ⊝₍ τ ₎ t ⟧ ρ meaning-onil : ∀ {τ Γ} {t : Term Γ τ} {ρ : ⟦ Γ ⟧} → ⟦nil₍ τ ₎⟧ (⟦ t ⟧ ρ) ≡ ⟦ onil₍ τ ₎ t ⟧ ρ meaning-⊕ {base ι} {Γ} {τ} {Δt} {ρ} = meaning-⊕-base ι {Γ} {τ} {Δt} {ρ} meaning-⊕ {σ ⇒ τ} {Γ} {t} {Δt} {ρ} = ext (λ v → let Γ′ = σ ⋆ (σ ⇒ τ) ⋆ ΔType (σ ⇒ τ) ⋆ Γ ρ′ : ⟦ Γ′ ⟧ ρ′ = v • (⟦ t ⟧ ρ) • (⟦ Δt ⟧ ρ) • ρ x : Term Γ′ σ x = var this f : Term Γ′ (σ ⇒ τ) f = var (that this) Δf : Term Γ′ (ΔType (σ ⇒ τ)) Δf = var (that (that this)) y = app f x Δy = app (app Δf x) (onil x) in begin ⟦ t ⟧ ρ v ⟦⊕₍ τ ₎⟧ ⟦ Δt ⟧ ρ v (⟦nil₍ σ ₎⟧ v) ≡⟨ cong (λ hole → ⟦ t ⟧ ρ v ⟦⊕₍ τ ₎⟧ ⟦ Δt ⟧ ρ v hole) (meaning-onil {t = x} {ρ′}) ⟩ ⟦ t ⟧ ρ v ⟦⊕₍ τ ₎⟧ ⟦ Δt ⟧ ρ v (⟦ onil x ⟧ ρ′) ≡⟨ meaning-⊕ {t = y} {Δt = Δy} {ρ′} ⟩ ⟦ y ⊕₍ τ ₎ Δy ⟧ ρ′ ∎) where open ≡-Reasoning open Disambiguation meaning-⊝ {base ι} {Γ} {s} {t} {ρ} = meaning-⊝-base ι {Γ} {s} {t} {ρ} meaning-⊝ {σ ⇒ τ} {Γ} {s} {t} {ρ} = ext (λ v → ext (λ Δv → let Γ′ = ΔType σ ⋆ σ ⋆ (σ ⇒ τ) ⋆ (σ ⇒ τ) ⋆ Γ ρ′ : ⟦ Γ′ ⟧Context ρ′ = Δv • v • ⟦ t ⟧Term ρ • ⟦ s ⟧Term ρ • ρ Δx : Term Γ′ (ΔType σ) Δx = var this x : Term Γ′ σ x = var (that this) f : Term Γ′ (σ ⇒ τ) f = var (that (that this)) g : Term Γ′ (σ ⇒ τ) g = var (that (that (that this))) y = app f x y′ = app g (x ⊕₍ σ ₎ Δx) in begin ⟦ s ⟧ ρ (v ⟦⊕₍ σ ₎⟧ Δv) ⟦⊝₍ τ ₎⟧ ⟦ t ⟧ ρ v ≡⟨ cong (λ hole → ⟦ s ⟧ ρ hole ⟦⊝₍ τ ₎⟧ ⟦ t ⟧ ρ v) (meaning-⊕ {t = x} {Δt = Δx} {ρ′}) ⟩ ⟦ s ⟧ ρ (⟦ x ⊕₍ σ ₎ Δx ⟧ ρ′) ⟦⊝₍ τ ₎⟧ ⟦ t ⟧ ρ v ≡⟨ meaning-⊝ {s = y′} {y} {ρ′} ⟩ ⟦ y′ ⊝ y ⟧ ρ′ ∎)) where open ≡-Reasoning open Disambiguation meaning-onil {base ι} {Γ} {t} {ρ} = meaning-onil-base ι {Γ} {t} {ρ} meaning-onil {σ ⇒ τ} {Γ} {t} {ρ} = meaning-⊝ {σ ⇒ τ} {Γ} {t} {t} {ρ} -- Ideally, this proof should simply be: -- meaning-⊝ {σ ⇒ τ} {Γ} {t} {t} {ρ} -- -- However, the types of the results don't match because using onil constructs -- different environments.
{ "alphanum_fraction": 0.526553008, "avg_line_length": 34.02, "ext": "agda", "hexsha": "7ce7098398db217176e93b7fcf98f7b9068cbe60", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2016-02-18T12:26:44.000Z", "max_forks_repo_forks_event_min_datetime": "2016-02-18T12:26:44.000Z", "max_forks_repo_head_hexsha": "39bb081c6f192bdb87bd58b4a89291686d2d7d03", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "inc-lc/ilc-agda", "max_forks_repo_path": "Parametric/Change/Evaluation.agda", "max_issues_count": 6, "max_issues_repo_head_hexsha": "39bb081c6f192bdb87bd58b4a89291686d2d7d03", "max_issues_repo_issues_event_max_datetime": "2017-05-04T13:53:59.000Z", "max_issues_repo_issues_event_min_datetime": "2015-07-01T18:09:31.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "inc-lc/ilc-agda", "max_issues_repo_path": "Parametric/Change/Evaluation.agda", "max_line_length": 82, "max_stars_count": 10, "max_stars_repo_head_hexsha": "39bb081c6f192bdb87bd58b4a89291686d2d7d03", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "inc-lc/ilc-agda", "max_stars_repo_path": "Parametric/Change/Evaluation.agda", "max_stars_repo_stars_event_max_datetime": "2019-07-19T07:06:59.000Z", "max_stars_repo_stars_event_min_datetime": "2015-03-04T06:09:20.000Z", "num_tokens": 2232, "size": 5103 }
module TelescopingLet1 where f : (let ★ = Set) (A : ★) → A → A f A x = x data X : ★ where -- should fail, since ★ is not in global scope
{ "alphanum_fraction": 0.5971223022, "avg_line_length": 17.375, "ext": "agda", "hexsha": "899418079a13b18401c3997dacc62e9e2a065077", "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/TelescopingLet1.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/TelescopingLet1.agda", "max_line_length": 46, "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/TelescopingLet1.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": 50, "size": 139 }
-- Andreas, 2017-09-03, issue #2729. -- Expect non-indexed or -primed variables when splitting. -- {-# OPTIONS -v interaction.case:100 #-} -- {-# OPTIONS -v tc.cover:40 #-} data Size : Set where ↑ : Size → Size data Nat : Size → Set where zero : ∀ i → Nat (↑ i) suc : ∀ i → Nat i → Nat (↑ i) pred : ∀ i → Nat i → Nat i pred i x = {!x!} -- C-c C-c -- WRONG (agda-2.5.3): -- pred .(↑ i₁) (zero i₁) = ? -- pred .(↑ i₁) (suc i₁ x) = ? -- EXPECTED (correct in agda-2.5.1.1): -- pred .(↑ i) (zero i) = ? -- pred .(↑ i) (suc i x) = ?
{ "alphanum_fraction": 0.5212569316, "avg_line_length": 22.5416666667, "ext": "agda", "hexsha": "34d91d239f5cb6e1a752a915086835dca2f2e58c", "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/Issue2729.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/Issue2729.agda", "max_line_length": 58, "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/Issue2729.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": 213, "size": 541 }
-- Andreas, 2017-07-29, issue #2644 reported by Christian Sattler -- -- Silly mistake in expandRecordVar: -- Substitution applied to ListTel instead of Telescope. -- (Messed up the de Bruijn indices, garbage.) -- This file should pass with lots of yellow. {-# OPTIONS --allow-unsolved-metas #-} -- {-# OPTIONS -v tc.meta.assign.proj:45 #-} -- OLD: -- {-# OPTIONS -v tc.cc:20 #-} -- {-# OPTIONS -v tc.lhs:10 #-} -- {-# OPTIONS -v tc.decl:10 #-} -- {-# OPTIONS -v tc.ip:20 #-} -- {-# OPTIONS -v tc.check.internal:20 #-} -- {-# OPTIONS -v tc.meta.check:30 #-} -- {-# OPTIONS -v tc:20 #-} -- {-# OPTIONS -v tc.meta:50 #-} -- {-# OPTIONS -v tc:45 #-} -- {-# OPTIONS -v tc.term.exlam:100 -v tc:90 #-} record Σ (A¹ : Set) (B¹ : A¹ → Set) : Set where constructor pair field fst : A¹ snd : B¹ fst open Σ postulate Path : (A² : Set) → A² → A² → Set path : (A³ : Set) → Path _ _ _ record S : Set₁ where constructor mkS field Aₛ : Set Bₛ : (aₛ¹ : Aₛ) → Set zₛ : (aₛ² : Aₛ) → Bₛ aₛ² record T : Set₁ where constructor mkT field A : Set B : (a¹ : A) → Set z : (a² : A) → B a² s : (a³ : A) → B a³ → B a³ p : (a⁴ : A) (f : B a⁴) → Path _ f (s _ (z _)) -- passes without the matching f₀ : S → T f₀ X = record { A = Σ _ _ ; B = λ b → Σ _ _ -- λ { (b₁ , b₂) → Σ _ _ } ; z = λ z₁ → pair (S.zₛ X _) _ ; s = λ s₁ s₂ → _ ; p = λ p₁ p₂ → path _ } -- This was my final variant module Final where mutual TA : S → Set TA Z = Σ _ _ aux : (Y : S) → TA Y → Set aux Y (pair b¹ b²) = Σ _ _ -- fails fₐ : S → T fₐ X = record { A = TA X ; B = aux X ; z = λ (z¹ : TA X) → pair (S.zₛ X _) _ ; s = λ (s¹ : TA X) (s² : aux X s¹) → _ ; p = λ (p¹ : TA X) (p² : aux X p¹) → path _ } -- Intermediate fₐᵤ : S → T fₐᵤ X = record { A = TA ; B = aux ; z = λ (z₁ : TA) → pair (S.zₛ X _) _ ; s = λ (s₁ : TA) (s₂ : aux s₁) → _ ; p = λ (p₁ : TA) (p₂ : aux p₁) → path _ } where TA = Σ _ _ aux : TA → Set -- (passes without the matching) -- aux b = let b₁ = fst b; b₂ = snd b in {! Σ _ _ !} -- worked aux (pair b₁ b₂) = Σ _ _ -- failed -- Close to original f : S → T f X = record { A = Σ _ _ ; B = λ { (pair b₁ b₂) → Σ _ _ } ; z = λ z₁ → pair (S.zₛ X _) _ ; s = λ s₁ s₂ → _ ; p = λ p₁ p₂ → path _ } {- Hunted down the crash cause: context before projection expansion (X : S) (p¹ : TA X) (p² : aux X p¹) meta args: [X, p¹, pair (S.zₛ X (_aₛ²_34 X p¹)) (?1 X p¹)] trying to expand projected variable X eta-expanding var X in terms ([X, p¹, pair (S.zₛ X (_aₛ²_34 X p¹)) (?1 X p¹)],_8 (?2 X p¹ p²)) meta args: [mkS Aₛ(X) Bₛ(X) zₛ(X), p¹, pair (zₛ(X) (_aₛ²_34 (mkS Aₛ(X) Bₛ(X) zₛ(X)) p¹)) (?1 (mkS Aₛ(X) Bₛ(X) zₛ(X)) p¹)] context before projection expansion (X : S) S (p¹ : TA X) TA 0 (p² : aux X p¹) aux 1 0 context after projection expansion (Aₛ(X) : Set) (Bₛ(X) : Aₛ(X) → Set) (zₛ(X) : (aₛ² : Aₛ(X)) → Bₛ(X) aₛ²) (p¹ : TA (mkS Aₛ(X) Bₛ(X) zₛ(X))) -- This type is fine (p² : aux Aₛ(X) (mkS Bₛ(X) zₛ(X) p¹)) -- This type is messed up! -} -- -} -- -} -- -} -- -} -- -}
{ "alphanum_fraction": 0.469005848, "avg_line_length": 25.3333333333, "ext": "agda", "hexsha": "3080b7912925d0a54685396f7e5c32eac3e603b9", "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/Issue2644.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/Issue2644.agda", "max_line_length": 90, "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/Issue2644.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": 1376, "size": 3420 }
-- Kapitel 1, Abschnitt D (Die Eigenschaften der Gleichheit) module CombinatoryLogic.Equality where open import Algebra.Definitions using (Congruent₂; LeftCongruent; RightCongruent) open import Data.Vec using (Vec; []; _∷_; foldr₁; lookup) open import Function using (_$_) open import Relation.Binary using (IsEquivalence; Setoid) open import Relation.Binary.PropositionalEquality using (_≡_; refl) open import CombinatoryLogic.Semantics open import CombinatoryLogic.Syntax private -- A lemma used in the proofs of Propositions 1 and 2. lemma-CQXX : ∀ {X} → ⊢ C ∙ Q ∙ X ∙ X lemma-CQXX {X} = let s₁ = ⊢ Π ∙ (W ∙ (C ∙ Q)) [ ax Q ] s₂ = ⊢ W ∙ (C ∙ Q) ∙ X [ Π s₁ ] s₃ = ⊢ Q ∙ (W ∙ (C ∙ Q) ∙ X) ∙ (C ∙ Q ∙ X ∙ X) [ W ] s₄ = ⊢ C ∙ Q ∙ X ∙ X [ Q₁ s₂ s₃ ] in s₄ -- Satz 1 prop₁ : ∀ {X} → ⊢ Q ∙ X ∙ X prop₁ {X} = s₆ where s₄ = ⊢ C ∙ Q ∙ X ∙ X [ lemma-CQXX ] s₅ = ⊢ Q ∙ (C ∙ Q ∙ X ∙ X) ∙ (Q ∙ X ∙ X) [ C ] s₆ = ⊢ Q ∙ X ∙ X [ Q₁ s₄ s₅ ] -- Satz 2 prop₂ : ∀ {X Y} → ⊢ Q ∙ X ∙ Y → ⊢ Q ∙ Y ∙ X prop₂ {X} {Y} ⊢QXY = s₅ where s₁ = ⊢ Q ∙ X ∙ Y [ ⊢QXY ] -- NOTE: Curry's proof contains a mistake: CQXX should be CQXY. s₂ = ⊢ Q ∙ (C ∙ Q ∙ X ∙ X) ∙ (C ∙ Q ∙ X ∙ Y) [ Q₂ {Z = C ∙ Q ∙ X} s₁ ] s₃ = ⊢ C ∙ Q ∙ X ∙ X [ lemma-CQXX ] -- NOTE: Curry's proof uses rule Q, but there is no such rule. s₄ = ⊢ C ∙ Q ∙ X ∙ Y [ Q₁ s₃ s₂ ] s₅ = ⊢ Q ∙ Y ∙ X [ Q₁ s₄ C ] -- Satz 3 prop₃ : ∀ {X Y Z} → ⊢ Q ∙ X ∙ Y → ⊢ Q ∙ Y ∙ Z → ⊢ Q ∙ X ∙ Z prop₃ {X} {Y} {Z} ⊢QXY ⊢QYZ = s₃ where s₁ = ⊢ Q ∙ Y ∙ Z [ ⊢QYZ ] s₂ = ⊢ Q ∙ (Q ∙ X ∙ Y) ∙ (Q ∙ X ∙ Z) [ Q₂ {Z = Q ∙ X} s₁ ] s₃ = ⊢ Q ∙ X ∙ Z [ Q₁ ⊢QXY s₂ ] -- Satz 4 prop₄ : ∀ {X Y Z} → ⊢ Q ∙ X ∙ Y → ⊢ Q ∙ (X ∙ Z) ∙ (Y ∙ Z) prop₄ {X} {Y} {Z} Hp = s₅ where p₁ = λ {X} → ⊢ Q ∙ (C ∙ (B ∙ (W ∙ K)) ∙ Z ∙ X) ∙ (B ∙ (W ∙ K) ∙ X ∙ Z) [ C ] p₂ = λ {X} → ⊢ Q ∙ (B ∙ (W ∙ K) ∙ X ∙ Z) ∙ (W ∙ K ∙ (X ∙ Z)) [ B ] p₃ = λ {X} → ⊢ Q ∙ (W ∙ K ∙ (X ∙ Z)) ∙ (K ∙ (X ∙ Z) ∙ (X ∙ Z)) [ W ] p₄ = λ {X} → ⊢ Q ∙ (K ∙ (X ∙ Z) ∙ (X ∙ Z)) ∙ (X ∙ Z) [ K ] p₅ = λ {X} → ⊢ Q ∙ (C ∙ (B ∙ (W ∙ K)) ∙ Z ∙ X) ∙ (X ∙ Z) [ prop₃ p₁ $ prop₃ p₂ $ prop₃ p₃ p₄ ] s₁ = ⊢ Q ∙ (C ∙ (B ∙ (W ∙ K)) ∙ Z ∙ X) ∙ (C ∙ (B ∙ (W ∙ K)) ∙ Z ∙ Y) [ Q₂ Hp ] s₂ = ⊢ Q ∙ (C ∙ (B ∙ (W ∙ K)) ∙ Z ∙ X) ∙ (X ∙ Z) [ p₅ ] s₃ = ⊢ Q ∙ (C ∙ (B ∙ (W ∙ K)) ∙ Z ∙ Y) ∙ (Y ∙ Z) [ p₅ ] s₄ = ⊢ Q ∙ (X ∙ Z) ∙ (C ∙ (B ∙ (W ∙ K)) ∙ Z ∙ X) [ prop₂ s₂ ] s₅ = ⊢ Q ∙ (X ∙ Z) ∙ (Y ∙ Z) [ prop₃ s₄ $ prop₃ s₁ s₃ ] -- Satz 5 prop₅ : ∀ {X Y} → X ≡ Y → ⊢ Q ∙ X ∙ Y prop₅ {X} {Y} refl = prop₁ -- Satz 6 (first part) isEquivalence : IsEquivalence _≈_ isEquivalence = record { refl = prop₁ ; sym = prop₂ ; trans = prop₃ } setoid : Setoid _ _ setoid = record { Carrier = Combinator ; _≈_ = _≈_ ; isEquivalence = isEquivalence } module Reasoning where module ≈ = IsEquivalence isEquivalence import Relation.Binary.Reasoning.Base.Single _≈_ ≈.refl ≈.trans as Base open Base using (begin_; _∎) public infixr 2 _≈⟨⟩_ step-≈ step-≈˘ _≈⟨⟩_ : ∀ x {y} → x Base.IsRelatedTo y → x Base.IsRelatedTo y _ ≈⟨⟩ x≈y = x≈y step-≈ = Base.step-∼ syntax step-≈ x y≈z x≈y = x ≈⟨ x≈y ⟩ y≈z step-≈˘ : ∀ x {y z} → y Base.IsRelatedTo z → y ≈ x → x Base.IsRelatedTo z step-≈˘ x y∼z y≈x = x ≈⟨ ≈.sym y≈x ⟩ y∼z syntax step-≈˘ x y≈z y≈x = x ≈˘⟨ y≈x ⟩ y≈z -- Satz 6 (second part) cong : Congruent₂ _≈_ _∙_ cong {X} {X′} {Y} {Y′} ⊢X==X′ ⊢Y==Y′ = s₃ where s₁ = ⊢ X ∙ Y == X ∙ Y′ [ Q₂ ⊢Y==Y′ ] s₂ = ⊢ X ∙ Y′ == X′ ∙ Y′ [ prop₄ ⊢X==X′ ] s₃ = ⊢ X ∙ Y == X′ ∙ Y′ [ prop₃ s₁ s₂ ] -- congˡ and congʳ follow from cong, but are also just different names for -- Q₂ and prop₄, respectively. congˡ : LeftCongruent _≈_ _∙_ congˡ = Q₂ congʳ : RightCongruent _≈_ _∙_ congʳ = prop₄ -- TODO: Satz 7, 8 prop₉ : ∀ {X} → ⊢ I ∙ X == X prop₉ {X} = begin I ∙ X ≈⟨⟩ W ∙ K ∙ X ≈⟨ W ⟩ K ∙ X ∙ X ≈⟨ K ⟩ X ∎ where open Reasoning -- Note after the proof of Satz 9. S : Combinator S = B ∙ (B ∙ W) ∙ (B ∙ B ∙ C) prop-S : ∀ {X} {Y} {Z} → ⊢ S ∙ X ∙ Y ∙ Z == X ∙ Z ∙ (Y ∙ Z) prop-S {X} {Y} {Z} = begin S ∙ X ∙ Y ∙ Z ≈⟨⟩ B ∙ (B ∙ W) ∙ (B ∙ B ∙ C) ∙ X ∙ Y ∙ Z ≈⟨ congʳ $ congʳ B ⟩ B ∙ W ∙ (B ∙ B ∙ C ∙ X) ∙ Y ∙ Z ≈⟨ congʳ B ⟩ W ∙ (B ∙ B ∙ C ∙ X ∙ Y) ∙ Z ≈⟨ W ⟩ B ∙ B ∙ C ∙ X ∙ Y ∙ Z ∙ Z ≈⟨ congʳ $ congʳ $ congʳ B ⟩ B ∙ (C ∙ X) ∙ Y ∙ Z ∙ Z ≈⟨ congʳ B ⟩ C ∙ X ∙ (Y ∙ Z) ∙ Z ≈⟨ C ⟩ X ∙ Z ∙ (Y ∙ Z) ∎ where open Reasoning -- TODO: ⊢ B == S(KS)K, ⊢ C == S(BBS)(KK), ⊢ W == SS(SK), ⊢ I == SKK
{ "alphanum_fraction": 0.4116116116, "avg_line_length": 35.6785714286, "ext": "agda", "hexsha": "03a1c76dd9d39e1b86e9fc0b9ae05703171ba669", "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": "df8bf877e60b3059532c54a247a36a3d83cd55b0", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "splintah/combinatory-logic", "max_forks_repo_path": "CombinatoryLogic/Equality.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "df8bf877e60b3059532c54a247a36a3d83cd55b0", "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": "splintah/combinatory-logic", "max_issues_repo_path": "CombinatoryLogic/Equality.agda", "max_line_length": 111, "max_stars_count": 1, "max_stars_repo_head_hexsha": "df8bf877e60b3059532c54a247a36a3d83cd55b0", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "splintah/combinatory-logic", "max_stars_repo_path": "CombinatoryLogic/Equality.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-28T23:44:42.000Z", "max_stars_repo_stars_event_min_datetime": "2022-02-28T23:44:42.000Z", "num_tokens": 2508, "size": 4995 }
{-# OPTIONS --guardedness #-} module Cubical.README where ------------------------------------------------------------------------ -- An experimental library for Cubical Agda ----------------------------------------------------------------------- -- The library comes with a .agda-lib file, for use with the library -- management system. ------------------------------------------------------------------------ -- Module hierarchy ------------------------------------------------------------------------ -- The core library for Cubical Agda. -- It contains basic primitives, equivalences, glue types. import Cubical.Core.Everything -- The foundations for Cubical Agda. -- The Prelude module is self-explanatory. import Cubical.Foundations.Prelude import Cubical.Foundations.Everything -- Kinds and properties of functions import Cubical.Functions.Everything -- Data types and properties import Cubical.Data.Everything -- Higher-inductive types import Cubical.HITs.Everything -- Coinductive data types and properties import Cubical.Codata.Everything -- Papers import Cubical.Papers.Everything -- Properties and proofs about relations import Cubical.Relation.Everything -- Category theory import Cubical.Categories.Everything -- Homotopy theory import Cubical.Homotopy.Everything -- Properties and kinds of Modalities import Cubical.Modalities.Everything -- Various experiments using Cubical Agda import Cubical.Experiments.Everything -- Other modules (TODO: add descriptions) import Cubical.Induction.Everything import Cubical.Structures.Everything -- general definition of cohomology import Cubical.Cohomology.Everything -- cohomology with constant Integer coefficients import Cubical.ZCohomology.Everything -- Algebra library (in development) import Cubical.Algebra.Everything -- Various talks import Cubical.Talks.Everything -- Reflection import Cubical.Reflection.Everything -- Displayed univalent graphs import Cubical.Displayed.Everything -- Syntax typeclasses import Cubical.Syntax.Everything
{ "alphanum_fraction": 0.6930301532, "avg_line_length": 25.6075949367, "ext": "agda", "hexsha": "1317f3eccb36f8324e73acc3e7cf64bd78d57a1a", "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": "1b9c97a2140fe96fe636f4c66beedfd7b8096e8f", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "howsiyu/cubical", "max_forks_repo_path": "Cubical/README.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "1b9c97a2140fe96fe636f4c66beedfd7b8096e8f", "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": "howsiyu/cubical", "max_issues_repo_path": "Cubical/README.agda", "max_line_length": 72, "max_stars_count": null, "max_stars_repo_head_hexsha": "1b9c97a2140fe96fe636f4c66beedfd7b8096e8f", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "howsiyu/cubical", "max_stars_repo_path": "Cubical/README.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 421, "size": 2023 }
-- Andreas, 2017-04-26, issue #2554 -- Allow mutual sized types in successor style. -- {-# OPTIONS -v tc.pos.args:100 #-} -- {-# OPTIONS -v tc.pos:100 #-} -- {-# OPTIONS -v tc.polarity:20 #-} open import Agda.Builtin.Size mutual data C : Size → Set where c : ∀{i} → D i → C (↑ i) data D : Size → Set where d : ∀{i} → C i → D (↑ i) -- Test subtyping test : ∀{i} {j : Size< i} → C j → C i test x = x -- Define a size-preserving function mutual f : ∀{i} → C i → C i f (c y) = c (g y) g : ∀{i} → D i → D i g (d x) = d (f x)
{ "alphanum_fraction": 0.5208711434, "avg_line_length": 17.21875, "ext": "agda", "hexsha": "163861fe4c4dc2c76fe65151d6843b18c3088a66", "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/Issue2554-size-mutual.agda", "max_issues_count": 3, "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "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": "shlevy/agda", "max_issues_repo_path": "test/Succeed/Issue2554-size-mutual.agda", "max_line_length": 47, "max_stars_count": 2, "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/Issue2554-size-mutual.agda", "max_stars_repo_stars_event_max_datetime": "2020-09-20T00:28:57.000Z", "max_stars_repo_stars_event_min_datetime": "2019-10-29T09:40:30.000Z", "num_tokens": 214, "size": 551 }
open import OutsideIn.Prelude open import OutsideIn.X module OutsideIn.TopLevel(x : X) where import OutsideIn.Expressions as E open E(x) open X(x) data Program (ev : Set)(tv : Set) : Set where end : Program ev tv bind₁_,_ : ∀ {s} → Expression ev tv s → Program (Ⓢ ev) tv → Program ev tv bind₂_·_∷_⇒_,_ : ∀ {s} → (n : ℕ) → Expression ev (tv ⨁ n) s → QConstraint (tv ⨁ n) → Type (tv ⨁ n) → Program (Ⓢ ev) tv → Program ev tv
{ "alphanum_fraction": 0.5723140496, "avg_line_length": 34.5714285714, "ext": "agda", "hexsha": "0eb14ac353548178662986188b4124fbfa3bd01e", "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": "fc1fc1bba2af95806d9075296f9ed1074afa4c24", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "liamoc/outside-in", "max_forks_repo_path": "OutsideIn/TopLevel.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "fc1fc1bba2af95806d9075296f9ed1074afa4c24", "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": "liamoc/outside-in", "max_issues_repo_path": "OutsideIn/TopLevel.agda", "max_line_length": 77, "max_stars_count": 2, "max_stars_repo_head_hexsha": "fc1fc1bba2af95806d9075296f9ed1074afa4c24", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "liamoc/outside-in", "max_stars_repo_path": "OutsideIn/TopLevel.agda", "max_stars_repo_stars_event_max_datetime": "2020-11-19T14:30:07.000Z", "max_stars_repo_stars_event_min_datetime": "2015-09-14T05:22:15.000Z", "num_tokens": 167, "size": 484 }
module Fail.NonCopatternInstance where record HasId (a : Set) : Set where field id : a → a open HasId ⦃ ... ⦄ {-# COMPILE AGDA2HS HasId class #-} data Unit : Set where MkUnit : Unit {-# COMPILE AGDA2HS Unit #-} instance UnitHasId : HasId Unit UnitHasId = record { id = λ x → x } -- NOT CORRECT -- UnitHasId .id x = x -- CORRECT {-# COMPILE AGDA2HS UnitHasId #-}
{ "alphanum_fraction": 0.6120906801, "avg_line_length": 18.0454545455, "ext": "agda", "hexsha": "d5f31ff4cff874455cbdf9be906f9b26a32194eb", "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": "8c8f24a079ed9677dbe6893cf786e7ed52dfe8b6", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "dxts/agda2hs", "max_forks_repo_path": "test/Fail/NonCopatternInstance.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "8c8f24a079ed9677dbe6893cf786e7ed52dfe8b6", "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": "dxts/agda2hs", "max_issues_repo_path": "test/Fail/NonCopatternInstance.agda", "max_line_length": 54, "max_stars_count": 1, "max_stars_repo_head_hexsha": "8c8f24a079ed9677dbe6893cf786e7ed52dfe8b6", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "dxts/agda2hs", "max_stars_repo_path": "test/Fail/NonCopatternInstance.agda", "max_stars_repo_stars_event_max_datetime": "2021-05-25T09:41:34.000Z", "max_stars_repo_stars_event_min_datetime": "2021-05-25T09:41:34.000Z", "num_tokens": 129, "size": 397 }
-- Andreas, 2020-02-15, issue #4447 -- -- Positivity checker needs to see the constructor types -- in the same way as the type checker has seen them. -- -- Thus, we need to reduce types of constructors even -- with definitions that have not yet been subjected to termination -- checking, e.g. because they live in a mutual block with the data type. -- {-# OPTIONS -v term:10 #-} -- {-# OPTIONS -v tc.pos:10 #-} -- {-# OPTIONS -v tc.data:10 #-} data ⊥ : Set where -- Mutual block: data D : Set D' = (D → ⊥) → D data D where abs : D' -- Positivity checker needs to unfold D', otherwise it does not see -- the correct occurrences of D. -- From here, the road to absurdity is paved: app : D → D → ⊥ app (abs f) = f delta : D → ⊥ delta x = app x x Omega : ⊥ Omega = delta (abs delta)
{ "alphanum_fraction": 0.6506329114, "avg_line_length": 21.9444444444, "ext": "agda", "hexsha": "f87f3e66bdf66a64c98dc5d8861eef1cc961154b", "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": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "shlevy/agda", "max_forks_repo_path": "test/Fail/Issue4447False.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/Issue4447False.agda", "max_line_length": 73, "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/Issue4447False.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": 230, "size": 790 }
module Acme.Data.Fin where open import Acme.Type open import Acme.Data.Nat as ℕ using (ℕ) Fin : Elt ℕ → Type Fin = ℕ.induction (λ _ → Type) base (λ _ → step) where base : Type base _ = false step : Type → Type step ih [] = false step ih (c ∷ cs) = c == 'Z' && isNil cs || c == 'S' && ih cs zero : ∀ {n} → Elt (Fin (ℕ.suc n)) zero {n} = Fin (ℕ.suc n) ∋ "Z" suc : ∀ {n} → Elt (Fin n) → Elt (Fin (ℕ.suc n)) suc [ k ] = [ 'S' ∷ k ] sub : ∀ n str → str ∈ Fin n → str ∈ ℕ sub = ℕ.induction (λ n → ∀ str → str ∈ Fin n → str ∈ ℕ) (λ _ ()) step where step : ∀ n → (∀ str → str ∈ Fin n → str ∈ ℕ) → (∀ str → str ∈ Fin (ℕ.suc n) → str ∈ ℕ) step n ih (c ∷ cs) isFin = checkZ (c ≟ 'Z') cs {{isFin}} where checkS : ∀ {b} → Reflects c 'S' b → ∀ cs → {{IsTrue (b && Fin n cs)}} → (c ∷ cs) ∈ ℕ checkS true cs {{isFin}} = ih cs isFin checkZ : ∀ {b} → Reflects c 'Z' b → ∀ cs → {{IsTrue (b && isNil cs || c == 'S' && Fin n cs)}} → (c ∷ cs) ∈ ℕ checkZ true [] = _ checkZ false cs = checkS (c ≟ 'S') cs cast : ∀ {n} → Elt (Fin n) → Elt ℕ cast {n} p .value = p .value cast {n} p .check = sub n (p .value) (p .check)
{ "alphanum_fraction": 0.4546178344, "avg_line_length": 24.6274509804, "ext": "agda", "hexsha": "76888b9b522af53da29308a74fb81d97909145cd", "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": "9e83fe708271b4437ae4e259175397d96d10aaf6", "max_forks_repo_licenses": [ "CC0-1.0" ], "max_forks_repo_name": "gallais/STRINaGda", "max_forks_repo_path": "src/Acme/Data/Fin.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "9e83fe708271b4437ae4e259175397d96d10aaf6", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "CC0-1.0" ], "max_issues_repo_name": "gallais/STRINaGda", "max_issues_repo_path": "src/Acme/Data/Fin.agda", "max_line_length": 65, "max_stars_count": 2, "max_stars_repo_head_hexsha": "9e83fe708271b4437ae4e259175397d96d10aaf6", "max_stars_repo_licenses": [ "CC0-1.0" ], "max_stars_repo_name": "gallais/STRINaGda", "max_stars_repo_path": "src/Acme/Data/Fin.agda", "max_stars_repo_stars_event_max_datetime": "2021-04-01T20:56:37.000Z", "max_stars_repo_stars_event_min_datetime": "2018-02-14T22:26:17.000Z", "num_tokens": 496, "size": 1256 }
{-# OPTIONS --without-K --safe #-} module Categories.Category.Instance.PointedSets where -- Category of Pointed Sets open import Level open import Relation.Binary open import Function using (_∘′_; _$_) renaming (id to idf) open import Relation.Binary.PropositionalEquality as ≡ using (_≡_; refl) open import Data.Product open import Categories.Category open import Categories.Category.Instance.Sets open import Categories.Functor using (Functor) PointedSets : ∀ o → Category (suc o) o o PointedSets o = record { Obj = Σ (Set o) idf ; _⇒_ = λ c d → Σ (proj₁ c → proj₁ d) (λ f → f (proj₂ c) ≡ proj₂ d) ; _≈_ = λ f g → ∀ x → proj₁ f x ≡ proj₁ g x ; id = idf , refl ; _∘_ = λ { (f , f-pres-pt) (g , g-pres-pt) → f ∘′ g , ≡.trans (≡.cong f g-pres-pt) f-pres-pt} ; assoc = λ _ → refl ; sym-assoc = λ _ → refl ; identityˡ = λ _ → refl ; identityʳ = λ _ → refl ; identity² = λ _ → refl ; equiv = record { refl = λ _ → refl ; sym = λ pf x → ≡.sym $ pf x ; trans = λ i≡j j≡k x → ≡.trans (i≡j x) (j≡k x) } ; ∘-resp-≈ = λ {_} {_} {_} {_} {h} {g} f≡h g≡i x → ≡.trans (f≡h (proj₁ g x)) (≡.cong (proj₁ h) $ g≡i x) } Underlying : {o : Level} → Functor (PointedSets o) (Sets o) Underlying = record { F₀ = proj₁ ; F₁ = proj₁ ; identity = refl ; homomorphism = refl ; F-resp-≈ = λ f≈g {x} → f≈g x }
{ "alphanum_fraction": 0.5722501797, "avg_line_length": 34.775, "ext": "agda", "hexsha": "bc66570a57ea866509b7163462373ece6732fd44", "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/PointedSets.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/PointedSets.agda", "max_line_length": 122, "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/PointedSets.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": 531, "size": 1391 }
{-# OPTIONS --without-K --rewriting --termination-depth=2 #-} open import HoTT open import cw.CW open import cw.examples.Sphere module cw.examples.Torus where ⊤-has-dec-eq : has-dec-eq ⊤ ⊤-has-dec-eq unit unit = inl idp ⊤-is-set : is-set ⊤ ⊤-is-set = dec-eq-is-set ⊤-has-dec-eq cw-torus-skel : Skeleton {lzero} (S (S 0)) CWTorus : Type₀ CWTorus = ⟦ cw-torus-skel ⟧ α₁ : Bool → S⁰ → ⊤ α₁ _ _ = unit X₁ = attached-skeleton (⊤ , ⊤-is-set) (Bool , Bool-is-set) α₁ α₂ : ⊤ → S¹ → (Attached α₁) α₂ unit = Pushout-rec ψ ψ (cst idp) where ψ : ⊤ → Attached α₁ ψ unit = PushoutGeneric.from-cc (inl unit) X₂ = attached-skeleton X₁ (⊤ , ⊤-is-set) α₂ cw-torus-skel = X₂
{ "alphanum_fraction": 0.6290322581, "avg_line_length": 18.4324324324, "ext": "agda", "hexsha": "8e6af8922636c53e740be4023a5bf03b3bbd1069", "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": "01bbd8841f9b9b25666b91e65b196d8f472b9978", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "maxdore/hott-morse", "max_forks_repo_path": "theorems/cw/examples/Torus.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "01bbd8841f9b9b25666b91e65b196d8f472b9978", "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": "maxdore/hott-morse", "max_issues_repo_path": "theorems/cw/examples/Torus.agda", "max_line_length": 61, "max_stars_count": null, "max_stars_repo_head_hexsha": "01bbd8841f9b9b25666b91e65b196d8f472b9978", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "maxdore/hott-morse", "max_stars_repo_path": "theorems/cw/examples/Torus.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 284, "size": 682 }
{-# OPTIONS --without-K #-} module equality.reasoning where open import equality.core module ≡-Reasoning {i} {X : Set i} where infix 4 _IsRelatedTo_ infix 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 : X) : Set i where relTo : x ≡ y → x IsRelatedTo y begin_ : ∀ {x y} → x IsRelatedTo y → x ≡ y begin relTo p = p _≡⟨_⟩_ : ∀ x {y z} → x ≡ y → y IsRelatedTo z → x IsRelatedTo z _ ≡⟨ p ⟩ relTo q = relTo (p · q) _∎ : ∀ x → x IsRelatedTo x _∎ _ = relTo refl
{ "alphanum_fraction": 0.6289308176, "avg_line_length": 24.4615384615, "ext": "agda", "hexsha": "2b9cf9cb14075781e0330ad98ce3f86c1e4bf0b9", "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": "equality/reasoning.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": "equality/reasoning.agda", "max_line_length": 67, "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": "equality/reasoning.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": 238, "size": 636 }
{-# OPTIONS --allow-unsolved-metas #-} {- The moral of the story is best told by comparing RegularVsConstructedMoreSimpler and RegularVsConstructed-EnhancedReg: * aliased type constructors can lose information about their dependencies, leading to some inconvenience when using a function which takes those dependencies implicitly * expressing those constructors as records (instead of as aliases) averts the above inconvenience * the loss of information happens when the resultant type is made from projections on the dependencies, where only a proper subset of all the possible projections are used TODO: what if instead of projections, we use a function? (try one that's abstract, and one that case splits on arguments) - see ProjectedMorality ... so far it looks like it doesn't matter --- not sure why TODO: what if the argument type (the one that's losing information) were data instead of record? - see DataMorality ... weirdness! -} module AgdaFeaturePitfallInstanceResolution where record Symmetry {B : Set₁} (_∼_ : B → B → Set) : Set₁ where field symmetry : ∀ {x y} → x ∼ y → y ∼ x Property : Set → Set₁ Property A = A → Set Extension : {A : Set} → Property A → Set Extension P = ∀ f → P f postulate PropertyEquivalence : ∀ {P : Set} → Property P → Property P → Set record Regular : Set where no-eta-equality infixr 5 _,_ record Σ (𝔒 : Set₁) (𝔓 : 𝔒 → Set) : Set₁ where constructor _,_ field π₀ : 𝔒 π₁ : 𝔓 π₀ open Σ public ExtensionProperty : ∀ (𝔒 : Set) → Set₁ ExtensionProperty 𝔒 = Σ (Property 𝔒) Extension _≈_ : {𝔒 : Set} → ExtensionProperty 𝔒 → ExtensionProperty 𝔒 → Set _≈_ P Q = PropertyEquivalence (π₀ P) (π₀ Q) record Instance : Set where no-eta-equality postulate instance _ : ∀ {𝔒 : Set} → Symmetry (_≈_ {𝔒 = 𝔒}) open Symmetry ⦃ … ⦄ module Test {𝔒 : Set} where test1-fails : {P Q : ExtensionProperty 𝔒} → P ≈ Q → Q ≈ P test1-fails P≈Q = symmetry P≈Q test2-works : {P Q : ExtensionProperty 𝔒} → P ≈ Q → Q ≈ P test2-works {P} {Q} P≈Q = symmetry {x = P} {y = Q} P≈Q test3-fails : {P Q : ExtensionProperty 𝔒} → P ≈ Q → Q ≈ P test3-fails {P} {Q} P≈Q = symmetry {x = _ , _} {y = _ , _} P≈Q test4-works : {P Q : ExtensionProperty 𝔒} → P ≈ Q → Q ≈ P test4-works {P} {Q} P≈Q = symmetry {x = _ , π₁ P} {y = _ , π₁ Q} P≈Q record Function : Set where no-eta-equality postulate symmetry : ∀ {𝔒} {x y : ExtensionProperty 𝔒} → x ≈ y → y ≈ x -- normalises to : {𝔒 : Set} {x y : Σ (𝔒 → Set) (λ P → (f : 𝔒) → P f)} → PropertyEquivalence (π₀ x) (π₀ y) → PropertyEquivalence (π₀ y) (π₀ x) module Test {𝔒 : Set} where test1-fails : {P Q : ExtensionProperty 𝔒} → P ≈ Q → Q ≈ P test1-fails P≈Q = symmetry P≈Q test2-works : {P Q : ExtensionProperty 𝔒} → P ≈ Q → Q ≈ P test2-works {P} {Q} P≈Q = symmetry {x = P} {y = Q} P≈Q test3-fails : {P Q : ExtensionProperty 𝔒} → P ≈ Q → Q ≈ P test3-fails {P} {Q} P≈Q = symmetry {x = _ , _} {y = _ , _} P≈Q test4-works : {P Q : ExtensionProperty 𝔒} → P ≈ Q → Q ≈ P test4-works {P} {Q} P≈Q = symmetry {x = _ , π₁ P} {y = _ , π₁ Q} P≈Q record Revamped : Set where no-eta-equality record ExtensionProperty (𝔒 : Set) : Set₁ where constructor _,_ field π₀ : Property 𝔒 π₁ : Extension π₀ open ExtensionProperty _≈_ : {𝔒 : Set} → ExtensionProperty 𝔒 → ExtensionProperty 𝔒 → Set _≈_ P Q = PropertyEquivalence (π₀ P) (π₀ Q) record Instance : Set where no-eta-equality postulate instance _ : ∀ {𝔒 : Set} → Symmetry (_≈_ {𝔒 = 𝔒}) open Symmetry ⦃ … ⦄ module Test {𝔒 : Set} where test1-fails : {P Q : ExtensionProperty 𝔒} → P ≈ Q → Q ≈ P test1-fails P≈Q = symmetry P≈Q test2-works : {P Q : ExtensionProperty 𝔒} → P ≈ Q → Q ≈ P test2-works {P} {Q} P≈Q = symmetry {x = P} {y = Q} P≈Q test3-fails : {P Q : ExtensionProperty 𝔒} → P ≈ Q → Q ≈ P test3-fails {P} {Q} P≈Q = symmetry {x = _ , _} {y = _ , _} P≈Q test4-works : {P Q : ExtensionProperty 𝔒} → P ≈ Q → Q ≈ P test4-works {P} {Q} P≈Q = symmetry {x = _ , π₁ P} {y = _ , π₁ Q} P≈Q record Function : Set where no-eta-equality postulate symmetry : ∀ {𝔒} {x y : ExtensionProperty 𝔒} → x ≈ y → y ≈ x -- normalises to : ∀ {𝔒} {x y : ExtensionProperty 𝔒} → PropertyEquivalence (π₀ x) (π₀ y) → PropertyEquivalence (π₀ y) (π₀ x) module Test {𝔒 : Set} where test1-fails : {P Q : ExtensionProperty 𝔒} → P ≈ Q → Q ≈ P test1-fails P≈Q = symmetry P≈Q test2-works : {P Q : ExtensionProperty 𝔒} → P ≈ Q → Q ≈ P test2-works {P} {Q} P≈Q = symmetry {x = P} {y = Q} P≈Q test3-fails : {P Q : ExtensionProperty 𝔒} → P ≈ Q → Q ≈ P test3-fails {P} {Q} P≈Q = symmetry {x = _ , _} {y = _ , _} P≈Q test4-works : {P Q : ExtensionProperty 𝔒} → P ≈ Q → Q ≈ P test4-works {P} {Q} P≈Q = symmetry {x = _ , π₁ P} {y = _ , π₁ Q} P≈Q record PostulatedExtensionProperty : Set where no-eta-equality postulate ExtensionProperty : Set → Set₁ π₀ : {𝔒 : Set} → ExtensionProperty 𝔒 → Property 𝔒 π₁ : {𝔒 : Set} → (P : ExtensionProperty 𝔒) → Extension (π₀ P) _,_ : {𝔒 : Set} → (π₀ : Property 𝔒) → Extension π₀ → ExtensionProperty 𝔒 _≈_ : {𝔒 : Set} → ExtensionProperty 𝔒 → ExtensionProperty 𝔒 → Set _≈_ P Q = PropertyEquivalence (π₀ P) (π₀ Q) record Instance : Set where no-eta-equality postulate instance _ : ∀ {𝔒 : Set} → Symmetry (_≈_ {𝔒 = 𝔒}) open Symmetry ⦃ … ⦄ module Test {𝔒 : Set} where test1-works : {P Q : ExtensionProperty 𝔒} → P ≈ Q → Q ≈ P test1-works P≈Q = symmetry P≈Q test2-works : {P Q : ExtensionProperty 𝔒} → P ≈ Q → Q ≈ P test2-works {P} {Q} P≈Q = symmetry {x = P} {y = Q} P≈Q test3-inexpressible : {P Q : ExtensionProperty 𝔒} → P ≈ Q → Q ≈ P test3-inexpressible {P} {Q} P≈Q = {!!} -- symmetry {x = _ , _} {y = _ , _} P≈Q test4-inexpressible : {P Q : ExtensionProperty 𝔒} → P ≈ Q → Q ≈ P test4-inexpressible {P} {Q} P≈Q = {!!} -- symmetry {x = _ , π₁ P} {y = _ , π₁ Q} P≈Q record Function : Set where no-eta-equality postulate symmetry : ∀ {𝔒} {x y : ExtensionProperty 𝔒} → x ≈ y → y ≈ x -- normalises to : ∀ {𝔒} {x y : ExtensionProperty 𝔒} → PropertyEquivalence (π₀ x) (π₀ y) → PropertyEquivalence (π₀ y) (π₀ x) module Test {𝔒 : Set} where test1-works : {P Q : ExtensionProperty 𝔒} → P ≈ Q → Q ≈ P test1-works P≈Q = symmetry P≈Q test2-works : {P Q : ExtensionProperty 𝔒} → P ≈ Q → Q ≈ P test2-works {P} {Q} P≈Q = symmetry {x = P} {y = Q} P≈Q test3-inexpressible : {P Q : ExtensionProperty 𝔒} → P ≈ Q → Q ≈ P test3-inexpressible {P} {Q} P≈Q = {!!} -- symmetry {x = _ , _} {y = _ , _} P≈Q test4-inexpressible : {P Q : ExtensionProperty 𝔒} → P ≈ Q → Q ≈ P test4-inexpressible {P} {Q} P≈Q = {!!} -- symmetry {x = _ , π₁ P} {y = _ , π₁ Q} P≈Q record Constructed : Set where no-eta-equality infixr 5 _,_ record Σ (𝔒 : Set₁) (𝔓 : 𝔒 → Set) : Set₁ where constructor _,_ field π₀ : 𝔒 π₁ : 𝔓 π₀ open Σ public ExtensionProperty : Set → Set₁ ExtensionProperty 𝔒 = Σ (Property 𝔒) Extension record _≈_ {𝔒 : Set} (P Q : ExtensionProperty 𝔒) : Set where constructor ∁ field π₀ : PropertyEquivalence (π₀ P) (π₀ Q) record Instance : Set where no-eta-equality postulate instance _ : {𝔒 : Set} → Symmetry (_≈_ {𝔒 = 𝔒}) open Symmetry ⦃ … ⦄ module Test {𝔒 : Set} where test1-works : {P Q : ExtensionProperty 𝔒} → P ≈ Q → Q ≈ P test1-works P≈Q = symmetry P≈Q test2-works : {P Q : ExtensionProperty 𝔒} → P ≈ Q → Q ≈ P test2-works {P} {Q} P≈Q = symmetry {x = P} {y = Q} P≈Q test3-works : {P Q : ExtensionProperty 𝔒} → P ≈ Q → Q ≈ P test3-works {P} {Q} P≈Q = symmetry {x = _ , _} {y = _ , _} P≈Q test4-works : {P Q : ExtensionProperty 𝔒} → P ≈ Q → Q ≈ P test4-works {P} {Q} P≈Q = symmetry {x = _ , π₁ P} {y = _ , π₁ Q} P≈Q record Function : Set where no-eta-equality postulate symmetry : ∀ {𝔒} {x y : ExtensionProperty 𝔒} → x ≈ y → y ≈ x -- normalises to : {𝔒 : Set} {x y : Σ (𝔒 → Set) (λ P → (f : 𝔒) → P f)} → x ≈ y → y ≈ x module Test {𝔒 : Set} where test1-works : {P Q : ExtensionProperty 𝔒} → P ≈ Q → Q ≈ P test1-works P≈Q = symmetry P≈Q test2-works : {P Q : ExtensionProperty 𝔒} → P ≈ Q → Q ≈ P test2-works {P} {Q} P≈Q = symmetry {x = P} {y = Q} P≈Q test3-works : {P Q : ExtensionProperty 𝔒} → P ≈ Q → Q ≈ P test3-works {P} {Q} P≈Q = symmetry {x = _ , _} {y = _ , _} P≈Q test4-works : {P Q : ExtensionProperty 𝔒} → P ≈ Q → Q ≈ P test4-works {P} {Q} P≈Q = symmetry {x = _ , π₁ P} {y = _ , π₁ Q} P≈Q record RegularVsConstructed : Set where no-eta-equality infixr 5 _,_ record Σ (𝔒 : Set₁) (𝔓 : 𝔒 → Set) : Set₁ where constructor _,_ field π₀ : 𝔒 π₁ : 𝔓 π₀ open Σ public ExtensionProperty : Set → Set₁ ExtensionProperty 𝔒 = Σ (Property 𝔒) Extension record _≈R_ {𝔒 : Set} (P Q : ExtensionProperty 𝔒) : Set where constructor ∁ field π₀ : PropertyEquivalence (π₀ P) (π₀ Q) _≈F_ : {𝔒 : Set} → ExtensionProperty 𝔒 → ExtensionProperty 𝔒 → Set _≈F_ P Q = PropertyEquivalence (π₀ P) (π₀ Q) record Instance : Set where no-eta-equality postulate instance _ : {𝔒 : Set} → Symmetry (_≈R_ {𝔒 = 𝔒}) postulate instance _ : {𝔒 : Set} → Symmetry (_≈F_ {𝔒 = 𝔒}) open Symmetry ⦃ … ⦄ module Test {𝔒 : Set} where test1-worksR : {P Q : ExtensionProperty 𝔒} → P ≈R Q → Q ≈R P test1-worksR P≈Q = symmetry P≈Q test2-worksR : {P Q : ExtensionProperty 𝔒} → P ≈R Q → Q ≈R P test2-worksR {P} {Q} P≈Q = symmetry {x = P} {y = Q} P≈Q test3-worksR : {P Q : ExtensionProperty 𝔒} → P ≈R Q → Q ≈R P test3-worksR {P} {Q} P≈Q = symmetry {x = _ , _} {y = _ , _} P≈Q test4-worksR : {P Q : ExtensionProperty 𝔒} → P ≈R Q → Q ≈R P test4-worksR {P} {Q} P≈Q = symmetry {x = _ , π₁ P} {y = _ , π₁ Q} P≈Q test1-failsF : {P Q : ExtensionProperty 𝔒} → P ≈F Q → Q ≈F P test1-failsF P≈Q = symmetry P≈Q test2-worksF : {P Q : ExtensionProperty 𝔒} → P ≈F Q → Q ≈F P test2-worksF {P} {Q} P≈Q = symmetry {x = P} {y = Q} P≈Q test3-failsF : {P Q : ExtensionProperty 𝔒} → P ≈F Q → Q ≈F P test3-failsF {P} {Q} P≈Q = symmetry {x = _ , _} {y = _ , _} P≈Q test4-worksF : {P Q : ExtensionProperty 𝔒} → P ≈F Q → Q ≈F P test4-worksF {P} {Q} P≈Q = symmetry {x = _ , π₁ P} {y = _ , π₁ Q} P≈Q record Function : Set where no-eta-equality postulate symmetryR : ∀ {𝔒} {x y : ExtensionProperty 𝔒} → x ≈R y → y ≈R x postulate symmetryF : ∀ {𝔒} {x y : ExtensionProperty 𝔒} → x ≈F y → y ≈F x module Test {𝔒 : Set} where test1-worksR : {P Q : ExtensionProperty 𝔒} → P ≈R Q → Q ≈R P test1-worksR P≈Q = symmetryR P≈Q test2-worksR : {P Q : ExtensionProperty 𝔒} → P ≈R Q → Q ≈R P test2-worksR {P} {Q} P≈Q = symmetryR {x = P} {y = Q} P≈Q test3-worksR : {P Q : ExtensionProperty 𝔒} → P ≈R Q → Q ≈R P test3-worksR {P} {Q} P≈Q = symmetryR {x = _ , _} {y = _ , _} P≈Q test4-worksR : {P Q : ExtensionProperty 𝔒} → P ≈R Q → Q ≈R P test4-worksR {P} {Q} P≈Q = symmetryR {x = _ , π₁ P} {y = _ , π₁ Q} P≈Q test1-failsF : {P Q : ExtensionProperty 𝔒} → P ≈F Q → Q ≈F P test1-failsF P≈Q = symmetryF P≈Q test2-worksF : {P Q : ExtensionProperty 𝔒} → P ≈F Q → Q ≈F P test2-worksF {P} {Q} P≈Q = symmetryF {x = P} {y = Q} P≈Q test3-failsF : {P Q : ExtensionProperty 𝔒} → P ≈F Q → Q ≈F P test3-failsF {P} {Q} P≈Q = symmetryF {x = _ , _} {y = _ , _} P≈Q test4-worksF : {P Q : ExtensionProperty 𝔒} → P ≈F Q → Q ≈F P test4-worksF {P} {Q} P≈Q = symmetryF {x = _ , π₁ P} {y = _ , π₁ Q} P≈Q record RegularVsConstructedSimpler : Set where no-eta-equality infixr 5 _,_ record Σ (𝔒 : Set₁) (𝔓 : 𝔒 → Set) : Set₁ where constructor _,_ field π₀ : 𝔒 π₁ : 𝔓 π₀ open Σ public postulate Prop : Set₁ postulate Ext : Prop → Set postulate PropEq : Prop → Set ExtProp : Set₁ ExtProp = Σ Prop Ext record ≈C_ (P : ExtProp) : Set where constructor ∁ field π₀ : PropEq (π₀ P) ≈R_ : ExtProp → Set ≈R_ P = PropEq (π₀ P) record Instance : Set where no-eta-equality record Class {B : Set₁} (∼_ : B → Set) : Set₁ where field foo : ∀ {x} → ∼ x → Set open Class ⦃ … ⦄ postulate instance _ : Class ≈C_ postulate instance _ : Class ≈R_ module Test where test1-worksC : {P : ExtProp} → ≈C P → Set test1-worksC P≈Q = foo P≈Q test2-worksC : {P : ExtProp} → ≈C P → Set test2-worksC {P} P≈Q = foo {x = P} P≈Q test3-worksC : {P : ExtProp} → ≈C P → Set test3-worksC {P} P≈Q = foo {x = _ , _} P≈Q test4-worksC : {P : ExtProp} → ≈C P → Set test4-worksC {P} P≈Q = foo {x = _ , π₁ P} P≈Q test1-failsR : {P : ExtProp} → ≈R P → Set test1-failsR P≈Q = foo P≈Q test2-worksR : {P : ExtProp} → ≈R P → Set test2-worksR {P} P≈Q = foo {x = P} P≈Q test3-failsR : {P : ExtProp} → ≈R P → Set test3-failsR {P} P≈Q = foo {x = _ , _} P≈Q test4-worksR : {P : ExtProp} → ≈R P → Set test4-worksR {P} P≈Q = foo {x = _ , π₁ P} P≈Q record Function : Set where no-eta-equality postulate fooC : {x : ExtProp} → ≈C x → Set postulate fooR : {x : ExtProp} → ≈R x → Set module Test where test1-worksC : {P : ExtProp} → ≈C P → Set test1-worksC P≈Q = fooC P≈Q test2-worksC : {P : ExtProp} → ≈C P → Set test2-worksC {P} P≈Q = fooC {x = P} P≈Q test3-worksC : {P : ExtProp} → ≈C P → Set test3-worksC {P} P≈Q = fooC {x = _ , _} P≈Q test4-worksC : {P : ExtProp} → ≈C P → Set test4-worksC {P} P≈Q = fooC {x = _ , π₁ P} P≈Q test1-failsR : {P : ExtProp} → ≈R P → Set test1-failsR P≈Q = fooR P≈Q test2-worksR : {P : ExtProp} → ≈R P → Set test2-worksR {P} P≈Q = fooR {x = P} P≈Q test3-failsR : {P : ExtProp} → ≈R P → Set test3-failsR {P} P≈Q = fooR {x = _ , _} P≈Q test4-worksR : {P : ExtProp} → ≈R P → Set test4-worksR {P} P≈Q = fooR {x = _ , π₁ P} P≈Q record RegularVsConstructedMoreSimpler : Set where no-eta-equality infixr 5 _,_ record Σ (𝔒 : Set₁) (𝔓 : 𝔒 → Set) : Set₁ where constructor _,_ field π₀ : 𝔒 π₁ : Set open Σ postulate Prop : Set₁ postulate Ext : Prop → Set postulate PropEq : Prop → Set ExtProp : Set₁ ExtProp = Σ Prop Ext Reg : ExtProp → Set Reg P = PropEq (π₀ P) record Con (P : ExtProp) : Set where constructor ∁ field π₀ : Reg P module Instance where record Class {B : Set₁} (F : B → Set) : Set₁ where field foo : ∀ {x} → F x → Set open Class ⦃ … ⦄ postulate instance _ : Class Reg postulate instance _ : Class Con postulate instance _ : Class Ext postulate instance _ : Class PropEq test1-failsR : {P : ExtProp} → Reg P → Set test1-failsR P≈Q = foo P≈Q test2-worksR : {P : ExtProp} → Reg P → Set test2-worksR {P} P≈Q = foo {x = P} P≈Q test3-failsR : {P : ExtProp} → Reg P → Set test3-failsR {P} P≈Q = foo {x = _ , _} P≈Q test4-worksR : {P : ExtProp} → Reg P → Set test4-worksR {P} P≈Q = foo {x = _ , π₁ P} P≈Q test1-worksC : {P : ExtProp} → Con P → Set test1-worksC P≈Q = foo P≈Q test2-worksC : {P : ExtProp} → Con P → Set test2-worksC {P} P≈Q = foo {x = P} P≈Q test3-worksC : {P : ExtProp} → Con P → Set test3-worksC {P} P≈Q = foo {x = _ , _} P≈Q test4-worksC : {P : ExtProp} → Con P → Set test4-worksC {P} P≈Q = foo {x = _ , π₁ P} P≈Q module Function where postulate fooR : {x : ExtProp} → Reg x → Set postulate fooC : {x : ExtProp} → Con x → Set test1-failsR : {P : ExtProp} → Reg P → Set test1-failsR P≈Q = fooR P≈Q test2-worksR : {P : ExtProp} → Reg P → Set test2-worksR {P} P≈Q = fooR {x = P} P≈Q test3-failsR : {P : ExtProp} → Reg P → Set test3-failsR {P} P≈Q = fooR {x = _ , _} P≈Q test4-worksR : {P : ExtProp} → Reg P → Set test4-worksR {P} P≈Q = fooR {x = _ , π₁ P} P≈Q test1-worksC : {P : ExtProp} → Con P → Set test1-worksC P≈Q = fooC P≈Q test2-worksC : {P : ExtProp} → Con P → Set test2-worksC {P} P≈Q = fooC {x = P} P≈Q test3-worksC : {P : ExtProp} → Con P → Set test3-worksC {P} P≈Q = fooC {x = _ , _} P≈Q test4-worksC : {P : ExtProp} → Con P → Set test4-worksC {P} P≈Q = fooC {x = _ , π₁ P} P≈Q module RegularVsConstructed-EnhancedReg where infixr 5 _,_ record Σ (𝔒 : Set₁) (𝔓 : 𝔒 → Set) : Set₁ where constructor _,_ field π₀ : 𝔒 π₁ : Set open Σ postulate Prop : Set₁ postulate Ext : Prop → Set postulate PropEq : Prop → Set → Set ExtProp : Set₁ ExtProp = Σ Prop Ext Reg : ExtProp → Set Reg P = PropEq (π₀ P) (π₁ P) record Con (P : ExtProp) : Set where constructor ∁ field π₀ : Reg P module Instance where record Class {B : Set₁} (F : B → Set) : Set₁ where field foo : ∀ {x} → F x → Set open Class ⦃ … ⦄ postulate instance _ : Class Reg postulate instance _ : Class Con postulate instance _ : Class Ext test1-failsR : {P : ExtProp} → Reg P → Set test1-failsR P≈Q = foo P≈Q test2-worksR : {P : ExtProp} → Reg P → Set test2-worksR {P} P≈Q = foo {x = P} P≈Q test3-failsR : {P : ExtProp} → Reg P → Set test3-failsR {P} P≈Q = foo {x = _ , _} P≈Q test4-worksR : {P : ExtProp} → Reg P → Set test4-worksR {P} P≈Q = foo {x = _ , π₁ P} P≈Q test1-worksC : {P : ExtProp} → Con P → Set test1-worksC P≈Q = foo P≈Q test2-worksC : {P : ExtProp} → Con P → Set test2-worksC {P} P≈Q = foo {x = P} P≈Q test3-worksC : {P : ExtProp} → Con P → Set test3-worksC {P} P≈Q = foo {x = _ , _} P≈Q test4-worksC : {P : ExtProp} → Con P → Set test4-worksC {P} P≈Q = foo {x = _ , π₁ P} P≈Q module Function where postulate fooR : {x : ExtProp} → Reg x → Set postulate fooC : {x : ExtProp} → Con x → Set test1-failsR : {P : ExtProp} → Reg P → Set test1-failsR P≈Q = fooR P≈Q test2-worksR : {P : ExtProp} → Reg P → Set test2-worksR {P} P≈Q = fooR {x = P} P≈Q test3-failsR : {P : ExtProp} → Reg P → Set test3-failsR {P} P≈Q = fooR {x = _ , _} P≈Q test4-worksR : {P : ExtProp} → Reg P → Set test4-worksR {P} P≈Q = fooR {x = _ , π₁ P} P≈Q test1-worksC : {P : ExtProp} → Con P → Set test1-worksC P≈Q = fooC P≈Q test2-worksC : {P : ExtProp} → Con P → Set test2-worksC {P} P≈Q = fooC {x = P} P≈Q test3-worksC : {P : ExtProp} → Con P → Set test3-worksC {P} P≈Q = fooC {x = _ , _} P≈Q test4-worksC : {P : ExtProp} → Con P → Set test4-worksC {P} P≈Q = fooC {x = _ , π₁ P} P≈Q record ProjectedMorality : Set where no-eta-equality infixr 5 _,_ record Σ (𝔒 : Set₁) (𝔓 : 𝔒 → Set) : Set₁ where constructor _,_ field π₀ : 𝔒 π₁ : Set open Σ postulate Prop : Set₁ postulate Ext : Prop → Set postulate PropEq : Prop → Set Reg : Σ Prop Ext → Set Reg P = PropEq (π₀ P) postulate bar : ∀ {𝔒 : Set₁} → 𝔒 → 𝔒 postulate qux : ∀ {𝔒} {𝔓 : 𝔒 → Set} → Σ 𝔒 𝔓 → Σ 𝔒 𝔓 postulate fake-π₀ : ∀ {𝔒} {𝔓 : 𝔒 → Set} → Σ 𝔒 𝔓 → 𝔒 abstract abstracted-π₀ : ∀ {𝔒} {𝔓 : 𝔒 → Set} → Σ 𝔒 𝔓 → 𝔒 abstracted-π₀ x = π₀ x Reg-using-abstracted-projection : Σ Prop Ext → Set Reg-using-abstracted-projection (P0 , P1) = PropEq (abstracted-π₀ {𝔒 = Prop} {𝔓 = Ext} (P0 , P1)) Reg-using-q : Σ Prop Ext → Set Reg-using-q x = PropEq (π₀ (qux x)) Reg-using-fake-π₀ : Σ Prop Ext → Set Reg-using-fake-π₀ x = PropEq (fake-π₀ x) record Con (P : Σ Prop Ext) : Set where constructor ∁ field π₀ : Reg P record Con-using-abstracted-projection (P : Σ Prop Ext) : Set where constructor ∁ field π₀ : Reg-using-abstracted-projection P record Con-using-q (P : Σ Prop Ext) : Set where constructor ∁ field π₀ : Reg-using-q P record Con-using-fake-π₀ (P : Σ Prop Ext) : Set where constructor ∁ field π₀ : Reg-using-fake-π₀ P record Class {B : Set₁} (F : B → Set) : Set₁ where field foo : ∀ {x} → F x → Set open Class ⦃ … ⦄ postulate instance _ : Class Reg postulate instance _ : Class Reg-using-abstracted-projection postulate instance _ : Class Reg-using-q postulate instance _ : Class Reg-using-fake-π₀ postulate instance _ : Class Con postulate instance _ : Class Con-using-abstracted-projection postulate instance _ : Class Con-using-q postulate instance _ : Class Con-using-fake-π₀ test1-failsR : ∀ {P} → Reg P → Set test1-failsR = foo test1-failsRap : ∀ {P} → Reg-using-abstracted-projection P → Set test1-failsRap = foo test1-failsRq : ∀ {P} → Reg-using-q P → Set test1-failsRq = foo test1-failsRf : ∀ {P} → Reg-using-fake-π₀ P → Set test1-failsRf = foo test1-worksC : ∀ {P} → Con P → Set test1-worksC = foo test1-worksCap : ∀ {P} → Con-using-abstracted-projection P → Set test1-worksCap = foo test1-worksCq : ∀ {P} → Con-using-q P → Set test1-worksCq = foo test1-worksCf : ∀ {P} → Con-using-fake-π₀ P → Set test1-worksCf = foo record DataMorality : Set where no-eta-equality module _ (𝔒 : Set₁) (𝔓 : 𝔒 → Set) where data Σ : Set₁ where _,_ : 𝔒 → Set → Σ module _ {𝔒 : Set₁} {𝔓 : 𝔒 → Set} where dπ₀ : Σ _ 𝔓 → 𝔒 dπ₀ (x , _) = x dπ₁ : Σ _ 𝔓 → Set dπ₁ (_ , y) = y postulate Prop : Set₁ postulate Ext : Prop → Set postulate PropEq : Prop → Set Reg : Σ Prop Ext → Set Reg P = PropEq (dπ₀ P) postulate bar : ∀ {𝔒 : Set₁} → 𝔒 → 𝔒 postulate qux : ∀ {𝔒} {𝔓 : 𝔒 → Set} → Σ 𝔒 𝔓 → Σ 𝔒 𝔓 postulate fake-π₀ : ∀ {𝔒} {𝔓 : 𝔒 → Set} → Σ 𝔒 𝔓 → 𝔒 abstract abstracted-π₀ : ∀ {𝔒} {𝔓 : 𝔒 → Set} → Σ 𝔒 𝔓 → 𝔒 abstracted-π₀ x = dπ₀ x Reg-using-abstracted-projection : Σ Prop Ext → Set Reg-using-abstracted-projection (P0 , P1) = PropEq (abstracted-π₀ {𝔒 = Prop} {𝔓 = Ext} (P0 , P1)) Reg-using-q : Σ Prop Ext → Set Reg-using-q x = PropEq (dπ₀ (qux x)) Reg-using-fake-π₀ : Σ Prop Ext → Set Reg-using-fake-π₀ x = PropEq (fake-π₀ x) record Con (P : Σ Prop Ext) : Set where constructor ∁ field π₀ : Reg P record Con-using-abstracted-projection (P : Σ Prop Ext) : Set where constructor ∁ field π₀ : Reg-using-abstracted-projection P record Con-using-q (P : Σ Prop Ext) : Set where constructor ∁ field π₀ : Reg-using-q P record Con-using-fake-π₀ (P : Σ Prop Ext) : Set where constructor ∁ field π₀ : Reg-using-fake-π₀ P record Class {B : Set₁} (F : B → Set) : Set₁ where field foo : ∀ {x} → F x → Set open Class ⦃ … ⦄ postulate instance _ : Class Reg postulate instance _ : Class Reg-using-abstracted-projection postulate instance _ : Class Reg-using-q postulate instance _ : Class Reg-using-fake-π₀ postulate instance _ : Class Con postulate instance _ : Class Con-using-abstracted-projection postulate instance _ : Class Con-using-q postulate instance _ : Class Con-using-fake-π₀ test1-failsR : ∀ {P} → Reg P → Set test1-failsR = foo test1-failsRap : ∀ {P} → Reg-using-abstracted-projection P → Set test1-failsRap = foo -- woah, it actually works. why? test1-failsRq : ∀ {P} → Reg-using-q P → Set test1-failsRq = foo -- NB this doesn't fail if instance of Class Reg is excluded test1-failsRf : ∀ {P} → Reg-using-fake-π₀ P → Set test1-failsRf = foo -- NB this doesn't fail if instance of Class Reg is excluded test1-worksC : ∀ {P} → Con P → Set test1-worksC = foo test1-worksCap : ∀ {P} → Con-using-abstracted-projection P → Set test1-worksCap = foo test1-worksCq : ∀ {P} → Con-using-q P → Set test1-worksCq = foo test1-worksCf : ∀ {P} → Con-using-fake-π₀ P → Set test1-worksCf = foo module RevampedSimpleFailure where record ExtensionProperty (𝔒 : Set) : Set₁ where field π₀ : Property 𝔒 π₁ : Extension π₀ open ExtensionProperty _≈_ : {𝔒 : Set} → ExtensionProperty 𝔒 → ExtensionProperty 𝔒 → Set _≈_ P Q = PropertyEquivalence (π₀ P) (π₀ Q) postulate symmetry : ∀ {𝔒} {x y : ExtensionProperty 𝔒} → x ≈ y → y ≈ x -- normalises to : ∀ {𝔒} {x y : ExtensionProperty 𝔒} → PropertyEquivalence (π₀ x) (π₀ y) → PropertyEquivalence (π₀ y) (π₀ x) test-fails : {𝔒 : Set} {P Q : ExtensionProperty 𝔒} → P ≈ Q → Q ≈ P test-fails P≈Q = symmetry P≈Q module PostulatedExtensionPropertySimpleSuccess where postulate ExtensionProperty : Set → Set₁ π₀ : {𝔒 : Set} → ExtensionProperty 𝔒 → Property 𝔒 _≈_ : {𝔒 : Set} → ExtensionProperty 𝔒 → ExtensionProperty 𝔒 → Set _≈_ P Q = PropertyEquivalence (π₀ P) (π₀ Q) postulate symmetry : ∀ {𝔒} {x y : ExtensionProperty 𝔒} → x ≈ y → y ≈ x -- normalises to : ∀ {𝔒} {x y : ExtensionProperty 𝔒} → PropertyEquivalence (π₀ {𝔒} x) (π₀ {𝔒} y) → PropertyEquivalence (π₀ {𝔒} y) (π₀ {𝔒} x) test-works : {𝔒 : Set} {P Q : ExtensionProperty 𝔒} → P ≈ Q → Q ≈ P test-works P≈Q = symmetry P≈Q module RevampedVerySimpleFailure where -- was PropertyEquivalence : ∀ {P : Set} → Property P → Property P → Set postulate _∼_ : Set → Set → Set record ExtensionProperty : Set₁ where field π₀ : Set -- was Property 𝔒 π₁ : Set -- was Extension π₀ open ExtensionProperty postulate symmetry : ∀ {x y : ExtensionProperty} → π₀ x ∼ π₀ y → π₀ y ∼ π₀ x postulate x y : ExtensionProperty test-fails : π₀ x ∼ π₀ y → π₀ y ∼ π₀ x test-fails = symmetry module PostulatedExtensionPropertyVerySimpleSuccess where postulate _∼_ : Set → Set → Set postulate ExtensionProperty : Set₁ π₀ : ExtensionProperty → Set postulate symmetry : ∀ {x y : ExtensionProperty} → π₀ x ∼ π₀ y → π₀ y ∼ π₀ x postulate x y : ExtensionProperty test-works : π₀ x ∼ π₀ y → π₀ y ∼ π₀ x test-works P≈Q = symmetry P≈Q module RevampedEvenSimplerFailure where -- was _∼_, which was PropertyEquivalence postulate F : Set → Set record ExtensionProperty : Set₁ where field π₀ : Set π₁ : Set open ExtensionProperty postulate symmetry : ∀ {x : ExtensionProperty} → F (π₀ x) → Set postulate x : ExtensionProperty postulate Fpx : F (π₀ x) test-fails1 : Set test-fails1 = symmetry Fpx test-fails2 : Set test-fails2 = symmetry {x = record { π₀ = π₀ x ; π₁ = _}} Fpx test-works-arbitrarily : Set test-works-arbitrarily = symmetry {x = record { π₀ = π₀ x ; π₁ = F (F (π₁ x)) }} Fpx module PostulatedExtensionPropertyEvenSimplerSuccess where postulate F : Set → Set postulate ExtensionProperty : Set₁ π₀ : ExtensionProperty → Set postulate symmetry : ∀ {x : ExtensionProperty} → F (π₀ x) → Set postulate x : ExtensionProperty postulate Fpx : F (π₀ x) test-works1 : Set test-works1 = symmetry Fpx test-works2 : Set test-works2 = symmetry {x = x} Fpx module RevampedEvenSimplerFailureClassified where postulate F : Set → Set record ExtensionProperty : Set₁ where field π₀ : Set π₁ : Set open ExtensionProperty record Symmetry' (R : Set → Set) : Set₁ where field symmetry : ∀ {x : ExtensionProperty} → R (π₀ x) → Set open Symmetry' ⦃ … ⦄ postulate instance _ : Symmetry' F postulate x : ExtensionProperty postulate Fpx : F (π₀ x) test-fails1 : Set test-fails1 = symmetry Fpx test-fails2 : Set test-fails2 = symmetry {x = record { π₀ = π₀ x ; π₁ = _}} Fpx test-works-arbitrarily : Set test-works-arbitrarily = symmetry {x = record { π₀ = π₀ x ; π₁ = F (F (π₁ x)) }} Fpx module PostulatedExtensionPropertyEvenSimplerSuccessClassified where postulate F : Set → Set postulate ExtensionProperty : Set₁ π₀ : ExtensionProperty → Set record Symmetry' (R : Set → Set) : Set₁ where field symmetry : ∀ {x : ExtensionProperty} → R (π₀ x) → Set open Symmetry' ⦃ … ⦄ postulate instance _ : Symmetry' F postulate x : ExtensionProperty postulate Fpx : F (π₀ x) test-works1 : Set test-works1 = symmetry Fpx test-works2 : Set test-works2 = symmetry {x = x} Fpx module RevampedVsPostulated where record R : Set₁ where field f1 : Set f2 : Set open R postulate fooR : ∀ {x : R} → f1 x → Set postulate r : R postulate f1r : f1 r test-fails1 : Set test-fails1 = fooR f1r postulate S : Set₁ g1 : S → Set postulate fooS : ∀ {x : S} → g1 x → Set postulate s : S postulate g1s : g1 s test-works1 : Set test-works1 = fooS g1s
{ "alphanum_fraction": 0.5851517695, "avg_line_length": 28.6533066132, "ext": "agda", "hexsha": "03d89ebde2ae6216930409c5aa8c7f0e2bdd2a26", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_forks_repo_licenses": [ "RSA-MD" ], "max_forks_repo_name": "m0davis/oscar", "max_forks_repo_path": "archive/agda-3/src/AgdaFeaturePitfallInstanceResolution.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_issues_repo_issues_event_max_datetime": "2019-05-11T23:33:04.000Z", "max_issues_repo_issues_event_min_datetime": "2019-04-29T00:35:04.000Z", "max_issues_repo_licenses": [ "RSA-MD" ], "max_issues_repo_name": "m0davis/oscar", "max_issues_repo_path": "archive/agda-3/src/AgdaFeaturePitfallInstanceResolution.agda", "max_line_length": 173, "max_stars_count": null, "max_stars_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_stars_repo_licenses": [ "RSA-MD" ], "max_stars_repo_name": "m0davis/oscar", "max_stars_repo_path": "archive/agda-3/src/AgdaFeaturePitfallInstanceResolution.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 11612, "size": 28596 }
{-# OPTIONS --without-K --safe #-} -- Properties of F<:⁻ -- -- This file shows several structural properties of F<:⁻, including weakening, -- narrowing and transitivity. They are not used anywhere, but just serve as a -- reference to compare the complexity with the corresponding proofs of D<:. module FsubMinus2 where open import Data.List as List open import Data.Nat open import Data.Maybe as Maybe open import Data.Product open import Data.Sum open import Function open import Data.Empty renaming (⊥ to False) open import Relation.Nullary open import Relation.Binary.PropositionalEquality as ≡ open import Data.Nat.Properties as ℕₚ open import Data.Maybe.Properties as Maybeₚ open import Utils open import FsubMinus open import Data.List.Properties as Listₚ open import Induction.Nat open FsubMinus.FsubMinus infixl 7 _⇑ Γ-⇑ : Env → Ftyp → Ftyp Γ-⇑ Γ = _↑ length Γ _⇑ : Env → Env [] ⇑ = [] (T ∷ Γ) ⇑ = Γ-⇑ Γ T ∷ Γ ⇑ ↑-↑-comm : ∀ T m n → m ≤ n → T ↑ m ↑ suc n ≡ T ↑ n ↑ m ↑-↑-comm ⊤ m n m≤n = refl ↑-↑-comm (var x) m n m≤n with n ≤? x ... | yes n≤x rewrite ≤?-yes $ ≤-step $ ≤-trans m≤n n≤x | ≤?-yes $ ≤-trans m≤n n≤x | ≤?-yes n≤x = refl ... | no x<n with m ≤? x ... | yes m≤x rewrite proj₂ $ ≤?-no x<n = refl ... | no x<m with suc n ≤? x ... | yes 1+n≤x = ⊥-elim $ x<m (≤-trans (≤-step m≤n) 1+n≤x) ... | no x<1+n = refl ↑-↑-comm (Π<: S ∙ U) m n m≤n rewrite ↑-↑-comm S m n m≤n | ↑-↑-comm U (suc m) (suc n) (s≤s m≤n) = refl <:∈-weakening-≤ : ∀ {x T Γ} → x <: T ∈ Γ → ∀ Γ₁ Γ₂ T′ → Γ ≡ Γ₁ ‣ Γ₂ → length Γ₂ ≤ x → suc x <: Γ-⇑ Γ₂ T ∈ Γ₁ ‣ T′ ! ‣ Γ₂ ⇑ <:∈-weakening-≤ hd Γ₁ [] T′ refl l≤x = tl hd <:∈-weakening-≤ hd Γ₁ (_ ∷ Γ₂) T′ eq () <:∈-weakening-≤ (tl <:∈) Γ₁ [] T′ refl l≤x = tl (tl <:∈) <:∈-weakening-≤ (tl {T = T} <:∈) Γ₁ (_ ∷ Γ₂) T′ refl (s≤s l≤x) rewrite ↑-↑-comm T 0 (length Γ₂) z≤n = tl $ <:∈-weakening-≤ <:∈ Γ₁ Γ₂ T′ refl l≤x <:∈-weakening-> : ∀ {x T Γ} → x <: T ∈ Γ → ∀ Γ₁ Γ₂ T′ → Γ ≡ Γ₁ ‣ Γ₂ → length Γ₂ > x → x <: Γ-⇑ Γ₂ T ∈ Γ₁ ‣ T′ ! ‣ Γ₂ ⇑ <:∈-weakening-> hd Γ₁ [] T′ eq () <:∈-weakening-> hd Γ₁ (T ∷ Γ₂) T′ refl l>x rewrite ↑-↑-comm T 0 (length Γ₂) z≤n = hd <:∈-weakening-> (tl <:∈) Γ₁ [] T′ eq () <:∈-weakening-> (tl {T = T} <:∈) Γ₁ (_ ∷ Γ₂) T′ refl (s≤s l>x) rewrite ↑-↑-comm T 0 (length Γ₂) z≤n = tl $ <:∈-weakening-> <:∈ Γ₁ Γ₂ T′ refl l>x <:∈-weakening : ∀ {x T Γ} → x <: T ∈ Γ → ∀ Γ₁ Γ₂ T′ → Γ ≡ Γ₁ ‣ Γ₂ → ↑-idx x (length Γ₂) <: Γ-⇑ Γ₂ T ∈ Γ₁ ‣ T′ ! ‣ Γ₂ ⇑ <:∈-weakening {x} <:∈ Γ₁ Γ₂ T′ eq with length Γ₂ ≤? x ... | yes p = <:∈-weakening-≤ <:∈ Γ₁ Γ₂ T′ eq p ... | no ¬p = <:∈-weakening-> <:∈ Γ₁ Γ₂ T′ eq (≰⇒> ¬p) <:-weakening-gen : ∀ {Γ S U} → Γ ⊢F S <: U → ∀ Γ₁ Γ₂ T → Γ ≡ Γ₁ ‣ Γ₂ → Γ₁ ‣ T ! ‣ Γ₂ ⇑ ⊢F Γ-⇑ Γ₂ S <: Γ-⇑ Γ₂ U <:-weakening-gen ftop Γ₁ Γ₂ T eq = ftop <:-weakening-gen (fvrefl {_} {x}) Γ₁ Γ₂ T eq rewrite ↑-var x (length Γ₂) = fvrefl <:-weakening-gen (fbinds {_} {x} T∈Γ D) Γ₁ Γ₂ T eq rewrite ↑-var x (length Γ₂) = fbinds (<:∈-weakening T∈Γ Γ₁ Γ₂ T eq) (<:-weakening-gen D Γ₁ Γ₂ T eq) <:-weakening-gen (fall {S₂ = S₂} Dp Db) Γ₁ Γ₂ T eq = fall (<:-weakening-gen Dp Γ₁ Γ₂ T eq) (<:-weakening-gen Db Γ₁ (Γ₂ ‣ S₂ !) T (cong (S₂ ∷_) eq)) <:-weakening : ∀ {S U} Γ₁ Γ₂ T → Γ₁ ‣ Γ₂ ⊢F S <: U → Γ₁ ‣ T ! ‣ Γ₂ ⇑ ⊢F Γ-⇑ Γ₂ S <: Γ-⇑ Γ₂ U <:-weakening _ _ T D = <:-weakening-gen D _ _ T refl <:-weakening-hd : ∀ {Γ S U} T → Γ ⊢F S <: U → Γ ‣ T ! ⊢F S ↑ 0 <: U ↑ 0 <:-weakening-hd T D = <:-weakening _ [] T D <:-weakening′ : ∀ {Γ S U} Γ′ → Γ ⊢F S <: U → Γ ‣ Γ′ ⊢F repeat (length Γ′) (_↑ 0) S <: repeat (length Γ′) (_↑ 0) U <:-weakening′ [] D = D <:-weakening′ (T ∷ Γ′) D = <:-weakening-hd T $ <:-weakening′ Γ′ D <:-refl : ∀ Γ T → Γ ⊢F T <: T <:-refl Γ ⊤ = ftop <:-refl Γ (var x) = fvrefl <:-refl Γ (Π<: S ∙ U) = fall (<:-refl Γ S) (<:-refl (S ∷ Γ) U) module TransProof where open ≤-Reasoning <:∈-find : ∀ {x T Γ} → x <: T ∈ Γ → ∀ T₁ T₂ Γ₁ Γ₂ → Γ ≡ Γ₁ ‣ T₁ ! ‣ Γ₂ → x ≢ length Γ₂ × x <: T ∈ Γ₁ ‣ T₂ ! ‣ Γ₂ ⊎ x ≡ length Γ₂ × T ≡ repeat (suc (length Γ₂)) (_↑ 0) T₁ × x <: repeat (suc (length Γ₂)) (_↑ 0) T₂ ∈ Γ₁ ‣ T₂ ! ‣ Γ₂ <:∈-find hd T₁ T₂ Γ₁ [] refl = inj₂ (refl , refl , hd) <:∈-find hd T₁ T₂ Γ₁ (_ ∷ Γ₂) refl = inj₁ ((λ ()) , hd) <:∈-find (tl <:∈) T₁ T₂ Γ₁ [] refl = inj₁ ((λ ()) , tl <:∈) <:∈-find (tl <:∈) T₁ T₂ Γ₁ (_ ∷ Γ₂) refl with <:∈-find <:∈ T₁ T₂ Γ₁ Γ₂ refl ... | inj₁ (n≢l , r) = inj₁ ((λ n≡l → n≢l (suc-injective n≡l)) , tl r) ... | inj₂ (n≡l , e , r) = inj₂ (cong suc n≡l , cong (_↑ 0) e , tl r) infix 4 _≺:[_]_ data _≺:[_]_ : Env → ℕ → Env → Set where ≺[_,_] : ∀ {Γ U} S → Γ ⊢F S <: U → Γ ‣ S ! ≺:[ 0 ] Γ ‣ U ! _∷_ : ∀ {Γ₁ n Γ₂} T → Γ₁ ≺:[ n ] Γ₂ → Γ₁ ‣ T ! ≺:[ suc n ] Γ₂ ‣ T ! <:∈-find′ : ∀ {x T Γ Γ′ n} → x <: T ∈ Γ → Γ′ ≺:[ n ] Γ → x ≡ n × (∃ λ T′ → n <: T′ ∈ Γ′ × Γ′ ⊢F T′ <: T) ⊎ x ≢ n × x <: T ∈ Γ′ <:∈-find′ hd ≺[ T′ , T′<:T ] = inj₁ (refl , T′ ↑ 0 , hd , <:-weakening-hd T′ T′<:T) <:∈-find′ hd (T ∷ Γ′≺:Γ) = inj₂ ((λ ()) , hd) <:∈-find′ (tl T∈Γ) ≺[ T′ , T′<:T ] = inj₂ ((λ ()) , tl T∈Γ) <:∈-find′ (tl T∈Γ) (S ∷ Γ′≺:Γ) with <:∈-find′ T∈Γ Γ′≺:Γ ... | inj₁ (x≡n , T′ , T′∈Γ′ , T′<:T) = inj₁ (cong suc x≡n , T′ ↑ 0 , tl T′∈Γ′ , <:-weakening-hd S T′<:T) ... | inj₂ (x≢n , T∈Γ′) = inj₂ (x≢n ∘ suc-injective , tl T∈Γ′) trans-on : Ftyp → Set trans-on T = ∀ {Γ S U} → Γ ⊢F S <: T → Γ ⊢F T <: U → Γ ⊢F S <: U narrow-on : Ftyp → Set narrow-on T = ∀ {Γ Γ′ n S U} → Γ ⊢F S <: U → Γ′ ≺:[ n ] Γ → n <: T ∈ Γ → Γ′ ⊢F S <: U <:-trans-rec : ∀ T → (∀ T′ → Ftyp-measure T′ < Ftyp-measure T → trans-on T′ × narrow-on T′) → trans-on T <:-trans-rec ⊤ rec S<:T ftop = S<:T <:-trans-rec (var x) rec S<:T ftop = ftop <:-trans-rec (var x) rec S<:T fvrefl = S<:T <:-trans-rec (var x) rec fvrefl (fbinds T∈Γ T<:U) = fbinds T∈Γ T<:U <:-trans-rec (var x) rec (fbinds S∈Γ S<:T) (fbinds T∈Γ T<:U) = fbinds S∈Γ (<:-trans-rec (var x) rec S<:T (fbinds T∈Γ T<:U)) <:-trans-rec (Π<: S ∙ U) rec S<:T ftop = ftop <:-trans-rec (Π<: S ∙ U) rec (fbinds S∈Γ S<:T) (fall Db Dp) = fbinds S∈Γ (<:-trans-rec (Π<: S ∙ U) rec S<:T (fall Db Dp)) <:-trans-rec (Π<: S ∙ U) rec (fall Dp₁ Db₁) (fall Dp₂ Db₂) = fall (<:-trans-rec S (λ T′ T′<:S → rec T′ (≤-stepsʳ _ T′<:S)) Dp₂ Dp₁) (<:-trans-rec U (λ T′ T′<U → rec T′ (≤-trans T′<U (≤-stepsˡ _ ≤-refl))) (proj₂ (rec (S ↑ 0) S↑0<SU) Db₁ ≺[ _ , Dp₂ ] hd) Db₂) where S↑0<SU : Ftyp-measure (S ↑ 0) < Ftyp-measure S + Ftyp-measure U S↑0<SU = begin-strict Ftyp-measure (S ↑ 0) ≡⟨ Ftyp-measure-↑ S 0 ⟩ Ftyp-measure S <⟨ ≤-refl ⟩ 1 + Ftyp-measure S ≡⟨ sym (+-comm _ 1) ⟩ Ftyp-measure S + 1 ≤⟨ +-monoʳ-≤ _ (Ftyp-measure≥1 U) ⟩ Ftyp-measure S + Ftyp-measure U ∎ <:-narrowing-rec : ∀ T → (∀ T′ → Ftyp-measure T′ ≤ Ftyp-measure T → trans-on T′) → narrow-on T <:-narrowing-rec T trans ftop Γ′≺:Γ T∈Γ = ftop <:-narrowing-rec T trans fvrefl Γ′≺:Γ T∈Γ = fvrefl <:-narrowing-rec T trans (fbinds S∈Γ S<:U) Γ′≺:Γ T∈Γ with <:∈-find′ S∈Γ Γ′≺:Γ ... | inj₁ (refl , T′ , T′∈Γ′ , T′<:T) rewrite <:∈-func S∈Γ T∈Γ = fbinds T′∈Γ′ (trans T ≤-refl T′<:T (<:-narrowing-rec T trans S<:U Γ′≺:Γ T∈Γ)) ... | inj₂ (x≢n , T′∈Γ′) = fbinds T′∈Γ′ (<:-narrowing-rec T trans S<:U Γ′≺:Γ T∈Γ) <:-narrowing-rec T trans (fall Dp Db) Γ′≺:Γ T∈Γ = fall (<:-narrowing-rec T trans Dp Γ′≺:Γ T∈Γ) (<:-narrowing-rec (T ↑ 0) (λ T′ → trans T′ ∘ T′≤T T′) Db (_ ∷ Γ′≺:Γ) (tl T∈Γ)) where T′≤T : ∀ T′ → Ftyp-measure T′ ≤ Ftyp-measure (T ↑ 0) → Ftyp-measure T′ ≤ Ftyp-measure T T′≤T T′ T′≤T↑0 = begin Ftyp-measure T′ ≤⟨ T′≤T↑0 ⟩ Ftyp-measure (T ↑ 0) ≡⟨ Ftyp-measure-↑ T 0 ⟩ Ftyp-measure T ∎ <:-trans-narrow : ∀ T → trans-on T × narrow-on T <:-trans-narrow = wfRec (λ T → trans-on T × narrow-on T) λ T rec → <:-trans-rec T rec , <:-narrowing-rec T λ T′ T′≤T → <:-trans-rec T′ λ T″ T″<T′ → rec T″ (≤-trans T″<T′ T′≤T) where open Measure <-wellFounded Ftyp-measure <:-trans : ∀ {T} → trans-on T <:-trans {T} = proj₁ $ <:-trans-narrow T <:-narrow : ∀ {T} → narrow-on T <:-narrow {T} = proj₂ $ <:-trans-narrow T <:-weakening-size-gen : ∀ {Γ S U} → (S<:U : Γ ⊢F S <: U) → ∀ Γ₁ Γ₂ T → (eq : Γ ≡ Γ₁ ‣ Γ₂) → F-measure S<:U ≡ F-measure (<:-weakening-gen S<:U Γ₁ Γ₂ T eq) <:-weakening-size-gen ftop Γ₁ Γ₂ T eq = refl <:-weakening-size-gen (fvrefl {_} {x}) Γ₁ Γ₂ T eq rewrite ↑-var x (length Γ₂) = refl <:-weakening-size-gen (fbinds {_} {x} S∈Γ D) Γ₁ Γ₂ T eq rewrite ↑-var x (length Γ₂) = cong suc (<:-weakening-size-gen D Γ₁ Γ₂ T eq) <:-weakening-size-gen (fall {S₂ = S} Dp Db) Γ₁ Γ₂ T eq = cong suc (cong₂ _+_ (<:-weakening-size-gen Dp Γ₁ Γ₂ T eq) (<:-weakening-size-gen Db Γ₁ (S ∷ Γ₂) T (cong (S ∷_) eq))) open TransProof using (<:-trans ; <:-narrow) public
{ "alphanum_fraction": 0.4067515219, "avg_line_length": 45.3640167364, "ext": "agda", "hexsha": "7de53751ac548ca2a3930e7dc3c0a08ed43a2172", "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": "48214a55ebb484fd06307df4320813d4a002535b", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "HuStmpHrrr/popl20-artifact", "max_forks_repo_path": "agda/FsubMinus2.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "48214a55ebb484fd06307df4320813d4a002535b", "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": "HuStmpHrrr/popl20-artifact", "max_issues_repo_path": "agda/FsubMinus2.agda", "max_line_length": 139, "max_stars_count": 1, "max_stars_repo_head_hexsha": "48214a55ebb484fd06307df4320813d4a002535b", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "HuStmpHrrr/popl20-artifact", "max_stars_repo_path": "agda/FsubMinus2.agda", "max_stars_repo_stars_event_max_datetime": "2021-09-23T08:40:28.000Z", "max_stars_repo_stars_event_min_datetime": "2021-09-23T08:40:28.000Z", "num_tokens": 4437, "size": 10842 }
module Categories where infix 10 _≡_ data _≡_ {A : Set}(a : A) : {B : Set} -> B -> Set where refl : a ≡ a trans : forall {A B C}{a : A}{b : B}{c : C} -> a ≡ b -> b ≡ c -> a ≡ c trans refl p = p sym : forall {A B}{a : A}{b : B} -> a ≡ b -> b ≡ a sym refl = refl resp : forall {A}{B : A -> Set}{a a' : A} -> (f : (a : A) -> B a) -> a ≡ a' -> f a ≡ f a' resp f refl = refl record Cat : Set1 where field Obj : Set Hom : Obj -> Obj -> Set id : forall X -> Hom X X _○_ : forall {X Y Z} -> Hom Y Z -> Hom X Y -> Hom X Z idl : forall {X Y}{f : Hom X Y} -> id Y ○ f ≡ f idr : forall {X Y}{f : Hom X Y} -> f ○ id X ≡ f assoc : forall {W X Y Z}{f : Hom W X}{g : Hom X Y}{h : Hom Y Z} -> (h ○ g) ○ f ≡ h ○ (g ○ f) open Cat record Functor (C D : Cat) : Set where field Fun : Obj C -> Obj D map : forall {X Y} -> (Hom C X Y) -> Hom D (Fun X) (Fun Y) mapid : forall {X} -> map (id C X) ≡ id D (Fun X) map○ : forall {X Y Z}{f : Hom C X Y}{g : Hom C Y Z} -> map (_○_ C g f) ≡ _○_ D (map g) (map f) open Functor idF : forall C -> Functor C C idF C = record {Fun = \x -> x; map = \x -> x; mapid = refl; map○ = refl} _•_ : forall {C D E} -> Functor D E -> Functor C D -> Functor C E F • G = record {Fun = \X -> Fun F (Fun G X); map = \f -> map F (map G f); mapid = trans (resp (\x -> map F x) (mapid G)) (mapid F); map○ = trans (resp (\x -> map F x) (map○ G)) (map○ F)} record Nat {C D : Cat} (F G : Functor C D) : Set where field η : (X : Obj C) -> Hom D (Fun F X) (Fun G X) law : {X Y : Obj C}{f : Hom C X Y} -> _○_ D (η Y) (map F f) ≡ _○_ D (map G f) (η X) open Nat _▪_ : forall {C D : Cat}{F G H : Functor C D} -> Nat G H -> Nat F G -> Nat F H _▪_ {D = D} A B = record { η = \X -> _○_ D (η A X) (η B X); law = \{X}{Y} -> trans (assoc D) (trans (resp (\f -> _○_ D (η A Y) f) (law B)) (trans (sym (assoc D)) (trans (resp (\g -> _○_ D g (η B X)) (law A)) (assoc D)))) }
{ "alphanum_fraction": 0.4258660508, "avg_line_length": 32.3134328358, "ext": "agda", "hexsha": "f18de87e3d1869c31286a47b71bedd959822be98", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_forks_event_min_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_head_hexsha": "477c8c37f948e6038b773409358fd8f38395f827", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "larrytheliquid/agda", "max_forks_repo_path": "benchmark/categories/Categories.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "477c8c37f948e6038b773409358fd8f38395f827", "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": "larrytheliquid/agda", "max_issues_repo_path": "benchmark/categories/Categories.agda", "max_line_length": 78, "max_stars_count": null, "max_stars_repo_head_hexsha": "477c8c37f948e6038b773409358fd8f38395f827", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "larrytheliquid/agda", "max_stars_repo_path": "benchmark/categories/Categories.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 847, "size": 2165 }
------------------------------------------------------------------------ -- Pointers to results from the paper ------------------------------------------------------------------------ -- Note that this is a version of the code that does not quite match -- the description in the paper. See README for some discussion of the -- changes. {-# OPTIONS --cubical --sized-types #-} module README.Pointers-to-results-from-the-paper where -- Library code. import Delay-monad import Delay-monad.Bisimilarity import Delay-monad.Bisimilarity.Alternative import Delay-monad.Monad import Delay-monad.Partial-order import Delay-monad.Termination import Equality.Propositional as Equality import Interval import H-level.Truncation.Propositional as Truncation import Quotient import Univalence-axiom -- Code from this development. import Delay-monad.Alternative import Delay-monad.Alternative.Equivalence import Delay-monad.Alternative.Partial-order import Delay-monad.Alternative.Termination import Delay-monad.Alternative.Weak-bisimilarity import Lifting import Partiality-algebra import Partiality-algebra.Category import Partiality-algebra.Eliminators import Partiality-algebra.Fixpoints import Partiality-algebra.Pi import Partiality-monad.Coinductive.Alternative import Partiality-monad.Inductive as Partiality-monad import Partiality-monad.Inductive.Alternative-order as Alternative-order import Partiality-monad.Inductive.Eliminators import Partiality-monad.Inductive.Fixpoints import Partiality-monad.Inductive.Monad as Monad import Partiality-monad.Inductive.Monad.Adjunction as Adjunction import Partiality-monad.Equivalence import README.Lambda import Search ------------------------------------------------------------------------ -- Section 2 -- Note that most of the following definitions are taken from a -- library. -- Extensionality for functions. Extensionality = Equality.Extensionality ext = Interval.ext -- Strong bisimilarity implies equality for the delay monad. Delay-ext = Delay-monad.Bisimilarity.Extensionality -- The property of being a set. Is-set = Equality.Is-set -- The property of being a proposition. Is-proposition = Equality.Is-proposition -- Propositional extensionality. Propositional-extensionality = Univalence-axiom.Propositional-extensionality -- The univalence axiom. Univalence = Univalence-axiom.Univalence -- Quotient types. import Quotient -- Countable choice. Countable-choice = Truncation.Axiom-of-countable-choice ------------------------------------------------------------------------ -- Section 3.1 -- Definition 1: Partiality algebras and partiality algebra morphisms. -- The function η is called now and ⊥ is called never. Partiality-algebra = Partiality-algebra.Partiality-algebra Morphism = Partiality-algebra.Morphism -- An identity morphism. id = Partiality-algebra.id -- Composition of morphisms. _∘_ = Partiality-algebra._∘_ -- Partiality algebras form a category. category = Partiality-algebra.Category.category -- The partiality monad, defined as a QIIT. (The proof α is called -- antisymmetry.) _⊥ = Partiality-monad._⊥ -- A partiality algebra for the partiality monad. partiality-monad = Partiality-monad.partiality-algebra -- Initiality. Initial = Partiality-algebra.Eliminators.Initial -- Theorem 2. Induction-principle = Partiality-algebra.Eliminators.Elimination-principle universality-to-induction = Partiality-algebra.Eliminators.∀initiality→∀eliminators induction-to-universality = Partiality-algebra.Eliminators.∀eliminators→∀initiality -- The partiality monad's induction principle. induction-principle = Partiality-monad.eliminators -- A proof that shows that A ⊥ is a set without making use of the -- set-truncation "constructor". T-is-set = Partiality-algebra.Partiality-algebra-with.T-is-set -- Lemma 3. lemma-3 = Partiality-monad.Inductive.Eliminators.⊥-rec-⊥ ------------------------------------------------------------------------ -- Section 3.2 -- Definition 4: The category ω-CPO of pointed ω-cpos. ω-CPO = Adjunction.ω-CPPO ω-cpo = Adjunction.ω-cppo -- The forgetful functor U from ω-CPO (and in fact Part_A for any A) -- to SET. U = Adjunction.Forget -- The functor F from SET to ω-CPO. F = Adjunction.Partial -- Theorem 5. theorem-5 = Adjunction.Partial⊣Forget -- Corollary 6. corollary-6 = Adjunction.Partiality-monad -- A direct construction of a monad structure on _⊥. μ = Monad.join module Monad-laws = Monad.Monad-laws ------------------------------------------------------------------------ -- Section 3.3 -- Lemma 7. For the second part the code uses a propositional -- truncation that is not present in the paper: the result proved in -- the code is more general, and works even if the type "A" is not a -- set. lemma-7-part-1 = Alternative-order.now⊑never≃⊥ lemma-7-part-2 = Alternative-order.now⊑now≃∥≡∥ lemma-7-part-3 = Alternative-order.now⊑⨆≃∥∃now⊑∥ -- Corollary 8. For the second part the code uses a propositional -- truncation that is not present in the paper: the result proved in -- the code is more general, and works even if the type "A" is not a -- set. corollary-8-part-1 = Alternative-order.now⊑→⇓ corollary-8-part-2 = Alternative-order.now≡now≃∥≡∥ corollary-8-part-3 = Alternative-order.now≢never -- The order is flat. flat-order = Alternative-order.flat-order ------------------------------------------------------------------------ -- Section 4, not including Sections 4.1 and 4.2 -- Definition 9: The delay monad and weak bisimilarity. The definition -- of _↓_ is superficially different from the one in the paper. The -- first definition of weak bisimilarity, _∼D_, is different from the -- one in the paper, but is logically equivalent to the second one, -- _∼D′_, which is closer to the paper's definition. Delay = Delay-monad.Delay _↓D_ = Delay-monad.Termination._⇓_ _∼D_ = Delay-monad.Bisimilarity._≈_ _∼D′_ = Delay-monad.Bisimilarity.Alternative._≈₂_ ∼D⇔∼D′ = Delay-monad.Partial-order.≈⇔≈₂ -- The delay monad is a monad. Delay-monad = Delay-monad.Monad.delay-monad -- The relation _↓D_ is pointwise propositional (when the type "A" is -- a set). ↓D-propositional = Delay-monad.Termination.Terminates-propositional -- The relation _∼D′_ is pointwise propositional (when the type "A" is -- a set). ∼D′-propositional = Delay-monad.Bisimilarity.Alternative.≈₂-propositional -- _∼D_ is an equivalence relation. ∼D-reflexive = Delay-monad.Bisimilarity.reflexive ∼D-symmetric = Delay-monad.Bisimilarity.symmetric ∼D-transitive = Delay-monad.Bisimilarity.transitive-≈ ------------------------------------------------------------------------ -- Section 4.1 -- The predicate is-mon. is-mon = Delay-monad.Alternative.Increasing -- Monotone sequences. Seq = Delay-monad.Alternative.Delay -- Lemma 10. lemma-10 = Delay-monad.Alternative.Equivalence.Delay↔Delay -- The relation ↓_Seq. _↓-Seq_ = Delay-monad.Alternative.Termination._⇓_ -- This relation is pointwise logically equivalent to a -- propositionally truncated variant (when the type "A" is a set). ↓-Seq⇔∥↓-Seq∥ = Delay-monad.Alternative.Termination.⇓⇔∥⇓∥ -- The relation ⊑_Seq. _⊑-Seq_ = Delay-monad.Alternative.Partial-order._∥⊑∥_ -- This relation is pointwise propositional. ⊑-Seq-propositional = Delay-monad.Alternative.Partial-order.∥⊑∥-propositional -- The relation ∼_Seq. _∼-Seq_ = Delay-monad.Alternative.Weak-bisimilarity._≈_ -- This relation is pointwise propositional. ≈-Seq-propositional = Delay-monad.Alternative.Weak-bisimilarity.≈-propositional -- Lemma 11. lemma-11 = Partiality-monad.Coinductive.Alternative.⊥↔⊥ ------------------------------------------------------------------------ -- Section 4.2 -- The function w. w = Partiality-monad.Equivalence.Delay→⊥ -- Lemma 12. w-monotone = Partiality-monad.Equivalence.Delay→⊥-mono w̃ = Partiality-monad.Equivalence.⊥→⊥ -- Lemma 13. lemma-13 = Partiality-monad.Equivalence.⊥→⊥-injective -- Lemma 14. lemma-14 = Partiality-monad.Equivalence.Delay→⊥-surjective -- The function w̃ is surjective. w̃-surjective = Partiality-monad.Equivalence.⊥→⊥-surjective -- Theorem 15. theorem-15-part-1 = Partiality-monad.Equivalence.⊥→⊥-equiv theorem-15-part-2 = Partiality-monad.Equivalence.⊥≃⊥′ theorem-15-part-3 = Partiality-monad.Equivalence.⊥≃⊥ ------------------------------------------------------------------------ -- Section 5.1 -- A fixpoint combinator. fix = Partiality-algebra.Fixpoints.fix -- If the argument is ω-continuous, then the result is a least fixed -- point. fixed-point = Partiality-algebra.Fixpoints.fix-is-fixpoint-combinator least = Partiality-algebra.Fixpoints.fix-is-least -- A kind of dependent function space with a type as the domain and a -- family of partiality algebras as the codomain. The result is a -- partiality algebra. Π = Partiality-algebra.Pi.Π -- The search function. module The-search-function = Search.Direct ------------------------------------------------------------------------ -- Section 5.3 -- Operational semantics. module Operational-semantics = README.Lambda ------------------------------------------------------------------------ -- Section 6 -- A quotient inductive-inductive definition of the lifting -- construction on ω-cpos. (This construction is based on a suggestion -- from Paolo Capriotti.) module Lifting-construction = Lifting
{ "alphanum_fraction": 0.6890166028, "avg_line_length": 26.6931818182, "ext": "agda", "hexsha": "ae4d2cff8ba9109740d8cacdd6766bfffc9281aa", "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": "f69749280969f9093e5e13884c6feb0ad2506eae", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "nad/partiality-monad", "max_forks_repo_path": "README/Pointers-to-results-from-the-paper.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "f69749280969f9093e5e13884c6feb0ad2506eae", "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/partiality-monad", "max_issues_repo_path": "README/Pointers-to-results-from-the-paper.agda", "max_line_length": 72, "max_stars_count": 2, "max_stars_repo_head_hexsha": "f69749280969f9093e5e13884c6feb0ad2506eae", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "nad/partiality-monad", "max_stars_repo_path": "README/Pointers-to-results-from-the-paper.agda", "max_stars_repo_stars_event_max_datetime": "2020-07-03T08:56:08.000Z", "max_stars_repo_stars_event_min_datetime": "2020-05-21T22:59:18.000Z", "num_tokens": 2549, "size": 9396 }
module Cats.Category.Cones where open import Relation.Binary using (Rel ; IsEquivalence ; _Preserves₂_⟶_⟶_) open import Level using (_⊔_) open import Cats.Category.Base open import Cats.Functor using (Functor) renaming (_∘_ to _∘F_) open import Cats.Util.Conv import Relation.Binary.PropositionalEquality as ≡ import Cats.Category.Constructions.Iso as Iso import Cats.Util.Function as Fun module _ {lo la l≈ lo′ la′ l≈′} {J : Category lo la l≈} {Z : Category lo′ la′ l≈′} (D : Functor J Z) where infixr 9 _∘_ infixr 4 _≈_ private module Z = Category Z module J = Category J module D = Functor D -- We could define cones in terms of wedges (and limits in terms of ends). record Cone : Set (lo ⊔ la ⊔ la′ ⊔ lo′ ⊔ l≈′) where field Apex : Z.Obj arr : ∀ j → Apex Z.⇒ D.fobj j commute : ∀ {i j} (α : i J.⇒ j) → arr j Z.≈ D.fmap α Z.∘ arr i instance HasObj-Cone : HasObj Cone lo′ la′ l≈′ HasObj-Cone = record { Cat = Z ; _ᴼ = Cone.Apex } Obj = Cone record _⇒_ (A B : Obj) : Set (lo ⊔ la′ ⊔ l≈′) where private module A = Cone A ; module B = Cone B field θ : A.Apex Z.⇒ B.Apex commute : ∀ j → B.arr j Z.∘ θ Z.≈ A.arr j instance HasArrow-⇒ : ∀ {A B} → HasArrow (A ⇒ B) lo′ la′ l≈′ HasArrow-⇒ = record { Cat = Z ; _⃗ = _⇒_.θ } _≈_ : ∀ {A B} → Rel (A ⇒ B) l≈′ _≈_ = Z._≈_ Fun.on _⇒_.θ equiv : ∀ {A B} → IsEquivalence (_≈_ {A} {B}) equiv = Fun.on-isEquivalence _⇒_.θ Z.equiv id : ∀ {A} → A ⇒ A id = record { θ = Z.id ; commute = λ j → Z.id-r } _∘_ : ∀ {A B C} → B ⇒ C → A ⇒ B → A ⇒ C _∘_ {A} {B} {C} f g = record { θ = f ⃗ Z.∘ g ⃗ ; commute = λ j → begin arr C j Z.∘ f ⃗ Z.∘ g ⃗ ≈⟨ Z.unassoc ⟩ (arr C j Z.∘ f ⃗) Z.∘ g ⃗ ≈⟨ Z.∘-resp-l (commute f j) ⟩ arr B j Z.∘ g ⃗ ≈⟨ commute g j ⟩ arr A j ∎ } where open Cone using (arr) open _⇒_ using (commute) open Z.≈-Reasoning Cones : Category (lo ⊔ la ⊔ lo′ ⊔ la′ ⊔ l≈′) (lo ⊔ la′ ⊔ l≈′) l≈′ Cones = record { Obj = Obj ; _⇒_ = _⇒_ ; _≈_ = _≈_ ; id = id ; _∘_ = _∘_ ; equiv = equiv ; ∘-resp = Z.∘-resp ; id-r = Z.id-r ; id-l = Z.id-l ; assoc = Z.assoc } open Iso.Build Cones using (_≅_) open Iso.Build Z using () renaming (_≅_ to _≅Z_) cone-iso→obj-iso : ∀ {c d : Cone} → c ≅ d → c ᴼ ≅Z d ᴼ cone-iso→obj-iso i = record { forth = forth i ⃗ ; back = back i ⃗ ; back-forth = back-forth i ; forth-back = forth-back i } where open _≅_ apFunctor : ∀ {lo la l≈ lo′ la′ l≈′ lo″ la″ l≈″} → {Y : Category lo la l≈} → {Z : Category lo′ la′ l≈′} → (F : Functor Y Z) → {J : Category lo″ la″ l≈″} → {D : Functor J Y} → Cone D → Cone (F ∘F D) apFunctor {Y = Y} {Z} F {J} {D} c = record { Apex = fobj F Apex ; arr = λ j → fmap F (arr j) ; commute = λ {i} {j} α → Z.≈.sym ( begin fmap (F ∘F D) α Z.∘ fmap F (arr i) ≡⟨ ≡.refl ⟩ fmap F (fmap D α) Z.∘ fmap F (arr i) ≈⟨ fmap-∘ F ⟩ fmap F (fmap D α Y.∘ arr i) ≈⟨ fmap-resp F (Y.≈.sym (commute α)) ⟩ fmap F (arr j) ∎ ) } where module Y = Category Y module Z = Category Z open Cone c open Z.≈-Reasoning open Functor
{ "alphanum_fraction": 0.4879465582, "avg_line_length": 21.9299363057, "ext": "agda", "hexsha": "561887bedc1a53b1b0be83b7444c62ddf41e0de1", "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": "a3b69911c4c6ec380ddf6a0f4510d3a755734b86", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "alessio-b-zak/cats", "max_forks_repo_path": "Cats/Category/Cones.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "a3b69911c4c6ec380ddf6a0f4510d3a755734b86", "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": "alessio-b-zak/cats", "max_issues_repo_path": "Cats/Category/Cones.agda", "max_line_length": 76, "max_stars_count": null, "max_stars_repo_head_hexsha": "a3b69911c4c6ec380ddf6a0f4510d3a755734b86", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "alessio-b-zak/cats", "max_stars_repo_path": "Cats/Category/Cones.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1437, "size": 3443 }
{-# OPTIONS --without-K --safe #-} module Dodo.Nullary.Disjoint where -- Stdlib imports open import Level using (Level) open import Data.Product using (_×_) open import Relation.Nullary using (¬_) -- # Definitions Disjoint : ∀ {a b : Level} (A : Set a) (B : Set b) → Set _ Disjoint A B = ¬ (A × B)
{ "alphanum_fraction": 0.6534653465, "avg_line_length": 20.2, "ext": "agda", "hexsha": "d5bd06c7c5acc5f94ddac09ccd4fe67d5801f8db", "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": "376f0ccee1e1aa31470890e494bcb534324f598a", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "sourcedennis/agda-dodo", "max_forks_repo_path": "src/Dodo/Nullary/Disjoint.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "376f0ccee1e1aa31470890e494bcb534324f598a", "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": "sourcedennis/agda-dodo", "max_issues_repo_path": "src/Dodo/Nullary/Disjoint.agda", "max_line_length": 58, "max_stars_count": null, "max_stars_repo_head_hexsha": "376f0ccee1e1aa31470890e494bcb534324f598a", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "sourcedennis/agda-dodo", "max_stars_repo_path": "src/Dodo/Nullary/Disjoint.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 87, "size": 303 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Properties related to Linked ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} module Data.List.Relation.Unary.Linked.Properties where open import Data.List hiding (any) open import Data.List.Relation.Unary.AllPairs as AllPairs using (AllPairs; []; _∷_) open import Data.List.Relation.Unary.All using (All; []; _∷_) open import Data.List.Relation.Unary.Linked as Linked using (Linked; []; [-]; _∷_) open import Data.Fin.Base using (Fin) open import Data.Fin.Properties using (suc-injective) open import Data.Nat.Base using (zero; suc; _<_; z≤n; s≤s) open import Data.Nat.Properties using (≤-refl; ≤-pred; ≤-step) open import Level using (Level) open import Function using (_∘_; flip) open import Relation.Binary using (Rel; Transitive; DecSetoid) open import Relation.Binary.PropositionalEquality using (_≢_) open import Relation.Unary using (Pred; Decidable) open import Relation.Nullary using (yes; no) private variable a b p ℓ : Level A : Set a B : Set b ------------------------------------------------------------------------ -- Relationship to other predicates ------------------------------------------------------------------------ module _ {R : Rel A ℓ} where AllPairs⇒Linked : ∀ {xs} → AllPairs R xs → Linked R xs AllPairs⇒Linked [] = [] AllPairs⇒Linked (px ∷ []) = [-] AllPairs⇒Linked ((px ∷ _) ∷ py ∷ pxs) = px ∷ (AllPairs⇒Linked (py ∷ pxs)) module _ {R : Rel A ℓ} (trans : Transitive R) where Linked⇒All : ∀ {v x xs} → R v x → Linked R (x ∷ xs) → All (R v) (x ∷ xs) Linked⇒All Rvx [-] = Rvx ∷ [] Linked⇒All Rvx (Rxy ∷ Rxs) = Rvx ∷ Linked⇒All (trans Rvx Rxy) Rxs Linked⇒AllPairs : ∀ {xs} → Linked R xs → AllPairs R xs Linked⇒AllPairs [] = [] Linked⇒AllPairs [-] = [] ∷ [] Linked⇒AllPairs (Rxy ∷ Rxs) = Linked⇒All Rxy Rxs ∷ Linked⇒AllPairs Rxs ------------------------------------------------------------------------ -- Introduction (⁺) and elimination (⁻) rules for list operations ------------------------------------------------------------------------ -- map module _ {R : Rel A ℓ} {f : B → A} where map⁺ : ∀ {xs} → Linked (λ x y → R (f x) (f y)) xs → Linked R (map f xs) map⁺ [] = [] map⁺ [-] = [-] map⁺ (Rxy ∷ Rxs) = Rxy ∷ map⁺ Rxs ------------------------------------------------------------------------ -- applyUpTo module _ {R : Rel A ℓ} where applyUpTo⁺₁ : ∀ f n → (∀ {i} → suc i < n → R (f i) (f (suc i))) → Linked R (applyUpTo f n) applyUpTo⁺₁ f zero Rf = [] applyUpTo⁺₁ f (suc zero) Rf = [-] applyUpTo⁺₁ f (suc (suc n)) Rf = Rf (s≤s (s≤s z≤n)) ∷ (applyUpTo⁺₁ (f ∘ suc) (suc n) (Rf ∘ s≤s)) applyUpTo⁺₂ : ∀ f n → (∀ i → R (f i) (f (suc i))) → Linked R (applyUpTo f n) applyUpTo⁺₂ f n Rf = applyUpTo⁺₁ f n (λ _ → Rf _) ------------------------------------------------------------------------ -- applyDownFrom module _ {R : Rel A ℓ} where applyDownFrom⁺₁ : ∀ f n → (∀ {i} → suc i < n → R (f (suc i)) (f i)) → Linked R (applyDownFrom f n) applyDownFrom⁺₁ f zero Rf = [] applyDownFrom⁺₁ f (suc zero) Rf = [-] applyDownFrom⁺₁ f (suc (suc n)) Rf = Rf ≤-refl ∷ applyDownFrom⁺₁ f (suc n) (Rf ∘ ≤-step) applyDownFrom⁺₂ : ∀ f n → (∀ i → R (f (suc i)) (f i)) → Linked R (applyDownFrom f n) applyDownFrom⁺₂ f n Rf = applyDownFrom⁺₁ f n (λ _ → Rf _)
{ "alphanum_fraction": 0.4842801986, "avg_line_length": 35.5490196078, "ext": "agda", "hexsha": "f90ad7b1ff5013f535f44608818385f985da2063", "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/List/Relation/Unary/Linked/Properties.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "DreamLinuxer/popl21-artifact", "max_issues_repo_path": "agda-stdlib/src/Data/List/Relation/Unary/Linked/Properties.agda", "max_line_length": 72, "max_stars_count": 5, "max_stars_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "DreamLinuxer/popl21-artifact", "max_stars_repo_path": "agda-stdlib/src/Data/List/Relation/Unary/Linked/Properties.agda", "max_stars_repo_stars_event_max_datetime": "2020-10-10T21:41:32.000Z", "max_stars_repo_stars_event_min_datetime": "2020-10-07T12:07:53.000Z", "num_tokens": 1153, "size": 3626 }
{-# OPTIONS --without-K --rewriting #-} open import HoTT open import groups.Cokernel {- K ↑ ╎ ψ₁ q[_] ╎ ψ₂ Coker ψ₂ ↞--- G ←------ L ↑ ↑ φ₁ ╎ ╎ inject ↑ ↑ H ↞------- Ker ψ₁ φ₂ Then, H ≃ᴳ Ker/Im. -} module groups.KernelImageUniqueFactorization {i j k l} {G : Group i} {H : Group j} {K : Group k} {L : Group l} (ψ₁ : G →ᴳ K) (ψ₂ : L →ᴳ G) (G-ab : is-abelian G) (φ₁ : Ker ψ₁ →ᴳ H) (φ₁-is-surj : is-surjᴳ φ₁) (φ₂ : H →ᴳ Coker ψ₂ G-ab) (φ₂-is-inj : is-injᴳ φ₂) (φ-comm : ∀ ker → GroupHom.f (φ₂ ∘ᴳ φ₁) ker == q[ fst ker ]) where private module G = Group G module H = Group H module K = Group K module L = Group L module ψ₁ = GroupHom ψ₁ module ψ₂ = GroupHom ψ₂ module φ₁ = GroupHom φ₁ module φ₂ = GroupHom φ₂ φ₂' : H →ᴳ QuotGroup (im-npropᴳ ψ₂ G-ab) φ₂' = GroupIso.f-hom (Coker-β ψ₂ G-ab) ∘ᴳ φ₂ abstract φ₂'-is-inj : is-injᴳ φ₂' φ₂'-is-inj = ∘-is-inj (–>-is-inj (GroupIso.f-equiv (Coker-β ψ₂ G-ab))) φ₂-is-inj open import groups.PropQuotUniqueFactorization (ker-propᴳ ψ₁) (im-npropᴳ ψ₂ G-ab) φ₁ φ₁-is-surj φ₂' φ₂'-is-inj φ-comm open import groups.KernelImage ψ₁ ψ₂ G-ab H-iso-Ker/Im : H ≃ᴳ Ker/Im H-iso-Ker/Im = Ker/Im-β ⁻¹ᴳ ∘eᴳ H-iso-P/Q
{ "alphanum_fraction": 0.5276344878, "avg_line_length": 26.0961538462, "ext": "agda", "hexsha": "266e4722edd6c75da566d63f74a1f0d3e555b2bf", "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": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "timjb/HoTT-Agda", "max_forks_repo_path": "theorems/groups/KernelImageUniqueFactorization.agda", "max_issues_count": 31, "max_issues_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "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": "timjb/HoTT-Agda", "max_issues_repo_path": "theorems/groups/KernelImageUniqueFactorization.agda", "max_line_length": 86, "max_stars_count": 294, "max_stars_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "timjb/HoTT-Agda", "max_stars_repo_path": "theorems/groups/KernelImageUniqueFactorization.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": 594, "size": 1357 }
{-# OPTIONS --experimental-irrelevance #-} --{-# OPTIONS -v tc.lhs.unify:65 -v tc.irr:50 #-} open import Agda.Builtin.Bool open import Agda.Builtin.Equality data D : ..(b : Bool) → Set where c : (b : Bool) → D b test : ..(a : Bool) → D a → Bool test a (c b) = b data ⊥ : Set where record ⊤ : Set where constructor tt case_of_ : ∀ {a b} {A : Set a} {B : Set b} → A → (A → B) → B case x of f = f x -- Not so shape-irrelevant type! T : ..(n : Bool) → Set T n = case test n (c _) of λ where true → ⊤ false → ⊥ data Foo : Set where foo : .(b : Bool) → T b → Foo bad : (b : ⊥) → foo true tt ≡ foo false b → ⊥ bad b _ = b jackpot : ⊥ jackpot = bad _ refl
{ "alphanum_fraction": 0.5530973451, "avg_line_length": 21.1875, "ext": "agda", "hexsha": "020d8cacb1e7094e770d77ee7a34616898b6bfd8", "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/Issue2640.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/Issue2640.agda", "max_line_length": 60, "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/Issue2640.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": 258, "size": 678 }
module Numeral.Natural.Combinatorics where open import Numeral.Natural open import Numeral.Natural.Oper -- Counting combinations. -- `𝑐𝐶 n k` is the number of ways one can pick `k` number of distinct objects from a set of `n` number of distinct objects. -- Equivalently, it is the number of `k`-sized subsets of an `n`-sized set. -- Also called: Binomial coefficients -- Formulated using sets: -- 𝐶: Set → ℕ → Set -- 𝐶 S k = {(K∊℘(S)). #K = k} -- 𝑐𝐶(n) = #𝐶(𝕟(n)) 𝑐𝐶 : ℕ → ℕ → ℕ 𝑐𝐶 _ 𝟎 = 𝐒 𝟎 𝑐𝐶 𝟎 (𝐒 k) = 𝟎 𝑐𝐶 (𝐒 n) (𝐒 k) = 𝑐𝐶 n k + 𝑐𝐶 n (𝐒 k) -- Counting partial permutations. -- `𝑐𝑃 n k` is the number of arrangements for a list of `n` number of distinct objects into `k` number of objects. -- Equivalently, it is the number of injective functions (function equality by the standard function extensionality) of type `𝕟(k) → 𝕟(n)`. -- Also called: Falling factorial -- Formulated using sets: -- 𝑃: Set → ℕ → Set -- 𝑃 S k = {(π: 𝕟(k) → S). Injective(π)} -- 𝑐𝑃(n) = #𝑃(𝕟(n)) 𝑐𝑃 : ℕ → ℕ → ℕ 𝑐𝑃 _ 𝟎 = 𝐒 𝟎 𝑐𝑃 𝟎 (𝐒 k) = 𝟎 𝑐𝑃 (𝐒 n) (𝐒 k) = 𝑐𝑃 n k ⋅ (𝐒 n) -- Counting derangements. -- `𝑐𝐷(n)` is the number of permutations of a list of `n` number of distinct objects such that in every permutation, no object is permuted with itself. -- Formulated using sets: -- 𝐷: Set → Set -- 𝐷(S) = {(π∊𝑃(S)). ∀(s∊S). π(s) ≠ s} -- 𝑐𝐷(n) = #𝐷(𝕟(n)) 𝑐𝐷 : ℕ → ℕ 𝑐𝐷(𝟎) = 𝐒 𝟎 𝑐𝐷(𝐒 𝟎) = 𝟎 𝑐𝐷(𝐒(𝐒 n)) = 𝐒(n) ⋅ (𝑐𝐷 (𝐒 n) + 𝑐𝐷 n) -- Stirling numbers of the first kind. stir₁ : ℕ → ℕ → ℕ stir₁ 𝟎 𝟎 = 𝐒(𝟎) stir₁ (𝐒(n)) 𝟎 = 𝟎 stir₁ 𝟎 (𝐒(k)) = 𝟎 stir₁ (𝐒(n)) (𝐒(k)) = (n ⋅ stir₁ n (𝐒(k))) + stir₁ n k -- Stirling numbers of the second kind. stir₂ : ℕ → ℕ → ℕ stir₂ 𝟎 𝟎 = 𝐒(𝟎) stir₂ (𝐒(n)) 𝟎 = 𝟎 stir₂ 𝟎 (𝐒(k)) = 𝟎 stir₂ (𝐒(n)) (𝐒(k)) = (𝐒(k) ⋅ stir₂ n (𝐒(k))) + stir₂ n k -- Counting injective functions. 𝑐𝐼𝑛𝑗 : ℕ → ℕ → ℕ 𝑐𝐼𝑛𝑗 = 𝑐𝑃 -- Counting surjective functions. 𝑐𝑆𝑢𝑟𝑗 : ℕ → ℕ → ℕ 𝑐𝑆𝑢𝑟𝑗 a b = stir₂ a b ⋅ (b !)
{ "alphanum_fraction": 0.5805962607, "avg_line_length": 30.921875, "ext": "agda", "hexsha": "52b33ebf1469336fa71f9d562cac132658ad6985", "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": "Numeral/Natural/Combinatorics.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": "Numeral/Natural/Combinatorics.agda", "max_line_length": 151, "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": "Numeral/Natural/Combinatorics.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": 1037, "size": 1979 }
------------------------------------------------------------------------------ -- The LTC-PCF base ------------------------------------------------------------------------------ {-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} {- LTC-PCF The logical framework (Agda) * Logical constants * Curry-Howard isomorphism * Equality * Identity type * Term language and conversion rules * Postulates * Inductively defined predicates * Inductive families -} module LTC-PCF.Base where -- First-order logic with equality. open import Common.FOL.FOL-Eq public -- Common definitions. open import Common.DefinitionsI public infixl 7 _·_ infix 0 if_then_else_ ------------------------------------------------------------------------------ -- The term language of LTC-PCF correspond to the PCF terms. -- t ::= x -- | t · t -- | λ x.t -- | fix x.t -- | true | false | if -- | zero | succ | pred | iszero -- NB. We define the PCF terms as constants. After that, we will -- define some function symbols based on these constants for -- convenience in writing. postulate _·_ : D → D → D -- LTC-PCF application. lam : (D → D) → D -- LTC-PCF λ-abstraction. fix : (D → D) → D -- LTC-PCF fixed-point operator. true false if : D -- LTC-PCF partial Booleans. zero succ pred iszero : D -- LTC-PCF partial natural numbers. ------------------------------------------------------------------------------ -- Definitions -- We define some function symbols for convenience in writing. abstract if_then_else_ : D → D → D → D if b then t else t' = if · b · t · t' succ₁ : D → D succ₁ n = succ · n pred₁ : D → D pred₁ n = pred · n iszero₁ : D → D iszero₁ n = iszero · n ------------------------------------------------------------------------------ -- Conversion rules -- The conversion relation _conv_ satifies (Aczel 1977. The strength -- of Martin-Löf's intuitionistic type theory with one universe, -- p. 8). -- -- x conv y <=> FOTC ⊢ x ≡ y, -- -- therefore, we introduce the conversion rules as non-logical axioms. -- N.B. We write the conversion rules on the defined function symbols -- instead of on the PCF constants. -- Conversion rule for the λ-abstraction and the application. postulate beta : ∀ f a → lam f · a ≡ f a -- Conversion rule for the fixed-pointed operator. postulate fix-eq : ∀ f → fix f ≡ f (fix f) -- Conversion rules for Booleans. postulate -- if-true : ∀ t {t'} → if · true · t · t' ≡ t -- if-false : ∀ {t} t' → if · false · t · t' ≡ t' if-true : ∀ t {t'} → (if true then t else t') ≡ t if-false : ∀ {t} t' → (if false then t else t') ≡ t' -- Conversion rules for pred. postulate -- pred-0 : pred · zero ≡ zero -- pred-S : ∀ d → pred · (succ · d) ≡ d -- N.B. We don't need this equation in FOTC. pred-0 : pred₁ zero ≡ zero pred-S : ∀ n → pred₁ (succ₁ n) ≡ n -- Conversion rules for iszero. postulate -- iszero-0 : iszero · zero ≡ true -- iszero-S : ∀ d → iszero · (succ · d) ≡ false iszero-0 : iszero₁ zero ≡ true iszero-S : ∀ n → iszero₁ (succ₁ n) ≡ false ------------------------------------------------------------------------------ -- Discrimination rules postulate t≢f : true ≢ false -- 0≢S : ∀ {d} → zero ≢ succ · d 0≢S : ∀ {n} → zero ≢ succ₁ n
{ "alphanum_fraction": 0.5027901786, "avg_line_length": 30.3728813559, "ext": "agda", "hexsha": "09830f3db8af316531b6a46ee22e63c5cda6b0d3", "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/LTC-PCF/Base.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/LTC-PCF/Base.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/LTC-PCF/Base.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": 961, "size": 3584 }
open import Data.Product using ( proj₁ ; proj₂ ) open import Data.Sum using ( _⊎_ ; inj₁ ; inj₂ ) open import Relation.Binary.PropositionalEquality using ( refl ) open import Web.Semantic.DL.ABox.Interp using ( ⌊_⌋ ; ind ; _*_ ) open import Web.Semantic.DL.ABox.Interp.Morphism using ( _,_ ) open import Web.Semantic.DL.ABox.Model using ( _⊨a_ ; on-bnode ; bnodes ; _,_ ; ⊨a-resp-≲ ) open import Web.Semantic.DL.Category.Composition using ( _∙_ ) open import Web.Semantic.DL.Category.Properties.Composition.Lemmas using ( compose-left ; compose-right ; compose-resp-⊨a ) open import Web.Semantic.DL.Category.Properties.Tensor.Lemmas using ( tensor-up ; tensor-down ; tensor-resp-⊨a ) open import Web.Semantic.DL.Category.Object using ( Object ; IN ; fin ) open import Web.Semantic.DL.Category.Morphism using ( _⇒_ ; BN ; impl ; _⊑_ ; _≣_ ; _,_ ) open import Web.Semantic.DL.Category.Tensor using ( _⊗_ ; _⟨⊗⟩_ ) open import Web.Semantic.DL.Category.Unit using ( I ) open import Web.Semantic.DL.Category.Wiring using ( wires-≈ ; wires-≈⁻¹ ; symm ) open import Web.Semantic.DL.Signature using ( Signature ) open import Web.Semantic.DL.TBox using ( TBox ) open import Web.Semantic.DL.TBox.Interp using ( Δ ; _⊨_≈_ ; ≈-refl ; ≈-sym ) open import Web.Semantic.DL.TBox.Interp.Morphism using ( ≲-refl ) open import Web.Semantic.Util using ( _∘_ ; False ; ⊎-swap ; _⊕_⊕_ ; inode ; bnode ; enode ; left ; right ; up ; down ) module Web.Semantic.DL.Category.Properties.Tensor.SymmNatural {Σ : Signature} {S T : TBox Σ} where symm-natural : ∀ {A₁ A₂ B₁ B₂ : Object S T} (F₁ : A₁ ⇒ B₁) (F₂ : A₂ ⇒ B₂) → ((F₁ ⟨⊗⟩ F₂) ∙ symm B₁ B₂ ≣ symm A₁ A₂ ∙ (F₂ ⟨⊗⟩ F₁)) symm-natural {A₁} {A₂} {B₁} {B₂} F₁ F₂ = (LHS⊑RHS , RHS⊑LHS) where LHS⊑RHS : (F₁ ⟨⊗⟩ F₂) ∙ symm B₁ B₂ ⊑ symm A₁ A₂ ∙ (F₂ ⟨⊗⟩ F₁) LHS⊑RHS J J⊨STA J⊨LHS = (f , J⊨RHS) where f : False ⊕ (IN A₂ ⊎ IN A₁) ⊕ (BN F₂ ⊎ BN F₁) → Δ ⌊ J ⌋ f (inode ()) f (bnode (inj₁ x)) = ind J (inode (inj₂ x)) f (bnode (inj₂ x)) = ind J (inode (inj₁ x)) f (enode (inj₁ v)) = ind J (bnode (inode (inj₂ v))) f (enode (inj₂ v)) = ind J (bnode (inode (inj₁ v))) lemma₀ : ∀ x → ⌊ J ⌋ ⊨ ind J (inode (⊎-swap x)) ≈ f (bnode x) lemma₀ (inj₁ x) = ≈-refl ⌊ J ⌋ lemma₀ (inj₂ y) = ≈-refl ⌊ J ⌋ lemma₁ : ∀ x → ⌊ J ⌋ ⊨ ind J (left (up x)) ≈ on-bnode f (ind J) (right (down x)) lemma₁ (inode x) = ≈-refl ⌊ J ⌋ lemma₁ (bnode v) = ≈-refl ⌊ J ⌋ lemma₁ (enode y) = wires-≈ ⊎-swap (proj₂ (fin (B₂ ⊗ B₁)) (inj₂ y)) (compose-right (F₁ ⟨⊗⟩ F₂) (symm B₁ B₂) J J⊨LHS) lemma₂ : ∀ x → ⌊ J ⌋ ⊨ ind J (left (down x)) ≈ on-bnode f (ind J) (right (up x)) lemma₂ (inode x) = ≈-refl ⌊ J ⌋ lemma₂ (bnode v) = ≈-refl ⌊ J ⌋ lemma₂ (enode y) = wires-≈ ⊎-swap (proj₂ (fin (B₂ ⊗ B₁)) (inj₁ y)) (compose-right (F₁ ⟨⊗⟩ F₂) (symm B₁ B₂) J J⊨LHS) J⊨RHS : bnodes J f ⊨a impl (symm A₁ A₂ ∙ (F₂ ⟨⊗⟩ F₁)) J⊨RHS = compose-resp-⊨a (symm A₁ A₂) (F₂ ⟨⊗⟩ F₁) (bnodes J f) (wires-≈⁻¹ ⊎-swap lemma₀ (proj₁ (fin (A₂ ⊗ A₁)))) (tensor-resp-⊨a F₂ F₁ (right * bnodes J f) (⊨a-resp-≲ (≲-refl ⌊ J ⌋ , lemma₂) (impl F₂) (tensor-down F₁ F₂ (left * J) (compose-left (F₁ ⟨⊗⟩ F₂) (symm B₁ B₂) J J⊨LHS))) (⊨a-resp-≲ (≲-refl ⌊ J ⌋ , lemma₁) (impl F₁) (tensor-up F₁ F₂ (left * J) (compose-left (F₁ ⟨⊗⟩ F₂) (symm B₁ B₂) J J⊨LHS)))) RHS⊑LHS : symm A₁ A₂ ∙ (F₂ ⟨⊗⟩ F₁) ⊑ (F₁ ⟨⊗⟩ F₂) ∙ symm B₁ B₂ RHS⊑LHS J J⊨STA J⊨RHS = (f , J⊨LHS) where f : ((BN F₁ ⊎ BN F₂) ⊕ (IN B₁ ⊎ IN B₂) ⊕ False) → Δ ⌊ J ⌋ f (inode (inj₁ v)) = ind J (bnode (enode (inj₂ v))) f (inode (inj₂ v)) = ind J (bnode (enode (inj₁ v))) f (bnode (inj₁ y)) = ind J (enode (inj₂ y)) f (bnode (inj₂ y)) = ind J (enode (inj₁ y)) f (enode ()) lemma₀ : ∀ x → ⌊ J ⌋ ⊨ f (bnode (⊎-swap x)) ≈ ind J (enode x) lemma₀ (inj₁ y) = ≈-refl ⌊ J ⌋ lemma₀ (inj₂ y) = ≈-refl ⌊ J ⌋ lemma₁ : ∀ x → ⌊ J ⌋ ⊨ ind J (right (down x)) ≈ on-bnode f (ind J) (left (up x)) lemma₁ (inode x) = ≈-sym ⌊ J ⌋ (wires-≈ ⊎-swap (proj₂ (fin (A₂ ⊗ A₁)) (inj₂ x)) (compose-left (symm A₁ A₂) (F₂ ⟨⊗⟩ F₁) J J⊨RHS)) lemma₁ (bnode v) = ≈-refl ⌊ J ⌋ lemma₁ (enode y) = ≈-refl ⌊ J ⌋ lemma₂ : ∀ x → ⌊ J ⌋ ⊨ ind J (right (up x)) ≈ on-bnode f (ind J) (left (down x)) lemma₂ (inode x) = ≈-sym ⌊ J ⌋ (wires-≈ ⊎-swap (proj₂ (fin (A₂ ⊗ A₁)) (inj₁ x)) (compose-left (symm A₁ A₂) (F₂ ⟨⊗⟩ F₁) J J⊨RHS)) lemma₂ (bnode v) = ≈-refl ⌊ J ⌋ lemma₂ (enode y) = ≈-refl ⌊ J ⌋ J⊨LHS : bnodes J f ⊨a impl ((F₁ ⟨⊗⟩ F₂) ∙ symm B₁ B₂) J⊨LHS = compose-resp-⊨a (F₁ ⟨⊗⟩ F₂) (symm B₁ B₂) (bnodes J f) (tensor-resp-⊨a F₁ F₂ (left * bnodes J f) (⊨a-resp-≲ (≲-refl ⌊ J ⌋ , lemma₁) (impl F₁) (tensor-down F₂ F₁ (right * J) (compose-right (symm A₁ A₂) (F₂ ⟨⊗⟩ F₁) J J⊨RHS))) (⊨a-resp-≲ (≲-refl ⌊ J ⌋ , lemma₂) (impl F₂) (tensor-up F₂ F₁ (right * J) (compose-right (symm A₁ A₂) (F₂ ⟨⊗⟩ F₁) J J⊨RHS)))) (wires-≈⁻¹ ⊎-swap lemma₀ (proj₁ (fin (B₂ ⊗ B₁))))
{ "alphanum_fraction": 0.5494505495, "avg_line_length": 44.701754386, "ext": "agda", "hexsha": "fc2722e1c16622617635bf186fc33d7f23716c0c", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:40:03.000Z", "max_forks_repo_forks_event_min_datetime": "2017-12-03T14:52:09.000Z", "max_forks_repo_head_hexsha": "8ddbe83965a616bff6fc7a237191fa261fa78bab", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "agda/agda-web-semantic", "max_forks_repo_path": "src/Web/Semantic/DL/Category/Properties/Tensor/SymmNatural.agda", "max_issues_count": 4, "max_issues_repo_head_hexsha": "8ddbe83965a616bff6fc7a237191fa261fa78bab", "max_issues_repo_issues_event_max_datetime": "2021-01-04T20:57:19.000Z", "max_issues_repo_issues_event_min_datetime": "2018-11-14T02:32:28.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "agda/agda-web-semantic", "max_issues_repo_path": "src/Web/Semantic/DL/Category/Properties/Tensor/SymmNatural.agda", "max_line_length": 76, "max_stars_count": 9, "max_stars_repo_head_hexsha": "8ddbe83965a616bff6fc7a237191fa261fa78bab", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "agda/agda-web-semantic", "max_stars_repo_path": "src/Web/Semantic/DL/Category/Properties/Tensor/SymmNatural.agda", "max_stars_repo_stars_event_max_datetime": "2020-03-14T14:21:08.000Z", "max_stars_repo_stars_event_min_datetime": "2015-09-13T17:46:41.000Z", "num_tokens": 2456, "size": 5096 }
-- Andreas, 2017-04-26 -- Allow more flexible size assignment. module _ where open import Agda.Builtin.Size module ZeroZero where data Nat : Size → Set where zero : ∀{i} → Nat i -- does not have to be ↑ i suc : ∀{i} → Nat i → Nat (↑ i) mon : ∀{i}{j : Size< i} → Nat j → Nat i mon x = x minus : ∀{i} → Nat i → Nat ∞ → Nat i minus x zero = x minus zero (suc y) = zero minus (suc x) (suc y) = minus x y div : ∀{i} → Nat i → Nat ∞ → Nat i div zero y = zero div (suc x) y = suc (div (minus x y) y) module DSuc where -- Here, the upper least bound for the size is the number itself. data Nat : Size → Set where zero : ∀{i} → Nat i suc : ∀{i} → Nat i → Nat (↑ i) dsuc : ∀{i} → Nat i → Nat (↑ ↑ i) -- Testing subtyping. mon : ∀{i}{j : Size< i} → Nat j → Nat i mon x = x minus : ∀{i} → Nat i → Nat ∞ → Nat i minus x zero = x minus zero y = zero minus (suc x) (suc y) = minus x y minus (suc x) (dsuc y) = minus x (suc y) minus (dsuc x) (suc y) = minus (suc x) y minus (dsuc x) (dsuc y) = minus x y div : ∀{i} → Nat i → Nat ∞ → Nat i div zero y = zero div (suc x) y = suc (div (minus x y) y) div (dsuc x) y = suc (div (minus (suc x) y) y)
{ "alphanum_fraction": 0.5152701644, "avg_line_length": 24.5576923077, "ext": "agda", "hexsha": "e579b51517dc3976b16b2f45bb3ff6bbd04f6b74", "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/Issue2554-size-plus2.agda", "max_issues_count": 3, "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "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": "shlevy/agda", "max_issues_repo_path": "test/Succeed/Issue2554-size-plus2.agda", "max_line_length": 67, "max_stars_count": 2, "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/Issue2554-size-plus2.agda", "max_stars_repo_stars_event_max_datetime": "2020-09-20T00:28:57.000Z", "max_stars_repo_stars_event_min_datetime": "2019-10-29T09:40:30.000Z", "num_tokens": 501, "size": 1277 }
{-# OPTIONS --without-K #-} open import HoTT import homotopy.HopfConstruction open import homotopy.CircleHSpace open import homotopy.SuspensionJoin using () renaming (e to suspension-join) import homotopy.JoinAssocCubical module homotopy.Hopf where module Hopf = homotopy.HopfConstruction S¹ S¹-connected S¹-hSpace Hopf : S² → Type₀ Hopf = Hopf.H.f Hopf-fiber : Hopf north == S¹ Hopf-fiber = idp Hopf-total : Σ _ Hopf == S³ Hopf-total = Σ _ Hopf =⟨ Hopf.theorem ⟩ S¹ * S¹ =⟨ ua (suspension-join S⁰) |in-ctx (λ u → u * S¹) ⟩ (S⁰ * S⁰) * S¹ =⟨ homotopy.JoinAssocCubical.*-assoc ⟩ S⁰ * (S⁰ * S¹) =⟨ ! (ua (suspension-join S¹)) |in-ctx (λ u → S⁰ * u) ⟩ S⁰ * S² =⟨ ! (ua (suspension-join S²)) ⟩ S³ ∎
{ "alphanum_fraction": 0.6548431105, "avg_line_length": 27.1481481481, "ext": "agda", "hexsha": "cd790779eb58a648a91a6b927d4d0c62735139bb", "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": "bc849346a17b33e2679a5b3f2b8efbe7835dc4b6", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cmknapp/HoTT-Agda", "max_forks_repo_path": "theorems/homotopy/Hopf.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "bc849346a17b33e2679a5b3f2b8efbe7835dc4b6", "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": "cmknapp/HoTT-Agda", "max_issues_repo_path": "theorems/homotopy/Hopf.agda", "max_line_length": 76, "max_stars_count": null, "max_stars_repo_head_hexsha": "bc849346a17b33e2679a5b3f2b8efbe7835dc4b6", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cmknapp/HoTT-Agda", "max_stars_repo_path": "theorems/homotopy/Hopf.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 303, "size": 733 }
data Nat : Set where zero : Nat suc : Nat → Nat {-# BUILTIN NATURAL Nat #-} data _≡_ {A : Set} (x : A) : A → Set where refl : x ≡ x pred : Nat → Nat pred zero = zero pred (suc n) = n {-# NON_TERMINATING #-} loop : Nat → Nat loop zero = zero loop n = loop (pred n) -- Non-terminating functions reduce when evaluated at top-level, -- but not in a hole. hole : Set hole = {!!}
{ "alphanum_fraction": 0.6020671835, "avg_line_length": 16.125, "ext": "agda", "hexsha": "78436ee5e704c4d8e68738bb981898ff760c9a63", "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/NonTerminatingReduce.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/NonTerminatingReduce.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/interaction/NonTerminatingReduce.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": 128, "size": 387 }
module z01-fp-with-booleans where open import bool {- data 𝔹 : Set where tt : 𝔹 ff : 𝔹 ˜_ : 𝔹 → 𝔹 ˜ tt = ff ˜ ff = tt if_then_else_ : ∀ {ℓ} {A : Set ℓ} → 𝔹 → A → A → A if tt then t else f = t if ff then t else f = f -} -- load / type-check file -- C-c, C-l -- check type of expression -- C-c, C-d ; then prompt for expression ------------------------------------------------------------------------------ -- p 24 1.8 Exercises z01-1-8-01a : 𝔹 z01-1-8-01a = tt && (ff xor ~ ff) z01-1-8-01b : 𝔹 z01-1-8-01b = ~ tt && (ff imp ff) z01-1-8-01c : 𝔹 z01-1-8-01c = if tt xor tt then ff else ff -- 1-8-4 data day : Set where mon : day tue : day wed : day thu : day fri : day sat : day sun : day -- 1-8-5 nextday : day → day nextday mon = tue nextday tue = wed nextday wed = thu nextday thu = fri nextday fri = sat nextday sat = sun nextday sun = mon -- 1-8-6 data suit : Set where hearts : suit spades : suit diamonds : suit clubs : suit -- 1-8-7 is-red : suit → 𝔹 is-red hearts = tt is-red spades = ff is-red diamonds = tt is-red clubs = ff
{ "alphanum_fraction": 0.5467160037, "avg_line_length": 15.2253521127, "ext": "agda", "hexsha": "f4b3bcb5738d582892999a0b1b9f35755bcc4624", "lang": "Agda", "max_forks_count": 8, "max_forks_repo_forks_event_max_datetime": "2021-09-21T15:58:10.000Z", "max_forks_repo_forks_event_min_datetime": "2015-04-13T21:40:15.000Z", "max_forks_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_forks_repo_licenses": [ "Unlicense" ], "max_forks_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_forks_repo_path": "agda/book/2015-Verified_Functional_programming_in_Agda-Stump/ial/z01-fp-with-booleans.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "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": "haroldcarr/learn-haskell-coq-ml-etc", "max_issues_repo_path": "agda/book/2015-Verified_Functional_programming_in_Agda-Stump/ial/z01-fp-with-booleans.agda", "max_line_length": 78, "max_stars_count": 36, "max_stars_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_stars_repo_licenses": [ "Unlicense" ], "max_stars_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_stars_repo_path": "agda/book/2015-Verified_Functional_programming_in_Agda-Stump/ial/z01-fp-with-booleans.agda", "max_stars_repo_stars_event_max_datetime": "2021-07-30T06:55:03.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-29T14:37:15.000Z", "num_tokens": 436, "size": 1081 }
------------------------------------------------------------------------------ -- Propositional equality ------------------------------------------------------------------------------ {-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} -- This module is re-exported by (some) "base" modules. module Common.FOL.Relation.Binary.PropositionalEquality where open import Common.FOL.FOL using ( D ) infix 4 _≡_ ------------------------------------------------------------------------------ -- The identity type on the universe of discourse. data _≡_ (x : D) : D → Set where refl : x ≡ x -- Elimination rule. subst : (A : D → Set) → ∀ {x y} → x ≡ y → A x → A y subst A refl Ax = Ax -- Identity properties sym : ∀ {x y} → x ≡ y → y ≡ x sym refl = refl trans : ∀ {x y z} → x ≡ y → y ≡ z → x ≡ z trans refl h = h trans₂ : ∀ {w x y z} → w ≡ x → x ≡ y → y ≡ z → w ≡ z trans₂ refl refl h = h subst₂ : (A : D → D → Set) → ∀ {x x' y y'} → x ≡ y → x' ≡ y' → A x x' → A y y' subst₂ A refl refl Axs = Axs subst₃ : (A : D → D → D → Set) → ∀ {x₁ x₂ x₃ y₁ y₂ y₃} → x₁ ≡ y₁ → x₂ ≡ y₂ → x₃ ≡ y₃ → A x₁ x₂ x₃ → A y₁ y₂ y₃ subst₃ A refl refl refl Axs = Axs subst₄ : (A : D → D → D → D → Set) → ∀ {x₁ x₂ x₃ x₄ y₁ y₂ y₃ y₄} → x₁ ≡ y₁ → x₂ ≡ y₂ → x₃ ≡ y₃ → x₄ ≡ y₄ → A x₁ x₂ x₃ x₄ → A y₁ y₂ y₃ y₄ subst₄ A refl refl refl refl Axs = Axs
{ "alphanum_fraction": 0.4281967213, "avg_line_length": 27.7272727273, "ext": "agda", "hexsha": "dc1da6ee49fe5d10a624dc6567741de258045539", "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/Common/FOL/Relation/Binary/PropositionalEquality.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/Common/FOL/Relation/Binary/PropositionalEquality.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/Common/FOL/Relation/Binary/PropositionalEquality.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": 532, "size": 1525 }
-- Needs the --injective-type-constructors option enabled to type check. module InjectiveTypeConstructors where data D (A : Set) : Set where data _==_ (A : Set) : Set → Set where refl : A == A injD : ∀ {A B} → D A == D B → A == B injD refl = refl
{ "alphanum_fraction": 0.6388888889, "avg_line_length": 22.9090909091, "ext": "agda", "hexsha": "0d3710b7bbaa3b91729a65eb25da57631e035a7d", "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/InjectiveTypeConstructors.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/InjectiveTypeConstructors.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/Fail/InjectiveTypeConstructors.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": 84, "size": 252 }
module Cats.Category.Product.Binary.Facts where open import Cats.Category open import Cats.Category.Product.Binary using (_×_) open import Cats.Functor open import Cats.Util.Logic.Constructive using (_∧_ ; _,_ ; ∧-eliml ; ∧-elimr) module _ {lo la l≈ lo′ la′ l≈′} {C : Category lo la l≈} {D : Category lo′ la′ l≈′} where private module C = Category C module D = Category D module × = Category (C × D) open Category._≅_ iso-intro : ∀ {A A′ B B′} → A C.≅ A′ → B D.≅ B′ → (A , B) ×.≅ (A′ , B′) iso-intro f g = record { forth = forth f , forth g ; back = back f , back g ; back-forth = back-forth f , back-forth g ; forth-back = forth-back f , forth-back g } iso-elim : ∀ {A A′ B B′} → (A , B) ×.≅ (A′ , B′) → A C.≅ A′ ∧ B D.≅ B′ iso-elim f = record { forth = ∧-eliml (forth f) ; back = ∧-eliml (back f) ; back-forth = ∧-eliml (back-forth f) ; forth-back = ∧-eliml (forth-back f) } , record { forth = ∧-elimr (forth f) ; back = ∧-elimr (back f) ; back-forth = ∧-elimr (back-forth f) ; forth-back = ∧-elimr (forth-back f) }
{ "alphanum_fraction": 0.5375323555, "avg_line_length": 25.7555555556, "ext": "agda", "hexsha": "133546f0b464fc86c5aa69069e83402e1d71fbce", "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": "a3b69911c4c6ec380ddf6a0f4510d3a755734b86", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "alessio-b-zak/cats", "max_forks_repo_path": "Cats/Category/Product/Binary/Facts.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "a3b69911c4c6ec380ddf6a0f4510d3a755734b86", "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": "alessio-b-zak/cats", "max_issues_repo_path": "Cats/Category/Product/Binary/Facts.agda", "max_line_length": 78, "max_stars_count": null, "max_stars_repo_head_hexsha": "a3b69911c4c6ec380ddf6a0f4510d3a755734b86", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "alessio-b-zak/cats", "max_stars_repo_path": "Cats/Category/Product/Binary/Facts.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 419, "size": 1159 }
{- # --without-K # -} open import Data.Unit open import Data.Empty open import Data.Nat open import Data.Sum as Sum open import Data.Product open import Function open import Relation.Binary.PropositionalEquality open import Relation.Unary open import Relation.Binary open import Relation.Binary using (module IsEquivalence; Setoid; module Setoid) open ≡-Reasoning import Relation.Binary.HeterogeneousEquality as HE open import Relation.Binary.HeterogeneousEquality using (_≅_; refl) -- | Polynomials data Poly : Set₁ where _▹_ : (A : Set) (B : A → Set) → Poly -- | Interpretation of polynomials as functor, object part. ⟦_⟧ : Poly → Set → Set ⟦ A ▹ B ⟧ X = Σ[ a ∈ A ] (B a → X) -- | Interpretation of polynomials as functor, morphism part. ⟦_⟧₁ : (P : Poly) → ∀{X Y} → (X → Y) → (⟦ P ⟧ X → ⟦ P ⟧ Y) ⟦ A ▹ B ⟧₁ f (a , α) = (a , (λ x → f (α x))) -- | Finite trees over the signature determined by P with one free variable. data _* (P : Poly) : Set where sup : ⟦ P ⟧ (P *) ⊎ ⊤ → P * -- | Inverse of sup. sup⁻¹ : ∀{P} → P * → ⟦ P ⟧ (P *) ⊎ ⊤ sup⁻¹ (sup x) = x _extends_ : ∀{P} → P * → P * → Set _extends_ {A ▹ B} (sup (inj₁ (a' , β))) (sup (inj₁ (a , α))) = Σ[ e ∈ a' ≡ a ] (∀ (b : B a') → (β b) extends α (subst B e b)) sup (inj₂ _) extends sup (inj₁ _) = ⊥ sup (inj₁ x) extends sup (inj₂ _) = ⊤ sup (inj₂ _) extends sup (inj₂ _) = ⊥ PreApprox : Poly → Set PreApprox P = ℕ → P * converges : ∀{P} → PreApprox P → Set converges u = ∀ n → u (1 + n) extends u n non-empty : ∀{P} → P * → Set non-empty (sup (inj₁ x)) = ⊤ non-empty (sup (inj₂ _)) = ⊥ root : ∀{A B} → (t : (A ▹ B) *) → non-empty t → A root (sup (inj₁ x)) p = proj₁ x root (sup (inj₂ y)) () branch : ∀{A B} → (t : (A ▹ B) *) → (p : non-empty t) → B (root t p) → (A ▹ B) * branch (sup (inj₁ x)) p b = proj₂ x b branch (sup (inj₂ y)) () b _∞ : Poly → Set P ∞ = Σ[ u ∈ PreApprox P ] (non-empty (u 0) × converges u) -- | If u₀ is non-empty and u converges, then uₙ is non-empty for every n. ne₀→all-ne : ∀{P} → (u : PreApprox P) → non-empty (u 0) → converges u → ∀ n → non-empty (u n) ne₀→all-ne u ne₀ conv zero = ne₀ ne₀→all-ne {A ▹ B} u ne₀ conv (suc n) with u (suc n) | u n | conv n ... | sup (inj₁ x) | y | z = tt ... | sup (inj₂ x) | sup (inj₁ y) | () ... | sup (inj₂ x) | sup (inj₂ y) | () -- | If t₂ extends t₁ and they are both non-empty, then they have the same -- root labels. ext→root≡ : ∀{A B} → (t₁ t₂ : (A ▹ B) *) (ne₁ : non-empty t₁) (ne₂ : non-empty t₂) (e : t₂ extends t₁) → root t₁ ne₁ ≡ root t₂ ne₂ ext→root≡ (sup (inj₁ (a , α))) (sup (inj₁ (b , β))) ne₁ ne₂ e = sym (proj₁ e) ext→root≡ (sup (inj₁ x)) (sup (inj₂ tt)) ne₁ () e ext→root≡ (sup (inj₂ tt)) (sup (inj₁ y)) () ne₂ e ext→root≡ (sup (inj₂ tt)) (sup (inj₂ tt)) ne₁ ne₂ () -- | The roots of the first two trees in a converging sequence have the same -- label. This is used as base case in conv→suc-roots≡. conv→roots-0-1≡ : ∀{A B} → (u : PreApprox (A ▹ B)) (ne : non-empty (u 0)) (c : converges u) → root (u 0) ne ≡ root (u 1) (ne₀→all-ne u ne c 1) conv→roots-0-1≡ {A} {B} u ne c = ext→root≡ (u 0) (u 1) ne (ne₀→all-ne u ne c 1) (c 0) -- | The roots of two successive trees in a converging sequence have the same -- label. We use this in the induction step in conv→roots≡. conv→suc-roots≡ : ∀{A B} → (u : PreApprox (A ▹ B)) (ne : non-empty (u 0)) (c : converges u) → ∀ n → root (u n) (ne₀→all-ne u ne c n) ≡ root (u (1 + n)) (ne₀→all-ne u ne c (1 + n)) conv→suc-roots≡ u ne c zero = conv→roots-0-1≡ u ne c conv→suc-roots≡ u ne c (suc n) = ext→root≡ (u (1 + n)) (u (2 + n)) (ne₀→all-ne u ne c (1 + n)) (ne₀→all-ne u ne c (2 + n)) (c (suc n)) -- | The root of any tree in a converging sequence has the same label as -- the root of the first tree. conv→roots≡ : ∀{A B} → (u : PreApprox (A ▹ B)) (ne : non-empty (u 0)) (c : converges u) → ∀ n → root (u 0) ne ≡ root (u n) (ne₀→all-ne u ne c n) conv→roots≡ u ne c zero = refl conv→roots≡ u ne c (suc n) = trans (conv→roots≡ u ne c n) (conv→suc-roots≡ u ne c n) -- | All trees in a converging sequence have the same root label. conv→all-roots≡ : ∀{A B} → (u : PreApprox (A ▹ B)) (ne : non-empty (u 0)) (c : converges u) → ∀ n m → root (u n) (ne₀→all-ne u ne c n) ≡ root (u m) (ne₀→all-ne u ne c m) conv→all-roots≡ u ne c n m = begin root (u n) (ne₀→all-ne u ne c n) ≡⟨ sym (conv→roots≡ u ne c n) ⟩ root (u 0) ne ≡⟨ conv→roots≡ u ne c m ⟩ root (u m) (ne₀→all-ne u ne c m) ∎ -- | If t₁ is non-empty and t₂ extends t₁, then all branches of t₂ are -- non-empty. This shows that _extends_ defines a strict order. conv+ne₀→ne-branch : ∀{A B} → (t₁ t₂ : (A ▹ B)*) (ne₁ : non-empty t₁) (ne₂ : non-empty t₂) (e : t₂ extends t₁) → ∀ b → non-empty (branch t₂ ne₂ b) conv+ne₀→ne-branch (sup (inj₁ (a , α))) (sup (inj₁ (.a , β))) ne₁ ne₂ (refl , q) b with α b | β b | q b ... | sup (inj₁ x) | sup (inj₁ y) | z = tt ... | sup (inj₁ x) | sup (inj₂ tt) | () ... | sup (inj₂ tt) | sup (inj₁ y) | z = tt ... | sup (inj₂ tt) | sup (inj₂ tt) | () conv+ne₀→ne-branch (sup (inj₁ x)) (sup (inj₂ tt)) ne₁ () e b conv+ne₀→ne-branch (sup (inj₂ tt)) t₂ () ne₂ e b -- | If t₂ extends t₂, then all branches of t₂ extend the corresponding one -- of t₁. conv→branch-conv : ∀{A B} → (t₁ t₂ : (A ▹ B)*) (ne₁ : non-empty t₁) (ne₂ : non-empty t₂) (e : t₂ extends t₁) → ∀ b b' → b ≅ b' → (branch t₂ ne₂ b) extends (branch t₁ ne₁ b') conv→branch-conv (sup (inj₁ (a'' , α))) (sup (inj₁ (.a'' , β))) ne₁ ne₂ (refl , t) b .b refl = t b conv→branch-conv (sup (inj₁ x)) (sup (inj₂ tt)) ne₁ () e b b' p conv→branch-conv (sup (inj₂ tt)) (sup y) () ne₂ e b b' p -- | Technical lemma: -- The equality proofs for substitution by root equality are the same. root-conv≡ : ∀ {A B} → (u : PreApprox (A ▹ B)) (ne : non-empty (u 0)) (c : converges u) → ∀ b n → (subst B (conv→roots≡ u ne c (1 + n)) b) ≅ (subst B (conv→roots≡ u ne c n) b) root-conv≡ {A} {B} u ne c b n = HE.trans (HE.≡-subst-removable B (conv→roots≡ u ne c (1 + n)) b) (HE.sym (HE.≡-subst-removable B (conv→roots≡ u ne c n) b)) -- | Coalgebra structure on P∞. out : ∀{P} → P ∞ → ⟦ P ⟧ (P ∞) out {A ▹ B} (u , ne , conv) = (a , α) where a : A a = root (u 0) ne u' : B a → PreApprox (A ▹ B) u' b n = branch (u (1 + n)) (ne₀→all-ne u ne conv (1 + n)) (subst B (conv→roots≡ u ne conv (1 + n)) b) ne' : (b : B a) → non-empty (u' b 0) ne' b = conv+ne₀→ne-branch (u 0) (u 1) ne (ne₀→all-ne u ne conv 1) (conv 0) (subst B (conv→roots≡ u ne conv 1) b) conv' : (b : B a) → converges (u' b) conv' b n = conv→branch-conv (u (1 + n)) (u (2 + n)) (ne₀→all-ne u ne conv (1 + n)) (ne₀→all-ne u ne conv (2 + n)) (conv (1 + n)) (subst B (conv→roots≡ u ne conv (2 + n)) b) (subst B (conv→roots≡ u ne conv (1 + n)) b) (root-conv≡ u ne conv b (suc n)) α : B a → (A ▹ B) ∞ α b = (u' b , ne' b , conv' b) -- | Get root label. root∞ : ∀{A B} → (A ▹ B) ∞ → A root∞ t = proj₁ (out t) -- | Get branches below root. branch∞ : ∀{A B} → (t : (A ▹ B) ∞) → B (root∞ t) → (A ▹ B) ∞ branch∞ t = proj₂ (out t) -- | Corecursion principle for P∞. corec : ∀{P} {C : Set} → (C → ⟦ P ⟧ C) → (C → P ∞) corec {A ▹ B} {C} f c = (u , ne , conv) where u-aux : C → PreApprox (A ▹ B) u-aux c zero = let (a , α) = f c in sup (inj₁ (a , (λ x → sup (inj₂ tt)))) u-aux c (suc n) = let (a , α) = f c in sup (inj₁ (a , (λ b → u-aux (α b) n))) u : PreApprox (A ▹ B) u = u-aux c ne : non-empty (u 0) ne = tt conv-aux : (c : C) → converges (u-aux c) conv-aux c zero = (refl , (λ b → tt)) conv-aux c (suc n) = (refl , (λ b → conv-aux (proj₂ (f c) b) n)) conv : converges u conv = conv-aux c
{ "alphanum_fraction": 0.5097897027, "avg_line_length": 33.3629032258, "ext": "agda", "hexsha": "c6dfc01b81fee1b3e92c9b0ee55169654a6c8928", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "8fc7a6cd878f37f9595124ee8dea62258da28aa4", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "hbasold/Sandbox", "max_forks_repo_path": "TypeTheory/Container/MTypeAsSeq.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "8fc7a6cd878f37f9595124ee8dea62258da28aa4", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "hbasold/Sandbox", "max_issues_repo_path": "TypeTheory/Container/MTypeAsSeq.agda", "max_line_length": 82, "max_stars_count": null, "max_stars_repo_head_hexsha": "8fc7a6cd878f37f9595124ee8dea62258da28aa4", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "hbasold/Sandbox", "max_stars_repo_path": "TypeTheory/Container/MTypeAsSeq.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 3375, "size": 8274 }
module Tactic.Nat.Auto where open import Prelude open import Builtin.Reflection open import Tactic.Reflection.Quote open import Tactic.Reflection open import Tactic.Nat.NF open import Tactic.Nat.Exp open import Tactic.Nat.Reflect open import Tactic.Nat.Auto.Lemmas open Tactic.Nat.Reflect public using (cantProve; invalidGoal) module _ {Atom : Set} {{_ : Eq Atom}} {{_ : Ord Atom}} where liftNFEq : ∀ (e₁ : Exp Atom) e₂ ρ → ⟦ norm e₁ ⟧n ρ ≡ ⟦ norm e₂ ⟧n ρ → ⟦ e₁ ⟧e ρ ≡ ⟦ e₂ ⟧e ρ liftNFEq e₁ e₂ ρ H = eraseEquality $ ⟦ e₁ ⟧e ρ ≡⟨ sound e₁ ρ ⟩ ⟦ norm e₁ ⟧n ρ ≡⟨ H ⟩ ⟦ norm e₂ ⟧n ρ ≡⟨ sound e₂ ρ ⟩ʳ ⟦ e₂ ⟧e ρ ∎ unliftNFEq : ∀ (e₁ : Exp Atom) e₂ ρ → ⟦ e₁ ⟧e ρ ≡ ⟦ e₂ ⟧e ρ → ⟦ norm e₁ ⟧n ρ ≡ ⟦ norm e₂ ⟧n ρ unliftNFEq e₁ e₂ ρ H = ⟦ norm e₁ ⟧n ρ ≡⟨ sound e₁ ρ ⟩ʳ ⟦ e₁ ⟧e ρ ≡⟨ H ⟩ ⟦ e₂ ⟧e ρ ≡⟨ sound e₂ ρ ⟩ ⟦ norm e₂ ⟧n ρ ∎ auto-proof : ∀ e₁ e₂ → norm e₁ ≡ norm e₂ → ∀ ρ → ⟦ e₁ ⟧e ρ ≡ ⟦ e₂ ⟧e ρ auto-proof e₁ e₂ nfeq ρ = liftNFEq e₁ e₂ ρ (cong (λ n → ⟦ n ⟧n ρ) nfeq) auto-tactic : Type → Tactic auto-tactic t hole = do just ((e₁ , e₂) , Γ) ← termToEq t where nothing → unify hole $ failedProof (quote invalidGoal) t prf ← newMeta! unify hole (def₄ (quote auto-proof) (` e₁) (` e₂) prf (quotedEnv Γ)) unify prf (con₀ (quote refl)) <|> do def (quote _≡_) (_ ∷ _ ∷ vArg lnf ∷ vArg rnf ∷ []) ← normalise =<< inferType prf where sgoal → typeError $ strErr "Huh? This is a weird equality goal:" ∷ termErr sgoal ∷ [] typeError $ strErr "Normal forms are not equal:" ∷ termErr lnf ∷ strErr "≠" ∷ termErr rnf ∷ [] macro auto : Tactic auto = on-goal auto-tactic
{ "alphanum_fraction": 0.6021831413, "avg_line_length": 34.3541666667, "ext": "agda", "hexsha": "b316f1849af1fe51c4a9f3e02237542556bb9532", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "75016b4151ed601e28f4462cd7b6b1aaf5d0d1a6", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "lclem/agda-prelude", "max_forks_repo_path": "src/Tactic/Nat/Auto.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "75016b4151ed601e28f4462cd7b6b1aaf5d0d1a6", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "lclem/agda-prelude", "max_issues_repo_path": "src/Tactic/Nat/Auto.agda", "max_line_length": 98, "max_stars_count": null, "max_stars_repo_head_hexsha": "75016b4151ed601e28f4462cd7b6b1aaf5d0d1a6", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "lclem/agda-prelude", "max_stars_repo_path": "src/Tactic/Nat/Auto.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 734, "size": 1649 }
import Lvl open import Structure.Setoid open import Type module Automaton.TuringMachine where open import Data.Boolean import Data.Boolean.Operators open Data.Boolean.Operators.Programming open import Data.Either as Either using (_‖_) open import Data.Either.Setoid open import Data.Option as Option open import Data.Option.Functions as Option open import Data.Option.Setoid open import Data.Tuple as Tuple using (_⨯_ ; _,_) open import Data.Tuple.Equivalence open import Data.List renaming (∅ to ε ; _⊰_ to _·_) open import Data.List.Setoid open import Functional open import Logic open import Relator.Equals.Proofs.Equivalence open import Structure.Operator open import Structure.Relator open import Structure.Relator.Properties open import Syntax.Transitivity open import Type.Size.Finite private variable ℓₚ ℓₛ ℓₐ ℓₑₛ ℓₑₐ : Lvl.Level private variable Alphabet : Type{ℓₐ} data Direction : Type{Lvl.𝟎} where Backward : Direction Stay : Direction Forward : Direction private instance _ = [≡]-equiv {T = Direction} record Tape (Alphabet : Type{ℓₐ}) : Type{ℓₐ} where coinductive field back : Tape(Alphabet) current : Alphabet front : Tape(Alphabet) update : (Alphabet → Alphabet) → Tape(Alphabet) back (update _) = back current(update f) = f(current) front (update _) = front stepBackward : Tape(Alphabet) → Tape(Alphabet) Tape.back (stepBackward t) = Tape.back(Tape.back t) Tape.current(stepBackward t) = Tape.current(Tape.back t) Tape.front (stepBackward t) = t stepForward : Tape(Alphabet) → Tape(Alphabet) Tape.back (stepForward t) = t Tape.current(stepForward t) = Tape.current(Tape.front t) Tape.front (stepForward t) = Tape.front(Tape.front t) stepInDirection : Direction → Tape(Alphabet) → Tape(Alphabet) stepInDirection Backward = stepBackward stepInDirection Stay = id stepInDirection Forward = stepForward module _ ⦃ equiv-alphabet : Equiv{ℓₑₐ}(Alphabet) ⦄ where step-inverseₗᵣ : ∀{t : Tape(Alphabet)} → (Tape.current(stepBackward(stepForward(t))) ≡ Tape.current(t)) step-inverseₗᵣ = reflexivity(_≡_ ⦃ equiv-alphabet ⦄) step-inverseᵣₗ : ∀{t : Tape(Alphabet)} → (Tape.current(stepBackward(stepForward(t))) ≡ Tape.current(t)) step-inverseᵣₗ = reflexivity(_≡_ ⦃ equiv-alphabet ⦄) module _ (State : Type{ℓₛ}) ⦃ equiv-state : Equiv{ℓₑₛ}(State) ⦄ (Alphabet : Type{ℓₐ}) ⦃ equiv-alphabet : Equiv{ℓₑₐ}(Alphabet) ⦄ where private instance _ = [≡]-equiv {T = Bool} -- Turing machine -- `State` (Q) is the set of states. -- `Alphabet` (Σ) is the set of symbols/the alphabet. -- `transition` (δ) is the transition function. -- `start` (q₀) is the start state. -- `Final` (F) is the subset of State which are the final/accepting states. record TuringMachine : Type{ℓₛ Lvl.⊔ ℓₑₐ Lvl.⊔ ℓₑₛ Lvl.⊔ ℓₐ Lvl.⊔ Lvl.𝐒(ℓₚ)} where constructor turingMachine field ⦃ State-finite ⦄ : Finite(State) ⦃ Alphabet-finite ⦄ : Finite(Alphabet) transition : State → Option(Alphabet) → Option(State ⨯ Alphabet ⨯ Direction) ⦃ transition-binaryOperator ⦄ : BinaryOperator(transition) start : State Final : State → Type{ℓₚ} ⦃ Final-unaryRelator ⦄ : UnaryRelator(Final) -- isFinal : State → Bool -- TODO: Not sure what the best (most easy to use) formalization of a TM would be or if this is correct Configuration = State ⨯ Tape(Option(Alphabet)) module Configuration where step : TuringMachine{ℓₚ} → (Configuration → Option(Configuration)) step tm (s , t) = Option.map (\(ns , nx , dir) → (ns , stepInDirection dir (Tape.update t (Some ∘ const nx)))) (TuringMachine.transition tm s (Tape.current t))
{ "alphanum_fraction": 0.688029661, "avg_line_length": 37.0196078431, "ext": "agda", "hexsha": "a31e03cba7320e25dc8148c84e78f7822764bd91", "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": "Automaton/TuringMachine.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": "Automaton/TuringMachine.agda", "max_line_length": 163, "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": "Automaton/TuringMachine.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": 1177, "size": 3776 }
module Data.QuadTree.LensProofs.Valid-LensBCD where open import Haskell.Prelude renaming (zero to Z; suc to S) open import Data.Lens.Lens open import Data.Logic open import Data.QuadTree.InternalAgda open import Agda.Primitive open import Data.Lens.Proofs.LensLaws open import Data.Lens.Proofs.LensPostulates open import Data.Lens.Proofs.LensComposition open import Data.QuadTree.Implementation.QuadrantLenses open import Data.QuadTree.Implementation.Definition open import Data.QuadTree.Implementation.ValidTypes open import Data.QuadTree.Implementation.SafeFunctions open import Data.QuadTree.Implementation.PublicFunctions open import Data.QuadTree.Implementation.DataLenses -- The lens laws have been proven for LensA, and the proof is quite long. -- The implementation of lens b/c/d is basically identical, so I won't bother to proof them for now --- Lens laws for lensB postulate ValidLens-LensB-ViewSet : {t : Set} {{eqT : Eq t}} {dep : Nat} -> ViewSet (lensB {t} {dep}) ValidLens-LensB-SetView : {t : Set} {{eqT : Eq t}} {dep : Nat} -> SetView (lensB {t} {dep}) ValidLens-LensB-SetSet : {t : Set} {{eqT : Eq t}} {dep : Nat} -> SetSet (lensB {t} {dep}) ValidLens-LensB : {t : Set} {{eqT : Eq t}} {dep : Nat} -> ValidLens (VQuadrant t {S dep}) (VQuadrant t {dep}) ValidLens-LensB {t} {dep} = CValidLens lensB (ValidLens-LensB-ViewSet) (ValidLens-LensB-SetView) (ValidLens-LensB-SetSet) --- Lens laws for lensC postulate ValidLens-LensC-ViewSet : {t : Set} {{eqT : Eq t}} {dep : Nat} -> ViewSet (lensC {t} {dep}) ValidLens-LensC-SetView : {t : Set} {{eqT : Eq t}} {dep : Nat} -> SetView (lensC {t} {dep}) ValidLens-LensC-SetSet : {t : Set} {{eqT : Eq t}} {dep : Nat} -> SetSet (lensC {t} {dep}) ValidLens-LensC : {t : Set} {{eqT : Eq t}} {dep : Nat} -> ValidLens (VQuadrant t {S dep}) (VQuadrant t {dep}) ValidLens-LensC {t} {dep} = CValidLens lensC (ValidLens-LensC-ViewSet) (ValidLens-LensC-SetView) (ValidLens-LensC-SetSet) --- Lens laws for lensD postulate ValidLens-LensD-ViewSet : {t : Set} {{eqT : Eq t}} {dep : Nat} -> ViewSet (lensD {t} {dep}) ValidLens-LensD-SetView : {t : Set} {{eqT : Eq t}} {dep : Nat} -> SetView (lensD {t} {dep}) ValidLens-LensD-SetSet : {t : Set} {{eqT : Eq t}} {dep : Nat} -> SetSet (lensD {t} {dep}) ValidLens-LensD : {t : Set} {{eqT : Eq t}} {dep : Nat} -> ValidLens (VQuadrant t {S dep}) (VQuadrant t {dep}) ValidLens-LensD {t} {dep} = CValidLens lensD (ValidLens-LensD-ViewSet) (ValidLens-LensD-SetView) (ValidLens-LensD-SetSet)
{ "alphanum_fraction": 0.6496649293, "avg_line_length": 38.3714285714, "ext": "agda", "hexsha": "05bd61445ba0c858f51e763e3147c2b5897517a2", "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/QuadTree/LensProofs/Valid-LensBCD.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/QuadTree/LensProofs/Valid-LensBCD.agda", "max_line_length": 121, "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/QuadTree/LensProofs/Valid-LensBCD.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": 889, "size": 2686 }
{-# OPTIONS --type-in-type #-} module Bias where open import AgdaPrelude myFun : (a : Set) -> a -> a -> a -> a myFun a x y z = x --myApp1 = myFun _ Zero Zero (Nil Nat) myApp2 = myFun _ (Nil Nat) Zero Zero
{ "alphanum_fraction": 0.6095238095, "avg_line_length": 17.5, "ext": "agda", "hexsha": "2569f7965b3ebcc4f727b7861cd5e1fe68e02807", "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": "64a1b4c6632153d75cba540f7c91f40b49375e2f", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "JoeyEremondi/lambda-pi-constraint", "max_forks_repo_path": "thesisExamples/Bias.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "64a1b4c6632153d75cba540f7c91f40b49375e2f", "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": "JoeyEremondi/lambda-pi-constraint", "max_issues_repo_path": "thesisExamples/Bias.agda", "max_line_length": 38, "max_stars_count": 16, "max_stars_repo_head_hexsha": "64a1b4c6632153d75cba540f7c91f40b49375e2f", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "JoeyEremondi/lambda-pi-constraint", "max_stars_repo_path": "thesisExamples/Bias.agda", "max_stars_repo_stars_event_max_datetime": "2021-02-05T20:21:46.000Z", "max_stars_repo_stars_event_min_datetime": "2017-03-16T11:14:56.000Z", "num_tokens": 73, "size": 210 }
module Test2 where open import MiniHoTT A : Set A = ℕ -- a, b : A {- [ a, b ] : List A [ a, b ] := inr ( a , ?) -- inr ((a, inr ( b, inl(unit)) -} T : {A : Set} → (X : Set) → Set T {A} X = 𝟙 lzero + A × X -- This is an example of a polynomial functor. data List (A : Set) : Set where [] : List A cons : A → List A → List A data Vec (A : Set) : ℕ → Set where nil : ∀ n → Vec A n cons : ∀ n → A → Vec A n → Vec A (succ n) data Fin : ℕ → Set where cero : ∀ {n} → Fin n succ : ∀ {n} → Fin n → Fin (succ n) at : ∀ {n : ℕ} {A : Set} → Vec A (succ n) → Fin (succ n) → A at v n = {! !} go' : ∀ {n} {A : Set} → (Fin 0n → A) → Fin n → Vec A n go' pick cero = nil _ go' pick (succ n) = cons {! !} (pick {! n !}) (go' {! pick !} {! !}) record Algebra (A : Set) (T : Set → Set) : Set (lsuc lzero) where constructor algebra field X : Set μ : T X → X -- Objects: (X, μ) -- morphisms f : (X, μ) ­--> (Y, ν) -- this is given by α : X → Y, that makes the diagram commutes. -- Initial object: Object (X, μ) + initiallity condition: -- Any other (Y, ν), there exists unique α : X → Y such that... list-is-an-algebra : (A : Set) → Algebra A (λ X → 𝟙 lzero + A × X) list-is-an-algebra A = algebra (List A) λ { (inl x) → [] ; (inr (a , xs)) → cons a xs } -- where (T X -> X) is the type of list with elements of type A. -- elements? is TA a set? -- Yes, assuming A is a set. Let's find that. list-of-nats-is-set : A is-set → isSet (T A) list-of-nats-is-set A-is-set = +-set (prop-is-set 𝟙-is-prop) (∑-set A-is-set λ _ → A-is-set) -- T(X) = 1+X + (X ×X) a
{ "alphanum_fraction": 0.4397463002, "avg_line_length": 20.3440860215, "ext": "agda", "hexsha": "66b84c6c7dec8d8d9c2c7d27167368305d2ebb55", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2020-04-26T15:16:01.000Z", "max_forks_repo_forks_event_min_datetime": "2020-04-26T15:16:01.000Z", "max_forks_repo_head_hexsha": "9e81415f0276ee42b4a57816c1dcd3aaa6d9ea60", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "jonaprieto/mini-hott", "max_forks_repo_path": "src/Test2.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "9e81415f0276ee42b4a57816c1dcd3aaa6d9ea60", "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": "jonaprieto/mini-hott", "max_issues_repo_path": "src/Test2.agda", "max_line_length": 75, "max_stars_count": 3, "max_stars_repo_head_hexsha": "9e81415f0276ee42b4a57816c1dcd3aaa6d9ea60", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "jonaprieto/mini-hott", "max_stars_repo_path": "src/Test2.agda", "max_stars_repo_stars_event_max_datetime": "2019-08-17T10:28:06.000Z", "max_stars_repo_stars_event_min_datetime": "2019-05-12T14:19:04.000Z", "num_tokens": 694, "size": 1892 }
open import Level open import Ordinals open import logic open import Relation.Nullary module LEMC {n : Level } (O : Ordinals {n} ) (p∨¬p : ( p : Set n) → p ∨ ( ¬ p )) where open import zf open import Data.Nat renaming ( zero to Zero ; suc to Suc ; ℕ to Nat ; _⊔_ to _n⊔_ ) open import Relation.Binary.PropositionalEquality open import Data.Nat.Properties open import Data.Empty open import Relation.Binary open import Relation.Binary.Core open import nat import OD open inOrdinal O open OD O open OD.OD open OD._==_ open ODAxiom odAxiom import OrdUtil import ODUtil open Ordinals.Ordinals O open Ordinals.IsOrdinals isOrdinal open Ordinals.IsNext isNext open OrdUtil O open ODUtil O open import zfc open HOD open _⊆_ decp : ( p : Set n ) → Dec p -- assuming axiom of choice decp p with p∨¬p p decp p | case1 x = yes x decp p | case2 x = no x ∋-p : (A x : HOD ) → Dec ( A ∋ x ) ∋-p A x with p∨¬p ( A ∋ x) -- LEM ∋-p A x | case1 t = yes t ∋-p A x | case2 t = no (λ x → t x) double-neg-eilm : {A : Set n} → ¬ ¬ A → A -- we don't have this in intutionistic logic double-neg-eilm {A} notnot with decp A -- assuming axiom of choice ... | yes p = p ... | no ¬p = ⊥-elim ( notnot ¬p ) power→⊆ : ( A t : HOD) → Power A ∋ t → t ⊆ A power→⊆ A t PA∋t = record { incl = λ {x} t∋x → double-neg-eilm (λ not → t1 t∋x (λ x → not x) ) } where t1 : {x : HOD } → t ∋ x → ¬ ¬ (A ∋ x) t1 = power→ A t PA∋t --- With assuption of HOD is ordered, p ∨ ( ¬ p ) <=> axiom of choice --- record choiced ( X : Ordinal ) : Set n where field a-choice : Ordinal is-in : odef (* X) a-choice open choiced -- ∋→d : ( a : HOD ) { x : HOD } → * (& a) ∋ x → X ∋ * (a-choice (choice-func X not)) -- ∋→d a lt = subst₂ (λ j k → odef j k) *iso (sym &iso) lt oo∋ : { a : HOD} { x : Ordinal } → odef (* (& a)) x → a ∋ * x oo∋ lt = subst₂ (λ j k → odef j k) *iso (sym &iso) lt ∋oo : { a : HOD} { x : Ordinal } → a ∋ * x → odef (* (& a)) x ∋oo lt = subst₂ (λ j k → odef j k ) (sym *iso) &iso lt OD→ZFC : ZFC OD→ZFC = record { ZFSet = HOD ; _∋_ = _∋_ ; _≈_ = _=h=_ ; ∅ = od∅ ; Select = Select ; isZFC = isZFC } where -- infixr 200 _∈_ -- infixr 230 _∩_ _∪_ isZFC : IsZFC (HOD ) _∋_ _=h=_ od∅ Select isZFC = record { choice-func = λ A {X} not A∋X → * (a-choice (choice-func X not) ); choice = λ A {X} A∋X not → oo∋ (is-in (choice-func X not)) } where -- -- the axiom choice from LEM and OD ordering -- choice-func : (X : HOD ) → ¬ ( X =h= od∅ ) → choiced (& X) choice-func X not = have_to_find where ψ : ( ox : Ordinal ) → Set n ψ ox = (( x : Ordinal ) → x o< ox → ( ¬ odef X x )) ∨ choiced (& X) lemma-ord : ( ox : Ordinal ) → ψ ox lemma-ord ox = TransFinite0 {ψ} induction ox where ∀-imply-or : {A : Ordinal → Set n } {B : Set n } → ((x : Ordinal ) → A x ∨ B) → ((x : Ordinal ) → A x) ∨ B ∀-imply-or {A} {B} ∀AB with p∨¬p ((x : Ordinal ) → A x) -- LEM ∀-imply-or {A} {B} ∀AB | case1 t = case1 t ∀-imply-or {A} {B} ∀AB | case2 x = case2 (lemma (λ not → x not )) where lemma : ¬ ((x : Ordinal ) → A x) → B lemma not with p∨¬p B lemma not | case1 b = b lemma not | case2 ¬b = ⊥-elim (not (λ x → dont-orb (∀AB x) ¬b )) induction : (x : Ordinal) → ((y : Ordinal) → y o< x → ψ y) → ψ x induction x prev with ∋-p X ( * x) ... | yes p = case2 ( record { a-choice = x ; is-in = ∋oo p } ) ... | no ¬p = lemma where lemma1 : (y : Ordinal) → (y o< x → odef X y → ⊥) ∨ choiced (& X) lemma1 y with ∋-p X (* y) lemma1 y | yes y<X = case2 ( record { a-choice = y ; is-in = ∋oo y<X } ) lemma1 y | no ¬y<X = case1 ( λ lt y<X → ¬y<X (d→∋ X y<X) ) lemma : ((y : Ordinal) → y o< x → odef X y → ⊥) ∨ choiced (& X) lemma = ∀-imply-or lemma1 odef→o< : {X : HOD } → {x : Ordinal } → odef X x → x o< & X odef→o< {X} {x} lt = o<-subst {_} {_} {x} {& X} ( c<→o< ( subst₂ (λ j k → odef j k ) (sym *iso) (sym &iso) lt )) &iso &iso have_to_find : choiced (& X) have_to_find = dont-or (lemma-ord (& X )) ¬¬X∋x where ¬¬X∋x : ¬ ((x : Ordinal) → x o< (& X) → odef X x → ⊥) ¬¬X∋x nn = not record { eq→ = λ {x} lt → ⊥-elim (nn x (odef→o< lt) lt) ; eq← = λ {x} lt → ⊥-elim ( ¬x<0 lt ) } -- -- axiom regurality from ε-induction (using axiom of choice above) -- -- from https://math.stackexchange.com/questions/2973777/is-it-possible-to-prove-regularity-with-transfinite-induction-only -- -- FIXME : don't use HOD make this level n, so we can remove ε-induction1 record Minimal (x : HOD) : Set (suc n) where field min : HOD x∋min : x ∋ min min-empty : (y : HOD ) → ¬ ( min ∋ y) ∧ (x ∋ y) open Minimal open _∧_ induction : {x : HOD} → ({y : HOD} → x ∋ y → (u : HOD ) → (u∋x : u ∋ y) → Minimal u ) → (u : HOD ) → (u∋x : u ∋ x) → Minimal u induction {x} prev u u∋x with p∨¬p ((y : Ordinal ) → ¬ (odef x y) ∧ (odef u y)) ... | case1 P = record { min = x ; x∋min = u∋x ; min-empty = λ y → P (& y) } ... | case2 NP = min2 where p : HOD p = record { od = record { def = λ y1 → odef x y1 ∧ odef u y1 } ; odmax = omin (odmax x) (odmax u) ; <odmax = lemma } where lemma : {y : Ordinal} → OD.def (od x) y ∧ OD.def (od u) y → y o< omin (odmax x) (odmax u) lemma {y} lt = min1 (<odmax x (proj1 lt)) (<odmax u (proj2 lt)) np : ¬ (p =h= od∅) np p∅ = NP (λ y p∋y → ∅< {p} {_} (d→∋ p p∋y) p∅ ) y1choice : choiced (& p) y1choice = choice-func p np y1 : HOD y1 = * (a-choice y1choice) y1prop : (x ∋ y1) ∧ (u ∋ y1) y1prop = oo∋ (is-in y1choice) min2 : Minimal u min2 = prev (proj1 y1prop) u (proj2 y1prop) Min2 : (x : HOD) → (u : HOD ) → (u∋x : u ∋ x) → Minimal u Min2 x u u∋x = (ε-induction {λ y → (u : HOD ) → (u∋x : u ∋ y) → Minimal u } induction x u u∋x ) cx : {x : HOD} → ¬ (x =h= od∅ ) → choiced (& x ) cx {x} nx = choice-func x nx minimal : (x : HOD ) → ¬ (x =h= od∅ ) → HOD minimal x ne = min (Min2 (* (a-choice (cx {x} ne) )) x ( oo∋ (is-in (cx ne))) ) x∋minimal : (x : HOD ) → ( ne : ¬ (x =h= od∅ ) ) → odef x ( & ( minimal x ne ) ) x∋minimal x ne = x∋min (Min2 (* (a-choice (cx {x} ne) )) x ( oo∋ (is-in (cx ne))) ) minimal-1 : (x : HOD ) → ( ne : ¬ (x =h= od∅ ) ) → (y : HOD ) → ¬ ( odef (minimal x ne) (& y)) ∧ (odef x (& y) ) minimal-1 x ne y = min-empty (Min2 (* (a-choice (cx ne) )) x ( oo∋ (is-in (cx ne)))) y
{ "alphanum_fraction": 0.443647949, "avg_line_length": 42.0837988827, "ext": "agda", "hexsha": "9a6b5619b57344013d4ef5b4e533a41b009cfbe8", "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": "031f1ea3a3037cd51eb022dbfb5c75b037bf8aa0", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "shinji-kono/zf-in-agda", "max_forks_repo_path": "src/LEMC.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "031f1ea3a3037cd51eb022dbfb5c75b037bf8aa0", "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": "shinji-kono/zf-in-agda", "max_issues_repo_path": "src/LEMC.agda", "max_line_length": 143, "max_stars_count": 5, "max_stars_repo_head_hexsha": "031f1ea3a3037cd51eb022dbfb5c75b037bf8aa0", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "shinji-kono/zf-in-agda", "max_stars_repo_path": "src/LEMC.agda", "max_stars_repo_stars_event_max_datetime": "2021-01-10T13:27:48.000Z", "max_stars_repo_stars_event_min_datetime": "2019-10-02T13:46:23.000Z", "num_tokens": 2771, "size": 7533 }
module Data.QuadTree.Implementation.Definition where open import Haskell.Prelude renaming (zero to Z; suc to S) open import Data.Lens.Lens open import Data.Logic {-# FOREIGN AGDA2HS {-# LANGUAGE Safe #-} {-# LANGUAGE LambdaCase #-} {-# LANGUAGE Rank2Types #-} import Data.Nat import Data.Lens.Lens import Data.Logic #-} ---- Quadrants -- A quadrant is either a leaf or a node with 4 sub-quadrants data Quadrant (t : Set) : Set where Leaf : t -> Quadrant t Node : Quadrant t -> Quadrant t -> Quadrant t -> Quadrant t -> Quadrant t {-# COMPILE AGDA2HS Quadrant deriving (Show, Eq) #-} ---- QuadTree -- A quadtree is the width/height + the root quadrant data QuadTree (t : Set) : Set where Wrapper : (Nat × Nat) -> Quadrant t -> QuadTree t {-# COMPILE AGDA2HS QuadTree deriving (Show, Eq) #-}
{ "alphanum_fraction": 0.6957605985, "avg_line_length": 26.7333333333, "ext": "agda", "hexsha": "4eb7557ff8d48e1259ee18b8934313c181c144a8", "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/QuadTree/Implementation/Definition.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/QuadTree/Implementation/Definition.agda", "max_line_length": 75, "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/QuadTree/Implementation/Definition.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": 224, "size": 802 }
{-# 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 open import Function module GenericElim.Desc 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) Branches : (E : Enum) (P : Tag E → Set) → Set Branches [] P = ⊤ Branches (l ∷ E) P = P here × Branches E (λ t → P (there t)) case : {E : Enum} (P : Tag E → Set) (cs : Branches E P) (t : Tag E) → P t case P (c , cs) here = c case P (c , cs) (there t) = case (λ t → P (there t)) cs t UncurriedBranches : (E : Enum) (P : Tag E → Set) (X : Set) → Set UncurriedBranches E P X = Branches E P → X CurriedBranches : (E : Enum) (P : Tag E → Set) (X : Set) → Set CurriedBranches [] P X = X CurriedBranches (l ∷ E) P X = P here → CurriedBranches E (λ t → P (there t)) X curryBranches : {E : Enum} {P : Tag E → Set} {X : Set} → UncurriedBranches E P X → CurriedBranches E P X curryBranches {[]} f = f tt curryBranches {l ∷ E} f = λ c → curryBranches (λ cs → f (c , cs)) uncurryBranches : {E : Enum} {P : Tag E → Set} {X : Set} → CurriedBranches E P X → UncurriedBranches E P X uncurryBranches {[]} x tt = x uncurryBranches {l ∷ E} f (c , cs) = uncurryBranches (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 ISet : Set → Set₁ ISet I = I → Set El : {I : Set} (D : Desc I) → ISet I → ISet I El (End j) X i = j ≡ i El (Rec j D) X i = X j × El D X i El (Arg A B) X i = Σ A (λ a → El (B a) X i) Hyps : {I : Set} (D : Desc I) (X : ISet I) (P : (i : I) → X i → Set) (i : I) (xs : El D X i) → Set Hyps (End j) X P i q = ⊤ Hyps (Rec j D) X P i (x , xs) = P j x × Hyps D X P i xs Hyps (Arg A B) X P i (a , b) = Hyps (B a) X P i b ---------------------------------------------------------------------- BranchesD : (I : Set) (E : Enum) → Set BranchesD I E = Branches E (λ _ → Desc I) caseD : {I : Set} {E : Enum} (cs : BranchesD I E) (t : Tag E) → Desc I caseD = case (λ _ → Desc _) ---------------------------------------------------------------------- UncurriedEl : {I : Set} (D : Desc I) (X : ISet I) → Set UncurriedEl D X = ∀{i} → El D X i → X i CurriedEl : {I : Set} (D : Desc I) (X : ISet I) → Set CurriedEl (End i) X = X i CurriedEl (Rec i D) X = (x : X i) → CurriedEl D X CurriedEl (Arg A B) X = (a : A) → CurriedEl (B a) X CurriedEl' : {I : Set} (D : Desc I) (X : ISet I) (i : I) → Set CurriedEl' (End j) X i = j ≡ i → X i CurriedEl' (Rec j D) X i = (x : X j) → CurriedEl' D X i CurriedEl' (Arg A B) X i = (a : A) → CurriedEl' (B a) X i curryEl : {I : Set} (D : Desc I) (X : ISet I) → UncurriedEl D X → CurriedEl D X curryEl (End i) X cn = cn refl curryEl (Rec i D) X cn = λ x → curryEl D X (λ xs → cn (x , xs)) curryEl (Arg A B) X cn = λ a → curryEl (B a) X (λ xs → cn (a , xs)) uncurryEl : {I : Set} (D : Desc I) (X : ISet I) → CurriedEl D X → UncurriedEl D X uncurryEl (End i) X cn refl = cn uncurryEl (Rec i D) X cn (x , xs) = uncurryEl D X (cn x) xs uncurryEl (Arg A B) X cn (a , xs) = uncurryEl (B a) X (cn a) xs ---------------------------------------------------------------------- UncurriedHyps : {I : Set} (D : Desc I) (X : ISet I) (P : (i : I) → X i → Set) (cn : UncurriedEl D X) → Set UncurriedHyps D X P cn = ∀ i (xs : El D X i) (ihs : Hyps 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 D X) → Set CurriedHyps (End i) X P cn = P i (cn refl) CurriedHyps (Rec i D) X P cn = (x : X i) → P i x → CurriedHyps D X P (λ xs → cn (x , xs)) CurriedHyps (Arg A B) X P cn = (a : A) → CurriedHyps (B a) X P (λ xs → cn (a , xs)) CurriedHyps' : {I : Set} (D : Desc I) (X : ISet I) (P : (i : I) → X i → Set) (i : I) (cn : El D X i → X i) → Set CurriedHyps' (End j) X P i cn = (q : j ≡ i) → P i (cn q) CurriedHyps' (Rec j D) X P i cn = (x : X j) → P j x → CurriedHyps' D X P i (λ xs → cn (x , xs)) CurriedHyps' (Arg A B) X P i cn = (a : A) → CurriedHyps' (B a) X P i (λ xs → cn (a , xs)) curryHyps : {I : Set} (D : Desc I) (X : ISet I) (P : (i : I) → X i → Set) (cn : UncurriedEl D X) → UncurriedHyps D X P cn → CurriedHyps D X P cn curryHyps (End i) X P cn pf = pf i refl tt curryHyps (Rec i D) X P cn pf = λ x ih → curryHyps D X P (λ xs → cn (x , xs)) (λ i xs ihs → pf i (x , xs) (ih , ihs)) curryHyps (Arg A B) X P cn pf = λ a → curryHyps (B a) X P (λ xs → cn (a , xs)) (λ i xs ihs → pf i (a , xs) ihs) uncurryHyps : {I : Set} (D : Desc I) (X : ISet I) (P : (i : I) → X i → Set) (cn : UncurriedEl D X) → CurriedHyps D X P cn → UncurriedHyps D X P cn uncurryHyps (End .i) X P cn pf i refl tt = pf uncurryHyps (Rec j D) X P cn pf i (x , xs) (ih , ihs) = uncurryHyps D X P (λ ys → cn (x , ys)) (pf x ih) i xs ihs uncurryHyps (Arg A B) X P cn pf i (a , xs) ihs = uncurryHyps (B a) X P (λ ys → cn (a , ys)) (pf a) i xs ihs ---------------------------------------------------------------------- data μ {I : Set} (D : Desc I) : ISet I where init : UncurriedEl D (μ D) inj : {I : Set} (D : Desc I) → CurriedEl D (μ D) inj D = curryEl D (μ D) init ---------------------------------------------------------------------- ind : {I : Set} (D : Desc I) (P : (i : I) → μ D i → Set) (α : UncurriedHyps D (μ D) P init) (i : I) (x : μ D i) → P i x hyps : {I : Set} (D₁ : Desc I) (P : (i : I) → μ D₁ i → Set) (α : UncurriedHyps D₁ (μ D₁) P init) (D₂ : Desc I) (i : I) (xs : El D₂ (μ D₁) i) → Hyps D₂ (μ D₁) P i xs ind D P α i (init xs) = α i xs (hyps D P α D i xs) hyps D P α (End j) i q = tt hyps D P α (Rec j A) i (x , xs) = ind D P α j x , hyps D P α A i xs hyps D P α (Arg A B) i (a , b) = hyps D P α (B a) i b ---------------------------------------------------------------------- indCurried : {I : Set} (D : Desc I) (P : (i : I) → μ D i → Set) (f : CurriedHyps D (μ D) P init) (i : I) (x : μ D i) → P i x indCurried D P f i x = ind D P (uncurryHyps D (μ D) P init f) i x Summer : {I : Set} (E : Enum) (C : Tag E → Desc I) → let D = Arg (Tag E) C in (X : ISet I) (cn : UncurriedEl D X) (P : (i : I) → X i → Set) → Tag E → Set Summer E C X cn P t = let D = Arg (Tag E) C in CurriedHyps (C t) X P (λ xs → cn (t , xs)) SumCurriedHyps : {I : Set} (E : Enum) (C : Tag E → Desc I) → let D = Arg (Tag E) C in (P : (i : I) → μ D i → Set) → Tag E → Set SumCurriedHyps E C P t = let D = Arg (Tag E) C in Summer E C (μ D) init P t elimUncurried : {I : Set} (E : Enum) (C : Tag E → Desc I) → let D = Arg (Tag E) C in (P : (i : I) → μ D i → Set) → Branches E (SumCurriedHyps E C P) → (i : I) (x : μ D i) → P i x elimUncurried E C P cs i x = let D = Arg (Tag E) C in indCurried D P (case (SumCurriedHyps E C P) cs) i x elim : {I : Set} (E : Enum) (C : Tag E → Desc I) → let D = Arg (Tag E) C in (P : (i : I) → μ D i → Set) → CurriedBranches E (SumCurriedHyps E C P) ((i : I) (x : μ D i) → P i x) elim E C P = curryBranches (elimUncurried E C P) ---------------------------------------------------------------------- Soundness : Set₁ Soundness = {I : Set} (E : Enum) (C : Tag E → Desc I) → let D = Arg (Tag E) C in (P : (i : I) → μ D i → Set) (cs : Branches E (SumCurriedHyps E C P)) (i : I) (x : μ D i) → ∃ λ α → elimUncurried E C P cs i x ≡ ind D P α i x sound : Soundness sound E C P cs i x = let D = Arg (Tag E) C in (uncurryHyps D (μ D) P init (case (SumCurriedHyps E C P) cs)) , refl Completeness : Set₁ Completeness = {I : Set} (E : Enum) (C : Tag E → Desc I) → let D = Arg (Tag E) C in (P : (i : I) → μ D i → Set) (α : UncurriedHyps D (μ D) P init) (i : I) (x : μ D i) → ∃ λ cs → ind D P α i x ≡ elimUncurried E C P cs i x uncurryHypsIdent : {I : Set} (D : Desc I) (X : ISet I) (P : (i : I) → X i → Set) (cn : UncurriedEl D X) (α : UncurriedHyps D X P cn) (i : I) (xs : El D X i) (ihs : Hyps D X P i xs) → α i xs ihs ≡ uncurryHyps D X P cn (curryHyps D X P cn α) i xs ihs uncurryHypsIdent (End .i) X P cn α i refl tt = refl uncurryHypsIdent (Rec j D) X P cn α i (x , xs) (p , ps) = uncurryHypsIdent D X P (λ xs → cn (x , xs)) (λ k ys rs → α k (x , ys) (p , rs)) i xs ps uncurryHypsIdent (Arg A B) X P cn α i (a , xs) ps = uncurryHypsIdent (B a) X P (λ xs → cn (a , xs)) (λ j ys → α j (a , ys)) i xs ps postulate ext3 : {A : Set} {B : A → Set} {C : (a : A) → B a → Set} {Z : (a : A) (b : B a) → C a b → Set} (f g : (a : A) (b : B a) (c : C a b) → Z a b c) → ((a : A) (b : B a) (c : C a b) → f a b c ≡ g a b c) → f ≡ g toBranches : {I : Set} (E : Enum) (C : Tag E → Desc I) → let D = Arg (Tag E) C in (X : ISet I) (cn : UncurriedEl D X) (P : (i : I) → X i → Set) (α : UncurriedHyps D X P cn) → Branches E (Summer E C X cn P) toBranches [] C X cn P α = tt toBranches (l ∷ E) C X cn P α = curryHyps (C here) X P (λ xs → cn (here , xs)) (λ i xs → α i (here , xs)) , toBranches E (λ t → C (there t)) X (λ xs → cn (there (proj₁ xs) , proj₂ xs)) P (λ i xs ih → α i (there (proj₁ xs) , proj₂ xs) ih) ToBranches : {I : Set} {E : Enum} (C : Tag E → Desc I) → let D = Arg (Tag E) C in (X : ISet I) (cn : UncurriedEl D X) (P : (i : I) → X i → Set) (α : UncurriedHyps D X P cn) (t : Tag E) → let β = toBranches E C X cn P α in case (Summer E C X cn P) β t ≡ curryHyps D X P cn α t ToBranches C X cn P α here = refl ToBranches C X cn P α (there t) with ToBranches (λ t → C (there t)) X (λ xs → cn (there (proj₁ xs) , proj₂ xs)) P (λ i xs ih → α i (there (proj₁ xs) , proj₂ xs) ih) t ... | ih rewrite ih = refl completeα : {I : Set} (E : Enum) (C : Tag E → Desc I) → let D = Arg (Tag E) C in (P : (i : I) → μ D i → Set) (α : UncurriedHyps D (μ D) P init) (i : I) (xs : El D (μ D) i) (ihs : Hyps D (μ D) P i xs) → let β = toBranches E C (μ D) init P α in α i xs ihs ≡ uncurryHyps D (μ D) P init (case (SumCurriedHyps E C P) β) i xs ihs completeα E C P α i (t , xs) ihs with ToBranches C (μ D) init P α t where D = Arg (Tag E) C ... | q rewrite q = uncurryHypsIdent D (μ D) P init α i (t , xs) ihs where D = Arg (Tag E) C complete' : {I : Set} (E : Enum) (C : Tag E → Desc I) → let D = Arg (Tag E) C in (P : (i : I) → μ D i → Set) (α : UncurriedHyps D (μ D) P init) (i : I) (x : μ D i) → let β = toBranches E C (μ D) init P α in ind D P α i x ≡ elimUncurried E C P β i x complete' E C P α i (init (t , xs)) = cong (λ f → ind D P f i (init (t , xs))) (ext3 α (uncurryHyps D (μ D) P init (case (SumCurriedHyps E C P) β)) (completeα E C P α)) where D = Arg (Tag E) C β = toBranches E C (μ D) init P α complete : Completeness complete E C P α i x = let D = Arg (Tag E) C in toBranches E C (μ D) init P α , complete' E C P α i x ---------------------------------------------------------------------- ℕE : Enum ℕE = "zero" ∷ "suc" ∷ [] VecE : Enum VecE = "nil" ∷ "cons" ∷ [] ℕT : Set ℕT = Tag ℕE VecT : Set VecT = Tag VecE zeroT : ℕT zeroT = here sucT : ℕT sucT = there here nilT : VecT nilT = here consT : VecT consT = there here ℕC : ℕT → Desc ⊤ ℕC = caseD $ End tt , Rec tt (End tt) , tt ℕD : Desc ⊤ ℕD = Arg ℕT ℕC ℕ : ⊤ → Set ℕ = μ ℕD zero : ℕ tt zero = init (zeroT , refl) suc : ℕ tt → ℕ tt suc n = init (sucT , n , refl) VecC : (A : Set) → VecT → Desc (ℕ tt) VecC A = caseD $ End zero , Arg (ℕ tt) (λ n → Arg A λ _ → Rec n (End (suc n))) , tt nilD : (A : Set) → Desc (ℕ tt) nilD A = End zero consD : (A : Set) → Desc (ℕ tt) consD A = Arg (ℕ tt) (λ n → Arg A (λ _ → Rec n (End (suc n)))) VecD : (A : Set) → Desc (ℕ tt) VecD A = Arg VecT (VecC A) Vec : (A : Set) → ℕ tt → Set Vec A = μ (VecD A) NilEl : (A : Set) (n : ℕ tt) → Set NilEl A n = El (nilD A) (Vec A) n ConsEl : (A : Set) → ℕ tt → Set ConsEl A n = El (consD A) (Vec A) n VecEl : (A : Set) → ℕ tt → Set VecEl A n = El (VecD A) (Vec A) n NilHyps : (A : Set) (P : (n : ℕ tt) → Vec A n → Set) (n : ℕ tt) (xs : NilEl A n) → Set NilHyps A P n xs = Hyps (nilD A) (Vec A) P n xs ConsHyps : (A : Set) (P : (n : ℕ tt) → Vec A n → Set) (n : ℕ tt) (xs : ConsEl A n) → Set ConsHyps A P n xs = Hyps (consD A) (Vec A) P n xs VecHyps : (A : Set) (P : (n : ℕ tt) → Vec A n → Set) (n : ℕ tt) (xs : VecEl A n) → Set VecHyps A P n xs = Hyps (VecD A) (Vec A) P n xs ConsUncurriedHyps : (A : Set) (P : (n : ℕ tt) → Vec A n → Set) (cn : UncurriedEl (consD A) (Vec A)) → Set ConsUncurriedHyps A P cn = UncurriedHyps (consD A) (Vec A) P cn nil : (A : Set) → Vec A zero nil A = init (nilT , refl) cons : (A : Set) (n : ℕ tt) (x : A) (xs : Vec A n) → Vec A (suc n) cons A n x xs = init (consT , n , x , xs , refl) nil2 : (A : Set) → Vec A zero nil2 A = inj (VecD A) nilT cons2 : (A : Set) (n : ℕ tt) (x : A) (xs : Vec A n) → Vec A (suc n) cons2 A = inj (VecD A) consT ---------------------------------------------------------------------- module Induction where add : ℕ tt → ℕ tt → ℕ tt add = ind ℕD (λ _ _ → ℕ tt → ℕ tt) (λ u t,c → case (λ t → (c : El (ℕC t) ℕ u) (ih : Hyps ℕD ℕ (λ u n → ℕ u → ℕ u) u (t , c)) → ℕ u → ℕ u ) ( (λ q ih n → n) , (λ m,q ih,tt n → suc (proj₁ ih,tt n)) , tt ) (proj₁ t,c) (proj₂ t,c) ) tt mult : ℕ tt → ℕ tt → ℕ tt mult = ind ℕD (λ _ _ → ℕ tt → ℕ tt) (λ u t,c → case (λ t → (c : El (ℕC t) ℕ u) (ih : Hyps ℕD ℕ (λ u n → ℕ u → ℕ u) u (t , c)) → ℕ u → ℕ u ) ( (λ q ih n → zero) , (λ m,q ih,tt n → add n (proj₁ ih,tt n)) , tt ) (proj₁ t,c) (proj₂ t,c) ) tt append : (A : Set) (m : ℕ tt) (xs : Vec A m) (n : ℕ tt) (ys : Vec A n) → Vec A (add m n) append A = ind (VecD A) (λ m xs → (n : ℕ tt) (ys : Vec A n) → Vec A (add m n)) (λ m t,c → case (λ t → (c : El (VecC A t) (Vec A) m) (ih : Hyps (VecD A) (Vec A) (λ m xs → (n : ℕ tt) (ys : Vec A n) → Vec A (add m n)) m (t , c)) (n : ℕ tt) (ys : Vec A n) → Vec A (add m n) ) ( (λ q ih n ys → subst (λ m → Vec A (add m n)) q ys) , (λ m',x,xs,q ih,tt n ys → let m' = proj₁ m',x,xs,q x = proj₁ (proj₂ m',x,xs,q) q = proj₂ (proj₂ (proj₂ m',x,xs,q)) ih = proj₁ ih,tt in subst (λ m → Vec A (add m n)) q (cons A (add m' n) x (ih n ys)) ) , tt ) (proj₁ t,c) (proj₂ t,c) ) Concat : (A : Set) (m n : ℕ tt) (xss : Vec (Vec A m) n) → Set Concat A m n xss = Vec A (mult n m) ConsBranch : (A : Set) (m : ℕ tt) → Set ConsBranch A m = UncurriedHyps (consD (Vec A m)) (Vec (Vec A m)) (Concat A m) (λ xs → init (consT , xs)) ConsElimBranch : (A : Set) (m : ℕ tt) → Set ConsElimBranch A m = CurriedHyps (consD (Vec A m)) (Vec (Vec A m)) (Concat A m) (λ xs → init (consT , xs)) ElimBranch : (t : VecT) (A : Set) (m : ℕ tt) → Set ElimBranch t A m = SumCurriedHyps VecE (VecC (Vec A m)) (Concat A m) t nilBranch : (A : Set) (m n : ℕ tt) (xss : NilEl (Vec A m) n) (ihs : NilHyps (Vec A m) (Concat A m) n xss) → Vec A (mult n m) nilBranch A m n q u = subst (λ n → Vec A (mult n m)) q (nil A) consBranch : (A : Set) (m : ℕ tt) → ConsBranch A m consBranch A m n n',xs,xss,q ih,u = let n' = proj₁ n',xs,xss,q xs = proj₁ (proj₂ n',xs,xss,q) q = proj₂ (proj₂ (proj₂ n',xs,xss,q)) ih = proj₁ ih,u in subst (λ n → Vec A (mult n m)) q (append A m xs (mult n' m) ih) ConcatConvoy : (A : Set) (m n : ℕ tt) (t : VecT) → Set ConcatConvoy A m n t = (xss : El (VecC (Vec A m) t) (Vec (Vec A m)) n) (ihs : VecHyps (Vec A m) (Concat A m) n (t , xss)) → Vec A (mult n m) concatα : (A : Set) (m n : ℕ tt) (xss : VecEl (Vec A m) n) (ihs : VecHyps (Vec A m) (Concat A m) n xss) → Vec A (mult n m) concatα A m n xss = case (ConcatConvoy A m n) (nilBranch A m n , consBranch A m n , tt) (proj₁ xss) (proj₂ xss) concat : (A : Set) (m n : ℕ tt) (xss : Vec (Vec A m) n) → Concat A m n xss concat A m = ind (VecD (Vec A m)) (Concat A m) (concatα A m) ---------------------------------------------------------------------- module GenericElim where add : ℕ tt → ℕ tt → ℕ tt add = elim ℕE ℕC _ (λ n → n) (λ m ih n → suc (ih n)) tt mult : ℕ tt → ℕ tt → ℕ tt mult = elim ℕE ℕC _ (λ 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 = elim VecE (VecC A) (λ m xs → (n : ℕ tt) (ys : Vec A n) → Vec A (add m n)) (λ 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 = elim VecE (VecC (Vec A m)) (λ n xss → Vec A (mult n m)) (nil A) (λ n xs xss ih → append A m xs (mult n m) ih) ----------------------------------------------------------------------
{ "alphanum_fraction": 0.4855755333, "avg_line_length": 29.7199312715, "ext": "agda", "hexsha": "a160e08b22d4041f49aecbd6ced76f02cf860dda", "lang": "Agda", "max_forks_count": 2, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:31:22.000Z", "max_forks_repo_forks_event_min_datetime": "2016-05-02T08:56:15.000Z", "max_forks_repo_head_hexsha": "832383d7adf37aa2364213fb0aeb67e9f61a248f", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "larrytheliquid/generic-elim", "max_forks_repo_path": "src/GenericElim/Desc.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "832383d7adf37aa2364213fb0aeb67e9f61a248f", "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": "larrytheliquid/generic-elim", "max_issues_repo_path": "src/GenericElim/Desc.agda", "max_line_length": 106, "max_stars_count": 11, "max_stars_repo_head_hexsha": "832383d7adf37aa2364213fb0aeb67e9f61a248f", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "larrytheliquid/generic-elim", "max_stars_repo_path": "src/GenericElim/Desc.agda", "max_stars_repo_stars_event_max_datetime": "2021-09-09T08:46:42.000Z", "max_stars_repo_stars_event_min_datetime": "2015-06-02T14:05:20.000Z", "num_tokens": 7211, "size": 17297 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Bounded vectors (inefficient, concrete implementation) ------------------------------------------------------------------------ -- Vectors of a specified maximum length. {-# OPTIONS --without-K --safe #-} module Data.BoundedVec.Inefficient where open import Data.Nat.Base open import Data.List.Base ------------------------------------------------------------------------ -- The type infixr 5 _∷_ data BoundedVec {a} (A : Set a) : ℕ → Set a where [] : ∀ {n} → BoundedVec A n _∷_ : ∀ {n} (x : A) (xs : BoundedVec A n) → BoundedVec A (suc n) ------------------------------------------------------------------------ -- Increasing the bound -- Note that this operation is linear in the length of the list. ↑ : ∀ {a n} {A : Set a} → BoundedVec A n → BoundedVec A (suc n) ↑ [] = [] ↑ (x ∷ xs) = x ∷ ↑ xs ------------------------------------------------------------------------ -- Conversions fromList : ∀ {a} {A : Set a} → (xs : List A) → BoundedVec A (length xs) fromList [] = [] fromList (x ∷ xs) = x ∷ fromList xs toList : ∀ {a n} {A : Set a} → BoundedVec A n → List A toList [] = [] toList (x ∷ xs) = x ∷ toList xs
{ "alphanum_fraction": 0.4248210024, "avg_line_length": 28.5681818182, "ext": "agda", "hexsha": "3292e48e365de48e5d373bbb0f44127d2b434a97", "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/BoundedVec/Inefficient.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/BoundedVec/Inefficient.agda", "max_line_length": 72, "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/BoundedVec/Inefficient.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 316, "size": 1257 }
{-# OPTIONS --rewriting --prop #-} open import common hiding (_===_) {- Syntax of term- and type-expressions, using de Bruijn indices -} variable {n} {m} {k} : ℕ data Expr : SyntaxSort → ℕ → Set TyExpr = Expr Ty TmExpr = Expr Tm data Expr where uu : {n : ℕ} → TyExpr n el : {n : ℕ} (v : TmExpr n) → TyExpr n pi : {n : ℕ} (A : TyExpr n) (B : TyExpr (suc n)) → TyExpr n var : {n : ℕ} (x : VarPos n) → TmExpr n lam : {n : ℕ} (A : TyExpr n) (B : TyExpr (suc n)) (u : TmExpr (suc n)) → TmExpr n app : {n : ℕ} (A : TyExpr n) (B : TyExpr (suc n)) (f : TmExpr n) (a : TmExpr n) → TmExpr n data Ctx : ℕ → Set where ◇ : Ctx 0 _,_ : {n : ℕ} (Γ : Ctx n) (A : TyExpr n) → Ctx (suc n) {- The four different forms of (pre)judgments. -} data Judgment : Set where _⊢_ : {n : ℕ} (Γ : Ctx n) → TyExpr n → Judgment _⊢_:>_ : {n : ℕ} (Γ : Ctx n) → TmExpr n → TyExpr n → Judgment _⊢_==_ : {n : ℕ} (Γ : Ctx n) → TyExpr n → TyExpr n → Judgment _⊢_==_:>_ : {n : ℕ} (Γ : Ctx n) → TmExpr n → TmExpr n → TyExpr n → Judgment -- weakenV : {n : ℕ} (p : WeakPos n) → VarPos n → VarPos (suc n) -- weakenV last x = prev x -- weakenV (prev p) last = last -- weakenV (prev p) (prev x) = prev (weakenV p x) weaken : {n : ℕ} {k : SyntaxSort} (p : WeakPos n) → Expr k n → Expr k (suc n) weaken p uu = uu weaken p (el v) = el (weaken p v) weaken p (pi A B) = pi (weaken p A) (weaken (prev p) B) weaken p (var x) = var (weakenV p x) weaken p (lam A B u) = lam (weaken p A) (weaken (prev p) B) (weaken (prev p) u) weaken p (app A B f a) = app (weaken p A) (weaken (prev p) B) (weaken p f) (weaken p a) -- data Mor (n m : ℕ) : ℕ → Set where -- ◇ : Mor n m 0 -- _,_ : {k : ℕ} (δ : Mor n m k) (u : TmExpr (n + m)) → Mor n m (suc k) -- weakenMor : Mor n m k → Mor n (suc m) k -- weakenMor ◇ = ◇ -- weakenMor (δ , u) = (weakenMor δ , weaken last u) -- weakenMor+ : Mor n m k → Mor n (suc m) (suc k) -- weakenMor+ δ = weakenMor δ , var last data Mor (m : ℕ) : ℕ → Set where ◇ : Mor m 0 _,_ : {k : ℕ} (δ : Mor m k) (u : TmExpr m) → Mor m (suc k) weakenMor : Mor m k → Mor (suc m) k weakenMor ◇ = ◇ weakenMor (δ , u) = (weakenMor δ , weaken last u) weakenMor+ : Mor m k → Mor (suc m) (suc k) weakenMor+ δ = weakenMor δ , var last weakV : {n m : ℕ} → VarPos n → VarPos (n + m) weakV {m = zero} x = x weakV {m = suc m} x = prev (weakV x) infix 30 _[_] -- _[_] : {p : SyntaxSort} (A : Expr p (n + k)) (δ : Mor n m k) → Expr p (n + m) _[_] : {p : SyntaxSort} (A : Expr p k) (δ : Mor m k) → Expr p m uu [ δ ] = uu el v [ δ ] = el (v [ δ ]) pi A B [ δ ] = pi (A [ δ ]) (B [ weakenMor+ δ ]) var last [ δ , u ] = u var (prev x) [ δ , u ] = var x [ δ ] lam A B u [ δ ] = lam (A [ δ ]) (B [ weakenMor+ δ ]) (u [ weakenMor+ δ ]) app A B f a [ δ ] = app (A [ δ ]) (B [ weakenMor+ δ ]) (f [ δ ]) (a [ δ ]) idMor : Mor n n idMor {zero} = ◇ idMor {suc n} = (weakenMor idMor , var last) subst : {n : ℕ} {k : SyntaxSort} → Expr k (suc n) → TmExpr n → Expr k n subst e a = e [ idMor , a ] get : {n : ℕ} → VarPos n → Ctx n → TyExpr n get last (Γ , A) = weaken last A get (prev k) (Γ , A) = weaken last (get k Γ) {- Derivability of judgments, the typing rules of the type theory -} data Derivable : Judgment → Prop where -- Variable rules Var : {n : ℕ} {Γ : Ctx n} (k : VarPos n) → Derivable (Γ ⊢ get k Γ) → Derivable (Γ ⊢ var k :> get k Γ) -- Symmetry and transitivity for types TyRefl : {n : ℕ} {Γ : Ctx n} {A : TyExpr n} → Derivable (Γ ⊢ A) → Derivable (Γ ⊢ A == A) TySymm : {n : ℕ} {Γ : Ctx n} {A B : TyExpr n} → Derivable (Γ ⊢ A == B) → Derivable (Γ ⊢ B == A) TyTran : {n : ℕ} {Γ : Ctx n} {A B C : TyExpr n} → Derivable (Γ ⊢ A == B)→ Derivable (Γ ⊢ B == C) → Derivable (Γ ⊢ A == C) -- Symmetry and transitivity for terms TmRefl : {n : ℕ} {Γ : Ctx n} {A : TyExpr n} {u : TmExpr n} → Derivable (Γ ⊢ u :> A) → Derivable (Γ ⊢ u == u :> A) TmSymm : {n : ℕ} {Γ : Ctx n} {u v : TmExpr n} {A : TyExpr n} → Derivable (Γ ⊢ u == v :> A) → Derivable (Γ ⊢ v == u :> A) TmTran : {n : ℕ} {Γ : Ctx n} {u v w : TmExpr n} {A : TyExpr n} → Derivable (Γ ⊢ u == v :> A)→ Derivable (Γ ⊢ v == w :> A) → Derivable (Γ ⊢ u == w :> A) -- Conversion rules Conv : {n : ℕ} {Γ : Ctx n} {u : TmExpr n} {A B : TyExpr n} → Derivable (Γ ⊢ u :> A) → Derivable (Γ ⊢ A == B) → Derivable (Γ ⊢ u :> B) ConvEq : {n : ℕ} {Γ : Ctx n} {u u' : TmExpr n} {A B : TyExpr n} → Derivable (Γ ⊢ u == u' :> A) → Derivable (Γ ⊢ A == B) → Derivable (Γ ⊢ u == u' :> B) -- Rules for UU UU : {n : ℕ} {Γ : Ctx n} → Derivable (Γ ⊢ uu) UUCong : {n : ℕ} {Γ : Ctx n} → Derivable (Γ ⊢ uu == uu) -- Rules for El El : {n : ℕ} {Γ : Ctx n} {v : TmExpr n} → Derivable (Γ ⊢ v :> uu) → Derivable (Γ ⊢ el v) ElCong : {n : ℕ} {Γ : Ctx n} {v v' : TmExpr n} → {- Derivable (Γ ⊢ v :> uu) → Derivable (Γ ⊢ v' :> uu) → -} Derivable (Γ ⊢ v == v' :> uu) → Derivable (Γ ⊢ el v == el v') -- Rules for Pi Pi : {n : ℕ} {Γ : Ctx n} {A : TyExpr n} {B : TyExpr (suc n)} → Derivable (Γ ⊢ A) → Derivable ((Γ , A) ⊢ B) → Derivable (Γ ⊢ pi A B) PiCong : {n : ℕ} {Γ : Ctx n} {A A' : TyExpr n} {B B' : TyExpr (suc n)} → {- Derivable (Γ ⊢ A) → Derivable (Γ ⊢ A') → -} Derivable (Γ ⊢ A == A') → {- Derivable ((Γ , A) ⊢ B) → Derivable ((Γ , A') ⊢ B') → -} Derivable ((Γ , A) ⊢ B == B') → Derivable (Γ ⊢ pi A B == pi A' B') -- Rules for lambda Lam : {n : ℕ} {Γ : Ctx n} {A : TyExpr n} {B : TyExpr (suc n)} {u : TmExpr (suc n)} → Derivable (Γ ⊢ A) → Derivable ((Γ , A) ⊢ B) → Derivable ((Γ , A) ⊢ u :> B) → Derivable (Γ ⊢ lam A B u :> pi A B) LamCong : {n : ℕ} {Γ : Ctx n} {A A' : TyExpr n} {B B' : TyExpr (suc n)} {u u' : TmExpr (suc n)} → {- Derivable (Γ ⊢ A) → Derivable (Γ ⊢ A') → -} Derivable (Γ ⊢ A == A') → {- Derivable ((Γ , A) ⊢ B) → Derivable ((Γ , A') ⊢ B') → -} Derivable ((Γ , A) ⊢ B == B') → {- Derivable ((Γ , A) ⊢ u :> B) → Derivable ((Γ , A') ⊢ u' :> B') → -} Derivable ((Γ , A) ⊢ u == u' :> B) → Derivable (Γ ⊢ lam A B u == lam A' B' u' :> pi A B) -- Rules for app App : {n : ℕ} {Γ : Ctx n} {A : TyExpr n} {B : TyExpr (suc n)} {f a : TmExpr n} → Derivable (Γ ⊢ A) → Derivable ((Γ , A) ⊢ B) → Derivable (Γ ⊢ f :> pi A B) → Derivable (Γ ⊢ a :> A) → Derivable (Γ ⊢ app A B f a :> subst B a) AppCong : {n : ℕ} {Γ : Ctx n} {A A' : TyExpr n} {B B' : TyExpr (suc n)} {f f' a a' : TmExpr n} → {- Derivable (Γ ⊢ A) → Derivable (Γ ⊢ A') → -} Derivable (Γ ⊢ A == A') → {- Derivable ((Γ , A) ⊢ B) → Derivable ((Γ , A') ⊢ B') → -} Derivable ((Γ , A) ⊢ B == B') → {- Derivable (Γ ⊢ f :> pi A B) → Derivable (Γ ⊢ f' :> pi A' B') → -} Derivable (Γ ⊢ f == f' :> pi A B) → {- Derivable (Γ ⊢ a :> A) → Derivable (Γ ⊢ a' :> A') → -} Derivable (Γ ⊢ a == a' :> A) → Derivable (Γ ⊢ app A B f a == app A' B' f' a' :> subst B a) -- Equality rules BetaPi : {n : ℕ} {Γ : Ctx n} {A : TyExpr n} {B : TyExpr (suc n)} {u : TmExpr (suc n)} {a : TmExpr n} → Derivable (Γ ⊢ A) → Derivable ((Γ , A) ⊢ B) → Derivable ((Γ , A) ⊢ u :> B) → Derivable (Γ ⊢ a :> A) → Derivable (Γ ⊢ app A B (lam A B u) a == subst u a :> subst B a) EtaPi : {n : ℕ} {Γ : Ctx n} {A : TyExpr n} {B : TyExpr (suc n)} {f : TmExpr n} → Derivable (Γ ⊢ A) → Derivable ((Γ , A) ⊢ B) → Derivable (Γ ⊢ f :> pi A B) → Derivable (Γ ⊢ f == lam A B (app (weaken last A) (weaken (prev last) B) (weaken last f) (var last)) :> pi A B) data DepCtx (n : ℕ) : ℕ → Set where ◇ : DepCtx n 0 _,_ : {m : ℕ} → DepCtx n m → TyExpr (n + m) → DepCtx n (suc m) _++_ : {n m : ℕ} → Ctx n → DepCtx n m → Ctx (n + m) Γ ++ ◇ = Γ Γ ++ (Δ , A) = (Γ ++ Δ) , A infixl 30 _++_ _-WeakPos_ : (n : ℕ) → WeakPos n → ℕ n -WeakPos last = n suc n -WeakPos prev k = n -WeakPos k weakenCtx : (k : WeakPos n) (Γ : Ctx n) (T : TyExpr (n -WeakPos k)) → Ctx (suc n) weakenCtx last Γ T = Γ , T weakenCtx (prev k) (Γ , A) T = weakenCtx k Γ T , weaken k A -- data _⊢_===_ (Γ : Ctx n) : DepCtx n m → DepCtx n m → Prop where -- tt : Γ ⊢ ◇ === ◇ -- _,_ : {Δ Δ' : DepCtx n m} {A A' : TyExpr (n + m)} → (Γ ⊢ Δ === Δ') → Derivable ((Γ ++ Δ) ⊢ A == A') → Γ ⊢ (Δ , A) === (Δ' , A') -- data _⊢_∷>_⇒_ (Γ : Ctx n) : Mor n m k → DepCtx n m → DepCtx n k → Prop where -- tt : {Δ : DepCtx n m} → Γ ⊢ ◇ ∷> Δ ⇒ ◇ -- _,_ : {Δ : DepCtx n m} {Δ' : DepCtx n k} {δ : Mor n m k} {u : TmExpr (n + m)} {A : TyExpr (n + k)} -- → Γ ⊢ δ ∷> Δ ⇒ Δ' -- → Derivable (Γ ++ Δ ⊢ u :> (A [ δ ])) -- → Γ ⊢ (δ , u) ∷> Δ ⇒ (Δ' , A) -- WeakTy : {k : WeakPos n} {Γ : Ctx n} {T : TyExpr (n -WeakPos k)} {A : TyExpr n} -- → Derivable (Γ ⊢ A) → Derivable (weakenCtx k Γ T ⊢ weaken k A) -- WeakTy= : {k : WeakPos n} {Γ : Ctx n} {T : TyExpr (n -WeakPos k)} {A B : TyExpr n} -- → Derivable (Γ ⊢ A == B) → Derivable (weakenCtx k Γ T ⊢ weaken k A == weaken k B) -- WeakTm : {k : WeakPos n} {Γ : Ctx n} {T : TyExpr (n -WeakPos k)} {u : TmExpr n} {A : TyExpr n} -- → Derivable (Γ ⊢ u :> A) → Derivable (weakenCtx k Γ T ⊢ weaken k u :> weaken k A) -- WeakTm= : {k : WeakPos n} {Γ : Ctx n} {T : TyExpr (n -WeakPos k)} {u v : TmExpr n} {A : TyExpr n} -- → Derivable (Γ ⊢ u == v :> A) → Derivable (weakenCtx k Γ T ⊢ weaken k u == weaken k v :> weaken k A) -- WeakTy UU = UU -- WeakTy (El dv) = El (WeakTm dv) -- WeakTy (Pi dA dB) = Pi (WeakTy dA) (WeakTy dB) -- WeakTy= (TyRefl dA) = TyRefl (WeakTy dA) -- WeakTy= (TySymm dA=) = TySymm (WeakTy= dA=) -- WeakTy= (TyTran dA= dB=) = TyTran (WeakTy= dA=) (WeakTy= dB=) -- WeakTy= UUCong = UUCong -- WeakTy= (ElCong dv dv' dv=) = ElCong (WeakTm dv) (WeakTm dv') (WeakTm= dv=) -- WeakTy= (PiCong dA dA' dA= dB dB' dB=) = PiCong (WeakTy dA) (WeakTy dA') (WeakTy= dA=) (WeakTy dB) (WeakTy dB') (WeakTy= dB=) -- WeakTm (Var k dA) = Conv (Var (weakenV _ k) {!!}) {!!} -- WeakTm (Conv du dA=) = Conv (WeakTm du) (WeakTy= dA=) -- WeakTm (Lam dA dB du) = Lam (WeakTy dA) (WeakTy dB) (WeakTm du) -- WeakTm (App dA dB df da) = Conv (App (WeakTy dA) (WeakTy dB) (WeakTm df) (WeakTm da)) {!!} -- WeakTm= (TmRefl du) = TmRefl (WeakTm du) -- WeakTm= (TmSymm du=) = TmSymm (WeakTm= du=) -- WeakTm= (TmTran du= dv=) = TmTran (WeakTm= du=) (WeakTm= dv=) -- WeakTm= (ConvEq du= dA=) = ConvEq (WeakTm= du=) (WeakTy= dA=) -- WeakTm= (LamCong dA dA' dA= dB dB' dB= du du' du=) = LamCong (WeakTy dA) (WeakTy dA') (WeakTy= dA=) (WeakTy dB) (WeakTy dB') (WeakTy= dB=) (WeakTm du) (WeakTm du') (WeakTm= du=) -- WeakTm= (AppCong dA dA' dA= dB dB' dB= df df' df= da da' da=) = ConvEq (AppCong (WeakTy dA) (WeakTy dA') (WeakTy= dA=) (WeakTy dB) (WeakTy dB') (WeakTy= dB=) (WeakTm df) (WeakTm df') (WeakTm= df=) (WeakTm da) (WeakTm da') (WeakTm= da=)) {!!} -- WeakTm= (BetaPi dA dB du da) = ConvEq (TmTran (BetaPi (WeakTy dA) (WeakTy dB) (WeakTm du) (WeakTm da)) {!!}) {!!} -- WeakMor : {Γ : Ctx n} {Δ : DepCtx n m} {Δ' : DepCtx n k} {T : TyExpr (n + m)} {δ : Mor n m k} → Γ ⊢ δ ∷> Δ ⇒ Δ' → Γ ⊢ weakenMor δ ∷> (Δ , T) ⇒ Δ' -- WeakMor tt = tt -- WeakMor (dδ , du) = WeakMor dδ , Conv (WeakTm du) {!!} -- SubstTy : {Γ : Ctx n} {Δ : DepCtx n m} {Δ' : DepCtx n k} {A : TyExpr (n + k)} {δ : Mor n m k} -- → Derivable (Γ ++ Δ' ⊢ A) → Γ ⊢ δ ∷> Δ ⇒ Δ' → Derivable (Γ ++ Δ ⊢ A [ δ ]) -- SubstTy= : {Γ : Ctx n} {Δ : DepCtx n m} {Δ' : DepCtx n k} {A A' : TyExpr (n + k)} {δ : Mor n m k} -- → Derivable (Γ ++ Δ' ⊢ A) → Derivable (Γ ++ Δ' ⊢ A == A') → Γ ⊢ δ ∷> Δ ⇒ Δ' → Derivable (Γ ++ Δ ⊢ A [ δ ] == A' [ δ ]) -- SubstTm : {Γ : Ctx n} {Δ : DepCtx n m} {Δ' : DepCtx n k} {u : TmExpr (n + k)} {A : TyExpr (n + k)} {δ : Mor n m k} -- → Derivable (Γ ++ Δ' ⊢ u :> A) → Γ ⊢ δ ∷> Δ ⇒ Δ' → Derivable (Γ ++ Δ ⊢ u [ δ ] :> A [ δ ]) -- SubstTm= : {Γ : Ctx n} {Δ : DepCtx n m} {Δ' : DepCtx n k} {u u' : TmExpr (n + k)} {A : TyExpr (n + k)} {δ : Mor n m k} -- → Derivable (Γ ++ Δ' ⊢ u == u' :> A) → Γ ⊢ δ ∷> Δ ⇒ Δ' → Derivable (Γ ++ Δ ⊢ u [ δ ] == u' [ δ ] :> A [ δ ]) -- WeakMor+ : {Γ : Ctx n} {Δ : DepCtx n m} {Δ' : DepCtx n k} {A : TyExpr (n + k)} {δ : Mor n m k} → Derivable (Γ ++ Δ' ⊢ A) → Γ ⊢ δ ∷> Δ ⇒ Δ' → Γ ⊢ weakenMor+ δ ∷> (Δ , A [ δ ]) ⇒ (Δ' , A) -- WeakMor+ dA dδ = WeakMor dδ , Conv (Var last (WeakTy (SubstTy dA dδ))) {!syntx!} -- TyEqTy1 : {Γ : Ctx n} {A B : TyExpr n} → Derivable (Γ ⊢ A == B) → Derivable (Γ ⊢ A) -- TyEqTy2 : {Γ : Ctx n} {A B : TyExpr n} → Derivable (Γ ⊢ A == B) → Derivable (Γ ⊢ B) -- TmEqTm1 : {Γ : Ctx n} {u u' : TmExpr n} {A : TyExpr n} → Derivable (Γ ⊢ u == u' :> A) → Derivable (Γ ⊢ u :> A) -- TmEqTm2 : {Γ : Ctx n} {u u' : TmExpr n} {A : TyExpr n} → Derivable (Γ ⊢ u == u' :> A) → Derivable (Γ ⊢ u' :> A) -- SubstTy UU dδ = UU -- SubstTy (El dv) dδ = El (SubstTm dv dδ) -- SubstTy (Pi dA dB) dδ = Pi (SubstTy dA dδ) (SubstTy dB (WeakMor+ dA dδ)) -- -- SubstTy= _ (TyRefl dA) dδ = TyRefl (SubstTy dA dδ) -- -- SubstTy= dA (TySymm dA=) dδ = TySymm (SubstTy= {!!} dA= dδ) -- -- SubstTy= dA (TyTran dA= dB=) dδ = TyTran (SubstTy= dA dA= dδ) (SubstTy= {!!} dB= dδ) -- -- SubstTy= dA UUCong dδ = UUCong -- -- SubstTy= dA (ElCong dv=) dδ = ElCong (SubstTm= dv= dδ) -- -- SubstTy= {Γ = Γ} (Pi dA dB) (PiCong dA= dB=) dδ = PiCong (SubstTy= dA dA= dδ) (SubstTy= dB dB= (WeakMor+ dA dδ)) -- -- SubstTm (Var k du) dδ = {!!} -- -- SubstTm (Conv du dA=) dδ = Conv (SubstTm du dδ) (SubstTy= dA= dδ) -- -- SubstTm (Lam dA dB du) dδ = Lam (SubstTy dA dδ) (SubstTy dB (WeakMor+ dA dδ)) (SubstTm du (WeakMor+ dA dδ)) -- -- SubstTm (App dA dB df da) dδ = Conv (App (SubstTy dA dδ) (SubstTy dB (WeakMor+ dA dδ)) (SubstTm df dδ) (SubstTm da dδ)) {!!} -- -- SubstTm= (TmRefl du) dδ = TmRefl (SubstTm du dδ) -- -- SubstTm= (TmSymm du=) dδ = TmSymm (SubstTm= du= dδ) -- -- SubstTm= (TmTran du= dv=) dδ = TmTran (SubstTm= du= dδ) (SubstTm= dv= dδ) -- -- SubstTm= (ConvEq du= dA=) dδ = ConvEq (SubstTm= du= dδ) (SubstTy= dA= dδ) -- -- SubstTm= (LamCong dA= dB= du=) dδ = LamCong (SubstTy= dA= dδ) (SubstTy= dB= (WeakMor+ {!TyEqTy1 dA=!} dδ)) (SubstTm= du= (WeakMor+ {!TyEqTy1 dA=!} dδ)) -- -- SubstTm= (AppCong dA= dB= df= da=) dδ = ConvEq (AppCong (SubstTy= dA= dδ) (SubstTy= dB= (WeakMor+ {!TyEqTy1 dA=!} dδ)) (SubstTm= df= dδ) (SubstTm= da= dδ)) {!stx!} -- -- SubstTm= (BetaPi dA dB du da) dδ = ConvEq (TmTran (BetaPi (SubstTy dA dδ) (SubstTy dB (WeakMor+ dA dδ)) (SubstTm du (WeakMor+ dA dδ)) (SubstTm da dδ)) {!!}) {!!} -- -- ConvTy : {n m : ℕ} {Γ : Ctx n} {Δ Δ' : DepCtx n m} {A : TyExpr (n + m)} → Derivable ((Γ ++ Δ) ⊢ A) → (Γ ⊢ Δ === Δ') → Derivable ((Γ ++ Δ') ⊢ A) -- -- ConvTy= : {n m : ℕ} {Γ : Ctx n} {Δ Δ' : DepCtx n m} {A A' : TyExpr (n + m)} → Derivable ((Γ ++ Δ) ⊢ A == A') → (Γ ⊢ Δ === Δ') → Derivable ((Γ ++ Δ') ⊢ A == A') -- -- ConvTm : {n m : ℕ} {Γ : Ctx n} {Δ Δ' : DepCtx n m} {A : TyExpr (n + m)} {u : TmExpr (n + m)} → Derivable ((Γ ++ Δ) ⊢ u :> A) → (Γ ⊢ Δ === Δ') → Derivable ((Γ ++ Δ') ⊢ u :> A) -- -- ConvTm= : {n m : ℕ} {Γ : Ctx n} {Δ Δ' : DepCtx n m} {A : TyExpr (n + m)} {u u' : TmExpr (n + m)} → Derivable ((Γ ++ Δ) ⊢ u == u' :> A) → (Γ ⊢ Δ === Δ') → Derivable ((Γ ++ Δ') ⊢ u == u' :> A) -- -- ConvTy UU dΔ= = UU -- -- ConvTy (El dv) dΔ= = El (ConvTm dv dΔ=) -- -- ConvTy (Pi dA dB) dΔ= = Pi (ConvTy dA dΔ=) (ConvTy dB (dΔ= , TyRefl dA)) -- -- ConvTy= (TyRefl dA) dΔ= = TyRefl (ConvTy dA dΔ=) -- -- ConvTy= (TySymm dA=) dΔ= = TySymm (ConvTy= dA= dΔ=) -- -- ConvTy= (TyTran dA= dB=) dΔ= = TyTran (ConvTy= dA= dΔ=) (ConvTy= dB= dΔ=) -- -- ConvTy= UUCong dΔ= = UUCong -- -- ConvTy= (ElCong dv=) dΔ= = ElCong (ConvTm= dv= dΔ=) -- -- ConvTy= (PiCong dA= dB=) dΔ= = PiCong (ConvTy= dA= dΔ=) (ConvTy= dB= (dΔ= , {!ok!})) -- -- ConvTm (Var k du) dΔ= = Conv (Var k (ConvTy {!TODO!} dΔ=)) {!TODO!} -- -- ConvTm (Conv du dA=) dΔ= = Conv (ConvTm du dΔ=) (ConvTy= dA= dΔ=) -- -- ConvTm (Lam dA dB du) dΔ= = Lam (ConvTy dA dΔ=) (ConvTy dB (dΔ= , TyRefl dA)) (ConvTm du (dΔ= , TyRefl dA)) -- -- ConvTm (App dA dB df da) dΔ= = App (ConvTy dA dΔ=) (ConvTy dB (dΔ= , TyRefl dA)) (ConvTm df dΔ=) (ConvTm da dΔ=) -- -- ConvTm= (TmRefl du) dΔ= = TmRefl (ConvTm du dΔ=) -- -- ConvTm= (TmSymm du=) dΔ= = TmSymm (ConvTm= du= dΔ=) -- -- ConvTm= (TmTran du= dv=) dΔ= = TmTran (ConvTm= du= dΔ=) (ConvTm= dv= dΔ=) -- -- ConvTm= (ConvEq du= dA=) dΔ= = ConvEq (ConvTm= du= dΔ=) (ConvTy= dA= dΔ=) -- -- ConvTm= (LamCong dA= dB= du=) dΔ= = LamCong (ConvTy= dA= dΔ=) (ConvTy= dB= (dΔ= , {!ok!})) (ConvTm= du= (dΔ= , {!ok!})) -- -- ConvTm= (AppCong dA= dB= df= da=) dΔ= = AppCong (ConvTy= dA= dΔ=) (ConvTy= dB= (dΔ= , {!ok!})) (ConvTm= df= dΔ=) (ConvTm= da= dΔ=) -- -- ConvTm= (BetaPi dA dB du da) dΔ= = BetaPi (ConvTy dA dΔ=) (ConvTy dB (dΔ= , TyRefl dA)) (ConvTm du (dΔ= , TyRefl dA)) (ConvTm da dΔ=) -- -- TyEqTy1 (TyRefl dA) = dA -- -- TyEqTy1 (TySymm dA=) = TyEqTy2 dA= -- -- TyEqTy1 (TyTran dA= dB=) = TyEqTy1 dA= -- -- TyEqTy1 UUCong = UU -- -- TyEqTy1 (ElCong du=) = El (TmEqTm1 du=) -- -- TyEqTy1 (PiCong dA= dB=) = Pi (TyEqTy1 dA=) (TyEqTy1 dB=) -- -- TyEqTy2 (TyRefl dA) = dA -- -- TyEqTy2 (TySymm dA=) = TyEqTy1 dA= -- -- TyEqTy2 (TyTran dA= dB=) = TyEqTy2 dB= -- -- TyEqTy2 UUCong = UU -- -- TyEqTy2 (ElCong du=) = El (TmEqTm2 du=) -- -- TyEqTy2 (PiCong dA= dB=) = Pi (TyEqTy2 dA=) (ConvTy (TyEqTy2 dB=) (tt , dA=)) -- -- TmEqTm1 (TmRefl du) = du -- -- TmEqTm1 (TmSymm du=) = TmEqTm2 du= -- -- TmEqTm1 (TmTran du= dv=) = TmEqTm1 du= -- -- TmEqTm1 (ConvEq du= dA=) = Conv (TmEqTm1 du=) dA= -- -- TmEqTm1 (LamCong dA= dB= du=) = Lam (TyEqTy1 dA=) (TyEqTy1 dB=) (TmEqTm1 du=) -- -- TmEqTm1 (AppCong dA= dB= df= da=) = App (TyEqTy1 dA=) (TyEqTy1 dB=) (TmEqTm1 df=) (TmEqTm1 da=) -- -- TmEqTm1 (BetaPi dA dB du da) = App dA dB (Lam dA dB du) da -- -- TmEqTm2 (TmRefl du) = du -- -- TmEqTm2 (TmSymm du=) = TmEqTm1 du= -- -- TmEqTm2 (TmTran du= dv=) = TmEqTm2 dv= -- -- TmEqTm2 (ConvEq du= dA=) = Conv (TmEqTm2 du=) dA= -- -- TmEqTm2 (LamCong dA= dB= du=) = Conv (Lam (TyEqTy2 dA=) (ConvTy (TyEqTy2 dB=) (tt , dA=)) (ConvTm (Conv (TmEqTm2 du=) dB=) (tt , dA=))) (PiCong (TySymm dA=) (ConvTy= (TySymm dB=) (tt , dA=))) -- -- TmEqTm2 (AppCong dA= dB= df= da=) = Conv (App (TyEqTy2 dA=) (ConvTy (TyEqTy2 dB=) (tt , dA=)) (Conv (TmEqTm2 df=) (PiCong dA= dB=)) (Conv (TmEqTm2 da=) dA=)) {!TySymm (SubstTy= dB= (tt , {!da=!}))!} -- -- TmEqTm2 (BetaPi dA dB du da) = {!SubstTm du (tt , {!da!})!}
{ "alphanum_fraction": 0.5132905084, "avg_line_length": 52.1907514451, "ext": "agda", "hexsha": "c6c09eddb61be1d168c07159c1598d6a7aedd269", "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": "f9bfefd0a70ae5bdc3906829ee1165c731882bca", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "guillaumebrunerie/general-type-theories", "max_forks_repo_path": "traditional.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "f9bfefd0a70ae5bdc3906829ee1165c731882bca", "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": "guillaumebrunerie/general-type-theories", "max_issues_repo_path": "traditional.agda", "max_line_length": 244, "max_stars_count": null, "max_stars_repo_head_hexsha": "f9bfefd0a70ae5bdc3906829ee1165c731882bca", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "guillaumebrunerie/general-type-theories", "max_stars_repo_path": "traditional.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 8816, "size": 18058 }
{-# OPTIONS --universe-polymorphism #-} module TrustMe where open import Common.Equality postulate A : Set x : A eq : x ≡ x eq = primTrustMe evaluates-to-refl : sym (sym eq) ≡ eq evaluates-to-refl = refl
{ "alphanum_fraction": 0.6807511737, "avg_line_length": 13.3125, "ext": "agda", "hexsha": "cd667cd6e22dc66726c2c85ca7bb8823e6fdf365", "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/TrustMe.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/TrustMe.agda", "max_line_length": 39, "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/TrustMe.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": 69, "size": 213 }
-- Eta contraction didn't consider hiding when contracting, -- leading to the following module not type checking. module Issue259 where postulate A : Set B : A → Set foo : (∀ x → B x) → A q : ∀ {x} → B x foo′ : (∀ {x} → B x) → A bar : A bar = foo (λ y → q {y}) Baz : B bar → Set → Set Baz b C with C Baz b C | _ = C -- In fact you're not allowed to eta contract hidden lambdas at all. bar′ : A bar′ = foo′ (λ {y} → q {y}) Baz′ : B bar′ → Set → Set Baz′ b C with C Baz′ b C | _ = C
{ "alphanum_fraction": 0.5621301775, "avg_line_length": 18.7777777778, "ext": "agda", "hexsha": "ed6332e1b31ebcfb43c86d4e4dad168b2900ea7a", "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/Issue259.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/Issue259.agda", "max_line_length": 68, "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/Issue259.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": 193, "size": 507 }
module Issue728 where open import Common.MAlonzo using () renaming (main to mainDefault) main = mainDefault
{ "alphanum_fraction": 0.7909090909, "avg_line_length": 18.3333333333, "ext": "agda", "hexsha": "493e2cba0be269698d572da0c3c252928240805e", "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/Compiler/simple/Issue728.agda", "max_issues_count": 16, "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_issues_event_max_datetime": "2019-09-08T13:47:04.000Z", "max_issues_repo_issues_event_min_datetime": "2018-10-08T00:32:04.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "shlevy/agda", "max_issues_repo_path": "test/Compiler/simple/Issue728.agda", "max_line_length": 66, "max_stars_count": 7, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "test/Compiler/simple/Issue728.agda", "max_stars_repo_stars_event_max_datetime": "2018-11-06T16:38:43.000Z", "max_stars_repo_stars_event_min_datetime": "2018-11-05T22:13:36.000Z", "num_tokens": 26, "size": 110 }
-- Andreas, 2020-09-09, issue #4880 -- Make sure that duplicate hiding info is an error. module _ (A B : Set) where postulate _ : { { A } } → B -- Expected: ERROR or WARNING -- For instance: -- {A} cannot appear by itself. It needs to be the argument to a -- function expecting an implicit argument. -- when scope checking {A}
{ "alphanum_fraction": 0.6777108434, "avg_line_length": 23.7142857143, "ext": "agda", "hexsha": "f4d9c1d9d88caf50c75adbfd6f5261bd8fa0d021", "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": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "shlevy/agda", "max_forks_repo_path": "test/Fail/Issue4880.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/Issue4880.agda", "max_line_length": 64, "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/Issue4880.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": 94, "size": 332 }
{-# OPTIONS --universe-polymorphism #-} open import Level hiding (suc; zero) open import Categories.Category module Categories.Power {o ℓ e : Level} (C : Category o ℓ e) where open import Function using () renaming (id to idf) open import Data.Nat using (ℕ; _+_; zero; suc; _≤?_) open import Data.Product using (_,_) open import Data.Fin using (Fin; inject+; raise; zero; suc; #_) open import Data.Sum using (_⊎_; inj₁; inj₂; map) renaming ([_,_] to ⟦_,_⟧; [_,_]′ to ⟦_,_⟧′) open import Function using (flip) renaming (_∘_ to _∙_) open import Relation.Nullary.Decidable using (True) open import Data.Vec.N-ary using (N-ary) open import Categories.Bifunctor using (Bifunctor) open import Categories.Functor using (Functor; module Functor) module C = Category C Exp : (I : Set) → Category o ℓ e Exp I = record { Obj = I → C.Obj ; _⇒_ = λ x y → (i : I) → C [ x i , y i ] ; _≡_ = λ f g → (i : I) → C [ f i ≡ g i ] ; _∘_ = λ f g i → C [ f i ∘ g i ] ; id = λ {x} i → C.id ; assoc = λ {A} {B} {C'} {D} {f} {g} {h} i → C.assoc ; identityˡ = λ {A} {B} {f} i → C.identityˡ ; identityʳ = λ {A} {B} {f} i → C.identityʳ ; equiv = record { refl = λ {x} i → C.Equiv.refl ; sym = λ f i → C.Equiv.sym (f i) ; trans = λ f g i → C.Equiv.trans (f i) (g i) } ; ∘-resp-≡ = λ f≡g h≡i x → C.∘-resp-≡ (f≡g x) (h≡i x) } Power : (n : ℕ) → Category o ℓ e Power n = Exp (Fin n) Powerfunctor′ : (D : Category o ℓ e) (I : Set) → Set (e ⊔ ℓ ⊔ o) Powerfunctor′ D I = Functor (Exp I) D Powerfunctor : (D : Category o ℓ e) (n : ℕ) → Set (e ⊔ ℓ ⊔ o) Powerfunctor D n = Powerfunctor′ D (Fin n) Powerendo′ : (I : Set) → Set (e ⊔ ℓ ⊔ o) Powerendo′ I = Powerfunctor′ C I Powerendo : (n : ℕ) → Set (e ⊔ ℓ ⊔ o) Powerendo n = Powerfunctor C n Hyperendo : (n m : ℕ) → Set (e ⊔ ℓ ⊔ o) Hyperendo n m = Functor (Power n) (Power m) Hyperendo′ : (I J : Set) → Set (e ⊔ ℓ ⊔ o) Hyperendo′ I J = Functor (Exp I) (Exp J) _par_ : ∀ {I I′ J J′} (F : Hyperendo′ I I′) (G : Hyperendo′ J J′) → Hyperendo′ (I ⊎ J) (I′ ⊎ J′) F par G = record { F₀ = λ xs → ⟦ F.F₀ (xs ∙ inj₁) , G.F₀ (xs ∙ inj₂) ⟧′ ; F₁ = λ {A B} fs → ⟦ F.F₁ (fs ∙ inj₁) , G.F₁ (fs ∙ inj₂) ⟧ ; identity = λ {A} → ⟦ F.identity , G.identity ⟧ ; homomorphism = λ {A B C fs gs} → ⟦ F.homomorphism , G.homomorphism ⟧ ; F-resp-≡ = λ {A B fs gs} fs≡gs → ⟦ F.F-resp-≡ (fs≡gs ∙ inj₁) , G.F-resp-≡ (fs≡gs ∙ inj₂) ⟧ } where private module F = Functor F private module G = Functor G flattenP : ∀ {D : Category o ℓ e} {n m} (F : Powerfunctor′ D (Fin n ⊎ Fin m)) → Powerfunctor′ D (Fin (n + m)) flattenP {n = n} {m = m} F = record { F₀ = λ As → F.F₀ (As ∙ pack) ; F₁ = λ {As Bs} fs → F.F₁ (fs ∙ pack) ; identity = λ {As} → F.identity ; homomorphism = λ {As Bs Cs fs gs} → F.homomorphism ; F-resp-≡ = λ {As Bs fs gs} fs≡gs → F.F-resp-≡ (fs≡gs ∙ pack) } where private module F = Functor F pack = ⟦ inject+ m , raise n ⟧′ flattenHʳ : ∀ {I} {n m} (F : Hyperendo′ I (Fin n ⊎ Fin m)) → Hyperendo′ I (Fin (n + m)) flattenHʳ {n = n} {m} F = record { F₀ = λ As → F.F₀ As ∙ chops n ; F₁ = λ {As Bs} fs → F.F₁ fs ∙ chops n ; identity = F.identity ∙ chops n ; homomorphism = F.homomorphism ∙ chops n ; F-resp-≡ = λ fs≡gs → F.F-resp-≡ fs≡gs ∙ chops n } where private module F = Functor F chops : (n : ℕ) → ∀ {m} (k : Fin (n + m)) → Fin n ⊎ Fin m chops 0 k = inj₂ k chops (suc n) zero = inj₁ zero chops (suc n) (suc k) = map suc idf (chops n k) flattenH : ∀ {n m n′ m′} (F : Hyperendo′ (Fin n ⊎ Fin m) (Fin n′ ⊎ Fin m′)) → Hyperendo (n + m) (n′ + m′) flattenH = flattenHʳ ∙ flattenP _∥_ : ∀ {n n′ m m′} (F : Hyperendo n n′) (G : Hyperendo m m′) → Hyperendo (n + m) (n′ + m′) F ∥ G = flattenH (F par G) reduce′ : ∀ (H : Bifunctor C C C) {I J} (F : Powerendo′ I) (G : Powerendo′ J) → Powerendo′ (I ⊎ J) reduce′ H {I} {J} F G = record { F₀ = my-F₀ ; F₁ = my-F₁ ; identity = λ {As} → my-identity {As} ; homomorphism = λ {As Bs Cs fs gs} → my-homomorphism {fs = fs} {gs} ; F-resp-≡ = λ fs → H.F-resp-≡ (F.F-resp-≡ (fs ∙ inj₁) , G.F-resp-≡ (fs ∙ inj₂)) } where private module L = Category (Exp (I ⊎ J)) private module F = Functor F private module G = Functor G private module H = Functor H open L using () renaming (_≡_ to _≡≡_; _∘_ to _∘∘_) open C using (_≡_; _∘_) my-F₀ = λ As → H.F₀ ((F.F₀ (As ∙ inj₁)) , (G.F₀ (As ∙ inj₂))) my-F₁ : ∀ {As Bs} → L._⇒_ As Bs → C [ my-F₀ As , my-F₀ Bs ] my-F₁ {As} {Bs} fs = H.F₁ (F.F₁ (fs ∙ inj₁) , G.F₁ (fs ∙ inj₂)) .my-identity : ∀ {As} → my-F₁ (L.id {As}) ≡ C.id my-identity {As} = begin H.F₁ (F.F₁ (λ i → C.id {As (inj₁ i)}) , G.F₁ (λ i → C.id {As (inj₂ i)})) ↓⟨ H.F-resp-≡ (F.identity , G.identity) ⟩ H.F₁ (C.id , C.id) ↓⟨ H.identity ⟩ C.id ∎ where open C.HomReasoning .my-homomorphism : ∀ {As Bs Cs} {fs : L._⇒_ As Bs} {gs : L._⇒_ Bs Cs} → my-F₁ (gs ∘∘ fs) ≡ (my-F₁ gs ∘ my-F₁ fs) my-homomorphism {fs = fs} {gs} = begin my-F₁ (gs ∘∘ fs) ↓⟨ H.F-resp-≡ (F.homomorphism , G.homomorphism) ⟩ H.F₁ ((F.F₁ (gs ∙ inj₁) ∘ F.F₁ (fs ∙ inj₁)) , (G.F₁ (gs ∙ inj₂) ∘ G.F₁ (fs ∙ inj₂))) ↓⟨ H.homomorphism ⟩ my-F₁ gs ∘ my-F₁ fs ∎ where open C.HomReasoning reduce : ∀ (H : Bifunctor C C C) {n m} (F : Powerendo n) (G : Powerendo m) → Powerendo (n + m) reduce H F G = flattenP (reduce′ H F G) flattenP-assocʳ : ∀ {n₁ n₂ n₃} (F : Powerendo′ (Fin n₁ ⊎ (Fin n₂ ⊎ Fin n₃))) → Powerendo ((n₁ + n₂) + n₃) flattenP-assocʳ {n₁} {n₂} {n₃} F = record { F₀ = λ As → F.F₀ (As ∙ pack) ; F₁ = λ {As Bs} fs → F.F₁ (fs ∙ pack) ; identity = λ {As} → F.identity ; homomorphism = λ {As Bs Cs fs gs} → F.homomorphism ; F-resp-≡ = λ {As Bs fs gs} fs≡gs → F.F-resp-≡ (fs≡gs ∙ pack) } where module F = Functor F pack = ⟦ inject+ n₃ ∙ inject+ n₂ , ⟦ inject+ n₃ ∙ raise n₁ , raise (n₁ + n₂) ⟧′ ⟧′ reduce2ʳ : ∀ (G : Bifunctor C C C) {n₁ n₂ n₃} (F₁ : Powerendo n₁) (F₂ : Powerendo n₂) (F₃ : Powerendo n₃) → Powerendo ((n₁ + n₂) + n₃) reduce2ʳ G F₁ F₂ F₃ = flattenP-assocʳ (reduce′ G F₁ (reduce′ G F₂ F₃)) overlaps : ∀ {D E} (H : Bifunctor D D E) {I} (F G : Powerfunctor′ D I) → Powerfunctor′ E I overlaps {D} {E} H {I} F G = record { F₀ = my-F₀ ; F₁ = my-F₁ ; identity = λ {As} → my-identity {As} ; homomorphism = λ {As Bs Cs fs gs} → my-homomorphism {fs = fs} {gs} ; F-resp-≡ = λ fs → H.F-resp-≡ (F.F-resp-≡ fs , G.F-resp-≡ fs) } where private module L = Category (Exp I) private module F = Functor F private module G = Functor G private module H = Functor H private module D = Category D private module E = Category E open L using () renaming (_≡_ to _≡≡_; _∘_ to _∘∘_) open E using (_≡_; _∘_) open D using () renaming (_∘_ to _∘D_) my-F₀ = λ As → H.F₀ (F.F₀ As , G.F₀ As) my-F₁ : ∀ {As Bs} → (Exp I) [ As , Bs ] → E [ my-F₀ As , my-F₀ Bs ] my-F₁ {As} {Bs} fs = H.F₁ (F.F₁ fs , G.F₁ fs) .my-identity : ∀ {As} → my-F₁ (L.id {As}) ≡ E.id my-identity {As} = begin H.F₁ (F.F₁ (λ i → C.id {As i}) , G.F₁ (λ i → C.id {As i})) ↓⟨ H.F-resp-≡ (F.identity , G.identity) ⟩ H.F₁ (D.id , D.id) ↓⟨ H.identity ⟩ E.id ∎ where open E.HomReasoning .my-homomorphism : ∀ {As Bs Cs} {fs : (Exp I) [ As , Bs ]} {gs : (Exp I) [ Bs , Cs ]} → my-F₁ (gs ∘∘ fs) ≡ (my-F₁ gs ∘ my-F₁ fs) my-homomorphism {fs = fs} {gs} = begin my-F₁ (gs ∘∘ fs) ↓⟨ H.F-resp-≡ (F.homomorphism , G.homomorphism) ⟩ H.F₁ ((F.F₁ gs ∘D F.F₁ fs) , (G.F₁ gs ∘D G.F₁ fs)) ↓⟨ H.homomorphism ⟩ my-F₁ gs ∘ my-F₁ fs ∎ where open E.HomReasoning overlap2ʳ : ∀ (G : Bifunctor C C C) {n} (F₁ F₂ F₃ : Powerendo n) → Powerendo n overlap2ʳ G F₁ F₂ F₃ = (overlaps {C} G F₁ (overlaps {C} G F₂ F₃)) select′ : ∀ {I} (i : I) → Powerendo′ I select′ {I} i = record { F₀ = λ xs → xs i ; F₁ = λ fs → fs i ; identity = C.Equiv.refl ; homomorphism = C.Equiv.refl ; F-resp-≡ = λ eqs → eqs i } select : ∀ m {n} {m<n : True (suc m ≤? n)} → Powerendo n select m {n} {m<n} = select′ (#_ m {n} {m<n}) triv : (n : ℕ) → Hyperendo n n triv n = record { F₀ = λ x → x ; F₁ = λ x → x ; identity = λ _ → C.Equiv.refl ; homomorphism = λ _ → C.Equiv.refl ; F-resp-≡ = λ x → x } pad : ∀ (l r : ℕ) {n m} (F : Hyperendo n m) → Hyperendo ((l + n) + r) ((l + m) + r) pad l r F = (triv l ∥ F) ∥ triv r padˡ : ∀ (l : ℕ) {n m} (F : Hyperendo n m) → Hyperendo (l + n) (l + m) padˡ l F = triv l ∥ F padʳ : ∀ (r : ℕ) {n m} (F : Hyperendo n m) → Hyperendo (n + r) (m + r) padʳ r F = F ∥ triv r unary : (F : Functor C C) → Powerendo 1 unary F = record { F₀ = λ As → F.F₀ (As zero) ; F₁ = λ fs → F.F₁ (fs zero) ; identity = F.identity ; homomorphism = F.homomorphism ; F-resp-≡ = λ fs≡gs → F.F-resp-≡ (fs≡gs zero) } where module F = Functor F unaryH : (F : Functor C C) → Hyperendo 1 1 unaryH F = record { F₀ = λ As → F.F₀ ∙ As ; F₁ = λ fs → F.F₁ ∙ fs ; identity = λ _ → F.identity ; homomorphism = λ _ → F.homomorphism ; F-resp-≡ = λ fs≡gs → F.F-resp-≡ ∙ fs≡gs } where module F = Functor F nullary : (X : C.Obj) → Powerendo 0 nullary X = record { F₀ = λ _ → X ; F₁ = λ _ → C.id ; identity = C.Equiv.refl ; homomorphism = C.Equiv.sym C.identityˡ ; F-resp-≡ = λ _ → C.Equiv.refl } nullaryH : (X : C.Obj) → Hyperendo 0 1 nullaryH X = record { F₀ = λ _ _ → X ; F₁ = λ _ _ → C.id ; identity = λ _ → C.Equiv.refl ; homomorphism = λ _ → C.Equiv.sym C.identityˡ ; F-resp-≡ = λ _ _ → C.Equiv.refl } binary : (F : Bifunctor C C C) → Powerendo 2 binary F = record { F₀ = λ As → F.F₀ (As zero , As (suc zero)) ; F₁ = λ fs → F.F₁ (fs zero , fs (suc zero)) ; identity = F.identity ; homomorphism = F.homomorphism ; F-resp-≡ = λ fs≡gs → F.F-resp-≡ (fs≡gs zero , fs≡gs (suc zero)) } where module F = Functor F binaryH : (F : Bifunctor C C C) → Hyperendo 2 1 binaryH F = record { F₀ = λ As _ → F.F₀ (As zero , As (suc zero)) ; F₁ = λ fs _ → F.F₁ (fs zero , fs (suc zero)) ; identity = λ _ → F.identity ; homomorphism = λ _ → F.homomorphism ; F-resp-≡ = λ fs≡gs _ → F.F-resp-≡ (fs≡gs zero , fs≡gs (suc zero)) } where module F = Functor F hyp : ∀ {n} (F : Powerendo n) → Hyperendo n 1 hyp F = record { F₀ = λ As _ → F.F₀ As ; F₁ = λ fs _ → F.F₁ fs ; identity = λ _ → F.identity ; homomorphism = λ _ → F.homomorphism ; F-resp-≡ = λ fs≡gs _ → F.F-resp-≡ fs≡gs } where module F = Functor F private curryⁿ : ∀ n {a b} {A : Set a} {B : Set b} → ((Fin n → A) → B) → N-ary n A B curryⁿ zero f = f (λ ()) curryⁿ (suc n) {A = A} f = λ x → curryⁿ n (f ∙ addon x) where addon : A → (Fin n → A) → Fin (suc n) → A addon x _ zero = x addon _ g (suc i) = g i plex′ : ∀ {J I} → (J → Powerendo′ I) → Hyperendo′ I J plex′ Fs = record { F₀ = flip (Functor.F₀ ∙ Fs) ; F₁ = flip (λ j → Functor.F₁ (Fs j)) ; identity = λ j → Functor.identity (Fs j) ; homomorphism = λ j → Functor.homomorphism (Fs j) ; F-resp-≡ = flip (λ j → Functor.F-resp-≡ (Fs j)) } plex : ∀ {n} {I} → N-ary n (Powerendo′ I) (Hyperendo′ I (Fin n)) plex {n} = curryⁿ n plex′ widenˡ : ∀ (l : ℕ) {n} (F : Powerendo n) → Powerendo (l + n) widenˡ l F = record { F₀ = λ As → F.F₀ (As ∙ pack) ; F₁ = λ {As Bs} fs → F.F₁ (fs ∙ pack) ; identity = λ {As} → F.identity ; homomorphism = λ {As Bs Cs fs gs} → F.homomorphism ; F-resp-≡ = λ {As Bs fs gs} fs≡gs → F.F-resp-≡ (fs≡gs ∙ pack) } where private module F = Functor F pack = raise l widenʳ : ∀ (r : ℕ) {n} (F : Powerendo n) → Powerendo (n + r) widenʳ r F = record { F₀ = λ As → F.F₀ (As ∙ pack) ; F₁ = λ {As Bs} fs → F.F₁ (fs ∙ pack) ; identity = λ {As} → F.identity ; homomorphism = λ {As Bs Cs fs gs} → F.homomorphism ; F-resp-≡ = λ {As Bs fs gs} fs≡gs → F.F-resp-≡ (fs≡gs ∙ pack) } where private module F = Functor F pack = inject+ r
{ "alphanum_fraction": 0.5332666333, "avg_line_length": 33.691011236, "ext": "agda", "hexsha": "adf52c2e2aaacb9da67c6689b3fd0c3185bceaaf", "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/Power.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/Power.agda", "max_line_length": 134, "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/Power.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": 5247, "size": 11994 }
------------------------------------------------------------------------ -- INCREMENTAL λ-CALCULUS -- -- Caching evaluation ------------------------------------------------------------------------ import Parametric.Syntax.Type as Type import Parametric.Syntax.Term as Term import Parametric.Syntax.MType as MType import Parametric.Syntax.MTerm as MTerm import Parametric.Denotation.Value as Value import Parametric.Denotation.Evaluation as Evaluation import Parametric.Denotation.MValue as MValue import Parametric.Denotation.CachingMValue as CachingMValue import Parametric.Denotation.MEvaluation as MEvaluation module Parametric.Denotation.CachingMEvaluation {Base : Type.Structure} (Const : Term.Structure Base) (⟦_⟧Base : Value.Structure Base) (⟦_⟧Const : Evaluation.Structure Const ⟦_⟧Base) (ValConst : MTerm.ValConstStructure Const) (CompConst : MTerm.CompConstStructure Const) (cbnToCompConst : MTerm.CbnToCompConstStructure Const CompConst) (cbvToCompConst : MTerm.CbvToCompConstStructure Const CompConst) -- I should really switch to records - can it get sillier than this? More -- precisely, this is the kind of thing ML functors are designed to replace. -- They have also subtyping --- not sure whether that's good or bad. (⟦_⟧ValBase : MEvaluation.ValStructure Const ⟦_⟧Base ValConst CompConst cbnToCompConst cbvToCompConst) (⟦_⟧CompBase : MEvaluation.CompStructure Const ⟦_⟧Base ValConst CompConst cbnToCompConst cbvToCompConst) (ΔBase : CachingMValue.Structure Base ⟦_⟧Base) where open Type.Structure Base open Term.Structure Base Const open MType.Structure Base open MTerm.Structure Const ValConst CompConst cbnToCompConst cbvToCompConst open Value.Structure Base ⟦_⟧Base open Evaluation.Structure Const ⟦_⟧Base ⟦_⟧Const open MValue.Structure Base ⟦_⟧Base open CachingMValue.Structure Base ⟦_⟧Base ΔBase open MEvaluation.Structure Const ⟦_⟧Base ValConst CompConst cbnToCompConst cbvToCompConst ⟦_⟧ValBase ⟦_⟧CompBase open import Base.Denotation.Notation -- Extension Point: Evaluation of constants. ValStructure : Set ValStructure = ∀ {τ} → ValConst τ → ⟦ τ ⟧ValTypeHidCache CompStructure : Set CompStructure = ∀ {τ} → CompConst τ → ⟦ τ ⟧CompTypeHidCache module Structure (⟦_⟧ValBaseTermCache : ValStructure) (⟦_⟧CompBaseTermCache : CompStructure) where {- -- Prototype here the type-correctness of a simple non-standard semantics. -- This describes a simplified version of the transformation by Liu and -- Tanenbaum, PEPM 1995 - but for now, instead of producing object language -- terms, we produce host language terms to take advantage of the richer type -- system of the host language (in particular, here we need the unit type, -- product types and *existentials*). -- -- As usual, we'll later switch to a real term transformation. -} open import Data.Product hiding (map) open import Data.Unit -- Defining a caching semantics for Term proves to be hard, requiring to -- insert and remove caches where we apply constants. -- Indeed, our plugin interface is not satisfactory for adding caching. CBPV can help us. -- The solution is to distinguish among different kinds of constants. Some are -- value constructors (and thus do not return caches), while others are -- computation constructors (and thus should return caches). For products, I -- believe we will only use positive/value products (i.e. pattern-match products), -- not negative/computation products (i.e. projection products). ⟦_⟧CompTermCache : ∀ {τ Γ} → Comp Γ τ → ⟦ Γ ⟧ValCtxHidCache → ⟦ τ ⟧CompTypeHidCache ⟦_⟧ValTermCache : ∀ {τ Γ} → Val Γ τ → ⟦ Γ ⟧ValCtxHidCache → ⟦ τ ⟧ValTypeHidCache ⟦_⟧ValsTermCache : ∀ {Γ Σ} → Vals Γ Σ → ⟦ Γ ⟧ValCtxHidCache → ⟦ Σ ⟧ValCtxHidCache open import Base.Denotation.Environment ValType ⟦_⟧ValTypeHidCache public using () renaming (⟦_⟧Var to ⟦_⟧ValVarHidCache) -- This says that the environment does not contain caches... sounds wrong! -- Either we add extra variables for the caches, or we store computations in -- the environment (but that does not make sense), or we store caches in -- values, by acting not on F but on something else (U?). -- Copy of ⟦_⟧Vals ⟦ ∅ ⟧ValsTermCache ρ = ∅ ⟦ vt • valtms ⟧ValsTermCache ρ = ⟦ vt ⟧ValTermCache ρ • ⟦ valtms ⟧ValsTermCache ρ -- I suspect the plan was to use extra variables; that's annoying to model in -- Agda but easier in implementations. ⟦ vVar x ⟧ValTermCache ρ = ⟦ x ⟧ValVarHidCache ρ ⟦ vThunk x ⟧ValTermCache ρ = ⟦ x ⟧CompTermCache ρ -- No caching, because the arguments are values, so evaluating them does not -- produce intermediate results. ⟦ vConst c ⟧ValTermCache ρ = ⟦ c ⟧ValBaseTermCache -- The only caching is done by the interpretation of the constant (because the -- arguments are values so need no caching). ⟦_⟧CompTermCache (cConst c) ρ = ⟦ c ⟧CompBaseTermCache -- Also, where are introduction forms for pairs and sums among values? With -- them, we should see that we can interpret them without adding a cache. -- Thunks keep seeming noops. ⟦_⟧CompTermCache (cForce x) ρ = ⟦ x ⟧ValTermCache ρ -- The effect of F is a writer monad of cached values, where the monoid is -- (isomorphic to) the free monoid over (∃ τ . τ), but we push the -- existentials up when pairing things! -- That's what we're interpreting computations in. In fact, one could use -- monads directly, but that does not deal with arity satisfactorily. ⟦_⟧CompTermCache (cReturn v) ρ = vUnit , (⟦ v ⟧ValTermCache ρ , tt) -- A function can invoke, in tail position, either a `cReturn` directly, or -- invoke another function. In the latter case, we need to ensure that the -- return value of the other function is not forwarded directly, but that -- further intermediate results from the current function are also recorded. -- -- At one time, `f1 into cReturn` did this correctly, but `f1` didn't, while -- instead, they should be equivalent. In other words, we want `_into_` to -- satisfy the monadic laws for bind. {- -- Here we'd have a problem with the original `_into_` constructor from CBPV, because it does -- not require converting expressions to the "CBPV A-normal form". -- -- If we tried supporting it, we could try to write something like: ⟦_⟧CompTermCache (v₁ into v₂) ρ = -- Sequence commands and combine their caches. {- let (_ , (r₁ , c₁)) = ⟦ v₁ ⟧CompTermCache ρ (_ , (r₂ , c₂)) = ⟦ v₂ ⟧CompTermCache (r₁ • ρ) in , (r₂ , (c₁ ,′ c₂)) -} -- However, the code above does not work, because we only guarantee that v₂ is -- a computation, not that it's an F-computation - v₂ could also be function -- type or a computation product. -- Instead, we use a restricted CBPV, where these two possibilities are forbidden. -- If you want to save something between different lambdas, you need to add an -- F U to reflect that. (Double-check the papers which show how to encode -- arity using CBPV, it seems that they should find the same problem --- -- XXX they don't). -} -- But if we alter _into_ as described above, composing the caches works! -- However, we should not forget we also need to save the new intermediate -- result, that is the one produced by the first part of the let. ⟦_⟧CompTermCache (_into_ {σ} {τ} v₁ v₂) ρ = let (τ₁ , (r₁ , c₁)) = ⟦ v₁ ⟧CompTermCache ρ (τ₂ , (r₂ , c₂)) = ⟦ v₂ ⟧CompTermCache (r₁ • ρ) in (τ₁ v× τ₂ v× σ) , (r₂ ,′ (c₁ ,′ c₂ ,′ r₁)) -- Note the compositionality and luck: we don't need to do anything at the -- cReturn time, we just need the nested into to do their job, because as I -- said intermediate results are a writer monad. -- -- Q: But then, do we still need to do all the other stuff? IOW, do we still -- need to forbid (λ x . y <- f args; g args') and replace it with (λ x . y <- -- f args; z <- g args'; z)? -- -- A: One thing we still need is using the monadic version of into for the -- same reasons - which makes sense, since it has the type of monadic bind. -- -- Maybe not: if we use a monad, which respects left and right identity, the -- two above forms are equivalent. But what about associativity? We don't have -- associativity with nested tuples in the middle. That's why the monad uses -- lists! We can also use nested tuple, as long as in the into case we don't -- do (a, b) but append a b (ahem, where?), which decomposes the first list -- and prepends it to the second. To this end, we need to know the type of the -- first element, or to ensure it's always a pair. XXX: We should just reuse -- HList. -- In abstractions, we should start collecting all variables... -- Here, unlike in ⟦_⟧TermCache, we don't need to invent an empty cache, -- that's moved into the handling of cReturn. This makes *the* difference for -- nested lambdas, where we don't need to create caches multiple times! ⟦_⟧CompTermCache (cAbs v) ρ = λ x → ⟦ v ⟧CompTermCache (x • ρ) -- Here we see that we are in a sort of A-normal form, because the argument is -- a value (not quite ANF though, since values can be thunks - that is, -- computations which haven't been run yet, I guess. Do we have an use for -- that? That allows passing lambdas as arguments directly - which is fine, -- because producing a closure indeed does not have intermediate results!). ⟦_⟧CompTermCache (cApp t v) ρ = ⟦ t ⟧CompTermCache ρ (⟦ v ⟧ValTermCache ρ) ⟦_⟧TermCacheCBV : ∀ {τ Γ} → Term Γ τ → ⟦ fromCBVCtx Γ ⟧ValCtxHidCache → ⟦ cbvToCompType τ ⟧CompTypeHidCache ⟦ t ⟧TermCacheCBV = ⟦ fromCBV t ⟧CompTermCache module _ (ι : Base) where Γ : ValContext Γ = ∅ σ = B ι τ = B ι f : Comp Γ (σ ⇛ F τ) f = cAbs (cReturn (vVar vThis)) bar : ⟦ σ ⇛ F τ ⟧CompTypeHidCache bar = ⟦ f ⟧CompTermCache ∅ open import Relation.Binary.PropositionalEquality bar≡ : bar ≡ (λ x → vUnit , x , tt) bar≡ = refl dbar : ⟦ σ ⇛ F τ ⟧ΔCompType dbar = λ dx → vUnit , λ c₀ → (dx , c₀) barbaz : ⟦ base ι ⟧Type → ⟦ ΔBase ι ⟧Type → ⟦ base ι ⟧Type × ⟦ ΔBase ι ⟧Type barbaz x dx = let (τ₁ , y , c₁) = bar x (τ₂ , dbar′) = dbar dx (dy , c₂) = dbar′ c₁ in y , dy module _ (f : ⟦ σ ⇛ F τ ⟧CompTypeHidCache) (df : ⟦ σ ⇛ F τ ⟧ΔCompType) (proof : ∀ x dx → proj₁ (f x) ≡ proj₁ (df dx)) where -- fdf₁ : ⟦ base ι ⟧Type → ⟦ ΔBase ι ⟧Type → ⟦ base ι ⟧Type × ⟦ ΔBase ι ⟧Type -- fdf₁ x dx = -- let -- (τ₁ , y , c₁) = f x -- (τ₂ , dbar′) = df dx -- --(dy , c₂) = dbar′ c₁ -- fails, as it should be expected! -- in y , dy fdf : ⟦ base ι ⟧Type → ⟦ ΔBase ι ⟧Type → ⟦ base ι ⟧Type × ⟦ ΔBase ι ⟧Type fdf x dx with proof x dx ... | p = let (τ₁ , y , c₁) = f x (τ₂ , dbar′) = df dx (dy , c₂) = dbar′ (subst ⟦_⟧ValTypeHidCache p c₁) -- in y , dy
{ "alphanum_fraction": 0.6730436367, "avg_line_length": 43.3873517787, "ext": "agda", "hexsha": "aac35bab33c012bff6d87062a64506be1e0a99c2", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2016-02-18T12:26:44.000Z", "max_forks_repo_forks_event_min_datetime": "2016-02-18T12:26:44.000Z", "max_forks_repo_head_hexsha": "39bb081c6f192bdb87bd58b4a89291686d2d7d03", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "inc-lc/ilc-agda", "max_forks_repo_path": "Parametric/Denotation/CachingMEvaluation.agda", "max_issues_count": 6, "max_issues_repo_head_hexsha": "39bb081c6f192bdb87bd58b4a89291686d2d7d03", "max_issues_repo_issues_event_max_datetime": "2017-05-04T13:53:59.000Z", "max_issues_repo_issues_event_min_datetime": "2015-07-01T18:09:31.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "inc-lc/ilc-agda", "max_issues_repo_path": "Parametric/Denotation/CachingMEvaluation.agda", "max_line_length": 112, "max_stars_count": 10, "max_stars_repo_head_hexsha": "39bb081c6f192bdb87bd58b4a89291686d2d7d03", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "inc-lc/ilc-agda", "max_stars_repo_path": "Parametric/Denotation/CachingMEvaluation.agda", "max_stars_repo_stars_event_max_datetime": "2019-07-19T07:06:59.000Z", "max_stars_repo_stars_event_min_datetime": "2015-03-04T06:09:20.000Z", "num_tokens": 3383, "size": 10977 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Fancy display functions for List-based tables -- -- The functions in this module assume some (unenforced) invariants. -- If you cannot guarantee that your data respects these invariants, -- you should instead use Text.Tabular.List. ------------------------------------------------------------------------ {-# OPTIONS --safe --without-K #-} module Text.Tabular.Base where open import Data.Bool.Base using (if_then_else_) open import Data.Char.Base using (Char) open import Data.List.Base as List using (List; []; _∷_; _?∷_; _++_; _∷ʳ?_; null; map; intersperse) open import Data.Maybe.Base as Maybe using (Maybe; nothing; just; maybe) open import Data.Nat.Base open import Data.String.Base as String using (String; fromChar; unlines; replicate; length) open import Function.Base open import Agda.Builtin.Equality open String using ( Alignment ; Left ; Center ; Right ) public record TabularLine : Set where field left : Maybe String cont : Maybe Char sep : String right : Maybe String open TabularLine record TabularConfig : Set where field top : Maybe TabularLine sep : Maybe TabularLine row : TabularLine bot : Maybe TabularLine open TabularConfig unicode : TabularConfig unicode .top = just λ where .left → just "┌" .cont → just '─' .sep → "┬" .right → just "┐" unicode .sep = just λ where .left → just "├" .cont → just '─' .sep → "┼" .right → just "┤" unicode .row = λ where .left → just "│" .cont → nothing .sep → "│" .right → just "│" unicode .bot = just λ where .left → just "└" .cont → just '─' .sep → "┴" .right → just "┘" ascii : TabularConfig ascii .top = just λ where .left → just "+" .cont → just '-' .sep → "-" .right → just "+" ascii .sep = just λ where .left → just "|" .cont → just '-' .sep → "+" .right → just "|" ascii .row = λ where .left → just "|" .cont → nothing .sep → "|" .right → just "|" ascii .bot = just λ where .left → just "+" .cont → just '-' .sep → "-" .right → just "+" compact : TabularConfig → TabularConfig compact c = record c { sep = nothing } private dropBorder : TabularLine → TabularLine dropBorder l = record l { left = nothing; right = nothing } noBorder : TabularConfig → TabularConfig noBorder c .top = nothing noBorder c .sep = Maybe.map dropBorder (c .sep) noBorder c .row = dropBorder (c .row) noBorder c .bot = nothing private space : TabularLine → TabularLine space l = let pad = maybe fromChar " " (l .cont) in λ where .left → Maybe.map (String._++ pad) (l .left) .cont → l .cont .sep → pad String.++ l .sep String.++ pad .right → Maybe.map (pad String.++_) (l .right) addSpace : TabularConfig → TabularConfig addSpace c .top = Maybe.map space (c .top) addSpace c .sep = Maybe.map space (c .sep) addSpace c .row = space (c .row) addSpace c .bot = Maybe.map space (c .bot) whitespace : TabularConfig whitespace .top = nothing whitespace .sep = nothing whitespace .row = λ where .left → nothing .cont → nothing .sep → " " .right → nothing whitespace .bot = nothing -- /!\ Invariants: -- * the table is presented as a list of rows -- * header has the same length as each one of the rows -- i.e. we have a rectangular table -- * all of the strings in a given column have the same length unsafeDisplay : TabularConfig → List (List String) → List String unsafeDisplay _ [] = [] unsafeDisplay c (header ∷ rows) = map String.concat $ th ++ (trs ∷ʳ? lbot) where cellsOf : Maybe Char → List String → List String cellsOf nothing = id cellsOf (just c) = map (λ cell → replicate (length cell) c) lineOf : TabularLine → List String → List String lineOf l xs = l .left ?∷ intersperse (l .sep) (cellsOf (l .cont) xs) ∷ʳ? l .right mlineOf : Maybe TabularLine → List String → Maybe (List String) mlineOf l xs = Maybe.map (λ l → lineOf l xs) l ltop : Maybe (List String) lsep : Maybe (List String) tr : List String → List String lbot : Maybe (List String) ltop = mlineOf (c. top) header lsep = mlineOf (c. sep) header tr = lineOf (c. row) lbot = mlineOf (c. bot) header th = ltop ?∷ tr header ∷ [] trs = if null rows then id else (maybe _∷_ id lsep) $ maybe intersperse id lsep $ map tr rows
{ "alphanum_fraction": 0.6131779471, "avg_line_length": 26.5595238095, "ext": "agda", "hexsha": "52c10e931dc94459d132eda1454365a8a47ddb2a", "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/Text/Tabular/Base.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/Text/Tabular/Base.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/Text/Tabular/Base.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": 1356, "size": 4462 }
{-# OPTIONS --without-K --rewriting #-} open import HoTT open import homotopy.elims.Lemmas module homotopy.elims.SuspSmash {i j k} {X : Ptd i} {Y : Ptd j} {P : Susp (X ∧ Y) → Type k} (north* : P north) (south* : P south) (smin* : (x : de⊙ X) (y : de⊙ Y) → north* == south* [ P ↓ merid (smin x y) ]) where private smbase*-template : ∀ {s} (p : smin (pt X) (pt Y) == s) → north* == south* [ P ↓ merid s ] smbase*-template p = transport (λ κ → north* == south* [ P ↓ merid κ ]) p (smin* (pt X) (pt Y)) smbasel* = smbase*-template (smgluel (pt X)) smbaser* = smbase*-template (smgluer (pt Y)) -- note that [smin*] is adjusted. coh* : (s : X ∧ Y) → north* == south* [ P ↓ merid s ] coh* = Smash-elim (λ x y → fst (fill-l x) ◃ fst (fill-r y) ◃ fst fill-base ◃ smin* x y) smbasel* smbaser* (λ x → ↓↓-from-squareover $ ap (λ p → fst (fill-l x) ◃ p ◃ fst fill-base ◃ smin* x (pt Y)) fill-r-β ∙h↓⊡ ap (fst (fill-l x) ◃_) (idp◃ _) ∙h↓⊡ snd (fill-l x)) (λ y → ↓↓-from-squareover $ ap (λ p → p ◃ fst (fill-r y) ◃ fst fill-base ◃ smin* (pt X) y) fill-l-β ∙h↓⊡ idp◃ _ ∙h↓⊡ snd (fill-r y)) where fill-template : ∀ {s₁ s₂} (p : s₁ == s₂) (α : north* == south* [ P ↓ merid s₁ ]) (β : north* == south* [ P ↓ merid s₂ ]) → Σ (north* == north*) (λ q → SquareOver P (natural-square merid p) (q ◃ α) (↓-ap-in _ _ (apd (λ _ → north*) p)) (↓-ap-in _ _ (apd (λ _ → south*) p)) β) fill-template p α β = fill-upper-left _ _ _ _ _ fill-base = fill-template (smgluel (pt X)) (smin* (pt X) (pt Y)) smbasel* fill-l = λ x → fill-template (smgluel x) (fst fill-base ◃ smin* x (pt Y)) smbasel* fill-l-β : fst (fill-l (pt X)) == idp fill-l-β = ! $ fill-upper-left-unique _ _ _ _ _ idp (idp◃ _ ∙h↓⊡ snd fill-base) fill-r = λ y → fill-template (smgluer y) (fst fill-base ◃ smin* (pt X) y) smbaser* fill-r-β : fst (fill-r (pt Y)) == idp fill-r-β = ! $ fill-upper-left-unique _ _ _ _ _ idp (idp◃ _ ∙h↓⊡ snd fill-base) ∙ ap (λ sp → fst (fill-template (snd sp) (fst fill-base ◃ smin* (pt X) (pt Y)) (smbase*-template (snd sp)))) (contr-has-all-paths {{pathfrom-is-contr (smin (pt X) (pt Y))}} (smbasel , smgluel (pt X)) (smbaser , smgluer (pt Y))) SuspSmash-elim : Π (Susp (X ∧ Y)) P SuspSmash-elim = Susp-elim north* south* coh*
{ "alphanum_fraction": 0.4890426759, "avg_line_length": 40.0153846154, "ext": "agda", "hexsha": "d163bba88380f9e4dd3da1b0b59bc3047fc066a4", "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": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "timjb/HoTT-Agda", "max_forks_repo_path": "theorems/homotopy/elims/SuspSmash.agda", "max_issues_count": 31, "max_issues_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "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": "timjb/HoTT-Agda", "max_issues_repo_path": "theorems/homotopy/elims/SuspSmash.agda", "max_line_length": 86, "max_stars_count": 294, "max_stars_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "timjb/HoTT-Agda", "max_stars_repo_path": "theorems/homotopy/elims/SuspSmash.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": 971, "size": 2601 }
{-# OPTIONS --prop --show-irrelevant #-} postulate P : Prop p : P A : P → Set f : {x : P} → A x test : A p test = f
{ "alphanum_fraction": 0.4920634921, "avg_line_length": 11.4545454545, "ext": "agda", "hexsha": "894d9665d61f4bae1217764c09f8d3eb8656c390", "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/Issue4122-implicit.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/Issue4122-implicit.agda", "max_line_length": 40, "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/Issue4122-implicit.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": 51, "size": 126 }
-- Andreas, 2017-11-06, issue #2840 reported by wenkokke Id : (F : Set → Set) → Set → Set Id F = F data D (A : Set) : Set where c : Id _ A -- WAS: internal error in positivity checker -- EXPECTED: success, or -- Failed to solve the following constraints: -- [4] _F_2 A A = D A : Set -- when checking the constructor c in the declaration of D
{ "alphanum_fraction": 0.6542857143, "avg_line_length": 23.3333333333, "ext": "agda", "hexsha": "da02526337c8d29baa8e45271c10c5968a856550", "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/Fail/Issue2840.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/Fail/Issue2840.agda", "max_line_length": 58, "max_stars_count": 1, "max_stars_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "alhassy/agda", "max_stars_repo_path": "test/Fail/Issue2840.agda", "max_stars_repo_stars_event_max_datetime": "2016-03-17T01:45:59.000Z", "max_stars_repo_stars_event_min_datetime": "2016-03-17T01:45:59.000Z", "num_tokens": 112, "size": 350 }
{-# OPTIONS --without-K #-} open import HoTT open import cohomology.Exactness open import cohomology.Theory open import cohomology.CofiberSequence module cohomology.LongExactSequence {i} (CT : CohomologyTheory i) (n : ℤ) {X Y : Ptd i} (f : fst (X ⊙→ Y)) where open CohomologyTheory CT long-exact-diag : ExactDiag _ _ long-exact-diag = C n (⊙Susp (⊙Cof f)) ⟨ CF-hom n (⊙susp-fmap (⊙cfcod f)) ⟩→ C n (⊙Susp Y) ⟨ CF-hom n (⊙susp-fmap f) ⟩→ C n (⊙Susp X) ⟨ CF-hom n ⊙ext-glue ⟩→ C n (⊙Cof f) ⟨ CF-hom n (⊙cfcod f) ⟩→ C n Y ⟨ CF-hom n f ⟩→ C n X ⊣| long-exact-cofiber : ExactSeq long-exact-diag long-exact-cofiber = transport (λ {(_ , g , h , k) → ExactSeq $ _ ⟨ CF-hom n k ⟩→ _ ⟨ CF-hom n h ⟩→ _ ⟨ CF-hom n g ⟩→ _ ⟨ CF-hom n (⊙cfcod f) ⟩→ _ ⟨ CF-hom n f ⟩→ _ ⊣|}) (cofiber-sequence f) (exact-build (_ ⟨ CF-hom n (⊙cfcod⁴ f) ⟩→ _ ⟨ CF-hom n (⊙cfcod³ f) ⟩→ _ ⟨ CF-hom n (⊙cfcod² f) ⟩→ _ ⟨ CF-hom n (⊙cfcod f) ⟩→ _ ⟨ CF-hom n f ⟩→ _ ⊣|) (C-exact n (⊙cfcod³ f)) (C-exact n (⊙cfcod² f)) (C-exact n (⊙cfcod f)) (C-exact n f))
{ "alphanum_fraction": 0.5164279697, "avg_line_length": 34.9117647059, "ext": "agda", "hexsha": "78606999f20baec0239fcd032c87955596b9a064", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "1695a7f3dc60177457855ae846bbd86fcd96983e", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "danbornside/HoTT-Agda", "max_forks_repo_path": "cohomology/LongExactSequence.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "1695a7f3dc60177457855ae846bbd86fcd96983e", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "danbornside/HoTT-Agda", "max_issues_repo_path": "cohomology/LongExactSequence.agda", "max_line_length": 65, "max_stars_count": null, "max_stars_repo_head_hexsha": "1695a7f3dc60177457855ae846bbd86fcd96983e", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "danbornside/HoTT-Agda", "max_stars_repo_path": "cohomology/LongExactSequence.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 529, "size": 1187 }
module UnSizedIO.IOObject where open import Data.Product open import UnSizedIO.Base open import UnSizedIO.Object -- An IO object is like a simple object, -- but the method returns IO applied to the result type of a simple object -- which means the method returns an IO program which when terminating -- returns the result of the simple object module _ (ioi : IOInterface) (let C = Command ioi) (let R = Response ioi) (oi : Interface) (let M = Method oi) (let Rt = Result oi) where record IOObject : Set where coinductive field method : (m : M) → IO ioi (Rt m × IOObject) open IOObject public
{ "alphanum_fraction": 0.6920684292, "avg_line_length": 26.7916666667, "ext": "agda", "hexsha": "96ad0aad3f0e312292fc732c7be4c3a38c6c76f8", "lang": "Agda", "max_forks_count": 2, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:41:00.000Z", "max_forks_repo_forks_event_min_datetime": "2018-09-01T15:02:37.000Z", "max_forks_repo_head_hexsha": "7cc45e0148a4a508d20ed67e791544c30fecd795", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "agda/ooAgda", "max_forks_repo_path": "src/UnSizedIO/IOObject.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "7cc45e0148a4a508d20ed67e791544c30fecd795", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "agda/ooAgda", "max_issues_repo_path": "src/UnSizedIO/IOObject.agda", "max_line_length": 80, "max_stars_count": 23, "max_stars_repo_head_hexsha": "7cc45e0148a4a508d20ed67e791544c30fecd795", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "agda/ooAgda", "max_stars_repo_path": "src/UnSizedIO/IOObject.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": 178, "size": 643 }
{-# OPTIONS --copatterns #-} open import Common.Size open import Common.Prelude open import Common.Product renaming (proj₁ to fst; proj₂ to snd) record Stream (i : Size) (A : Set) : Set where coinductive field force : ∀{j : Size< i} → A × Stream j A open Stream head : ∀{i A} → Stream (↑ i) A → A head s = fst (force s) tail : ∀{i A} → Stream (↑ i) A → Stream i A tail s = snd (force s) smap : ∀{i A B} (f : A → B) → Stream i A → Stream i B force (smap f s) with force s ... | a , as = f a , smap f as scanl : ∀{i A B} (f : B → A → B) (b : B) (s : Stream i A) → Stream i B force (scanl f b s) with force s ... | a , as = b , scanl f (f b a) as _!_ : ∀{A} (s : Stream _ A) (n : Nat) → A s ! zero = head s s ! suc n = tail s ! n _!!_ : ∀{A} (s : Stream _ A) (n : Nat) → A s !! n with force s _ !! zero | a , as = a _ !! suc n | a , as = as !! n nats : ∀{i} → Stream i Nat force nats = 0 , smap suc nats sums : Stream _ Nat sums = scanl (_+_) 0 (tail nats) main : IO Unit main = printNat (sums ! 100) -- Expected output, due to Gauss: 5050
{ "alphanum_fraction": 0.5620853081, "avg_line_length": 23.9772727273, "ext": "agda", "hexsha": "0252795029122598c91b930a01b8f8e45df6f7fb", "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": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "redfish64/autonomic-agda", "max_forks_repo_path": "test/Compiler/simple/CopatternStreamSized.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "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": "redfish64/autonomic-agda", "max_issues_repo_path": "test/Compiler/simple/CopatternStreamSized.agda", "max_line_length": 70, "max_stars_count": null, "max_stars_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "redfish64/autonomic-agda", "max_stars_repo_path": "test/Compiler/simple/CopatternStreamSized.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 415, "size": 1055 }
{-# OPTIONS --without-K --allow-unsolved-metas #-} module Space where open import Data.Empty using (⊥; ⊥-elim) open import Data.Nat using (ℕ; suc) renaming (_+_ to _ℕ+_; _*_ to _ℕ*_; _⊔_ to _ℕ⊔_) open import Data.Nat.Properties open import Data.Integer as ℤ using (ℤ; +_; -[1+_]; ∣_∣; _+_; _⊔_; -_) open import Data.Rational using (ℚ) renaming (1/_ to recip) open import Data.Sum using (_⊎_; inj₁; inj₂) open import Data.Product using (_×_; _,_; proj₁; proj₂) open import Data.Maybe open import Relation.Nullary using (¬_; yes; no) open import Relation.Binary.PropositionalEquality renaming ([_] to R[_]) using (_≡_; refl; sym; trans; cong; inspect) open import Data.Unit using (⊤; tt) open import Singleton open import PiFrac ------------------------------------------------------------------------------ -- Space denotational semantics -- for each type, we calculate its memory requirements which are two -- numbers (m , z). The number m represents the amount of space needed -- to store values of the type. The number z represents the effect of -- the value on space when it is interpreted. Ex. a gc process needs m -- bits to be stored but when run it releases z bits. -- Number of points in type card : (t : 𝕌) → ℕ card 𝟘 = 0 card 𝟙 = 1 card (t₁ +ᵤ t₂) = card t₁ ℕ+ card t₂ card (t₁ ×ᵤ t₂) = card t₁ ℕ* card t₂ card ● t [ v ] = 1 card 𝟙/● t [ v ] = 1 -- If number of points is zero then it is impossible to find a value -- of the type 0empty : {t : 𝕌} → card t ≡ 0 → (v : ⟦ t ⟧) → ⊥ 0empty {𝟘} _ () 0empty {𝟙} () tt 0empty {t₁ +ᵤ t₂} s (inj₁ v₁) with card t₁ | card t₂ | inspect card t₁ 0empty {t₁ +ᵤ t₂} refl (inj₁ v₁) | ℕ.zero | ℕ.zero | R[ s₁ ] = 0empty {t₁} s₁ v₁ 0empty {t₁ +ᵤ t₂} s (inj₂ v₂) with card t₁ | card t₂ | inspect card t₂ 0empty {t₁ +ᵤ t₂} refl (inj₂ v₂) | ℕ.zero | ℕ.zero | R[ s₂ ] = 0empty {t₂} s₂ v₂ 0empty {t₁ ×ᵤ t₂} s (v₁ , v₂) with card t₁ | card t₂ | inspect card t₁ | inspect card t₂ 0empty {t₁ ×ᵤ t₂} refl (v₁ , v₂) | ℕ.zero | _ | R[ s₁ ] | _ = 0empty {t₁} s₁ v₁ 0empty {t₁ ×ᵤ t₂} s (v₁ , v₂) | ℕ.suc n₁ | ℕ.zero | R[ s₁ ] | R[ s₂ ] = 0empty {t₂} s₂ v₂ 0empty {● t [ v ]} () (.v , refl) 0empty {𝟙/● t [ v ]} () f -- Space effects -- For a pointed type, even though we only have one value, that value -- could be large and we need just as much space to store it as we -- would need for any value of the given type. For a fractional type, -- the effect is to de-allocate the space above. space : (t : 𝕌) → {¬t≡0 : ¬ card t ≡ 0} → ℤ space 𝟘 {0ne} = ⊥-elim (0ne refl) space 𝟙 = + 0 space (t₁ +ᵤ t₂) {pne} with card t₁ | card t₂ | inspect card t₁ | inspect card t₂ ... | 0 | 0 | R[ s₁ ] | R[ s₂ ] = ⊥-elim (pne refl) ... | 0 | suc n | R[ s₁ ] | R[ s₂ ] = space t₂ {λ t2≡0 → ⊥-elim (pne (trans (sym s₂) t2≡0))} ... | suc m | 0 | R[ s₁ ] | R[ s₂ ] = space t₁ {λ t1≡0 → ⊥-elim (pne (trans (sym (trans s₁ (sym (+-identityʳ (suc m))))) t1≡0))} ... | suc m | suc n | R[ s₁ ] | R[ s₂ ] = + 1 + (space t₁ {λ t1≡0 → ⊥-elim (1+n≢0 (trans (sym s₁) t1≡0))} ⊔ space t₂ {λ t2≡0 → ⊥-elim ((1+n≢0 (trans (sym s₂) t2≡0)))}) space (t₁ ×ᵤ t₂) {pne} with card t₁ | card t₂ | inspect card t₁ | inspect card t₂ ... | 0 | 0 | R[ s₁ ] | R[ s₂ ] = ⊥-elim (pne refl) ... | 0 | suc n | R[ s₁ ] | R[ s₂ ] = ⊥-elim (pne refl) ... | suc m | 0 | R[ s₁ ] | R[ s₂ ] = ⊥-elim (pne (*-zeroʳ (suc m))) ... | suc m | suc n | R[ s₁ ] | R[ s₂ ] = space t₁ {λ t1≡0 → ⊥-elim (1+n≢0 (trans (sym s₁) t1≡0))} + space t₂ {λ t2≡0 → ⊥-elim (1+n≢0 (trans (sym s₂) t2≡0))} space ● t [ v ] = space t {λ t≡0 → 0empty t≡0 v} space 𝟙/● t [ v ] = - space t {λ t≡0 → 0empty t≡0 v} -- TODO -- Every combinator preserves space effects card= : (t₁ t₂ : 𝕌) (C : t₁ ⟷ t₂) → (card t₁ ≡ card t₂) card= .(𝟘 +ᵤ t₂) t₂ unite₊l = refl card= t₁ .(𝟘 +ᵤ t₁) uniti₊l = refl card= .(t₂ +ᵤ 𝟘) t₂ unite₊r rewrite +-identityʳ (card t₂) = refl card= t₁ .(t₁ +ᵤ 𝟘) uniti₊r rewrite +-identityʳ (card t₁) = refl card= (t₁ +ᵤ t₂) _ swap₊ rewrite +-comm (card t₁) (card t₂) = refl card= (t₁ +ᵤ t₂ +ᵤ t₃) _ assocl₊ rewrite +-assoc (card t₁) (card t₂) (card t₃) = refl card= ((t₁ +ᵤ t₂) +ᵤ t₃) _ assocr₊ rewrite +-assoc (card t₁) (card t₂) (card t₃) = refl card= (𝟙 ×ᵤ t₂) t₂ unite⋆l rewrite +-identityʳ (card t₂) = refl card= t₁ (𝟙 ×ᵤ t₁) uniti⋆l rewrite +-identityʳ (card t₁) = refl card= (t₂ ×ᵤ 𝟙) t₂ unite⋆r rewrite *-identityʳ (card t₂) = refl card= t₁ (t₁ ×ᵤ 𝟙) uniti⋆r rewrite *-identityʳ (card t₁) = refl card= (t₁ ×ᵤ t₂) _ swap⋆ rewrite *-comm (card t₁) (card t₂) = refl card= (t₁ ×ᵤ t₂ ×ᵤ t₃) _ assocl⋆ rewrite *-assoc (card t₁) (card t₂) (card t₃) = refl card= ((t₁ ×ᵤ t₂) ×ᵤ t₃) _ assocr⋆ rewrite *-assoc (card t₁) (card t₂) (card t₃) = refl card= .(𝟘 ×ᵤ _) .𝟘 absorbr = refl card= (t ×ᵤ 𝟘) .𝟘 absorbl rewrite *-zeroʳ (card t) = refl card= .𝟘 (t ×ᵤ 𝟘) factorzr rewrite *-zeroʳ (card t) = refl card= .𝟘 .(𝟘 ×ᵤ _) factorzl = refl card= ((t₁ +ᵤ t₂) ×ᵤ t₃) _ dist rewrite *-distribʳ-+ (card t₃) (card t₁) (card t₂) = refl card= _ ((t₁ +ᵤ t₂) ×ᵤ t₃) factor rewrite *-distribʳ-+ (card t₃) (card t₁) (card t₂) = refl card= (t₃ ×ᵤ (t₁ +ᵤ t₂)) _ distl rewrite *-distribˡ-+ (card t₃) (card t₁) (card t₂) = refl card= _ (t₃ ×ᵤ (t₁ +ᵤ t₂)) factorl rewrite *-distribˡ-+ (card t₃) (card t₁) (card t₂) = refl card= t₁ .t₁ id⟷ = refl card= t₁ t₂ (c₁ ⊚ c₂) rewrite card= _ _ c₁ | card= _ _ c₂ = refl card= (t₁ +ᵤ t₂) (t₃ +ᵤ t₄) (c₁ ⊕ c₂) rewrite card= _ _ c₁ | card= _ _ c₂ = refl card= (t₁ ×ᵤ t₂) (t₃ ×ᵤ t₄) (c₁ ⊗ c₂) rewrite card= _ _ c₁ | card= _ _ c₂ = refl card= .(● _ [ _ ]) .(● _ [ eval c _ ]) (lift c) = refl card= .(● _ ×ᵤ _ [ _ , _ ]) .(● _ [ _ ] ×ᵤ ● _ [ _ ]) tensorl = refl card= .(● _ [ _ ] ×ᵤ ● _ [ _ ]) .(● _ ×ᵤ _ [ _ , _ ]) tensorr = refl card= .(● _ +ᵤ _ [ inj₁ _ ]) .(● _ [ _ ]) plusll = refl card= .(● _ [ _ ]) .(● _ +ᵤ _ [ inj₁ _ ]) pluslr = refl card= .(● _ +ᵤ _ [ inj₂ _ ]) .(● _ [ _ ]) plusrl = refl card= .(● _ [ _ ]) .(● _ +ᵤ _ [ inj₂ _ ]) plusrr = refl card= .(𝟙/● _ ×ᵤ _ [ _ , _ ]) .(𝟙/● _ [ _ ] ×ᵤ 𝟙/● _ [ _ ]) fracl = refl card= .(𝟙/● _ [ _ ] ×ᵤ 𝟙/● _ [ _ ]) .(𝟙/● _ ×ᵤ _ [ _ , _ ]) fracr = refl card= .𝟙 .(● _ [ v ] ×ᵤ 𝟙/● _ [ v ]) (η v) = refl card= .(● _ [ v ] ×ᵤ 𝟙/● _ [ v ]) .𝟙 (ε v) = refl card= .(● _ [ _ ]) .(● _ [ _ ]) (== c x) = refl card= .(● (● t [ v ]) [ w ]) .(● t [ v ]) (ll {t} {v} {w}) = refl space= : (t₁ t₂ : 𝕌) → (c : t₁ ⟷ t₂) → Set space= t₁ t₂ c with card t₁ ≟ 0 space= t₁ t₂ c | yes _ = ⊤ space= t₁ t₂ c | no nz₁ = space t₁ {nz₁} ≡ space t₂ {λ nz₂ → nz₁ (trans (card= _ _ c) nz₂)} space≡ : (t₁ t₂ : 𝕌) → (c : t₁ ⟷ t₂) → space= t₁ t₂ c space≡ t₁ t₂ c with card t₁ ≟ 0 space≡ t₁ t₂ c | yes _ = tt space≡ t₁ t₂ c | no nz₁ = {!!} -- Groupoid interpretation ???? Groupoid for pointed 1/A is point and -- (size A) loops on point labeled (= a1), (= a2), (= a3), etc. ------------------------------------------------------------------------------
{ "alphanum_fraction": 0.5509786737, "avg_line_length": 44.1677419355, "ext": "agda", "hexsha": "61e723f4ec7113620ae0cab7f4e6d0b38279d442", "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": "fracGC/Space.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": "fracGC/Space.agda", "max_line_length": 93, "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": "fracGC/Space.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": 3226, "size": 6846 }
_∘_ : {A : Set} {B : A → Set} {C : {x : A} → B x → Set₁} → (∀ {x} (y : B x) → C y) → (g : (x : A) → B x) → ((x : A) → C (g x)) f ∘ g = λ x → f (g x) postulate R : {A : Set₁} → A → A → Set₁ _≡_ : {A : Set₁} → A → A → Set₁ _≡_ = R data D (A : Set) : Set where c : A → D A postulate cong : {A B : Set₁} {x y : A} (f : A → B) → x ≡ y → f x ≡ f y refl : {A : Set₁} {x : A} → x ≡ x A : Set P : D A → Set p : (F : A → Set) → (P ∘ c) ≡ F → (P ∘ c) ≡ F eq : P ≡ P _ : p (P ∘ c) (cong (_∘ c) eq) ≡ p (P ∘ c) (cong (_∘ c) eq) _ = cong (λ eq → p _ eq) (cong (cong (_∘ c)) refl)
{ "alphanum_fraction": 0.3565640194, "avg_line_length": 23.7307692308, "ext": "agda", "hexsha": "fc2702ccdcbb96be565ab28315b1f637edb79df3", "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": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "shlevy/agda", "max_forks_repo_path": "test/Succeed/Issue4907.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/Issue4907.agda", "max_line_length": 64, "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/Issue4907.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": 335, "size": 617 }
-------------------------------------------------------------------------------- -- This is part of Agda Inference Systems {-# OPTIONS --sized-types --guardedness #-} open import Data.Product open import Data.Vec open import Data.Unit open import Codata.Colist open import Agda.Builtin.Equality open import Size open import Data.Nat open import Data.Fin open import Codata.Thunk open import Relation.Unary using (_⊆_) open import Examples.Colists.Auxiliary.Colist_member open import is-lib.InfSys module Examples.Colists.allPos where U = Colist ℕ ∞ data allPosRN : Set where allp-Λ allp-t : allPosRN allP-Λ-r : FinMetaRule U allP-Λ-r .Ctx = ⊤ allP-Λ-r .comp c = [] , ----------------- [] allP-t-r : FinMetaRule U allP-t-r .Ctx = Σ[ (x , _) ∈ ℕ × Thunk (Colist ℕ) ∞ ] x Data.Nat.> 0 allP-t-r .comp ((x , xs) , _) = xs .force ∷ [] , ----------------- x ∷ xs allPosIS : IS U allPosIS .Names = allPosRN allPosIS .rules allp-Λ = from allP-Λ-r allPosIS .rules allp-t = from allP-t-r allPos : U → Set allPos = CoInd⟦ allPosIS ⟧ allPosSpec : U → Set allPosSpec xs = ∀{x} → x ∈ xs → x Data.Nat.> 0 allPosSound : allPos ⊆ allPosSpec allPosSound {x ∷ xs} ap mem with ap .CoInd⟦_⟧.unfold allPosSound {x ∷ xs} ap here | allp-t , ((.x , .xs) , x>0) , refl , prem = x>0 allPosSound {x ∷ xs} ap (there mem) | allp-t , ((.x , .xs) , _) , refl , prem = allPosSound (prem zero) mem allPosSpecCons : ∀{xs} → allPosSpec xs → ISF[ allPosIS ] allPosSpec xs allPosSpecCons {[]} _ = allp-Λ , (tt , (refl , λ ())) allPosSpecCons {(x ∷ xs)} Sxs = allp-t , (((x , xs) , Sxs here) , (refl , λ {Fin.zero → λ mem → Sxs (there mem)})) allPosComplete : allPosSpec ⊆ allPos allPosComplete = coind[ allPosIS ] allPosSpec allPosSpecCons {- allPos as Container -} open import Data.Empty using (⊥) open import Data.Container.Indexed open import is-lib.InfSys.Container U open ISCont allPosCont : ISCont allPosCont .Command [] = ⊤ allPosCont .Command (x ∷ xs) = x Data.Nat.> 0 allPosCont .Response {[]} tt = ⊥ allPosCont .Response {_ ∷ _} _ = Fin 1 allPosCont .next {_ ∷ xs} _ zero = xs .force allPosC : U → Set allPosC = ISCont.CoInd⟦ allPosCont ⟧
{ "alphanum_fraction": 0.6079749104, "avg_line_length": 28.253164557, "ext": "agda", "hexsha": "cdcdd97c0bd11afccda13461add26ea8696a039a", "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": "b9043f99e4bf7211db4066a7a943401d127f0c8f", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "LcicC/inference-systems-agda", "max_forks_repo_path": "Examples/Colists/allPos.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "b9043f99e4bf7211db4066a7a943401d127f0c8f", "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": "LcicC/inference-systems-agda", "max_issues_repo_path": "Examples/Colists/allPos.agda", "max_line_length": 116, "max_stars_count": 3, "max_stars_repo_head_hexsha": "b9043f99e4bf7211db4066a7a943401d127f0c8f", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "LcicC/inference-systems-agda", "max_stars_repo_path": "Examples/Colists/allPos.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-25T15:48:52.000Z", "max_stars_repo_stars_event_min_datetime": "2022-03-10T15:53:47.000Z", "num_tokens": 794, "size": 2232 }
module Cats.Bifunctor where open import Data.Product using (_,_) open import Level using (_⊔_) open import Relation.Binary using (IsEquivalence ; _Preserves₂_⟶_⟶_) open import Cats.Category open import Cats.Category.Cat using (_∘_ ; ∘-resp ; _≈_ ; equiv) open import Cats.Category.Cat.Facts.Product using (Swap ; hasBinaryProducts) open import Cats.Category.Fun using (Fun ; Trans ; ≈-intro ; ≈-elim) open import Cats.Category.Product.Binary using (_×_) open import Cats.Category.Product.Binary.Facts using (iso-intro) open import Cats.Functor using (Functor) open import Cats.Trans.Iso using (NatIso) open import Cats.Util.Simp using (simp!) import Cats.Category.Constructions.Iso as Iso import Cats.Category.Fun.Facts as Fun open Functor open Trans open Iso.Build._≅_ module _ {lo la l≈ lo′ la′ l≈′ lo″ la″ l≈″} where Bifunctor : Category lo la l≈ → Category lo′ la′ l≈′ → Category lo″ la″ l≈″ → Set (lo ⊔ la ⊔ l≈ ⊔ lo′ ⊔ la′ ⊔ l≈′ ⊔ lo″ ⊔ la″ ⊔ l≈″) Bifunctor C D E = Functor (C × D) E module _ {C : Category lo la l≈} {D : Category lo′ la′ l≈′} {E : Category lo″ la″ l≈″} where private module C = Category C module D = Category D module E = Category E biobj : Bifunctor C D E → C.Obj → D.Obj → E.Obj biobj F c d = fobj F (c , d) bimap : (F : Bifunctor C D E) → ∀ {A B A′ B′} → (A C.⇒ B) → (A′ D.⇒ B′) → biobj F A A′ E.⇒ biobj F B B′ bimap F f g = fmap F (f , g) Bifunctor→Functor₁ : Bifunctor C D E → C.Obj → Functor D E Bifunctor→Functor₁ F x = record { fobj = λ d → fobj F (x , d) ; fmap = λ f → fmap F (C.id , f) ; fmap-resp = λ x≈y → fmap-resp F (C.≈.refl , x≈y) ; fmap-id = fmap-id F ; fmap-∘ = λ where {f = f} {g} → begin fmap F (C.id , f) E.∘ fmap F (C.id , g) ≈⟨ fmap-∘ F ⟩ fmap F (C.id C.∘ C.id , f D.∘ g) ≈⟨ fmap-resp F (C.id-l , D.≈.refl) ⟩ fmap F (C.id , f D.∘ g) ∎ } where open E.≈-Reasoning Bifunctor→Functor₁-resp : ∀ {F G x y} → F ≈ G → x C.≅ y → Bifunctor→Functor₁ F x ≈ Bifunctor→Functor₁ G y Bifunctor→Functor₁-resp {F} {G} {x} {y} record { iso = Fx≅Gx ; forth-natural = fnat } x≅y = record { iso = λ {z} → let open E.≅-Reasoning in begin fobj F (x , z) ≈⟨ Fx≅Gx ⟩ fobj G (x , z) ≈⟨ fobj-resp G (iso-intro x≅y D.≅.refl) ⟩ fobj G (y , z) ∎ ; forth-natural = λ {c} {d} {f} → let open E.≈-Reasoning in triangle (fmap G (forth x≅y , f) E.∘ forth Fx≅Gx) ( begin ((E.id E.∘ fmap G (forth x≅y , D.id)) E.∘ forth Fx≅Gx) E.∘ fmap F (C.id , f) ≈⟨ simp! E ⟩ fmap G (forth x≅y , D.id) E.∘ forth Fx≅Gx E.∘ fmap F (C.id , f) ≈⟨ E.∘-resp-r fnat ⟩ fmap G (forth x≅y , D.id) E.∘ (fmap G (C.id , f) E.∘ forth Fx≅Gx) ≈⟨ simp! E ⟩ (fmap G (forth x≅y , D.id) E.∘ fmap G (C.id , f)) E.∘ forth Fx≅Gx ≈⟨ E.∘-resp-l (fmap-∘ G) ⟩ fmap G (forth x≅y C.∘ C.id , D.id D.∘ f) E.∘ forth Fx≅Gx ≈⟨ E.∘-resp-l (fmap-resp G (C.id-r , D.id-l)) ⟩ fmap G (forth x≅y , f) E.∘ forth Fx≅Gx ∎ ) ( begin fmap G (C.id , f) E.∘ (E.id E.∘ fmap G (forth x≅y , D.id)) E.∘ forth Fx≅Gx ≈⟨ E.∘-resp-r (E.∘-resp-l E.id-l) ⟩ fmap G (C.id , f) E.∘ fmap G (forth x≅y , D.id) E.∘ forth Fx≅Gx ≈⟨ simp! E ⟩ (fmap G (C.id , f) E.∘ fmap G (forth x≅y , D.id)) E.∘ forth Fx≅Gx ≈⟨ E.∘-resp-l (fmap-∘ G) ⟩ fmap G (C.id C.∘ forth x≅y , f D.∘ D.id) E.∘ forth Fx≅Gx ≈⟨ E.∘-resp-l (fmap-resp G (C.id-l , D.id-r)) ⟩ fmap G (forth x≅y , f) E.∘ forth Fx≅Gx ∎ ) } transposeBifunctor₁ : Bifunctor C D E → Functor C (Fun D E) transposeBifunctor₁ F = record { fobj = Bifunctor→Functor₁ F ; fmap = λ {a} {b} f → record { component = λ d → fmap F (f , D.id) ; natural = λ {a′} {b′} {g} → begin fmap F (f , D.id) E.∘ fmap (Bifunctor→Functor₁ F a) g ≈⟨ fmap-∘ F ⟩ fmap F (f C.∘ C.id , D.id D.∘ g) ≈⟨ fmap-resp F ( (C.≈.trans C.id-r (C.≈.sym C.id-l)) , D.≈.trans D.id-l (D.≈.sym D.id-r) ) ⟩ fmap F (C.id C.∘ f , g D.∘ D.id) ≈⟨ E.≈.sym (fmap-∘ F) ⟩ fmap (Bifunctor→Functor₁ F b) g E.∘ fmap F (f , D.id) ∎ } ; fmap-resp = λ x≈y → ≈-intro (fmap-resp F (x≈y , D.≈.refl)) ; fmap-id = ≈-intro (fmap-id F) ; fmap-∘ = λ where {f = f} {g} → ≈-intro ( begin fmap F (f , D.id) E.∘ fmap F (g , D.id) ≈⟨ fmap-∘ F ⟩ fmap F (f C.∘ g , D.id D.∘ D.id) ≈⟨ fmap-resp F (C.≈.refl , D.id-l) ⟩ fmap F (f C.∘ g , D.id) ∎) } where open E.≈-Reasoning transposeBifunctor₁-resp : ∀ {F G} → F ≈ G → transposeBifunctor₁ F ≈ transposeBifunctor₁ G transposeBifunctor₁-resp {F} {G} F≈G = record { iso = Fun.≈→≅ (Bifunctor→Functor₁-resp F≈G C.≅.refl) ; forth-natural = λ {c} {d} {f} → ≈-intro ( let open E.≈-Reasoning in triangle (fmap G (f , D.id) E.∘ forth (iso F≈G)) ( begin ((E.id E.∘ fmap G (C.id , D.id)) E.∘ forth (iso F≈G)) E.∘ fmap F (f , D.id) ≈⟨ E.∘-resp-l (E.≈.trans (E.∘-resp-l (E.≈.trans E.id-l (fmap-id G))) E.id-l) ⟩ forth (iso F≈G) E.∘ fmap F (f , D.id) ≈⟨ forth-natural F≈G ⟩ (fmap G (f , D.id) E.∘ forth (iso F≈G)) ∎ ) ( begin fmap G (f , D.id) E.∘ (E.id E.∘ fmap G (C.id , D.id)) E.∘ forth (iso F≈G) ≈⟨ E.∘-resp-r (E.≈.trans (E.∘-resp-l (E.≈.trans E.id-l (fmap-id G))) E.id-l) ⟩ fmap G (f , D.id) E.∘ forth (iso F≈G) ∎ )) } where open E.≈-Reasoning open NatIso using (iso ; forth-natural) module _ {lo la l≈} {C : Category lo la l≈} {lo′ la′ l≈′} {D : Category lo′ la′ l≈′} {lo″ la″ l≈″} {E : Category lo″ la″ l≈″} where private module C = Category C module D = Category D module E = Category E Bifunctor→Functor₂ : Bifunctor C D E → D.Obj → Functor C E Bifunctor→Functor₂ F x = Bifunctor→Functor₁ (F ∘ Swap) x Bifunctor→Functor₂-resp : ∀ {F G x y} → F ≈ G → x D.≅ y → Bifunctor→Functor₂ F x ≈ Bifunctor→Functor₂ G y Bifunctor→Functor₂-resp {F} {G} F≈G x≅y = Bifunctor→Functor₁-resp {F = F ∘ Swap} {G = G ∘ Swap} (∘-resp F≈G refl) x≅y where open IsEquivalence equiv transposeBifunctor₂ : Bifunctor C D E → Functor D (Fun C E) transposeBifunctor₂ F = transposeBifunctor₁ (F ∘ Swap) transposeBifunctor₂-resp : ∀ {F G} → F ≈ G → transposeBifunctor₂ F ≈ transposeBifunctor₂ G transposeBifunctor₂-resp {F} {G} F≈G = transposeBifunctor₁-resp {F = F ∘ Swap} {G = G ∘ Swap} (∘-resp F≈G refl) where open IsEquivalence equiv
{ "alphanum_fraction": 0.4645847176, "avg_line_length": 33.296460177, "ext": "agda", "hexsha": "63a35ca97416c0f5ed48fcbf79659f9c74dd54e5", "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": "a3b69911c4c6ec380ddf6a0f4510d3a755734b86", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "alessio-b-zak/cats", "max_forks_repo_path": "Cats/Bifunctor.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "a3b69911c4c6ec380ddf6a0f4510d3a755734b86", "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": "alessio-b-zak/cats", "max_issues_repo_path": "Cats/Bifunctor.agda", "max_line_length": 92, "max_stars_count": null, "max_stars_repo_head_hexsha": "a3b69911c4c6ec380ddf6a0f4510d3a755734b86", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "alessio-b-zak/cats", "max_stars_repo_path": "Cats/Bifunctor.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 3024, "size": 7525 }
------------------------------------------------------------------------ -- Banker's queues (following Okasaki) ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} open import Equality module Queue.Bankers {c⁺} (eq : ∀ {a p} → Equality-with-J a p c⁺) where open Derived-definitions-and-properties eq open import Prelude open import Bijection eq using (_↔_) open import Erased.Without-box-cong eq as Erased hiding (map) open import Function-universe eq hiding (id; _∘_) open import List eq as L hiding (map) open import Nat eq open import Surjection eq using (_↠_) open import Tactic.By.Parametrised eq private variable a ℓ ℓ₁ ℓ₂ : Level A B : Type a p q x : A f : A → B b : Bool xs : List A ------------------------------------------------------------------------ -- Queues -- Queues. -- -- Note that the invariant is erased. record Queue (A : Type a) : Type a where field front rear : List A length-front length-rear : ℕ @0 length-invariant : length-rear ≤ length-front @0 length-front≡ : length-front ≡ length front @0 length-rear≡ : length-rear ≡ length rear open Queue public ------------------------------------------------------------------------ -- Conversion functions -- Converts queues to lists. to-List : Queue A → List A to-List q = q .front ++ reverse (q .rear) -- Converts lists to queues. from-List : List A → Queue A from-List xs = record { front = xs ; rear = [] ; length-front = length xs ; length-rear = 0 ; length-invariant = zero≤ _ ; length-front≡ = refl _ ; length-rear≡ = refl _ } -- The function from-List is a right inverse of to-List. to-List-from-List : to-List (from-List xs) ≡ xs to-List-from-List {xs = xs} = xs ++ [] ≡⟨ ++-right-identity _ ⟩∎ xs ∎ ------------------------------------------------------------------------ -- Queues with broken invariants private -- Queues where the invariant may have been broken (slightly). record Almost-queue (A : Type a) : Type a where field front rear : List A length-front length-rear : ℕ @0 length-invariant : length-rear ≤ suc length-front @0 length-front≡ : length-front ≡ length front @0 length-rear≡ : length-rear ≡ length rear open Almost-queue -- Some conversion functions. from-Almost-queue : Almost-queue A → List A from-Almost-queue q = q .front ++ reverse (q .rear) to-Almost-queue : Queue A → Almost-queue A to-Almost-queue q = record { front = q .front ; rear = q .rear ; length-front = q .length-front ; length-rear = q .length-rear ; length-front≡ = q .length-front≡ ; length-rear≡ = q .length-rear≡ ; length-invariant = ≤-step (q .length-invariant) } -- Restores the invariant by rotating the queue, if necessary. rotate′ : (q : Almost-queue A) (b : Bool) → @0 T b ↔ suc (q .length-front) ≡ q .length-rear → Queue A rotate′ q true _ = record { front = q .front ++ reverse (q .rear) ; rear = [] ; length-front = q .length-front + q .length-rear ; length-rear = 0 ; length-invariant = zero≤ _ ; length-rear≡ = refl _ ; length-front≡ = ⟨ q .length-front ⟩ + q .length-rear ≡⟨ ⟨by⟩ (q .length-front≡) ⟩ length (q .front) + ⟨ q .length-rear ⟩ ≡⟨ ⟨by⟩ (q .length-rear≡) ⟩ length (q .front) + ⟨ length (q .rear) ⟩ ≡⟨ ⟨by⟩ (length-reverse (q .rear)) ⟩ ⟨ length (q .front) + length (reverse (q .rear)) ⟩ ≡⟨ ⟨by⟩ (length-++ (q .front)) ⟩∎ length (q .front ++ reverse (q .rear)) ∎ } rotate′ q false 1+f≢r = record { front = q .front ; rear = q .rear ; length-front = q .length-front ; length-rear = q .length-rear ; length-front≡ = q .length-front≡ ; length-rear≡ = q .length-rear≡ ; length-invariant = case ≤→<⊎≡ (q .length-invariant) of λ @0 where (inj₁ 1+r≤1+f) → suc≤suc⁻¹ 1+r≤1+f (inj₂ r≡1+f) → ⊥-elim (_↔_.from 1+f≢r (sym r≡1+f)) } rotate : Almost-queue A → Queue A rotate q = rotate′ q (suc (q .length-front) == q .length-rear) T[==]↔≡ to-List-rotate′ : ∀ b {p} → to-List (rotate′ q b p) ≡ from-Almost-queue q to-List-rotate′ false = refl _ to-List-rotate′ {q = q} true = (q .front ++ reverse (q .rear)) ++ [] ≡⟨ ++-right-identity _ ⟩∎ q .front ++ reverse (q .rear) ∎ to-List-rotate : (q : Almost-queue A) → to-List (rotate q) ≡ from-Almost-queue q to-List-rotate q = to-List-rotate′ (suc (q .length-front) == q .length-rear) ------------------------------------------------------------------------ -- Queue operations -- Enqueues an element. enqueue : A → Queue A → Queue A enqueue x q = rotate (record (to-Almost-queue q) { rear = x ∷ q .rear ; length-rear = 1 + q .length-rear ; length-rear≡ = cong suc (q .length-rear≡) ; length-invariant = suc≤suc (q .length-invariant) }) to-List-enqueue : ∀ q → to-List (enqueue x q) ≡ to-List q ++ x ∷ [] to-List-enqueue {x = x} q = to-List (enqueue x q) ≡⟨ to-List-rotate (record { length-invariant = suc≤suc (q .length-invariant) }) ⟩ q .front ++ ⟨ reverse (x ∷ q .rear) ⟩ ≡⟨ ⟨by⟩ (reverse-∷ (q .rear)) ⟩ q .front ++ (reverse (q .rear) ++ x ∷ []) ≡⟨ ++-associative (q .front) _ _ ⟩∎ (q .front ++ reverse (q .rear)) ++ x ∷ [] ∎ -- Dequeues an element, if possible. dequeue : Queue A → Maybe (A × Queue A) dequeue (record { front = [] }) = nothing dequeue q@(record { front = x ∷ front ; length-front = suc length-front }) = just (x , rotate (record (to-Almost-queue q) { front = front ; length-front = length-front ; length-invariant = q .length-invariant ; length-front≡ = cancel-suc (q .length-front≡) })) dequeue {A = A} q@(record { front = x ∷ front ; length-front = zero }) = $⟨ [ q .length-front≡ ] ⟩ Erased (zero ≡ suc (length front)) ↝⟨ Erased.map 0≢+ ⟩ Erased ⊥ ↔⟨ Erased-⊥↔⊥ ⟩ ⊥ ↝⟨ ⊥-elim ⟩□ Maybe (A × Queue A) □ to-List-dequeue : (q : Queue A) → ⊎-map id (Σ-map id to-List) (dequeue q) ≡ _↔_.to List↔Maybe[×List] (to-List q) to-List-dequeue (record { front = []; rear = [] }) = refl _ to-List-dequeue q@(record { front = []; rear = _ ∷ _ }) = $⟨ [ q .length-invariant ] ⟩ Erased (q .length-rear ≤ q .length-front) ↝⟨ Erased.map (subst (_ ≤_) (q .length-front≡)) ⟩ Erased (q .length-rear ≤ 0) ↝⟨ Erased.map (subst (_≤ _) (q .length-rear≡)) ⟩ Erased (suc _ ≤ 0) ↝⟨ Erased.map (≮0 _) ⟩ Erased ⊥ ↔⟨ Erased-⊥↔⊥ ⟩ ⊥ ↝⟨ ⊥-elim ⟩□ _ □ to-List-dequeue q@(record { front = x ∷ front ; length-front = suc length-front }) = cong (just ∘ (x ,_)) (to-List-rotate (record { length-invariant = q .length-invariant })) to-List-dequeue q@(record { front = x ∷ front ; length-front = zero }) = $⟨ [ q .length-front≡ ] ⟩ Erased (zero ≡ suc (length front)) ↝⟨ Erased.map 0≢+ ⟩ Erased ⊥ ↔⟨ Erased-⊥↔⊥ ⟩ ⊥ ↝⟨ ⊥-elim ⟩□ _ □ -- The "inverse" of the dequeue operation. dequeue⁻¹ : Maybe (A × Queue A) → Queue A dequeue⁻¹ nothing = from-List [] dequeue⁻¹ (just (x , q)) = record q { front = x ∷ q .front ; length-front = suc (q .length-front) ; length-invariant = ≤-step (q .length-invariant) ; length-front≡ = cong suc (q .length-front≡) } to-List-dequeue⁻¹ : (x : Maybe (A × Queue A)) → to-List (dequeue⁻¹ x) ≡ _↔_.from List↔Maybe[×List] (⊎-map id (Σ-map id to-List) x) to-List-dequeue⁻¹ nothing = refl _ to-List-dequeue⁻¹ (just _) = refl _ -- A map function. map : (A → B) → Queue A → Queue B map f q = record { front = L.map f (q .front) ; rear = L.map f (q .rear) ; length-front = q .length-front ; length-rear = q .length-rear ; length-invariant = q .length-invariant ; length-front≡ = q .length-front ≡⟨ q .length-front≡ ⟩ ⟨ length (q .front) ⟩ ≡⟨ ⟨by⟩ (length∘map _ (q .front)) ⟩∎ length (L.map f (q .front)) ∎ ; length-rear≡ = q .length-rear ≡⟨ q .length-rear≡ ⟩ ⟨ length (q .rear) ⟩ ≡⟨ ⟨by⟩ (length∘map _ (q .rear)) ⟩∎ length (L.map f (q .rear)) ∎ } to-List-map : ∀ q → to-List (map f q) ≡ L.map f (to-List q) to-List-map {f = f} q = L.map f (q .front) ++ ⟨ reverse (L.map f (q .rear)) ⟩ ≡⟨ ⟨by⟩ (map-reverse (q .rear)) ⟩ L.map f (q .front) ++ L.map f (reverse (q .rear)) ≡⟨ sym $ map-++ _ (q .front) _ ⟩∎ L.map f (q .front ++ reverse (q .rear)) ∎
{ "alphanum_fraction": 0.4812946616, "avg_line_length": 34.4782608696, "ext": "agda", "hexsha": "09c856420b5b15acae1f69eb0c9841891bf9983d", "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/Queue/Bankers.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/Queue/Bankers.agda", "max_line_length": 100, "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/Queue/Bankers.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": 3064, "size": 9516 }
open import Agda.Builtin.Reflection open import Agda.Builtin.List open import Agda.Builtin.Unit data World : Set where ww : World test : Term → TC ⊤ test hole = unify (con (quote ww) []) hole HVet : Set₁ HVet = {@(tactic test) w : World} → Set a : {HQ : HVet} → HQ → ⊤ a = _
{ "alphanum_fraction": 0.6501766784, "avg_line_length": 16.6470588235, "ext": "agda", "hexsha": "72d809c604bc8cbfba4ac969d97b4a6e6c9c0bc8", "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/Issue4170.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/Issue4170.agda", "max_line_length": 39, "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/Issue4170.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": 283 }
{-# OPTIONS --without-K --rewriting #-} module JamesAll where import JamesTwoMaps import JamesFirstComposite import JamesSecondComposite import JamesContractibility
{ "alphanum_fraction": 0.8263473054, "avg_line_length": 18.5555555556, "ext": "agda", "hexsha": "b93453a0e5ea45ff5e5e342df59709e18501e2ca", "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": "89fbc29473d2d1ed1a45c3c0e56288cdcf77050b", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "guillaumebrunerie/JamesConstruction", "max_forks_repo_path": "JamesAll.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "89fbc29473d2d1ed1a45c3c0e56288cdcf77050b", "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": "guillaumebrunerie/JamesConstruction", "max_issues_repo_path": "JamesAll.agda", "max_line_length": 39, "max_stars_count": 5, "max_stars_repo_head_hexsha": "89fbc29473d2d1ed1a45c3c0e56288cdcf77050b", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "guillaumebrunerie/JamesConstruction", "max_stars_repo_path": "JamesAll.agda", "max_stars_repo_stars_event_max_datetime": "2018-11-16T22:10:16.000Z", "max_stars_repo_stars_event_min_datetime": "2016-12-07T04:34:52.000Z", "num_tokens": 34, "size": 167 }
A : Set A = ? B : Set B = ?
{ "alphanum_fraction": 0.3571428571, "avg_line_length": 5.6, "ext": "agda", "hexsha": "5ead6bdd2f5349deb0d75395fb035f6d6e81a6d6", "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/Issue3082.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/Issue3082.agda", "max_line_length": 7, "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/Issue3082.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": 14, "size": 28 }
open import Level open import Ordinals module BAlgbra {n : Level } (O : Ordinals {n}) where open import zf open import logic import OrdUtil import OD import ODUtil import ODC open import Relation.Nullary open import Relation.Binary open import Data.Empty open import Relation.Binary open import Relation.Binary.Core open import Relation.Binary.PropositionalEquality open import Data.Nat renaming ( zero to Zero ; suc to Suc ; ℕ to Nat ; _⊔_ to _n⊔_ ; _+_ to _n+_ ) open inOrdinal O open Ordinals.Ordinals O open Ordinals.IsOrdinals isOrdinal open Ordinals.IsNext isNext open OrdUtil O open ODUtil O open OD O open OD.OD open ODAxiom odAxiom open HOD open _∧_ open _∨_ open Bool --_∩_ : ( A B : HOD ) → HOD --A ∩ B = record { od = record { def = λ x → odef A x ∧ odef B x } ; -- odmax = omin (odmax A) (odmax B) ; <odmax = λ y → min1 (<odmax A (proj1 y)) (<odmax B (proj2 y)) } _∪_ : ( A B : HOD ) → HOD A ∪ B = record { od = record { def = λ x → odef A x ∨ odef B x } ; odmax = omax (odmax A) (odmax B) ; <odmax = lemma } where lemma : {y : Ordinal} → odef A y ∨ odef B y → y o< omax (odmax A) (odmax B) lemma {y} (case1 a) = ordtrans (<odmax A a) (omax-x _ _) lemma {y} (case2 b) = ordtrans (<odmax B b) (omax-y _ _) _\_ : ( A B : HOD ) → HOD A \ B = record { od = record { def = λ x → odef A x ∧ ( ¬ ( odef B x ) ) }; odmax = odmax A ; <odmax = λ y → <odmax A (proj1 y) } ∪-Union : { A B : HOD } → Union (A , B) ≡ ( A ∪ B ) ∪-Union {A} {B} = ==→o≡ ( record { eq→ = lemma1 ; eq← = lemma2 } ) where lemma1 : {x : Ordinal} → odef (Union (A , B)) x → odef (A ∪ B) x lemma1 {x} lt = lemma3 lt where lemma4 : {y : Ordinal} → odef (A , B) y ∧ odef (* y) x → ¬ (¬ ( odef A x ∨ odef B x) ) lemma4 {y} z with proj1 z lemma4 {y} z | case1 refl = double-neg (case1 ( subst (λ k → odef k x ) *iso (proj2 z)) ) lemma4 {y} z | case2 refl = double-neg (case2 ( subst (λ k → odef k x ) *iso (proj2 z)) ) lemma3 : (((u : Ordinal ) → ¬ odef (A , B) u ∧ odef (* u) x) → ⊥) → odef (A ∪ B) x lemma3 not = ODC.double-neg-eilm O (FExists _ lemma4 not) -- choice lemma2 : {x : Ordinal} → odef (A ∪ B) x → odef (Union (A , B)) x lemma2 {x} (case1 A∋x) = subst (λ k → odef (Union (A , B)) k) &iso ( IsZF.union→ isZF (A , B) (* x) A ⟪ case1 refl , d→∋ A A∋x ⟫ ) lemma2 {x} (case2 B∋x) = subst (λ k → odef (Union (A , B)) k) &iso ( IsZF.union→ isZF (A , B) (* x) B ⟪ case2 refl , d→∋ B B∋x ⟫ ) ∩-Select : { A B : HOD } → Select A ( λ x → ( A ∋ x ) ∧ ( B ∋ x ) ) ≡ ( A ∩ B ) ∩-Select {A} {B} = ==→o≡ ( record { eq→ = lemma1 ; eq← = lemma2 } ) where lemma1 : {x : Ordinal} → odef (Select A (λ x₁ → (A ∋ x₁) ∧ (B ∋ x₁))) x → odef (A ∩ B) x lemma1 {x} lt = ⟪ proj1 lt , subst (λ k → odef B k ) &iso (proj2 (proj2 lt)) ⟫ lemma2 : {x : Ordinal} → odef (A ∩ B) x → odef (Select A (λ x₁ → (A ∋ x₁) ∧ (B ∋ x₁))) x lemma2 {x} lt = ⟪ proj1 lt , ⟪ d→∋ A (proj1 lt) , d→∋ B (proj2 lt) ⟫ ⟫ dist-ord : {p q r : HOD } → p ∩ ( q ∪ r ) ≡ ( p ∩ q ) ∪ ( p ∩ r ) dist-ord {p} {q} {r} = ==→o≡ ( record { eq→ = lemma1 ; eq← = lemma2 } ) where lemma1 : {x : Ordinal} → odef (p ∩ (q ∪ r)) x → odef ((p ∩ q) ∪ (p ∩ r)) x lemma1 {x} lt with proj2 lt lemma1 {x} lt | case1 q∋x = case1 ⟪ proj1 lt , q∋x ⟫ lemma1 {x} lt | case2 r∋x = case2 ⟪ proj1 lt , r∋x ⟫ lemma2 : {x : Ordinal} → odef ((p ∩ q) ∪ (p ∩ r)) x → odef (p ∩ (q ∪ r)) x lemma2 {x} (case1 p∩q) = ⟪ proj1 p∩q , case1 (proj2 p∩q ) ⟫ lemma2 {x} (case2 p∩r) = ⟪ proj1 p∩r , case2 (proj2 p∩r ) ⟫ dist-ord2 : {p q r : HOD } → p ∪ ( q ∩ r ) ≡ ( p ∪ q ) ∩ ( p ∪ r ) dist-ord2 {p} {q} {r} = ==→o≡ ( record { eq→ = lemma1 ; eq← = lemma2 } ) where lemma1 : {x : Ordinal} → odef (p ∪ (q ∩ r)) x → odef ((p ∪ q) ∩ (p ∪ r)) x lemma1 {x} (case1 cp) = ⟪ case1 cp , case1 cp ⟫ lemma1 {x} (case2 cqr) = ⟪ case2 (proj1 cqr) , case2 (proj2 cqr) ⟫ lemma2 : {x : Ordinal} → odef ((p ∪ q) ∩ (p ∪ r)) x → odef (p ∪ (q ∩ r)) x lemma2 {x} lt with proj1 lt | proj2 lt lemma2 {x} lt | case1 cp | _ = case1 cp lemma2 {x} lt | _ | case1 cp = case1 cp lemma2 {x} lt | case2 cq | case2 cr = case2 ⟪ cq , cr ⟫ record IsBooleanAlgebra ( L : Set n) ( b1 : L ) ( b0 : L ) ( -_ : L → L ) ( _+_ : L → L → L ) ( _x_ : L → L → L ) : Set (suc n) where field +-assoc : {a b c : L } → a + ( b + c ) ≡ (a + b) + c x-assoc : {a b c : L } → a x ( b x c ) ≡ (a x b) x c +-sym : {a b : L } → a + b ≡ b + a -sym : {a b : L } → a x b ≡ b x a +-aab : {a b : L } → a + ( a x b ) ≡ a x-aab : {a b : L } → a x ( a + b ) ≡ a +-dist : {a b c : L } → a + ( b x c ) ≡ ( a x b ) + ( a x c ) x-dist : {a b c : L } → a x ( b + c ) ≡ ( a + b ) x ( a + c ) a+0 : {a : L } → a + b0 ≡ a ax1 : {a : L } → a x b1 ≡ a a+-a1 : {a : L } → a + ( - a ) ≡ b1 ax-a0 : {a : L } → a x ( - a ) ≡ b0 record BooleanAlgebra ( L : Set n) : Set (suc n) where field b1 : L b0 : L -_ : L → L _+_ : L → L → L _x_ : L → L → L isBooleanAlgebra : IsBooleanAlgebra L b1 b0 -_ _+_ _x_
{ "alphanum_fraction": 0.4854182655, "avg_line_length": 42.3739837398, "ext": "agda", "hexsha": "5c1e8b0a845dd0c757c3b8f2ecea54b0103a1860", "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": "031f1ea3a3037cd51eb022dbfb5c75b037bf8aa0", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "shinji-kono/zf-in-agda", "max_forks_repo_path": "src/BAlgbra.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "031f1ea3a3037cd51eb022dbfb5c75b037bf8aa0", "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": "shinji-kono/zf-in-agda", "max_issues_repo_path": "src/BAlgbra.agda", "max_line_length": 129, "max_stars_count": 5, "max_stars_repo_head_hexsha": "031f1ea3a3037cd51eb022dbfb5c75b037bf8aa0", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "shinji-kono/zf-in-agda", "max_stars_repo_path": "src/BAlgbra.agda", "max_stars_repo_stars_event_max_datetime": "2021-01-10T13:27:48.000Z", "max_stars_repo_stars_event_min_datetime": "2019-10-02T13:46:23.000Z", "num_tokens": 2317, "size": 5212 }
{-# OPTIONS --without-K --rewriting #-} open import HoTT open import homotopy.CircleHSpace open import homotopy.LoopSpaceCircle import homotopy.Pi2HSusp as Pi2HSusp open import homotopy.IterSuspensionStable -- This summerizes all [πₙ Sⁿ] module homotopy.PinSn where πS-SphereS-iso-ℤ : ∀ n → πS n (⊙Sphere (S n)) ≃ᴳ ℤ-group πS-SphereS-iso-ℤ 0 = πS 0 ⊙S¹ ≃ᴳ⟨ unTrunc-iso ΩS¹-group-structure ⟩ Ω^S-group 0 ⊙S¹ ≃ᴳ⟨ ΩS¹-iso-ℤ ⟩ ℤ-group ≃ᴳ∎ πS-SphereS-iso-ℤ 1 = πS 1 ⊙S² ≃ᴳ⟨ Pi2HSusp.π₂-Susp ⊙S¹-hSpace ⟩ πS 0 ⊙S¹ ≃ᴳ⟨ πS-SphereS-iso-ℤ O ⟩ ℤ-group ≃ᴳ∎ πS-SphereS-iso-ℤ (S (S n)) = πS (S (S n)) (⊙Sphere (S (S (S n)))) ≃ᴳ⟨ Susp^StableSucc.stable (S n) (S n) (≤-ap-S $ ≤-ap-S $ *2-increasing n) (⊙Sphere (S (S n))) {{Sphere-conn (S (S n))}} ⟩ πS (S n) (⊙Sphere (S (S n))) ≃ᴳ⟨ πS-SphereS-iso-ℤ (S n) ⟩ ℤ-group ≃ᴳ∎
{ "alphanum_fraction": 0.5620280475, "avg_line_length": 25.75, "ext": "agda", "hexsha": "81872d48aaf80327f201f61dea01370540aab656", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "timjb/HoTT-Agda", "max_forks_repo_path": "theorems/homotopy/PinSn.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "timjb/HoTT-Agda", "max_issues_repo_path": "theorems/homotopy/PinSn.agda", "max_line_length": 58, "max_stars_count": null, "max_stars_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "timjb/HoTT-Agda", "max_stars_repo_path": "theorems/homotopy/PinSn.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 473, "size": 927 }