Search is not available for this dataset
text
string
meta
dict
------------------------------------------------------------------------ -- The Agda standard library -- -- A pointwise lifting of a relation to incorporate a new infimum. ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} -- This module is designed to be used with -- Relation.Nullary.Construct.Add.Infimum open import Relation.Binary module Relation.Binary.Construct.Add.Infimum.Equality {a ℓ} {A : Set a} (_≈_ : Rel A ℓ) where open import Relation.Binary.Construct.Add.Point.Equality _≈_ public renaming (_≈∙_ to _≈₋_ ; ∙≈∙ to ⊥₋≈⊥₋ ; ≈∙-refl to ≈₋-refl ; ≈∙-sym to ≈₋-sym ; ≈∙-trans to ≈₋-trans ; ≈∙-dec to ≈₋-dec ; ≈∙-irrelevant to ≈₋-irrelevant ; ≈∙-substitutive to ≈₋-substitutive ; ≈∙-isEquivalence to ≈₋-isEquivalence ; ≈∙-isDecEquivalence to ≈₋-isDecEquivalence )
{ "alphanum_fraction": 0.4916317992, "avg_line_length": 31.8666666667, "ext": "agda", "hexsha": "e4227198f140f1dade45b782dbce23483f05bceb", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "omega12345/agda-mode", "max_forks_repo_path": "test/asset/agda-stdlib-1.0/Relation/Binary/Construct/Add/Infimum/Equality.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "omega12345/agda-mode", "max_issues_repo_path": "test/asset/agda-stdlib-1.0/Relation/Binary/Construct/Add/Infimum/Equality.agda", "max_line_length": 72, "max_stars_count": 5, "max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "omega12345/agda-mode", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Relation/Binary/Construct/Add/Infimum/Equality.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": 306, "size": 956 }
-- Andreas, 2017-07-24, issue #2654 reported by rntz -- When splitting projections in an extended lambda, -- we have to print them postfix, regardless of whether -- the user chose --postfix-projections or not. -- {-# OPTIONS --postfix-projections #-} -- {-# OPTIONS -v interaction.case:60 #-} open import Common.Product dup : ∀{A : Set} (a : A) → A × A dup = λ { x → {!!} } -- C-c C-c RET -- Expected result after result splitting: -- dup = λ { x .proj₁ → {!!} ; x .proj₂ → {!!} }
{ "alphanum_fraction": 0.6229508197, "avg_line_length": 30.5, "ext": "agda", "hexsha": "486a25ce0e88c0bf581a47b94cfb9ec85d943913", "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/Issue2654.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/Issue2654.agda", "max_line_length": 55, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/interaction/Issue2654.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": 145, "size": 488 }
import Relation.Binary.PropositionalEquality as Eq open Eq using (_≡_; refl; sym; trans; cong) open Eq.≡-Reasoning open import Data.Nat using (ℕ; zero; suc) open import Data.Product using (_×_; proj₁; proj₂) renaming (_,_ to ⟨_,_⟩) open import Data.Sum using (_⊎_; inj₁; inj₂) open import Relation.Nullary using (¬_) open import Relation.Nullary.Negation using (contraposition) open import Data.Unit using (⊤; tt) open import Data.Empty using (⊥; ⊥-elim) open import Data.List using (List; []; _∷_; foldr; map) open import Function using (_∘_) double-negation : ∀ {A : Set} → A → ¬ ¬ A double-negation x ¬x = ¬x x triple-negation : ∀ {A : Set} → ¬ ¬ ¬ A → ¬ A triple-negation ¬¬¬x x = ¬¬¬x (double-negation x) Stable : Set → Set Stable A = ¬ ¬ A → A ¬-stable : ∀ {A : Set} → Stable (¬ A) ¬-stable = triple-negation ×-stable : ∀ {A B : Set} → Stable A → Stable B → Stable (A × B) ×-stable ¬¬x→x ¬¬y→y ¬¬xy = ⟨ ¬¬x→x (contraposition (contraposition proj₁) ¬¬xy) , ¬¬y→y (contraposition (contraposition proj₂) ¬¬xy) ⟩ ∀-stable : ∀ {A : Set} {B : A → Set} → (∀ (x : A) → Stable (B x)) → Stable (∀ (x : A) → B x) ∀-stable ∀x→¬¬y→y ¬¬∀x→y x = ∀x→¬¬y→y x (contraposition (contraposition λ{∀x→y → ∀x→y x}) ¬¬∀x→y) -- Gödel-Gentzen translation {-- data Var : ℕ → Set where zero : ∀ (n : ℕ) → Var (suc n) suc : ∀ (n : ℕ) → Var n → Var (suc n) data Formula : ℕ → Set where _`≡_ : ∀ (n : ℕ) → Var n → Var n → Formula n _`×_ : ∀ (n : ℕ) → Formula n → Formula n → Formula n _`⊎_ : ∀ (n : ℕ) → Formula n → Formula n → Formula n `¬_ : ∀ (n : ℕ) → Formula n → Formula n --} data Formula : Set₁ where atomic : ∀ (A : Set) → Formula _`×_ : Formula → Formula → Formula _`⊎_ : Formula → Formula → Formula `¬_ : Formula → Formula interp : Formula → Set interp (atomic A) = A interp (`A `× `B) = interp `A × interp `B interp (`A `⊎ `B) = interp `A ⊎ interp `B interp (`¬ `A) = ¬ interp `A g : Formula → Formula g (atomic A) = `¬ `¬ (atomic A) g (`A `× `B) = g `A `× g `B g (`A `⊎ `B) = `¬ ((`¬ g `A) `× (`¬ g `B)) g (`¬ `A) = `¬ g `A stable-g : ∀ (`A : Formula) → Stable (interp (g `A)) stable-g (atomic A) = ¬-stable stable-g (`A `× `B) = ×-stable (stable-g `A) (stable-g `B) stable-g (`A `⊎ `B) = ¬-stable stable-g (`¬ `A) = ¬-stable
{ "alphanum_fraction": 0.5663129973, "avg_line_length": 30.16, "ext": "agda", "hexsha": "7687676da03c7a9e78ddd7f6fa02f4a0ab8011aa", "lang": "Agda", "max_forks_count": 304, "max_forks_repo_forks_event_max_datetime": "2022-03-28T11:35:02.000Z", "max_forks_repo_forks_event_min_datetime": "2018-07-16T18:24:59.000Z", "max_forks_repo_head_hexsha": "8a2c2ace545092fd0e04bf5831ed458267f18ae4", "max_forks_repo_licenses": [ "CC-BY-4.0" ], "max_forks_repo_name": "manikdv/plfa.github.io", "max_forks_repo_path": "extra/extra/Stable.agda", "max_issues_count": 323, "max_issues_repo_head_hexsha": "8a2c2ace545092fd0e04bf5831ed458267f18ae4", "max_issues_repo_issues_event_max_datetime": "2022-03-30T07:42:57.000Z", "max_issues_repo_issues_event_min_datetime": "2018-07-05T22:34:34.000Z", "max_issues_repo_licenses": [ "CC-BY-4.0" ], "max_issues_repo_name": "manikdv/plfa.github.io", "max_issues_repo_path": "extra/extra/Stable.agda", "max_line_length": 92, "max_stars_count": 1003, "max_stars_repo_head_hexsha": "8a2c2ace545092fd0e04bf5831ed458267f18ae4", "max_stars_repo_licenses": [ "CC-BY-4.0" ], "max_stars_repo_name": "manikdv/plfa.github.io", "max_stars_repo_path": "extra/extra/Stable.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-27T07:03:28.000Z", "max_stars_repo_stars_event_min_datetime": "2018-07-05T18:15:14.000Z", "num_tokens": 907, "size": 2262 }
{-# OPTIONS --without-K --exact-split --safe #-} open import Fragment.Equational.Theory module Fragment.Equational.FreeExtension.Base (Θ : Theory) where open import Fragment.Equational.Model Θ open import Fragment.Equational.Coproduct Θ open import Level using (Level; Setω; _⊔_) open import Data.Nat using (ℕ) private variable a ℓ : Level Extension : Setω Extension = ∀ {a} {ℓ} → Model {a} {ℓ} → ℕ → Model {a} {a ⊔ ℓ} IsFreeExtension : Extension → Setω IsFreeExtension _[_] = ∀ {a ℓ} (A : Model {a} {ℓ}) (n : ℕ) → IsCoproduct A (J n) (A [ n ]) record FreeExtension : Setω where field _[_] : Extension _[_]-isFrex : IsFreeExtension _[_]
{ "alphanum_fraction": 0.6656716418, "avg_line_length": 23.9285714286, "ext": "agda", "hexsha": "ebd18334566935ab313873b1e0285520b3bab804", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2021-06-16T08:04:31.000Z", "max_forks_repo_forks_event_min_datetime": "2021-06-15T15:34:50.000Z", "max_forks_repo_head_hexsha": "f2a6b1cf4bc95214bd075a155012f84c593b9496", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "yallop/agda-fragment", "max_forks_repo_path": "src/Fragment/Equational/FreeExtension/Base.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "f2a6b1cf4bc95214bd075a155012f84c593b9496", "max_issues_repo_issues_event_max_datetime": "2021-06-16T10:24:15.000Z", "max_issues_repo_issues_event_min_datetime": "2021-06-16T09:44:31.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "yallop/agda-fragment", "max_issues_repo_path": "src/Fragment/Equational/FreeExtension/Base.agda", "max_line_length": 69, "max_stars_count": 18, "max_stars_repo_head_hexsha": "f2a6b1cf4bc95214bd075a155012f84c593b9496", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "yallop/agda-fragment", "max_stars_repo_path": "src/Fragment/Equational/FreeExtension/Base.agda", "max_stars_repo_stars_event_max_datetime": "2022-01-17T17:26:09.000Z", "max_stars_repo_stars_event_min_datetime": "2021-06-15T15:45:39.000Z", "num_tokens": 220, "size": 670 }
module Prelude.Function where id : ∀ {a} {A : Set a} → A → A id x = x {-# INLINE id #-} infixl -10 id syntax id {A = A} x = x ofType A const : ∀ {a b} {A : Set a} {B : Set b} → A → B → A const x _ = x {-# INLINE const #-} flip : ∀ {a b c} {A : Set a} {B : Set b} {C : A → B → Set c} → (∀ x y → C x y) → ∀ y x → C x y flip f x y = f y x {-# INLINE flip #-} infixr 9 _∘_ _∘_ : ∀ {a b c} {A : Set a} {B : A → Set b} {C : ∀ x → B x → Set c} (f : ∀ {x} (y : B x) → C x y) (g : ∀ x → B x) → ∀ x → C x (g x) (f ∘ g) x = f (g x) {-# INLINE _∘_ #-} infixr 9 _∘′_ _∘′_ : ∀ {a b c} {A : Set a} {B : Set b} {C : Set c} → (B → C) → (A → B) → (A → C) f ∘′ g = f ∘ g {-# INLINE _∘′_ #-} infixr -20 _$_ _$′_ infixr 0 case_of_ case_return_of_ _$_ : ∀ {a b} {A : Set a} {B : A → Set b} → (∀ x → B x) → ∀ x → B x f $ x = f x _$′_ : ∀ {a b}{A : Set a} {B : Set b} → (A → B) → A → B f $′ x = f x case_of_ : ∀ {a b} {A : Set a} {B : Set b} → A → (A → B) → B case x of f = f x case₂_,_of_ : ∀ {a b c} {A : Set a} {B : Set b} {C : Set c} → A → B → (A → B → C) → C case₂ x , y of f = f x y case₃_,_,_of_ : ∀ {a b c d} {A : Set a} {B : Set b} {C : Set c} {D : Set d} → A → B → C → (A → B → C → D) → D case₃ x , y , z of f = f x y z case₄_,_,_,_of_ : ∀ {a b c d e} {A : Set a} {B : Set b} {C : Set c} {D : Set d} {E : Set e} → A → B → C → D → (A → B → C → D → E) → E case₄ x , y , z , w of f = f x y z w case_return_of_ : ∀ {a b} {A : Set a} (x : A) (B : A → Set b) → (∀ x → B x) → B x case x return B of f = f x infixr 0 letSyntax syntax letSyntax e (λ x → b) = let[ x := e ] b letSyntax : ∀ {a b} {A : Set a} {B : Set b} → A → (A → B) → B letSyntax x f = f x {-# INLINE _$_ #-} {-# INLINE _$′_ #-} {-# INLINE case_of_ #-} {-# INLINE case₂_,_of_ #-} {-# INLINE case_return_of_ #-} infixl 8 _on_ _on_ : ∀ {a b c} {A : Set a} {B : A → Set b} {C : ∀ x y → B x → B y → Set c} → (∀ {x y} (z : B x) (w : B y) → C x y z w) → (f : ∀ x → B x) → ∀ x y → C x y (f x) (f y) h on f = λ x y → h (f x) (f y) {-# INLINE _on_ #-} it : ∀ {a} {A : Set a} {{x : A}} → A it {{x}} = x {-# INLINE it #-} asInstance : ∀ {a b} {A : Set a} {B : A → Set b} (x : A) → (∀ {{x}} → B x) → B x asInstance x f = f {{x}} {-# INLINE asInstance #-} record Instance {a} (A : Set a) : Set a where constructor ! field {{x}} : A mkInstance : ∀ {a} {A : Set a} → A → Instance A mkInstance x = ! {{x}} {-# INLINE mkInstance #-} -- Can be used to force normalisation at compile time. static : ∀ {a} {A : Set a} → A → A static x = x {-# STATIC static #-}
{ "alphanum_fraction": 0.4373540856, "avg_line_length": 27.3404255319, "ext": "agda", "hexsha": "98e50307e82ff7135e0691f47da9efb46b31e7ce", "lang": "Agda", "max_forks_count": 24, "max_forks_repo_forks_event_max_datetime": "2021-04-22T06:10:41.000Z", "max_forks_repo_forks_event_min_datetime": "2015-03-12T18:03:45.000Z", "max_forks_repo_head_hexsha": "158d299b1b365e186f00d8ef5b8c6844235ee267", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "L-TChen/agda-prelude", "max_forks_repo_path": "src/Prelude/Function.agda", "max_issues_count": 59, "max_issues_repo_head_hexsha": "158d299b1b365e186f00d8ef5b8c6844235ee267", "max_issues_repo_issues_event_max_datetime": "2022-01-14T07:32:36.000Z", "max_issues_repo_issues_event_min_datetime": "2016-02-09T05:36:44.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "L-TChen/agda-prelude", "max_issues_repo_path": "src/Prelude/Function.agda", "max_line_length": 109, "max_stars_count": 111, "max_stars_repo_head_hexsha": "158d299b1b365e186f00d8ef5b8c6844235ee267", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "L-TChen/agda-prelude", "max_stars_repo_path": "src/Prelude/Function.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-12T23:29:26.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-05T11:28:15.000Z", "num_tokens": 1162, "size": 2570 }
{- Definition of various kinds of categories. This library follows the UniMath terminology, that is: Concept Ob C Hom C Univalence Precategory Type Type No Category Type Set No Univalent Category Type Set Yes This file also contains - pathToIso : Turns a path between two objects into an isomorphism between them - opposite categories -} {-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.Categories.Category where open import Cubical.Categories.Category.Base public open import Cubical.Categories.Category.Properties public
{ "alphanum_fraction": 0.696, "avg_line_length": 24.0384615385, "ext": "agda", "hexsha": "7dbecb149b94b72b8865795b7235399fbef6d1d9", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "dan-iel-lee/cubical", "max_forks_repo_path": "Cubical/Categories/Category.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "dan-iel-lee/cubical", "max_issues_repo_path": "Cubical/Categories/Category.agda", "max_line_length": 83, "max_stars_count": null, "max_stars_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "dan-iel-lee/cubical", "max_stars_repo_path": "Cubical/Categories/Category.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 137, "size": 625 }
{-# OPTIONS --without-K --safe #-} open import Categories.Category module Categories.Morphism.Lifts.Properties {o ℓ e} (𝒞 : Category o ℓ e) where open import Level open import Data.Product using (_,_; proj₁; proj₂) open import Categories.Category.Construction.Arrow 𝒞 open import Categories.Diagram.Pullback 𝒞 open import Categories.Diagram.Pushout 𝒞 open import Categories.Morphism.Lifts 𝒞 open import Categories.Morphism.Reasoning 𝒞 renaming (glue to glue-■) import Categories.Morphism as Mor open Category 𝒞 open Definitions 𝒞 open HomReasoning -- We want to talk about retracts of morphisms, so -- we don't use the definition of 'Retract' applied to '𝒞' open Mor 𝒞 hiding (Retract) open Mor using (Retract) open Morphism⇒ -------------------------------------------------------------------------------- -- Lifting and Retractions module _ {X Y T} {f : X ⇒ Y} {i : X ⇒ T} {p : T ⇒ Y} (factors : f ≈ p ∘ i) where -- If 'f' factors into 'p ∘ i' and 'f' has the left lifting property -- with respect to 'p', then 'f' is a retraction of 'i' in the arrow -- category of 𝒞. retract-liftˡ : Lifts f p → Retract Arrow (mor f) (mor i) retract-liftˡ lifts = record { section = mor⇒ (fill-commˡ ○ ⟺ identityʳ) ; retract = mor⇒ (⟺ factors ○ ⟺ identityʳ) ; is-retract = identity² , fill-commʳ } where open Filler (lifts (identityˡ ○ factors)) -- We have an analogous situation for right lifts. retract-liftʳ : Lifts i f → Retract Arrow (mor f) (mor p) retract-liftʳ lifts = record { section = mor⇒ (identityˡ ○ factors) ; retract = mor⇒ (identityˡ ○ ⟺ fill-commʳ) ; is-retract = fill-commˡ , identity² } where open Filler (lifts (⟺ factors ○ ⟺ identityʳ)) -------------------------------------------------------------------------------- -- Closure Properties of Injective and Projective morphisms. module _ {j} (J : MorphismClass j) where private variable X Y Z : Obj f g h i p : X ⇒ Y -- If 'f' is an isomorphism, then it must be J-Projective. iso-proj : ∀ {X Y} (f : X ⇒ Y) → IsIso f → Proj J f iso-proj f f-iso g g∈J {h} {i} comm = record { filler = h ∘ inv ; fill-commˡ = cancelʳ isoˡ ; fill-commʳ = extendʳ (⟺ comm) ○ elimʳ isoʳ } where open IsIso f-iso -- Dually, If 'f' is an isomorphism, then it must be J-Injective. iso-inj : ∀ {X Y} (f : X ⇒ Y) → IsIso f → Inj J f iso-inj f f-iso g g∈J {h} {i} comm = record { filler = inv ∘ i ; fill-commˡ = extendˡ comm ○ elimˡ isoˡ ; fill-commʳ = cancelˡ isoʳ } where open IsIso f-iso -- J-Projective morphisms are closed under composition. proj-∘ : ∀ {X Y Z} {f : Y ⇒ Z} {g : X ⇒ Y} → Proj J f → Proj J g → Proj J (f ∘ g) proj-∘ {f = f} {g = g} f-proj g-proj h h∈J {k} {i} comm = record { filler = UpperFiller.filler ; fill-commˡ = begin UpperFiller.filler ∘ f ∘ g ≈⟨ pullˡ UpperFiller.fill-commˡ ⟩ LowerFiller.filler ∘ g ≈⟨ LowerFiller.fill-commˡ ⟩ k ∎ ; fill-commʳ = UpperFiller.fill-commʳ } where module LowerFiller = Filler (g-proj h h∈J (assoc ○ comm)) module UpperFiller = Filler (f-proj h h∈J (⟺ LowerFiller.fill-commʳ)) -- J-Injective morphisms are closed under composition. inj-∘ : ∀ {X Y Z} {f : Y ⇒ Z} {g : X ⇒ Y} → Inj J f → Inj J g → Inj J (f ∘ g) inj-∘ {f = f} {g = g} f-inj g-inj h h∈J {k} {i} comm = record { filler = LowerFiller.filler ; fill-commˡ = LowerFiller.fill-commˡ ; fill-commʳ = begin (f ∘ g) ∘ LowerFiller.filler ≈⟨ pullʳ LowerFiller.fill-commʳ ⟩ f ∘ UpperFiller.filler ≈⟨ UpperFiller.fill-commʳ ⟩ i ∎ } where module UpperFiller = Filler (f-inj h h∈J (comm ○ assoc)) module LowerFiller = Filler (g-inj h h∈J UpperFiller.fill-commˡ) -- J-Projective morphisms are stable under pushout. proj-pushout : ∀ {X Y Z} {p : X ⇒ Y} {f : X ⇒ Z} → (P : Pushout p f) → Proj J p → Proj J (Pushout.i₂ P) proj-pushout {p = p} {f = f} po p-proj h h∈J sq = record { filler = universal fill-commˡ ; fill-commˡ = universal∘i₂≈h₂ ; fill-commʳ = unique-diagram (pullʳ universal∘i₁≈h₁ ○ fill-commʳ) (pullʳ universal∘i₂≈h₂ ○ ⟺ sq) } where open Pushout po open Filler (p-proj h h∈J (glue-■ sq commute)) -- J-Injective morphisms are stable under pullback. inj-pullback : ∀ {X Y Z} {i : X ⇒ Z} {f : Y ⇒ Z} → (P : Pullback i f) → Inj J i → Inj J (Pullback.p₂ P) inj-pullback {i = i} {f = f} pb i-inj h h∈J sq = record { filler = universal fill-commʳ ; fill-commˡ = unique-diagram (pullˡ p₁∘universal≈h₁ ○ fill-commˡ) (pullˡ p₂∘universal≈h₂ ○ sq) ; fill-commʳ = p₂∘universal≈h₂ } where open Pullback pb open Filler (i-inj h h∈J (glue-■ (⟺ commute) sq)) -- J-Projective morphisms are stable under retractions. proj-retract : Proj J p → Retract Arrow (mor f) (mor p) → Proj J f proj-retract {p = p} {f = f} p-proj f-retracts h h∈J {g} {k} sq = record { filler = filler ∘ cod⇒ section ; fill-commˡ = begin (filler ∘ cod⇒ section) ∘ f ≈⟨ extendˡ (square section) ⟩ (filler ∘ p) ∘ dom⇒ section ≈⟨ fill-commˡ ⟩∘⟨refl ⟩ (g ∘ dom⇒ retract) ∘ dom⇒ section ≈⟨ cancelʳ (proj₁ is-retract) ⟩ g ∎ ; fill-commʳ = begin h ∘ filler ∘ cod⇒ section ≈⟨ extendʳ fill-commʳ ⟩ k ∘ (cod⇒ retract ∘ cod⇒ section) ≈⟨ elimʳ (proj₂ is-retract) ⟩ k ∎ } where open Retract f-retracts open Filler (p-proj h h∈J (glue-■ sq (square retract))) -- J-Injective morphisms are stable under retractions. inj-retract : Inj J i → Retract Arrow (mor f) (mor i) → Inj J f inj-retract {i = i} {f = f} i-inj f-retracts h h∈J {g} {k} sq = record { filler = dom⇒ retract ∘ filler ; fill-commˡ = begin (dom⇒ retract ∘ filler) ∘ h ≈⟨ extendˡ fill-commˡ ⟩ (dom⇒ retract ∘ dom⇒ section) ∘ g ≈⟨ elimˡ (proj₁ is-retract) ⟩ g ∎ ; fill-commʳ = begin f ∘ dom⇒ retract ∘ filler ≈⟨ extendʳ (⟺ (square retract)) ⟩ cod⇒ retract ∘ i ∘ filler ≈⟨ refl⟩∘⟨ fill-commʳ ⟩ cod⇒ retract ∘ cod⇒ section ∘ k ≈⟨ cancelˡ (proj₂ is-retract) ⟩ k ∎ } where open Retract f-retracts open Filler (i-inj h h∈J (glue-■ (square section) sq))
{ "alphanum_fraction": 0.5786833856, "avg_line_length": 33.2291666667, "ext": "agda", "hexsha": "4104d1a20e5608266e4c10ffe20d67d93458333c", "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": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Code-distancing/agda-categories", "max_forks_repo_path": "src/Categories/Morphism/Lifts/Properties.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "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": "Code-distancing/agda-categories", "max_issues_repo_path": "src/Categories/Morphism/Lifts/Properties.agda", "max_line_length": 105, "max_stars_count": 5, "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/Morphism/Lifts/Properties.agda", "max_stars_repo_stars_event_max_datetime": "2019-05-22T03:54:24.000Z", "max_stars_repo_stars_event_min_datetime": "2019-05-21T17:07:19.000Z", "num_tokens": 2400, "size": 6380 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Rational numbers ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} module Data.Rational.Base where open import Function using (id) open import Data.Integer.Base as ℤ using (ℤ; ∣_∣; +_; -[1+_]) import Data.Integer.GCD as ℤ import Data.Integer.DivMod as ℤ open import Data.Nat.GCD open import Data.Nat.Divisibility as ℕDiv using (divides; 0∣⇒≡0) open import Data.Nat.Coprimality as C using (Coprime; Bézout-coprime; coprime-/gcd) open import Data.Nat.Base as ℕ using (ℕ; zero; suc) hiding (module ℕ) import Data.Nat.DivMod as ℕ open import Data.Rational.Unnormalised using (ℚᵘ; mkℚᵘ; _≢0) open import Data.Product open import Data.Sum.Base using (inj₂) open import Level using (0ℓ) open import Relation.Nullary using (¬_) open import Relation.Nullary.Decidable using (False; fromWitnessFalse; toWitnessFalse) open import Relation.Nullary.Negation using (contradiction) open import Relation.Binary using (Rel) open import Relation.Binary.PropositionalEquality using (_≡_; _≢_; refl; subst; cong; cong₂; module ≡-Reasoning) open ≡-Reasoning -- Note, these are re-exported publicly to maintain backwards -- compatability. Although we are unable (?) to put a warning on them, -- using these from `Data.Rational` should be viewed as a deprecated -- feature. open import Data.Integer public using (+0; +[1+_]) ------------------------------------------------------------------------ -- Rational numbers in reduced form. Note that there is exactly one -- way to represent every rational number. record ℚ : Set where constructor mkℚ field numerator : ℤ denominator-1 : ℕ .isCoprime : Coprime ∣ numerator ∣ (suc denominator-1) denominatorℕ : ℕ denominatorℕ = suc denominator-1 denominator : ℤ denominator = + denominatorℕ open ℚ public using () renaming ( numerator to ↥_ ; denominator to ↧_ ; denominatorℕ to ↧ₙ_ ) mkℚ+ : ∀ n d → .{d≢0 : d ≢0} → .(Coprime n d) → ℚ mkℚ+ n (suc d) coprime = mkℚ (+ n) d coprime ------------------------------------------------------------------------ -- Equality of rational numbers (coincides with _≡_) infix 4 _≃_ _≃_ : Rel ℚ 0ℓ p ≃ q = (↥ p ℤ.* ↧ q) ≡ (↥ q ℤ.* ↧ p) ------------------------------------------------------------------------ -- Ordering of rationals infix 4 _≤_ _<_ _≥_ _>_ _≰_ _≱_ _≮_ _≯_ data _≤_ : Rel ℚ 0ℓ where *≤* : ∀ {p q} → (↥ p ℤ.* ↧ q) ℤ.≤ (↥ q ℤ.* ↧ p) → p ≤ q data _<_ : Rel ℚ 0ℓ where *<* : ∀ {p q} → (↥ p ℤ.* ↧ q) ℤ.< (↥ q ℤ.* ↧ p) → p < q _≥_ : Rel ℚ 0ℓ x ≥ y = y ≤ x _>_ : Rel ℚ 0ℓ x > y = y < x _≰_ : Rel ℚ 0ℓ x ≰ y = ¬ (x ≤ y) _≱_ : Rel ℚ 0ℓ x ≱ y = ¬ (x ≥ y) _≮_ : Rel ℚ 0ℓ x ≮ y = ¬ (x < y) _≯_ : Rel ℚ 0ℓ x ≯ y = ¬ (x > y) ------------------------------------------------------------------------ -- Negation -_ : ℚ → ℚ - mkℚ -[1+ n ] d prf = mkℚ +[1+ n ] d prf - mkℚ +0 d prf = mkℚ +0 d prf - mkℚ +[1+ n ] d prf = mkℚ -[1+ n ] d prf ------------------------------------------------------------------------ -- Constructing rationals -- A constructor for ℚ that takes two natural numbers, say 6 and 21, -- and returns them in a normalized form, e.g. say 2 and 7 normalize : ∀ (m n : ℕ) {n≢0 : n ≢0} → ℚ normalize m n {n≢0} = mkℚ+ (m ℕ./ gcd m n) (n ℕ./ gcd m n) {n/g≢0} (coprime-/gcd m n {g≢0}) where g≢0 = fromWitnessFalse (gcd[m,n]≢0 m n (inj₂ (toWitnessFalse n≢0))) n/g≢0 = fromWitnessFalse (n/gcd[m,n]≢0 m n {n≢0} {g≢0}) -- A constructor for ℚ that (unlike mkℚ) automatically normalises it's -- arguments. See the constants section below for how to use this operator. infixl 7 _/_ _/_ : (n : ℤ) (d : ℕ) → {d≢0 : d ≢0} → ℚ (+ n / d) {d≢0} = normalize n d {d≢0} (-[1+ n ] / d) {d≢0} = - normalize (suc n) d {d≢0} ------------------------------------------------------------------------------ -- Some constants 0ℚ : ℚ 0ℚ = + 0 / 1 1ℚ : ℚ 1ℚ = + 1 / 1 ½ : ℚ ½ = + 1 / 2 -½ : ℚ -½ = - ½ ------------------------------------------------------------------------------ -- Operations on rationals infix 8 -_ 1/_ infixl 7 _*_ _÷_ infixl 6 _-_ _+_ -- addition _+_ : ℚ → ℚ → ℚ p + q = (↥ p ℤ.* ↧ q ℤ.+ ↥ q ℤ.* ↧ p) / (↧ₙ p ℕ.* ↧ₙ q) -- multiplication _*_ : ℚ → ℚ → ℚ p * q = (↥ p ℤ.* ↥ q) / (↧ₙ p ℕ.* ↧ₙ q) -- subtraction _-_ : ℚ → ℚ → ℚ p - q = p + (- q) -- reciprocal: requires a proof that the numerator is not zero 1/_ : (p : ℚ) → .{n≢0 : ∣ ↥ p ∣ ≢0} → ℚ 1/ mkℚ +[1+ n ] d prf = mkℚ +[1+ d ] n (C.sym prf) 1/ mkℚ -[1+ n ] d prf = mkℚ -[1+ d ] n (C.sym prf) -- division: requires a proof that the denominator is not zero _÷_ : (p q : ℚ) → .{n≢0 : ∣ ↥ q ∣ ≢0} → ℚ (p ÷ q) {n≢0} = p * (1/ q) {n≢0} ------------------------------------------------------------------------ -- Conversion to and from unnormalized rationals toℚᵘ : ℚ → ℚᵘ toℚᵘ (mkℚ n d-1 _) = mkℚᵘ n d-1 fromℚᵘ : ℚᵘ → ℚ fromℚᵘ (mkℚᵘ n d-1) = n / suc d-1
{ "alphanum_fraction": 0.5091494068, "avg_line_length": 26.1736842105, "ext": "agda", "hexsha": "1bcd733d3adefd605ef6c9dccaea9680ca66cc96", "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/Rational/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/Data/Rational/Base.agda", "max_line_length": 86, "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/Rational/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": 1866, "size": 4973 }
------------------------------------------------------------------------------ -- Testing the translation of logical schemata with 11-ary predicates symbols ------------------------------------------------------------------------------ {-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} module P11 where postulate D : Set P-refl : {P : D → D → D → D → D → D → D → D → D → D → D → Set} → ∀ {x₁ x₂ x₃ x₄ x₅ x₆ x₇ x₈ x₉ x₁₀ x₁₁} → P x₁ x₂ x₃ x₄ x₅ x₆ x₇ x₈ x₉ x₁₀ x₁₁ → P x₁ x₂ x₃ x₄ x₅ x₆ x₇ x₈ x₉ x₁₀ x₁₁ {-# ATP prove P-refl #-}
{ "alphanum_fraction": 0.4, "avg_line_length": 36.5789473684, "ext": "agda", "hexsha": "bbea43d24d865f109f8f8149d8745dbd2eb9d726", "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": "test/Succeed/non-fol-theorems/P11.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": "test/Succeed/non-fol-theorems/P11.agda", "max_line_length": 78, "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": "test/Succeed/non-fol-theorems/P11.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": 213, "size": 695 }
------------------------------------------------------------------------ -- Safe modules that use --cubical ------------------------------------------------------------------------ {-# OPTIONS --safe --cubical #-} module README.Safe.Cubical where -- A proof of univalence. import Equality.Path.Univalence -- A proof of univalence for an arbitrary "equality with J". import Equality.Path.Isomorphisms.Univalence -- Very stable booleans. import Bool.Very-stable -- Listed finite subsets. import Finite-subset.Listed -- An alternative definition of listed finite subsets. import Finite-subset.Listed.Alternative -- Kuratowski finite subsets. import Finite-subset.Kuratowski -- An example related to Nat.Wrapper, defined in Cubical Agda. import Nat.Wrapper.Cubical -- Abstract binding trees, based on Harper's "Practical Foundations -- for Programming Languages". import Abstract-binding-tree import README.Abstract-binding-tree -- Overview of code related to a paper. import README.HITs-without-paths
{ "alphanum_fraction": 0.6620825147, "avg_line_length": 22.1304347826, "ext": "agda", "hexsha": "4ef897dde3bc38eea24f8e3237f61994238cb793", "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": "README/Safe/Cubical.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": "README/Safe/Cubical.agda", "max_line_length": 72, "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": "README/Safe/Cubical.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": 200, "size": 1018 }
{-# OPTIONS --without-K --safe --no-sized-types --no-guardedness --no-subtyping #-} module Agda.Builtin.Char.Properties where open import Agda.Builtin.Char open import Agda.Builtin.Equality primitive primCharToNatInjective : ∀ a b → primCharToNat a ≡ primCharToNat b → a ≡ b
{ "alphanum_fraction": 0.7098976109, "avg_line_length": 24.4166666667, "ext": "agda", "hexsha": "dfd2015c6de162ca8e66ea47bc12d8dbdabe4e07", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-04-18T13:34:07.000Z", "max_forks_repo_forks_event_min_datetime": "2021-04-18T13:34:07.000Z", "max_forks_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "shlevy/agda", "max_forks_repo_path": "src/data/lib/prim/Agda/Builtin/Char/Properties.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_issues_event_max_datetime": "2015-09-15T15:49:15.000Z", "max_issues_repo_issues_event_min_datetime": "2015-09-15T15:49:15.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "shlevy/agda", "max_issues_repo_path": "src/data/lib/prim/Agda/Builtin/Char/Properties.agda", "max_line_length": 76, "max_stars_count": 1, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "src/data/lib/prim/Agda/Builtin/Char/Properties.agda", "max_stars_repo_stars_event_max_datetime": "2016-05-20T13:58:52.000Z", "max_stars_repo_stars_event_min_datetime": "2016-05-20T13:58:52.000Z", "num_tokens": 81, "size": 293 }
{-# OPTIONS --cubical --safe #-} module Cubical.HITs.S1.Properties where open import Cubical.Foundations.Prelude open import Cubical.Foundations.GroupoidLaws open import Cubical.Foundations.Equiv open import Cubical.Foundations.HLevels open import Cubical.Foundations.Isomorphism open import Cubical.Foundations.Univalence open import Cubical.HITs.S1.Base open import Cubical.HITs.PropositionalTruncation isConnectedS¹ : (s : S¹) → ∥ base ≡ s ∥ isConnectedS¹ base = ∣ refl ∣ isConnectedS¹ (loop i) = squash ∣ (λ j → loop (i ∧ j)) ∣ ∣ (λ j → loop (i ∨ ~ j)) ∣ i isGroupoidS¹ : isGroupoid S¹ isGroupoidS¹ s t = recPropTrunc isPropIsSet (λ p → subst (λ s → isSet (s ≡ t)) p (recPropTrunc isPropIsSet (λ q → subst (λ t → isSet (base ≡ t)) q isSetΩS¹) (isConnectedS¹ t))) (isConnectedS¹ s)
{ "alphanum_fraction": 0.6973684211, "avg_line_length": 28.8275862069, "ext": "agda", "hexsha": "9316dc20bfbdab346ee2220d944589dd1e68940a", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "df4ef7edffd1c1deb3d4ff342c7178e9901c44f1", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "limemloh/cubical", "max_forks_repo_path": "Cubical/HITs/S1/Properties.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "df4ef7edffd1c1deb3d4ff342c7178e9901c44f1", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "limemloh/cubical", "max_issues_repo_path": "Cubical/HITs/S1/Properties.agda", "max_line_length": 62, "max_stars_count": null, "max_stars_repo_head_hexsha": "df4ef7edffd1c1deb3d4ff342c7178e9901c44f1", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "limemloh/cubical", "max_stars_repo_path": "Cubical/HITs/S1/Properties.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 289, "size": 836 }
-- Andreas, 2016-02-09, issue and test case by Nisse {-# OPTIONS --allow-unsolved-metas #-} open import Common.Level postulate _≡_ : ∀ {a} {A : Set a} → A → A → Set a refl : ∀ {a} {A : Set a} (x : A) → x ≡ x record R a p : Set (lsuc (a ⊔ p)) where field elim : {A : Set a} (P : {x y : A} → x ≡ y → Set p) → (∀ x → P (refl x)) → ∀ {x y} (x≡y : x ≡ y) → P x≡y module _ (eq : ∀ {a p} → R a p) where open module M {a p} = R (eq {a} {p}) postulate elim-refl : ∀ {a p} {A : Set a} (P : {x y : A} → x ≡ y → Set p) (r : ∀ x → P (refl x)) {x} → elim P r (refl x) ≡ r x cong : ∀ {a b} {A : Set a} {B : Set b} (f : A → B) {x y : A} → x ≡ y → f x ≡ f y subst : ∀ {a p} {A : Set a} (P : A → Set p) {x y : A} → x ≡ y → P x → P y subst-refl : ∀ {a p} {A : Set a} (P : A → Set p) {x} (p : P x) → subst P (refl x) p ≡ p trans : ∀ {a} {A : Set a} {x y z : A} → x ≡ y → y ≡ z → x ≡ z cong₂ : ∀ {a b c} {A : Set a} {B : Set b} {C : Set c} (f : A → B → C) {x y : A} {u v : B} → x ≡ y → u ≡ v → f y v ≡ f x u trans-reflʳ : ∀ {a} {A : Set a} {x y : A} (x≡y : x ≡ y) → trans x≡y (refl y) ≡ x≡y trans-reflˡ : ∀ {a} {A : Set a} {x y : A} (x≡y : x ≡ y) → trans (refl x) x≡y ≡ x≡y [subst≡]≡[trans≡trans] : ∀ {a} {A : Set a} {x y : A} {p : x ≡ y} {q : x ≡ x} {r : y ≡ y} → (subst (λ z → z ≡ z) p q ≡ r) ≡ (trans q p ≡ trans p r) [subst≡]≡[trans≡trans] {p = p} {q} {r} = elim (λ {x y} p → {q : x ≡ x} {r : y ≡ y} → (subst (λ z → z ≡ z) p q ≡ r) ≡ (trans q p ≡ trans p r)) (λ x {q r} → trans (cong (λ x → x ≡ _) (subst-refl (λ z → z ≡ z) _)) (cong₂ _≡_ (trans-reflʳ _) (trans-reflˡ _))) p foo : ∀ {a} {A : Set a} {x : A} {q : x ≡ x} {r : x ≡ x} → [subst≡]≡[trans≡trans] {p = refl x} {q = q} {r = r} ≡ [subst≡]≡[trans≡trans] {p = refl x} {q = q} {r = r} foo = elim-refl ? ?
{ "alphanum_fraction": 0.358950328, "avg_line_length": 34.9836065574, "ext": "agda", "hexsha": "f1a7fed56ceb257bb1e685165422c938850dd9c9", "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/Issue1826.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/Issue1826.agda", "max_line_length": 71, "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/Issue1826.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": 988, "size": 2134 }
{-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.HITs.S3.Base where open import Cubical.Foundations.Prelude data S³ : Type₀ where base : S³ surf : PathP (λ j → PathP (λ i → base ≡ base) refl refl) refl refl
{ "alphanum_fraction": 0.6869565217, "avg_line_length": 25.5555555556, "ext": "agda", "hexsha": "b2269c91ba93ec00d25a3c2f89b2b3c1e7935336", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "dan-iel-lee/cubical", "max_forks_repo_path": "Cubical/HITs/S3/Base.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_issues_repo_issues_event_max_datetime": "2022-01-27T02:07:48.000Z", "max_issues_repo_issues_event_min_datetime": "2022-01-27T02:07:48.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "dan-iel-lee/cubical", "max_issues_repo_path": "Cubical/HITs/S3/Base.agda", "max_line_length": 68, "max_stars_count": null, "max_stars_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "dan-iel-lee/cubical", "max_stars_repo_path": "Cubical/HITs/S3/Base.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 75, "size": 230 }
{-# OPTIONS --without-K #-} module hott.truncation.elim where open import sum open import equality open import function open import hott.equivalence open import hott.level open import hott.loop open import hott.truncation.core open import hott.truncation.equality open import hott.univalence open import sets.nat open import sets.unit is-null : ∀ {i j}{X : Set i}{Y : Set j} → Y → (X → Y) → Set _ is-null y f = ∀ x → y ≡ f x is-null-level : ∀ {i j}{X : Set i}{Y : Set j} → h 2 Y → (y : Y)(f : X → Y) → h 1 (is-null y f) is-null-level hY y f = Π-level λ x → hY y (f x) compose-is-null : ∀ {i j k}{X : Set i}{Y : Set j}{Z : Set k} → (y : Y)(f : X → Y)(g : Y → Z) → is-null y f → is-null (g y) (g ∘ f) compose-is-null y f g c y' = ap g (c y') Null : ∀ {i j} → ℕ → Set i → Set j → Set _ Null n X Y = Σ (X → Y) λ f → (x : X) → is-null (refl' n (f x)) (mapΩ n f) -- connected components Conn : ∀ {i}{X : Set i}(n : ℕ) → Trunc n X → Set _ Conn {X = X} n c = Σ X λ x → [ x ] ≡ c map-conn : ∀ {i j}{X : Set i}{Y : Set j}(n : ℕ) → (c : Trunc n X) → (X → Y) → (Conn n c → Y) map-conn n c f (x , p) = f x conn-decomp : ∀ {i}{X : Set i}(n : ℕ) → Σ (Trunc n X) (Conn n) ≅ X conn-decomp {X = X} n = total-iso [_] conn-connected : ∀ {i}{X : Set i}(n : ℕ)(c : Trunc n X) → contr (Trunc n (Conn n c)) conn-connected {X = X} n c = φ c , lem c where φ' : (x : X) → Trunc n (Conn n [ x ]) φ' x = [ x , refl ] φ : (c : Trunc n X) → Trunc n (Conn n c) φ = Trunc-dep-elim n (λ c → Trunc n (Conn n c)) (λ _ → Trunc-level n) φ' lem' : (c : Trunc n X)(a : Conn n c) → φ c ≡ [ a ] lem' .([ x ]) (x , refl) = Trunc-dep-elim-β n (λ c → Trunc n (Conn n c)) (λ _ → Trunc-level n) φ' x lem : (c : Trunc n X)(a : Trunc n (Conn n c)) → φ c ≡ a lem c = Trunc-dep-elim n (λ a → φ c ≡ a) (λ a → h↑ (Trunc-level n) (φ c) a) (lem' c) -- main result module CM {i j} n (X : Set i)(Y : Set j) (hY : h (n + 2) Y) where cm' : Y → Null n X Y cm' y = (λ _ → y) , (λ x p → sym (mapΩ-const n y x p)) cm : (Trunc (suc n) X → Y) → Null n X Y cm f = (λ x → f [ x ]) , λ x → subst₂ (is-null) (mapΩ-refl n f) (eq x) (compose-is-null (refl' n [ x ]) (mapΩ n [_]) (mapΩ n f) (λ p → h1⇒prop (Ω-level n hT) _ _)) where f' : X → Y f' x = f [ x ] eq' : (x : X)(p : Ω n x) → mapΩ n f (mapΩ n [_] p) ≡ mapΩ n f' p eq' x p = mapΩ-hom n [_] f p eq : (x : X) → mapΩ n f ∘ mapΩ n [_] ≡ mapΩ n f' eq x = funext (eq' x) hT : h (n + 1) (Trunc (suc n) X) hT = subst (λ m → h m (Trunc (suc n) X)) (+-commutativity 1 n) (Trunc-level (suc n)) Trunc-elim' : ∀ {i j} n (X : Set i)(Y : Set j) → h (n + 2) Y → (Trunc (suc n) X → Y) ≅ Null n X Y null-connected : ∀ {i j} n {X : Set i}{Y : Set j} → contr (Trunc (suc n) X) → h (n + 2) Y → (f : X → Y) → ((x : X) → is-null (refl' n (f x)) (mapΩ n f {x})) → (x : X) → is-null (f x) f null-connected zero hX hY f c x₀ x₁ = c x₀ x₁ null-connected (suc n) {X} hX hY f c x₀ x₁ = φ (trunc-equality (suc n) (h1⇒prop (h↑ hX) _ _)) where ap-null : (x y : X)(p : x ≡ y) → is-null (refl' n (ap f p)) (mapΩ n (ap f) {p}) ap-null x .x refl = c x φ : Trunc (suc n) (x₀ ≡ x₁) → f x₀ ≡ f x₁ φ = invert (Trunc-elim' n (x₀ ≡ x₁) (f x₀ ≡ f x₁) (hY _ _)) ( ap f , ap-null x₀ x₁ ) Trunc-elim-connected : ∀ {i j} n (X : Set i)(Y : Set j) → contr (Trunc (suc n) X) → h (n + 2) Y → Y ≅ Null n X Y Trunc-elim-connected n X Y hX hY = ≈⇒≅ (cm' , cm-equiv' (proj₁ hX)) where open CM n X Y hY module _ (x₀ : X) where g : Null n X Y → Y g (f , c) = f x₀ α : (y : Y) → g (cm' y) ≡ y α y = refl β : (x : Null n X Y) → cm' (g x) ≡ x β (f , c) = unapΣ ( (funext λ x → null-connected n hX hY f c _ _) , h1⇒prop (Π-level λ x → is-null-level (Ω-level n hY) _ _) _ _) f-iso : Y ≅ Null n X Y f-iso = iso cm' g α β cm-equiv : X → weak-equiv cm' cm-equiv x₀ = proj₂ (≅⇒≈ (f-iso x₀)) cm-equiv' : Trunc (suc n) X → weak-equiv cm' cm-equiv' = invert (Trunc-elim-iso (suc n) X (weak-equiv cm') (h! (weak-equiv-h1 cm'))) cm-equiv abstract Trunc-elim'₀ : ∀ {i j} n (X : Set i)(Y : Set j) → h (n + 2) Y → (Trunc (suc n) X → Y) ≅ Null n X Y Trunc-elim'₀ n X Y hY = begin (Trunc (suc n) X → Y) ≅⟨ ( Π-ap-iso refl≅ λ c → Trunc-elim-connected n _ _ (conn-connected (suc n) c) hY) ⟩ ((c : Trunc (suc n) X) → Null n (Conn (suc n) c) Y) ≅⟨ ΠΣ-swap-iso ⟩ ( Σ ((c : Trunc (suc n) X) → Conn (suc n) c → Y) λ f → ((c : Trunc (suc n) X) → (x : Conn (suc n) c) → is-null _ (mapΩ n (f c))) ) ≅⟨ sym≅ ( Σ-ap-iso (curry-iso (λ _ _ → Y)) λ f → curry-iso λ c x → is-null _ (mapΩ n (λ x' → f (c , x'))) ) ⟩ ( Σ ((Σ (Trunc (suc n) X) λ c → Conn (suc n) c) → Y) λ f → (((x' : (Σ (Trunc (suc n) X) λ c → Conn (suc n) c)) → is-null _ (mapΩ n (λ x → f (proj₁ x' , x))))) ) ≅⟨ ( Σ-ap-iso' (→-ap-iso (conn-decomp (suc n)) refl≅) λ f → Π-ap-iso (conn-decomp (suc n)) λ x → refl≅ ) ⟩ ( Σ (X → Y) λ f → (((x : X) → is-null _ (mapΩ n (λ x → f (proj₁ x)) {x , refl}))) ) ≅⟨ ( Σ-ap-iso refl≅ λ f → Π-ap-iso refl≅ λ x → lem f x ) ⟩ Null n X Y ∎ where open ≅-Reasoning lem : (f : X → Y) (x : X) → is-null (refl' n (f x)) (mapΩ n (map-conn (suc n) [ x ] f) {x , refl}) ≅ is-null (refl' n (f x)) (mapΩ n f {x}) lem f x = ≡⇒≅ (ap (is-null (refl' n (f x))) (funext hom)) ·≅ sym≅ is-const-equiv where π : Conn (suc n) [ x ] → X π = proj₁ hom : (p : Ω n (x , refl)) → mapΩ n (map-conn (suc n) [ x ] f) p ≡ mapΩ n f (mapΩ n proj₁ p) hom p = sym (mapΩ-hom n proj₁ f p) φ : Ω n {Conn (suc n) [ x ]} (x , refl) ≅ Ω n x φ = loop-sum n λ a → Trunc-level (suc n) _ _ is-const-equiv : is-null {X = Ω n x} (refl' n (f x)) (mapΩ n f {x}) ≅ is-null {X = Ω n {Conn (suc n) [ x ]} (x , refl)} (refl' n (f x)) (mapΩ n f ∘ mapΩ n proj₁) is-const-equiv = Π-ap-iso (sym≅ φ) λ p → refl≅ Trunc-elim'-β₀ : ∀ {i j n}{X : Set i}{Y : Set j} (hY : h (n + 2) Y) → (f : Trunc (suc n) X → Y) → proj₁ (apply (Trunc-elim'₀ n X Y hY) f) ≡ (λ x → f [ x ]) Trunc-elim'-β₀ hY f = refl Trunc-elim'-β : ∀ {i j n}{X : Set i}{Y : Set j} (hY : h (n + 2) Y) → (f : Trunc (suc n) X → Y) → apply (Trunc-elim'₀ n X Y hY) f ≡ CM.cm n X Y hY f Trunc-elim'-β {n = n} hY f = unapΣ ( Trunc-elim'-β₀ hY f , h1⇒prop (Π-level λ x → is-null-level (Ω-level n hY) _ _) _ _ ) Trunc-elim' n X Y hY = ≈⇒≅ (cm , cm-we) where open CM n X Y hY cm-eq : apply (Trunc-elim'₀ n X Y hY) ≡ cm cm-eq = funext (Trunc-elim'-β hY) cm-we : weak-equiv cm cm-we = subst weak-equiv cm-eq (proj₂ (≅⇒≈ (Trunc-elim'₀ n X Y hY))) -- example Repr : ∀ {i} → Set i → Set _ Repr {i} A = Σ (Trunc 2 A → Set i) λ hom → (a : A) → hom [ a ] ≅ (a ≡ a) Braiding : ∀ {i} → Set i → Set _ Braiding A = {a : A}(p q : a ≡ a) → p · q ≡ q · p braiding-repr : ∀ {i}{A : Set i} → h 3 A → Braiding A → Repr A braiding-repr {i}{A} hA γ = (λ c → proj₁ (hom c)) , λ a → ≡⇒≅ (ap proj₁ (hom-β a)) where eq : A → Set _ eq a = (a ≡ a) hom' : A → Type _ 2 hom' a = eq a , hA a a type-eq-iso : ∀ {n}{X Y : Type i n} → (X ≡ Y) ≅ (proj₁ X ≈ proj₁ Y) type-eq-iso {n}{X}{Y} = begin (X ≡ Y) ≅⟨ sym≅ Σ-split-iso ⟩ (Σ (proj₁ X ≡ proj₁ Y) λ p → subst (h n) p (proj₂ X) ≡ proj₂ Y) ≅⟨ (Σ-ap-iso refl≅ λ p → contr-⊤-iso (hn-h1 n _ _ _)) ⟩ ((proj₁ X ≡ proj₁ Y) × ⊤) ≅⟨ ×-right-unit ⟩ (proj₁ X ≡ proj₁ Y) ≅⟨ uni-iso ⟩ (proj₁ X ≈ proj₁ Y) ∎ where open ≅-Reasoning type-eq : ∀ {n}{X : Type i n}{p : X ≡ X} → ((x : proj₁ X) → coerce (ap proj₁ p) x ≡ x) → p ≡ refl type-eq f = invert≅ (iso≡ type-eq-iso) (unapΣ ( funext f , h1⇒prop (weak-equiv-h1 _) _ _)) ap-eq : {a b : A}(p : a ≡ b)(q : a ≡ a) → coerce (ap proj₁ (ap hom' p)) q ≡ sym p · q · p ap-eq refl q = sym (left-unit q) hom-null : (a : A) → is-null refl (mapΩ 1 hom' {a}) hom-null a p = sym (type-eq λ q → ap-eq p q · ap (λ z → z · p) (γ (sym p) q) · associativity q (sym p) p · ap (λ z → q · z) (right-inverse p) · left-unit q) hom-iso : (Trunc 2 A → Type i 2) ≅ Null 1 A (Type i 2) hom-iso = Trunc-elim' 1 A (Type i 2) type-level hom : Trunc 2 A → Type _ 2 hom = invert hom-iso (hom' , hom-null) hom-β : (a : A) → hom [ a ] ≡ hom' a hom-β a = funext-inv (ap proj₁ (_≅_.iso₂ hom-iso (hom' , hom-null))) a
{ "alphanum_fraction": 0.4403345127, "avg_line_length": 34.9325842697, "ext": "agda", "hexsha": "8ff4db8d25a3d637aee4075f59aefd0c157f8f78", "lang": "Agda", "max_forks_count": 4, "max_forks_repo_forks_event_max_datetime": "2019-05-04T19:31:00.000Z", "max_forks_repo_forks_event_min_datetime": "2015-02-02T12:17:00.000Z", "max_forks_repo_head_hexsha": "bbbc3bfb2f80ad08c8e608cccfa14b83ea3d258c", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "pcapriotti/agda-base", "max_forks_repo_path": "src/hott/truncation/elim.agda", "max_issues_count": 4, "max_issues_repo_head_hexsha": "bbbc3bfb2f80ad08c8e608cccfa14b83ea3d258c", "max_issues_repo_issues_event_max_datetime": "2016-10-26T11:57:26.000Z", "max_issues_repo_issues_event_min_datetime": "2015-02-02T14:32:16.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "pcapriotti/agda-base", "max_issues_repo_path": "src/hott/truncation/elim.agda", "max_line_length": 100, "max_stars_count": 20, "max_stars_repo_head_hexsha": "bbbc3bfb2f80ad08c8e608cccfa14b83ea3d258c", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "pcapriotti/agda-base", "max_stars_repo_path": "src/hott/truncation/elim.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-01T11:25:54.000Z", "max_stars_repo_stars_event_min_datetime": "2015-06-12T12:20:17.000Z", "num_tokens": 3959, "size": 9327 }
module Records where data Sigma (A : Set) (B : A -> Set) : Set where _,_ : (x : A) (y : B x) -> Sigma A B fst : {A : Set}{B : A -> Set} -> Sigma A B -> A fst (x , y) = x snd : {A : Set}{B : A -> Set} -> (p : Sigma A B) -> B (fst p) snd (x , y) = y data Sigma1 (A : Set1) (B : A -> Set1) : Set1 where _,_ : (x : A) (y : B x) -> Sigma1 A B fst1 : {A : Set1}{B : A -> Set1} -> Sigma1 A B -> A fst1 (x , y) = x snd1 : {A : Set1}{B : A -> Set1} -> (p : Sigma1 A B) -> B (fst1 p) snd1 (x , y) = y data Zero : Set where data Unit : Set where Void : Unit data Test1 : Set where data Test2 : Set where data Test3 : Set where data Nat : Set where ze : Nat su : Nat -> Nat data Fin : Nat -> Set where fze : {n : Nat} -> Fin (su n) fsu : {n : Nat} -> Fin n -> Fin (su n) mutual data Sig : Set1 where Epsilon : Sig _<_ : (S : Sig)(A : [| S |] -> Set) -> Sig [|_|] : Sig -> Set [| Epsilon |] = Unit [| S < A |] = Sigma [| S |] A size : Sig -> Nat size Epsilon = ze size (S < A) = su (size S) typeAt : (S : Sig) -> Fin (size S) -> Sigma1 Sig (\ S -> [| S |] -> Set) typeAt Epsilon () typeAt (S < A) fze = ( S , A ) typeAt (S < A) (fsu y) = typeAt S y fsts : (S : Sig)(i : Fin (size S)) -> [| S |] -> [| fst1 (typeAt S i) |] fsts Epsilon () rec fsts (S < A) fze rec = fst rec fsts (S < A) (fsu y) rec = fsts S y (fst rec) at : (S : Sig)(i : Fin (size S))(rec : [| S |]) -> snd1 (typeAt S i) (fsts S i rec) at Epsilon () rec at (S < A) fze rec = snd rec at (S < A) (fsu y) rec = at S y (fst rec) -- * Record definition combinators: -- ** Non dependant case works: fi : {a : Set1} -> (S : Sig) -> Set -> (Sig -> a) -> a fi S A k = k (S < (\_ -> A)) begin : {a : Set1} -> (Sig -> a) -> a begin k = k Epsilon end : (Sig -> Sig) end x = x test : Sig test = begin fi Test1 fi Test2 fi Test3 end -- ** Dependant case doesn't: fiD : {a : Sig -> Set1} -> (S : Sig) -> (A : ([| S |] -> Set)) -> ((S : Sig) -> a S) -> a (S < A) fiD S A k = k (S < A) beginD : {a : Sig -> Set1} -> ((S : Sig) -> a S) -> a Epsilon beginD k = k Epsilon endD : (Sig -> Sig) endD x = x test2 : Sig test2 = beginD fiD ((\ _ -> Test1)) fiD {!!} fiD {!!} endD
{ "alphanum_fraction": 0.4926402944, "avg_line_length": 22.412371134, "ext": "agda", "hexsha": "b8d6ede3968d74cd5b161a8c5751e5f84134c631", "lang": "Agda", "max_forks_count": 12, "max_forks_repo_forks_event_max_datetime": "2022-02-11T01:57:40.000Z", "max_forks_repo_forks_event_min_datetime": "2016-08-14T21:36:35.000Z", "max_forks_repo_head_hexsha": "8c46f766bddcec2218ddcaa79996e087699a75f2", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "mietek/epigram", "max_forks_repo_path": "models/Records.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "8c46f766bddcec2218ddcaa79996e087699a75f2", "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": "mietek/epigram", "max_issues_repo_path": "models/Records.agda", "max_line_length": 97, "max_stars_count": 48, "max_stars_repo_head_hexsha": "8c46f766bddcec2218ddcaa79996e087699a75f2", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "mietek/epigram", "max_stars_repo_path": "models/Records.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-11T01:55:28.000Z", "max_stars_repo_stars_event_min_datetime": "2016-01-09T17:36:19.000Z", "num_tokens": 888, "size": 2174 }
{-# OPTIONS --without-K #-} open import HoTT open import cohomology.Exactness open import cohomology.Choice open import cohomology.FunctionOver module cohomology.Theory where -- [i] for the universe level of the group record CohomologyTheory i : Type (lsucc i) where field C : ℤ → Ptd i → Group i CEl : ℤ → Ptd i → Type i CEl n X = Group.El (C n X) Cid : (n : ℤ) (X : Ptd i) → CEl n X Cid n X = GroupStructure.ident (Group.group-struct (C n X)) ⊙CEl : ℤ → Ptd i → Ptd i ⊙CEl n X = ⊙[ CEl n X , Cid n X ] field CF-hom : (n : ℤ) {X Y : Ptd i} → fst (X ⊙→ Y) → (C n Y →ᴳ C n X) CF-ident : (n : ℤ) {X : Ptd i} → CF-hom n {X} {X} (⊙idf X) == idhom (C n X) CF-comp : (n : ℤ) {X Y Z : Ptd i} (g : fst (Y ⊙→ Z)) (f : fst (X ⊙→ Y)) → CF-hom n (g ⊙∘ f) == CF-hom n f ∘ᴳ CF-hom n g CF : (n : ℤ) {X Y : Ptd i} → fst (X ⊙→ Y) → CEl n Y → CEl n X CF n f = GroupHom.f (CF-hom n f) field C-abelian : (n : ℤ) (X : Ptd i) → is-abelian (C n X) C-Susp : (n : ℤ) (X : Ptd i) → C (succ n) (⊙Susp X) ≃ᴳ C n X C-SuspF : (n : ℤ) {X Y : Ptd i} (f : fst (X ⊙→ Y)) → fst (C-Susp n X) ∘ᴳ CF-hom (succ n) (⊙susp-fmap f) == CF-hom n f ∘ᴳ fst (C-Susp n Y) C-exact : (n : ℤ) {X Y : Ptd i} (f : fst (X ⊙→ Y)) → is-exact (CF-hom n (⊙cfcod' f)) (CF-hom n f) C-additive : (n : ℤ) {I : Type i} (Z : I → Ptd i) → ((W : I → Type i) → has-choice 0 I W) → is-equiv (GroupHom.f (Πᴳ-hom-in (CF-hom n ∘ ⊙bwin {X = Z}))) {- Alternate form of suspension axiom naturality -} C-Susp-↓ : (n : ℤ) {X Y : Ptd i} (f : fst (X ⊙→ Y)) → CF-hom (succ n) (⊙susp-fmap f) == CF-hom n f [ uncurry _→ᴳ_ ↓ pair×= (group-ua (C-Susp n Y)) (group-ua (C-Susp n X)) ] C-Susp-↓ n f = hom-over-isos $ function-over-equivs _ _ $ ap GroupHom.f (C-SuspF n f) record OrdinaryTheory i : Type (lsucc i) where constructor ordinary-theory field cohomology-theory : CohomologyTheory i open CohomologyTheory cohomology-theory public field C-dimension : (n : ℤ) → n ≠ 0 → C n (⊙Lift ⊙S⁰) == 0ᴳ
{ "alphanum_fraction": 0.534107402, "avg_line_length": 31.8, "ext": "agda", "hexsha": "621ba6140d854531e2cec31d88ceceaf540876ba", "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/cohomology/Theory.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/cohomology/Theory.agda", "max_line_length": 79, "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/cohomology/Theory.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 927, "size": 2067 }
{- Byzantine Fault Tolerant Consensus Verification in Agda, version 0.9. Copyright (c) 2020, 2021, Oracle and/or its affiliates. Licensed under the Universal Permissive License v 1.0 as shown at https://opensource.oracle.com/licenses/upl -} open import LibraBFT.Prelude open import LibraBFT.Lemmas open import LibraBFT.Base.Types open import LibraBFT.Abstract.Types.EpochConfig open WithAbsVote -- This module defines abstract records (the initial or "genesis" record, blocks, and quorum -- certificates), along with related definitions and properties. module LibraBFT.Abstract.Records (UID : Set) (_≟UID_ : (u₀ u₁ : UID) → Dec (u₀ ≡ u₁)) -- Needed to prove ≟Block and ≈?QC (NodeId : Set) (𝓔 : EpochConfig UID NodeId) (𝓥 : VoteEvidence UID NodeId 𝓔) where open import LibraBFT.Abstract.Types UID NodeId open EpochConfig 𝓔 -- Abstract blocks do /not/ need to carry the state hash. Since the -- state hash of a concrete block is supposed to be hashed in the -- UID of an abstract one; the connection between states is implicit. -- Our proofs all work modulo injectivity of UID anyway. record Block : Set where constructor Block∙new field bRound : Round bId : UID bPrevQC : Maybe UID -- 'nothing' indicates it extends the genesis block. open Block public Block-η : {b b' : Block} → bRound b ≡ bRound b' → bId b ≡ bId b' → bPrevQC b ≡ bPrevQC b' → b ≡ b' Block-η refl refl refl = refl -- We define a Vote as an AbsVoteData applied -- to the correct parameters; This helps in defining -- and manipulating the 𝓥 vote evidence predicate. Vote : Set Vote = AbsVoteData UID NodeId 𝓔 vRound : Vote → Round vRound = abs-vRound vMember : Vote → EpochConfig.Member 𝓔 vMember = abs-vMember vBlockUID : Vote → UID vBlockUID = abs-vBlockUID Vote-η : {v v' : Vote} → vRound v ≡ vRound v' → vMember v ≡ vMember v' → vBlockUID v ≡ vBlockUID v' → v ≡ v' Vote-η refl refl refl = refl -- * Quorum Certificates -- -- A valid quorum certificate contains at least 'QuorumSize ec' -- votes from different authors. record QC : Set where constructor QC∙new field qRound : Round qCertBlockId : UID -- this is the id for the block it certifies. qVotes : List Vote -- The voters form a quorum qVotes-C1 : IsQuorum (List-map vMember qVotes) -- All votes are for the same blockId qVotes-C2 : All (λ v → vBlockUID v ≡ qCertBlockId) qVotes -- Likewise for rounds qVotes-C3 : All (λ v → vRound v ≡ qRound) qVotes -- And we have evidence for all votes qVotes-C4 : All 𝓥 qVotes open QC public ------------------------ -- QC's make a setoid -- ------------------------ -- Two QC's are said to be equivalent if they have the same ID; -- that is, they certify the same block. As we are talking about -- /abstract/ QCs, we have proofs that both have at least QuorumSize -- votes for /the same block/! -- -- It might be tempting to want qRound q₀ ≡ qRound q₁ in here, -- but the proof of ←-≈Rec in LibraBFT.Abstract.Records.Extends -- would be impossible. _≈QC_ : QC → QC → Set q₀ ≈QC q₁ = qCertBlockId q₀ ≡ qCertBlockId q₁ _≈QC?_ : (q₀ q₁ : QC) → Dec (q₀ ≈QC q₁) q₀ ≈QC? q₁ with qCertBlockId q₀ ≟UID qCertBlockId q₁ ...| yes refl = yes refl ...| no neq = no λ x → neq x ≈QC-refl : Reflexive _≈QC_ ≈QC-refl = refl ≈QC-sym : Symmetric _≈QC_ ≈QC-sym refl = refl ≈QC-trans : Transitive _≈QC_ ≈QC-trans refl x = x QC-setoid : Setoid ℓ0 ℓ0 QC-setoid = record { Carrier = QC ; _≈_ = _≈QC_ ; isEquivalence = record { refl = λ {q} → ≈QC-refl {q} ; sym = λ {q} {u} → ≈QC-sym {q} {u} ; trans = λ {q} {u} {l} → ≈QC-trans {q} {u} {l} } } -- Accessing common fields in different Records types is a nuissance; yet, Blocks, -- votes and QC's all have three important common fields: author, round and maybe the -- ID of a previous record. Therefore we declare a type-class that provide "getters" -- for commonly used fields. record HasRound (A : Set) : Set where constructor is-librabft-record field getRound : A → Round open HasRound {{...}} public instance block-is-record : HasRound Block block-is-record = is-librabft-record bRound vote-is-record : HasRound Vote vote-is-record = is-librabft-record vRound qc-is-record : HasRound QC qc-is-record = is-librabft-record qRound _≟Block_ : (b₀ b₁ : Block) → Dec (b₀ ≡ b₁) b₀ ≟Block b₁ with bRound b₀ ≟ bRound b₁ ...| no neq = no λ x → neq (cong bRound x) ...| yes r≡ with (bId b₀) ≟UID (bId b₁) ...| no neq = no λ x → neq (cong bId x) ...| yes i≡ with Maybe-≡-dec {A = UID} _≟UID_ (bPrevQC b₀) (bPrevQC b₁) ...| no neq = no λ x → neq (cong bPrevQC x) ...| yes p≡ = yes (Block-η r≡ i≡ p≡) qcVotes : QC → List Vote qcVotes = qVotes -- Now we can state whether an author has voted in a given QC. _∈QC_ : Member → QC → Set a ∈QC qc = Any (λ v → vMember v ≡ a) (qcVotes qc) ∈QC-Member : ∀{α}(q : QC)(v : α ∈QC q) → α ≡ vMember (List-lookup (qcVotes q) (Any-index v)) ∈QC-Member {α} q v = aux v where aux : ∀{vs}(p : Any (λ v → vMember v ≡ α) vs) → α ≡ vMember (List-lookup vs (Any-index p)) aux (here px) = sym px aux (there p) = aux p -- Gets the vote of a ∈QC -- TODO-1: make q explicit; a implicit ∈QC-Vote : {a : Member} (q : QC) → (a ∈QC q) → Vote ∈QC-Vote q a∈q = Any-lookup a∈q ∈QC-Vote-correct : ∀ q → {a : Member} → (p : a ∈QC q) → (∈QC-Vote {a} q p) ∈ qcVotes q ∈QC-Vote-correct q a∈q = Any-lookup-correct a∈q -- Same vote in two QC's means the QCs are equivalent ∈QC-Vote-≈ : {v : Vote}{q q' : QC} → v ∈ qcVotes q → v ∈ qcVotes q' → q ≈QC q' ∈QC-Vote-≈ {v} {q} {q'} vq vq' = trans (sym (All-lookup (qVotes-C2 q) vq)) (All-lookup (qVotes-C2 q') vq') -- A record is either one of the types introduced above or the initial/genesis record. data Record : Set where I : Record B : Block → Record Q : QC → Record -- Records are equivalent if and only if they are either not -- QCs and propositionally equal or they are equivalent qcs. data _≈Rec_ : Record → Record → Set where eq-I : I ≈Rec I eq-Q : ∀{q₀ q₁} → q₀ ≈QC q₁ → Q q₀ ≈Rec Q q₁ eq-B : ∀{b₀ b₁} → b₀ ≡ b₁ → B b₀ ≈Rec B b₁ ≈Rec-refl : Reflexive _≈Rec_ ≈Rec-refl {I} = eq-I ≈Rec-refl {B x} = eq-B refl ≈Rec-refl {Q x} = eq-Q (≈QC-refl {x}) ≈Rec-sym : Symmetric _≈Rec_ ≈Rec-sym {I} eq-I = eq-I ≈Rec-sym {B x} (eq-B prf) = eq-B (sym prf) ≈Rec-sym {Q x} {Q y} (eq-Q prf) = eq-Q (≈QC-sym {x} {y} prf) ≈Rec-trans : Transitive _≈Rec_ ≈Rec-trans {I} eq-I eq-I = eq-I ≈Rec-trans {B x} (eq-B p₀) (eq-B p₁) = eq-B (trans p₀ p₁) ≈Rec-trans {Q x} {Q y} {Q z} (eq-Q p₀) (eq-Q p₁) = eq-Q (≈QC-trans {x} {y} {z} p₀ p₁) Rec-setoid : Setoid ℓ0 ℓ0 Rec-setoid = record { Carrier = Record ; _≈_ = _≈Rec_ ; isEquivalence = record { refl = λ {q} → ≈Rec-refl {q} ; sym = λ {q} {u} → ≈Rec-sym {q} {u} ; trans = λ {q} {u} {l} → ≈Rec-trans {q} {u} {l} } } -- Record unique ids carry whether the abstract id was assigned -- to a QC or a Block; this can be useful to avoid having to deal -- with 'blockId ≟ initialAgreedID' in order to decide whether -- a block is the genesis block or not. data TypedUID : Set where id-I : TypedUID id-B∨Q : UID -> TypedUID id-I≢id-B∨Q : ∀{id} → id-I ≡ id-B∨Q id → ⊥ id-I≢id-B∨Q () id-B∨Q-inj : ∀{u₁ u₂} → id-B∨Q u₁ ≡ id-B∨Q u₂ → u₁ ≡ u₂ id-B∨Q-inj refl = refl uid : Record → TypedUID uid I = id-I uid (B b) = id-B∨Q (bId b) uid (Q q) = id-B∨Q (qCertBlockId q) -- Each record has a round round : Record → Round round I = 0 round (B b) = getRound b round (Q q) = getRound q
{ "alphanum_fraction": 0.5810827177, "avg_line_length": 32.6363636364, "ext": "agda", "hexsha": "e2535fa81b6d45c6284798165083af6db413fc79", "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": "71aa2168e4875ffdeece9ba7472ee3cee5fa9084", "max_forks_repo_licenses": [ "UPL-1.0" ], "max_forks_repo_name": "cwjnkins/bft-consensus-agda", "max_forks_repo_path": "LibraBFT/Abstract/Records.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "71aa2168e4875ffdeece9ba7472ee3cee5fa9084", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "UPL-1.0" ], "max_issues_repo_name": "cwjnkins/bft-consensus-agda", "max_issues_repo_path": "LibraBFT/Abstract/Records.agda", "max_line_length": 111, "max_stars_count": null, "max_stars_repo_head_hexsha": "71aa2168e4875ffdeece9ba7472ee3cee5fa9084", "max_stars_repo_licenses": [ "UPL-1.0" ], "max_stars_repo_name": "cwjnkins/bft-consensus-agda", "max_stars_repo_path": "LibraBFT/Abstract/Records.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 2922, "size": 8257 }
{-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.HITs.Rationals.HITQ.Base where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Function open import Cubical.Relation.Nullary open import Cubical.HITs.Ints.QuoInt open import Cubical.Data.Nat as ℕ hiding (_·_) open import Cubical.Data.NatPlusOne open import Cubical.Data.Sigma -- ℚ as a higher inductive type data ℚ : Type₀ where con : (u : ℤ) (a : ℤ) → ¬ (a ≡ pos 0) → ℚ path : ∀ u a v b {p q} → (u · b) ≡ (v · a) → con u a p ≡ con v b q trunc : isSet ℚ [_] : ℤ × ℕ₊₁ → ℚ [ a , 1+ b ] = con a (pos (suc b)) (ℕ.snotz ∘ cong abs) -- Natural number and negative integer literals for ℚ open import Cubical.Data.Nat.Literals public instance fromNatℚ : HasFromNat ℚ fromNatℚ = record { Constraint = λ _ → Unit ; fromNat = λ n → [ pos n , 1 ] } instance fromNegℚ : HasFromNeg ℚ fromNegℚ = record { Constraint = λ _ → Unit ; fromNeg = λ n → [ neg n , 1 ] }
{ "alphanum_fraction": 0.6621761658, "avg_line_length": 26.0810810811, "ext": "agda", "hexsha": "1d0dc9bffcde1f2466e2b0dcd55810408de6b61d", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "dan-iel-lee/cubical", "max_forks_repo_path": "Cubical/HITs/Rationals/HITQ/Base.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_issues_repo_issues_event_max_datetime": "2022-01-27T02:07:48.000Z", "max_issues_repo_issues_event_min_datetime": "2022-01-27T02:07:48.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "dan-iel-lee/cubical", "max_issues_repo_path": "Cubical/HITs/Rationals/HITQ/Base.agda", "max_line_length": 79, "max_stars_count": null, "max_stars_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "dan-iel-lee/cubical", "max_stars_repo_path": "Cubical/HITs/Rationals/HITQ/Base.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 344, "size": 965 }
module FFI where postulate IO : Set -> Set {-# BUILTIN IO IO #-} {-# COMPILED_TYPE IO IO #-} postulate return : {A : Set} -> A -> IO A _>>=_ : {A B : Set} -> IO A -> (A -> IO B) -> IO B {-# COMPILED return (\_ -> return :: a -> IO a) #-} {-# COMPILED _>>=_ (\_ _ -> (>>=) :: IO a -> (a -> IO b) -> IO b) #-} data Unit : Set where unit : Unit {-# COMPILED_DATA Unit () nothing #-} main : IO Unit main = return unit
{ "alphanum_fraction": 0.505800464, "avg_line_length": 18.7391304348, "ext": "agda", "hexsha": "eb58db098a7295852e858642227952aabd19ee92", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_forks_event_min_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "masondesu/agda", "max_forks_repo_path": "test/fail/customised/FFI.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "masondesu/agda", "max_issues_repo_path": "test/fail/customised/FFI.agda", "max_line_length": 70, "max_stars_count": 1, "max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/agda-kanso", "max_stars_repo_path": "test/fail/customised/FFI.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": 149, "size": 431 }
module Numeral.CoordinateVector.Proofs where import Lvl open import Data.Boolean open import Data.Boolean.Stmt open import Data.Boolean.Stmt.Proofs import Data.Either as Either import Functional as Fn open import Function.Equals open import Function.Names open import Function.PointwiseStructure open import Logic.Classical open import Logic.Predicate open import Logic.Propositional open import Logic.Propositional.Theorems open import Numeral.CoordinateVector open import Numeral.Finite open import Numeral.Finite.Oper.Comparisons open import Numeral.Finite.Proofs open import Numeral.Natural import Relator.Equals as Eq open import Relator.Equals.Proofs.Equivalence open import Structure.Setoid open import Structure.Function.Multi import Structure.Function.Names as Names open import Structure.Function open import Structure.Operator.Field open import Structure.Operator.Group open import Structure.Operator.Monoid open import Structure.Operator.Properties open import Structure.Operator.Vector open import Structure.Operator open import Structure.Relator.Properties open import Type open import Syntax.Function open import Syntax.Transitivity -- Note: The structure stuff here is actually a specialization of Function.PointwiseStructure module _ {ℓ ℓₑ} {T : Type{ℓ}} ⦃ _ : Equiv{ℓₑ}(T) ⦄ where private variable _▫_ _▫₁_ _▫₂_ _+_ _⋅_ : T → T → T private variable f inv : T → T private variable id 𝟎ₛ 𝟏ₛ x init : T private variable d n : ℕ private variable i j k : 𝕟(n) private variable v : Vector(n)(T) instance -- A component-wise operator have a left identity of repeated elements when its underlying operator have a left identity. map₂-fill-identityₗ : ⦃ ident : Identityₗ(_▫_)(id) ⦄ → Identityₗ(map₂{d = n}(_▫_))(fill{d = n}(id)) map₂-fill-identityₗ = pointwiseFunction-identityₗ instance -- A component-wise operator have a right identity of repeated elements when its underlying operator have a right identity. map₂-fill-identityᵣ : ⦃ ident : Identityᵣ(_▫_)(id) ⦄ → Identityᵣ(map₂{d = n}(_▫_))(fill{d = n}(id)) map₂-fill-identityᵣ = pointwiseFunction-identityᵣ instance -- A component-wise operator have an identity of repeated elements when its underlying operator have an identity. map₂-fill-identity : ⦃ ident : Identity(_▫_)(id) ⦄ → Identity(map₂{d = n}(_▫_))(fill{d = n}(id)) map₂-fill-identity = pointwiseFunction-identity instance map₂-map-inverseₗ : ⦃ ident : Identityₗ(_▫_)(id) ⦄ ⦃ inver : InverseFunctionₗ(_▫_) ⦃ [∃]-intro _ ⦄ (inv) ⦄ → InverseFunctionₗ(map₂{d = n}(_▫_)) ⦃ [∃]-intro _ ⦄ (map(inv)) map₂-map-inverseₗ = pointwiseFunction-inverseFunctionₗ instance map₂-map-inverseᵣ : ⦃ ident : Identityᵣ(_▫_)(id) ⦄ ⦃ inver : InverseFunctionᵣ(_▫_) ⦃ [∃]-intro _ ⦄ (inv) ⦄ → InverseFunctionᵣ(map₂{d = n}(_▫_)) ⦃ [∃]-intro _ ⦄ (map(inv)) map₂-map-inverseᵣ = pointwiseFunction-inverseFunctionᵣ instance map₂-map-inverse : ⦃ ident : Identity(_▫_)(id) ⦄ ⦃ inver : InverseFunction(_▫_) ⦃ [∃]-intro _ ⦄ (inv) ⦄ → InverseFunction(map₂{d = n}(_▫_)) ⦃ [∃]-intro _ ⦄ (map(inv)) map₂-map-inverse = pointwiseFunction-inverseFunction instance -- A component-wise operator is commutative when its underlying operator is commutative. map₂-commutativity : ⦃ comm : Commutativity(_▫_) ⦄ → Commutativity(map₂{d = n}(_▫_)) map₂-commutativity = pointwiseFunction-commutativity instance -- A component-wise operator is associative when its underlying operator is associative. map₂-associativity : ⦃ assoc : Associativity(_▫_) ⦄ → Associativity(map₂{d = n}(_▫_)) map₂-associativity = pointwiseFunction-associativity instance -- A component-wise operator is left distributive over another component-wise operator when their underlying operators distribute. map₂-distributivityₗ : ⦃ distₗ : Distributivityₗ(_▫₁_)(_▫₂_) ⦄ → Distributivityₗ(map₂{d = n}(_▫₁_))(map₂{d = n}(_▫₂_)) map₂-distributivityₗ = pointwiseFunction-distributivityₗ instance -- A component-wise operator is right distributive over another component-wise operator when their underlying operators distribute. map₂-distributivityᵣ : ⦃ distᵣ : Distributivityᵣ(_▫₁_)(_▫₂_) ⦄ → Distributivityᵣ(map₂{d = n}(_▫₁_))(map₂{d = n}(_▫₂_)) map₂-distributivityᵣ = pointwiseFunction-distributivityᵣ instance map₂-preserves : Preserving₂(fill) (_▫_) (map₂{d = n}(_▫_)) map₂-preserves = pointwiseFunction-const-preserves instance -- A component-wise function is a function when its underlying function is a function. map-function : ⦃ func : Function(f) ⦄ → Function(map{d = n}(f)) map-function = pointwiseFunction-function instance -- A component-wise binary operator is a binary operator when its underlying binary operator is a binary operator. map₂-binaryOperator : ⦃ oper : BinaryOperator(_▫_) ⦄ → BinaryOperator(map₂{d = n}(_▫_)) map₂-binaryOperator = pointwiseFunction-binaryOperator instance -- A component-wise operator is a monoid when its underlying operator is a monoid. map₂-monoid : ⦃ monoid : Monoid(_▫_) ⦄ → Monoid(map₂{d = n}(_▫_)) map₂-monoid = pointwiseFunction-monoid instance -- A component-wise operator is a group when its underlying operator is a group. map₂-group : ⦃ group : Group(_▫_) ⦄ → Group(map₂{d = n}(_▫_)) map₂-group = pointwiseFunction-group instance -- A component-wise operator is a commutative group when its underlying operator is a commutative group. map₂-commutativeGroup : ⦃ commutativeGroup : CommutativeGroup(_▫_) ⦄ → CommutativeGroup(map₂{d = n}(_▫_)) map₂-commutativeGroup = pointwiseFunction-commutativeGroup {- TODO: Is this even possible? instance -- Note: The reason for `d = 𝐒(n)` is so that one cannot shrink a field to the "trivial field" in this way (which is not a field). map₂-field : ⦃ field-structure : Field(_+_)(_⋅_) ⦄ → Field(map₂{d = 𝐒(n)}(_+_))(map₂{d = 𝐒(n)}(_⋅_)) Field.[+]-commutative-group map₂-field = map₂-commutativeGroup Field.[⋅]-monoid map₂-field = map₂-monoid Field.⅟ (map₂-field ⦃ f ⦄) v ⦃ Field.intro nonzero ⦄ = {!!} -- map (x ↦ Field.⅟ f x ⦃ Field.intro (p ↦ nonzero (intro {!!})) ⦄) v Field.[⋅]-inverseₗ map₂-field = {!!} Field.[⋅]-inverseᵣ map₂-field = {!!} Field.distinct-identities (map₂-field ⦃ f ⦄) p = Field.distinct-identities f (_⊜_.proof p {𝟎}) -} instance -- Component-wise operators constructs a vector space from a field when using the fields as scalars and coordinate vectors as vectors. CoordinateVector-vectorSpace : ⦃ field-structure : Field(_+_)(_⋅_) ⦄ → VectorSpace(map₂{d = n}(_+_)) (s ↦ map{d = n}(s ⋅_)) (_+_) (_⋅_) CoordinateVector-vectorSpace ⦃ field-structure ⦄ = pointwiseFunction-vectorSpace field-structure indexProject-values : ∀{true false : T} → (proj(indexProject i true false) j ≡ true) ∨ (proj(indexProject i true false) j ≡ false) indexProject-values {𝐒 n}{i = i}{j = j} with (i ≡? j) ... | 𝑇 = [∨]-introₗ (reflexivity(_≡_)) ... | 𝐹 = [∨]-introᵣ (reflexivity(_≡_)) indexProject-true : ∀{true false : T} → (i Eq.≡ j) ∨ (false ≡ true) ↔ (proj(indexProject i true false) j ≡ true) indexProject-true {n}{i = i}{j = j} {true = true}{false = false} = [∨]-mapₗ-[↔] [≡][≡?]-equivalence ⦗ [↔]-transitivity ⦘ᵣ [↔]-intro (l{n}{i}{j}) ([↔]-to-[←] [→ₗ][∨][∧]-preserving ([∧]-intro (r₁{n}{i}{j}) (r₂{n}{i}{j}))) where l : ∀{n}{i j : 𝕟(n)} → IsTrue(i ≡? j) ∨ (false ≡ true) ← (proj(indexProject i true false) j ≡ true) l {𝐒 n} {i = i} {j = j} p with (i ≡? j) ... | 𝑇 = [∨]-introₗ [⊤]-intro ... | 𝐹 = [∨]-introᵣ p r₁ : ∀{n}{i j : 𝕟(n)} → IsTrue(i ≡? j) → (proj(indexProject i true false) j ≡ true) r₁ {𝐒 n} {i = i}{j = j} p with 𝑇 ← (i ≡? j) = reflexivity(_≡_) r₂ : ∀{n}{i j : 𝕟(n)} → (false ≡ true) → (proj(indexProject i true false) j ≡ true) r₂ {𝐒 n} {i = i}{j = j} p with (i ≡? j) ... | 𝑇 = reflexivity(_≡_) ... | 𝐹 = p indexProject-false : ∀{true false : T} → ((i Eq.≢ j) ∨ (false ≡ true)) ↔ (proj(indexProject i true false) j ≡ false) indexProject-false {n}{i = i}{j = j} {true = true}{false = false} = [∨]-mapₗ-[↔] ([↔]-transitivity ([¬]-unaryOperator [≡][≡?]-equivalence) ([↔]-symmetry false-true-opposites)) ⦗ [↔]-transitivity ⦘ᵣ [↔]-intro (l{n}{i}{j}) ([↔]-to-[←] [→ₗ][∨][∧]-preserving ([∧]-intro (r₁{n}{i}{j}) (r₂{n}{i}{j}))) where l : ∀{n}{i j : 𝕟(n)} → (IsFalse(i ≡? j) ∨ (false ≡ true)) ← (proj(indexProject i true false) j ≡ false) l {n} {i} {j} p with (i ≡? j) ... | 𝑇 = [∨]-introᵣ (symmetry(_≡_) p) ... | 𝐹 = [∨]-introₗ [⊤]-intro r₁ : ∀{n}{i j : 𝕟(n)} → IsFalse(i ≡? j) → (proj(indexProject i true false) j ≡ false) r₁ {𝐒 n} {i = i}{j = j} p with (i ≡? j) ... | 𝑇 = [⊥]-elim p ... | 𝐹 = reflexivity(_≡_) r₂ : ∀{n}{i j : 𝕟(n)} → (false ≡ true) → (proj(indexProject i true false) j ≡ false) r₂ {𝐒 n} {i = i}{j = j} p with (i ≡? j) ... | 𝑇 = symmetry(_≡_) p ... | 𝐹 = reflexivity(_≡_) module _ ⦃ ident : Identityₗ(_⋅_)(𝟏ₛ) ⦄ ⦃ absor : Absorberₗ(_⋅_)(𝟎ₛ) ⦄ where map₂-indexProject-identityₗ : map₂(_⋅_) (indexProject i 𝟏ₛ 𝟎ₛ) v ≡ indexProject i (v(i)) 𝟎ₛ _⊜_.proof (map₂-indexProject-identityₗ {i = i}{v = v}) {x} with (i ≡? x) | [↔]-to-[←] ([≡][≡?]-equivalence {i = i}{j = x}) ... | 𝑇 | p = identityₗ(_⋅_)(𝟏ₛ) 🝖 congruence₁ ⦃ [≡]-equiv ⦄ (v) ⦃ [≡]-to-function ⦄ (symmetry(Eq._≡_) (p([⊤]-intro))) ... | 𝐹 | _ = absorberₗ(_⋅_)(𝟎ₛ) module _ ⦃ ident : Identityᵣ(_⋅_)(𝟏ₛ) ⦄ ⦃ absor : Absorberᵣ(_⋅_)(𝟎ₛ) ⦄ where map₂-indexProject-identityᵣ : map₂(_⋅_) v (indexProject i 𝟏ₛ 𝟎ₛ) ≡ indexProject i (v(i)) 𝟎ₛ _⊜_.proof (map₂-indexProject-identityᵣ {v = v}{i = i}) {x} with (i ≡? x) | [↔]-to-[←] ([≡][≡?]-equivalence {i = i}{j = x}) ... | 𝑇 | p = identityᵣ(_⋅_)(𝟏ₛ) 🝖 congruence₁ ⦃ [≡]-equiv ⦄ (v) ⦃ [≡]-to-function ⦄ (symmetry(Eq._≡_) (p([⊤]-intro))) ... | 𝐹 | _ = absorberᵣ(_⋅_)(𝟎ₛ) tail-function : Function(tail{d = 𝐒(d)}{T = T}) Function.congruence(tail-function{d = d}) (intro xy) = intro xy instance foldᵣ-function : ∀{ℓᵣ ℓₑᵣ}{R : Type{ℓᵣ}} ⦃ equiv-R : Equiv{ℓₑᵣ}(R)⦄ {f : T → R → R}{init} → ⦃ oper : BinaryOperator(f) ⦄ → Function(foldᵣ{d = d} f init) foldᵣ-function {d} {f = f}{init = init} = intro(p{d = d}) where p : ∀{d} → Names.Congruence₁(foldᵣ{d = d} f init) p {𝟎} _ = reflexivity(_≡_) p {𝐒(𝟎)} xy = congruence₂ₗ(f)(_) (_⊜_.proof xy) p {𝐒(𝐒(d))} xy = congruence₂(f) (_⊜_.proof xy) (p {𝐒(d)} (congruence₁(tail) ⦃ tail-function ⦄ xy)) -- TODO: Generalize Numeral.Natural.Oper.Summation for these kinds of proofs {- module _ ⦃ oper : BinaryOperator(_▫_) ⦄ ⦃ ident : Identityᵣ(_▫_)(id) ⦄ ( neq : (id ≢ x) ) where foldᵣ-indexProject-identityᵣ : foldᵣ(_▫_) init (indexProject i x id) ≡ x ▫ init foldᵣ-indexProject-identityᵣ {init}{𝐒(𝟎)} {i = 𝟎} = reflexivity(_≡_) foldᵣ-indexProject-identityᵣ {init}{𝐒(𝐒(n))} {i = 𝟎} = foldᵣ{d = 𝐒(𝐒(n))}(_▫_) init (indexProject 𝟎 x id) 🝖[ _≡_ ]-[] proj(indexProject{d = 𝐒(𝐒(n))} 𝟎 x id)(𝟎) ▫ foldᵣ{d = 𝐒(n)}(_▫_) init (tail(indexProject 𝟎 x id)) 🝖[ _≡_ ]-[] x ▫ foldᵣ{d = 𝐒(n)}(_▫_) init (tail(indexProject 𝟎 x id)) 🝖[ _≡_ ]-[ {!!} ] x ▫ init 🝖-end {-foldᵣ(_▫_) id (indexProject 𝟎 x id) 🝖[ _≡_ ]-[ {!!} ] proj(indexProject 𝟎 x id)(𝟎) ▫ (foldᵣ(_▫_) id (tail(indexProject 𝟎 x id))) 🝖[ _≡_ ]-[ {!!} ] id ▫ (foldᵣ(_▫_) id (tail(indexProject 𝟎 x id))) 🝖[ _≡_ ]-[ {!!} ] foldᵣ(_▫_) id (tail(indexProject 𝟎 x id)) 🝖[ _≡_ ]-[ {!!} ] x 🝖-end-} foldᵣ-indexProject-identityᵣ {init}{𝐒(𝐒(n))} {i = 𝐒 i} = {!!} -}
{ "alphanum_fraction": 0.610360547, "avg_line_length": 50.9071729958, "ext": "agda", "hexsha": "b3d17e01fa726bc28d82c995096cad97416238a9", "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/CoordinateVector/Proofs.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/CoordinateVector/Proofs.agda", "max_line_length": 174, "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/CoordinateVector/Proofs.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": 4617, "size": 12065 }
{-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.Categories.Instances.Functors where open import Cubical.Categories.Category open import Cubical.Categories.Functor.Base open import Cubical.Categories.NaturalTransformation.Base open import Cubical.Categories.NaturalTransformation.Properties open import Cubical.Categories.Morphism renaming (isIso to isIsoC) open import Cubical.Foundations.Prelude private variable ℓC ℓC' ℓD ℓD' : Level module _ (C : Precategory ℓC ℓC') (D : Precategory ℓD ℓD') ⦃ isCatD : isCategory D ⦄ where open Precategory open NatTrans open Functor FUNCTOR : Precategory (ℓ-max (ℓ-max ℓC ℓC') (ℓ-max ℓD ℓD')) (ℓ-max (ℓ-max ℓC ℓC') ℓD') FUNCTOR .ob = Functor C D FUNCTOR .Hom[_,_] = NatTrans FUNCTOR .id = idTrans FUNCTOR ._⋆_ = seqTrans FUNCTOR .⋆IdL α = makeNatTransPath λ i x → D .⋆IdL (α .N-ob x) i FUNCTOR .⋆IdR α = makeNatTransPath λ i x → D .⋆IdR (α .N-ob x) i FUNCTOR .⋆Assoc α β γ = makeNatTransPath λ i x → D .⋆Assoc (α .N-ob x) (β .N-ob x) (γ .N-ob x) i isCatFUNCTOR : isCategory FUNCTOR isCatFUNCTOR .isSetHom = isSetNat open isIsoC renaming (inv to invC) -- component wise iso is an iso in Functor FUNCTORIso : ∀ {F G : Functor C D} (α : F ⇒ G) → (∀ (c : C .ob) → isIsoC {C = D} (α ⟦ c ⟧)) → isIsoC {C = FUNCTOR} α FUNCTORIso α is .invC .N-ob c = (is c) .invC FUNCTORIso {F} {G} α is .invC .N-hom {c} {d} f = invMoveL areInv-αc ( α ⟦ c ⟧ ⋆⟨ D ⟩ (G ⟪ f ⟫ ⋆⟨ D ⟩ is d .invC) ≡⟨ sym (D .⋆Assoc _ _ _) ⟩ (α ⟦ c ⟧ ⋆⟨ D ⟩ G ⟪ f ⟫) ⋆⟨ D ⟩ is d .invC ≡⟨ sym (invMoveR areInv-αd (α .N-hom f)) ⟩ F ⟪ f ⟫ ∎ ) where areInv-αc : areInv (α ⟦ c ⟧) ((is c) .invC) areInv-αc = isIso→areInv (is c) areInv-αd : areInv (α ⟦ d ⟧) ((is d) .invC) areInv-αd = isIso→areInv (is d) FUNCTORIso α is .sec = makeNatTransPath (funExt (λ c → (is c) .sec)) FUNCTORIso α is .ret = makeNatTransPath (funExt (λ c → (is c) .ret)) instance ⦃isCatFUNCTOR⦄ : {C : Precategory ℓC ℓC'} {D : Precategory ℓD ℓD'} ⦃ isCatD : isCategory D ⦄ → isCategory (FUNCTOR C D) ⦃isCatFUNCTOR⦄ {C = C} {D} = isCatFUNCTOR C D
{ "alphanum_fraction": 0.6010733453, "avg_line_length": 37.2666666667, "ext": "agda", "hexsha": "badb05c9871f25aaabc229bdb6cc21c54ffcc542", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "5de11df25b79ee49d5c084fbbe6dfc66e4147a2e", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Edlyr/cubical", "max_forks_repo_path": "Cubical/Categories/Instances/Functors.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "5de11df25b79ee49d5c084fbbe6dfc66e4147a2e", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Edlyr/cubical", "max_issues_repo_path": "Cubical/Categories/Instances/Functors.agda", "max_line_length": 98, "max_stars_count": null, "max_stars_repo_head_hexsha": "5de11df25b79ee49d5c084fbbe6dfc66e4147a2e", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Edlyr/cubical", "max_stars_repo_path": "Cubical/Categories/Instances/Functors.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 908, "size": 2236 }
module Issue947 where A : Set₁ A = Set where B : Set₁ B = Set module _ where C : Set₁ C = Set module M where -- Andreas, 2020-04-25, #4623 -- These empty `where` blocks now generate warnings.
{ "alphanum_fraction": 0.6600985222, "avg_line_length": 11.2777777778, "ext": "agda", "hexsha": "a3b852ff64bd4efd3dcff3c404ac31e065eb6e70", "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/Issue947.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/Issue947.agda", "max_line_length": 52, "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/Issue947.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 72, "size": 203 }
module Type.Isomorphism where open import Functional import Lvl open import Structure.Setoid open import Structure.Function.Domain hiding (inverseₗ ; inverseᵣ) open import Type private variable ℓ ℓ₁ ℓ₂ ℓₑ ℓₑ₁ ℓₑ₂ : Lvl.Level module _ (A : Type{ℓ₁}) (B : Type{ℓ₂}) ⦃ equiv-A : Equiv{ℓₑ₁}(A) ⦄ ⦃ equiv-B : Equiv{ℓₑ₂}(B) ⦄ where record _≅_ : Type{ℓ₁ Lvl.⊔ ℓₑ₁ Lvl.⊔ ℓ₂ Lvl.⊔ ℓₑ₂} where field left : A ← B right : A → B ⦃ inverseₗ ⦄ : Inverseₗ(right)(left) ⦃ inverseᵣ ⦄ : Inverseᵣ(right)(left)
{ "alphanum_fraction": 0.6388888889, "avg_line_length": 22.5, "ext": "agda", "hexsha": "f2367e36e3ec4096350749a7fd1703e20463dcef", "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": "Type/Isomorphism.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": "Type/Isomorphism.agda", "max_line_length": 66, "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": "Type/Isomorphism.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": 244, "size": 540 }
{-# OPTIONS --safe --warning=error --without-K #-} open import LogicalFormulae open import Lists.Definition open import Lists.Length open import Numbers.Naturals.Semiring module Lists.Concat where appendEmptyList : {a : _} → {A : Set a} → (l : List A) → (l ++ [] ≡ l) appendEmptyList [] = refl appendEmptyList (x :: l) = applyEquality (_::_ x) (appendEmptyList l) concatAssoc : {a : _} → {A : Set a} → (x : List A) → (y : List A) → (z : List A) → ((x ++ y) ++ z) ≡ x ++ (y ++ z) concatAssoc [] m n = refl concatAssoc (x :: l) m n = applyEquality (_::_ x) (concatAssoc l m n) canMovePrepend : {a : _} → {A : Set a} → (l : A) → (x : List A) (y : List A) → ((l :: x) ++ y ≡ l :: (x ++ y)) canMovePrepend l [] n = refl canMovePrepend l (x :: m) n = refl lengthConcat : {a : _} {A : Set a} (l1 l2 : List A) → length (l1 ++ l2) ≡ length l1 +N length l2 lengthConcat [] l2 = refl lengthConcat (x :: l1) l2 = applyEquality succ (lengthConcat l1 l2)
{ "alphanum_fraction": 0.5966209081, "avg_line_length": 37.88, "ext": "agda", "hexsha": "4aad91ece69147364b6845da78b574b39ebf2330", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-29T13:23:07.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-29T13:23:07.000Z", "max_forks_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Smaug123/agdaproofs", "max_forks_repo_path": "Lists/Concat.agda", "max_issues_count": 14, "max_issues_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_issues_repo_issues_event_max_datetime": "2020-04-11T11:03:39.000Z", "max_issues_repo_issues_event_min_datetime": "2019-01-06T21:11:59.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Smaug123/agdaproofs", "max_issues_repo_path": "Lists/Concat.agda", "max_line_length": 114, "max_stars_count": 4, "max_stars_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Smaug123/agdaproofs", "max_stars_repo_path": "Lists/Concat.agda", "max_stars_repo_stars_event_max_datetime": "2022-01-28T06:04:15.000Z", "max_stars_repo_stars_event_min_datetime": "2019-08-08T12:44:19.000Z", "num_tokens": 339, "size": 947 }
-- Andreas, 2020-03-19, issue #4486 -- "did you mean?" now also for invalid imports record Foo : Set₁ where field Θ : Set open Foo using () renaming (θ to unwrap) -- EXPECTED: -- The module Foo doesn't export the following: -- θ (did you mean 'Θ'?) module M where private postulate S : Set open M using (S) -- EXPECTED: -- The module M doesn't export the following: -- S module N where module O where record R : Set where open O public using (module R) module N' where module O where record R : Set where open O public hiding (module R) open N using (R) open N' using (module R) -- EXPECTED: -- The module N doesn't export the following: -- R -- The module N' doesn't export the following: -- module R module AB where record Ananas : Set where open AB using (Bananas) -- EXPECTED: -- The module AB doesn't export the following: -- Bananas (did you mean 'Ananas'?) open AB using (module Bananas) -- EXPECTED: -- The module AB doesn't export the following: -- module Bananas (did you mean 'Ananas'?)
{ "alphanum_fraction": 0.6736641221, "avg_line_length": 19.0545454545, "ext": "agda", "hexsha": "ef28f61081418c52bdd2219dcafc467d3c042aa5", "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/Issue4486.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/Issue4486.agda", "max_line_length": 47, "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/Issue4486.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": 297, "size": 1048 }
{-# OPTIONS --without-K --exact-split #-} module lists where import 17-number-theory open 17-number-theory public unit-list : {l1 : Level} {A : UU l1} → A → list A unit-list a = cons a nil {- First we introduce the functoriality of the list operation, because it will come in handy when we try to define and prove more advanced things. -} functor-list : {l1 l2 : Level} {A : UU l1} {B : UU l2} (f : A → B) → list A → list B functor-list f nil = nil functor-list f (cons a x) = cons (f a) (functor-list f x) identity-law-functor-list : {l1 : Level} {A : UU l1} → functor-list (id {A = A}) ~ id identity-law-functor-list nil = refl identity-law-functor-list (cons a x) = ap (cons a) (identity-law-functor-list x) composition-law-functor-list : {l1 l2 l3 : Level} {A : UU l1} {B : UU l2} {C : UU l3} → (f : A → B) (g : B → C) → functor-list (g ∘ f) ~ (functor-list g ∘ functor-list f) composition-law-functor-list f g nil = refl composition-law-functor-list f g (cons a x) = ap (cons (g (f a))) (composition-law-functor-list f g x) {- Concatenation of lists is an associative operation and nil is the unit for list concatenation. -} assoc-concat-list : {l1 : Level} {A : UU l1} (x y z : list A) → Id (concat-list (concat-list x y) z) (concat-list x (concat-list y z)) assoc-concat-list nil y z = refl assoc-concat-list (cons a x) y z = ap (cons a) (assoc-concat-list x y z) left-unit-law-concat-list : {l1 : Level} {A : UU l1} (x : list A) → Id (concat-list nil x) x left-unit-law-concat-list x = refl right-unit-law-concat-list : {l1 : Level} {A : UU l1} (x : list A) → Id (concat-list x nil) x right-unit-law-concat-list nil = refl right-unit-law-concat-list (cons a x) = ap (cons a) (right-unit-law-concat-list x) {- The length operation or course behaves well with respect to the other list operations. -} length-nil : {l1 : Level} {A : UU l1} → Id (length-list {A = A} nil) zero-ℕ length-nil = refl length-concat-list : {l1 : Level} {A : UU l1} (x y : list A) → Id (length-list (concat-list x y)) (add-ℕ (length-list x) (length-list y)) length-concat-list nil y = inv (left-unit-law-add-ℕ (length-list y)) length-concat-list (cons a x) y = ( ap succ-ℕ (length-concat-list x y)) ∙ ( inv (left-successor-law-add-ℕ (length-list x) (length-list y))) {- We now prove the properties of flattening. -} flatten-unit-list : {l1 : Level} {A : UU l1} (x : list A) → Id (flatten-list (unit-list x)) x flatten-unit-list x = right-unit-law-concat-list x length-flatten-list : {l1 : Level} {A : UU l1} (x : list (list A)) → Id ( length-list (flatten-list x)) ( sum-list-ℕ (functor-list length-list x)) length-flatten-list nil = refl length-flatten-list (cons a x) = ( length-concat-list a (flatten-list x)) ∙ ( ap (add-ℕ (length-list a)) (length-flatten-list x)) flatten-concat-list : {l1 : Level} {A : UU l1} (x y : list (list A)) → Id ( flatten-list (concat-list x y)) ( concat-list (flatten-list x) (flatten-list y)) flatten-concat-list nil y = refl flatten-concat-list (cons a x) y = ( ap (concat-list a) (flatten-concat-list x y)) ∙ ( inv (assoc-concat-list a (flatten-list x) (flatten-list y))) flatten-flatten-list : {l1 : Level} {A : UU l1} (x : list (list (list A))) → Id ( flatten-list (flatten-list x)) ( flatten-list (functor-list flatten-list x)) flatten-flatten-list nil = refl flatten-flatten-list (cons a x) = ( flatten-concat-list a (flatten-list x)) ∙ ( ap (concat-list (flatten-list a)) (flatten-flatten-list x)) {- Next, we prove the basic properties of list reversal. -} reverse-unit-list : {l1 : Level} {A : UU l1} (a : A) → Id (reverse-list (unit-list a)) (unit-list a) reverse-unit-list a = refl length-reverse-list : {l1 : Level} {A : UU l1} (x : list A) → Id (length-list (reverse-list x)) (length-list x) length-reverse-list nil = refl length-reverse-list (cons a x) = ( length-concat-list (reverse-list x) (unit-list a)) ∙ ( ap succ-ℕ (length-reverse-list x)) reverse-concat-list : {l1 : Level} {A : UU l1} (x y : list A) → Id ( reverse-list (concat-list x y)) ( concat-list (reverse-list y) (reverse-list x)) reverse-concat-list nil y = inv (right-unit-law-concat-list (reverse-list y)) reverse-concat-list (cons a x) y = ( ap (λ t → concat-list t (unit-list a)) (reverse-concat-list x y)) ∙ ( assoc-concat-list (reverse-list y) (reverse-list x) (unit-list a)) reverse-flatten-list : {l1 : Level} {A : UU l1} (x : list (list A)) → Id ( reverse-list (flatten-list x)) ( flatten-list (reverse-list (functor-list reverse-list x))) reverse-flatten-list nil = refl reverse-flatten-list (cons a x) = ( reverse-concat-list a (flatten-list x)) ∙ ( ( ap (λ t → concat-list t (reverse-list a)) (reverse-flatten-list x)) ∙ ( ( ap ( concat-list ( flatten-list (reverse-list (functor-list reverse-list x)))) ( inv (flatten-unit-list (reverse-list a)))) ∙ ( inv ( flatten-concat-list ( reverse-list (functor-list reverse-list x)) ( unit-list (reverse-list a)))))) reverse-reverse-list : {l1 : Level} {A : UU l1} (x : list A) → Id (reverse-list (reverse-list x)) x reverse-reverse-list nil = refl reverse-reverse-list (cons a x) = ( reverse-concat-list (reverse-list x) (unit-list a)) ∙ ( ap (concat-list (unit-list a)) (reverse-reverse-list x)) -------------------------------------------------------------------------------- {- Next we define the head and tail operations, and we define the operations of picking and removing the last element from a list. -} head-list : {l1 : Level} {A : UU l1} → list A → list A head-list nil = nil head-list (cons a x) = unit-list a tail-list : {l1 : Level} {A : UU l1} → list A → list A tail-list nil = nil tail-list (cons a x) = x last-element-list : {l1 : Level} {A : UU l1} → list A → list A last-element-list nil = nil last-element-list (cons a nil) = unit-list a last-element-list (cons a (cons b x)) = last-element-list (cons b x) remove-last-element-list : {l1 : Level} {A : UU l1} → list A → list A remove-last-element-list nil = nil remove-last-element-list (cons a nil) = nil remove-last-element-list (cons a (cons b x)) = cons a (remove-last-element-list (cons b x)) cons' : {l1 : Level} {A : UU l1} → list A → A → list A cons' x a = concat-list x (unit-list a) {- We prove the basic properties about heads and tails and their duals. -} eta-list : {l1 : Level} {A : UU l1} (x : list A) → Id (concat-list (head-list x) (tail-list x)) x eta-list nil = refl eta-list (cons a x) = refl eta-list' : {l1 : Level} {A : UU l1} (x : list A) → Id (concat-list (remove-last-element-list x) (last-element-list x)) x eta-list' nil = refl eta-list' (cons a nil) = refl eta-list' (cons a (cons b x)) = ap (cons a) (eta-list' (cons b x)) last-element-cons' : {l1 : Level} {A : UU l1} (x : list A) (a : A) → Id (last-element-list (cons' x a)) (unit-list a) last-element-cons' nil a = refl last-element-cons' (cons b nil) a = refl last-element-cons' (cons b (cons c x)) a = last-element-cons' (cons c x) a head-concat-list : {l1 : Level} {A : UU l1} (x y : list A) → Id ( head-list (concat-list x y)) ( head-list (concat-list (head-list x) (head-list y))) head-concat-list nil nil = refl head-concat-list nil (cons x y) = refl head-concat-list (cons a x) y = refl tail-concat-list : {l1 : Level} {A : UU l1} (x y : list A) → Id ( tail-list (concat-list x y)) ( concat-list (tail-list x) (tail-list (concat-list (head-list x) y))) tail-concat-list nil y = refl tail-concat-list (cons a x) y = refl last-element-concat-list : {l1 : Level} {A : UU l1} (x y : list A) → Id ( last-element-list (concat-list x y)) ( last-element-list ( concat-list (last-element-list x) (last-element-list y))) last-element-concat-list nil nil = refl last-element-concat-list nil (cons b nil) = refl last-element-concat-list nil (cons b (cons c y)) = last-element-concat-list nil (cons c y) last-element-concat-list (cons a nil) nil = refl last-element-concat-list (cons a nil) (cons b nil) = refl last-element-concat-list (cons a nil) (cons b (cons c y)) = last-element-concat-list (cons a nil) (cons c y) last-element-concat-list (cons a (cons b x)) y = last-element-concat-list (cons b x) y remove-last-element-concat-list : {l1 : Level} {A : UU l1} (x y : list A) → Id ( remove-last-element-list (concat-list x y)) ( concat-list ( remove-last-element-list (concat-list x (head-list y))) ( remove-last-element-list y)) remove-last-element-concat-list nil nil = refl remove-last-element-concat-list nil (cons a nil) = refl remove-last-element-concat-list nil (cons a (cons b y)) = refl remove-last-element-concat-list (cons a nil) nil = refl remove-last-element-concat-list (cons a nil) (cons b y) = refl remove-last-element-concat-list (cons a (cons b x)) y = ap (cons a) (remove-last-element-concat-list (cons b x) y) head-reverse-list : {l1 : Level} {A : UU l1} (x : list A) → Id (head-list (reverse-list x)) (last-element-list x) head-reverse-list nil = refl head-reverse-list (cons a nil) = refl head-reverse-list (cons a (cons b x)) = ( ap head-list ( assoc-concat-list (reverse-list x) (unit-list b) (unit-list a))) ∙ ( ( head-concat-list ( reverse-list x) ( concat-list (unit-list b) (unit-list a))) ∙ ( ( inv (head-concat-list (reverse-list x) (unit-list b))) ∙ ( head-reverse-list (cons b x)))) last-element-reverse-list : {l1 : Level} {A : UU l1} (x : list A) → Id (last-element-list (reverse-list x)) (head-list x) last-element-reverse-list x = ( inv (head-reverse-list (reverse-list x))) ∙ ( ap head-list (reverse-reverse-list x)) tail-concat-list' : {l1 : Level} {A : UU l1} (x y : list A) → Id ( tail-list (concat-list x y)) ( concat-list ( tail-list x) ( tail-list (concat-list (last-element-list x) y))) tail-concat-list' nil y = refl tail-concat-list' (cons a nil) y = refl tail-concat-list' (cons a (cons b x)) y = ap (cons b) (tail-concat-list' (cons b x) y) tail-reverse-list : {l1 : Level} {A : UU l1} (x : list A) → Id (tail-list (reverse-list x)) (reverse-list (remove-last-element-list x)) tail-reverse-list nil = refl tail-reverse-list (cons a nil) = refl tail-reverse-list (cons a (cons b x)) = ( tail-concat-list' (reverse-list (cons b x)) (unit-list a)) ∙ ( ( ap ( λ t → concat-list ( tail-list (reverse-list (cons b x))) ( tail-list (concat-list t (unit-list a)))) ( last-element-cons' (reverse-list x) b)) ∙ ( ap (λ t → concat-list t (unit-list a)) (tail-reverse-list (cons b x)))) remove-last-element-reverse-list : {l1 : Level} {A : UU l1} (x : list A) → Id (remove-last-element-list (reverse-list x)) (reverse-list (tail-list x)) remove-last-element-reverse-list x = ( inv (reverse-reverse-list (remove-last-element-list (reverse-list x)))) ∙ ( ( inv (ap reverse-list (tail-reverse-list (reverse-list x)))) ∙ ( ap (reverse-list ∘ tail-list) (reverse-reverse-list x))) -------------------------------------------------------------------------------- map-algebra-list : {l1 : Level} (A : UU l1) → coprod unit (A × list A) → list A map-algebra-list A (inl star) = nil map-algebra-list A (inr (pair a x)) = cons a x inv-map-algebra-list : {l1 : Level} (A : UU l1) → list A → coprod unit (A × list A) inv-map-algebra-list A nil = inl star inv-map-algebra-list A (cons a x) = inr (pair a x) issec-inv-map-algebra-list : {l1 : Level} (A : UU l1) → (map-algebra-list A ∘ inv-map-algebra-list A) ~ id issec-inv-map-algebra-list A nil = refl issec-inv-map-algebra-list A (cons a x) = refl isretr-inv-map-algebra-list : {l1 : Level} (A : UU l1) → (inv-map-algebra-list A ∘ map-algebra-list A) ~ id isretr-inv-map-algebra-list A (inl star) = refl isretr-inv-map-algebra-list A (inr (pair a x)) = refl is-equiv-map-algebra-list : {l1 : Level} (A : UU l1) → is-equiv (map-algebra-list A) is-equiv-map-algebra-list A = is-equiv-has-inverse ( inv-map-algebra-list A) ( issec-inv-map-algebra-list A) ( isretr-inv-map-algebra-list A) -------------------------------------------------------------------------------- Eq-list : {l1 : Level} {A : UU l1} → list A → list A → UU l1 Eq-list nil nil = raise _ unit Eq-list nil (cons x y) = raise _ empty Eq-list (cons a x) nil = raise _ empty Eq-list (cons a x) (cons b y) = (Id a b) × (Eq-list x y) data Eq-list' {l1 : Level} {A : UU l1} : list A → list A → UU l1 where refl-nil : Eq-list' nil nil eq-cons : (x y : list A) (a b : A) → Eq-list' x y → Id a b → Eq-list' (cons a x) (cons b y) refl-Eq-list : {l1 : Level} {A : UU l1} (x : list A) → Eq-list x x refl-Eq-list nil = map-raise star refl-Eq-list (cons a x) = pair refl (refl-Eq-list x) contraction-total-Eq-list : {l1 : Level} {A : UU l1} (x : list A) → (y : Σ (list A) (Eq-list x)) → Id (pair x (refl-Eq-list x)) y contraction-total-Eq-list nil (pair nil (map-raise star)) = refl contraction-total-Eq-list nil (pair (cons b y) (map-raise ())) contraction-total-Eq-list (cons a x) (pair nil (map-raise ())) contraction-total-Eq-list (cons a x) (pair (cons .a y) (pair refl e)) = {!!} is-contr-total-Eq-list : {l1 : Level} {A : UU l1} (x : list A) → is-contr (Σ (list A) (Eq-list x)) is-contr-total-Eq-list nil = pair ( pair nil (map-raise star)) {!!} is-contr-total-Eq-list (cons x x₁) = {!!}
{ "alphanum_fraction": 0.6205668497, "avg_line_length": 34.9170984456, "ext": "agda", "hexsha": "6b765f05352a0daf0a1a92aeb7a93ca8dd8ce297", "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": "22023fd35023cb6804424ce12cd10d252b80fd29", "max_forks_repo_licenses": [ "CC-BY-4.0" ], "max_forks_repo_name": "tmoux/HoTT-Intro", "max_forks_repo_path": "Agda/lists.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "22023fd35023cb6804424ce12cd10d252b80fd29", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "CC-BY-4.0" ], "max_issues_repo_name": "tmoux/HoTT-Intro", "max_issues_repo_path": "Agda/lists.agda", "max_line_length": 80, "max_stars_count": null, "max_stars_repo_head_hexsha": "22023fd35023cb6804424ce12cd10d252b80fd29", "max_stars_repo_licenses": [ "CC-BY-4.0" ], "max_stars_repo_name": "tmoux/HoTT-Intro", "max_stars_repo_path": "Agda/lists.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 4422, "size": 13478 }
------------------------------------------------------------------------ -- INCREMENTAL λ-CALCULUS -- -- Reexport Data.List from the standard library. -- -- Here we expose different names, for use in Contexts. ------------------------------------------------------------------------ module Base.Data.ContextList where import Data.List as List open List public using () renaming ( [] to ∅ ; _∷_ to _•_ ; map to mapContext )
{ "alphanum_fraction": 0.4535147392, "avg_line_length": 24.5, "ext": "agda", "hexsha": "9bf03ab46b5f07a32dc56551e7bc3e33c08e0a3a", "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": "Base/Data/ContextList.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": "Base/Data/ContextList.agda", "max_line_length": 72, "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": "Base/Data/ContextList.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": 87, "size": 441 }
module PatternSynonyms where data ℕ : Set where zero : ℕ suc : (n : ℕ) → ℕ {-# BUILTIN NATURAL ℕ #-} {-# BUILTIN ZERO zero #-} {-# BUILTIN SUC suc #-} pattern z = zero pattern sz = suc z pattern ss x = suc (suc x) data _≡_ {A : Set}(x : A) : A → Set where refl : x ≡ x test : z ≡ zero test = refl test′ : sz ≡ suc zero test′ = refl test″ : ss z ≡ suc (suc zero) test″ = refl test‴ : ss ≡ λ x → suc (suc x) test‴ = refl f : ℕ → ℕ f z = zero f sz = suc z f (ss 0) = 2 f (ss (suc n)) = n test-f : f zero ≡ zero test-f = refl test-f′ : f (suc zero) ≡ suc zero test-f′ = refl test-f″ : f (suc (suc 0)) ≡ 2 test-f″ = refl test-f‴ : ∀ {n} → f (suc (suc (suc n))) ≡ n test-f‴ = refl ------------------------------------------------------------------------ data L (A : Set) : Set where nil : L A cons : A → L A → L A pattern cc x y xs = cons x (cons y xs) test-cc : ∀ {A} → cc ≡ λ (x : A) y xs → cons x (cons y xs) test-cc = refl crazyLength : ∀ {A} → L A → ℕ crazyLength nil = 0 crazyLength (cons x nil) = 1 crazyLength (cc x y xs) = 9000 swap : ∀ {A} → L A → L A swap nil = nil swap (cons x nil) = cons x nil swap (cc x y xs) = cc y x xs test-swap : ∀ {xs} → swap (cons 1 (cons 2 xs)) ≡ cons 2 (cons 1 xs) test-swap = refl ------------------------------------------------------------------------ -- refl and _ record ⊤ : Set where constructor tt data _⊎_ (A B : Set) : Set where inj₁ : (x : A) → A ⊎ B inj₂ : (y : B) → A ⊎ B infixr 4 _,_ record Σ (A : Set)(B : A → Set) : Set where constructor _,_ field proj₁ : A proj₂ : B proj₁ open Σ _×_ : (A B : Set) → Set A × B = Σ A λ _ → B infixr 5 _+_ infixr 6 _*_ data Sig (O : Set) : Set₁ where ε ψ : Sig O ρ : (o : O) → Sig O ι : (o : O) → Sig O _+_ _*_ : (Σ Σ′ : Sig O) → Sig O σ π : (A : Set)(φ : A → Sig O) → Sig O ⟦_⟧ : ∀ {O} → Sig O → (Set → (O → Set) → (O → Set)) ⟦ ε ⟧ P R o = ⊤ ⟦ ψ ⟧ P R o = P ⟦ ρ o′ ⟧ P R o = R o′ ⟦ ι o′ ⟧ P R o = o ≡ o′ ⟦ Σ + Σ′ ⟧ P R o = ⟦ Σ ⟧ P R o ⊎ ⟦ Σ′ ⟧ P R o ⟦ Σ * Σ′ ⟧ P R o = ⟦ Σ ⟧ P R o × ⟦ Σ′ ⟧ P R o ⟦ σ A φ ⟧ P R o = Σ A λ x → ⟦ φ x ⟧ P R o ⟦ π A φ ⟧ P R o = (x : A) → ⟦ φ x ⟧ P R o ′List : Sig ⊤ ′List = ε + ψ * ρ _ data μ {O}(Σ : Sig O)(P : Set)(o : O) : Set where ⟨_⟩ : ⟦ Σ ⟧ P (μ Σ P) o → μ Σ P o List : Set → Set List A = μ ′List A _ infixr 5 _∷_ pattern [] = ⟨ inj₁ _ ⟩ pattern _∷_ x xs = ⟨ inj₂ (x , xs) ⟩ length : ∀ {A} → List A → ℕ length [] = zero length (x ∷ xs) = suc (length xs) test-list : List ℕ test-list = 1 ∷ 2 ∷ [] test-length : length test-list ≡ 2 test-length = refl ′Vec : Sig ℕ ′Vec = ι 0 + σ ℕ λ m → ψ * ρ m * ι (suc m) Vec : Set → ℕ → Set Vec A n = μ ′Vec A n pattern []V = ⟨ inj₁ refl ⟩ pattern _∷V_ x xs = ⟨ inj₂ (_ , x , xs , refl) ⟩ nilV : ∀ {A} → Vec A zero nilV = []V consV : ∀ {A n} → A → Vec A n → Vec A (suc n) consV x xs = x ∷V xs lengthV : ∀ {A n} → Vec A n → ℕ lengthV []V = 0 lengthV (x ∷V xs) = suc (lengthV xs) test-lengthV : lengthV (consV 1 (consV 2 (consV 3 nilV))) ≡ 3 test-lengthV = refl ------------------------------------------------------------------------ -- .-patterns pattern zr = (.zero , refl) pattern underscore² = _ , _ dot : (p : Σ ℕ λ n → n ≡ zero) → ⊤ × ⊤ dot zr = underscore² ------------------------------------------------------------------------ -- Implicit arguments {- pattern hiddenUnit = {_} -- XXX: We get lhs error msgs, can we refine -- that? imp : {p : ⊤} → ⊤ imp hiddenUnit = _ -} data Box (A : Set) : Set where box : {x : A} → Box A pattern [_] y = box {x = y} b : Box ℕ b = [ 1 ] test-box : b ≡ box {x = 1} test-box = refl ------------------------------------------------------------------------ -- Anonymous λs g : ℕ → ℕ g = λ { z → z ; sz → sz ; (ss n) → n } test-g : g zero ≡ zero test-g = refl test-g′ : g sz ≡ suc zero test-g′ = refl test-g″ : ∀ {n} → g (suc (suc n)) ≡ n test-g″ = refl ------------------------------------------------------------------------ -- λs postulate X Y : Set h : X → Y p : (x : X)(y : Y) → h x ≡ y → ⊤ p x .((λ x → x) (h x)) refl = _ pattern app x = x , .((λ x → x) (h x)) p′ : (p : X × Y) → h (proj₁ p) ≡ proj₂ p → ⊤ p′ (app x) refl = _ ------------------------------------------------------------------------ -- records record Rec : Set where constructor rr field r : ℕ rrr : (x : Rec) → x ≡ record { r = 0 } → ⊤ rrr .(record { r = 0}) refl = _ rrr′ : (x : Rec) → x ≡ record { r = 0 } → ⊤ rrr′ .(rr 0) refl = _ rrrr : (a : Rec × ℕ) → proj₁ a ≡ record { r = proj₂ a } → ⊤ rrrr (.(rr 0) , 0) refl = _ rrrr (.(rr (suc n)) , suc n) refl = _ pattern pair x = (.(record { r = x }) , x) rrrr′ : (a : Rec × ℕ) → proj₁ a ≡ record { r = proj₂ a } → ⊤ rrrr′ (pair 0) refl = _ rrrr′ (pair (suc n)) refl = _ ------------------------------------------------------------------------ -- lets pp : (x : X)(y : Y) → h x ≡ y → ⊤ pp x .(let i = (λ x → x) in i (h x)) refl = _ pattern llet x = x , .(let i = (λ x → x) in i (h x)) pp′ : (p : X × Y) → h (proj₁ p) ≡ proj₂ p → ⊤ pp′ (llet x) refl = _ ------------------------------------------------------------------------ -- absurd patterns pattern absurd = () data ⊥ : Set where ⊥-elim : ∀ {A : Set} → ⊥ → A ⊥-elim absurd ------------------------------------------------------------------------ -- ambiguous constructors data ℕ2 : Set where zero : ℕ2 suc : ℕ2 -> ℕ2 -- This needs a type signature, because it is ambiguous: amb : ℕ2 amb = suc (suc zero) -- This isn't ambiguous, because the overloading is resolved when the -- pattern synonym is scope-checked: unamb = ss z ------------------------------------------------------------------------ -- underscore pattern trivial = ._ trivf : (a : ⊤) -> a ≡ tt -> ⊤ trivf trivial refl = trivial ------------------------------------------------------------------------ -- let open pattern nuts = .(let open Σ in z) foo : (n : ℕ) -> n ≡ z -> ℕ foo nuts refl = nuts ------------------------------------------------------------------------ -- pattern synonym inside unparamterised module module M where pattern sss x = suc (suc (suc x)) a : ℕ a = sss 2 mb : ℕ mb = M.sss 0 mf : ℕ -> ℕ -> ℕ mf (M.sss _) = M.sss mf _ = \ _ -> 0 {- module M (A : Set)(a : A) where pattern peep x = x , .a pop : (z : A × A) -> proj₂ z ≡ a -> ⊤ pop (peep x) refl = _ peep' = peep pop' : (z : ⊤ × ⊤) -> proj₂ z ≡ tt -> ⊤ pop' (M.peep tt) refl = _ peep' = M.peep -}
{ "alphanum_fraction": 0.4215805471, "avg_line_length": 19.1836734694, "ext": "agda", "hexsha": "ca2d9b609d1bbd5e5cc08aa5fa9f46326c07dd03", "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": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "asr/agda-kanso", "max_forks_repo_path": "test/succeed/PatternSynonyms.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5", "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": "asr/agda-kanso", "max_issues_repo_path": "test/succeed/PatternSynonyms.agda", "max_line_length": 72, "max_stars_count": null, "max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/agda-kanso", "max_stars_repo_path": "test/succeed/PatternSynonyms.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 2475, "size": 6580 }
{-# OPTIONS --without-K --safe #-} open import Algebra open import Data.Bool.Base using (Bool; if_then_else_) open import Function.Base using (_∘_) open import Data.Integer.Base as ℤ using (ℤ; +_; +0; +[1+_]; -[1+_]) import Data.Integer.Properties as ℤP open import Data.Integer.DivMod as ℤD open import Data.Nat as ℕ using (ℕ; zero; suc) open import Data.Nat.Properties as ℕP using (≤-step) import Data.Nat.DivMod as ℕD open import Level using (0ℓ) open import Data.Product open import Relation.Nullary open import Relation.Nullary.Negation using (contraposition) open import Relation.Nullary.Decidable open import Relation.Unary using (Pred) open import Relation.Binary.PropositionalEquality.Core using (_≡_; _≢_; refl; cong; sym; subst; trans; ≢-sym) open import Relation.Binary open import Data.Rational.Unnormalised as ℚ using (ℚᵘ; mkℚᵘ; _≢0; _/_; 0ℚᵘ; 1ℚᵘ; ↥_; ↧_; ↧ₙ_) import Data.Rational.Unnormalised.Properties as ℚP open import Algebra.Bundles open import Algebra.Structures open import Data.Empty open import Data.Sum open import Data.Maybe.Base open import RealsRefactored open import Data.List open import Function.Structures {_} {_} {_} {_} {ℕ} _≡_ {ℕ} _≡_ {- The solvers are used and renamed often enough to warrant them being opened up here for the sake of consistency and cleanliness. -} open ℝ-Solver open import NonReflectiveZ as ℤ-Solver using () renaming ( solve to ℤsolve ; _⊕_ to _:+_ ; _⊗_ to _:*_ ; _⊖_ to _:-_ ; ⊝_ to :-_ ; _⊜_ to _:=_ ; Κ to ℤΚ ) open import NonReflectiveQ as ℚ-Solver using () renaming ( solve to ℚsolve ; _⊕_ to _+:_ ; _⊗_ to _*:_ ; _⊖_ to _-:_ ; ⊝_ to -:_ ; _⊜_ to _=:_ ; Κ to ℚΚ ) open ℚᵘ open ℝ -- We use "Inequality" instead of "a≤x≤b" to avoid mixing up variable names in practice. -- Intervals of the form (b,a) where a ≤ b will be nonempty of course. record ⦅_,_⦆ (a b : ℝ) : Set where constructor mk⦅⦆ field x : ℝ inequality : a < x < b record ⦅_,_⟧ (a b : ℝ) : Set where constructor mk⦅⟧ field x : ℝ inequality : a < x ≤ b record ⟦_,_⦆ (a b : ℝ) : Set where constructor mk⟦⦆ field x : ℝ inequality : a ≤ x < b record ⟦_,_⟧ (a b : ℝ) : Set where constructor mk⟦⟧ field x : ℝ inequality : a ≤ x ≤ b record ⦅-∞,_⦆ (a : ℝ) : Set where constructor mk⦅-∞⦆ field x : ℝ inequality : x < a record ⦅-∞,_⟧ (a : ℝ) : Set where constructor mk⦅-∞⟧ field x : ℝ inequality : x ≤ a record ⦅_,∞⦆ (a : ℝ) : Set where constructor mk⦅∞⦆ field x : ℝ inequality : a < x record ⟦_,∞⦆ (a : ℝ) : Set where constructor mk⟦∞⦆ field x : ℝ inequality : a ≤ x _isNonvoid : {A : Set} -> (P : A -> Set) -> Set _isNonvoid {A} P = ∃ λ (x : A) -> P x Compact⟦_,_⟧ : ℝ -> ℝ -> Set Compact⟦ a , b ⟧ = ∃ λ (x : ℝ) -> a ≤ x ≤ b -- Too much bloat? data _isUpperBoundOf_ (b : ℝ) (P : ℝ -> Set) : Set where upBound* : (∀ x -> P x -> x ≤ b) -> b isUpperBoundOf P _isBoundedAbove : (P : ℝ -> Set) -> Set P isBoundedAbove = ∃ λ (b : ℝ) -> b isUpperBoundOf P _isSupremumOf_ : (s : ℝ) -> (P : ℝ -> Set) -> Set s isSupremumOf P = s isUpperBoundOf P × (∀ ε -> ε > 0ℝ -> ∃ λ x -> P x × x > s - ε) _hasSupremum : (ℝ -> Set) -> Set P hasSupremum = ∃ λ s -> s isSupremumOf P proposition-4-3-if : ∀ {P : ℝ -> Set} -> P isNonvoid -> P isBoundedAbove -> (∀ {x y : ℝ} -> x < y -> y isUpperBoundOf P ⊎ ∃ λ a -> P a × x < a) -> P hasSupremum proposition-4-3-if {P} P≠Ø P≤U hyp = {!!} proposition-4-3-onlyif : ∀ {P : ℝ -> Set} -> P isNonvoid -> P hasSupremum -> ∀ {x y : ℝ} -> x < y -> y isUpperBoundOf P ⊎ ∃ λ a -> P a × x < a proposition-4-3-onlyif {P} P≠Ø (s , upBound* P≤s , hyp) {x} {y} x<y = [ left , right ]′ (corollary-2-17 s x y x<y) where open ≤-Reasoning left : s < y -> y isUpperBoundOf P ⊎ ∃ λ a -> P a × x < a left s<y = inj₁ (upBound* (λ z Pz -> ≤-trans (P≤s z Pz) (<⇒≤ s<y))) right : s > x -> y isUpperBoundOf P ⊎ ∃ λ a -> P a × x < a right s>x = let aget = hyp (s - x) (x<y⇒0<y-x x s s>x); a = proj₁ aget in inj₂ (a , proj₁ (proj₂ aget) , (begin-strict x ≈⟨ solve 2 (λ s x → x ⊜ s ⊖ (s ⊖ x)) ≃-refl s x ⟩ s - (s - x) <⟨ proj₂ (proj₂ aget) ⟩ a ∎))
{ "alphanum_fraction": 0.5681146236, "avg_line_length": 29.7094594595, "ext": "agda", "hexsha": "2818555bc8a46d7f321cb1d615e7466e28910202", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "6fbaca08b1d63b5765d184f6284fb0e58c9f5e52", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "z-murray/AnalysisAgda", "max_forks_repo_path": "Continuity.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "6fbaca08b1d63b5765d184f6284fb0e58c9f5e52", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "z-murray/AnalysisAgda", "max_issues_repo_path": "Continuity.agda", "max_line_length": 114, "max_stars_count": null, "max_stars_repo_head_hexsha": "6fbaca08b1d63b5765d184f6284fb0e58c9f5e52", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "z-murray/AnalysisAgda", "max_stars_repo_path": "Continuity.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1709, "size": 4397 }
{-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.Algebra.RingSolver.CommRingSolver where open import Cubical.Foundations.Prelude open import Cubical.Data.FinData open import Cubical.Data.Nat using (ℕ) open import Cubical.Data.Nat.Order using (zero-≤) open import Cubical.Data.Vec.Base open import Cubical.Algebra.CommRing open import Cubical.Algebra.Ring open import Cubical.Algebra.RingSolver.RawAlgebra renaming (⟨_⟩ to ⟨_⟩ᵣ) open import Cubical.Algebra.RingSolver.AlgebraExpression public open import Cubical.Algebra.RingSolver.CommRingHornerForms open import Cubical.Algebra.RingSolver.CommRingEvalHom private variable ℓ : Level module EqualityToNormalform (R : CommRing {ℓ}) where νR = CommRing→RawℤAlgebra R open CommRingStr (snd R) open Theory (CommRing→Ring R) open Eval ℤAsRawRing νR open IteratedHornerOperations νR open HomomorphismProperties R ℤExpr : (n : ℕ) → Type _ ℤExpr = Expr ℤAsRawRing (fst R) normalize : (n : ℕ) → ℤExpr n → IteratedHornerForms νR n normalize n (K r) = Constant n νR r normalize n (∣ k) = Variable n νR k normalize n (x +' y) = (normalize n x) +ₕ (normalize n y) normalize n (x ·' y) = (normalize n x) ·ₕ (normalize n y) normalize n (-' x) = -ₕ (normalize n x) isEqualToNormalform : (n : ℕ) (e : ℤExpr n) (xs : Vec (fst R) n) → eval n (normalize n e) xs ≡ ⟦ e ⟧ xs isEqualToNormalform ℕ.zero (K r) [] = refl isEqualToNormalform (ℕ.suc n) (K r) (x ∷ xs) = eval (ℕ.suc n) (Constant (ℕ.suc n) νR r) (x ∷ xs) ≡⟨ refl ⟩ eval (ℕ.suc n) (0ₕ ·X+ Constant n νR r) (x ∷ xs) ≡⟨ combineCasesEval 0ₕ (Constant n νR r) x xs ⟩ eval (ℕ.suc n) 0ₕ (x ∷ xs) · x + eval n (Constant n νR r) xs ≡⟨ cong (λ u → u · x + eval n (Constant n νR r) xs) (Eval0H _ (x ∷ xs)) ⟩ 0r · x + eval n (Constant n νR r) xs ≡⟨ cong (λ u → u + eval n (Constant n νR r) xs) (0LeftAnnihilates _) ⟩ 0r + eval n (Constant n νR r) xs ≡⟨ +Lid _ ⟩ eval n (Constant n νR r) xs ≡⟨ isEqualToNormalform n (K r) xs ⟩ _ ∎ isEqualToNormalform (ℕ.suc n) (∣ zero) (x ∷ xs) = eval (ℕ.suc n) (1ₕ ·X+ 0ₕ) (x ∷ xs) ≡⟨ refl ⟩ eval (ℕ.suc n) 1ₕ (x ∷ xs) · x + eval n 0ₕ xs ≡⟨ cong (λ u → u · x + eval n 0ₕ xs) (Eval1ₕ _ (x ∷ xs)) ⟩ 1r · x + eval n 0ₕ xs ≡⟨ cong (λ u → 1r · x + u ) (Eval0H _ xs) ⟩ 1r · x + 0r ≡⟨ +Rid _ ⟩ 1r · x ≡⟨ ·Lid _ ⟩ x ∎ isEqualToNormalform (ℕ.suc n) (∣ (suc k)) (x ∷ xs) = eval (ℕ.suc n) (0ₕ ·X+ Variable n νR k) (x ∷ xs) ≡⟨ combineCasesEval 0ₕ (Variable n νR k) x xs ⟩ eval (ℕ.suc n) 0ₕ (x ∷ xs) · x + eval n (Variable n νR k) xs ≡⟨ cong (λ u → u · x + eval n (Variable n νR k) xs) (Eval0H _ (x ∷ xs)) ⟩ 0r · x + eval n (Variable n νR k) xs ≡⟨ cong (λ u → u + eval n (Variable n νR k) xs) (0LeftAnnihilates _) ⟩ 0r + eval n (Variable n νR k) xs ≡⟨ +Lid _ ⟩ eval n (Variable n νR k) xs ≡⟨ isEqualToNormalform n (∣ k) xs ⟩ ⟦ ∣ (suc k) ⟧ (x ∷ xs) ∎ isEqualToNormalform ℕ.zero (-' e) [] = eval ℕ.zero (-ₕ (normalize ℕ.zero e)) [] ≡⟨ -EvalDist ℕ.zero (normalize ℕ.zero e) [] ⟩ - eval ℕ.zero (normalize ℕ.zero e) [] ≡⟨ cong -_ (isEqualToNormalform ℕ.zero e [] ) ⟩ - ⟦ e ⟧ [] ∎ isEqualToNormalform (ℕ.suc n) (-' e) (x ∷ xs) = eval (ℕ.suc n) (-ₕ (normalize (ℕ.suc n) e)) (x ∷ xs) ≡⟨ -EvalDist (ℕ.suc n) (normalize (ℕ.suc n) e) (x ∷ xs) ⟩ - eval (ℕ.suc n) (normalize (ℕ.suc n) e) (x ∷ xs) ≡⟨ cong -_ (isEqualToNormalform (ℕ.suc n) e (x ∷ xs) ) ⟩ - ⟦ e ⟧ (x ∷ xs) ∎ isEqualToNormalform ℕ.zero (e +' e₁) [] = eval ℕ.zero (normalize ℕ.zero e +ₕ normalize ℕ.zero e₁) [] ≡⟨ +Homeval ℕ.zero (normalize ℕ.zero e) _ [] ⟩ eval ℕ.zero (normalize ℕ.zero e) [] + eval ℕ.zero (normalize ℕ.zero e₁) [] ≡⟨ cong (λ u → u + eval ℕ.zero (normalize ℕ.zero e₁) []) (isEqualToNormalform ℕ.zero e []) ⟩ ⟦ e ⟧ [] + eval ℕ.zero (normalize ℕ.zero e₁) [] ≡⟨ cong (λ u → ⟦ e ⟧ [] + u) (isEqualToNormalform ℕ.zero e₁ []) ⟩ ⟦ e ⟧ [] + ⟦ e₁ ⟧ [] ∎ isEqualToNormalform (ℕ.suc n) (e +' e₁) (x ∷ xs) = eval (ℕ.suc n) (normalize (ℕ.suc n) e +ₕ normalize (ℕ.suc n) e₁) (x ∷ xs) ≡⟨ +Homeval (ℕ.suc n) (normalize (ℕ.suc n) e) _ (x ∷ xs) ⟩ eval (ℕ.suc n) (normalize (ℕ.suc n) e) (x ∷ xs) + eval (ℕ.suc n) (normalize (ℕ.suc n) e₁) (x ∷ xs) ≡⟨ cong (λ u → u + eval (ℕ.suc n) (normalize (ℕ.suc n) e₁) (x ∷ xs)) (isEqualToNormalform (ℕ.suc n) e (x ∷ xs)) ⟩ ⟦ e ⟧ (x ∷ xs) + eval (ℕ.suc n) (normalize (ℕ.suc n) e₁) (x ∷ xs) ≡⟨ cong (λ u → ⟦ e ⟧ (x ∷ xs) + u) (isEqualToNormalform (ℕ.suc n) e₁ (x ∷ xs)) ⟩ ⟦ e ⟧ (x ∷ xs) + ⟦ e₁ ⟧ (x ∷ xs) ∎ isEqualToNormalform ℕ.zero (e ·' e₁) [] = eval ℕ.zero (normalize ℕ.zero e ·ₕ normalize ℕ.zero e₁) [] ≡⟨ ·Homeval ℕ.zero (normalize ℕ.zero e) _ [] ⟩ eval ℕ.zero (normalize ℕ.zero e) [] · eval ℕ.zero (normalize ℕ.zero e₁) [] ≡⟨ cong (λ u → u · eval ℕ.zero (normalize ℕ.zero e₁) []) (isEqualToNormalform ℕ.zero e []) ⟩ ⟦ e ⟧ [] · eval ℕ.zero (normalize ℕ.zero e₁) [] ≡⟨ cong (λ u → ⟦ e ⟧ [] · u) (isEqualToNormalform ℕ.zero e₁ []) ⟩ ⟦ e ⟧ [] · ⟦ e₁ ⟧ [] ∎ isEqualToNormalform (ℕ.suc n) (e ·' e₁) (x ∷ xs) = eval (ℕ.suc n) (normalize (ℕ.suc n) e ·ₕ normalize (ℕ.suc n) e₁) (x ∷ xs) ≡⟨ ·Homeval (ℕ.suc n) (normalize (ℕ.suc n) e) _ (x ∷ xs) ⟩ eval (ℕ.suc n) (normalize (ℕ.suc n) e) (x ∷ xs) · eval (ℕ.suc n) (normalize (ℕ.suc n) e₁) (x ∷ xs) ≡⟨ cong (λ u → u · eval (ℕ.suc n) (normalize (ℕ.suc n) e₁) (x ∷ xs)) (isEqualToNormalform (ℕ.suc n) e (x ∷ xs)) ⟩ ⟦ e ⟧ (x ∷ xs) · eval (ℕ.suc n) (normalize (ℕ.suc n) e₁) (x ∷ xs) ≡⟨ cong (λ u → ⟦ e ⟧ (x ∷ xs) · u) (isEqualToNormalform (ℕ.suc n) e₁ (x ∷ xs)) ⟩ ⟦ e ⟧ (x ∷ xs) · ⟦ e₁ ⟧ (x ∷ xs) ∎ solve : {n : ℕ} (e₁ e₂ : ℤExpr n) (xs : Vec (fst R) n) (p : eval n (normalize n e₁) xs ≡ eval n (normalize n e₂) xs) → ⟦ e₁ ⟧ xs ≡ ⟦ e₂ ⟧ xs solve e₁ e₂ xs p = ⟦ e₁ ⟧ xs ≡⟨ sym (isEqualToNormalform _ e₁ xs) ⟩ eval _ (normalize _ e₁) xs ≡⟨ p ⟩ eval _ (normalize _ e₂) xs ≡⟨ isEqualToNormalform _ e₂ xs ⟩ ⟦ e₂ ⟧ xs ∎ ℤExpr : (R : CommRing {ℓ}) (n : ℕ) → _ ℤExpr R n = EqualityToNormalform.ℤExpr R n solve : (R : CommRing {ℓ}) {n : ℕ} (e₁ e₂ : ℤExpr R n) (xs : Vec (fst R) n) (p : eval n (EqualityToNormalform.normalize R n e₁) xs ≡ eval n (EqualityToNormalform.normalize R n e₂) xs) → _ solve R = EqualityToNormalform.solve R module VarNames3 (R : CommRing {ℓ}) where X1 : ℤExpr R 3 X1 = ∣ Fin.zero X2 : ℤExpr R 3 X2 = ∣ (suc Fin.zero) X3 : ℤExpr R 3 X3 = ∣ (suc (suc Fin.zero)) module VarNames4 (R : CommRing {ℓ}) where X1 : ℤExpr R 4 X1 = ∣ Fin.zero X2 : ℤExpr R 4 X2 = ∣ (suc Fin.zero) X3 : ℤExpr R 4 X3 = ∣ (suc (suc Fin.zero)) X4 : ℤExpr R 4 X4 = ∣ (suc (suc (suc Fin.zero))) module VarNames5 (R : CommRing {ℓ}) where X1 : ℤExpr R 5 X1 = ∣ Fin.zero X2 : ℤExpr R 5 X2 = ∣ (suc Fin.zero) X3 : ℤExpr R 5 X3 = ∣ (suc (suc Fin.zero)) X4 : ℤExpr R 5 X4 = ∣ (suc (suc (suc Fin.zero))) X5 : ℤExpr R 5 X5 = ∣ (suc (suc (suc (suc Fin.zero)))) module VarNames6 (R : CommRing {ℓ}) where X1 : ℤExpr R 6 X1 = ∣ Fin.zero X2 : ℤExpr R 6 X2 = ∣ (suc Fin.zero) X3 : ℤExpr R 6 X3 = ∣ (suc (suc Fin.zero)) X4 : ℤExpr R 6 X4 = ∣ (suc (suc (suc Fin.zero))) X5 : ℤExpr R 6 X5 = ∣ (suc (suc (suc (suc Fin.zero)))) X6 : ℤExpr R 6 X6 = ∣ (suc (suc (suc (suc (suc Fin.zero)))))
{ "alphanum_fraction": 0.484548105, "avg_line_length": 38.6261261261, "ext": "agda", "hexsha": "1f5b611117c6518dd1209063f83597cae46c9e1f", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "dan-iel-lee/cubical", "max_forks_repo_path": "Cubical/Algebra/RingSolver/CommRingSolver.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "dan-iel-lee/cubical", "max_issues_repo_path": "Cubical/Algebra/RingSolver/CommRingSolver.agda", "max_line_length": 115, "max_stars_count": null, "max_stars_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "dan-iel-lee/cubical", "max_stars_repo_path": "Cubical/Algebra/RingSolver/CommRingSolver.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 3354, "size": 8575 }
{-# OPTIONS --without-K --rewriting #-} open import HoTT open import cohomology.Theory open import cohomology.PtdMapSequence open import groups.ExactSequence open import groups.Exactness open import groups.HomSequence open import cw.CW module cw.cohomology.FirstCohomologyGroupOnDiag {i} (OT : OrdinaryTheory i) (⊙skel : ⊙Skeleton {i} 1) (ac : ⊙has-cells-with-choice 0 ⊙skel i) where open OrdinaryTheory OT open import cw.cohomology.TipCoboundary OT ⊙skel open import cw.cohomology.TipGrid OT ⊙skel ac open import cw.cohomology.WedgeOfCells OT {- Coker ≃ C(X₁) = C(X) ^ | | C(X₁/X₀) WoC WoC := Wedges of Cells -} open import groups.KernelImage {K = Lift-group {j = i} Unit-group} cst-hom cw-co∂-head CX₁/X₀-is-abelian open import groups.KernelCstImage (Lift-group {j = i} Unit-group) cw-co∂-head CX₁/X₀-is-abelian C-cw-iso-ker/im : C 1 ⊙⟦ ⊙skel ⟧ ≃ᴳ Ker/Im C-cw-iso-ker/im = Ker-cst-quot-Im ⁻¹ᴳ ∘eᴳ Coker-cw-co∂-head ⁻¹ᴳ where
{ "alphanum_fraction": 0.6785361029, "avg_line_length": 28.0833333333, "ext": "agda", "hexsha": "a327b3f45a0309cae7645d7834e1b78fc30bc438", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2018-12-26T21:31:57.000Z", "max_forks_repo_forks_event_min_datetime": "2018-12-26T21:31:57.000Z", "max_forks_repo_head_hexsha": "e7d663b63d89f380ab772ecb8d51c38c26952dbb", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "mikeshulman/HoTT-Agda", "max_forks_repo_path": "theorems/cw/cohomology/FirstCohomologyGroupOnDiag.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "e7d663b63d89f380ab772ecb8d51c38c26952dbb", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "mikeshulman/HoTT-Agda", "max_issues_repo_path": "theorems/cw/cohomology/FirstCohomologyGroupOnDiag.agda", "max_line_length": 104, "max_stars_count": null, "max_stars_repo_head_hexsha": "e7d663b63d89f380ab772ecb8d51c38c26952dbb", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "mikeshulman/HoTT-Agda", "max_stars_repo_path": "theorems/cw/cohomology/FirstCohomologyGroupOnDiag.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 365, "size": 1011 }
-------------------------------------------------------------------------------- -- This file provides functions for escaping -------------------------------------------------------------------------------- module Parse.Escape where open import Class.Map open import Data.SimpleMap open import Data.String using (fromList; toList) open import Prelude open import Prelude.Strings private translationTable : SimpleMap String Char translationTable = ("newline" , '\n') ∷ ("space" , ' ') ∷ ("ast" , '*') ∷ ("sq" , '□') ∷ ("lparen" , '(') ∷ ("rparen" , ')') ∷ ("lbrace" , '{') ∷ ("rbrace" , '}') ∷ ("lsquare" , '[') ∷ ("rsquare" , ']') ∷ ("langle" , '<') ∷ ("rangle" , '>') ∷ ("equal" , '=') ∷ ("dot" , '.') ∷ ("comma" , ',') ∷ ("colon" , ':') ∷ ("semicolon" , ';') ∷ ("question" , '?') ∷ ("exclamation" , '!') ∷ ("at" , '@') ∷ ("doublequote" , '"') ∷ ("ampersand" , '&') ∷ ("backslash" , '\\') ∷ ("slash" , '/') ∷ ("pipe" , '|') ∷ ("circumflex" , '^') ∷ ("underscore" , '_') ∷ ("dollar" , '$') ∷ ("minus" , '-') ∷ ("forall" , '∀') ∷ ("exists" , '∃') ∷ ("alpha" , 'α') ∷ ("beta" , 'β') ∷ ("gamma" , 'γ') ∷ ("delta" , 'δ') ∷ ("epsilon" , 'ε') ∷ ("zeta" , 'ζ') ∷ ("eta" , 'η') ∷ ("theta" , 'θ') ∷ ("iota" , 'ι') ∷ ("kappa" , 'κ') ∷ ("lambda" , 'λ') ∷ ("mu" , 'μ') ∷ ("nu" , 'ν') ∷ ("xi" , 'ξ') ∷ ("omicron" , 'ο') ∷ ("pi" , 'π') ∷ ("rho" , 'ρ') ∷ ("varsigma" , 'ς') ∷ ("sigma" , 'σ') ∷ ("tau" , 'τ') ∷ ("upsilon" , 'υ') ∷ ("phi" , 'φ') ∷ ("chi" , 'χ') ∷ ("psi" , 'ψ') ∷ ("omega" , 'ω') ∷ ("Alpha" , 'Α') ∷ ("Beta" , 'Β') ∷ ("Gamma" , 'Γ') ∷ ("Delta" , 'Δ') ∷ ("Epsilon" , 'Ε') ∷ ("Zeta" , 'Ζ') ∷ ("Eta" , 'Η') ∷ ("Theta" , 'Θ') ∷ ("Iota" , 'Ι') ∷ ("Kappa" , 'Κ') ∷ ("Lambda" , 'Λ') ∷ ("Mu" , 'Μ') ∷ ("Nu" , 'Ν') ∷ ("Xi" , 'Ξ') ∷ ("Omicron" , 'Ο') ∷ ("Pi" , 'Π') ∷ ("Rho" , 'Ρ') ∷ ("Varsigma" , 'Σ') ∷ ("Sigma" , 'Σ') ∷ ("Tau" , 'Τ') ∷ ("Upsilon" , 'Υ') ∷ ("Phi" , 'Φ') ∷ ("Chi" , 'Χ') ∷ ("Psi" , 'Ψ') ∷ ("Omega" , 'Ω') ∷ [] escapeTable : SimpleMap Char String escapeTable = map swap translationTable isSpecialChar : Char → Bool isSpecialChar c = c ≣ '$' ∨ c ≣ '_' ∨ c ≣ '!' ∨ c ≣ '@' ∨ c ≣ '&' ∨ c ≣ '^' -- accepts the head and tail of a string and returns the head of the full string without escape symbols unescape : Char → String → Char unescape c r = if ⌊ c ≟ '\\' ⌋ then (case strHead r of λ { nothing → c ; (just x) → x }) else c groupEscaped : List Char → List (List Char) groupEscaped = helper false where helper : Bool → List Char → List (List Char) helper b [] = [] helper false (x ∷ l) = if ⌊ x ≟ '\\' ⌋ then helper true l else [ x ] ∷ helper false l helper true (x ∷ l) = ('\\' ∷ [ x ]) ∷ helper false l translate : List Char → Maybe (List Char) translate = helper ∘ splitMulti '=' where helper : List (List Char) → Maybe (List Char) helper [] = just [] helper (l ∷ []) = just l helper (l ∷ l₁ ∷ l₂) = do l' ← lookup (fromList l₁) translationTable l'' ← helper l₂ return $ l + (if isSpecialChar l' then '\\' ∷ [ l' ] else [ l' ]) + l'' escapeChar : Char → List Char escapeChar c = maybe (λ s → "=" ++ toList s ++ "=") [ c ] $ lookup c escapeTable ruleToConstr : String → String ruleToConstr = fromList ∘ concat ∘ helper ∘ groupEscaped ∘ toList where helper : List (List Char) → List (List Char) helper [] = [] helper (l ∷ l₁) = (case l of λ where (c ∷ []) → if isSpecialChar c then [ c ] else escapeChar c ('\\' ∷ c ∷ []) → if isSpecialChar c then escapeChar c else l _ → l) ∷ (helper l₁)
{ "alphanum_fraction": 0.4494039368, "avg_line_length": 44.5308641975, "ext": "agda", "hexsha": "639cac68e50609c1c75bd6cf805df8d66c32cb1a", "lang": "Agda", "max_forks_count": 2, "max_forks_repo_forks_event_max_datetime": "2021-10-20T10:46:20.000Z", "max_forks_repo_forks_event_min_datetime": "2019-06-27T23:12:48.000Z", "max_forks_repo_head_hexsha": "62fa6f36e4555360d94041113749bbb6d291691c", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "WhatisRT/meta-cedille", "max_forks_repo_path": "src/Parse/Escape.agda", "max_issues_count": 10, "max_issues_repo_head_hexsha": "62fa6f36e4555360d94041113749bbb6d291691c", "max_issues_repo_issues_event_max_datetime": "2020-04-25T15:29:17.000Z", "max_issues_repo_issues_event_min_datetime": "2019-06-13T17:44:43.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "WhatisRT/meta-cedille", "max_issues_repo_path": "src/Parse/Escape.agda", "max_line_length": 106, "max_stars_count": 35, "max_stars_repo_head_hexsha": "62fa6f36e4555360d94041113749bbb6d291691c", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "WhatisRT/meta-cedille", "max_stars_repo_path": "src/Parse/Escape.agda", "max_stars_repo_stars_event_max_datetime": "2021-10-12T22:59:10.000Z", "max_stars_repo_stars_event_min_datetime": "2019-06-13T07:44:50.000Z", "num_tokens": 1385, "size": 3607 }
{-# OPTIONS --without-K --safe #-} module Categories.Category.Indiscrete where -- Category where all arrows are inhabited by a single element open import Level open import Data.Unit open import Categories.Category open import Relation.Binary.PropositionalEquality as ≡ Indiscrete : ∀ {o ℓ} (A : Set o) → Category o ℓ ℓ Indiscrete {_} {ℓ} A = record { Obj = A ; _⇒_ = λ _ _ → Lift ℓ ⊤ ; _≈_ = _≡_ ; id = _ ; _∘_ = _ ; assoc = refl ; sym-assoc = refl ; identityˡ = refl ; identityʳ = refl ; identity² = refl ; equiv = isEquivalence ; ∘-resp-≈ = λ where refl refl → refl }
{ "alphanum_fraction": 0.600931677, "avg_line_length": 23, "ext": "agda", "hexsha": "cdcdb98005cc4d80fabc12ce4cc6000e0eca5b91", "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/Indiscrete.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/Indiscrete.agda", "max_line_length": 62, "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/Indiscrete.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": 214, "size": 644 }
{-# OPTIONS --copatterns #-} -- {-# OPTIONS -v term:20 #-} -- {-# OPTIONS --no-positivity-check #-} -- {-# OPTIONS -v tc.def.fun:50 #-} module CopatternNonterminating where open import Common.Equality record Stream (A : Set) : Set where coinductive field head : A tail : Stream A module S = Stream illdefined : {A : Set} -> Stream A S.head illdefined = S.head illdefined S.tail illdefined = S.tail illdefined -- should not termination-check {- illRepeat : {A : Set}(a : A) → Stream A ( (S.head (illRepeat a))) = a (S.head (S.tail (illRepeat a))) = a (S.tail (S.tail (illRepeat a))) = S.tail (S.tail (illRepeat a)) -} {- -- deep copattern matches are not yet translated into something -- that termination checks illRepeat : {A : Set}(a : A) → Stream A ( (S.head (illRepeat a))) = a (S.head (S.tail (illRepeat a))) = a (S.tail (S.tail (illRepeat a))) = (S.tail (illRepeat a)) record _≈_ {A : Set}(s t : Stream A) : Set where field head : S.head s ≡ S.head t tail : S.tail s ≈ S.tail t module B = _≈_ repeat : {A : Set}(a : A) → Stream A S.head (repeat a) = a S.tail (repeat a) = repeat a -- THIS SHOULD NOT TERMINATION CHECK WITH CURRENT TRANSLATION SEMANTICS -- OF COPATTERNS repeat′ : {A : Set}(a : A) → Stream A ( (S.head (repeat′ a))) = a (S.head (S.tail (repeat′ a))) = a (S.tail (S.tail (repeat′ a))) = S.tail (repeat′ a) -- invalid projection repeat≈repeat′ : {A : Set}(a : A) → repeat a ≈ repeat′ a ( (B.head (repeat≈repeat′ a))) = refl (B.head (B.tail (repeat≈repeat′ a))) = refl (B.tail (B.tail (repeat≈repeat′ a))) = repeat≈repeat′ a -}
{ "alphanum_fraction": 0.61360799, "avg_line_length": 27.6206896552, "ext": "agda", "hexsha": "9ba95cbe6d6ec78ee079704c602c189bd993f128", "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/Fail/CopatternNonterminating.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/Fail/CopatternNonterminating.agda", "max_line_length": 72, "max_stars_count": 3, "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/CopatternNonterminating.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": 528, "size": 1602 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Properties of functions, such as associativity and commutativity ------------------------------------------------------------------------ -- This file contains some core definitions which are reexported by -- Algebra.FunctionProperties. They are placed here because -- Algebra.FunctionProperties is a parameterised module, and some of -- the parameters are irrelevant for these definitions. {-# OPTIONS --without-K --safe #-} module Algebra.FunctionProperties.Core where open import Level ------------------------------------------------------------------------ -- Unary and binary operations Op₁ : ∀ {ℓ} → Set ℓ → Set ℓ Op₁ A = A → A Op₂ : ∀ {ℓ} → Set ℓ → Set ℓ Op₂ A = A → A → A
{ "alphanum_fraction": 0.5251256281, "avg_line_length": 30.6153846154, "ext": "agda", "hexsha": "cccfe99c4523f6afd5af4796c602660993b4c84a", "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/Algebra/FunctionProperties/Core.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/Algebra/FunctionProperties/Core.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/Algebra/FunctionProperties/Core.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 153, "size": 796 }
------------------------------------------------------------------------ -- An alternative (non-standard) coinductive definition of weak -- bisimilarity ------------------------------------------------------------------------ -- This definition is based on the function "wb" in Section 6.5.1 of -- Pous and Sangiorgi's "Enhancements of the bisimulation proof -- method". {-# OPTIONS --sized-types #-} open import Labelled-transition-system module Bisimilarity.Weak.Alternative {ℓ} (lts : LTS ℓ) where open import Prelude import Bisimilarity import Bisimilarity.Equational-reasoning-instances open import Equational-reasoning open LTS lts -- We get weak bisimilarity by instantiating strong bisimilarity with -- a different LTS. private module WB = Bisimilarity (weak lts) open WB public using ( ⟨_,_⟩ ; [_]_≡_ ; [_]_≡′_ ; Extensionality ; force ; left-to-right ; right-to-left ) renaming ( _∼_ to _≈_ ; _∼′_ to _≈′_ ; [_]_∼_ to [_]_≈_ ; [_]_∼′_ to [_]_≈′_ ; _⟶⟨_⟩ʳˡ_ to _⇒⟨_⟩ʳˡ_ ; _[_]⟶⟨_⟩ʳˡ_ to _[_]⇒⟨_⟩ʳˡ_ ) infix -3 lr-result-with-action lr-result-without-action lr-result-without-action = WB.lr-result-without-action lr-result-with-action = WB.lr-result-with-action syntax lr-result-without-action p′≈q′ q q⟶q′ = p′≈q′ ⇐⟨ q⟶q′ ⟩ q syntax lr-result-with-action p′≈q′ μ q q⟶q′ = p′≈q′ [ μ ]⇐⟨ q⟶q′ ⟩ q -- Strongly bisimilar processes are weakly bisimilar. private module SB = Bisimilarity lts open SB using (_∼_; _∼′_; [_]_∼_; [_]_∼′_; force) mutual ∼⇒≈ : ∀ {i p q} → p ∼ q → [ i ] p ≈ q ∼⇒≈ {i} = λ p∼q → ⟨ lr p∼q , Σ-map id (Σ-map id symmetric) ∘ lr (symmetric p∼q) ⟩ where lr : ∀ {p p′ q μ} → p ∼ q → p [ μ ]⇒̂ p′ → ∃ λ q′ → q [ μ ]⇒̂ q′ × [ i ] p′ ≈′ q′ lr p∼q p⇒̂p′ = Σ-map id (Σ-map id ∼⇒≈′) (SB.strong-is-weak⇒̂ p∼q p⇒̂p′) ∼⇒≈′ : ∀ {i p q} → p ∼ q → [ i ] p ≈′ q force (∼⇒≈′ p∼q) = ∼⇒≈ p∼q ∼⇒≈″ : ∀ {p q} → p ∼′ q → p ≈′ q force (∼⇒≈″ p∼′q) = ∼⇒≈ (force p∼′q) -- TODO: I suspect that the size isn't necessarily preserved: A weak -- proof of a given size might require a strong proof which is much -- larger, because a single weak transition might correspond to a -- large number of strong transitions. I guess this has to be proved -- for a particular LTS, or with certain assumptions about the LTS.
{ "alphanum_fraction": 0.5431596091, "avg_line_length": 28.2298850575, "ext": "agda", "hexsha": "daa9f492d26620265b42d22959eabb1ba2e454c0", "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/Weak/Alternative.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/Weak/Alternative.agda", "max_line_length": 72, "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/Weak/Alternative.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 922, "size": 2456 }
------------------------------------------------------------------------ -- A breadth-first backend which uses the derivative operator ------------------------------------------------------------------------ module TotalParserCombinators.BreadthFirst where open import Data.List open import Data.List.Membership.Propositional open import Data.Product open import Function.Base open import Function.Equality using (_⟨$⟩_) open import Function.Inverse using (_↔_; module Inverse) open import Relation.Binary.HeterogeneousEquality as H using () renaming (_≅_ to _≅H_) open import Relation.Binary.PropositionalEquality as P using (_≡_) open import TotalParserCombinators.Congruence using (_≅P_; _∎) import TotalParserCombinators.Congruence.Sound as CS open import TotalParserCombinators.Derivative as D using (D) import TotalParserCombinators.InitialBag as I open import TotalParserCombinators.Parser open import TotalParserCombinators.Semantics open import TotalParserCombinators.Simplification as S using (simplify) ------------------------------------------------------------------------ -- A parametrised backend -- The function f is applied before the derivative. module Parse {Tok} (f : ∀ {R xs} → Parser Tok R xs → ∃ λ xs′ → Parser Tok R xs′) (f-correct : ∀ {R xs} (p : Parser Tok R xs) → proj₂ (f p) ≅P p) where -- The parsing function. parse : ∀ {R xs} → Parser Tok R xs → List Tok → List R parse {xs = xs} p [] = xs parse p (t ∷ s) = parse (D t $ proj₂ $ f p) s -- A variant of f-correct. f-correct′ : ∀ {R xs} (p : Parser Tok R xs) → proj₂ (f p) ≅ p f-correct′ = CS.sound ∘ f-correct -- The backend is sound with respect to the semantics. sound : ∀ {R xs x} {p : Parser Tok R xs} (s : List Tok) → x ∈ parse p s → x ∈ p · s sound [] x∈p = I.sound _ x∈p sound (t ∷ s) x∈p = Inverse.to (f-correct′ _) ⟨$⟩ D.sound _ (sound s x∈p) -- The backend is complete with respect to the semantics. complete : ∀ {R xs x} {p : Parser Tok R xs} (s : List Tok) → x ∈ p · s → x ∈ parse p s complete [] x∈p = I.complete x∈p complete (t ∷ s) x∈p = complete s $ D.complete $ Inverse.from (f-correct′ _) ⟨$⟩ x∈p -- The backend does not introduce any unneeded ambiguity. -- -- The proof complete is a left inverse of sound, so the (finite) type -- x ∈ parse p s contains at most as many proofs as x ∈ p · s. In -- other words, the output of parse p s can only contain n copies of x -- if there are at least n distinct parse trees in x ∈ p · s. complete∘sound : ∀ {R xs x} s (p : Parser Tok R xs) (x∈p : x ∈ parse p s) → complete s (sound s x∈p) ≡ x∈p complete∘sound [] p x∈p = I.complete∘sound p x∈p complete∘sound (t ∷ s) p x∈p rewrite Inverse.left-inverse-of (f-correct′ p) (D.sound (proj₂ (f p)) (sound s x∈p)) | D.complete∘sound (proj₂ (f p)) (sound s x∈p) = complete∘sound s (D t $ proj₂ $ f p) x∈p -- The backend does not remove any ambiguity. -- -- The proof complete is a right inverse of sound, which implies that -- the (finite) type x ∈ parse p s contains at least as many proofs as -- x ∈ p · s. In other words, if the output of parse p s contains n -- copies of x, then there are at most n distinct parse trees in -- x ∈ p · s. sound∘complete : ∀ {R xs x} {p : Parser Tok R xs} (s : List Tok) (x∈p : x ∈ p · s) → sound s (complete s x∈p) ≡ x∈p sound∘complete [] x∈p = I.sound∘complete x∈p sound∘complete (t ∷ s) x∈p rewrite sound∘complete s $ D.complete $ Inverse.from (f-correct′ _) ⟨$⟩ x∈p | D.sound∘complete $ Inverse.from (f-correct′ _) ⟨$⟩ x∈p = Inverse.right-inverse-of (f-correct′ _) x∈p -- The backend is correct. correct : ∀ {R xs x s} {p : Parser Tok R xs} → x ∈ p · s ↔ x ∈ parse p s correct {s = s} {p} = record { to = P.→-to-⟶ $ complete s ; from = P.→-to-⟶ $ sound s ; inverse-of = record { left-inverse-of = sound∘complete s ; right-inverse-of = complete∘sound s p } } ------------------------------------------------------------------------ -- Specific instantiations -- Parsing without simplification. parse : ∀ {Tok R xs} → Parser Tok R xs → List Tok → List R parse = Parse.parse -,_ _∎ parse-correct : ∀ {Tok R xs x s} {p : Parser Tok R xs} → x ∈ p · s ↔ x ∈ parse p s parse-correct = Parse.correct -,_ _∎ -- Parsing with simplification. parse-with-simplification : ∀ {Tok R xs} → Parser Tok R xs → List Tok → List R parse-with-simplification = Parse.parse (λ p → -, simplify p) S.correct parse-with-simplification-correct : ∀ {Tok R xs x s} {p : Parser Tok R xs} → x ∈ p · s ↔ x ∈ parse-with-simplification p s parse-with-simplification-correct = Parse.correct _ S.correct ------------------------------------------------------------------------ -- An observation -- The worst-case complexity of parse (without simplification) is /at -- least/ exponential in the size of the input string. There is a -- (finite) parser p whose derivative is p ∣ p (for any token). The -- n-th derivative thus contains (at least) 2^n outermost occurrences -- of _∣_, and these occurrences have to be traversed to compute the -- initial bag of the n-th derivative. parse-inefficient : ∀ {Tok R} → ∃ λ (p : Parser Tok R []) → ∀ t → D t p ≅H p ∣ p parse-inefficient {R = R} = (fail {R = R} >>= (λ _ → fail) , λ t → H.refl)
{ "alphanum_fraction": 0.5832881172, "avg_line_length": 37.3581081081, "ext": "agda", "hexsha": "8c5cd22bd7a3011aa2e88929e0b929db66417395", "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": "76774f54f466cfe943debf2da731074fe0c33644", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "nad/parser-combinators", "max_forks_repo_path": "TotalParserCombinators/BreadthFirst.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "76774f54f466cfe943debf2da731074fe0c33644", "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/parser-combinators", "max_issues_repo_path": "TotalParserCombinators/BreadthFirst.agda", "max_line_length": 72, "max_stars_count": 1, "max_stars_repo_head_hexsha": "76774f54f466cfe943debf2da731074fe0c33644", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "nad/parser-combinators", "max_stars_repo_path": "TotalParserCombinators/BreadthFirst.agda", "max_stars_repo_stars_event_max_datetime": "2020-07-03T08:56:13.000Z", "max_stars_repo_stars_event_min_datetime": "2020-07-03T08:56:13.000Z", "num_tokens": 1689, "size": 5529 }
-- Duplicate of #1984 postulate Path : {A : Set} → A → Set admit : {Z : Set} → Z X : Set Y : X → Set Y' : X → Set record Square : Set₁ where field A : Set B : Set b : B coh : Path b -- Spurious mutual block to trigger the problem mut : Set record Cocone : Set where field x : X -- x : Cocone → X -- x (mkCocone x) = x postulate m n : Cocone fung : (c : Cocone) → Y' (Cocone.x c) → Path c record CoconeDep (P : X → Set) : Set where inductive field x' : P (Cocone.x m) s : Square s .Square.A = CoconeDep Y s .Square.B = Cocone s .Square.b = n s .Square.coh = fung _ (admit {Y' (Cocone.x (s .Square.b))}) mut = X
{ "alphanum_fraction": 0.5654135338, "avg_line_length": 15.4651162791, "ext": "agda", "hexsha": "0cded02a4ee7d74354387a6d661b40db49dd063b", "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/Bugs/Issue4251.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/Bugs/Issue4251.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/Bugs/Issue4251.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": 256, "size": 665 }
------------------------------------------------------------------------ -- A type for values that should be erased at run-time ------------------------------------------------------------------------ -- The definitions in this module are reexported from Erased. -- This module imports Equivalence.Erased. {-# OPTIONS --without-K --safe #-} open import Equality open import Prelude hiding ([_,_]) module Erased.Level-2 {c⁺} (eq-J : ∀ {a p} → Equality-with-J a p c⁺) where open Derived-definitions-and-properties eq-J open import Logical-equivalence using (_⇔_) open import Bijection eq-J as Bijection using (_↔_; Has-quasi-inverse) open import Embedding eq-J as Emb using (Embedding; Is-embedding) open import Equivalence eq-J as Eq using (_≃_; Is-equivalence) open import Equivalence.Erased eq-J as EEq using (_≃ᴱ_; Is-equivalenceᴱ) open import Function-universe eq-J as F hiding (id; _∘_) open import H-level eq-J as H-level open import H-level.Closure eq-J open import Injection eq-J using (_↣_; Injective) open import Monad eq-J hiding (map; map-id; map-∘) open import Preimage eq-J using (_⁻¹_) open import Surjection eq-J using (_↠_; Split-surjective) open import Erased.Level-1 eq-J as E₁ hiding (module []-cong; module []-cong₂-⊔) private variable a b c ℓ ℓ₁ ℓ₂ ℓ₃ : Level A B : Type a eq k k′ p x y : A P : A → Type p f g : A → B n : ℕ ------------------------------------------------------------------------ -- Results that depend on an instantiation of the []-cong axioms (for -- two universe levels as well as their maximum) module []-cong₂-⊔ (ax₁ : E₁.[]-cong-axiomatisation ℓ₁) (ax₂ : E₁.[]-cong-axiomatisation ℓ₂) (ax : E₁.[]-cong-axiomatisation (ℓ₁ ⊔ ℓ₂)) where open E₁.Erased-cong ax ax open E₁.[]-cong₁ ax₂ open E₁.[]-cong₂ ax₁ ax₂ open E₁.[]-cong₂-⊔ ax₁ ax₂ ax private module EEq′ = EEq.[]-cong₂-⊔ ax₁ ax₂ ax ---------------------------------------------------------------------- -- Erased commutes with all kinds of functions (in some cases -- assuming extensionality) private -- A lemma used below. Erased-≃ᴱ↔≃ᴱ : {@0 A : Type ℓ₁} {@0 B : Type ℓ₂} → Erased (A ≃ᴱ B) ↝[ ℓ₁ ⊔ ℓ₂ ∣ ℓ₁ ⊔ ℓ₂ ]ᴱ (Erased A ≃ᴱ Erased B) Erased-≃ᴱ↔≃ᴱ {A = A} {B = B} ext = Erased (A ≃ᴱ B) ↔⟨ Erased-cong-≃ EEq.≃ᴱ-as-Σ ⟩ Erased (∃ λ (f : A → B) → Is-equivalenceᴱ f) ↔⟨ Erased-Σ↔Σ ⟩ (∃ λ (f : Erased (A → B)) → Erased (Is-equivalenceᴱ (erased f))) ↝⟨ (Σ-cong Erased-Π↔Π-Erased λ _ → EEq′.Erased-Is-equivalenceᴱ↔Is-equivalenceᴱ ext) ⟩ (∃ λ (f : Erased A → Erased B) → Is-equivalenceᴱ f) ↔⟨ inverse EEq.≃ᴱ-as-Σ ⟩□ Erased A ≃ᴱ Erased B □ -- Erased commutes with all kinds of functions (in some cases -- assuming extensionality). Erased-↝↝↝ : {@0 A : Type ℓ₁} {@0 B : Type ℓ₂} → Erased (A ↝[ k ] B) ↝[ ℓ₁ ⊔ ℓ₂ ∣ ℓ₁ ⊔ ℓ₂ ] (Erased A ↝[ k ] Erased B) Erased-↝↝↝ {k = implication} _ = from-isomorphism Erased-Π↔Π-Erased Erased-↝↝↝ {k = logical-equivalence} _ = from-isomorphism Erased-⇔↔⇔ Erased-↝↝↝ {k = injection} {A = A} {B = B} ext = Erased (A ↣ B) ↔⟨ Erased-cong-↔ ↣↔∃-Injective ⟩ Erased (∃ λ (f : A → B) → Injective f) ↔⟨ Erased-Σ↔Σ ⟩ (∃ λ (f : Erased (A → B)) → Erased (Injective (erased f))) ↝⟨ Σ-cong Erased-Π↔Π-Erased (λ _ → Erased-Injective↔Injective ext) ⟩ (∃ λ (f : Erased A → Erased B) → Injective f) ↔⟨ inverse ↣↔∃-Injective ⟩□ Erased A ↣ Erased B □ Erased-↝↝↝ {k = embedding} {A = A} {B = B} ext = Erased (Embedding A B) ↔⟨ Erased-cong-↔ Emb.Embedding-as-Σ ⟩ Erased (∃ λ (f : A → B) → Is-embedding f) ↔⟨ Erased-Σ↔Σ ⟩ (∃ λ (f : Erased (A → B)) → Erased (Is-embedding (erased f))) ↝⟨ Σ-cong Erased-Π↔Π-Erased (λ _ → Erased-Is-embedding↔Is-embedding ext) ⟩ (∃ λ (f : Erased A → Erased B) → Is-embedding f) ↔⟨ inverse Emb.Embedding-as-Σ ⟩□ Embedding (Erased A) (Erased B) □ Erased-↝↝↝ {k = surjection} {A = A} {B = B} {k = k′} ext = Erased (A ↠ B) ↔⟨ Erased-cong-↔ ↠↔∃-Split-surjective ⟩ Erased (∃ λ (f : A → B) → Split-surjective f) ↔⟨ Erased-Σ↔Σ ⟩ (∃ λ (f : Erased (A → B)) → Erased (Split-surjective (erased f))) ↝⟨ Σ-cong Erased-Π↔Π-Erased (λ _ → Erased-Split-surjective↔Split-surjective (lower-extensionality? k′ ℓ₁ lzero ext)) ⟩ (∃ λ (f : Erased A → Erased B) → Split-surjective f) ↔⟨ inverse ↠↔∃-Split-surjective ⟩□ Erased A ↠ Erased B □ Erased-↝↝↝ {k = bijection} {A = A} {B = B} ext = Erased (A ↔ B) ↔⟨ Erased-cong-↔ Bijection.↔-as-Σ ⟩ Erased (∃ λ (f : A → B) → Has-quasi-inverse f) ↔⟨ Erased-Σ↔Σ ⟩ (∃ λ (f : Erased (A → B)) → Erased (Has-quasi-inverse (erased f))) ↝⟨ (Σ-cong Erased-Π↔Π-Erased λ _ → Erased-Has-quasi-inverse↔Has-quasi-inverse ext) ⟩ (∃ λ (f : Erased A → Erased B) → Has-quasi-inverse f) ↔⟨ inverse Bijection.↔-as-Σ ⟩□ Erased A ↔ Erased B □ Erased-↝↝↝ {k = equivalence} {A = A} {B = B} ext = Erased (A ≃ B) ↔⟨ Erased-cong-↔ Eq.≃-as-Σ ⟩ Erased (∃ λ (f : A → B) → Is-equivalence f) ↔⟨ Erased-Σ↔Σ ⟩ (∃ λ (f : Erased (A → B)) → Erased (Is-equivalence (erased f))) ↝⟨ Σ-cong Erased-Π↔Π-Erased (λ _ → Erased-Is-equivalence↔Is-equivalence ext) ⟩ (∃ λ (f : Erased A → Erased B) → Is-equivalence f) ↔⟨ inverse Eq.≃-as-Σ ⟩□ Erased A ≃ Erased B □ Erased-↝↝↝ {k = equivalenceᴱ} ext = Erased-≃ᴱ↔≃ᴱ ext -- Erased commutes with all kinds of functions (in some cases -- assuming extensionality). Erased-↝↔↝ : {@0 A : Type ℓ₁} {@0 B : Type ℓ₂} → Extensionality? k (ℓ₁ ⊔ ℓ₂) (ℓ₁ ⊔ ℓ₂) → Erased (A ↝[ k ] B) ↔ (Erased A ↝[ k ] Erased B) Erased-↝↔↝ {k = implication} = λ _ → Erased-Π↔Π-Erased Erased-↝↔↝ {k = logical-equivalence} = λ _ → Erased-⇔↔⇔ Erased-↝↔↝ {k = injection} = Erased-↝↝↝ Erased-↝↔↝ {k = embedding} = Erased-↝↝↝ Erased-↝↔↝ {k = surjection} = Erased-↝↝↝ Erased-↝↔↝ {k = bijection} = Erased-↝↝↝ Erased-↝↔↝ {k = equivalence} = Erased-↝↝↝ Erased-↝↔↝ {k = equivalenceᴱ} = λ ([ ext ]) → Erased-≃ᴱ↔≃ᴱ ext -- Erased-↝↔↝ and Erased-↝↝↝ produce equal functions. to-Erased-↝↔↝≡to-Erased-↝↝↝ : {@0 A : Type ℓ₁} {@0 B : Type ℓ₂} (ext : Extensionality? k (ℓ₁ ⊔ ℓ₂) (ℓ₁ ⊔ ℓ₂)) (ext′ : Extensionality? k′ (ℓ₁ ⊔ ℓ₂) (ℓ₁ ⊔ ℓ₂)) → _↔_.to (Erased-↝↔↝ {k = k} {A = A} {B = B} ext) ≡ to-implication (Erased-↝↝↝ {k = k} {A = A} {B = B} {k = k′} ext′) to-Erased-↝↔↝≡to-Erased-↝↝↝ {k = implication} {k′ = implication} _ _ = refl _ to-Erased-↝↔↝≡to-Erased-↝↝↝ {k = implication} {k′ = logical-equivalence} _ _ = refl _ to-Erased-↝↔↝≡to-Erased-↝↝↝ {k = implication} {k′ = injection} _ _ = refl _ to-Erased-↝↔↝≡to-Erased-↝↝↝ {k = implication} {k′ = embedding} _ _ = refl _ to-Erased-↝↔↝≡to-Erased-↝↝↝ {k = implication} {k′ = surjection} _ _ = refl _ to-Erased-↝↔↝≡to-Erased-↝↝↝ {k = implication} {k′ = bijection} _ _ = refl _ to-Erased-↝↔↝≡to-Erased-↝↝↝ {k = implication} {k′ = equivalence} _ _ = refl _ to-Erased-↝↔↝≡to-Erased-↝↝↝ {k = implication} {k′ = equivalenceᴱ} _ _ = refl _ to-Erased-↝↔↝≡to-Erased-↝↝↝ {k = logical-equivalence} {k′ = implication} _ _ = refl _ to-Erased-↝↔↝≡to-Erased-↝↝↝ {k = logical-equivalence} {k′ = logical-equivalence} _ _ = refl _ to-Erased-↝↔↝≡to-Erased-↝↝↝ {k = logical-equivalence} {k′ = injection} _ _ = refl _ to-Erased-↝↔↝≡to-Erased-↝↝↝ {k = logical-equivalence} {k′ = embedding} _ _ = refl _ to-Erased-↝↔↝≡to-Erased-↝↝↝ {k = logical-equivalence} {k′ = surjection} _ _ = refl _ to-Erased-↝↔↝≡to-Erased-↝↝↝ {k = logical-equivalence} {k′ = bijection} _ _ = refl _ to-Erased-↝↔↝≡to-Erased-↝↝↝ {k = logical-equivalence} {k′ = equivalence} _ _ = refl _ to-Erased-↝↔↝≡to-Erased-↝↝↝ {k = logical-equivalence} {k′ = equivalenceᴱ} _ _ = refl _ to-Erased-↝↔↝≡to-Erased-↝↝↝ {k = injection} {k′ = implication} _ _ = refl _ to-Erased-↝↔↝≡to-Erased-↝↝↝ {k = injection} {k′ = logical-equivalence} _ _ = refl _ to-Erased-↝↔↝≡to-Erased-↝↝↝ {k = injection} {k′ = injection} _ _ = refl _ to-Erased-↝↔↝≡to-Erased-↝↝↝ {k = injection} {k′ = embedding} _ _ = refl _ to-Erased-↝↔↝≡to-Erased-↝↝↝ {k = injection} {k′ = surjection} _ _ = refl _ to-Erased-↝↔↝≡to-Erased-↝↝↝ {k = injection} {k′ = bijection} _ _ = refl _ to-Erased-↝↔↝≡to-Erased-↝↝↝ {k = injection} {k′ = equivalence} _ _ = refl _ to-Erased-↝↔↝≡to-Erased-↝↝↝ {k = injection} {k′ = equivalenceᴱ} _ _ = refl _ to-Erased-↝↔↝≡to-Erased-↝↝↝ {k = surjection} {k′ = implication} _ _ = refl _ to-Erased-↝↔↝≡to-Erased-↝↝↝ {k = surjection} {k′ = logical-equivalence} _ _ = refl _ to-Erased-↝↔↝≡to-Erased-↝↝↝ {k = surjection} {k′ = injection} _ _ = refl _ to-Erased-↝↔↝≡to-Erased-↝↝↝ {k = surjection} {k′ = embedding} _ _ = refl _ to-Erased-↝↔↝≡to-Erased-↝↝↝ {k = surjection} {k′ = surjection} _ _ = refl _ to-Erased-↝↔↝≡to-Erased-↝↝↝ {k = surjection} {k′ = bijection} _ _ = refl _ to-Erased-↝↔↝≡to-Erased-↝↝↝ {k = surjection} {k′ = equivalence} _ _ = refl _ to-Erased-↝↔↝≡to-Erased-↝↝↝ {k = surjection} {k′ = equivalenceᴱ} _ _ = refl _ to-Erased-↝↔↝≡to-Erased-↝↝↝ {k = bijection} {k′ = implication} _ _ = refl _ to-Erased-↝↔↝≡to-Erased-↝↝↝ {k = bijection} {k′ = logical-equivalence} _ _ = refl _ to-Erased-↝↔↝≡to-Erased-↝↝↝ {k = bijection} {k′ = injection} _ _ = refl _ to-Erased-↝↔↝≡to-Erased-↝↝↝ {k = bijection} {k′ = embedding} _ _ = refl _ to-Erased-↝↔↝≡to-Erased-↝↝↝ {k = bijection} {k′ = surjection} _ _ = refl _ to-Erased-↝↔↝≡to-Erased-↝↝↝ {k = bijection} {k′ = bijection} _ _ = refl _ to-Erased-↝↔↝≡to-Erased-↝↝↝ {k = bijection} {k′ = equivalence} _ _ = refl _ to-Erased-↝↔↝≡to-Erased-↝↝↝ {k = bijection} {k′ = equivalenceᴱ} _ _ = refl _ to-Erased-↝↔↝≡to-Erased-↝↝↝ {k = equivalence} {k′ = implication} _ _ = refl _ to-Erased-↝↔↝≡to-Erased-↝↝↝ {k = equivalence} {k′ = logical-equivalence} _ _ = refl _ to-Erased-↝↔↝≡to-Erased-↝↝↝ {k = equivalence} {k′ = injection} _ _ = refl _ to-Erased-↝↔↝≡to-Erased-↝↝↝ {k = equivalence} {k′ = embedding} _ _ = refl _ to-Erased-↝↔↝≡to-Erased-↝↝↝ {k = equivalence} {k′ = surjection} _ _ = refl _ to-Erased-↝↔↝≡to-Erased-↝↝↝ {k = equivalence} {k′ = bijection} _ _ = refl _ to-Erased-↝↔↝≡to-Erased-↝↝↝ {k = equivalence} {k′ = equivalence} _ _ = refl _ to-Erased-↝↔↝≡to-Erased-↝↝↝ {k = equivalence} {k′ = equivalenceᴱ} _ _ = refl _ to-Erased-↝↔↝≡to-Erased-↝↝↝ {k = equivalenceᴱ} {k′ = implication} _ _ = refl _ to-Erased-↝↔↝≡to-Erased-↝↝↝ {k = equivalenceᴱ} {k′ = logical-equivalence} _ _ = refl _ to-Erased-↝↔↝≡to-Erased-↝↝↝ {k = equivalenceᴱ} {k′ = injection} _ ext = apply-ext ext λ _ → EEq′.to≡to→≡-Erased ext (refl _) to-Erased-↝↔↝≡to-Erased-↝↝↝ {k = equivalenceᴱ} {k′ = embedding} _ ext = apply-ext ext λ _ → EEq′.to≡to→≡-Erased ext (refl _) to-Erased-↝↔↝≡to-Erased-↝↝↝ {k = equivalenceᴱ} {k′ = surjection} _ ext = apply-ext ext λ _ → EEq′.to≡to→≡-Erased ext (refl _) to-Erased-↝↔↝≡to-Erased-↝↝↝ {k = equivalenceᴱ} {k′ = bijection} _ ext = apply-ext ext λ _ → EEq′.to≡to→≡-Erased ext (refl _) to-Erased-↝↔↝≡to-Erased-↝↝↝ {k = equivalenceᴱ} {k′ = equivalence} _ ext = apply-ext ext λ _ → EEq′.to≡to→≡-Erased ext (refl _) to-Erased-↝↔↝≡to-Erased-↝↝↝ {k = equivalenceᴱ} {k′ = equivalenceᴱ} _ _ = refl _ to-Erased-↝↔↝≡to-Erased-↝↝↝ {k = embedding} {k′ = implication} ext _ = apply-ext ext λ _ → _↔_.to (Embedding-to-≡↔≡ ext) λ _ → refl _ to-Erased-↝↔↝≡to-Erased-↝↝↝ {k = embedding} {k′ = logical-equivalence} ext _ = apply-ext ext λ _ → _↔_.to (Embedding-to-≡↔≡ ext) λ _ → refl _ to-Erased-↝↔↝≡to-Erased-↝↝↝ {k = embedding} {k′ = injection} ext _ = apply-ext ext λ _ → _↔_.to (Embedding-to-≡↔≡ ext) λ _ → refl _ to-Erased-↝↔↝≡to-Erased-↝↝↝ {k = embedding} {k′ = embedding} ext _ = apply-ext ext λ _ → _↔_.to (Embedding-to-≡↔≡ ext) λ _ → refl _ to-Erased-↝↔↝≡to-Erased-↝↝↝ {k = embedding} {k′ = surjection} ext _ = apply-ext ext λ _ → _↔_.to (Embedding-to-≡↔≡ ext) λ _ → refl _ to-Erased-↝↔↝≡to-Erased-↝↝↝ {k = embedding} {k′ = bijection} ext _ = apply-ext ext λ _ → _↔_.to (Embedding-to-≡↔≡ ext) λ _ → refl _ to-Erased-↝↔↝≡to-Erased-↝↝↝ {k = embedding} {k′ = equivalence} ext _ = apply-ext ext λ _ → _↔_.to (Embedding-to-≡↔≡ ext) λ _ → refl _ to-Erased-↝↔↝≡to-Erased-↝↝↝ {k = embedding} {k′ = equivalenceᴱ} ext _ = apply-ext ext λ _ → _↔_.to (Embedding-to-≡↔≡ ext) λ _ → refl _ -- Erased preserves all kinds of functions. Erased-cong : {@0 A : Type ℓ₁} {@0 B : Type ℓ₂} → @0 A ↝[ k ] B → Erased A ↝[ k ] Erased B Erased-cong A↝B = Erased-↝↝↝ _ [ A↝B ] -- Dec-Erased preserves symmetric kinds of functions (in some cases -- assuming extensionality). Dec-Erased-cong : {@0 A : Type ℓ₁} {@0 B : Type ℓ₂} → @0 Extensionality? ⌊ k ⌋-sym (ℓ₁ ⊔ ℓ₂) lzero → @0 A ↝[ ⌊ k ⌋-sym ] B → Dec-Erased A ↝[ ⌊ k ⌋-sym ] Dec-Erased B Dec-Erased-cong ext A↝B = Erased-cong A↝B ⊎-cong Erased-cong (→-cong ext A↝B F.id) ------------------------------------------------------------------------ -- Results that depend on three instances of the axiomatisation of -- []-cong, all for the same universe level module []-cong₁₃ (ax₁ : E₁.[]-cong-axiomatisation ℓ) (ax₂ : E₁.[]-cong-axiomatisation ℓ) (ax : E₁.[]-cong-axiomatisation ℓ) where -- Note that []-cong₂-⊔, which contains Erased-cong, is instantiated -- with all of the module parameters. open []-cong₂-⊔ ax₁ ax₂ ax private module BC₁ = E₁.[]-cong₁ ax₁ module BC₂ = E₁.[]-cong₁ ax₂ ---------------------------------------------------------------------- -- Erased-cong maps F.id to F.id for all kinds of functions (in some -- cases assuming extensionality) private -- Lemmas used in the implementation of Erased-cong-id. Erased-cong-≃-id : {@0 A : Type ℓ} → Extensionality ℓ ℓ → Erased-cong {k = equivalence} F.id ≡ F.id {A = Erased A} Erased-cong-≃-id ext = Eq.lift-equality ext (refl _) Erased-cong-≃ᴱ-id : {@0 A : Type ℓ} → Erased (Extensionality ℓ ℓ) → Erased-cong {k = equivalenceᴱ} F.id ≡ F.id {A = Erased A} Erased-cong-≃ᴱ-id [ ext ] = EEq.[]-cong₂-⊔.to≡to→≡-Erased ax₁ ax₂ ax ext (refl _) Erased-cong-Embedding-id : {@0 A : Type ℓ} → Extensionality ℓ ℓ → Erased-cong {k = embedding} F.id ≡ F.id {A = Erased A} Erased-cong-Embedding-id ext = _↔_.to (Embedding-to-≡↔≡ ext) λ _ → refl _ Erased-cong-↠-id : {@0 A : Type ℓ} → Extensionality ℓ ℓ → Erased-cong {k = surjection} F.id ≡ F.id {A = Erased A} Erased-cong-↠-id ext = $⟨ lemma ⟩ _↔_.to ↠↔∃-Split-surjective (Erased-cong F.id) ≡ _↔_.to ↠↔∃-Split-surjective F.id ↝⟨ Eq.≃-≡ (from-isomorphism ↠↔∃-Split-surjective) ⟩□ Erased-cong F.id ≡ F.id □ where lemma : (map id , λ x → [ erased x ] , BC₂.[]-cong [ refl _ ]) ≡ (id , λ x → x , refl _) lemma = cong (_ ,_) $ apply-ext ext λ _ → cong (_ ,_) BC₂.[]-cong-[refl] Erased-cong-↔-id : {@0 A : Type ℓ} → Extensionality ℓ ℓ → Erased-cong {k = bijection} F.id ≡ F.id {A = Erased A} Erased-cong-↔-id ext = $⟨ lemma ⟩ _↔_.to Bijection.↔-as-Σ (Erased-cong F.id) ≡ _↔_.to Bijection.↔-as-Σ F.id ↝⟨ Eq.≃-≡ (from-isomorphism Bijection.↔-as-Σ) ⟩□ Erased-cong F.id ≡ F.id □ where lemma : ( map id , map id , (λ { [ x ] → BC₂.[]-cong [ refl x ] }) , (λ { [ x ] → BC₁.[]-cong [ refl x ] }) ) ≡ (id , id , refl , refl) lemma = cong (λ p → id , id , p) $ cong₂ _,_ (apply-ext ext λ _ → BC₂.[]-cong-[refl]) (apply-ext ext λ _ → BC₁.[]-cong-[refl]) Erased-cong-↣-id : {@0 A : Type ℓ} → Extensionality ℓ ℓ → Erased-cong {k = injection} F.id ≡ F.id {A = Erased A} Erased-cong-↣-id ext = $⟨ lemma ⟩ _↔_.to ↣↔∃-Injective (Erased-cong F.id) ≡ _↔_.to ↣↔∃-Injective F.id ↝⟨ Eq.≃-≡ (from-isomorphism ↣↔∃-Injective) ⟩□ Erased-cong F.id ≡ F.id □ where lemma : ( map id , λ {_ _} → _↣_.injective (Erased-cong F.id) ) ≡ (id , λ {_ _} → _↣_.injective F.id) lemma = cong (_ ,_) $ implicit-extensionality ext λ _ → implicit-extensionality ext λ _ → apply-ext ext λ eq → BC₁.[]-cong (BC₂.[]-cong⁻¹ eq) ≡⟨ []-cong-unique ax₁ ax₂ ⟩ BC₂.[]-cong (BC₂.[]-cong⁻¹ eq) ≡⟨ _↔_.right-inverse-of BC₂.Erased-≡↔[]≡[] _ ⟩∎ eq ∎ -- Erased-cong maps F.id to F.id for all kinds of functions (in some -- cases assuming extensionality). Erased-cong-id : {@0 A : Type ℓ} → Extensionality? k ℓ ℓ → Erased-cong F.id ≡ F.id {k = k} {A = Erased A} Erased-cong-id {k = implication} = λ _ → map-id Erased-cong-id {k = logical-equivalence} = λ _ → Erased-cong-⇔-id Erased-cong-id {k = injection} = Erased-cong-↣-id Erased-cong-id {k = embedding} = Erased-cong-Embedding-id Erased-cong-id {k = surjection} = Erased-cong-↠-id Erased-cong-id {k = bijection} = Erased-cong-↔-id Erased-cong-id {k = equivalence} = Erased-cong-≃-id Erased-cong-id {k = equivalenceᴱ} = Erased-cong-≃ᴱ-id ------------------------------------------------------------------------ -- Results that depend on instances of the axiomatisation of []-cong -- for three universe levels, as well as for the maximum of each pair -- drawn from these three levels module []-cong₃-⊔ (ax₁ : []-cong-axiomatisation ℓ₁) (ax₂ : []-cong-axiomatisation ℓ₂) (ax₃ : []-cong-axiomatisation ℓ₃) (ax₁₂ : []-cong-axiomatisation (ℓ₁ ⊔ ℓ₂)) (ax₁₃ : []-cong-axiomatisation (ℓ₁ ⊔ ℓ₃)) (ax₂₃ : []-cong-axiomatisation (ℓ₂ ⊔ ℓ₃)) where private module EC₁ = []-cong₂-⊔ ax₁ ax₃ ax₁₃ module EC₂ = []-cong₂-⊔ ax₂ ax₃ ax₂₃ module EC₃ = []-cong₂-⊔ ax₁ ax₂ ax₁₂ ---------------------------------------------------------------------- -- Erased-cong commutes with F._∘_ for all kinds of functions (in -- some cases assuming extensionality) private -- Lemmas used in the implementation of Erased-cong-∘. Erased-cong-≃-∘ : {@0 A : Type ℓ₁} {@0 B : Type ℓ₂} {@0 C : Type ℓ₃} → Extensionality (ℓ₁ ⊔ ℓ₃) (ℓ₁ ⊔ ℓ₃) → (@0 f : B ≃ C) (@0 g : A ≃ B) → EC₁.Erased-cong {k = equivalence} (f F.∘ g) ≡ EC₂.Erased-cong f F.∘ EC₃.Erased-cong g Erased-cong-≃-∘ ext _ _ = Eq.lift-equality ext (refl _) Erased-cong-≃ᴱ-∘ : {@0 A : Type ℓ₁} {@0 B : Type ℓ₂} {@0 C : Type ℓ₃} → Erased (Extensionality (ℓ₁ ⊔ ℓ₃) (ℓ₁ ⊔ ℓ₃)) → (@0 f : B ≃ᴱ C) (@0 g : A ≃ᴱ B) → EC₁.Erased-cong {k = equivalenceᴱ} (f F.∘ g) ≡ EC₂.Erased-cong f F.∘ EC₃.Erased-cong g Erased-cong-≃ᴱ-∘ [ ext ] _ _ = EEq.[]-cong₂-⊔.to≡to→≡-Erased ax₁ ax₃ ax₁₃ ext (refl _) Erased-cong-Embedding-∘ : {@0 A : Type ℓ₁} {@0 B : Type ℓ₂} {@0 C : Type ℓ₃} → Extensionality (ℓ₁ ⊔ ℓ₃) (ℓ₁ ⊔ ℓ₃) → (@0 f : Embedding B C) (@0 g : Embedding A B) → EC₁.Erased-cong {k = embedding} (f F.∘ g) ≡ EC₂.Erased-cong f F.∘ EC₃.Erased-cong g Erased-cong-Embedding-∘ ext _ _ = _↔_.to (Embedding-to-≡↔≡ ext) λ _ → refl _ right-inverse-of-cong-∘ : ∀ {ℓ₁ ℓ₂ ℓ₃} (ax₁ : []-cong-axiomatisation ℓ₁) (ax₂ : []-cong-axiomatisation ℓ₂) (ax₃ : []-cong-axiomatisation ℓ₃) (ax₁₂ : []-cong-axiomatisation (ℓ₁ ⊔ ℓ₂)) (ax₁₃ : []-cong-axiomatisation (ℓ₁ ⊔ ℓ₃)) (ax₂₃ : []-cong-axiomatisation (ℓ₂ ⊔ ℓ₃)) → let module EC₁′ = []-cong₂-⊔ ax₁ ax₃ ax₁₃ module EC₂′ = []-cong₂-⊔ ax₂ ax₃ ax₂₃ module EC₃′ = []-cong₂-⊔ ax₁ ax₂ ax₁₂ in ∀ {@0 A : Type ℓ₁} {@0 B : Type ℓ₂} {@0 C : Type ℓ₃} {x} → (@0 f : B ↠ C) (@0 g : A ↠ B) → _↠_.right-inverse-of (EC₁′.Erased-cong (f F.∘ g)) x ≡ _↠_.right-inverse-of (EC₂′.Erased-cong f F.∘ EC₃′.Erased-cong g) x right-inverse-of-cong-∘ ax₁ ax₂ ax₃ _ _ _ {x = [ x ]} f g = BC₃.[]-cong [ trans (cong (_↠_.to f) (_↠_.right-inverse-of g (_↠_.from f x))) (_↠_.right-inverse-of f x) ] ≡⟨ E₁.[]-cong₁.[]-cong-trans ax₃ ⟩ trans (BC₃.[]-cong [ cong (_↠_.to f) (_↠_.right-inverse-of g (_↠_.from f x)) ]) (BC₃.[]-cong [ _↠_.right-inverse-of f x ]) ≡⟨ cong (λ p → trans p _) (E₁.[]-cong₂.[]-cong-cong ax₂ ax₃) ⟩∎ trans (cong (map (_↠_.to f)) (BC₂.[]-cong [ _↠_.right-inverse-of g (_↠_.from f x) ])) (BC₃.[]-cong [ _↠_.right-inverse-of f x ]) ∎ where module BC₂ = E₁.[]-cong₁ ax₂ module BC₃ = E₁.[]-cong₁ ax₃ Erased-cong-↠-∘ : {@0 A : Type ℓ₁} {@0 B : Type ℓ₂} {@0 C : Type ℓ₃} → Extensionality ℓ₃ (ℓ₁ ⊔ ℓ₃) → (@0 f : B ↠ C) (@0 g : A ↠ B) → EC₁.Erased-cong {k = surjection} (f F.∘ g) ≡ EC₂.Erased-cong f F.∘ EC₃.Erased-cong g Erased-cong-↠-∘ ext f g = $⟨ lemma ⟩ _↔_.to ↠↔∃-Split-surjective (EC₁.Erased-cong (f F.∘ g)) ≡ _↔_.to ↠↔∃-Split-surjective (EC₂.Erased-cong f F.∘ EC₃.Erased-cong g) ↝⟨ Eq.≃-≡ (from-isomorphism ↠↔∃-Split-surjective) ⟩□ EC₁.Erased-cong (f F.∘ g) ≡ EC₂.Erased-cong f F.∘ EC₃.Erased-cong g □ where lemma : ( map (_↠_.to f ∘ _↠_.to g) , (λ x → [ _↠_.from g (_↠_.from f (erased x)) ] , _↠_.right-inverse-of (EC₁.Erased-cong (f F.∘ g)) x) ) ≡ ( (λ x → [ _↠_.to f (_↠_.to g (erased x)) ]) , (λ x → [ _↠_.from g (_↠_.from f (erased x)) ] , _↠_.right-inverse-of (EC₂.Erased-cong f F.∘ EC₃.Erased-cong g) x) ) lemma = cong (_ ,_) $ apply-ext ext λ ([ x ]) → cong ([ _↠_.from g (_↠_.from f x) ] ,_) (right-inverse-of-cong-∘ ax₁ ax₂ ax₃ ax₁₂ ax₁₃ ax₂₃ f g) Erased-cong-↔-∘ : {@0 A : Type ℓ₁} {@0 B : Type ℓ₂} {@0 C : Type ℓ₃} → Extensionality (ℓ₁ ⊔ ℓ₃) (ℓ₁ ⊔ ℓ₃) → (@0 f : B ↔ C) (@0 g : A ↔ B) → EC₁.Erased-cong {k = bijection} (f F.∘ g) ≡ EC₂.Erased-cong f F.∘ EC₃.Erased-cong g Erased-cong-↔-∘ ext f g = $⟨ lemma ⟩ _↔_.to Bijection.↔-as-Σ (EC₁.Erased-cong (f F.∘ g)) ≡ _↔_.to Bijection.↔-as-Σ (EC₂.Erased-cong f F.∘ EC₃.Erased-cong g) ↝⟨ Eq.≃-≡ (from-isomorphism Bijection.↔-as-Σ) ⟩□ EC₁.Erased-cong (f F.∘ g) ≡ EC₂.Erased-cong f F.∘ EC₃.Erased-cong g □ where lemma : ( map (_↔_.to f ∘ _↔_.to g) , map (_↔_.from g ∘ _↔_.from f) , _↔_.right-inverse-of (EC₁.Erased-cong (f F.∘ g)) , _↔_.left-inverse-of (EC₁.Erased-cong (f F.∘ g)) ) ≡ ( (λ x → [ _↔_.to f (_↔_.to g (erased x)) ]) , (λ x → [ _↔_.from g (_↔_.from f (erased x)) ]) , _↔_.right-inverse-of (EC₂.Erased-cong f F.∘ EC₃.Erased-cong g) , _↔_.left-inverse-of (EC₂.Erased-cong f F.∘ EC₃.Erased-cong g) ) lemma = cong (λ p → map (_↔_.to f ∘ _↔_.to g) , map (_↔_.from g ∘ _↔_.from f) , p) $ cong₂ _,_ (apply-ext (lower-extensionality ℓ₁ ℓ₁ ext) λ _ → right-inverse-of-cong-∘ ax₁ ax₂ ax₃ ax₁₂ ax₁₃ ax₂₃ (_↔_.surjection f) (_↔_.surjection g)) (apply-ext (lower-extensionality ℓ₃ ℓ₃ ext) λ _ → right-inverse-of-cong-∘ ax₃ ax₂ ax₁ ax₂₃ ax₁₃ ax₁₂ (_↔_.surjection $ inverse g) (_↔_.surjection $ inverse f)) Erased-cong-↣-∘ : {@0 A : Type ℓ₁} {@0 B : Type ℓ₂} {@0 C : Type ℓ₃} → Extensionality (ℓ₁ ⊔ ℓ₃) (ℓ₁ ⊔ ℓ₃) → (@0 f : B ↣ C) (@0 g : A ↣ B) → EC₁.Erased-cong {k = injection} (f F.∘ g) ≡ EC₂.Erased-cong f F.∘ EC₃.Erased-cong g Erased-cong-↣-∘ ext f g = $⟨ lemma ⟩ _↔_.to ↣↔∃-Injective (EC₁.Erased-cong (f F.∘ g)) ≡ _↔_.to ↣↔∃-Injective (EC₂.Erased-cong f F.∘ EC₃.Erased-cong g) ↝⟨ Eq.≃-≡ (from-isomorphism ↣↔∃-Injective) ⟩□ EC₁.Erased-cong (f F.∘ g) ≡ EC₂.Erased-cong f F.∘ EC₃.Erased-cong g □ where module BC₁ = E₁.[]-cong₁ ax₁ module BC₂ = E₁.[]-cong₁ ax₂ module BC₃ = E₁.[]-cong₁ ax₃ lemma : ( map (_↣_.to f ∘ _↣_.to g) , λ {_ _} → _↣_.injective (EC₁.Erased-cong (f F.∘ g)) ) ≡ ( (λ x → [ _↣_.to f (_↣_.to g (erased x)) ]) , λ {_ _} → _↣_.injective (EC₂.Erased-cong f F.∘ EC₃.Erased-cong g) ) lemma = cong (_ ,_) $ implicit-extensionality (lower-extensionality ℓ₃ lzero ext) λ _ → implicit-extensionality (lower-extensionality ℓ₃ lzero ext) λ _ → apply-ext (lower-extensionality ℓ₁ ℓ₃ ext) λ eq → let eq′ = [ _↣_.injective f (erased (BC₃.[]-cong⁻¹ eq)) ] in BC₁.[]-cong [ _↣_.injective g (erased eq′) ] ≡⟨ cong BC₁.[]-cong $ BC₁.[]-cong [ cong (_↣_.injective g ∘ erased) $ sym $ _↔_.left-inverse-of BC₂.Erased-≡↔[]≡[] _ ] ⟩∎ BC₁.[]-cong [ _↣_.injective g (erased (BC₂.[]-cong⁻¹ (BC₂.[]-cong eq′))) ] ∎ -- Erased-cong commutes with F._∘_ for all kinds of functions (in -- some cases assuming extensionality). Erased-cong-∘ : {@0 A : Type ℓ₁} {@0 B : Type ℓ₂} {@0 C : Type ℓ₃} → Extensionality? k (ℓ₁ ⊔ ℓ₃) (ℓ₁ ⊔ ℓ₃) → (@0 f : B ↝[ k ] C) (@0 g : A ↝[ k ] B) → EC₁.Erased-cong (f F.∘ g) ≡ EC₂.Erased-cong f F.∘ EC₃.Erased-cong g Erased-cong-∘ {k = implication} = λ _ f → map-∘ f Erased-cong-∘ {k = logical-equivalence} = λ _ → Erased-cong-⇔-∘ Erased-cong-∘ {k = injection} = Erased-cong-↣-∘ Erased-cong-∘ {k = embedding} = λ ext f g → Erased-cong-Embedding-∘ ext f g Erased-cong-∘ {k = surjection} = λ ext → Erased-cong-↠-∘ (lower-extensionality ℓ₁ lzero ext) Erased-cong-∘ {k = bijection} = Erased-cong-↔-∘ Erased-cong-∘ {k = equivalence} = Erased-cong-≃-∘ Erased-cong-∘ {k = equivalenceᴱ} = λ ext f g → Erased-cong-≃ᴱ-∘ ext f g ------------------------------------------------------------------------ -- Results that depend on instances of the axiomatisation of []-cong -- for all universe levels module []-cong (ax : ∀ {ℓ} → []-cong-axiomatisation ℓ) where private open module BC₂ {ℓ₁ ℓ₂} = []-cong₂-⊔ (ax {ℓ = ℓ₁}) (ax {ℓ = ℓ₂}) ax public open module BC₁₃ {ℓ} = []-cong₁₃ (ax {ℓ = ℓ}) ax ax public open module BC₃ {ℓ₁ ℓ₂ ℓ₃} = []-cong₃-⊔ (ax {ℓ = ℓ₁}) (ax {ℓ = ℓ₂}) (ax {ℓ = ℓ₃}) ax ax ax public
{ "alphanum_fraction": 0.4803475664, "avg_line_length": 49.0216306156, "ext": "agda", "hexsha": "e8aa86180288e2523bc8eb051a143f487e3d4eb9", "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/Erased/Level-2.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/Erased/Level-2.agda", "max_line_length": 147, "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/Erased/Level-2.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": 12138, "size": 29462 }
agda --compile Ackermann.agda ./Ackermann
{ "alphanum_fraction": 0.7857142857, "avg_line_length": 14, "ext": "agda", "hexsha": "32b6b4af203632b916ffba7c007130bca0635c53", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2018-11-09T22:08:40.000Z", "max_forks_repo_forks_event_min_datetime": "2018-11-09T22:08:40.000Z", "max_forks_repo_head_hexsha": "9ad63ea473a958506c041077f1d810c0c7c8c18d", "max_forks_repo_licenses": [ "Info-ZIP" ], "max_forks_repo_name": "seanwallawalla-forks/RosettaCodeData", "max_forks_repo_path": "Task/Ackermann-function/Agda/ackermann-function-2.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "9ad63ea473a958506c041077f1d810c0c7c8c18d", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "Info-ZIP" ], "max_issues_repo_name": "seanwallawalla-forks/RosettaCodeData", "max_issues_repo_path": "Task/Ackermann-function/Agda/ackermann-function-2.agda", "max_line_length": 29, "max_stars_count": 1, "max_stars_repo_head_hexsha": "9ad63ea473a958506c041077f1d810c0c7c8c18d", "max_stars_repo_licenses": [ "Info-ZIP" ], "max_stars_repo_name": "LaudateCorpus1/RosettaCodeData", "max_stars_repo_path": "Task/Ackermann-function/Agda/ackermann-function-2.agda", "max_stars_repo_stars_event_max_datetime": "2018-11-09T22:08:38.000Z", "max_stars_repo_stars_event_min_datetime": "2018-11-09T22:08:38.000Z", "num_tokens": 13, "size": 42 }
{-# OPTIONS --warning ShadowingInTelescope --allow-unsolved-metas #-} open import Agda.Primitive -- warning here data _~_ {a a : Level} {A : Set a} (a : A) : A -> Set where refl : a ~ a module _ {a} {A : Set a} where -- nothing: the repetition is in separate telescopes data Eq (a : A) : (a : A) → Set where refl : Eq a a -- warning here f : ∀ (a : Level) → ∀ {A : Set a} A ~ A → Set → Set f a A ~ B = λ x → x -- nothing here: the repetition is in separate telescopes f' : ∀ a → Set a → Set a f' a = g a where g : ∀ a → Set a → Set a g a z = z -- nothing here: the variable {a} is not user-written h : ∀ {a} → Set a → Set a h = g _ where g : ∀ a → Set a → Set a g a z = z i : (Set → Set → Set) → (∀ _ _ → _) i f = f
{ "alphanum_fraction": 0.5531628533, "avg_line_length": 20.6388888889, "ext": "agda", "hexsha": "a481223882c200a9f89861182772975434c8e471", "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": "aac88412199dd4cbcb041aab499d8a6b7e3f4a2e", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "hborum/agda", "max_forks_repo_path": "test/Succeed/Issue3989.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "aac88412199dd4cbcb041aab499d8a6b7e3f4a2e", "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": "hborum/agda", "max_issues_repo_path": "test/Succeed/Issue3989.agda", "max_line_length": 69, "max_stars_count": null, "max_stars_repo_head_hexsha": "aac88412199dd4cbcb041aab499d8a6b7e3f4a2e", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "hborum/agda", "max_stars_repo_path": "test/Succeed/Issue3989.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 275, "size": 743 }
open import Proc module Interp (param : Param) where import Hear open import Basics private open module P = Process param open module H = Hear param open Tran data Result {a : U}(p : Proc a) : Set where speak : forall {w q} -> p -! w !-> q -> Result p refuse : Silent p -> Result p upR : {a b : U}{p : Proc b}(φ : Tran a b) -> Result p -> Result (φ /| p) upR φ (speak s) = speak (tx-/| s) upR φ (refuse s) = refuse (silent-/| s) Oracle : Set Oracle = Nat -> LR prophecy : Oracle -> LR prophecy ol = ol zero nextOracle : Oracle -> Oracle nextOracle ol = ol % suc anyOracle : Oracle anyOracle _ = left ocons : LR -> Oracle -> Oracle ocons l or zero = l ocons l or (suc n) = or n step : {a : U}{p : Proc a} -> Guard p -> Oracle -> Result p step og _ = refuse silent-o step (>g _) _ = refuse silent-> step (w !g p) _ = speak tx-! step (w ! p +g f) _ = speak tx-+ step (defg x g) ol with step g ol ... | refuse s1 = refuse (silent-def s1) ... | speak s1 = speak (tx-def s1) step (g1 ||g g2) ol with step g1 (nextOracle ol) | step g2 (nextOracle ol) | prophecy ol ... | refuse s1 | refuse s2 | _ = refuse (silent-|| s1 s2) ... | speak s1 | refuse s2 | _ = speak (tx-!| s1 (sound g2)) ... | refuse s1 | speak s2 | _ = speak (tx-|! (sound g1) s2) ... | speak s1 | speak _ | left = speak (tx-!| s1 (sound g2)) ... | speak _ | speak s2 | right = speak (tx-|! (sound g1) s2) step (φ /|g g) ol = upR φ (step g ol)
{ "alphanum_fraction": 0.5562827225, "avg_line_length": 27.7818181818, "ext": "agda", "hexsha": "65c8b6f964c584d78a262d36424f6060b4da37e0", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cruhland/agda", "max_forks_repo_path": "examples/outdated-and-incorrect/cbs/Interp.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "cruhland/agda", "max_issues_repo_path": "examples/outdated-and-incorrect/cbs/Interp.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": "examples/outdated-and-incorrect/cbs/Interp.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": 534, "size": 1528 }
module Issue481PonderBase where postulate List : Set as : List
{ "alphanum_fraction": 0.7285714286, "avg_line_length": 11.6666666667, "ext": "agda", "hexsha": "d986656abcb68791676b7b12ff2557fa368d89af", "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/Issue481PonderBase.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/Issue481PonderBase.agda", "max_line_length": 31, "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/Issue481PonderBase.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": 22, "size": 70 }
{-# OPTIONS --without-K --rewriting #-} open import lib.Basics open import lib.types.Coproduct open import lib.types.Empty open import lib.types.Pi module lib.Relation2 where module _ {i} {P : Type i} where Dec-level : ∀ {n} → has-level (S n) P → has-level (S n) (Dec P) Dec-level pP (inl p₁) (inl p₂) = equiv-preserves-level (inl=inl-equiv p₁ p₂ ⁻¹) (pP p₁ p₂) Dec-level pP (inl p) (inr ¬p) = ⊥-rec $ ¬p p Dec-level pP (inr ¬p) (inl p) = ⊥-rec $ ¬p p Dec-level {n} pP (inr ¬p₁) (inr ¬p₂) = equiv-preserves-level (inr=inr-equiv ¬p₁ ¬p₂ ⁻¹) (prop-has-level-S ¬-is-prop ¬p₁ ¬p₂)
{ "alphanum_fraction": 0.6198347107, "avg_line_length": 30.25, "ext": "agda", "hexsha": "8ee2c48ef80908a4e83437f658d3deb2e4d506ad", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2018-12-26T21:31:57.000Z", "max_forks_repo_forks_event_min_datetime": "2018-12-26T21:31:57.000Z", "max_forks_repo_head_hexsha": "e7d663b63d89f380ab772ecb8d51c38c26952dbb", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "mikeshulman/HoTT-Agda", "max_forks_repo_path": "core/lib/Relation2.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "e7d663b63d89f380ab772ecb8d51c38c26952dbb", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "mikeshulman/HoTT-Agda", "max_issues_repo_path": "core/lib/Relation2.agda", "max_line_length": 65, "max_stars_count": null, "max_stars_repo_head_hexsha": "e7d663b63d89f380ab772ecb8d51c38c26952dbb", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "mikeshulman/HoTT-Agda", "max_stars_repo_path": "core/lib/Relation2.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 241, "size": 605 }
module Thesis.SIRelBigStep.IlcSILR where open import Data.Unit.Base hiding (_≤_) open import Data.Product open import Relation.Nullary open import Relation.Binary.PropositionalEquality open import Thesis.SIRelBigStep.Lang public open import Thesis.SIRelBigStep.DLang public open import Thesis.SIRelBigStep.ArithExtra public rrelT3-skeleton : ∀ {τ Γ} → ((v1 : Val τ) → (dv : DVal τ) → (v2 : Val τ) → (k : ℕ) → Set) → (t1 : Term Γ τ) (dt : DTerm Γ τ) (t2 : Term Γ τ) (ρ1 : ⟦ Γ ⟧Context) (dρ : ChΔ Γ) (ρ2 : ⟦ Γ ⟧Context) → ℕ → Set rrelT3-skeleton {τ} ternary-rel t1 dt t2 ρ1 dρ ρ2 k = (v1 v2 : Val τ) → ∀ j (j<k : j < k) → (ρ1⊢t1↓[j]v1 : ρ1 ⊢ t1 ↓[ i' j ] v1) → (ρ2⊢t2↓[n2]v2 : ρ2 ⊢ t2 ↓[ no ] v2) → Σ[ dv ∈ DVal τ ] ρ1 D dρ ⊢ dt ↓ dv × ternary-rel v1 dv v2 (k ∸ j) mutual rrelT3 : ∀ {τ Γ} (t1 : Term Γ τ) (dt : DTerm Γ τ) (t2 : Term Γ τ) (ρ1 : ⟦ Γ ⟧Context) (dρ : ChΔ Γ) (ρ2 : ⟦ Γ ⟧Context) → ℕ → Set rrelT3 {τ} = rrelT3-skeleton (rrelV3 τ) rrelV3 : ∀ τ (v1 : Val τ) (dv : DVal τ) (v2 : Val τ) → (n : ℕ) → Set -- Making this case first ensures rrelV3 splits on its second argument, hence -- that all its equations hold definitionally. rrelV3 τ v1 (bang v2) v2' n = v2 ≡ v2' rrelV3 nat (natV v1) (dnatV dv) (natV v2) n = dv + v1 ≡ v2 rrelV3 (σ ⇒ τ) (closure {Γ1} t1 ρ1) (dclosure {ΔΓ} dt ρ dρ) (closure {Γ2} t2 ρ2) n = Σ ((Γ1 ≡ Γ2) × (Γ1 ≡ ΔΓ)) λ { (refl , refl) → ρ1 ≡ ρ × ρ1 ⊕ρ dρ ≡ ρ2 × t1 ≡ t2 × dt ≡ derive-dterm t1 × ∀ (k : ℕ) (k<n : k < n) v1 dv v2 → rrelV3 σ v1 dv v2 k → rrelT3 t1 dt t2 (v1 • ρ1) (dv • dρ) (v2 • ρ2) k } rrelV3 (pair τ1 τ2) (pairV va1 vb1) (dpairV dva dvb) (pairV va2 vb2) n = rrelV3 τ1 va1 dva va2 n × rrelV3 τ2 vb1 dvb vb2 n rrelV3→⊕ : ∀ {τ n} v1 dv v2 → rrelV3 τ v1 dv v2 n → v1 ⊕ dv ≡ v2 rrelV3→⊕ v1 (bang v2) v2' vv = vv rrelV3→⊕ (closure {Γ} t ρ) (dclosure .(derive-dterm t) .ρ dρ) (closure .t .(ρ ⊕ρ dρ)) ((refl , refl) , refl , refl , refl , refl , dvv) with Γ ≟Ctx Γ | ≟Ctx-refl Γ ... | .(yes refl) | refl = refl rrelV3→⊕ (natV n) (dnatV dn) (natV .(dn + n)) refl rewrite +-comm n dn = refl rrelV3→⊕ (pairV va1 vb1) (dpairV dva dvb) (pairV va2 vb2) (vaa , vbb) rewrite rrelV3→⊕ va1 dva va2 vaa | rrelV3→⊕ vb1 dvb vb2 vbb = refl rrelρ3 : ∀ Γ (ρ1 : ⟦ Γ ⟧Context) (dρ : ChΔ Γ) (ρ2 : ⟦ Γ ⟧Context) → ℕ → Set rrelρ3 ∅ ∅ ∅ ∅ n = ⊤ rrelρ3 (τ • Γ) (v1 • ρ1) (dv • dρ) (v2 • ρ2) n = rrelV3 τ v1 dv v2 n × rrelρ3 Γ ρ1 dρ ρ2 n rrelρ3→⊕ : ∀ {Γ n} ρ1 dρ ρ2 → rrelρ3 Γ ρ1 dρ ρ2 n → ρ1 ⊕ρ dρ ≡ ρ2 rrelρ3→⊕ ∅ ∅ ∅ tt = refl rrelρ3→⊕ (v1 • ρ1) (dv • dρ) (v2 • ρ2) (vv , ρρ) rewrite rrelV3→⊕ v1 dv v2 vv | rrelρ3→⊕ ρ1 dρ ρ2 ρρ = refl rrelV3-mono : ∀ m n → m ≤ n → ∀ τ v1 dv v2 → rrelV3 τ v1 dv v2 n → rrelV3 τ v1 dv v2 m rrelV3-mono m n m≤n τ v1 (bang v2) v2′ vv = vv rrelV3-mono m n m≤n (σ ⇒ τ) (closure t ρ) (dclosure dt ρ₁ dρ) (closure t₁ ρ₂) -- Validity ((refl , refl) , refl , refl , refl , refl , vv) = (refl , refl) , refl , refl , refl , refl , λ k k<m → vv k (≤-trans k<m m≤n) rrelV3-mono m n m≤n nat (natV n₁) (dnatV n₂) (natV n₃) vv = vv rrelV3-mono m n m≤n (pair τ1 τ2) (pairV va1 vb1) (dpairV dva dvb) (pairV va2 vb2) (vaa , vbb) = rrelV3-mono m n m≤n τ1 va1 dva va2 vaa , rrelV3-mono m n m≤n τ2 vb1 dvb vb2 vbb rrelρ3-mono : ∀ m n → m ≤ n → ∀ Γ ρ1 dρ ρ2 → rrelρ3 Γ ρ1 dρ ρ2 n → rrelρ3 Γ ρ1 dρ ρ2 m rrelρ3-mono m n m≤n ∅ ∅ ∅ ∅ tt = tt rrelρ3-mono m n m≤n (τ • Γ) (v1 • ρ1) (dv • dρ) (v2 • ρ2) (vv , ρρ) = rrelV3-mono m n m≤n _ v1 dv v2 vv , rrelρ3-mono m n m≤n Γ ρ1 dρ ρ2 ρρ ⟦_⟧RelVar3 : ∀ {Γ τ n} (x : Var Γ τ) {ρ1 dρ ρ2} → rrelρ3 Γ ρ1 dρ ρ2 n → rrelV3 τ (⟦ x ⟧Var ρ1) (D.⟦ x ⟧Var dρ) (⟦ x ⟧Var ρ2) n ⟦ this ⟧RelVar3 {v1 • ρ1} {dv • dρ} {v2 • ρ2} (vv , ρρ) = vv ⟦ that x ⟧RelVar3 {v1 • ρ1} {dv • dρ} {v2 • ρ2} (vv , ρρ) = ⟦ x ⟧RelVar3 ρρ -- Direct analogue of rrelV3→⊕ for rrelT3: simply say that the resulting values -- are related. -- Alternatively, one could try internalizing ⊕ and giving some term equivalence, but it does not seem worthwhile. rrelT3→⊕ : ∀ {τ Γ k} (t1 : Term Γ τ) (dt : DTerm Γ τ) (t2 : Term Γ τ) (ρ1 : ⟦ Γ ⟧Context) (dρ : ChΔ Γ) (ρ2 : ⟦ Γ ⟧Context) → rrelT3 {τ} t1 dt t2 ρ1 dρ ρ2 k → rrelT3-skeleton (λ v1 dv v2 _ → v1 ⊕ dv ≡ v2) t1 dt t2 ρ1 dρ ρ2 k rrelT3→⊕ t1 dt t2 ρ1 dρ ρ2 ttrel v1 v2 j j<k ρ1⊢t1↓[j]v1 ρ2⊢t2↓[n2]v2 with ttrel v1 v2 j j<k ρ1⊢t1↓[j]v1 ρ2⊢t2↓[n2]v2 ... | dv , ↓dv , vv = dv , ↓dv , rrelV3→⊕ v1 dv v2 vv
{ "alphanum_fraction": 0.5637942552, "avg_line_length": 44.4653465347, "ext": "agda", "hexsha": "ba7db6e6148612c35f42172457d927ce4d58cafa", "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": "Thesis/SIRelBigStep/IlcSILR.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": "Thesis/SIRelBigStep/IlcSILR.agda", "max_line_length": 163, "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": "Thesis/SIRelBigStep/IlcSILR.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": 2379, "size": 4491 }
{-# OPTIONS --without-K --rewriting #-} module PathInduction where open import Base public -- The rewriting relation {-<rewrite>-} postulate _↦_ : ∀ {i} {A : Type i} → A → A → Type i {-# BUILTIN REWRITE _↦_ #-} {-</>-} -- We redefine concatenation of paths to use induction on both paths, in order -- to make unification more powerful infixr 80 _∙_ _∙_ : ∀ {i} {A : Type i} {a b c : A} (p : a == b) (q : b == c) → a == c idp ∙ idp = idp record Coh {i} (A : Type i) : Type i where field & : A open Coh public instance J→ : ∀ {i j k} {A : Type i} {B : A → Type j} {f : (a : A) → B a} {P : {g : (a : A) → B a} (h : (a : A) → f a == g a) → Type k} → Coh (P (λ a → idp)) → Coh ({g : (a : A) → B a} → (h : (a : A) → f a == g a) → P h) & (J→ {A = A} {B} {f} {P = P} d) h = transport P (λ= (app=-β h)) (J-aux (λ= h)) where J-aux : {g : (a : A) → B a} (h : f == g) → P (app= h) J-aux idp = & d J→! : ∀ {i j k} {A : Type i} {B : A → Type j} {f : (a : A) → B a} {P : {g : (a : A) → B a} (h : (a : A) → g a == f a) → Type k} → Coh (P (λ a → idp)) → Coh ({g : (a : A) → B a} → (h : (a : A) → g a == f a) → P h) & (J→! {A = A} {B} {f} {P = P} d) h = transport P (λ= (app=-β h)) (J-aux (λ= h)) where J-aux : {g : (a : A) → B a} (h : g == f) → P (app= h) J-aux idp = & d module _ {i j} {A : Type i} {a : A} where instance J- : {B : (a' : A) → a == a' → Type j} → Coh (B a idp) → Coh ({a' : A} (p : a == a') → B a' p) & (J- d) idp = & d J! : {B : (a' : A) → a' == a → Type j} → Coh (B a idp) → Coh ({a' : A} (p : a' == a) → B a' p) & (J! d) idp = & d J□ : {B : {b c d : A} {p : a == b} {q : a == c} {r : b == d} {s : c == d} → Square p q r s → Type j} → Coh (B ids) → Coh ({b c d : A} {p : a == b} {q : a == c} {r : b == d} {s : c == d} (sq : Square p q r s) → B sq) & (J□ {B = B} d) ids = & d J□i : {B : {b c d : A} {p : a == b} {q : a == c} {r : b == d} {s : c == d} → Square p q r s → Type j} → Coh (B ids) → Coh ({b c d : A} {p : a == b} {q : a == c} {r : b == d} {s : c == d} {sq : Square p q r s} → B sq) & (J□i {B = B} d) {sq = ids} = & d J□1 : {B : (p : a == a) → Square p idp idp idp → Type j} → Coh (B idp ids) → Coh ({p : a == a} (sq : Square p idp idp idp) → B p sq) & (J□1 {B = B} d) c = aux B (& d) c where e : {a b c d : A} (q : a == c) (r : b == d) (s : c == d) → Square (q ∙ s ∙ ! r) q r s e idp idp idp = ids aux : {a b c d : A} {q : a == c} {r : b == d} {s : c == d} (B : (p : a == b) → Square p q r s → Type j) → B (q ∙ s ∙ ! r) (e q r s) → {p : a == b} (sq : Square p q r s) → B p sq aux B d ids = d J□2 : {B : (p : a == a) → Square idp p idp idp → Type j} → Coh (B idp ids) → Coh ({p : a == a} (sq : Square idp p idp idp) → B p sq) & (J□2 {B = B} d) c = aux B (& d) c where e : {a b c d : A} (p : a == b) (r : b == d) (s : c == d) → Square p (p ∙ r ∙ ! s) r s e idp idp idp = ids aux : {a b c d : A} {p : a == b} {r : b == d} {s : c == d} (B : (q : a == c) → Square p q r s → Type j) → B (p ∙ r ∙ ! s) (e p r s) → {q : a == c} (sq : Square p q r s) → B q sq aux B d ids = d J□3 : {B : (p : a == a) → Square idp idp p idp → Type j} → Coh (B idp ids) → Coh ({p : a == a} (sq : Square idp idp p idp) → B p sq) & (J□3 {B = B} d) c = aux B (& d) c where e : {a b c d : A} (p : a == b) (q : a == c) (s : c == d) → Square p q (! p ∙ q ∙ s) s e idp idp idp = ids aux : {a b c d : A} {p : a == b} {q : a == c} {s : c == d} (B : (r : b == d) → Square p q r s → Type j) → B (! p ∙ q ∙ s) (e p q s) → {r : b == d} (sq : Square p q r s) → B r sq aux B d ids = d J□4 : {B : (p : a == a) → Square idp idp idp p → Type j} → Coh (B idp ids) → Coh ({p : a == a} (sq : Square idp idp idp p) → B p sq) & (J□4 {B = B} d) c = aux B (& d) c where e : {a b c d : A} (p : a == b) (q : a == c) (r : b == d) → Square p q r (! q ∙ p ∙ r) e idp idp idp = ids aux : {a b c d : A} {p : a == b} {q : a == c} {r : b == d} (B : (s : c == d) → Square p q r s → Type j) → B (! q ∙ p ∙ r) (e p q r) → {s : c == d} (sq : Square p q r s) → B s sq aux B d ids = d instance idp-Coh : ∀ {i} {A : Type i} {a : A} → Coh (a == a) & idp-Coh = idp ids-Coh : ∀ {i} {A : Type i} {a : A} → Coh (Square {a₀₀ = a} idp idp idp idp) & ids-Coh = ids idc-Coh : ∀ {i} {A : Type i} {a : A} → Coh (Cube {a₀₀₀ = a} ids ids ids ids ids ids) & idc-Coh = idc -- Allows us to put the initial [a] in the [Coh] strip-a : ∀ {i j} {A : Type i} {P : A → A → Type j} → ((a : A) → Coh ({b : A} → P a b)) → Coh ({a b : A} → P a b) & (strip-a z) = & (z _) -- Allows us to put the initial [A] in the [Coh] strip-A : ∀ {i j} {P : Type i → Type j} → ((A : Type i) → Coh (P A)) → Coh ({A : Type i} → P A) & (strip-A z) = & (z _) -- Allows us to have implicit arguments implicit : ∀ {i j k} {A : Type i} {B : A → Type j} {C : (a : A) → B a → Type k} → Coh ({a : A} (b : B a) → C a b) → Coh ({a : A} {b : B a} → C a b) & (implicit d) = & d _ path-induction : ∀ {i} {A : Type i} {{a : A}} → A path-induction {{a}} = a -- Rules for cubes instance idsidc1-Coh : ∀ {i} {A : Type i} {a : A} → Coh (Σ (Square (idp {a = a}) idp idp idp) (λ left → Cube left ids ids ids ids ids)) & idsidc1-Coh = (ids , idc) idsidc2-Coh : ∀ {i} {A : Type i} {a : A} → Coh (Σ (Square (idp {a = a}) idp idp idp) (λ right → Cube ids right ids ids ids ids)) & idsidc2-Coh = (ids , idc) idsidc6-Coh : ∀ {i} {A : Type i} {a : A} → Coh (Σ (Square (idp {a = a}) idp idp idp) (λ front → Cube ids ids ids ids ids front)) & idsidc6-Coh = (ids , idc) module _ {i j} {A : Type i} {a : A} where instance JCube1 : {B : (p : Square {a₀₀ = a} idp idp idp idp) → Cube p ids ids ids ids ids → Type j} → Coh (B ids idc) → Coh ({p : Square {a₀₀ = a} idp idp idp idp} (cube : Cube p ids ids ids ids ids) → B p cube) & (JCube1 {B = B} d) c = aux B (& d) c where comp : Coh ({a₀₀₁ a₀₁₁ a₁₀₁ a₁₁₁ : A} {p₀₋₁ : a₀₀₁ == a₀₁₁} {p₋₀₁ : a₀₀₁ == a₁₀₁} {p₋₁₁ : a₀₁₁ == a₁₁₁} {p₁₋₁ : a₁₀₁ == a₁₁₁} (right : Square p₀₋₁ p₋₀₁ p₋₁₁ p₁₋₁) {a₀₀₀ : A} {p₀₀₋ : a₀₀₀ == a₀₀₁} {a₀₁₀ : A} {p₀₁₋ : a₀₁₀ == a₀₁₁} {a₁₀₀ : A} {p₁₀₋ : a₁₀₀ == a₁₀₁} {a₁₁₀ : A} {p₁₁₋ : a₁₁₀ == a₁₁₁} {p₀₋₀ : a₀₀₀ == a₀₁₀} (back : Square p₀₋₀ p₀₀₋ p₀₁₋ p₀₋₁) {p₋₀₀ : a₀₀₀ == a₁₀₀} (top : Square p₋₀₀ p₀₀₋ p₁₀₋ p₋₀₁) {p₋₁₀ : a₀₁₀ == a₁₁₀} (bottom : Square p₋₁₀ p₀₁₋ p₁₁₋ p₋₁₁) {p₁₋₀ : a₁₀₀ == a₁₁₀} (front : Square p₁₋₀ p₁₀₋ p₁₁₋ p₁₋₁) → Σ (Square p₀₋₀ p₋₀₀ p₋₁₀ p₁₋₀) (λ left → Cube left right back top bottom front)) comp = path-induction aux : {a₀₀₀ a₀₁₀ a₁₀₀ a₁₁₀ a₀₀₁ a₀₁₁ a₁₀₁ a₁₁₁ : A} {p₀₋₀ : a₀₀₀ == a₀₁₀} {p₋₀₀ : a₀₀₀ == a₁₀₀} {p₋₁₀ : a₀₁₀ == a₁₁₀} {p₁₋₀ : a₁₀₀ == a₁₁₀} -- missing left {p₀₋₁ : a₀₀₁ == a₀₁₁} {p₋₀₁ : a₀₀₁ == a₁₀₁} {p₋₁₁ : a₀₁₁ == a₁₁₁} {p₁₋₁ : a₁₀₁ == a₁₁₁} {right : Square p₀₋₁ p₋₀₁ p₋₁₁ p₁₋₁} {p₀₀₋ : a₀₀₀ == a₀₀₁} {p₀₁₋ : a₀₁₀ == a₀₁₁} {p₁₀₋ : a₁₀₀ == a₁₀₁} {p₁₁₋ : a₁₁₀ == a₁₁₁} {back : Square p₀₋₀ p₀₀₋ p₀₁₋ p₀₋₁} {top : Square p₋₀₀ p₀₀₋ p₁₀₋ p₋₀₁} {bottom : Square p₋₁₀ p₀₁₋ p₁₁₋ p₋₁₁} {front : Square p₁₋₀ p₁₀₋ p₁₁₋ p₁₋₁} → (B : (left : Square p₀₋₀ p₋₀₀ p₋₁₀ p₁₋₀) → Cube left right back top bottom front → Type j) → uncurry B (& comp right back top bottom front) → ({left : Square p₀₋₀ p₋₀₀ p₋₁₀ p₁₋₀} (cube : Cube left right back top bottom front) → B left cube) aux B d idc = d JCube2 : {B : (p : Square {a₀₀ = a} idp idp idp idp) → Cube ids p ids ids ids ids → Type j} → Coh (B ids idc) → Coh ({p : Square {a₀₀ = a} idp idp idp idp} (cube : Cube ids p ids ids ids ids) → B p cube) & (JCube2 {B = B} d) c = aux B (& d) c where comp : Coh ({a₀₀₀ a₀₁₀ a₁₀₀ a₁₁₀ : A} {p₀₋₀ : a₀₀₀ == a₀₁₀} {p₋₀₀ : a₀₀₀ == a₁₀₀} {p₋₁₀ : a₀₁₀ == a₁₁₀} {p₁₋₀ : a₁₀₀ == a₁₁₀} (left : Square p₀₋₀ p₋₀₀ p₋₁₀ p₁₋₀) {a₀₀₁ : A} {p₀₀₋ : a₀₀₀ == a₀₀₁} {a₀₁₁ : A} {p₀₁₋ : a₀₁₀ == a₀₁₁} {a₁₀₁ : A} {p₁₀₋ : a₁₀₀ == a₁₀₁} {a₁₁₁ : A} {p₁₁₋ : a₁₁₀ == a₁₁₁} {p₀₋₁ : a₀₀₁ == a₀₁₁} (back : Square p₀₋₀ p₀₀₋ p₀₁₋ p₀₋₁) {p₋₀₁ : a₀₀₁ == a₁₀₁} (top : Square p₋₀₀ p₀₀₋ p₁₀₋ p₋₀₁) {p₋₁₁ : a₀₁₁ == a₁₁₁} (bottom : Square p₋₁₀ p₀₁₋ p₁₁₋ p₋₁₁) {p₁₋₁ : a₁₀₁ == a₁₁₁} (front : Square p₁₋₀ p₁₀₋ p₁₁₋ p₁₋₁) → Σ (Square p₀₋₁ p₋₀₁ p₋₁₁ p₁₋₁) (λ right → Cube left right back top bottom front)) comp = path-induction aux : {a₀₀₀ a₀₁₀ a₁₀₀ a₁₁₀ a₀₀₁ a₀₁₁ a₁₀₁ a₁₁₁ : A} {p₀₋₀ : a₀₀₀ == a₀₁₀} {p₋₀₀ : a₀₀₀ == a₁₀₀} {p₋₁₀ : a₀₁₀ == a₁₁₀} {p₁₋₀ : a₁₀₀ == a₁₁₀} {left : Square p₀₋₀ p₋₀₀ p₋₁₀ p₁₋₀} {p₀₋₁ : a₀₀₁ == a₀₁₁} {p₋₀₁ : a₀₀₁ == a₁₀₁} {p₋₁₁ : a₀₁₁ == a₁₁₁} {p₁₋₁ : a₁₀₁ == a₁₁₁} {p₀₀₋ : a₀₀₀ == a₀₀₁} {p₀₁₋ : a₀₁₀ == a₀₁₁} {p₁₀₋ : a₁₀₀ == a₁₀₁} {p₁₁₋ : a₁₁₀ == a₁₁₁} {back : Square p₀₋₀ p₀₀₋ p₀₁₋ p₀₋₁} {top : Square p₋₀₀ p₀₀₋ p₁₀₋ p₋₀₁} {bottom : Square p₋₁₀ p₀₁₋ p₁₁₋ p₋₁₁} {front : Square p₁₋₀ p₁₀₋ p₁₁₋ p₁₋₁} → (B : (right : Square p₀₋₁ p₋₀₁ p₋₁₁ p₁₋₁) → Cube left right back top bottom front → Type j) → uncurry B (& comp left back top bottom front) → ({right : Square p₀₋₁ p₋₀₁ p₋₁₁ p₁₋₁} (cube : Cube left right back top bottom front) → B right cube) aux B d idc = d JCube6 : {B : (p : Square {a₀₀ = a} idp idp idp idp) → Cube ids ids ids ids ids p → Type j} → Coh (B ids idc) → Coh ({p : Square {a₀₀ = a} idp idp idp idp} (cube : Cube ids ids ids ids ids p) → B p cube) & (JCube6 {B = B} d) c = aux B (& d) c where comp : Coh ({a₀₀₀ a₀₁₀ a₁₀₀ a₁₁₀ : A} {p₀₋₀ : a₀₀₀ == a₀₁₀} {p₋₀₀ : a₀₀₀ == a₁₀₀} {p₋₁₀ : a₀₁₀ == a₁₁₀} {p₁₋₀ : a₁₀₀ == a₁₁₀} (left : Square p₀₋₀ p₋₀₀ p₋₁₀ p₁₋₀) {a₀₀₁ : A} {p₀₀₋ : a₀₀₀ == a₀₀₁} {a₀₁₁ : A} {p₀₁₋ : a₀₁₀ == a₀₁₁} {a₁₀₁ : A} {p₁₀₋ : a₁₀₀ == a₁₀₁} {a₁₁₁ : A} {p₁₁₋ : a₁₁₀ == a₁₁₁} {p₀₋₁ : a₀₀₁ == a₀₁₁} (back : Square p₀₋₀ p₀₀₋ p₀₁₋ p₀₋₁) {p₋₀₁ : a₀₀₁ == a₁₀₁} (top : Square p₋₀₀ p₀₀₋ p₁₀₋ p₋₀₁) {p₋₁₁ : a₀₁₁ == a₁₁₁} (bottom : Square p₋₁₀ p₀₁₋ p₁₁₋ p₋₁₁) {p₁₋₁ : a₁₀₁ == a₁₁₁} (right : Square p₀₋₁ p₋₀₁ p₋₁₁ p₁₋₁) → Σ (Square p₁₋₀ p₁₀₋ p₁₁₋ p₁₋₁) (λ front → Cube left right back top bottom front)) comp = path-induction aux : {a₀₀₀ a₀₁₀ a₁₀₀ a₁₁₀ a₀₀₁ a₀₁₁ a₁₀₁ a₁₁₁ : A} {p₀₋₀ : a₀₀₀ == a₀₁₀} {p₋₀₀ : a₀₀₀ == a₁₀₀} {p₋₁₀ : a₀₁₀ == a₁₁₀} {p₁₋₀ : a₁₀₀ == a₁₁₀} {left : Square p₀₋₀ p₋₀₀ p₋₁₀ p₁₋₀} {p₀₋₁ : a₀₀₁ == a₀₁₁} {p₋₀₁ : a₀₀₁ == a₁₀₁} {p₋₁₁ : a₀₁₁ == a₁₁₁} {p₁₋₁ : a₁₀₁ == a₁₁₁} {right : Square p₀₋₁ p₋₀₁ p₋₁₁ p₁₋₁} {p₀₀₋ : a₀₀₀ == a₀₀₁} {p₀₁₋ : a₀₁₀ == a₀₁₁} {p₁₀₋ : a₁₀₀ == a₁₀₁} {p₁₁₋ : a₁₁₀ == a₁₁₁} {back : Square p₀₋₀ p₀₀₋ p₀₁₋ p₀₋₁} {top : Square p₋₀₀ p₀₀₋ p₁₀₋ p₋₀₁} {bottom : Square p₋₁₀ p₀₁₋ p₁₁₋ p₋₁₁} → (B : (front : Square p₁₋₀ p₁₀₋ p₁₁₋ p₁₋₁) → Cube left right back top bottom front → Type j) → uncurry B (& comp left back top bottom right) → ({front : Square p₁₋₀ p₁₀₋ p₁₁₋ p₁₋₁} (cube : Cube left right back top bottom front) → B front cube) aux B d idc = d -- Flat cubes (cubes where the four lateral faces are actually only 2-dimensional paths data FlatCube {i} {A : Type i} {a : A} : {b c d : A} {p p' : a == b} {q q' : a == c} {r r' : b == d} {s s' : c == d} → Square p q r s → Square p' q' r' s' → p == p' → q == q' → r == r' → s == s' → Type i where idfc : FlatCube ids ids idp idp idp idp instance idfc-Coh : ∀ {i} {A : Type i} {a : A} → Coh (FlatCube {a = a} ids ids idp idp idp idp) & idfc-Coh = idfc JFlatCube1 : ∀ {i j} {A : Type i} {a : A} {B : (p : Square {a₀₀ = a} idp idp idp idp) → FlatCube p ids idp idp idp idp → Type j} → Coh (B ids idfc) → Coh ({p : Square {a₀₀ = a} idp idp idp idp} (cube : FlatCube p ids idp idp idp idp) → B p cube) & (JFlatCube1 {i} {j} {B = B} d) c = aux B (& d) c where comp : {A : Type i} {a b c d : A} {p' : a == b} {q' : a == c} {r' : b == d} {s' : c == d} (sq' : Square p' q' r' s') {p : a == b} (p= : p == p') {q : a == c} (q= : q == q') {r : b == d} (r= : r == r') {s : c == d} (s= : s == s') → Square p q r s comp ids idp idp idp idp = ids fill : {A : Type i} {a b c d : A} {p' : a == b} {q' : a == c} {r' : b == d} {s' : c == d} (sq' : Square p' q' r' s') {p : a == b} (p= : p == p') {q : a == c} (q= : q == q') {r : b == d} (r= : r == r') {s : c == d} (s= : s == s') → FlatCube (comp sq' p= q= r= s=) sq' p= q= r= s= fill ids idp idp idp idp = idfc aux : {A : Type i} {a b c d : A} {p' : a == b} {q' : a == c} {r' : b == d} {s' : c == d} {sq' : Square p' q' r' s'} {p : a == b} {p= : p == p'} {q : a == c} {q= : q == q'} {r : b == d} {r= : r == r'} {s : c == d} {s= : s == s'} (B : (sq : Square p q r s) (fil : FlatCube sq sq' p= q= r= s=) → Type j) → B (comp sq' p= q= r= s=) (fill sq' p= q= r= s=) → {sq : Square p q r s} (fil : FlatCube sq sq' p= q= r= s=) → B sq fil aux B d idfc = d JFlatCube2 : ∀ {i j} {A : Type i} {a : A} {B : (p : Square {a₀₀ = a} idp idp idp idp) → FlatCube ids p idp idp idp idp → Type j} → Coh (B ids idfc) → Coh ({p : Square {a₀₀ = a} idp idp idp idp} (cube : FlatCube ids p idp idp idp idp) → B p cube) & (JFlatCube2 d) idfc = & d ap-∙ : ∀ {i j} {A : Type i} {B : Type j} (f : A → B) {a b c : A} (p : a == b) (q : b == c) → ap f (p ∙ q) == ap f p ∙ ap f q ap-∙ f idp idp = idp ap-∙! : ∀ {i j} {A : Type i} {B : Type j} (f : A → B) {a b : A} (p : a == b) {c : A} (q : c == b) → ap f (p ∙ ! q) == ap f p ∙ ! (ap f q) ap-∙! f idp idp = idp ap-shape-∙! : ∀ {i j} {A : Type i} {B : Type j} (f : A → B) {a b c : A} {p : a == b} {q : a == c} {r : b == c} → p == q ∙ ! r → ap f p == ap f q ∙ ! (ap f r) ap-shape-∙! f {q = idp} {r = idp} idp = idp ap-!∙ : ∀ {i j} {A : Type i} {B : Type j} (f : A → B) {a b : A} (p : b == a) {c : A} (q : b == c) → ap f (! p ∙ q) == ! (ap f p) ∙ ap f q ap-!∙ f idp idp = idp ∘-ap : ∀ {i j k} {A : Type i} {B : Type j} {C : Type k} (g : B → C) (f : A → B) {x y : A} (p : x == y) → ap g (ap f p) == ap (g ∘ f) p ∘-ap f g p = ! (ap-∘ f g p) ∙idp : ∀ {i} {A : Type i} {a b : A} {p : a == b} → p ∙ idp == p ∙idp {p = idp} = idp idp∙ : ∀ {i} {A : Type i} {a a' : A} {p : a == a'} → idp ∙ p == p idp∙ {p = idp} = idp !-inv-r : ∀ {i} {A : Type i} {a b : A} {p : a == b} → p ∙ ! p == idp !-inv-r {p = idp} = idp !-inv-l : ∀ {i} {A : Type i} {a b : A} {p : a == b} → ! p ∙ p == idp !-inv-l {p = idp} = idp module _ {i} {A : Type i} where horiz-degen-square : {a a' : A} {p q : a == a'} → p == q → Square p idp idp q horiz-degen-square idp = hid-square vert-degen-square : {a a' : A} {p q : a == a'} → p == q → Square idp p q idp vert-degen-square idp = vid-square horiz-degen-path : {a a' : A} {p q : a == a'} → Square p idp idp q → p == q horiz-degen-path {p = idp} ids = idp horiz-degen-square-idp : {a a' : A} {p : a == a'} → horiz-degen-square (idp {a = p}) == hid-square horiz-degen-square-idp {p = idp} = idp horiz-degen-square-β : {a a' : A} {p q : a == a'} {sq : Square p idp idp q} → horiz-degen-square (horiz-degen-path sq) == sq horiz-degen-square-β {p = idp} {sq = ids} = idp horiz-degen-square-η : {a a' : A} {p q : a == a'} {r : p == q} → horiz-degen-path (horiz-degen-square r) == r horiz-degen-square-η {p = idp} {r = idp} = idp module _ {i j} {A : Type i} {B : Type j} {f g : A → B} where natural-square : (h : (a : A) → f a == g a) {x y : A} (p : x == y) → {fp : f x == f y} (fp= : ap f p == fp) → {gp : g x == g y} (gp= : ap g p == gp) → Square (h x) fp gp (h y) natural-square h idp idp idp = hid-square ↓-='-to-square : {x y : A} {p : x == y} {u : f x == g x} {v : f y == g y} → {fp : f x == f y} (fp= : ap f p == fp) → {gp : g x == g y} (gp= : ap g p == gp) → u == v [ (λ z → f z == g z) ↓ p ] → Square u fp gp v ↓-='-to-square {p = idp} idp idp α = horiz-degen-square α ↓-='-from-square : {x y : A} {p : x == y} {u : f x == g x} {v : f y == g y} → {fp : f x == f y} (fp= : ap f p == fp) → {gp : g x == g y} (gp= : ap g p == gp) → Square u fp gp v → u == v [ (λ z → f z == g z) ↓ p ] ↓-='-from-square {p = idp} idp idp sq = horiz-degen-path sq {- Used for getting square equivalents of glue-β terms -} natural-square-β : (h : (a : A) → f a == g a) {x y : A} (p : x == y) {fp : f x == f y} {fp= : ap f p == fp} {gp : g x == g y} {gp= : ap g p == gp} {sq : Square (h x) fp gp (h y)} → apd h p == ↓-='-from-square fp= gp= sq → natural-square h p fp= gp= == sq natural-square-β _ idp {fp= = idp} {gp= = idp} α = ! horiz-degen-square-idp ∙ ap horiz-degen-square α ∙ horiz-degen-square-β module _ {i j k} {A : Type i} {B : Type j} (C : B → Type k) (f : A → B) where ↓-ap-in2 : {x y : A} {p : x == y} {u : C (f x)} {v : C (f y)} {fp : f x == f y} (fp= : ap f p == fp) → u == v [ C ∘ f ↓ p ] → u == v [ C ↓ fp ] ↓-ap-in2 {p = idp} idp idp = idp module _ {i j k} {A : Type i} {B : Type j} (C : B → Type k) {f : A → B} where ↓-ap-in-coh : {X : Type i} {g : X → A} {x y : X} {p : x == y} {gp : g x == g y} {p-β : ap g p == gp} (h : (a : A) → C (f a)) → ↓-ap-in C f (apd h gp) == ↓-ap-in2 C (f ∘ g) (ap-∘ f g p ∙ ap (ap f) p-β) (apd (h ∘ g) p) ↓-ap-in-coh {p = idp} {p-β = idp} h = idp ↓-PathOver-from-square : ∀ {i j} {A X : Type i} {P : A → Type j} {a b : X → A} {q : (x : X) → a x == b x} {f : (x : X) → P (a x)} {g : (x : X) → P (b x)} {x y : X} {p : x == y} {u : PathOver P (q x) (f x) (g x)} {v : PathOver P (q y) (f y) (g y)} {a-p : a x == a y} {ap= : ap a p == a-p} {b-p : b x == b y} {bp= : ap b p == b-p} → SquareOver P (natural-square q p ap= bp=) u (↓-ap-in2 P a {p = p} ap= (apd f p)) (↓-ap-in2 P b bp= (apd g p)) v → u == v [ (λ z → f z == g z [ P ↓ q z ]) ↓ p ] ↓-PathOver-from-square {p = idp} {ap= = idp} {bp= = idp} pq = coh pq where coh : ∀ {i j} {A : Type i} {P : A → Type j} {a b : A} {q : a == b} {f : P a} {g : P b} {u v : f == g [ P ↓ q ]} → SquareOver P hid-square u idp idp v → u == v coh {q = idp} {u = idp} ids = idp adapt-SquareOver : ∀ {i j} {A : Type i} {P : A → Type j} {a b c d : A} {p : a == b} {q : a == c} {r : b == d} {s : c == d} {sq : Square p q r s} {a' : P a} {b' : P b} {c' : P c} {d' : P d} {p' : a' == b' [ P ↓ p ]} {q' q'2 : a' == c' [ P ↓ q ]} {r' r'2 : b' == d' [ P ↓ r ]} {s' : c' == d' [ P ↓ s ]} (q'= : q' == q'2) (r'= : r' == r'2) → SquareOver P sq p' q' r' s' → SquareOver P sq p' q'2 r'2 s' adapt-SquareOver {sq = ids} idp idp ids = ids ap-square-natural-square : ∀ {i j k} {A : Type i} {B : Type j} {C : Type k} (f : B → C) → Coh ({a b : A} (p : a == b) {u v : A → B} (g : (x : A) → u x == v x) {up : u a == u b} {up= : ap u p == up} {vp : v a == v b} {vp= : ap v p == vp} {fup : ap (λ z → f (u z)) p == ap f up} (fup= : ap-∘ f u p ∙ ap (ap f) up= == fup) {fvp : ap (λ z → f (v z)) p == ap f vp} (fvp= : ap-∘ f v p ∙ ap (ap f) vp= == fvp) → ap-square f (natural-square g p up= vp=) == natural-square (ap f ∘ g) p fup fvp) ap-square-natural-square {i} {j} {k} f = path-induction ap-square-horiz-degen-square : ∀ {i j} {A : Type i} {B : Type j} {f : A → B} {a a' : A} {p p' : a == a'} (p= : p == p') → ap-square f (horiz-degen-square p=) == horiz-degen-square (ap (ap f) p=) ap-square-horiz-degen-square {p = idp} idp = idp adapt-square : ∀ {i} {A : Type i} {a b c d : A} {p : a == b} {q : a == c} {r : b == d} {s : c == d} (sq : Square p q r s) {q' : a == c} (q= : q == q') {r' : b == d} (r= : r == r') → Square p q' r' s adapt-square ids idp idp = ids ap2-idf : ∀ {i} → Coh ({A : Type i} {x y : A} {p q : x == y} {r : p == q} → Square (ap (ap (λ z → z)) r) (ap-idf _) (ap-idf _) r) ap2-idf = path-induction ap-∘3 : ∀ {i j k l} {A : Type i} {B : Type j} {C : Type k} {D : Type l} (f : C → D) (g : B → C) (h : A → B) {a b : A} (p : a == b) → Square (ap-∘ f (g ∘ h) p) (ap-∘ (f ∘ g) h p) (ap (ap f) (ap-∘ g h p)) (ap-∘ f g (ap h p)) ap-∘3 f g h idp = ids _∙□_ : ∀ {i} {A : Type i} {a b c d e f : A} {p : a == b} {q : a == c} {r : b == d} {s : c == d} {t : c == e} {u : d == f} {v : e == f} (sq1 : Square p q r s) (sq2 : Square s t u v) → Square p (q ∙ t) (r ∙ u) v ids ∙□ ids = ids _|∙_ : ∀ {i} {A : Type i} {a b c d : A} {p p' : a == b} {q : a == c} {r : b == d} {s : c == d} (p= : p == p') (sq1 : Square p' q r s) → Square p q r s idp |∙ ids = ids _∙|_ : ∀ {i} {A : Type i} {a b c d : A} {p : a == b} {q : a == c} {r : b == d} {s s' : c == d} (sq1 : Square p q r s) (s= : s == s') → Square p q r s' ids ∙| idp = ids infixr 80 _∙□_ _|∙_ _∙|_ _∙³x_ : ∀ {i} {A : Type i} {a₀₀₀ a₀₁₀ a₁₀₀ a₁₁₀ a₀₀₁ a₀₁₁ a₁₀₁ a₁₁₁ a₀₀₂ a₀₁₂ a₁₀₂ a₁₁₂ : A} {p₀₋₀ : a₀₀₀ == a₀₁₀} {p₋₀₀ : a₀₀₀ == a₁₀₀} {p₋₁₀ : a₀₁₀ == a₁₁₀} {p₁₋₀ : a₁₀₀ == a₁₁₀} {sq₋₋₀ : Square p₀₋₀ p₋₀₀ p₋₁₀ p₁₋₀} -- left {p₀₋₁ : a₀₀₁ == a₀₁₁} {p₋₀₁ : a₀₀₁ == a₁₀₁} {p₋₁₁ : a₀₁₁ == a₁₁₁} {p₁₋₁ : a₁₀₁ == a₁₁₁} {sq₋₋₁ : Square p₀₋₁ p₋₀₁ p₋₁₁ p₁₋₁} -- middle {p₀₋₂ : a₀₀₂ == a₀₁₂} {p₋₀₂ : a₀₀₂ == a₁₀₂} {p₋₁₂ : a₀₁₂ == a₁₁₂} {p₁₋₂ : a₁₀₂ == a₁₁₂} {sq₋₋₂ : Square p₀₋₂ p₋₀₂ p₋₁₂ p₁₋₂} -- right {p₀₀l : a₀₀₀ == a₀₀₁} {p₀₁l : a₀₁₀ == a₀₁₁} {p₁₀l : a₁₀₀ == a₁₀₁} {p₁₁l : a₁₁₀ == a₁₁₁} {sq₀₋l : Square p₀₋₀ p₀₀l p₀₁l p₀₋₁} -- backl {sq₋₀l : Square p₋₀₀ p₀₀l p₁₀l p₋₀₁} -- topl {sq₋₁l : Square p₋₁₀ p₀₁l p₁₁l p₋₁₁} -- bottoml {sq₁₋l : Square p₁₋₀ p₁₀l p₁₁l p₁₋₁} -- frontl {p₀₀r : a₀₀₁ == a₀₀₂} {p₀₁r : a₀₁₁ == a₀₁₂} {p₁₀r : a₁₀₁ == a₁₀₂} {p₁₁r : a₁₁₁ == a₁₁₂} {sq₀₋r : Square p₀₋₁ p₀₀r p₀₁r p₀₋₂} -- backr {sq₋₀r : Square p₋₀₁ p₀₀r p₁₀r p₋₀₂} -- topr {sq₋₁r : Square p₋₁₁ p₀₁r p₁₁r p₋₁₂} -- bottomr {sq₁₋r : Square p₁₋₁ p₁₀r p₁₁r p₁₋₂} -- frontr → Cube sq₋₋₀ sq₋₋₁ sq₀₋l sq₋₀l sq₋₁l sq₁₋l → Cube sq₋₋₁ sq₋₋₂ sq₀₋r sq₋₀r sq₋₁r sq₁₋r → Cube sq₋₋₀ sq₋₋₂ (sq₀₋l ∙□ sq₀₋r) (sq₋₀l ∙□ sq₋₀r) (sq₋₁l ∙□ sq₋₁r) (sq₁₋l ∙□ sq₁₋r) idc ∙³x idc = idc infixr 80 _∙³x_ x-degen-cube : ∀ {i} {A : Type i} {a₀₀ a₀₁ a₁₀ a₁₁ : A} {p₀₋ : a₀₀ == a₀₁} {p₋₀ : a₀₀ == a₁₀} {p₋₁ : a₀₁ == a₁₁} {p₁₋ : a₁₀ == a₁₁} {sq₋₋₀ sq₋₋₁ : Square p₀₋ p₋₀ p₋₁ p₁₋} → sq₋₋₀ == sq₋₋₁ → Cube sq₋₋₀ sq₋₋₁ hid-square hid-square hid-square hid-square x-degen-cube {sq₋₋₀ = ids} idp = idc natural-cube-η∞ : ∀ {i j} {A : Type i} {B : Type j} {u : A → B} {r : (a : A) → u a == u a} (p : ∀ a → r a == idp) {x y : A} (q : x == y) {uq : u x == u y} {uq= : ap u q == uq} → Cube (horiz-degen-square (p x)) (horiz-degen-square (p y)) (natural-square r q uq= uq=) vid-square vid-square vid-square natural-cube-η∞ p idp {uq= = idp} = x-degen-cube idp natural-square-∘ : ∀ {i} {A B C : Type i} {a b : C} (p : a == b) (k : C → A) → Coh ({f g : A → B} (h : (a : A) → f a == g a) {fkp : _} {fkp= : ap (f ∘ k) p == fkp} {gkp : _} {gkp= : ap (g ∘ k) p == gkp} {fkp2 : _} (fkp2= : ∘-ap f k p ∙ fkp= == fkp2) {gkp2 : _} (gkp2= : ∘-ap g k p ∙ gkp= == gkp2) → natural-square (h ∘ k) p fkp= gkp= == natural-square h (ap k p) fkp2 gkp2) natural-square-∘ idp = path-induction _-∙³_ : ∀ {i} {A : Type i} {a₀₀₀ a₀₁₀ a₁₀₀ a₁₁₀ a₀₀₁ a₀₁₁ a₁₀₁ a₁₁₁ : A} {p₀₋₀ : a₀₀₀ == a₀₁₀} {p₋₀₀ : a₀₀₀ == a₁₀₀} {p₋₁₀ : a₀₁₀ == a₁₁₀} {p₁₋₀ : a₁₀₀ == a₁₁₀} {sq₋₋₀ sq₋₋₀' : Square p₀₋₀ p₋₀₀ p₋₁₀ p₁₋₀} -- left {p₀₋₁ : a₀₀₁ == a₀₁₁} {p₋₀₁ : a₀₀₁ == a₁₀₁} {p₋₁₁ : a₀₁₁ == a₁₁₁} {p₁₋₁ : a₁₀₁ == a₁₁₁} {sq₋₋₁ : Square p₀₋₁ p₋₀₁ p₋₁₁ p₁₋₁} -- right {p₀₀ : a₀₀₀ == a₀₀₁} {p₀₁ : a₀₁₀ == a₀₁₁} {p₁₀ : a₁₀₀ == a₁₀₁} {p₁₁ : a₁₁₀ == a₁₁₁} {sq₀₋ : Square p₀₋₀ p₀₀ p₀₁ p₀₋₁} -- back {sq₋₀ : Square p₋₀₀ p₀₀ p₁₀ p₋₀₁} -- top {sq₋₁ : Square p₋₁₀ p₀₁ p₁₁ p₋₁₁} -- bottom {sq₁₋ : Square p₁₋₀ p₁₀ p₁₁ p₁₋₁} -- front → (sq₋₋₀ == sq₋₋₀') → Cube sq₋₋₀' sq₋₋₁ sq₀₋ sq₋₀ sq₋₁ sq₁₋ → Cube sq₋₋₀ sq₋₋₁ sq₀₋ sq₋₀ sq₋₁ sq₁₋ idp -∙³ idc = idc _-|∙³_ : ∀ {i} {A : Type i} → {a₀₀₀ a₀₁₀ : A} {a b p₀₋₀ p₁₋₀ : a₀₀₀ == a₀₁₀} {p : a == b} {q : a == p₀₋₀} {r : b == p₁₋₀} {sq₋₋₀ : p₀₋₀ == p₁₋₀} -- left (α : Square p q r sq₋₋₀) {a₀₀₁ : A} {p₀₀₋ : a₀₀₀ == a₀₀₁} {a₀₁₁ : A} {p₀₁₋ : a₀₁₀ == a₀₁₁} {a₁₀₁ : A} {p₁₀₋ : a₀₀₀ == a₁₀₁} {a₁₁₁ : A} {p₁₁₋ : a₀₁₀ == a₁₁₁} {p₀₋₁ : a₀₀₁ == a₀₁₁} {sq₀₋₋ : Square p₀₋₀ p₀₀₋ p₀₁₋ p₀₋₁} -- back {p₋₀₁ : a₀₀₁ == a₁₀₁} {sq₋₀₋ : Square idp p₀₀₋ p₁₀₋ p₋₀₁} -- top {p₋₁₁ : a₀₁₁ == a₁₁₁} {sq₋₁₋ : Square idp p₀₁₋ p₁₁₋ p₋₁₁} -- bottom {p₁₋₁ : a₁₀₁ == a₁₁₁} {sq₁₋₋ : Square p₁₋₀ p₁₀₋ p₁₁₋ p₁₋₁} -- front {sq₋₋₁ : Square p₀₋₁ p₋₀₁ p₋₁₁ p₁₋₁} -- right → Cube (horiz-degen-square sq₋₋₀) sq₋₋₁ sq₀₋₋ sq₋₀₋ sq₋₁₋ sq₁₋₋ → Cube (horiz-degen-square p) sq₋₋₁ (q |∙ sq₀₋₋ ) sq₋₀₋ sq₋₁₋ (r |∙ sq₁₋₋) ids -|∙³ idc = idc infixr 80 _-|∙³_ adapt-cube : ∀ {i} {A : Type i} {a₀₀₀ a₀₁₀ a₁₀₀ a₁₁₀ a₀₀₁ a₀₁₁ a₁₀₁ a₁₁₁ : A} {p₀₋₀ : a₀₀₀ == a₀₁₀} {p₋₀₀ : a₀₀₀ == a₁₀₀} {p₋₁₀ : a₀₁₀ == a₁₁₀} {p₁₋₀ : a₁₀₀ == a₁₁₀} {sq₋₋₀ : Square p₀₋₀ p₋₀₀ p₋₁₀ p₁₋₀} -- left {p₀₋₁ : a₀₀₁ == a₀₁₁} {p₋₀₁ : a₀₀₁ == a₁₀₁} {p₋₁₁ : a₀₁₁ == a₁₁₁} {p₁₋₁ : a₁₀₁ == a₁₁₁} {sq₋₋₁ : Square p₀₋₁ p₋₀₁ p₋₁₁ p₁₋₁} -- right {p₀₀₋ : a₀₀₀ == a₀₀₁} {p₀₁₋ : a₀₁₀ == a₀₁₁} {p₁₀₋ : a₁₀₀ == a₁₀₁} {p₁₁₋ : a₁₁₀ == a₁₁₁} {sq₀₋₋ : Square p₀₋₀ p₀₀₋ p₀₁₋ p₀₋₁} -- back {sq₋₀₋ : Square p₋₀₀ p₀₀₋ p₁₀₋ p₋₀₁} -- top {sq₋₁₋ : Square p₋₁₀ p₀₁₋ p₁₁₋ p₋₁₁} -- bottom {sq₁₋₋ : Square p₁₋₀ p₁₀₋ p₁₁₋ p₁₋₁} -- front (cube : Cube sq₋₋₀ sq₋₋₁ sq₀₋₋ sq₋₀₋ sq₋₁₋ sq₁₋₋ ) {p₀₀₋' : a₀₀₀ == a₀₀₁} (p₀₀₋= : p₀₀₋ == p₀₀₋') {p₀₁₋' : a₀₁₀ == a₀₁₁} (p₀₁₋= : p₀₁₋ == p₀₁₋') {p₁₀₋' : a₁₀₀ == a₁₀₁} (p₁₀₋= : p₁₀₋ == p₁₀₋') {p₁₁₋' : a₁₁₀ == a₁₁₁} (p₁₁₋= : p₁₁₋ == p₁₁₋') {sq₀₋₋' : Square p₀₋₀ p₀₀₋' p₀₁₋' p₀₋₁} (sq₀₋₋= : adapt-square sq₀₋₋ p₀₀₋= p₀₁₋= == sq₀₋₋') -- back {sq₋₀₋' : Square p₋₀₀ p₀₀₋' p₁₀₋' p₋₀₁} (sq₋₀₋= : adapt-square sq₋₀₋ p₀₀₋= p₁₀₋= == sq₋₀₋') -- top {sq₋₁₋' : Square p₋₁₀ p₀₁₋' p₁₁₋' p₋₁₁} (sq₋₁₋= : adapt-square sq₋₁₋ p₀₁₋= p₁₁₋= == sq₋₁₋') -- bottom {sq₁₋₋' : Square p₁₋₀ p₁₀₋' p₁₁₋' p₁₋₁} (sq₁₋₋= : adapt-square sq₁₋₋ p₁₀₋= p₁₁₋= == sq₁₋₋') -- front → Cube sq₋₋₀ sq₋₋₁ sq₀₋₋' sq₋₀₋' sq₋₁₋' sq₁₋₋' adapt-cube idc idp idp idp idp idp idp idp idp = idc adapt-cube-idp : ∀ {i} {A : Type i} {a₀₀₀ a₀₁₀ a₁₀₀ a₁₁₀ a₀₀₁ a₀₁₁ a₁₀₁ a₁₁₁ : A} {p₀₋₀ : a₀₀₀ == a₀₁₀} {p₋₀₀ : a₀₀₀ == a₁₀₀} {p₋₁₀ : a₀₁₀ == a₁₁₀} {p₁₋₀ : a₁₀₀ == a₁₁₀} {sq₋₋₀ : Square p₀₋₀ p₋₀₀ p₋₁₀ p₁₋₀} -- left {p₀₋₁ : a₀₀₁ == a₀₁₁} {p₋₀₁ : a₀₀₁ == a₁₀₁} {p₋₁₁ : a₀₁₁ == a₁₁₁} {p₁₋₁ : a₁₀₁ == a₁₁₁} {sq₋₋₁ : Square p₀₋₁ p₋₀₁ p₋₁₁ p₁₋₁} -- right {p₀₀₋ : a₀₀₀ == a₀₀₁} {p₀₁₋ : a₀₁₀ == a₀₁₁} {p₁₀₋ : a₁₀₀ == a₁₀₁} {p₁₁₋ : a₁₁₀ == a₁₁₁} {sq₀₋₋ : Square p₀₋₀ p₀₀₋ p₀₁₋ p₀₋₁} -- back {sq₋₀₋ : Square p₋₀₀ p₀₀₋ p₁₀₋ p₋₀₁} -- top {sq₋₁₋ : Square p₋₁₀ p₀₁₋ p₁₁₋ p₋₁₁} -- bottom {sq₁₋₋ : Square p₁₋₀ p₁₀₋ p₁₁₋ p₁₋₁} -- front (cube : Cube sq₋₋₀ sq₋₋₁ sq₀₋₋ sq₋₀₋ sq₋₁₋ sq₁₋₋ ) {sq₀₋₋' : Square p₀₋₀ p₀₀₋ p₀₁₋ p₀₋₁} (sq₀₋₋= : sq₀₋₋ == sq₀₋₋') -- back {sq₋₀₋' : Square p₋₀₀ p₀₀₋ p₁₀₋ p₋₀₁} (sq₋₀₋= : sq₋₀₋ == sq₋₀₋') -- top {sq₋₁₋' : Square p₋₁₀ p₀₁₋ p₁₁₋ p₋₁₁} (sq₋₁₋= : sq₋₁₋ == sq₋₁₋') -- bottom {sq₁₋₋' : Square p₁₋₀ p₁₀₋ p₁₁₋ p₁₋₁} (sq₁₋₋= : sq₁₋₋ == sq₁₋₋') -- front → Cube sq₋₋₀ sq₋₋₁ sq₀₋₋' sq₋₀₋' sq₋₁₋' sq₁₋₋' adapt-cube-idp idc idp idp idp idp = idc {- A SquareOver between paths can be represented as a cube -} module _ {i j} {A : Type i} {B : Type j} {f g : A → B} where cube-to-↓-square : {a : A} {a= : f a == g a} {b : A} {p : a == b} {c : A} {q : a == c} {d : A} {r : b == d} {s : c == d} {sq : Square p q r s} {fp : _} {fp= : ap f p == fp} {fq : _} {fq= : ap f q == fq} {fr : _} {fr= : ap f r == fr} {fs : _} {fs= : ap f s == fs} {b= : f b == g b} (p= : Square fp a= b= (ap g p)) {c= : f c == g c} {q= : Square fq a= c= (ap g q)} {q□ : PathOver (λ z → f z == g z) q a= c=} (q□= : q□ == ↓-='-from-square fq= idp (square-symmetry q=)) {d= : f d == g d} {r= : Square b= fr (ap g r) d=} {r□ : PathOver (λ z → f z == g z) r b= d=} (r□= : r□ == ↓-='-from-square fr= idp r=) (s= : Square fs c= d= (ap g s)) → Cube (ap-square f sq) (ap-square g sq) (fp= |∙ p=) (fq= |∙ q=) (fr= |∙ square-symmetry r=) (fs= |∙ s=) → SquareOver (λ z → f z == g z) sq (↓-='-from-square fp= idp (square-symmetry p=)) q□ r□ (↓-='-from-square fs= idp (square-symmetry s=)) cube-to-↓-square {sq = ids} {fp= = idp} {fq= = idp} {fr= = idp} {fs= = idp} p= idp idp s= cube = & coh cube (& coh2) where coh : Coh ({A : Type j} {x y : A} {a= b= : x == y} {p= : Square idp a= b= idp} {c= : x == y} {q= : Square idp a= c= idp} {d= : x == y} {r= : Square b= idp idp d=} {s=' : Square idp c= d= idp} → Cube ids ids (idp |∙ p=) (idp |∙ q=) (idp |∙ square-symmetry r=) s=' → {s= : Square idp c= d= idp} (s== : s= == s=') → Square (horiz-degen-path (square-symmetry p=)) (horiz-degen-path (square-symmetry q=)) (horiz-degen-path r=) (horiz-degen-path (square-symmetry s=))) coh = path-induction coh2 : Coh ({A : Type j} {a b c d : A} {p : a == b} {q : a == c} {r : b == d} {s : c == d} {sq : Square p q r s} → sq == idp |∙ sq) coh2 = path-induction x-degen-cube-in : ∀ {i} → Coh ({A : Type i} {a b c d : A} {p : a == b} {q : a == c} {r : b == d} {s : c == d} {sq sq' : Square p q r s} → sq == sq' → Cube sq sq' hid-square hid-square hid-square hid-square) x-degen-cube-in = path-induction x-degen-cube-out : ∀ {i} → Coh ({A : Type i} {a b c d : A} {p : a == b} {q : a == c} {r : b == d} {s : c == d} {sq sq' : Square p q r s} → Cube sq sq' hid-square hid-square hid-square hid-square → sq == sq') x-degen-cube-out = path-induction {- A pathover between squares can be represented as a cube -} module _ {i j} {A : Type i} {B : Type j} {b₀₀ b₀₁ b₁₀ b₁₁ : A → B} {p₀₋ : (a : A) → b₀₀ a == b₀₁ a} {p₋₀ : (a : A) → b₀₀ a == b₁₀ a} {p₋₁ : (a : A) → b₀₁ a == b₁₁ a} {p₁₋ : (a : A) → b₁₀ a == b₁₁ a} where cube-to-↓-path : {x y : A} {q : x == y} {sqx : Square (p₀₋ x) (p₋₀ x) (p₋₁ x) (p₁₋ x)} {sqy : Square (p₀₋ y) (p₋₀ y) (p₋₁ y) (p₁₋ y)} {b₀₀q : b₀₀ x == b₀₀ y} (b₀₀q= : ap b₀₀ q == b₀₀q) {b₀₁q : b₀₁ x == b₀₁ y} (b₀₁q= : ap b₀₁ q == b₀₁q) {b₁₀q : b₁₀ x == b₁₀ y} (b₁₀q= : ap b₁₀ q == b₁₀q) {b₁₁q : b₁₁ x == b₁₁ y} (b₁₁q= : ap b₁₁ q == b₁₁q) → Cube sqx sqy (natural-square p₀₋ q b₀₀q= b₀₁q=) (natural-square p₋₀ q b₀₀q= b₁₀q=) (natural-square p₋₁ q b₀₁q= b₁₁q=) (natural-square p₁₋ q b₁₀q= b₁₁q=) → sqx == sqy [ (λ z → Square (p₀₋ z) (p₋₀ z) (p₋₁ z) (p₁₋ z)) ↓ q ] cube-to-↓-path {q = idp} idp idp idp idp cu = & x-degen-cube-out cu _|∙³_ : ∀ {i} {A : Type i} {a₀₀₀ a₀₁₀ a₁₀₀ a₁₁₀ a₀₀₁ a₀₁₁ a₁₀₁ a₁₁₁ : A} {p₀₋₀ p₀₋₀' : a₀₀₀ == a₀₁₀} {p₋₀₀ p₋₀₀' : a₀₀₀ == a₁₀₀} {p₋₁₀ p₋₁₀' : a₀₁₀ == a₁₁₀} {p₁₋₀ p₁₋₀' : a₁₀₀ == a₁₁₀} {sq₋₋₀ : Square p₀₋₀ p₋₀₀ p₋₁₀ p₁₋₀} -- left {p₀₋₀= : p₀₋₀ == p₀₋₀'} {p₋₀₀= : p₋₀₀ == p₋₀₀'} {p₋₁₀= : p₋₁₀ == p₋₁₀'} {p₁₋₀= : p₁₋₀ == p₁₋₀'} {sq₋₋₀' : Square p₀₋₀' p₋₀₀' p₋₁₀' p₁₋₀'} -- middle {p₀₋₁ : a₀₀₁ == a₀₁₁} {p₋₀₁ : a₀₀₁ == a₁₀₁} {p₋₁₁ : a₀₁₁ == a₁₁₁} {p₁₋₁ : a₁₀₁ == a₁₁₁} {sq₋₋₁ : Square p₀₋₁ p₋₀₁ p₋₁₁ p₁₋₁} -- right {p₀₀₋ : a₀₀₀ == a₀₀₁} {p₀₁₋ : a₀₁₀ == a₀₁₁} {p₁₀₋ : a₁₀₀ == a₁₀₁} {p₁₁₋ : a₁₁₀ == a₁₁₁} {sq₀₋₋ : Square p₀₋₀' p₀₀₋ p₀₁₋ p₀₋₁} -- back {sq₋₀₋ : Square p₋₀₀' p₀₀₋ p₁₀₋ p₋₀₁} -- top {sq₋₁₋ : Square p₋₁₀' p₀₁₋ p₁₁₋ p₋₁₁} -- bottom {sq₁₋₋ : Square p₁₋₀' p₁₀₋ p₁₁₋ p₁₋₁} -- front → FlatCube sq₋₋₀ sq₋₋₀' p₀₋₀= p₋₀₀= p₋₁₀= p₁₋₀= → Cube sq₋₋₀' sq₋₋₁ sq₀₋₋ sq₋₀₋ sq₋₁₋ sq₁₋₋ → Cube sq₋₋₀ sq₋₋₁ (p₀₋₀= |∙ sq₀₋₋) (p₋₀₀= |∙ sq₋₀₋) (p₋₁₀= |∙ sq₋₁₋) (p₁₋₀= |∙ sq₁₋₋) idfc |∙³ idc = idc _/∙³_ : ∀ {i} {A : Type i} {a b c d : A} {p p' : a == b} {q q' : a == c} {r r' : b == d} {s s' : c == d} {sq sq2 : Square p q r s} (sq= : sq == sq2) {sq' : Square p' q' r' s'} {p= : p == p'} {q= : q == q'} {r= : r == r'} {s= : s == s'} → FlatCube sq2 sq' p= q= r= s= → FlatCube sq sq' p= q= r= s= idp /∙³ idfc = idfc _∙³/_ : ∀ {i} {A : Type i} {a b c d : A} {p p' : a == b} {q q' : a == c} {r r' : b == d} {s s' : c == d} {sq : Square p q r s} {sq' : Square p' q' r' s'} {p= : p == p'} {q= : q == q'} {r= : r == r'} {s= : s == s'} → FlatCube sq sq' p= q= r= s= → {sq'2 : Square p' q' r' s'} → sq' == sq'2 → FlatCube sq sq'2 p= q= r= s= idfc ∙³/ idp = idfc _∙fc_ : ∀ {i} {A : Type i} {a b c d : A} {p p' p'' : a == b} {q q' q'' : a == c} {r r' r'' : b == d} {s s' s'' : c == d} {sq : Square p q r s} {sq' : Square p' q' r' s'} {sq'' : Square p'' q'' r'' s''} {p= : p == p'} {q= : q == q'} {r= : r == r'} {s= : s == s'} {p=' : p' == p''} {q=' : q' == q''} {r=' : r' == r''} {s=' : s' == s''} → FlatCube sq sq' p= q= r= s= → FlatCube sq' sq'' p=' q=' r=' s=' → FlatCube sq sq'' (p= ∙ p=') (q= ∙ q=') (r= ∙ r=') (s= ∙ s=') idfc ∙fc idfc = idfc infixr 80 _|∙³_ _-∙³_ _/∙³_ _∙fc_ _∙³/_ adapt-flatcube : ∀ {i} {A : Type i} {a b c d : A} {p p' : a == b} {q q' : a == c} {r r' : b == d} {s s' : c == d} {p= p=' : p == p'} (p== : p= == p=') {q= q=' : q == q'} (q== : q= == q=') {r= r=' : r == r'} (r== : r= == r=') {s= s=' : s == s'} (s== : s= == s=') {sq : Square p q r s} {sq' : Square p' q' r' s'} → FlatCube sq sq' p= q= r= s= → FlatCube sq sq' p=' q=' r=' s=' adapt-flatcube idp idp idp idp idfc = idfc !² : ∀ {i} {A : Type i} {a b c d : A} {p : a == b} {q : a == c} {r : b == d} {s : c == d} → Square p q r s → Square s (! q) (! r) p !² ids = ids !³ : ∀ {i} {A : Type i} {a₀₀₀ a₀₁₀ a₁₀₀ a₁₁₀ a₀₀₁ a₀₁₁ a₁₀₁ a₁₁₁ : A} {p₀₋₀ : a₀₀₀ == a₀₁₀} {p₋₀₀ : a₀₀₀ == a₁₀₀} {p₋₁₀ : a₀₁₀ == a₁₁₀} {p₁₋₀ : a₁₀₀ == a₁₁₀} {sq₋₋₀ : Square p₀₋₀ p₋₀₀ p₋₁₀ p₁₋₀} -- left {p₀₋₁ : a₀₀₁ == a₀₁₁} {p₋₀₁ : a₀₀₁ == a₁₀₁} {p₋₁₁ : a₀₁₁ == a₁₁₁} {p₁₋₁ : a₁₀₁ == a₁₁₁} {sq₋₋₁ : Square p₀₋₁ p₋₀₁ p₋₁₁ p₁₋₁} -- right {p₀₀ : a₀₀₀ == a₀₀₁} {p₀₁ : a₀₁₀ == a₀₁₁} {p₁₀ : a₁₀₀ == a₁₀₁} {p₁₁ : a₁₁₀ == a₁₁₁} {sq₀₋ : Square p₀₋₀ p₀₀ p₀₁ p₀₋₁} -- back {sq₋₀ : Square p₋₀₀ p₀₀ p₁₀ p₋₀₁} -- top {sq₋₁ : Square p₋₁₀ p₀₁ p₁₁ p₋₁₁} -- bottom {sq₁₋ : Square p₁₋₀ p₁₀ p₁₁ p₁₋₁} -- front → Cube sq₋₋₀ sq₋₋₁ sq₀₋ sq₋₀ sq₋₁ sq₁₋ → Cube sq₋₋₁ sq₋₋₀ (!² sq₀₋) (!² sq₋₀) (!² sq₋₁) (!² sq₁₋) !³ idc = idc natural-square-homotopy : ∀ {i j} {A : Type i} {B : Type j} {a : A} → Coh ({u v : A → B} {f g : (x : A) → u x == v x} (h : (x : A) → f x == g x) {b : A} (p : a == b) {up : u a == u b} {up= : ap u p == up} {vp : v a == v b} {vp= : ap v p == vp} → FlatCube (natural-square f p up= vp=) (natural-square g p up= vp=) (h a) idp idp (h b)) natural-square-homotopy = path-induction natural-cube2 : ∀ {i j} {A : Type i} {B : Type j} {a : A} → Coh ({f g : A → B} (h : (a : A) → f a == g a) {b : A} {p : a == b} {c : A} {q : a == c} {d : A} {r : b == d} {s : c == d} (sq : Square p q r s) {fp : f a == f b} {fp= : ap f p == fp} {gp : g a == g b} {gp= : ap g p == gp} {fq : f a == f c} {fq= : ap f q == fq} {gq : g a == g c} {gq= : ap g q == gq} {fr : f b == f d} {fr= : ap f r == fr} {gr : g b == g d} {gr= : ap g r == gr} {fs : f c == f d} {fs= : ap f s == fs} {gs : g c == g d} {gs= : ap g s == gs} {fsq : Square fp fq fr fs} (fsq= : FlatCube (ap-square f sq) fsq fp= fq= fr= fs=) {gsq : Square gp gq gr gs} (gsq= : FlatCube (ap-square g sq) gsq gp= gq= gr= gs=) → Cube (natural-square h p fp= gp=) (natural-square h s fs= gs=) (natural-square h q fq= gq=) fsq gsq (natural-square h r fr= gr=)) natural-cube2 = path-induction ap-square-idf : ∀ {i} {A : Type i} {a b c d : A} {p : a == b} {q : a == c} {r : b == d} {s : c == d} (sq : Square p q r s) → FlatCube (ap-square (λ z → z) sq) sq (ap-idf p) (ap-idf q) (ap-idf r) (ap-idf s) ap-square-idf ids = idfc hid-flatcube : ∀ {i} {A : Type i} {a b c d : A} {p : a == b} {q : a == c} {r : b == d} {s : c == d} (sq : Square p q r s) → FlatCube sq sq idp idp idp idp hid-flatcube ids = idfc module _ {i j} {A : Type i} {B : Type j} where natural-square= : Coh ({f g : A → B} (h : (a : A) → f a == g a) {x y : A} {p p' : x == y} (p= : p == p') → {fp : f x == f y} {fp= : ap f p == fp} {fp' : f x == f y} {fp=' : ap f p' == fp'} → {gp : g x == g y} {gp= : ap g p == gp} {gp' : g x == g y} {gp=' : ap g p' == gp'} → {fp=fp' : fp == fp'} (fp=fp'= : Square (ap (ap f) p=) fp= fp=' fp=fp') → {gp=gp' : gp == gp'} (gp=gp'= : Square (ap (ap g) p=) gp= gp=' gp=gp') → FlatCube (natural-square h p fp= gp=) (natural-square h p' fp=' gp=') idp fp=fp' gp=gp' idp) natural-square= = path-induction -- More or less a special case of the previous one natural-square== : Coh ({f g : A → B} (h : (a : A) → f a == g a) {x y : A} (p : x == y) → {fp : f x == f y} {fp= : ap f p == fp} {fp' : f x == f y} {fp=' : ap f p == fp'} → {gp : g x == g y} {gp= : ap g p == gp} {gp' : g x == g y} {gp=' : ap g p == gp'} → {fpp' : fp == fp'} (fpp'= : ! fp= ∙ fp=' == fpp') → {gpp' : gp == gp'} (gpp'= : ! gp= ∙ gp=' == gpp') → FlatCube (natural-square h p fp= gp=) (natural-square h p fp=' gp=') idp fpp' gpp' idp) natural-square== = path-induction ∘-ap-square : ∀ {i j k} {A : Type i} {B : Type j} {C : Type k} (g : B → C) (f : A → B) {a b c d : A} {p : a == b} {q : a == c} {r : b == d} {s : c == d} (sq : Square p q r s) → FlatCube (ap-square g (ap-square f sq)) (ap-square (g ∘ f) sq) (∘-ap g f p) (∘-ap g f q) (∘-ap g f r) (∘-ap g f s) ∘-ap-square g f ids = idfc ap-square-∘ : ∀ {i j k} {A : Type i} {B : Type j} {C : Type k} (g : B → C) (f : A → B) {a b c d : A} {p : a == b} {q : a == c} {r : b == d} {s : c == d} (sq : Square p q r s) → FlatCube (ap-square (g ∘ f) sq) (ap-square g (ap-square f sq)) (ap-∘ g f p) (ap-∘ g f q) (ap-∘ g f r) (ap-∘ g f s) ap-square-∘ g f ids = idfc -- Similar to [ap-square-natural-square] natural-square-ap : ∀ {i j k} {A : Type i} {B : Type j} {C : Type k} (f : B → C) → Coh ({a b : A} (p : a == b) {u v : A → B} (g : (x : A) → u x == v x) {fup : _} {fup= : ap (f ∘ u) p == fup} {fvp : _} {fvp= : ap (f ∘ v) p == fvp} {up : _} {up= : ap u p == up} {vp : _} {vp= : ap v p == vp} {apfup : ap f up == fup} (apfup= : Square (∘-ap f u p) (ap (ap f) up=) fup= apfup) {apfvp : ap f vp == fvp} (apfvp= : Square (∘-ap f v p) (ap (ap f) vp=) fvp= apfvp) → natural-square (ap f ∘ g) p fup= fvp= == adapt-square (ap-square f (natural-square g p up= vp=)) apfup apfvp) natural-square-ap f = path-induction cube-rotate : ∀ {i} {A : Type i} {a₀₀₀ a₀₁₀ a₁₀₀ a₁₁₀ a₀₀₁ a₀₁₁ a₁₀₁ a₁₁₁ : A} {p₀₋₀ : a₀₀₀ == a₀₁₀} {p₋₀₀ : a₀₀₀ == a₁₀₀} {p₋₁₀ : a₀₁₀ == a₁₁₀} {p₁₋₀ : a₁₀₀ == a₁₁₀} {sq₋₋₀ : Square p₀₋₀ p₋₀₀ p₋₁₀ p₁₋₀} -- left {p₀₋₁ : a₀₀₁ == a₀₁₁} {p₋₀₁ : a₀₀₁ == a₁₀₁} {p₋₁₁ : a₀₁₁ == a₁₁₁} {p₁₋₁ : a₁₀₁ == a₁₁₁} {sq₋₋₁ : Square p₀₋₁ p₋₀₁ p₋₁₁ p₁₋₁} -- right {p₀₀₋ : a₀₀₀ == a₀₀₁} {p₀₁₋ : a₀₁₀ == a₀₁₁} {p₁₀₋ : a₁₀₀ == a₁₀₁} {p₁₁₋ : a₁₁₀ == a₁₁₁} {sq₀₋₋ : Square p₀₋₀ p₀₀₋ p₀₁₋ p₀₋₁} -- back {sq₋₀₋ : Square p₋₀₀ p₀₀₋ p₁₀₋ p₋₀₁} -- top {sq₋₁₋ : Square p₋₁₀ p₀₁₋ p₁₁₋ p₋₁₁} -- bottom {sq₁₋₋ : Square p₁₋₀ p₁₀₋ p₁₁₋ p₁₋₁} -- front → Cube sq₋₋₀ sq₋₋₁ sq₀₋₋ sq₋₀₋ sq₋₁₋ sq₁₋₋ → Cube sq₀₋₋ sq₁₋₋ sq₋₋₀ (square-symmetry sq₋₀₋) (square-symmetry sq₋₁₋) sq₋₋₁ cube-rotate idc = idc horiz-degen-path-hid-square : ∀ {i} → Coh ({A : Type i} {x y : A} {p : x == y} → idp == horiz-degen-path (horiz-degen-square (idp {a = p}))) horiz-degen-path-hid-square = path-induction module _ {i j k} {A : Type i} {B : Type j} {C : Type k} {g h : B → C} (f : A → B) where ↓-ap-in-=' : {x y : A} {p : x == y} (k : (x : A) → g (f x) == h (f x)) {gfp : g (f x) == g (f y)} {gfp= : ap g (ap f p) == gfp} → ↓-ap-in (λ z → g z == h z) f (apd k p) == ↓-='-from-square gfp= idp (natural-square k p (ap-∘ g f p ∙ gfp=) (ap-∘ h f p)) ↓-ap-in-=' {p = idp} k {gfp= = idp} = & horiz-degen-path-hid-square module _ {i j} {A : Type i} {a : A} where instance JCubehorizdegensquare : {B : (p : idp {a = a} == idp) → Cube ids (horiz-degen-square p) ids ids ids ids → Type j} → Coh (B idp idc) → Coh ({p : idp == idp} (cube : Cube ids (horiz-degen-square p) ids ids ids ids) → B p cube) & (JCubehorizdegensquare {B} d) cube = B= (! horiz-degen-square-η) (! horiz-degen-square-β) horiz-degen-square-◂ cube (& (JCube2 {B = B'} d) cube) where B' : (p : Square {a₀₀ = a} idp idp idp idp) → Cube ids p ids ids ids ids → Type j B' p c = B (horiz-degen-path p) (c ∙³x & x-degen-cube-in (! horiz-degen-square-β)) horiz-degen-square-◂ : ∀ {i} {A : Type i} {a a' : A} {p q : a == a'} {r : p == q} → ap horiz-degen-square (! (horiz-degen-square-η {r = r})) == ! horiz-degen-square-β horiz-degen-square-◂ {p = idp} {r = idp} = idp B= : {p' p : idp == idp} (p= : p == p') (p=' : horiz-degen-square p == horiz-degen-square p') (p== : ap horiz-degen-square p= == p=') (c : Cube ids (horiz-degen-square p) ids ids ids ids) → B p' (c ∙³x & x-degen-cube-in p=') → B p c B= idp _ idp c = transport (B _) (& eq c) where eq : Coh ({sq : Square (idp {a = a}) idp idp idp} (c : Cube ids sq ids ids ids ids) → c ∙³x & x-degen-cube-in idp == c) eq = path-induction
{ "alphanum_fraction": 0.453452381, "avg_line_length": 45.0160771704, "ext": "agda", "hexsha": "2b1ecc8df06dfe547f7d7d6bf5435ea947bbda0d", "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": "PathInduction.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": "PathInduction.agda", "max_line_length": 195, "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": "PathInduction.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": 21973, "size": 42000 }
module lib where open import datatypes public open import logic public open import thms public open import termination public open import error public open import io public
{ "alphanum_fraction": 0.8390804598, "avg_line_length": 19.3333333333, "ext": "agda", "hexsha": "070a2361dfb5c82f5c0b4cd0f0edc43f38933ac4", "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": "lib.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": "lib.agda", "max_line_length": 30, "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": "lib.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": 36, "size": 174 }
{-# OPTIONS --without-K --safe #-} -- Take a relation that is already reflexive and transitive -- and make it symmetric. -- (Borrowed from Categories/Support/ZigZag from copumpkin's Categories library module Relation.Binary.Construct.Symmetrize where open import Level open import Relation.Binary open import Relation.Binary.Construct.On using () renaming (isEquivalence to on-preserves-equivalence) data Direction : Set where ↘ ↗ : Direction rotate : Direction → Direction rotate ↘ = ↗ rotate ↗ = ↘ private variable c ℓ₁ ℓ₂ : Level Carrier : Set c data ZigZag′ (_∼_ : Rel Carrier ℓ₂) : (x y : Carrier) (begin end : Direction) → Set (levelOfTerm x ⊔ ℓ₂) where zig : ∀ {x y z e} (first : x ∼ y) (rest : ZigZag′ _∼_ y z ↗ e) → ZigZag′ _∼_ x z ↘ e zag : ∀ {x y z e} (first : y ∼ x) (rest : ZigZag′ _∼_ y z ↘ e) → ZigZag′ _∼_ x z ↗ e slish : ∀ {x y} (last : x ∼ y) → ZigZag′ _∼_ x y ↘ ↘ slash : ∀ {x y} (last : y ∼ x) → ZigZag′ _∼_ x y ↗ ↗ data Alternating′ (_∼_ : Carrier -> Carrier -> Set ℓ₂) (x y : Carrier) : Set (levelOfTerm x ⊔ ℓ₂) where disorient : ∀ {begin end} (zz : ZigZag′ _∼_ x y begin end) → Alternating′ _∼_ x y module _ (Base : Preorder c ℓ₁ ℓ₂) where ZigZag : (x y : Preorder.Carrier Base) (begin end : Direction) → Set (c ⊔ ℓ₂) ZigZag = ZigZag′ (Preorder._∼_ Base) private sym′ : {x y z : Preorder.Carrier Base} {begin middle end : Direction} → ZigZag y z middle end → ZigZag y x middle begin → ZigZag z x (rotate end) begin sym′ (zig first rest) accum = sym′ rest (zag first accum) sym′ (zag first rest) accum = sym′ rest (zig first accum) sym′ (slish last) accum = zag last accum sym′ (slash last) accum = zig last accum sym : ∀ {x y begin end} → ZigZag x y begin end → ZigZag y x (rotate end) (rotate begin) sym (zig first rest) = sym′ rest (slash first) sym (zag first rest) = sym′ rest (slish first) sym (slish last) = slash last sym (slash last) = slish last trans : ∀ {x y z begin end begin′ end′} → ZigZag x y begin end → ZigZag y z begin′ end′ → ZigZag x z begin end′ trans (zig first rest) yz = zig first (trans rest yz) trans (zag first rest) yz = zag first (trans rest yz) trans (slish last) (zig first rest) = zig (Preorder.trans Base last first) rest trans (slish last) (zag first rest) = zig last (zag first rest) trans (slish last) (slish only) = slish (Preorder.trans Base last only) trans (slish last) (slash only) = zig last (slash only) trans (slash last) (zig first rest) = zag last (zig first rest) trans (slash last) (zag first rest) = zag (Preorder.trans Base first last) rest trans (slash last) (slish only) = zag last (slish only) trans (slash last) (slash only) = slash (Preorder.trans Base only last) Alternating : (x y : Preorder.Carrier Base) → Set (c ⊔ ℓ₂) Alternating = Alternating′ (Preorder._∼_ Base) private is-equivalence : IsEquivalence Alternating is-equivalence = record { refl = disorient (slash (Preorder.refl Base)) ; sym = λ where (disorient zz) → disorient (sym zz) ; trans = λ where (disorient ij) (disorient jk) → disorient (trans ij jk) } setoid : Setoid c (c ⊔ ℓ₂) setoid = record { Carrier = Preorder.Carrier Base ; _≈_ = Alternating ; isEquivalence = is-equivalence } -- the main eliminators for Alternating -- they prove that any equivalence that -- respects the base preorder also respects its Alternating completion. locally-minimal : ∀ {ℓ′} {_≈_ : Rel (Preorder.Carrier Base) ℓ′} (≈-isEquivalence : IsEquivalence _≈_) → (Preorder._∼_ Base ⇒ _≈_) → (Alternating ⇒ _≈_) locally-minimal {_} {_≋_} isEq inj (disorient zz) = impl zz where open IsEquivalence isEq renaming (sym to >sym; trans to _>trans>_) impl : {i j : Preorder.Carrier Base} {b e : Direction} → ZigZag i j b e → i ≋ j impl (zig first rest) = inj first >trans> impl rest impl (zag first rest) = >sym (inj first) >trans> impl rest impl (slish last) = inj last impl (slash last) = >sym (inj last) minimal : ∀ {c′ ℓ′} (Dest : Setoid c′ ℓ′) (f : Preorder.Carrier Base → Setoid.Carrier Dest) → (Preorder._∼_ Base =[ f ]⇒ Setoid._≈_ Dest) → (Alternating =[ f ]⇒ Setoid._≈_ Dest) minimal Dest f inj = locally-minimal (on-preserves-equivalence f (Setoid.isEquivalence Dest)) inj
{ "alphanum_fraction": 0.6489288182, "avg_line_length": 43.8484848485, "ext": "agda", "hexsha": "346183f569ea537c782232a9cbf131fb26993c46", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "6ebc1349ee79669c5c496dcadd551d5bbefd1972", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Taneb/agda-categories", "max_forks_repo_path": "Relation/Binary/Construct/Symmetrize.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "6ebc1349ee79669c5c496dcadd551d5bbefd1972", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Taneb/agda-categories", "max_issues_repo_path": "Relation/Binary/Construct/Symmetrize.agda", "max_line_length": 113, "max_stars_count": null, "max_stars_repo_head_hexsha": "6ebc1349ee79669c5c496dcadd551d5bbefd1972", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Taneb/agda-categories", "max_stars_repo_path": "Relation/Binary/Construct/Symmetrize.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1470, "size": 4341 }
open import Prelude module Implicits.Resolution.Ambiguous.Resolution where open import Data.Fin.Substitution open import Data.List open import Data.List.Any open Membership-≡ open import Implicits.Syntax open import Implicits.Substitutions data _⊢ᵣ_ {ν} (Δ : ICtx ν) : Type ν → Set where r-tabs : ∀ {r} → ictx-weaken Δ ⊢ᵣ r → Δ ⊢ᵣ ∀' r r-tapp : ∀ {r} a → Δ ⊢ᵣ ∀' r → Δ ⊢ᵣ (r tp[/tp a ]) r-ivar : ∀ {r} → r ∈ Δ → Δ ⊢ᵣ r r-iabs : ∀ {a b} → (a ∷ Δ) ⊢ᵣ b → Δ ⊢ᵣ (a ⇒ b) r-iapp : ∀ {a b} → Δ ⊢ᵣ (a ⇒ b) → Δ ⊢ᵣ a → Δ ⊢ᵣ b
{ "alphanum_fraction": 0.5943396226, "avg_line_length": 27.8947368421, "ext": "agda", "hexsha": "9b8096884ec0e43b5d58eee73049b9bfad9e8267", "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": "7fe638b87de26df47b6437f5ab0a8b955384958d", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "metaborg/ts.agda", "max_forks_repo_path": "src/Implicits/Resolution/Ambiguous/Resolution.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "7fe638b87de26df47b6437f5ab0a8b955384958d", "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": "metaborg/ts.agda", "max_issues_repo_path": "src/Implicits/Resolution/Ambiguous/Resolution.agda", "max_line_length": 54, "max_stars_count": 4, "max_stars_repo_head_hexsha": "7fe638b87de26df47b6437f5ab0a8b955384958d", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "metaborg/ts.agda", "max_stars_repo_path": "src/Implicits/Resolution/Ambiguous/Resolution.agda", "max_stars_repo_stars_event_max_datetime": "2021-05-07T04:08:41.000Z", "max_stars_repo_stars_event_min_datetime": "2019-04-05T17:57:11.000Z", "num_tokens": 246, "size": 530 }
-- Andreas, 2015-07-20, record patterns open import Common.Prelude postulate A : Set record R : Set where field f : A T : Bool → Set T true = R T false = A test : ∀{b} → T b → A test record{f = a} = a -- Could succeed by some magic.
{ "alphanum_fraction": 0.6280991736, "avg_line_length": 13.4444444444, "ext": "agda", "hexsha": "5362fb908237d391fff36cac830b9c05c9dc8797", "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/RecordPattern5.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/RecordPattern5.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/Fail/RecordPattern5.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": 242 }
module AnnotatedTypes where {- -- ATypes are stratified such that that dynamically bound -- functions can only have dynamically bound parameters. -- TODO: why exactly is that necessary? -- Think about the example of the evaluation of a dynamic function with -- static components -- The following well-formedness relation as an alternative representation -- for this constraint: module AType-WF where open import Relation.Binary.PropositionalEquality -- Static and dynamic binding times data BT : Set where stat : BT dyn : BT -- Ordering on binding times: dynamic binding time subsumes static -- binding time. data _≤-bt_ : BT → BT → Set where bt≤bt : ∀ bt → bt ≤-bt bt stat≤bt : ∀ bt → stat ≤-bt bt module WF (ATy : Set) (typeof : ATy → Type) (btof : ATy → BT) where data wf : ATy → Set where wf-int : ∀ α → typeof α ≡ Int → wf α wf-fun : ∀ α α₁ α₂ → typeof α ≡ Fun (typeof α₁) (typeof α₂) → --btof α ≤-bt btof α₁ → --btof α ≤-bt btof α₂ → wf α₁ → wf α₂ → wf α -- Note that in [wf-fun],we can omit the checking of the label of -- the arguments against that of the function and [_≤-bt_] is -- unnecessary wf-pair : ∀ α α₁ α₂ → typeof α ≡ typeof α₁ • typeof α₂ → wf α₁ → wf α₂ → wf α wf-sum : ∀ α α₁ α₂ → typeof α ≡ typeof α₁ ⊎ typeof α₂ → wf α₁ → wf α₂ → wf α -- It is easy to check that the stratification respects the -- well-formedness, given the intended mapping from ATypes to -- binding times expained above: btof : AType → BT btof AInt = stat btof (AFun aty aty₁) = stat btof (D x) = dyn btof (aty • aty₁) = stat btof (aty ⊎ aty₁) = stat --------------------- -- Alternative [btof] --------------------- btof' : AType → BT btof' AInt = stat btof' (AFun aty aty₁) = stat btof' (D x) = dyn btof' (aty • aty₁) = dyn btof' (aty ⊎ aty₁) = dyn open WF AType typeof btof using (wf-fun; wf-int) renaming (wf to wf-AType) lem-wf-AType : ∀ α → wf-AType α lem-wf-AType AInt = WF.wf-int AInt refl lem-wf-AType (AFun α₁ α₂) = WF.wf-fun (AFun α₁ α₂) α₁ α₂ refl (lem-wf-AType α₁) (lem-wf-AType α₂) lem-wf-AType (D Int) = WF.wf-int (D Int) refl lem-wf-AType (D (Fun x x₁)) = WF.wf-fun (D (Fun x x₁)) (D x) (D x₁) refl (lem-wf-AType (D x)) (lem-wf-AType (D x₁)) lem-wf-AType (D (x • x₁)) = WF.wf-pair (D (x • x₁)) (D x) (D x₁) refl (lem-wf-AType (D x)) (lem-wf-AType (D x₁)) lem-wf-AType (D (x ⊎ x₁)) = WF.wf-sum (D (x ⊎ x₁)) (D x) (D x₁) refl (lem-wf-AType (D x)) (lem-wf-AType (D x₁)) lem-wf-AType (α₁ • α₂) = WF.wf-pair (α₁ • α₂) α₁ α₂ refl (lem-wf-AType α₁) (lem-wf-AType α₂) lem-wf-AType (α₁ ⊎ α₂) = WF.wf-sum (α₁ ⊎ α₂) α₁ α₂ refl (lem-wf-AType α₁) (lem-wf-AType α₂) --lem-wf-AType AInt = WF.wf-int AInt refl --lem-wf-AType (AFun α α₁) = WF.wf-fun (AFun α α₁) α α₁ refl (stat≤bt (btof α)) -- (stat≤bt (btof α₁)) -- (lem-wf-AType α) -- (lem-wf-AType α₁) --lem-wf-AType (D Int) = WF.wf-int (D Int) refl --lem-wf-AType (D (Fun x x₁)) = WF.wf-fun (D (Fun x x₁)) -- (D x) (D x₁) -- refl (bt≤bt dyn) (bt≤bt dyn) -- (lem-wf-AType (D x)) -- (lem-wf-AType (D x₁)) ----------------------------------------- -- Note that [lem-wf-AType] is based upon -- a modified [wf] ----------------------------------------- -}
{ "alphanum_fraction": 0.5055176038, "avg_line_length": 37.6831683168, "ext": "agda", "hexsha": "66841e8c3e96b732908b5da779f673faea4d5414", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2019-10-15T09:01:37.000Z", "max_forks_repo_forks_event_min_datetime": "2019-10-15T09:01:37.000Z", "max_forks_repo_head_hexsha": "ef878f7fa5afa51fb7a14cd8f7f75da0af1b9deb", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "luminousfennell/polybta", "max_forks_repo_path": "AnnotatedTypes.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "ef878f7fa5afa51fb7a14cd8f7f75da0af1b9deb", "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": "luminousfennell/polybta", "max_issues_repo_path": "AnnotatedTypes.agda", "max_line_length": 95, "max_stars_count": 1, "max_stars_repo_head_hexsha": "ef878f7fa5afa51fb7a14cd8f7f75da0af1b9deb", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "luminousfennell/polybta", "max_stars_repo_path": "AnnotatedTypes.agda", "max_stars_repo_stars_event_max_datetime": "2019-10-15T04:35:29.000Z", "max_stars_repo_stars_event_min_datetime": "2019-10-15T04:35:29.000Z", "num_tokens": 1324, "size": 3806 }
{-# OPTIONS --without-K --safe #-} open import Categories.Category open import Categories.Functor hiding (id) -- Cocone over a Functor F (from shape category J into category C) module Categories.Diagram.Cocone {o ℓ e} {o′ ℓ′ e′} {C : Category o ℓ e} {J : Category o′ ℓ′ e′} (F : Functor J C) where open Category C open Functor F open import Level record Coapex (N : Obj) : Set (o ⊔ ℓ ⊔ e ⊔ o′ ⊔ ℓ′) where field ψ : (X : Category.Obj J) → F₀ X ⇒ N commute : ∀ {X Y} (f : J [ X , Y ]) → ψ Y ∘ F₁ f ≈ ψ X record Cocone : Set (o ⊔ ℓ ⊔ e ⊔ o′ ⊔ ℓ′) where field {N} : Obj coapex : Coapex N open Coapex coapex public open Coapex open Cocone record Cocone⇒ (c c′ : Cocone) : Set (ℓ ⊔ e ⊔ o′) where field arr : N c ⇒ N c′ commute : ∀ {X} → arr ∘ ψ c X ≈ ψ c′ X open Cocone⇒
{ "alphanum_fraction": 0.5802919708, "avg_line_length": 22.8333333333, "ext": "agda", "hexsha": "9e4e1c4993f823d6996c0446502afe46036aed32", "lang": "Agda", "max_forks_count": 64, "max_forks_repo_forks_event_max_datetime": "2022-03-14T02:00:59.000Z", "max_forks_repo_forks_event_min_datetime": "2019-06-02T16:58:15.000Z", "max_forks_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Code-distancing/agda-categories", "max_forks_repo_path": "src/Categories/Diagram/Cocone.agda", "max_issues_count": 236, "max_issues_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_issues_repo_issues_event_max_datetime": "2022-03-28T14:31:43.000Z", "max_issues_repo_issues_event_min_datetime": "2019-06-01T14:53:54.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Code-distancing/agda-categories", "max_issues_repo_path": "src/Categories/Diagram/Cocone.agda", "max_line_length": 89, "max_stars_count": 279, "max_stars_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Trebor-Huang/agda-categories", "max_stars_repo_path": "src/Categories/Diagram/Cocone.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": 329, "size": 822 }
module CompilingCoinduction where open import Common.Coinduction open import Common.Char open import Common.String data Unit : Set where unit : Unit {-# COMPILED_DATA Unit () () #-} postulate IO : Set → Set {-# COMPILED_TYPE IO IO #-} {-# BUILTIN IO IO #-} {-# IMPORT Data.Text.IO #-} postulate putStrLn : ∞ String → IO Unit {-# COMPILED putStrLn Data.Text.IO.putStrLn #-} {-# COMPILED_UHC putStrLn (UHC.Agda.Builtins.primPutStrLn) #-} {-# COMPILED_JS putStrLn function(x) { return function(cb) { process.stdout.write(x(0) + "\n"); cb(0); }; } #-} main = putStrLn (♯ "a")
{ "alphanum_fraction": 0.6683673469, "avg_line_length": 20.275862069, "ext": "agda", "hexsha": "431cc9c8d68cb15c1bc77bc987c1c9abffe2b3b3", "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": "222c4c64b2ccf8e0fc2498492731c15e8fef32d4", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "pthariensflame/agda", "max_forks_repo_path": "test/Compiler/simple/CompilingCoinduction.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "222c4c64b2ccf8e0fc2498492731c15e8fef32d4", "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": "pthariensflame/agda", "max_issues_repo_path": "test/Compiler/simple/CompilingCoinduction.agda", "max_line_length": 111, "max_stars_count": null, "max_stars_repo_head_hexsha": "222c4c64b2ccf8e0fc2498492731c15e8fef32d4", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "pthariensflame/agda", "max_stars_repo_path": "test/Compiler/simple/CompilingCoinduction.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 163, "size": 588 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Core lemmas for division and modulus operations ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} module Data.Nat.DivMod.Core where open import Agda.Builtin.Nat using () renaming (div-helper to divₕ; mod-helper to modₕ) open import Data.Nat.Base open import Data.Nat.Properties open import Data.Sum.Base using (_⊎_; inj₁; inj₂) open import Data.Product using (_×_; _,_) open import Relation.Binary.PropositionalEquality open import Relation.Nullary using (yes; no) open import Relation.Nullary.Negation using (contradiction) open ≤-Reasoning ------------------------------------------------------------------------- -- Helper lemmas that have no interpretation for _%_, only for modₕ private mod-cong₃ : ∀ {c n a₁ a₂ b} → a₁ ≡ a₂ → modₕ c n a₁ b ≡ modₕ c n a₂ b mod-cong₃ refl = refl modₕ-skipTo0 : ∀ acc n a b → modₕ acc n (b + a) a ≡ modₕ (a + acc) n b 0 modₕ-skipTo0 acc n zero b = cong (λ v → modₕ acc n v 0) (+-identityʳ b) modₕ-skipTo0 acc n (suc a) b = begin-equality modₕ acc n (b + suc a) (suc a) ≡⟨ mod-cong₃ (+-suc b a) ⟩ modₕ acc n (suc b + a) (suc a) ≡⟨⟩ modₕ (suc acc) n (b + a) a ≡⟨ modₕ-skipTo0 (suc acc) n a b ⟩ modₕ (a + suc acc) n b 0 ≡⟨ cong (λ v → modₕ v n b 0) (+-suc a acc) ⟩ modₕ (suc a + acc) n b 0 ∎ ------------------------------------------------------------------------- -- Lemmas for modₕ that also have an interpretation for _%_ a[modₕ]1≡0 : ∀ a → modₕ 0 0 a 0 ≡ 0 a[modₕ]1≡0 zero = refl a[modₕ]1≡0 (suc a) = a[modₕ]1≡0 a n[modₕ]n≡0 : ∀ acc v → modₕ acc (acc + v) (suc v) v ≡ 0 n[modₕ]n≡0 acc v = modₕ-skipTo0 acc (acc + v) v 1 a[modₕ]n<n : ∀ acc d n → modₕ acc (acc + n) d n ≤ acc + n a[modₕ]n<n acc zero n = m≤m+n acc n a[modₕ]n<n acc (suc d) zero = a[modₕ]n<n zero d (acc + 0) a[modₕ]n<n acc (suc d) (suc n) rewrite +-suc acc n = a[modₕ]n<n (suc acc) d n a[modₕ]n≤a : ∀ acc a n → modₕ acc (acc + n) a n ≤ acc + a a[modₕ]n≤a acc zero n = ≤-reflexive (sym (+-identityʳ acc)) a[modₕ]n≤a acc (suc a) (suc n) = begin modₕ acc (acc + suc n) (suc a) (suc n) ≡⟨ cong (λ v → modₕ acc v (suc a) (suc n)) (+-suc acc n) ⟩ modₕ acc (suc acc + n) (suc a) (suc n) ≤⟨ a[modₕ]n≤a (suc acc) a n ⟩ suc acc + a ≡⟨ sym (+-suc acc a) ⟩ acc + suc a ∎ a[modₕ]n≤a acc (suc a) zero = begin modₕ acc (acc + 0) (suc a) 0 ≡⟨ cong (λ v → modₕ acc v (suc a) 0) (+-identityʳ acc) ⟩ modₕ acc acc (suc a) 0 ≤⟨ a[modₕ]n≤a 0 a acc ⟩ a ≤⟨ n≤1+n a ⟩ suc a ≤⟨ m≤n+m (suc a) acc ⟩ acc + suc a ∎ a≤n⇒a[modₕ]n≡a : ∀ acc n a b → modₕ acc n a (a + b) ≡ acc + a a≤n⇒a[modₕ]n≡a acc n zero b = sym (+-identityʳ acc) a≤n⇒a[modₕ]n≡a acc n (suc a) b = begin-equality modₕ (suc acc) n a (a + b) ≡⟨ a≤n⇒a[modₕ]n≡a (suc acc) n a b ⟩ suc acc + a ≡⟨ sym (+-suc acc a) ⟩ acc + suc a ∎ modₕ-idem : ∀ acc a n → modₕ 0 (acc + n) (modₕ acc (acc + n) a n) (acc + n) ≡ modₕ acc (acc + n) a n modₕ-idem acc zero n = a≤n⇒a[modₕ]n≡a 0 (acc + n) acc n modₕ-idem acc (suc a) zero rewrite +-identityʳ acc = modₕ-idem 0 a acc modₕ-idem acc (suc a) (suc n) rewrite +-suc acc n = modₕ-idem (suc acc) a n a+1[modₕ]n≡0⇒a[modₕ]n≡n-1 : ∀ acc l n → modₕ acc (acc + l) (suc n) l ≡ 0 → modₕ acc (acc + l) n l ≡ acc + l a+1[modₕ]n≡0⇒a[modₕ]n≡n-1 acc zero zero eq rewrite +-identityʳ acc = refl a+1[modₕ]n≡0⇒a[modₕ]n≡n-1 acc zero (suc n) eq rewrite +-identityʳ acc = a+1[modₕ]n≡0⇒a[modₕ]n≡n-1 0 acc n eq a+1[modₕ]n≡0⇒a[modₕ]n≡n-1 acc (suc l) (suc n) eq rewrite +-suc acc l = a+1[modₕ]n≡0⇒a[modₕ]n≡n-1 (suc acc) l n eq k<1+a[modₕ]n⇒k≤a[modₕ]n : ∀ acc k n l → suc k ≤ modₕ acc (acc + l) (suc n) l → k ≤ modₕ acc (acc + l) n l k<1+a[modₕ]n⇒k≤a[modₕ]n acc k zero (suc l) (s≤s leq) = leq k<1+a[modₕ]n⇒k≤a[modₕ]n acc k (suc n) zero leq rewrite +-identityʳ acc = k<1+a[modₕ]n⇒k≤a[modₕ]n 0 k n acc leq k<1+a[modₕ]n⇒k≤a[modₕ]n acc k (suc n) (suc l) leq rewrite +-suc acc l = k<1+a[modₕ]n⇒k≤a[modₕ]n (suc acc) k n l leq 1+a[modₕ]n≤1+k⇒a[modₕ]n≤k : ∀ acc k n l → 0 < modₕ acc (acc + l) (suc n) l → modₕ acc (acc + l) (suc n) l ≤ suc k → modₕ acc (acc + l) n l ≤ k 1+a[modₕ]n≤1+k⇒a[modₕ]n≤k acc k zero (suc l) 0<mod (s≤s leq) = leq 1+a[modₕ]n≤1+k⇒a[modₕ]n≤k acc k (suc n) zero 0<mod leq rewrite +-identityʳ acc = 1+a[modₕ]n≤1+k⇒a[modₕ]n≤k 0 k n acc 0<mod leq 1+a[modₕ]n≤1+k⇒a[modₕ]n≤k acc k (suc n) (suc l) 0<mod leq rewrite +-suc acc l = 1+a[modₕ]n≤1+k⇒a[modₕ]n≤k (suc acc) k n l 0<mod leq a+n[modₕ]n≡a[modₕ]n : ∀ acc a n → modₕ acc (acc + n) (acc + a + suc n) n ≡ modₕ acc (acc + n) a n a+n[modₕ]n≡a[modₕ]n acc zero n rewrite +-identityʳ acc = begin-equality modₕ acc (acc + n) (acc + suc n) n ≡⟨ mod-cong₃ (+-suc acc n) ⟩ modₕ acc (acc + n) (suc acc + n) n ≡⟨ modₕ-skipTo0 acc (acc + n) n (suc acc) ⟩ modₕ (acc + n) (acc + n) (suc acc) 0 ≡⟨⟩ modₕ 0 (acc + n) acc (acc + n) ≡⟨ a≤n⇒a[modₕ]n≡a 0 (acc + n) acc n ⟩ acc ∎ a+n[modₕ]n≡a[modₕ]n acc (suc a) zero rewrite +-identityʳ acc = begin-equality modₕ acc acc (acc + suc a + 1) 0 ≡⟨ mod-cong₃ (+-comm (acc + suc a) 1) ⟩ modₕ acc acc (1 + (acc + suc a)) 0 ≡⟨⟩ modₕ 0 acc (acc + suc a) acc ≡⟨ mod-cong₃ (+-comm acc (suc a)) ⟩ modₕ 0 acc (suc a + acc) acc ≡⟨ mod-cong₃ (sym (+-suc a acc)) ⟩ modₕ 0 acc (a + suc acc) acc ≡⟨ a+n[modₕ]n≡a[modₕ]n 0 a acc ⟩ modₕ 0 acc a acc ∎ a+n[modₕ]n≡a[modₕ]n acc (suc a) (suc n) rewrite +-suc acc n = begin-equality mod₁ (acc + suc a + (2 + n)) (suc n) ≡⟨ cong (λ v → mod₁ (v + suc (suc n)) (suc n)) (+-suc acc a) ⟩ mod₁ (suc acc + a + (2 + n)) (suc n) ≡⟨⟩ mod₂ (acc + a + (2 + n)) n ≡⟨ mod-cong₃ (sym (+-assoc (acc + a) 1 (suc n))) ⟩ mod₂ (acc + a + 1 + suc n) n ≡⟨ mod-cong₃ (cong (_+ suc n) (+-comm (acc + a) 1)) ⟩ mod₂ (suc acc + a + suc n) n ≡⟨ a+n[modₕ]n≡a[modₕ]n (suc acc) a n ⟩ mod₂ a n ∎ where mod₁ = modₕ acc (suc acc + n) mod₂ = modₕ (suc acc) (suc acc + n) ------------------------------------------------------------------------- -- Helper lemmas that have no interpretation for `_/_`, only for `divₕ` private div-cong₃ : ∀ {c n a₁ a₂ b} → a₁ ≡ a₂ → divₕ c n a₁ b ≡ divₕ c n a₂ b div-cong₃ refl = refl divₕ-restart : ∀ {acc} d n j → j < n → divₕ acc d n j ≡ divₕ (suc acc) d (n ∸ suc j) d divₕ-restart d (suc n) zero j<n = refl divₕ-restart d (suc n) (suc j) (s≤s j<n) = divₕ-restart d n j j<n divₕ-finish : ∀ {acc} d n j → j ≥ n → divₕ acc d n j ≡ acc divₕ-finish d zero j j≥n = refl divₕ-finish d (suc n) (suc j) (s≤s j≥n) = divₕ-finish d n j j≥n acc≤divₕ[acc] : ∀ {acc} d n j → acc ≤ divₕ acc d n j acc≤divₕ[acc] {acc} d zero j = ≤-refl acc≤divₕ[acc] {acc} d (suc n) zero = ≤-trans (n≤1+n acc) (acc≤divₕ[acc] d n d) acc≤divₕ[acc] {acc} d (suc n) (suc j) = acc≤divₕ[acc] d n j divₕ-extractAcc : ∀ acc d n j → divₕ acc d n j ≡ acc + divₕ 0 d n j divₕ-extractAcc acc d zero j = sym (+-identityʳ acc) divₕ-extractAcc acc d (suc n) (suc j) = divₕ-extractAcc acc d n j divₕ-extractAcc acc d (suc n) zero = begin-equality divₕ (suc acc) d n d ≡⟨ divₕ-extractAcc (suc acc) d n d ⟩ suc acc + divₕ 0 d n d ≡⟨ sym (+-suc acc _) ⟩ acc + suc (divₕ 0 d n d) ≡⟨ cong (acc +_) (sym (divₕ-extractAcc 1 d n d)) ⟩ acc + divₕ 1 d n d ∎ pattern inj₂′ x = inj₂ (inj₁ x) pattern inj₃ x = inj₂ (inj₂ x) -- This hideous lemma details the conditions needed for two divisions to -- be equal when the two offsets (i.e. the 4ᵗʰ parameters) are different. -- It may be that this triple sum has an elegant simplification to a -- set of inequalities involving the modulus but I can't find it. divₕ-offsetEq : ∀ {acc₁ acc₂} d n j k → j ≤ d → k ≤ d → (acc₁ ≡ acc₂ × j ≤ k × k < modₕ 0 d n d) ⊎ (acc₁ ≡ acc₂ × modₕ 0 d n d ≤ j × j ≤ k) ⊎ (acc₁ ≡ suc acc₂ × k < modₕ 0 d n d × modₕ 0 d n d ≤ j) → divₕ acc₁ d n j ≡ divₕ acc₂ d n k divₕ-offsetEq d zero j k j≤d k≤d (inj₁ (refl , _)) = refl divₕ-offsetEq d zero j k j≤d k≤d (inj₂′ (refl , _)) = refl divₕ-offsetEq d zero j k j≤d k≤d (inj₃ (eq , () , _)) -- (0 , 0) cases divₕ-offsetEq d (suc n) zero zero j≤d k≤d (inj₁ (refl , _)) = divₕ-offsetEq d n d d ≤-refl ≤-refl (inj₂′ (refl , a[modₕ]n<n 0 n d , ≤-refl)) divₕ-offsetEq d (suc n) zero zero j≤d k≤d (inj₂′ (refl , _)) = divₕ-offsetEq d n d d ≤-refl ≤-refl (inj₂′ (refl , a[modₕ]n<n 0 n d , ≤-refl)) divₕ-offsetEq d (suc n) zero zero j≤d k≤d (inj₃ (_ , 0<mod , mod≤0)) = contradiction (<-transˡ 0<mod mod≤0) λ() -- (0 , suc) cases divₕ-offsetEq d (suc n) zero (suc k) j≤d k≤d (inj₁ (refl , _ , 1+k<mod)) = divₕ-offsetEq d n d k ≤-refl (<⇒≤ k≤d) (inj₃ (refl , k<1+a[modₕ]n⇒k≤a[modₕ]n 0 (suc k) n d 1+k<mod , a[modₕ]n<n 0 n d)) divₕ-offsetEq d (suc n) zero (suc k) j≤d k≤d (inj₂′ (refl , mod≤0 , _)) = divₕ-offsetEq d n d k ≤-refl (<⇒≤ k≤d) (inj₃ (refl , subst (k <_) (sym (a+1[modₕ]n≡0⇒a[modₕ]n≡n-1 0 d n (n≤0⇒n≡0 mod≤0))) k≤d , a[modₕ]n<n 0 n d)) divₕ-offsetEq d (suc n) zero (suc k) j≤d k≤d (inj₃ (_ , 1+k<mod , mod≤0)) = contradiction (<-transˡ 1+k<mod mod≤0) λ() -- (suc , 0) cases divₕ-offsetEq d (suc n) (suc j) zero j≤d k≤d (inj₁ (_ , () , _)) divₕ-offsetEq d (suc n) (suc j) zero j≤d k≤d (inj₂′ (_ , _ , ())) divₕ-offsetEq d (suc n) (suc j) zero j≤d k≤d (inj₃ (eq , 0<mod , mod≤1+j)) = divₕ-offsetEq d n j d (<⇒≤ j≤d) ≤-refl (inj₂′ (eq , 1+a[modₕ]n≤1+k⇒a[modₕ]n≤k 0 j n d 0<mod mod≤1+j , <⇒≤ j≤d)) -- (suc , suc) cases divₕ-offsetEq d (suc n) (suc j) (suc k) j≤d k≤d (inj₁ (eq , s≤s j≤k , 1+k<mod)) = divₕ-offsetEq d n j k (<⇒≤ j≤d) (<⇒≤ k≤d) (inj₁ (eq , j≤k , k<1+a[modₕ]n⇒k≤a[modₕ]n 0 (suc k) n d 1+k<mod)) divₕ-offsetEq d (suc n) (suc j) (suc k) j≤d k≤d (inj₂′ (eq , mod≤1+j , (s≤s j≤k))) with modₕ 0 d (suc n) d ≟ 0 ... | yes mod≡0 = divₕ-offsetEq d n j k (<⇒≤ j≤d) (<⇒≤ k≤d) (inj₁ (eq , j≤k , subst (k <_) (sym (a+1[modₕ]n≡0⇒a[modₕ]n≡n-1 0 d n mod≡0)) k≤d)) ... | no mod≢0 = divₕ-offsetEq d n j k (<⇒≤ j≤d) (<⇒≤ k≤d) (inj₂′ (eq , 1+a[modₕ]n≤1+k⇒a[modₕ]n≤k 0 j n d (n≢0⇒n>0 mod≢0) mod≤1+j , j≤k)) divₕ-offsetEq d (suc n) (suc j) (suc k) j≤d k≤d (inj₃ (eq , k<mod , mod≤1+j)) = divₕ-offsetEq d n j k (<⇒≤ j≤d) (<⇒≤ k≤d) (inj₃ (eq , k<1+a[modₕ]n⇒k≤a[modₕ]n 0 (suc k) n d k<mod , 1+a[modₕ]n≤1+k⇒a[modₕ]n≤k 0 j n d (<-transʳ z≤n k<mod) mod≤1+j)) ------------------------------------------------------------------------- -- Lemmas for divₕ that also have an interpretation for _/_ -- The quotient and remainder are related to the dividend and -- divisor in the right way. div-mod-lemma : ∀ accᵐ accᵈ d n → accᵐ + accᵈ * suc (accᵐ + n) + d ≡ modₕ accᵐ (accᵐ + n) d n + divₕ accᵈ (accᵐ + n) d n * suc (accᵐ + n) div-mod-lemma accᵐ accᵈ zero n = +-identityʳ _ div-mod-lemma accᵐ accᵈ (suc d) zero rewrite +-identityʳ accᵐ = begin-equality accᵐ + accᵈ * suc accᵐ + suc d ≡⟨ +-suc _ d ⟩ suc accᵈ * suc accᵐ + d ≡⟨ div-mod-lemma zero (suc accᵈ) d accᵐ ⟩ modₕ 0 accᵐ d accᵐ + divₕ (suc accᵈ) accᵐ d accᵐ * suc accᵐ ≡⟨⟩ modₕ accᵐ accᵐ (suc d) 0 + divₕ accᵈ accᵐ (suc d) 0 * suc accᵐ ∎ div-mod-lemma accᵐ accᵈ (suc d) (suc n) rewrite +-suc accᵐ n = begin-equality accᵐ + accᵈ * m + suc d ≡⟨ +-suc _ d ⟩ suc (accᵐ + accᵈ * m + d) ≡⟨ div-mod-lemma (suc accᵐ) accᵈ d n ⟩ modₕ _ _ d n + divₕ accᵈ _ d n * m ∎ where m = 2 + accᵐ + n n[divₕ]n≡1 : ∀ n m → divₕ 0 n (suc m) m ≡ 1 n[divₕ]n≡1 n zero = refl n[divₕ]n≡1 n (suc m) = n[divₕ]n≡1 n m a[divₕ]1≡a : ∀ acc a → divₕ acc 0 a 0 ≡ acc + a a[divₕ]1≡a acc zero = sym (+-identityʳ acc) a[divₕ]1≡a acc (suc a) = trans (a[divₕ]1≡a (suc acc) a) (sym (+-suc acc a)) a*n[divₕ]n≡a : ∀ acc a n → divₕ acc n (a * suc n) n ≡ acc + a a*n[divₕ]n≡a acc zero n = sym (+-identityʳ acc) a*n[divₕ]n≡a acc (suc a) n = begin-equality divₕ acc n (suc a * suc n) n ≡⟨ divₕ-restart n (suc a * suc n) n (m≤m+n (suc n) _) ⟩ divₕ (suc acc) n (suc a * suc n ∸ suc n) n ≡⟨⟩ divₕ (suc acc) n (suc n + a * suc n ∸ suc n) n ≡⟨ div-cong₃ (m+n∸m≡n (suc n) (a * suc n)) ⟩ divₕ (suc acc) n (a * suc n) n ≡⟨ a*n[divₕ]n≡a (suc acc) a n ⟩ suc acc + a ≡⟨ sym (+-suc acc a) ⟩ acc + suc a ∎ +-distrib-divₕ : ∀ acc k m n j → modₕ k (k + j) m j + modₕ 0 (k + j) n (k + j) < suc (k + j) → divₕ acc (k + j) (m + n) j ≡ divₕ acc (k + j) m j + divₕ 0 (k + j) n (k + j) +-distrib-divₕ acc k (suc m) n zero leq rewrite +-identityʳ k = +-distrib-divₕ (suc acc) 0 m n k leq +-distrib-divₕ acc k (suc m) n (suc j) leq rewrite +-suc k j = +-distrib-divₕ acc (suc k) m n j leq +-distrib-divₕ acc k zero n j leq = begin-equality divₕ acc (k + j) n j ≡⟨ divₕ-extractAcc acc (k + j) n j ⟩ acc + divₕ 0 (k + j) n j ≡⟨ cong (acc +_) (divₕ-offsetEq _ n j _ (m≤n+m j k) ≤-refl case) ⟩ acc + divₕ 0 (k + j) n (k + j) ∎ where case = inj₂′ (refl , +-cancelˡ-≤ (suc k) leq , m≤n+m j k) divₕ-mono-≤ : ∀ {acc} k {m n o p} → m ≤ n → p ≤ o → divₕ acc (k + o) m o ≤ divₕ acc (k + p) n p divₕ-mono-≤ {acc} k {0} {n} {_} {p} z≤n p≤o = acc≤divₕ[acc] (k + p) n p divₕ-mono-≤ {acc} k {_} {_} {suc o} {suc p} (s≤s m≤n) (s≤s p≤o) rewrite +-suc k o | +-suc k p = divₕ-mono-≤ (suc k) m≤n p≤o divₕ-mono-≤ {acc} k {suc m} {suc n} {o} {0} (s≤s m≤n) z≤n with o <? suc m ... | no o≮1+m rewrite +-identityʳ k = begin divₕ acc (k + o) (suc m) o ≡⟨ divₕ-finish (k + o) (suc m) o (≮⇒≥ o≮1+m) ⟩ acc ≤⟨ n≤1+n acc ⟩ suc acc ≤⟨ acc≤divₕ[acc] k n k ⟩ divₕ (suc acc) k n k ∎ ... | yes o<1+m rewrite +-identityʳ k = begin divₕ acc (k + o) (suc m) o ≡⟨ divₕ-restart (k + o) (suc m) o o<1+m ⟩ divₕ (suc acc) (k + o) (m ∸ o) (k + o) ≤⟨ divₕ-mono-≤ 0 (≤-trans (m∸n≤m m o) m≤n) (m≤m+n k o) ⟩ divₕ (suc acc) k n k ∎
{ "alphanum_fraction": 0.5132154006, "avg_line_length": 54.8098859316, "ext": "agda", "hexsha": "ed049b0a09eb2bc987e9291a61adf7702b63dcfa", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "DreamLinuxer/popl21-artifact", "max_forks_repo_path": "agda-stdlib/src/Data/Nat/DivMod/Core.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "DreamLinuxer/popl21-artifact", "max_issues_repo_path": "agda-stdlib/src/Data/Nat/DivMod/Core.agda", "max_line_length": 168, "max_stars_count": 5, "max_stars_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "DreamLinuxer/popl21-artifact", "max_stars_repo_path": "agda-stdlib/src/Data/Nat/DivMod/Core.agda", "max_stars_repo_stars_event_max_datetime": "2020-10-10T21:41:32.000Z", "max_stars_repo_stars_event_min_datetime": "2020-10-07T12:07:53.000Z", "num_tokens": 7310, "size": 14415 }
module HostRequirements where open import Agda.Builtin.Unit open import Data.String as String using (String) open import Category.Applicative open import Category.Monad open import Category.Monad.State data Path : Set where MkPath : String -> Path data Value : Set where MkValue : String -> Value data Identifier : Set where MkIdentifier : String -> Identifier separator : String separator = "/" data Env : Set where MkEnv : Env {- get : Path -> State Env Value get path = return (MkValue "") set : Path -> Value -> State Env ⊤ set path value = return ⊤ delete : Path -> State Env ⊤ delete path = return ⊤ getConsensusState : State Env ConsensusState getConsensusState = ? getCallingModule : State Env Identifier getCallingModule = return (MkIdentifier "") -}
{ "alphanum_fraction": 0.7329910141, "avg_line_length": 19.475, "ext": "agda", "hexsha": "4ea8045950e0ad1ed9246fcc07e8eccb10c18e9b", "lang": "Agda", "max_forks_count": 6, "max_forks_repo_forks_event_max_datetime": "2022-02-10T07:34:35.000Z", "max_forks_repo_forks_event_min_datetime": "2019-09-28T09:22:42.000Z", "max_forks_repo_head_hexsha": "9a83c83d567f1c09eb23d51c8eae905a91fc0816", "max_forks_repo_licenses": [ "Apache-2.0" ], "max_forks_repo_name": "dogemos/ics", "max_forks_repo_path": "spec/ics-024-host-requirements/HostRequirements.agda", "max_issues_count": 14, "max_issues_repo_head_hexsha": "9a83c83d567f1c09eb23d51c8eae905a91fc0816", "max_issues_repo_issues_event_max_datetime": "2020-01-15T06:18:42.000Z", "max_issues_repo_issues_event_min_datetime": "2019-09-28T09:38:57.000Z", "max_issues_repo_licenses": [ "Apache-2.0" ], "max_issues_repo_name": "dogemos/ics", "max_issues_repo_path": "spec/ics-024-host-requirements/HostRequirements.agda", "max_line_length": 48, "max_stars_count": 7, "max_stars_repo_head_hexsha": "9a83c83d567f1c09eb23d51c8eae905a91fc0816", "max_stars_repo_licenses": [ "Apache-2.0" ], "max_stars_repo_name": "dogemos/ics", "max_stars_repo_path": "spec/ics-024-host-requirements/HostRequirements.agda", "max_stars_repo_stars_event_max_datetime": "2020-01-07T10:54:54.000Z", "max_stars_repo_stars_event_min_datetime": "2019-09-22T06:14:38.000Z", "num_tokens": 193, "size": 779 }
{-# OPTIONS --safe #-} module Cubical.Algebra.CommRing.DirectProd where open import Cubical.Foundations.Prelude open import Cubical.Data.Sigma open import Cubical.Algebra.Ring open import Cubical.Algebra.Ring.DirectProd open import Cubical.Algebra.CommRing.Base private variable ℓ ℓ' : Level module _ (A'@(A , Ar) : CommRing ℓ) (B'@(B , Br) : CommRing ℓ') where AB = DirectProd-Ring (CommRing→Ring A') (CommRing→Ring B') open RingStr (snd AB) using () renaming ( 0r to 0AB ; 1r to 1AB ; _+_ to _+AB_ ; -_ to -AB_ ; _·_ to _·AB_ ; +Assoc to +ABAssoc ; +IdL to +ABIdL ; +IdR to +ABIdR ; +InvL to +ABInvL ; +InvR to +ABInvR ; +Comm to +ABComm ; ·Assoc to ·ABAssoc ; ·IdR to ·ABIdR ; ·IdL to ·ABIdL ; ·DistR+ to ·ABDistR+ ; ·DistL+ to ·ABDistL+ ; is-set to isSetAB ) DirectProd-CommRing : CommRing (ℓ-max ℓ ℓ') fst DirectProd-CommRing = A × B CommRingStr.0r (snd DirectProd-CommRing) = 0AB CommRingStr.1r (snd DirectProd-CommRing) = 1AB CommRingStr._+_ (snd DirectProd-CommRing) = _+AB_ CommRingStr._·_ (snd DirectProd-CommRing) = _·AB_ CommRingStr.- snd DirectProd-CommRing = -AB_ CommRingStr.isCommRing (snd DirectProd-CommRing) = makeIsCommRing isSetAB +ABAssoc +ABIdR +ABInvR +ABComm ·ABAssoc ·ABIdR ·ABDistR+ λ x y i → (CommRingStr.·Comm Ar (fst x) (fst y) i) , (CommRingStr.·Comm Br (snd x) (snd y) i)
{ "alphanum_fraction": 0.6067708333, "avg_line_length": 26.0338983051, "ext": "agda", "hexsha": "bd6b213846a0c789456f774d394b74c73960e2f6", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "thomas-lamiaux/cubical", "max_forks_repo_path": "Cubical/Algebra/CommRing/DirectProd.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "thomas-lamiaux/cubical", "max_issues_repo_path": "Cubical/Algebra/CommRing/DirectProd.agda", "max_line_length": 97, "max_stars_count": null, "max_stars_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "thomas-lamiaux/cubical", "max_stars_repo_path": "Cubical/Algebra/CommRing/DirectProd.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 571, "size": 1536 }
-- Operators for combining and building families module SOAS.Families.Build {T : Set} where open import SOAS.Common open import SOAS.Context open import SOAS.Sorting {T} open import SOAS.Families.Core {T} -- | Metavariable contexts -- Inductive construction of context- and type-indexed sets data MCtx : Set where ⁅⁆ : MCtx ⁅_⊩ₙ_⁆_ : (Π : Ctx {T}) → (τ : T) → MCtx → MCtx infixr 7 ⁅_⊩ₙ_⁆_ -- Pattern synonym for parameterless elements and final elements infixr 10 ⁅_⁆̣ ⁅_⊩ₙ_⁆̣ infixr 7 ⁅_⁆_ ⁅_⊩_⁆_ ⁅_·_⊩_⁆_ ⁅_⊩_⁆̣ ⁅_·_⊩_⁆̣ _⁅_⊩ₙ_⁆ pattern ⁅_⁆̣ α = ⁅ ∅ ⊩ₙ α ⁆ ⁅⁆ pattern ⁅_⊩ₙ_⁆̣ Π α = ⁅ Π ⊩ₙ α ⁆ ⁅⁆ pattern ⁅_⁆_ τ 𝔐 = ⁅ ∅ ⊩ₙ τ ⁆ 𝔐 pattern ⁅_⊩_⁆_ τ α 𝔐 = ⁅ ⌊ τ ⌋ ⊩ₙ α ⁆ 𝔐 pattern ⁅_·_⊩_⁆_ τ₁ τ₂ α 𝔐 = ⁅ ⌊ τ₁ ∙ τ₂ ⌋ ⊩ₙ α ⁆ 𝔐 pattern ⁅_⊩_⁆̣ τ α = ⁅ ⌊ τ ⌋ ⊩ₙ α ⁆ ⁅⁆ pattern ⁅_·_⊩_⁆̣ τ₁ τ₂ α = ⁅ ⌊ τ₁ ∙ τ₂ ⌋ ⊩ₙ α ⁆ ⁅⁆ -- Add type-context pair to the end of the metavariable context _⁅_⊩ₙ_⁆ : MCtx → Ctx {T} → T → MCtx ⁅⁆ ⁅ Γ ⊩ₙ α ⁆ = ⁅ Γ ⊩ₙ α ⁆̣ (⁅ Π ⊩ₙ τ ⁆ 𝔐) ⁅ Γ ⊩ₙ α ⁆ = ⁅ Π ⊩ₙ τ ⁆ (𝔐 ⁅ Γ ⊩ₙ α ⁆) private variable Γ Δ Θ Π : Ctx α β γ τ : T 𝔐 : MCtx -- Membership of metavariable contexts data _⊩_∈_ : Ctx → T → MCtx → Set where ↓ : Π ⊩ τ ∈ (⁅ Π ⊩ₙ τ ⁆ 𝔐) ↑_ : Π ⊩ τ ∈ 𝔐 → Π ⊩ τ ∈ (⁅ Γ ⊩ₙ α ⁆ 𝔐) infixr 220 ↑_ -- Metavariable context can be interpreted as a family via the membership ∥_∥ : MCtx → Familyₛ ∥ 𝔐 ∥ α Γ = Γ ⊩ α ∈ 𝔐 infixr 60 ∥_∥ _▷_ : MCtx → (Familyₛ → Familyₛ) → Familyₛ 𝔐 ▷ 𝒳 = 𝒳 ∥ 𝔐 ∥ infix 4 _▷_ -- Generalised sums and pattern matching data +₂ (A B : Set) : Set where _₁ : A → +₂ A B _₂ : B → +₂ A B data +₃ (A B C : Set) : Set where _₁ : A → +₃ A B C _₂ : B → +₃ A B C _₃ : C → +₃ A B C data +₄ (A B C D : Set) : Set where _₁ : A → +₄ A B C D _₂ : B → +₄ A B C D _₃ : C → +₄ A B C D _₄ : D → +₄ A B C D infixr 60 _₁ infixr 60 _₂ infixr 60 _₃ infixr 60 _₄ ₂| : {A B : Set}{X : Set} → (A → X) → (B → X) → (+₂ A B → X) ₂| f g (a ₁) = f a ₂| f g (b ₂) = g b ₃| : {A B C : Set}{X : Set} → (A → X) → (B → X) → (C → X) → (+₃ A B C → X) ₃| f g h (a ₁) = f a ₃| f g h (b ₂) = g b ₃| f g h (c ₃) = h c ₄| : {A B C D : Set}{X : Set} → (A → X) → (B → X) → (C → X) → (D → X) → (+₄ A B C D → X) ₄| f g h e (a ₁) = f a ₄| f g h e (b ₂) = g b ₄| f g h e (c ₃) = h c ₄| f g h e (d ₄) = e d pattern _ₛ 𝔪 = 𝔪 ₁ pattern _ₘ 𝔪 = 𝔪 ₂ infixr 60 _ₛ infixr 60 _ₘ -- Empty and unit families data Ø : Familyₛ where data _⊪_ (Γ : Ctx)(α : T) : Familyₛ where ● : (Γ ⊪ α) α Γ ⊪_ : T → Familyₛ ⊪ α = ∅ ⊪ α infix 20 _⊪_ infix 20 ⊪_ -- Sum of families infix 10 _⊹_ infix 10 _⊹_⊹_ infix 10 _⊹_⊹_⊹_ _⊹_ : Familyₛ → Familyₛ → Familyₛ (𝒳 ⊹ 𝒴) α Γ = +₂ (𝒳 α Γ) (𝒴 α Γ) _⊹₁_ : {𝒳₁ 𝒳₂ 𝒴₁ 𝒴₂ : Familyₛ} → (𝒳₁ ⇾̣ 𝒳₂) → (𝒴₁ ⇾̣ 𝒴₂) → (𝒳₁ ⊹ 𝒴₁) ⇾̣ (𝒳₂ ⊹ 𝒴₂) (f ⊹₁ g) (x ₁) = (f x) ₁ (f ⊹₁ g) (y ₂) = (g y) ₂ _⊹_⊹_ : Familyₛ → Familyₛ → Familyₛ → Familyₛ (𝒳 ⊹ 𝒴 ⊹ 𝒵) α Γ = +₃ (𝒳 α Γ) (𝒴 α Γ) (𝒵 α Γ) _⊹_⊹_⊹_ : Familyₛ → Familyₛ → Familyₛ → Familyₛ → Familyₛ (𝒳 ⊹ 𝒴 ⊹ 𝒵 ⊹ 𝒲) α Γ = +₄ (𝒳 α Γ) (𝒴 α Γ) (𝒵 α Γ) (𝒲 α Γ)
{ "alphanum_fraction": 0.5087248322, "avg_line_length": 22.5757575758, "ext": "agda", "hexsha": "3fe8da1abe7a99a34d1d710a6540f7dd531116d1", "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": "b224d31e20cfd010b7c924ce940f3c2f417777e3", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "k4rtik/agda-soas", "max_forks_repo_path": "SOAS/Families/Build.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "b224d31e20cfd010b7c924ce940f3c2f417777e3", "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": "k4rtik/agda-soas", "max_issues_repo_path": "SOAS/Families/Build.agda", "max_line_length": 88, "max_stars_count": null, "max_stars_repo_head_hexsha": "b224d31e20cfd010b7c924ce940f3c2f417777e3", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "k4rtik/agda-soas", "max_stars_repo_path": "SOAS/Families/Build.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1842, "size": 2980 }
module Data.Num.Properties where open import Data.Num open import Data.Num.Core open import Data.Num.Next open import Data.Num.Continuous open import Data.Nat open import Data.Nat.Properties open import Data.Nat.Properties.Simple open import Data.Nat.Properties.Extra open import Data.Fin.Properties hiding (setoid; _≟_) open import Data.Nat.DM open import Data.Fin as Fin using (Fin; #_; fromℕ≤; inject≤) renaming (zero to z; suc to s) open import Data.Unit using (⊤; tt) open import Data.Empty using (⊥) open import Function open import Relation.Nullary open import Relation.Nullary.Decidable open import Relation.Nullary.Negation open import Relation.Binary open import Relation.Binary.PropositionalEquality open ≡-Reasoning open ≤-Reasoning renaming (begin_ to start_; _∎ to _□; _≡⟨_⟩_ to _≈⟨_⟩_) open DecTotalOrder decTotalOrder using (reflexive) renaming (refl to ≤-refl) -- start -- {! !} -- ≤⟨ {! !} ⟩ -- {! !} -- ≤⟨ {! !} ⟩ -- {! !} -- ≤⟨ {! !} ⟩ -- {! !} -- □ -- begin -- {! !} -- ≡⟨ {! !} ⟩ -- {! !} -- ≡⟨ {! !} ⟩ -- {! !} -- ≡⟨ {! !} ⟩ -- {! !} -- ≡⟨ {! !} ⟩ -- {! !} -- ∎ -- toℕ-⊹-ℤₙ-homo : ∀ {o} -- → (xs ys : Numeral 1 1 o) -- → ⟦ ⊹-ℤₙ xs ys ⟧ ≡ ⟦ xs ⟧ + ⟦ ys ⟧ -- toℕ-⊹-ℤₙ-homo {o} (x ∙) ys = -- begin -- Digit-toℕ x o + ⟦ ys ⟧ * 1 -- ≡⟨ cong (_+_ (Digit-toℕ x o)) (*-right-identity ⟦ ys ⟧) ⟩ -- Digit-toℕ x o + ⟦ ys ⟧ -- ∎ -- toℕ-⊹-ℤₙ-homo {o} (x ∷ xs) ys = -- begin -- Digit-toℕ x o + ⟦ ⊹-ℤₙ xs ys ⟧ * 1 -- ≡⟨ cong (λ w → Digit-toℕ x o + w * 1) (toℕ-⊹-ℤₙ-homo xs ys) ⟩ -- Digit-toℕ x o + (⟦ xs ⟧ + ⟦ ys ⟧) * 1 -- ≡⟨ cong (_+_ (Digit-toℕ x o)) (distribʳ-*-+ 1 ⟦ xs ⟧ ⟦ ys ⟧) ⟩ -- Digit-toℕ x o + (⟦ xs ⟧ * 1 + ⟦ ys ⟧ * 1) -- ≡⟨ cong (λ w → Digit-toℕ x o + (⟦ xs ⟧ * 1 + w)) (*-right-identity ⟦ ys ⟧) ⟩ -- Digit-toℕ x o + (⟦ xs ⟧ * 1 + ⟦ ys ⟧) -- ≡⟨ sym (+-assoc (Digit-toℕ x o) (⟦ xs ⟧ * 1) ⟦ ys ⟧) ⟩ -- Digit-toℕ x o + ⟦ xs ⟧ * 1 + ⟦ ys ⟧ -- ∎ toℕ-⊹-Proper-homo : ∀ {b d o} → (¬gapped : ¬ (Gapped#0 b d o)) → (proper : suc d + o ≥ 2) → (xs ys : Numeral (suc b) (suc d) o) → ⟦ ⊹-Proper ¬gapped proper xs ys ⟧ ≡ ⟦ xs ⟧ + ⟦ ys ⟧ toℕ-⊹-Proper-homo {b} {d} {o} ¬gapped proper (x ∙) ys = n+-Proper-toℕ ¬gapped proper x ys toℕ-⊹-Proper-homo {b} {d} {o} ¬gapped proper (x ∷ xs) (y ∙) = begin ⟦ n+-Proper ¬gapped proper y (x ∷ xs) ⟧ ≡⟨ n+-Proper-toℕ ¬gapped proper y (x ∷ xs) ⟩ Digit-toℕ y o + (Digit-toℕ x o + ⟦ xs ⟧ * suc b) ≡⟨ +-comm (Digit-toℕ y o) (Digit-toℕ x o + ⟦ xs ⟧ * suc b) ⟩ Digit-toℕ x o + ⟦ xs ⟧ * suc b + Digit-toℕ y o ∎ toℕ-⊹-Proper-homo {b} {d} {o} ¬gapped proper (x ∷ xs) (y ∷ ys) with sumView b d o ¬gapped proper x y toℕ-⊹-Proper-homo {b} {d} {o} ¬gapped proper (x ∷ xs) (y ∷ ys) | NoCarry leftover property = begin Digit-toℕ leftover o + ⟦ ⊹-Proper ¬gapped proper xs ys ⟧ * suc b ≡⟨ cong (λ w → Digit-toℕ leftover o + w * suc b) (toℕ-⊹-Proper-homo ¬gapped proper xs ys) ⟩ Digit-toℕ leftover o + (⟦ xs ⟧ + ⟦ ys ⟧) * suc b ≡⟨ cong (λ w → w + (⟦ xs ⟧ + ⟦ ys ⟧) * suc b) property ⟩ Digit-toℕ x o + (Digit-toℕ y o) + (⟦ xs ⟧ + ⟦ ys ⟧) * suc b ≡⟨ cong (λ w → Digit-toℕ x o + (Digit-toℕ y o) + w) (distribʳ-*-+ (suc b) ⟦ xs ⟧ ⟦ ys ⟧) ⟩ (Digit-toℕ x o) + (Digit-toℕ y o) + (⟦ xs ⟧ * suc b + ⟦ ys ⟧ * suc b) ≡⟨ +-assoc (Digit-toℕ x o) (Digit-toℕ y o) (⟦ xs ⟧ * suc b + ⟦ ys ⟧ * suc b) ⟩ Digit-toℕ x o + (Digit-toℕ y o + (⟦ xs ⟧ * suc b + ⟦ ys ⟧ * suc b)) ≡⟨ cong (λ w → Digit-toℕ x o + w) (a+[b+c]≡b+[a+c] (Digit-toℕ y o) (⟦ xs ⟧ * suc b) (⟦ ys ⟧ * suc b)) ⟩ Digit-toℕ x o + (⟦ xs ⟧ * suc b + (Digit-toℕ y o + ⟦ ys ⟧ * suc b)) ≡⟨ sym (+-assoc (Digit-toℕ x o) (⟦ xs ⟧ * suc b) (Digit-toℕ y o + ⟦ ys ⟧ * suc b)) ⟩ Digit-toℕ x o + ⟦ xs ⟧ * suc b + (Digit-toℕ y o + ⟦ ys ⟧ * suc b) ∎ toℕ-⊹-Proper-homo {b} {d} {o} ¬gapped proper (x ∷ xs) (y ∷ ys) | Fixed leftover carry property = begin Digit-toℕ leftover o + ⟦ n+-Proper ¬gapped proper carry (⊹-Proper ¬gapped proper xs ys) ⟧ * suc b ≡⟨ cong (λ w → Digit-toℕ leftover o + w * suc b) (n+-Proper-toℕ ¬gapped proper carry (⊹-Proper ¬gapped proper xs ys)) ⟩ Digit-toℕ leftover o + (Digit-toℕ carry o + ⟦ ⊹-Proper ¬gapped proper xs ys ⟧) * suc b ≡⟨ cong (λ w → Digit-toℕ leftover o + (Digit-toℕ carry o + w) * suc b) (toℕ-⊹-Proper-homo ¬gapped proper xs ys) ⟩ Digit-toℕ leftover o + (Digit-toℕ carry o + (⟦ xs ⟧ + ⟦ ys ⟧)) * suc b ≡⟨ cong (λ w → Digit-toℕ leftover o + w) (distribʳ-*-+ (suc b) (Digit-toℕ carry o) (⟦ xs ⟧ + ⟦ ys ⟧)) ⟩ Digit-toℕ leftover o + ((Digit-toℕ carry o) * suc b + (⟦ xs ⟧ + ⟦ ys ⟧) * suc b) ≡⟨ cong (λ w → Digit-toℕ leftover o + ((Digit-toℕ carry o) * suc b + w)) (distribʳ-*-+ (suc b) ⟦ xs ⟧ ⟦ ys ⟧) ⟩ Digit-toℕ leftover o + ((Digit-toℕ carry o) * suc b + (⟦ xs ⟧ * suc b + ⟦ ys ⟧ * suc b)) ≡⟨ sym (+-assoc (Digit-toℕ leftover o) ((Digit-toℕ carry o) * suc b) (⟦ xs ⟧ * suc b + ⟦ ys ⟧ * suc b)) ⟩ Digit-toℕ leftover o + (Digit-toℕ carry o) * suc b + (⟦ xs ⟧ * suc b + ⟦ ys ⟧ * suc b) ≡⟨ cong (λ w → w + (⟦ xs ⟧ * suc b + ⟦ ys ⟧ * suc b)) property ⟩ (Digit-toℕ x o) + (Digit-toℕ y o) + (⟦ xs ⟧ * suc b + ⟦ ys ⟧ * suc b) ≡⟨ +-assoc (Digit-toℕ x o) (Digit-toℕ y o) (⟦ xs ⟧ * suc b + ⟦ ys ⟧ * suc b) ⟩ Digit-toℕ x o + (Digit-toℕ y o + (⟦ xs ⟧ * suc b + ⟦ ys ⟧ * suc b)) ≡⟨ cong (λ w → Digit-toℕ x o + w) (a+[b+c]≡b+[a+c] (Digit-toℕ y o) (⟦ xs ⟧ * suc b) (⟦ ys ⟧ * suc b)) ⟩ Digit-toℕ x o + (⟦ xs ⟧ * suc b + (Digit-toℕ y o + ⟦ ys ⟧ * suc b)) ≡⟨ sym (+-assoc (Digit-toℕ x o) (⟦ xs ⟧ * suc b) (Digit-toℕ y o + ⟦ ys ⟧ * suc b)) ⟩ Digit-toℕ x o + ⟦ xs ⟧ * suc b + (Digit-toℕ y o + ⟦ ys ⟧ * suc b) ∎ toℕ-⊹-Proper-homo {b} {d} {o} ¬gapped proper (x ∷ xs) (y ∷ ys) | Floating leftover carry property = begin Digit-toℕ leftover o + ⟦ n+-Proper ¬gapped proper carry (⊹-Proper ¬gapped proper xs ys) ⟧ * suc b ≡⟨ cong (λ w → Digit-toℕ leftover o + w * suc b) (n+-Proper-toℕ ¬gapped proper carry (⊹-Proper ¬gapped proper xs ys)) ⟩ Digit-toℕ leftover o + (Digit-toℕ carry o + ⟦ ⊹-Proper ¬gapped proper xs ys ⟧) * suc b ≡⟨ cong (λ w → Digit-toℕ leftover o + (Digit-toℕ carry o + w) * suc b) (toℕ-⊹-Proper-homo ¬gapped proper xs ys) ⟩ Digit-toℕ leftover o + (Digit-toℕ carry o + (⟦ xs ⟧ + ⟦ ys ⟧)) * suc b ≡⟨ cong (λ w → Digit-toℕ leftover o + w) (distribʳ-*-+ (suc b) (Digit-toℕ carry o) (⟦ xs ⟧ + ⟦ ys ⟧)) ⟩ Digit-toℕ leftover o + ((Digit-toℕ carry o) * suc b + (⟦ xs ⟧ + ⟦ ys ⟧) * suc b) ≡⟨ cong (λ w → Digit-toℕ leftover o + ((Digit-toℕ carry o) * suc b + w)) (distribʳ-*-+ (suc b) ⟦ xs ⟧ ⟦ ys ⟧) ⟩ Digit-toℕ leftover o + ((Digit-toℕ carry o) * suc b + (⟦ xs ⟧ * suc b + ⟦ ys ⟧ * suc b)) ≡⟨ sym (+-assoc (Digit-toℕ leftover o) ((Digit-toℕ carry o) * suc b) (⟦ xs ⟧ * suc b + ⟦ ys ⟧ * suc b)) ⟩ Digit-toℕ leftover o + (Digit-toℕ carry o) * suc b + (⟦ xs ⟧ * suc b + ⟦ ys ⟧ * suc b) ≡⟨ cong (λ w → w + (⟦ xs ⟧ * suc b + ⟦ ys ⟧ * suc b)) property ⟩ (Digit-toℕ x o) + (Digit-toℕ y o) + (⟦ xs ⟧ * suc b + ⟦ ys ⟧ * suc b) ≡⟨ +-assoc (Digit-toℕ x o) (Digit-toℕ y o) (⟦ xs ⟧ * suc b + ⟦ ys ⟧ * suc b) ⟩ Digit-toℕ x o + (Digit-toℕ y o + (⟦ xs ⟧ * suc b + ⟦ ys ⟧ * suc b)) ≡⟨ cong (λ w → Digit-toℕ x o + w) (a+[b+c]≡b+[a+c] (Digit-toℕ y o) (⟦ xs ⟧ * suc b) (⟦ ys ⟧ * suc b)) ⟩ Digit-toℕ x o + (⟦ xs ⟧ * suc b + (Digit-toℕ y o + ⟦ ys ⟧ * suc b)) ≡⟨ sym (+-assoc (Digit-toℕ x o) (⟦ xs ⟧ * suc b) (Digit-toℕ y o + ⟦ ys ⟧ * suc b)) ⟩ Digit-toℕ x o + ⟦ xs ⟧ * suc b + (Digit-toℕ y o + ⟦ ys ⟧ * suc b) ∎ -- _⊹_ : ∀ {b d o} -- → {cond : N+Closed b d o} -- → (xs ys : Numeral b d o) -- → Numeral b d o -- _⊹_ {b} {d} {o} {IsContinuous cont} xs ys with numView b d o -- _⊹_ {cond = IsContinuous ()} xs ys | NullBase d o -- _⊹_ {cond = IsContinuous cont} xs ys | NoDigits b o = NoDigits-explode xs -- _⊹_ {cond = IsContinuous ()} xs ys | AllZeros b -- _⊹_ {cond = IsContinuous cont} xs ys | Proper b d o proper with Gapped#0? b d o -- _⊹_ {cond = IsContinuous ()} xs ys | Proper b d o proper | yes ¬gapped#0 -- _⊹_ {cond = IsContinuous cont} xs ys | Proper b d o proper | no ¬gapped#0 = ⊹-Proper (≤-pred (≰⇒> ¬gapped#0)) proper xs ys -- _⊹_ {cond = ℤₙ} xs ys = ⊹-ℤₙ xs ys toℕ-⊹-homo : ∀ {b d o} → (cont : True (Continuous? b d o)) → (xs ys : Numeral b d o) → ⟦ _⊹_ {cont = cont} xs ys ⟧ ≡ ⟦ xs ⟧ + ⟦ ys ⟧ toℕ-⊹-homo {b} {d} {o} cont xs ys with numView b d o toℕ-⊹-homo () xs ys | NullBase d o toℕ-⊹-homo cont xs ys | NoDigits b o = NoDigits-explode xs toℕ-⊹-homo () xs ys | AllZeros b toℕ-⊹-homo cont xs ys | Proper b d o proper with Gapped#0? b d o toℕ-⊹-homo () xs ys | Proper b d o proper | yes gapped#0 toℕ-⊹-homo cont xs ys | Proper b d o proper | no ¬gapped#0 = toℕ-⊹-Proper-homo ¬gapped#0 proper xs ys -- toℕ-≋-ℕ⇒Num-lemma-1 : ∀ m n → m * suc n ≡ 0 → m ≡ 0 -- toℕ-≋-ℕ⇒Num-lemma-1 zero n p = refl -- toℕ-≋-ℕ⇒Num-lemma-1 (suc m) n () -- -- -- toℕ-≋-ℕ⇒Num-lemma-2 : ∀ m n → m ≢ 0 → m + n ≢ 0 -- toℕ-≋-ℕ⇒Num-lemma-2 zero n p = contradiction refl p -- toℕ-≋-ℕ⇒Num-lemma-2 (suc m) n p () -- -- toℕ-≋-ℕ⇒Numeral : ∀ {b d o} -- → (xs ys : Numeral b d o) -- → toℕ xs ≡ toℕ ys -- → xs ≋ ys -- toℕ-≋-ℕ⇒Numeral ∙ ∙ ⟦xs⟧≡⟦ys⟧ = tt -- toℕ-≋-ℕ⇒Numeral {b} {zero} ∙ (() ∷ ys) ⟦∙⟧≡⟦y∷ys⟧ -- toℕ-≋-ℕ⇒Numeral {b} {suc d} {o} ∙ (y ∷ ys) ⟦∙⟧≡⟦y∷ys⟧ with Digit-toℕ y o ≟ 0 -- toℕ-≋-ℕ⇒Numeral {zero} {suc d} ∙ (y ∷ ys) ⟦∙⟧≡⟦y∷ys⟧ | yes p = tt -- toℕ-≋-ℕ⇒Numeral {suc b} {suc d} {o} ∙ (y ∷ ys) ⟦∙⟧≡⟦y∷ys⟧ | yes p = -- let ⟦ys⟧≡0 : toℕ ys * suc b ≡ 0 -- ⟦ys⟧≡0 = -- begin -- toℕ ys * suc b -- ≡⟨ cong (λ w → w + toℕ ys * suc b) (sym p) ⟩ -- o + Fin.toℕ y + toℕ ys * suc b -- ≡⟨ sym ⟦∙⟧≡⟦y∷ys⟧ ⟩ -- zero -- ∎ -- in -- toℕ-≋-ℕ⇒Numeral ∙ ys (sym (toℕ-≋-ℕ⇒Num-lemma-1 (toℕ ys) b ⟦ys⟧≡0)) -- toℕ-≋-ℕ⇒Numeral {b} {suc d} {o} ∙ (y ∷ ys) ⟦∙⟧≡⟦y∷ys⟧ | no ¬p = toℕ-≋-ℕ⇒Num-lemma-2 (Digit-toℕ y o) (toℕ ys * b) ¬p (sym ⟦∙⟧≡⟦y∷ys⟧) -- toℕ-≋-ℕ⇒Numeral {b} {zero} (() ∷ xs) ∙ ⟦x∷xs⟧≡⟦∙⟧ -- toℕ-≋-ℕ⇒Numeral {b} {suc d} {o} (x ∷ xs) ∙ ⟦x∷xs⟧≡⟦∙⟧ with Digit-toℕ x o ≟ 0 -- toℕ-≋-ℕ⇒Numeral {zero} {suc d} (x ∷ xs) ∙ ⟦x∷xs⟧≡⟦∙⟧ | yes p = tt -- toℕ-≋-ℕ⇒Numeral {suc b} {suc d} (x ∷ xs) ∙ ⟦x∷xs⟧≡⟦∙⟧ | yes p = {! !} -- toℕ-≋-ℕ⇒Numeral {b} {suc d} (x ∷ xs) ∙ ⟦x∷xs⟧≡⟦∙⟧ | no ¬p = {! !} -- toℕ-≋-ℕ⇒Numeral (x ∷ xs) (x₁ ∷ ys) ⟦xs⟧≡⟦ys⟧ = {! !} -- begin -- {! !} -- ≡⟨ {! !} ⟩ -- {! !} -- ≡⟨ {! !} ⟩ -- {! !} -- ≡⟨ {! !} ⟩ -- {! !} -- ≡⟨ {! !} ⟩ -- {! !} -- ∎ -- start -- {! !} -- ≤⟨ {! !} ⟩ -- {! !} -- ≤⟨ {! !} ⟩ -- {! !} -- ≤⟨ {! !} ⟩ -- {! !} -- □
{ "alphanum_fraction": 0.4822362985, "avg_line_length": 46.156779661, "ext": "agda", "hexsha": "4ec417b015675fbd6e6fc2f19d82040a91c6f073", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2015-05-30T05:50:50.000Z", "max_forks_repo_forks_event_min_datetime": "2015-05-30T05:50:50.000Z", "max_forks_repo_head_hexsha": "aae093cc9bf21f11064e7f7b12049448cd6449f1", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "banacorn/numeral", "max_forks_repo_path": "Data/Num/Properties.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "aae093cc9bf21f11064e7f7b12049448cd6449f1", "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": "banacorn/numeral", "max_issues_repo_path": "Data/Num/Properties.agda", "max_line_length": 135, "max_stars_count": 1, "max_stars_repo_head_hexsha": "aae093cc9bf21f11064e7f7b12049448cd6449f1", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "banacorn/numeral", "max_stars_repo_path": "Data/Num/Properties.agda", "max_stars_repo_stars_event_max_datetime": "2015-04-23T15:58:28.000Z", "max_stars_repo_stars_event_min_datetime": "2015-04-23T15:58:28.000Z", "num_tokens": 5394, "size": 10893 }
-- Andreas, 2022-03-25, issue #5838, inconsistency in Cubical Agda. -- Reported by Tom Jack: variant of test/Fail/Issue5838.agda. {-# OPTIONS --safe --cubical #-} open import Agda.Builtin.Bool open import Agda.Builtin.Sigma open import Agda.Primitive.Cubical open import Agda.Primitive.Cubical public renaming ( primIMin to _∧_ -- I → I → I ; primIMax to _∨_ -- I → I → I ; primINeg to ~_ -- I → I ; isOneEmpty to empty ; primComp to comp ; primHComp to hcomp ; primTransp to transp ; itIsOne to 1=1 ) open import Agda.Builtin.Cubical.Path open import Agda.Builtin.Cubical.Glue; open Helpers public open import Agda.Builtin.Cubical.Sub public renaming ( inc to inS ; primSubOut to outS ) --------------------------------------------------------------------------- -- Foundations Type = Set Path : (A : Type) → A → A → Type Path A a b = PathP (λ _ → A) a b isProp : Type → Type isProp A = (x y : A) → x ≡ y toPathP : {A : I → Type} {x : A i0} {y : A i1} → transp (λ i → A i) i0 x ≡ y → PathP A x y toPathP {A = A} {x = x} p i = hcomp (λ j → λ { (i = i0) → x ; (i = i1) → p j }) (transp (λ j → A (i ∧ j)) (~ i) x) isProp→PathP : ∀ {B : I → Type} → ((i : I) → isProp (B i)) → (b0 : B i0) (b1 : B i1) → PathP (λ i → B i) b0 b1 isProp→PathP hB b0 b1 = toPathP (hB _ _ _) --------------------------------------------------------------------------- -- Equivalence -- The identity equivalence idIsEquiv : (A : Type) → isEquiv (λ (x : A) → x) idIsEquiv A .equiv-proof y = (y , refl) , λ z i → z .snd (~ i) , λ j → z .snd (~ i ∨ j) idEquiv : (A : Type) → A ≃ A idEquiv A .fst = λ x → x idEquiv A .snd = idIsEquiv A isPropIsEquiv : {A B : Type} (f : A → B) → isProp (isEquiv f) isPropIsEquiv f p q i .equiv-proof y = let p2 = p .equiv-proof y .snd q2 = q .equiv-proof y .snd in p2 (q .equiv-proof y .fst) i , λ w j → hcomp (λ k → λ { (i = i0) → p2 w j ; (i = i1) → q2 w (j ∨ ~ k) ; (j = i0) → p2 (q2 w (~ k)) i ; (j = i1) → w }) (p2 w (i ∨ j)) equivEq : {A B : Type} {e f : A ≃ B} → (h : e .fst ≡ f .fst) → e ≡ f equivEq {e = e} {f = f} h i = h i , isProp→PathP (λ i → isPropIsEquiv (h i)) (e .snd) (f .snd) i --------------------------------------------------------------------------- -- Univalence Glue : (A : Type) {φ : I} → (Te : Partial φ (Σ Type λ T → T ≃ A)) → Type Glue A Te = primGlue A (λ x → Te x .fst) (λ x → Te x .snd) ua : ∀ {A B : Type} → A ≃ B → A ≡ B ua {A = A} {B = B} e i = Glue B (λ { (i = i0) → (A , e) ; (i = i1) → (B , idEquiv B) }) --------------------------------------------------------------------------- -- Isomorphisms record Iso (A B : Type) : Type where no-eta-equality constructor iso field fun : A → B inv : B → A rightInv : ∀ b → fun (inv b) ≡ b leftInv : ∀ a → inv (fun a) ≡ a -- Any iso is an equivalence module _ {A B : Type} (i : Iso A B) where open Iso i renaming ( fun to f ; inv to g ; rightInv to s ; leftInv to t) private module _ (y : B) (x0 x1 : A) (p0 : f x0 ≡ y) (p1 : f x1 ≡ y) where fill0 : I → I → A fill0 i = hfill (λ k → λ { (i = i1) → t x0 k ; (i = i0) → g y }) (inS (g (p0 (~ i)))) fill1 : I → I → A fill1 i = hfill (λ k → λ { (i = i1) → t x1 k ; (i = i0) → g y }) (inS (g (p1 (~ i)))) fill2 : I → I → A fill2 i = hfill (λ k → λ { (i = i1) → fill1 k i1 ; (i = i0) → fill0 k i1 }) (inS (g y)) p : x0 ≡ x1 p i = fill2 i i1 sq : I → I → A sq i j = hcomp (λ k → λ { (i = i1) → fill1 j (~ k) ; (i = i0) → fill0 j (~ k) ; (j = i1) → t (fill2 i i1) (~ k) ; (j = i0) → g y }) (fill2 i j) sq1 : I → I → B sq1 i j = hcomp (λ k → λ { (i = i1) → s (p1 (~ j)) k ; (i = i0) → s (p0 (~ j)) k ; (j = i1) → s (f (p i)) k ; (j = i0) → s y k }) (f (sq i j)) lemIso : (x0 , p0) ≡ (x1 , p1) lemIso i .fst = p i lemIso i .snd = λ j → sq1 i (~ j) isoToIsEquiv : isEquiv f isoToIsEquiv .equiv-proof y .fst .fst = g y isoToIsEquiv .equiv-proof y .fst .snd = s y isoToIsEquiv .equiv-proof y .snd z = lemIso y (g y) (fst z) (s y) (snd z) isoToEquiv : A ≃ B isoToEquiv .fst = _ isoToEquiv .snd = isoToIsEquiv --------------------------------------------------------------------------- -- Booleans notEquiv : Bool ≃ Bool notEquiv = isoToEquiv (iso not not notnot notnot) where not : Bool → Bool not true = false not false = true notnot : ∀ x → not (not x) ≡ x notnot true = refl notnot false = refl --------------------------------------------------------------------------- -- Circle data S¹ : Type where base : S¹ loop : base ≡ base -- rot, used in the Hopf fibration -- we will denote rotation by _·_ -- it is called μ in the HoTT-book in "8.5.2 The Hopf construction" rotLoop : (a : S¹) → a ≡ a rotLoop base = loop rotLoop (loop i) j = hcomp (λ k → λ { (i = i0) → loop (j ∨ ~ k) ; (i = i1) → loop (j ∧ k) ; (j = i0) → loop (i ∨ ~ k) ; (j = i1) → loop (i ∧ k)}) base --------------------------------------------------------------------------- -- Inconsistency distilled from #5838 -- twisted-square : Path (Path Type S¹ S¹) refl refl -- needs Path in Type₁ twisted-square : (i j : I) → Type -- SLOW twisted-square i j = Glue S¹ λ { (i = i0) → S¹ , equivEq {e = idEquiv S¹} {f = idEquiv S¹} (λ k x → rotLoop x k) j ; (i = i1) → S¹ , idEquiv S¹ ; (j = i0) → S¹ , idEquiv S¹ ; (j = i1) → S¹ , idEquiv S¹ } DoubleCover : S¹ → Type DoubleCover base = Bool DoubleCover (loop i) = ua notEquiv i -- @tomjack writes (2022-03-24): -- Here is an addendum to Issue5838.agda which shows (I think?) -- that compHCompU DoTransp also needs to be fixed: twisted-square' : (i j : I) → Type twisted-square' i j = hcomp (λ k → λ { (i = i0) → twisted-square k j ; (i = i1) → S¹ ; (j = i0) → S¹ ; (j = i1) → S¹ }) S¹ -- Exploit an invalid reduction of transp on composition for the universe. bad' : true ≡ false bad' k = transp (λ i → DoubleCover (transp (λ j → twisted-square' i j) (k ∧ (i ∨ ~ i)) base)) i0 false -- Expected: -- false != true of type Bool -- when checking the definition of bad' -- This is test/Fail/Issue5838: -- Exploit an invalid reduction of transp on Glue. bad : true ≡ false bad k = transp (λ i → DoubleCover (transp (λ j → twisted-square i j) (k ∧ (i ∨ ~ i)) base)) i0 false -- Expected: -- false != true of type Bool -- when checking the definition of bad
{ "alphanum_fraction": 0.441857261, "avg_line_length": 30.885106383, "ext": "agda", "hexsha": "ae23051a2851fea76f09e6dc701b317fe66c947f", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "98c9382a59f707c2c97d75919e389fc2a783ac75", "max_forks_repo_licenses": [ "BSD-2-Clause" ], "max_forks_repo_name": "KDr2/agda", "max_forks_repo_path": "test/Fail/Issue5838b.agda", "max_issues_count": 6, "max_issues_repo_head_hexsha": "98c9382a59f707c2c97d75919e389fc2a783ac75", "max_issues_repo_issues_event_max_datetime": "2021-11-24T08:31:10.000Z", "max_issues_repo_issues_event_min_datetime": "2021-10-18T08:12:24.000Z", "max_issues_repo_licenses": [ "BSD-2-Clause" ], "max_issues_repo_name": "KDr2/agda", "max_issues_repo_path": "test/Fail/Issue5838b.agda", "max_line_length": 102, "max_stars_count": null, "max_stars_repo_head_hexsha": "98c9382a59f707c2c97d75919e389fc2a783ac75", "max_stars_repo_licenses": [ "BSD-2-Clause" ], "max_stars_repo_name": "KDr2/agda", "max_stars_repo_path": "test/Fail/Issue5838b.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 2489, "size": 7258 }
open import Agda.Builtin.Equality -- Case splitting should not remove implicit arguments record ⊤ : Set where constructor tt test₁ : {A : Set} → ⊤ → ⊤ test₁ {A} x = {!x!} -- Case splitting on an implicit argument should make it visible test₂ : {x : ⊤} → ⊤ test₂ = {!.x!} -- Implicit variables in dot patterns should be replaced by _ postulate A B : Set f : A → B test₃ : {x : A} (y : B) → f x ≡ y → B test₃ y e = {!e!} -- .. but not if they are bound inside the dot pattern test₄ : (f : A → A) → f ≡ (λ x → x) → Set test₄ f e = {!e!}
{ "alphanum_fraction": 0.6073394495, "avg_line_length": 21.8, "ext": "agda", "hexsha": "176aabd31b9b6bf8af46533f60919716ee5727af", "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": "222c4c64b2ccf8e0fc2498492731c15e8fef32d4", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "pthariensflame/agda", "max_forks_repo_path": "test/interaction/CaseSplitAndImplicits.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "222c4c64b2ccf8e0fc2498492731c15e8fef32d4", "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": "pthariensflame/agda", "max_issues_repo_path": "test/interaction/CaseSplitAndImplicits.agda", "max_line_length": 64, "max_stars_count": 3, "max_stars_repo_head_hexsha": "222c4c64b2ccf8e0fc2498492731c15e8fef32d4", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "pthariensflame/agda", "max_stars_repo_path": "test/interaction/CaseSplitAndImplicits.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": 194, "size": 545 }
{-# OPTIONS --without-K --rewriting #-} module UpperNaturals where open import Basics open import lib.Basics open import lib.NType2 open import lib.types.Pi open import lib.types.Nat open import lib.types.Truncation ≤-antisymmetry : {n m : ℕ} (_ : n ≤ m) (_ : m ≤ n) → n == m ≤-antisymmetry {_} {_} (inl p) _ = p ≤-antisymmetry {_} {_} _ (inl p) = ! p ≤-antisymmetry {_} {_} (inr p) q = quodlibet (<-to-≱ p q) -- A propositional version of _≤_ _≤p_ : ℕ → ℕ → PropT₀ n ≤p m = (n ≤ m) , (≤-is-prop {n} {m}) _is-upward-closed : (N : ℕ → PropT₀) → Type _ N is-upward-closed = (n m : ℕ) → n ≤ m → (N n) holds → (N m) holds upward-closed-is-a-prop : (N : ℕ → PropT₀) → (N is-upward-closed) is-a-prop upward-closed-is-a-prop N = mp (λ _ → mp (λ m → mp (λ _ → mp (λ _ → (N m) holds-is-a-prop)))) where mp = mapping-into-prop-is-a-prop ℕ→PropT₀-is-a-set : (ℕ → PropT₀) is-a-set ℕ→PropT₀-is-a-set = Π-level {_}{_}{ℕ}{λ _ → PropT₀}{0} (λ _ → hProp-is-set _) ℕ↑-prop : SubtypeProp (ℕ → PropT₀) _ ℕ↑-prop = _is-upward-closed , upward-closed-is-a-prop {- The Upper Naturals An upper natural is an upward closed proposition concerning natural numbers. The interpretation is that an upper natural is a natural ``defined by its upper bounds'', in the sense that for the proposition N holding of a natural n means that n is an upper bound of N. The important bit about upper naturals is that they satisfy the well-ordering principle, constructively. -} ℕ↑ : Type₁ ℕ↑ = Subtype ℕ↑-prop -- Σ (ℕ → PropT₀) _is-upward-closed ℕ↑-is-a-set : ℕ↑ is-a-set ℕ↑-is-a-set = Subtype-level ℕ↑-prop _is-an-upper-bound-of_ : ℕ → ℕ↑ → Type _ n is-an-upper-bound-of M = ((fst M) n) holds _≤:↑_ : ℕ↑ → ℕ → Type _ M ≤:↑ n = n is-an-upper-bound-of M ≤:↑-is-a-prop : {M : ℕ↑} {n : ℕ} → (M ≤:↑ n) is-a-prop ≤:↑-is-a-prop {M} {n} = ((fst M) n) holds-is-a-prop ≤p-is-upward-closed : {n : ℕ} → (n ≤p_) is-upward-closed ≤p-is-upward-closed = λ n m z z₁ → ≤-trans z₁ z _^↑ : ℕ → ℕ↑ n ^↑ = (n ≤p_) , ≤p-is-upward-closed -- 0 is bounded above by every number. O↑ : ℕ↑ O↑ = O ^↑ -- Infinity is defined to be the number with no upper bounds. ∞↑ : ℕ↑ ∞↑ = (λ _ → False) , proof where proof : (λ _ → False) is-upward-closed proof = λ n m _ z → z ∞↑-has-no-upper-bounds : (n : ℕ) → ¬ (∞↑ ≤:↑ n) ∞↑-has-no-upper-bounds n = λ z → z ≤:↑-refl : {n : ℕ} → n is-an-upper-bound-of (n ^↑) ≤:↑-refl = ≤-refl -- The ordering on the upper naturals is defined by saying that -- N is at most M if every upper bound of M is an upper bound of N. _≤↑_ : ℕ↑ → ℕ↑ → Type _ N ≤↑ M = (n : ℕ) → M ≤:↑ n → N ≤:↑ n ≤↑-is-a-prop : {N M : ℕ↑} → (N ≤↑ M) is-a-prop ≤↑-is-a-prop {N} {M} = mp (λ n → mp (λ _ → ≤:↑-is-a-prop {N} {n})) where mp = mapping-into-prop-is-a-prop ≤↑-refl : {N : ℕ↑} → N ≤↑ N ≤↑-refl = λ n z → z ≤↑-trans : {N M P : ℕ↑} → N ≤↑ M → M ≤↑ P → N ≤↑ P ≤↑-trans = λ z z₁ n z₂ → z n (z₁ n z₂) ^↑-is-monotone : {n m : ℕ} → n ≤ m → (n ^↑) ≤↑ (m ^↑) ^↑-is-monotone = λ x k x₁ → ≤-trans x x₁ ^↑-yoneda : {n : ℕ} {M : ℕ↑} → M ≤↑ (n ^↑) → M ≤:↑ n ^↑-yoneda {n} {M} = λ x → x n ≤:↑-refl ^↑-is-full : {n m : ℕ} → (n ^↑) ≤↑ (m ^↑) → n ≤ m ^↑-is-full {n} {m} = λ z → z m (inl idp) ^↑-is-ff : {n m : ℕ} → (n ≤ m) ≃ ((n ^↑) ≤↑ (m ^↑)) ^↑-is-ff {n} {m} = equiv ^↑-is-monotone ^↑-is-full (λ b → prop-path (≤↑-is-a-prop {(n ^↑)} {(m ^↑)}) (λ _ → ≤-trans (b m (inl idp))) b) (λ a → prop-path ≤-is-prop (≤-trans a (inl idp)) a) =-to-≤↑ : {N M : ℕ↑} → N == M → N ≤↑ M =-to-≤↑ idp = λ n z → z ^↑-is-injective : {n m : ℕ} → (n ^↑) == (m ^↑) → n == m ^↑-is-injective {n} {m} = λ x → ≤-antisymmetry (^↑-is-full (=-to-≤↑ x)) (^↑-is-full ((=-to-≤↑ (! x)))) O↑≤↑ : (N : ℕ↑) → O↑ ≤↑ N O↑≤↑ N = λ n x → ^↑-is-monotone (O≤ n) n ≤:↑-refl _≤↑∞↑ : (N : ℕ↑) → N ≤↑ ∞↑ N ≤↑∞↑ = λ n x → quodlibet (∞↑-has-no-upper-bounds n x) minℕ : (P : ℕ → Type₀) → ℕ↑ minℕ P = (λ n → min-pred n) , (λ n m x → Trunc-rec (implication n m x)) where min-pred : (n : ℕ) → PropT₀ min-pred n = ∃ (λ k → (P k) And (k ≤ n)) implication : (n m : ℕ) (x : n ≤ m) → Σ ℕ (λ k → (P k) And (k ≤ n)) → min-pred m holds implication n m x = λ {(k , p) → [ k , fst p , ≤-trans (snd p) x ] } {- Probably requires propositional resizing minℕ↑ : (P : ℕ↑ → Type₀) → ℕ↑ minℕ↑ P = (λ n → min-pred n) , (λ n m x → Trunc-rec (implication n m x)) where min-pred : (n : ℕ) → PropT₀ min-pred n = ∃ (λ K → (P K) And (K ≤:↑ n)) implication : (n m : ℕ) (x : n ≤ m) → Σ ℕ↑ (λ K → (P K) And (K ≤:↑ n)) → min-pred m holds implication n m x = λ {(k , p) → [ k , fst p , ≤-trans (snd p) x ] } -}
{ "alphanum_fraction": 0.4912963342, "avg_line_length": 31.3012820513, "ext": "agda", "hexsha": "5da4f9a31cd1d461aacd3943c3ea5a3475b6ca94", "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": "497e720a1ddaa2ec713c060f999f4b3ee2fe5e8a", "max_forks_repo_licenses": [ "CC0-1.0" ], "max_forks_repo_name": "glangmead/formalization", "max_forks_repo_path": "cohesion/david_jaz_261/UpperNaturals.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "497e720a1ddaa2ec713c060f999f4b3ee2fe5e8a", "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": "glangmead/formalization", "max_issues_repo_path": "cohesion/david_jaz_261/UpperNaturals.agda", "max_line_length": 101, "max_stars_count": 6, "max_stars_repo_head_hexsha": "497e720a1ddaa2ec713c060f999f4b3ee2fe5e8a", "max_stars_repo_licenses": [ "CC0-1.0" ], "max_stars_repo_name": "glangmead/formalization", "max_stars_repo_path": "cohesion/david_jaz_261/UpperNaturals.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-13T05:51:12.000Z", "max_stars_repo_stars_event_min_datetime": "2021-10-06T17:39:22.000Z", "num_tokens": 2078, "size": 4883 }
-- Agda program using the Iowa Agda library open import bool module TO-PROVE-evendoublecoin (Choice : Set) (choose : Choice → 𝔹) (lchoice : Choice → Choice) (rchoice : Choice → Choice) where open import eq open import nat open import list open import maybe --------------------------------------------------------------------------- -- Translated Curry operations: add : ℕ → ℕ → ℕ add zero x = x add (suc y) z = suc (add y z) coin : Choice → ℕ → ℕ coin c1 x = if choose c1 then x else suc x double : ℕ → ℕ double x = add x x even : ℕ → 𝔹 even zero = tt even (suc zero) = ff even (suc (suc x)) = even x --------------------------------------------------------------------------- evendoublecoin : (c1 : Choice) → (x : ℕ) → (even (double (coin c1 x))) ≡ tt evendoublecoin c1 x = ? ---------------------------------------------------------------------------
{ "alphanum_fraction": 0.4765714286, "avg_line_length": 21.3414634146, "ext": "agda", "hexsha": "0047a030ccf42e0edd72a3ef6b9ef1dd6159349a", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-10-09T16:02:18.000Z", "max_forks_repo_forks_event_min_datetime": "2021-10-09T16:02:18.000Z", "max_forks_repo_head_hexsha": "c34d76595b23e5152e6a5883ad3b0ec1d840f6d9", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "DouglasRMiles/pakcs_lib", "max_forks_repo_path": "docs/src/tooldocs/verify/TO-PROVE-evendoublecoin.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "c34d76595b23e5152e6a5883ad3b0ec1d840f6d9", "max_issues_repo_issues_event_max_datetime": "2021-02-24T12:41:30.000Z", "max_issues_repo_issues_event_min_datetime": "2021-02-21T22:25:13.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "DouglasRMiles/pakcs_lib", "max_issues_repo_path": "docs/src/tooldocs/verify/TO-PROVE-evendoublecoin.agda", "max_line_length": 75, "max_stars_count": 2, "max_stars_repo_head_hexsha": "c34d76595b23e5152e6a5883ad3b0ec1d840f6d9", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "DouglasRMiles/pakcs_lib", "max_stars_repo_path": "docs/src/tooldocs/verify/TO-PROVE-evendoublecoin.agda", "max_stars_repo_stars_event_max_datetime": "2021-02-21T22:25:28.000Z", "max_stars_repo_stars_event_min_datetime": "2021-01-06T18:32:48.000Z", "num_tokens": 230, "size": 875 }
-- Andreas, 2013-10-22 -- Fixed by checking with-function-types in internal syntax! module Issue893 where postulate S : Set data Dec (Px : Set) (q : Px → S) : Set where tt : Dec Px q -- record parameter is essential to reproduce error message record Rec (P : S → Set) : Set where field prop : {x : S} → P x → S bla : (x : S) → Dec (P x) prop bla x with x bla x | _ = tt
{ "alphanum_fraction": 0.5873786408, "avg_line_length": 21.6842105263, "ext": "agda", "hexsha": "075edc82e3d7cee91b7535d972c9c3f8d77e8d9e", "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/Issue893.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/Issue893.agda", "max_line_length": 61, "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/Issue893.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": 134, "size": 412 }
{-# OPTIONS --cubical --safe #-} module Data.Rational.SternBrocot where open import Prelude import Data.Nat as ℕ import Data.Nat.Properties as ℕ open import Data.Bits renaming (Bits to ℚ⁺; [] to 1ℚ; 0∷_ to lℚ; 1∷_ to rℚ) open import Data.Bits.Equatable -- ⟦_⇓⟧ : ℚ⁺ → (ℕ × ℕ) -- ⟦ 1ℚ ⇓⟧ = 1 , 1 -- ⟦ lℚ x ⇓⟧ = let p , q = ⟦ x ⇓⟧ in p , p ℕ.+ q -- ⟦ rℚ x ⇓⟧ = let p , q = ⟦ x ⇓⟧ in p ℕ.+ q , q -- module TerminationProofs where -- Tᴮ⇒≡ : {n m : ℕ} → n ≡ m → T (n ℕ.≡ᴮ m) -- Tᴮ⇒≡ {n} {m} n≡m = subst (λ n′ → T (n ℕ.≡ᴮ n′)) n≡m (ℕ.complete-== n) -- lift-suc-≡ : ∀ {n m} s → m ≡ n → T (n ℕ.≡ᴮ s) → T (m ℕ.≡ᴮ s) -- lift-suc-≡ {n} {m} s m≡n p = Tᴮ⇒≡ (m≡n ; ℕ.sound-== (n) s p) -- lemma₁ : ∀ a m → a ℕ.+ m ℕ.+ zero ≡ m ℕ.+ a -- lemma₁ a m = ℕ.+-idʳ (a ℕ.+ m) ; ℕ.+-comm a m -- lemma₂ : ∀ n a m → n ℕ.+ m ℕ.+ suc a ≡ n ℕ.+ suc m ℕ.+ a -- lemma₂ n a m = ℕ.+-assoc n m (suc a) ; cong (n ℕ.+_) (ℕ.+-suc m a) ; sym (ℕ.+-assoc n (suc m) a) -- lemma₃ : ∀ n a → n ℕ.+ a ℕ.+ zero ≡ n ℕ.+ zero ℕ.+ a -- lemma₃ n a = ℕ.+-idʳ (n ℕ.+ a) ; cong (ℕ._+ a) (sym (ℕ.+-idʳ n)) -- _+1/_+1 : ℕ → ℕ → ℚ⁺ -- n +1/ m +1 = go zero n m (n ℕ.+ m) -- where -- go : (a n m s : ℕ) → ℚ⁺ -- go a zero (suc m) (suc s) = lℚ (go zero a m s) -- go a (suc n) (suc m) (suc s) = go (suc a) n m s -- go a (suc n) zero (suc s) = rℚ (go zero n a s) -- go _ _ _ _ = 1ℚ euclidian : ℕ → ℕ → ℕ → ℚ⁺ euclidian n m zero = 1ℚ euclidian n m (suc s) = if n ℕ.≡ᴮ m then 1ℚ else if n ℕ.<ᴮ m then lℚ (euclidian n (m ℕ.∸ (1 ℕ.+ n)) s) else rℚ (euclidian (n ℕ.∸ (1 ℕ.+ m)) m s) normalise-suc : ℕ → ℕ → ℚ⁺ normalise-suc n m = euclidian n m (n ℕ.+ m) ℚ : Type ℚ = ℚ⁺ import Data.Rational.Unnormalised as F open import Data.Rational.Unnormalised using (_/suc_; _/_) import Data.Integer as ℤ open import Data.Integer using (ℤ; ⁺; ⁻suc; ⁻) open import Data.Bits.Fold zer : (ℕ × ℕ) → (ℕ × ℕ) zer (p , q) = p , suc p ℕ.+ q one : (ℕ × ℕ) → (ℕ × ℕ) one (p , q) = suc p ℕ.+ q , q fraction : ℚ → (ℕ × ℕ) fraction = foldr-bits zer one (0 , 0) ⟦_⇓⟧ : ℚ → F.ℚ ⟦ 1ℚ ⇓⟧ = ⁺ 0 F./suc 0 ⟦ lℚ xs ⇓⟧ = let n , d = fraction xs in ⁻suc n /suc d ⟦ rℚ xs ⇓⟧ = let n , d = fraction xs in ⁺ (suc n) /suc d ⟦_⇑⟧ : F.ℚ → ℚ ⟦ ⁺ zero /suc den-pred ⇑⟧ = 1ℚ ⟦ ⁺ (suc x) /suc den-pred ⇑⟧ = rℚ (normalise-suc x den-pred) ⟦ ⁻suc x /suc den-pred ⇑⟧ = lℚ (normalise-suc x den-pred) -- open import Path.Reasoning -- n≢sn+d : ∀ n d → (n ℕ.≡ᴮ suc (n ℕ.+ d)) ≡ false -- n≢sn+d zero d = refl -- n≢sn+d (suc n) d = n≢sn+d n d -- n<sn+d : ∀ n d → (n ℕ.<ᴮ suc (n ℕ.+ d)) ≡ true -- n<sn+d zero d = refl -- n<sn+d (suc n) d = n<sn+d n d -- n+d-n≡d : ∀ n d → n ℕ.+ d ℕ.∸ n ≡ d -- n+d-n≡d zero d = refl -- n+d-n≡d (suc n) d = n+d-n≡d n d -- euclidian-term-helper : ∀ n d s₁ s₂ → (n ℕ.+ d ℕ.≤ s₁) → (n ℕ.+ d ℕ.≤ s₂) → euclidian n d s₁ ≡ euclidian n d s₂ -- euclidian-term-helper zero zero zero zero p₁ p₂ = refl -- euclidian-term-helper zero zero zero (suc s₂) p₁ p₂ = refl -- euclidian-term-helper zero zero (suc s₁) zero p₁ p₂ = refl -- euclidian-term-helper zero zero (suc s₁) (suc s₂) p₁ p₂ = refl -- euclidian-term-helper zero (suc d) (suc s₁) (suc s₂) p₁ p₂ = cong lℚ (euclidian-term-helper zero d s₁ s₂ (ℕ.p≤p d s₁ p₁) (ℕ.p≤p d s₂ p₂)) -- euclidian-term-helper (suc n) zero (suc s₁) (suc s₂) p₁ p₂ = cong rℚ (euclidian-term-helper n zero s₁ s₂ (ℕ.p≤p (n ℕ.+ zero) s₁ p₁) (ℕ.p≤p (n ℕ.+ zero) s₂ p₂)) -- euclidian-term-helper (suc n) (suc d) (suc s₁) (suc s₂) p₁ p₂ with n ℕ.≡ᴮ d | n ℕ.<ᴮ d -- euclidian-term-helper (suc n) (suc d) (suc s₁) (suc s₂) p₁ p₂ | false | false = cong rℚ (euclidian-term-helper (n ℕ.∸ suc d) (suc d) s₁ s₂ {!!} {!!}) -- euclidian-term-helper (suc n) (suc d) (suc s₁) (suc s₂) p₁ p₂ | false | true = cong lℚ (euclidian-term-helper (suc n) (d ℕ.∸ suc n) s₁ s₂ {!!} {!!}) -- euclidian-term-helper (suc n) (suc d) (suc s₁) (suc s₂) p₁ p₂ | true | _ = refl -- norm-l : ∀ n d → normalise-suc n (suc n ℕ.+ d) ≡ lℚ (normalise-suc n d) -- norm-l n d = -- normalise-suc n (suc n ℕ.+ d) ≡⟨⟩ -- euclidian n (suc n ℕ.+ d) (n ℕ.+ (suc n ℕ.+ d)) ≡⟨ cong (euclidian n (suc n ℕ.+ d)) (ℕ.+-suc n (n ℕ.+ d)) ⟩ -- euclidian n (suc n ℕ.+ d) (suc n ℕ.+ (n ℕ.+ d)) ≡⟨⟩ -- (if n ℕ.≡ᴮ suc (n ℕ.+ d) then 1ℚ else -- if n ℕ.<ᴮ suc (n ℕ.+ d) then lℚ (euclidian n (n ℕ.+ d ℕ.∸ n) (n ℕ.+ (n ℕ.+ d))) else rℚ (euclidian (n ℕ.∸ suc (suc (n ℕ.+ d))) (suc (n ℕ.+ d)) (n ℕ.+ (n ℕ.+ d)))) ≡⟨ cong (if_then 1ℚ else if n ℕ.<ᴮ suc (n ℕ.+ d) then lℚ (euclidian n (n ℕ.+ d ℕ.∸ n) (n ℕ.+ (n ℕ.+ d))) else rℚ (euclidian (n ℕ.∸ suc (suc (n ℕ.+ d))) (suc (n ℕ.+ d)) (n ℕ.+ (n ℕ.+ d)))) (n≢sn+d n d) ⟩ -- (if n ℕ.<ᴮ suc (n ℕ.+ d) then -- lℚ (euclidian n (n ℕ.+ d ℕ.∸ n) (n ℕ.+ (n ℕ.+ d))) else -- rℚ (euclidian (n ℕ.∸ suc (suc (n ℕ.+ d))) (suc (n ℕ.+ d)) (n ℕ.+ (n ℕ.+ d)))) ≡⟨ cong (if_then lℚ ((euclidian n (n ℕ.+ d ℕ.∸ n) (n ℕ.+ (n ℕ.+ d)))) else rℚ ((euclidian (n ℕ.∸ suc (suc (n ℕ.+ d))) (suc (n ℕ.+ d)) (n ℕ.+ (n ℕ.+ d))))) (n<sn+d n d) ⟩ -- lℚ (euclidian n (n ℕ.+ d ℕ.∸ n) (n ℕ.+ (n ℕ.+ d))) ≡⟨ cong (λ ndn → lℚ (euclidian n ndn (n ℕ.+ (n ℕ.+ d)))) (n+d-n≡d n d) ⟩ -- lℚ (euclidian n d (n ℕ.+ (n ℕ.+ d))) ≡⟨ {!!} ⟩ -- lℚ (euclidian n d (n ℕ.+ d)) ≡⟨⟩ -- lℚ (normalise-suc n d) ∎ -- ℚ-retract′ : ∀ x → normalise-suc (fst (fraction x)) (snd (fraction x)) ≡ x -- ℚ-retract′ 1ℚ = refl -- ℚ-retract′ (rℚ x) = {!!} -- ℚ-retract′ (lℚ x) = let n , d = fraction x in -- normalise-suc n (suc (n ℕ.+ d)) ≡⟨ {!!} ⟩ -- lℚ x ∎ -- ℚ-retract : ∀ x → ⟦ ⟦ x ⇓⟧ ⇑⟧ ≡ x -- ℚ-retract 1ℚ = refl -- ℚ-retract (lℚ x) = cong lℚ (ℚ-retract′ x) -- ℚ-retract (rℚ x) = cong rℚ (ℚ-retract′ x)
{ "alphanum_fraction": 0.5083258729, "avg_line_length": 41.6791044776, "ext": "agda", "hexsha": "b6d4d7934c6271641ff8a80f52f2c865e715a155", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-11T12:30:21.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-11T12:30:21.000Z", "max_forks_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "oisdk/agda-playground", "max_forks_repo_path": "Data/Rational/SternBrocot.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "oisdk/agda-playground", "max_issues_repo_path": "Data/Rational/SternBrocot.agda", "max_line_length": 375, "max_stars_count": 6, "max_stars_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "oisdk/agda-playground", "max_stars_repo_path": "Data/Rational/SternBrocot.agda", "max_stars_repo_stars_event_max_datetime": "2021-11-16T08:11:34.000Z", "max_stars_repo_stars_event_min_datetime": "2020-09-11T17:45:41.000Z", "num_tokens": 2886, "size": 5585 }
module _ where record ⊤ : Set where instance constructor tt data Nat : Set where suc : Nat → Nat NZ : Nat → Set NZ (suc _) = ⊤ postulate A : ∀ n → {{_ : NZ n}} → Set B : ∀ n (nz : NZ n) → Set B (suc n) nz = A (suc n)
{ "alphanum_fraction": 0.5341880342, "avg_line_length": 12.3157894737, "ext": "agda", "hexsha": "2401585123e5faad6c3a2888dbdbdd877094b976", "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/InstanceEta.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/InstanceEta.agda", "max_line_length": 30, "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/InstanceEta.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": 93, "size": 234 }
module Nat where data Rel (A : Set) : Set1 where rel : (A -> A -> Set) -> Rel A _is_than_ : {A : Set} -> A -> Rel A -> A -> Set x is rel f than y = f x y data Acc {A : Set} (less : Rel A) (x : A) : Set where acc : ((y : A) -> x is less than y -> Acc less y) -> Acc less x data WO {A : Set} (less : Rel A) : Set where wo : ((x : A) -> Acc less x) -> WO less data False : Set where data True : Set where tt : True data Nat : Set where Z : Nat S : Nat -> Nat data ∏ {A : Set} (f : A -> Set) : Set where ∏I : ((z : A) -> f z) -> ∏ f ltNat : Nat -> Nat -> Set ltNat Z Z = False ltNat Z (S n) = True ltNat (S m) (S n) = ltNat m n ltNat (S m) Z = False ltNatRel : Rel Nat ltNatRel = rel ltNat postulate woltNat : WO ltNatRel idN : Nat -> Nat idN x = x id : {A : Set} -> A -> A id x = x down1 : Nat -> Nat down1 Z = Z down1 (S n) = down1 n -- measure down1 = (woNat, id) -- For a function f : (x:A) -> B(x) -- f(p) = ... f(x1) ... f(x2) -- measure_set : Set -- measure_rel : Rel measure_set -- measure_ord : WO measure_rel -- measure_fun : A -> measure_set -- For j-th call of f in i-th clause of f: -- measure_i_j_hint : xj is measure_rel than p data Measure : Set1 where μ : {M : Set} -> {rel : Rel M} -> (ord : WO rel) -> Measure {- down1_measure_set : Set down1_measure_set = Nat down1_measure_rel : Rel down1_measure_set down1_measure_rel = ltNatRel down1_measure_ord : WO measure_rel down1_measure_ord = woltNat -} down1-measure : Measure down1-measure = μ woltNat down1-2-1-hint : (n : Nat) -> n is ltNatRel than (S n) down1-2-1-hint Z = tt down1-2-1-hint (S n) = down1-2-1-hint n {- down2 : Nat -> Nat down2 Z = Z down2 (S n) = down2 (idN n) down3 : Nat -> Nat down3 Z = Z down3 (S n) = down3 (id n) plus : Nat -> Nat -> Nat plus Z n = n plus (S m) n = S(plus m n) -}
{ "alphanum_fraction": 0.5903814262, "avg_line_length": 19.6630434783, "ext": "agda", "hexsha": "1aa8e00c317c6c38870969d358cf747bba66dd94", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cruhland/agda", "max_forks_repo_path": "examples/Termination/Nat.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "cruhland/agda", "max_issues_repo_path": "examples/Termination/Nat.agda", "max_line_length": 65, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "examples/Termination/Nat.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": 700, "size": 1809 }
open import Agda.Builtin.Unit open import Agda.Builtin.Bool open import Agda.Builtin.Reflection postulate tac : {A : Set} (x : A) → Term → TC ⊤ data D : Set where con : {@(tactic tac true) y : Bool} → D -- WAS: Internal error in Serialize/Instances/Internal for MetaV case -- SHOULD: succeed
{ "alphanum_fraction": 0.6966666667, "avg_line_length": 21.4285714286, "ext": "agda", "hexsha": "bd757aad37f9f3aae0ca48790de7a9fd3f972a93", "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/ConstructorWithTacticArg.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/ConstructorWithTacticArg.agda", "max_line_length": 69, "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/ConstructorWithTacticArg.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": 91, "size": 300 }
{- Pointed structure: X ↦ X -} {-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.Structures.Relational.Pointed where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Equiv open import Cubical.Foundations.Isomorphism open import Cubical.Foundations.Structure open import Cubical.Foundations.RelationalStructure open import Cubical.Foundations.Univalence open import Cubical.Relation.ZigZag.Base open import Cubical.HITs.SetQuotients open import Cubical.HITs.PropositionalTruncation open import Cubical.Structures.Pointed private variable ℓ : Level -- Structured relations PointedRelStr : StrRel PointedStructure ℓ PointedRelStr R = R pointedSuitableRel : SuitableStrRel {ℓ = ℓ} PointedStructure PointedRelStr pointedSuitableRel .quo _ _ _ = isContrSingl _ pointedSuitableRel .symmetric _ r = r pointedSuitableRel .transitive _ _ r r' = ∣ _ , r , r' ∣ pointedSuitableRel .set setX = setX pointedSuitableRel .prop propR = propR pointedRelMatchesEquiv : StrRelMatchesEquiv {ℓ = ℓ} PointedRelStr PointedEquivStr pointedRelMatchesEquiv _ _ _ = idEquiv _ pointedRelAction : StrRelAction {ℓ = ℓ} PointedRelStr pointedRelAction .actStr f = f pointedRelAction .actStrId _ = refl pointedRelAction .actRel α = α pointedPositiveRel : PositiveStrRel {ℓ = ℓ} pointedSuitableRel pointedPositiveRel .act = pointedRelAction pointedPositiveRel .reflexive x = ∣ refl ∣ pointedPositiveRel .detransitive R R' rr' = rr' pointedPositiveRel .quo R = isoToIsEquiv isom where open Iso isom : Iso _ _ isom .fun = _ isom .inv q = q isom .rightInv = elimProp (λ _ → squash/ _ _) (λ _ → refl) isom .leftInv = elimProp (λ _ → squash/ _ _) (λ _ → refl)
{ "alphanum_fraction": 0.7769230769, "avg_line_length": 29.649122807, "ext": "agda", "hexsha": "eff62d4cb2fcd53b84e0317e0736bc891392be62", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "dan-iel-lee/cubical", "max_forks_repo_path": "Cubical/Structures/Relational/Pointed.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_issues_repo_issues_event_max_datetime": "2022-01-27T02:07:48.000Z", "max_issues_repo_issues_event_min_datetime": "2022-01-27T02:07:48.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "dan-iel-lee/cubical", "max_issues_repo_path": "Cubical/Structures/Relational/Pointed.agda", "max_line_length": 81, "max_stars_count": null, "max_stars_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "dan-iel-lee/cubical", "max_stars_repo_path": "Cubical/Structures/Relational/Pointed.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 541, "size": 1690 }
-- Issue #4115 reported by Guillaume Brunerie {-# OPTIONS --prop #-} data Unit : Set where tt : Unit postulate P : Prop {-# TERMINATING #-} p : P p = p works : Unit → P works b = p -- WAS: Agda loops during injectivity analysis of `loops` loops : Unit → P loops tt = p
{ "alphanum_fraction": 0.6344086022, "avg_line_length": 13.2857142857, "ext": "agda", "hexsha": "cdf534822ee0ae5025cfd9ed661b2458650a6a85", "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/Issue4115.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/Issue4115.agda", "max_line_length": 57, "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/Issue4115.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": 279 }
module Data.Boolean.Stmt.Proofs where import Lvl open import Data.Boolean open import Data.Boolean.Proofs hiding (bivalence ; disjointness) import Data.Boolean.Operators open Data.Boolean.Operators.Programming open import Data.Boolean.Stmt open import Functional open import Logic.Propositional as Logic using (⊥ ; _∨_ ; _∧_ ; ¬_ ; _↔_ ; [⊤]-intro ; [↔]-intro ; [⊥]-elim) open import Relator.Equals open import Type -- A boolean operation is either true or false bivalence : ∀{a} → (IsTrue(a) ∨ IsFalse(a)) bivalence {𝑇} = Logic.[∨]-introₗ [⊤]-intro bivalence {𝐹} = Logic.[∨]-introᵣ [⊤]-intro -- A boolean operation is not both true and false at the same time disjointness : ∀{a} → IsTrue(a) → IsFalse(a) → ⊥ disjointness {𝑇} [⊤]-intro () disjointness {𝐹} () [⊤]-intro module IsTrue where [𝑇]-intro : IsTrue(𝑇) [𝑇]-intro = [⊤]-intro [𝐹]-elim : ¬ IsTrue(𝐹) [𝐹]-elim () [∧]-intro : ∀{a b} → IsTrue(a) → IsTrue(b) → IsTrue(a && b) [∧]-intro {𝑇} {b} ta tb = tb [∧]-intro {𝐹} {b} ta tb = ta [∨]-introₗ : ∀{a b} → IsTrue(a) → IsTrue(a || b) [∨]-introₗ {_}{𝑇} _ = [⊤]-intro [∨]-introₗ {_}{𝐹} = id [∨]-introᵣ : ∀{a b} → IsTrue(b) → IsTrue(a || b) [∨]-introᵣ {𝑇}{_} _ = [⊤]-intro [∨]-introᵣ {𝐹}{_} = id [∧]-elimₗ : ∀{a b} → IsTrue(a && b) → IsTrue(a) [∧]-elimₗ {𝑇}{𝑇} [⊤]-intro = [⊤]-intro [∧]-elimₗ {𝑇}{𝐹} () [∧]-elimₗ {𝐹}{𝑇} () [∧]-elimₗ {𝐹}{𝐹} () [∧]-elimᵣ : ∀{a b} → IsTrue(a && b) → IsTrue(b) [∧]-elimᵣ {𝑇}{𝑇} [⊤]-intro = [⊤]-intro [∧]-elimᵣ {𝑇}{𝐹} () [∧]-elimᵣ {𝐹}{𝑇} () [∧]-elimᵣ {𝐹}{𝐹} () [∨]-elim : ∀{ℓ₂}{φ : Type{ℓ₂}}{a b} → (IsTrue(a) → φ) → (IsTrue(b) → φ) → IsTrue(a || b) → φ [∨]-elim {_}{_}{𝑇}{𝑇} f _ [⊤]-intro = f [⊤]-intro [∨]-elim {_}{_}{𝑇}{𝐹} f _ [⊤]-intro = f [⊤]-intro [∨]-elim {_}{_}{𝐹}{𝑇} _ f [⊤]-intro = f [⊤]-intro [∨]-elim {_}{_}{𝐹}{𝐹} _ f () [¬]-intro : ∀{a} → IsFalse(a) → IsTrue(! a) [¬]-intro {𝐹} fa = [⊤]-intro [¬]-elim : ∀{a} → IsTrue(! a) → IsFalse(a) [¬]-elim {𝑇} () [¬]-elim {𝐹} [⊤]-intro = [⊤]-intro [→?]-intro : ∀{a b} → (IsTrue a → IsTrue b) → IsTrue (a →? b) [→?]-intro {𝑇} {𝑇} _ = [⊤]-intro [→?]-intro {𝑇} {𝐹} tab = tab [⊤]-intro [→?]-intro {𝐹} {𝑇} _ = [⊤]-intro [→?]-intro {𝐹} {𝐹} _ = [⊤]-intro [→?]-elim : ∀{a b} → IsTrue (a →? b) → (IsTrue a → IsTrue b) [→?]-elim {𝑇} {𝑇} tab ta = [⊤]-intro [←?]-intro : ∀{a b} → (IsTrue b → IsTrue a) → IsTrue (a ←? b) [←?]-intro {𝑇} {𝑇} tba = [⊤]-intro [←?]-intro {𝑇} {𝐹} tba = [⊤]-intro [←?]-intro {𝐹} {𝑇} tba = tba [⊤]-intro [←?]-intro {𝐹} {𝐹} tba = [⊤]-intro [←?]-elim : ∀{a b} → IsTrue (a ←? b) → (IsTrue b → IsTrue a) [←?]-elim {𝑇} {𝑇} tab tb = [⊤]-intro [==]-intro : ∀{a b} → (IsTrue b → IsTrue a) → (IsTrue a → IsTrue b) → IsTrue(a == b) [==]-intro {𝑇} {𝑇} ba ab = [⊤]-intro [==]-intro {𝑇} {𝐹} ba ab = ab [⊤]-intro [==]-intro {𝐹} {𝑇} ba ab = ba [⊤]-intro [==]-intro {𝐹} {𝐹} ba ab = [⊤]-intro [==]-elimₗ : ∀{a b} → IsTrue(a == b) → (IsTrue b → IsTrue a) [==]-elimₗ {𝑇} {𝑇} tab tb = [⊤]-intro [==]-elimᵣ : ∀{a b} → IsTrue(a == b) → (IsTrue a → IsTrue b) [==]-elimᵣ {𝑇} {𝑇} tab ta = [⊤]-intro [!]-intro : ∀{a b} → (IsTrue a → IsTrue b) → (IsTrue a → IsTrue(not b)) → IsTrue(not a) [!]-intro {𝑇} {𝑇} tab tanb = tanb [⊤]-intro [!]-intro {𝑇} {𝐹} tab tanb = tab [⊤]-intro [!]-intro {𝐹} {𝑇} tab tanb = [⊤]-intro [!]-intro {𝐹} {𝐹} tab tanb = [⊤]-intro [!]-elim : ∀{a b} → IsTrue a → IsTrue(not a) → IsTrue b [!]-elim {𝑇} {𝑇} ta tnb = [⊤]-intro [!]-elim {𝑇} {𝐹} ta tnb = tnb [!]-elim {𝐹} {𝑇} ta tnb = [⊤]-intro [!]-elim {𝐹} {𝐹} ta tnb = ta is-𝑇 : ∀{a} → IsTrue(a) ↔ (a ≡ 𝑇) is-𝑇 {a} = [↔]-intro (l{a}) (r{a}) where r : ∀ {a} → IsTrue(a) → (a ≡ 𝑇) r {𝑇} _ = [≡]-intro r {𝐹} () l : ∀ {a} → IsTrue(a) ← (a ≡ 𝑇) l [≡]-intro = [⊤]-intro preserves-[&&][∧] : ∀{a b} → IsTrue(a && b) ↔ IsTrue(a) ∧ IsTrue(b) preserves-[&&][∧] = [↔]-intro (\{(Logic.[∧]-intro l r) → [∧]-intro l r}) (proof ↦ Logic.[∧]-intro ([∧]-elimₗ proof) ([∧]-elimᵣ proof)) preserves-[||][∨] : ∀{a b} → IsTrue(a || b) ↔ IsTrue(a) ∨ IsTrue(b) preserves-[||][∨] = [↔]-intro (Logic.[∨]-elim [∨]-introₗ [∨]-introᵣ) ([∨]-elim Logic.[∨]-introₗ Logic.[∨]-introᵣ) preserves-[!][¬] : ∀{a} → IsTrue(! a) ↔ (¬ IsTrue(a)) preserves-[!][¬] {a} = [↔]-intro (l{a}) (r{a}) where l : ∀{a} → IsTrue(! a) ← (¬ IsTrue(a)) l {𝐹} _ = [⊤]-intro l {𝑇} f = [⊥]-elim (f [⊤]-intro) r : ∀{a} → IsTrue(! a) → (¬ IsTrue(a)) r {𝑇} () _ r {𝐹} _ () module IsFalse where [∧]-introₗ : ∀{a b} → IsFalse(a) → IsFalse(a && b) [∧]-introₗ {_}{𝑇} = id [∧]-introₗ {_}{𝐹} _ = [⊤]-intro [∧]-introᵣ : ∀{a b} → IsFalse(b) → IsFalse(a && b) [∧]-introᵣ {𝑇}{_} = id [∧]-introᵣ {𝐹}{_} _ = [⊤]-intro [∨]-intro : ∀{a b} → IsFalse(a) → IsFalse(b) → IsFalse(a || b) [∨]-intro {𝑇} fa fb = fa [∨]-intro {𝐹} fa fb = fb [¬]-intro : ∀{a} → IsTrue(a) → IsFalse(! a) [¬]-intro = id [¬]-elim : ∀{a} → IsFalse(! a) → IsTrue(a) [¬]-elim = id is-𝐹 : ∀{a} → IsFalse(a) ↔ (a ≡ 𝐹) is-𝐹 {a} = [↔]-intro (l{a}) (r{a}) where r : ∀{a} → IsFalse(a) → (a ≡ 𝐹) r {𝑇} () r {𝐹} _ = [≡]-intro l : ∀{a} → IsFalse(a) ← (a ≡ 𝐹) l [≡]-intro = [⊤]-intro true-false-opposites : ∀{a} → IsTrue(a) ↔ (¬ IsFalse(a)) true-false-opposites {𝑇} = [↔]-intro (const [⊤]-intro) (const id) true-false-opposites {𝐹} = [↔]-intro (_$ [⊤]-intro) const false-true-opposites : ∀{a} → IsFalse(a) ↔ (¬ IsTrue(a)) false-true-opposites {𝑇} = [↔]-intro (_$ [⊤]-intro) const false-true-opposites {𝐹} = [↔]-intro (const [⊤]-intro) (const id)
{ "alphanum_fraction": 0.4745702006, "avg_line_length": 32.091954023, "ext": "agda", "hexsha": "7f760ff3dda5927620e252eff32d212356536a95", "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/Boolean/Stmt/Proofs.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/Boolean/Stmt/Proofs.agda", "max_line_length": 108, "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/Boolean/Stmt/Proofs.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": 2965, "size": 5584 }
-- Andreas, 2017-05-15, issue 2585, reported by Martin Stone Davis -- Information about whether a function uses copatterns -- needs to be added already while function is defines. -- Otherwise, clauses might fail to check due to missing eta. {-# OPTIONS --postfix-projections #-} open import Agda.Builtin.Equality record Super : Set₁ where eta-equality field set : Set record Sub : Set₁ where eta-equality field super1 : Super super2 : Super super1=2 : super1 ≡ super2 postulate X : Set works : Sub works .Sub.super1 = record { set = X } works .Sub.super2 .Super.set = X works .Sub.super1=2 = refl test : Sub test .Sub.super1 .Super.set = X test .Sub.super2 .Super.set = X test .Sub.super1=2 = refl -- Should pass
{ "alphanum_fraction": 0.7001338688, "avg_line_length": 20.75, "ext": "agda", "hexsha": "b08db5202560248085fb06a95295d158c4412aa0", "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/Issue2585.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/Issue2585.agda", "max_line_length": 66, "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/Issue2585.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": 219, "size": 747 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Various forms of induction for natural numbers ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} module Induction.Nat where open import Function open import Data.Nat open import Data.Nat.Properties using (≤⇒≤′) open import Data.Fin using (_≺_) open import Data.Fin.Properties open import Data.Product open import Data.Unit open import Induction open import Induction.WellFounded as WF open import Level using (Lift) open import Relation.Binary.PropositionalEquality open import Relation.Unary ------------------------------------------------------------------------ -- Ordinary induction Rec : ∀ ℓ → RecStruct ℕ ℓ ℓ Rec ℓ P zero = Lift ℓ ⊤ Rec ℓ P (suc n) = P n recBuilder : ∀ {ℓ} → RecursorBuilder (Rec ℓ) recBuilder P f zero = _ recBuilder P f (suc n) = f n (recBuilder P f n) rec : ∀ {ℓ} → Recursor (Rec ℓ) rec = build recBuilder ------------------------------------------------------------------------ -- Complete induction CRec : ∀ ℓ → RecStruct ℕ ℓ ℓ CRec ℓ P zero = Lift ℓ ⊤ CRec ℓ P (suc n) = P n × CRec ℓ P n cRecBuilder : ∀ {ℓ} → RecursorBuilder (CRec ℓ) cRecBuilder P f zero = _ cRecBuilder P f (suc n) = f n ih , ih where ih = cRecBuilder P f n cRec : ∀ {ℓ} → Recursor (CRec ℓ) cRec = build cRecBuilder ------------------------------------------------------------------------ -- Complete induction based on _<′_ <′-Rec : ∀ {ℓ} → RecStruct ℕ ℓ ℓ <′-Rec = WfRec _<′_ mutual <′-wellFounded : WellFounded _<′_ <′-wellFounded n = acc (<′-wellFounded′ n) <′-wellFounded′ : ∀ n → <′-Rec (Acc _<′_) n <′-wellFounded′ zero _ () <′-wellFounded′ (suc n) .n ≤′-refl = <′-wellFounded n <′-wellFounded′ (suc n) m (≤′-step m<n) = <′-wellFounded′ n m m<n module _ {ℓ} where open WF.All <′-wellFounded ℓ public renaming ( wfRecBuilder to <′-recBuilder ; wfRec to <′-rec ) hiding (wfRec-builder) ------------------------------------------------------------------------ -- Complete induction based on _<_ <-Rec : ∀ {ℓ} → RecStruct ℕ ℓ ℓ <-Rec = WfRec _<_ <-wellFounded : WellFounded _<_ <-wellFounded = Subrelation.wellFounded ≤⇒≤′ <′-wellFounded module _ {ℓ} where open WF.All <-wellFounded ℓ public renaming ( wfRecBuilder to <-recBuilder ; wfRec to <-rec ) hiding (wfRec-builder) ------------------------------------------------------------------------ -- Complete induction based on _≺_ ≺-Rec : ∀ {ℓ} → RecStruct ℕ ℓ ℓ ≺-Rec = WfRec _≺_ ≺-wellFounded : WellFounded _≺_ ≺-wellFounded = Subrelation.wellFounded ≺⇒<′ <′-wellFounded module _ {ℓ} where open WF.All ≺-wellFounded ℓ public renaming ( wfRecBuilder to ≺-recBuilder ; wfRec to ≺-rec ) hiding (wfRec-builder) ------------------------------------------------------------------------ -- Examples private module Examples where -- Doubles its input. twice : ℕ → ℕ twice = rec _ λ { zero _ → zero ; (suc n) twice-n → suc (suc twice-n) } -- Halves its input (rounding downwards). -- -- The step function is mentioned in a proof below, so it has been -- given a name. (The mutual keyword is used to avoid having to give -- a type signature for the step function.) mutual half₁-step = λ { zero _ → zero ; (suc zero) _ → zero ; (suc (suc n)) (_ , half₁n , _) → suc half₁n } half₁ : ℕ → ℕ half₁ = cRec _ half₁-step -- An alternative implementation of half₁. mutual half₂-step = λ { zero _ → zero ; (suc zero) _ → zero ; (suc (suc n)) rec → suc (rec n (≤′-step ≤′-refl)) } half₂ : ℕ → ℕ half₂ = <′-rec _ half₂-step -- The application half₁ (2 + n) is definitionally equal to -- 1 + half₁ n. Perhaps it is instructive to see why. half₁-2+ : ∀ n → half₁ (2 + n) ≡ 1 + half₁ n half₁-2+ n = begin half₁ (2 + n) ≡⟨⟩ cRec _ half₁-step (2 + n) ≡⟨⟩ half₁-step (2 + n) (cRecBuilder _ half₁-step (2 + n)) ≡⟨⟩ half₁-step (2 + n) (let ih = cRecBuilder _ half₁-step (1 + n) in half₁-step (1 + n) ih , ih) ≡⟨⟩ half₁-step (2 + n) (let ih = cRecBuilder _ half₁-step n in half₁-step (1 + n) (half₁-step n ih , ih) , half₁-step n ih , ih) ≡⟨⟩ 1 + half₁-step n (cRecBuilder _ half₁-step n) ≡⟨⟩ 1 + cRec _ half₁-step n ≡⟨⟩ 1 + half₁ n ∎ where open ≡-Reasoning -- The application half₂ (2 + n) is definitionally equal to -- 1 + half₂ n. Perhaps it is instructive to see why. half₂-2+ : ∀ n → half₂ (2 + n) ≡ 1 + half₂ n half₂-2+ n = begin half₂ (2 + n) ≡⟨⟩ <′-rec _ half₂-step (2 + n) ≡⟨⟩ half₂-step (2 + n) (<′-recBuilder _ half₂-step (2 + n)) ≡⟨⟩ 1 + <′-recBuilder _ half₂-step (2 + n) n (≤′-step ≤′-refl) ≡⟨⟩ 1 + Some.wfRecBuilder _ half₂-step (2 + n) (<′-wellFounded (2 + n)) n (≤′-step ≤′-refl) ≡⟨⟩ 1 + Some.wfRecBuilder _ half₂-step (2 + n) (acc (<′-wellFounded′ (2 + n))) n (≤′-step ≤′-refl) ≡⟨⟩ 1 + half₂-step n (Some.wfRecBuilder _ half₂-step n (<′-wellFounded′ (2 + n) n (≤′-step ≤′-refl))) ≡⟨⟩ 1 + half₂-step n (Some.wfRecBuilder _ half₂-step n (<′-wellFounded′ (1 + n) n ≤′-refl)) ≡⟨⟩ 1 + half₂-step n (Some.wfRecBuilder _ half₂-step n (<′-wellFounded n)) ≡⟨⟩ 1 + half₂-step n (<′-recBuilder _ half₂-step n) ≡⟨⟩ 1 + <′-rec _ half₂-step n ≡⟨⟩ 1 + half₂ n ∎ where open ≡-Reasoning -- Some properties that the functions above satisfy, proved using -- cRec. half₁-+₁ : ∀ n → half₁ (twice n) ≡ n half₁-+₁ = cRec _ λ { zero _ → refl ; (suc zero) _ → refl ; (suc (suc n)) (_ , half₁twice-n≡n , _) → cong (suc ∘ suc) half₁twice-n≡n } half₂-+₁ : ∀ n → half₂ (twice n) ≡ n half₂-+₁ = cRec _ λ { zero _ → refl ; (suc zero) _ → refl ; (suc (suc n)) (_ , half₁twice-n≡n , _) → cong (suc ∘ suc) half₁twice-n≡n } -- Some properties that the functions above satisfy, proved using -- <′-rec. half₁-+₂ : ∀ n → half₁ (twice n) ≡ n half₁-+₂ = <′-rec _ λ { zero _ → refl ; (suc zero) _ → refl ; (suc (suc n)) rec → cong (suc ∘ suc) (rec n (≤′-step ≤′-refl)) } half₂-+₂ : ∀ n → half₂ (twice n) ≡ n half₂-+₂ = <′-rec _ λ { zero _ → refl ; (suc zero) _ → refl ; (suc (suc n)) rec → cong (suc ∘ suc) (rec n (≤′-step ≤′-refl)) } ------------------------------------------------------------------------ -- DEPRECATED NAMES ------------------------------------------------------------------------ -- Please use the new names as continuing support for the old names is -- not guaranteed. -- Version 0.15 rec-builder = recBuilder {-# WARNING_ON_USAGE rec-builder "Warning: rec-builder was deprecated in v0.15. Please use recBuilder instead." #-} cRec-builder = cRecBuilder {-# WARNING_ON_USAGE cRec-builder "Warning: cRec-builder was deprecated in v0.15. Please use cRecBuilder instead." #-} <′-rec-builder = <′-recBuilder {-# WARNING_ON_USAGE <′-rec-builder "Warning: <′-rec-builder was deprecated in v0.15. Please use <′-recBuilder instead." #-} <-rec-builder = <-recBuilder {-# WARNING_ON_USAGE <-rec-builder "Warning: <-rec-builder was deprecated in v0.15. Please use <-recBuilder instead." #-} ≺-rec-builder = ≺-recBuilder {-# WARNING_ON_USAGE ≺-rec-builder "Warning: ≺-rec-builder was deprecated in v0.15. Please use ≺-recBuilder instead." #-} <′-well-founded = <′-wellFounded {-# WARNING_ON_USAGE <′-well-founded "Warning: <′-well-founded was deprecated in v0.15. Please use <′-wellFounded instead." #-} <′-well-founded′ = <′-wellFounded′ {-# WARNING_ON_USAGE <′-well-founded′ "Warning: <′-well-founded′ was deprecated in v0.15. Please use <′-wellFounded′ instead." #-} <-well-founded = <-wellFounded {-# WARNING_ON_USAGE <-well-founded "Warning: <-well-founded was deprecated in v0.15. Please use <-wellFounded instead." #-} ≺-well-founded = ≺-wellFounded {-# WARNING_ON_USAGE ≺-well-founded "Warning: ≺-well-founded was deprecated in v0.15. Please use ≺-wellFounded instead." #-}
{ "alphanum_fraction": 0.5005024004, "avg_line_length": 28.8006430868, "ext": "agda", "hexsha": "893a13a8951b2e7915ce1eb97dcaab05ec4e21b2", "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/Induction/Nat.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/Induction/Nat.agda", "max_line_length": 77, "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/Induction/Nat.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 2809, "size": 8957 }
{-# OPTIONS --without-K --safe #-} open import Categories.Category -- Reasoning facilities about morphism equivalences (not necessarily 'squares') module Categories.Morphism.Reasoning {o ℓ e} (C : Category o ℓ e) where open import Categories.Morphism.Reasoning.Core C public open import Categories.Morphism.Reasoning.Iso C public
{ "alphanum_fraction": 0.7784431138, "avg_line_length": 30.3636363636, "ext": "agda", "hexsha": "d77aac4d0969b2417d6a817c1c2d51fb5b81a5bf", "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": "7672b7a3185ae77467cc30e05dbe50b36ff2af8a", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "bblfish/agda-categories", "max_forks_repo_path": "src/Categories/Morphism/Reasoning.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "7672b7a3185ae77467cc30e05dbe50b36ff2af8a", "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": "bblfish/agda-categories", "max_issues_repo_path": "src/Categories/Morphism/Reasoning.agda", "max_line_length": 79, "max_stars_count": 5, "max_stars_repo_head_hexsha": "7672b7a3185ae77467cc30e05dbe50b36ff2af8a", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "bblfish/agda-categories", "max_stars_repo_path": "src/Categories/Morphism/Reasoning.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": 78, "size": 334 }
{-# OPTIONS --cubical-compatible --universe-polymorphism #-} module WithoutK where open import Common.Level -- Propositional equality. data _≡_ {A : Set} : A → A → Set where refl : ∀ x → x ≡ x -- The J rule. J : {A : Set} (P : {x y : A} → x ≡ y → Set) → (∀ x → P (refl x)) → ∀ {x y} (x≡y : x ≡ y) → P x≡y J P p (refl x) = p x -- Christine Paulin-Mohring's version of the J rule. J′ : {A : Set} {x : A} (P : {y : A} → x ≡ y → Set) → P (refl x) → ∀ {y} (x≡y : x ≡ y) → P x≡y J′ P p (refl x) = p -- A variant of _≡_. data _≡′_ {A : Set} (x : A) : A → Set where refl : x ≡′ x -- We normalise before checking index well-formedness. const : ∀ {a b} {A : Set a} {B : Set b} → A → B → A const x _ = x id : {A : Set} {x y : A} → const x y ≡′ const y x → x ≡′ y id refl = refl -- We can handle more complicated indices as well. data ⊥ : Set where data Bool : Set where true false : Bool true≢false : true ≡ false → ⊥ true≢false () data D : Set where c₀ : D c₂ : (i₁ i₂ : D) → D f : ∀ {x y z} → x ≡ y → c₂ y c₀ ≡ c₂ c₀ z → x ≡ z f x≡y (refl .(c₂ c₀ c₀)) = x≡y -- The indices can contain literals. data ℕ : Set where zero : ℕ suc : (n : ℕ) → ℕ {-# BUILTIN NATURAL ℕ #-} g : 2 ≡ 3 → 3 ≡ 5 g () h : ∀ {n} → 2 ≡ suc n → n ≡ 1 h (refl .2) = refl _
{ "alphanum_fraction": 0.5116099071, "avg_line_length": 18.7246376812, "ext": "agda", "hexsha": "c2e66af9ce56f66f2052f7037266fa866a5f3b6d", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "98c9382a59f707c2c97d75919e389fc2a783ac75", "max_forks_repo_licenses": [ "BSD-2-Clause" ], "max_forks_repo_name": "KDr2/agda", "max_forks_repo_path": "test/Succeed/WithoutK.agda", "max_issues_count": 6, "max_issues_repo_head_hexsha": "98c9382a59f707c2c97d75919e389fc2a783ac75", "max_issues_repo_issues_event_max_datetime": "2021-11-24T08:31:10.000Z", "max_issues_repo_issues_event_min_datetime": "2021-10-18T08:12:24.000Z", "max_issues_repo_licenses": [ "BSD-2-Clause" ], "max_issues_repo_name": "KDr2/agda", "max_issues_repo_path": "test/Succeed/WithoutK.agda", "max_line_length": 60, "max_stars_count": null, "max_stars_repo_head_hexsha": "98c9382a59f707c2c97d75919e389fc2a783ac75", "max_stars_repo_licenses": [ "BSD-2-Clause" ], "max_stars_repo_name": "KDr2/agda", "max_stars_repo_path": "test/Succeed/WithoutK.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 560, "size": 1292 }
------------------------------------------------------------------------------ -- Testing Agda internal term: @Pi _ (NoAbs _ _)@ ------------------------------------------------------------------------------ {-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} -- After the patch -- -- Wed Sep 21 04:50:43 COT 2011 [email protected] -- * got rid of the Fun constructor in internal syntax (using Pi _ (NoAbs _ _) instead) -- -- Agda is using @Pi _ (NoAbs _ _)@ for the non-dependent -- functions. We test some translations of non-dependent functions. module Agda.InternalTerms.PiNoAbsTerm where postulate _↔_ : Set → Set → Set D : Set A : Set postulate foo₁ : ((x : D) → A) → A {-# ATP prove foo₁ #-} postulate foo₂ : A → ((x : D) → A) {-# ATP prove foo₂ #-} postulate foo₃ : ((x : D) → A) ↔ A {-# ATP prove foo₃ #-}
{ "alphanum_fraction": 0.4937106918, "avg_line_length": 28.9090909091, "ext": "agda", "hexsha": "ce9043649cecc4f61b904c6b9251da0ca9438447", "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": "test/Succeed/fol-theorems/Agda/InternalTerms/PiNoAbsTerm.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": "test/Succeed/fol-theorems/Agda/InternalTerms/PiNoAbsTerm.agda", "max_line_length": 89, "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": "test/Succeed/fol-theorems/Agda/InternalTerms/PiNoAbsTerm.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": 244, "size": 954 }
module Everything where import Generics.Prelude import Generics.Telescope import Generics.Telescope.Equality import Generics.Desc import Generics.All import Generics.HasDesc import Generics.Accessibility import Generics.Helpers import Generics.Reflection import Generics.Mu import Generics.Mu.All import Generics.Mu.Elim import Generics.Mu.Fold import Generics.Mu.Conversion import Generics.Constructions.Case import Generics.Constructions.Cong import Generics.Constructions.DecEq import Generics.Constructions.Elim import Generics.Constructions.Fold import Generics.Constructions.Mu import Generics.Constructions.Recursion import Generics.Constructions.Show import Generics -- Work In Progress --------------------------------- -- import Generics.Mu.NoConfusion -- import Generics.Constructions.Injective
{ "alphanum_fraction": 0.8226600985, "avg_line_length": 23.2, "ext": "agda", "hexsha": "259f1caa49151b07ac45d0a119504ee742a0d80b", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2022-01-14T10:35:16.000Z", "max_forks_repo_forks_event_min_datetime": "2021-04-08T08:32:42.000Z", "max_forks_repo_head_hexsha": "db764f858d908aa39ea4901669a6bbce1525f757", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "flupe/generics", "max_forks_repo_path": "Everything.agda", "max_issues_count": 4, "max_issues_repo_head_hexsha": "db764f858d908aa39ea4901669a6bbce1525f757", "max_issues_repo_issues_event_max_datetime": "2022-01-14T10:48:30.000Z", "max_issues_repo_issues_event_min_datetime": "2021-09-13T07:33:50.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "flupe/generics", "max_issues_repo_path": "Everything.agda", "max_line_length": 42, "max_stars_count": 11, "max_stars_repo_head_hexsha": "db764f858d908aa39ea4901669a6bbce1525f757", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "flupe/generics", "max_stars_repo_path": "Everything.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-05T09:35:17.000Z", "max_stars_repo_stars_event_min_datetime": "2021-04-08T15:10:20.000Z", "num_tokens": 186, "size": 812 }
------------------------------------------------------------------------------ -- Fair properties ------------------------------------------------------------------------------ {-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} module FOTC.Program.ABP.Fair.PropertiesI where open import Common.FOL.Relation.Binary.EqReasoning open import FOTC.Base open import FOTC.Base.List open import FOTC.Base.List.PropertiesI open import FOTC.Data.List open import FOTC.Data.List.PropertiesI open import FOTC.Data.Stream.Type open import FOTC.Program.ABP.Fair.Type open import FOTC.Program.ABP.Terms ------------------------------------------------------------------------------ -- Because a greatest post-fixed point is a fixed-point, then the Fair -- predicate is also a pre-fixed point of the functional FairF, i.e. -- -- FairF Fair ≤ Fair (see FOTC.Program.ABP.Fair). Fair-in : ∀ {os} → ∃[ ft ] ∃[ os' ] F*T ft ∧ os ≡ ft ++ os' ∧ Fair os' → Fair os Fair-in h = Fair-coind A h' h where A : D → Set A os = ∃[ ft ] ∃[ os' ] F*T ft ∧ os ≡ ft ++ os' ∧ Fair os' h' : ∀ {os} → A os → ∃[ ft ] ∃[ os' ] F*T ft ∧ os ≡ ft ++ os' ∧ A os' h' (ft , os' , FTft , prf , Fos') = ft , os' , FTft , prf , Fair-out Fos' head-tail-Fair : ∀ {os} → Fair os → os ≡ T ∷ tail₁ os ∨ os ≡ F ∷ tail₁ os head-tail-Fair {os} Fos with Fair-out Fos ... | .(T ∷ []) , os' , f*tnil , h , Fos' = inj₁ prf₃ where prf₁ : os ≡ T ∷ [] ++ os' prf₁ = os ≡⟨ h ⟩ (T ∷ []) ++ os' ≡⟨ ++-∷ T [] os' ⟩ T ∷ [] ++ os' ∎ prf₂ : tail₁ os ≡ [] ++ os' prf₂ = tail₁ os ≡⟨ tailCong prf₁ ⟩ tail₁ (T ∷ [] ++ os') ≡⟨ tail-∷ T ([] ++ os') ⟩ [] ++ os' ∎ prf₃ : os ≡ T ∷ tail₁ os prf₃ = os ≡⟨ prf₁ ⟩ T ∷ [] ++ os' ≡⟨ ∷-rightCong (sym prf₂) ⟩ T ∷ tail₁ os ∎ ... | .(F ∷ ft) , os' , f*tcons {ft} FTft , h , Fos' = inj₂ prf₃ where prf₁ : os ≡ F ∷ ft ++ os' prf₁ = os ≡⟨ h ⟩ (F ∷ ft) ++ os' ≡⟨ ++-∷ F ft os' ⟩ F ∷ ft ++ os' ∎ prf₂ : tail₁ os ≡ ft ++ os' prf₂ = tail₁ os ≡⟨ tailCong prf₁ ⟩ tail₁ (F ∷ ft ++ os') ≡⟨ tail-∷ F (ft ++ os') ⟩ ft ++ os' ∎ prf₃ : os ≡ F ∷ tail₁ os prf₃ = os ≡⟨ prf₁ ⟩ F ∷ ft ++ os' ≡⟨ ∷-rightCong (sym prf₂) ⟩ F ∷ tail₁ os ∎ tail-Fair : ∀ {os} → Fair os → Fair (tail₁ os) tail-Fair {os} Fos with Fair-out Fos ... | .(T ∷ []) , os' , f*tnil , h , Fos' = subst Fair (sym prf₂) Fos' where prf₁ : os ≡ T ∷ os' prf₁ = os ≡⟨ h ⟩ (T ∷ []) ++ os' ≡⟨ ++-∷ T [] os' ⟩ T ∷ [] ++ os' ≡⟨ ∷-rightCong (++-leftIdentity os') ⟩ T ∷ os' ∎ prf₂ : tail₁ os ≡ os' prf₂ = tail₁ os ≡⟨ tailCong prf₁ ⟩ tail₁ (T ∷ os') ≡⟨ tail-∷ T os' ⟩ os' ∎ ... | .(F ∷ ft) , os' , f*tcons {ft} FTft , h , Fos' = subst Fair (sym prf₂) (Fair-in (ft , os' , FTft , refl , Fos')) where prf₁ : os ≡ F ∷ ft ++ os' prf₁ = os ≡⟨ h ⟩ (F ∷ ft) ++ os' ≡⟨ ++-∷ F ft os' ⟩ F ∷ ft ++ os' ∎ prf₂ : tail₁ os ≡ ft ++ os' prf₂ = tail₁ os ≡⟨ tailCong prf₁ ⟩ tail₁ (F ∷ ft ++ os') ≡⟨ tail-∷ F (ft ++ os') ⟩ ft ++ os' ∎ Fair→Stream : ∀ {os} → Fair os → Stream os Fair→Stream Fos = Stream-coind A h Fos where A : D → Set A xs = Fair xs h : ∀ {os} → A os → ∃[ o' ] ∃[ os' ] os ≡ o' ∷ os' ∧ A os' h {os} As with head-tail-Fair As ... | inj₁ prf = T , tail₁ os , prf , tail-Fair As ... | inj₂ prf = F , tail₁ os , prf , tail-Fair As F*T→List : ∀ {xs} → F*T xs → List xs F*T→List f*tnil = lcons T lnil F*T→List (f*tcons {ft} FTft) = lcons F (F*T→List FTft)
{ "alphanum_fraction": 0.4340744571, "avg_line_length": 32.7796610169, "ext": "agda", "hexsha": "01efcdb18dcfd2a49dafc562f6e498f571b94254", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "asr/fotc", "max_forks_repo_path": "src/fot/FOTC/Program/ABP/Fair/PropertiesI.agda", "max_issues_count": 2, "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "asr/fotc", "max_issues_repo_path": "src/fot/FOTC/Program/ABP/Fair/PropertiesI.agda", "max_line_length": 78, "max_stars_count": 11, "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/fotc", "max_stars_repo_path": "src/fot/FOTC/Program/ABP/Fair/PropertiesI.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": 1520, "size": 3868 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Table-related properties ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} module Data.Table.Properties where open import Data.Table open import Data.Table.Relation.Binary.Equality open import Data.Bool using (true; false; if_then_else_) open import Data.Nat using (zero; suc) open import Data.Empty using (⊥-elim) open import Data.Fin using (Fin; suc; zero; _≟_; punchIn) import Data.Fin.Properties as FP open import Data.Fin.Permutation as Perm using (Permutation; _⟨$⟩ʳ_; _⟨$⟩ˡ_) open import Data.List as L using (List; _∷_; []) open import Data.List.Relation.Unary.Any using (here; there; index) open import Data.List.Membership.Propositional using (_∈_) open import Data.Product as Product using (Σ; ∃; _,_; proj₁; proj₂) open import Data.Vec as V using (Vec; _∷_; []) import Data.Vec.Properties as VP open import Function using (_∘_; flip) open import Function.Inverse using (Inverse) open import Relation.Binary.PropositionalEquality as P using (_≡_; _≢_; refl; sym; cong) open import Relation.Nullary using (yes; no) open import Relation.Nullary.Negation using (contradiction) ------------------------------------------------------------------------ -- select module _ {a} {A : Set a} where -- Selecting from any table is the same as selecting from a constant table. select-const : ∀ {n} (z : A) (i : Fin n) t → select z i t ≗ select z i (replicate (lookup t i)) select-const z i t j with j ≟ i ... | yes _ = refl ... | no _ = refl -- Selecting an element from a table then looking it up is the same as looking -- up the index in the original table select-lookup : ∀ {n x i} (t : Table A n) → lookup (select x i t) i ≡ lookup t i select-lookup {i = i} t with i ≟ i ... | yes _ = refl ... | no i≢i = contradiction refl i≢i -- Selecting an element from a table then removing the same element produces a -- constant table select-remove : ∀ {n x} i (t : Table A (suc n)) → remove i (select x i t) ≗ replicate {n = n} x select-remove i t j with punchIn i j ≟ i ... | yes p = contradiction p (FP.punchInᵢ≢i _ _) ... | no ¬p = refl ------------------------------------------------------------------------ -- permute -- Removing an index 'i' from a table permuted with 'π' is the same as -- removing the element, then permuting with 'π' minus 'i'. remove-permute : ∀ {m n} (π : Permutation (suc m) (suc n)) i (t : Table A (suc n)) → remove (π ⟨$⟩ˡ i) (permute π t) ≗ permute (Perm.remove (π ⟨$⟩ˡ i) π) (remove i t) remove-permute π i t j = P.cong (lookup t) (Perm.punchIn-permute′ π i j) ------------------------------------------------------------------------ -- fromList module _ {a} {A : Set a} where fromList-∈ : ∀ {xs : List A} (i : Fin (L.length xs)) → lookup (fromList xs) i ∈ xs fromList-∈ {[]} () fromList-∈ {x ∷ xs} zero = here refl fromList-∈ {x ∷ xs} (suc i) = there (fromList-∈ i) index-fromList-∈ : ∀ {xs i} → index (fromList-∈ {xs} i) ≡ i index-fromList-∈ {[]} {()} index-fromList-∈ {x ∷ xs} {zero} = refl index-fromList-∈ {x ∷ xs} {suc i} = cong suc index-fromList-∈ fromList-index : ∀ {xs} {x : A} (x∈xs : x ∈ xs) → lookup (fromList xs) (index x∈xs) ≡ x fromList-index (here px) = sym px fromList-index (there x∈xs) = fromList-index x∈xs ------------------------------------------------------------------------ -- There exists an isomorphism between tables and vectors. module _ {a n} {A : Set a} where ↔Vec : Inverse (≡-setoid A n) (P.setoid (Vec A n)) ↔Vec = record { to = record { _⟨$⟩_ = toVec ; cong = VP.tabulate-cong } ; from = P.→-to-⟶ fromVec ; inverse-of = record { left-inverse-of = VP.lookup∘tabulate ∘ lookup ; right-inverse-of = VP.tabulate∘lookup } } ------------------------------------------------------------------------ -- Other module _ {a} {A : Set a} where lookup∈ : ∀ {xs : List A} (i : Fin (L.length xs)) → ∃ λ x → x ∈ xs lookup∈ i = _ , fromList-∈ i
{ "alphanum_fraction": 0.5429789249, "avg_line_length": 35.1916666667, "ext": "agda", "hexsha": "1b399f27ebc5ca1b7e3f7facc8e663cd46355bc4", "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/Table/Properties.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "omega12345/agda-mode", "max_issues_repo_path": "test/asset/agda-stdlib-1.0/Data/Table/Properties.agda", "max_line_length": 89, "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/Table/Properties.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1255, "size": 4223 }
{-# OPTIONS --without-K --rewriting #-} open import HoTT open import homotopy.FinWedge open import homotopy.Bouquet open import groups.SphereEndomorphism open import cohomology.Theory module cohomology.RephraseSubFinCoboundary (OT : OrdinaryTheory lzero) where open OrdinaryTheory OT open import cohomology.SphereEndomorphism cohomology-theory open import cohomology.Sphere OT open import cohomology.SubFinBouquet OT abstract rephrase-in-degree : ∀ n {I : ℕ} {JA JB : Type₀} (JB-ac : has-choice 0 JB lzero) (JB-dec : has-dec-eq JB) {J} (p : Fin J ≃ Coprod JA JB) (f : ⊙FinBouquet I (S n) ⊙→ ⊙Susp (⊙Bouquet JB n)) g → GroupIso.f (C-FinBouquet-diag (S n) I) (CEl-fmap (ℕ-to-ℤ (S n)) f (<– (CEl-Susp (ℕ-to-ℤ n) (⊙Bouquet JB n)) (GroupIso.g (C-SubFinBouquet-diag n JB-ac (–> p)) g))) ∼ λ <I → Group.subsum-r (C2 0) (–> p) (λ b → Group.exp (C2 0) (g b) (⊙SphereS-endo-degree n (⊙Susp-fmap (⊙bwproj JB-dec b) ⊙∘ f ⊙∘ ⊙fwin <I))) rephrase-in-degree n {I} {JA} {JB} JB-ac JB-dec {J} p f g <I = GroupIso.f (C-FinBouquet-diag (S n) I) (CEl-fmap (ℕ-to-ℤ (S n)) f (<– (CEl-Susp (ℕ-to-ℤ n) (⊙Bouquet JB n)) (GroupIso.g (C-SubFinBouquet-diag n JB-ac (–> p)) g))) <I =⟨ ap (λ g → GroupIso.f (C-FinBouquet-diag (S n) I) (CEl-fmap (ℕ-to-ℤ (S n)) f (<– (CEl-Susp (ℕ-to-ℤ n) (⊙Bouquet JB n)) g)) <I) (inverse-C-SubFinBouquet-diag-β n JB-ac JB-dec p g) ⟩ GroupIso.f (C-FinBouquet-diag (S n) I) (CEl-fmap (ℕ-to-ℤ (S n)) f (<– (CEl-Susp (ℕ-to-ℤ n) (⊙Bouquet JB n)) (Group.subsum-r (C (ℕ-to-ℤ n) (⊙Bouquet JB n)) (–> p) (λ b → CEl-fmap (ℕ-to-ℤ n) (⊙bwproj JB-dec b) (CEl-fmap (ℕ-to-ℤ n) ⊙lift (GroupIso.g (C-Sphere-diag n) (g b))))))) <I =⟨ ap (λ g → GroupIso.f (C-FinBouquet-diag (S n) I) g <I) $ GroupHom.pres-subsum-r (C-fmap (ℕ-to-ℤ (S n)) f ∘ᴳ GroupIso.g-hom (C-Susp (ℕ-to-ℤ n) (⊙Bouquet JB n))) (–> p) (λ b → CEl-fmap (ℕ-to-ℤ n) (⊙bwproj JB-dec b) (CEl-fmap (ℕ-to-ℤ n) ⊙lift (GroupIso.g (C-Sphere-diag n) (g b)))) ⟩ GroupIso.f (C-FinBouquet-diag (S n) I) (Group.subsum-r (C (ℕ-to-ℤ (S n)) (⊙FinBouquet I (S n))) (–> p) (λ b → CEl-fmap (ℕ-to-ℤ (S n)) f (<– (CEl-Susp (ℕ-to-ℤ n) (⊙Bouquet JB n)) (CEl-fmap (ℕ-to-ℤ n) (⊙bwproj JB-dec b) (CEl-fmap (ℕ-to-ℤ n) ⊙lift (GroupIso.g (C-Sphere-diag n) (g b))))))) <I =⟨ ap (λ f → GroupIso.f (C-FinBouquet-diag (S n) I) (Group.subsum-r (C (ℕ-to-ℤ (S n)) (⊙FinBouquet I (S n))) (–> p) f) <I) (λ= λ b → ap (CEl-fmap (ℕ-to-ℤ (S n)) f) $ C-Susp-fmap' (ℕ-to-ℤ n) (⊙bwproj JB-dec b) □$ᴳ CEl-fmap (ℕ-to-ℤ n) ⊙lift (GroupIso.g (C-Sphere-diag n) (g b))) ⟩ GroupIso.f (C-FinBouquet-diag (S n) I) (Group.subsum-r (C (ℕ-to-ℤ (S n)) (⊙FinBouquet I (S n))) (–> p) (λ b → CEl-fmap (ℕ-to-ℤ (S n)) f (CEl-fmap (ℕ-to-ℤ (S n)) (⊙Susp-fmap (⊙bwproj JB-dec b)) (<– (CEl-Susp (ℕ-to-ℤ n) (⊙Sphere n)) (CEl-fmap (ℕ-to-ℤ n) ⊙lift (GroupIso.g (C-Sphere-diag n) (g b))))))) <I =⟨ C-FinBouquet-diag-β (S n) I (Group.subsum-r (C (ℕ-to-ℤ (S n)) (⊙FinBouquet I (S n))) (–> p) (λ b → CEl-fmap (ℕ-to-ℤ (S n)) f (CEl-fmap (ℕ-to-ℤ (S n)) (⊙Susp-fmap (⊙bwproj JB-dec b)) (<– (CEl-Susp (ℕ-to-ℤ n) (⊙Sphere n)) (CEl-fmap (ℕ-to-ℤ n) ⊙lift (GroupIso.g (C-Sphere-diag n) (g b))))))) <I ⟩ GroupIso.f (C-Sphere-diag (S n)) (CEl-fmap (ℕ-to-ℤ (S n)) ⊙lower (CEl-fmap (ℕ-to-ℤ (S n)) (⊙fwin <I) (Group.subsum-r (C (ℕ-to-ℤ (S n)) (⊙FinBouquet I (S n))) (–> p) (λ b → CEl-fmap (ℕ-to-ℤ (S n)) f (CEl-fmap (ℕ-to-ℤ (S n)) (⊙Susp-fmap (⊙bwproj JB-dec b)) (<– (CEl-Susp (ℕ-to-ℤ n) (⊙Sphere n)) (CEl-fmap (ℕ-to-ℤ n) ⊙lift (GroupIso.g (C-Sphere-diag n) (g b))))))))) =⟨ GroupHom.pres-subsum-r ( GroupIso.f-hom (C-Sphere-diag (S n)) ∘ᴳ C-fmap (ℕ-to-ℤ (S n)) ⊙lower ∘ᴳ C-fmap (ℕ-to-ℤ (S n)) (⊙fwin <I)) (–> p) (λ b → CEl-fmap (ℕ-to-ℤ (S n)) f (CEl-fmap (ℕ-to-ℤ (S n)) (⊙Susp-fmap (⊙bwproj JB-dec b)) (<– (CEl-Susp (ℕ-to-ℤ n) (⊙Sphere n)) (CEl-fmap (ℕ-to-ℤ n) ⊙lift (GroupIso.g (C-Sphere-diag n) (g b)))))) ⟩ Group.subsum-r (C2 0) (–> p) (λ b → GroupIso.f (C-Sphere-diag (S n)) (CEl-fmap (ℕ-to-ℤ (S n)) ⊙lower (CEl-fmap (ℕ-to-ℤ (S n)) (⊙fwin <I) (CEl-fmap (ℕ-to-ℤ (S n)) f (CEl-fmap (ℕ-to-ℤ (S n)) (⊙Susp-fmap (⊙bwproj JB-dec b)) (<– (CEl-Susp (ℕ-to-ℤ n) (⊙Sphere n)) (CEl-fmap (ℕ-to-ℤ n) ⊙lift (GroupIso.g (C-Sphere-diag n) (g b))))))))) =⟨ ap (Group.subsum-r (C2 0) (–> p)) (λ= λ b → ap (GroupIso.f (C-Sphere-diag (S n)) ∘ CEl-fmap (ℕ-to-ℤ (S n)) ⊙lower) $ ∘-CEl-fmap (ℕ-to-ℤ (S n)) (⊙fwin <I) f _ ∙ ∘-CEl-fmap (ℕ-to-ℤ (S n)) (f ⊙∘ ⊙fwin <I) (⊙Susp-fmap (⊙bwproj JB-dec b)) _ ∙ CEl-fmap-⊙Sphere-endo-η (ℕ-to-ℤ (S n)) n (⊙Susp-fmap (⊙bwproj JB-dec b) ⊙∘ f ⊙∘ ⊙fwin <I) (<– (CEl-Susp (ℕ-to-ℤ n) (⊙Sphere n)) (CEl-fmap (ℕ-to-ℤ n) ⊙lift (GroupIso.g (C-Sphere-diag n) (g b))))) ⟩ Group.subsum-r (C2 0) (–> p) (λ b → GroupIso.f (C-Sphere-diag (S n)) (CEl-fmap (ℕ-to-ℤ (S n)) ⊙lower (Group.exp (C (ℕ-to-ℤ (S n)) (⊙Sphere (S n))) (<– (CEl-Susp (ℕ-to-ℤ n) (⊙Sphere n)) (CEl-fmap (ℕ-to-ℤ n) ⊙lift (GroupIso.g (C-Sphere-diag n) (g b)))) (⊙SphereS-endo-degree n (⊙Susp-fmap (⊙bwproj JB-dec b) ⊙∘ f ⊙∘ ⊙fwin <I))))) =⟨ ap (Group.subsum-r (C2 0) (–> p)) (λ= λ b → GroupHom.pres-exp (GroupIso.f-hom (C-Sphere-diag (S n)) ∘ᴳ C-fmap (ℕ-to-ℤ (S n)) ⊙lower) (<– (CEl-Susp (ℕ-to-ℤ n) (⊙Sphere n)) (CEl-fmap (ℕ-to-ℤ n) ⊙lift (GroupIso.g (C-Sphere-diag n) (g b)))) (⊙SphereS-endo-degree n (⊙Susp-fmap (⊙bwproj JB-dec b) ⊙∘ f ⊙∘ ⊙fwin <I))) ⟩ Group.subsum-r (C2 0) (–> p) (λ b → Group.exp (C2 0) (GroupIso.f (C-Sphere-diag n) (–> (CEl-Susp (ℕ-to-ℤ n) (⊙Lift (⊙Sphere n))) (CEl-fmap (ℕ-to-ℤ (S n)) (⊙lift {j = lzero} ⊙∘ ⊙Susp-fmap {Y = ⊙Sphere n} ⊙lower) (CEl-fmap (ℕ-to-ℤ (S n)) ⊙lower (<– (CEl-Susp (ℕ-to-ℤ n) (⊙Sphere n)) (CEl-fmap (ℕ-to-ℤ n) ⊙lift (GroupIso.g (C-Sphere-diag n) (g b)))))))) (⊙SphereS-endo-degree n (⊙Susp-fmap (⊙bwproj JB-dec b) ⊙∘ f ⊙∘ ⊙fwin <I))) =⟨ ap (Group.subsum-r (C2 0) (–> p)) (λ= λ b → ap (λ g → Group.exp (C2 0) g (⊙SphereS-endo-degree n (⊙Susp-fmap (⊙bwproj JB-dec b) ⊙∘ f ⊙∘ ⊙fwin <I))) $ ap (GroupIso.f (C-Sphere-diag n) ∘ –> (CEl-Susp (ℕ-to-ℤ n) (⊙Lift (⊙Sphere n)))) ( CEl-fmap-∘ (ℕ-to-ℤ (S n)) ⊙lift (⊙Susp-fmap {Y = ⊙Sphere n} ⊙lower) _ ∙ ap (CEl-fmap (ℕ-to-ℤ (S n)) (⊙Susp-fmap {Y = ⊙Sphere n} ⊙lower)) ( ∘-CEl-fmap (ℕ-to-ℤ (S n)) ⊙lift ⊙lower _ ∙ CEl-fmap-idf (ℕ-to-ℤ (S n)) _)) ∙ ap (GroupIso.f (C-Sphere-diag n)) ( (C-Susp-fmap (ℕ-to-ℤ n) ⊙lower □$ᴳ _) ∙ ap (CEl-fmap (ℕ-to-ℤ n) ⊙lower) (GroupIso.f-g (C-Susp (ℕ-to-ℤ n) (⊙Sphere n)) _) ∙ ∘-CEl-fmap (ℕ-to-ℤ n) ⊙lower ⊙lift _ ∙ CEl-fmap-idf (ℕ-to-ℤ n) _) ∙ GroupIso.f-g (C-Sphere-diag n) (g b)) ⟩ Group.subsum-r (C2 0) (–> p) (λ b → Group.exp (C2 0) (g b) (⊙SphereS-endo-degree n (⊙Susp-fmap (⊙bwproj JB-dec b) ⊙∘ f ⊙∘ ⊙fwin <I))) =∎ {- the version specialzied to [Fin J]. -} rephrase-in-degree' : ∀ n {I J : ℕ} (f : ⊙FinBouquet I (S n) ⊙→ ⊙Susp (⊙FinBouquet J n)) g → GroupIso.f (C-FinBouquet-diag (S n) I) (CEl-fmap (ℕ-to-ℤ (S n)) f (<– (CEl-Susp (ℕ-to-ℤ n) (⊙FinBouquet J n)) (GroupIso.g (C-FinBouquet-diag n J) g))) ∼ λ <I → Group.sum (C2 0) (λ <J → Group.exp (C2 0) (g <J) (⊙SphereS-endo-degree n (⊙Susp-fmap (⊙fwproj <J) ⊙∘ f ⊙∘ ⊙fwin <I))) rephrase-in-degree' n {I} {J} f g = rephrase-in-degree n {I} {JA = Empty} {JB = Fin J} (Fin-has-choice 0 lzero) Fin-has-dec-eq (⊔₁-Empty (Fin J) ⁻¹) f g
{ "alphanum_fraction": 0.4640275387, "avg_line_length": 49.2372881356, "ext": "agda", "hexsha": "6c71a718467e4feea32edc14d9b30184c81cc196", "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/cohomology/RephraseSubFinCoboundary.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/cohomology/RephraseSubFinCoboundary.agda", "max_line_length": 125, "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/cohomology/RephraseSubFinCoboundary.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 3960, "size": 8715 }
------------------------------------------------------------------------ -- Pointwise products of binary relations ------------------------------------------------------------------------ module Relation.Binary.Product.Pointwise where open import Data.Function open import Data.Product open import Data.Sum open import Relation.Nullary.Product open import Relation.Binary private module Dummy {a₁ a₂ : Set} where infixr 2 _×-Rel_ _×-Rel_ : Rel a₁ → Rel a₂ → Rel (a₁ × a₂) ∼₁ ×-Rel ∼₂ = (∼₁ on₁ proj₁) -×- (∼₂ on₁ proj₂) -- Some properties which are preserved by ×-Rel (under certain -- assumptions). _×-reflexive_ : ∀ {≈₁ ∼₁ ≈₂ ∼₂} → ≈₁ ⇒ ∼₁ → ≈₂ ⇒ ∼₂ → (≈₁ ×-Rel ≈₂) ⇒ (∼₁ ×-Rel ∼₂) refl₁ ×-reflexive refl₂ = λ x≈y → (refl₁ (proj₁ x≈y) , refl₂ (proj₂ x≈y)) _×-refl_ : ∀ {∼₁ ∼₂} → Reflexive ∼₁ → Reflexive ∼₂ → Reflexive (∼₁ ×-Rel ∼₂) refl₁ ×-refl refl₂ = (refl₁ , refl₂) ×-irreflexive₁ : ∀ {≈₁ <₁ ≈₂ <₂} → Irreflexive ≈₁ <₁ → Irreflexive (≈₁ ×-Rel ≈₂) (<₁ ×-Rel <₂) ×-irreflexive₁ ir = λ x≈y x<y → ir (proj₁ x≈y) (proj₁ x<y) ×-irreflexive₂ : ∀ {≈₁ <₁ ≈₂ <₂} → Irreflexive ≈₂ <₂ → Irreflexive (≈₁ ×-Rel ≈₂) (<₁ ×-Rel <₂) ×-irreflexive₂ ir = λ x≈y x<y → ir (proj₂ x≈y) (proj₂ x<y) _×-symmetric_ : ∀ {∼₁ ∼₂} → Symmetric ∼₁ → Symmetric ∼₂ → Symmetric (∼₁ ×-Rel ∼₂) sym₁ ×-symmetric sym₂ = λ x∼y → sym₁ (proj₁ x∼y) , sym₂ (proj₂ x∼y) _×-transitive_ : ∀ {∼₁ ∼₂} → Transitive ∼₁ → Transitive ∼₂ → Transitive (∼₁ ×-Rel ∼₂) trans₁ ×-transitive trans₂ = λ x∼y y∼z → trans₁ (proj₁ x∼y) (proj₁ y∼z) , trans₂ (proj₂ x∼y) (proj₂ y∼z) _×-antisymmetric_ : ∀ {≈₁ ≤₁ ≈₂ ≤₂} → Antisymmetric ≈₁ ≤₁ → Antisymmetric ≈₂ ≤₂ → Antisymmetric (≈₁ ×-Rel ≈₂) (≤₁ ×-Rel ≤₂) antisym₁ ×-antisymmetric antisym₂ = λ x≤y y≤x → ( antisym₁ (proj₁ x≤y) (proj₁ y≤x) , antisym₂ (proj₂ x≤y) (proj₂ y≤x) ) ×-asymmetric₁ : ∀ {<₁ ∼₂} → Asymmetric <₁ → Asymmetric (<₁ ×-Rel ∼₂) ×-asymmetric₁ asym₁ = λ x<y y<x → asym₁ (proj₁ x<y) (proj₁ y<x) ×-asymmetric₂ : ∀ {∼₁ <₂} → Asymmetric <₂ → Asymmetric (∼₁ ×-Rel <₂) ×-asymmetric₂ asym₂ = λ x<y y<x → asym₂ (proj₂ x<y) (proj₂ y<x) _×-≈-respects₂_ : ∀ {≈₁ ∼₁ ≈₂ ∼₂} → ∼₁ Respects₂ ≈₁ → ∼₂ Respects₂ ≈₂ → (∼₁ ×-Rel ∼₂) Respects₂ (≈₁ ×-Rel ≈₂) _×-≈-respects₂_ {≈₁ = ≈₁} {∼₁ = ∼₁} {≈₂ = ≈₂} {∼₂ = ∼₂} resp₁ resp₂ = (λ {x y z} → resp¹ {x} {y} {z}) , (λ {x y z} → resp² {x} {y} {z}) where ∼ = ∼₁ ×-Rel ∼₂ resp¹ : ∀ {x} → (∼ x) Respects (≈₁ ×-Rel ≈₂) resp¹ y≈y' x∼y = proj₁ resp₁ (proj₁ y≈y') (proj₁ x∼y) , proj₁ resp₂ (proj₂ y≈y') (proj₂ x∼y) resp² : ∀ {y} → (flip₁ ∼ y) Respects (≈₁ ×-Rel ≈₂) resp² x≈x' x∼y = proj₂ resp₁ (proj₁ x≈x') (proj₁ x∼y) , proj₂ resp₂ (proj₂ x≈x') (proj₂ x∼y) ×-total : ∀ {∼₁ ∼₂} → Symmetric ∼₁ → Total ∼₁ → Total ∼₂ → Total (∼₁ ×-Rel ∼₂) ×-total {∼₁ = ∼₁} {∼₂ = ∼₂} sym₁ total₁ total₂ = total where total : Total (∼₁ ×-Rel ∼₂) total x y with total₁ (proj₁ x) (proj₁ y) | total₂ (proj₂ x) (proj₂ y) ... | inj₁ x₁∼y₁ | inj₁ x₂∼y₂ = inj₁ ( x₁∼y₁ , x₂∼y₂) ... | inj₁ x₁∼y₁ | inj₂ y₂∼x₂ = inj₂ (sym₁ x₁∼y₁ , y₂∼x₂) ... | inj₂ y₁∼x₁ | inj₂ y₂∼x₂ = inj₂ ( y₁∼x₁ , y₂∼x₂) ... | inj₂ y₁∼x₁ | inj₁ x₂∼y₂ = inj₁ (sym₁ y₁∼x₁ , x₂∼y₂) _×-decidable_ : ∀ {∼₁ ∼₂} → Decidable ∼₁ → Decidable ∼₂ → Decidable (∼₁ ×-Rel ∼₂) dec₁ ×-decidable dec₂ = λ x y → dec₁ (proj₁ x) (proj₁ y) ×-dec dec₂ (proj₂ x) (proj₂ y) -- Some collections of properties which are preserved by ×-Rel. _×-isEquivalence_ : ∀ {≈₁ ≈₂} → IsEquivalence ≈₁ → IsEquivalence ≈₂ → IsEquivalence (≈₁ ×-Rel ≈₂) _×-isEquivalence_ {≈₁ = ≈₁} {≈₂ = ≈₂} eq₁ eq₂ = record { refl = λ {x} → _×-refl_ {∼₁ = ≈₁} {∼₂ = ≈₂} (refl eq₁) (refl eq₂) {x} ; sym = λ {x y} → _×-symmetric_ {∼₁ = ≈₁} {∼₂ = ≈₂} (sym eq₁) (sym eq₂) {x} {y} ; trans = λ {x y z} → _×-transitive_ {∼₁ = ≈₁} {∼₂ = ≈₂} (trans eq₁) (trans eq₂) {x} {y} {z} } where open IsEquivalence _×-isPreorder_ : ∀ {≈₁ ∼₁ ≈₂ ∼₂} → IsPreorder ≈₁ ∼₁ → IsPreorder ≈₂ ∼₂ → IsPreorder (≈₁ ×-Rel ≈₂) (∼₁ ×-Rel ∼₂) _×-isPreorder_ {∼₁ = ∼₁} {∼₂ = ∼₂} pre₁ pre₂ = record { isEquivalence = isEquivalence pre₁ ×-isEquivalence isEquivalence pre₂ ; reflexive = λ {x y} → _×-reflexive_ {∼₁ = ∼₁} {∼₂ = ∼₂} (reflexive pre₁) (reflexive pre₂) {x} {y} ; trans = λ {x y z} → _×-transitive_ {∼₁ = ∼₁} {∼₂ = ∼₂} (trans pre₁) (trans pre₂) {x} {y} {z} ; ∼-resp-≈ = ∼-resp-≈ pre₁ ×-≈-respects₂ ∼-resp-≈ pre₂ } where open IsPreorder _×-isDecEquivalence_ : ∀ {≈₁ ≈₂} → IsDecEquivalence ≈₁ → IsDecEquivalence ≈₂ → IsDecEquivalence (≈₁ ×-Rel ≈₂) eq₁ ×-isDecEquivalence eq₂ = record { isEquivalence = isEquivalence eq₁ ×-isEquivalence isEquivalence eq₂ ; _≟_ = _≟_ eq₁ ×-decidable _≟_ eq₂ } where open IsDecEquivalence _×-isPartialOrder_ : ∀ {≈₁ ≤₁ ≈₂ ≤₂} → IsPartialOrder ≈₁ ≤₁ → IsPartialOrder ≈₂ ≤₂ → IsPartialOrder (≈₁ ×-Rel ≈₂) (≤₁ ×-Rel ≤₂) _×-isPartialOrder_ {≤₁ = ≤₁} {≤₂ = ≤₂} po₁ po₂ = record { isPreorder = isPreorder po₁ ×-isPreorder isPreorder po₂ ; antisym = λ {x y} → _×-antisymmetric_ {≤₁ = ≤₁} {≤₂ = ≤₂} (antisym po₁) (antisym po₂) {x} {y} } where open IsPartialOrder _×-isStrictPartialOrder_ : ∀ {≈₁ <₁ ≈₂ <₂} → IsStrictPartialOrder ≈₁ <₁ → IsStrictPartialOrder ≈₂ <₂ → IsStrictPartialOrder (≈₁ ×-Rel ≈₂) (<₁ ×-Rel <₂) _×-isStrictPartialOrder_ {<₁ = <₁} {≈₂ = ≈₂} {<₂ = <₂} spo₁ spo₂ = record { isEquivalence = isEquivalence spo₁ ×-isEquivalence isEquivalence spo₂ ; irrefl = λ {x y} → ×-irreflexive₁ {<₁ = <₁} {≈₂ = ≈₂} {<₂ = <₂} (irrefl spo₁) {x} {y} ; trans = λ {x y z} → _×-transitive_ {∼₁ = <₁} {∼₂ = <₂} (trans spo₁) (trans spo₂) {x} {y} {z} ; <-resp-≈ = <-resp-≈ spo₁ ×-≈-respects₂ <-resp-≈ spo₂ } where open IsStrictPartialOrder open Dummy public -- "Packages" (e.g. setoids) can also be combined. _×-preorder_ : Preorder → Preorder → Preorder p₁ ×-preorder p₂ = record { isPreorder = isPreorder p₁ ×-isPreorder isPreorder p₂ } where open Preorder _×-setoid_ : Setoid → Setoid → Setoid s₁ ×-setoid s₂ = record { isEquivalence = isEquivalence s₁ ×-isEquivalence isEquivalence s₂ } where open Setoid _×-decSetoid_ : DecSetoid → DecSetoid → DecSetoid s₁ ×-decSetoid s₂ = record { isDecEquivalence = isDecEquivalence s₁ ×-isDecEquivalence isDecEquivalence s₂ } where open DecSetoid _×-poset_ : Poset → Poset → Poset s₁ ×-poset s₂ = record { isPartialOrder = isPartialOrder s₁ ×-isPartialOrder isPartialOrder s₂ } where open Poset _×-strictPartialOrder_ : StrictPartialOrder → StrictPartialOrder → StrictPartialOrder s₁ ×-strictPartialOrder s₂ = record { isStrictPartialOrder = isStrictPartialOrder s₁ ×-isStrictPartialOrder isStrictPartialOrder s₂ } where open StrictPartialOrder
{ "alphanum_fraction": 0.4846938776, "avg_line_length": 37.5514018692, "ext": "agda", "hexsha": "31ab2abf761290b701fa78475d49898a686d0299", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:54:10.000Z", "max_forks_repo_forks_event_min_datetime": "2015-07-21T16:37:58.000Z", "max_forks_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "isabella232/Lemmachine", "max_forks_repo_path": "vendor/stdlib/src/Relation/Binary/Product/Pointwise.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3", "max_issues_repo_issues_event_max_datetime": "2022-03-12T12:17:51.000Z", "max_issues_repo_issues_event_min_datetime": "2022-03-12T12:17:51.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "larrytheliquid/Lemmachine", "max_issues_repo_path": "vendor/stdlib/src/Relation/Binary/Product/Pointwise.agda", "max_line_length": 72, "max_stars_count": 56, "max_stars_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "isabella232/Lemmachine", "max_stars_repo_path": "vendor/stdlib/src/Relation/Binary/Product/Pointwise.agda", "max_stars_repo_stars_event_max_datetime": "2021-12-21T17:02:19.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-20T02:11:42.000Z", "num_tokens": 3175, "size": 8036 }
open import Common.Prelude hiding (tt) instance tt : ⊤ tt = record{} NonZero : Nat → Set NonZero zero = ⊥ NonZero (suc _) = ⊤ pred′ : (n : Nat) {{_ : NonZero n}} → Nat pred′ zero {{}} pred′ (suc n) = n test : (n : Nat) {{x y : NonZero n}} → Nat test n = pred′ n
{ "alphanum_fraction": 0.5567765568, "avg_line_length": 16.0588235294, "ext": "agda", "hexsha": "0dd49c7af1a9fcf296cd396f15174030f5c79f78", "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/NonUniqueInstance1.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/NonUniqueInstance1.agda", "max_line_length": 42, "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/NonUniqueInstance1.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": 105, "size": 273 }
-- MIT License -- Copyright (c) 2021 Luca Ciccone and Luca Padovani -- Permission is hereby granted, free of charge, to any person -- obtaining a copy of this software and associated documentation -- files (the "Software"), to deal in the Software without -- restriction, including without limitation the rights to use, -- copy, modify, merge, publish, distribute, sublicense, and/or sell -- copies of the Software, and to permit persons to whom the -- Software is furnished to do so, subject to the following -- conditions: -- The above copyright notice and this permission notice shall be -- included in all copies or substantial portions of the Software. -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -- OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -- HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -- WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -- FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -- OTHER DEALINGS IN THE SOFTWARE. {-# OPTIONS --guardedness #-} open import Data.Empty using (⊥-elim) open import Data.Product open import Data.Sum open import Relation.Nullary open import Relation.Unary using (_∈_) open import Relation.Binary.PropositionalEquality using (_≡_; _≢_; refl; trans; sym; subst) open import Relation.Binary.Construct.Closure.ReflexiveTransitive using (ε; _◅_) open import Function.Base using (case_of_) open import Common module Compliance {ℙ : Set} (message : Message ℙ) where open import Action message open import SessionType message open import Transitions message open import Session message open import Progress message data Compliance : Session -> Set record ∞Compliance (S : Session) : Set where constructor delay_ coinductive field force : Compliance S open ∞Compliance public data Compliance where win#def : ∀{T S} (w : Win T) (def : Defined S) -> Compliance (T # S) out#inp : ∀{f g} (W : Witness f) (F : ∀{x} (!x : x ∈ dom f) -> ∞Compliance (f x .force # g x .force)) -> Compliance (out f # inp g) inp#out : ∀{f g} (W : Witness g) (F : ∀{x} (!x : x ∈ dom g) -> ∞Compliance (f x .force # g x .force)) -> Compliance (inp f # out g) subject-reduction : ∀{S S'} -> Compliance S -> Reduction S S' -> ∞Compliance S' force (subject-reduction (win#def (out U) def) (sync {I _} (out !x) s)) = ⊥-elim (U _ !x) force (subject-reduction (inp#out _ F) (sync inp (out !x))) = F !x .force force (subject-reduction (out#inp _ F) (sync (out !x) inp)) = F !x .force subject-reduction* : ∀{S S'} -> Compliance S -> Reductions S S' -> ∞Compliance S' force (subject-reduction* comp ε) = comp subject-reduction* comp (red ◅ reds) = subject-reduction* (subject-reduction comp red .force) reds compliance->progress : ∀{S} -> Compliance S -> Progress S compliance->progress (win#def w def) = win#def w def compliance->progress (out#inp W F) = out#inp W compliance->progress (inp#out W F) = inp#out W compliance->defined : ∀{T S} -> Compliance (T # S) -> Defined T × Defined S compliance->defined (win#def (out _) def) = out , def compliance->defined (out#inp _ _) = out , inp compliance->defined (inp#out _ _) = inp , out compliance-sound : ∀{S} -> Compliance S -> ComplianceS S compliance-sound comp reds = progress-sound (compliance->progress (subject-reduction* comp reds .force)) compliance-complete : ∀{S} -> ComplianceS S -> ∞Compliance S force (compliance-complete {T # S} spec) with spec ε ... | inj₁ (win#def w def) = win#def w def ... | inj₂ (_ , sync inp (out !x)) = inp#out (_ , !x) λ !x -> compliance-complete λ reds -> spec (sync inp (out !x) ◅ reds) ... | inj₂ (_ , sync (out !x) inp) = out#inp (_ , !x) λ !x -> compliance-complete λ reds -> spec (sync (out !x) inp ◅ reds)
{ "alphanum_fraction": 0.6954498449, "avg_line_length": 42.5054945055, "ext": "agda", "hexsha": "a8098613ab5e19ea480ba7e9d3aea718d20de747", "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": "c4b78e70c3caf68d509f4360b9171d9f80ecb825", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "boystrange/FairSubtypingAgda", "max_forks_repo_path": "src/Compliance.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "c4b78e70c3caf68d509f4360b9171d9f80ecb825", "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": "boystrange/FairSubtypingAgda", "max_issues_repo_path": "src/Compliance.agda", "max_line_length": 133, "max_stars_count": 4, "max_stars_repo_head_hexsha": "c4b78e70c3caf68d509f4360b9171d9f80ecb825", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "boystrange/FairSubtypingAgda", "max_stars_repo_path": "src/Compliance.agda", "max_stars_repo_stars_event_max_datetime": "2022-01-24T14:38:47.000Z", "max_stars_repo_stars_event_min_datetime": "2021-07-29T14:32:30.000Z", "num_tokens": 1102, "size": 3868 }
module +-mono-< where open import Data.Nat using (ℕ; zero; suc; _+_) open import Data.Nat.Properties using (+-comm) open import Relations using (_<_; z<s; s<s) open import <-trans using (<-trans) +-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)
{ "alphanum_fraction": 0.4512743628, "avg_line_length": 23.8214285714, "ext": "agda", "hexsha": "14d2d4f27e25523272cfeb3519a38e6fa859e3dc", "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": "df7722b88a9b3dfde320a690b78c4c1ef8c7c547", "max_forks_repo_licenses": [ "Apache-2.0" ], "max_forks_repo_name": "akiomik/plfa-solutions", "max_forks_repo_path": "part1/relations/+-mono-<.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "df7722b88a9b3dfde320a690b78c4c1ef8c7c547", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "Apache-2.0" ], "max_issues_repo_name": "akiomik/plfa-solutions", "max_issues_repo_path": "part1/relations/+-mono-<.agda", "max_line_length": 78, "max_stars_count": 1, "max_stars_repo_head_hexsha": "df7722b88a9b3dfde320a690b78c4c1ef8c7c547", "max_stars_repo_licenses": [ "Apache-2.0" ], "max_stars_repo_name": "akiomik/plfa-solutions", "max_stars_repo_path": "part1/relations/+-mono-<.agda", "max_stars_repo_stars_event_max_datetime": "2020-07-07T09:42:22.000Z", "max_stars_repo_stars_event_min_datetime": "2020-07-07T09:42:22.000Z", "num_tokens": 292, "size": 667 }
{-# OPTIONS --cubical --safe #-} module Cubical.Foundations.Everything where -- Basic cubical prelude open import Cubical.Foundations.Prelude public -- Definition of Identity types and definitions of J, funExt, -- univalence and propositional truncation using Id instead of Path open import Cubical.Foundations.Id hiding ( _≡_ ; _≡⟨_⟩_ ; _∎ ) renaming ( _≃_ to EquivId ; EquivContr to EquivContrId ; J to JId ; ap to apId ; equivFun to equivFunId ; equivCtr to equivCtrId ; fiber to fiberId ; funExt to funExtId ; isContr to isContrId ; isProp to isPropId ; isSet to isSetId ; isEquiv to isEquivId ; equivIsEquiv to equivIsEquivId ; refl to reflId ; ∥_∥ to propTruncId ; ∣_∣ to incId ; isPropIsContr to isPropIsContrId ; isPropIsEquiv to isPropIsEquivId ) open import Cubical.Foundations.GroupoidLaws public open import Cubical.Foundations.CartesianKanOps public open import Cubical.Foundations.Function public open import Cubical.Foundations.Equiv public open import Cubical.Foundations.Equiv.Properties public open import Cubical.Foundations.PathSplitEquiv public open import Cubical.Foundations.BiInvEquiv public open import Cubical.Foundations.FunExtEquiv public open import Cubical.Foundations.HLevels public open import Cubical.Foundations.Path public open import Cubical.Foundations.Transport public open import Cubical.Foundations.Univalence public open import Cubical.Foundations.UnivalenceId public open import Cubical.Foundations.GroupoidLaws public open import Cubical.Foundations.Isomorphism public open import Cubical.Foundations.Logic open import Cubical.Foundations.HoTT-UF
{ "alphanum_fraction": 0.684073107, "avg_line_length": 39.8958333333, "ext": "agda", "hexsha": "8da3efa470f1d91eb44637848be754d9c0c5fa7c", "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": "7fd336c6d31a6e6d58a44114831aacd63f422545", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cj-xu/cubical", "max_forks_repo_path": "Cubical/Foundations/Everything.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "7fd336c6d31a6e6d58a44114831aacd63f422545", "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": "cj-xu/cubical", "max_issues_repo_path": "Cubical/Foundations/Everything.agda", "max_line_length": 67, "max_stars_count": null, "max_stars_repo_head_hexsha": "7fd336c6d31a6e6d58a44114831aacd63f422545", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cj-xu/cubical", "max_stars_repo_path": "Cubical/Foundations/Everything.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 496, "size": 1915 }
module Prelude.String where open import Agda.Primitive open import Prelude.Unit open import Prelude.Char open import Prelude.Bool open import Prelude.Nat open import Prelude.List open import Prelude.Maybe open import Prelude.Equality open import Prelude.Equality.Unsafe open import Prelude.Decidable open import Prelude.Ord open import Prelude.Function open import Prelude.Monad open import Prelude.Semiring open import Agda.Builtin.String public open import Agda.Builtin.FromString public unpackString = primStringToList packString = primStringFromList unpackString-inj : ∀ {x y} → unpackString x ≡ unpackString y → x ≡ y unpackString-inj {x} p with unpackString x unpackString-inj refl | ._ = unsafeEqual infixr 5 _&_ _&_ = primStringAppend parseNat : String → Maybe Nat parseNat = parseNat′ ∘ unpackString where pDigit : Char → Maybe Nat pDigit c = if isDigit c then just (charToNat c - charToNat '0') else nothing pNat : Nat → List Char → Maybe Nat pNat n [] = just n pNat n (c ∷ s) = pDigit c >>= λ d → pNat (n * 10 + d) s parseNat′ : List Char → Maybe Nat parseNat′ [] = nothing parseNat′ (c ∷ s) = pDigit c >>= λ d → pNat d s -- Eq -- instance EqString : Eq String _==_ {{EqString}} x y with primStringEquality x y ... | true = yes unsafeEqual ... | false = no unsafeNotEqual -- Ord -- instance OrdString : Ord String OrdString = OrdBy unpackString-inj OrdLawsString : Ord/Laws String OrdLawsString = OrdLawsBy unpackString-inj -- Overloaded literals -- instance StringIsString : IsString String IsString.Constraint StringIsString _ = ⊤ IsString.fromString StringIsString s = s ListIsString : IsString (List Char) IsString.Constraint ListIsString _ = ⊤ IsString.fromString ListIsString s = unpackString s -- Monoid -- instance open import Prelude.Monoid MonoidString : Monoid String mempty {{MonoidString}} = "" _<>_ {{MonoidString}} = primStringAppend
{ "alphanum_fraction": 0.7151515152, "avg_line_length": 23.8554216867, "ext": "agda", "hexsha": "45583f89c5ba65fa554cb244623159041327ac1f", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "75016b4151ed601e28f4462cd7b6b1aaf5d0d1a6", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "lclem/agda-prelude", "max_forks_repo_path": "src/Prelude/String.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "75016b4151ed601e28f4462cd7b6b1aaf5d0d1a6", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "lclem/agda-prelude", "max_issues_repo_path": "src/Prelude/String.agda", "max_line_length": 68, "max_stars_count": null, "max_stars_repo_head_hexsha": "75016b4151ed601e28f4462cd7b6b1aaf5d0d1a6", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "lclem/agda-prelude", "max_stars_repo_path": "src/Prelude/String.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 559, "size": 1980 }
{-# OPTIONS --cubical-compatible #-} module Common.IO where open import Agda.Builtin.IO public open import Common.Bool open import Common.Char open import Common.Nat open import Common.String open import Common.Unit open import Common.Float infixl 1 _>>=_ postulate return : ∀ {a} {A : Set a} → A → IO A _>>=_ : ∀ {a b} {A : Set a} {B : Set b} → IO A → (A → IO B) → IO B {-# COMPILE GHC return = \_ _ -> return #-} {-# COMPILE GHC _>>=_ = \_ _ _ _ -> (>>=) #-} {-# COMPILE UHC return = \_ _ x -> UHC.Agda.Builtins.primReturn x #-} {-# COMPILE UHC _>>=_ = \_ _ _ _ x y -> UHC.Agda.Builtins.primBind x y #-} {-# COMPILE JS return = function(u0) { return function(u1) { return function(x) { return function(cb) { cb(x); }; }; }; } #-} {-# COMPILE JS _>>=_ = function(u0) { return function(u1) { return function(u2) { return function(u3) { return function(x) { return function(y) { return function(cb) { x(function (xx) { y(xx)(cb); }); }; }; }; }; }; }; } #-} {-# FOREIGN GHC import qualified Data.Text.IO #-} postulate putStr : String -> IO Unit {-# COMPILE GHC putStr = Data.Text.IO.putStr #-} {-# COMPILE UHC putStr = UHC.Agda.Builtins.primPutStr #-} {-# COMPILE JS putStr = function (x) { return function(cb) { process.stdout.write(x); cb(0); }; } #-} printChar : Char -> IO Unit printChar c = putStr (charToStr c) putStrLn : String -> IO Unit putStrLn s = putStr s >>= \_ -> putStr "\n" printNat : Nat -> IO Unit printNat n = putStr (natToString n) printBool : Bool -> IO Unit printBool true = putStr "true" printBool false = putStr "false" printFloat : Float -> IO Unit printFloat f = putStr (floatToString f) infixr 2 _<$>_ _<$>_ : {A B : Set}(f : A -> B)(m : IO A) -> IO B f <$> x = x >>= λ y -> return (f y) infixr 0 bind bind : ∀ {a b} {A : Set a} {B : Set b} → IO A → (A → IO B) → IO B bind m f = m >>= f infixr 0 then then : ∀ {a b} {A : Set a} {B : Set b} -> IO A -> IO B -> IO B then m f = m >>= λ _ -> f syntax bind e (\ x -> f) = x <- e , f syntax then e f = e ,, f
{ "alphanum_fraction": 0.5857843137, "avg_line_length": 28.3333333333, "ext": "agda", "hexsha": "85656477fa3e0905be98f540286d00dbe802eb1a", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "98c9382a59f707c2c97d75919e389fc2a783ac75", "max_forks_repo_licenses": [ "BSD-2-Clause" ], "max_forks_repo_name": "KDr2/agda", "max_forks_repo_path": "test/Common/IO.agda", "max_issues_count": 6, "max_issues_repo_head_hexsha": "98c9382a59f707c2c97d75919e389fc2a783ac75", "max_issues_repo_issues_event_max_datetime": "2021-11-24T08:31:10.000Z", "max_issues_repo_issues_event_min_datetime": "2021-10-18T08:12:24.000Z", "max_issues_repo_licenses": [ "BSD-2-Clause" ], "max_issues_repo_name": "KDr2/agda", "max_issues_repo_path": "test/Common/IO.agda", "max_line_length": 105, "max_stars_count": null, "max_stars_repo_head_hexsha": "98c9382a59f707c2c97d75919e389fc2a783ac75", "max_stars_repo_licenses": [ "BSD-2-Clause" ], "max_stars_repo_name": "KDr2/agda", "max_stars_repo_path": "test/Common/IO.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 677, "size": 2040 }
module OpenModuleShortHand where data Nat : Set where zero : Nat suc : Nat -> Nat module List (Elem : Set) where data List : Set where [] : List _::_ : Elem -> List -> List open List Nat {- This means open module _ = List Nat -} xs : List xs = zero :: (suc zero :: [])
{ "alphanum_fraction": 0.5938566553, "avg_line_length": 13.3181818182, "ext": "agda", "hexsha": "ac4362424728a28a7aaddefe2134e91d86a5c4db", "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/OpenModuleShortHand.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/OpenModuleShortHand.agda", "max_line_length": 32, "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/OpenModuleShortHand.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": 90, "size": 293 }
module classify-tests where open import lib open import classify open import syntax-util test = check-beta-inequiv (mlam "a" (mlam "b" (mvar "a"))) (mlam "a" (mlam "b" (mvar "b")))
{ "alphanum_fraction": 0.6830601093, "avg_line_length": 22.875, "ext": "agda", "hexsha": "2db0989fec7f2fa632a8d62ad80b00dc19f90ae7", "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": "acf691e37210607d028f4b19f98ec26c4353bfb5", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "xoltar/cedille", "max_forks_repo_path": "src/classify-tests.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "acf691e37210607d028f4b19f98ec26c4353bfb5", "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": "xoltar/cedille", "max_issues_repo_path": "src/classify-tests.agda", "max_line_length": 91, "max_stars_count": null, "max_stars_repo_head_hexsha": "acf691e37210607d028f4b19f98ec26c4353bfb5", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "xoltar/cedille", "max_stars_repo_path": "src/classify-tests.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 61, "size": 183 }
{-# OPTIONS --without-K --safe #-} module Cats.Displayed where open import Data.Product using (Σ ; Σ-syntax ; _,_) open import Level using (_⊔_ ; suc) open import Relation.Binary using (Setoid ; IsEquivalence ; Rel ; REL ; _Preserves₂_⟶_⟶_) open import Cats.Category record DisplayedCategory {lo la l≈} (C : Category lo la l≈) lo′ la′ l≈′ : Set (lo ⊔ la ⊔ l≈ ⊔ suc (lo′ ⊔ la′ ⊔ l≈′)) where infixr 9 _∘_ infix 4 _≈[_]_ infixr -1 _⇒[_]_ Base = C module Base = Category Base private module C = Category C field Obj : (c : C.Obj) → Set lo′ _⇒[_]_ : ∀ {a b} (a⁺ : Obj a) (f : a C.⇒ b) (b⁺ : Obj b) → Set la′ _≈[_]_ : ∀ {a b} {f g : a C.⇒ b} {a⁺ : Obj a} {b⁺ : Obj b} → a⁺ ⇒[ f ] b⁺ → f C.≈ g → a⁺ ⇒[ g ] b⁺ → Set l≈′ id : ∀ {a} {a⁺ : Obj a} → a⁺ ⇒[ C.id ] a⁺ _∘_ : ∀ {a b c} {a⁺ : Obj a} {b⁺ : Obj b} {c⁺ : Obj c} → {f : b C.⇒ c} {g : a C.⇒ b} → (f⁺ : b⁺ ⇒[ f ] c⁺) (g⁺ : a⁺ ⇒[ g ] b⁺) → a⁺ ⇒[ f C.∘ g ] c⁺ ≈-refl : ∀ {a b} {f : a C.⇒ b} {a⁺ : Obj a} {b⁺ : Obj b} {f⁺ : a⁺ ⇒[ f ] b⁺} → f⁺ ≈[ C.≈.refl ] f⁺ ≈-sym : ∀ {a b} {f g : a C.⇒ b} {f≈g : f C.≈ g} {a⁺ : Obj a} {b⁺ : Obj b} → {f⁺ : a⁺ ⇒[ f ] b⁺} {g⁺ : a⁺ ⇒[ g ] b⁺} → f⁺ ≈[ f≈g ] g⁺ → g⁺ ≈[ C.≈.sym f≈g ] f⁺ ≈-trans : ∀ {a b} → {f g h : a C.⇒ b} {f≈g : f C.≈ g} {g≈h : g C.≈ h} → {a⁺ : Obj a} {b⁺ : Obj b} → {f⁺ : a⁺ ⇒[ f ] b⁺} {g⁺ : a⁺ ⇒[ g ] b⁺} {h⁺ : a⁺ ⇒[ h ] b⁺} → f⁺ ≈[ f≈g ] g⁺ → g⁺ ≈[ g≈h ] h⁺ → f⁺ ≈[ C.≈.trans f≈g g≈h ] h⁺ ∘-resp : ∀ {a b c} {f g : b C.⇒ c} {h i : a C.⇒ b} → {f≈g : f C.≈ g} {h≈i : h C.≈ i} → {a⁺ : Obj a} {b⁺ : Obj b} {c⁺ : Obj c} → {f⁺ : b⁺ ⇒[ f ] c⁺} {g⁺ : b⁺ ⇒[ g ] c⁺} → {h⁺ : a⁺ ⇒[ h ] b⁺} {i⁺ : a⁺ ⇒[ i ] b⁺} → f⁺ ≈[ f≈g ] g⁺ → h⁺ ≈[ h≈i ] i⁺ → f⁺ ∘ h⁺ ≈[ C.∘-resp f≈g h≈i ] g⁺ ∘ i⁺ id-r : ∀ {a b} {f : a C.⇒ b} {a⁺ : Obj a} {b⁺ : Obj b} {f⁺ : a⁺ ⇒[ f ] b⁺} → f⁺ ∘ id ≈[ C.id-r ] f⁺ id-l : ∀ {a b} {f : a C.⇒ b} {a⁺ : Obj a} {b⁺ : Obj b} {f⁺ : a⁺ ⇒[ f ] b⁺} → id ∘ f⁺ ≈[ C.id-l ] f⁺ assoc : ∀ {a b c d} {f : c C.⇒ d} {g : b C.⇒ c} {h : a C.⇒ b} → {a⁺ : Obj a} {b⁺ : Obj b} {c⁺ : Obj c} {d⁺ : Obj d} → {f⁺ : c⁺ ⇒[ f ] d⁺} {g⁺ : b⁺ ⇒[ g ] c⁺} {h⁺ : a⁺ ⇒[ h ] b⁺} → (f⁺ ∘ g⁺) ∘ h⁺ ≈[ C.assoc ] f⁺ ∘ (g⁺ ∘ h⁺) module BuildTotal {lo la l≈} {C : Category lo la l≈} {lo′ la′ l≈′} (D : DisplayedCategory C lo′ la′ l≈′) where infixr 9 _∘_ infix 4 _≈_ infixr -1 _⇒_ private module C = Category C module D = DisplayedCategory D Obj : Set (lo ⊔ lo′) Obj = Σ[ c ∈ C.Obj ] D.Obj c _⇒_ : (a b : Obj) → Set (la ⊔ la′) (a , a⁺) ⇒ (b , b⁺) = Σ[ f ∈ a C.⇒ b ] (a⁺ D.⇒[ f ] b⁺) _≈_ : ∀ {a b} → Rel (a ⇒ b) (l≈ ⊔ l≈′) (f , f⁺) ≈ (g , g⁺) = Σ[ f≈g ∈ f C.≈ g ] f⁺ D.≈[ f≈g ] g⁺ id : ∀ {a} → a ⇒ a id = C.id , D.id _∘_ : ∀ {a b c} → b ⇒ c → a ⇒ b → a ⇒ c (f , f⁺) ∘ (g , g⁺) = (f C.∘ g) , (f⁺ D.∘ g⁺) equiv : ∀ {a b} → IsEquivalence (_≈_ {a} {b}) equiv = record { refl = C.≈.refl , D.≈-refl ; sym = λ where (f≈g , f⁺≈g⁺) → C.≈.sym f≈g , D.≈-sym f⁺≈g⁺ ; trans = λ where (f≈g , f⁺≈g⁺) (g≈h , g⁺≈h⁺) → C.≈.trans f≈g g≈h , D.≈-trans f⁺≈g⁺ g⁺≈h⁺ } ∘-resp : ∀ {a b c} → (_∘_ {a} {b} {c} Preserves₂ _≈_ ⟶ _≈_ ⟶ _≈_) ∘-resp (f≈g , f⁺≈g⁺) (h≈i , h⁺≈i⁺) = C.∘-resp f≈g h≈i , D.∘-resp f⁺≈g⁺ h⁺≈i⁺ id-r : ∀ {a b} {f : a ⇒ b} → f ∘ id ≈ f id-r = C.id-r , D.id-r id-l : ∀ {a b} {f : a ⇒ b} → id ∘ f ≈ f id-l = C.id-l , D.id-l assoc : ∀ {a b c d} {f : c ⇒ d} {g : b ⇒ c} {h : a ⇒ b} → (f ∘ g) ∘ h ≈ f ∘ (g ∘ h) assoc = C.assoc , D.assoc Total : Category (lo ⊔ lo′) (la ⊔ la′) (l≈ ⊔ l≈′) Total = record { Obj = Obj ; _⇒_ = _⇒_ ; _≈_ = _≈_ ; id = id ; _∘_ = _∘_ ; equiv = equiv ; ∘-resp = ∘-resp ; id-r = id-r ; id-l = id-l ; assoc = assoc } open BuildTotal public using (Total)
{ "alphanum_fraction": 0.3679149798, "avg_line_length": 27.8309859155, "ext": "agda", "hexsha": "378755eabb8bbadc32759a71b4edb23d46cdece2", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2019-03-18T15:35:07.000Z", "max_forks_repo_forks_event_min_datetime": "2019-03-18T15:35:07.000Z", "max_forks_repo_head_hexsha": "1ad7b243acb622d46731e9ae7029408db6e561f1", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "JLimperg/cats", "max_forks_repo_path": "Cats/Displayed.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "1ad7b243acb622d46731e9ae7029408db6e561f1", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "JLimperg/cats", "max_issues_repo_path": "Cats/Displayed.agda", "max_line_length": 80, "max_stars_count": 24, "max_stars_repo_head_hexsha": "1ad7b243acb622d46731e9ae7029408db6e561f1", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "JLimperg/cats", "max_stars_repo_path": "Cats/Displayed.agda", "max_stars_repo_stars_event_max_datetime": "2021-08-06T05:00:46.000Z", "max_stars_repo_stars_event_min_datetime": "2017-11-03T15:18:57.000Z", "num_tokens": 2326, "size": 3952 }
module EqTest where import Common.Level data _≡_ {a : Set} (x : a) : a -> Set where refl : x ≡ x data Maybe (a : Set) : Set where just : a -> Maybe a nothing : Maybe a data ℕ : Set where zero : ℕ suc : ℕ -> ℕ _≟_ : (x y : ℕ) -> Maybe (x ≡ y) suc m ≟ suc n with m ≟ n suc .n ≟ suc n | just refl = just refl suc m ≟ suc n | nothing = nothing zero ≟ suc _ = nothing suc m ≟ zero = nothing zero ≟ zero = just refl
{ "alphanum_fraction": 0.5538116592, "avg_line_length": 19.3913043478, "ext": "agda", "hexsha": "e22fe438ed9c66f9a8e98ca4fe14a2b19a8109f1", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_forks_event_min_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "masondesu/agda", "max_forks_repo_path": "test/succeed/EqTest.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/EqTest.agda", "max_line_length": 43, "max_stars_count": 1, "max_stars_repo_head_hexsha": "477c8c37f948e6038b773409358fd8f38395f827", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "larrytheliquid/agda", "max_stars_repo_path": "test/succeed/EqTest.agda", "max_stars_repo_stars_event_max_datetime": "2018-10-10T17:08:44.000Z", "max_stars_repo_stars_event_min_datetime": "2018-10-10T17:08:44.000Z", "num_tokens": 177, "size": 446 }
module Issue477b where record D where field A : Set
{ "alphanum_fraction": 0.7321428571, "avg_line_length": 9.3333333333, "ext": "agda", "hexsha": "c93a111ef18fd1b9115105851232092c99a59bca", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_path": "test/Fail/Issue477b.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/Issue477b.agda", "max_line_length": 22, "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/Issue477b.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": 17, "size": 56 }
{-# OPTIONS --without-K --safe #-} open import Categories.Category -- BinaryCoproducts -- a category with all binary coproducts -- Cocartesian -- a category with all coproducts -- since most of the work is dual to Categories.Category.Cartesian, so the idea -- in this module is to make use of duality module Categories.Category.Cocartesian {o ℓ e} (𝒞 : Category o ℓ e) where open import Level private module 𝒞 = Category 𝒞 open Category 𝒞 open HomReasoning variable A B C D : Obj f g h i : A ⇒ B open import Categories.Object.Initial 𝒞 open import Categories.Object.Coproduct 𝒞 open import Categories.Object.Duality 𝒞 open import Categories.Category.Monoidal open import Categories.Category.Monoidal.Symmetric open import Categories.Category.Cartesian 𝒞.op open import Categories.Morphism 𝒞 open import Categories.Morphism.Properties 𝒞 open import Categories.Morphism.Duality 𝒞 open import Categories.Morphism.Reasoning 𝒞 open import Categories.Functor renaming (id to idF) open import Categories.Functor.Properties open import Categories.Functor.Bifunctor record BinaryCoproducts : Set (levelOfTerm 𝒞) where infixr 6 _+_ infixr 7 _+₁_ field coproduct : ∀ {A B} → Coproduct A B module coproduct {A} {B} = Coproduct (coproduct {A} {B}) _+_ : Obj → Obj → Obj A + B = coproduct.A+B {A} {B} open coproduct using (i₁; i₂; [_,_]; inject₁; inject₂; []-cong₂) renaming (unique to +-unique; η to +-η; g-η to +-g-η) public module Dual where op-binaryProducts : BinaryProducts op-binaryProducts = record { product = coproduct→product coproduct } module op-binaryProducts = BinaryProducts op-binaryProducts open Dual +-comm : A + B ≅ B + A +-comm = op-≅⇒≅ (op-binaryProducts.×-comm) +-assoc : A + B + C ≅ (A + B) + C +-assoc = op-≅⇒≅ (op-binaryProducts.×-assoc) _+₁_ : A ⇒ B → C ⇒ D → A + C ⇒ B + D _+₁_ = op-binaryProducts._⁂_ open op-binaryProducts using () renaming ( ⟨⟩-congʳ to []-congʳ ; ⟨⟩-congˡ to []-congˡ ; assocˡ to +-assocʳ ; assocʳ to +-assocˡ ; swap to +-swap ; first to +-first ; second to +-second ; π₁∘⁂ to +₁∘i₁ ; π₂∘⁂ to +₁∘i₂ ; ⁂-cong₂ to +₁-cong₂ ; ⁂∘⟨⟩ to []∘+₁ ; ⁂∘⁂ to +₁∘+₁ ; ⟨⟩∘ to ∘[] ; first↔second to +-second↔first ; swap∘⁂ to +₁∘+-swap ; swap∘swap to +-swap∘swap ) public -- since op-×- has type Bifunctor 𝒞.op 𝒞.op 𝒞.op, -- need to rewrap in order to type check -+- : Bifunctor 𝒞 𝒞 𝒞 -+- = record { F₀ = op-×-.F₀ ; F₁ = op-×-.F₁ ; identity = op-×-.identity ; homomorphism = op-×-.homomorphism ; F-resp-≈ = op-×-.F-resp-≈ } where op-×- = op-binaryProducts.-×- module op-×- = Functor op-×- -+_ : Obj → Functor 𝒞 𝒞 -+_ = appʳ -+- _+- : Obj → Functor 𝒞 𝒞 _+- = appˡ -+- record Cocartesian : Set (levelOfTerm 𝒞) where field initial : Initial coproducts : BinaryCoproducts module initial = Initial initial module coproducts = BinaryCoproducts coproducts open initial renaming (! to ¡; !-unique to ¡-unique; !-unique₂ to ¡-unique₂) public open coproducts hiding (module Dual) public module Dual where open coproducts.Dual public op-cartesian : Cartesian op-cartesian = record { terminal = ⊥⇒op⊤ initial ; products = op-binaryProducts } module op-cartesian = Cartesian op-cartesian open Dual ⊥+A≅A : ⊥ + A ≅ A ⊥+A≅A = op-≅⇒≅ (op-cartesian.⊤×A≅A) A+⊥≅A : A + ⊥ ≅ A A+⊥≅A = op-≅⇒≅ (op-cartesian.A×⊤≅A) open op-cartesian using () -- both are natural isomorphism renaming (⊤×--id to ⊥+--id; -×⊤-id to -+⊥-id) public +-monoidal : Monoidal 𝒞 +-monoidal = record { ⊗ = -+- ; unit = unit ; unitorˡ = ⊥+A≅A ; unitorʳ = A+⊥≅A ; associator = ≅.sym +-assoc ; unitorˡ-commute-from = ⟺ unitorˡ-commute-to ; unitorˡ-commute-to = ⟺ unitorˡ-commute-from ; unitorʳ-commute-from = ⟺ unitorʳ-commute-to ; unitorʳ-commute-to = ⟺ unitorʳ-commute-from ; assoc-commute-from = ⟺ assoc-commute-to ; assoc-commute-to = ⟺ assoc-commute-from -- the proof idea of triangle is that the opposite triangle is obtained for free, -- but notice that triangle and the opposite triangle form isomorphism. ; triangle = λ {X Y} → Iso-≈ triangle (Iso-∘ ([ X +- ]-resp-Iso (Iso-swap (iso ⊥+A≅A))) (iso +-assoc)) ([ -+ Y ]-resp-Iso (Iso-swap (iso A+⊥≅A))) ; pentagon = λ {X Y Z W} → Iso-≈ pentagon (Iso-∘ ([ X +- ]-resp-Iso (iso +-assoc)) (Iso-∘ (iso +-assoc) ([ -+ W ]-resp-Iso (iso +-assoc)))) (Iso-∘ (iso +-assoc) (iso +-assoc)) } where op-monoidal = op-cartesian.monoidal open Monoidal op-monoidal open _≅_ module +-monoidal = Monoidal +-monoidal +-symmetric : Symmetric +-monoidal +-symmetric = record { braided = record { braiding = record { F⇒G = record { η = λ _ → +-swap ; commute = λ _ → ⟺ +₁∘+-swap ; sym-commute = λ _ → +₁∘+-swap } ; F⇐G = record { η = λ _ → +-swap ; commute = λ _ → ⟺ +₁∘+-swap ; sym-commute = λ _ → +₁∘+-swap } ; iso = λ _ → iso +-comm } ; hexagon₁ = braided.hexagon₂ ; hexagon₂ = braided.hexagon₁ } ; commutative = commutative } where op-symmetric = op-cartesian.symmetric open Symmetric op-symmetric open _≅_ -- we don't open this module publicly in order to prevent introducing conflicts -- with Cartesian category module +-symmetric = Symmetric +-symmetric
{ "alphanum_fraction": 0.5338286437, "avg_line_length": 29.8396226415, "ext": "agda", "hexsha": "feee2f2e4a1099127a9a115fc197c910058c1c7f", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "58e5ec015781be5413bdf968f7ec4fdae0ab4b21", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "MirceaS/agda-categories", "max_forks_repo_path": "src/Categories/Category/Cocartesian.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "58e5ec015781be5413bdf968f7ec4fdae0ab4b21", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "MirceaS/agda-categories", "max_issues_repo_path": "src/Categories/Category/Cocartesian.agda", "max_line_length": 86, "max_stars_count": null, "max_stars_repo_head_hexsha": "58e5ec015781be5413bdf968f7ec4fdae0ab4b21", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "MirceaS/agda-categories", "max_stars_repo_path": "src/Categories/Category/Cocartesian.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 2060, "size": 6326 }
{-# OPTIONS --without-K #-} data D : Set where @0 c : D data P (x : D) : Set where record R : Set where field f : P c
{ "alphanum_fraction": 0.5348837209, "avg_line_length": 11.7272727273, "ext": "agda", "hexsha": "4c3c1aa24f17e34ae7994bc5979f21508cebf199", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "98c9382a59f707c2c97d75919e389fc2a783ac75", "max_forks_repo_licenses": [ "BSD-2-Clause" ], "max_forks_repo_name": "KDr2/agda", "max_forks_repo_path": "test/Fail/Issue5920a.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "98c9382a59f707c2c97d75919e389fc2a783ac75", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "BSD-2-Clause" ], "max_issues_repo_name": "KDr2/agda", "max_issues_repo_path": "test/Fail/Issue5920a.agda", "max_line_length": 27, "max_stars_count": null, "max_stars_repo_head_hexsha": "98c9382a59f707c2c97d75919e389fc2a783ac75", "max_stars_repo_licenses": [ "BSD-2-Clause" ], "max_stars_repo_name": "KDr2/agda", "max_stars_repo_path": "test/Fail/Issue5920a.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 45, "size": 129 }
{-# OPTIONS --without-K --safe #-} open import Level using (Level) open import Data.List using (List; sum) renaming ([] to []ᴸ; _∷_ to _∷ᴸ_) open import Data.Nat using (ℕ; _+_; zero; suc) open import Data.Vec using (Vec; _++_; take; drop) renaming ([] to []ⱽ; _∷_ to _∷ⱽ_) open import Data.Product as Prod using (∃; ∃₂; _×_; _,_) module FLA.Data.VectorList where -- At the moment, `VectorList` is named `RList` in the Haskell code. data VectorList (A : Set) : List ℕ → Set where []ⱽᴸ : VectorList A []ᴸ _∷ⱽᴸ_ : {n : ℕ} {ns : List ℕ} → Vec A n → VectorList A ns → VectorList A (n ∷ᴸ ns) infixr 5 _∷ⱽᴸ_ concat : {A : Set} {ns : List ℕ} → VectorList A ns → Vec A (sum ns) concat []ⱽᴸ = []ⱽ concat (v ∷ⱽᴸ vs) = v ++ concat vs -- We will want to use split to split a VectorList split : {ℓ : Level} {A : Set ℓ} → {m n : ℕ} → Vec A (m + n) → Vec A m × Vec A n split {ℓ} {A} {zero} {n} v = []ⱽ , v split {ℓ} {A} {suc m} {n} (v ∷ⱽ vs) = let v₁ , v₂ = split vs in v ∷ⱽ v₁ , v₂ -- split' : {ℓ : Level} {A : Set ℓ} → {m n : ℕ} → Vec A (m + n) → Vec A m × Vec A n -- split' {ℓ} {A} {m} {n} v = (take v , drop v) -- Hmm, this will be hard to translate to Haskell, since we match on ns splitToVectorList : {A : Set} → (ns : List ℕ) → Vec A (sum ns) → VectorList A ns splitToVectorList []ᴸ v = []ⱽᴸ splitToVectorList (_ ∷ᴸ ns) v = let v₁ , v₂ = split v in v₁ ∷ⱽᴸ (splitToVectorList ns v₂)
{ "alphanum_fraction": 0.5706409373, "avg_line_length": 39.2162162162, "ext": "agda", "hexsha": "7478834529dc4af2f91b481bf0fcb737c04f045f", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2021-09-07T19:55:59.000Z", "max_forks_repo_forks_event_min_datetime": "2021-04-12T20:34:17.000Z", "max_forks_repo_head_hexsha": "375475a2daa57b5995ceb78b4bffcbfcbb5d8898", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "turion/functional-linear-algebra", "max_forks_repo_path": "src/FLA/Data/VectorList.agda", "max_issues_count": 6, "max_issues_repo_head_hexsha": "375475a2daa57b5995ceb78b4bffcbfcbb5d8898", "max_issues_repo_issues_event_max_datetime": "2022-01-07T05:27:53.000Z", "max_issues_repo_issues_event_min_datetime": "2020-09-01T01:42:12.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "turion/functional-linear-algebra", "max_issues_repo_path": "src/FLA/Data/VectorList.agda", "max_line_length": 84, "max_stars_count": 21, "max_stars_repo_head_hexsha": "375475a2daa57b5995ceb78b4bffcbfcbb5d8898", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "turion/functional-linear-algebra", "max_stars_repo_path": "src/FLA/Data/VectorList.agda", "max_stars_repo_stars_event_max_datetime": "2022-01-07T05:28:00.000Z", "max_stars_repo_stars_event_min_datetime": "2020-09-22T20:49:34.000Z", "num_tokens": 599, "size": 1451 }
module Issue477 where data D where c : D
{ "alphanum_fraction": 0.7045454545, "avg_line_length": 8.8, "ext": "agda", "hexsha": "f464b2df8eacb77ecf428956bb572dfc837f7745", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "masondesu/agda", "max_forks_repo_path": "test/fail/Issue477.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "masondesu/agda", "max_issues_repo_path": "test/fail/Issue477.agda", "max_line_length": 21, "max_stars_count": 1, "max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/agda-kanso", "max_stars_repo_path": "test/fail/Issue477.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": 14, "size": 44 }
{-# OPTIONS --safe #-} -- --without-K #-} import Data.String.Base as String {-# BUILTIN FROMSTRING String.toList #-} open import Data.Nat using (ℕ; zero; suc) open import Data.Bool using (Bool; true; false) open import Data.Unit using (⊤; tt) open import Data.Fin using (Fin; zero; suc) renaming (#_ to #'_) open import Data.Product using (_,_) open import Data.Vec using (Vec; []; _∷_) open import Data.Vec.Relation.Unary.All using (All; []; _∷_) open import Data.String open import Relation.Binary.PropositionalEquality using (_≡_; refl) import Level as L open import PiCalculus.Syntax open Scoped open import PiCalculus.Semantics open import PiCalculus.LinearTypeSystem.Algebras open import PiCalculus.LinearTypeSystem.Algebras.Linear using (Linear) open import PiCalculus.LinearTypeSystem.Algebras.Shared using (Shared) open import PiCalculus.LinearTypeSystem.Algebras.Graded using (Graded) module PiCalculus.Examples where open Raw variable n : ℕ raw : Raw raw = ⦅ν "x"⦆ (("x" ⦅ "y" ⦆ 𝟘) ∥ ("x" ⟨ "a" ⟩ 𝟘)) scoped : Scoped 1 scoped = ν (((#' 0) ⦅⦆ 𝟘) ⦃ "y" ⦄ ∥ ((#' 0) ⟨ #' 1 ⟩ 𝟘)) ⦃ "x" ⦄ _ : Conversion.fromRaw ("a" ∷ []) raw ≡ scoped _ = refl channel-over-channel₀ : Raw channel-over-channel₀ = ⦅ν "x"⦆ ( ("x" ⦅ "r" ⦆ "r" ⦅ "p" ⦆ 𝟘) ∥ (⦅ν "z"⦆ ("x" ⟨ "z" ⟩ "z" ⟨ "y" ⟩ 𝟘))) channel-over-channel₁ : Raw channel-over-channel₁ = ⦅ν "x"⦆ ⦅ν "z"⦆ ( ("x" ⦅ "r" ⦆ "r" ⦅ "p" ⦆ 𝟘) ∥ ("x" ⟨ "z" ⟩ "z" ⟨ "y" ⟩ 𝟘)) channel-over-channel₂ : Raw channel-over-channel₂ = ⦅ν "z"⦆ ⦅ν "x"⦆ ( ("x" ⦅ "r" ⦆ "r" ⦅ "p" ⦆ 𝟘) ∥ ("x" ⟨ "z" ⟩ "z" ⟨ "y" ⟩ 𝟘)) channel-over-channel₃ : Raw channel-over-channel₃ = ⦅ν "z"⦆ ⦅ν "x"⦆ ( ("z" ⦅ "p" ⦆ 𝟘) ∥ ("z" ⟨ "y" ⟩ 𝟘)) channel-over-channel₄ : Raw channel-over-channel₄ = ⦅ν "z"⦆ ⦅ν "x"⦆ (𝟘 ∥ 𝟘) channel-over-channel₅ : Raw channel-over-channel₅ = ⦅ν "z"⦆ ⦅ν "x"⦆ 𝟘 channel-over-channel₆ : Raw channel-over-channel₆ = ⦅ν "z"⦆ 𝟘 channel-over-channel₇ : Raw channel-over-channel₇ = 𝟘 _!_≅_ : ∀ {n} → Vec Name n → Raw → Raw → Set _!_≅_ = Conversion.map₂ _≅_ _!_⇒_ : ∀ {n} → Vec Name n → Raw → Raw → Set _!_⇒_ = Conversion.map₂ _⇒_ _ : ("y" ∷ []) ! channel-over-channel₀ ≅ channel-over-channel₁ _ = _ , ν-cong cong-symm stop scope-ext ((λ ()) , (λ ()) , tt) _ : ("y" ∷ []) ! channel-over-channel₁ ≅ channel-over-channel₂ _ = _ , stop scope-scope-comm _ : ("y" ∷ []) ! channel-over-channel₂ ⇒ channel-over-channel₃ _ = _ , res res comm _ : ("y" ∷ []) ! channel-over-channel₃ ⇒ channel-over-channel₄ _ = _ , res res comm _ : ("y" ∷ []) ! channel-over-channel₄ ≅ channel-over-channel₅ _ = _ , ν-cong ν-cong stop comp-end _ : ("y" ∷ []) ! channel-over-channel₅ ≅ channel-over-channel₆ _ = _ , ν-cong stop scope-end _ : ("y" ∷ []) ! channel-over-channel₆ ≅ channel-over-channel₇ _ = _ , stop scope-end module Shared-Graded-Linear where data Grading : Set where sha gra lin : Grading pattern 0∙ = false pattern 1∙ = true QUANTIFIERS : Algebras Algebras.Idx QUANTIFIERS = Grading Algebras.∃Idx QUANTIFIERS = sha Algebras.Usage QUANTIFIERS sha = ⊤ Algebras.Usage QUANTIFIERS gra = ℕ Algebras.Usage QUANTIFIERS lin = Bool Algebras.UsageAlgebra QUANTIFIERS sha = Shared Algebras.UsageAlgebra QUANTIFIERS gra = Graded Algebras.UsageAlgebra QUANTIFIERS lin = Linear open Algebras QUANTIFIERS hiding (ℓᵢ;ℓₒ;ℓ∅;ℓ#;0∙;1∙) open import PiCalculus.LinearTypeSystem QUANTIFIERS open import PiCalculus.LinearTypeSystem.ContextLemmas QUANTIFIERS _!_;[_]_⊢_▹_ : Vec Name n → PreCtx n → (idxs : Idxs n) → Ctx idxs → Raw → Ctx idxs → Set ctx ! γ ;[ idxs ] Γ ⊢ P ▹ Δ = Conversion.map (λ P' → γ ;[ idxs ] Γ ⊢ P' ▹ Δ) ctx P ω∙ : ⊤ ² ω∙ = tt , tt ℓ# : Bool ² ℓ# = true , true ℓᵢ : Bool ² ℓᵢ = true , false ℓₒ : Bool ² ℓₒ = false , true ℓ∅ : Bool ² ℓ∅ = false , false instance name : Name name = "" _ : ([] -, "y") ! [] -, 𝟙 ;[ [] -, sha ] [] -, ω∙ ⊢ channel-over-channel₀ ▹ ε _ = ν C[ 𝟙 ; ω∙ ] ℓᵢ {lin} 1∙ (((here ) ⦅⦆ (here ⦅⦆ 𝟘)) ∥ (ν 𝟙 ω∙ {lin} 1∙ ((there here) ⟨ here ⟩ (here ⟨ there there here ⟩ 𝟘)))) _ : [] -, 𝟙 ;[ [] -, sha ] [] -, ω∙ ⊢ ν (((#' 0) ⟨ #' 1 ⟩ 𝟘) ∥ ((#' 0) ⦅⦆ 𝟘)) ▹ ε _ = ν 𝟙 ω∙ {lin} 1∙ ((# 0 ⟨ # 1 ⟩ 𝟘) ∥ (# 0 ⦅⦆ 𝟘)) p : Scoped 1 p = ν (((#' 0) ⦅⦆ ((#' 0) ⦅⦆ 𝟘)) ∥ (ν ((#' 1) ⟨ #' 0 ⟩ (#' 0) ⟨ #' 2 ⟩ 𝟘))) _ : [] -, 𝟙 ;[ [] -, sha ] [] -, ω∙ ⊢ p ▹ ε _ = ν C[ 𝟙 ; ω∙ ] {lin} ℓᵢ {lin} 1∙ ( (here ⦅⦆ (here ⦅⦆ 𝟘)) ∥ (ν 𝟙 ω∙ 1∙ (there here ⟨ here ⟩ (here ⟨ there there here ⟩ 𝟘)))) P : Scoped 2 P = (ν (suc zero ⟨ zero ⟩ zero ⟨ suc (suc zero) ⟩ 𝟘)) ∥ (zero ⦅⦆ zero ⦅⦆ 𝟘) ⊢P : ∀ {n} → [] -, 𝟙 -, C[ C[ 𝟙 ; ω∙ ] ; ℓᵢ ] ;[ [] -, sha -, gra ] [] -, ω∙ -, (suc n , suc n) ⊢ P ▹ [] -, ω∙ -, (n , n) ⊢P = ν 𝟙 ω∙ {lin} 1∙ ((there here) ⟨ here ⟩ (here ⟨ there there here ⟩ 𝟘)) ∥ (here ⦅⦆ (here ⦅⦆ 𝟘)) ⊢P∥P : [] -, 𝟙 ;[ [] -, sha ] [] -, ω∙ ⊢ ν (P ∥ P) ▹ ε ⊢P∥P = ν C[ 𝟙 ; ω∙ ] ℓᵢ 2 (⊢P ∥ ⊢P) sync : ∀ {n} → Fin n → Fin n → Fin n → Scoped n sync i0 i1 o = i0 ⦅⦆ suc i1 ⦅⦆ suc (suc o) ⟨ suc zero ⟩ suc (suc o) ⟨ zero ⟩ 𝟘 send : ∀ {n} → Fin n → Scoped n send c = ν (suc c ⟨ zero ⟩ 𝟘) recv : ∀ {n} → Fin n → Scoped n recv c = c ⦅⦆ (suc c ⦅⦆ 𝟘) example : Scoped 0 example = ν ( (send zero) ∥ ν ( (send zero) ∥ ν ( recv zero ∥ sync (#' 2) (#' 1) (#' 0)))) ⊢-send : ∀ {n} {γ : PreCtx n} {idxs : Idxs n} {Γ : Ctx idxs} {k l} → γ -, C[_;_] {idx = lin} (C[_;_] {idx = sha} 𝟙 ω∙) ℓ∅ ;[ idxs -, gra ] Γ -, (k , suc l) ⊢ send zero ▹ Γ -, (k , l) ⊢-send = ν _ _ 0∙ (there here ⟨ here ⟩ 𝟘) ⊢-recv : ∀ {n} {γ : PreCtx n} {idxs : Idxs n} {Γ : Ctx idxs} {t : Type} {k l} → γ -, (C[_;_] {idx = lin} t ℓ∅) ;[ idxs -, gra ] Γ -, (suc (suc l) , k) ⊢ recv zero ▹ Γ -, (l , k) ⊢-recv = here ⦅⦆ (there here ⦅⦆ 𝟘) ⊢-sync : ∀ {n} {γ : PreCtx n} {idxs : Idxs n} {Γ : Ctx idxs} {t : Type} {lx rx ly ry lz rz} → γ -, C[_;_] {idx = lin} t ℓ∅ -, C[ t ; ℓ∅ ] -, C[ t ; ℓ∅ ] ;[ idxs -, gra -, gra -, gra ] Γ -, (suc lx , rx) -, (suc ly , ry) -, (lz , suc (suc rz)) ⊢ sync (#' 2) (#' 1) (#' 0) ▹ Γ -, (lx , rx) -, (ly , ry) -, (lz , rz) ⊢-sync = (there (there here)) ⦅⦆ (there (there here)) ⦅⦆ (there (there here)) ⟨ there here ⟩ (there (there here)) ⟨ here ⟩ 𝟘 _ : [] ; [] ⊢ example ▹ [] _ = ν _ _ _ ( ⊢-send ∥ ν _ _ _ ( ⊢-send ∥ ν _ _ _ ( ⊢-recv ∥ ⊢-sync ))) module Linear where QUANTIFIERS : Algebras Algebras.Idx QUANTIFIERS = ⊤ Algebras.∃Idx QUANTIFIERS = tt Algebras.Usage QUANTIFIERS _ = Bool Algebras.UsageAlgebra QUANTIFIERS _ = Linear open Algebras QUANTIFIERS open import PiCalculus.LinearTypeSystem QUANTIFIERS open import PiCalculus.LinearTypeSystem.ContextLemmas QUANTIFIERS _ : [] -, C[ 𝟙 ; ℓᵢ ] -, 𝟙 ; [] -, ℓ# -, ℓ# ∋[ #' 1 ] C[ 𝟙 ; ℓᵢ ] ; ℓᵢ ▹ [] -, ℓₒ -, ℓ# _ = there here
{ "alphanum_fraction": 0.5150959368, "avg_line_length": 31.5022222222, "ext": "agda", "hexsha": "7a742ced047a05e007ce79b4459bfc7d9d1de242", "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": "0fc3cf6bcc0cd07d4511dbe98149ac44e6a38b1a", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "guilhermehas/typing-linear-pi", "max_forks_repo_path": "src/PiCalculus/Examples.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "0fc3cf6bcc0cd07d4511dbe98149ac44e6a38b1a", "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": "guilhermehas/typing-linear-pi", "max_issues_repo_path": "src/PiCalculus/Examples.agda", "max_line_length": 138, "max_stars_count": null, "max_stars_repo_head_hexsha": "0fc3cf6bcc0cd07d4511dbe98149ac44e6a38b1a", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "guilhermehas/typing-linear-pi", "max_stars_repo_path": "src/PiCalculus/Examples.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 3262, "size": 7088 }
{-# OPTIONS --safe #-} open import Definition.Typed.EqualityRelation module Definition.LogicalRelation.Irrelevance {{eqrel : EqRelSet}} where open EqRelSet {{...}} open import Tools.Empty using (⊥; ⊥-elim) open import Definition.Untyped open import Definition.Typed open import Definition.Typed.Properties open import Definition.LogicalRelation open import Definition.LogicalRelation.ShapeView open import Tools.Product import Tools.PropositionalEquality as PE import Data.Fin as Fin import Data.Nat as Nat -- Irrelevance for propositionally equal types irrelevance′ : ∀ {A A′ Γ r l} → A PE.≡ A′ → Γ ⊩⟨ l ⟩ A ^ r → Γ ⊩⟨ l ⟩ A′ ^ r irrelevance′ PE.refl [A] = [A] irrelevance′′ : ∀ {A A′ Γ r r' ll ll' l} → A PE.≡ A′ → r PE.≡ r' → ll PE.≡ ll' → Γ ⊩⟨ l ⟩ A ^ [ r , ll ] → Γ ⊩⟨ l ⟩ A′ ^ [ r' , ll' ] irrelevance′′ PE.refl PE.refl PE.refl [A] = [A] -- Irrelevance for propositionally equal types and contexts irrelevanceΓ′ : ∀ {l A A′ r Γ Γ′} → Γ PE.≡ Γ′ → A PE.≡ A′ → Γ ⊩⟨ l ⟩ A ^ r → Γ′ ⊩⟨ l ⟩ A′ ^ r irrelevanceΓ′ PE.refl PE.refl [A] = [A] -- helper function to deal with relevance reduction-irrelevant-Univ : ∀ {Γ A t l l' ll ll' l< l<' r r' el el' D D'} (e : r PE.≡ r') → Γ ⊩⟨ l ⟩ t ∷ A ^ [ ! , next ll ] / Uᵣ (Uᵣ r ll l< el D) → Γ ⊩⟨ l' ⟩ t ∷ A ^ [ ! , next ll ] / Uᵣ (Uᵣ r' ll' l<' el' D') reduction-irrelevant-Univ {Γ} {A} {t} {ι ¹} {ι ¹} {⁰} {⁰} PE.refl (Uₜ K d typeK K≡K [t]) = Uₜ K d typeK K≡K [t] reduction-irrelevant-Univ {Γ} {A} {t} {∞} {∞} {¹} {¹} PE.refl (Uₜ K d typeK K≡K [t]) = Uₜ K d typeK K≡K [t] reduction-irrelevant-Univ= : ∀ {Γ A t u l l' ll ll' l< l<' r r' el el' D D'} (e : r PE.≡ r') → Γ ⊩⟨ l ⟩ t ≡ u ∷ A ^ [ ! , next ll ] / Uᵣ (Uᵣ r ll l< el D) → Γ ⊩⟨ l' ⟩ t ≡ u ∷ A ^ [ ! , next ll ] / Uᵣ (Uᵣ r' ll' l<' el' D') reduction-irrelevant-Univ= {l = ι ¹} {ι ¹} {⁰} {⁰} PE.refl (Uₜ₌ [t] [u] A≡B [t≡u]) = Uₜ₌ (reduction-irrelevant-Univ PE.refl [t]) (reduction-irrelevant-Univ PE.refl [u]) A≡B [t≡u] reduction-irrelevant-Univ= {l = ∞} {∞} {¹} {¹} {l<} {l<'} PE.refl (Uₜ₌ [t] [u] A≡B [t≡u]) = Uₜ₌ (reduction-irrelevant-Univ PE.refl [t]) (reduction-irrelevant-Univ PE.refl [u]) A≡B [t≡u] -- NB: for Pi cases it seems like it would be cleaner to do -- irrelevanceFoo (Pi ...) rewrite whrDet* ... -- instead of messing with PE.subst and irrelevanceEq′ etc -- however for some reason the termination checker doesn't accept it mutual -- Irrelevance for type equality irrelevanceEq : ∀ {Γ A B r l l′} (p : Γ ⊩⟨ l ⟩ A ^ r) (q : Γ ⊩⟨ l′ ⟩ A ^ r) → Γ ⊩⟨ l ⟩ A ≡ B ^ r / p → Γ ⊩⟨ l′ ⟩ A ≡ B ^ r / q irrelevanceEq p q A≡B = irrelevanceEqT (goodCasesRefl p q) A≡B -- Irrelevance for type equality with propositionally equal first types irrelevanceEq′ : ∀ {Γ A A′ B r r' l l′ ll ll'} (eq : A PE.≡ A′) (eqr : r PE.≡ r') (eql : ll PE.≡ ll') (p : Γ ⊩⟨ l ⟩ A ^ [ r , ll ]) (q : Γ ⊩⟨ l′ ⟩ A′ ^ [ r' , ll' ]) → Γ ⊩⟨ l ⟩ A ≡ B ^ [ r , ll ] / p → Γ ⊩⟨ l′ ⟩ A′ ≡ B ^ [ r' , ll' ] / q irrelevanceEq′ PE.refl PE.refl PE.refl p q A≡B = irrelevanceEq p q A≡B -- Irrelevance for type equality with propositionally equal types irrelevanceEq″ : ∀ {Γ A A′ B B′ r r' ll ll' l l′} (eqA : A PE.≡ A′) (eqB : B PE.≡ B′) (eqr : r PE.≡ r') (eql : ll PE.≡ ll') (p : Γ ⊩⟨ l ⟩ A ^ [ r , ll ]) (q : Γ ⊩⟨ l′ ⟩ A′ ^ [ r' , ll' ]) → Γ ⊩⟨ l ⟩ A ≡ B ^ [ r , ll ] / p → Γ ⊩⟨ l′ ⟩ A′ ≡ B′ ^ [ r' , ll' ] / q irrelevanceEq″ PE.refl PE.refl PE.refl PE.refl p q A≡B = irrelevanceEq p q A≡B -- Irrelevance for type equality with propositionally equal second types irrelevanceEqR′ : ∀ {Γ A B B′ r l} (eqB : B PE.≡ B′) (p : Γ ⊩⟨ l ⟩ A ^ r) → Γ ⊩⟨ l ⟩ A ≡ B ^ r / p → Γ ⊩⟨ l ⟩ A ≡ B′ ^ r / p irrelevanceEqR′ PE.refl p A≡B = A≡B -- Irrelevance for type equality with propositionally equal types and -- a lifting of propositionally equal types irrelevanceEqLift″ : ∀ {Γ A A′ B B′ C C′ rC r l l′} (eqA : A PE.≡ A′) (eqB : B PE.≡ B′) (eqC : C PE.≡ C′) (p : Γ ∙ C ^ rC ⊩⟨ l ⟩ A ^ r) (q : Γ ∙ C′ ^ rC ⊩⟨ l′ ⟩ A′ ^ r) → Γ ∙ C ^ rC ⊩⟨ l ⟩ A ≡ B ^ r / p → Γ ∙ C′ ^ rC ⊩⟨ l′ ⟩ A′ ≡ B′ ^ r / q irrelevanceEqLift″ PE.refl PE.refl PE.refl p q A≡B = irrelevanceEq p q A≡B -- Helper for irrelevance of type equality using shape view irrelevanceEqT : ∀ {Γ A B r l l′} {p : Γ ⊩⟨ l ⟩ A ^ r} {q : Γ ⊩⟨ l′ ⟩ A ^ r} → ShapeView Γ l l′ A A r r p q → Γ ⊩⟨ l ⟩ A ≡ B ^ r / p → Γ ⊩⟨ l′ ⟩ A ≡ B ^ r / q irrelevanceEqT (ℕᵥ D D′) A≡B = A≡B irrelevanceEqT (Emptyᵥ D D′) A≡B = A≡B irrelevanceEqT (ne (ne K D neK _) (ne K₁ D₁ neK₁ K≡K₁)) (ne₌ M D′ neM K≡M) rewrite whrDet* (red D , ne neK) (red D₁ , ne neK₁) = ne₌ M D′ neM K≡M irrelevanceEqT {Γ} {r = r} (Πᵥ (Πᵣ 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′]) = let ΠFG≡ΠF₁G₁ = whrDet* (red D , Πₙ) (red D₁ , Πₙ) F≡F₁ , rF≡rF₁ , lF≡lF₁ , G≡G₁ , lG≡lG₁ , lΠ≡lΠ₁ = Π-PE-injectivity ΠFG≡ΠF₁G₁ in Π₌ F′ G′ (PE.subst₃ _ rF≡rF₁ lF≡lF₁ lG≡lG₁ D′) (PE.subst5 (λ x rx lx lx' lx'' → Γ ⊢ x ≅ Π F′ ^ rx ° lx ▹ G′ ° lx' ° lx'' ^ r) ΠFG≡ΠF₁G₁ rF≡rF₁ lF≡lF₁ lG≡lG₁ lΠ≡lΠ₁ A≡B) (λ {ρ} [ρ] ⊢Δ → irrelevanceEq′ (PE.cong (wk ρ) F≡F₁) rF≡rF₁ (PE.cong ι lF≡lF₁) ([F] [ρ] ⊢Δ) ([F]₁ [ρ] ⊢Δ) ([F≡F′] [ρ] ⊢Δ)) (λ {ρ} [ρ] ⊢Δ [a]₁ → let [a] = irrelevanceTerm′ (PE.cong (wk ρ) (PE.sym F≡F₁)) (PE.sym rF≡rF₁) (PE.cong ι (PE.sym lF≡lF₁)) ([F]₁ [ρ] ⊢Δ) ([F] [ρ] ⊢Δ) [a]₁ in irrelevanceEq′ (PE.cong (λ y → wk (lift ρ) y [ _ ]) G≡G₁) PE.refl (PE.cong ι lG≡lG₁) ([G] [ρ] ⊢Δ [a]) ([G]₁ [ρ] ⊢Δ [a]₁) ([G≡G′] [ρ] ⊢Δ [a])) irrelevanceEqT {Γ} {r = r} (∃ᵥ (∃ᵣ 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′]) = let ∃FG≡∃F₁G₁ = whrDet* (red D , ∃ₙ) (red D₁ , ∃ₙ) F≡F₁ , G≡G₁ = ∃-PE-injectivity ∃FG≡∃F₁G₁ in ∃₌ F′ G′ D′ (PE.subst (λ x → Γ ⊢ x ≅ ∃ F′ ▹ G′ ^ r) ∃FG≡∃F₁G₁ A≡B) (λ {ρ} [ρ] ⊢Δ → irrelevanceEq′ (PE.cong (wk ρ) F≡F₁) PE.refl PE.refl ([F] [ρ] ⊢Δ) ([F]₁ [ρ] ⊢Δ) ([F≡F′] [ρ] ⊢Δ)) (λ {ρ} [ρ] ⊢Δ [a]₁ → let [a] = irrelevanceTerm′ (PE.cong (wk ρ) (PE.sym F≡F₁)) (PE.refl) (PE.refl) ([F]₁ [ρ] ⊢Δ) ([F] [ρ] ⊢Δ) [a]₁ in irrelevanceEq′ (PE.cong (λ y → wk (lift ρ) y [ _ ]) G≡G₁) PE.refl PE.refl ([G] [ρ] ⊢Δ [a]) ([G]₁ [ρ] ⊢Δ [a]₁) ([G≡G′] [ρ] ⊢Δ [a])) irrelevanceEqT (Uᵥ (Uᵣ _ _ _ PE.refl D) (Uᵣ _ _ _ e D')) A≡B = let U≡U = whrDet* (red D , Uₙ) (red D' , Uₙ) in let r≡r , l≡l = Univ-PE-injectivity U≡U in PE.subst _ l≡l (PE.subst _ r≡r A≡B) irrelevanceEqT (emb⁰¹ x) A≡B = irrelevanceEqT x A≡B irrelevanceEqT (emb¹⁰ x) A≡B = irrelevanceEqT x A≡B irrelevanceEqT (emb¹∞ x) A≡B = irrelevanceEqT x A≡B irrelevanceEqT (emb∞¹ x) A≡B = irrelevanceEqT x A≡B irrelevance-level : ∀ {A Γ r l l'} → l <∞ l' → Γ ⊩⟨ l ⟩ A ^ r → Γ ⊩⟨ l' ⟩ A ^ r irrelevance-level l< (ℕᵣ x) = ℕᵣ x irrelevance-level l< (Emptyᵣ x) = Emptyᵣ x irrelevance-level l< (ne x) = ne x irrelevance-level l< (Πᵣ′ rF lF lG lF≤ lG≤ F G D ⊢F ⊢G A≡A [F] [G] G-ext) = Πᵣ′ rF lF lG lF≤ lG≤ F G D ⊢F ⊢G A≡A (λ x ⊢Δ → irrelevance-level l< ([F] x ⊢Δ )) (λ [ρ] ⊢Δ x → irrelevance-level l< ([G] [ρ] ⊢Δ (irrelevanceTerm (irrelevance-level l< ([F] [ρ] ⊢Δ)) ([F] [ρ] ⊢Δ) x))) λ [ρ] ⊢Δ [a] [b] x → irrelevanceEq ([G] [ρ] ⊢Δ (irrelevanceTerm (irrelevance-level l< ([F] [ρ] ⊢Δ)) ([F] [ρ] ⊢Δ) [a])) (irrelevance-level l< ([G] [ρ] ⊢Δ (irrelevanceTerm (irrelevance-level l< ([F] [ρ] ⊢Δ)) ([F] [ρ] ⊢Δ) [a]))) (G-ext [ρ] ⊢Δ (irrelevanceTerm (irrelevance-level l< ([F] [ρ] ⊢Δ)) ([F] [ρ] ⊢Δ) [a]) (irrelevanceTerm (irrelevance-level l< ([F] [ρ] ⊢Δ)) ([F] [ρ] ⊢Δ) [b]) (irrelevanceEqTerm (irrelevance-level l< ([F] [ρ] ⊢Δ )) ([F] [ρ] ⊢Δ) x)) irrelevance-level l< (∃ᵣ′ F G D ⊢F ⊢G A≡A [F] [G] G-ext) = ∃ᵣ′ F G D ⊢F ⊢G A≡A (λ x ⊢Δ → irrelevance-level l< ([F] x ⊢Δ )) (λ [ρ] ⊢Δ x → irrelevance-level l< ([G] [ρ] ⊢Δ (irrelevanceTerm (irrelevance-level l< ([F] [ρ] ⊢Δ)) ([F] [ρ] ⊢Δ) x))) λ [ρ] ⊢Δ [a] [b] x → irrelevanceEq ([G] [ρ] ⊢Δ (irrelevanceTerm (irrelevance-level l< ([F] [ρ] ⊢Δ)) ([F] [ρ] ⊢Δ) [a])) (irrelevance-level l< ([G] [ρ] ⊢Δ (irrelevanceTerm (irrelevance-level l< ([F] [ρ] ⊢Δ)) ([F] [ρ] ⊢Δ) [a]))) (G-ext [ρ] ⊢Δ (irrelevanceTerm (irrelevance-level l< ([F] [ρ] ⊢Δ)) ([F] [ρ] ⊢Δ) [a]) (irrelevanceTerm (irrelevance-level l< ([F] [ρ] ⊢Δ)) ([F] [ρ] ⊢Δ) [b]) (irrelevanceEqTerm (irrelevance-level l< ([F] [ρ] ⊢Δ )) ([F] [ρ] ⊢Δ) x)) irrelevance-level {r = [ .! , ll ]} ∞< (Uᵣ (Uᵣ r .⁰ emb< eq d)) = emb ∞< (Uᵣ (Uᵣ r _ emb< eq d)) irrelevance-level ∞< (emb emb< [A]) = emb ∞< (emb emb< [A]) -------------------------------------------------------------------------------- -- Irrelevance for terms irrelevanceTerm : ∀ {Γ A t r l l′} (p : Γ ⊩⟨ l ⟩ A ^ r) (q : Γ ⊩⟨ l′ ⟩ A ^ r) → Γ ⊩⟨ l ⟩ t ∷ A ^ r / p → Γ ⊩⟨ l′ ⟩ t ∷ A ^ r / q irrelevanceTerm p q t = irrelevanceTermT (goodCasesRefl p q) t -- Irrelevance for terms with propositionally equal types irrelevanceTerm′ : ∀ {Γ A A′ t r r' l l′ ll ll'} (eq : A PE.≡ A′) (req : r PE.≡ r') (leq : ll PE.≡ ll') (p : Γ ⊩⟨ l ⟩ A ^ [ r , ll ]) (q : Γ ⊩⟨ l′ ⟩ A′ ^ [ r' , ll' ]) → Γ ⊩⟨ l ⟩ t ∷ A ^ [ r , ll ] / p → Γ ⊩⟨ l′ ⟩ t ∷ A′ ^ [ r' , ll' ] / q irrelevanceTerm′ PE.refl PE.refl PE.refl p q t = irrelevanceTerm p q t -- Irrelevance for terms with propositionally equal types and terms irrelevanceTerm″ : ∀ {Γ A A′ t t′ r r' ll ll' l l′} (eqA : A PE.≡ A′) (req : r PE.≡ r') (leq : ll PE.≡ ll') (eqt : t PE.≡ t′) (p : Γ ⊩⟨ l ⟩ A ^ [ r , ll ]) (q : Γ ⊩⟨ l′ ⟩ A′ ^ [ r' , ll' ]) → Γ ⊩⟨ l ⟩ t ∷ A ^ [ r , ll ] / p → Γ ⊩⟨ l′ ⟩ t′ ∷ A′ ^ [ r' , ll' ] / q irrelevanceTerm″ PE.refl PE.refl PE.refl PE.refl p q t = irrelevanceTerm p q t -- Irrelevance for terms with propositionally equal types, terms and contexts irrelevanceTermΓ″ : ∀ {l l′ A A′ t t′ r Γ Γ′} → Γ PE.≡ Γ′ → A PE.≡ A′ → t PE.≡ t′ → ([A] : Γ ⊩⟨ l ⟩ A ^ r) ([A′] : Γ′ ⊩⟨ l′ ⟩ A′ ^ r) → Γ ⊩⟨ l ⟩ t ∷ A ^ r / [A] → Γ′ ⊩⟨ l′ ⟩ t′ ∷ A′ ^ r / [A′] irrelevanceTermΓ″ PE.refl PE.refl PE.refl [A] [A′] [t] = irrelevanceTerm [A] [A′] [t] -- Helper for irrelevance of terms using shape view irrelevanceTermT : ∀ {Γ A t r l l′} {p : Γ ⊩⟨ l ⟩ A ^ r} {q : Γ ⊩⟨ l′ ⟩ A ^ r} → ShapeView Γ l l′ A A r r p q → Γ ⊩⟨ l ⟩ t ∷ A ^ r / p → Γ ⊩⟨ l′ ⟩ t ∷ A ^ r / q irrelevanceTermT (ℕᵥ D D′) t = t irrelevanceTermT (Emptyᵥ D D′) t = t irrelevanceTermT { r = [ ! , ll ] } (ne (ne K D neK K≡K) (ne K₁ D₁ neK₁ K≡K₁)) (neₜ k d nf) with whrDet* (red D₁ , ne neK₁) (red D , ne neK) irrelevanceTermT {r = [ ! , ll ]} (ne (ne K D neK K≡K) (ne .K D₁ neK₁ K≡K₁)) (neₜ k d nf) | PE.refl = neₜ k d nf irrelevanceTermT { r = [ % , ll ] } (ne (ne K D neK K≡K) (ne K₁ D₁ neK₁ K≡K₁)) (neₜ d) with whrDet* (red D₁ , ne neK₁) (red D , ne neK) irrelevanceTermT {r = [ % , ll ]} (ne (ne K D neK K≡K) (ne .K D₁ neK₁ K≡K₁)) (neₜ d) | PE.refl = neₜ d irrelevanceTermT {Γ} {t = t} {r = [ ! , ll ]} (Πᵥ (Πᵣ 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 d funcF f≡f [f] [f]₁) = let ΠFG≡ΠF₁G₁ = whrDet* (red D , Πₙ) (red D₁ , Πₙ) F≡F₁ , rF≡rF₁ , lF≡lF₁ , G≡G₁ , lG≡lG₁ , lΠ≡lΠ₁ = Π-PE-injectivity ΠFG≡ΠF₁G₁ in Πₜ f (PE.subst (λ x → Γ ⊢ t :⇒*: f ∷ x ^ ll) ΠFG≡ΠF₁G₁ d) funcF (PE.subst (λ x → Γ ⊢ f ≅ f ∷ x ^ [ ! , ll ]) ΠFG≡ΠF₁G₁ f≡f) (λ {ρ} [ρ] ⊢Δ [a]₁ [b]₁ [a≡b]₁ → let [a] = irrelevanceTerm′ (PE.cong (wk ρ) (PE.sym F≡F₁)) (PE.sym rF≡rF₁) (PE.cong ι (PE.sym lF≡lF₁)) ([F]₁ [ρ] ⊢Δ) ([F] [ρ] ⊢Δ) [a]₁ [b] = irrelevanceTerm′ (PE.cong (wk ρ) (PE.sym F≡F₁)) (PE.sym rF≡rF₁) (PE.cong ι (PE.sym lF≡lF₁)) ([F]₁ [ρ] ⊢Δ) ([F] [ρ] ⊢Δ) [b]₁ [a≡b] = irrelevanceEqTerm′ (PE.cong (wk ρ) (PE.sym F≡F₁)) (PE.sym rF≡rF₁) (PE.cong ι (PE.sym lF≡lF₁)) ([F]₁ [ρ] ⊢Δ) ([F] [ρ] ⊢Δ) [a≡b]₁ in irrelevanceEqTerm′ (PE.cong (λ G → wk (lift ρ) G [ _ ]) G≡G₁) PE.refl (PE.cong ι lG≡lG₁) ([G] [ρ] ⊢Δ [a]) ([G]₁ [ρ] ⊢Δ [a]₁) ([f] [ρ] ⊢Δ [a] [b] [a≡b])) (λ {ρ} [ρ] ⊢Δ [a]₁ → let [a] = irrelevanceTerm′ (PE.cong (wk ρ) (PE.sym F≡F₁)) (PE.sym rF≡rF₁) (PE.cong ι (PE.sym lF≡lF₁)) ([F]₁ [ρ] ⊢Δ) ([F] [ρ] ⊢Δ) [a]₁ in irrelevanceTerm′ (PE.cong (λ G → wk (lift ρ) G [ _ ]) G≡G₁) PE.refl (PE.cong ι lG≡lG₁) ([G] [ρ] ⊢Δ [a]) ([G]₁ [ρ] ⊢Δ [a]₁) ([f]₁ [ρ] ⊢Δ [a])) irrelevanceTermT {Γ} {t = t} {r = [ % , ll ]} (Πᵥ (Πᵣ 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₁)) d = let ΠFG≡ΠF₁G₁ = whrDet* (red D , Πₙ) (red D₁ , Πₙ) in PE.subst (λ x → Γ ⊢ t ∷ x ^ [ % , ll ]) ΠFG≡ΠF₁G₁ d irrelevanceTermT {Γ} {t = t} {r = [ % , ll ]} (∃ᵥ (∃ᵣ F G D ⊢F ⊢G A≡A [F] [G] G-ext) (∃ᵣ F₁ G₁ D₁ ⊢F₁ ⊢G₁ A≡A₁ [F]₁ [G]₁ G-ext₁)) d = let ∃FG≡∃F₁G₁ = whrDet* (red D , ∃ₙ) (red D₁ , ∃ₙ) in PE.subst (λ x → Γ ⊢ t ∷ x ^ [ % , ll ]) ∃FG≡∃F₁G₁ d irrelevanceTermT (Uᵥ (Uᵣ r ll l< PE.refl D) (Uᵣ r' ll' l<' _ D')) t = let U≡U = whrDet* (red D , Uₙ) (red D' , Uₙ) r≡r , l≡l = Univ-PE-injectivity U≡U in reduction-irrelevant-Univ r≡r t irrelevanceTermT (emb⁰¹ x) t = irrelevanceTermT x t irrelevanceTermT (emb¹⁰ x) t = irrelevanceTermT x t irrelevanceTermT (emb¹∞ x) t = irrelevanceTermT x t irrelevanceTermT (emb∞¹ x) t = irrelevanceTermT x t -------------------------------------------------------------------------------- -- Irrelevance for term equality irrelevanceEqTerm : ∀ {Γ A t u r l l′} (p : Γ ⊩⟨ l ⟩ A ^ r) (q : Γ ⊩⟨ l′ ⟩ A ^ r) → Γ ⊩⟨ l ⟩ t ≡ u ∷ A ^ r / p → Γ ⊩⟨ l′ ⟩ t ≡ u ∷ A ^ r / q irrelevanceEqTerm p q t≡u = irrelevanceEqTermT (goodCasesRefl p q) t≡u -- Irrelevance for term equality with propositionally equal types irrelevanceEqTerm′ : ∀ {Γ A A′ t u r r' l l′ ll ll'} (eq : A PE.≡ A′) (req : r PE.≡ r') (leq : ll PE.≡ ll') (p : Γ ⊩⟨ l ⟩ A ^ [ r , ll ]) (q : Γ ⊩⟨ l′ ⟩ A′ ^ [ r' , ll' ]) → Γ ⊩⟨ l ⟩ t ≡ u ∷ A ^ [ r , ll ] / p → Γ ⊩⟨ l′ ⟩ t ≡ u ∷ A′ ^ [ r' , ll' ] / q irrelevanceEqTerm′ PE.refl PE.refl PE.refl p q t≡u = irrelevanceEqTerm p q t≡u -- Irrelevance for term equality with propositionally equal types and terms irrelevanceEqTerm″ : ∀ {Γ A A′ t t′ u u′ r r' ll ll' l l′} (req : r PE.≡ r') (leq : ll PE.≡ ll') (eqt : t PE.≡ t′) (equ : u PE.≡ u′) (eqA : A PE.≡ A′) (p : Γ ⊩⟨ l ⟩ A ^ [ r , ll ]) (q : Γ ⊩⟨ l′ ⟩ A′ ^ [ r' , ll' ]) → Γ ⊩⟨ l ⟩ t ≡ u ∷ A ^ [ r , ll ] / p → Γ ⊩⟨ l′ ⟩ t′ ≡ u′ ∷ A′ ^ [ r' , ll' ] / q irrelevanceEqTerm″ PE.refl PE.refl PE.refl PE.refl PE.refl p q t≡u = irrelevanceEqTerm p q t≡u -- Helper for irrelevance of term equality using shape view irrelevanceEqTermT : ∀ {Γ A t u r} {l l′} {p : Γ ⊩⟨ l ⟩ A ^ r} {q : Γ ⊩⟨ l′ ⟩ A ^ r} → ShapeView Γ l l′ A A r r p q → Γ ⊩⟨ l ⟩ t ≡ u ∷ A ^ r / p → Γ ⊩⟨ l′ ⟩ t ≡ u ∷ A ^ r / q irrelevanceEqTermT (ℕᵥ D D′) t≡u = t≡u irrelevanceEqTermT (Emptyᵥ D D′) t≡u = t≡u irrelevanceEqTermT { r = [ ! , ll ] } (ne (ne K D neK K≡K) (ne K₁ D₁ neK₁ K≡K₁)) (neₜ₌ k m d d′ nf) with whrDet* (red D₁ , ne neK₁) (red D , ne neK) irrelevanceEqTermT (ne (ne K D neK K≡K) (ne .K D₁ neK₁ K≡K₁)) (neₜ₌ k m d d′ nf) | PE.refl = neₜ₌ k m d d′ nf irrelevanceEqTermT { r = [ % , ll ] } (ne (ne K D neK K≡K) (ne K₁ D₁ neK₁ K≡K₁)) (neₜ₌ d d′) with whrDet* (red D₁ , ne neK₁) (red D , ne neK) irrelevanceEqTermT (ne (ne K D neK K≡K) (ne .K D₁ neK₁ K≡K₁)) (neₜ₌ d d′) | PE.refl = neₜ₌ d d′ irrelevanceEqTermT {Γ} {t = t} {u = u} {r = [ ! , ll ]} (Πᵥ (Πᵣ rF lF lG lF≤ lG≤ F G D ⊢F ⊢G A≡A [F] [G] G-ext) (Πᵣ rF₁ lF₁ lG₁ lF₁≤ lG₁≤ F₁ G₁ D₁ ⊢F₁ ⊢G₁ A≡A₁ [F]₁ [G]₁ G-ext₁)) (Πₜ₌ f g d d′ funcF funcG f≡g [f] [g] [f≡g]) = let ΠFG≡ΠF₁G₁ = whrDet* (red D , Πₙ) (red D₁ , Πₙ) F≡F₁ , rF≡rF₁ , lF≡lF₁ , G≡G₁ , lG≡lG₁ , lΠ≡lΠ₁ = Π-PE-injectivity ΠFG≡ΠF₁G₁ [A] = Πᵣ′ rF lF lG lF≤ lG≤ F G D ⊢F ⊢G A≡A [F] [G] G-ext [A]₁ = Πᵣ′ rF₁ lF₁ lG₁ lF₁≤ lG₁≤ F₁ G₁ D₁ ⊢F₁ ⊢G₁ A≡A₁ [F]₁ [G]₁ G-ext₁ in Πₜ₌ f g (PE.subst (λ x → Γ ⊢ t :⇒*: f ∷ x ^ ll) ΠFG≡ΠF₁G₁ d) (PE.subst (λ x → Γ ⊢ u :⇒*: g ∷ x ^ ll) ΠFG≡ΠF₁G₁ d′) funcF funcG (PE.subst (λ x → Γ ⊢ f ≅ g ∷ x ^ [ ! , ll ]) ΠFG≡ΠF₁G₁ f≡g) (irrelevanceTerm [A] [A]₁ [f]) (irrelevanceTerm [A] [A]₁ [g]) (λ {ρ} [ρ] ⊢Δ [a]₁ → let [a] = irrelevanceTerm′ (PE.cong (wk ρ) (PE.sym F≡F₁)) (PE.sym rF≡rF₁) (PE.cong ι (PE.sym lF≡lF₁)) ([F]₁ [ρ] ⊢Δ) ([F] [ρ] ⊢Δ) [a]₁ in irrelevanceEqTerm′ (PE.cong (λ G → wk (lift ρ) G [ _ ]) G≡G₁) PE.refl (PE.cong ι lG≡lG₁) ([G] [ρ] ⊢Δ [a]) ([G]₁ [ρ] ⊢Δ [a]₁) ([f≡g] [ρ] ⊢Δ [a])) irrelevanceEqTermT {Γ} {t = t} {u = u} {r = [ % , ll ]} (Πᵥ (Πᵣ 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₁)) (d , d′) = let ΠFG≡ΠF₁G₁ = whrDet* (red D , Πₙ) (red D₁ , Πₙ) in (PE.subst (λ x → Γ ⊢ t ∷ x ^ [ % , ll ]) ΠFG≡ΠF₁G₁ d , PE.subst (λ x → Γ ⊢ u ∷ x ^ [ % , ll ]) ΠFG≡ΠF₁G₁ d′) irrelevanceEqTermT {Γ} {t = t} {u = u} {r = [ % , ll ]} (∃ᵥ (∃ᵣ F G D ⊢F ⊢G A≡A [F] [G] G-ext) (∃ᵣ F₁ G₁ D₁ ⊢F₁ ⊢G₁ A≡A₁ [F]₁ [G]₁ G-ext₁)) (d , d′) = let ∃FG≡∃F₁G₁ = whrDet* (red D , ∃ₙ) (red D₁ , ∃ₙ) in (PE.subst (λ x → Γ ⊢ t ∷ x ^ [ % , ll ]) ∃FG≡∃F₁G₁ d , PE.subst (λ x → Γ ⊢ u ∷ x ^ [ % , ll ]) ∃FG≡∃F₁G₁ d′) irrelevanceEqTermT (Uᵥ (Uᵣ r ll l< PE.refl D) (Uᵣ r' ll' l<' _ D')) t = let U≡U = whrDet* (red D , Uₙ) (red D' , Uₙ) r≡r , l≡l = Univ-PE-injectivity U≡U in reduction-irrelevant-Univ= r≡r t irrelevanceEqTermT (emb⁰¹ x) t≡u = irrelevanceEqTermT x t≡u irrelevanceEqTermT (emb¹⁰ x) t≡u = irrelevanceEqTermT x t≡u irrelevanceEqTermT (emb¹∞ x) t≡u = irrelevanceEqTermT x t≡u irrelevanceEqTermT (emb∞¹ x) t≡u = irrelevanceEqTermT x t≡u irrelevance-≤ : ∀ {A Γ r l l'} → l ≤ l' → Γ ⊩⟨ ι l ⟩ A ^ r → Γ ⊩⟨ ι l' ⟩ A ^ r irrelevance-≤ (<is≤ 0<1) [A] = irrelevance-level emb< [A] irrelevance-≤ (≡is≤ PE.refl) [A] = [A]
{ "alphanum_fraction": 0.4073808027, "avg_line_length": 63.64, "ext": "agda", "hexsha": "d69092cc769799a794a1b0038c2e73a34d7928bb", "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/Irrelevance.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/Irrelevance.agda", "max_line_length": 187, "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/Irrelevance.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": 9695, "size": 22274 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Solver for equations in commutative monoids -- -- Adapted from Algebra.Monoid-solver ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} open import Algebra open import Data.Bool as Bool using (Bool; true; false; if_then_else_; _∨_) open import Data.Fin using (Fin; zero; suc) open import Data.Maybe as Maybe using (Maybe; decToMaybe; From-just; from-just) open import Data.Nat.Base as ℕ using (ℕ; zero; suc; _+_) open import Data.Product using (_×_; uncurry) open import Data.Vec using (Vec; []; _∷_; lookup; replicate) open import Function using (_∘_) import Relation.Binary.Reasoning.Setoid as EqReasoning import Relation.Binary.Reflection as Reflection import Relation.Nullary.Decidable as Dec import Data.Vec.Relation.Binary.Pointwise.Inductive as Pointwise open import Relation.Binary.PropositionalEquality as P using (_≡_; decSetoid) open import Relation.Nullary using (Dec) module Algebra.Solver.IdempotentCommutativeMonoid {m₁ m₂} (M : IdempotentCommutativeMonoid m₁ m₂) where open IdempotentCommutativeMonoid M open EqReasoning setoid ------------------------------------------------------------------------ -- Monoid expressions -- There is one constructor for every operation, plus one for -- variables; there may be at most n variables. infixr 5 _⊕_ infixr 10 _•_ data Expr (n : ℕ) : Set where var : Fin n → Expr n id : Expr n _⊕_ : Expr n → Expr n → Expr n -- An environment contains one value for every variable. Env : ℕ → Set _ Env n = Vec Carrier n -- The semantics of an expression is a function from an environment to -- a value. ⟦_⟧ : ∀ {n} → Expr n → Env n → Carrier ⟦ var x ⟧ ρ = lookup ρ x ⟦ id ⟧ ρ = ε ⟦ e₁ ⊕ e₂ ⟧ ρ = ⟦ e₁ ⟧ ρ ∙ ⟦ e₂ ⟧ ρ ------------------------------------------------------------------------ -- Normal forms -- A normal form is a vector of bits (a set). Normal : ℕ → Set Normal n = Vec Bool n -- The semantics of a normal form. ⟦_⟧⇓ : ∀ {n} → Normal n → Env n → Carrier ⟦ [] ⟧⇓ _ = ε ⟦ b ∷ v ⟧⇓ (a ∷ ρ) = if b then a ∙ (⟦ v ⟧⇓ ρ) else (⟦ v ⟧⇓ ρ) ------------------------------------------------------------------------ -- Constructions on normal forms -- The empty bag. empty : ∀{n} → Normal n empty = replicate false -- A singleton bag. sg : ∀{n} (i : Fin n) → Normal n sg zero = true ∷ empty sg (suc i) = false ∷ sg i -- The composition of normal forms. _•_ : ∀{n} (v w : Normal n) → Normal n [] • [] = [] (l ∷ v) • (m ∷ w) = (l ∨ m) ∷ v • w ------------------------------------------------------------------------ -- Correctness of the constructions on normal forms -- The empty bag stands for the unit ε. empty-correct : ∀{n} (ρ : Env n) → ⟦ empty ⟧⇓ ρ ≈ ε empty-correct [] = refl empty-correct (a ∷ ρ) = empty-correct ρ -- The singleton bag stands for a single variable. sg-correct : ∀{n} (x : Fin n) (ρ : Env n) → ⟦ sg x ⟧⇓ ρ ≈ lookup ρ x sg-correct zero (x ∷ ρ) = begin x ∙ ⟦ empty ⟧⇓ ρ ≈⟨ ∙-congˡ (empty-correct ρ) ⟩ x ∙ ε ≈⟨ identityʳ _ ⟩ x ∎ sg-correct (suc x) (m ∷ ρ) = sg-correct x ρ -- Normal form composition corresponds to the composition of the monoid. flip12 : ∀ a b c → a ∙ (b ∙ c) ≈ b ∙ (a ∙ c) flip12 a b c = begin a ∙ (b ∙ c) ≈⟨ sym (assoc _ _ _) ⟩ (a ∙ b) ∙ c ≈⟨ ∙-congʳ (comm _ _) ⟩ (b ∙ a) ∙ c ≈⟨ assoc _ _ _ ⟩ b ∙ (a ∙ c) ∎ distr : ∀ a b c → a ∙ (b ∙ c) ≈ (a ∙ b) ∙ (a ∙ c) distr a b c = begin a ∙ (b ∙ c) ≈⟨ ∙-cong (sym (idem a)) refl ⟩ (a ∙ a) ∙ (b ∙ c) ≈⟨ assoc _ _ _ ⟩ a ∙ (a ∙ (b ∙ c)) ≈⟨ ∙-congˡ (sym (assoc _ _ _)) ⟩ a ∙ ((a ∙ b) ∙ c) ≈⟨ ∙-congˡ (∙-congʳ (comm _ _)) ⟩ a ∙ ((b ∙ a) ∙ c) ≈⟨ ∙-congˡ (assoc _ _ _) ⟩ a ∙ (b ∙ (a ∙ c)) ≈⟨ sym (assoc _ _ _) ⟩ (a ∙ b) ∙ (a ∙ c) ∎ comp-correct : ∀ {n} (v w : Normal n) (ρ : Env n) → ⟦ v • w ⟧⇓ ρ ≈ (⟦ v ⟧⇓ ρ ∙ ⟦ w ⟧⇓ ρ) comp-correct [] [] ρ = sym (identityˡ _) comp-correct (true ∷ v) (true ∷ w) (a ∷ ρ) = trans (∙-congˡ (comp-correct v w ρ)) (distr _ _ _) comp-correct (true ∷ v) (false ∷ w) (a ∷ ρ) = trans (∙-congˡ (comp-correct v w ρ)) (sym (assoc _ _ _)) comp-correct (false ∷ v) (true ∷ w) (a ∷ ρ) = trans (∙-congˡ (comp-correct v w ρ)) (flip12 _ _ _) comp-correct (false ∷ v) (false ∷ w) (a ∷ ρ) = comp-correct v w ρ ------------------------------------------------------------------------ -- Normalization -- A normaliser. normalise : ∀ {n} → Expr n → Normal n normalise (var x) = sg x normalise id = empty normalise (e₁ ⊕ e₂) = normalise e₁ • normalise e₂ -- The normaliser preserves the semantics of the expression. normalise-correct : ∀ {n} (e : Expr n) (ρ : Env n) → ⟦ normalise e ⟧⇓ ρ ≈ ⟦ e ⟧ ρ normalise-correct (var x) ρ = sg-correct x ρ normalise-correct id ρ = empty-correct ρ normalise-correct (e₁ ⊕ e₂) ρ = begin ⟦ normalise e₁ • normalise e₂ ⟧⇓ ρ ≈⟨ comp-correct (normalise e₁) (normalise e₂) ρ ⟩ ⟦ normalise e₁ ⟧⇓ ρ ∙ ⟦ normalise e₂ ⟧⇓ ρ ≈⟨ ∙-cong (normalise-correct e₁ ρ) (normalise-correct e₂ ρ) ⟩ ⟦ e₁ ⟧ ρ ∙ ⟦ e₂ ⟧ ρ ∎ ------------------------------------------------------------------------ -- "Tactics" open module R = Reflection setoid var ⟦_⟧ (⟦_⟧⇓ ∘ normalise) normalise-correct public using (solve; _⊜_) -- We can decide if two normal forms are /syntactically/ equal. infix 5 _≟_ _≟_ : ∀ {n} (nf₁ nf₂ : Normal n) → Dec (nf₁ ≡ nf₂) nf₁ ≟ nf₂ = Dec.map Pointwise-≡↔≡ (decidable Bool._≟_ nf₁ nf₂) where open Pointwise -- We can also give a sound, but not necessarily complete, procedure -- for determining if two expressions have the same semantics. prove′ : ∀ {n} (e₁ e₂ : Expr n) → Maybe (∀ ρ → ⟦ e₁ ⟧ ρ ≈ ⟦ e₂ ⟧ ρ) prove′ e₁ e₂ = Maybe.map lemma (decToMaybe (normalise e₁ ≟ normalise e₂)) where lemma : normalise e₁ ≡ normalise e₂ → ∀ ρ → ⟦ e₁ ⟧ ρ ≈ ⟦ e₂ ⟧ ρ lemma eq ρ = R.prove ρ e₁ e₂ (begin ⟦ normalise e₁ ⟧⇓ ρ ≡⟨ P.cong (λ e → ⟦ e ⟧⇓ ρ) eq ⟩ ⟦ normalise e₂ ⟧⇓ ρ ∎) -- This procedure can be combined with from-just. prove : ∀ n (e₁ e₂ : Expr n) → From-just (prove′ e₁ e₂) prove _ e₁ e₂ = from-just (prove′ e₁ e₂) -- prove : ∀ n (es : Expr n × Expr n) → -- From-just (uncurry prove′ es) -- prove _ = from-just ∘ uncurry prove′ -- -}
{ "alphanum_fraction": 0.5347744361, "avg_line_length": 29.8317757009, "ext": "agda", "hexsha": "5aab691dff510a34b0e9cf4a8d0bb8794dc8d500", "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/Algebra/Solver/IdempotentCommutativeMonoid.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/Algebra/Solver/IdempotentCommutativeMonoid.agda", "max_line_length": 77, "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/Algebra/Solver/IdempotentCommutativeMonoid.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 2394, "size": 6384 }
open import Agda.Primitive postulate ℓ : Level F : Level → Set module Two where mutual α : Level α = _ G : F (α ⊔ ℓ) → F ℓ G A = A H : F (α ⊔ ℓ) → F α H A = A module Three where mutual α : Level α = _ β : Level β = _ G : F (α ⊔ β ⊔ ℓ) → F ℓ G A = A H : F (α ⊔ β ⊔ ℓ) → F α H A = A I : F (α ⊔ β ⊔ ℓ) → F β I A = A
{ "alphanum_fraction": 0.4035087719, "avg_line_length": 10.2307692308, "ext": "agda", "hexsha": "69344ba484172bcd259036e41e1c0e14fe335387", "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/Issue2780.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/Issue2780.agda", "max_line_length": 27, "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/Issue2780.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": 181, "size": 399 }