Search is not available for this dataset
text
string
meta
dict
{-# OPTIONS --without-K --rewriting #-} module lib.groupoids.Groupoids where open import lib.groupoids.FundamentalPreGroupoid public
{ "alphanum_fraction": 0.7794117647, "avg_line_length": 19.4285714286, "ext": "agda", "hexsha": "f6f8e183f9c3ae7099f88c66b55dc2e7c23d8dc3", "lang": "Agda", "max_forks_count": 50, "max_forks_repo_forks_event_max_datetime": "2022-02-14T03:03:25.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-10T01:48:08.000Z", "max_forks_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "timjb/HoTT-Agda", "max_forks_repo_path": "core/lib/groupoids/Groupoids.agda", "max_issues_count": 31, "max_issues_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_issues_repo_issues_event_max_datetime": "2021-10-03T19:15:25.000Z", "max_issues_repo_issues_event_min_datetime": "2015-03-05T20:09:00.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "timjb/HoTT-Agda", "max_issues_repo_path": "core/lib/groupoids/Groupoids.agda", "max_line_length": 55, "max_stars_count": 294, "max_stars_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "timjb/HoTT-Agda", "max_stars_repo_path": "core/lib/groupoids/Groupoids.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-20T13:54:45.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T16:23:23.000Z", "num_tokens": 31, "size": 136 }
module Luau.Syntax where open import Agda.Builtin.Equality using (_≡_) open import Agda.Builtin.Bool using (Bool; true; false) open import Agda.Builtin.Float using (Float) open import Agda.Builtin.String using (String) open import Luau.Var using (Var) open import Luau.Addr using (Addr) open import Luau.Type using (Type) open import FFI.Data.Maybe using (Maybe; just; nothing) infixr 5 _∙_ data Annotated : Set where maybe : Annotated yes : Annotated data VarDec : Annotated → Set where var : Var → VarDec maybe var_∈_ : ∀ {a} → Var → Type → VarDec a name : ∀ {a} → VarDec a → Var name (var x) = x name (var x ∈ T) = x data FunDec : Annotated → Set where _⟨_⟩∈_ : ∀ {a} → Var → VarDec a → Type → FunDec a _⟨_⟩ : Var → VarDec maybe → FunDec maybe fun : ∀ {a} → FunDec a → VarDec a fun (f ⟨ x ⟩∈ T) = (var f ∈ T) fun (f ⟨ x ⟩) = (var f) arg : ∀ {a} → FunDec a → VarDec a arg (f ⟨ x ⟩∈ T) = x arg (f ⟨ x ⟩) = x data BinaryOperator : Set where + : BinaryOperator - : BinaryOperator * : BinaryOperator / : BinaryOperator < : BinaryOperator > : BinaryOperator == : BinaryOperator ~= : BinaryOperator <= : BinaryOperator >= : BinaryOperator ·· : BinaryOperator data Value : Set where nil : Value addr : Addr → Value number : Float → Value bool : Bool → Value string : String → Value data Block (a : Annotated) : Set data Stat (a : Annotated) : Set data Expr (a : Annotated) : Set data Block a where _∙_ : Stat a → Block a → Block a done : Block a data Stat a where function_is_end : FunDec a → Block a → Stat a local_←_ : VarDec a → Expr a → Stat a return : Expr a → Stat a data Expr a where var : Var → Expr a val : Value → Expr a _$_ : Expr a → Expr a → Expr a function_is_end : FunDec a → Block a → Expr a block_is_end : VarDec a → Block a → Expr a binexp : Expr a → BinaryOperator → Expr a → Expr a isAnnotatedᴱ : ∀ {a} → Expr a → Maybe (Expr yes) isAnnotatedᴮ : ∀ {a} → Block a → Maybe (Block yes) isAnnotatedᴱ (var x) = just (var x) isAnnotatedᴱ (val v) = just (val v) isAnnotatedᴱ (M $ N) with isAnnotatedᴱ M | isAnnotatedᴱ N isAnnotatedᴱ (M $ N) | just M′ | just N′ = just (M′ $ N′) isAnnotatedᴱ (M $ N) | _ | _ = nothing isAnnotatedᴱ (function f ⟨ var x ∈ T ⟩∈ U is B end) with isAnnotatedᴮ B isAnnotatedᴱ (function f ⟨ var x ∈ T ⟩∈ U is B end) | just B′ = just (function f ⟨ var x ∈ T ⟩∈ U is B′ end) isAnnotatedᴱ (function f ⟨ var x ∈ T ⟩∈ U is B end) | _ = nothing isAnnotatedᴱ (function _ is B end) = nothing isAnnotatedᴱ (block var b ∈ T is B end) with isAnnotatedᴮ B isAnnotatedᴱ (block var b ∈ T is B end) | just B′ = just (block var b ∈ T is B′ end) isAnnotatedᴱ (block var b ∈ T is B end) | _ = nothing isAnnotatedᴱ (block _ is B end) = nothing isAnnotatedᴱ (binexp M op N) with isAnnotatedᴱ M | isAnnotatedᴱ N isAnnotatedᴱ (binexp M op N) | just M′ | just N′ = just (binexp M′ op N′) isAnnotatedᴱ (binexp M op N) | _ | _ = nothing isAnnotatedᴮ (function f ⟨ var x ∈ T ⟩∈ U is C end ∙ B) with isAnnotatedᴮ B | isAnnotatedᴮ C isAnnotatedᴮ (function f ⟨ var x ∈ T ⟩∈ U is C end ∙ B) | just B′ | just C′ = just (function f ⟨ var x ∈ T ⟩∈ U is C′ end ∙ B′) isAnnotatedᴮ (function f ⟨ var x ∈ T ⟩∈ U is C end ∙ B) | _ | _ = nothing isAnnotatedᴮ (function _ is C end ∙ B) = nothing isAnnotatedᴮ (local var x ∈ T ← M ∙ B) with isAnnotatedᴱ M | isAnnotatedᴮ B isAnnotatedᴮ (local var x ∈ T ← M ∙ B) | just M′ | just B′ = just (local var x ∈ T ← M′ ∙ B′) isAnnotatedᴮ (local var x ∈ T ← M ∙ B) | _ | _ = nothing isAnnotatedᴮ (local _ ← M ∙ B) = nothing isAnnotatedᴮ (return M ∙ B) with isAnnotatedᴱ M | isAnnotatedᴮ B isAnnotatedᴮ (return M ∙ B) | just M′ | just B′ = just (return M′ ∙ B′) isAnnotatedᴮ (return M ∙ B) | _ | _ = nothing isAnnotatedᴮ done = just done
{ "alphanum_fraction": 0.644989339, "avg_line_length": 33.8018018018, "ext": "agda", "hexsha": "d9175067dac11a4e08c47a45757e18977f7a8ace", "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": "362428f8b4b6f5c9d43f4daf55bcf7873f536c3f", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "XanderYZZ/luau", "max_forks_repo_path": "prototyping/Luau/Syntax.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "362428f8b4b6f5c9d43f4daf55bcf7873f536c3f", "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": "XanderYZZ/luau", "max_issues_repo_path": "prototyping/Luau/Syntax.agda", "max_line_length": 127, "max_stars_count": 1, "max_stars_repo_head_hexsha": "72d8d443431875607fd457a13fe36ea62804d327", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "TheGreatSageEqualToHeaven/luau", "max_stars_repo_path": "prototyping/Luau/Syntax.agda", "max_stars_repo_stars_event_max_datetime": "2021-12-05T21:53:03.000Z", "max_stars_repo_stars_event_min_datetime": "2021-12-05T21:53:03.000Z", "num_tokens": 1444, "size": 3752 }
------------------------------------------------------------------------------ -- All the common modules ------------------------------------------------------------------------------ {-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} module Common.Everything where open import Common.DefinitionsATP open import Common.DefinitionsI open import Common.FOL.FOL open import Common.FOL.FOL-Eq open import Common.FOL.Relation.Binary.EqReasoning open import Common.FOL.Relation.Binary.PropositionalEquality open import Common.Relation.Binary.PreorderReasoning open import Common.Relation.Unary
{ "alphanum_fraction": 0.5658263305, "avg_line_length": 32.4545454545, "ext": "agda", "hexsha": "7eeebd1eb5118a21d709abebc3c655bd977ada4c", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "asr/fotc", "max_forks_repo_path": "src/fot/Common/Everything.agda", "max_issues_count": 2, "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "asr/fotc", "max_issues_repo_path": "src/fot/Common/Everything.agda", "max_line_length": 78, "max_stars_count": 11, "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/fotc", "max_stars_repo_path": "src/fot/Common/Everything.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": 129, "size": 714 }
module Structure.Category.Monoidal where import Lvl open import Data.Tuple as Tuple using (_,_ ; _⨯_) open import Data.Tuple.Category open import Data.Tuple.Equivalence import Functional as Fn open import Logic.Predicate open import Structure.Setoid open import Structure.Category open import Structure.Category.Functor import Structure.Category.Functor.Functors as Functors open import Structure.Category.NaturalTransformation open import Syntax.Function open import Type private variable ℓ ℓₒ ℓₘ ℓₑ ℓₒ₁ ℓₘ₁ ℓₑ₁ ℓₒ₂ ℓₘ₂ ℓₑ₂ : Lvl.Level private variable Obj : Type{ℓ} private variable Morphism : Obj → Obj → Type{ℓ} open Functors.Wrapped module _ {C : CategoryObject{ℓₒ}{ℓₘ}{ℓₑ}} (product@([∃]-intro _) : (C ⨯ᶜᵃᵗ C) →ᶠᵘⁿᶜᵗᵒʳ C) (𝟏 : CategoryObject.Object(C)) where open CategoryObject(C) open Category.ArrowNotation(category) open Category(category) open Functor record MonoidalCategory : Type{Lvl.of(Type.of C)} where constructor intro field associator : (((product ∘ᶠᵘⁿᶜᵗᵒʳ (Tupleᶜᵃᵗ.mapLeft product))) ∘ᶠᵘⁿᶜᵗᵒʳ Tupleᶜᵃᵗ.associateLeft) ↔ᴺᵀ (product ∘ᶠᵘⁿᶜᵗᵒʳ (Tupleᶜᵃᵗ.mapRight product)) unitorₗ : (product ∘ᶠᵘⁿᶜᵗᵒʳ Tupleᶜᵃᵗ.constₗ 𝟏) ↔ᴺᵀ idᶠᵘⁿᶜᵗᵒʳ unitorᵣ : (product ∘ᶠᵘⁿᶜᵗᵒʳ Tupleᶜᵃᵗ.constᵣ 𝟏) ↔ᴺᵀ idᶠᵘⁿᶜᵗᵒʳ _⊗_ : Object → Object → Object _⊗_ = Tuple.curry([∃]-witness product) _<⊗>_ : ∀{x₁ x₂ y₁ y₂} → (x₁ ⟶ x₂) → (y₁ ⟶ y₂) → ((x₁ ⊗ y₁) ⟶ (x₂ ⊗ y₂)) _<⊗>_ = Tuple.curry(map([∃]-proof product)) α : ∀(x)(y)(z) → (((x ⊗ y) ⊗ z) ⟶ (x ⊗ (y ⊗ z))) α x y z = [∃]-witness associator (x , (y , z)) υₗ : ∀(x) → ((𝟏 ⊗ x) ⟶ x) υₗ = [∃]-witness unitorₗ υᵣ : ∀(x) → ((x ⊗ 𝟏) ⟶ x) υᵣ = [∃]-witness unitorᵣ α⁻¹ : ∀(x)(y)(z) → ((x ⊗ (y ⊗ z)) ⟶ ((x ⊗ y) ⊗ z)) α⁻¹ x y z = [∃]-witness (invᴺᵀ associator) (x , (y , z)) υₗ⁻¹ : ∀(x) → (x ⟶ (𝟏 ⊗ x)) υₗ⁻¹ = [∃]-witness (invᴺᵀ unitorₗ) υᵣ⁻¹ : ∀(x) → (x ⟶ (x ⊗ 𝟏)) υᵣ⁻¹ = [∃]-witness (invᴺᵀ unitorᵣ) α-natural : ∀{(x₁ , (x₂ , x₃)) (y₁ , (y₂ , y₃)) : Object ⨯ (Object ⨯ Object)} {(f₁ , f₂ , f₃) : ((x₁ ⟶ y₁) ⨯ ((x₂ ⟶ y₂) ⨯ (x₃ ⟶ y₃)))} → ((α y₁ y₂ y₃) ∘ ((f₁ <⊗> f₂) <⊗> f₃) ≡ (f₁ <⊗> (f₂ <⊗> f₃)) ∘ (α x₁ x₂ x₃)) α-natural = NaturalTransformation.natural(NaturalIsomorphism.naturalTransformation([∃]-proof associator)) υₗ-natural : ∀{x y}{f : x ⟶ y} → (υₗ(y) ∘ (id <⊗> f) ≡ f ∘ υₗ(x)) υₗ-natural = NaturalTransformation.natural(NaturalIsomorphism.naturalTransformation([∃]-proof unitorₗ)) υᵣ-natural : ∀{x y}{f : x ⟶ y} → (υᵣ(y) ∘ (f <⊗> id) ≡ f ∘ υᵣ(x)) υᵣ-natural = NaturalTransformation.natural(NaturalIsomorphism.naturalTransformation([∃]-proof unitorᵣ)) α⁻¹-natural : ∀{((x₁ , x₂) , x₃) ((y₁ , y₂) , y₃) : (Object ⨯ Object) ⨯ Object} {(f₁ , f₂ , f₃) : ((x₁ ⟶ y₁) ⨯ ((x₂ ⟶ y₂) ⨯ (x₃ ⟶ y₃)))} → ((α⁻¹ y₁ y₂ y₃) ∘ (f₁ <⊗> (f₂ <⊗> f₃)) ≡ ((f₁ <⊗> f₂) <⊗> f₃) ∘ (α⁻¹ x₁ x₂ x₃)) α⁻¹-natural = NaturalTransformation.natural(NaturalIsomorphism.naturalTransformation([∃]-proof (invᴺᵀ associator))) υₗ⁻¹-natural : ∀{x y}{f : x ⟶ y} → (υₗ⁻¹(y) ∘ f ≡ (id <⊗> f) ∘ υₗ⁻¹(x)) υₗ⁻¹-natural = NaturalTransformation.natural(NaturalIsomorphism.naturalTransformation([∃]-proof (invᴺᵀ unitorₗ))) υᵣ⁻¹-natural : ∀{x y}{f : x ⟶ y} → (υᵣ⁻¹(y) ∘ f ≡ (f <⊗> id) ∘ υᵣ⁻¹(x)) υᵣ⁻¹-natural = NaturalTransformation.natural(NaturalIsomorphism.naturalTransformation([∃]-proof (invᴺᵀ unitorᵣ))) -- TODO: And the coherence conditions? record Monoidalᶜᵃᵗ{ℓₒ}{ℓₘ}{ℓₑ} (C : CategoryObject{ℓₒ}{ℓₘ}{ℓₑ}) : Type{Lvl.𝐒(ℓₒ Lvl.⊔ ℓₘ Lvl.⊔ ℓₑ)} where constructor intro field productFunctor : (C ⨯ᶜᵃᵗ C) →ᶠᵘⁿᶜᵗᵒʳ C unitObject : CategoryObject.Object(C) ⦃ monoidalCategory ⦄ : MonoidalCategory(productFunctor)(unitObject) module _ {C₁ : CategoryObject{ℓₒ}{ℓₘ}{ℓₑ}} ⦃ (intro product₁ 𝟏₁) : Monoidalᶜᵃᵗ(C₁) ⦄ {C₂ : CategoryObject{ℓₒ}{ℓₘ}{ℓₑ}} ⦃ (intro product₂ 𝟏₂) : Monoidalᶜᵃᵗ(C₂) ⦄ (functor@([∃]-intro F) : (C₁ →ᶠᵘⁿᶜᵗᵒʳ C₂)) where instance _ = C₁ instance _ = C₂ open CategoryObject ⦃ … ⦄ open Category ⦃ … ⦄ open Category.ArrowNotation ⦃ … ⦄ open Functor ⦃ … ⦄ open MonoidalCategory ⦃ … ⦄ -- Also called: Lax monoidal functor, applicative functor, idiom. record MonoidalFunctor : Type{Lvl.of(Type.of C₁)} where constructor intro field ε : 𝟏₂ ⟶ F(𝟏₁) Μ : (product₂ ∘ᶠᵘⁿᶜᵗᵒʳ Tupleᶜᵃᵗ.map functor functor) →ᴺᵀ (functor ∘ᶠᵘⁿᶜᵗᵒʳ product₁) μ : ∀{x y} → ((F(x) ⊗ F(y)) ⟶ F(x ⊗ y)) μ{x}{y} = [∃]-witness Μ (x , y) μ-natural : ∀{(x₁ , x₂) (y₁ , y₂) : Object ⦃ C₁ ⦄ ⨯ Object ⦃ C₁ ⦄} {(f₁ , f₂) : ((x₁ ⟶ y₁) ⨯ (x₂ ⟶ y₂))} → (μ ∘ (map(f₁) <⊗> map(f₂)) ≡ map(f₁ <⊗> f₂) ∘ μ) μ-natural = NaturalTransformation.natural([∃]-proof Μ) -- TODO: Coherence conditions module _ {C : CategoryObject{ℓₒ}{ℓₘ}{ℓₑ}} ⦃ (intro product 𝟏) : Monoidalᶜᵃᵗ(C) ⦄ (functor@([∃]-intro F) : (⟲ᶠᵘⁿᶜᵗᵒʳ C)) where instance _ = C open CategoryObject ⦃ … ⦄ open Category ⦃ … ⦄ open Category.ArrowNotation ⦃ … ⦄ open Functor ⦃ … ⦄ open MonoidalCategory ⦃ … ⦄ record TensorialStrength : Type{Lvl.of(Type.of C)} where constructor intro field Β : (product ∘ᶠᵘⁿᶜᵗᵒʳ Tupleᶜᵃᵗ.mapRight functor) →ᴺᵀ (functor ∘ᶠᵘⁿᶜᵗᵒʳ product) β : ∀{x y} → ((x ⊗ F(y)) ⟶ F(x ⊗ y)) β{x}{y} = [∃]-witness Β (x , y) β-natural : ∀{(x₁ , x₂) (y₁ , y₂) : Object ⦃ C ⦄ ⨯ Object ⦃ C ⦄} {(f₁ , f₂) : ((x₁ ⟶ y₁) ⨯ (x₂ ⟶ y₂))} → (β ∘ (f₁ <⊗> map(f₂)) ≡ map(f₁ <⊗> f₂) ∘ β) β-natural = NaturalTransformation.natural([∃]-proof Β) module TensorialStrengthenedMonoidalEndofunctor ⦃ monoidal : MonoidalFunctor(functor) ⦄ ⦃ strength : TensorialStrength ⦄ where open MonoidalFunctor(monoidal) open TensorialStrength(strength) Ι : idᶠᵘⁿᶜᵗᵒʳ →ᴺᵀ functor ∃.witness Ι x = {!!} ∘ μ{x}{𝟏} ∘ {!!} ∃.proof Ι = {!!} ι : ∀{x} → (x ⟶ F(x)) ι{x} = [∃]-witness Ι x
{ "alphanum_fraction": 0.5871421396, "avg_line_length": 36.2, "ext": "agda", "hexsha": "02fc6f0ed21cebdb82b505d9efeae9188dcec54c", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_path": "Structure/Category/Monoidal.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_path": "Structure/Category/Monoidal.agda", "max_line_length": 151, "max_stars_count": 6, "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_path": "Structure/Category/Monoidal.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": 3084, "size": 5973 }
{-# OPTIONS --universe-polymorphism #-} module Categories.Adjunction where open import Level open import Relation.Binary using (Rel; IsEquivalence) open import Data.Sum open import Data.Product open import Function using (flip) open import Categories.Category open import Categories.Functor hiding (equiv; assoc; identityˡ; identityʳ; ∘-resp-≡) renaming (id to idF; _≡_ to _≡F_; _∘_ to _∘F_) open import Categories.NaturalTransformation hiding (equiv; setoid) renaming (id to idT; _≡_ to _≡T_) open import Categories.Monad open import Categories.Support.Equivalence record Adjunction {o ℓ e} {o₁ ℓ₁ e₁} {C : Category o ℓ e} {D : Category o₁ ℓ₁ e₁} (F : Functor D C) (G : Functor C D) : Set (o ⊔ ℓ ⊔ e ⊔ o₁ ⊔ ℓ₁ ⊔ e₁) where field unit : NaturalTransformation idF (G ∘F F) counit : NaturalTransformation (F ∘F G) idF .zig : idT ≡T (counit ∘ʳ F) ∘₁ (F ∘ˡ unit) .zag : idT ≡T (G ∘ˡ counit) ∘₁ (unit ∘ʳ G) private module C = Category C private module D = Category D private module F = Functor F private module G = Functor G renaming (F₀ to G₀; F₁ to G₁; F-resp-≡ to G-resp-≡) open F hiding (op) open G hiding (op) private module unit = NaturalTransformation unit private module counit = NaturalTransformation counit monad : Monad D monad = record { F = G ∘F F ; η = unit ; μ = G ∘ˡ (counit ∘ʳ F) ; assoc = assoc′ ; identityˡ = identityˡ′ ; identityʳ = identityʳ′ } where .assoc′ : ∀ {x} → G₁ (counit.η (F₀ x)) D.∘ G₁ (F₁ (G₁ (counit.η (F₀ x)))) D.≡ G₁ (counit.η (F₀ x)) D.∘ G₁ (counit.η (F₀ (G₀ (F₀ x)))) assoc′ {x} = begin G₁ (counit.η (F₀ x)) D.∘ G₁ (F₁ (G₁ (counit.η (F₀ x)))) ↑⟨ G.homomorphism ⟩ G₁ ((counit.η (F₀ x)) C.∘ (F₁ (G₁ (counit.η (F₀ x))))) ↓⟨ G-resp-≡ (NaturalTransformation.commute counit (counit.η (F₀ x))) ⟩ G₁ (counit.η (F₀ x) C.∘ counit.η (F₀ (G₀ (F₀ x)))) ↓⟨ G.homomorphism ⟩ G₁ (counit.η (F₀ x)) D.∘ G₁ (counit.η (F₀ (G₀ (F₀ x)))) ∎ where open D.HomReasoning .identityˡ′ : ∀ {x} → G₁ (counit.η (F₀ x)) D.∘ G₁ (F₁ (unit.η x)) D.≡ D.id identityˡ′ {x} = begin G₁ (counit.η (F₀ x)) D.∘ G₁ (F₁ (unit.η x)) ↑⟨ G.homomorphism ⟩ G₁ ((counit.η (F₀ x)) C.∘ (F₁ (unit.η x))) ↑⟨ G-resp-≡ zig ⟩ G₁ C.id ↓⟨ G.identity ⟩ D.id ∎ where open D.HomReasoning .identityʳ′ : ∀ {x} → G₁ (counit.η (F₀ x)) D.∘ unit.η (G₀ (F₀ x)) D.≡ D.id identityʳ′ = D.Equiv.sym zag op : Adjunction {C = D.op} {D = C.op} G.op F.op op = record { unit = counit.op; counit = unit.op; zig = zag; zag = zig } infixr 5 _⊣_ _⊣_ = Adjunction id : ∀ {o ℓ e} {C : Category o ℓ e} → Adjunction (idF {C = C}) (idF {C = C}) id {C = C} = record { unit = idT ; counit = idT ; zig = Equiv.sym C.identityˡ ; zag = Equiv.sym C.identityˡ } where module C = Category C open C infix 4 _≡_ _≡_ : ∀ {o ℓ e} {o₁ ℓ₁ e₁} {C : Category o ℓ e} {D : Category o₁ ℓ₁ e₁} {F : Functor D C} {G : Functor C D} → Rel (F ⊣ G) (o ⊔ e ⊔ o₁ ⊔ e₁) _≡_ {C = C} {D} {F} {G} X Y = Adjunction.unit X ≡T Adjunction.unit Y × Adjunction.counit X ≡T Adjunction.counit Y .equiv : ∀ {o ℓ e} {o₁ ℓ₁ e₁} {C : Category o ℓ e} {D : Category o₁ ℓ₁ e₁} {F : Functor D C} {G : Functor C D} → IsEquivalence (_≡_ {F = F} {G}) equiv {C = C} {D} {F} {G} = record { refl = (D.Equiv.refl), (C.Equiv.refl) ; sym = λ {T U : F ⊣ G} → sym' {T = T} {U = U} ; trans = λ {T U V : F ⊣ G} → trans' {T = T} {U = U} {V = V} } where module C = Category C module D = Category D sym' : {T U : F ⊣ G} → (H : T ≡ U) → flip _≡_ T U sym' {T} {U} (H₁ , H₂) = (λ {x} → D.Equiv.sym H₁) , (λ {x} → C.Equiv.sym H₂) trans' : {T U V : F ⊣ G} → T ≡ U → U ≡ V → T ≡ V trans' {T} {U} {V} (H₁ , H₂) (H₃ , H₄) = (λ {x} → D.Equiv.trans H₁ H₃) , (C.Equiv.trans H₂ H₄) setoid : ∀ {o ℓ e} {o₁ ℓ₁ e₁} {C : Category o ℓ e} {D : Category o₁ ℓ₁ e₁} {F : Functor D C} {G : Functor C D} → Setoid (o ⊔ ℓ ⊔ e ⊔ o₁ ⊔ ℓ₁ ⊔ e₁) (o ⊔ e ⊔ o₁ ⊔ e₁) setoid {C = C} {D} {F} {G} = record { Carrier = Adjunction F G ; _≈_ = _≡_ ; isEquivalence = equiv {F = F} {G = G} }
{ "alphanum_fraction": 0.5320571956, "avg_line_length": 34.688, "ext": "agda", "hexsha": "7d7fdca14f9df0bb002dcbbfba0a9ed3b50da017", "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": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "p-pavel/categories", "max_forks_repo_path": "Categories/Adjunction.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2", "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": "p-pavel/categories", "max_issues_repo_path": "Categories/Adjunction.agda", "max_line_length": 156, "max_stars_count": 1, "max_stars_repo_head_hexsha": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "p-pavel/categories", "max_stars_repo_path": "Categories/Adjunction.agda", "max_stars_repo_stars_event_max_datetime": "2018-12-29T21:51:57.000Z", "max_stars_repo_stars_event_min_datetime": "2018-12-29T21:51:57.000Z", "num_tokens": 1847, "size": 4336 }
{-# OPTIONS --safe --warning=error --without-K --guardedness #-} open import Agda.Primitive using (Level; lzero; lsuc; _⊔_) open import Setoids.Setoids open import Rings.Definition open import Rings.Lemmas open import Rings.Orders.Partial.Definition open import Rings.Orders.Total.Definition open import Groups.Definition open import Groups.Lemmas open import Fields.Fields open import Sets.EquivalenceRelations open import Sequences open import Setoids.Orders.Partial.Definition open import Setoids.Orders.Total.Definition open import Functions.Definition open import LogicalFormulae open import Numbers.Naturals.Semiring open import Numbers.Naturals.Order open import Semirings.Definition module Fields.CauchyCompletion.Setoid {m n o : _} {A : Set m} {S : Setoid {m} {n} A} {_+_ : A → A → A} {_*_ : A → A → A} {_<_ : Rel {m} {o} A} {pOrder : SetoidPartialOrder S _<_} {R : Ring S _+_ _*_} {pRing : PartiallyOrderedRing R pOrder} (order : TotallyOrderedRing pRing) (F : Field R) where open Setoid S open SetoidTotalOrder (TotallyOrderedRing.total order) open SetoidPartialOrder pOrder open Equivalence eq open PartiallyOrderedRing pRing open Ring R open Group additiveGroup open Field F open import Fields.Lemmas F open import Fields.CauchyCompletion.Definition order F open import Fields.CauchyCompletion.Addition order F open import Rings.Orders.Partial.Lemmas pRing open import Rings.Orders.Total.Lemmas order open import Rings.Orders.Total.AbsoluteValue order open import Rings.InitialRing R open import Fields.Orders.Total.Lemmas {F = F} (record { oRing = order }) isZero : CauchyCompletion → Set (m ⊔ o) isZero record { elts = elts ; converges = converges } = ∀ ε → 0R < ε → Sg ℕ (λ N → ∀ {m : ℕ} → (N <N m) → (abs (index elts m)) < ε) private transitiveLemma : {a b c e/2 : A} → abs (a + inverse b) < e/2 → abs (b + inverse c) < e/2 → (abs (a + inverse c)) < (e/2 + e/2) transitiveLemma {a} {b} {c} {e/2} a-b<e/2 b-c<e/2 with triangleInequality (a + inverse b) (b + inverse c) transitiveLemma {a} {b} {c} {e/2} a-b<e/2 b-c<e/2 | inl x = SetoidPartialOrder.<Transitive pOrder (<WellDefined (absWellDefined _ _ (Equivalence.transitive eq (Equivalence.symmetric eq +Associative) (+WellDefined (Equivalence.reflexive eq) (Equivalence.transitive eq +Associative (Equivalence.transitive eq (+WellDefined invLeft (Equivalence.reflexive eq)) identLeft))))) (Equivalence.reflexive eq) x) (ringAddInequalities a-b<e/2 b-c<e/2) transitiveLemma {a} {b} {c} {e/2} a-b<e/2 b-c<e/2 | inr x = <WellDefined (Equivalence.symmetric eq (Equivalence.transitive eq (absWellDefined _ _ (Equivalence.symmetric eq ((Equivalence.transitive eq (Equivalence.symmetric eq +Associative) (+WellDefined (Equivalence.reflexive eq) (Equivalence.transitive eq +Associative (Equivalence.transitive eq (+WellDefined invLeft (Equivalence.reflexive eq)) identLeft))))))) x)) (Equivalence.reflexive eq) (ringAddInequalities a-b<e/2 b-c<e/2) cauchyCompletionSetoid : Setoid CauchyCompletion (cauchyCompletionSetoid Setoid.∼ a) b = isZero (a +C (-C b)) Equivalence.reflexive (Setoid.eq cauchyCompletionSetoid) {x} ε 0<e = 0 , t where t : {m : ℕ} → (0 <N m) → abs (index (apply _+_ (CauchyCompletion.elts x) (map inverse (CauchyCompletion.elts x))) m) < ε t {m} 0<m rewrite indexAndApply (CauchyCompletion.elts x) (map inverse (CauchyCompletion.elts x)) _+_ {m} | equalityCommutative (mapAndIndex (CauchyCompletion.elts x) inverse m) = <WellDefined (Equivalence.symmetric eq (Equivalence.transitive eq (absWellDefined _ _ invRight) (identityOfIndiscernablesRight _∼_ (Equivalence.reflexive eq) absZero))) (Equivalence.reflexive eq) 0<e Equivalence.symmetric (Setoid.eq cauchyCompletionSetoid) {x} {y} x=y ε 0<e with x=y ε 0<e Equivalence.symmetric (Setoid.eq cauchyCompletionSetoid) {x} {y} x=y ε 0<e | N , pr = N , t where t : {m : ℕ} → N <N m → abs (index (apply _+_ (CauchyCompletion.elts y) (map inverse (CauchyCompletion.elts x))) m) < ε t {m} N<m = <WellDefined (Equivalence.transitive eq (absNegation _) (absWellDefined _ _ (identityOfIndiscernablesRight _∼_ (identityOfIndiscernablesLeft _∼_ (identityOfIndiscernablesLeft _∼_ (Equivalence.transitive eq (inverseDistributes) (Equivalence.transitive eq groupIsAbelian (+WellDefined (Equivalence.transitive eq (inverseWellDefined additiveGroup (identityOfIndiscernablesLeft _∼_ (Equivalence.reflexive eq) (mapAndIndex _ inverse m))) (invTwice additiveGroup (index (CauchyCompletion.elts y) m))) (identityOfIndiscernablesLeft _∼_ (Equivalence.reflexive eq) (equalityCommutative (mapAndIndex (CauchyCompletion.elts x) inverse m)))))) (equalityCommutative (mapAndApply (CauchyCompletion.elts x) (map inverse (CauchyCompletion.elts y)) _+_ inverse m))) (equalityCommutative (mapAndIndex _ inverse m))) (equalityCommutative (indexAndApply (CauchyCompletion.elts y) (map inverse (CauchyCompletion.elts x)) _+_ {m}))))) (Equivalence.reflexive eq) (pr N<m) Equivalence.transitive (Setoid.eq cauchyCompletionSetoid) {x} {y} {z} x=y y=z ε 0<e with halve charNot2 ε ... | e/2 , prHalf with x=y e/2 (halvePositive e/2 (<WellDefined (Equivalence.reflexive eq) (Equivalence.symmetric eq prHalf) 0<e)) ... | Nx , prX with y=z e/2 (halvePositive e/2 (<WellDefined (Equivalence.reflexive eq) (Equivalence.symmetric eq prHalf) 0<e)) ... | Ny , prY = (Nx +N Ny) , t where t : {m : ℕ} → (Nx +N Ny <N m) → abs (index (apply _+_ (CauchyCompletion.elts x) (map inverse (CauchyCompletion.elts z))) m) < ε t {m} nsPr with prX {m} (le (_<N_.x nsPr +N Ny) (transitivity (applyEquality succ (transitivity (equalityCommutative (Semiring.+Associative ℕSemiring _ Ny Nx)) (applyEquality ( λ i → (_<N_.x nsPr) +N i) (Semiring.commutative ℕSemiring Ny Nx)))) (_<N_.proof nsPr))) ... | x-y<e/2 with prY {m} (le (_<N_.x nsPr +N Nx) (transitivity (applyEquality succ (equalityCommutative (Semiring.+Associative ℕSemiring _ Nx Ny))) (_<N_.proof nsPr))) ... | y-z<e/2 rewrite indexAndApply (CauchyCompletion.elts x) (map inverse (CauchyCompletion.elts z)) _+_ {m} | indexAndApply (CauchyCompletion.elts x) (map inverse (CauchyCompletion.elts y)) _+_ {m} | indexAndApply (CauchyCompletion.elts y) (map inverse (CauchyCompletion.elts z)) _+_ {m} | equalityCommutative (mapAndIndex (CauchyCompletion.elts z) inverse m) | equalityCommutative (mapAndIndex (CauchyCompletion.elts y) inverse m) = <WellDefined (Equivalence.reflexive eq) prHalf (transitiveLemma x-y<e/2 y-z<e/2) injectionPreservesSetoid : (a b : A) → (a ∼ b) → Setoid._∼_ cauchyCompletionSetoid (injection a) (injection b) injectionPreservesSetoid a b a=b ε 0<e = 0 , t where t : {m : ℕ} → 0 <N m → abs (index (apply _+_ (constSequence a) (map inverse (constSequence b))) m) < ε t {m} 0<m = <WellDefined (identityOfIndiscernablesLeft _∼_ (absWellDefined 0G _ (identityOfIndiscernablesRight _∼_ (Equivalence.transitive eq (Equivalence.symmetric eq (transferToRight'' additiveGroup a=b)) (+WellDefined (identityOfIndiscernablesLeft _∼_ (Equivalence.reflexive eq) (indexAndConst a m)) (identityOfIndiscernablesRight _∼_ (Equivalence.reflexive eq) (transitivity (applyEquality inverse (equalityCommutative (indexAndConst _ m))) (mapAndIndex _ inverse m))))) (equalityCommutative (indexAndApply (constSequence a) _ _+_ {m})))) absZero) (Equivalence.reflexive eq) 0<e infinitesimalImplies0 : (a : A) → ({ε : A} → (0R < ε) → a < ε) → (a ∼ 0R) || (a < 0R) infinitesimalImplies0 a pr with totality 0R a infinitesimalImplies0 a pr | inl (inl 0<a) with halve charNot2 a infinitesimalImplies0 a pr | inl (inl 0<a) | a/2 , prA/2 with pr {a/2} (halvePositive a/2 (<WellDefined (Equivalence.reflexive eq) (Equivalence.symmetric eq prA/2) 0<a)) ... | bl with halvePositive a/2 (<WellDefined (Equivalence.reflexive eq) (Equivalence.symmetric eq prA/2) 0<a) ... | 0<a/2 = exFalso (irreflexive {a} (<WellDefined identLeft prA/2 (ringAddInequalities 0<a/2 bl))) infinitesimalImplies0 a pr | inl (inr a<0) = inr a<0 infinitesimalImplies0 a pr | inr 0=a = inl (Equivalence.symmetric eq 0=a) injectionPreservesSetoid' : (a b : A) → Setoid._∼_ cauchyCompletionSetoid (injection a) (injection b) → a ∼ b injectionPreservesSetoid' a b a=b = transferToRight additiveGroup (absZeroImpliesZero ans) where infinitesimal : {ε : A} → 0G < ε → abs (a + inverse b) < ε infinitesimal {ε} 0<e with a=b ε 0<e ... | N , pr with pr {succ N} (le 0 refl) ... | bl rewrite indexAndApply (constSequence a) (map inverse (constSequence b)) _+_ {N} | indexAndConst a N | equalityCommutative (mapAndIndex (constSequence b) inverse N) | indexAndConst b N = bl ans : (abs (a + inverse b)) ∼ 0G ans with infinitesimalImplies0 _ infinitesimal ... | inl x = x ... | inr x = exFalso (absNonnegative x) CInjection : SetoidInjection S cauchyCompletionSetoid injection SetoidInjection.wellDefined CInjection {x} {y} x=y = injectionPreservesSetoid x y x=y SetoidInjection.injective CInjection {x} {y} x=y = injectionPreservesSetoid' x y x=y trivialIfInputTrivial : (0R ∼ 1R) → (a : CauchyCompletion) → Setoid._∼_ cauchyCompletionSetoid (injection 0R) a trivialIfInputTrivial 0=1 a ε 0<e = exFalso (irreflexive {0G} (<WellDefined (Equivalence.reflexive eq) (oneZeroImpliesAllZero R 0=1) 0<e))
{ "alphanum_fraction": 0.7350185226, "avg_line_length": 87.4095238095, "ext": "agda", "hexsha": "304ed5d1d42d3a9b7c081a1ea154ca29ee66e1ad", "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": "Fields/CauchyCompletion/Setoid.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": "Fields/CauchyCompletion/Setoid.agda", "max_line_length": 964, "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": "Fields/CauchyCompletion/Setoid.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": 3053, "size": 9178 }
{-# OPTIONS --safe --warning=error --without-K #-} open import Agda.Primitive using (Level; lzero; lsuc; _⊔_) open import LogicalFormulae open import Functions.Definition open import Numbers.Naturals.Definition open import Numbers.Naturals.Order open import Sets.FinSet.Definition open import Sets.FinSet.Lemmas open import Setoids.Setoids open import Setoids.Cardinality.Infinite.Definition open import Sets.Cardinality.Infinite.Lemmas open import Setoids.Subset open import Sets.EquivalenceRelations module Setoids.Cardinality.Infinite.Lemmas where finsetNotInfiniteSetoid : {n : ℕ} → InfiniteSetoid (reflSetoid (FinSet n)) → False finsetNotInfiniteSetoid {n} isInfinite = isInfinite n id (record { inj = record { wellDefined = id ; injective = id } ; surj = record { wellDefined = id ; surjective = λ {x} → x , refl } }) dedekindInfiniteImpliesInfiniteSetoid : {a b : _} {A : Set a} (S : Setoid {a} {b} A) → DedekindInfiniteSetoid S → InfiniteSetoid S dedekindInfiniteImpliesInfiniteSetoid S record { inj = inj ; isInjection = isInj } zero f isBij with SetoidInvertible.inverse (setoidBijectiveImpliesInvertible isBij) (inj 0) ... | () dedekindInfiniteImpliesInfiniteSetoid {A = A} S record { inj = inj ; isInjection = isInj } (succ n) f isBij = noInjectionNToFinite {f = t} tInjective where t : ℕ → FinSet (succ n) t n = SetoidInvertible.inverse (setoidBijectiveImpliesInvertible isBij) (inj n) tInjective : Injection t tInjective pr = SetoidInjection.injective isInj (SetoidInjection.injective (SetoidBijection.inj (setoidInvertibleImpliesBijective (inverseInvertible (setoidBijectiveImpliesInvertible isBij)))) pr)
{ "alphanum_fraction": 0.7723676202, "avg_line_length": 54.7666666667, "ext": "agda", "hexsha": "1b73c694290d1618e51c1cbd81ade4f211038340", "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": "Setoids/Cardinality/Infinite/Lemmas.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": "Setoids/Cardinality/Infinite/Lemmas.agda", "max_line_length": 200, "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": "Setoids/Cardinality/Infinite/Lemmas.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": 497, "size": 1643 }
module SystemF.BigStep.Extrinsic.Semantics where open import Prelude hiding (⊥; id) open import Function as Fun using () open import Data.List hiding ([_]; monad) open import Data.List.Properties as ListProp using () open import Data.Fin.Substitution open import Extensions.List open import SystemF.BigStep.Types open import SystemF.BigStep.Extrinsic.Terms open import SystemF.BigStep.Extrinsic.Welltyped -- environments mutual Env : Set Env = List Val data Val : Set where unit : Val clos : Env → (t : Term) → Val tclos : Env → (t : Term) → Val open import Relation.Binary.List.Pointwise hiding (refl; map) mutual -- welltypedness relations between typing contexts and environmets -- is just the pointwise extension of value-welltypedness _⊢_ : ∀ {n} → Ctx n → Env → Set Γ ⊢ E = Rel (λ{ a v → ⊢̬ v ∶ a}) Γ E data ⊢̬_∶_ {n} : Val → Type n → Set where unit : ------------------- ⊢̬ unit ∶ Unit clos : ∀ {b t}{Γ : Ctx n}{E a} → (a ∷ Γ) ⊢ t ∶ b → Γ ⊢ E → ------------------- ⊢̬ clos E t ∶ (a ⇒ b) tclos : ∀ {a t}{Γ : Ctx n}{E} → (Γ ctx/ wk) ⊢ t ∶ a → Γ ⊢ E → --------------------- ⊢̬ tclos E t ∶ ∀' a module UglyBits where _wt/_ : ∀ {n m}{Γ : Ctx n}{t a} → Γ ⊢ t ∶ a → (ρ : Sub Type n m) → (Γ ctx/ ρ) ⊢ t ∶ (a / ρ) unit wt/ ρ = unit ƛ a t wt/ ρ = ƛ (a / ρ) (t wt/ ρ) var x wt/ ρ = var ([]=-map x) (f · e) wt/ ρ = (f wt/ ρ) · (e wt/ ρ) Λ t wt/ ρ = Λ (subst (λ Γ → Γ ⊢ _ ∶ _) (sym $ CtxLemmas.ctx/-wk-comm _ ρ) (t wt/ (ρ ↑))) (_[_] {a = a} t b) wt/ ρ = subst (λ a → _ ⊢ _ ∶ a) (sym $ Lemmas.sub-commutes a) ((t wt/ ρ) [ (b / ρ) ]) module StepIndexed where open UglyBits open import Level as Lev using () open import Data.Maybe open import Category.Monad open RawMonad (monad {f = Lev.zero}) -- quadratic return through the layered monad pattern just² x = just (just x) -- substitution-free semantics in double-layered maybe monad; -- distinguishing semantic errors from timeouts _⊢_⇓_ : ∀ (μ : Env) → Term → ℕ → Maybe (Maybe Val) μ ⊢ x ⇓ zero = nothing μ ⊢ unit ⇓ (suc n) = just² unit μ ⊢ ƛ t ⇓ (suc n) = just² (clos μ t) μ ⊢ Λ t ⇓ (suc n) = just² (tclos μ t ) μ ⊢ f · e ⇓ (suc n) with (μ ⊢ f ⇓ n) | μ ⊢ e ⇓ n -- timeout ... | nothing | _ = nothing ... | _ | nothing = nothing -- success ... | just² (clos μ' t) | just² v = (v ∷ μ') ⊢ t ⇓ n -- semantic errors & semantic error propagation ... | _ | _ = just nothing μ ⊢ t [-] ⇓ (suc n) with (μ ⊢ t ⇓ n) -- timeout ... | nothing = nothing -- success ... | just² (tclos μ' t') = μ' ⊢ t' ⇓ n -- semantic error (propagation) ... | _ = just nothing μ ⊢ var x ⇓ (suc n) = just (maybe-lookup x μ) -- extrinsic safety _⊢_⇓_ok : ∀ {n}{Γ : Ctx n}{μ : Env}{t a} → Γ ⊢ μ → Γ ⊢ t ∶ a → ∀ n → All (Any (λ v → ⊢̬ v ∶ a)) (μ ⊢ t ⇓ n) μ ⊢ x ⇓ zero ok = nothing μ ⊢ unit ⇓ suc n ok = just² unit μ ⊢ ƛ a x ⇓ suc n ok = just² (clos x μ) μ ⊢ Λ x ⇓ suc n ok = just² (tclos x μ) _⊢_⇓_ok {μ = E} μ (_·_ {f = f}{e = e} wtf wte) (suc n) with E ⊢ f ⇓ n | E ⊢ e ⇓ n | μ ⊢ wtf ⇓ n ok | μ ⊢ wte ⇓ n ok -- timeout ... | nothing | _ | _ | _ = nothing ... | just _ | nothing | _ | _ = nothing -- success ... | just² (clos μ' t) | just² v | just² (clos wtt wtμ') | just² px = (px ∷ wtμ') ⊢ wtt ⇓ n ok -- semantic error propagation ... | just nothing | _ | (just ()) | _ ... | _ | just nothing | _ | (just ()) -- semantic errors ... | just² (tclos _ _) | _ | just² () | _ ... | just² unit | _ | just² () | _ _⊢_⇓_ok {μ = E} μ (_[_] {f = f} wtf b) (suc n) with E ⊢ f ⇓ n | μ ⊢ wtf ⇓ n ok -- timeout ... | nothing | _ = nothing -- semantic errors ... | just nothing | (just ()) ... | just² unit | just² () ... | just² (clos x t) | just² () -- success ... | just² (tclos μ' t) | just² (tclos tok μ'ok) = μ'ok ⊢ subst (λ Γ → Γ ⊢ _ ∶ _) (CtxLemmas.ctx/-wk-sub≡id _ b) (tok wt/ (sub b)) ⇓ n ok μ ⊢ var x ⇓ suc n ok with pointwise-maybe-lookup μ x μ ⊢ var x ⇓ suc n ok | _ , is-just , p rewrite is-just = just² p module DelayMonad where open import Coinduction open import Category.Monad.Partiality open import Data.Maybe module _ where open Workaround _⊢lookup_ : Env → ℕ → Maybe Val [] ⊢lookup n = nothing (x ∷ μ) ⊢lookup zero = just x (x ∷ μ) ⊢lookup suc n = μ ⊢lookup n ret : ∀ {a} {A : Set a} → A → (Maybe A) ⊥P ret x = now (just x) -- substitution free semantics for SystemF _⊢_⇓P : ∀ (μ : Env) → Term → (Maybe Val) ⊥P μ ⊢ unit ⇓P = ret unit μ ⊢ ƛ t ⇓P = ret (clos μ t) μ ⊢ Λ t ⇓P = ret (tclos μ t ) μ ⊢ f · e ⇓P = μ ⊢ f ⇓P >>= λ{ (just (clos μ' t)) → μ ⊢ e ⇓P >>= (λ{ (just v) → later (♯ ((v ∷ μ') ⊢ t ⇓P)) ; nothing → now nothing }) ; _ → now nothing } μ ⊢ t [-] ⇓P = μ ⊢ t ⇓P >>= λ{ (just (tclos μ' t')) → later (♯ (μ' ⊢ t' ⇓P)) ; _ → now nothing } μ ⊢ var x ⇓P = now (μ ⊢lookup x) _⊢_⇓ : ∀ (μ : Env) → Term → (Maybe Val) ⊥ μ ⊢ t ⇓ = ⟦ μ ⊢ t ⇓P ⟧P {-} open import Category.Monad.Partiality.All open Alternative {-} module Compositional where private module Eq = Equality (_≡_) open import Level as Level open import Category.Monad open Eq hiding (_⇓) open RawMonad (monad {f = Level.zero}) _·⇓_ : ∀ (f e : Val ⊥) → Val ⊥ f ·⇓ e = f >>= λ{ (clos x t) → {!!} ; _ → now error } ·-comp : ∀ {μ f e} → (μ ⊢ f · e ⇓) ≅ ((μ ⊢ f ⇓) ·⇓ (μ ⊢ e ⇓)) ·-comp = {!!} -} module Safety where _⊢_⇓okP : ∀ {n}{Γ : Ctx n}{μ : Env}{t a} → Γ ⊢ μ → Γ ⊢ t ∶ a → AllP (λ v → ⊢̬ v ∶ a) (μ ⊢ t ⇓) μ ⊢ unit ⇓okP = now unit μ ⊢ ƛ a t₁ ⇓okP = now (clos t₁ μ) μ ⊢ var x ⇓okP = now {!!} μ ⊢ f · e ⇓okP = {!μ ⊢ f ⇓okP!} μ ⊢ Λ t₁ ⇓okP = {!!} μ ⊢ t [ b ] ⇓okP = {!!} -}
{ "alphanum_fraction": 0.5016891892, "avg_line_length": 28.5990338164, "ext": "agda", "hexsha": "46fb737ffaecbb4074808f8f994255047d5767bd", "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/SystemF/BigStep/Extrinsic/Semantics.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/SystemF/BigStep/Extrinsic/Semantics.agda", "max_line_length": 98, "max_stars_count": null, "max_stars_repo_head_hexsha": "7fe638b87de26df47b6437f5ab0a8b955384958d", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "metaborg/ts.agda", "max_stars_repo_path": "src/SystemF/BigStep/Extrinsic/Semantics.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 2424, "size": 5920 }
{-# OPTIONS --allow-unsolved-metas #-} open import Level open import Ordinals module ODUtil {n : Level } (O : Ordinals {n} ) where open import zf open import Data.Nat renaming ( zero to Zero ; suc to Suc ; ℕ to Nat ; _⊔_ to _n⊔_ ) open import Relation.Binary.PropositionalEquality hiding ( [_] ) open import Data.Nat.Properties open import Data.Empty open import Relation.Nullary open import Relation.Binary hiding ( _⇔_ ) open import logic open import nat open Ordinals.Ordinals O open Ordinals.IsOrdinals isOrdinal open Ordinals.IsNext isNext import OrdUtil open OrdUtil O import OD open OD O open OD.OD open ODAxiom odAxiom open HOD open _⊆_ open _∧_ open _==_ cseq : HOD → HOD cseq x = record { od = record { def = λ y → odef x (osuc y) } ; odmax = osuc (odmax x) ; <odmax = lemma } where lemma : {y : Ordinal} → def (od x) (osuc y) → y o< osuc (odmax x) lemma {y} lt = ordtrans <-osuc (ordtrans (<odmax x lt) <-osuc ) pair-xx<xy : {x y : HOD} → & (x , x) o< osuc (& (x , y) ) pair-xx<xy {x} {y} = ⊆→o≤ lemma where lemma : {z : Ordinal} → def (od (x , x)) z → def (od (x , y)) z lemma {z} (case1 refl) = case1 refl lemma {z} (case2 refl) = case1 refl pair-<xy : {x y : HOD} → {n : Ordinal} → & x o< next n → & y o< next n → & (x , y) o< next n pair-<xy {x} {y} {o} x<nn y<nn with trio< (& x) (& y) | inspect (omax (& x)) (& y) ... | tri< a ¬b ¬c | record { eq = eq1 } = next< (subst (λ k → k o< next o ) (sym eq1) (osuc<nx y<nn)) ho< ... | tri> ¬a ¬b c | record { eq = eq1 } = next< (subst (λ k → k o< next o ) (sym eq1) (osuc<nx x<nn)) ho< ... | tri≈ ¬a b ¬c | record { eq = eq1 } = next< (subst (λ k → k o< next o ) (omax≡ _ _ b) (subst (λ k → osuc k o< next o) b (osuc<nx x<nn))) ho< -- another form of infinite -- pair-ord< : {x : Ordinal } → Set n pair-ord< : {x : HOD } → ( {y : HOD } → & y o< next (odmax y) ) → & ( x , x ) o< next (& x) pair-ord< {x} ho< = subst (λ k → & (x , x) o< k ) lemmab0 lemmab1 where lemmab0 : next (odmax (x , x)) ≡ next (& x) lemmab0 = trans (cong (λ k → next k) (omxx _)) (sym nexto≡) lemmab1 : & (x , x) o< next ( odmax (x , x)) lemmab1 = ho< trans-⊆ : { A B C : HOD} → A ⊆ B → B ⊆ C → A ⊆ C trans-⊆ A⊆B B⊆C = record { incl = λ x → incl B⊆C (incl A⊆B x) } refl-⊆ : {A : HOD} → A ⊆ A refl-⊆ {A} = record { incl = λ x → x } od⊆→o≤ : {x y : HOD } → x ⊆ y → & x o< osuc (& y) od⊆→o≤ {x} {y} lt = ⊆→o≤ {x} {y} (λ {z} x>z → subst (λ k → def (od y) k ) &iso (incl lt (d→∋ x x>z))) subset-lemma : {A x : HOD } → ( {y : HOD } → x ∋ y → (A ∩ x ) ∋ y ) ⇔ ( x ⊆ A ) subset-lemma {A} {x} = record { proj1 = λ lt → record { incl = λ x∋z → proj1 (lt x∋z) } ; proj2 = λ x⊆A lt → ⟪ incl x⊆A lt , lt ⟫ } ω<next-o∅ : {y : Ordinal} → infinite-d y → y o< next o∅ ω<next-o∅ {y} lt = <odmax infinite lt nat→ω : Nat → HOD nat→ω Zero = od∅ nat→ω (Suc y) = Union (nat→ω y , (nat→ω y , nat→ω y)) ω→nato : {y : Ordinal} → infinite-d y → Nat ω→nato iφ = Zero ω→nato (isuc lt) = Suc (ω→nato lt) ω→nat : (n : HOD) → infinite ∋ n → Nat ω→nat n = ω→nato ω∋nat→ω : {n : Nat} → def (od infinite) (& (nat→ω n)) ω∋nat→ω {Zero} = subst (λ k → def (od infinite) k) (sym ord-od∅) iφ ω∋nat→ω {Suc n} = subst (λ k → def (od infinite) k) lemma (isuc ( ω∋nat→ω {n})) where lemma : & (Union (* (& (nat→ω n)) , (* (& (nat→ω n)) , * (& (nat→ω n))))) ≡ & (nat→ω (Suc n)) lemma = subst (λ k → & (Union (k , ( k , k ))) ≡ & (nat→ω (Suc n))) (sym *iso) refl pair1 : { x y : HOD } → (x , y ) ∋ x pair1 = case1 refl pair2 : { x y : HOD } → (x , y ) ∋ y pair2 = case2 refl single : {x y : HOD } → (x , x ) ∋ y → x ≡ y single (case1 eq) = ==→o≡ ( ord→== (sym eq) ) single (case2 eq) = ==→o≡ ( ord→== (sym eq) ) open import Relation.Binary.HeterogeneousEquality as HE using (_≅_ ) -- postulate f-extensionality : { n m : Level} → HE.Extensionality n m ω-prev-eq1 : {x y : Ordinal} → & (Union (* y , (* y , * y))) ≡ & (Union (* x , (* x , * x))) → ¬ (x o< y) ω-prev-eq1 {x} {y} eq x<y = eq→ (ord→== eq) {& (* y)} (λ not2 → not2 (& (* y , * y)) ⟪ case2 refl , subst (λ k → odef k (& (* y))) (sym *iso) (case1 refl)⟫ ) (λ u → lemma u ) where lemma : (u : Ordinal) → ¬ def (od (* x , (* x , * x))) u ∧ def (od (* u)) (& (* y)) lemma u t with proj1 t lemma u t | case1 u=x = o<> (c<→o< {* y} {* u} (proj2 t)) (subst₂ (λ j k → j o< k ) (trans (sym &iso) (trans (sym u=x) (sym &iso)) ) (sym &iso) x<y ) -- x ≡ & (* u) lemma u t | case2 u=xx = o<¬≡ (lemma1 (subst (λ k → odef k (& (* y)) ) (trans (cong (λ k → * k ) u=xx) *iso ) (proj2 t))) x<y where lemma1 : {x y : Ordinal } → (* x , * x ) ∋ * y → x ≡ y -- y = x ∈ ( x , x ) = u lemma1 (case1 eq) = subst₂ (λ j k → j ≡ k ) &iso &iso (sym eq) lemma1 (case2 eq) = subst₂ (λ j k → j ≡ k ) &iso &iso (sym eq) ω-prev-eq : {x y : Ordinal} → & (Union (* y , (* y , * y))) ≡ & (Union (* x , (* x , * x))) → x ≡ y ω-prev-eq {x} {y} eq with trio< x y ω-prev-eq {x} {y} eq | tri< a ¬b ¬c = ⊥-elim (ω-prev-eq1 eq a) ω-prev-eq {x} {y} eq | tri≈ ¬a b ¬c = b ω-prev-eq {x} {y} eq | tri> ¬a ¬b c = ⊥-elim (ω-prev-eq1 (sym eq) c) ω-∈s : (x : HOD) → Union ( x , (x , x)) ∋ x ω-∈s x not = not (& (x , x)) ⟪ case2 refl , subst (λ k → odef k (& x) ) (sym *iso) (case1 refl) ⟫ ωs≠0 : (x : HOD) → ¬ ( Union ( x , (x , x)) ≡ od∅ ) ωs≠0 y eq = ⊥-elim ( ¬x<0 (subst (λ k → & y o< k ) ord-od∅ (c<→o< (subst (λ k → odef k (& y )) eq (ω-∈s y) ))) ) nat→ω-iso : {i : HOD} → (lt : infinite ∋ i ) → nat→ω ( ω→nat i lt ) ≡ i nat→ω-iso {i} = ε-induction {λ i → (lt : infinite ∋ i ) → nat→ω ( ω→nat i lt ) ≡ i } ind i where ind : {x : HOD} → ({y : HOD} → x ∋ y → (lt : infinite ∋ y) → nat→ω (ω→nat y lt) ≡ y) → (lt : infinite ∋ x) → nat→ω (ω→nat x lt) ≡ x ind {x} prev lt = ind1 lt *iso where ind1 : {ox : Ordinal } → (ltd : infinite-d ox ) → * ox ≡ x → nat→ω (ω→nato ltd) ≡ x ind1 {o∅} iφ refl = sym o∅≡od∅ ind1 (isuc {x₁} ltd) ox=x = begin nat→ω (ω→nato (isuc ltd) ) ≡⟨⟩ Union (nat→ω (ω→nato ltd) , (nat→ω (ω→nato ltd) , nat→ω (ω→nato ltd))) ≡⟨ cong (λ k → Union (k , (k , k ))) lemma ⟩ Union (* x₁ , (* x₁ , * x₁)) ≡⟨ trans ( sym *iso) ox=x ⟩ x ∎ where open ≡-Reasoning lemma0 : x ∋ * x₁ lemma0 = subst (λ k → odef k (& (* x₁))) (trans (sym *iso) ox=x) (λ not → not (& (* x₁ , * x₁)) ⟪ pair2 , subst (λ k → odef k (& (* x₁))) (sym *iso) pair1 ⟫ ) lemma1 : infinite ∋ * x₁ lemma1 = subst (λ k → odef infinite k) (sym &iso) ltd lemma3 : {x y : Ordinal} → (ltd : infinite-d x ) (ltd1 : infinite-d y ) → y ≡ x → ltd ≅ ltd1 lemma3 iφ iφ refl = HE.refl lemma3 iφ (isuc {y} ltd1) eq = ⊥-elim ( ¬x<0 (subst₂ (λ j k → j o< k ) &iso eq (c<→o< (ω-∈s (* y)) ))) lemma3 (isuc {y} ltd) iφ eq = ⊥-elim ( ¬x<0 (subst₂ (λ j k → j o< k ) &iso (sym eq) (c<→o< (ω-∈s (* y)) ))) lemma3 (isuc {x} ltd) (isuc {y} ltd1) eq with lemma3 ltd ltd1 (ω-prev-eq (sym eq)) ... | t = HE.cong₂ (λ j k → isuc {j} k ) (HE.≡-to-≅ (ω-prev-eq eq)) t lemma2 : {x y : Ordinal} → (ltd : infinite-d x ) (ltd1 : infinite-d y ) → y ≡ x → ω→nato ltd ≡ ω→nato ltd1 lemma2 {x} {y} ltd ltd1 eq = lemma6 eq (lemma3 {x} {y} ltd ltd1 eq) where lemma6 : {x y : Ordinal} → {ltd : infinite-d x } {ltd1 : infinite-d y } → y ≡ x → ltd ≅ ltd1 → ω→nato ltd ≡ ω→nato ltd1 lemma6 refl HE.refl = refl lemma : nat→ω (ω→nato ltd) ≡ * x₁ lemma = trans (cong (λ k → nat→ω k) (lemma2 {x₁} {_} ltd (subst (λ k → infinite-d k ) (sym &iso) ltd) &iso ) ) ( prev {* x₁} lemma0 lemma1 ) ω→nat-iso : {i : Nat} → ω→nat ( nat→ω i ) (ω∋nat→ω {i}) ≡ i ω→nat-iso {i} = lemma i (ω∋nat→ω {i}) *iso where lemma : {x : Ordinal } → ( i : Nat ) → (ltd : infinite-d x ) → * x ≡ nat→ω i → ω→nato ltd ≡ i lemma {x} Zero iφ eq = refl lemma {x} (Suc i) iφ eq = ⊥-elim ( ωs≠0 (nat→ω i) (trans (sym eq) o∅≡od∅ )) -- Union (nat→ω i , (nat→ω i , nat→ω i)) ≡ od∅ lemma Zero (isuc {x} ltd) eq = ⊥-elim ( ωs≠0 (* x) (subst (λ k → k ≡ od∅ ) *iso eq )) lemma (Suc i) (isuc {x} ltd) eq = cong (λ k → Suc k ) (lemma i ltd (lemma1 eq) ) where -- * x ≡ nat→ω i lemma1 : * (& (Union (* x , (* x , * x)))) ≡ Union (nat→ω i , (nat→ω i , nat→ω i)) → * x ≡ nat→ω i lemma1 eq = subst (λ k → * x ≡ k ) *iso (cong (λ k → * k) ( ω-prev-eq (subst (λ k → _ ≡ k ) &iso (cong (λ k → & k ) (sym (subst (λ k → _ ≡ Union ( k , ( k , k ))) (sym *iso ) eq ))))))
{ "alphanum_fraction": 0.4753037357, "avg_line_length": 48.9277777778, "ext": "agda", "hexsha": "f2201ab226fc431f31e91b94ebab871b10912796", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "031f1ea3a3037cd51eb022dbfb5c75b037bf8aa0", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "shinji-kono/zf-in-agda", "max_forks_repo_path": "src/ODUtil.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "031f1ea3a3037cd51eb022dbfb5c75b037bf8aa0", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "shinji-kono/zf-in-agda", "max_issues_repo_path": "src/ODUtil.agda", "max_line_length": 159, "max_stars_count": 5, "max_stars_repo_head_hexsha": "031f1ea3a3037cd51eb022dbfb5c75b037bf8aa0", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "shinji-kono/zf-in-agda", "max_stars_repo_path": "src/ODUtil.agda", "max_stars_repo_stars_event_max_datetime": "2021-01-10T13:27:48.000Z", "max_stars_repo_stars_event_min_datetime": "2019-10-02T13:46:23.000Z", "num_tokens": 3838, "size": 8807 }
{-# OPTIONS --sized-types #-} module SNat.Order.Properties where open import Data.Sum renaming (_⊎_ to _∨_) open import Relation.Binary.PropositionalEquality open import Size open import SNat open import SNat.Order tot≤ : {ι ι' : Size} → (m : SNat {ι}) → (n : SNat {ι'}) → m ≤ n ∨ n ≤ m tot≤ zero n = inj₁ (z≤n n) tot≤ m zero = inj₂ (z≤n m) tot≤ (succ m) (succ n) with tot≤ m n ...| inj₁ m≤n = inj₁ (s≤s m≤n) ...| inj₂ n≤m = inj₂ (s≤s n≤m) refl≤ : {n : SNat} → n ≤ n refl≤ {n} with tot≤ n n ... | inj₁ n≤n = n≤n ... | inj₂ n≤n = n≤n trans≤ : {ι ι' ι'' : Size}{n : SNat {ι}}{n' : SNat {ι'}}{n'' : SNat {ι''}} → n ≤ n' → n' ≤ n'' → n ≤ n'' trans≤ {n'' = n''} (z≤n n') _ = z≤n n'' trans≤ (s≤s n≤n') (s≤s n'≤n'') = s≤s (trans≤ n≤n' n'≤n'') refl≅ : {n : SNat} → n ≅ n refl≅ {zero} = z≅z refl≅ {succ _} = s≅s refl≅ trans≅ : {ι ι' ι'' : Size}{n : SNat {ι}}{n' : SNat {ι'}}{n'' : SNat {ι''}} → n ≅ n' → n' ≅ n'' → n ≅ n'' trans≅ z≅z z≅z = z≅z trans≅ (s≅s n≅n') (s≅s n'≅n'') = s≅s (trans≅ n≅n' n'≅n'') lemma-z≤′n : {ι ι' : Size}(n : SNat {ι}) → zero {ι'} ≤′ n lemma-z≤′n zero = ≤′-eq z≅z lemma-z≤′n (succ n) = ≤′-step (lemma-z≤′n n) lemma-s≤′s : {ι ι' : Size}{m : SNat {ι}}{n : SNat {ι'}} → m ≤′ n → succ m ≤′ succ n lemma-s≤′s (≤′-eq m≅n) = ≤′-eq (s≅s m≅n) lemma-s≤′s (≤′-step m≤′n) = ≤′-step (lemma-s≤′s m≤′n) lemma-≤-≤′ : {ι ι' : Size}{m : SNat {ι}}{n : SNat {ι'}} → m ≤ n → m ≤′ n lemma-≤-≤′ (z≤n n) = lemma-z≤′n n lemma-≤-≤′ (s≤s m≤n) = lemma-s≤′s (lemma-≤-≤′ m≤n) lemma-≅-≤ : {ι ι' : Size}{m : SNat {ι}}{n : SNat {ι'}} → m ≅ n → m ≤ n lemma-≅-≤ z≅z = z≤n zero lemma-≅-≤ (s≅s m≅n) = s≤s (lemma-≅-≤ m≅n) lemma-≡-≤′ : {a b c : SNat} → b ≡ a → a ≤′ c → b ≤′ c lemma-≡-≤′ b≡a a≤′c rewrite b≡a = a≤′c lemma-n≤sn : {ι : Size}(n : SNat {ι}) → n ≤ succ n lemma-n≤sn zero = z≤n (succ zero) lemma-n≤sn (succ n) = s≤s (lemma-n≤sn n) lemma-≤′-≤ : {ι ι' : Size}{m : SNat {ι}}{n : SNat {ι'}} → m ≤′ n → m ≤ n lemma-≤′-≤ (≤′-eq m≅n) = lemma-≅-≤ m≅n lemma-≤′-≤ (≤′-step {n = n} m≤′n) = trans≤ (lemma-≤′-≤ m≤′n) (lemma-n≤sn n) refl≤′ : {n : SNat} → n ≤′ n refl≤′ = lemma-≤-≤′ refl≤ trans≤′ : {ι ι' ι'' : Size}{n : SNat {ι}}{n' : SNat {ι'}}{n'' : SNat {ι''}} → n ≤′ n' → n' ≤′ n'' → n ≤′ n'' trans≤′ n≤′n' n'≤′n'' = lemma-≤-≤′ (trans≤ (lemma-≤′-≤ n≤′n') (lemma-≤′-≤ n'≤′n''))
{ "alphanum_fraction": 0.4554973822, "avg_line_length": 33.7058823529, "ext": "agda", "hexsha": "185ff58fbf22fac284855fa63fd4c78bb1676ae6", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "bgbianchi/sorting", "max_forks_repo_path": "agda/SNat/Order/Properties.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "bgbianchi/sorting", "max_issues_repo_path": "agda/SNat/Order/Properties.agda", "max_line_length": 109, "max_stars_count": 6, "max_stars_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "bgbianchi/sorting", "max_stars_repo_path": "agda/SNat/Order/Properties.agda", "max_stars_repo_stars_event_max_datetime": "2021-08-24T22:11:15.000Z", "max_stars_repo_stars_event_min_datetime": "2015-05-21T12:50:35.000Z", "num_tokens": 1337, "size": 2292 }
------------------------------------------------------------------------ -- Modules that can (perhaps) not be type-checked in safe mode, and -- do not use --sized-types ------------------------------------------------------------------------ {-# OPTIONS --without-K #-} module README.Unsafe where -- Strings. import String -- IO. import IO-monad
{ "alphanum_fraction": 0.3977272727, "avg_line_length": 20.7058823529, "ext": "agda", "hexsha": "d45e63e64ce8c8458bbd5b615ec6e6fb98dcf01b", "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/Unsafe.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/Unsafe.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/Unsafe.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": 56, "size": 352 }
-- Issue #1842, __IMPOSSIBLE__ showed up in debug output {-# OPTIONS -v interaction.case:65 #-} -- KEEP data Bool : Set where true false : Bool test : Bool → Bool test x = {!x!} -- C-c C-c -- Splitting here with debug output turned on -- should not crash.
{ "alphanum_fraction": 0.6641221374, "avg_line_length": 20.1538461538, "ext": "agda", "hexsha": "a2f8d07d5b77524c0b2b19da14325b4d7263931b", "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/interaction/Issue1842.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/Issue1842.agda", "max_line_length": 56, "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/Issue1842.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": 77, "size": 262 }
{-# OPTIONS --safe #-} module Cubical.Algebra.CommMonoid.CommMonoidProd where open import Cubical.Foundations.Prelude open import Cubical.Foundations.HLevels open import Cubical.Data.Sigma open import Cubical.Algebra.CommMonoid.Base open CommMonoidStr private variable ℓ ℓ' : Level CommMonoidProd : CommMonoid ℓ → CommMonoid ℓ' → CommMonoid (ℓ-max ℓ ℓ') CommMonoidProd M N = makeCommMonoid ε× _·×_ is-set× assoc× ·IdR× comm× where ε× : (fst M) × (fst N) ε× = (ε (snd M)) , (ε (snd N)) _·×_ : (fst M) × (fst N) → (fst M) × (fst N) → (fst M) × (fst N) (x₁ , x₂) ·× (y₁ , y₂) = (_·_ (snd M) x₁ y₁) , (_·_ (snd N) x₂ y₂) is-set× : isSet ((fst M) × (fst N)) is-set× = isSet× (is-set (snd M)) (is-set (snd N)) assoc× : ∀ x y z → x ·× (y ·× z) ≡ (x ·× y) ·× z assoc× _ _ _ = cong₂ (_,_) (·Assoc (snd M) _ _ _) (·Assoc (snd N) _ _ _) ·IdR× : ∀ x → x ·× ε× ≡ x ·IdR× _ = cong₂ (_,_) (·IdR (snd M) _) (·IdR (snd N) _) comm× : ∀ x y → x ·× y ≡ y ·× x comm× _ _ = cong₂ (_,_) (·Comm (snd M) _ _) (·Comm (snd N) _ _)
{ "alphanum_fraction": 0.5624404194, "avg_line_length": 27.6052631579, "ext": "agda", "hexsha": "9a73a6dbfb367b517e825b9ac607ebe43478c431", "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/CommMonoid/CommMonoidProd.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/CommMonoid/CommMonoidProd.agda", "max_line_length": 74, "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/CommMonoid/CommMonoidProd.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 445, "size": 1049 }
open import Common.Prelude test : List Char → Char test [] = 'a' test ('a' ∷ []) = 'b' -- test (c ∷ cs) = c
{ "alphanum_fraction": 0.4833333333, "avg_line_length": 15, "ext": "agda", "hexsha": "2bc8f214cc9a52933117bfb293a76e2080d17a4c", "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/Issue708b.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/Issue708b.agda", "max_line_length": 26, "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/Issue708b.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": 44, "size": 120 }
{-# OPTIONS --rewriting --allow-unsolved-metas #-} open import Agda.Builtin.Equality using (_≡_) open import Agda.Builtin.Equality.Rewrite postulate cast : (A B : Set) → A → B cast-rew : (A : Set) (x : A) → cast A A x ≡ x {-# REWRITE cast-rew #-} postulate A : Set x y : A data D (B : A → Set) (b : B y) : Set where con : cast (B x) (B y) ? ≡ b → D B b record R (B : A → Set) (b : B y) : Set where field eq : cast (B x) (B y) ? ≡ b
{ "alphanum_fraction": 0.5562913907, "avg_line_length": 21.5714285714, "ext": "agda", "hexsha": "1dc5c4e0373b86e05aee18611cf973c54436e6a8", "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/Issue4721b.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/Issue4721b.agda", "max_line_length": 50, "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/Issue4721b.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": 179, "size": 453 }
module ShowNat where open import IO open import Data.Unit open import Data.Nat.Show main = run (putStrLn (Data.Nat.Show.show 10))
{ "alphanum_fraction": 0.7651515152, "avg_line_length": 16.5, "ext": "agda", "hexsha": "d5430a5d8f0f35bc0110c8cd627ae3ca07ed91f2", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_forks_event_min_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_path": "test/Compiler/with-stdlib/ShowNat.agda", "max_issues_count": 16, "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_issues_event_max_datetime": "2019-09-08T13:47:04.000Z", "max_issues_repo_issues_event_min_datetime": "2018-10-08T00:32:04.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "shlevy/agda", "max_issues_repo_path": "test/Compiler/with-stdlib/ShowNat.agda", "max_line_length": 45, "max_stars_count": 7, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "test/Compiler/with-stdlib/ShowNat.agda", "max_stars_repo_stars_event_max_datetime": "2018-11-06T16:38:43.000Z", "max_stars_repo_stars_event_min_datetime": "2018-11-05T22:13:36.000Z", "num_tokens": 36, "size": 132 }
module nat where open import product open import bool open import maybe open import eq ---------------------------------------------------------------------- -- datatypes ---------------------------------------------------------------------- data ℕ : Set where zero : ℕ suc : ℕ → ℕ nat = ℕ ---------------------------------------------------------------------- -- syntax ---------------------------------------------------------------------- infixl 10 _*_ infixl 9 _+_ _∸_ infixl 8 _<_ _=ℕ_ _≤_ _>_ _≥_ -- pragmas to get decimal notation: {-# BUILTIN NATURAL ℕ #-} ---------------------------------------------------------------------- -- operations ---------------------------------------------------------------------- --------------------------------------- -- basic arithmetic operations --------------------------------------- _+_ : ℕ → ℕ → ℕ zero + n = n suc m + n = suc (m + n) {-# BUILTIN NATPLUS _+_ #-} _*_ : ℕ → ℕ → ℕ zero * n = zero suc m * n = n + (m * n) {-# BUILTIN NATTIMES _*_ #-} pred : ℕ → ℕ pred 0 = 0 pred (suc n) = n _∸_ : ℕ → ℕ → ℕ m ∸ zero = m zero ∸ suc n = zero suc m ∸ suc n = m ∸ n -- see nat-division.agda for division function {-# BUILTIN NATMINUS _∸_ #-} square : ℕ → ℕ square x = x * x -------------------------------------------------- -- comparisons -------------------------------------------------- _<_ : ℕ → ℕ → 𝔹 0 < 0 = ff 0 < (suc y) = tt (suc x) < (suc y) = x < y (suc x) < 0 = ff _=ℕ_ : ℕ → ℕ → 𝔹 0 =ℕ 0 = tt suc x =ℕ suc y = x =ℕ y _ =ℕ _ = ff _≤_ : ℕ → ℕ → 𝔹 x ≤ y = (x < y) || x =ℕ y _>_ : ℕ → ℕ → 𝔹 a > b = b < a _≥_ : ℕ → ℕ → 𝔹 a ≥ b = b ≤ a min : ℕ → ℕ → ℕ min x y = if x < y then x else y max : ℕ → ℕ → ℕ max x y = if x < y then y else x data compare-t : Set where compare-lt : compare-t compare-eq : compare-t compare-gt : compare-t compare : ℕ → ℕ → compare-t compare 0 0 = compare-eq compare 0 (suc y) = compare-lt compare (suc x) 0 = compare-gt compare (suc x) (suc y) = compare x y iszero : ℕ → 𝔹 iszero 0 = tt iszero _ = ff parity : ℕ → 𝔹 parity 0 = ff parity (suc x) = ~ (parity x) _pow_ : ℕ → ℕ → ℕ x pow 0 = 1 x pow (suc y) = x * (x pow y) factorial : ℕ → ℕ factorial 0 = 1 factorial (suc x) = (suc x) * (factorial x) is-even : ℕ → 𝔹 is-odd : ℕ → 𝔹 is-even 0 = tt is-even (suc x) = is-odd x is-odd 0 = ff is-odd (suc x) = is-even x
{ "alphanum_fraction": 0.408023901, "avg_line_length": 18.1627906977, "ext": "agda", "hexsha": "cae4676847dd3fdbfdfdeccc66bc03166e8803e6", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "b33c6a59d664aed46cac8ef77d34313e148fecc2", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "heades/AUGL", "max_forks_repo_path": "nat.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "b33c6a59d664aed46cac8ef77d34313e148fecc2", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "heades/AUGL", "max_issues_repo_path": "nat.agda", "max_line_length": 70, "max_stars_count": null, "max_stars_repo_head_hexsha": "b33c6a59d664aed46cac8ef77d34313e148fecc2", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "heades/AUGL", "max_stars_repo_path": "nat.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 781, "size": 2343 }
module ctxt where open import cedille-types open import ctxt-types public open import subst open import general-util open import syntax-util open import type-util open import free-vars new-sym-info-trie : trie sym-info new-sym-info-trie = trie-insert empty-trie compileFail-qual ((term-decl compileFailType) , "missing" , "missing") new-qualif : qualif new-qualif = trie-insert empty-trie compileFail (compileFail-qual , []) qualif-nonempty : qualif → 𝔹 qualif-nonempty q = trie-nonempty (trie-remove q compileFail) qualif-insert-params : qualif → var → var → params → qualif qualif-insert-params σ qv v ps = trie-insert σ v (qv , params-to-args ps) qualif-insert-import : qualif → var → maybe import-as → 𝕃 string → args → qualif qualif-insert-import σ mn oa [] as = σ qualif-insert-import σ mn oa (v :: vs) as = qualif-insert-import (trie-insert σ (maybe-else v (λ {(ImportAs _ pfx) → pfx # v}) oa) (mn # v , as)) mn oa vs as new-ctxt : (filename modname : string) → ctxt new-ctxt fn mn = record { fn = fn; mn = mn; ps = []; qual = new-qualif; syms = empty-trie; mod-map = empty-trie; id-map = empty-trie; id-current = 0; id-list = []; i = empty-trie; μ = empty-trie; μ' = empty-trie; Is/μ = empty-trie; μ~ = empty-trie; μᵤ = nothing; μ̲ = empty-stringset } empty-ctxt : ctxt empty-ctxt = new-ctxt "" "" ctxt-get-info : var → ctxt → maybe sym-info ctxt-get-info v Γ = trie-lookup (ctxt.i Γ) v ctxt-get-qi : ctxt → var → maybe qualif-info ctxt-get-qi = trie-lookup ∘ ctxt.qual ctxt-qualif-args-length : ctxt → erased? → var → maybe ℕ ctxt-qualif-args-length Γ me v = ctxt-get-qi Γ v >>= λ qv → just (if me then length (snd qv) else length (erase-args (snd qv))) qi-var-if : maybe qualif-info → var → var qi-var-if (just (v , _)) _ = v qi-var-if nothing v = v --ctxt-restore-info : ctxt → var → maybe qualif-info → maybe sym-info → ctxt --ctxt-restore-info (mk-ctxt (fn , mn , ps , q , ) syms i Δ) v qi si = -- mk-ctxt (fn , mn , ps , f qi v q) syms (f si (qi-var-if qi v) (trie-remove i (qi-var-if (trie-lookup q v) v))) Δ -- where -- f : ∀{A : Set} → maybe A → string → trie A → trie A -- f (just a) s t = trie-insert t s a -- f nothing s t = trie-remove t s --ctxt-restore-info* : ctxt → 𝕃 (string × maybe qualif-info × maybe sym-info) → ctxt --ctxt-restore-info* Γ [] = Γ --ctxt-restore-info* Γ ((v , qi , m) :: ms) = ctxt-restore-info* (ctxt-restore-info Γ v qi m) ms def-params : defScope → params → defParams def-params tt ps = nothing def-params ff ps = just ps inst-term : ctxt → params → args → term → term inst-term Γ ps as t with subst-params-args ps as ...| σ , ps' , as' = lam-expand-term (substs-params Γ σ ps') (substs Γ σ t) -- TODO add renamectxt to avoid capture bugs? inst-type : ctxt → params → args → type → type inst-type Γ ps as T with subst-params-args ps as ...| σ , ps' , as' = abs-expand-type (substs-params Γ σ ps') (substs Γ σ T) inst-kind : ctxt → params → args → kind → kind inst-kind Γ ps as k with subst-params-args ps as ...| σ , ps' , as' = abs-expand-kind (substs-params Γ σ ps') (substs Γ σ k) inst-ctrs : ctxt → params → args → ctrs → ctrs inst-ctrs Γ ps as c with subst-params-args ps as ...| σ , ps' , as' = flip map c λ where (Ctr x T) → Ctr x (abs-expand-type (substs-params Γ σ ps') (substs Γ σ T)) maybe-inst-type = maybe-else (λ as T → T) ∘ inst-type maybe-inst-kind = maybe-else (λ as T → T) ∘ inst-kind maybe-inst-ctrs = maybe-else (λ as c → c) ∘ inst-ctrs ctxt-term-decl : posinfo → var → type → ctxt → ctxt ctxt-term-decl pi v T Γ = let v' = pi % v in record Γ { qual = qualif-insert-params (ctxt.qual Γ) v' v []; i = trie-insert (ctxt.i Γ) v' (term-decl T , ctxt.fn Γ , pi) } ctxt-type-decl : posinfo → var → kind → ctxt → ctxt ctxt-type-decl pi v k Γ = let v' = pi % v in record Γ { qual = qualif-insert-params (ctxt.qual Γ) v' v []; i = trie-insert (ctxt.i Γ) v' (type-decl k , ctxt.fn Γ , pi) } ctxt-tk-decl : posinfo → var → tpkd → ctxt → ctxt ctxt-tk-decl p x (Tkt t) Γ = ctxt-term-decl p x t Γ ctxt-tk-decl p x (Tkk k) Γ = ctxt-type-decl p x k Γ infix 4 _,_-_:`_ _,_-_:`_ : ctxt → posinfo → var → tpkd → ctxt Γ , pi - x :` tk = ctxt-tk-decl pi x tk Γ -- TODO not sure how this and renaming interacts with module scope ctxt-var-decl-if : var → ctxt → ctxt ctxt-var-decl-if v Γ with trie-lookup (ctxt.i Γ) v ... | just (rename-def _ , _) = Γ ... | just (var-decl , _) = Γ ... | _ = ctxt-var-decl v Γ add-indices-to-ctxt : indices → ctxt → ctxt add-indices-to-ctxt = flip $ foldr λ {(Index x _) → ctxt-var-decl x} add-params-to-ctxt : params → ctxt → ctxt add-params-to-ctxt = flip $ foldr λ {(Param me x _) Γ → if ctxt-binds-var Γ (unqual-local x) then Γ else (ctxt-var-decl x ∘ ctxt-var-decl (unqual-local x)) Γ} add-caseArgs-to-ctxt : case-args → ctxt → ctxt add-caseArgs-to-ctxt = flip $ foldr λ {(CaseArg me x _) → ctxt-var-decl x} add-ctrs-to-ctxt : ctrs → ctxt → ctxt add-ctrs-to-ctxt = flip $ foldr λ {(Ctr x T) → ctxt-var-decl x} ctxt-rename-rep : ctxt → var → var ctxt-rename-rep Γ v with trie-lookup (ctxt.i Γ) v ...| just (rename-def v' , _) = v' ...| _ = v -- we assume that only the left variable might have been renamed ctxt-eq-rep : ctxt → var → var → 𝔹 ctxt-eq-rep Γ x y = (ctxt-rename-rep Γ x) =string y {- add a renaming mapping the first variable to the second, unless they are equal. Notice that adding a renaming for v will overwrite any other declarations for v. -} ctxt-rename : var → var → ctxt → ctxt ctxt-rename v v' Γ = record Γ { qual = trie-insert (ctxt.qual Γ) v (v' , []); i = trie-insert (ctxt.i Γ) v (rename-def v' , missing-location) } ---------------------------------------------------------------------- -- lookup functions ---------------------------------------------------------------------- -- lookup mod params from filename lookup-mod-params : ctxt → var → maybe params lookup-mod-params Γ fn = trie-lookup (ctxt.syms Γ) fn >>=c λ mn _ → trie-lookup (ctxt.mod-map Γ) mn >>=c λ fn' → just -- look for a defined kind for the given var, which is assumed to be a type, -- then instantiate its parameters qual-lookup : ctxt → var → maybe (var × args × sym-info) qual-lookup Γ v = trie-lookup (ctxt.qual Γ) v >>=c λ qv as → trie-lookup (ctxt.i Γ) qv >>= λ si → just (qv , as , si) env-lookup : ctxt → var → maybe sym-info env-lookup = trie-lookup ∘ ctxt.i ctxt-lookup-tpkd-var : ctxt → var → maybe (var × args × tpkd) ctxt-lookup-tpkd-var Γ v with qual-lookup Γ v ... | just (qv , as , term-decl T , _) = just $ qv , as , Tkt T ... | just (qv , as , type-decl k , _) = just $ qv , as , Tkk k ... | just (qv , as , term-def mps _ t T , _) = just $ qv , as , Tkt (maybe-inst-type Γ mps as T) ... | just (qv , as , ctr-def ps T _ _ _ , _) = just $ qv , as , Tkt (inst-type Γ ps as T) ... | just (qv , as , type-def mps _ T k , _) = just $ qv , as , Tkk (maybe-inst-kind Γ mps as k) ... | _ = nothing ctxt-lookup-type-var : ctxt → var → maybe (var × args × kind) ctxt-lookup-type-var Γ v = ctxt-lookup-tpkd-var Γ v >>= λ where (qv , as , Tkt T) → nothing (qv , as , Tkk k) → just (qv , as , k) ctxt-lookup-term-var : ctxt → var → maybe (var × args × type) ctxt-lookup-term-var Γ v = ctxt-lookup-tpkd-var Γ v >>= λ where (qv , as , Tkt T) → just (qv , as , T) (qv , as , Tkk k) → nothing ctxt-lookup-term-var-def : ctxt → var → maybe term ctxt-lookup-term-var-def Γ v with env-lookup Γ v ... | just (term-def mps opacity-open (just t) _ , _) = just $ maybe-else id lam-expand-term mps t ... | just (term-udef mps opacity-open t , _) = just $ maybe-else id lam-expand-term mps t ... | _ = nothing ctxt-lookup-type-var-def : ctxt → var → maybe type ctxt-lookup-type-var-def Γ v with env-lookup Γ v ... | just (type-def mps opacity-open (just T) _ , _) = just $ maybe-else id lam-expand-type mps T ... | _ = nothing ctxt-lookup-kind-var-def : ctxt → var → maybe (params × kind) ctxt-lookup-kind-var-def Γ x with qual-lookup Γ x ...| just (_ , as , kind-def ps k , _) = case subst-params-args' Γ ps as k of λ where (k' , ps' , as') → just (ps' , k') ...| _ = nothing ctxt-binds-term-var : ctxt → var → maybe (var × args) ctxt-binds-term-var Γ x with qual-lookup Γ x ...| just (qx , as , term-def _ _ _ _ , _) = just (qx , as) ...| just (qx , as , term-udef _ _ _ , _) = just (qx , as) ...| just (qx , as , term-decl _ , _) = just (qx , as) ...| just (qx , as , ctr-def _ _ _ _ _ , _) = just (qx , as) --...| just (qx , as , var-decl , _) = just (qx , as) ...| _ = nothing ctxt-binds-type-var : ctxt → var → maybe (var × args) ctxt-binds-type-var Γ x with qual-lookup Γ x ...| just (qx , as , type-def _ _ _ _ , _) = just (qx , as) ...| just (qx , as , type-decl _ , _) = just (qx , as) ...| _ = nothing {- inst-enc-defs : ctxt → params → args → encoding-defs → encoding-defs inst-enc-defs Γ ps as (mk-enc-defs ecs gcs Cast cast-in cast-out cast-is Functor functor-in functor-out Fix fix-in fix-out lambek1 lambek2 fix-ind) = let as = arg-set-erased tt <$> as in mk-enc-defs ecs gcs (inst-type Γ ps as Cast) (inst-term Γ ps as cast-in) (inst-term Γ ps as cast-out) (inst-term Γ ps as cast-is) (inst-type Γ ps as Functor) (inst-term Γ ps as functor-in) (inst-term Γ ps as functor-out) (inst-type Γ ps as Fix) (inst-term Γ ps as fix-in) (inst-term Γ ps as fix-out) (inst-term Γ ps as lambek1) (inst-term Γ ps as lambek2) (inst-term Γ ps as fix-ind) -} data-lookup' : ctxt → var → var → 𝕃 tmtp → maybe datatype-info data-lookup' Γ xₒ x as = (maybe-else' {B = maybe (var × args × 𝕃 tmtp × params × kind × kind × ctrs × encoding-defs × encoded-defs)} (trie-lookup (ctxt.μ' Γ) x) -- Is x known locally to be a datatype? (trie-lookup (ctxt.μ Γ) x >>=c λ ps rest → -- No, so is it a global datatype? let asₚ = tmtps-to-args-for-params nothing ps as asᵢ = drop (length ps) as in just (x , asₚ , asᵢ , ps , rest)) λ where (x' , as') → -- Yes, it is a local datatype of x', and gives as' as parameters to x' trie-lookup (ctxt.μ Γ) x' >>= λ rest → just (x' , as' , as , rest)) >>= λ where (x' , asₚ , asᵢ , ps , kᵢ , k , cs , eds , gds) → just $ mk-data-info x' xₒ asₚ asᵢ ps (inst-kind Γ ps asₚ kᵢ) (inst-kind Γ ps asₚ k) cs (inst-ctrs Γ ps asₚ (map-snd (subst Γ (params-to-tpapps ps (TpVar x')) x') <$> cs)) eds {-(inst-enc-defs Γ ps asₚ eds)-} gds --λ y → inst-ctrs Γ ps asₚ (map-snd (rename-var {TYPE} Γ x' y) <$> cs) data-lookup : ctxt → var → 𝕃 tmtp → maybe datatype-info data-lookup Γ x = data-lookup' Γ x x data-lookup-mu : ctxt → var → var → 𝕃 tmtp → maybe datatype-info data-lookup-mu Γ xₒ x as = trie-lookup (ctxt.Is/μ Γ) x >>= λ x' → data-lookup' Γ xₒ x' as data-highlight : ctxt → var → ctxt data-highlight Γ x = record Γ { μ̲ = stringset-insert (ctxt.μ̲ Γ) x } ctxt-lookup-term-loc : ctxt → var → maybe location ctxt-lookup-term-loc Γ x = qual-lookup Γ x >>= λ where (_ , _ , term-decl _ , loc) → just loc (_ , _ , term-def _ _ _ _ , loc) → just loc (_ , _ , term-udef _ _ _ , loc) → just loc (_ , _ , ctr-def _ _ _ _ _ , loc) → just loc (_ , _ , var-decl , loc) → just loc _ → nothing ctxt-lookup-type-loc : ctxt → var → maybe location ctxt-lookup-type-loc Γ x = qual-lookup Γ x >>= λ where (_ , _ , type-decl _ , loc) → just loc (_ , _ , type-def _ _ _ _ , loc) → just loc (_ , _ , var-decl , loc) → just loc _ → nothing ---------------------------------------------------------------------- ctxt-var-location : ctxt → var → location ctxt-var-location Γ x with trie-lookup (ctxt.i Γ) x ... | just (_ , l) = l ... | nothing = missing-location ctxt-clarify-def : ctxt → opacity → var → maybe ctxt ctxt-clarify-def Γ o x with qual-lookup Γ x ...| just (qx , as , type-def ps o' T? k , loc) = maybe-if (o xor o') >> just (record Γ { i = trie-insert (ctxt.i Γ) qx (type-def ps o T? k , loc) }) ...| just (qx , as , term-def ps o' t? T , loc) = maybe-if (o xor o') >> just (record Γ { i = trie-insert (ctxt.i Γ) qx (term-def ps o t? T , loc) }) ...| just (qx , as , term-udef ps o' t , loc) = maybe-if (o xor o') >> just (record Γ { i = trie-insert (ctxt.i Γ) qx (term-udef ps o t , loc) }) ...| _ = nothing ctxt-set-current-file : ctxt → string → string → ctxt ctxt-set-current-file Γ fn mn = record Γ { fn = fn; mn = mn; ps = []; qual = new-qualif } ctxt-set-current-mod : ctxt → string × string × params × qualif → ctxt ctxt-set-current-mod Γ (fn , mn , ps , qual) = record Γ { fn = fn; mn = mn; ps = ps; qual = qual } ctxt-add-current-params : ctxt → ctxt ctxt-add-current-params Γ = record Γ { syms = trie-insert (ctxt.syms Γ) (ctxt.fn Γ) (ctxt.mn Γ , []); mod-map = trie-insert (ctxt.mod-map Γ) (ctxt.mn Γ) (ctxt.fn Γ , ctxt.ps Γ) } ctxt-clear-symbol : ctxt → string → ctxt ctxt-clear-symbol Γ x = let qx = qualif-var Γ x in record Γ { qual = trie-remove (ctxt.qual Γ) x; syms = trie-map (λ ss → fst ss , remove _=string_ x (snd ss)) (ctxt.syms Γ); i = trie-remove (ctxt.i Γ) qx; μ = trie-remove (ctxt.μ Γ) qx; Is/μ = trie-remove (ctxt.Is/μ Γ) qx; μ̲ = trie-remove (ctxt.μ̲ Γ) qx } ctxt-clear-symbols : ctxt → 𝕃 string → ctxt ctxt-clear-symbols Γ [] = Γ ctxt-clear-symbols Γ (v :: vs) = ctxt-clear-symbols (ctxt-clear-symbol Γ v) vs ctxt-clear-symbols-of-file : ctxt → (filename : string) → ctxt ctxt-clear-symbols-of-file Γ fn = elim-pair (trie-lookup𝕃2 (ctxt.syms Γ) fn) λ mn xs → let ps = maybe-else' (trie-lookup (ctxt.mod-map Γ) mn) [] snd in record Γ { syms = trie-insert (ctxt.syms Γ) fn (mn , []); mod-map = trie-insert (ctxt.mod-map Γ) mn (fn , ps); i = hremove (ctxt.i Γ) mn xs; μ = hremove (ctxt.μ Γ) mn xs; Is/μ = hremove (ctxt.Is/μ Γ) mn xs; μ̲ = hremove (ctxt.μ̲ Γ) mn xs } where hremove : ∀ {A : Set} → trie A → var → 𝕃 string → trie A hremove i mn [] = i hremove i mn (x :: xs) = hremove (trie-remove i (mn # x)) mn xs ctxt-add-current-id : ctxt → ctxt ctxt-add-current-id Γ with trie-contains (ctxt.id-map Γ) (ctxt.fn Γ) ...| tt = Γ ...| ff = record Γ { id-map = trie-insert (ctxt.id-map Γ) (ctxt.fn Γ) (suc (ctxt.id-current Γ)); id-current = suc (ctxt.id-current Γ); id-list = ctxt.fn Γ :: ctxt.id-list Γ } ctxt-initiate-file : ctxt → (filename modname : string) → ctxt ctxt-initiate-file Γ fn mn = ctxt-add-current-id (ctxt-set-current-file (ctxt-clear-symbols-of-file Γ fn) fn mn) unqual : ctxt → var → string unqual Γ v = if qualif-nonempty (ctxt.qual Γ) then unqual-local (unqual-all (ctxt.qual Γ) v) else v qualified-ctxt : ctxt → ctxt qualified-ctxt Γ = -- use ctxt.i so we bring ALL defs (even from cousin modules, etc...) into scope record Γ {qual = for trie-strings (ctxt.i Γ) accum empty-trie use λ x q → trie-insert q x (x , [])}
{ "alphanum_fraction": 0.6046058816, "avg_line_length": 37.328320802, "ext": "agda", "hexsha": "83eeb09a1331fe641a25822df8e0a70405973fe1", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "9df4b85b55b57f97466242fdbb499adbd3bca893", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "zmthy/cedille", "max_forks_repo_path": "src/ctxt.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "9df4b85b55b57f97466242fdbb499adbd3bca893", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "zmthy/cedille", "max_issues_repo_path": "src/ctxt.agda", "max_line_length": 158, "max_stars_count": null, "max_stars_repo_head_hexsha": "9df4b85b55b57f97466242fdbb499adbd3bca893", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "zmthy/cedille", "max_stars_repo_path": "src/ctxt.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 4952, "size": 14894 }
module nat-division-wf where open import bool open import bool-thms open import eq open import neq open import nat open import nat-thms open import product open import product-thms open import sum open import termination ---------------------------------------------------------------------- -- syntax ---------------------------------------------------------------------- infixl 10 _÷_!_ ---------------------------------------------------------------------- -- operations ---------------------------------------------------------------------- {- a div-result for dividend x and divisor d consists of the quotient q, remainder r, a proof that q * d + r = x, and a proof that the remainder is less than the divisor. -} div-result : ℕ → ℕ → Set div-result x d = Σ ℕ (λ q → Σ ℕ (λ r → q * d + r ≡ x ∧ r < d ≡ tt)) -- this uses well-founded recursion. The approach in nat-division.agda is arguably simpler. div-helper : ∀ (x : ℕ) → ↓𝔹 _>_ x → (d : ℕ) → d =ℕ 0 ≡ ff → div-result x d div-helper x ↓x 0 () div-helper 0 (pf↓ fx) (suc d) _ = 0 , 0 , refl , refl div-helper (suc x) (pf↓ fx) (suc d) _ with keep (x < d) div-helper (suc x) (pf↓ fx) (suc d) _ | tt , p = 0 , suc x , refl , p div-helper (suc x) (pf↓ fx) (suc d) _ | ff , p with div-helper (x ∸ d) (fx (∸<1 {x} {d})) (suc d) refl div-helper (suc x) (pf↓ fx) (suc d) _ | ff , p | q , r , u , v = suc q , r , lem{q * suc d} (∸eq-swap{x}{d}{q * suc d + r} (<ff{x} p) u) , v where lem : ∀ {a b c : ℕ} → a + b + c ≡ x → suc (c + a + b) ≡ suc x lem{a}{b}{c} p' rewrite +comm c a | sym (+assoc a c b) | +comm c b | +assoc a b c | p' = refl _÷_!_ : (x : ℕ) → (d : ℕ) → d =ℕ 0 ≡ ff → div-result x d x ÷ d ! p = div-helper x (↓-> x) d p _÷_!!_ : ℕ → (d : ℕ) → d =ℕ 0 ≡ ff → ℕ × ℕ x ÷ d !! p with x ÷ d ! p ... | q , r , p' = q , r -- return quotient only _÷_div_ : ℕ → (d : ℕ) → d =ℕ 0 ≡ ff → ℕ x ÷ d div p with x ÷ d ! p ... | q , r , p' = q
{ "alphanum_fraction": 0.4592933948, "avg_line_length": 35.5090909091, "ext": "agda", "hexsha": "c3e7b3fa845e49382ea1513d858b04ededbc2477", "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": "nat-division-wf.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": "nat-division-wf.agda", "max_line_length": 92, "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": "nat-division-wf.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": 688, "size": 1953 }
------------------------------------------------------------------------------ -- Agda-Prop Library. -- Useful views. ------------------------------------------------------------------------------ open import Data.Nat using (ℕ) module Data.PropFormula.Views (n : ℕ) where ------------------------------------------------------------------------------ open import Data.PropFormula.Syntax n ------------------------------------------------------------------------------ data nView : PropFormula → Set where conj : (φ₁ φ₂ : PropFormula) → nView (φ₁ ∧ φ₂) disj : (φ₁ φ₂ : PropFormula) → nView (φ₁ ∨ φ₂) impl : (φ₁ φ₂ : PropFormula) → nView (φ₁ ⊃ φ₂) biimpl : (φ₁ φ₂ : PropFormula) → nView (φ₁ ⇔ φ₂) nconj : (φ₁ φ₂ : PropFormula) → nView (¬ (φ₁ ∧ φ₂)) ndisj : (φ₁ φ₂ : PropFormula) → nView (¬ (φ₁ ∨ φ₂)) nneg : (φ₁ : PropFormula) → nView (¬ ¬ φ₁) nimpl : (φ₁ φ₂ : PropFormula) → nView (¬ (φ₁ ⊃ φ₂)) nbiim : (φ₁ φ₂ : PropFormula) → nView (¬ (φ₁ ⇔ φ₂)) ntop : nView (¬ ⊤) nbot : nView (¬ ⊥) other : (φ₁ : PropFormula) → nView φ₁ n-view : (φ : PropFormula) → nView φ n-view (φ₁ ∧ φ₂) = conj _ _ n-view (φ₁ ∨ φ₂) = disj _ _ n-view (φ₁ ⊃ φ₂) = impl _ _ n-view (φ₁ ⇔ φ₂) = biimpl _ _ n-view (¬ (φ₁ ∧ φ₂)) = nconj _ _ n-view (¬ (φ₁ ∨ φ₂)) = ndisj _ _ n-view (¬ (φ₁ ⊃ φ₂)) = nimpl _ _ n-view (¬ (φ₁ ⇔ φ₂)) = nbiim _ _ n-view (¬ (¬ φ₁)) = nneg _ n-view (¬ ⊤) = ntop n-view (¬ ⊥) = nbot n-view φ₁ = other _ data ConjView : PropFormula → Set where conj : (φ₁ φ₂ : PropFormula) → ConjView (φ₁ ∧ φ₂) other : (φ : PropFormula) → ConjView φ conj-view : (φ : PropFormula) → ConjView φ conj-view (φ₁ ∧ φ₂) = conj _ _ conj-view φ = other _ data DisjView : PropFormula → Set where disj : (φ₁ φ₂ : PropFormula) → DisjView (φ₁ ∨ φ₂) other : (φ : PropFormula) → DisjView φ disj-view : (φ : PropFormula) → DisjView φ disj-view (φ₁ ∨ φ₂) = disj _ _ disj-view φ = other _ data dView : PropFormula → Set where conj : (φ₁ φ₂ : PropFormula) → dView (φ₁ ∧ φ₂) disj : (φ₁ φ₂ : PropFormula) → dView (φ₁ ∨ φ₂) other : (φ : PropFormula) → dView φ d-view : (φ : PropFormula) → dView φ d-view (φ₁ ∧ φ₂) = conj _ _ d-view (φ₁ ∨ φ₂) = disj _ _ d-view φ = other _ data dViewAux : PropFormula → Set where case₁ : (φ₁ φ₂ φ₃ : PropFormula) → dViewAux ((φ₁ ∨ φ₂) ∧ φ₃) case₂ : (φ₁ φ₂ φ₃ : PropFormula) → dViewAux (φ₁ ∧ (φ₂ ∨ φ₃)) other : (φ : PropFormula) → dViewAux φ d-view-aux : (φ : PropFormula) → dViewAux φ d-view-aux ((φ₁ ∨ φ₂) ∧ φ₃) = case₁ _ _ _ d-view-aux (φ₁ ∧ (φ₂ ∨ φ₃)) = case₂ _ _ _ d-view-aux φ = other _ data cViewAux : PropFormula → Set where case₁ : (φ₁ φ₂ φ₃ : PropFormula) → cViewAux ((φ₁ ∧ φ₂) ∨ φ₃) case₂ : (φ₁ φ₂ φ₃ : PropFormula) → cViewAux (φ₁ ∨ (φ₂ ∧ φ₃)) other : (φ : PropFormula) → cViewAux φ c-view-aux : (φ : PropFormula) → cViewAux φ c-view-aux ((φ ∧ ψ) ∨ φ₃) = case₁ _ _ _ c-view-aux (φ ∨ (ψ ∧ φ₃)) = case₂ _ _ _ c-view-aux φ = other _ data ImplView : PropFormula → Set where impl : (φ₁ φ₂ : PropFormula) → ImplView (φ₁ ⊃ φ₂) other : (φ : PropFormula) → ImplView φ impl-view : (φ : PropFormula) → ImplView φ impl-view (φ₁ ⊃ φ₂) = impl _ _ impl-view φ = other _ data BiimplView : PropFormula → Set where biimpl : (φ₁ φ₂ : PropFormula) → BiimplView (φ₁ ⇔ φ₂) other : (φ : PropFormula) → BiimplView φ biimpl-view : (φ : PropFormula) → BiimplView φ biimpl-view (φ₁ ⇔ φ₂) = biimpl _ _ biimpl-view φ = other _ data NegView : PropFormula → Set where neg : (φ : PropFormula) → NegView (¬ φ) pos : (φ : PropFormula) → NegView φ neg-view : (φ : PropFormula) → NegView φ neg-view (¬ φ) = neg _ neg-view φ = pos _ data PushNegView : PropFormula → Set where yes : (φ : PropFormula) → PushNegView φ no-∧ : (φ₁ φ₂ : PropFormula) → PushNegView (φ₁ ∧ φ₂) no-∨ : (φ₁ φ₂ : PropFormula) → PushNegView (φ₁ ∨ φ₂) no : (φ : PropFormula) → PushNegView φ push-neg-view : (φ : PropFormula) → PushNegView φ push-neg-view φ with n-view φ push-neg-view .(φ₁ ∧ φ₂) | conj φ₁ φ₂ = no-∧ _ _ push-neg-view .(φ₁ ∨ φ₂) | disj φ₁ φ₂ = no-∨ _ _ push-neg-view .(φ₁ ⊃ φ₂) | impl φ₁ φ₂ = yes _ push-neg-view .(φ₁ ⇔ φ₂) | biimpl φ₁ φ₂ = yes _ push-neg-view .(¬ (φ₁ ∧ φ₂)) | nconj φ₁ φ₂ = yes _ push-neg-view .(¬ (φ₁ ∨ φ₂)) | ndisj φ₁ φ₂ = yes _ push-neg-view .(¬ (¬ φ₁)) | nneg φ₁ = yes _ push-neg-view .(¬ (φ₁ ⊃ φ₂)) | nimpl φ₁ φ₂ = yes _ push-neg-view .(¬ (φ₁ ⇔ φ₂)) | nbiim φ₁ φ₂ = yes _ push-neg-view .(¬ ⊤) | ntop = yes _ push-neg-view .(¬ ⊥) | nbot = yes _ push-neg-view φ | other .φ = no _ data LiteralView : PropFormula → Set where yes : (φ : PropFormula) → LiteralView φ no : (φ : PropFormula) → LiteralView φ literal-view : (φ : PropFormula) → LiteralView φ literal-view φ with n-view φ literal-view .(φ₁ ∧ φ₂) | conj φ₁ φ₂ = no _ literal-view .(φ₁ ∨ φ₂) | disj φ₁ φ₂ = no _ literal-view .(φ₁ ⊃ φ₂) | impl φ₁ φ₂ = no _ literal-view .(φ₁ ⇔ φ₂) | biimpl φ₁ φ₂ = no _ literal-view .(¬ (φ₁ ∧ φ₂)) | nconj φ₁ φ₂ = no _ literal-view .(¬ (φ₁ ∨ φ₂)) | ndisj φ₁ φ₂ = no _ literal-view .(¬ (¬ φ₁)) | nneg φ₁ = no _ literal-view .(¬ (φ₁ ⊃ φ₂)) | nimpl φ₁ φ₂ = no _ literal-view .(¬ (φ₁ ⇔ φ₂)) | nbiim φ₁ φ₂ = no _ literal-view .(¬ ⊤) | ntop = yes _ literal-view .(¬ ⊥) | nbot = yes _ literal-view φ | other _ = yes _
{ "alphanum_fraction": 0.5301248417, "avg_line_length": 35.4294871795, "ext": "agda", "hexsha": "47b9b5eadc7d9d02d46f9dc62b21c656246701d5", "lang": "Agda", "max_forks_count": 2, "max_forks_repo_forks_event_max_datetime": "2017-12-01T17:01:25.000Z", "max_forks_repo_forks_event_min_datetime": "2017-03-30T16:41:56.000Z", "max_forks_repo_head_hexsha": "a1730062a6aaced2bb74878c1071db06477044ae", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "jonaprieto/agda-prop", "max_forks_repo_path": "src/Data/PropFormula/Views.agda", "max_issues_count": 18, "max_issues_repo_head_hexsha": "a1730062a6aaced2bb74878c1071db06477044ae", "max_issues_repo_issues_event_max_datetime": "2017-12-18T16:34:21.000Z", "max_issues_repo_issues_event_min_datetime": "2017-03-08T14:33:10.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "jonaprieto/agda-prop", "max_issues_repo_path": "src/Data/PropFormula/Views.agda", "max_line_length": 78, "max_stars_count": 13, "max_stars_repo_head_hexsha": "a1730062a6aaced2bb74878c1071db06477044ae", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "jonaprieto/agda-prop", "max_stars_repo_path": "src/Data/PropFormula/Views.agda", "max_stars_repo_stars_event_max_datetime": "2022-01-17T03:33:12.000Z", "max_stars_repo_stars_event_min_datetime": "2017-05-01T16:45:41.000Z", "num_tokens": 2109, "size": 5527 }
open import Agda.Builtin.Nat f : Nat → Nat f 0 = zero f 0 = 0 -- All -- But Only f (suc n) = n -- These f 0 = 0 -- Lines -- These Two -- Used to be highlighted -- Should be! g : Nat → Nat g 0 = zero g 0 -- The highlihting should still = 0 -- span multiple lines if the clause does g (suc n) = n g 0 -- Even -- With -- A Lot = 0 -- Of Empty Lines in between
{ "alphanum_fraction": 0.4709677419, "avg_line_length": 22.1428571429, "ext": "agda", "hexsha": "eeee76fb8200dbe34f5860f7a03eab7123149766", "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/LaTeXAndHTML/succeed/Issue3965.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/LaTeXAndHTML/succeed/Issue3965.agda", "max_line_length": 56, "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/LaTeXAndHTML/succeed/Issue3965.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": 148, "size": 465 }
{-# OPTIONS --without-K --rewriting #-} open import lib.Basics open import lib.NType2 open import lib.types.Empty open import lib.types.Group open import lib.types.Int open import lib.types.List open import lib.types.Nat open import lib.types.Pi open import lib.types.SetQuotient open import lib.types.Sigma open import lib.types.Word open import lib.groups.GroupProduct open import lib.groups.Homomorphism open import lib.groups.Isomorphism module lib.groups.FreeAbelianGroup {i} where -- the relation for making the quotient. -- [fsr-sym] is not needed, but it seems more principled to -- make [FormalSumRel] an equivalence relation. data FormalSumRel {A : Type i} : Word A → Word A → Type i where fsr-refl : ∀ {l₁ l₂} → l₁ == l₂ → FormalSumRel l₁ l₂ fsr-trans : ∀ {l₁ l₂ l₃} → FormalSumRel l₁ l₂ → FormalSumRel l₂ l₃ → FormalSumRel l₁ l₃ fsr-sym : ∀ {l₁ l₂} → FormalSumRel l₁ l₂ → FormalSumRel l₂ l₁ fsr-cons : ∀ x {l₁ l₂} → FormalSumRel l₁ l₂ → FormalSumRel (x :: l₁) (x :: l₂) fsr-swap : ∀ x₁ x₂ l → FormalSumRel (x₁ :: x₂ :: l) (x₂ :: x₁ :: l) fsr-flip : ∀ x₁ l → FormalSumRel (x₁ :: flip x₁ :: l) l -- The quotient FormalSum : Type i → Type i FormalSum A = SetQuot (FormalSumRel {A}) module _ {A : Type i} where fs[_] : Word A → FormalSum A fs[_] = q[_] module FormalSumElim {k} {P : FormalSum A → Type k} {{p : {x : FormalSum A} → is-set (P x)}} (incl* : (a : Word A) → P fs[ a ]) (rel* : ∀ {a₁ a₂} (r : FormalSumRel a₁ a₂) → incl* a₁ == incl* a₂ [ P ↓ quot-rel r ]) = SetQuotElim incl* rel* open FormalSumElim public using () renaming (f to FormalSum-elim) module FormalSumRec {k} {B : Type k} {{p : is-set B}} (incl* : Word A → B) (rel* : ∀ {a₁ a₂} (r : FormalSumRel a₁ a₂) → incl* a₁ == incl* a₂) = SetQuotRec incl* rel* open FormalSumRec public using () renaming (f to FormalSum-rec) module _ {A : Type i} where -- useful properties that remain public abstract FormalSumRel-cong-++-l : ∀ {l₁ l₁'} → FormalSumRel {A} l₁ l₁' → (l₂ : Word A) → FormalSumRel (l₁ ++ l₂) (l₁' ++ l₂) FormalSumRel-cong-++-l (fsr-refl idp) l₂ = fsr-refl idp FormalSumRel-cong-++-l (fsr-trans fsr₁ fsr₂) l₂ = fsr-trans (FormalSumRel-cong-++-l fsr₁ l₂) (FormalSumRel-cong-++-l fsr₂ l₂) FormalSumRel-cong-++-l (fsr-sym fsr) l₂ = fsr-sym (FormalSumRel-cong-++-l fsr l₂) FormalSumRel-cong-++-l (fsr-cons x fsr₁) l₂ = fsr-cons x (FormalSumRel-cong-++-l fsr₁ l₂) FormalSumRel-cong-++-l (fsr-swap x₁ x₂ l₁) l₂ = fsr-swap x₁ x₂ (l₁ ++ l₂) FormalSumRel-cong-++-l (fsr-flip x₁ l₁) l₂ = fsr-flip x₁ (l₁ ++ l₂) FormalSumRel-cong-++-r : ∀ (l₁ : Word A) → ∀ {l₂ l₂'} → FormalSumRel l₂ l₂' → FormalSumRel (l₁ ++ l₂) (l₁ ++ l₂') FormalSumRel-cong-++-r nil fsr₂ = fsr₂ FormalSumRel-cong-++-r (x :: l₁) fsr₂ = fsr-cons x (FormalSumRel-cong-++-r l₁ fsr₂) FormalSumRel-swap1 : ∀ x l₁ l₂ → FormalSumRel {A} (l₁ ++ (x :: l₂)) (x :: l₁ ++ l₂) FormalSumRel-swap1 x nil l₂ = fsr-refl idp FormalSumRel-swap1 x (x₁ :: l₁) l₂ = fsr-trans (fsr-cons x₁ (FormalSumRel-swap1 x l₁ l₂)) (fsr-swap x₁ x (l₁ ++ l₂)) module _ (A : Type i) where private infixl 80 _⊞_ _⊞_ : FormalSum A → FormalSum A → FormalSum A _⊞_ = FormalSum-rec (λ l₁ → FormalSum-rec (λ l₂ → fs[ l₁ ++ l₂ ]) (λ r → quot-rel $ FormalSumRel-cong-++-r l₁ r)) (λ {l₁} {l₁'} r → λ= $ FormalSum-elim (λ l₂ → quot-rel $ FormalSumRel-cong-++-l r l₂) (λ _ → prop-has-all-paths-↓)) abstract FormalSumRel-cong-flip : ∀ {l₁ l₂} → FormalSumRel {A} l₁ l₂ → FormalSumRel (Word-flip l₁) (Word-flip l₂) FormalSumRel-cong-flip (fsr-refl idp) = fsr-refl idp FormalSumRel-cong-flip (fsr-trans fsr₁ fsr₂) = fsr-trans (FormalSumRel-cong-flip fsr₁) (FormalSumRel-cong-flip fsr₂) FormalSumRel-cong-flip (fsr-sym fsr) = fsr-sym (FormalSumRel-cong-flip fsr) FormalSumRel-cong-flip (fsr-cons x fsr₁) = fsr-cons (flip x) (FormalSumRel-cong-flip fsr₁) FormalSumRel-cong-flip (fsr-swap x₁ x₂ l) = fsr-swap (flip x₁) (flip x₂) (Word-flip l) FormalSumRel-cong-flip (fsr-flip (inl x) l) = fsr-flip (inr x) (Word-flip l) FormalSumRel-cong-flip (fsr-flip (inr x) l) = fsr-flip (inl x) (Word-flip l) ⊟ : FormalSum A → FormalSum A ⊟ = FormalSum-rec (fs[_] ∘ Word-flip) (λ r → quot-rel $ FormalSumRel-cong-flip r) ⊞-unit : FormalSum A ⊞-unit = fs[ nil ] abstract ⊞-unit-l : ∀ g → ⊞-unit ⊞ g == g ⊞-unit-l = FormalSum-elim (λ _ → idp) (λ _ → prop-has-all-paths-↓) ⊞-assoc : ∀ g₁ g₂ g₃ → (g₁ ⊞ g₂) ⊞ g₃ == g₁ ⊞ (g₂ ⊞ g₃) ⊞-assoc = FormalSum-elim (λ l₁ → FormalSum-elim (λ l₂ → FormalSum-elim (λ l₃ → ap fs[_] $ ++-assoc l₁ l₂ l₃) (λ _ → prop-has-all-paths-↓)) (λ _ → prop-has-all-paths-↓)) (λ _ → prop-has-all-paths-↓) Word-inv-l : ∀ l → FormalSumRel {A} (Word-flip l ++ l) nil Word-inv-l nil = fsr-refl idp Word-inv-l (x :: l) = fsr-trans (FormalSumRel-swap1 x (flip x :: Word-flip l) l) $ fsr-trans (fsr-flip x (Word-flip l ++ l)) (Word-inv-l l) ⊟-inv-l : ∀ g → (⊟ g) ⊞ g == ⊞-unit ⊟-inv-l = FormalSum-elim (λ l → quot-rel (Word-inv-l l)) (λ _ → prop-has-all-paths-↓) FormalSumRel-swap : ∀ l₁ l₂ → FormalSumRel {A} (l₁ ++ l₂) (l₂ ++ l₁) FormalSumRel-swap l₁ nil = fsr-refl (++-unit-r l₁) FormalSumRel-swap l₁ (x :: l₂) = fsr-trans (FormalSumRel-swap1 x l₁ l₂) (fsr-cons x (FormalSumRel-swap l₁ l₂)) ⊞-comm : ∀ g₁ g₂ → g₁ ⊞ g₂ == g₂ ⊞ g₁ ⊞-comm = FormalSum-elim (λ l₁ → FormalSum-elim (λ l₂ → quot-rel $ FormalSumRel-swap l₁ l₂) (λ _ → prop-has-all-paths-↓)) (λ _ → prop-has-all-paths-↓) FormalSum-group-structure : GroupStructure (FormalSum A) FormalSum-group-structure = record { ident = ⊞-unit ; inv = ⊟ ; comp = _⊞_ ; unit-l = ⊞-unit-l ; assoc = ⊞-assoc ; inv-l = ⊟-inv-l } FreeAbGroup : AbGroup i FreeAbGroup = group _ FormalSum-group-structure , ⊞-comm module FreeAbGroup = AbGroup FreeAbGroup {- Freeness (universal properties) -} module _ {A : Type i} {j} (G : AbGroup j) where private module G = AbGroup G abstract Word-extendᴳ-emap : ∀ f {l₁ l₂} → FormalSumRel {A} l₁ l₂ → Word-extendᴳ G.grp f l₁ == Word-extendᴳ G.grp f l₂ Word-extendᴳ-emap f (fsr-refl idp) = idp Word-extendᴳ-emap f (fsr-trans fsr fsr₁) = (Word-extendᴳ-emap f fsr) ∙ (Word-extendᴳ-emap f fsr₁) Word-extendᴳ-emap f (fsr-sym fsr) = ! (Word-extendᴳ-emap f fsr) Word-extendᴳ-emap f (fsr-cons x fsr) = ap (G.comp (PlusMinus-extendᴳ G.grp f x)) (Word-extendᴳ-emap f fsr) Word-extendᴳ-emap f (fsr-swap x₁ x₂ l) = ! (G.assoc (PlusMinus-extendᴳ G.grp f x₁) (PlusMinus-extendᴳ G.grp f x₂) (Word-extendᴳ G.grp f l)) ∙ ap (λ g → G.comp g (Word-extendᴳ G.grp f l)) (G.comm (PlusMinus-extendᴳ G.grp f x₁) (PlusMinus-extendᴳ G.grp f x₂)) ∙ G.assoc (PlusMinus-extendᴳ G.grp f x₂) (PlusMinus-extendᴳ G.grp f x₁) (Word-extendᴳ G.grp f l) Word-extendᴳ-emap f (fsr-flip (inl x) l) = ! (G.assoc (f x) (G.inv (f x)) (Word-extendᴳ G.grp f l)) ∙ ap (λ g → G.comp g (Word-extendᴳ G.grp f l)) (G.inv-r (f x)) ∙ G.unit-l _ Word-extendᴳ-emap f (fsr-flip (inr x) l) = ! (G.assoc (G.inv (f x)) (f x) (Word-extendᴳ G.grp f l)) ∙ ap (λ g → G.comp g (Word-extendᴳ G.grp f l)) (G.inv-l (f x)) ∙ G.unit-l _ FormalSum-extend : (A → G.El) → FormalSum A → G.El FormalSum-extend f = FormalSum-rec (Word-extendᴳ G.grp f) (λ r → Word-extendᴳ-emap f r) FreeAbGroup-extend : (A → G.El) → (FreeAbGroup.grp A →ᴳ G.grp) FreeAbGroup-extend f' = record {M} where module M where f : FreeAbGroup.El A → G.El f = FormalSum-extend f' abstract pres-comp : preserves-comp (FreeAbGroup.comp A) G.comp f pres-comp = FormalSum-elim (λ l₁ → FormalSum-elim (λ l₂ → Word-extendᴳ-++ G.grp f' l₁ l₂) (λ _ → prop-has-all-paths-↓)) (λ _ → prop-has-all-paths-↓) private module Lemma (hom : FreeAbGroup.grp A →ᴳ G.grp) where open GroupHom hom f* : A → G.El f* a = f fs[ inl a :: nil ] abstract PlusMinus-extend-hom : ∀ x → PlusMinus-extendᴳ G.grp f* x == f fs[ x :: nil ] PlusMinus-extend-hom (inl x) = idp PlusMinus-extend-hom (inr x) = ! $ pres-inv fs[ inl x :: nil ] Word-extend-hom : ∀ l → Word-extendᴳ G.grp f* l == f fs[ l ] Word-extend-hom nil = ! pres-ident Word-extend-hom (x :: l) = ap2 G.comp (PlusMinus-extend-hom x) (Word-extend-hom l) ∙ ! (pres-comp _ _) open Lemma FreeAbGroup-extend-is-equiv : is-equiv FreeAbGroup-extend FreeAbGroup-extend-is-equiv = is-eq _ from to-from from-to where to = FreeAbGroup-extend from = f* abstract to-from : ∀ h → to (from h) == h to-from h = group-hom= $ λ= $ FormalSum-elim (λ l → Word-extend-hom h l) (λ _ → prop-has-all-paths-↓) from-to : ∀ f → from (to f) == f from-to f = λ= λ a → G.unit-r (f a) FreeAbGroup-extend-hom : Πᴳ A (λ _ → G.grp) →ᴳ hom-group (FreeAbGroup.grp A) G FreeAbGroup-extend-hom = record {M} where module M where f : (A → G.El) → (FreeAbGroup.grp A →ᴳ G.grp) f = FreeAbGroup-extend abstract pres-comp : preserves-comp (Group.comp (Πᴳ A (λ _ → G.grp))) (Group.comp (hom-group (FreeAbGroup.grp A) G)) f pres-comp = λ f₁ f₂ → group-hom= $ λ= $ FormalSum-elim (Word-extendᴳ-comp G f₁ f₂) (λ _ → prop-has-all-paths-↓) FreeAbGroup-extend-iso : Πᴳ A (λ _ → G.grp) ≃ᴳ hom-group (FreeAbGroup.grp A) G FreeAbGroup-extend-iso = FreeAbGroup-extend-hom , FreeAbGroup-extend-is-equiv {- relation with [Word-exp] -} module _ {A : Type i} where abstract FormalSumRel-pres-exp : ∀ (a : A) z → fs[ Word-exp a z ] == GroupStructure.exp (FormalSum-group-structure A) fs[ inl a :: nil ] z FormalSumRel-pres-exp a (pos O) = idp FormalSumRel-pres-exp a (pos (S O)) = idp FormalSumRel-pres-exp a (pos (S (S n))) = ap (Group.comp (FreeAbGroup.grp A) fs[ inl a :: nil ]) (FormalSumRel-pres-exp a (pos (S n))) FormalSumRel-pres-exp a (negsucc O) = idp FormalSumRel-pres-exp a (negsucc (S n)) = ap (Group.comp (FreeAbGroup.grp A) fs[ inr a :: nil ]) (FormalSumRel-pres-exp a (negsucc n))
{ "alphanum_fraction": 0.5931349244, "avg_line_length": 40.2950191571, "ext": "agda", "hexsha": "ae3104fcd724509185c5ea2e81501ae78994a043", "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": "core/lib/groups/FreeAbelianGroup.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": "core/lib/groups/FreeAbelianGroup.agda", "max_line_length": 129, "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": "core/lib/groups/FreeAbelianGroup.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 4034, "size": 10517 }
open import Agda.Builtin.IO open import Agda.Builtin.Reflection open import Agda.Builtin.String open import Agda.Builtin.Unit _>>=_ : {A B : Set} → TC A → (A → TC B) → TC B _>>=_ = λ x f → bindTC x f postulate putStr : String → IO ⊤ {-# FOREIGN GHC import qualified Data.Text.IO #-} {-# COMPILE GHC putStr = Data.Text.IO.putStr #-} {-# COMPILE JS putStr = function (x) { return function(cb) { process.stdout.write(x); cb(0); }; } #-} main : IO ⊤ main = putStr "Success\n"
{ "alphanum_fraction": 0.6290322581, "avg_line_length": 23.619047619, "ext": "agda", "hexsha": "7a824db17164d9b57d25ea2fc6ad9b82befb4173", "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/Compiler/simple/Issue5420.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/Compiler/simple/Issue5420.agda", "max_line_length": 49, "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/Compiler/simple/Issue5420.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": 150, "size": 496 }
{- trying (and failing) to create a univesal "successor" -} -- types with and without payloads defined dependently, those w/o payloads in terms of those with (using ⊤ as a trivial payload) -- this complicates the successor constructor, `!`, so we use use pattern (OR function?), `¡` module Oscar.Data3 where record ⊤ : Set where constructor tt infixr 20 _∷_ -- List data ⟦_⟧ {a} (A : Set a) : Set a where ∅ : ⟦ A ⟧ _∷_ : A → ⟦ A ⟧ → ⟦ A ⟧ -- Nat ⟦⟧ = ⟦ ⊤ ⟧ infix 21 ¡_ pattern ¡_ ⟦A⟧ = tt ∷ ⟦A⟧ --¡ : ⟦⟧ → ⟦⟧ --¡ ⟦A⟧ = tt ∷ ⟦A⟧ -- Fin, with payload data ⟦_⟧[_] {a} (A : ⟦⟧ → Set a) : ⟦⟧ → Set a where ∅ : ∀ {n} → ⟦ A ⟧[ ¡ n ] _∷_ : ∀ {n} → A n → ⟦ A ⟧[ n ] → ⟦ A ⟧[ ¡ n ] data ⟦_⟧[_₀] {a} (A : ⟦⟧ → Set a) : ⟦⟧ → Set a where ∅ : ⟦ A ⟧[ ∅ ₀] _∷_ : ∀ {n} → A n → ⟦ A ⟧[ n ₀] → ⟦ A ⟧[ ¡ n ₀] Const_ : ∀ {a} {A : Set a} {b} {B : Set b} → B → A → B Const_ x _ = x ⟦⟧[_₀] = ⟦ Const ⊤ ⟧[_₀] -- Fin ⟦⟧[_] = ⟦ Const ⊤ ⟧[_] -- m ≤ n, counting down from n-1 to m data ⟦_⟧[_≤↓_] {a} (A : ⟦⟧ → Set a) (m : ⟦⟧) : ⟦⟧ → Set a where ∅ : ⟦ A ⟧[ m ≤↓ m ] _∷_ : ∀ {n} → A n → ⟦ A ⟧[ m ≤↓ n ] → ⟦ A ⟧[ m ≤↓ ¡ n ] infix 21 ‼_ pattern ‼_ ⟦A⟧ = tt ∷ ⟦A⟧ -- tricky, works for all above _∷_ constructors only because it is defined afterwards, won't work for later-defined constructors testNat : ⟦⟧ testNat = ¡ ∅ testListNat : ⟦ ⟦⟧ ⟧ testListNat = ¡ ∅ ∷ ‼ ∅ ∷ ‼ ‼ ∅ ∷ ∅ ∷ ¡ ¡ ¡ ∅ ∷ ∅ testFin : ⟦⟧[ ¡ ¡ ∅ ] testFin = ‼ ∅ ⟦⟧[_≤↓_] = ⟦ Const ⊤ ⟧[_≤↓_] test≤↓ : ⟦⟧[ ‼ ‼ ‼ ∅ ≤↓ ‼ ‼ ‼ ‼ ‼ ∅ ] test≤↓ = ‼ ‼ ∅ -- m ≤ n, counting up from m to n-1 data ⟦_⟧[_↑≤_] {a} (A : ⟦⟧ → Set a) (m : ⟦⟧) : ⟦⟧ → Set a where ∅ : ⟦ A ⟧[ m ↑≤ m ] _∷_ : ∀ {n} → A m → ⟦ A ⟧[ ¡ m ↑≤ n ] → ⟦ A ⟧[ m ↑≤ n ] ⟦⟧[_↑≤_] = ⟦ Const ⊤ ⟧[_↑≤_] -- Inj (almost) data ⟦_⟧[_↓≤↓_] {a} (A : ⟦⟧ → ⟦⟧ → Set a) : ⟦⟧ → ⟦⟧ → Set a where ∅ : ∀ {n} → ⟦ A ⟧[ ∅ ↓≤↓ n ] _∷_ : ∀ {m n} → A m n → ⟦ A ⟧[ m ↓≤↓ n ] → ⟦ A ⟧[ ¡ m ↓≤↓ ¡ n ] ⟦⟧[_↓≤↓_] = ⟦ Const Const ⊤ ⟧[_↓≤↓_] ⓪ ⑴ ⑵ : ⟦⟧ ⓪ = ∅ ⑴ = ‼ ∅ ⑵ = ‼ ⑴ data D : ⟦⟧ → ⟦⟧ → Set where List : D ⓪ ⓪ Fin : D ⑴ ⑴ Vec : D ⑴ ⑴ Descend : D ⑴ ⑵ Ascend : D ⑴ ⑵ Inj : D ⑵ ⑵ open import Oscar.Level theA : ∀ ℓ → ⟦⟧ → Set (lsuc ℓ) theA ℓ ∅ = Set ℓ theA ℓ (tt ∷ x₁) = ⟦⟧ → theA ℓ x₁ theIndices : ⟦⟧ → Set theIndices x = ⟦ Const ⟦⟧ ⟧[ x ₀] μ : ∀ {p i} → D p i → ∀ {a} → theA a p → theIndices i → Set a μ List A _ = ⟦ A ⟧ μ Fin A (n ∷ _) = ⟦ A ⟧[ n ] μ Vec A (n ∷ _) = ⟦ A ⟧[ n ₀] μ Descend A (m ∷ n ∷ _) = ⟦ A ⟧[ m ≤↓ n ] μ Ascend A (m ∷ n ∷ _) = ⟦ A ⟧[ m ↑≤ n ] μ Inj A (m ∷ n ∷ ∅) = ⟦ A ⟧[ m ↓≤↓ n ] μ¡ : ∀ {p i} → D p i → theIndices i → Set μ¡ List _ = ⟦⟧ → ⟦⟧ μ¡ Fin (n ∷ _) = ⟦⟧[ n ] → ⟦⟧[ ¡ n ] μ¡ Vec (n ∷ _) = ⟦⟧[ n ₀] → ⟦⟧[ ¡ n ₀] μ¡ Descend (m ∷ n ∷ _) = ⟦⟧[ m ≤↓ n ] → ⟦⟧[ m ≤↓ ¡ n ] μ¡ Ascend (m ∷ n ∷ _) = ⟦⟧[ ¡ m ↑≤ n ] → ⟦⟧[ m ↑≤ n ] μ¡ Inj (m ∷ n ∷ _) = ⟦⟧[ m ↓≤↓ n ] → ⟦⟧[ ¡ m ↓≤↓ ¡ n ] μ¡↑ : ∀ {p i} → D p i → Set μ¡↑ List = ⟦⟧ → ⟦⟧ μ¡↑ Fin = {!!} μ¡↑ Vec = {!!} μ¡↑ Descend = {!!} μ¡↑ Ascend = {!!} μ¡↑ Inj = {!!} theArguments : ∀ {p i} → (d : D p i) → Set theArguments List = μ¡ List ∅ theArguments Fin = {n : ⟦⟧} → μ¡ Fin (n ∷ ∅) theArguments Vec = {n : ⟦⟧} → μ¡ Vec (n ∷ ∅) theArguments Descend = {m : ⟦⟧} → {n : ⟦⟧} → μ¡ Descend (m ∷ n ∷ ∅) theArguments Ascend = {m : ⟦⟧} → {n : ⟦⟧} → μ¡ Ascend (m ∷ n ∷ ∅) theArguments Inj = {m : ⟦⟧} → {n : ⟦⟧} → μ¡ Inj (m ∷ n ∷ ∅) infix 21 ↑_ ↑_ : ∀ {p i} → {d : D p i} → {I : theIndices i} → μ¡ d I ↑_ {d = List} = ‼_ ↑_ {d = Fin} {x ∷ I} = ‼_ ↑_ {d = Vec} {x ∷ I} = ‼_ ↑_ {d = Descend} {x ∷ x₁ ∷ I} = ‼_ ↑_ {d = Ascend} {x ∷ x₁ ∷ I} = tt ∷_ ↑_ {d = Inj} {x ∷ x₁ ∷ I} = tt ∷_ ↑↑ : ∀ {p i} → {d : D p i} → theArguments d ↑↑ {d = List} = {!‼_!} ↑↑ {d = Fin} = ‼_ ↑↑ {d = Vec} = ‼_ ↑↑ {d = Descend} = ‼_ ↑↑ {d = Ascend} = tt ∷_ ↑↑ {d = Inj} = tt ∷_ record BANG {p i} (d : D p i) : Set where field ⟰ : theArguments d open BANG ⦃ … ⦄ instance BANGFin : BANG Fin BANG.⟰ BANGFin {n} = ‼_ testμ : μ Fin (Const ⊤) (‼ ‼ ‼ ‼ ∅ ∷ ∅) testμ = ⟰ {d = Fin} {!!} -- ↑↑ {d = Fin} {!!} -- ↑_ {d = Fin} {I = _ ∷ {!!}} ∅ -- ↑_ {d = Fin} {I = {!!} ∷ {!!}} {!!} {- data ⟦_⟧ {a} (A : Set a) : Set a where data ⟦_⟧[_] {a} (A : ⟦⟧ → Set a) : ⟦⟧ → Set a where data ⟦_⟧[_≤↓_] {a} (A : ⟦⟧ → Set a) (m : ⟦⟧) : ⟦⟧ → Set a where data ⟦_⟧[_↑≤_] {a} (A : ⟦⟧ → Set a) (m : ⟦⟧) : ⟦⟧ → Set a where data ⟦_⟧[_↓≤↓_] {a} (A : ⟦⟧ → ⟦⟧ → Set a) : ⟦⟧ → ⟦⟧ → Set a where -}
{ "alphanum_fraction": 0.4065172175, "avg_line_length": 25.755952381, "ext": "agda", "hexsha": "c1e93497fd18d54b62222a5ed78880e720c1445e", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_forks_repo_licenses": [ "RSA-MD" ], "max_forks_repo_name": "m0davis/oscar", "max_forks_repo_path": "archive/agda-2/Oscar/Data3.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_issues_repo_issues_event_max_datetime": "2019-05-11T23:33:04.000Z", "max_issues_repo_issues_event_min_datetime": "2019-04-29T00:35:04.000Z", "max_issues_repo_licenses": [ "RSA-MD" ], "max_issues_repo_name": "m0davis/oscar", "max_issues_repo_path": "archive/agda-2/Oscar/Data3.agda", "max_line_length": 154, "max_stars_count": null, "max_stars_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_stars_repo_licenses": [ "RSA-MD" ], "max_stars_repo_name": "m0davis/oscar", "max_stars_repo_path": "archive/agda-2/Oscar/Data3.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 2465, "size": 4327 }
module SimpleTT where data 𝟘 : Set where absurd : ∀ {ℓ} {A : Set ℓ} → 𝟘 → A absurd () data _⁺ (A : Set) : Set where Z : A ⁺ S : A → A ⁺ record Signature : Set₁ where field ty-op : Set tm-op : Set ty-ty-arg : ty-op → Set -- ty-tm-arg : ty-op → Set -- tm-ty-arg : tm-op → Set tm-tm-arg : tm-op → Set open Signature data Theory : Set₁ thy-signature : Theory → Signature data Ty (T : Theory) : Set data Tm (T : Theory) (A : Ty T) : Set data Theory where thy-empty : Theory th-type : ∀ (T : Theory) → (α : Set) → (α → Ty T) → Theory th-term : ∀ (T : Theory) → (α : Set) → (α → Ty T) → Ty T → Theory thy-signature thy-empty = record { ty-op = 𝟘 ; tm-op = 𝟘 ; ty-ty-arg = absurd ; tm-tm-arg = absurd } thy-signature (th-type T α x) = record { ty-op = (ty-op Σ) ⁺ ; tm-op = tm-op Σ ; ty-ty-arg = t ; tm-tm-arg = tm-tm-arg Σ } where Σ = thy-signature T t : ∀ (f : (ty-op Σ) ⁺) → Set t Z = α t (S f) = ty-ty-arg (thy-signature T) f thy-signature (th-term T α ts t) = record { ty-op = ty-op Σ ; tm-op = (tm-op Σ) ⁺ ; ty-ty-arg = ty-ty-arg Σ ; tm-tm-arg = tm } where Σ = thy-signature T tm : ∀ (f : (tm-op Σ) ⁺) → Set tm Z = {!!} tm (S x) = {!!} data Ty T where ty-expr : ∀ (f : ty-op (thy-signature T)) → (ty-ty-arg (thy-signature T) f → Ty T) → Ty T data Tm T A where
{ "alphanum_fraction": 0.4585459184, "avg_line_length": 23.0588235294, "ext": "agda", "hexsha": "c7ade1a29356fc1999a888784079d6a94bf3ec05", "lang": "Agda", "max_forks_count": 6, "max_forks_repo_forks_event_max_datetime": "2021-05-24T02:51:43.000Z", "max_forks_repo_forks_event_min_datetime": "2021-02-16T13:43:07.000Z", "max_forks_repo_head_hexsha": "2aaf850bb1a262681c5a232cdefae312f921b9d4", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "andrejbauer/formaltt", "max_forks_repo_path": "src/Experimental/SimpleTT.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "2aaf850bb1a262681c5a232cdefae312f921b9d4", "max_issues_repo_issues_event_max_datetime": "2021-05-14T16:15:17.000Z", "max_issues_repo_issues_event_min_datetime": "2021-04-30T14:18:25.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "andrejbauer/formaltt", "max_issues_repo_path": "src/Experimental/SimpleTT.agda", "max_line_length": 93, "max_stars_count": 21, "max_stars_repo_head_hexsha": "0a9d25e6e3965913d9b49a47c88cdfb94b55ffeb", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cilinder/formaltt", "max_stars_repo_path": "src/Experimental/SimpleTT.agda", "max_stars_repo_stars_event_max_datetime": "2021-11-19T15:50:08.000Z", "max_stars_repo_stars_event_min_datetime": "2021-02-16T14:07:06.000Z", "num_tokens": 590, "size": 1568 }
-- Copyright: (c) 2016 Ertugrul Söylemez -- License: BSD3 -- Maintainer: Ertugrul Söylemez <[email protected]> module Algebra.Category.Category where open import Algebra.Category.Semigroupoid open import Core -- A category is a semigroupoid with an identity morphism on every -- object. record Category {c h r} : Set (lsuc (c ⊔ h ⊔ r)) where field semigroupoid : Semigroupoid {c} {h} {r} open Semigroupoid semigroupoid public field id : ∀ {A} → Hom A A left-id : ∀ {A B} (f : Hom A B) → id ∘ f ≈ f right-id : ∀ {A B} (f : Hom A B) → f ∘ id ≈ f -- The identity morphism is unique for each object. id-unique : ∀ {A} {id' : Hom A A} → id' ∘ id ≈ id → id' ≈ id id-unique {id' = id'} left-id' = begin id' ≈[ sym (right-id _) ] id' ∘ id ≈[ left-id' ] id qed private ∘-monic : ∀ {A B C} {f : Hom B C} {g : Hom A B} → Monic f → Monic g → Monic (f ∘ g) ∘-monic {f = f} {g} pf pg {g1 = g1} {g2} p = pg $ pf $ begin f ∘ (g ∘ g1) ≈[ sym (assoc f g g1) ] f ∘ g ∘ g1 ≈[ p ] f ∘ g ∘ g2 ≈[ assoc f g g2 ] f ∘ (g ∘ g2) qed BimonicEq : Equiv Ob BimonicEq = record { _≈_ = _bimonic_; refl = record { to = id; from = id; to-monic = id-monic; from-monic = id-monic }; sym = λ m → let module m = _bimonic_ m in record { to = m.from; from = m.to; to-monic = m.from-monic; from-monic = m.to-monic }; trans = λ m1 m2 → let module m1 = _bimonic_ m1 module m2 = _bimonic_ m2 in record { to = m2.to ∘ m1.to; from = m1.from ∘ m2.from; to-monic = ∘-monic m2.to-monic m1.to-monic; from-monic = ∘-monic m1.from-monic m2.from-monic } } where id-monic : ∀ {A} → Monic (id {A}) id-monic {g1 = g1} {g2} p = begin g1 ≈[ sym (left-id g1) ] id ∘ g1 ≈[ p ] id ∘ g2 ≈[ left-id g2 ] g2 qed module BimonicEq = Equiv BimonicEq -- Isomorphisms record Iso {A B} (f : Hom A B) : Set (h ⊔ r) where field inv : Hom B A left-inv : inv ∘ f ≈ id right-inv : f ∘ inv ≈ id -- Inverses are unique for each morphism. inv-unique : ∀ g → f ∘ g ≈ id → g ≈ inv inv-unique g right-inv' = begin g ≈[ sym (left-id g) ] id ∘ g ≈[ ∘-cong (sym left-inv) refl ] (inv ∘ f) ∘ g ≈[ assoc inv f g ] inv ∘ (f ∘ g) ≈[ ∘-cong refl right-inv' ] inv ∘ id ≈[ right-id inv ] inv qed inv-iso : Iso inv inv-iso = record { inv = f; left-inv = right-inv; right-inv = left-inv } inv-invol : ∀ g h → g ∘ f ≈ id → h ∘ g ≈ id → f ≈ h inv-invol g h g-left-inv h-left-inv = begin f ≈[ sym (left-id f) ] id ∘ f ≈[ ∘-cong (sym h-left-inv) refl ] (h ∘ g) ∘ f ≈[ assoc h g f ] h ∘ (g ∘ f) ≈[ ∘-cong refl g-left-inv ] h ∘ id ≈[ right-id h ] h qed record _≃_ A B : Set (h ⊔ r) where field to : Hom A B iso : Iso to open Iso iso public IsoEq : Equiv Ob IsoEq = record { _≈_ = _≃_; refl = irefl; sym = isym; trans = itrans } where irefl : ∀ {A} → A ≃ A irefl = record { to = id; iso = record { inv = id; left-inv = left-id id; right-inv = left-id id } } isym : ∀ {A B} → A ≃ B → B ≃ A isym iso = record { to = iso.inv; iso = record { inv = iso.to; left-inv = iso.right-inv; right-inv = iso.left-inv } } where module iso = _≃_ iso itrans : ∀ {A B C} → A ≃ B → B ≃ C → A ≃ C itrans iso1 iso2 = record { to = iso2.to ∘ iso1.to; iso = record { inv = iso1.inv ∘ iso2.inv; left-inv = begin iso1.inv ∘ iso2.inv ∘ (iso2.to ∘ iso1.to) ≈[ assoc iso1.inv iso2.inv (iso2.to ∘ iso1.to) ] iso1.inv ∘ (iso2.inv ∘ (iso2.to ∘ iso1.to)) ≈[ ∘-cong refl (sym (assoc iso2.inv iso2.to iso1.to)) ] iso1.inv ∘ (iso2.inv ∘ iso2.to ∘ iso1.to) ≈[ ∘-cong refl (∘-cong iso2.left-inv refl) ] iso1.inv ∘ (id ∘ iso1.to) ≈[ ∘-cong refl (left-id iso1.to) ] iso1.inv ∘ iso1.to ≈[ iso1.left-inv ] id qed; right-inv = begin iso2.to ∘ iso1.to ∘ (iso1.inv ∘ iso2.inv) ≈[ assoc iso2.to iso1.to (iso1.inv ∘ iso2.inv) ] iso2.to ∘ (iso1.to ∘ (iso1.inv ∘ iso2.inv)) ≈[ ∘-cong refl (sym (assoc iso1.to iso1.inv iso2.inv)) ] iso2.to ∘ (iso1.to ∘ iso1.inv ∘ iso2.inv) ≈[ ∘-cong refl (∘-cong iso1.right-inv refl) ] iso2.to ∘ (id ∘ iso2.inv) ≈[ ∘-cong refl (left-id iso2.inv) ] iso2.to ∘ iso2.inv ≈[ iso2.right-inv ] id qed } } where module iso1 = _≃_ iso1 module iso2 = _≃_ iso2 Iso→Epic : ∀ {A B} {f : Hom A B} → Iso f → Epic f Iso→Epic {f = f} iso {g1 = g1} {g2} p = begin g1 ≈[ sym (right-id g1) ] g1 ∘ id ≈[ ∘-cong refl (sym iso.right-inv) ] g1 ∘ (f ∘ iso.inv) ≈[ sym (assoc g1 f iso.inv) ] g1 ∘ f ∘ iso.inv ≈[ ∘-cong p refl ] g2 ∘ f ∘ iso.inv ≈[ assoc g2 f iso.inv ] g2 ∘ (f ∘ iso.inv) ≈[ ∘-cong refl iso.right-inv ] g2 ∘ id ≈[ right-id g2 ] g2 qed where module iso = Iso iso Iso→Monic : ∀ {A B} {f : Hom A B} → Iso f → Monic f Iso→Monic {f = f} iso {g1 = g1} {g2} p = begin g1 ≈[ sym (left-id g1) ] id ∘ g1 ≈[ ∘-cong (sym iso.left-inv) refl ] iso.inv ∘ f ∘ g1 ≈[ assoc iso.inv f g1 ] iso.inv ∘ (f ∘ g1) ≈[ ∘-cong refl p ] iso.inv ∘ (f ∘ g2) ≈[ sym (assoc iso.inv f g2) ] iso.inv ∘ f ∘ g2 ≈[ ∘-cong iso.left-inv refl ] id ∘ g2 ≈[ left-id g2 ] g2 qed where module iso = Iso iso MonicOrd : PartialOrder Ob MonicOrd = record { Eq = BimonicEq; _≤_ = _≤_; antisym = antisym; refl' = refl'; trans = mtrans } where _≤_ : Ob → Ob → Set _ A ≤ B = ∃ (λ (f : Hom A B) → Monic f) antisym : ∀ {A B} → A ≤ B → B ≤ A → A bimonic B antisym A≤B B≤A = record { to = fst A≤B; from = fst B≤A; to-monic = snd A≤B; from-monic = snd B≤A } refl' : ∀ {A B} → A bimonic B → A ≤ B refl' bi = _bimonic_.to bi , _bimonic_.to-monic bi mtrans : ∀ {A B C} → A ≤ B → B ≤ C → A ≤ C mtrans (f , p) (g , q) = g ∘ f , ∘-monic q p -- A functor is a structure-preserving mapping from one category to -- another. record Functor {cc ch cr dc dh dr} (C : Category {cc} {ch} {cr}) (D : Category {dc} {dh} {dr}) : Set (cc ⊔ ch ⊔ cr ⊔ dc ⊔ dh ⊔ dr) where private module C = Category C module D = Category D field semifunctor : Semifunctor C.semigroupoid D.semigroupoid open Semifunctor semifunctor public field id-preserving : ∀ {A} → map (C.id {A}) D.≈ D.id {F A} Iso-preserving : ∀ {A B} {f : C.Hom A B} → C.Iso f → D.Iso (map f) Iso-preserving {f = f} p = record { inv = map inv; left-inv = D.begin map inv D.∘ map f D.≈[ D.sym (∘-preserving inv f) ] map (inv C.∘ f) D.≈[ map-cong left-inv ] map C.id D.≈[ id-preserving ] D.id D.qed; right-inv = D.begin map f D.∘ map inv D.≈[ D.sym (∘-preserving f inv) ] map (f C.∘ inv) D.≈[ map-cong right-inv ] map C.id D.≈[ id-preserving ] D.id D.qed } where open Category.Iso p -- Category of types and functions. Sets : ∀ {r} → Category Sets {r} = record { semigroupoid = record { Ob = Set r; Hom = λ A B → A → B; Eq = λ {A B} → FuncEq A B; _∘_ = _∘_; ∘-cong = ∘-cong; assoc = λ _ _ _ _ → PropEq.refl }; id = λ x → x; left-id = λ _ _ → PropEq.refl; right-id = λ _ _ → PropEq.refl } where open module MyEquiv {A} {B} = Equiv (FuncEq A B) _∘_ : {A B C : Set r} (f : B → C) (g : A → B) → A → C (f ∘ g) x = f (g x) infixl 6 _∘_ ∘-cong : ∀ {A B C} {f1 f2 : B → C} {g1 g2 : A → B} → f1 ≈ f2 → g1 ≈ g2 → f1 ∘ g1 ≈ f2 ∘ g2 ∘-cong {f1 = f1} f1≈f2 g1≈g2 x = PropEq.trans (cong f1 (g1≈g2 _)) (f1≈f2 _) module Sets {r} = Category (Sets {r}) injective→monic : ∀ {a} {A B : Set a} {f : A → B} → (∀ {x y} → f x ≡ f y → x ≡ y) → Sets.Monic f injective→monic inj p x = inj (p x) monic→injective : ∀ {a} {A B : Set a} {f : A → B} → Sets.Monic f → ∀ {x y} → f x ≡ f y → x ≡ y monic→injective monic p = monic Sets.id p surjective→epic : ∀ {a} {A B : Set a} {f : A → B} → (∀ y → ∃ (λ x → f x ≡ y)) → Sets.Epic f surjective→epic {f = f} surj {g1 = g1} {g2} p y with surj y surjective→epic {f = f} surj {g1 = g1} {g2} p y | x , q = begin g1 y ≈[ cong g1 (sym q) ] g1 (f x) ≈[ p x ] g2 (f x) ≈[ cong g2 q ] g2 y qed where open module MyEquiv {A} = Equiv (PropEq A)
{ "alphanum_fraction": 0.4519614013, "avg_line_length": 25.3563829787, "ext": "agda", "hexsha": "6317f9e884bb0cc1415a03c123a03e8b0ce3a8e4", "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": "d9245e5a8b2e902781736de09bd17e81022f6f13", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "esoeylemez/agda-simple", "max_forks_repo_path": "Algebra/Category/Category.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "d9245e5a8b2e902781736de09bd17e81022f6f13", "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": "esoeylemez/agda-simple", "max_issues_repo_path": "Algebra/Category/Category.agda", "max_line_length": 114, "max_stars_count": 1, "max_stars_repo_head_hexsha": "d9245e5a8b2e902781736de09bd17e81022f6f13", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "esoeylemez/agda-simple", "max_stars_repo_path": "Algebra/Category/Category.agda", "max_stars_repo_stars_event_max_datetime": "2019-10-07T17:36:42.000Z", "max_stars_repo_stars_event_min_datetime": "2019-10-07T17:36:42.000Z", "num_tokens": 3641, "size": 9534 }
{-# OPTIONS --safe #-} {- Properties of nullary relations, i.e. structures on types. Includes several results from [Notions of Anonymous Existence in Martin-Löf Type Theory](https://lmcs.episciences.org/3217) by Altenkirch, Coquand, Escardo, Kraus. -} module Cubical.Relation.Nullary.Properties where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Function open import Cubical.Foundations.Isomorphism open import Cubical.Foundations.Equiv open import Cubical.Functions.Fixpoint open import Cubical.Data.Empty as ⊥ open import Cubical.Relation.Nullary.Base open import Cubical.HITs.PropositionalTruncation.Base private variable ℓ : Level A : Type ℓ IsoPresDiscrete : ∀ {ℓ ℓ'}{A : Type ℓ} {B : Type ℓ'} → Iso A B → Discrete A → Discrete B IsoPresDiscrete e dA x y with dA (Iso.inv e x) (Iso.inv e y) ... | yes p = subst Dec (λ i → Iso.rightInv e x i ≡ Iso.rightInv e y i) (yes (cong (Iso.fun e) p)) ... | no p = subst Dec (λ i → Iso.rightInv e x i ≡ Iso.rightInv e y i) (no λ q → p (sym (Iso.leftInv e (Iso.inv e x)) ∙∙ cong (Iso.inv e) q ∙∙ Iso.leftInv e (Iso.inv e y))) EquivPresDiscrete : ∀ {ℓ ℓ'}{A : Type ℓ} {B : Type ℓ'} → A ≃ B → Discrete A → Discrete B EquivPresDiscrete e = IsoPresDiscrete (equivToIso e) isProp¬ : (A : Type ℓ) → isProp (¬ A) isProp¬ A p q i x = isProp⊥ (p x) (q x) i Stable¬ : Stable (¬ A) Stable¬ ¬¬¬a a = ¬¬¬a ¬¬a where ¬¬a = λ ¬a → ¬a a fromYes : A → Dec A → A fromYes _ (yes a) = a fromYes a (no _) = a discreteDec : (Adis : Discrete A) → Discrete (Dec A) discreteDec Adis (yes p) (yes p') = decideYes (Adis p p') -- TODO: monad would simply stuff where decideYes : Dec (p ≡ p') → Dec (yes p ≡ yes p') decideYes (yes eq) = yes (cong yes eq) decideYes (no ¬eq) = no λ eq → ¬eq (cong (fromYes p) eq) discreteDec Adis (yes p) (no ¬p) = ⊥.rec (¬p p) discreteDec Adis (no ¬p) (yes p) = ⊥.rec (¬p p) discreteDec {A = A} Adis (no ¬p) (no ¬p') = yes (cong no (isProp¬ A ¬p ¬p')) isPropDec : (Aprop : isProp A) → isProp (Dec A) isPropDec Aprop (yes a) (yes a') = cong yes (Aprop a a') isPropDec Aprop (yes a) (no ¬a) = ⊥.rec (¬a a) isPropDec Aprop (no ¬a) (yes a) = ⊥.rec (¬a a) isPropDec {A = A} Aprop (no ¬a) (no ¬a') = cong no (isProp¬ A ¬a ¬a') mapDec : ∀ {B : Type ℓ} → (A → B) → (¬ A → ¬ B) → Dec A → Dec B mapDec f _ (yes p) = yes (f p) mapDec _ f (no ¬p) = no (f ¬p) EquivPresDec : ∀ {ℓ ℓ'}{A : Type ℓ} {B : Type ℓ'} → A ≃ B → Dec A → Dec B EquivPresDec p = mapDec (p .fst) (λ f → f ∘ invEq p) ¬→¬∥∥ : ¬ A → ¬ ∥ A ∥ ¬→¬∥∥ ¬p ∣ a ∣ = ¬p a ¬→¬∥∥ ¬p (squash x y i) = isProp⊥ (¬→¬∥∥ ¬p x) (¬→¬∥∥ ¬p y) i Dec∥∥ : Dec A → Dec ∥ A ∥ Dec∥∥ = mapDec ∣_∣ ¬→¬∥∥ -- we have the following implications -- X ── ∣_∣ ─→ ∥ X ∥ -- ∥ X ∥ ── populatedBy ─→ ⟪ X ⟫ -- ⟪ X ⟫ ── notEmptyPopulated ─→ NonEmpty X -- reexport propositional truncation for uniformity open Cubical.HITs.PropositionalTruncation.Base using (∣_∣) public populatedBy : ∥ A ∥ → ⟪ A ⟫ populatedBy {A = A} a (f , fIsConst) = h a where h : ∥ A ∥ → Fixpoint f h ∣ a ∣ = f a , fIsConst (f a) a h (squash a b i) = 2-Constant→isPropFixpoint f fIsConst (h a) (h b) i notEmptyPopulated : ⟪ A ⟫ → NonEmpty A notEmptyPopulated {A = A} pop u = u (fixpoint (pop (h , hIsConst))) where h : A → A h a = ⊥.elim (u a) hIsConst : ∀ x y → h x ≡ h y hIsConst x y i = ⊥.elim (isProp⊥ (u x) (u y) i) -- these implications induce the following for different kinds of stability, gradually weakening the assumption Dec→Stable : Dec A → Stable A Dec→Stable (yes x) = λ _ → x Dec→Stable (no x) = λ f → ⊥.elim (f x) Stable→PStable : Stable A → PStable A Stable→PStable st = st ∘ notEmptyPopulated PStable→SplitSupport : PStable A → SplitSupport A PStable→SplitSupport pst = pst ∘ populatedBy -- Although SplitSupport and Collapsible are not properties, their path versions, HSeparated and Collapsible≡, are. -- Nevertheless they are logically equivalent SplitSupport→Collapsible : SplitSupport A → Collapsible A SplitSupport→Collapsible {A = A} hst = h , hIsConst where h : A → A h p = hst ∣ p ∣ hIsConst : 2-Constant h hIsConst p q i = hst (squash ∣ p ∣ ∣ q ∣ i) Collapsible→SplitSupport : Collapsible A → SplitSupport A Collapsible→SplitSupport f x = fixpoint (populatedBy x f) HSeparated→Collapsible≡ : HSeparated A → Collapsible≡ A HSeparated→Collapsible≡ hst x y = SplitSupport→Collapsible (hst x y) Collapsible≡→HSeparated : Collapsible≡ A → HSeparated A Collapsible≡→HSeparated col x y = Collapsible→SplitSupport (col x y) -- stability of path space under truncation or path collapsability are necessary and sufficient properties -- for a a type to be a set. Collapsible≡→isSet : Collapsible≡ A → isSet A Collapsible≡→isSet {A = A} col a b p q = p≡q where f : (x : A) → a ≡ x → a ≡ x f x = col a x .fst fIsConst : (x : A) → (p q : a ≡ x) → f x p ≡ f x q fIsConst x = col a x .snd rem : (p : a ≡ b) → PathP (λ i → a ≡ p i) (f a refl) (f b p) rem p j = f (p j) (λ i → p (i ∧ j)) p≡q : p ≡ q p≡q j i = hcomp (λ k → λ { (i = i0) → f a refl k ; (i = i1) → fIsConst b p q j k ; (j = i0) → rem p i k ; (j = i1) → rem q i k }) a HSeparated→isSet : HSeparated A → isSet A HSeparated→isSet = Collapsible≡→isSet ∘ HSeparated→Collapsible≡ isSet→HSeparated : isSet A → HSeparated A isSet→HSeparated setA x y = extract where extract : ∥ x ≡ y ∥ → x ≡ y extract ∣ p ∣ = p extract (squash p q i) = setA x y (extract p) (extract q) i -- by the above more sufficient conditions to inhibit isSet A are given PStable≡→HSeparated : PStable≡ A → HSeparated A PStable≡→HSeparated pst x y = PStable→SplitSupport (pst x y) PStable≡→isSet : PStable≡ A → isSet A PStable≡→isSet = HSeparated→isSet ∘ PStable≡→HSeparated Separated→PStable≡ : Separated A → PStable≡ A Separated→PStable≡ st x y = Stable→PStable (st x y) Separated→isSet : Separated A → isSet A Separated→isSet = PStable≡→isSet ∘ Separated→PStable≡ -- Proof of Hedberg's theorem: a type with decidable equality is an h-set Discrete→Separated : Discrete A → Separated A Discrete→Separated d x y = Dec→Stable (d x y) Discrete→isSet : Discrete A → isSet A Discrete→isSet = Separated→isSet ∘ Discrete→Separated
{ "alphanum_fraction": 0.6251379909, "avg_line_length": 35.2277777778, "ext": "agda", "hexsha": "0c6dd66cadb5b8c812f27e44367a17065fd9fde7", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "1b9c97a2140fe96fe636f4c66beedfd7b8096e8f", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "howsiyu/cubical", "max_forks_repo_path": "Cubical/Relation/Nullary/Properties.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "1b9c97a2140fe96fe636f4c66beedfd7b8096e8f", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "howsiyu/cubical", "max_issues_repo_path": "Cubical/Relation/Nullary/Properties.agda", "max_line_length": 123, "max_stars_count": null, "max_stars_repo_head_hexsha": "1b9c97a2140fe96fe636f4c66beedfd7b8096e8f", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "howsiyu/cubical", "max_stars_repo_path": "Cubical/Relation/Nullary/Properties.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 2432, "size": 6341 }
{-# OPTIONS --without-K --safe #-} module Categories.Category.Instance.Properties.Setoids where open import Categories.Category.Instance.Properties.Setoids.Complete using (Setoids-Complete) public open import Categories.Category.Instance.Properties.Setoids.Cocomplete using (Setoids-Cocomplete) public open import Categories.Category.Instance.Properties.Setoids.LCCC using (Setoids-LCCC) public
{ "alphanum_fraction": 0.802919708, "avg_line_length": 25.6875, "ext": "agda", "hexsha": "bd3080c292ad05ece55205d6e5dd9a545bc117a4", "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": "6cbfdf3f1be15ef513435e3b85faae92cb1ac36f", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "bond15/agda-categories", "max_forks_repo_path": "src/Categories/Category/Instance/Properties/Setoids.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "6cbfdf3f1be15ef513435e3b85faae92cb1ac36f", "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": "bond15/agda-categories", "max_issues_repo_path": "src/Categories/Category/Instance/Properties/Setoids.agda", "max_line_length": 70, "max_stars_count": null, "max_stars_repo_head_hexsha": "6cbfdf3f1be15ef513435e3b85faae92cb1ac36f", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "bond15/agda-categories", "max_stars_repo_path": "src/Categories/Category/Instance/Properties/Setoids.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 82, "size": 411 }
open import Relation.Binary.PropositionalEquality using ( refl ) open import Web.Semantic.DL.ABox.Interp using ( _*_ ; ⌊_⌋ ; ind ) open import Web.Semantic.DL.ABox.Interp.Morphism using ( _,_ ) open import Web.Semantic.DL.ABox.Model using ( _⊨a_ ; on-bnode ; bnodes ; ⊨a-resp-≲ ; ⊨a-resp-≡³ ; _,_ ) open import Web.Semantic.DL.Category.Object using ( Object ; IN ; iface ) open import Web.Semantic.DL.Category.Morphism using ( _⇒_ ; BN ; impl ; _≣_ ; _⊑_ ; _,_ ) open import Web.Semantic.DL.Category.Composition using ( _∙_ ) open import Web.Semantic.DL.Category.Properties.Composition.Lemmas using ( compose-left ; compose-right ; compose-resp-⊨a ) open import Web.Semantic.DL.Signature using ( Signature ) open import Web.Semantic.DL.TBox using ( TBox ) open import Web.Semantic.DL.TBox.Interp using ( Δ ; _⊨_≈_ ; ≈-refl ; ≈-sym ) open import Web.Semantic.DL.TBox.Interp.Morphism using ( ≲-refl ) open import Web.Semantic.Util using ( _∘_ ; _⊕_⊕_ ; False ; inode ; bnode ; enode ; left ; right ) module Web.Semantic.DL.Category.Properties.Composition.Assoc {Σ : Signature} {S T : TBox Σ} where compose-assoc : ∀ {A B C D : Object S T} (F : A ⇒ B) (G : B ⇒ C) (H : C ⇒ D) → ((F ∙ G) ∙ H ≣ F ∙ (G ∙ H)) compose-assoc {A} {B} {C} {D} F G H = (LHS⊑RHS , RHS⊑LHS) where LHS⊑RHS : (F ∙ G) ∙ H ⊑ F ∙ (G ∙ H) LHS⊑RHS I I⊨STA I⊨LHS = (f , I⊨RHS) where f : (BN F ⊕ IN B ⊕ (BN G ⊕ IN C ⊕ BN H)) → Δ ⌊ I ⌋ f (inode u) = ind I (bnode (inode (inode u))) f (bnode y) = ind I (bnode (inode (bnode y))) f (enode (inode v)) = ind I (bnode (inode (enode v))) f (enode (bnode z)) = ind I (bnode (bnode z)) f (enode (enode w)) = ind I (bnode (enode w)) I⊨F : left * bnodes I f ⊨a impl F I⊨F = ⊨a-resp-≡³ (left * left * I) (on-bnode f (ind I) ∘ left) refl (impl F) (compose-left F G (left * I) (compose-left (F ∙ G) H I I⊨LHS)) I⊨G : left * right * bnodes I f ⊨a impl G I⊨G = ⊨a-resp-≡³ (right * left * I) (on-bnode f (ind I) ∘ right ∘ left) refl (impl G) (compose-right F G (left * I) (compose-left (F ∙ G) H I I⊨LHS)) I⊨H : right * right * bnodes I f ⊨a impl H I⊨H = ⊨a-resp-≡³ (right * I) (on-bnode f (ind I) ∘ right ∘ right) refl (impl H) (compose-right (F ∙ G) H I I⊨LHS) I⊨RHS : bnodes I f ⊨a impl (F ∙ (G ∙ H)) I⊨RHS = compose-resp-⊨a F (G ∙ H) (bnodes I f) I⊨F (compose-resp-⊨a G H (right * bnodes I f) I⊨G I⊨H) RHS⊑LHS : F ∙ (G ∙ H) ⊑ (F ∙ G) ∙ H RHS⊑LHS I I⊨STA I⊨RHS = (f , I⊨LHS) where f : ((BN F ⊕ IN B ⊕ BN G) ⊕ IN C ⊕ BN H) → Δ ⌊ I ⌋ f (inode (inode u)) = ind I (bnode (inode u)) f (inode (bnode y)) = ind I (bnode (bnode y)) f (inode (enode v)) = ind I (bnode (enode (inode v))) f (bnode z) = ind I (bnode (enode (bnode z))) f (enode w) = ind I (bnode (enode (enode w))) I⊨F : left * left * bnodes I f ⊨a impl F I⊨F = ⊨a-resp-≡³ (left * I) (on-bnode f (ind I) ∘ left ∘ left) refl (impl F) (compose-left F (G ∙ H) I I⊨RHS) I⊨G : right * left * bnodes I f ⊨a impl G I⊨G = ⊨a-resp-≡³ (left * right * I) (on-bnode f (ind I) ∘ left ∘ right) refl (impl G) (compose-left G H (right * I) (compose-right F (G ∙ H) I I⊨RHS)) I⊨H : right * bnodes I f ⊨a impl H I⊨H = ⊨a-resp-≡³ (right * right * I) (on-bnode f (ind I) ∘ right) refl (impl H) (compose-right G H (right * I) (compose-right F (G ∙ H) I I⊨RHS)) I⊨LHS : bnodes I f ⊨a impl ((F ∙ G) ∙ H) I⊨LHS = compose-resp-⊨a (F ∙ G) H (bnodes I f) (compose-resp-⊨a F G (left * bnodes I f) I⊨F I⊨G) I⊨H
{ "alphanum_fraction": 0.5714285714, "avg_line_length": 44.746835443, "ext": "agda", "hexsha": "2120ef948c5d250ba46266473651865fd2f17a8d", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:40:03.000Z", "max_forks_repo_forks_event_min_datetime": "2017-12-03T14:52:09.000Z", "max_forks_repo_head_hexsha": "8ddbe83965a616bff6fc7a237191fa261fa78bab", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "agda/agda-web-semantic", "max_forks_repo_path": "src/Web/Semantic/DL/Category/Properties/Composition/Assoc.agda", "max_issues_count": 4, "max_issues_repo_head_hexsha": "8ddbe83965a616bff6fc7a237191fa261fa78bab", "max_issues_repo_issues_event_max_datetime": "2021-01-04T20:57:19.000Z", "max_issues_repo_issues_event_min_datetime": "2018-11-14T02:32:28.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "agda/agda-web-semantic", "max_issues_repo_path": "src/Web/Semantic/DL/Category/Properties/Composition/Assoc.agda", "max_line_length": 80, "max_stars_count": 9, "max_stars_repo_head_hexsha": "8ddbe83965a616bff6fc7a237191fa261fa78bab", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "agda/agda-web-semantic", "max_stars_repo_path": "src/Web/Semantic/DL/Category/Properties/Composition/Assoc.agda", "max_stars_repo_stars_event_max_datetime": "2020-03-14T14:21:08.000Z", "max_stars_repo_stars_event_min_datetime": "2015-09-13T17:46:41.000Z", "num_tokens": 1591, "size": 3535 }
module Esterel.Variable.Shared where open import Data.Nat using (ℕ) renaming (_≟_ to _≟ℕ_) open import Function using (_∘_) open import Relation.Nullary using (Dec ; yes ; no ; ¬_) open import Relation.Binary using (Decidable) open import Relation.Binary.PropositionalEquality using (_≡_ ; refl ; cong ; trans ; sym) data SharedVar : Set where _ₛₕ : ℕ → SharedVar unwrap : SharedVar → ℕ unwrap (n ₛₕ) = n unwrap-inverse : ∀ {s} → (unwrap s) ₛₕ ≡ s unwrap-inverse {_ ₛₕ} = refl unwrap-injective : ∀ {s t} → unwrap s ≡ unwrap t → s ≡ t unwrap-injective s'≡t' = trans (sym unwrap-inverse) (trans (cong _ₛₕ s'≡t') unwrap-inverse) -- for backward compatibility unwrap-neq : ∀{k1 : SharedVar} → ∀{k2 : SharedVar} → ¬ k1 ≡ k2 → ¬ (unwrap k1) ≡ (unwrap k2) unwrap-neq = (_∘ unwrap-injective) wrap : ℕ → SharedVar wrap = _ₛₕ bijective : ∀{x} → unwrap (wrap x) ≡ x bijective = refl _≟_ : Decidable {A = SharedVar} _≡_ (s ₛₕ) ≟ (t ₛₕ) with s ≟ℕ t ... | yes p = yes (cong _ₛₕ p) ... | no ¬p = no (¬p ∘ cong unwrap) data Status : Set where ready : Status new : Status old : Status _≟ₛₜ_ : Decidable {A = Status} _≡_ ready ≟ₛₜ ready = yes refl ready ≟ₛₜ new = no λ() ready ≟ₛₜ old = no λ() new ≟ₛₜ ready = no λ() new ≟ₛₜ new = yes refl new ≟ₛₜ old = no λ() old ≟ₛₜ ready = no λ() old ≟ₛₜ new = no λ() old ≟ₛₜ old = yes refl
{ "alphanum_fraction": 0.6273792094, "avg_line_length": 23.5517241379, "ext": "agda", "hexsha": "8c8213a141a08228c69d6c0738b68ee3987b4902", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2020-04-15T20:02:49.000Z", "max_forks_repo_forks_event_min_datetime": "2020-04-15T20:02:49.000Z", "max_forks_repo_head_hexsha": "4340bef3f8df42ab8167735d35a4cf56243a45cd", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "florence/esterel-calculus", "max_forks_repo_path": "agda/Esterel/Variable/Shared.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "4340bef3f8df42ab8167735d35a4cf56243a45cd", "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": "florence/esterel-calculus", "max_issues_repo_path": "agda/Esterel/Variable/Shared.agda", "max_line_length": 92, "max_stars_count": 3, "max_stars_repo_head_hexsha": "4340bef3f8df42ab8167735d35a4cf56243a45cd", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "florence/esterel-calculus", "max_stars_repo_path": "agda/Esterel/Variable/Shared.agda", "max_stars_repo_stars_event_max_datetime": "2020-07-01T03:59:31.000Z", "max_stars_repo_stars_event_min_datetime": "2020-04-16T10:58:53.000Z", "num_tokens": 553, "size": 1366 }
open import Relation.Binary using (IsDecEquivalence) open import Agda.Builtin.Equality module UnifyMguL (A : Set) ⦃ isDecEquivalenceA : IsDecEquivalence (_≡_ {A = A}) ⦄ where open import UnifyTermL A open import Data.Product using (∃; _,_) open import Data.Maybe using (Maybe; just; nothing) open import Category.Monad using (RawMonad) import Level open RawMonad (Data.Maybe.monad {Level.zero}) open import Relation.Binary.PropositionalEquality open import Relation.Nullary open IsDecEquivalence isDecEquivalenceA amgu : ∀ {m} (s t : Term m) (acc : ∃ (AList m)) -> Maybe (∃ (AList m)) amgu (leaf l₁) (leaf l₂) acc with l₁ ≟ l₂ … | yes _ = just acc … | no _ = nothing amgu (leaf l) (s' fork t') acc = nothing amgu (s' fork t') (leaf l) acc = nothing amgu (s1 fork s2) (t1 fork t2) acc = amgu s2 t2 =<< amgu s1 t1 acc amgu (i x) (i y) (m , anil) = just (flexFlex x y) amgu (i x) t (m , anil) = flexRigid x t amgu t (i x) (m , anil) = flexRigid x t amgu s t (n , σ asnoc r / z) = (λ σ -> σ ∃asnoc r / z) <$> amgu ((r for z) ◃ s) ((r for z) ◃ t) (n , σ) mgu : ∀ {m} -> (s t : Term m) -> Maybe (∃ (AList m)) mgu {m} s t = amgu s t (m , anil)
{ "alphanum_fraction": 0.6192468619, "avg_line_length": 33.1944444444, "ext": "agda", "hexsha": "a7c6e6d5b2705f08073583aa02895e2a1cc70724", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_forks_repo_licenses": [ "RSA-MD" ], "max_forks_repo_name": "m0davis/oscar", "max_forks_repo_path": "archive/agda-1/UnifyMguL.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_issues_repo_issues_event_max_datetime": "2019-05-11T23:33:04.000Z", "max_issues_repo_issues_event_min_datetime": "2019-04-29T00:35:04.000Z", "max_issues_repo_licenses": [ "RSA-MD" ], "max_issues_repo_name": "m0davis/oscar", "max_issues_repo_path": "archive/agda-1/UnifyMguL.agda", "max_line_length": 87, "max_stars_count": null, "max_stars_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_stars_repo_licenses": [ "RSA-MD" ], "max_stars_repo_name": "m0davis/oscar", "max_stars_repo_path": "archive/agda-1/UnifyMguL.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 441, "size": 1195 }
module Proof.Setup where import LF import IIRD import IIRDr import DefinitionalEquality import Identity open LF open IIRD open IIRDr open DefinitionalEquality open Identity -- Given a code for a general IIRD we should give a code for a restricted IIRD. ε : {I : Set}{D : I -> Set1} -> OPg I D -> OPr I D ε {I}{D} (ι < j | e >') = \i -> σ (j == i) \p -> ι (subst₁ D p e) ε (σ A γ) = \i -> σ A \a -> ε (γ a) i ε (δ A j γ) = \i -> δ A j \g -> ε (γ g) i G→H : {I : Set}{D : I -> Set1}(γ : OPg I D)(U : I -> Set)(T : (i : I) -> U i -> D i) (a : Gu γ U T) -> Hu (ε γ) U T (Gi γ U T a) G→H (ι < i | e >') U T ★ = < refl | ★ > G→H (σ A γ) U T < a | b > = < a | G→H (γ a) U T b > G→H (δ A i γ) U T < g | b > = < g | G→H (γ (T « i × g »)) U T b > H→G : {I : Set}{D : I -> Set1}(γ : OPg I D)(U : I -> Set)(T : (i : I) -> U i -> D i) (i : I) -> Hu (ε γ) U T i -> Gu γ U T H→G (ι < j | e >') U T i < p | ★ > = ★ H→G (σ A γ) U T i < a | b > = < a | H→G (γ a) U T i b > H→G (δ A j γ) U T i < g | b > = < g | H→G (γ (T « j × g »)) U T i b > -- We can turn an inductive argument of the general IIRD to an inductive -- argument of the restricted version. H→G∘G→H-identity : {I : Set}{D : I -> Set1} (γ : OPg I D)(U : I -> Set)(T : (i : I) -> U i -> D i) (a : Gu γ U T) -> H→G γ U T (Gi γ U T a) (G→H γ U T a) ≡ a H→G∘G→H-identity (ι < i | e >') U T ★ = refl-≡ H→G∘G→H-identity (σ A γ) U T < a | b > = cong-≡ (\z -> < a | z >) (H→G∘G→H-identity (γ a) U T b) H→G∘G→H-identity (δ A i γ) U T < g | b > = cong-≡ (\z -> < g | z >) (H→G∘G→H-identity (γ (T « i × g »)) U T b) {- Gi∘H→G-identity : {I : Set}{D : I -> Set1} (γ : OPg I D)(U : I -> Set)(T : (i : I) -> U i -> D i) (i : I)(b : Hu (ε γ) U T i) -> Gi γ U T (H→G γ U T i b) == i Gi∘H→G-identity (ι < j | e >') U T i < p | ★ > = p Gi∘H→G-identity (σ A γ) U T i < a | b > = Gi∘H→G-identity (γ a) U T i b Gi∘H→G-identity (δ A j γ) U T i < g | b > = Gi∘H→G-identity (γ (T « j × g »)) U T i b Gt∘H→G-identity : {I : Set}{D : I -> Set1} (γ : OPg I D)(U : I -> Set)(T : (i : I) -> U i -> D i) (i : I)(b : Hu (ε γ) U T i) -> Gt γ U T (H→G γ U T i b) ≡₁ Ht (ε γ) U T i b Gt∘H→G-identity γ U T i b = ? -- This one ain't true! p ≢ refl : x == y G→H∘H→G-identity : {I : Set}{D : I -> Set1} (γ : OPg I D)(U : I -> Set)(T : (i : I) -> U i -> D i) (i : I)(b : Hu (ε γ) U T i) -> G→H γ U T (H→G γ U T i b) ≡ b G→H∘H→G-identity (ι < j | e >') U T i < p | ★ > = ? G→H∘H→G-identity (σ A γ) U T i < a | b > = ? G→H∘H→G-identity (δ A j γ) U T i < g | b > = ? -} -- Rather than proving equalities (which doesn't hold anyway) we provide -- substitution rules. G→H∘H→G-subst : {I : Set}{D : I -> Set1} (γ : OPg I D)(U : I -> Set)(T : (i : I) -> U i -> D i) (F : (i : I)(a : Hu (ε γ) U T i) -> Set1) (i : I)(a : Hu (ε γ) U T i) (h : F (Gi γ U T (H→G γ U T i a)) (G→H γ U T (H→G γ U T i a))) -> F i a G→H∘H→G-subst (ι < j | e >') U T F i < p | ★ > h = elim==₁ j (\z q -> F z < q | ★ >) h i p G→H∘H→G-subst (σ A γ) U T F i < a | b > h = G→H∘H→G-subst (γ a) U T (\j c -> F j < a | c >) i b h G→H∘H→G-subst (δ A j γ) U T F i < g | b > h = G→H∘H→G-subst (γ (T « j × g »)) U T (\j c -> F j < g | c >) i b h -- Q. When can we remove a G→H∘H→G-subst ? -- A. When a = G→H γ U T i a' G→H∘H→G-identity : {I : Set}{D : I -> Set1} (γ : OPg I D)(U : I -> Set)(T : (i : I) -> U i -> D i) (F : (i : I)(a : Hu (ε γ) U T i) -> Set1) (a : Gu γ U T) (h : F (Gi γ U T (H→G γ U T (Gi γ U T a) (G→H γ U T a))) (G→H γ U T (H→G γ U T (Gi γ U T a) (G→H γ U T a))) ) -> G→H∘H→G-subst γ U T F (Gi γ U T a) (G→H γ U T a) h ≡₁ h G→H∘H→G-identity (ι < i | e >') U T F ★ h = refl-≡₁ G→H∘H→G-identity (σ A γ) U T F < a | b > h = G→H∘H→G-identity (γ a) U T (\j c -> F j < a | c >) b h G→H∘H→G-identity (δ A i γ) U T F < g | b > h = G→H∘H→G-identity (γ (T « i × g »)) U T (\j c -> F j < g | c >) b h εIArg : {I : Set}{D : I -> Set1}(γ : OPg I D)(U : I -> Set)(T : (i : I) -> U i -> D i) (i : I)(a : Hu (ε γ) U T i) -> KIArg γ U T (H→G γ U T i a) -> KIArg (ε γ i) U T a εIArg (ι < j | e >') U T i < h | ★ > () εIArg (σ A γ) U T i < a | b > v = εIArg (γ a) U T i b v εIArg (δ A j γ) U T i < g | b > (inl a) = inl a εIArg (δ A j γ) U T i < g | b > (inr v) = inr (εIArg (γ (T « j × g »)) U T i b v) εIArg→I-identity : {I : Set}{D : I -> Set1}(γ : OPg I D)(U : I -> Set)(T : (i : I) -> U i -> D i) (i : I)(a : Hu (ε γ) U T i)(v : KIArg γ U T (H→G γ U T i a)) -> KIArg→I (ε γ i) U T a (εIArg γ U T i a v) ≡ KIArg→I γ U T (H→G γ U T i a) v εIArg→I-identity (ι < j | e >') U T i < p | ★ > () εIArg→I-identity (σ A γ) U T i < a | b > v = εIArg→I-identity (γ a) U T i b v εIArg→I-identity (δ A j γ) U T i < g | b > (inl a) = refl-≡ εIArg→I-identity (δ A j γ) U T i < g | b > (inr v) = εIArg→I-identity (γ (T « j × g »)) U T i b v εIArg→U-identity : {I : Set}{D : I -> Set1}(γ : OPg I D)(U : I -> Set)(T : (i : I) -> U i -> D i) (i : I)(a : Hu (ε γ) U T i)(v : KIArg γ U T (H→G γ U T i a)) -> KIArg→U (ε γ i) U T a (εIArg γ U T i a v) ≡ KIArg→U γ U T (H→G γ U T i a) v εIArg→U-identity (ι < j | e >') U T i < p | ★ > () εIArg→U-identity (σ A γ) U T i < a | b > v = εIArg→U-identity (γ a) U T i b v εIArg→U-identity (δ A j γ) U T i < g | b > (inl a) = refl-≡ εIArg→U-identity (δ A j γ) U T i < g | b > (inr v) = εIArg→U-identity (γ (T « j × g »)) U T i b v εIArg-subst : {I : Set}{D : I -> Set1}(γ : OPg I D)(U : I -> Set)(T : (i : I) -> U i -> D i) (F : (i : I)(u : U i) -> Set1) (i : I)(a : Hu (ε γ) U T i)(v : KIArg γ U T (H→G γ U T i a)) -> F (KIArg→I (ε γ i) U T a (εIArg γ U T i a v)) (KIArg→U (ε γ i) U T a (εIArg γ U T i a v)) -> F (KIArg→I γ U T (H→G γ U T i a) v) (KIArg→U γ U T (H→G γ U T i a) v) εIArg-subst (ι < j | e >') U T F i < p | ★ > () h εIArg-subst (σ A γ) U T F i < a | b > v h = εIArg-subst (γ a) U T F i b v h εIArg-subst (δ A j γ) U T F i < g | b > (inl a) h = h εIArg-subst (δ A j γ) U T F i < g | b > (inr v) h = εIArg-subst (γ (T « j × g »)) U T F i b v h εIArg-identity : {I : Set}{D : I -> Set1} (γ : OPg I D)(U : I -> Set)(T : (i : I) -> U i -> D i) (F : (i : I)(u : U i) -> Set1) (a : Gu γ U T) (v : KIArg γ U T (H→G γ U T (Gi γ U T a) (G→H γ U T a))) (h : F (KIArg→I (ε γ (Gi γ U T a)) U T (G→H γ U T a) (εIArg γ U T (Gi γ U T a) (G→H γ U T a) v)) (KIArg→U (ε γ (Gi γ U T a)) U T (G→H γ U T a) (εIArg γ U T (Gi γ U T a) (G→H γ U T a) v)) ) -> εIArg-subst γ U T F (Gi γ U T a) (G→H γ U T a) v h ≡₁ h εIArg-identity (ι < i | e >') U T F ★ () h εIArg-identity (σ A γ) U T F < a | b > v h = εIArg-identity (γ a) U T F b v h εIArg-identity (δ A i γ) U T F < g | b > (inl a) h = refl-≡₁ εIArg-identity (δ A i γ) U T F < g | b > (inr v) h = εIArg-identity (γ (T « i × g »)) U T F b v h
{ "alphanum_fraction": 0.3881060116, "avg_line_length": 50.2272727273, "ext": "agda", "hexsha": "60c399fb0abec811253c643dbd71487021d551f8", "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": "examples/outdated-and-incorrect/iird/Proof/Setup.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "masondesu/agda", "max_issues_repo_path": "examples/outdated-and-incorrect/iird/Proof/Setup.agda", "max_line_length": 113, "max_stars_count": 1, "max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/agda-kanso", "max_stars_repo_path": "examples/outdated-and-incorrect/iird/Proof/Setup.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": 3488, "size": 7735 }
-- I decided that I wanted my Eq development to be separate from my HT one, -- which means that I prove Kleene is reflexive through logical equivalence -- being reflexive module Eq.KleeneTheoryEarly where open import Prelude open import T open import DynTheory open import Eq.Defs -- Theory about Kleene equality kleene-sym : Symmetric KleeneEq kleene-sym (kleeneq n val S1 S2) = kleeneq n val S2 S1 kleene-trans : Transitive KleeneEq kleene-trans {z = e''} (kleeneq n val e-eval e'-eval) (kleeneq n' val' e'-eval2 e''-eval) with eval-deterministic e'-eval e'-eval2 val val' ... | eq = kleeneq _ val e-eval (ID.coe1 (λ x → e'' ~>* x) (symm eq) e''-eval) kleene-converse-evaluation : ∀{e e' d : TNat} → e ≃ e' → d ~>* e → d ≃ e' kleene-converse-evaluation (kleeneq n val S1 S2) eval = kleeneq n val (eval-trans eval S1) S2
{ "alphanum_fraction": 0.6790266512, "avg_line_length": 33.1923076923, "ext": "agda", "hexsha": "cfee9eb0be20374ac86e2d1acbd2c598e859c98a", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2021-05-04T22:37:18.000Z", "max_forks_repo_forks_event_min_datetime": "2015-04-26T11:39:14.000Z", "max_forks_repo_head_hexsha": "7412725cf27873b2b23f7e411a236a97dd99ef91", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "msullivan/godels-t", "max_forks_repo_path": "Eq/KleeneTheoryEarly.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "7412725cf27873b2b23f7e411a236a97dd99ef91", "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": "msullivan/godels-t", "max_issues_repo_path": "Eq/KleeneTheoryEarly.agda", "max_line_length": 90, "max_stars_count": 4, "max_stars_repo_head_hexsha": "7412725cf27873b2b23f7e411a236a97dd99ef91", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "msullivan/godels-t", "max_stars_repo_path": "Eq/KleeneTheoryEarly.agda", "max_stars_repo_stars_event_max_datetime": "2021-03-22T00:28:03.000Z", "max_stars_repo_stars_event_min_datetime": "2016-12-25T01:52:57.000Z", "num_tokens": 283, "size": 863 }
open import Functional hiding (Domain) import Structure.Logic.Classical.NaturalDeduction import Structure.Logic.Classical.SetTheory.ZFC module Structure.Logic.Classical.SetTheory.ZFC.FunctionSet {ℓₗ} {Formula} {ℓₘₗ} {Proof} {ℓₒ} {Domain} ⦃ classicLogic : _ ⦄ (_∈_ : Domain → Domain → Formula) ⦃ signature : _ ⦄ where open Structure.Logic.Classical.NaturalDeduction.ClassicalLogic {ℓₗ} {Formula} {ℓₘₗ} {Proof} {ℓₒ} {Domain} (classicLogic) open Structure.Logic.Classical.SetTheory.ZFC.Signature {ℓₗ} {Formula} {ℓₘₗ} {Proof} {ℓₒ} {Domain} ⦃ classicLogic ⦄ {_∈_} (signature) open import Structure.Logic.Classical.SetTheory.SetBoundedQuantification ⦃ classicLogic ⦄ (_∈_) open import Structure.Logic.Classical.SetTheory.ZFC.BinaryRelatorSet ⦃ classicLogic ⦄ (_∈_) ⦃ signature ⦄ -- The set s can be interpreted as a function. FunctionSet : Domain → Formula FunctionSet(s) = ∀ₗ(x ↦ Unique(y ↦ (x , y) ∈ s)) -- TODO: Maybe also define something that states ∀ₗ(x ↦ (x ∈ A) ↔ ∃ₗ(y ↦ (x , y) ∈ s)) so that a set representation of a function with domains becomes unique? But I think when (s ∈ (B ^ A)) is satisfied, this is implied? So try to prove that (FunctionSet(f) ∧ Total(A)(f) ∧ (the thing I mentioned earlier)) ↔ (f ∈ (B ^ A)) -- The set s can be interpreted as a function with a specified domain. -- The following describes the relation to the standard notation of functions: -- • ∀(x∊A)∀y. ((x,y) ∈ S) ⇔ (S(x) = y) Total : Domain → Domain → Formula Total(A)(s) = ∀ₛ(A)(x ↦ ∃ₗ(y ↦ (x , y) ∈ s)) Injective' : Domain → Formula Injective'(f) = ∀ₗ(y ↦ Unique(x ↦ (x , y) ∈ f)) Surjective' : Domain → Domain → Formula Surjective'(B)(f) = ∀ₛ(B)(y ↦ ∃ₗ(x ↦ (x , y) ∈ f)) Bijective' : Domain → Domain → Formula Bijective'(B)(f) = Injective'(f) ∧ Surjective'(B)(f) -- The set of total function sets. All sets which can be interpreted as a total function. _^_ : Domain → Domain → Domain B ^ A = filter(℘(A ⨯ B)) (f ↦ FunctionSet(f) ∧ Total(A)(f)) _→ₛₑₜ_ = swap _^_ ⊷ : Domain → Domain ⊷ = lefts ⊶ : Domain → Domain ⊶ = rights map' : Domain → Domain → Domain map' = rightsOfMany unmap' : Domain → Domain → Domain unmap' = leftsOfMany apply-set : Domain → Domain → Domain apply-set = rightsOf unapply-set : Domain → Domain → Domain unapply-set = leftsOf _∘'_ : Domain → Domain → Domain _∘'_ f g = filter((⊷ f) ⨯ (⊶ g)) (a ↦ ∃ₗ(x ↦ ∃ₗ(y ↦ ∃ₗ(a₁ ↦ ((a₁ , y) ∈ f) ∧ ((x , a₁) ∈ g)) ∧ (a ≡ (x , y))))) -- inv : Domain → Domain -- inv f = filter(?) (yx ↦ ∃ₗ(x ↦ ∃ₗ(y ↦ ((x , y) ∈ f) ∧ (yx ≡ (y , x))))) module Cardinality where -- Injection _≼_ : Domain → Domain → Formula _≼_ (a)(b) = ∃ₛ(a →ₛₑₜ b)(Injective') -- Surjection _≽_ : Domain → Domain → Formula _≽_ (a)(b) = ∃ₛ(a →ₛₑₜ b)(Surjective'(b)) -- Bijection _≍_ : Domain → Domain → Formula _≍_ (a)(b) = ∃ₛ(a →ₛₑₜ b)(Bijective'(b)) -- Strict injection _≺_ : Domain → Domain → Formula _≺_ A B = (A ≼ B) ∧ ¬(A ≍ B) -- Strict surjection _≻_ : Domain → Domain → Formula _≻_ A B = (A ≽ B) ∧ ¬(A ≍ B) -- TODO: Definition of a "cardinality object" requires ordinals, which requires axiom of choice -- # : Domain → Domain
{ "alphanum_fraction": 0.632607303, "avg_line_length": 35.8850574713, "ext": "agda", "hexsha": "d118426f8f5a0856957f99009daafb49e55c83b6", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_path": "old/Structure/Logic/Classical/SetTheory/ZFC/FunctionSet.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_path": "old/Structure/Logic/Classical/SetTheory/ZFC/FunctionSet.agda", "max_line_length": 322, "max_stars_count": 6, "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_path": "old/Structure/Logic/Classical/SetTheory/ZFC/FunctionSet.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": 1164, "size": 3122 }
import AssocFree.STLambdaC.Typ import AssocFree.STLambdaC.Exp module AssocFree.STLambdaC.NF (TConst : Set) (Const : AssocFree.STLambdaC.Typ.Typ TConst → Set) where open module Typ = AssocFree.STLambdaC.Typ TConst using ( Typ ; Ctxt ; const ; _⇝_ ; [_] ; [] ; _∷_ ; _++_ ; case ; singleton ; _≪_ ) open module Exp = AssocFree.STLambdaC.Exp TConst Const using ( Exp ; const ; abs ; app ; var ; var₀ ; weaken+ ; weaken* ; xweaken+ ) mutual -- Normal forms data Atom {Γ : Ctxt} {T : Typ} : Exp Γ T → Set where const : ∀ c → Atom (const c) var : ∀ x → Atom (var x) app : ∀ {U M} {N : Exp Γ U} → Atom M → NF N → Atom (app M N) data NF {Γ : Ctxt} : ∀ {T} → Exp Γ T → Set where atom : ∀ {C} {M : Exp Γ (const C)} → Atom M → NF M abs : ∀ T {U} {M : Exp (T ∷ Γ) U} → NF M → NF (abs {Γ} T M) -- Shorthand atom₀ : ∀ {Γ T} → Atom (var₀ {Γ} {T}) atom₀ {Γ} {T} = var (singleton T ≪ Γ) -- Weakening mutual aweaken+ : ∀ B Γ Δ {T M} → Atom M → Atom (weaken+ B Γ Δ {T} M) aweaken+ B Γ Δ (const c) = const c aweaken+ B Γ Δ (app M N) = app (aweaken+ B Γ Δ M) (nweaken+ B Γ Δ N) aweaken+ B Γ Δ (var x) = var (xweaken+ B Γ Δ x) nweaken+ : ∀ B Γ Δ {T M} → NF M → NF (weaken+ B Γ Δ {T} M) nweaken+ B Γ Δ (atom N) = atom (aweaken+ B Γ Δ N) nweaken+ B Γ Δ (abs T N) = abs T (nweaken+ (T ∷ B) Γ Δ N) aweaken* : ∀ Γ {Δ T M} → Atom M → Atom (weaken* Γ {Δ} {T} M) aweaken* Γ {Δ} = aweaken+ [] Γ Δ
{ "alphanum_fraction": 0.5550139276, "avg_line_length": 29.306122449, "ext": "agda", "hexsha": "1bc53938be4c17d8c0c758258456c9314a778160", "lang": "Agda", "max_forks_count": 2, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:38:44.000Z", "max_forks_repo_forks_event_min_datetime": "2018-03-03T04:39:31.000Z", "max_forks_repo_head_hexsha": "08337fdb8375137a52cc9b3ade766305191b2394", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "agda/agda-assoc-free", "max_forks_repo_path": "src/AssocFree/STLambdaC/NF.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "08337fdb8375137a52cc9b3ade766305191b2394", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "agda/agda-assoc-free", "max_issues_repo_path": "src/AssocFree/STLambdaC/NF.agda", "max_line_length": 79, "max_stars_count": 3, "max_stars_repo_head_hexsha": "08337fdb8375137a52cc9b3ade766305191b2394", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "agda/agda-assoc-free", "max_stars_repo_path": "src/AssocFree/STLambdaC/NF.agda", "max_stars_repo_stars_event_max_datetime": "2020-08-27T20:56:20.000Z", "max_stars_repo_stars_event_min_datetime": "2016-11-22T11:48:31.000Z", "num_tokens": 594, "size": 1436 }
{-# OPTIONS --warning=error #-} module Issue278 where open import Agda.Builtin.Equality abstract module A where Foo : Set₁ Foo = Set module B where open A Foo≡Set : Foo ≡ Set Foo≡Set = refl
{ "alphanum_fraction": 0.6405529954, "avg_line_length": 14.4666666667, "ext": "agda", "hexsha": "ad2ba4620ee7437960024a8898ab0b065024167c", "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/Issue278.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/Issue278.agda", "max_line_length": 33, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "test/Fail/Issue278.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": 67, "size": 217 }
{-# OPTIONS --rewriting --confluence-check #-} open import Agda.Builtin.Nat using (Nat; zero; suc) open import Agda.Builtin.Equality open import Agda.Builtin.Equality.Rewrite variable k l m n : Nat postulate max : Nat → Nat → Nat max-0l : max 0 n ≡ n max-0r : max m 0 ≡ m max-diag : max m m ≡ m max-ss : max (suc m) (suc n) ≡ suc (max m n) max-diag-s : max (suc m) (suc m) ≡ suc m -- for global confluence max-assoc : max (max k l) m ≡ max k (max l m) {-# REWRITE max-0l max-0r #-} {-# REWRITE max-ss max-diag max-diag-s #-} --{-# REWRITE max-assoc #-} -- not confluent! postulate _+_ : Nat → Nat → Nat plus-0l : 0 + n ≡ n plus-0r : m + 0 ≡ m plus-00 : 0 + 0 ≡ 0 -- for global confluence plus-suc-l : (suc m) + n ≡ suc (m + n) plus-suc-0 : (suc m) + 0 ≡ suc m -- for global confluence plus-suc-r : m + (suc n) ≡ suc (m + n) plus-0-suc : 0 + (suc n) ≡ suc n plus-suc-suc : (suc m) + (suc n) ≡ suc (suc (m + n)) plus-assoc : (k + l) + m ≡ k + (l + m) -- not accepted by global confluence check {-# REWRITE plus-00 plus-0l plus-0r plus-suc-l plus-suc-0 plus-suc-r plus-0-suc plus-suc-suc #-} postulate _*_ : Nat → Nat → Nat mult-0l : 0 * n ≡ 0 mult-0r : m * 0 ≡ 0 mult-00 : 0 * 0 ≡ 0 mult-suc-l : (suc m) * n ≡ n + (m * n) mult-suc-l-0 : (suc m) * 0 ≡ 0 mult-suc-r : m * (suc n) ≡ (m * n) + m plus-mult-distr-l : k * (l + m) ≡ (k * l) + (k * m) plus-mult-distr-r : (k + l) * m ≡ (k * m) + (l * m) mult-assoc : (k * l) * m ≡ k * (l * m) {-# REWRITE mult-0l mult-0r mult-00 mult-suc-l mult-suc-l-0 #-} --{-# REWRITE mult-suc-r #-} -- requires rule plus-assoc! --{-# REWRITE plus-mult-distr-l #-} --{-# REWRITE plus-mult-distr-r #-} --{-# REWRITE mult-assoc #-}
{ "alphanum_fraction": 0.5387224421, "avg_line_length": 30.5, "ext": "agda", "hexsha": "5ddf8367cadb409422036bf9e4620512fe164a2f", "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/RewritingGlobalConfluence.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/RewritingGlobalConfluence.agda", "max_line_length": 83, "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/RewritingGlobalConfluence.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": 744, "size": 1769 }
module Text.Greek.SBLGNT where open import Data.List open import Text.Greek.Bible open import Text.Greek.SBLGNT.Matt open import Text.Greek.SBLGNT.Mark open import Text.Greek.SBLGNT.Luke open import Text.Greek.SBLGNT.John open import Text.Greek.SBLGNT.Acts open import Text.Greek.SBLGNT.Rom open import Text.Greek.SBLGNT.1Cor open import Text.Greek.SBLGNT.2Cor open import Text.Greek.SBLGNT.Gal open import Text.Greek.SBLGNT.Eph open import Text.Greek.SBLGNT.Phil open import Text.Greek.SBLGNT.Col open import Text.Greek.SBLGNT.1Thess open import Text.Greek.SBLGNT.2Thess open import Text.Greek.SBLGNT.1Tim open import Text.Greek.SBLGNT.2Tim open import Text.Greek.SBLGNT.Titus open import Text.Greek.SBLGNT.Phlm open import Text.Greek.SBLGNT.Heb open import Text.Greek.SBLGNT.Jas open import Text.Greek.SBLGNT.1Pet open import Text.Greek.SBLGNT.2Pet open import Text.Greek.SBLGNT.1John open import Text.Greek.SBLGNT.2John open import Text.Greek.SBLGNT.3John open import Text.Greek.SBLGNT.Jude open import Text.Greek.SBLGNT.Rev books : List (List (Word)) books = ΚΑΤΑ-ΜΑΘΘΑΙΟΝ ∷ ΚΑΤΑ-ΜΑΡΚΟΝ ∷ ΚΑΤΑ-ΛΟΥΚΑΝ ∷ ΚΑΤΑ-ΙΩΑΝΝΗΝ ∷ ΠΡΑΞΕΙΣ-ΑΠΟΣΤΟΛΩΝ ∷ ΠΡΟΣ-ΡΩΜΑΙΟΥΣ ∷ ΠΡΟΣ-ΚΟΡΙΝΘΙΟΥΣ-Α ∷ ΠΡΟΣ-ΚΟΡΙΝΘΙΟΥΣ-Β ∷ ΠΡΟΣ-ΓΑΛΑΤΑΣ ∷ ΠΡΟΣ-ΕΦΕΣΙΟΥΣ ∷ ΠΡΟΣ-ΦΙΛΙΠΠΗΣΙΟΥΣ ∷ ΠΡΟΣ-ΚΟΛΟΣΣΑΕΙΣ ∷ ΠΡΟΣ-ΘΕΣΣΑΛΟΝΙΚΕΙΣ-Α ∷ ΠΡΟΣ-ΘΕΣΣΑΛΟΝΙΚΕΙΣ-Β ∷ ΠΡΟΣ-ΤΙΜΟΘΕΟΝ-Α ∷ ΠΡΟΣ-ΤΙΜΟΘΕΟΝ-Β ∷ ΠΡΟΣ-ΤΙΤΟΝ ∷ ΠΡΟΣ-ΦΙΛΗΜΟΝΑ ∷ ΠΡΟΣ-ΕΒΡΑΙΟΥΣ ∷ ΙΑΚΩΒΟΥ ∷ ΠΕΤΡΟΥ-Α ∷ ΠΕΤΡΟΥ-Β ∷ ΙΩΑΝΝΟΥ-Α ∷ ΙΩΑΝΝΟΥ-Β ∷ ΙΩΑΝΝΟΥ-Γ ∷ ΙΟΥΔΑ ∷ ΑΠΟΚΑΛΥΨΙΣ-ΙΩΑΝΝΟΥ ∷ []
{ "alphanum_fraction": 0.7657657658, "avg_line_length": 24.6666666667, "ext": "agda", "hexsha": "5ee4851cfcf99d209bb4f1cf4ecfff0ab56ba03d", "lang": "Agda", "max_forks_count": 5, "max_forks_repo_forks_event_max_datetime": "2017-06-11T11:25:09.000Z", "max_forks_repo_forks_event_min_datetime": "2015-02-27T22:34:13.000Z", "max_forks_repo_head_hexsha": "915c46c27c7f8aad5907474d8484f2685a4cd6a7", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "scott-fleischman/GreekGrammar", "max_forks_repo_path": "agda/Text/Greek/SBLGNT.agda", "max_issues_count": 13, "max_issues_repo_head_hexsha": "915c46c27c7f8aad5907474d8484f2685a4cd6a7", "max_issues_repo_issues_event_max_datetime": "2020-09-07T11:58:38.000Z", "max_issues_repo_issues_event_min_datetime": "2015-05-28T20:04:08.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "scott-fleischman/GreekGrammar", "max_issues_repo_path": "agda/Text/Greek/SBLGNT.agda", "max_line_length": 36, "max_stars_count": 44, "max_stars_repo_head_hexsha": "915c46c27c7f8aad5907474d8484f2685a4cd6a7", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "scott-fleischman/GreekGrammar", "max_stars_repo_path": "agda/Text/Greek/SBLGNT.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-06T15:41:57.000Z", "max_stars_repo_stars_event_min_datetime": "2015-05-29T14:48:51.000Z", "num_tokens": 1141, "size": 1554 }
{-# OPTIONS --with-K #-} open import Axiom.UniquenessOfIdentityProofs.WithK using (uip) open import Relation.Binary.PropositionalEquality hiding (Extensionality) open ≡-Reasoning open import Level using (Level) open import Data.Nat using (ℕ) open import Data.Vec using (Vec) open import FLA.Axiom.Extensionality.Propositional open import FLA.Algebra.Structures open import FLA.Algebra.Properties.Field open import FLA.Algebra.LinearMap open import FLA.Algebra.LinearMap.Properties open import FLA.Algebra.LinearAlgebra open import FLA.Algebra.LinearAlgebra.Matrix module FLA.Algebra.LinearAlgebra.Properties.Matrix where private variable ℓ : Level A : Set ℓ m n p q : ℕ ⦃ F ⦄ : Field A ------------------------------------------------------------------------------- -- M without the inner product proof: Mat↓ -- ------------------------------------------------------------------------------- private data Mat↓_∶_×_ (A : Set ℓ) ⦃ F : Field A ⦄ (m n : ℕ) : Set ℓ where ⟦_,_⟧ : (M : n ⊸ m ) → (Mᵀ : m ⊸ n ) → Mat↓ A ∶ m × n _·↓_ : ⦃ F : Field A ⦄ → Mat↓ A ∶ m × n → Vec A n → Vec A m ⟦ f , a ⟧ ·↓ x = f ·ˡᵐ x _ᵀ↓ : ⦃ F : Field A ⦄ → Mat↓ A ∶ m × n → Mat↓ A ∶ n × m ⟦ f , a ⟧ ᵀ↓ = ⟦ a , f ⟧ infixr 20 _·↓_ infixl 25 _ᵀ↓ Mat→Mat↓ : ⦃ F : Field A ⦄ → Mat m × n → Mat↓ A ∶ m × n Mat→Mat↓ ⟦ M , Mᵀ , p ⟧ = ⟦ M , Mᵀ ⟧ Mat↓→Mat : ⦃ F : Field A ⦄ → (Mat↓ : Mat↓ A ∶ m × n) → (p : (x : Vec A m) → (y : Vec A n) → ⟨ x , Mat↓ ·↓ y ⟩ ≡ ⟨ y , Mat↓ ᵀ↓ ·↓ x ⟩ ) → Mat m × n Mat↓→Mat ⟦ M , Mᵀ ⟧ p = ⟦ M , Mᵀ , p ⟧ ⟨x,Ay⟩≡⟨y,Aᵀx⟩-UIP : {ℓ : Level} → {A : Set ℓ} → ⦃ F : Field A ⦄ → (C : n ⊸ m) → (Cᵀ : m ⊸ n) → (p q : (x : Vec A m) (y : Vec A n) → ⟨ x , C ·ˡᵐ y ⟩ ≡ ⟨ y , Cᵀ ·ˡᵐ x ⟩) → p ≡ q ⟨x,Ay⟩≡⟨y,Aᵀx⟩-UIP {m} {n} {ℓ} {A} C Cᵀ p q = extensionality (λ x → extensionality (λ y → f C Cᵀ p q x y)) where f : {m n : ℕ} → {A : Set ℓ} → ⦃ F : Field A ⦄ → (C : n ⊸ m) → (Cᵀ : m ⊸ n) → (p q : (x : Vec A m) (y : Vec A n) → ⟨ x , C ·ˡᵐ y ⟩ ≡ ⟨ y , Cᵀ ·ˡᵐ x ⟩) → (x : Vec A m) → (y : Vec A n) → p x y ≡ q x y f C Cᵀ p q (x) (y) = uip (p x y) (q x y) Mat↓≡→Mat≡ : ⦃ F : Field A ⦄ → (C D : Mat m × n) → (Mat→Mat↓ C ≡ Mat→Mat↓ D) → C ≡ D Mat↓≡→Mat≡ ⟦ C , Cᵀ , p ⟧ ⟦ .C , .Cᵀ , q ⟧ refl rewrite ⟨x,Ay⟩≡⟨y,Aᵀx⟩-UIP C Cᵀ p q = refl ------------------------------------------------------------------------------- -- Proofs on M -- ------------------------------------------------------------------------------- module _ {ℓ : Level} {A : Set ℓ} ⦃ F : Field A ⦄ where open Field F ᵀᵀ : (B : Mat m × n) → B ᵀ ᵀ ≡ B ᵀᵀ B = Mat↓≡→Mat≡ (B ᵀ ᵀ) B (ᵀᵀ↓ B) where ᵀᵀ↓ : (B : Mat m × n) → Mat→Mat↓ (B ᵀ ᵀ) ≡ Mat→Mat↓ B ᵀᵀ↓ ⟦ M , Mᵀ , p ⟧ = refl ᵀ-distr-* : (L : Mat m × n) (R : Mat n × p) → (L *ᴹ R) ᵀ ≡ (R ᵀ *ᴹ L ᵀ) ᵀ-distr-* L R = Mat↓≡→Mat≡ ((L *ᴹ R) ᵀ) (R ᵀ *ᴹ L ᵀ) (ᵀ-distr-*↓ L R) where ᵀ-distr-*↓ : (L : Mat m × n) (R : Mat n × p) → Mat→Mat↓ ((L *ᴹ R) ᵀ) ≡ Mat→Mat↓ (R ᵀ *ᴹ L ᵀ) ᵀ-distr-*↓ ⟦ L , Lᵀ , p ⟧ ⟦ R , Rᵀ₁ , q ⟧ = refl ᵀ-distr-+ : (L R : Mat m × n) → (L +ᴹ R) ᵀ ≡ L ᵀ +ᴹ R ᵀ ᵀ-distr-+ L R = Mat↓≡→Mat≡ ((L +ᴹ R) ᵀ) (L ᵀ +ᴹ R ᵀ) (ᵀ-distr-+↓ L R) where ᵀ-distr-+↓ : (L R : Mat m × n) → Mat→Mat↓ ((L +ᴹ R) ᵀ) ≡ Mat→Mat↓ (L ᵀ +ᴹ R ᵀ) ᵀ-distr-+↓ ⟦ L , Lᵀ , p ⟧ ⟦ R , Rᵀ , q ⟧ = refl *ᴹ-distr-+ᴹₗ : (X : Mat m × n) (Y Z : Mat n × p) → X *ᴹ (Y +ᴹ Z) ≡ X *ᴹ Y +ᴹ X *ᴹ Z *ᴹ-distr-+ᴹₗ X Y Z = Mat↓≡→Mat≡ (X *ᴹ (Y +ᴹ Z)) (X *ᴹ Y +ᴹ X *ᴹ Z) (*ᴹ-distr-+ᴹ↓ₗ X Y Z) where *ᴹ-distr-+ᴹ↓ₗ : (X : Mat m × n) (Y Z : Mat n × p) → Mat→Mat↓ (X *ᴹ (Y +ᴹ Z)) ≡ Mat→Mat↓ (X *ᴹ Y +ᴹ X *ᴹ Z) *ᴹ-distr-+ᴹ↓ₗ ⟦ X , Xᵀ , Xₚ ⟧ ⟦ Y , Yᵀ , Yₚ ⟧ ⟦ Z , Zᵀ , Zₚ ⟧ rewrite *ˡᵐ-distr-+ˡᵐₗ X Y Z | *ˡᵐ-distr-+ˡᵐᵣ Yᵀ Zᵀ Xᵀ = refl *ᴹ-distr-+ᴹᵣ : (X Y : Mat m × n) (Z : Mat n × p) → (X +ᴹ Y) *ᴹ Z ≡ X *ᴹ Z +ᴹ Y *ᴹ Z *ᴹ-distr-+ᴹᵣ X Y Z = Mat↓≡→Mat≡ ((X +ᴹ Y) *ᴹ Z) (X *ᴹ Z +ᴹ Y *ᴹ Z) (*ᴹ-distr-+ᴹ↓ᵣ X Y Z) where *ᴹ-distr-+ᴹ↓ᵣ : (X Y : Mat m × n) (Z : Mat n × p) → Mat→Mat↓ ((X +ᴹ Y) *ᴹ Z) ≡ Mat→Mat↓ (X *ᴹ Z +ᴹ Y *ᴹ Z) *ᴹ-distr-+ᴹ↓ᵣ ⟦ X , Xᵀ , Xₚ ⟧ ⟦ Y , Yᵀ , Yₚ ⟧ ⟦ Z , Zᵀ , Zₚ ⟧ rewrite *ˡᵐ-distr-+ˡᵐᵣ X Y Z | *ˡᵐ-distr-+ˡᵐₗ Zᵀ Xᵀ Yᵀ = refl
{ "alphanum_fraction": 0.3889479277, "avg_line_length": 35.9160305344, "ext": "agda", "hexsha": "a07c02d178cfb3d5a69139ca23804642e0bde73d", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2021-09-07T19:55:59.000Z", "max_forks_repo_forks_event_min_datetime": "2021-04-12T20:34:17.000Z", "max_forks_repo_head_hexsha": "375475a2daa57b5995ceb78b4bffcbfcbb5d8898", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "turion/functional-linear-algebra", "max_forks_repo_path": "src/FLA/Algebra/LinearAlgebra/Properties/Matrix.agda", "max_issues_count": 6, "max_issues_repo_head_hexsha": "375475a2daa57b5995ceb78b4bffcbfcbb5d8898", "max_issues_repo_issues_event_max_datetime": "2022-01-07T05:27:53.000Z", "max_issues_repo_issues_event_min_datetime": "2020-09-01T01:42:12.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "turion/functional-linear-algebra", "max_issues_repo_path": "src/FLA/Algebra/LinearAlgebra/Properties/Matrix.agda", "max_line_length": 86, "max_stars_count": 21, "max_stars_repo_head_hexsha": "375475a2daa57b5995ceb78b4bffcbfcbb5d8898", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "turion/functional-linear-algebra", "max_stars_repo_path": "src/FLA/Algebra/LinearAlgebra/Properties/Matrix.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": 2347, "size": 4705 }
open import Relation.Binary open import Relation.Binary.PropositionalEquality module Category.Monad.Monotone.Identity {i}(pre : Preorder i i i) where open Preorder pre renaming (Carrier to I; _∼_ to _≤_; refl to ≤-refl) open import Relation.Unary.PredicateTransformer using (Pt) open import Category.Monad.Monotone pre open RawMPMonad Identity : Pt I i Identity = λ P i → P i instance id-monad : RawMPMonad Identity return id-monad px = px _≥=_ id-monad c f = f ≤-refl c
{ "alphanum_fraction": 0.7531120332, "avg_line_length": 25.3684210526, "ext": "agda", "hexsha": "1ceb60596b9e9e96fa6e550243f5bea2f706296b", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-12-28T17:38:05.000Z", "max_forks_repo_forks_event_min_datetime": "2021-12-28T17:38:05.000Z", "max_forks_repo_head_hexsha": "0c096fea1716d714db0ff204ef2a9450b7a816df", "max_forks_repo_licenses": [ "Apache-2.0" ], "max_forks_repo_name": "metaborg/mj.agda", "max_forks_repo_path": "src/Category/Monad/Monotone/Identity.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "0c096fea1716d714db0ff204ef2a9450b7a816df", "max_issues_repo_issues_event_max_datetime": "2020-10-14T13:41:58.000Z", "max_issues_repo_issues_event_min_datetime": "2019-01-13T13:03:47.000Z", "max_issues_repo_licenses": [ "Apache-2.0" ], "max_issues_repo_name": "metaborg/mj.agda", "max_issues_repo_path": "src/Category/Monad/Monotone/Identity.agda", "max_line_length": 71, "max_stars_count": 10, "max_stars_repo_head_hexsha": "0c096fea1716d714db0ff204ef2a9450b7a816df", "max_stars_repo_licenses": [ "Apache-2.0" ], "max_stars_repo_name": "metaborg/mj.agda", "max_stars_repo_path": "src/Category/Monad/Monotone/Identity.agda", "max_stars_repo_stars_event_max_datetime": "2021-09-24T08:02:33.000Z", "max_stars_repo_stars_event_min_datetime": "2017-11-17T17:10:36.000Z", "num_tokens": 139, "size": 482 }
-- A variant of LostTypeError. module LostTypeError2 where postulate Wrap : (A : Set) → (A → Set) → A → Set wrap : (A : Set) (P : A → Set) (x : A) → P x → Wrap A P x rewrap : (A : Set) (P : A → Set) (x : A) → Wrap A P x → Wrap A P x postulate A : Set data Box : Set where box : A → Box data Dummy : Set where box : Dummy postulate x y : A P : Box → Set Px : P (box x) bad : Wrap Box P (box y) bad = rewrap _ (λ a → P _) (box y) (wrap _ (λ a → P _) (box x) Px)
{ "alphanum_fraction": 0.5303643725, "avg_line_length": 19, "ext": "agda", "hexsha": "08feb7b64d086ed2525a093daa5498baff41f862", "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/LostTypeError2.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/LostTypeError2.agda", "max_line_length": 68, "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/LostTypeError2.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": 195, "size": 494 }
module InstanceMetaType where ⟨⟩ : {A : Set} {{a : A}} → A ⟨⟩ {{a}} = a postulate A : Set instance a : A f : (a : A) → Set test₁ : Set test₁ = f ⟨⟩ postulate B : Set b : B g : (b : B) → Set instance b' : _ b' = b test₂ : Set test₂ = g ⟨⟩
{ "alphanum_fraction": 0.4809160305, "avg_line_length": 9.7037037037, "ext": "agda", "hexsha": "e9e8edf324748afb21f66769a88966183d8f43c2", "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/InstanceMetaType.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/InstanceMetaType.agda", "max_line_length": 29, "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/InstanceMetaType.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 118, "size": 262 }
{-# OPTIONS --safe --without-K #-} open import Algebra.Bundles using (Group) module Categories.Category.Construction.GroupAsCategory o {c ℓ} (G : Group c ℓ) where open import Level open import Categories.Category.Groupoid open Group G -- A group is a groupoid with a single object open import Categories.Category.Construction.MonoidAsCategory o monoid renaming (MonoidAsCategory to GroupAsCategory) public GroupIsGroupoid : IsGroupoid GroupAsCategory GroupIsGroupoid = record { iso = record { isoˡ = inverseˡ _ ; isoʳ = inverseʳ _ } } GroupAsGroupoid : Groupoid o c ℓ GroupAsGroupoid = record { isGroupoid = GroupIsGroupoid }
{ "alphanum_fraction": 0.757296467, "avg_line_length": 25.0384615385, "ext": "agda", "hexsha": "e7eafbbb5fca935866ea2e83e165cb4220e01642", "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/Category/Construction/GroupAsCategory.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/Category/Construction/GroupAsCategory.agda", "max_line_length": 85, "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/Category/Construction/GroupAsCategory.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": 173, "size": 651 }
open import Agda.Builtin.IO open import Agda.Builtin.String open import Agda.Builtin.Unit postulate putStr : String → IO ⊤ {-# FOREIGN GHC import qualified Data.Text.IO #-} {-# COMPILE GHC putStr = Data.Text.IO.putStr #-} {-# COMPILE JS putStr = function (x) { return function(cb) { process.stdout.write(x); cb(0); }; } #-} F : Set → Set F A = A → A data D : Set where c₀ : D c₁ : F D f : D → String f c₀ = "OK\n" f (c₁ x) = f x main = putStr (f (c₁ c₀))
{ "alphanum_fraction": 0.5991820041, "avg_line_length": 18.1111111111, "ext": "agda", "hexsha": "689daaa9b932c842758d4aa47c5eb986232eb053", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "cc026a6a97a3e517bb94bafa9d49233b067c7559", "max_forks_repo_licenses": [ "BSD-2-Clause" ], "max_forks_repo_name": "cagix/agda", "max_forks_repo_path": "test/Compiler/simple/Issue5602.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "cc026a6a97a3e517bb94bafa9d49233b067c7559", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "BSD-2-Clause" ], "max_issues_repo_name": "cagix/agda", "max_issues_repo_path": "test/Compiler/simple/Issue5602.agda", "max_line_length": 49, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "cc026a6a97a3e517bb94bafa9d49233b067c7559", "max_stars_repo_licenses": [ "BSD-2-Clause" ], "max_stars_repo_name": "cagix/agda", "max_stars_repo_path": "test/Compiler/simple/Issue5602.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": 160, "size": 489 }
-- Andreas, 2015-08-27, issue reported by Jesper Cockx -- {-# OPTIONS -v tc.lhs:10 #-} -- {-# OPTIONS -v tc:10 #-} -- {-# OPTIONS -v tc.lhs.imp:100 #-} data Bool : Set where true false : Bool T : Set → Bool → Set T A true = {x : A} → A T A false = (x : A) → A test : (A : Set) (b : Bool) → T A b test A true {x} = x test A false x = x
{ "alphanum_fraction": 0.5457227139, "avg_line_length": 21.1875, "ext": "agda", "hexsha": "7e1e964d3a81c01a2091de966e20e67f5bc4ccdf", "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/Issue1634.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/Issue1634.agda", "max_line_length": 54, "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/Issue1634.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": 129, "size": 339 }
module _ where postulate A : Set data Box : Set where box : A → Box unbox : Box → A unbox (box {x}) = x
{ "alphanum_fraction": 0.5892857143, "avg_line_length": 9.3333333333, "ext": "agda", "hexsha": "9d4b5ce0986be30ac4281a0c70d47f7e65fea6b5", "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/Issue3074.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/Issue3074.agda", "max_line_length": 20, "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/Issue3074.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": 43, "size": 112 }
module rename where open import cedille-types open import constants open import ctxt-types open import free-vars open import syntax-util open import general-util renamectxt : Set renamectxt = stringset × trie string {- the trie maps vars to their renamed versions, and the stringset stores all those renamed versions -} empty-renamectxt : renamectxt empty-renamectxt = empty-stringset , empty-trie renamectxt-contains : renamectxt → string → 𝔹 renamectxt-contains (_ , r) s = trie-contains r s renamectxt-insert : renamectxt → (s1 s2 : string) → renamectxt renamectxt-insert (ranr , r) s x = stringset-insert ranr x , trie-insert r s x renamectxt-single : var → var → renamectxt renamectxt-single = renamectxt-insert empty-renamectxt renamectxt-lookup : renamectxt → string → maybe string renamectxt-lookup (ranr , r) s = trie-lookup r s renamectxt-remove : renamectxt → string → renamectxt renamectxt-remove (ranr , r) s with trie-lookup r s renamectxt-remove (ranr , r) s | nothing = ranr , r renamectxt-remove (ranr , r) s | just s' = stringset-remove ranr s' , trie-remove r s renamectxt-in-range : renamectxt → string → 𝔹 renamectxt-in-range (ranr , r) s = stringset-contains ranr s renamectxt-in-field : renamectxt → string → 𝔹 renamectxt-in-field m s = renamectxt-contains m s || renamectxt-in-range m s renamectxt-rep : renamectxt → string → string renamectxt-rep r x with renamectxt-lookup r x renamectxt-rep r x | nothing = x renamectxt-rep r x | just x' = x' eq-var : renamectxt → string → string → 𝔹 eq-var r x y = renamectxt-rep r x =string renamectxt-rep r y {-# NON_TERMINATING #-} fresh' : (var → 𝔹) → ℕ → var → var fresh' bound n base with base ^ ℕ-to-string n ...| x with bound x ...| tt = fresh' bound (suc n) base ...| ff = x fresh-h : (var → 𝔹) → var → var fresh-h bound ignored-var = ignored-var fresh-h bound x = if ~ bound x' then x' else uncurry (fresh' bound) (fresh-split [] (reverse (string-to-𝕃char x'))) where x' = unqual-local x to-num : 𝕃 char → ℕ to-num [] = 1 to-num ns = string-to-ℕ0 (𝕃char-to-string ns) fresh-split : 𝕃 char → 𝕃 char → ℕ × var fresh-split ns [] = to-num ns , "" fresh-split ns (c :: cs) with is-digit c ...| tt = fresh-split (c :: ns) cs ...| ff = to-num ns , 𝕃char-to-string (reverse (c :: cs)) fresh-var : ctxt → var → var fresh-var = fresh-h ∘' ctxt-binds-var fresh-var-renamectxt : ctxt → renamectxt → var → var fresh-var-renamectxt Γ ρ ignored-var = ignored-var fresh-var-renamectxt Γ ρ x = fresh-h (λ x → ctxt-binds-var Γ x || renamectxt-in-field ρ x) x fresh-var-new : ctxt → var → var fresh-var-new Γ ignored-var = fresh-var Γ "x" fresh-var-new Γ x = fresh-var Γ x rename-var-if : {ed : exprd} → ctxt → renamectxt → var → ⟦ ed ⟧ → var rename-var-if Γ ρ y t = if is-free-in y t || renamectxt-in-range ρ y then fresh-var-renamectxt Γ ρ y else y renamectxt-insert* : renamectxt → 𝕃 (var × var) → renamectxt renamectxt-insert* ρ [] = ρ renamectxt-insert* ρ ((x , y) :: vs) = renamectxt-insert* (renamectxt-insert ρ x y) vs
{ "alphanum_fraction": 0.6752994497, "avg_line_length": 32.5157894737, "ext": "agda", "hexsha": "bacfc48a27471fd042cfe8dd3c63163ebda7f781", "lang": "Agda", "max_forks_count": 34, "max_forks_repo_forks_event_max_datetime": "2022-02-20T18:33:16.000Z", "max_forks_repo_forks_event_min_datetime": "2018-09-17T11:51:36.000Z", "max_forks_repo_head_hexsha": "75f72bf2e41ac4042efc3128fa9958d4cd69b947", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "mudathirmahgoub/cedille", "max_forks_repo_path": "src/rename.agda", "max_issues_count": 123, "max_issues_repo_head_hexsha": "75f72bf2e41ac4042efc3128fa9958d4cd69b947", "max_issues_repo_issues_event_max_datetime": "2022-01-12T03:51:28.000Z", "max_issues_repo_issues_event_min_datetime": "2018-09-17T10:53:20.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "mudathirmahgoub/cedille", "max_issues_repo_path": "src/rename.agda", "max_line_length": 95, "max_stars_count": 328, "max_stars_repo_head_hexsha": "75f72bf2e41ac4042efc3128fa9958d4cd69b947", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "mudathirmahgoub/cedille", "max_stars_repo_path": "src/rename.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-26T10:33:07.000Z", "max_stars_repo_stars_event_min_datetime": "2018-09-14T20:06:09.000Z", "num_tokens": 956, "size": 3089 }
------------------------------------------------------------------------ -- Rice's theorem ------------------------------------------------------------------------ open import Equality.Propositional open import Prelude hiding (const; Decidable) -- To simplify the development, let's work with actual natural numbers -- as variables and constants (see -- Atom.one-can-restrict-attention-to-χ-ℕ-atoms). open import Atom open import Chi χ-ℕ-atoms open import Coding χ-ℕ-atoms open import Free-variables χ-ℕ-atoms import Coding.Instances.Nat -- The theorem is stated and proved under the assumption that a -- correct self-interpreter can be implemented. module Rices-theorem (eval : Exp) (cl-eval : Closed eval) (eval₁ : ∀ p v → Closed p → p ⇓ v → apply eval ⌜ p ⌝ ⇓ ⌜ v ⌝) (eval₂ : ∀ p v → Closed p → apply eval ⌜ p ⌝ ⇓ v → ∃ λ v′ → p ⇓ v′ × v ≡ ⌜ v′ ⌝) where open import H-level.Truncation.Propositional as Trunc hiding (rec) open import Logical-equivalence using (_⇔_) open import Tactic.By.Propositional open import Double-negation equality-with-J open import Equality.Decision-procedures equality-with-J open import Function-universe equality-with-J as F hiding (id; _∘_) open import H-level equality-with-J open import H-level.Closure equality-with-J open import Monad equality-with-J open import Cancellation χ-ℕ-atoms open import Compatibility χ-ℕ-atoms open import Computability χ-ℕ-atoms hiding (_∘_) open import Constants χ-ℕ-atoms open import Deterministic χ-ℕ-atoms open import Propositional χ-ℕ-atoms open import Reasoning χ-ℕ-atoms open import Termination χ-ℕ-atoms open import Values χ-ℕ-atoms open χ-atoms χ-ℕ-atoms open import Combinators as χ hiding (id; if_then_else_) open import Halting-problem open import Internal-coding ------------------------------------------------------------------------ -- The theorem -- Definition of "pointwise semantically equivalent". Pointwise-semantically-equivalent : Closed-exp → Closed-exp → Type Pointwise-semantically-equivalent e₁ e₂ = ∀ e v → semantics [ apply-cl e₁ e ]= v ⇔ semantics [ apply-cl e₂ e ]= v -- This relation is symmetric. symmetric : ∀ e₁ e₂ → Pointwise-semantically-equivalent e₁ e₂ → Pointwise-semantically-equivalent e₂ e₁ symmetric _ _ eq = λ e v → inverse (eq e v) -- Rice's theorem. module _ (P : Closed-exp →Bool) (let P′ = proj₁ P) (e∈ : Closed-exp) (Pe∈ : P′ [ e∈ ]= true) (e∉ : Closed-exp) (¬Pe∉ : P′ [ e∉ ]= false) (resp : ∀ e₁ e₂ {b} → Pointwise-semantically-equivalent e₁ e₂ → P′ [ e₁ ]= b → P′ [ e₂ ]= b) where private module Helper (p : Exp) (cl-p : Closed p) (hyp : ∀ e b → P′ [ e ]= b → apply p ⌜ e ⌝ ⇓ ⌜ b ⌝) where arg : Closed-exp → Closed-exp → Closed-exp arg e p = lambda v-x (apply (lambda v-underscore (apply (proj₁ e) (var v-x))) (apply eval (proj₁ p))) , (Closed′-closed-under-lambda $ Closed′-closed-under-apply (Closed′-closed-under-lambda $ Closed′-closed-under-apply (Closed→Closed′ $ proj₂ e) (Closed′-closed-under-var (inj₂ (inj₁ refl)))) (Closed′-closed-under-apply (Closed→Closed′ cl-eval) (Closed→Closed′ (proj₂ p)))) coded-arg : Closed-exp → Exp coded-arg e = const c-lambda (⌜ v-x ⌝ ∷ const c-apply ( ⌜ Exp.lambda v-underscore (apply (proj₁ e) (var v-x)) ⌝ ∷ const c-apply ( ⌜ eval ⌝ ∷ apply internal-code (var v-p) ∷ []) ∷ []) ∷ []) branches : List Br branches = branch c-false [] (apply p (coded-arg e∈)) ∷ branch c-true [] (χ.not (apply p (coded-arg e∉))) ∷ [] const-loop : Closed-exp const-loop = lambda v-underscore loop , (Closed′-closed-under-lambda $ Closed→Closed′ loop-closed) ⌜const-loop⌝ : Closed-exp ⌜const-loop⌝ = ⌜ proj₁ const-loop ⌝ halts : Exp halts = lambda v-p (case (apply p (proj₁ ⌜const-loop⌝)) branches) cl-coded-arg : ∀ e → Closed′ (v-p ∷ []) (coded-arg e) cl-coded-arg e = Closed′-closed-under-const λ where _ (inj₂ (inj₂ ())) _ (inj₁ refl) → Closed→Closed′ (rep-closed v-x) _ (inj₂ (inj₁ refl)) → Closed′-closed-under-const λ where _ (inj₂ (inj₂ ())) _ (inj₁ refl) → Closed→Closed′ $ rep-closed (Exp.lambda v-underscore (apply (proj₁ e) (var v-x))) _ (inj₂ (inj₁ refl)) → Closed′-closed-under-const λ where _ (inj₂ (inj₂ ())) _ (inj₁ refl) → Closed→Closed′ $ rep-closed eval _ (inj₂ (inj₁ refl)) → Closed′-closed-under-apply (Closed→Closed′ internal-code-closed) (Closed′-closed-under-var (inj₁ refl)) cl-halts : Closed halts cl-halts = Closed′-closed-under-lambda $ Closed′-closed-under-case (Closed′-closed-under-apply (Closed→Closed′ cl-p) (Closed→Closed′ $ proj₂ ⌜const-loop⌝)) (λ where (inj₁ refl) → Closed′-closed-under-apply (Closed→Closed′ cl-p) (cl-coded-arg e∈) (inj₂ (inj₁ refl)) → not-closed $ Closed′-closed-under-apply (Closed→Closed′ cl-p) (cl-coded-arg e∉) (inj₂ (inj₂ ()))) coded-arg⇓⌜arg⌝ : (e p : Closed-exp) → coded-arg e [ v-p ← ⌜ p ⌝ ] ⇓ ⌜ arg e ⌜ p ⌝ ⌝ coded-arg⇓⌜arg⌝ e p = coded-arg e [ v-p ← ⌜ p ⌝ ] ⟶⟨⟩ const c-lambda (⌜ v-x ⌝ ∷ const c-apply ( ⌜ Exp.lambda v-underscore (apply (proj₁ e) (var v-x)) ⌝ [ v-p ← ⌜ p ⌝ ] ∷ const c-apply ( ⌜ eval ⌝ [ v-p ← ⌜ p ⌝ ] ∷ apply (internal-code [ v-p ← ⌜ p ⌝ ]) ⌜ p ⌝ ∷ []) ∷ []) ∷ []) ≡⟨ cong (λ e → const _ (_ ∷ const _ (const _ (_ ∷ const _ (e ∷ _) ∷ _) ∷ _) ∷ _)) (subst-rep (proj₁ e)) ⟩⟶ const c-lambda (⌜ v-x ⌝ ∷ const c-apply ( ⌜ Exp.lambda v-underscore (apply (proj₁ e) (var v-x)) ⌝ ∷ const c-apply ( ⟨ ⌜ eval ⌝ [ v-p ← ⌜ p ⌝ ] ⟩ ∷ apply (internal-code [ v-p ← ⌜ p ⌝ ]) ⌜ p ⌝ ∷ []) ∷ []) ∷ []) ≡⟨ ⟨by⟩ (subst-rep eval) ⟩⟶ const c-lambda (⌜ v-x ⌝ ∷ const c-apply ( ⌜ Exp.lambda v-underscore (apply (proj₁ e) (var v-x)) ⌝ ∷ const c-apply ( ⌜ eval ⌝ ∷ apply ⟨ internal-code [ v-p ← ⌜ p ⌝ ] ⟩ ⌜ p ⌝ ∷ []) ∷ []) ∷ []) ≡⟨ ⟨by⟩ (subst-closed _ _ internal-code-closed) ⟩⟶ const c-lambda (⌜ v-x ⌝ ∷ const c-apply ( ⌜ Exp.lambda v-underscore (apply (proj₁ e) (var v-x)) ⌝ ∷ const c-apply ( ⌜ eval ⌝ ∷ apply internal-code ⌜ p ⌝ ∷ []) ∷ []) ∷ []) ⟶⟨ []⇓ (const (there (here (const (there (here (const (there (here ∙))))))))) (internal-code-correct (proj₁ p)) ⟩ const c-lambda (⌜ v-x ⌝ ∷ const c-apply ( ⌜ Exp.lambda v-underscore (apply (proj₁ e) (var v-x)) ⌝ ∷ const c-apply ( ⌜ eval ⌝ ∷ ⌜ ⌜ p ⌝ ⦂ Exp ⌝ ∷ []) ∷ []) ∷ []) ⟶⟨⟩ ⌜ arg e ⌜ p ⌝ ⌝ ■⟨ rep-value (arg e ⌜ p ⌝) ⟩ arg-lemma-⇓ : (e p : Closed-exp) → Terminates (proj₁ p) → Pointwise-semantically-equivalent (arg e ⌜ p ⌝) e arg-lemma-⇓ (e , cl-e) (p , cl-p) (vp , p⇓vp) (e′ , cl-e′) (v , _) = record { to = λ where (apply {v₂ = ve′} lambda q₁ (apply {v₂ = vp} lambda _ (apply {x = x} {e = e-body} {v₂ = ve″} q₂ q₃ q₄))) → apply ⟨ e ⟩ e′ ≡⟨ ⟨by⟩ (substs-closed e cl-e ((v-underscore , vp) ∷ (v-x , ve′) ∷ [])) ⟩⟶ apply (e [ v-x ← ve′ ] [ v-underscore ← vp ]) e′ ⟶⟨ apply q₂ q₁ ⟩ e-body [ x ← ⟨ ve′ ⟩ ] ≡⟨ ⟨by⟩ (values-only-compute-to-themselves (⇓-Value q₁) ( ve′ ≡⟨ sym $ subst-closed _ _ (closed⇓closed q₁ cl-e′) ⟩⟶ ve′ [ v-underscore ← vp ] ⇓⟨ q₃ ⟩■ ve″ )) ⟩⟶ e-body [ x ← ve″ ] ⇓⟨ q₄ ⟩■ v ; from = λ where (apply {v₂ = ve′} q₁ q₂ q₃) → proj₁ (apply-cl (arg (e , cl-e) ⌜ p ⌝) (e′ , cl-e′)) ⟶⟨ apply lambda q₂ ⟩ apply (lambda v-underscore (apply ⟨ e [ v-x ← ve′ ] ⟩ ve′)) (apply eval ⌜ p ⌝ [ v-x ← ve′ ]) ≡⟨ ⟨by⟩ (subst-closed _ _ cl-e) ⟩⟶ apply (lambda v-underscore (apply e ve′)) ⟨ apply eval ⌜ p ⌝ [ v-x ← ve′ ] ⟩ ≡⟨ ⟨by⟩ (subst-closed _ _ $ Closed′-closed-under-apply cl-eval (rep-closed p)) ⟩⟶ apply (lambda v-underscore (apply e ve′)) (apply eval ⌜ p ⌝) ⟶⟨ apply lambda (eval₁ p _ cl-p p⇓vp) ⟩ apply e ve′ [ v-underscore ← ⌜ vp ⌝ ] ≡⟨ subst-closed _ _ $ Closed′-closed-under-apply cl-e (closed⇓closed q₂ cl-e′) ⟩⟶ apply e ve′ ⇓⟨ apply q₁ (values-compute-to-themselves (⇓-Value q₂)) q₃ ⟩■ v } arg-lemma-⇓-true : (e : Closed-exp) → Terminates (proj₁ e) → P′ [ arg e∈ ⌜ e ⌝ ]= true arg-lemma-⇓-true e e⇓ = $⟨ Pe∈ ⟩ P′ [ e∈ ]= true ↝⟨ resp _ _ (symmetric (arg e∈ ⌜ e ⌝) e∈ (arg-lemma-⇓ e∈ e e⇓)) ⟩□ P′ [ arg e∈ ⌜ e ⌝ ]= true □ arg-lemma-⇓-false : (e : Closed-exp) → Terminates (proj₁ e) → P′ [ arg e∉ ⌜ e ⌝ ]= false arg-lemma-⇓-false e e⇓ = $⟨ ¬Pe∉ ⟩ P′ [ e∉ ]= false ↝⟨ resp _ _ (symmetric (arg e∉ ⌜ e ⌝) e∉ (arg-lemma-⇓ e∉ e e⇓)) ⟩□ P′ [ arg e∉ ⌜ e ⌝ ]= false □ arg-lemma-¬⇓′ : (e p : Closed-exp) → ¬ Terminates (proj₁ p) → Pointwise-semantically-equivalent (arg e ⌜ p ⌝) const-loop arg-lemma-¬⇓′ (e , cl-e) (p , cl-p) ¬p⇓ (e′ , cl-e′) (v , _) = record { to = λ where (apply {v₂ = ve′} lambda _ (apply {v₂ = vp} _ q _)) → ⊥-elim $ ¬p⇓ $ Σ-map id proj₁ $ eval₂ p vp cl-p ( apply eval ⌜ p ⌝ ≡⟨ sym $ subst-closed _ _ $ Closed′-closed-under-apply cl-eval (rep-closed p) ⟩⟶ apply eval ⌜ p ⌝ [ v-x ← ve′ ] ⇓⟨ q ⟩■ vp) ; from = λ where (apply lambda _ loop⇓) → ⊥-elim $ ¬loop⇓ (_ , loop⇓) } arg-lemma-¬⇓ : ∀ {b} (e₀ e : Closed-exp) → ¬ Terminates (proj₁ e) → P′ [ const-loop ]= b → P′ [ arg e₀ ⌜ e ⌝ ]= b arg-lemma-¬⇓ {b} e₀ e ¬e⇓ = P′ [ const-loop ]= b ↝⟨ resp _ _ (symmetric (arg e₀ ⌜ e ⌝) const-loop (arg-lemma-¬⇓′ e₀ e ¬e⇓)) ⟩□ P′ [ arg e₀ ⌜ e ⌝ ]= b □ ∃Bool : Type ∃Bool = ∃ λ (b : Bool) → apply p (proj₁ ⌜const-loop⌝) ⇓ ⌜ b ⌝ × P′ [ const-loop ]= b ¬¬∃ : ¬¬ ∃Bool ¬¬∃ = excluded-middle {A = P′ [ const-loop ]= true} >>= λ where (inj₁ P-const-loop) → return ( true , hyp const-loop true P-const-loop , P-const-loop ) (inj₂ ¬P-const-loop) → proj₂ P const-loop >>= λ where (true , P-const-loop) → ⊥-elim (¬P-const-loop P-const-loop) (false , ¬P-const-loop) → return ( false , hyp const-loop false ¬P-const-loop , ¬P-const-loop ) halts⇓-lemma : ∀ {v} → ∃Bool → (e : Closed-exp) → (P′ [ const-loop ]= false → apply p (⌜ arg e∈ ⌜ e ⌝ ⌝) ⇓ v) → (P′ [ const-loop ]= true → χ.not (apply p (⌜ arg e∉ ⌜ e ⌝ ⌝)) ⇓ v) → apply halts ⌜ e ⌝ ⇓ v halts⇓-lemma {v} ∃bool e e∈⇓v e∉⇓v = apply halts ⌜ e ⌝ ⟶⟨ apply lambda (rep⇓rep e) ⟩ case (apply ⟨ p [ v-p ← ⌜ e ⌝ ] ⟩ (proj₁ ⌜const-loop⌝)) (branches [ v-p ← ⌜ e ⌝ ]B⋆) ≡⟨ ⟨by⟩ (subst-closed _ _ cl-p) ⟩⟶ case (apply p (proj₁ ⌜const-loop⌝)) (branches [ v-p ← ⌜ e ⌝ ]B⋆) ⇓⟨ lemma ∃bool ⟩■ v where lemma : ∃Bool → _ lemma (true , p⌜const-loop⌝⇓true , P-const-loop) = case (apply p (proj₁ ⌜const-loop⌝)) (branches [ v-p ← ⌜ e ⌝ ]B⋆) ⟶⟨ case p⌜const-loop⌝⇓true (there (λ ()) here) [] ⟩ χ.not (apply ⟨ p [ v-p ← ⌜ e ⌝ ] ⟩ (coded-arg e∉ [ v-p ← ⌜ e ⌝ ])) ≡⟨ ⟨by⟩ (subst-closed _ _ cl-p) ⟩⟶ χ.not (apply p (coded-arg e∉ [ v-p ← ⌜ e ⌝ ])) ⟶⟨ []⇓ (case (apply→ ∙)) (coded-arg⇓⌜arg⌝ e∉ e) ⟩ χ.not (apply p (⌜ arg e∉ ⌜ e ⌝ ⌝)) ⇓⟨ e∉⇓v P-const-loop ⟩■ v lemma (false , p⌜const-loop⌝⇓false , ¬P-const-loop) = case (apply p (proj₁ ⌜const-loop⌝)) (branches [ v-p ← ⌜ e ⌝ ]B⋆) ⟶⟨ case p⌜const-loop⌝⇓false here [] ⟩ apply ⟨ p [ v-p ← ⌜ e ⌝ ] ⟩ (coded-arg e∈ [ v-p ← ⌜ e ⌝ ]) ≡⟨ ⟨by⟩ (subst-closed _ _ cl-p) ⟩⟶ apply p (coded-arg e∈ [ v-p ← ⌜ e ⌝ ]) ⟶⟨ []⇓ (apply→ ∙) (coded-arg⇓⌜arg⌝ e∈ e) ⟩ apply p (⌜ arg e∈ ⌜ e ⌝ ⌝) ⇓⟨ e∈⇓v ¬P-const-loop ⟩■ v ⇓-lemma : ∃Bool → (e : Closed-exp) → Terminates (proj₁ e) → apply halts ⌜ e ⌝ ⇓ ⌜ true ⦂ Bool ⌝ ⇓-lemma ∃bool e e⇓ = halts⇓-lemma ∃bool e (λ _ → apply p (⌜ arg e∈ ⌜ e ⌝ ⌝) ⇓⟨ hyp (arg e∈ ⌜ e ⌝) true (arg-lemma-⇓-true e e⇓) ⟩■ ⌜ true ⦂ Bool ⌝) (λ _ → χ.not (apply p (⌜ arg e∉ ⌜ e ⌝ ⌝)) ⟶⟨ []⇓ (case ∙) (hyp (arg e∉ ⌜ e ⌝) false (arg-lemma-⇓-false e e⇓)) ⟩ χ.not ⌜ false ⦂ Bool ⌝ ⇓⟨ not-correct false (rep⇓rep (false ⦂ Bool)) ⟩■ ⌜ true ⦂ Bool ⌝) ¬⇓-lemma : ∃Bool → (e : Closed-exp) → ¬ Terminates (proj₁ e) → apply halts ⌜ e ⌝ ⇓ ⌜ false ⦂ Bool ⌝ ¬⇓-lemma ∃bool e ¬e⇓ = halts⇓-lemma ∃bool e (λ ¬P-const-loop → apply p (⌜ arg e∈ ⌜ e ⌝ ⌝) ⇓⟨ hyp (arg e∈ ⌜ e ⌝) false (arg-lemma-¬⇓ e∈ e ¬e⇓ ¬P-const-loop) ⟩■ ⌜ false ⦂ Bool ⌝) (λ P-const-loop → χ.not (apply p (⌜ arg e∉ ⌜ e ⌝ ⌝)) ⟶⟨ []⇓ (case ∙) (hyp (arg e∉ ⌜ e ⌝) true (arg-lemma-¬⇓ e∉ e ¬e⇓ P-const-loop)) ⟩ χ.not ⌜ true ⦂ Bool ⌝ ⇓⟨ not-correct true (rep⇓rep (true ⦂ Bool)) ⟩■ ⌜ false ⦂ Bool ⌝) rice's-theorem : ¬ Decidable P rice's-theorem (p , cl-p , hyp , _) = ¬¬¬⊥ $ ¬¬∃ >>= λ ∃bool → return (intensional-halting-problem₀ ( halts , cl-halts , λ e cl-e → ⇓-lemma ∃bool (e , cl-e) , ¬⇓-lemma ∃bool (e , cl-e) )) where open Helper p cl-p hyp -- A variant of the theorem. rice's-theorem′ : (P : Closed-exp → Type) (e∈ : Closed-exp) → P e∈ → (e∉ : Closed-exp) → ¬ P e∉ → (∀ e₁ e₂ → Pointwise-semantically-equivalent e₁ e₂ → P e₁ → P e₂) → ¬ Decidable (as-function-to-Bool₁ P) rice's-theorem′ P e∈ Pe∈ e∉ ¬Pe∉ resp = rice's-theorem (as-function-to-Bool₁ P) e∈ ((λ _ → refl) , ⊥-elim ∘ (_$ Pe∈)) e∉ (⊥-elim ∘ ¬Pe∉ , (λ _ → refl)) (λ e₁ e₂ eq → Σ-map (_∘ resp e₂ e₁ (symmetric e₁ e₂ eq)) (_∘ (_∘ resp e₁ e₂ eq))) ------------------------------------------------------------------------ -- Examples -- The problem of deciding whether an expression implements the -- successor function is undecidable. Equal-to-suc : Closed-exp →Bool Equal-to-suc = as-function-to-Bool₁ λ e → (n : ℕ) → apply (proj₁ e) ⌜ n ⌝ ⇓ ⌜ suc n ⌝ equal-to-suc-not-decidable : ¬ Decidable Equal-to-suc equal-to-suc-not-decidable = rice's-theorem′ _ (s , from-⊎ (closed? s)) (λ n → apply lambda (rep⇓rep n) (rep⇓rep (suc n))) (z , from-⊎ (closed? z)) (λ z⌜n⌝⇓ → case z⌜n⌝⇓ 0 of λ { (apply () _ _) }) (λ e₁ e₂ e₁∼e₂ Pe₁ n → apply (proj₁ e₂) ⌜ n ⌝ ⇓⟨ _⇔_.to (e₁∼e₂ ⌜ n ⌝ ⌜ suc n ⌝) (Pe₁ n) ⟩■ ⌜ suc n ⌝) where z = const c-zero [] s = lambda v-n (const c-suc (var v-n ∷ [])) -- The problem of deciding whether an expression always terminates -- with the same value when applied to an arbitrary argument is -- undecidable. Is-constant : Closed-exp →Bool Is-constant = as-function-to-Bool₁ λ e → ∃ λ v → (n : ℕ) → apply (proj₁ e) ⌜ n ⌝ ⇓ v is-constant-not-decidable : ¬ Decidable Is-constant is-constant-not-decidable = rice's-theorem′ _ (c , from-⊎ (closed? c)) ((⌜ 0 ⌝ ⦂ Exp) , λ n → apply c ⌜ n ⌝ ⇓⟨ apply lambda (rep⇓rep n) (const []) ⟩■ ⌜ 0 ⌝) (f , from-⊎ (closed? f)) not-constant (λ e₁ e₂ e₁∼e₂ → Σ-map id λ {v} ⇓v n → let v-closed : Closed v v-closed = closed⇓closed (⇓v n) $ Closed′-closed-under-apply (proj₂ e₁) (rep-closed n) in apply (proj₁ e₂) ⌜ n ⌝ ⇓⟨ _⇔_.to (e₁∼e₂ ⌜ n ⌝ (v , v-closed)) (⇓v n) ⟩■ v) where c = lambda v-underscore ⌜ 0 ⌝ f = lambda v-n (var v-n) not-constant : ¬ ∃ λ v → (n : ℕ) → apply f ⌜ n ⌝ ⇓ v not-constant (v , constant) = impossible where v≡0 : v ≡ ⌜ 0 ⌝ v≡0 with constant 0 ... | apply lambda (const []) (const []) = refl v≡1 : v ≡ ⌜ 1 ⌝ v≡1 with constant 1 ... | apply lambda (const (const [] ∷ [])) (const (const [] ∷ [])) = refl 0≡1 = ⌜ 0 ⌝ ≡⟨ sym v≡0 ⟩ v ≡⟨ v≡1 ⟩∎ ⌜ 1 ⌝ ∎ impossible : ⊥ impossible with 0≡1 ... | ()
{ "alphanum_fraction": 0.4225439504, "avg_line_length": 36.9083969466, "ext": "agda", "hexsha": "2ee421578a38b40ded6688817307ecd0a91916ab", "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": "30966769b8cbd46aa490b6964a4aa0e67a7f9ab1", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "nad/chi", "max_forks_repo_path": "src/Rices-theorem.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "30966769b8cbd46aa490b6964a4aa0e67a7f9ab1", "max_issues_repo_issues_event_max_datetime": "2020-06-08T11:08:25.000Z", "max_issues_repo_issues_event_min_datetime": "2020-05-21T23:29:54.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "nad/chi", "max_issues_repo_path": "src/Rices-theorem.agda", "max_line_length": 138, "max_stars_count": 2, "max_stars_repo_head_hexsha": "30966769b8cbd46aa490b6964a4aa0e67a7f9ab1", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "nad/chi", "max_stars_repo_path": "src/Rices-theorem.agda", "max_stars_repo_stars_event_max_datetime": "2020-10-20T16:27:00.000Z", "max_stars_repo_stars_event_min_datetime": "2020-05-21T22:58:07.000Z", "num_tokens": 6905, "size": 19340 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Some Vec-related properties ------------------------------------------------------------------------ module Data.Vec.Properties where open import Algebra open import Category.Applicative.Indexed open import Category.Monad open import Category.Monad.Identity open import Data.Vec open import Data.List.Any using (here; there) renaming (module Membership-≡ to List) open import Data.Nat open import Data.Empty using (⊥-elim) import Data.Nat.Properties as Nat open import Data.Fin as Fin using (Fin; zero; suc; toℕ; fromℕ) open import Data.Fin.Properties using (_+′_) open import Data.Empty using (⊥-elim) open import Data.Product using (_×_ ; _,_) open import Function open import Function.Inverse using (_↔_) open import Relation.Binary module UsingVectorEquality {s₁ s₂} (S : Setoid s₁ s₂) where private module SS = Setoid S open SS using () renaming (Carrier to A) import Data.Vec.Equality as VecEq open VecEq.Equality S replicate-lemma : ∀ {m} n x (xs : Vec A m) → replicate {n = n} x ++ (x ∷ xs) ≈ replicate {n = 1 + n} x ++ xs replicate-lemma zero x xs = refl (x ∷ xs) replicate-lemma (suc n) x xs = SS.refl ∷-cong replicate-lemma n x xs xs++[]=xs : ∀ {n} (xs : Vec A n) → xs ++ [] ≈ xs xs++[]=xs [] = []-cong xs++[]=xs (x ∷ xs) = SS.refl ∷-cong xs++[]=xs xs map-++-commute : ∀ {b m n} {B : Set b} (f : B → A) (xs : Vec B m) {ys : Vec B n} → map f (xs ++ ys) ≈ map f xs ++ map f ys map-++-commute f [] = refl _ map-++-commute f (x ∷ xs) = SS.refl ∷-cong map-++-commute f xs open import Relation.Binary.PropositionalEquality as P using (_≡_; _≢_; refl; _≗_) open import Relation.Binary.HeterogeneousEquality using (_≅_; refl) ∷-injective : ∀ {a n} {A : Set a} {x y : A} {xs ys : Vec A n} → (x ∷ xs) ≡ (y ∷ ys) → x ≡ y × xs ≡ ys ∷-injective refl = refl , refl -- lookup is an applicative functor morphism. lookup-morphism : ∀ {a n} (i : Fin n) → Morphism (applicative {a = a}) (RawMonad.rawIApplicative IdentityMonad) lookup-morphism i = record { op = lookup i ; op-pure = lookup-replicate i ; op-⊛ = lookup-⊛ i } where lookup-replicate : ∀ {a n} {A : Set a} (i : Fin n) → lookup i ∘ replicate {A = A} ≗ id {A = A} lookup-replicate zero = λ _ → refl lookup-replicate (suc i) = lookup-replicate i lookup-⊛ : ∀ {a b n} {A : Set a} {B : Set b} i (fs : Vec (A → B) n) (xs : Vec A n) → lookup i (fs ⊛ xs) ≡ (lookup i fs $ lookup i xs) lookup-⊛ zero (f ∷ fs) (x ∷ xs) = refl lookup-⊛ (suc i) (f ∷ fs) (x ∷ xs) = lookup-⊛ i fs xs -- tabulate is an inverse of flip lookup. lookup∘tabulate : ∀ {a n} {A : Set a} (f : Fin n → A) (i : Fin n) → lookup i (tabulate f) ≡ f i lookup∘tabulate f zero = refl lookup∘tabulate f (suc i) = lookup∘tabulate (f ∘ suc) i tabulate∘lookup : ∀ {a n} {A : Set a} (xs : Vec A n) → tabulate (flip lookup xs) ≡ xs tabulate∘lookup [] = refl tabulate∘lookup (x ∷ xs) = P.cong (_∷_ x) $ tabulate∘lookup xs -- If you look up an index in allFin n, then you get the index. lookup-allFin : ∀ {n} (i : Fin n) → lookup i (allFin n) ≡ i lookup-allFin = lookup∘tabulate id -- Various lemmas relating lookup and _++_. lookup-++-< : ∀ {a} {A : Set a} {m n} (xs : Vec A m) (ys : Vec A n) i (i<m : toℕ i < m) → lookup i (xs ++ ys) ≡ lookup (Fin.fromℕ≤ i<m) xs lookup-++-< [] ys i () lookup-++-< (x ∷ xs) ys zero (s≤s z≤n) = refl lookup-++-< (x ∷ xs) ys (suc i) (s≤s (s≤s i<m)) = lookup-++-< xs ys i (s≤s i<m) lookup-++-≥ : ∀ {a} {A : Set a} {m n} (xs : Vec A m) (ys : Vec A n) i (i≥m : toℕ i ≥ m) → lookup i (xs ++ ys) ≡ lookup (Fin.reduce≥ i i≥m) ys lookup-++-≥ [] ys i i≥m = refl lookup-++-≥ (x ∷ xs) ys zero () lookup-++-≥ (x ∷ xs) ys (suc i) (s≤s i≥m) = lookup-++-≥ xs ys i i≥m lookup-++-inject+ : ∀ {a} {A : Set a} {m n} (xs : Vec A m) (ys : Vec A n) i → lookup (Fin.inject+ n i) (xs ++ ys) ≡ lookup i xs lookup-++-inject+ [] ys () lookup-++-inject+ (x ∷ xs) ys zero = refl lookup-++-inject+ (x ∷ xs) ys (suc i) = lookup-++-inject+ xs ys i lookup-++-+′ : ∀ {a} {A : Set a} {m n} (xs : Vec A m) (ys : Vec A n) i → lookup (fromℕ m +′ i) (xs ++ ys) ≡ lookup i ys lookup-++-+′ [] ys zero = refl lookup-++-+′ [] (y ∷ xs) (suc i) = lookup-++-+′ [] xs i lookup-++-+′ (x ∷ xs) ys i = lookup-++-+′ xs ys i -- Properties relating lookup and _[_]≔_. lookup∘update : ∀ {a} {A : Set a} {n} (i : Fin n) (xs : Vec A n) x → lookup i (xs [ i ]≔ x) ≡ x lookup∘update zero (_ ∷ xs) x = refl lookup∘update (suc i) (_ ∷ xs) x = lookup∘update i xs x lookup∘update′ : ∀ {a} {A : Set a} {n} {i j : Fin n} → i ≢ j → ∀ (xs : Vec A n) y → lookup i (xs [ j ]≔ y) ≡ lookup i xs lookup∘update′ {i = zero} {zero} i≢j xs y = ⊥-elim (i≢j refl) lookup∘update′ {i = zero} {suc j} i≢j (x ∷ xs) y = refl lookup∘update′ {i = suc i} {zero} i≢j (x ∷ xs) y = refl lookup∘update′ {i = suc i} {suc j} i≢j (x ∷ xs) y = lookup∘update′ (i≢j ∘ P.cong suc) xs y -- map is a congruence. map-cong : ∀ {a b n} {A : Set a} {B : Set b} {f g : A → B} → f ≗ g → _≗_ {A = Vec A n} (map f) (map g) map-cong f≗g [] = refl map-cong f≗g (x ∷ xs) = P.cong₂ _∷_ (f≗g x) (map-cong f≗g xs) -- map is functorial. map-id : ∀ {a n} {A : Set a} → _≗_ {A = Vec A n} (map id) id map-id [] = refl map-id (x ∷ xs) = P.cong (_∷_ x) (map-id xs) map-∘ : ∀ {a b c n} {A : Set a} {B : Set b} {C : Set c} (f : B → C) (g : A → B) → _≗_ {A = Vec A n} (map (f ∘ g)) (map f ∘ map g) map-∘ f g [] = refl map-∘ f g (x ∷ xs) = P.cong (_∷_ (f (g x))) (map-∘ f g xs) -- tabulate can be expressed using map and allFin. tabulate-∘ : ∀ {n a b} {A : Set a} {B : Set b} (f : A → B) (g : Fin n → A) → tabulate (f ∘ g) ≡ map f (tabulate g) tabulate-∘ {zero} f g = refl tabulate-∘ {suc n} f g = P.cong (_∷_ (f (g zero))) (tabulate-∘ f (g ∘ suc)) tabulate-allFin : ∀ {n a} {A : Set a} (f : Fin n → A) → tabulate f ≡ map f (allFin n) tabulate-allFin f = tabulate-∘ f id -- The positive case of allFin can be expressed recursively using map. allFin-map : ∀ n → allFin (suc n) ≡ zero ∷ map suc (allFin n) allFin-map n = P.cong (_∷_ zero) $ tabulate-∘ suc id -- If you look up every possible index, in increasing order, then you -- get back the vector you started with. map-lookup-allFin : ∀ {a} {A : Set a} {n} (xs : Vec A n) → map (λ x → lookup x xs) (allFin n) ≡ xs map-lookup-allFin {n = n} xs = begin map (λ x → lookup x xs) (allFin n) ≡⟨ P.sym $ tabulate-∘ (λ x → lookup x xs) id ⟩ tabulate (λ x → lookup x xs) ≡⟨ tabulate∘lookup xs ⟩ xs ∎ where open P.≡-Reasoning -- tabulate f contains f i. ∈-tabulate : ∀ {n a} {A : Set a} (f : Fin n → A) i → f i ∈ tabulate f ∈-tabulate f zero = here ∈-tabulate f (suc i) = there (∈-tabulate (f ∘ suc) i) -- allFin n contains all elements in Fin n. ∈-allFin : ∀ {n} (i : Fin n) → i ∈ allFin n ∈-allFin = ∈-tabulate id -- sum commutes with _++_. sum-++-commute : ∀ {m n} (xs : Vec ℕ m) {ys : Vec ℕ n} → sum (xs ++ ys) ≡ sum xs + sum ys sum-++-commute [] = refl sum-++-commute (x ∷ xs) {ys} = begin x + sum (xs ++ ys) ≡⟨ P.cong (λ p → x + p) (sum-++-commute xs) ⟩ x + (sum xs + sum ys) ≡⟨ P.sym (+-assoc x (sum xs) (sum ys)) ⟩ sum (x ∷ xs) + sum ys ∎ where open P.≡-Reasoning open CommutativeSemiring Nat.commutativeSemiring hiding (_+_; sym) -- foldr is a congruence. foldr-cong : ∀ {a b} {A : Set a} {B₁ : ℕ → Set b} {f₁ : ∀ {n} → A → B₁ n → B₁ (suc n)} {e₁} {B₂ : ℕ → Set b} {f₂ : ∀ {n} → A → B₂ n → B₂ (suc n)} {e₂} → (∀ {n x} {y₁ : B₁ n} {y₂ : B₂ n} → y₁ ≅ y₂ → f₁ x y₁ ≅ f₂ x y₂) → e₁ ≅ e₂ → ∀ {n} (xs : Vec A n) → foldr B₁ f₁ e₁ xs ≅ foldr B₂ f₂ e₂ xs foldr-cong _ e₁=e₂ [] = e₁=e₂ foldr-cong {B₁ = B₁} f₁=f₂ e₁=e₂ (x ∷ xs) = f₁=f₂ (foldr-cong {B₁ = B₁} f₁=f₂ e₁=e₂ xs) -- foldl is a congruence. foldl-cong : ∀ {a b} {A : Set a} {B₁ : ℕ → Set b} {f₁ : ∀ {n} → B₁ n → A → B₁ (suc n)} {e₁} {B₂ : ℕ → Set b} {f₂ : ∀ {n} → B₂ n → A → B₂ (suc n)} {e₂} → (∀ {n x} {y₁ : B₁ n} {y₂ : B₂ n} → y₁ ≅ y₂ → f₁ y₁ x ≅ f₂ y₂ x) → e₁ ≅ e₂ → ∀ {n} (xs : Vec A n) → foldl B₁ f₁ e₁ xs ≅ foldl B₂ f₂ e₂ xs foldl-cong _ e₁=e₂ [] = e₁=e₂ foldl-cong {B₁ = B₁} f₁=f₂ e₁=e₂ (x ∷ xs) = foldl-cong {B₁ = B₁ ∘ suc} f₁=f₂ (f₁=f₂ e₁=e₂) xs -- The (uniqueness part of the) universality property for foldr. foldr-universal : ∀ {a b} {A : Set a} (B : ℕ → Set b) (f : ∀ {n} → A → B n → B (suc n)) {e} (h : ∀ {n} → Vec A n → B n) → h [] ≡ e → (∀ {n} x → h ∘ _∷_ x ≗ f {n} x ∘ h) → ∀ {n} → h ≗ foldr B {n} f e foldr-universal B f h base step [] = base foldr-universal B f {e} h base step (x ∷ xs) = begin h (x ∷ xs) ≡⟨ step x xs ⟩ f x (h xs) ≡⟨ P.cong (f x) (foldr-universal B f h base step xs) ⟩ f x (foldr B f e xs) ∎ where open P.≡-Reasoning -- A fusion law for foldr. foldr-fusion : ∀ {a b c} {A : Set a} {B : ℕ → Set b} {f : ∀ {n} → A → B n → B (suc n)} e {C : ℕ → Set c} {g : ∀ {n} → A → C n → C (suc n)} (h : ∀ {n} → B n → C n) → (∀ {n} x → h ∘ f {n} x ≗ g x ∘ h) → ∀ {n} → h ∘ foldr B {n} f e ≗ foldr C g (h e) foldr-fusion {B = B} {f} e {C} h fuse = foldr-universal C _ _ refl (λ x xs → fuse x (foldr B f e xs)) -- The identity function is a fold. idIsFold : ∀ {a n} {A : Set a} → id ≗ foldr (Vec A) {n} _∷_ [] idIsFold = foldr-universal _ _ id refl (λ _ _ → refl) -- The _∈_ predicate is equivalent (in the following sense) to the -- corresponding predicate for lists. ∈⇒List-∈ : ∀ {a} {A : Set a} {n x} {xs : Vec A n} → x ∈ xs → x List.∈ toList xs ∈⇒List-∈ here = here P.refl ∈⇒List-∈ (there x∈) = there (∈⇒List-∈ x∈) List-∈⇒∈ : ∀ {a} {A : Set a} {x : A} {xs} → x List.∈ xs → x ∈ fromList xs List-∈⇒∈ (here P.refl) = here List-∈⇒∈ (there x∈) = there (List-∈⇒∈ x∈) -- Proof irrelevance for _[_]=_. proof-irrelevance-[]= : ∀ {a} {A : Set a} {n} {xs : Vec A n} {i x} → (p q : xs [ i ]= x) → p ≡ q proof-irrelevance-[]= here here = refl proof-irrelevance-[]= (there xs[i]=x) (there xs[i]=x') = P.cong there (proof-irrelevance-[]= xs[i]=x xs[i]=x') -- _[_]=_ can be expressed using lookup and _≡_. []=↔lookup : ∀ {a n i} {A : Set a} {x} {xs : Vec A n} → xs [ i ]= x ↔ lookup i xs ≡ x []=↔lookup {i = i} {x = x} {xs} = record { to = P.→-to-⟶ to ; from = P.→-to-⟶ (from i xs) ; inverse-of = record { left-inverse-of = λ _ → proof-irrelevance-[]= _ _ ; right-inverse-of = λ _ → P.proof-irrelevance _ _ } } where to : ∀ {n xs} {i : Fin n} → xs [ i ]= x → lookup i xs ≡ x to here = refl to (there xs[i]=x) = to xs[i]=x from : ∀ {n} (i : Fin n) xs → lookup i xs ≡ x → xs [ i ]= x from zero (.x ∷ _) refl = here from (suc i) (_ ∷ xs) p = there (from i xs p) ------------------------------------------------------------------------ -- Some properties related to _[_]≔_ []≔-idempotent : ∀ {n a} {A : Set a} (xs : Vec A n) (i : Fin n) {x₁ x₂ : A} → (xs [ i ]≔ x₁) [ i ]≔ x₂ ≡ xs [ i ]≔ x₂ []≔-idempotent [] () []≔-idempotent (x ∷ xs) zero = refl []≔-idempotent (x ∷ xs) (suc i) = P.cong (_∷_ x) $ []≔-idempotent xs i []≔-commutes : ∀ {n a} {A : Set a} (xs : Vec A n) (i j : Fin n) {x y : A} → i ≢ j → (xs [ i ]≔ x) [ j ]≔ y ≡ (xs [ j ]≔ y) [ i ]≔ x []≔-commutes [] () () _ []≔-commutes (x ∷ xs) zero zero 0≢0 = ⊥-elim $ 0≢0 refl []≔-commutes (x ∷ xs) zero (suc i) _ = refl []≔-commutes (x ∷ xs) (suc i) zero _ = refl []≔-commutes (x ∷ xs) (suc i) (suc j) i≢j = P.cong (_∷_ x) $ []≔-commutes xs i j (i≢j ∘ P.cong suc) []≔-updates : ∀ {n a} {A : Set a} (xs : Vec A n) (i : Fin n) {x : A} → (xs [ i ]≔ x) [ i ]= x []≔-updates [] () []≔-updates (x ∷ xs) zero = here []≔-updates (x ∷ xs) (suc i) = there ([]≔-updates xs i) []≔-minimal : ∀ {n a} {A : Set a} (xs : Vec A n) (i j : Fin n) {x y : A} → i ≢ j → xs [ i ]= x → (xs [ j ]≔ y) [ i ]= x []≔-minimal [] () () _ _ []≔-minimal (x ∷ xs) .zero zero 0≢0 here = ⊥-elim $ 0≢0 refl []≔-minimal (x ∷ xs) .zero (suc j) _ here = here []≔-minimal (x ∷ xs) (suc i) zero _ (there loc) = there loc []≔-minimal (x ∷ xs) (suc i) (suc j) i≢j (there loc) = there ([]≔-minimal xs i j (i≢j ∘ P.cong suc) loc) map-[]≔ : ∀ {n a b} {A : Set a} {B : Set b} (f : A → B) (xs : Vec A n) (i : Fin n) {x : A} → map f (xs [ i ]≔ x) ≡ map f xs [ i ]≔ f x map-[]≔ f [] () map-[]≔ f (x ∷ xs) zero = refl map-[]≔ f (x ∷ xs) (suc i) = P.cong (_∷_ _) $ map-[]≔ f xs i []≔-lookup : ∀ {a} {A : Set a} {n} (xs : Vec A n) (i : Fin n) → xs [ i ]≔ lookup i xs ≡ xs []≔-lookup [] () []≔-lookup (x ∷ xs) zero = refl []≔-lookup (x ∷ xs) (suc i) = P.cong (_∷_ x) $ []≔-lookup xs i []≔-++-inject+ : ∀ {a} {A : Set a} {m n x} (xs : Vec A m) (ys : Vec A n) i → (xs ++ ys) [ Fin.inject+ n i ]≔ x ≡ xs [ i ]≔ x ++ ys []≔-++-inject+ [] ys () []≔-++-inject+ (x ∷ xs) ys zero = refl []≔-++-inject+ (x ∷ xs) ys (suc i) = P.cong (_∷_ x) $ []≔-++-inject+ xs ys i
{ "alphanum_fraction": 0.4704049844, "avg_line_length": 36.6857142857, "ext": "agda", "hexsha": "c327b4c51c120486d6e58092eb916129e0823e62", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_forks_repo_licenses": [ "Apache-2.0" ], "max_forks_repo_name": "qwe2/try-agda", "max_forks_repo_path": "agda-stdlib-0.9/src/Data/Vec/Properties.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "Apache-2.0" ], "max_issues_repo_name": "qwe2/try-agda", "max_issues_repo_path": "agda-stdlib-0.9/src/Data/Vec/Properties.agda", "max_line_length": 83, "max_stars_count": 1, "max_stars_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_stars_repo_licenses": [ "Apache-2.0" ], "max_stars_repo_name": "qwe2/try-agda", "max_stars_repo_path": "agda-stdlib-0.9/src/Data/Vec/Properties.agda", "max_stars_repo_stars_event_max_datetime": "2016-10-20T15:52:05.000Z", "max_stars_repo_stars_event_min_datetime": "2016-10-20T15:52:05.000Z", "num_tokens": 5827, "size": 14124 }
module Numeral.Finite.Relation.Order where import Lvl open import Data open import Data.Boolean.Stmt open import Functional open import Numeral.Finite open import Numeral.Finite.Oper.Comparisons open import Numeral.Natural open import Type private variable an bn cn n : ℕ private variable a : 𝕟(an) private variable b : 𝕟(bn) private variable c : 𝕟(cn) _≤_ : 𝕟(an) → 𝕟(bn) → Type _≤_ = IsTrue ∘₂ (_≤?_) _≥_ : 𝕟(an) → 𝕟(bn) → Type _≥_ = IsTrue ∘₂ (_≥?_) _<_ : 𝕟(an) → 𝕟(bn) → Type _<_ = IsTrue ∘₂ (_<?_) _>_ : 𝕟(an) → 𝕟(bn) → Type _>_ = IsTrue ∘₂ (_>?_) _≡_ : 𝕟(an) → 𝕟(bn) → Type _≡_ = IsTrue ∘₂ (_≡?_) _≢_ : 𝕟(an) → 𝕟(bn) → Type _≢_ = IsTrue ∘₂ (_≢?_) -- TODO: open import Structure.Relator.Properties import Numeral.Natural.Relation.Order as ℕ [≤]-minimum : (𝟎{n} ≤ a) [≤]-minimum {a = 𝟎} = <> [≤]-minimum {a = 𝐒 _} = <> -- [≤]-maximum : (bound a ℕ.≤ n) → (a ≤ maximum{n}) -- [≤]-maximum {_} {𝟎} ℕ.[≤]-with-[𝐒] = <> -- [≤]-maximum {𝐒 an} {𝐒 a} {.(𝐒 n)} (ℕ.[≤]-with-[𝐒] {y = n} ⦃ p ⦄) = [≤]-maximum {an}{a}{n} p [≤]-maximum : (bound a ℕ.≤ 𝐒(n)) → (a ≤ maximum{n}) [≤]-maximum {a = 𝟎} {𝟎} (ℕ.succ _) = <> [≤]-maximum {a = 𝟎} {𝐒 _} (ℕ.succ _) = <> [≤]-maximum {a = 𝐒 a} {𝐒 x} (ℕ.succ p) = [≤]-maximum {a = a} p [≤]-maximum {a = 𝐒 {𝟎} ()} {𝟎} (ℕ.succ _) [≤]-maximum {a = 𝐒 {𝐒 n} a} {𝟎} (ℕ.succ ()) [≤]-reflexivity-raw : (a ≤ a) [≤]-reflexivity-raw {a = 𝟎} = <> [≤]-reflexivity-raw {a = 𝐒 a} = [≤]-reflexivity-raw {a = a} [≤]-asymmetry-raw : (a ≤ b) → (b ≤ a) → (a ≡ b) [≤]-asymmetry-raw {a = 𝟎} {b = 𝟎} _ _ = <> [≤]-asymmetry-raw {a = 𝐒 a} {b = 𝐒 b} p q = [≤]-asymmetry-raw {a = a}{b = b} p q [≤]-transitivity-raw : (a ≤ b) → (b ≤ c) → (a ≤ c) [≤]-transitivity-raw {a = 𝟎} {b = 𝟎} {c = 𝟎} p q = <> [≤]-transitivity-raw {a = 𝟎} {b = 𝟎} {c = 𝐒 c} p q = <> [≤]-transitivity-raw {a = 𝟎} {b = 𝐒 b} {c = 𝐒 c} p q = <> [≤]-transitivity-raw {a = 𝐒 a} {b = 𝐒 b} {c = 𝐒 c} p q = [≤]-transitivity-raw {a = a} {b = b} {c = c} p q
{ "alphanum_fraction": 0.4977667494, "avg_line_length": 30.5303030303, "ext": "agda", "hexsha": "826ef12c1695c995f467bc64ce820bcddf124b85", "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/Finite/Relation/Order.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/Finite/Relation/Order.agda", "max_line_length": 105, "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/Finite/Relation/Order.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": 1047, "size": 2015 }
-- This file just tests that the options --no-save-metas and -- --save-metas are parsed correctly. {-# OPTIONS --no-save-metas --save-metas #-}
{ "alphanum_fraction": 0.6827586207, "avg_line_length": 29, "ext": "agda", "hexsha": "1d26dfcb13e0c514cd08dfbdbda8de28cc3fa023", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "b5b3b1657556f720a7310cb7744edb1fac71eaf4", "max_forks_repo_licenses": [ "BSD-2-Clause" ], "max_forks_repo_name": "Seanpm2001-Agda-lang/agda", "max_forks_repo_path": "test/Succeed/Issue5731.agda", "max_issues_count": 6, "max_issues_repo_head_hexsha": "b5b3b1657556f720a7310cb7744edb1fac71eaf4", "max_issues_repo_issues_event_max_datetime": "2021-11-24T08:31:10.000Z", "max_issues_repo_issues_event_min_datetime": "2021-10-18T08:12:24.000Z", "max_issues_repo_licenses": [ "BSD-2-Clause" ], "max_issues_repo_name": "Seanpm2001-Agda-lang/agda", "max_issues_repo_path": "test/Succeed/Issue5731.agda", "max_line_length": 60, "max_stars_count": 1, "max_stars_repo_head_hexsha": "6b13364d36eeb60d8ec15eaf8effe23c73401900", "max_stars_repo_licenses": [ "BSD-2-Clause" ], "max_stars_repo_name": "sseefried/agda", "max_stars_repo_path": "test/Succeed/Issue5731.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-05T00:25:14.000Z", "max_stars_repo_stars_event_min_datetime": "2022-03-05T00:25:14.000Z", "num_tokens": 36, "size": 145 }
module Type.Category.IntensionalFunctionsCategory.LvlUpFunctor where import Lvl open import Relator.Equals open import Relator.Equals.Proofs.Equiv open import Structure.Category open import Structure.Category.Functor open import Type open import Type.Category.IntensionalFunctionsCategory private variable ℓ₁ ℓ₂ : Lvl.Level instance LvlUp-functor : Functor(typeIntensionalFnCategory)(typeIntensionalFnCategory)(Lvl.Up{ℓ₁}{ℓ₂}) Functor.map LvlUp-functor f(Lvl.up x) = Lvl.up(f(x)) Functor.op-preserving LvlUp-functor = [≡]-intro Functor.id-preserving LvlUp-functor = [≡]-intro
{ "alphanum_fraction": 0.7956448911, "avg_line_length": 33.1666666667, "ext": "agda", "hexsha": "8e3e49d1d8ed56dbc93c9bb88e91d4d8f791e4a7", "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/Category/IntensionalFunctionsCategory/LvlUpFunctor.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/Category/IntensionalFunctionsCategory/LvlUpFunctor.agda", "max_line_length": 95, "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/Category/IntensionalFunctionsCategory/LvlUpFunctor.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": 171, "size": 597 }
------------------------------------------------------------------------ -- Some results related to expansion for the delay monad ------------------------------------------------------------------------ {-# OPTIONS --sized-types #-} open import Prelude module Expansion.Delay-monad {a} {A : Type a} where open import Delay-monad open import Delay-monad.Bisimilarity as D using (force) import Delay-monad.Bisimilarity.Negative as DN open import Equality.Propositional open import Logical-equivalence using (_⇔_) open import Prelude.Size open import Function-universe equality-with-J hiding (id; _∘_) open import Function-universe.Size equality-with-J import Bisimilarity.Delay-monad as SD open import Equational-reasoning import Expansion.Equational-reasoning-instances open import Labelled-transition-system.Delay-monad A open import Bisimilarity delay-monad using ([_]_∼_) open import Expansion delay-monad ------------------------------------------------------------------------ -- The direct and the indirect definitions of expansion are pointwise -- logically equivalent -- Emulations of the constructors D.later and D.laterˡ. later-cong : ∀ {i x y} → [ i ] force x ≳′ force y → [ i ] later x ≳ later y later-cong x≳′y = ⟨ (λ { later → _ , ⟶→⟶̂ later , x≳′y }) , (λ { later → _ , ⟶→[]⇒ later , x≳′y }) ⟩ laterˡ : ∀ {i x y} → [ i ] force x ≳ y → [ i ] later x ≳ y laterˡ x≳y = ⟨ (λ { later → _ , done _ , convert {a = a} x≳y }) , Σ-map id (Σ-map later[]⇒ id) ∘ right-to-left x≳y ⟩ -- The direct definition of expansion is contained in the one -- obtained from the transition relation. direct→indirect : ∀ {i x y} → D.[ i ] x ≳ y → [ i ] x ≳ y direct→indirect D.now = reflexive direct→indirect (D.later p) = later-cong λ { .force → direct→indirect (force p) } direct→indirect (D.laterˡ p) = laterˡ (direct→indirect p) -- If x makes a sequence of zero or more silent transitions to y, then -- x is an expansion of y. ⇒→≳ : ∀ {i x y} → x ⇒ y → D.[ i ] x ≳ y ⇒→≳ done = D.reflexive _ ⇒→≳ (step _ later tr) = D.laterˡ (⇒→≳ tr) ⇒→≳ (step () now tr) -- If x makes a non-silent transition with the label y, then x is an -- expansion of now y. [just]⟶→≳now : ∀ {i x x′ y} → x [ just y ]⟶ x′ → D.[ i ] x ≳ now y [just]⟶→≳now now = D.reflexive _ [just]⇒→≳now : ∀ {i x x′ y} → x [ just y ]⇒ x′ → D.[ i ] x ≳ now y [just]⇒→≳now (steps tr now _) = ⇒→≳ tr [just]⇒̂→≳now : ∀ {i x x′ y} → x [ just y ]⇒̂ x′ → D.[ i ] x ≳ now y [just]⇒̂→≳now (silent () _) [just]⇒̂→≳now (non-silent _ tr) = [just]⇒→≳now tr [just]⟶̂→≳now : ∀ {i x x′ y} → x [ just y ]⟶̂ x′ → D.[ i ] x ≳ now y [just]⟶̂→≳now (done ()) [just]⟶̂→≳now (step tr) = [just]⇒̂→≳now (⟶→⇒̂ tr) -- The definition of expansion obtained from the transition relation -- is contained in the direct one. indirect→direct : ∀ {i} x y → [ i ] x ≳ y → D.[ i ] x ≳ y indirect→direct {i} (now x) y = ([ i ] now x ≳ y) ↝⟨ (λ p → left-to-right p now) ⟩ (∃ λ y′ → y [ just x ]⟶̂ y′ × [ i ] now x ≳′ y′) ↝⟨ sym ∘ [just]⟶̂→≡now ∘ proj₁ ∘ proj₂ ⟩ now x ≡ y ↝⟨ (λ { refl → D.reflexive _ }) ⟩□ D.[ i ] now x ≳ y □ indirect→direct {i} x (now y) = [ i ] x ≳ now y ↝⟨ (λ p → right-to-left p now) ⟩ (∃ λ x′ → x [ just y ]⇒ x′ × [ i ] x′ ≳′ now y) ↝⟨ [just]⇒→≳now ∘ proj₁ ∘ proj₂ ⟩□ D.[ i ] x ≳ now y □ indirect→direct (later x) (later y) lx≳ly = case left-to-right lx≳ly later of λ where (_ , step later , x≳′y) → D.later λ { .force {j} → indirect→direct _ _ (force x≳′y {j = j}) } (_ , done _ , x≳′ly) → let x′ , lx⇒x′ , x′≳′y = right-to-left lx≳ly later in lemma x≳′ly ([]⇒→⇒ _ lx⇒x′) x′≳′y where indirect→direct′ : ∀ {i x x′ y} → x ⇒ x′ → [ i ] x′ ≳ y → D.[ i ] x ≳ y indirect→direct′ done p = indirect→direct _ _ p indirect→direct′ (step _ later tr) p = D.laterˡ (indirect→direct′ tr p) indirect→direct′ (step () now _) lemma : ∀ {i x x′} → [ i ] force x ≳′ later y → later x ⇒ x′ → [ i ] x′ ≳′ force y → D.[ i ] later x ≳ later y lemma x≳′ly done lx≳′y = D.later λ { .force → D.laterˡʳ⁻¹ (indirect→direct _ _ (force lx≳′y)) (indirect→direct _ _ (force x≳′ly)) } lemma x≳′ly (step _ later x⇒x′) x′≳′y = D.later λ { .force → indirect→direct′ x⇒x′ (force x′≳′y) } -- The direct definition of the expansion relation is logically -- equivalent to the one obtained from the transition relation. -- -- TODO: Are the two definitions isomorphic? direct⇔indirect : ∀ {i x y} → D.[ i ] x ≳ y ⇔ [ i ] x ≳ y direct⇔indirect = record { to = direct→indirect ; from = indirect→direct _ _ } ------------------------------------------------------------------------ -- Some non-existence results Now≳later-now = ∀ x → now x ≳ later (record { force = now x }) now≳later-now⇔uninhabited : Now≳later-now ⇔ ¬ A now≳later-now⇔uninhabited = Now≳later-now ↝⟨ inverse $ ∀-cong _ (λ _ → direct⇔indirect) ⟩ DN.Now≳later-now ↝⟨ DN.now≳later-now⇔uninhabited ⟩□ ¬ A □ Laterˡ⁻¹ = ∀ {x y} → later x ≳ y → force x ≳ y laterˡ⁻¹⇔uninhabited : Laterˡ⁻¹ ⇔ ¬ A laterˡ⁻¹⇔uninhabited = Laterˡ⁻¹ ↝⟨ inverse $ implicit-∀-cong _ $ implicit-∀-cong _ $ →-cong _ direct⇔indirect direct⇔indirect ⟩ DN.Laterˡ⁻¹-≳ ↝⟨ DN.laterˡ⁻¹-≳⇔uninhabited ⟩□ ¬ A □ Laterʳ⁻¹-∼≳ = ∀ {i x} → [ i ] never ∼ later (record { force = now x }) → [ i ] never ≳ now x size-preserving-laterʳ⁻¹-∼≳⇔uninhabited : Laterʳ⁻¹-∼≳ ⇔ ¬ A size-preserving-laterʳ⁻¹-∼≳⇔uninhabited = Laterʳ⁻¹-∼≳ ↝⟨ inverse $ implicit-∀-size-cong _ $ implicit-∀-cong _ $ →-cong _ SD.direct⇔indirect direct⇔indirect ⟩ DN.Laterʳ⁻¹-∼≳ ↝⟨ DN.size-preserving-laterʳ⁻¹-∼≳⇔uninhabited ⟩□ ¬ A □ Laterʳ⁻¹ = ∀ {i x y} → [ i ] x ≳ later y → [ i ] x ≳ force y size-preserving-laterʳ⁻¹⇔uninhabited : Laterʳ⁻¹ ⇔ ¬ A size-preserving-laterʳ⁻¹⇔uninhabited = Laterʳ⁻¹ ↝⟨ inverse $ implicit-∀-size-cong _ $ implicit-∀-cong _ $ implicit-∀-cong _ $ →-cong _ direct⇔indirect direct⇔indirect ⟩ DN.Laterʳ⁻¹-≳ ↝⟨ DN.size-preserving-laterʳ⁻¹-≳⇔uninhabited ⟩□ ¬ A □ Transitivity-∼≳ˡ = ∀ {i} {x y z : Delay A ∞} → [ i ] x ∼ y → y ≳ z → [ i ] x ≳ z size-preserving-transitivity-∼≳ˡ⇔uninhabited : Transitivity-∼≳ˡ ⇔ ¬ A size-preserving-transitivity-∼≳ˡ⇔uninhabited = Transitivity-∼≳ˡ ↝⟨ inverse $ implicit-∀-size-cong _ $ implicit-∀-cong _ $ implicit-∀-cong _ $ implicit-∀-cong _ $ →-cong _ SD.direct⇔indirect (→-cong _ direct⇔indirect direct⇔indirect) ⟩ DN.Transitivity-∼≳ˡ ↝⟨ DN.size-preserving-transitivity-∼≳ˡ⇔uninhabited ⟩□ ¬ A □ Transitivityˡ = ∀ {i} {x y z : Delay A ∞} → [ i ] x ≳ y → y ≳ z → [ i ] x ≳ z size-preserving-transitivityˡ⇔uninhabited : Transitivityˡ ⇔ ¬ A size-preserving-transitivityˡ⇔uninhabited = Transitivityˡ ↝⟨ inverse $ implicit-∀-size-cong _ $ implicit-∀-cong _ $ implicit-∀-cong _ $ implicit-∀-cong _ $ →-cong _ direct⇔indirect (→-cong _ direct⇔indirect direct⇔indirect) ⟩ DN.Transitivity-≳ˡ ↝⟨ DN.size-preserving-transitivity-≳ˡ⇔uninhabited ⟩□ ¬ A □ Transitivity = ∀ {i} {x y z : Delay A ∞} → [ i ] x ≳ y → [ i ] y ≳ z → [ i ] x ≳ z size-preserving-transitivity⇔uninhabited : Transitivity ⇔ ¬ A size-preserving-transitivity⇔uninhabited = Transitivity ↝⟨ inverse $ implicit-∀-size-cong _ $ implicit-∀-cong _ $ implicit-∀-cong _ $ implicit-∀-cong _ $ →-cong _ direct⇔indirect $ →-cong _ direct⇔indirect direct⇔indirect ⟩ DN.Transitivity-≳ ↝⟨ DN.size-preserving-transitivity-≳⇔uninhabited ⟩□ ¬ A □
{ "alphanum_fraction": 0.538934941, "avg_line_length": 38.0956937799, "ext": "agda", "hexsha": "0d235a3849a4ddc0efb40c1097c2729721a8e050", "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/Expansion/Delay-monad.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/Expansion/Delay-monad.agda", "max_line_length": 137, "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/Expansion/Delay-monad.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 3156, "size": 7962 }
module Data.Proofs where import Lvl open import Data open import Logic open import Logic.Propositional open import Structure.Setoid renaming (_≡_ to _≡ₛ_) open import Structure.Function open import Structure.Function.Domain open import Structure.Function.Domain.Proofs open import Structure.Relator.Equivalence open import Structure.Relator.Properties open import Type open import Type.Properties.Empty open import Type.Properties.Singleton private variable ℓ ℓₑ ℓₑ₁ ℓₑ₂ ℓ₁ ℓ₂ : Lvl.Level private variable T : Type{ℓ} module General where module _ {_▫_ : Empty{ℓ} → Empty{ℓ} → Stmt{ℓₑ}} where Empty-equiv : Equiv(Empty) Equiv._≡_ Empty-equiv = _▫_ Reflexivity.proof (Equivalence.reflexivity (Equiv.equivalence Empty-equiv)) {} Symmetry.proof (Equivalence.symmetry (Equiv.equivalence Empty-equiv)) {} Transitivity.proof (Equivalence.transitivity (Equiv.equivalence Empty-equiv)) {} -- Any binary relation on Unit is an equivalence given that it is reflexive. module _ {_▫_ : Unit{ℓ} → Unit{ℓ} → Stmt{ℓ}} ⦃ proof : (<> ▫ <>) ⦄ where Unit-equiv : Equiv(Unit) Equiv._≡_ Unit-equiv = (_▫_) Reflexivity.proof (Equivalence.reflexivity (Equiv.equivalence Unit-equiv)) = proof Symmetry.proof (Equivalence.symmetry (Equiv.equivalence Unit-equiv)) _ = proof Transitivity.proof (Equivalence.transitivity (Equiv.equivalence Unit-equiv)) _ _ = proof module _ where open import Relator.Equals instance Empty-equiv : Equiv(Empty{ℓ}) Empty-equiv = General.Empty-equiv {_▫_ = _≡_} instance Unit-equiv : Equiv(Unit{ℓ}) Unit-equiv = General.Unit-equiv ⦃ [≡]-intro {x = <>} ⦄ {- TODO: So, why is this unprovable but Unit-IsUnit is? UIP? What is the difference? module _ where open import Relator.Equals.Proofs.Equiv testee : ∀{T : Type{ℓ}}{a : T} → IsUnit{ℓ}(a ≡ a) IsUnit.unit testee = [≡]-intro IsUnit.uniqueness testee {x} = {!!} -} instance -- `Unit` is an unit type. Unit-IsUnit : ⦃ equiv : Equiv{ℓₑ}(Unit) ⦄ → IsUnit{ℓ}(Unit) IsUnit.unit Unit-IsUnit = <> IsUnit.uniqueness Unit-IsUnit = reflexivity(_≡ₛ_) instance -- `Empty` is an empty type. Empty-IsEmpty : IsEmpty{ℓ}(Empty) Empty-IsEmpty = intro(empty) module _ ⦃ _ : Equiv{ℓₑ₁}(T) ⦄ ⦃ empty-equiv : Equiv{ℓₑ₂}(Empty{ℓ₂}) ⦄ where instance empty-injective : Injective ⦃ empty-equiv ⦄(empty{T = T}) Injective.proof(empty-injective) {} instance empty-function : Function ⦃ empty-equiv ⦄(empty{T = T}) Function.congruence empty-function {()} module _ ⦃ equiv : Equiv{ℓₑ}(T) ⦄ where -- TODO: Duplicated in Type.Properties.Singleton.Proofs Unit-fn-unique-value : ∀{f : Unit{ℓ} → T} → (∀{x y} → (f(x) ≡ₛ f(y))) Unit-fn-unique-value {x = <>} {y = <>} = reflexivity(_≡ₛ_) module _ ⦃ equiv : Equiv{ℓₑ}(Unit{ℓ₁}) ⦄ where Unit-fn-unique-fn : ∀{f g : T → Unit{ℓ₁}} → (∀{x y} → (_≡ₛ_ ⦃ equiv ⦄ (f(x)) (g(y)))) Unit-fn-unique-fn {f = f}{g = g}{x = x}{y = y} with f(x) | g(y) ... | <> | <> = reflexivity(_≡ₛ_ ⦃ equiv ⦄)
{ "alphanum_fraction": 0.6618468616, "avg_line_length": 36.6626506024, "ext": "agda", "hexsha": "f19370d415969c18171f847f772714f1fe142e19", "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/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/Proofs.agda", "max_line_length": 95, "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/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": 1041, "size": 3043 }
{- 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.ImplShared.Consensus.Types open import LibraBFT.ImplShared.Interface.Output -- This module defines the LBFT monad used by our (fake/simple, -- for now) "implementation", along with some utility functions -- to facilitate reasoning about it. module LibraBFT.ImplShared.Util.Util where open import Optics.All open import LibraBFT.ImplShared.Util.Dijkstra.Syntax public open import LibraBFT.ImplShared.Util.Dijkstra.RWS public open import LibraBFT.ImplShared.Util.Dijkstra.RWS.Syntax public open import LibraBFT.ImplShared.Util.Dijkstra.EitherD public open import LibraBFT.ImplShared.Util.Dijkstra.EitherD.Syntax public ---------------- -- LBFT Monad -- ---------------- -- Global 'LBFT'; works over the whole state. LBFT : Set → Set₁ LBFT = RWS Unit Output RoundManager LBFT-run : ∀ {A} → LBFT A → RoundManager → (A × RoundManager × List Output) LBFT-run m = RWS-run m unit LBFT-result : ∀ {A} → LBFT A → RoundManager → A LBFT-result m rm = proj₁ (LBFT-run m rm) LBFT-post : ∀ {A} → LBFT A → RoundManager → RoundManager LBFT-post m rm = proj₁ (proj₂ (LBFT-run m rm)) LBFT-outs : ∀ {A} → LBFT A → RoundManager → List Output LBFT-outs m rm = proj₂ (proj₂ (LBFT-run m rm)) LBFT-Pre = RoundManager → Set LBFT-Post = RWS-Post Output RoundManager LBFT-Post-True : ∀ {A} → LBFT-Post A → LBFT A → RoundManager → Set LBFT-Post-True Post m pre = let (x , post , outs) = LBFT-run m pre in Post x post outs LBFT-weakestPre : ∀ {A} (m : LBFT A) → LBFT-Post A → LBFT-Pre LBFT-weakestPre m Post pre = RWS-weakestPre m Post unit pre LBFT-Contract : ∀ {A} (m : LBFT A) → Set₁ LBFT-Contract{A} m = (Post : RWS-Post Output RoundManager A) → (pre : RoundManager) → LBFT-weakestPre m Post pre → LBFT-Post-True Post m pre LBFT-contract : ∀ {A} (m : LBFT A) → LBFT-Contract m LBFT-contract m Post pre pf = RWS-contract m Post unit pre pf LBFT-⇒ : ∀ {A} (P Q : LBFT-Post A) → (RWS-Post-⇒ P Q) → ∀ m pre → LBFT-weakestPre m P pre → LBFT-weakestPre m Q pre LBFT-⇒ Post₁ Post₂ f m pre pf = RWS-⇒ Post₁ Post₂ f m unit pre pf LBFT-⇒-bind : ∀ {A B} (P : LBFT-Post A) (Q : LBFT-Post B) (f : A → LBFT B) → (RWS-Post-⇒ P (RWS-weakestPre-bindPost unit f Q)) → ∀ m st → LBFT-weakestPre m P st → LBFT-weakestPre (m >>= f) Q st LBFT-⇒-bind Post Q f pf m st con = RWS-⇒-bind Post Q f unit pf m st con LBFT-⇒-ebind : ∀ {A B C} (P : LBFT-Post (Either C A)) (Q : LBFT-Post (Either C B)) → (f : A → LBFT (Either C B)) → RWS-Post-⇒ P (RWS-weakestPre-ebindPost unit f Q) → ∀ m st → LBFT-weakestPre m P st → LBFT-weakestPre (m ∙?∙ f) Q st LBFT-⇒-ebind Post Q f pf m st con = RWS-⇒-ebind Post Q f unit pf m st con
{ "alphanum_fraction": 0.6519028871, "avg_line_length": 37.6296296296, "ext": "agda", "hexsha": "bacca6b4dd2622565738875c79be923c03db2724", "lang": "Agda", "max_forks_count": 6, "max_forks_repo_forks_event_max_datetime": "2022-02-18T01:04:32.000Z", "max_forks_repo_forks_event_min_datetime": "2020-12-16T19:43:52.000Z", "max_forks_repo_head_hexsha": "49f8b1b70823be805d84ffc3157c3b880edb1e92", "max_forks_repo_licenses": [ "UPL-1.0" ], "max_forks_repo_name": "oracle/bft-consensus-agda", "max_forks_repo_path": "LibraBFT/ImplShared/Util/Util.agda", "max_issues_count": 72, "max_issues_repo_head_hexsha": "49f8b1b70823be805d84ffc3157c3b880edb1e92", "max_issues_repo_issues_event_max_datetime": "2022-03-25T05:36:11.000Z", "max_issues_repo_issues_event_min_datetime": "2021-02-04T05:04:33.000Z", "max_issues_repo_licenses": [ "UPL-1.0" ], "max_issues_repo_name": "oracle/bft-consensus-agda", "max_issues_repo_path": "LibraBFT/ImplShared/Util/Util.agda", "max_line_length": 111, "max_stars_count": 4, "max_stars_repo_head_hexsha": "49f8b1b70823be805d84ffc3157c3b880edb1e92", "max_stars_repo_licenses": [ "UPL-1.0" ], "max_stars_repo_name": "oracle/bft-consensus-agda", "max_stars_repo_path": "LibraBFT/ImplShared/Util/Util.agda", "max_stars_repo_stars_event_max_datetime": "2021-12-18T19:24:05.000Z", "max_stars_repo_stars_event_min_datetime": "2020-12-16T19:43:41.000Z", "num_tokens": 1072, "size": 3048 }
{-# OPTIONS --without-K #-} module README where -- This is a self-contained repository of basic results and utilities for -- Homotopy Type Theory. -- -- Modules are structured in a hierarchy, where all top-level modules are -- imported in this file, and each module only imports and re-exports all -- sub-modules. The most basic definitions for a submodule collection are -- defined in the `core` submodule. -- -- For example, in the case of equality, the module called `equality` is -- composed of a number of submodules: `core` (containing the basic -- definitions), `groupoid` (groupoid laws), `calculus` (for calculations -- involving equality proofs) and `reasoning` (for equational reasoning). -- Σ types and related utilities import sum -- Propositional equality import equality -- Basic types import sets -- Algebra import algebra -- Decidable predicates import decidable -- Pointed types and maps import pointed -- Functions, isomorphisms and properties thereof import function -- Overloading system import overloading -- Universe levels import level -- Container functors, W and M types import container -- Homotopy type theory infrastructure and results import hott -- Higher Inductive Types import higher
{ "alphanum_fraction": 0.7634146341, "avg_line_length": 23.6538461538, "ext": "agda", "hexsha": "51e100fef2ea45864adff645b8ffcf1309746842", "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": "README.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": "README.agda", "max_line_length": 73, "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": "README.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": 276, "size": 1230 }
{-# OPTIONS --cubical --guarded -W ignore #-} module combinations-of-lift-and-multiset where open import Clocked.Primitives open import Cubical.Foundations.Everything open import Cubical.Data.List as List open import Cubical.Data.List.Properties open import Cubical.Data.Sum using (_⊎_; inl; inr) open import combinations-of-lift-and-list --**************************************************************************-- --**************************************************************************-- -- Combining the monads Lift and Multiset freely and via a distributive law -- --**************************************************************************-- --**************************************************************************-- -- In this document I want to define a monad, called MultiLift, that is the free combination of the Lift monad and the Multiset monad. -- In order to do so, I will first define the the Multiset monad, and check that it is indeed a monad (Step 1). -- Then I define the LiftMulti monad, check that it is a monad (Step 2), and finally check that it is the free monad on the algebra -- structures of a delay algebra and a monoid (Step 3). -- The Lift monad has aleady been defined in my earlier work, combinations-of-lift-and-list. -- In the same file I check that lift is indeed a monad, and define various usefull functions, such as a map function for Lift. -- In addition to the free combination of the Multiset and the Lift monads, I also compose the two monads to form the monad -- LcM : A → Lift(Multiset A). This composition uses a distributive law, which I prove does indeed satisfy all the axioms for a -- distributive law. --****************************-- -- Step 1: The Multiset monad -- --****************************-- --This code is based on the finite powerset example from: --https://github.com/niccoloveltri/final-pfin/blob/main/Pfin/AsFreeJoinSemilattice.agda --We define the multiset monad as the free commutative monoid monad on A. --This is a HIT. data Multiset {ℓ} (A : Type ℓ) : Type ℓ where m∅ : Multiset A unitM : A → Multiset A _∪ₘ_ : Multiset A → Multiset A → Multiset A ass : ∀ x y z → x ∪ₘ (y ∪ₘ z) ≡ (x ∪ₘ y) ∪ₘ z com : ∀ x y → x ∪ₘ y ≡ y ∪ₘ x unitr : ∀ x → x ∪ₘ m∅ ≡ x trunc : isSet (Multiset A) -- map function for Multiset mapM : {A B : Set} → (A → B) → Multiset A → Multiset B mapM f m∅ = m∅ mapM f (unitM x) = unitM (f x) mapM f (M ∪ₘ N) = (mapM f M) ∪ₘ (mapM f N) mapM f (ass M M₁ M₂ i) = ass (mapM f M) (mapM f M₁) (mapM f M₂) i mapM f (com M N i) = com (mapM f M) (mapM f N) i mapM f (unitr M i) = unitr (mapM f M) i mapM f (trunc M N x y i i₁) = trunc (mapM f M) (mapM f N) (λ j → mapM f (x j)) (λ j → mapM f (y j)) i i₁ -- Bind and multiplication functions for Multiset Multiset-bind : {A B : Set} → (A → Multiset B) → Multiset A → Multiset B Multiset-bind f m∅ = m∅ Multiset-bind f (unitM a) = f a Multiset-bind f (x ∪ₘ y) = (Multiset-bind f x) ∪ₘ (Multiset-bind f y) Multiset-bind f (ass x y z i) = ass (Multiset-bind f x) (Multiset-bind f y) (Multiset-bind f z) i Multiset-bind f (com x y i) = com (Multiset-bind f x) (Multiset-bind f y) i Multiset-bind f (unitr x i) = unitr (Multiset-bind f x) i Multiset-bind f (trunc s₁ s₂ x y i i₁) = trunc (Multiset-bind f s₁) (Multiset-bind f s₂) (\ j → Multiset-bind f (x j)) (\ j → Multiset-bind f (y j)) i i₁ Multiset-mult : {A : Set} → Multiset (Multiset A) → Multiset A Multiset-mult m∅ = m∅ Multiset-mult (unitM x) = x Multiset-mult (x ∪ₘ y) = (Multiset-mult x) ∪ₘ (Multiset-mult y) Multiset-mult (ass x y z i) = ass (Multiset-mult x) (Multiset-mult y) (Multiset-mult z) i Multiset-mult (com x y i) = com (Multiset-mult x) (Multiset-mult y) i Multiset-mult (unitr x i) = unitr (Multiset-mult x) i Multiset-mult (trunc s₁ s₂ x y i i₁) = trunc (Multiset-mult s₁) (Multiset-mult s₂) (\ j → Multiset-mult (x j)) (\ j → Multiset-mult (y j)) i i₁ -- Elimination principle for Multiset -- module to make the inputs more readable -- no name for the module to make the use of it more readable module _ {ℓ}{A : Type ℓ} (P : Multiset A → hProp ℓ) (P∅ : fst (P m∅)) (Pη : ∀ m → fst (P (unitM m))) (P∪ : ∀ {m n} → fst(P m) → fst(P n) → fst(P (m ∪ₘ n))) where elimM : ∀ M → fst(P M) elimM m∅ = P∅ elimM (unitM x) = Pη x elimM (M ∪ₘ N) = P∪ (elimM M) (elimM N) elimM (ass M N O i) = isProp→PathP (λ j → snd (P (ass M N O j))) ((P∪ (elimM M) (P∪ (elimM N) (elimM O)))) ((P∪ (P∪ (elimM M) (elimM N)) (elimM O) )) i elimM (com M N i) = isProp→PathP (λ j → snd (P (com M N j))) (P∪ (elimM M) (elimM N)) (P∪ (elimM N) (elimM M)) i elimM (unitr M i) = isProp→PathP (λ j → snd (P (unitr M j))) (P∪ (elimM M) (P∅)) (elimM M) i elimM (trunc M N x y i j) = isOfHLevel→isOfHLevelDep 2 (λ k → isProp→isSet (snd (P k))) (elimM M) (elimM N) (cong elimM x) (cong elimM y) (trunc M N x y) i j -- Proving that the Multiset forms a monad -- Multiset-mult (unitM M) = M Multiset-unitlaw1 : {A : Set} → ∀(M : Multiset A) → Multiset-mult (unitM M) ≡ M Multiset-unitlaw1 M = refl -- Multiset-mult (map unitM M) = M Multiset-unitlaw2 : {A : Set} → ∀(M : Multiset A) → Multiset-mult (mapM unitM M) ≡ M Multiset-unitlaw2 m∅ = refl Multiset-unitlaw2 (unitM x) = refl Multiset-unitlaw2 (M ∪ₘ N) = cong₂ (_∪ₘ_) (Multiset-unitlaw2 M) (Multiset-unitlaw2 N) Multiset-unitlaw2 (ass M N P i) = λ j → ass (Multiset-unitlaw2 M j) (Multiset-unitlaw2 N j) (Multiset-unitlaw2 P j) i Multiset-unitlaw2 (com M N i) = λ j → com (Multiset-unitlaw2 M j) (Multiset-unitlaw2 N j) i Multiset-unitlaw2 (unitr M i) = λ j → unitr (Multiset-unitlaw2 M j) i Multiset-unitlaw2 (trunc M N x y i i₁) = λ k → trunc (Multiset-unitlaw2 M k) (Multiset-unitlaw2 N k) (λ j → (Multiset-unitlaw2 (x j)) k) ((λ j → (Multiset-unitlaw2 (y j)) k)) i i₁ --proving the same with elimM: Multiset-unitlaw2' : {A : Set} → ∀(M : Multiset A) → Multiset-mult (mapM unitM M) ≡ M Multiset-unitlaw2' M = elimM (λ N → (Multiset-mult (mapM unitM N) ≡ N) , trunc (Multiset-mult (mapM unitM N)) N) refl (λ N → refl) (λ eq1 → λ eq2 → cong₂ _∪ₘ_ eq1 eq2 ) M -- Multiset-mult (Multiset-mult M) = Multiset-mult (map Multiset-mult M) Multiset-multlaw : {A : Set} → ∀(M : Multiset (Multiset (Multiset A))) → Multiset-mult (Multiset-mult M) ≡ Multiset-mult (mapM Multiset-mult M) Multiset-multlaw m∅ = refl Multiset-multlaw (unitM M) = refl Multiset-multlaw (M ∪ₘ N) = cong₂ (_∪ₘ_) (Multiset-multlaw M) (Multiset-multlaw N) Multiset-multlaw (ass M N P i) = λ j → ass (Multiset-multlaw M j) (Multiset-multlaw N j) (Multiset-multlaw P j) i Multiset-multlaw (com M N i) = λ j → com (Multiset-multlaw M j) (Multiset-multlaw N j) i Multiset-multlaw (unitr M i) = λ j → unitr (Multiset-multlaw M j) i Multiset-multlaw (trunc M N x y i i₁) = λ k → trunc (Multiset-multlaw M k) (Multiset-multlaw N k) (λ j → (Multiset-multlaw (x j)) k) ((λ j → (Multiset-multlaw (y j)) k)) i i₁ --proving the same with Elim: Multiset-multlaw' : {A : Set} → ∀(M : Multiset (Multiset (Multiset A))) → Multiset-mult (Multiset-mult M) ≡ Multiset-mult (mapM Multiset-mult M) Multiset-multlaw' M = elimM (λ N → (Multiset-mult (Multiset-mult N) ≡ Multiset-mult (mapM Multiset-mult N)) , trunc (Multiset-mult (Multiset-mult N)) (Multiset-mult (mapM Multiset-mult N))) refl (λ N → refl) (λ eq1 → λ eq2 → cong₂ (_∪ₘ_) eq1 eq2) M -- the unit is a natural transformation: nattrans-Multunit : {A B : Set} → ∀(f : A → B) → ∀(x : A) → mapM f (unitM x) ≡ unitM (f x) nattrans-Multunit f x = refl -- the multiplication is a natural transformation: nattrans-MultisetMult : {A B : Set} → ∀(f : A → B) → ∀(MM : Multiset (Multiset A)) → mapM f (Multiset-mult MM) ≡ Multiset-mult (mapM (mapM f) MM) nattrans-MultisetMult f MM = elimM ((λ NN → (mapM f (Multiset-mult NN) ≡ Multiset-mult (mapM (mapM f) NN)) , trunc (mapM f (Multiset-mult NN)) (Multiset-mult (mapM (mapM f) NN)))) refl (λ M → refl) (λ eq1 → λ eq2 → cong₂ (_∪ₘ_) eq1 eq2) MM --*****************************-- -- Step 2: The MultiLift monad -- --*****************************-- --Now that we have a multiset monad and a lift monad, I want to show that the following combination of the two is again a monad: --MultiLift : (A : Set) → (κ : Cl) → Set --MultiLift A κ = Multiset (A ⊎ (▹ κ (MultiLift A κ))) data MultiLift (A : Set) (κ : Cl) : Set where conML : Multiset (A ⊎ (▹ κ (MultiLift A κ))) -> MultiLift A κ -- Elimination principle for MultiLift -- module to make the inputs more readable -- no name for the module to make the use of it more readable module _ {ℓ}{A : Set}{κ : Cl} (P : MultiLift A κ → hProp ℓ) (P∅ : fst (P (conML m∅))) (Pη1 : ∀ x → fst (P (conML (unitM (inl x))))) (Pη2 : ∀ {x} → (∀ α → fst (P (x α))) → fst (P (conML (unitM (inr x))))) (P∪ : ∀ {m n} → fst(P (conML m)) → fst(P (conML n)) → fst(P (conML (m ∪ₘ n)))) where elimML : ∀ M → fst(P M) elimML (conML m∅) = P∅ elimML (conML (unitM (inl x))) = Pη1 x elimML (conML (unitM (inr x))) = Pη2 λ α → elimML (x α) elimML (conML (x ∪ₘ y)) = P∪ (elimML (conML x)) (elimML (conML y)) elimML (conML (ass M N O i)) = isProp→PathP (λ j → snd (P (conML (ass M N O j)))) ((P∪ (elimML (conML M)) (P∪ (elimML (conML N)) (elimML (conML O))))) ((P∪ (P∪ (elimML (conML M)) (elimML (conML N))) (elimML (conML O)) )) i elimML (conML (com M N i)) = isProp→PathP (λ j → snd (P (conML (com M N j)))) (P∪ (elimML (conML M)) (elimML (conML N))) (P∪ (elimML (conML N)) (elimML (conML M))) i elimML (conML (unitr M i)) = isProp→PathP (λ j → snd (P (conML (unitr M j)))) (P∪ (elimML (conML M)) (P∅)) (elimML (conML M)) i elimML (conML (trunc M N x y i j)) = isOfHLevel→isOfHLevelDep 2 (λ z → isProp→isSet (snd (P (conML z)))) (elimML (conML M)) (elimML (conML N)) (cong elimML (cong conML x)) (cong elimML (cong conML y)) (trunc M N x y ) i j --***proof that MultiLift is a set***-- -- strategy: build isomorphism, then make equivalence, then use univalence to turn equivalence into equality, then transport. isoML : {A : Set}{κ : Cl} → Iso (Multiset (A ⊎ (▹ κ (MultiLift A κ)))) (MultiLift A κ) Iso.fun isoML = conML Iso.inv isoML (conML x) = x Iso.rightInv isoML (conML x) = refl Iso.leftInv isoML a = refl equivML : {A : Set}{κ : Cl} → (Multiset (A ⊎ (▹ κ (MultiLift A κ)))) ≃ (MultiLift A κ) equivML = isoToEquiv isoML equalML : {A : Set}{κ : Cl} → (Multiset (A ⊎ (▹ κ (MultiLift A κ)))) ≡ (MultiLift A κ) equalML = ua equivML truncML : {A : Set} {κ : Cl} → isSet (MultiLift A κ) truncML = subst⁻ isSet (sym equalML) trunc --IsotoPath as shortcut for this bit of code --***algebraic structure for MultiLift***-- --nowML and stepML turn MultiLift into a delay algebra structure: nowML : {A : Set} (κ : Cl) → A → (MultiLift A κ) nowML κ a = conML (unitM (inl a)) stepML : {A : Set} (κ : Cl) → ▹ κ (MultiLift A κ) → (MultiLift A κ) stepML κ a = conML (unitM (inr a)) --the union is derived from the multiset union, and turns MultiLift into a monoid: _∪ₘₗ_ : {A : Set} {κ : Cl} → (MultiLift A κ) → (MultiLift A κ) → (MultiLift A κ) _∪ₘₗ_ {A} {κ} (conML m) (conML n) = conML (m ∪ₘ n) --proof that this union does indeed provide a commutative monoid structure: assoc∪ₘₗ : {A : Set} {κ : Cl} → ∀(ml nl ol : (MultiLift A κ)) → (ml ∪ₘₗ nl) ∪ₘₗ ol ≡ ml ∪ₘₗ (nl ∪ₘₗ ol) assoc∪ₘₗ {A} {κ} (conML m) (conML n) (conML o) = cong conML (sym (ass m n o)) comm∪ₘₗ : {A : Set} {κ : Cl} → ∀(ml nl : (MultiLift A κ)) → ml ∪ₘₗ nl ≡ nl ∪ₘₗ ml comm∪ₘₗ {A} {κ} (conML m) (conML n) = cong conML (com m n) unitr∪ₘₗ : {A : Set} {κ : Cl} → ∀ (ml : (MultiLift A κ)) → ml ∪ₘₗ conML m∅ ≡ ml unitr∪ₘₗ {A} {κ} (conML m) = cong conML (unitr m ) --***monadic structure for MultiLift***-- --a map function to turn MultiLift into a functor mapML : {A B : Set} (κ : Cl) → (f : A → B) → (MultiLift A κ) → (MultiLift B κ) mapML κ f (conML m∅) = conML m∅ mapML κ f (conML (unitM (inl x))) = conML (unitM (inl (f x))) mapML κ f (conML (unitM (inr x))) = stepML κ (λ α → mapML κ f (x α)) mapML κ f (conML (x ∪ₘ y)) = (mapML κ f (conML x)) ∪ₘₗ (mapML κ f (conML y)) mapML κ f (conML (ass x y z i)) = sym (assoc∪ₘₗ (mapML κ f (conML x)) (mapML κ f (conML y)) (mapML κ f (conML z))) i mapML κ f (conML (com x y i)) = comm∪ₘₗ (mapML κ f (conML x)) (mapML κ f (conML y)) i mapML κ f (conML (unitr x i)) = unitr∪ₘₗ (mapML κ f (conML x)) i mapML κ f (conML (trunc x y z w i i₁)) = truncML (mapML κ f (conML x)) (mapML κ f (conML y)) (\ j → mapML κ f (conML (z j))) (\ j → mapML κ f (conML (w j))) i i₁ --a bind operator to make MultiLift into a monad bindML : {A B : Set} (κ : Cl) → (A → (MultiLift B κ)) → MultiLift A κ → MultiLift B κ bindML κ f (conML m∅) = conML m∅ bindML κ f (conML (unitM (inl x))) = f x bindML κ f (conML (unitM (inr x))) = stepML κ (\ α → bindML κ f (x α)) bindML κ f (conML (x ∪ₘ y)) = (bindML κ f (conML x)) ∪ₘₗ (bindML κ f (conML y)) bindML κ f (conML (ass x y z i)) = sym (assoc∪ₘₗ (bindML κ f (conML x)) (bindML κ f (conML y)) (bindML κ f (conML z))) i bindML κ f (conML (com x y i)) = comm∪ₘₗ (bindML κ f (conML x)) (bindML κ f (conML y)) i bindML κ f (conML (unitr x i)) = unitr∪ₘₗ (bindML κ f (conML x)) i bindML κ f (conML (trunc x y z w i i₁)) = truncML (bindML κ f (conML x)) (bindML κ f (conML y)) (\ j → bindML κ f (conML (z j))) (\ j → bindML κ f (conML (w j))) i i₁ --bindML commutes with ∪ₘₗ bindML-∪ₘₗ : {A B : Set} (κ : Cl) → ∀(f : A → (MultiLift B κ)) → ∀(ml nl : (MultiLift A κ)) → bindML κ f (ml ∪ₘₗ nl) ≡ (bindML κ f ml) ∪ₘₗ (bindML κ f nl) bindML-∪ₘₗ κ f (conML x) (conML y) = refl --***proof that MultiLift is a monad***-- --bindML and nowML need to be natural transformations nattrans-nowML : {A B : Set} (κ : Cl) → ∀(f : A → B) → ∀(x : A) → mapML κ f (nowML κ x) ≡ nowML κ (f x) nattrans-nowML {A}{B} κ f x = refl -- TODO: bindML -- bindML and nowML also need to satisfy three monad laws: -- unit is a left-identity for bind unitlawML1 : {A B : Set} (κ : Cl) → ∀ (f : A → (MultiLift B κ)) → ∀ (x : A) → (bindML {A} κ f (nowML κ x)) ≡ f x unitlawML1 κ f x = refl -- unit is a right-identity for bind unitlawML2 : {A : Set}(κ : Cl) → ∀(x : (MultiLift A κ)) → (bindML κ (nowML κ) x) ≡ x unitlawML2 κ x = elimML ((λ y → ((bindML κ (nowML κ) y) ≡ y) , truncML (bindML κ (nowML κ) y) y)) refl (λ y → refl) (λ p → cong conML (cong unitM (cong inr (later-ext (λ β → p β))))) (λ eq1 → λ eq2 → cong₂ _∪ₘₗ_ eq1 eq2) x -- bind is associative assoclawML : {A B C : Set}(κ : Cl) → ∀(f : A → (MultiLift B κ)) → ∀ (g : B → (MultiLift C κ)) → ∀ (x : (MultiLift A κ)) → (bindML κ (\ y → (bindML κ g (f y))) x) ≡ (bindML κ g (bindML κ f x)) assoclawML {A} {B} {C} κ f g x = elimML ((λ z → ((bindML κ (\ y → (bindML κ g (f y))) z) ≡ (bindML κ g (bindML κ f z))) , truncML ((bindML κ (\ y → (bindML κ g (f y))) z)) (bindML κ g (bindML κ f z)))) refl (λ y → refl) (λ p → cong conML (cong unitM (cong inr (later-ext (λ α → p α))))) (λ {m n} → λ eq1 → λ eq2 → (bindML κ (λ y → bindML κ g (f y)) (conML m) ∪ₘₗ bindML κ (λ y → bindML κ g (f y)) (conML n)) ≡⟨ cong₂ (_∪ₘₗ_) eq1 eq2 ⟩ (bindML κ g (bindML κ f (conML m)) ∪ₘₗ bindML κ g (bindML κ f (conML n))) ≡⟨ sym (bindML-∪ₘₗ κ g (bindML κ f (conML m)) (bindML κ f (conML n))) ⟩ bindML κ g (bindML κ f (conML m) ∪ₘₗ bindML κ f (conML n)) ∎) x --*************************************************************************************-- -- Step 3: The MultiLift monad as the free delay-algebra and commutiative monoid monad -- --*************************************************************************************-- -- We already know that (MultiLift, stepML) forms a delay algebra structure, -- and (Multilift, conML m∅ , ∪ₘₗ) forms a commutative monoid. -- What we need to show is that MultiLift is the free monad with these properties. -- That is, for a set A, and any other structure (B, δ, ε, _·_) where (B, δ) is a delay algebra and (B, ε, _·_) a commutative monoid -- given a function f : A → B, there is a unique function MultiLift A → B extending f that preserves the algebra structures. record IsComMonoid {A : Set} (ε : A) (_·_ : A → A → A) : Set where constructor iscommonoid field asso : (x y z : A) → (x · y) · z ≡ x · (y · z) comm : (x y : A) → (x · y) ≡ (y · x) uniteq : (x : A) → x · ε ≡ x record IsDelayComMonoid {A : Set}(κ : Cl) (dm : DelayMonoidData A κ) : Set where constructor isdelaycommonoid open DelayMonoidData dm field isComMonoid : IsComMonoid (ε) (_·_) isDelayalg : IsDelayalg κ (nextA) open IsComMonoid isComMonoid public open IsDelayalg isDelayalg public record IsExtendingML {A B : Set}{κ : Cl} (f : A → B) (h : (MultiLift A κ) → B) : Set where constructor isextendingML field extends : (x : A) → h (nowML κ x) ≡ (f x) --foldML defines the function we are after foldML : {A B : Set}{κ : Cl} → isSet A → isSet B → ∀ dm → IsDelayComMonoid {B} κ dm → (A → B) → (MultiLift A κ) → B foldML setA setB (dmdata nextB ε _·_) isDMB f (conML m∅) = ε foldML setA setB (dmdata nextB ε _·_) isDMB f (conML (unitM (inl x))) = f x foldML setA setB dm@(dmdata nextB ε _·_) isDMB f (conML (unitM (inr x))) = nextB (λ α → foldML setA setB dm isDMB f (x α)) foldML setA setB dm@(dmdata nextB ε _·_) isDMB f (conML (x ∪ₘ y)) = (foldML setA setB dm isDMB f (conML x)) · (foldML setA setB dm isDMB f (conML y)) foldML setA setB dm@(dmdata nextB ε _·_) isDMB f (conML (ass x y z i)) = sym (IsDelayComMonoid.asso isDMB (foldML setA setB dm isDMB f (conML x)) (foldML setA setB dm isDMB f (conML y)) (foldML setA setB dm isDMB f (conML z))) i foldML setA setB dm@(dmdata nextB ε _·_) isDMB f (conML (com x y i)) = IsDelayComMonoid.comm isDMB (foldML setA setB dm isDMB f (conML x)) (foldML setA setB dm isDMB f (conML y)) i foldML setA setB dm@(dmdata nextB ε _·_) isDMB f (conML (unitr x i)) = IsDelayComMonoid.uniteq isDMB (foldML setA setB dm isDMB f (conML x)) i foldML setA setB dm@(dmdata nextB ε _·_) isDMB f (conML (trunc x y x₁ y₁ i i₁)) = setB (foldML setA setB dm isDMB f (conML x)) (foldML setA setB dm isDMB f (conML y)) (λ j → (foldML setA setB dm isDMB f (conML (x₁ j)))) (λ j → (foldML setA setB dm isDMB f (conML (y₁ j)))) i i₁ --foldML extends the function f : A → B foldML-extends : {A B : Set}{κ : Cl} → ∀(setA : isSet A) → ∀(setB : isSet B) → ∀ dm → ∀(isDMB : IsDelayComMonoid {B} κ dm) → ∀ (f : A → B) → IsExtendingML f (foldML setA setB dm isDMB f) IsExtendingML.extends (foldML-extends setA setB dm isDMB f) x = refl -- or a more direct proof of the same fact: foldML-extends-f : {A B : Set}{κ : Cl} → ∀(setA : isSet A) → ∀(setB : isSet B) → ∀ dm → ∀(isDMB : IsDelayComMonoid {B} κ dm) → ∀ (f : A → B) → ∀ (x : A) → foldML setA setB dm isDMB f (nowML κ x) ≡ f x foldML-extends-f setA setB dm isDMB f x = refl --foldML preseves the DelayMonoid structure module _ {A B : Set}{κ : Cl} (setA : isSet A) (setB : isSet B) (dm : _) (isDMB : IsDelayComMonoid {B} κ dm) (f : A → B) where open IsPreservingDM open DelayMonoidData dm renaming (nextA to nextB) foldML-preserves : IsPreservingDM {MultiLift A κ}{B} κ (dmdata (stepML κ) (conML m∅) _∪ₘₗ_) dm (foldML setA setB dm isDMB f) unit-preserve foldML-preserves = refl next-preserve foldML-preserves x = cong nextB (later-ext (λ α → refl)) union-preserve foldML-preserves (conML x) (conML y) = refl --and foldML is unique in doing so. --That is, for any function h that both preserves the algebra structure --and extends the function f : A → B, -- h is equivalent to fold. module _ {A B : Set} {κ : Cl} (h : MultiLift A κ → B) (setA : isSet A) (setB : isSet B) (dm : _) (isDMB : IsDelayComMonoid {B} κ dm) (f : A → B) (isPDM : IsPreservingDM {MultiLift A κ}{B} κ (dmdata (stepML κ) (conML m∅) _∪ₘₗ_ ) dm h) (isExt : IsExtendingML f h) where open DelayMonoidData dm renaming (nextA to nextB) fold-uniquenessML : (x : (MultiLift A κ)) → h x ≡ (foldML setA setB dm isDMB f x) fold-uniquenessML x = elimML ((λ x → (h x ≡ (foldML setA setB dm isDMB f x)) , setB (h x) ((foldML setA setB dm isDMB f x)))) (IsPreservingDM.unit-preserve isPDM) (λ a → h (conML (unitM (inl a))) ≡⟨ refl ⟩ h (nowML κ a) ≡⟨ IsExtendingML.extends isExt a ⟩ f a ∎) (λ {x} → λ eq → h (conML (unitM (inr x))) ≡⟨ refl ⟩ h (stepML κ x) ≡⟨ IsPreservingDM.next-preserve isPDM x ⟩ nextB (λ α → h (x α)) ≡⟨ cong nextB (later-ext (λ α → (eq α))) ⟩ nextB (λ α → foldML setA setB (dmdata nextB ε _·_) isDMB f (x α)) ∎) (λ {x y} → λ eqx eqy → h (conML (x ∪ₘ y)) ≡⟨ refl ⟩ h ((conML x) ∪ₘₗ (conML y)) ≡⟨ IsPreservingDM.union-preserve isPDM (conML x) (conML y) ⟩ (h (conML x) · h (conML y)) ≡⟨ cong₂ _·_ eqx eqy ⟩ (foldML setA setB (dmdata nextB ε _·_) isDMB f (conML x) · foldML setA setB (dmdata nextB ε _·_) isDMB f (conML y)) ∎) x --****************************************************-- -- Composing Lift and Multiset via a distributive law -- --****************************************************-- --We now define a composite monad of the Multiset and Lift monads, formed via a distributive law. LcM : (A : Set) → (κ : Cl) → Set LcM A κ = myLift (Multiset A) κ -- the unit of this monad is simply the composit of the units for Lift (nowL x) and Multiset (unitM) nowLcM : {A : Set} {κ : Cl} → A → (LcM A κ) nowLcM x = nowL (unitM x) --LcM is a set. truncLcM : {A : Set} {κ : Cl} → isSet (LcM A κ) truncLcM = MyLiftSet.isSetmyLift trunc --LLCM is a set truncLLcM : {A : Set} {κ : Cl} → isSet (myLift (LcM A κ) κ) truncLLcM = MyLiftSet.isSetmyLift truncLcM -- we define a union on LcM, which will help in defining the distributive law. _l∪m_ : {A : Set} {κ : Cl} → (LcM A κ) → (LcM A κ) → (LcM A κ) nowL x l∪m nowL y = nowL (x ∪ₘ y) nowL x l∪m stepL y = stepL (λ α → (nowL x l∪m (y α))) stepL x l∪m y = stepL (λ α → ((x α) l∪m y)) --l∪m is associative, commutative, and nowL m∅ is a unit for l∪m assoc-l∪m : {A : Set} {κ : Cl} → ∀(x y z : LcM A κ) → (x l∪m y) l∪m z ≡ x l∪m (y l∪m z) assoc-l∪m (nowL x) (nowL y) (nowL z) = cong nowL (sym (ass x y z)) assoc-l∪m (nowL x) (nowL y) (stepL z) = cong stepL (later-ext λ α → assoc-l∪m (nowL x) (nowL y) (z α)) assoc-l∪m (nowL x) (stepL y) z = cong stepL (later-ext λ α → assoc-l∪m (nowL x) (y α) z) assoc-l∪m (stepL x) y z = cong stepL (later-ext λ α → assoc-l∪m (x α) y z) comm-l∪m : {A : Set} {κ : Cl} → ∀(x y : LcM A κ) → (x l∪m y) ≡ y l∪m x comm-l∪m (nowL x) (nowL y) = cong nowL (com x y) comm-l∪m (nowL x) (stepL y) = cong stepL (later-ext λ α → comm-l∪m (nowL x) (y α)) comm-l∪m (stepL x) (nowL y) = cong stepL (later-ext λ α → comm-l∪m (x α) (nowL y)) comm-l∪m (stepL x) (stepL y) = stepL (λ α → x α l∪m stepL y) ≡⟨ cong stepL (later-ext λ α → comm-l∪m (x α) (stepL y)) ⟩ stepL (λ α → stepL y l∪m x α) ≡⟨ refl ⟩ stepL (λ α → stepL (λ β → (y β) l∪m (x α))) ≡⟨ cong stepL (later-ext λ α → cong stepL (later-ext λ β → cong₂ _l∪m_ (sym (tick-irr y α β)) (tick-irr x α β) )) ⟩ stepL (λ α → stepL (λ β → (y α) l∪m (x β))) ≡⟨ cong stepL (later-ext λ α → cong stepL (later-ext λ β → comm-l∪m (y α) (x β))) ⟩ stepL (λ α → stepL (λ β → (x β) l∪m (y α))) ≡⟨ refl ⟩ stepL (λ α → (stepL x) l∪m (y α)) ≡⟨ cong stepL (later-ext λ α → comm-l∪m (stepL x) (y α)) ⟩ stepL (λ α → y α l∪m stepL x) ∎ unit-l∪m : {A : Set} {κ : Cl} → ∀(x : LcM A κ) → x l∪m (nowL m∅) ≡ x unit-l∪m (nowL x) = cong nowL (unitr x) unit-l∪m (stepL x) = cong stepL (later-ext λ α → unit-l∪m (x α)) lemma-nowL-l∪m-mapL : {A : Set} {κ : Cl} → ∀(x : LcM A κ) → ∀(M : Multiset A) → nowL M l∪m x ≡ mapL κ (M ∪ₘ_) x lemma-nowL-l∪m-mapL (nowL x) M = refl lemma-nowL-l∪m-mapL (stepL x) M = cong stepL (later-ext (λ α → lemma-nowL-l∪m-mapL (x α) M)) --mapL κ f distributes over l∪m if f distributes over ∪ₘ dist-mapL-l∪m : {A B : Set} {κ : Cl} → ∀(f : (Multiset A) → (Multiset B)) → ∀(fdist : ∀(m n : Multiset A) → f (m ∪ₘ n) ≡ f m ∪ₘ f n) → ∀(x y : (LcM A κ)) → mapL κ f (x l∪m y) ≡ (mapL κ f x) l∪m (mapL κ f y) dist-mapL-l∪m f fdist (nowL x) (nowL y) = cong nowL (fdist x y) dist-mapL-l∪m f fdist (nowL x) (stepL y) = cong stepL (later-ext λ α → dist-mapL-l∪m f fdist (nowL x) (y α)) dist-mapL-l∪m f fdist (stepL x) y = cong stepL (later-ext λ α → dist-mapL-l∪m f fdist (x α) y) -- and why not, I also need a ll∪m: _ll∪m_ : {A : Set} {κ : Cl} → (myLift (LcM A κ) κ) → (myLift (LcM A κ) κ) → (myLift (LcM A κ) κ) nowL x ll∪m nowL y = nowL (x l∪m y) nowL x ll∪m stepL y = stepL (λ α → (nowL x ll∪m (y α))) stepL x ll∪m y = stepL (λ α → ((x α) ll∪m y)) assoc-ll∪m : {A : Set} {κ : Cl} → ∀(x y z : (myLift (LcM A κ) κ)) → (x ll∪m y) ll∪m z ≡ x ll∪m (y ll∪m z) assoc-ll∪m (nowL x) (nowL y) (nowL z) = cong nowL (assoc-l∪m x y z) assoc-ll∪m (nowL x) (nowL y) (stepL z) = cong stepL (later-ext λ α → assoc-ll∪m (nowL x) (nowL y) (z α)) assoc-ll∪m (nowL x) (stepL y) z = cong stepL (later-ext λ α → assoc-ll∪m (nowL x) (y α) z) assoc-ll∪m (stepL x) y z = cong stepL (later-ext λ α → assoc-ll∪m (x α) y z) unit-ll∪m : {A : Set} {κ : Cl} → ∀(x : myLift (LcM A κ) κ) → nowL (nowL m∅) ll∪m x ≡ x unit-ll∪m (nowL x) = nowL (nowL m∅ l∪m x) ≡⟨ cong nowL (comm-l∪m (nowL m∅) x) ⟩ nowL (x l∪m nowL m∅) ≡⟨ cong nowL (unit-l∪m x) ⟩ nowL x ∎ unit-ll∪m (stepL x) = cong stepL (later-ext λ α → unit-ll∪m (x α)) lemma-nowL-ll∪m-mapL : {A : Set} {κ : Cl} → ∀(x : myLift (LcM A κ) κ) → ∀(M : LcM A κ) → nowL M ll∪m x ≡ mapL κ (M l∪m_) x lemma-nowL-ll∪m-mapL (nowL x) M = refl lemma-nowL-ll∪m-mapL (stepL x) M = cong stepL (later-ext (λ α → lemma-nowL-ll∪m-mapL (x α) M)) multL-ll∪m-l∪m : {A : Set} (κ : Cl) → ∀(x y : myLift (LcM A κ) κ) → MultL κ (x ll∪m y) ≡ MultL κ x l∪m MultL κ y multL-ll∪m-l∪m κ (nowL x) (nowL y) = refl multL-ll∪m-l∪m κ (nowL x) (stepL y) = stepL (λ α → MultL κ (nowL x ll∪m y α)) ≡⟨ cong stepL (later-ext(λ α → multL-ll∪m-l∪m κ (nowL x) (y α) )) ⟩ stepL (λ α → MultL κ (nowL x) l∪m MultL κ (y α)) ≡⟨ refl ⟩ stepL (λ α → x l∪m MultL κ (y α)) ≡⟨ cong stepL (later-ext (λ α → comm-l∪m x (MultL κ (y α)))) ⟩ (stepL (λ α → MultL κ (y α)) l∪m x) ≡⟨ refl ⟩ (stepL (λ α → MultL κ (y α)) l∪m x) ≡⟨ comm-l∪m (stepL (λ α → MultL κ (y α))) x ⟩ (x l∪m stepL (λ α → MultL κ (y α))) ∎ multL-ll∪m-l∪m κ (stepL x) y = cong stepL (later-ext (λ α → multL-ll∪m-l∪m κ (x α) y)) -- LcM is a monad via a distributive law, distributing Multiset over Lift. -- Here is the distributive law: distlawLcM : {A : Set} {κ : Cl} → Multiset (myLift A κ) → (LcM A κ) distlawLcM m∅ = nowL m∅ distlawLcM (unitM (nowL x)) = nowL (unitM x) distlawLcM (unitM (stepL x)) = stepL (λ α → distlawLcM (unitM (x α))) distlawLcM (x ∪ₘ y) = (distlawLcM x) l∪m (distlawLcM y) distlawLcM (ass x y z i) = assoc-l∪m (distlawLcM x) (distlawLcM y) (distlawLcM z) (~ i) distlawLcM (com x y i) = comm-l∪m (distlawLcM x) (distlawLcM y) i distlawLcM (unitr x i) = unit-l∪m (distlawLcM x) i distlawLcM (trunc x y x₁ y₁ i i₁) = truncLcM (distlawLcM x) (distlawLcM y) (λ j → distlawLcM (x₁ j)) (λ j → distlawLcM (y₁ j)) i i₁ --proof that distlawLcM is indeed a distributive law: --unit laws: unitlawLcM1 : {A : Set} {κ : Cl} → ∀(x : myLift A κ) → (distlawLcM (unitM x)) ≡ mapL κ unitM x unitlawLcM1 (nowL x) = refl unitlawLcM1 (stepL x) = cong stepL (later-ext λ α → unitlawLcM1 (x α)) unitlawLcM2 : {A : Set} {κ : Cl} → ∀(M : Multiset A) → (distlawLcM {A}{κ} (mapM nowL M)) ≡ nowL M unitlawLcM2 M = elimM (λ N → ((distlawLcM (mapM nowL N) ≡ nowL N) , truncLcM (distlawLcM (mapM nowL N)) (nowL N))) refl (λ N → refl) (λ {M N} → λ eqM eqN → distlawLcM (mapM nowL M) l∪m distlawLcM (mapM nowL N) ≡⟨ cong₂ (_l∪m_) eqM eqN ⟩ ((nowL M) l∪m (nowL N)) ≡⟨ refl ⟩ nowL (M ∪ₘ N) ∎ ) M --multiplication laws: multlawLcM1 : {A : Set} (κ : Cl) → ∀(M : Multiset (Multiset (myLift A κ))) → distlawLcM (Multiset-mult M) ≡ mapL κ Multiset-mult (distlawLcM (mapM distlawLcM M)) multlawLcM1 κ M = elimM (λ N → ((distlawLcM (Multiset-mult N) ≡ mapL κ Multiset-mult (distlawLcM (mapM distlawLcM N))) , truncLcM (distlawLcM (Multiset-mult N)) (mapL κ Multiset-mult (distlawLcM (mapM distlawLcM N))) )) refl (λ N → distlawLcM N ≡⟨ sym (mapL-identity (distlawLcM N)) ⟩ mapL κ (λ y → y) (distlawLcM N) ≡⟨ cong₂ (mapL κ) (funExt (λ y → sym (Multiset-unitlaw1 y))) refl ⟩ mapL κ (λ y → Multiset-mult (unitM y)) (distlawLcM N) ≡⟨ sym (mapmapL κ unitM Multiset-mult (distlawLcM N)) ⟩ mapL κ Multiset-mult (mapL κ unitM (distlawLcM N)) ≡⟨ cong (mapL κ Multiset-mult) (sym (unitlawLcM1 (distlawLcM N))) ⟩ mapL κ Multiset-mult (distlawLcM (unitM (distlawLcM N))) ∎) (λ {M N} → λ eqM eqN → (distlawLcM (Multiset-mult M) l∪m distlawLcM (Multiset-mult N)) ≡⟨ cong₂ _l∪m_ eqM eqN ⟩ (mapL κ Multiset-mult (distlawLcM (mapM distlawLcM M)) l∪m mapL κ Multiset-mult (distlawLcM (mapM distlawLcM N))) ≡⟨ sym (dist-mapL-l∪m Multiset-mult (λ x y → refl) (distlawLcM (mapM distlawLcM M)) (distlawLcM (mapM distlawLcM N))) ⟩ mapL κ Multiset-mult (distlawLcM (mapM distlawLcM M) l∪m distlawLcM (mapM distlawLcM N)) ∎) M -- lemma before we can do the second multiplication law: -- I don't know hot to split cases within elimM, so here is a lemma for the unitM case of the unitM case for the lemma-llum, split into nowL and stepL: lemma-llum-unit-unitcase : {A : Set} (κ : Cl) → ∀(x : myLift A κ) → ∀(y : (myLift (myLift A κ) κ)) → (mapL κ distlawLcM (distlawLcM (unitM (nowL x)))) ll∪m (mapL κ distlawLcM (distlawLcM (unitM y))) ≡ mapL κ distlawLcM (distlawLcM (unitM (nowL x)) l∪m distlawLcM (unitM y)) lemma-llum-unit-unitcase κ x (nowL y) = refl lemma-llum-unit-unitcase κ x (stepL y) = cong stepL (later-ext λ α → lemma-llum-unit-unitcase κ x (y α)) -- I don't know how to split cases within elimM, so here a lemma for the unitM case of elimM for lemma-llum, split into nowL and stepL: lemma-llum-unitcase : {A : Set} (κ : Cl) → ∀(x : (myLift (myLift A κ) κ))→ ∀(N : Multiset (myLift (myLift A κ) κ)) → (mapL κ distlawLcM (distlawLcM (unitM x))) ll∪m (mapL κ distlawLcM (distlawLcM N)) ≡ mapL κ distlawLcM (distlawLcM (unitM x) l∪m distlawLcM N) lemma-llum-unitcase κ (nowL x) N = elimM (λ N → ((mapL κ distlawLcM (distlawLcM (unitM (nowL x)))) ll∪m (mapL κ distlawLcM (distlawLcM N)) ≡ mapL κ distlawLcM (distlawLcM (unitM (nowL x)) l∪m distlawLcM N)) , truncLLcM ((mapL κ distlawLcM (distlawLcM (unitM (nowL x)))) ll∪m (mapL κ distlawLcM (distlawLcM N))) ( mapL κ distlawLcM (distlawLcM (unitM (nowL x)) l∪m distlawLcM N))) refl (λ y → lemma-llum-unit-unitcase κ x y) (λ {M N} → λ eqM eqN → (nowL (distlawLcM (unitM x)) ll∪m mapL κ distlawLcM (distlawLcM M l∪m distlawLcM N)) ≡⟨ lemma-nowL-ll∪m-mapL (mapL κ distlawLcM (distlawLcM M l∪m distlawLcM N)) (distlawLcM (unitM x)) ⟩ mapL κ (distlawLcM (unitM x) l∪m_) (mapL κ distlawLcM (distlawLcM M l∪m distlawLcM N)) ≡⟨ mapmapL κ distlawLcM (distlawLcM (unitM x) l∪m_) (distlawLcM M l∪m distlawLcM N) ⟩ mapL κ (λ y → distlawLcM (unitM x) l∪m distlawLcM y) (distlawLcM M l∪m distlawLcM N) ≡⟨ refl ⟩ mapL κ (λ y → distlawLcM ((unitM x) ∪ₘ y)) (distlawLcM M l∪m distlawLcM N) ≡⟨ sym (mapmapL κ (unitM x ∪ₘ_) distlawLcM (distlawLcM M l∪m distlawLcM N)) ⟩ mapL κ distlawLcM (mapL κ ((unitM x) ∪ₘ_) (distlawLcM M l∪m distlawLcM N)) ≡⟨ cong (mapL κ distlawLcM) (sym (lemma-nowL-l∪m-mapL (distlawLcM M l∪m distlawLcM N) (unitM x))) ⟩ mapL κ distlawLcM (nowL (unitM x) l∪m (distlawLcM M l∪m distlawLcM N)) ∎) N lemma-llum-unitcase κ (stepL x) N = cong stepL (later-ext (λ α → lemma-llum-unitcase κ (x α) N)) lemma-llum' : {A : Set} (κ : Cl) → ∀(M N : Multiset (myLift (myLift A κ) κ)) → (mapL κ distlawLcM (distlawLcM M)) ll∪m (mapL κ distlawLcM (distlawLcM N)) ≡ mapL κ distlawLcM (distlawLcM M l∪m distlawLcM N) lemma-llum' κ M = elimM (λ M₁ → (( ∀ N → (mapL κ distlawLcM (distlawLcM M₁)) ll∪m (mapL κ distlawLcM (distlawLcM N)) ≡ mapL κ distlawLcM (distlawLcM M₁ l∪m distlawLcM N)) , λ x y i N → truncLLcM ((mapL κ distlawLcM (distlawLcM M₁)) ll∪m (mapL κ distlawLcM (distlawLcM N))) (mapL κ distlawLcM (distlawLcM M₁ l∪m distlawLcM N)) (x N) (y N) i)) (λ N → ((nowL (nowL m∅) ll∪m mapL κ distlawLcM (distlawLcM N)) ≡⟨ unit-ll∪m (mapL κ distlawLcM (distlawLcM N)) ⟩ (mapL κ distlawLcM (distlawLcM N)) ≡⟨ cong (mapL κ distlawLcM) (sym (unit-l∪m (distlawLcM N))) ⟩ mapL κ distlawLcM (distlawLcM N l∪m nowL m∅) ≡⟨ cong (mapL κ distlawLcM) (comm-l∪m (distlawLcM N) (nowL m∅)) ⟩ mapL κ distlawLcM (nowL m∅ l∪m distlawLcM N) ∎)) (λ x → λ N → lemma-llum-unitcase κ x N) (λ {M M₁} → λ eqM eqM₁ → λ N → (mapL κ distlawLcM (distlawLcM M l∪m distlawLcM M₁) ll∪m mapL κ distlawLcM (distlawLcM N)) ≡⟨ cong (_ll∪m mapL κ distlawLcM (distlawLcM N)) (sym (eqM M₁)) ⟩ (((mapL κ distlawLcM (distlawLcM M)) ll∪m (mapL κ distlawLcM (distlawLcM M₁))) ll∪m mapL κ distlawLcM (distlawLcM N)) ≡⟨ assoc-ll∪m ((mapL κ distlawLcM (distlawLcM M))) ((mapL κ distlawLcM (distlawLcM M₁))) ((mapL κ distlawLcM (distlawLcM N))) ⟩ ((mapL κ distlawLcM (distlawLcM M)) ll∪m ((mapL κ distlawLcM (distlawLcM M₁)) ll∪m mapL κ distlawLcM (distlawLcM N))) ≡⟨ cong (mapL κ distlawLcM (distlawLcM M) ll∪m_) (eqM₁ N) ⟩ ((mapL κ distlawLcM (distlawLcM M) ll∪m mapL κ distlawLcM (distlawLcM M₁ l∪m distlawLcM N))) ≡⟨ refl ⟩ (mapL κ distlawLcM (distlawLcM M) ll∪m mapL κ distlawLcM (distlawLcM (M₁ ∪ₘ N))) ≡⟨ eqM (M₁ ∪ₘ N) ⟩ mapL κ distlawLcM (distlawLcM M l∪m (distlawLcM M₁ l∪m distlawLcM N)) ≡⟨ cong (mapL κ distlawLcM) (sym (assoc-l∪m (distlawLcM M) (distlawLcM M₁) (distlawLcM N))) ⟩ mapL κ distlawLcM ((distlawLcM M l∪m distlawLcM M₁) l∪m distlawLcM N) ∎) M -- then now the second multiplication law: -- I don't know how to split cases within elimM, so here a lemma for the unitM case of elimM for multlawLcM2, split into nowL and stepL: multlawLcM2-unitMcase : {A : Set} {κ : Cl} → ∀(x : (myLift (myLift A κ) κ)) → distlawLcM (mapM (MultL κ) (unitM x)) ≡ MultL κ (mapL κ distlawLcM (distlawLcM (unitM x))) multlawLcM2-unitMcase (nowL x) = refl multlawLcM2-unitMcase (stepL x) = cong stepL (later-ext λ α → multlawLcM2-unitMcase (x α)) -- and here the full proof of the second multiplication law: multlawLcM2 : {A : Set} (κ : Cl) → ∀(M : Multiset (myLift (myLift A κ) κ)) → distlawLcM (mapM (MultL κ) M) ≡ MultL κ (mapL κ distlawLcM (distlawLcM M)) multlawLcM2 κ M = elimM (λ N → ((distlawLcM (mapM (MultL κ) N) ≡ MultL κ (mapL κ distlawLcM (distlawLcM N))) , truncLcM (distlawLcM (mapM (MultL κ) N)) (MultL κ (mapL κ distlawLcM (distlawLcM N))))) refl (λ x → multlawLcM2-unitMcase x ) (λ {M N} → λ eqM eqN → distlawLcM (mapM (MultL κ) M) l∪m distlawLcM (mapM (MultL κ) N) ≡⟨ cong₂ (_l∪m_) eqM eqN ⟩ (MultL κ (mapL κ distlawLcM (distlawLcM M)) l∪m MultL κ (mapL κ distlawLcM (distlawLcM N))) ≡⟨ sym (multL-ll∪m-l∪m κ (mapL κ distlawLcM (distlawLcM M)) (mapL κ distlawLcM (distlawLcM N))) ⟩ MultL κ ((mapL κ distlawLcM (distlawLcM M)) ll∪m (mapL κ distlawLcM (distlawLcM N))) ≡⟨ cong (MultL κ) (lemma-llum' κ M N) ⟩ MultL κ (mapL κ distlawLcM (distlawLcM M l∪m distlawLcM N)) ∎) M --some random proofs that did not work, or work partially, that I'm not ready to through away yet: -- lemma-llum : {A : Set} (κ : Cl) → ∀(M N : Multiset (myLift (myLift A κ) κ)) → (mapL κ distlawLcM (distlawLcM M)) ll∪m (mapL κ distlawLcM (distlawLcM N)) -- ≡ mapL κ distlawLcM (distlawLcM M l∪m distlawLcM N) -- lemma-llum κ m∅ N = (nowL (nowL m∅) ll∪m mapL κ distlawLcM (distlawLcM N)) -- ≡⟨ unit-ll∪m (mapL κ distlawLcM (distlawLcM N)) ⟩ -- (mapL κ distlawLcM (distlawLcM N)) -- ≡⟨ cong (mapL κ distlawLcM) (sym (unit-l∪m (distlawLcM N))) ⟩ -- mapL κ distlawLcM (distlawLcM N l∪m nowL m∅) -- ≡⟨ cong (mapL κ distlawLcM) (comm-l∪m (distlawLcM N) (nowL m∅)) ⟩ -- mapL κ distlawLcM (nowL m∅ l∪m distlawLcM N) ∎ -- lemma-llum κ (unitM (nowL x)) m∅ = refl -- lemma-llum κ (unitM (nowL x)) (unitM (nowL y)) = refl -- lemma-llum κ (unitM (nowL x)) (unitM (stepL y)) = cong stepL (later-ext (λ α → lemma-llum κ (unitM (nowL x)) (unitM (y α)))) -- lemma-llum κ (unitM (nowL x)) (M ∪ₘ N) = (nowL (distlawLcM (unitM x)) ll∪m -- mapL κ distlawLcM (distlawLcM M l∪m distlawLcM N)) -- ≡⟨ lemma-nowL-ll∪m-mapL (mapL κ distlawLcM (distlawLcM M l∪m distlawLcM N)) (distlawLcM (unitM x)) ⟩ -- mapL κ (distlawLcM (unitM x) l∪m_) (mapL κ distlawLcM (distlawLcM M l∪m distlawLcM N)) -- ≡⟨ mapmapL κ distlawLcM (distlawLcM (unitM x) l∪m_) ((distlawLcM M l∪m distlawLcM N)) ⟩ -- mapL κ (λ y → distlawLcM (unitM x) l∪m (distlawLcM y)) (distlawLcM M l∪m distlawLcM N) -- ≡⟨ cong₂ (mapL κ) (funExt (λ y → refl)) refl ⟩ -- mapL κ (λ y → distlawLcM ((unitM x) ∪ₘ y)) (distlawLcM M l∪m distlawLcM N) -- ≡⟨ sym (mapmapL κ ((unitM x) ∪ₘ_) distlawLcM (distlawLcM M l∪m distlawLcM N)) ⟩ -- mapL κ distlawLcM (mapL κ ((unitM x) ∪ₘ_) (distlawLcM M l∪m distlawLcM N)) -- ≡⟨ cong (mapL κ distlawLcM) (sym (lemma-nowL-l∪m-mapL (distlawLcM M l∪m distlawLcM N) (unitM x))) ⟩ -- mapL κ distlawLcM (nowL (unitM x) l∪m (distlawLcM M l∪m distlawLcM N)) ∎ -- lemma-llum κ (unitM (nowL x)) (ass N N₁ N₂ i) = {!!} -- lemma-llum κ (unitM (nowL x)) (com N N₁ i) = {!!} -- lemma-llum κ (unitM (nowL x)) (unitr N i) = {!!} -- lemma-llum κ (unitM (nowL x)) (trunc N N₁ x₁ y i i₁) = {!!} -- lemma-llum κ (unitM (stepL x)) N = cong stepL (later-ext (λ α → lemma-llum κ (unitM (x α)) N)) -- lemma-llum κ (M ∪ₘ M₁) N = (mapL κ distlawLcM (distlawLcM M l∪m distlawLcM M₁) ll∪m mapL κ distlawLcM (distlawLcM N)) -- ≡⟨ cong (_ll∪m mapL κ distlawLcM (distlawLcM N)) (sym (lemma-llum κ M M₁)) ⟩ -- (((mapL κ distlawLcM (distlawLcM M)) ll∪m (mapL κ distlawLcM (distlawLcM M₁))) ll∪m mapL κ distlawLcM (distlawLcM N)) -- ≡⟨ assoc-ll∪m ((mapL κ distlawLcM (distlawLcM M))) ((mapL κ distlawLcM (distlawLcM M₁))) ((mapL κ distlawLcM (distlawLcM N))) ⟩ -- ((mapL κ distlawLcM (distlawLcM M)) ll∪m ((mapL κ distlawLcM (distlawLcM M₁)) ll∪m mapL κ distlawLcM (distlawLcM N))) -- ≡⟨ cong (mapL κ distlawLcM (distlawLcM M) ll∪m_) (lemma-llum κ M₁ N) ⟩ -- ((mapL κ distlawLcM (distlawLcM M) ll∪m mapL κ distlawLcM (distlawLcM M₁ l∪m distlawLcM N))) -- ≡⟨ refl ⟩ -- (mapL κ distlawLcM (distlawLcM M) ll∪m mapL κ distlawLcM (distlawLcM (M₁ ∪ₘ N))) -- ≡⟨ lemma-llum κ M (M₁ ∪ₘ N) ⟩ -- mapL κ distlawLcM (distlawLcM M l∪m (distlawLcM M₁ l∪m distlawLcM N)) -- ≡⟨ cong (mapL κ distlawLcM) (sym (assoc-l∪m (distlawLcM M) (distlawLcM M₁) (distlawLcM N))) ⟩ -- mapL κ distlawLcM ((distlawLcM M l∪m distlawLcM M₁) l∪m distlawLcM N) ∎ -- lemma-llum κ (ass M M₁ M₂ i) N = {!!} -- lemma-llum κ (com M M₁ i) N = {!!} -- lemma-llum κ (unitr M i) N = {!!} -- lemma-llum κ (trunc M M₁ x y i i₁) N = {!!} -- -- lemma-multlawLcM2-unitMcase-unitMcase : {A : Set} (κ : Cl) → ∀(x : (myLift A κ)) → ∀(y : (myLift (myLift A κ) κ)) → -- -- (MultL κ (mapL κ distlawLcM (distlawLcM (unitM (nowL x)))) l∪m MultL κ (mapL κ distlawLcM (distlawLcM (unitM y)))) -- -- ≡ MultL κ (mapL κ distlawLcM (distlawLcM (unitM (nowL x)) l∪m distlawLcM (unitM y))) -- -- lemma-multlawLcM2-unitMcase-unitMcase κ x (nowL y) = refl -- -- lemma-multlawLcM2-unitMcase-unitMcase κ x (stepL y) = (distlawLcM (unitM x) l∪m -- -- stepL (λ α → MultL κ (mapL κ distlawLcM (distlawLcM (unitM (y α)))))) -- -- ≡⟨ comm-l∪m (distlawLcM (unitM x)) -- -- (stepL (λ α → MultL κ (mapL κ distlawLcM (distlawLcM (unitM (y α)))))) ⟩ -- -- (stepL (λ α → MultL κ (mapL κ distlawLcM (distlawLcM (unitM (y α))))) l∪m -- -- distlawLcM (unitM x)) -- -- ≡⟨ refl ⟩ -- -- stepL (λ α → (MultL κ (mapL κ distlawLcM (distlawLcM (unitM (y α)))) l∪m -- -- distlawLcM (unitM x))) -- -- ≡⟨ cong stepL (later-ext λ α → comm-l∪m (MultL κ (mapL κ distlawLcM (distlawLcM (unitM (y α))))) -- -- (distlawLcM (unitM x)) ) ⟩ -- -- stepL (λ α → (distlawLcM (unitM x) l∪m -- -- (MultL κ (mapL κ distlawLcM (distlawLcM (unitM (y α))))))) -- -- ≡⟨ refl ⟩ -- -- stepL (λ α → (MultL κ (mapL κ distlawLcM (distlawLcM (unitM (nowL x))))) l∪m -- -- (MultL κ (mapL κ distlawLcM (distlawLcM (unitM (y α)))))) -- -- ≡⟨ cong stepL (later-ext λ α → lemma-multlawLcM2-unitMcase-unitMcase κ x (y α)) ⟩ -- -- stepL (λ α → MultL κ (mapL κ distlawLcM (nowL (unitM x) l∪m distlawLcM (unitM (y α))))) ∎ -- -- lemma-multlawLcM2-unitMcase : {A : Set} (κ : Cl) → ∀(x : (myLift (myLift A κ) κ)) → ∀ (N : Multiset (myLift (myLift A κ) κ)) → -- -- (MultL κ (mapL κ distlawLcM (distlawLcM (unitM x))) l∪m MultL κ (mapL κ distlawLcM (distlawLcM N))) -- -- ≡ MultL κ (mapL κ distlawLcM (distlawLcM (unitM x) l∪m distlawLcM N)) -- -- lemma-multlawLcM2 : {A : Set} (κ : Cl) → ∀(M N : Multiset (myLift (myLift A κ) κ)) → -- -- (MultL κ (mapL κ distlawLcM (distlawLcM M)) l∪m MultL κ (mapL κ distlawLcM (distlawLcM N))) -- -- ≡ MultL κ (mapL κ distlawLcM (distlawLcM M l∪m distlawLcM N)) -- -- lemma-multlawLcM2-unitMcase κ (nowL x) N = elimM -- -- (λ N → (((MultL κ (mapL κ distlawLcM (distlawLcM (unitM (nowL x)))) l∪m MultL κ (mapL κ distlawLcM (distlawLcM N))) -- -- ≡ (MultL κ (mapL κ distlawLcM (distlawLcM (unitM (nowL x)) l∪m distlawLcM N)))) , -- -- truncLcM (MultL κ (mapL κ distlawLcM (distlawLcM (unitM (nowL x)))) l∪m MultL κ (mapL κ distlawLcM (distlawLcM N))) -- -- (MultL κ (mapL κ distlawLcM (distlawLcM (unitM (nowL x)) l∪m distlawLcM N))) -- -- )) -- -- refl -- -- (λ y → lemma-multlawLcM2-unitMcase-unitMcase κ x y) -- -- (λ {M N} → λ eqM eqN → -- -- MultL κ (mapL κ distlawLcM (distlawLcM (unitM (nowL x)))) l∪m -- -- MultL κ (mapL κ distlawLcM (distlawLcM M l∪m distlawLcM N)) -- -- ≡⟨ cong (MultL κ (mapL κ distlawLcM (distlawLcM (unitM (nowL x)))) l∪m_) -- -- (sym (lemma-multlawLcM2 κ M N)) ⟩ -- -- (MultL κ (mapL κ distlawLcM (distlawLcM (unitM (nowL x)))) l∪m -- -- (MultL κ (mapL κ distlawLcM (distlawLcM M)) l∪m -- -- MultL κ (mapL κ distlawLcM (distlawLcM N)))) -- -- ≡⟨ sym (assoc-l∪m (MultL κ (mapL κ distlawLcM (distlawLcM (unitM (nowL x))))) -- -- (MultL κ (mapL κ distlawLcM (distlawLcM M))) -- -- (MultL κ (mapL κ distlawLcM (distlawLcM N)))) ⟩ -- -- ((MultL κ (mapL κ distlawLcM (distlawLcM (unitM (nowL x)))) l∪m -- -- MultL κ (mapL κ distlawLcM (distlawLcM M))) l∪m -- -- MultL κ (mapL κ distlawLcM (distlawLcM N))) -- -- ≡⟨ cong (_l∪m MultL κ (mapL κ distlawLcM (distlawLcM N))) -- -- (lemma-multlawLcM2-unitMcase κ (nowL x) M) ⟩ -- -- (MultL κ (mapL κ distlawLcM (nowL (unitM x) l∪m (distlawLcM M))) l∪m -- -- MultL κ (mapL κ distlawLcM (distlawLcM N))) -- -- ≡⟨ refl ⟩ -- -- (MultL κ (mapL κ distlawLcM (distlawLcM (unitM (nowL x)) l∪m (distlawLcM M))) l∪m -- -- MultL κ (mapL κ distlawLcM (distlawLcM N))) -- -- ≡⟨ refl ⟩ -- -- (MultL κ (mapL κ distlawLcM (distlawLcM (unitM (nowL x) ∪ₘ M))) l∪m -- -- MultL κ (mapL κ distlawLcM (distlawLcM N))) -- -- ≡⟨ lemma-multlawLcM2 κ (unitM (nowL x) ∪ₘ M) N ⟩ -- -- MultL κ (mapL κ distlawLcM ((distlawLcM (unitM (nowL x) ∪ₘ M)) l∪m distlawLcM N)) -- -- ≡⟨ refl ⟩ -- -- MultL κ (mapL κ distlawLcM ((nowL (unitM x) l∪m distlawLcM M) l∪m distlawLcM N)) -- -- ≡⟨ cong (MultL κ) (cong (mapL κ distlawLcM) -- -- (assoc-l∪m (nowL (unitM x)) (distlawLcM M) (distlawLcM N))) ⟩ -- -- MultL κ (mapL κ distlawLcM (nowL (unitM x) l∪m (distlawLcM M l∪m distlawLcM N))) ∎) -- -- N -- -- lemma-multlawLcM2-unitMcase κ (stepL x) N = cong stepL (later-ext λ α → lemma-multlawLcM2-unitMcase κ (x α) N) -- -- lemma-multlawLcM2 κ M N = elimM -- -- (λ M → ((MultL κ (mapL κ distlawLcM (distlawLcM M)) l∪m MultL κ (mapL κ distlawLcM (distlawLcM N))) -- -- ≡ MultL κ (mapL κ distlawLcM (distlawLcM M l∪m distlawLcM N))) , -- -- truncLcM (MultL κ (mapL κ distlawLcM (distlawLcM M)) l∪m MultL κ (mapL κ distlawLcM (distlawLcM N))) -- -- (MultL κ (mapL κ distlawLcM (distlawLcM M l∪m distlawLcM N))) ) -- -- (nowL m∅ l∪m MultL κ (mapL κ distlawLcM (distlawLcM N)) -- -- ≡⟨ comm-l∪m (nowL m∅) (MultL κ (mapL κ distlawLcM (distlawLcM N))) ⟩ -- -- (MultL κ (mapL κ distlawLcM (distlawLcM N)) l∪m nowL m∅) -- -- ≡⟨ unit-l∪m (MultL κ (mapL κ distlawLcM (distlawLcM N))) ⟩ -- -- MultL κ (mapL κ distlawLcM (distlawLcM N)) -- -- ≡⟨ cong (MultL κ) (cong (mapL κ distlawLcM) (sym (unit-l∪m (distlawLcM N)))) ⟩ -- -- MultL κ (mapL κ distlawLcM (distlawLcM N l∪m nowL m∅ )) -- -- ≡⟨ cong (MultL κ) (cong (mapL κ distlawLcM) (comm-l∪m (distlawLcM N) (nowL m∅))) ⟩ -- -- MultL κ (mapL κ distlawLcM (nowL m∅ l∪m distlawLcM N)) ∎ ) -- -- (λ x → lemma-multlawLcM2-unitMcase κ x N ) -- -- (λ {M₁ M₂} → λ eq1 eq2 → MultL κ (mapL κ distlawLcM (distlawLcM M₁ l∪m distlawLcM M₂)) l∪m -- -- MultL κ (mapL κ distlawLcM (distlawLcM N)) -- -- ≡⟨ cong (_l∪m MultL κ (mapL κ distlawLcM (distlawLcM N))) (sym (lemma-multlawLcM2 κ M₁ M₂)) ⟩ -- -- ((MultL κ (mapL κ distlawLcM (distlawLcM M₁))l∪m MultL κ (mapL κ distlawLcM (distlawLcM M₂))) l∪m -- -- MultL κ (mapL κ distlawLcM (distlawLcM N))) -- -- ≡⟨ assoc-l∪m (MultL κ (mapL κ distlawLcM (distlawLcM M₁))) -- -- (MultL κ (mapL κ distlawLcM (distlawLcM M₂))) -- -- (MultL κ (mapL κ distlawLcM (distlawLcM N))) ⟩ -- -- (MultL κ (mapL κ distlawLcM (distlawLcM M₁))l∪m (MultL κ (mapL κ distlawLcM (distlawLcM M₂)) l∪m -- -- MultL κ (mapL κ distlawLcM (distlawLcM N)))) -- -- ≡⟨ cong (MultL κ (mapL κ distlawLcM (distlawLcM M₁)) l∪m_) (lemma-multlawLcM2 κ M₂ N) ⟩ -- -- (MultL κ (mapL κ distlawLcM (distlawLcM M₁)) l∪m MultL κ (mapL κ distlawLcM (distlawLcM M₂ l∪m distlawLcM N)) ) -- -- ≡⟨ cong (MultL κ (mapL κ distlawLcM (distlawLcM M₁)) l∪m_) refl ⟩ -- -- (MultL κ (mapL κ distlawLcM (distlawLcM M₁)) l∪m MultL κ (mapL κ distlawLcM (distlawLcM (M₂ ∪ₘ N))) ) -- -- ≡⟨ lemma-multlawLcM2 κ M₁ ((M₂ ∪ₘ N)) ⟩ -- -- MultL κ (mapL κ distlawLcM (distlawLcM M₁ l∪m (distlawLcM M₂ l∪m distlawLcM N))) -- -- ≡⟨ cong (MultL κ) (cong (mapL κ distlawLcM) (sym (assoc-l∪m (distlawLcM M₁) (distlawLcM M₂) (distlawLcM N)))) ⟩ -- -- MultL κ (mapL κ distlawLcM ((distlawLcM M₁ l∪m distlawLcM M₂) l∪m distlawLcM N)) ∎) -- -- M -- -- -- lemma-lum : {A : Set} (κ : Cl) → ∀(M N : Multiset (myLift (myLift A κ) κ)) → -- (MultL κ (mapL κ distlawLcM (distlawLcM M)) l∪m MultL κ (mapL κ distlawLcM (distlawLcM N))) -- ≡ MultL κ (mapL κ distlawLcM (distlawLcM M l∪m distlawLcM N)) -- lemma-lum κ m∅ N = nowL m∅ l∪m MultL κ (mapL κ distlawLcM (distlawLcM N)) -- ≡⟨ comm-l∪m (nowL m∅) (MultL κ (mapL κ distlawLcM (distlawLcM N))) ⟩ -- (MultL κ (mapL κ distlawLcM (distlawLcM N)) l∪m nowL m∅) -- ≡⟨ unit-l∪m (MultL κ (mapL κ distlawLcM (distlawLcM N))) ⟩ -- MultL κ (mapL κ distlawLcM (distlawLcM N)) -- ≡⟨ cong (MultL κ) (cong (mapL κ distlawLcM) (sym (unit-l∪m (distlawLcM N)))) ⟩ -- MultL κ (mapL κ distlawLcM (distlawLcM N l∪m nowL m∅ )) -- ≡⟨ cong (MultL κ) (cong (mapL κ distlawLcM) (comm-l∪m (distlawLcM N) (nowL m∅))) ⟩ -- MultL κ (mapL κ distlawLcM (nowL m∅ l∪m distlawLcM N)) ∎ -- lemma-lum κ (unitM (nowL x)) m∅ = refl -- lemma-lum κ (unitM (nowL x)) (unitM (nowL y)) = refl -- lemma-lum κ (unitM (nowL x)) (unitM (stepL y)) = (distlawLcM (unitM x) l∪m -- stepL (λ α → MultL κ (mapL κ distlawLcM (distlawLcM (unitM (y α)))))) -- ≡⟨ comm-l∪m (distlawLcM (unitM x)) -- (stepL (λ α → MultL κ (mapL κ distlawLcM (distlawLcM (unitM (y α)))))) ⟩ -- (stepL (λ α → MultL κ (mapL κ distlawLcM (distlawLcM (unitM (y α))))) l∪m -- distlawLcM (unitM x)) -- ≡⟨ refl ⟩ -- stepL (λ α → (MultL κ (mapL κ distlawLcM (distlawLcM (unitM (y α)))) l∪m -- distlawLcM (unitM x))) -- ≡⟨ cong stepL (later-ext λ α → comm-l∪m (MultL κ (mapL κ distlawLcM (distlawLcM (unitM (y α))))) -- (distlawLcM (unitM x)) ) ⟩ -- stepL (λ α → (distlawLcM (unitM x) l∪m -- (MultL κ (mapL κ distlawLcM (distlawLcM (unitM (y α))))))) -- ≡⟨ refl ⟩ -- stepL (λ α → (MultL κ (mapL κ distlawLcM (distlawLcM (unitM (nowL x))))) l∪m -- (MultL κ (mapL κ distlawLcM (distlawLcM (unitM (y α)))))) -- ≡⟨ cong stepL (later-ext λ α → lemma-lum κ (unitM (nowL x)) (unitM (y α))) ⟩ -- stepL (λ α → MultL κ (mapL κ distlawLcM (nowL (unitM x) l∪m distlawLcM (unitM (y α))))) ∎ -- lemma-lum κ (unitM (nowL x)) (M ∪ₘ N) = MultL κ (mapL κ distlawLcM (distlawLcM (unitM (nowL x)))) l∪m -- MultL κ (mapL κ distlawLcM (distlawLcM M l∪m distlawLcM N)) -- ≡⟨ cong (MultL κ (mapL κ distlawLcM (distlawLcM (unitM (nowL x)))) l∪m_) -- (sym (lemma-lum κ M N)) ⟩ -- (MultL κ (mapL κ distlawLcM (distlawLcM (unitM (nowL x)))) l∪m -- (MultL κ (mapL κ distlawLcM (distlawLcM M)) l∪m -- MultL κ (mapL κ distlawLcM (distlawLcM N)))) -- ≡⟨ sym (assoc-l∪m (MultL κ (mapL κ distlawLcM (distlawLcM (unitM (nowL x))))) -- (MultL κ (mapL κ distlawLcM (distlawLcM M))) -- (MultL κ (mapL κ distlawLcM (distlawLcM N)))) ⟩ -- ((MultL κ (mapL κ distlawLcM (distlawLcM (unitM (nowL x)))) l∪m -- MultL κ (mapL κ distlawLcM (distlawLcM M))) l∪m -- MultL κ (mapL κ distlawLcM (distlawLcM N))) -- ≡⟨ cong (_l∪m MultL κ (mapL κ distlawLcM (distlawLcM N))) -- (lemma-lum κ (unitM (nowL x)) M) ⟩ -- (MultL κ (mapL κ distlawLcM (nowL (unitM x) l∪m (distlawLcM M))) l∪m -- MultL κ (mapL κ distlawLcM (distlawLcM N))) -- ≡⟨ refl ⟩ -- (MultL κ (mapL κ distlawLcM (distlawLcM (unitM (nowL x)) l∪m (distlawLcM M))) l∪m -- MultL κ (mapL κ distlawLcM (distlawLcM N))) -- ≡⟨ refl ⟩ -- (MultL κ (mapL κ distlawLcM (distlawLcM (unitM (nowL x) ∪ₘ M))) l∪m -- MultL κ (mapL κ distlawLcM (distlawLcM N))) -- ≡⟨ {!lemma-lum κ (unitM (nowL x) ∪ₘ M) N!} ⟩ -- MultL κ (mapL κ distlawLcM ((distlawLcM (unitM (nowL x) ∪ₘ M)) l∪m distlawLcM N)) -- ≡⟨ refl ⟩ -- MultL κ (mapL κ distlawLcM ((nowL (unitM x) l∪m distlawLcM M) l∪m distlawLcM N)) -- ≡⟨ cong (MultL κ) (cong (mapL κ distlawLcM) -- (assoc-l∪m (nowL (unitM x)) (distlawLcM M) (distlawLcM N))) ⟩ -- MultL κ (mapL κ distlawLcM (nowL (unitM x) l∪m (distlawLcM M l∪m distlawLcM N))) ∎ -- lemma-lum κ (unitM (nowL x)) (ass M N O i) = isProp→PathP {!!} {!!} {!!} {!!} -- lemma-lum κ (unitM (nowL x)) (com M N i) = {!!} -- lemma-lum κ (unitM (nowL x)) (unitr N i) = {!!} -- lemma-lum κ (unitM (nowL x)) (trunc M N y z i i₁) = {!!} -- lemma-lum κ (unitM (stepL x)) N = cong stepL (later-ext λ α → lemma-lum κ (unitM (x α)) N ) -- lemma-lum κ (M₁ ∪ₘ M₂) N = MultL κ (mapL κ distlawLcM (distlawLcM M₁ l∪m distlawLcM M₂)) l∪m -- MultL κ (mapL κ distlawLcM (distlawLcM N)) -- ≡⟨ cong (_l∪m MultL κ (mapL κ distlawLcM (distlawLcM N))) (sym (lemma-lum κ M₁ M₂)) ⟩ -- ((MultL κ (mapL κ distlawLcM (distlawLcM M₁))l∪m MultL κ (mapL κ distlawLcM (distlawLcM M₂))) l∪m -- MultL κ (mapL κ distlawLcM (distlawLcM N))) -- ≡⟨ assoc-l∪m (MultL κ (mapL κ distlawLcM (distlawLcM M₁))) -- (MultL κ (mapL κ distlawLcM (distlawLcM M₂))) -- (MultL κ (mapL κ distlawLcM (distlawLcM N))) ⟩ -- (MultL κ (mapL κ distlawLcM (distlawLcM M₁))l∪m (MultL κ (mapL κ distlawLcM (distlawLcM M₂)) l∪m -- MultL κ (mapL κ distlawLcM (distlawLcM N)))) -- ≡⟨ cong (MultL κ (mapL κ distlawLcM (distlawLcM M₁)) l∪m_) (lemma-lum κ M₂ N) ⟩ -- (MultL κ (mapL κ distlawLcM (distlawLcM M₁)) l∪m MultL κ (mapL κ distlawLcM (distlawLcM M₂ l∪m distlawLcM N)) ) -- ≡⟨ cong (MultL κ (mapL κ distlawLcM (distlawLcM M₁)) l∪m_) refl ⟩ -- (MultL κ (mapL κ distlawLcM (distlawLcM M₁)) l∪m MultL κ (mapL κ distlawLcM (distlawLcM (M₂ ∪ₘ N))) ) -- ≡⟨ lemma-lum κ M₁ ((M₂ ∪ₘ N)) ⟩ -- MultL κ (mapL κ distlawLcM (distlawLcM M₁ l∪m (distlawLcM M₂ l∪m distlawLcM N))) -- ≡⟨ cong (MultL κ) (cong (mapL κ distlawLcM) (sym (assoc-l∪m (distlawLcM M₁) (distlawLcM M₂) (distlawLcM N)))) ⟩ -- MultL κ (mapL κ distlawLcM ((distlawLcM M₁ l∪m distlawLcM M₂) l∪m distlawLcM N)) ∎ -- lemma-lum κ (ass M M₁ M₂ i) N = isProp→PathP (λ j → {!!}) (lemma-lum κ ((M ∪ₘ M₁) ∪ₘ M₂) N) (lemma-lum κ (M ∪ₘ (M₁ ∪ₘ M₂)) N) i -- lemma-lum κ (com M M₁ i) N = λ j → comm-l∪m {!!} {!!} i -- lemma-lum κ (unitr M i) N = λ j → {!!} -- lemma-lum κ (trunc M M₁ x y i i₁) N = {!!} -- --λ j → unitr (Multiset-unitlaw2 M j) i -- -- I don't know how to split cases within elimM, so here a lemma for the unitM case of elimM for multlawLcM2, split into nowL and stepL: -- multlawLcM2-unitMcase : {A : Set} {κ : Cl} → ∀(x : (myLift (myLift A κ) κ)) → -- distlawLcM (mapM (MultL κ) (unitM x)) ≡ MultL κ (mapL κ distlawLcM (distlawLcM (unitM x))) -- multlawLcM2-unitMcase (nowL x) = refl -- multlawLcM2-unitMcase (stepL x) = cong stepL (later-ext λ α → multlawLcM2-unitMcase (x α)) -- -- and here the full proof of the second multiplication law: -- multlawLcM2 : {A : Set} (κ : Cl) → ∀(M : Multiset (myLift (myLift A κ) κ)) → -- distlawLcM (mapM (MultL κ) M) ≡ MultL κ (mapL κ distlawLcM (distlawLcM M)) -- multlawLcM2 κ M = elimM -- (λ N → ((distlawLcM (mapM (MultL κ) N) ≡ MultL κ (mapL κ distlawLcM (distlawLcM N))) , -- truncLcM (distlawLcM (mapM (MultL κ) N)) (MultL κ (mapL κ distlawLcM (distlawLcM N))))) -- refl -- (λ x → multlawLcM2-unitMcase x ) -- (λ {M N} → λ eqM eqN → distlawLcM (mapM (MultL κ) M) l∪m distlawLcM (mapM (MultL κ) N) -- ≡⟨ cong₂ (_l∪m_) eqM eqN ⟩ -- (MultL κ (mapL κ distlawLcM (distlawLcM M)) l∪m MultL κ (mapL κ distlawLcM (distlawLcM N))) -- ≡⟨ lemma-lum κ M N ⟩ -- MultL κ (mapL κ distlawLcM (distlawLcM M l∪m distlawLcM N)) ∎) -- M
{ "alphanum_fraction": 0.4686859882, "avg_line_length": 72.0031380753, "ext": "agda", "hexsha": "8d9a8992cf881f7854a7b4ec2f60cf8a406d481c", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2022-01-13T15:22:51.000Z", "max_forks_repo_forks_event_min_datetime": "2022-01-13T15:22:51.000Z", "max_forks_repo_head_hexsha": "7859ab574c093f3bf0212ea685f405d1a2cee343", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "maaikezwart/Agda-proofs", "max_forks_repo_path": "combinations-of-lift-and-multiset.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "7859ab574c093f3bf0212ea685f405d1a2cee343", "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": "maaikezwart/Agda-proofs", "max_issues_repo_path": "combinations-of-lift-and-multiset.agda", "max_line_length": 180, "max_stars_count": null, "max_stars_repo_head_hexsha": "7859ab574c093f3bf0212ea685f405d1a2cee343", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "maaikezwart/Agda-proofs", "max_stars_repo_path": "combinations-of-lift-and-multiset.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 24039, "size": 68835 }
{-# OPTIONS --without-K --safe #-} open import Relation.Binary.Core module Magma.Definitions {a ℓ} {A : Set a} -- The underlying set (_≈_ : Rel A ℓ) -- The underlying equality where open import Algebra.Core open import Data.Product Alternativeˡ : Op₂ A → Set _ Alternativeˡ _∙_ = ∀ x y → ((x ∙ x) ∙ y) ≈ (x ∙ (y ∙ y)) Alternativeʳ : Op₂ A → Set _ Alternativeʳ _∙_ = ∀ x y → (x ∙ (y ∙ y)) ≈ ((x ∙ y) ∙ y) Alternative : Op₂ A → Set _ Alternative _∙_ = (Alternativeˡ _∙_ ) × ( Alternativeʳ _∙_) Flexible : Op₂ A → Set _ Flexible _∙_ = ∀ x y → ((x ∙ y) ∙ x) ≈ (x ∙ (y ∙ x)) Medial : Op₂ A → Set _ Medial _∙_ = ∀ x y u z → ((x ∙ y) ∙ (u ∙ z)) ≈ ((x ∙ u) ∙ (y ∙ z)) LeftSemimedial : Op₂ A → Set _ LeftSemimedial _∙_ = ∀ x y z → ((x ∙ x) ∙ (y ∙ z)) ≈ ((x ∙ y) ∙ (x ∙ z)) RightSemimedial : Op₂ A → Set _ RightSemimedial _∙_ = ∀ x y z → ((y ∙ z) ∙ (x ∙ x)) ≈ ((y ∙ x) ∙ (z ∙ x)) Semimedial : Op₂ A → Set _ Semimedial _∙_ = (LeftSemimedial _∙_) × (RightSemimedial _∙_)
{ "alphanum_fraction": 0.5508130081, "avg_line_length": 27.3333333333, "ext": "agda", "hexsha": "cbe32c4ec982b9fc110d1ff852861ac63600c976", "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": "443e831e536b756acbd1afd0d6bae7bc0d288048", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Akshobhya1234/agda-NonAssociativeAlgebra", "max_forks_repo_path": "src/Magma/Definitions.agda", "max_issues_count": 2, "max_issues_repo_head_hexsha": "443e831e536b756acbd1afd0d6bae7bc0d288048", "max_issues_repo_issues_event_max_datetime": "2021-10-09T08:24:56.000Z", "max_issues_repo_issues_event_min_datetime": "2021-10-04T05:30:30.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Akshobhya1234/agda-NonAssociativeAlgebra", "max_issues_repo_path": "src/Magma/Definitions.agda", "max_line_length": 73, "max_stars_count": 2, "max_stars_repo_head_hexsha": "443e831e536b756acbd1afd0d6bae7bc0d288048", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Akshobhya1234/agda-NonAssociativeAlgebra", "max_stars_repo_path": "src/Magma/Definitions.agda", "max_stars_repo_stars_event_max_datetime": "2021-08-17T09:14:03.000Z", "max_stars_repo_stars_event_min_datetime": "2021-08-15T06:16:13.000Z", "num_tokens": 431, "size": 984 }
module Luau.Type.FromJSON where open import Luau.Type using (Type; nil; _⇒_; _∪_; _∩_; any; number) open import Agda.Builtin.List using (List; _∷_; []) open import FFI.Data.Aeson using (Value; Array; Object; object; array; string; fromString; lookup) open import FFI.Data.Bool using (true; false) open import FFI.Data.Either using (Either; Left; Right) open import FFI.Data.Maybe using (Maybe; nothing; just) open import FFI.Data.String using (String; _++_) open import FFI.Data.Vector using (head; tail; null; empty) name = fromString "name" type = fromString "type" argTypes = fromString "argTypes" returnTypes = fromString "returnTypes" types = fromString "types" {-# TERMINATING #-} typeFromJSON : Value → Either String Type compoundFromArray : (Type → Type → Type) → Array → Either String Type typeFromJSON (object o) with lookup type o typeFromJSON (object o) | just (string "AstTypeFunction") with lookup argTypes o | lookup returnTypes o typeFromJSON (object o) | just (string "AstTypeFunction") | just (object argsSet) | just (object retsSet) with lookup types argsSet | lookup types retsSet typeFromJSON (object o) | just (string "AstTypeFunction") | just (object argsSet) | just (object retsSet) | just (array args) | just (array rets) with head args | head rets typeFromJSON (object o) | just (string "AstTypeFunction") | just (object argsSet) | just (object retsSet) | just (array args) | just (array rets) | just argValue | just retValue with typeFromJSON argValue | typeFromJSON retValue typeFromJSON (object o) | just (string "AstTypeFunction") | just (object argsSet) | just (object retsSet) | just (array args) | just (array rets) | just argValue | just retValue | Right arg | Right ret = Right (arg ⇒ ret) typeFromJSON (object o) | just (string "AstTypeFunction") | just (object argsSet) | just (object retsSet) | just (array args) | just (array rets) | just argValue | just retValue | Left err | _ = Left err typeFromJSON (object o) | just (string "AstTypeFunction") | just (object argsSet) | just (object retsSet) | just (array args) | just (array rets) | just argValue | just retValue | _ | Left err = Left err typeFromJSON (object o) | just (string "AstTypeFunction") | just (object argsSet) | just (object retsSet) | just (array args) | just (array rets) | _ | nothing = Left "No return type" typeFromJSON (object o) | just (string "AstTypeFunction") | just (object argsSet) | just (object retsSet) | just (array args) | just (array rets) | nothing | _ = Left "No argument type" typeFromJSON (object o) | just (string "AstTypeFunction") | just (object argsSet) | just (object retsSet) | just _ | _ = Left "argTypes.types is not an array" typeFromJSON (object o) | just (string "AstTypeFunction") | just (object argsSet) | just (object retsSet) | _ | just _ = Left "retTypes.types is not an array" typeFromJSON (object o) | just (string "AstTypeFunction") | just (object argsSet) | just (object retsSet) | nothing | _ = Left "argTypes.types does not exist" typeFromJSON (object o) | just (string "AstTypeFunction") | _ | just _ = Left "argTypes is not an object" typeFromJSON (object o) | just (string "AstTypeFunction") | just _ | _ = Left "returnTypes is not an object" typeFromJSON (object o) | just (string "AstTypeFunction") | nothing | nothing = Left "Missing argTypes and returnTypes" typeFromJSON (object o) | just (string "AstTypeReference") with lookup name o typeFromJSON (object o) | just (string "AstTypeReference") | just (string "nil") = Right nil typeFromJSON (object o) | just (string "AstTypeReference") | just (string "any") = Right any typeFromJSON (object o) | just (string "AstTypeReference") | just (string "number") = Right number typeFromJSON (object o) | just (string "AstTypeReference") | _ = Left "Unknown referenced type" typeFromJSON (object o) | just (string "AstTypeUnion") with lookup types o typeFromJSON (object o) | just (string "AstTypeUnion") | just (array types) = compoundFromArray _∪_ types typeFromJSON (object o) | just (string "AstTypeUnion") | _ = Left "`types` field must be an array" typeFromJSON (object o) | just (string "AstTypeIntersection") with lookup types o typeFromJSON (object o) | just (string "AstTypeIntersection") | just (array types) = compoundFromArray _∩_ types typeFromJSON (object o) | just (string "AstTypeIntersection") | _ = Left "`types` field must be an array" typeFromJSON (object o) | just (string ty) = Left ("Unsupported type " ++ ty) typeFromJSON (object o) | just _ = Left "`type` field must be a string" typeFromJSON (object o) | nothing = Left "No `type` field" typeFromJSON _ = Left "Unsupported JSON type" compoundFromArray ctor ts with head ts | tail ts compoundFromArray ctor ts | just hd | tl with null tl compoundFromArray ctor ts | just hd | tl | true = typeFromJSON hd compoundFromArray ctor ts | just hd | tl | false with typeFromJSON hd | compoundFromArray ctor tl compoundFromArray ctor ts | just hd | tl | false | Right hdTy | Right tlTy = Right (ctor hdTy tlTy) compoundFromArray ctor ts | just hd | tl | false | Left err | _ = Left err compoundFromArray ctor ts | just hd | tl | false | _ | Left Err = Left Err compoundFromArray ctor ts | nothing | empty = Left "Empty types array?"
{ "alphanum_fraction": 0.726487524, "avg_line_length": 76.6176470588, "ext": "agda", "hexsha": "c585c3f3719dd8ee046345859cece21b5bffda30", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "cd18adc20ecb805b8eeb770a9e5ef8e0cd123734", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Tr4shh/Roblox-Luau", "max_forks_repo_path": "prototyping/Luau/Type/FromJSON.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "cd18adc20ecb805b8eeb770a9e5ef8e0cd123734", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Tr4shh/Roblox-Luau", "max_issues_repo_path": "prototyping/Luau/Type/FromJSON.agda", "max_line_length": 228, "max_stars_count": null, "max_stars_repo_head_hexsha": "cd18adc20ecb805b8eeb770a9e5ef8e0cd123734", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Tr4shh/Roblox-Luau", "max_stars_repo_path": "prototyping/Luau/Type/FromJSON.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1452, "size": 5210 }
-- Andreas, 2015-05-06 issue reported by Jesper Cockx {-# OPTIONS --copatterns #-} record Foo (A : Set) : Set where field foo : A open Foo {{...}} public record ⊤ : Set where instance Foo⊤ : Foo ⊤ foo Foo⊤ = {!!} -- foo {{Foo⊤}} = {!!} -- Error WAS: -- An internal error has occurred. Please report this as a bug. -- Location of the error: src/full/Agda/TypeChecking/Rules/LHS/Split.hs:103 -- Better error: -- Not a valid projection for a copattern: foo -- when checking that the clause foo Foo⊤ = ? has type Foo ⊤
{ "alphanum_fraction": 0.6423220974, "avg_line_length": 21.36, "ext": "agda", "hexsha": "05a79558cb9fcda0b74adf1a03ecd1db4c440499", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "redfish64/autonomic-agda", "max_forks_repo_path": "test/Fail/Issue1413.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "redfish64/autonomic-agda", "max_issues_repo_path": "test/Fail/Issue1413.agda", "max_line_length": 75, "max_stars_count": null, "max_stars_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "redfish64/autonomic-agda", "max_stars_repo_path": "test/Fail/Issue1413.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 168, "size": 534 }
{-# OPTIONS --safe #-} module Cubical.Data.Vec.DepVec where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Equiv open import Cubical.Foundations.Isomorphism import Cubical.Data.Empty as ⊥ open import Cubical.Data.Unit open import Cubical.Data.Nat open import Cubical.Data.Sigma open import Cubical.Data.Vec open import Cubical.Relation.Nullary open Iso private variable ℓ : Level data depVec (G : (n : ℕ) → Type ℓ) : ℕ → Type ℓ where ⋆ : depVec G 0 _□_ : {n : ℕ} → (a : G n) → (v : depVec G n) → depVec G (suc n) module depVecPath (G : (n : ℕ) → Type ℓ) where code : {n : ℕ} → (v v' : depVec G n) → Type ℓ code ⋆ ⋆ = Unit* code (a □ v) (a' □ v') = (a ≡ a') × (v ≡ v') -- encode reflEncode : {n : ℕ} → (v : depVec G n) → code v v reflEncode ⋆ = tt* reflEncode (a □ v) = refl , refl encode : {n : ℕ} → (v v' : depVec G n) → (v ≡ v') → code v v' encode v v' p = J (λ v' _ → code v v') (reflEncode v) p encodeRefl : {n : ℕ} → (v : depVec G n) → encode v v refl ≡ reflEncode v encodeRefl v = JRefl (λ v' _ → code v v') (reflEncode v) -- decode decode : {n : ℕ} → (v v' : depVec G n) → (r : code v v') → (v ≡ v') decode ⋆ ⋆ _ = refl decode (a □ v) (a' □ v') (p , q) = cong₂ _□_ p q decodeRefl : {n : ℕ} → (v : depVec G n) → decode v v (reflEncode v) ≡ refl decodeRefl ⋆ = refl decodeRefl (a □ v) = refl -- equiv ≡Vec≃codeVec : {n : ℕ} → (v v' : depVec G n) → (v ≡ v') ≃ (code v v') ≡Vec≃codeVec v v' = isoToEquiv is where is : Iso (v ≡ v') (code v v') fun is = encode v v' inv is = decode v v' rightInv is = sect v v' where sect : {n : ℕ} → (v v' : depVec G n) → (r : code v v') → encode v v' (decode v v' r) ≡ r sect ⋆ ⋆ tt* = encodeRefl ⋆ sect (a □ v) (a' □ v') (p , q) = J (λ a' p → encode (a □ v) (a' □ v') (decode (a □ v) (a' □ v') (p , q)) ≡ (p , q)) (J (λ v' q → encode (a □ v) (a □ v') (decode (a □ v) (a □ v') (refl , q)) ≡ (refl , q)) (encodeRefl (a □ v)) q) p leftInv is = retr v v' where retr : {n : ℕ} → (v v' : depVec G n) → (p : v ≡ v') → decode v v' (encode v v' p) ≡ p retr v v' p = J (λ v' p → decode v v' (encode v v' p) ≡ p) (cong (decode v v) (encodeRefl v) ∙ decodeRefl v) p
{ "alphanum_fraction": 0.5027345393, "avg_line_length": 31.6933333333, "ext": "agda", "hexsha": "9e507180e7ea3c320d1679dc6a909280f304b154", "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/Data/Vec/DepVec.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/Data/Vec/DepVec.agda", "max_line_length": 126, "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/Data/Vec/DepVec.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 976, "size": 2377 }
{-# OPTIONS --allow-unsolved-metas #-} -- {-# OPTIONS -v tc.record.eta:20 -v tc.eta:100 -v tc.constr:50 #-} -- Andreas, 2013-05-15 reported by nomeata module Issue846 where open import Issue846.Imports opt-is-opt2 : ∀ n s → n mod 7 ≡ 1' → winner n s opt ≡ false opt-is-opt2 0 s () opt-is-opt2 (suc n) s eq = let (pick k 1≤k k≤6) = s (suc n) in cong not (opt-is-opt (suc n ∸ k) s (lem-sub-p n k eq {!1≤k!} {!!} )) -- The problem here was that the first hole was solved by -- 'nonEmpty' by the instance finder, -- which is called since the first hole is an unused argument. -- 'nonEmpty' of course does not fit, but the instance finder -- did not see it and produced constraints. -- The eta-contractor broke on something ill-typed. -- Now, the instance finder is a bit smarter due to -- improved equality checking for dependent function types. -- Unequal domains now do not block comparison of -- codomains, only block the domain type.
{ "alphanum_fraction": 0.6849315068, "avg_line_length": 33.8928571429, "ext": "agda", "hexsha": "a35bb1eeef845a0c690cabeebf682eeb8c21deb6", "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/LibSucceed/Issue846.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/LibSucceed/Issue846.agda", "max_line_length": 72, "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/LibSucceed/Issue846.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": 287, "size": 949 }
module DecidableOrder where open import Logic.Relations open import Logic.Identity using (_≡_) open module Antisym = PolyEq _≡_ using (Antisymmetric) record DecidableOrder (A : Set) : Set1 where field _≤_ : Rel A refl : Reflexive _≤_ antisym : Antisymmetric _≤_ trans : Transitive _≤_ total : Total _≤_ decide : forall x y -> Decidable (x ≤ y) infix 80 _≤_ _≥_ _≥_ = \(x y : A) -> y ≤ x
{ "alphanum_fraction": 0.633640553, "avg_line_length": 21.7, "ext": "agda", "hexsha": "6710b704fb102be30e4787387e9800cfab5f1801", "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/order/DecidableOrder.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/order/DecidableOrder.agda", "max_line_length": 54, "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/order/DecidableOrder.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": 151, "size": 434 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Properties, related to products, that rely on the K rule ------------------------------------------------------------------------ {-# OPTIONS --with-K --safe #-} module Data.Product.Properties.WithK where open import Data.Bool.Base open import Data.Product open import Data.Product.Properties using (,-injectiveˡ) open import Function open import Relation.Binary using (Decidable) open import Relation.Binary.PropositionalEquality open import Relation.Nullary.Reflects open import Relation.Nullary using (Dec; _because_; yes; no) open import Relation.Nullary.Decidable using (map′) ------------------------------------------------------------------------ -- Equality module _ {a b} {A : Set a} {B : Set b} where ,-injective : ∀ {a c : A} {b d : B} → (a , b) ≡ (c , d) → a ≡ c × b ≡ d ,-injective refl = refl , refl module _ {a b} {A : Set a} {B : A → Set b} where ,-injectiveʳ : ∀ {a} {b c : B a} → (Σ A B ∋ (a , b)) ≡ (a , c) → b ≡ c ,-injectiveʳ refl = refl -- Note: this is not an instance of `_×-dec_`, because we need `x` and `y` -- to have the same type before we can test them for equality. ≡-dec : Decidable _≡_ → (∀ {a} → Decidable {A = B a} _≡_) → Decidable {A = Σ A B} _≡_ ≡-dec dec₁ dec₂ (a , x) (b , y) with dec₁ a b ... | false because [a≢b] = no (invert [a≢b] ∘ ,-injectiveˡ) ... | yes refl = map′ (cong (a ,_)) ,-injectiveʳ (dec₂ x y)
{ "alphanum_fraction": 0.5373831776, "avg_line_length": 36.5365853659, "ext": "agda", "hexsha": "0b4d117d685182d62c12f31b02d1603938b14df1", "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/Product/Properties/WithK.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/Product/Properties/WithK.agda", "max_line_length": 76, "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/Product/Properties/WithK.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": 448, "size": 1498 }
-- Andreas, 2022-06-14, issue #5953 reported by Szumi Xi -- Cubical Agda switches dot-pattern termination off (#4606). -- However, this breaks also some benign cases. -- -- In this example with inductive-inductive types, -- dotted variables should still be recognized -- as variable patterns for termination certification. {-# OPTIONS --cubical #-} -- worked with --without-K but not --cubical -- Debugging: -- {-# OPTIONS -v term.check.clause:25 #-} -- {-# OPTIONS -v term:20 #-} data Con : Set data Ty : Con → Set data Con where nil : Con ext : (Γ : Con) → Ty Γ → Con data Ty where univ : (Γ : Con) → Ty Γ pi : (Γ : Con) (A : Ty Γ) → Ty (ext Γ A) → Ty Γ module _ (A : Set) (B : A → Set) (n : A) (e : (a : A) → B a → A) (u : (a : A) → B a) (p : (a : A) (b : B a) → B (e a b) → B a) where recCon : Con → A recTy : (Γ : Con) → Ty Γ → B (recCon Γ) recCon nil = n recCon (ext Γ A) = e (recCon Γ) (recTy Γ A) recTy Γ (univ Γ) = u (recCon Γ) recTy Γ (pi Γ A B) = p (recCon Γ) (recTy Γ A) (recTy (ext Γ A) B) -- Should pass the termination checker.
{ "alphanum_fraction": 0.5832566697, "avg_line_length": 24.7045454545, "ext": "agda", "hexsha": "ded35b8e86eb6e0170fcfd892b3d81970c3f7ef1", "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/Issue5953.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/Succeed/Issue5953.agda", "max_line_length": 71, "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/Issue5953.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 393, "size": 1087 }
open import Nat open import Prelude open import dynamics-core open import contexts module htype-decidable where arr-lemma : ∀{t1 t2 t3 t4} → t1 ==> t2 == t3 ==> t4 → t1 == t3 × t2 == t4 arr-lemma refl = refl , refl sum-lemma : ∀{t1 t2 t3 t4} → t1 ⊕ t2 == t3 ⊕ t4 → t1 == t3 × t2 == t4 sum-lemma refl = refl , refl prod-lemma : ∀{t1 t2 t3 t4} → t1 ⊠ t2 == t3 ⊠ t4 → t1 == t3 × t2 == t4 prod-lemma refl = refl , refl htype-dec : (t1 t2 : htyp) → t1 == t2 + (t1 == t2 → ⊥) htype-dec num num = Inl refl htype-dec num ⦇-⦈ = Inr (λ ()) htype-dec num (t1 ==> t2) = Inr (λ ()) htype-dec num (t1 ⊕ t2) = Inr (λ ()) htype-dec ⦇-⦈ num = Inr (λ ()) htype-dec ⦇-⦈ ⦇-⦈ = Inl refl htype-dec ⦇-⦈ (t1 ==> t2) = Inr (λ ()) htype-dec ⦇-⦈ (t1 ⊕ t2) = Inr (λ ()) htype-dec (t1 ==> t2) num = Inr (λ ()) htype-dec (t1 ==> t2) ⦇-⦈ = Inr (λ ()) htype-dec (t1 ==> t2) (t3 ==> t4) with htype-dec t1 t3 | htype-dec t2 t4 ... | Inl refl | Inl refl = Inl refl ... | Inl refl | Inr x₁ = Inr (λ x → x₁ (π2 (arr-lemma x))) ... | Inr x | Inl refl = Inr (λ x₁ → x (π1 (arr-lemma x₁))) ... | Inr x | Inr x₁ = Inr (λ x₂ → x (π1 (arr-lemma x₂))) htype-dec (t1 ==> t2) (t3 ⊕ t4) = Inr (λ ()) htype-dec (t1 ⊕ t2) num = Inr (λ ()) htype-dec (t1 ⊕ t2) ⦇-⦈ = Inr (λ ()) htype-dec (t1 ⊕ t2) (t3 ==> t4) = Inr (λ ()) htype-dec (t1 ⊕ t2) (t3 ⊕ t4) with htype-dec t1 t3 | htype-dec t2 t4 ... | Inl refl | Inl refl = Inl refl ... | Inl refl | Inr x₁ = Inr (λ x → x₁ (π2 (sum-lemma x))) ... | Inr x | Inl refl = Inr (λ x₁ → x (π1 (sum-lemma x₁))) ... | Inr x | Inr x₁ = Inr (λ x₂ → x (π1 (sum-lemma x₂))) htype-dec num (t3 ⊠ t4) = Inr (λ ()) htype-dec ⦇-⦈ (t3 ⊠ t4) = Inr (λ ()) htype-dec (t1 ==> t2) (t3 ⊠ t4) = Inr (λ ()) htype-dec (t1 ⊕ t2) (t3 ⊠ t4) = Inr (λ ()) htype-dec (t1 ⊠ t2) num = Inr (λ ()) htype-dec (t1 ⊠ t2) ⦇-⦈ = Inr (λ ()) htype-dec (t1 ⊠ t2) (t3 ==> t4) = Inr (λ ()) htype-dec (t1 ⊠ t2) (t3 ⊕ t4) = Inr (λ ()) htype-dec (t1 ⊠ t2) (t3 ⊠ t4) with htype-dec t1 t3 | htype-dec t2 t4 ... | Inl refl | Inl refl = Inl refl ... | Inl refl | Inr x₁ = Inr (λ x → x₁ (π2 (prod-lemma x))) ... | Inr x | Inl refl = Inr (λ x₁ → x (π1 (prod-lemma x₁))) ... | Inr x | Inr x₁ = Inr (λ x₂ → x (π1 (prod-lemma x₂)))
{ "alphanum_fraction": 0.4924078091, "avg_line_length": 40.4385964912, "ext": "agda", "hexsha": "29fcc758cfa468078601af31b98873fef1e934fe", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "a3640d7b0f76cdac193afd382694197729ed6d57", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "hazelgrove/hazelnut-agda", "max_forks_repo_path": "htype-decidable.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "a3640d7b0f76cdac193afd382694197729ed6d57", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "hazelgrove/hazelnut-agda", "max_issues_repo_path": "htype-decidable.agda", "max_line_length": 75, "max_stars_count": null, "max_stars_repo_head_hexsha": "a3640d7b0f76cdac193afd382694197729ed6d57", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "hazelgrove/hazelnut-agda", "max_stars_repo_path": "htype-decidable.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1160, "size": 2305 }
module Sets.PredicateSet.Filter {ℓₒ} {ℓₒₗ} where import Lvl open import Functional open import Logic.Propositional -- open import Sets.PredicateSet open import Type{ℓₒ Lvl.⊔ ℓₒₗ} -- An element in Filter(T) is in the subset of T. -- Something of type Filter(T) is of a restricted part of T. -- Note: The level of Stmt inside P is lower than Type. -- TODO: Is this the same as (⊤ ∩ P) in "Sets.PredicateSet"? record Filter {T : Type} (P : T → Stmt{ℓₒₗ}) : Type where constructor subelem field elem : T ⦃ satisfaction ⦄ : P(elem) -- postulate nested-subset : ∀{T}{φ₁}{φ₂} → (Tₛ₁ : Filter{T}(φ₁)) → (Tₛ₂ : Filter{Filter{T}(φ₁)}(φ₂)) → Filter{T}(x ↦ φ₁(x) ∧ φ₂(subelem (x) ⦃ ⦄)) -- postulate nested-subset : ∀{T}{φ₁}{φ₂} → (Tₛ₁ : Filter{T}(φ₁)) → (Tₛ₂ : Filter{Filter{T}(φ₁)}(φ₂ ∘ Filter.elem)) → Filter{T}(x ↦ φ₁(x) ∧ φ₂(x)) -- postulate nested-subset : ∀{T}{φ₁}{φ₂} → (Filter{Filter{T}(φ₁)}(φ₂ ∘ Filter.elem) ≡ Filter{T}(x ↦ φ₁(x) ∧ φ₂(x)))
{ "alphanum_fraction": 0.6251287333, "avg_line_length": 42.2173913043, "ext": "agda", "hexsha": "9481a0944bea2b6788a8034fa710acdff1aa4b0e", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_path": "old/Sets/PredicateSet/Filter.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_path": "old/Sets/PredicateSet/Filter.agda", "max_line_length": 146, "max_stars_count": 6, "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_path": "old/Sets/PredicateSet/Filter.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": 379, "size": 971 }
------------------------------------------------------------------------ -- "Equational" reasoning combinator setup ------------------------------------------------------------------------ {-# OPTIONS --sized-types #-} open import Labelled-transition-system module Bisimilarity.Weak.Alternative.Equational-reasoning-instances {ℓ} {lts : LTS ℓ} where open import Prelude open import Bisimilarity lts import Bisimilarity.Equational-reasoning-instances open import Bisimilarity.Weak.Alternative lts open import Equational-reasoning instance trans∼≈ : ∀ {i} → Transitive _∼_ [ i ]_≈_ trans∼≈ = is-transitive (transitive {a = ℓ} ∘ ∼⇒≈) trans∼′≈ : ∀ {i} → Transitive _∼′_ [ i ]_≈_ trans∼′≈ = is-transitive (transitive {a = ℓ} ∘ ∼⇒≈″) trans∼′≈′ : ∀ {i} → Transitive _∼′_ [ i ]_≈′_ trans∼′≈′ = is-transitive (transitive {a = ℓ} ∘ ∼⇒≈″) trans∼≈′ : ∀ {i} → Transitive _∼_ [ i ]_≈′_ trans∼≈′ {i} = is-transitive (transitive {a = ℓ} ∘ ∼⇒≈ {i}) convert∼≈ : Convertible _∼_ _≈_ convert∼≈ = is-convertible ∼⇒≈ convert∼′≈ : Convertible _∼′_ _≈_ convert∼′≈ = is-convertible (convert {a = ℓ} ∘ ∼⇒≈″) convert∼≈′ : Convertible _∼_ _≈′_ convert∼≈′ = is-convertible ∼⇒≈′ convert∼′≈′ : Convertible _∼′_ _≈′_ convert∼′≈′ = is-convertible ∼⇒≈″ open Bisimilarity.Equational-reasoning-instances {lts = weak lts} public
{ "alphanum_fraction": 0.563099631, "avg_line_length": 28.829787234, "ext": "agda", "hexsha": "093a455f868b27d393d2825f6db7de2a5aa9fa37", "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/Equational-reasoning-instances.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/Equational-reasoning-instances.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/Equational-reasoning-instances.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 537, "size": 1355 }
module monad where open import eq open import functor open import functions record Triple (T : Set → Set) : Set₁ where constructor MkTriple field η : ∀{A : Set} → A → T A μ : ∀{A : Set} → T (T A) → T A η-inv : ∀{A : Set} → T A → A -- triple-func : Functor T -- triple-assoc : ∀{A : Set} → μ {A} ∘ (fmap triple-func μ) ≡ (μ ∘ μ) -- triple-id₁ : ∀{A : Set} → μ ∘ η {T A} ≡ id -- triple-id₂ : ∀{A : Set} → (μ {A} ∘ fmap triple-func (η {A})) ≡ id record Monad (M : Set → Set) : Set₁ where constructor MkMonad field return : ∀{A : Set} → A → M A bind : ∀{A B : Set} → M A → (A → M B) → M B -- monad-funct : Functor M -- monad-left-id : ∀{A B : Set}{a : A}{f : A → M B} -- → bind (return a) f ≡ f a -- monad-right-id : ∀{A : Set}{c : M A} -- → bind c return ≡ c -- monad-assoc : ∀{A B C : Set}{c : M A}{f : A → M B}{g : B → M C} -- → bind (bind c f) g ≡ bind c (λ a → bind (f a) g)
{ "alphanum_fraction": 0.4759467758, "avg_line_length": 27.1388888889, "ext": "agda", "hexsha": "447ac82803c439fcb97555896df247b671bc76c5", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "b33c6a59d664aed46cac8ef77d34313e148fecc2", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "heades/AUGL", "max_forks_repo_path": "monad.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "b33c6a59d664aed46cac8ef77d34313e148fecc2", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "heades/AUGL", "max_issues_repo_path": "monad.agda", "max_line_length": 73, "max_stars_count": null, "max_stars_repo_head_hexsha": "b33c6a59d664aed46cac8ef77d34313e148fecc2", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "heades/AUGL", "max_stars_repo_path": "monad.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 394, "size": 977 }
open import Relation.Binary.PropositionalEquality using ( _≡_ ; refl ; sym ; trans ; cong ) open import AssocFree.DList using ( List ) open import AssocFree.DNat using ( ℕ ) module AssocFree.STLambdaC.Typ (TConst : Set) where infixr 2 _⇝_ data Typ : Set where const : TConst → Typ _⇝_ : Typ → Typ → Typ Var : Set Var = ℕ Ctxt : Set Ctxt = List Typ open AssocFree.DList public using ( [] ; [_] ; _++_ ; _∷_ ; _∈_ ; _≪_ ; _≫_ ; _⋙_ ; uniq ; singleton ; Case ; case ; inj₁ ; inj₂ ; inj₃ ; case-≪ ; case-≫ ; case-⋙ ; Case₃ ; case₃ ; caseˡ ; caseʳ ; caseˡ₃ ; caseʳ₃ ; case⁻¹ ; case-iso )
{ "alphanum_fraction": 0.6295681063, "avg_line_length": 25.0833333333, "ext": "agda", "hexsha": "c8326fdd6663db66f1101060d2c7ead5bdabe2da", "lang": "Agda", "max_forks_count": 2, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:38:44.000Z", "max_forks_repo_forks_event_min_datetime": "2018-03-03T04:39:31.000Z", "max_forks_repo_head_hexsha": "08337fdb8375137a52cc9b3ade766305191b2394", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "agda/agda-assoc-free", "max_forks_repo_path": "src/AssocFree/STLambdaC/Typ.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "08337fdb8375137a52cc9b3ade766305191b2394", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "agda/agda-assoc-free", "max_issues_repo_path": "src/AssocFree/STLambdaC/Typ.agda", "max_line_length": 91, "max_stars_count": 3, "max_stars_repo_head_hexsha": "08337fdb8375137a52cc9b3ade766305191b2394", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "agda/agda-assoc-free", "max_stars_repo_path": "src/AssocFree/STLambdaC/Typ.agda", "max_stars_repo_stars_event_max_datetime": "2020-08-27T20:56:20.000Z", "max_stars_repo_stars_event_min_datetime": "2016-11-22T11:48:31.000Z", "num_tokens": 235, "size": 602 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Some derivable properties ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} open import Algebra module Algebra.Properties.Semilattice {l₁ l₂} (L : Semilattice l₁ l₂) where open Semilattice L open import Algebra.Structures open import Relation.Binary import Relation.Binary.Construct.NaturalOrder.Left as LeftNaturalOrder import Relation.Binary.Lattice as R import Relation.Binary.Properties.Poset as R open import Relation.Binary.EqReasoning setoid open import Function open import Data.Product ------------------------------------------------------------------------ -- Every semilattice can be turned into a poset via the left natural -- order. poset : Poset _ _ _ poset = LeftNaturalOrder.poset _≈_ _∧_ isSemilattice open Poset poset using (_≤_; isPartialOrder) ------------------------------------------------------------------------ -- Every algebraic semilattice can be turned into an order-theoretic one. isOrderTheoreticMeetSemilattice : R.IsMeetSemilattice _≈_ _≤_ _∧_ isOrderTheoreticMeetSemilattice = record { isPartialOrder = isPartialOrder ; infimum = LeftNaturalOrder.infimum _≈_ _∧_ isSemilattice } orderTheoreticMeetSemilattice : R.MeetSemilattice _ _ _ orderTheoreticMeetSemilattice = record { isMeetSemilattice = isOrderTheoreticMeetSemilattice } isOrderTheoreticJoinSemilattice : R.IsJoinSemilattice _≈_ (flip _≤_) _∧_ isOrderTheoreticJoinSemilattice = record { isPartialOrder = R.invIsPartialOrder poset ; supremum = R.IsMeetSemilattice.infimum isOrderTheoreticMeetSemilattice } orderTheoreticJoinSemilattice : R.JoinSemilattice _ _ _ orderTheoreticJoinSemilattice = record { isJoinSemilattice = isOrderTheoreticJoinSemilattice }
{ "alphanum_fraction": 0.6664893617, "avg_line_length": 34.1818181818, "ext": "agda", "hexsha": "b7e29a0ecf8421123df7d15ba5cf810e3ffb3c01", "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/Properties/Semilattice.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/Properties/Semilattice.agda", "max_line_length": 75, "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/Properties/Semilattice.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 462, "size": 1880 }
module lambdasyntax where open import Data.Nat using (ℕ) open import Data.Bool using (Bool; true; false) open import Data.Vec using (Vec; []; lookup) open import Relation.Nullary open import Data.Empty hiding (⊥) open import Relation.Binary.PropositionalEquality data Label : Set where ⊤ ⊥ ✭ : Label data GType : Set where bool : Label → GType _⇒_ : GType → Label → GType → GType err : GType infixr 4 _∙_ infixl 6 _∨_ _∧_ data Term : Set where var : ℕ → Term litBool : Bool → Label → Term lam : GType → Term → Label → Term _∧_ : Term → Term → Term _∨_ : Term → Term → Term _∙_ : Term → Term → Term if_then_else_ : Term → Term → Term → Term error : Term Ctx : ℕ → Set Ctx = Vec GType getLabel : GType → Label getLabel (bool ℓ) = ℓ getLabel ((g ⇒ ℓ) g₁) = ℓ getLabel err = ✭ -- lazy propagation setLabel : GType → Label → GType setLabel (bool _) ℓ = bool ℓ setLabel ((t ⇒ x) t₁) ℓ = (t ⇒ ℓ) t₁ setLabel err _ = err -- gradual join _~⋎~_ : (ℓ₁ ℓ₂ : Label) → Label ⊤ ~⋎~ ⊤ = ⊤ ⊤ ~⋎~ ⊥ = ⊤ ⊤ ~⋎~ ✭ = ⊤ ⊥ ~⋎~ ⊤ = ⊤ ⊥ ~⋎~ ⊥ = ⊥ ⊥ ~⋎~ ✭ = ✭ ✭ ~⋎~ ⊤ = ⊤ ✭ ~⋎~ ⊥ = ✭ ✭ ~⋎~ ✭ = ✭ -- gradual meet _~⋏~_ : ∀ (ℓ₁ ℓ₂ : Label) → Label ⊥ ~⋏~ ✭ = ⊥ ✭ ~⋏~ ⊥ = ⊥ ℓ₁ ~⋏~ ✭ = ✭ ✭ ~⋏~ ℓ₂ = ✭ ⊤ ~⋏~ ⊤ = ⊤ ⊤ ~⋏~ ⊥ = ⊥ ⊥ ~⋏~ ⊤ = ⊥ ⊥ ~⋏~ ⊥ = ⊥ _:∧:_ : ∀ (t₁ t₂ : GType) → GType _:∨:_ : ∀ (t₁ t₂ : GType) → GType bool ℓ₁ :∧: bool ℓ₂ = bool (ℓ₁ ~⋏~ ℓ₂) (s₁₁ ⇒ ℓ₁) s₁₂ :∧: (s₂₁ ⇒ ℓ₂) s₂₂ = ((s₁₁ :∨: s₂₁) ⇒ (ℓ₁ ~⋏~ ℓ₂)) (s₁₂ :∧: s₂₂) _ :∧: _ = err -- _:∨:_ : ∀ (t₁ t₂ : gtype) → gtype bool ℓ₁ :∨: bool ℓ₂ = bool (ℓ₁ ~⋎~ ℓ₂) (s₁₁ ⇒ ℓ₁) s₁₂ :∨: (s₂₁ ⇒ ℓ₂) s₂₂ = ((s₁₁ :∧: s₂₁) ⇒ (ℓ₁ ~⋎~ ℓ₂)) (s₁₂ :∨: s₂₂) _ :∨: _ = err data _≤_ : Label → Label → Set where ⊥≤⊤ : ⊥ ≤ ⊤ ⊤≤⊤ : ⊤ ≤ ⊤ ⊥≤⊥ : ⊥ ≤ ⊥ ℓ≤✭ : ∀ {ℓ} → ℓ ≤ ✭ ✭≤ℓ : ∀ {ℓ} → ✭ ≤ ℓ _≤?_ : (ℓ₁ ℓ₂ : Label) → Dec (ℓ₁ ≤ ℓ₂) ⊤ ≤? ⊤ = yes ⊤≤⊤ ⊤ ≤? ⊥ = no (λ ()) ⊤ ≤? ✭ = yes (ℓ≤✭) ⊥ ≤? ⊤ = yes ⊥≤⊤ ⊥ ≤? ⊥ = yes ⊥≤⊥ ⊥ ≤? ✭ = yes (ℓ≤✭) ✭ ≤? ⊤ = yes (✭≤ℓ) ✭ ≤? ⊥ = yes (✭≤ℓ) ✭ ≤? ✭ = yes (ℓ≤✭) data _≾_ : GType → GType → Set where yes : (t₁ t₂ : GType) → t₁ ≾ t₂ no : (t₁ t₂ : GType) → t₁ ≾ t₂ _≾?_ : (t₁ t₂ : GType) → t₁ ≾ t₂ bool ℓ ≾? bool ℓ₁ with ℓ ≤? ℓ₁ ... | yes p = yes (bool ℓ) (bool ℓ₁) ... | no ¬p = no (bool ℓ) (bool ℓ₁) (t₁ ⇒ ℓ) t₂ ≾? (t₃ ⇒ ℓ₁) t₄ with t₃ ≾? t₁ | t₂ ≾? t₄ | ℓ ≤? ℓ₁ (t₁ ⇒ ℓ) t₂ ≾? (t₃ ⇒ ℓ₁) t₄ | yes .t₃ .t₁ | (yes .t₂ .t₄) | (yes p) = yes ((t₁ ⇒ ℓ) t₂) ((t₃ ⇒ ℓ₁) t₄) (t₁ ⇒ ℓ) t₂ ≾? (t₃ ⇒ ℓ₁) t₄ | yes .t₃ .t₁ | (yes .t₂ .t₄) | (no ¬p) = no ((t₁ ⇒ ℓ) t₂) ((t₃ ⇒ ℓ₁) t₄) (t₁ ⇒ ℓ) t₂ ≾? (t₃ ⇒ ℓ₁) t₄ | yes .t₃ .t₁ | (no .t₂ .t₄) | (yes p) = no ((t₁ ⇒ ℓ) t₂) ((t₃ ⇒ ℓ₁) t₄) (t₁ ⇒ ℓ) t₂ ≾? (t₃ ⇒ ℓ₁) t₄ | yes .t₃ .t₁ | (no .t₂ .t₄) | (no ¬p) = no ((t₁ ⇒ ℓ) t₂) ((t₃ ⇒ ℓ₁) t₄) (t₁ ⇒ ℓ) t₂ ≾? (t₃ ⇒ ℓ₁) t₄ | no .t₃ .t₁ | (yes .t₂ .t₄) | (yes p) = no ((t₁ ⇒ ℓ) t₂) ((t₃ ⇒ ℓ₁) t₄) (t₁ ⇒ ℓ) t₂ ≾? (t₃ ⇒ ℓ₁) t₄ | no .t₃ .t₁ | (yes .t₂ .t₄) | (no ¬p) = no ((t₁ ⇒ ℓ) t₂) ((t₃ ⇒ ℓ₁) t₄) (t₁ ⇒ ℓ) t₂ ≾? (t₃ ⇒ ℓ₁) t₄ | no .t₃ .t₁ | (no .t₂ .t₄) | (yes p) = no ((t₁ ⇒ ℓ) t₂) ((t₃ ⇒ ℓ₁) t₄) (t₁ ⇒ ℓ) t₂ ≾? (t₃ ⇒ ℓ₁) t₄ | no .t₃ .t₁ | (no .t₂ .t₄) | (no ¬p) = no ((t₁ ⇒ ℓ) t₂) ((t₃ ⇒ ℓ₁) t₄) -- everything else is no t₁ ≾? t₂ = no t₁ t₂
{ "alphanum_fraction": 0.439628483, "avg_line_length": 28.0869565217, "ext": "agda", "hexsha": "431ed2e02cd9c50e22c0d25dec8c03d334ba0802", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "acf5a153e14a7bdc0c9332fa602fa369fe7add46", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "kellino/TypeSystems", "max_forks_repo_path": "Agda/Gradual Security/lambdasyntax.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "acf5a153e14a7bdc0c9332fa602fa369fe7add46", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "kellino/TypeSystems", "max_issues_repo_path": "Agda/Gradual Security/lambdasyntax.agda", "max_line_length": 102, "max_stars_count": 2, "max_stars_repo_head_hexsha": "acf5a153e14a7bdc0c9332fa602fa369fe7add46", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "kellino/TypeSystems", "max_stars_repo_path": "Agda/Gradual Security/lambdasyntax.agda", "max_stars_repo_stars_event_max_datetime": "2017-05-26T23:06:17.000Z", "max_stars_repo_stars_event_min_datetime": "2016-10-27T08:05:40.000Z", "num_tokens": 1957, "size": 3230 }
module examplesPaperJFP.StackBisim where open import Data.Product open import Function open import Data.Nat.Base as N open import Data.Vec as Vec using (Vec; []; _∷_; head; tail) open import Relation.Binary.PropositionalEquality open import examplesPaperJFP.StatefulObject module _ {S : Set} {M : S → Set} {R : (s : S) → (m : M s) → Set} {next : (s : S) → (m : M s) → R s m → S} (let I = record { Stateˢ = S; Methodˢ = M; Resultˢ = R; nextˢ = next } ) (let O = Objectˢ I ) where module Bisim (I : Interfaceˢ) (let S = Stateˢ I) (let M = Methodˢ I) (let R = Resultˢ I) (let next = nextˢ I) (let O = Objectˢ I) where data ΣR {A : Set} {B : A → Set} (R : ∀{a} (b b′ : B a) → Set) : (p p′ : Σ[ a ∈ A ] B a) → Set where eqΣ : ∀{a}{b b′ : B a} → R b b′ → ΣR R (a , b) (a , b′) record _≅_ {s : S} (o o′ : O s) : Set where coinductive field bisimMethod : (m : M s) → ΣR (_≅_) (objectMethod o m) (objectMethod o′ m) open _≅_ public refl≅ : ∀{s} (o : O s) → o ≅ o bisimMethod (refl≅ o) m = let (r , o′) = objectMethod o m in eqΣ (refl≅ o′) module _ {E : Set} where private I = StackInterfaceˢ E S = Stateˢ I O = Objectˢ I open Bisim I pop-after-push : ∀{n} {v : Vec E n} {e : E} → let st = stack v (_ , st₁) = objectMethod st (push e) (e₂ , st₂) = objectMethod st₁ pop in (e ≡ e₂) × (st ≅ st₂) pop-after-push = refl , refl≅ _ push-after-pop : ∀{n} {v : Vec E n} {e : E} → let st = stack (e ∷ v) (e₁ , st₁) = objectMethod st pop (_ , st₂) = objectMethod st₁ (push e₁) in st ≅ st₂ push-after-pop = refl≅ _ tabulate : ∀ (n : ℕ) (f : ℕ → E) → Vec E n tabulate 0 f = [] tabulate (suc n) f = f 0 ∷ tabulate n (f ∘ suc) stackF : ∀ (n : ℕ) (f : ℕ → E) → Objectˢ (StackInterfaceˢ E) n objectMethod (stackF n f) (push e) = _ , stackF (suc n) λ { 0 → e ; (suc m) → f m } objectMethod (stackF (suc n) f) pop = f 0 , stackF n (f ∘ suc) impl-bisim : ∀{n f} v (p : tabulate n f ≡ v) → stackF n f ≅ stack v bisimMethod (impl-bisim v p) (push e) = eqΣ (impl-bisim (e ∷ v) (cong (_∷_ e) p)) bisimMethod (impl-bisim (e ∷ v) p) pop rewrite cong head p = eqΣ (impl-bisim v (cong tail p))
{ "alphanum_fraction": 0.4911717496, "avg_line_length": 28, "ext": "agda", "hexsha": "61facd798400fadf71720699132de0eb61d89fd2", "lang": "Agda", "max_forks_count": 2, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:41:00.000Z", "max_forks_repo_forks_event_min_datetime": "2018-09-01T15:02:37.000Z", "max_forks_repo_head_hexsha": "7cc45e0148a4a508d20ed67e791544c30fecd795", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "agda/ooAgda", "max_forks_repo_path": "examples/examplesPaperJFP/StackBisim.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "7cc45e0148a4a508d20ed67e791544c30fecd795", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "agda/ooAgda", "max_issues_repo_path": "examples/examplesPaperJFP/StackBisim.agda", "max_line_length": 119, "max_stars_count": 23, "max_stars_repo_head_hexsha": "7cc45e0148a4a508d20ed67e791544c30fecd795", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "agda/ooAgda", "max_stars_repo_path": "examples/examplesPaperJFP/StackBisim.agda", "max_stars_repo_stars_event_max_datetime": "2020-10-12T23:15:25.000Z", "max_stars_repo_stars_event_min_datetime": "2016-06-19T12:57:55.000Z", "num_tokens": 1034, "size": 2492 }
module STLC.Semantics where -- This file contains the definitional interpreter for STLC described -- in Section 2 of the paper. open import Data.Nat open import Data.Integer open import Data.List open import Data.List.Membership.Propositional open import Data.List.Relation.Unary.All as All open import Data.Maybe.Base hiding (_>>=_) ------------ -- SYNTAX -- ------------ -- These definitions correspond to Section 2.1, except we have -- included numbers (integers) and integer operations in the language. data Ty : Set where unit : Ty _⇒_ : (a b : Ty) → Ty int : Ty Ctx = List Ty -- Below, `Expr` uses `_∈_` from `Relation.Binary` in the Agda -- Standard Library to represent typed de Bruijn indices which witness -- the existence of an entry in the type context. data Expr (Γ : Ctx) : Ty → Set where unit : Expr Γ unit var : ∀ {t} → t ∈ Γ → Expr Γ t ƛ : ∀ {a b} → Expr (a ∷ Γ) b → Expr Γ (a ⇒ b) _·_ : ∀ {a b} → Expr Γ (a ⇒ b) → Expr Γ a → Expr Γ b num : ℤ → Expr Γ int iop : (ℤ → ℤ → ℤ) → (l r : Expr Γ int) → Expr Γ int ----------------------------- -- VALUES AND ENVIRONMENTS -- ----------------------------- -- These definitions correspond to Section 2.2. -- -- Note that the `All` type described in Section 2.2 of the paper (for -- simplicity) does not mention universe levels, whereas the `All` -- definition below refers to `Data.List.All` in the Agda Standard -- Library which is defined in a universe polymorphic manner. mutual data Val : Ty → Set where unit : Val unit ⟨_,_⟩ : ∀ {Γ a b} → Expr (a ∷ Γ) b → Env Γ → Val (a ⇒ b) num : ℤ → Val int Env : Ctx → Set Env Γ = All Val Γ -- The `lookup` function described in Section 2.2 of the paper is also -- defined in `Data.List.All` in the Agda Standard Library. ----------- -- MONAD -- ----------- -- These definitions correspond to Section 2.3. M : Ctx → Set → Set M Γ a = Env Γ → Maybe a _>>=_ : ∀ {Γ a b} → M Γ a → (a → M Γ b) → M Γ b (f >>= c) E with (f E) ... | just x = c x E ... | nothing = nothing return : ∀ {Γ a} → a → M Γ a return x E = just x getEnv : ∀ {Γ} → M Γ (Env Γ) getEnv E = return E E usingEnv : ∀ {Γ Γ' a} → Env Γ → M Γ a → M Γ' a usingEnv E f _ = f E timeout : ∀ {Γ a} → M Γ a timeout = λ _ → nothing ----------------- -- INTERPRETER -- ----------------- -- These definitions correspond to Section 2.4. eval : ℕ → ∀ {Γ t} → Expr Γ t → M Γ (Val t) eval zero _ = timeout eval (suc k) unit = return unit eval (suc k) (var x) = getEnv >>= λ E → return (All.lookup E x) eval (suc k) (ƛ b) = getEnv >>= λ E → return ⟨ b , E ⟩ eval (suc k) (l · r) = eval k l >>= λ{ ⟨ e , E ⟩ → eval k r >>= λ v → usingEnv (v ∷ E) (eval k e) } eval (suc k) (num x) = return (num x) eval (suc k) (iop f l r) = eval k l >>= λ{ (num vₗ) → eval k r >>= λ{ (num vᵣ) → return (num (f vₗ vᵣ)) }}
{ "alphanum_fraction": 0.5616626589, "avg_line_length": 24.4621848739, "ext": "agda", "hexsha": "d830d4e7eb181b4bb4952aaa3f0dc00f6652bae1", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-12-28T17:38:05.000Z", "max_forks_repo_forks_event_min_datetime": "2021-12-28T17:38:05.000Z", "max_forks_repo_head_hexsha": "0c096fea1716d714db0ff204ef2a9450b7a816df", "max_forks_repo_licenses": [ "Apache-2.0" ], "max_forks_repo_name": "metaborg/mj.agda", "max_forks_repo_path": "src/STLC/Semantics.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "0c096fea1716d714db0ff204ef2a9450b7a816df", "max_issues_repo_issues_event_max_datetime": "2020-10-14T13:41:58.000Z", "max_issues_repo_issues_event_min_datetime": "2019-01-13T13:03:47.000Z", "max_issues_repo_licenses": [ "Apache-2.0" ], "max_issues_repo_name": "metaborg/mj.agda", "max_issues_repo_path": "src/STLC/Semantics.agda", "max_line_length": 70, "max_stars_count": 10, "max_stars_repo_head_hexsha": "0c096fea1716d714db0ff204ef2a9450b7a816df", "max_stars_repo_licenses": [ "Apache-2.0" ], "max_stars_repo_name": "metaborg/mj.agda", "max_stars_repo_path": "src/STLC/Semantics.agda", "max_stars_repo_stars_event_max_datetime": "2021-09-24T08:02:33.000Z", "max_stars_repo_stars_event_min_datetime": "2017-11-17T17:10:36.000Z", "num_tokens": 983, "size": 2911 }
{-# OPTIONS --without-K --safe #-} open import Categories.Adjoint open import Categories.Category open import Categories.Functor renaming (id to idF) -- The crude monadicity theorem. This proof is based off of the version -- provided in "Sheaves In Geometry and Logic" by Maclane and Moerdijk. module Categories.Adjoint.Monadic.Crude {o ℓ e o′ ℓ′ e′} {𝒞 : Category o ℓ e} {𝒟 : Category o′ ℓ′ e′} {L : Functor 𝒞 𝒟} {R : Functor 𝒟 𝒞} (adjoint : L ⊣ R) where open import Level open import Function using (_$_) open import Data.Product using (Σ-syntax; _,_) open import Categories.Adjoint.Properties open import Categories.Adjoint.Monadic open import Categories.Adjoint.Monadic.Properties open import Categories.Category.Equivalence using (StrongEquivalence) open import Categories.Category.Equivalence.Properties using (pointwise-iso-equivalence) open import Categories.Functor.Properties open import Categories.NaturalTransformation.NaturalIsomorphism using (NaturalIsomorphism) open import Categories.NaturalTransformation open import Categories.Monad open import Categories.Diagram.Coequalizer open import Categories.Diagram.ReflexivePair open import Categories.Adjoint.Construction.EilenbergMoore open import Categories.Category.Construction.EilenbergMoore open import Categories.Category.Construction.Properties.EilenbergMoore open import Categories.Morphism open import Categories.Morphism.Notation open import Categories.Morphism.Properties import Categories.Morphism.Reasoning as MR private module L = Functor L module R = Functor R module 𝒞 = Category 𝒞 module 𝒟 = Category 𝒟 module adjoint = Adjoint adjoint T : Monad 𝒞 T = adjoint⇒monad adjoint 𝒞ᵀ : Category _ _ _ 𝒞ᵀ = EilenbergMoore T Comparison : Functor 𝒟 𝒞ᵀ Comparison = ComparisonF adjoint module Comparison = Functor Comparison open Coequalizer -- We could do this with limits, but this is far easier. PreservesReflexiveCoequalizers : (F : Functor 𝒟 𝒞) → Set _ PreservesReflexiveCoequalizers F = ∀ {A B} {f g : 𝒟 [ A , B ]} → ReflexivePair 𝒟 f g → (coeq : Coequalizer 𝒟 f g) → IsCoequalizer 𝒞 (F.F₁ f) (F.F₁ g) (F.F₁ (arr coeq)) where module F = Functor F module _ {F : Functor 𝒟 𝒞} (preserves-reflexive-coeq : PreservesReflexiveCoequalizers F) where open Functor F -- Unfortunately, we need to prove that the 'coequalize' arrows are equal as a lemma preserves-coequalizer-unique : ∀ {A B C} {f g : 𝒟 [ A , B ]} {h : 𝒟 [ B , C ]} {eq : 𝒟 [ 𝒟 [ h ∘ f ] ≈ 𝒟 [ h ∘ g ] ]} → (reflexive-pair : ReflexivePair 𝒟 f g) → (coe : Coequalizer 𝒟 f g) → 𝒞 [ F₁ (coequalize coe eq) ≈ IsCoequalizer.coequalize (preserves-reflexive-coeq reflexive-pair coe) ([ F ]-resp-square eq) ] preserves-coequalizer-unique reflexive-pair coe = IsCoequalizer.unique (preserves-reflexive-coeq reflexive-pair coe) (F-resp-≈ (universal coe) ○ homomorphism) where open 𝒞.HomReasoning -- If 𝒟 has coequalizers of reflexive pairs, then the comparison functor has a left adjoint. module _ (has-reflexive-coequalizers : ∀ {A B} {f g : 𝒟 [ A , B ]} → ReflexivePair 𝒟 f g → Coequalizer 𝒟 f g) where private reflexive-pair : (M : Module T) → ReflexivePair 𝒟 (L.F₁ (Module.action M)) (adjoint.counit.η (L.₀ (Module.A M))) reflexive-pair M = record { s = L.F₁ (adjoint.unit.η (Module.A M)) ; isReflexivePair = record { sectionₗ = begin 𝒟 [ L.F₁ (Module.action M) ∘ L.F₁ (adjoint.unit.η (Module.A M)) ] ≈˘⟨ L.homomorphism ⟩ L.F₁ (𝒞 [ Module.action M ∘ adjoint.unit.η (Module.A M) ] ) ≈⟨ L.F-resp-≈ (Module.identity M) ⟩ L.F₁ 𝒞.id ≈⟨ L.identity ⟩ 𝒟.id ∎ ; sectionᵣ = begin 𝒟 [ adjoint.counit.η (L.₀ (Module.A M)) ∘ L.F₁ (adjoint.unit.η (Module.A M)) ] ≈⟨ adjoint.zig ⟩ 𝒟.id ∎ } } where open 𝒟.HomReasoning -- The key part of the proof. As we have all reflexive coequalizers, we can create the following coequalizer. -- We can think of this as identifying the action of the algebra lifted to a "free" structure -- and the counit of the adjunction, as the unit of the adjunction (also lifted to the "free structure") is a section of both. has-coequalizer : (M : Module T) → Coequalizer 𝒟 (L.F₁ (Module.action M)) (adjoint.counit.η (L.₀ (Module.A M))) has-coequalizer M = has-reflexive-coequalizers (reflexive-pair M) module Comparison⁻¹ = Functor (Comparison⁻¹ adjoint has-coequalizer) module Comparison⁻¹⊣Comparison = Adjoint (Comparison⁻¹⊣Comparison adjoint has-coequalizer) -- We have one interesting coequalizer in 𝒞 built out of a T-module's action. coequalizer-action : (M : Module T) → Coequalizer 𝒞 (R.F₁ (L.F₁ (Module.action M))) (R.F₁ (adjoint.counit.η (L.₀ (Module.A M)))) coequalizer-action M = record { arr = Module.action M ; isCoequalizer = record { equality = Module.commute M ; coequalize = λ {X} {h} eq → 𝒞 [ h ∘ adjoint.unit.η (Module.A M) ] ; universal = λ {C} {h} {eq} → begin h ≈⟨ introʳ adjoint.zag ○ 𝒞.sym-assoc ⟩ 𝒞 [ 𝒞 [ h ∘ R.F₁ (adjoint.counit.η (L.₀ (Module.A M))) ] ∘ adjoint.unit.η (R.F₀ (L.F₀ (Module.A M))) ] ≈⟨ pushˡ (⟺ eq) ⟩ 𝒞 [ h ∘ 𝒞 [ R.F₁ (L.F₁ (Module.action M)) ∘ adjoint.unit.η (R.F₀ (L.F₀ (Module.A M))) ] ] ≈⟨ pushʳ (adjoint.unit.sym-commute (Module.action M)) ⟩ 𝒞 [ 𝒞 [ h ∘ adjoint.unit.η (Module.A M) ] ∘ Module.action M ] ∎ ; unique = λ {X} {h} {i} {eq} eq′ → begin i ≈⟨ introʳ (Module.identity M) ⟩ 𝒞 [ i ∘ 𝒞 [ Module.action M ∘ adjoint.unit.η (Module.A M) ] ] ≈⟨ pullˡ (⟺ eq′) ⟩ 𝒞 [ h ∘ adjoint.unit.η (Module.A M) ] ∎ } } where open 𝒞.HomReasoning open MR 𝒞 -- If 'R' preserves reflexive coequalizers, then the unit of the adjunction is a pointwise isomorphism unit-iso : PreservesReflexiveCoequalizers R → (X : Module T) → Σ[ h ∈ 𝒞ᵀ [ Comparison.F₀ (Comparison⁻¹.F₀ X) , X ] ] (Iso 𝒞ᵀ (Comparison⁻¹⊣Comparison.unit.η X) h) unit-iso preserves-reflexive-coeq X = let coequalizerˣ = has-coequalizer X coequalizerᴿˣ = ((IsCoequalizer⇒Coequalizer 𝒞 (preserves-reflexive-coeq (reflexive-pair X) (has-coequalizer X)))) coequalizer-iso = up-to-iso 𝒞 (coequalizer-action X) coequalizerᴿˣ module coequalizer-iso = _≅_ coequalizer-iso open 𝒞 open 𝒞.HomReasoning open MR 𝒞 α = record { arr = coequalizer-iso.to ; commute = begin coequalizer-iso.to ∘ R.F₁ (adjoint.counit.η _) ≈⟨ introʳ (R.F-resp-≈ L.identity ○ R.identity) ⟩ (coequalizer-iso.to ∘ R.F₁ (adjoint.counit.η _)) ∘ R.F₁ (L.F₁ 𝒞.id) ≈⟨ pushʳ (R.F-resp-≈ (L.F-resp-≈ (⟺ coequalizer-iso.isoʳ)) ○ R.F-resp-≈ L.homomorphism ○ R.homomorphism) ⟩ ((coequalizer-iso.to ∘ R.F₁ (adjoint.counit.η _)) ∘ R.F₁ (L.F₁ (R.F₁ (arr coequalizerˣ) ∘ adjoint.unit.η _))) ∘ R.F₁ (L.F₁ coequalizer-iso.to) ≈⟨ (refl⟩∘⟨ (R.F-resp-≈ L.homomorphism ○ R.homomorphism)) ⟩∘⟨refl ⟩ ((coequalizer-iso.to ∘ R.F₁ (adjoint.counit.η _)) ∘ R.F₁ (L.F₁ (R.F₁ (arr coequalizerˣ))) ∘ R.F₁ (L.F₁ (adjoint.unit.η _))) ∘ R.F₁ (L.F₁ coequalizer-iso.to) ≈⟨ center ([ R ]-resp-square (adjoint.counit.commute _)) ⟩∘⟨refl ⟩ ((coequalizer-iso.to ∘ (R.F₁ (arr coequalizerˣ) ∘ R.F₁ (adjoint.counit.η (L.F₀ _))) ∘ R.F₁ (L.F₁ (adjoint.unit.η _))) ∘ R.F₁ (L.F₁ coequalizer-iso.to)) ≈⟨ (refl⟩∘⟨ cancelʳ (⟺ R.homomorphism ○ R.F-resp-≈ adjoint.zig ○ R.identity)) ⟩∘⟨refl ⟩ (coequalizer-iso.to ∘ R.F₁ (arr coequalizerˣ)) ∘ R.F₁ (L.F₁ coequalizer-iso.to) ≈˘⟨ universal coequalizerᴿˣ ⟩∘⟨refl ⟩ Module.action X ∘ R.F₁ (L.F₁ coequalizer-iso.to) ∎ } in α , record { isoˡ = coequalizer-iso.isoˡ ; isoʳ = coequalizer-iso.isoʳ } -- If 'R' preserves reflexive coequalizers and reflects isomorphisms, then the counit of the adjunction is a pointwise isomorphism. counit-iso : PreservesReflexiveCoequalizers R → Conservative R → (X : 𝒟.Obj) → Σ[ h ∈ 𝒟 [ X , Comparison⁻¹.F₀ (Comparison.F₀ X) ] ] Iso 𝒟 (Comparison⁻¹⊣Comparison.counit.η X) h counit-iso preserves-reflexive-coeq conservative X = let coequalizerᴿᴷˣ = IsCoequalizer⇒Coequalizer 𝒞 (preserves-reflexive-coeq (reflexive-pair (Comparison.F₀ X)) (has-coequalizer (Comparison.F₀ X))) coequalizerᴷˣ = has-coequalizer (Comparison.F₀ X) coequalizer-iso = up-to-iso 𝒞 coequalizerᴿᴷˣ (coequalizer-action (Comparison.F₀ X)) module coequalizer-iso = _≅_ coequalizer-iso open 𝒞.HomReasoning open 𝒞.Equiv in conservative (Iso-resp-≈ 𝒞 coequalizer-iso.iso (⟺ (preserves-coequalizer-unique {R} preserves-reflexive-coeq (reflexive-pair (Comparison.F₀ X)) coequalizerᴷˣ)) refl) -- Now, for the final result. Both the unit and counit of the adjunction between the comparison functor and it's inverse are isomorphisms, -- so therefore they form natural isomorphism. Therfore, we have an equivalence of categories. crude-monadicity : PreservesReflexiveCoequalizers R → Conservative R → StrongEquivalence 𝒞ᵀ 𝒟 crude-monadicity preserves-reflexlive-coeq conservative = record { F = Comparison⁻¹ adjoint has-coequalizer ; G = Comparison ; weak-inverse = pointwise-iso-equivalence (Comparison⁻¹⊣Comparison adjoint has-coequalizer) (counit-iso preserves-reflexlive-coeq conservative) (unit-iso preserves-reflexlive-coeq) }
{ "alphanum_fraction": 0.6217361316, "avg_line_length": 57.9942857143, "ext": "agda", "hexsha": "490348ea017fc2fbe6367258a414fffbde6f1a7e", "lang": "Agda", "max_forks_count": 64, "max_forks_repo_forks_event_max_datetime": "2022-03-14T02:00:59.000Z", "max_forks_repo_forks_event_min_datetime": "2019-06-02T16:58:15.000Z", "max_forks_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Code-distancing/agda-categories", "max_forks_repo_path": "src/Categories/Adjoint/Monadic/Crude.agda", "max_issues_count": 236, "max_issues_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_issues_repo_issues_event_max_datetime": "2022-03-28T14:31:43.000Z", "max_issues_repo_issues_event_min_datetime": "2019-06-01T14:53:54.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Code-distancing/agda-categories", "max_issues_repo_path": "src/Categories/Adjoint/Monadic/Crude.agda", "max_line_length": 276, "max_stars_count": 279, "max_stars_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Trebor-Huang/agda-categories", "max_stars_repo_path": "src/Categories/Adjoint/Monadic/Crude.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": 3353, "size": 10149 }
open import Categories open import Monads module Monads.Kleisli {a b}{C : Cat {a}{b}}(M : Monad C) where open import Library open Cat C open Monad M Kl : Cat Kl = record{ Obj = Obj; Hom = λ X Y → Hom X (T Y); iden = η; comp = λ f g → comp (bind f) g; idl = λ{X}{Y}{f} → proof comp (bind η) f ≅⟨ cong (λ g → comp g f) law1 ⟩ comp iden f ≅⟨ idl ⟩ f ∎; idr = law2; ass = λ{_}{_}{_}{_}{f}{g}{h} → proof comp (bind (comp (bind f) g)) h ≅⟨ cong (λ f → comp f h) law3 ⟩ comp (comp (bind f) (bind g)) h ≅⟨ ass ⟩ comp (bind f) (comp (bind g) h) ∎}
{ "alphanum_fraction": 0.5, "avg_line_length": 18.9696969697, "ext": "agda", "hexsha": "688e8e6c71a1c6df9991fcb5d24f0e6521138b09", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2019-11-04T21:33:13.000Z", "max_forks_repo_forks_event_min_datetime": "2019-11-04T21:33:13.000Z", "max_forks_repo_head_hexsha": "74707d3538bf494f4bd30263d2f5515a84733865", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "jmchapman/Relative-Monads", "max_forks_repo_path": "Monads/Kleisli.agda", "max_issues_count": 3, "max_issues_repo_head_hexsha": "74707d3538bf494f4bd30263d2f5515a84733865", "max_issues_repo_issues_event_max_datetime": "2019-05-29T09:50:26.000Z", "max_issues_repo_issues_event_min_datetime": "2019-01-13T13:12:33.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "jmchapman/Relative-Monads", "max_issues_repo_path": "Monads/Kleisli.agda", "max_line_length": 62, "max_stars_count": 21, "max_stars_repo_head_hexsha": "74707d3538bf494f4bd30263d2f5515a84733865", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "jmchapman/Relative-Monads", "max_stars_repo_path": "Monads/Kleisli.agda", "max_stars_repo_stars_event_max_datetime": "2021-02-13T18:02:18.000Z", "max_stars_repo_stars_event_min_datetime": "2015-07-30T01:25:12.000Z", "num_tokens": 275, "size": 626 }
{-# OPTIONS --without-K --safe #-} module Categories.Category.Construction.SetoidDiscrete where open import Data.Unit using (⊤; tt) open import Function using (flip) open import Level using (Lift; lift) open import Relation.Binary using (Setoid; IsEquivalence) open import Categories.Category.Core using (Category) open import Categories.Category.Discrete using (DiscreteCategory) open import Categories.Morphism using (_≅_; ≅-isEquivalence) {- This is a better version of Discrete, which is more in line with the rest of this library, and makes a Category out of a Setoid. It is still 'wrong' as the equivalence is completely uninformative. -} Discrete : ∀ {o ℓ e} (A : Setoid o ℓ) → DiscreteCategory o ℓ e Discrete {o} {ℓ} {e} A = record { category = C ; isDiscrete = record { isGroupoid = record { _⁻¹ = sym } } } where open Setoid A C : Category o ℓ e C = record { Obj = Carrier ; _⇒_ = _≈_ ; _≈_ = λ _ _ → Lift e ⊤ ; id = Setoid.refl A ; _∘_ = flip trans }
{ "alphanum_fraction": 0.6519285042, "avg_line_length": 30.3714285714, "ext": "agda", "hexsha": "d0aa5d3a1c8e276aa299609e1fdc7a075408468e", "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/Construction/SetoidDiscrete.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/Construction/SetoidDiscrete.agda", "max_line_length": 68, "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/Construction/SetoidDiscrete.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": 311, "size": 1063 }
-- Reported by nils.anders.danielsson, Feb 7 2014 -- The code below is accepted by Agda 2.3.2.2. module Issue1048 where module M (_ : Set) where data D : Set where c₁ : D c₂ : D → D postulate A : Set open M A postulate ♭ : D → D ♯ : D → D data S : D → Set where s : (d : D) → S (♭ d) → S (c₂ d) postulate f : S (♭ (♯ c₁)) → S c₁ Foo : S (c₂ (♯ c₁)) → Set₁ Foo (s ._ x) with f x ... | _ = Set -- Bug.agda:24,1-25,14 -- The constructor c₁ does not construct an element of D -- when checking that the type (x : S (♭ (♯ c₁))) → S M.c₁ → Set₁ of -- the generated with function is well-formed -- Fixed. Need to normalize constructor in checkInternal.
{ "alphanum_fraction": 0.5955555556, "avg_line_length": 18.75, "ext": "agda", "hexsha": "05bd7c07660692f7dbc7da478ad14d211b41841b", "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/Issue1048.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/Issue1048.agda", "max_line_length": 68, "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/Issue1048.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": 259, "size": 675 }
{-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.Data.Nat.Coprime where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Function open import Cubical.Data.Sigma open import Cubical.Data.NatPlusOne open import Cubical.HITs.PropositionalTruncation as PropTrunc open import Cubical.Data.Nat.Base open import Cubical.Data.Nat.Properties open import Cubical.Data.Nat.Divisibility open import Cubical.Data.Nat.GCD areCoprime : ℕ × ℕ → Type₀ areCoprime (m , n) = isGCD m n 1 -- Any pair (m , n) can be converted to a coprime pair (m' , n') s.t. -- m' ∣ m, n' ∣ n if and only if one of m or n is nonzero module ToCoprime ((m , n) : ℕ × ℕ₊₁) where d = gcd m (ℕ₊₁→ℕ n) d∣m = gcdIsGCD m (ℕ₊₁→ℕ n) .fst .fst d∣n = gcdIsGCD m (ℕ₊₁→ℕ n) .fst .snd gr = gcdIsGCD m (ℕ₊₁→ℕ n) .snd c₁ : ℕ p₁ : c₁ · d ≡ m c₁ = ∣-untrunc d∣m .fst; p₁ = ∣-untrunc d∣m .snd c₂ : ℕ₊₁ p₂ : (ℕ₊₁→ℕ c₂) · d ≡ (ℕ₊₁→ℕ n) c₂ = 1+ (∣s-untrunc d∣n .fst); p₂ = ∣s-untrunc d∣n .snd toCoprime : ℕ × ℕ₊₁ toCoprime = (c₁ , c₂) private lem : ∀ a {b c d e} → a · b ≡ c → c · d ≡ e → a · (b · d) ≡ e lem a p q = ·-assoc a _ _ ∙ cong (_· _) p ∙ q gr' : ∀ d' → prediv d' c₁ → prediv d' (ℕ₊₁→ℕ c₂) → (d' · d) ∣ d gr' d' (b₁ , q₁) (b₂ , q₂) = gr (d' · d) ((∣ b₁ , lem b₁ q₁ p₁ ∣) , (∣ b₂ , lem b₂ q₂ p₂ ∣)) d-1 = m∣sn→z<m d∣n .fst q : d ≡ suc d-1 q = sym (+-comm 1 d-1 ∙ m∣sn→z<m d∣n .snd) private -- this only works because d > 0 (<=> m > 0 or n > 0) d-cancelʳ : ∀ d' → (d' · d) ∣ d → d' ∣ 1 d-cancelʳ d' div = ∣-cancelʳ d-1 (∣-trans (subst (λ x → (d' · x) ∣ x) q div) (∣-refl (sym (·-identityˡ _)))) toCoprimeAreCoprime : areCoprime (c₁ , ℕ₊₁→ℕ c₂) fst toCoprimeAreCoprime = ∣-oneˡ c₁ , ∣-oneˡ (ℕ₊₁→ℕ c₂) snd toCoprimeAreCoprime d' (d'∣c₁ , d'∣c₂) = PropTrunc.rec isProp∣ (λ a → PropTrunc.rec isProp∣ (λ b → d-cancelʳ d' (gr' d' a b)) d'∣c₂) d'∣c₁ toCoprime∣ : (c₁ ∣ m) × (ℕ₊₁→ℕ c₂ ∣ ℕ₊₁→ℕ n) toCoprime∣ = ∣ d , ·-comm d c₁ ∙ p₁ ∣ , ∣ d , ·-comm d (ℕ₊₁→ℕ c₂) ∙ p₂ ∣ toCoprime-idem : areCoprime (m , ℕ₊₁→ℕ n) → (c₁ , c₂) ≡ (m , n) toCoprime-idem cp i = q₁ i , ℕ₊₁→ℕ-inj q₂ i where q₁ = sym (·-identityʳ c₁) ∙ cong (c₁ ·_) (sym (isGCD→gcd≡ cp)) ∙ p₁ q₂ = sym (·-identityʳ (ℕ₊₁→ℕ c₂)) ∙ cong (ℕ₊₁→ℕ c₂ ·_) (sym (isGCD→gcd≡ cp)) ∙ p₂ open ToCoprime using (toCoprime; toCoprimeAreCoprime; toCoprime∣; toCoprime-idem) public toCoprime-cancelʳ : ∀ ((m , n) : ℕ × ℕ₊₁) k → toCoprime (m · ℕ₊₁→ℕ k , n ·₊₁ k) ≡ toCoprime (m , n) toCoprime-cancelʳ (m , n) (1+ k) i = inj-·sm {c₁'} {d-1} {c₁} r₁ i , ℕ₊₁→ℕ-inj (inj-·sm {ℕ₊₁→ℕ c₂'} {d-1} {ℕ₊₁→ℕ c₂} r₂) i where open ToCoprime (m , n) open ToCoprime (m · suc k , n ·₊₁ (1+ k)) using () renaming (c₁ to c₁'; p₁ to p₁'; c₂ to c₂'; p₂ to p₂') q₁ : c₁' · d · suc k ≡ m · suc k q₁ = sym (·-assoc c₁' (ToCoprime.d (m , n)) (suc k)) ∙ cong (c₁' ·_) (sym (gcd-factorʳ m (ℕ₊₁→ℕ n) (suc k))) ∙ p₁' q₂ : ℕ₊₁→ℕ c₂' · (ToCoprime.d (m , n)) · suc k ≡ ℕ₊₁→ℕ n · suc k q₂ = sym (·-assoc (ℕ₊₁→ℕ c₂') (ToCoprime.d (m , n)) (suc k)) ∙ cong (ℕ₊₁→ℕ c₂' ·_) (sym (gcd-factorʳ m (ℕ₊₁→ℕ n) (suc k))) ∙ p₂' r₁ : c₁' · suc d-1 ≡ c₁ · suc d-1 r₁ = subst (λ z → c₁' · z ≡ c₁ · z) q (inj-·sm q₁ ∙ sym p₁) r₂ : ℕ₊₁→ℕ c₂' · suc d-1 ≡ ℕ₊₁→ℕ c₂ · suc d-1 r₂ = subst (λ z → ℕ₊₁→ℕ c₂' · z ≡ ℕ₊₁→ℕ c₂ · z) q (inj-·sm q₂ ∙ sym p₂)
{ "alphanum_fraction": 0.5, "avg_line_length": 38.3125, "ext": "agda", "hexsha": "8c578162d2db91140e9de4640ddc5b1151555cbf", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "dan-iel-lee/cubical", "max_forks_repo_path": "Cubical/Data/Nat/Coprime.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_issues_repo_issues_event_max_datetime": "2022-01-27T02:07:48.000Z", "max_issues_repo_issues_event_min_datetime": "2022-01-27T02:07:48.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "dan-iel-lee/cubical", "max_issues_repo_path": "Cubical/Data/Nat/Coprime.agda", "max_line_length": 91, "max_stars_count": null, "max_stars_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "dan-iel-lee/cubical", "max_stars_repo_path": "Cubical/Data/Nat/Coprime.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1812, "size": 3678 }
{-# OPTIONS --cubical #-} module Issue4606 where open import Agda.Builtin.Cubical.Path open import Agda.Primitive.Cubical -- Test case from Andrew Pitts. ---------------------------------------------------------------------- -- Well-Founded Recursion ---------------------------------------------------------------------- data Acc {A : Set}(R : A → A → Set)(x : A) : Set where acc : (∀ y → R y x → Acc R y) → Acc R x iswf : {A : Set}(R : A → A → Set) → Set iswf R = ∀ x → Acc R x ---------------------------------------------------------------------- -- A logical contradiction ---------------------------------------------------------------------- data A : Set where O : A S : A → A E : ∀ x → S x ≡ x data _<_ (x : A) : A → Set where <S : x < S x O<O : O < O O<O = primTransp (\ i → O < E O i) i0 <S -- Given that O < O holds, we should not be able to prove that < is -- well-founded, but we can! iswf< : iswf _<_ iswf< i = acc (α i) where α : ∀ x y → y < x → Acc _<_ y -- I don't think the following clause should pass -- the termination checker α .(S y) y <S = acc (α y) data ⊥ : Set where AccO→⊥ : Acc _<_ O → ⊥ AccO→⊥ (acc f) = AccO→⊥ (f O O<O) contradiction : ⊥ contradiction = AccO→⊥ (iswf< O)
{ "alphanum_fraction": 0.4411047929, "avg_line_length": 25.1224489796, "ext": "agda", "hexsha": "b47277eb2590ae4169ac50f6f82a1ed2c142854e", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "shlevy/agda", "max_forks_repo_path": "test/Fail/Issue4606.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/Issue4606.agda", "max_line_length": 70, "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/Issue4606.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": 377, "size": 1231 }
module Type.Lemmas where open import Context open import Type.Core open import Function open import Data.Unit.Base open import Relation.Binary.PropositionalEquality foldlᶜ-▻-ε : ∀ {α} {A : Set α} -> (Θ : Con A) -> foldlᶜ _▻_ ε Θ ≡ Θ foldlᶜ-▻-ε ε = refl foldlᶜ-▻-ε (Γ ▻ σ) = cong (_▻ σ) (foldlᶜ-▻-ε Γ) -- Same as `mapᶜ f (Γ ▻▻ Δ) ≡ mapᶜ f Γ ▻▻ mapᶜ f Δ`, but we fully inline the definitions, -- because the REWRITE pragma requires that. mapᶜ-▻▻ : ∀ {α β} {A : Set α} {B : Set β} {f : A -> B} {Γ : Con A} -> ∀ Δ -> foldlᶜ (λ Ξ σ -> Ξ ▻ f σ) ε (foldlᶜ _▻_ Γ Δ) ≡ foldlᶜ _▻_ (foldlᶜ (λ Ξ σ -> Ξ ▻ f σ) ε Γ) (foldlᶜ (λ Ξ σ -> Ξ ▻ f σ) ε Δ) mapᶜ-▻▻ ε = refl mapᶜ-▻▻ (Δ ▻ τ) = cong (_▻ _) (mapᶜ-▻▻ Δ) keep-id : ∀ {α} {A : Set α} {Γ : Con A} {σ τ} -> (v : σ ∈ Γ ▻ τ) -> keep id v ≡ v keep-id vz = refl keep-id (vs v) = refl keep-keep : ∀ {α} {A : Set α} {Γ Δ Ξ : Con A} {σ τ} -> (κ : Δ ⊆ Ξ) -> (ι : Γ ⊆ Δ) -> (v : σ ∈ Γ ▻ τ) -> keep κ (keep ι v) ≡ keep (κ ∘ ι) v keep-keep κ ι vz = refl keep-keep κ ι (vs v) = refl dupl-keep-vs : ∀ {α} {A : Set α} {Γ Δ : Con A} {σ τ} -> (ι : Γ ⊆ Δ) -> (v : σ ∈ Γ ▻ τ) -> dupl (keep (vs_ ∘ ι) v) ≡ keep ι v dupl-keep-vs ι vz = refl dupl-keep-vs ι (vs v) = refl inject-foldr-poly : ∀ {α β γ} {A : Set α} {B : Set β} {yᶠ yᵍ} -> (C : B -> Set γ) -> (h : ∀ {yʰ} -> C yʰ -> C yʰ -> C yʰ) -> (g : C yᶠ -> C yᵍ) -> (∀ {y z} -> h (g y) (g z) ≡ g (h y z)) -> (f : A -> C yᶠ) -> (Γ : Con A) -> (z : C yᶠ) -> g (foldrᶜ (h ∘ f) z Γ) ≡ foldrᶜ (h ∘ g ∘ f) (g z) Γ inject-foldr-poly C h g dist f ε y = refl inject-foldr-poly C h g dist f (Γ ▻ x) y rewrite dist {f x} {y} = inject-foldr-poly C h g dist f Γ (h (f x) y) inject-foldr-mono : ∀ {α β} {A : Set α} {B : Set β} -> (h : B -> B -> B) -> (g : B -> B) -> (∀ {y z} -> h (g y) (g z) ≡ g (h y z)) -> (f : A -> B) -> (Γ : Con A) -> (y : B) -> g (foldrᶜ (h ∘ f) y Γ) ≡ foldrᶜ (h ∘ g ∘ f) (g y) Γ inject-foldr-mono h g dist f Γ y = inject-foldr-poly {B = ⊤} _ h g dist f Γ y keep-eq : ∀ {α} {A : Set α} {Θ Ξ : Con A} {σ} (ι κ : Θ ⊆ Ξ) -> (∀ {τ} -> (v : τ ∈ Θ) -> renᵛ ι v ≡ renᵛ κ v) -> (∀ {τ} -> (v : τ ∈ Θ ▻ σ) -> renᵛ (keep ι) v ≡ renᵛ (keep κ) v) keep-eq ι κ q vz = refl keep-eq ι κ q (vs v) = cong vs_ (q v) renᵗ-ext : ∀ {Θ Ξ σ} (ι κ : Θ ⊆ Ξ) (α : Θ ⊢ᵗ σ) -> (∀ {τ} -> (v : τ ∈ Θ) -> renᵛ ι v ≡ renᵛ κ v) -> renᵗ ι α ≡ renᵗ κ α renᵗ-ext ι κ (Var v) q = cong Var (q v) renᵗ-ext ι κ (Lam β) q = cong Lam_ (renᵗ-ext (keep ι) (keep κ) β (keep-eq ι κ q)) renᵗ-ext ι κ (φ ∙ α) q = cong₂ _∙_ (renᵗ-ext ι κ φ q) (renᵗ-ext ι κ α q) renᵗ-ext ι κ (α ⇒ β) q = cong₂ _⇒_ (renᵗ-ext ι κ α q) (renᵗ-ext ι κ β q) renᵗ-ext ι κ (π σ β) q = cong (π σ) (renᵗ-ext (keep ι) (keep κ) β (keep-eq ι κ q)) renᵗ-ext ι κ (μ ψ α) q = cong₂ μ (renᵗ-ext ι κ ψ q) (renᵗ-ext ι κ α q) renᵗ-keep-keep : ∀ {Θ Ξ Ω σ τ} (κ : Ξ ⊆ Ω) (ι : Θ ⊆ Ξ) (β : Θ ▻ σ ⊢ᵗ τ) -> renᵗ (keep κ ∘ keep ι) β ≡ renᵗ (keep (κ ∘ ι)) β renᵗ-keep-keep κ ι β = renᵗ-ext (keep κ ∘ keep ι) (keep (κ ∘ ι)) β λ { vz -> refl ; (vs v) -> refl } renᵗ-∘ : ∀ {Θ Ξ Ω σ} (κ : Ξ ⊆ Ω) (ι : Θ ⊆ Ξ) (α : Θ ⊢ᵗ σ) -> renᵗ κ (renᵗ ι α) ≡ renᵗ (κ ∘ ι) α renᵗ-∘ κ ι (Var v) = refl renᵗ-∘ κ ι (Lam β) = cong Lam_ (trans (renᵗ-∘ (keep κ) (keep ι) β) (renᵗ-keep-keep κ ι β)) renᵗ-∘ κ ι (f ∙ α) = cong₂ _∙_ (renᵗ-∘ κ ι f) (renᵗ-∘ κ ι α) renᵗ-∘ κ ι (α ⇒ β) = cong₂ _⇒_ (renᵗ-∘ κ ι α) (renᵗ-∘ κ ι β) renᵗ-∘ κ ι (π σ β) = cong (π σ) (trans (renᵗ-∘ (keep κ) (keep ι) β) (renᵗ-keep-keep κ ι β)) renᵗ-∘ κ ι (μ ψ α) = cong₂ μ (renᵗ-∘ κ ι ψ) (renᵗ-∘ κ ι α) renᵗ-keep-id : ∀ {Θ σ τ} (β : Θ ▻ σ ⊢ᵗ τ) -> renᵗ (keep id) β ≡ renᵗ id β renᵗ-keep-id β = renᵗ-ext (keep id) id β λ { vz -> refl ; (vs v) -> refl } renᵗ-id : ∀ {Θ σ} (α : Θ ⊢ᵗ σ) -> renᵗ id α ≡ α renᵗ-id (Var v) = refl renᵗ-id (Lam β) = cong Lam_ (trans (renᵗ-keep-id β) (renᵗ-id β)) renᵗ-id (φ ∙ α) = cong₂ _∙_ (renᵗ-id φ) (renᵗ-id α) renᵗ-id (α ⇒ β) = cong₂ _⇒_ (renᵗ-id α) (renᵗ-id β) renᵗ-id (π σ β) = cong (π σ) (trans (renᵗ-keep-id β) (renᵗ-id β)) renᵗ-id (μ ψ α) = cong₂ μ (renᵗ-id ψ) (renᵗ-id α) module EnvironmentLemmas {α β} {A : Set α} {_◆_ : Con A -> A -> Set β} (environment : Environment _◆_) where open Environment environment keepᵉ-eq : ∀ {Θ Ξ : Con A} {σ} (ρ χ : Ξ ⊢ᵉ Θ) -> (∀ {τ} -> (v : τ ∈ Θ) -> lookupᵉ v ρ ≡ lookupᵉ v χ ) -> (∀ {τ} -> (v : τ ∈ Θ ▻ σ) -> lookupᵉ v (keepᵉ ρ) ≡ lookupᵉ v (keepᵉ χ)) keepᵉ-eq ρ χ q vz = refl keepᵉ-eq ρ χ q (vs v) = cong (renᵈ vs_) (q v) module _ where open TypeEnv open EnvironmentLemmas environmentᵗ subᵗ-ext : ∀ {Θ Ξ σ} (ρ χ : Ξ ⊢ᵗᵉ Θ) (α : Θ ⊢ᵗ σ) -> (∀ {τ} -> (v : τ ∈ Θ) -> lookupᵉ v ρ ≡ lookupᵉ v χ) -> subᵗ ρ α ≡ subᵗ χ α subᵗ-ext ρ χ (Var v) q = q v subᵗ-ext ρ χ (Lam β) q = cong Lam_ (subᵗ-ext (keepᵉ ρ) (keepᵉ χ) β (keepᵉ-eq ρ χ q)) subᵗ-ext ρ χ (φ ∙ α) q = cong₂ _∙_ (subᵗ-ext ρ χ φ q) (subᵗ-ext ρ χ α q) subᵗ-ext ρ χ (α ⇒ β) q = cong₂ _⇒_ (subᵗ-ext ρ χ α q) (subᵗ-ext ρ χ β q) subᵗ-ext ρ χ (π σ β) q = cong (π σ) (subᵗ-ext (keepᵉ ρ) (keepᵉ χ) β (keepᵉ-eq ρ χ q)) subᵗ-ext ρ χ (μ ψ α) q = cong₂ μ (subᵗ-ext ρ χ ψ q) (subᵗ-ext ρ χ α q) subᵗ-keepᵉ-keep : ∀ {Θ Ξ Ω σ τ} (ρ : Ω ⊢ᵗᵉ Ξ) (ι : Θ ⊆ Ξ) (β : Θ ▻ σ ⊢ᵗ τ) -> subᵗ (keepᵉ ρ ∘ᵉ keep ι) β ≡ subᵗ (keepᵉ (ρ ∘ᵉ ι)) β subᵗ-keepᵉ-keep ρ ι β = subᵗ-ext (keepᵉ ρ ∘ᵉ keep ι) (keepᵉ (ρ ∘ᵉ ι)) β λ { vz -> refl ; (vs v) -> refl } subᵗ-renᵗ : ∀ {Θ Ξ Ω σ} (ρ : Ω ⊢ᵗᵉ Ξ) (ι : Θ ⊆ Ξ) (α : Θ ⊢ᵗ σ) -> subᵗ ρ (renᵗ ι α) ≡ subᵗ (ρ ∘ᵉ ι) α subᵗ-renᵗ ρ ι (Var v) = refl subᵗ-renᵗ ρ ι (Lam β) = cong Lam_ (trans (subᵗ-renᵗ (keepᵉ ρ) (keep ι) β) (subᵗ-keepᵉ-keep ρ ι β)) subᵗ-renᵗ ρ ι (φ ∙ α) = cong₂ _∙_ (subᵗ-renᵗ ρ ι φ) (subᵗ-renᵗ ρ ι α) subᵗ-renᵗ ρ ι (α ⇒ β) = cong₂ _⇒_ (subᵗ-renᵗ ρ ι α) (subᵗ-renᵗ ρ ι β) subᵗ-renᵗ ρ ι (π σ β) = cong (π σ) (trans (subᵗ-renᵗ (keepᵉ ρ) (keep ι) β) (subᵗ-keepᵉ-keep ρ ι β)) subᵗ-renᵗ ρ ι (μ ψ α) = cong₂ μ (subᵗ-renᵗ ρ ι ψ) (subᵗ-renᵗ ρ ι α) subᵗ-keepᵉ-idᵉ : ∀ {Θ σ τ} (β : Θ ▻ σ ⊢ᵗ τ) -> subᵗ (keepᵉ idᵉ) β ≡ subᵗ idᵉ β subᵗ-keepᵉ-idᵉ β = subᵗ-ext (keepᵉ idᵉ) idᵉ β λ { vz -> refl ; (vs v) -> refl } subᵗ-idᵉ : ∀ {Θ σ} (α : Θ ⊢ᵗ σ) -> subᵗ idᵉ α ≡ α subᵗ-idᵉ (Var v) = refl subᵗ-idᵉ (Lam β) = cong Lam_ (trans (subᵗ-keepᵉ-idᵉ β) (subᵗ-idᵉ β)) subᵗ-idᵉ (φ ∙ α) = cong₂ _∙_ (subᵗ-idᵉ φ) (subᵗ-idᵉ α) subᵗ-idᵉ (α ⇒ β) = cong₂ _⇒_ (subᵗ-idᵉ α) (subᵗ-idᵉ β) subᵗ-idᵉ (π σ β) = cong (π σ) (trans (subᵗ-keepᵉ-idᵉ β) (subᵗ-idᵉ β)) subᵗ-idᵉ (μ ψ α) = cong₂ μ (subᵗ-idᵉ ψ) (subᵗ-idᵉ α) subᵗ-keepᵉ-Var : ∀ {Θ Ξ σ τ} (ι : Θ ⊆ Ξ) (β : Θ ▻ σ ⊢ᵗ τ) -> subᵗ (keepᵉ (PackEnv (Var ∘ ι))) β ≡ subᵗ (PackEnv (Var ∘ keep ι)) β subᵗ-keepᵉ-Var ι β = subᵗ-ext (keepᵉ (PackEnv (Var ∘ ι))) (PackEnv (Var ∘ keep ι)) β λ { vz -> refl ; (vs v) -> refl } subᵗ-Var : ∀ {Θ Ξ σ} (ι : Θ ⊆ Ξ) (α : Θ ⊢ᵗ σ) -> subᵗ (PackEnv (Var ∘ ι)) α ≡ renᵗ ι α subᵗ-Var ι (Var v) = refl subᵗ-Var ι (Lam β) = cong Lam_ (trans (subᵗ-keepᵉ-Var ι β) (subᵗ-Var (keep ι) β)) subᵗ-Var ι (φ ∙ α) = cong₂ _∙_ (subᵗ-Var ι φ) (subᵗ-Var ι α) subᵗ-Var ι (α ⇒ β) = cong₂ _⇒_ (subᵗ-Var ι α) (subᵗ-Var ι β) subᵗ-Var ι (π σ β) = cong (π σ) (trans (subᵗ-keepᵉ-Var ι β) (subᵗ-Var (keep ι) β)) subᵗ-Var ι (μ ψ α) = cong₂ μ (subᵗ-Var ι ψ) (subᵗ-Var ι α) inject-foldr-⇒-renᵗ : ∀ {Θ Ξ Ω} {f : Star Θ -> Star Ξ} -> ∀ Δ -> (ι : Ξ ⊆ Ω) -> (β : Star Ξ) -> renᵗ ι (conToTypeBy f Δ β) ≡ conToTypeBy (renᵗ ι ∘ f) Δ (renᵗ ι β) inject-foldr-⇒-renᵗ Δ ι β = inject-foldr-poly Star _⇒_ (renᵗ ι) refl _ Δ β inject-foldr-⇒-subᵗ : ∀ {Θ Ξ Ω} {f : Star Θ -> Star Ξ} -> ∀ Δ -> (ρ : Ω TypeEnv.⊢ᵉ Ξ) -> (β : Star Ξ) -> subᵗ ρ (conToTypeBy f Δ β) ≡ conToTypeBy (subᵗ ρ ∘ f) Δ (subᵗ ρ β) inject-foldr-⇒-subᵗ Δ ρ β = inject-foldr-poly Star _⇒_ (subᵗ ρ) refl _ Δ β
{ "alphanum_fraction": 0.5002543882, "avg_line_length": 36.9107981221, "ext": "agda", "hexsha": "fde2d227f0f6b16d9452f1d3df2dfdc3fc257148", "lang": "Agda", "max_forks_count": 399, "max_forks_repo_forks_event_max_datetime": "2022-03-31T11:18:25.000Z", "max_forks_repo_forks_event_min_datetime": "2018-10-05T09:36:10.000Z", "max_forks_repo_head_hexsha": "f7d34336cd3d65f62b0da084a16f741dc9156413", "max_forks_repo_licenses": [ "Apache-2.0" ], "max_forks_repo_name": "AriFordsham/plutus", "max_forks_repo_path": "papers/unraveling-recursion/code/src/Type/Lemmas.agda", "max_issues_count": 2493, "max_issues_repo_head_hexsha": "f7d34336cd3d65f62b0da084a16f741dc9156413", "max_issues_repo_issues_event_max_datetime": "2022-03-31T15:31:31.000Z", "max_issues_repo_issues_event_min_datetime": "2018-09-28T19:28:17.000Z", "max_issues_repo_licenses": [ "Apache-2.0" ], "max_issues_repo_name": "AriFordsham/plutus", "max_issues_repo_path": "papers/unraveling-recursion/code/src/Type/Lemmas.agda", "max_line_length": 101, "max_stars_count": 1299, "max_stars_repo_head_hexsha": "f7d34336cd3d65f62b0da084a16f741dc9156413", "max_stars_repo_licenses": [ "Apache-2.0" ], "max_stars_repo_name": "AriFordsham/plutus", "max_stars_repo_path": "papers/unraveling-recursion/code/src/Type/Lemmas.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-28T01:10:02.000Z", "max_stars_repo_stars_event_min_datetime": "2018-10-02T13:41:39.000Z", "num_tokens": 4770, "size": 7862 }
module FunctionProofs where open FunctionSet ⦃ signature ⦄ [∃]-unrelatedᵣ-[→]ᵣ-inside-[∀ₛ] : ∀{D : Domain}{P : BinaryRelator} → Proof(∀ₗ(x ↦ ∃ₗ(y ↦ (x ∈ D) ⟶ P(x)(y))) ⟷ ∀ₛ(D)(x ↦ ∃ₗ(y ↦ P(x)(y)))) [∃]-unrelatedᵣ-[→]ᵣ-inside-[∀ₛ] {D}{P} = [↔]-with-[∀] ([∃]-unrelatedᵣ-[→]) [∀ₛ∃!]-to[∀ₛ∃] : ∀{P : BinaryRelator}{D : Domain} → Proof(∀ₛ(D)(x ↦ ∃ₗ!(y ↦ P(x)(y)))) → Proof(∀ₛ(D)(x ↦ ∃ₗ(y ↦ P(x)(y)))) [∀ₛ∃!]-to[∀ₛ∃] proof = ([∀ₛ]-intro(\{x} → xinD ↦ [∧].elimₗ([∀ₛ]-elim proof {x} xinD) )) -- The construction of a meta-function in the meta-logic from a function in the set theory fnset-witness : ∀{D} → (f : Domain) → ⦃ _ : Proof(Total(D)(f)) ⦄ → Function fnset-witness f ⦃ proof ⦄ = [∃]-fn-witness ⦃ [↔].elimₗ [∃]-unrelatedᵣ-[→]ᵣ-inside-[∀ₛ] (proof) ⦄ fnset-value : ∀{D} → (f : Domain) → ⦃ proof : Proof(Total(D)(f)) ⦄ → Proof(∀ₛ(D)(x ↦ (x , fnset-witness f(x)) ∈ f)) fnset-value{D} f ⦃ proof ⦄ = [∃]-fn-proof ⦃ [↔].elimₗ [∃]-unrelatedᵣ-[→]ᵣ-inside-[∀ₛ] (proof) ⦄ fnset-proof : ∀{D} → (f : Domain) → ⦃ _ : Proof(FunctionSet(f)) ⦄ → ⦃ total : Proof(Total(D)(f)) ⦄ → Proof(∀ₛ(D)(x ↦ ∀ₗ(y ↦ (fnset-witness{D} f ⦃ total ⦄ x ≡ y) ⟷ ((x , y) ∈ f)))) fnset-proof{D} f ⦃ function ⦄ ⦃ total ⦄ = ([∀ₛ]-intro(\{x} → x∈D ↦ ([∀].intro(\{y} → ([↔].intro (xy∈f ↦ ([→].elim ([∀].elim([∀].elim([∀].elim function{x}) {fnset-witness f(x)}) {y}) ([∧].intro ([∀ₛ]-elim(fnset-value f) {x} (x∈D)) (xy∈f) ) ) ) (fx≡y ↦ [≡].elimᵣ (fx≡y) ([∀ₛ]-elim (fnset-value(f)) {x} (x∈D)) ) ) )) )) [→ₛₑₜ]-witness : ∀{A B} → (f : Domain) → ⦃ _ : Proof(f ∈ (A →ₛₑₜ B)) ⦄ → Function [→ₛₑₜ]-witness f ⦃ proof ⦄ (x) = (fnset-witness f ⦃ [∧].elimᵣ([∧].elimᵣ([↔].elimᵣ ([∀].elim([∀].elim filter-membership)) (proof) )) ⦄ (x) )
{ "alphanum_fraction": 0.4588675214, "avg_line_length": 36.7058823529, "ext": "agda", "hexsha": "1b02fbfbac81799074fb464e0521f87b97b6383e", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_path": "old/Structure/Logic/Classical/SetTheory/ZFC/FunctionSet/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": "old/Structure/Logic/Classical/SetTheory/ZFC/FunctionSet/Proofs.agda", "max_line_length": 179, "max_stars_count": 6, "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_path": "old/Structure/Logic/Classical/SetTheory/ZFC/FunctionSet/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": 963, "size": 1872 }
------------------------------------------------------------------------ -- INCREMENTAL λ-CALCULUS -- -- Dependently typed changes (Def 3.4 and 3.5, Fig. 4b and 4e) ------------------------------------------------------------------------ import Parametric.Syntax.Type as Type import Parametric.Denotation.Value as Value open import Base.Change.Algebra as CA using (ChangeAlgebraFamily) module Parametric.Change.Validity {Base : Type.Structure} (⟦_⟧Base : Value.Structure Base) where open Type.Structure Base open Value.Structure Base ⟦_⟧Base open import Base.Denotation.Notation public open import Relation.Binary.PropositionalEquality open import Level -- Extension Point: Change algebras for base types Structure : Set₁ Structure = ChangeAlgebraFamily ⟦_⟧Base module Structure {{change-algebra-base : Structure}} where -- change algebras open CA public renaming -- Constructors for All′ ( [] to ∅ ; _∷_ to _•_ ) change-algebra : ∀ τ → ChangeAlgebra ⟦ τ ⟧Type change-algebra (base ι) = change-algebra₍ ι ₎ change-algebra (τ₁ ⇒ τ₂) = changeAlgebraFun {{change-algebra τ₁}} {{change-algebra τ₂}} -- We provide: change algebra for every type instance change-algebra-family : ChangeAlgebraFamily ⟦_⟧Type change-algebra-family = family change-algebra -- function changes module _ {τ₁ τ₂ : Type} where open FunctionChange {{change-algebra τ₁}} {{change-algebra τ₂}} public renaming ( correct to is-valid ; apply to call-change ) -- We also provide: change environments (aka. environment changes). open ListChanges ⟦_⟧Type {{change-algebra-family}} public using () renaming ( changeAlgebraListChanges to environment-changes ) after-env : ∀ {Γ : Context} → {ρ : ⟦ Γ ⟧} (dρ : Δ₍ Γ ₎ ρ) → ⟦ Γ ⟧ after-env {Γ} = after₍_₎ Γ
{ "alphanum_fraction": 0.6413755459, "avg_line_length": 28.625, "ext": "agda", "hexsha": "ff67f19b496bc9b66213a076cef6087e319f943d", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2016-02-18T12:26:44.000Z", "max_forks_repo_forks_event_min_datetime": "2016-02-18T12:26:44.000Z", "max_forks_repo_head_hexsha": "39bb081c6f192bdb87bd58b4a89291686d2d7d03", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "inc-lc/ilc-agda", "max_forks_repo_path": "Parametric/Change/Validity.agda", "max_issues_count": 6, "max_issues_repo_head_hexsha": "39bb081c6f192bdb87bd58b4a89291686d2d7d03", "max_issues_repo_issues_event_max_datetime": "2017-05-04T13:53:59.000Z", "max_issues_repo_issues_event_min_datetime": "2015-07-01T18:09:31.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "inc-lc/ilc-agda", "max_issues_repo_path": "Parametric/Change/Validity.agda", "max_line_length": 89, "max_stars_count": 10, "max_stars_repo_head_hexsha": "39bb081c6f192bdb87bd58b4a89291686d2d7d03", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "inc-lc/ilc-agda", "max_stars_repo_path": "Parametric/Change/Validity.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": 507, "size": 1832 }
------------------------------------------------------------------------ -- Various constants ------------------------------------------------------------------------ open import Atom module Constants (atoms : χ-atoms) where open χ-atoms atoms c-zero : Const c-zero = C.name 0 c-suc : Const c-suc = C.name 1 c-nil : Const c-nil = C.name 2 c-cons : Const c-cons = C.name 3 c-apply : Const c-apply = C.name 4 c-case : Const c-case = C.name 5 c-rec : Const c-rec = C.name 6 c-lambda : Const c-lambda = C.name 7 c-const : Const c-const = C.name 8 c-var : Const c-var = C.name 9 c-branch : Const c-branch = C.name 10 c-true : Const c-true = C.name 11 c-false : Const c-false = C.name 12 c-pair : Const c-pair = C.name 13 v-equal : Var v-equal = V.name 0 v-m : Var v-m = V.name 1 v-n : Var v-n = V.name 2 v-x : Var v-x = V.name 3 v-new : Var v-new = V.name 4 v-e : Var v-e = V.name 5 v-subst : Var v-subst = V.name 6 v-e₁ : Var v-e₁ = V.name 7 v-e₂ : Var v-e₂ = V.name 8 v-bs : Var v-bs = V.name 9 v-y : Var v-y = V.name 10 v-c : Var v-c = V.name 11 v-es : Var v-es = V.name 12 v-ys : Var v-ys = V.name 13 v-member : Var v-member = V.name 14 v-xs : Var v-xs = V.name 15 v-lookup : Var v-lookup = V.name 16 v-b : Var v-b = V.name 17 v-c′ : Var v-c′ = V.name 18 v-underscore : Var v-underscore = V.name 19 v-substs : Var v-substs = V.name 20 v-e′ : Var v-e′ = V.name 21 v-map : Var v-map = V.name 22 v-p : Var v-p = V.name 23 v-eval : Var v-eval = V.name 24 v-internal-code : Var v-internal-code = V.name 25 v-halts : Var v-halts = V.name 26 v-z : Var v-z = V.name 27 v-f : Var v-f = V.name 28 v-g : Var v-g = V.name 29
{ "alphanum_fraction": 0.5485232068, "avg_line_length": 11.6830985915, "ext": "agda", "hexsha": "41f42ed873a385ff888472abc6b590d3b833a364", "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": "30966769b8cbd46aa490b6964a4aa0e67a7f9ab1", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "nad/chi", "max_forks_repo_path": "src/Constants.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "30966769b8cbd46aa490b6964a4aa0e67a7f9ab1", "max_issues_repo_issues_event_max_datetime": "2020-06-08T11:08:25.000Z", "max_issues_repo_issues_event_min_datetime": "2020-05-21T23:29:54.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "nad/chi", "max_issues_repo_path": "src/Constants.agda", "max_line_length": 72, "max_stars_count": 2, "max_stars_repo_head_hexsha": "30966769b8cbd46aa490b6964a4aa0e67a7f9ab1", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "nad/chi", "max_stars_repo_path": "src/Constants.agda", "max_stars_repo_stars_event_max_datetime": "2020-10-20T16:27:00.000Z", "max_stars_repo_stars_event_min_datetime": "2020-05-21T22:58:07.000Z", "num_tokens": 649, "size": 1659 }
open import Function using () renaming ( _∘′_ to _∘_ ) open import Relation.Binary.PropositionalEquality using ( _≡_ ; refl ; sym ; cong ; cong₂ ; subst ) open import AssocFree.Util using ( subst-natural ) import AssocFree.STLambdaC.Typ open Relation.Binary.PropositionalEquality.≡-Reasoning using ( begin_ ; _≡⟨_⟩_ ; _∎ ) module AssocFree.STLambdaC.Exp (TConst : Set) (Const : AssocFree.STLambdaC.Typ.Typ TConst → Set) where open module Typ = AssocFree.STLambdaC.Typ TConst using ( Typ ; Var ; Ctxt ; const ; _⇝_ ; [] ; [_] ; _++_ ; _∷_ ; _∈_ ; _≪_ ; _≫_ ; _⋙_ ; uniq ; singleton ; Case ; case ; inj₁ ; inj₂ ; inj₃ ; case-≪ ; case-≫ ; case-⋙ ; Case₃ ; case₃ ; caseˡ ; caseʳ ; caseˡ₃ ; caseʳ₃ ; case⁻¹ ; case-iso ) -- Syntax data Exp (Γ : Ctxt) : Typ → Set where const : ∀ {T} → Const T → Exp Γ T abs : ∀ T {U} → Exp (T ∷ Γ) U → Exp Γ (T ⇝ U) app : ∀ {T U} → Exp Γ (T ⇝ U) → Exp Γ T → Exp Γ U var : ∀ {T} → (T ∈ Γ) → Exp Γ T -- Shorthand var₀ : ∀ {Γ T} → Exp (T ∷ Γ) T var₀ {Γ} {T} = var (singleton T ≪ Γ) var₁ : ∀ {Γ T U} → Exp (U ∷ (T ∷ Γ)) T var₁ {Γ} {T} {U} = var ([ U ] ≫ singleton T ≪ Γ) var₂ : ∀ {Γ T U V} → Exp (V ∷ (U ∷ (T ∷ Γ))) T var₂ {Γ} {T} {U} {V} = var ([ V ] ≫ [ U ] ≫ singleton T ≪ Γ) -- Andreas Abel suggested defining substitution and renaming together, citing: -- -- Conor McBride -- Type Preserving Renaming and Substitution -- -- Thorsten Altenkirch and Bernhard Reus -- Monadic Presentations of Lambda Terms Using Generalized Inductive Types -- -- http://www2.tcs.ifi.lmu.de/~abel/ParallelSubstitution.agda -- The idea is to define two kinds, for expressions and variables, -- such that the kind of variables is contained in the kind of -- expressions (so admits recursion). mutual data Kind : Set where var : Kind exp : ∀ {k} → IsVar k → Kind data IsVar : Kind → Set where var : IsVar var Thing : Kind → Ctxt → Typ → Set Thing var Γ T = (T ∈ Γ) Thing (exp var) Γ T = Exp Γ T Substn : Kind → Ctxt → Ctxt → Set Substn k Γ Δ = ∀ {T} → (T ∈ Δ) → Thing k Γ T -- Convert between variables, things and expressions thing : ∀ {k Γ T} → (T ∈ Γ) → Thing k Γ T thing {var} x = x thing {exp var} x = var x expr : ∀ {k Γ T} → Thing k Γ T → Exp Γ T expr {var} x = var x expr {exp var} M = M -- Extensional equivalence on substitutions (note: not assuming extensionality) _≈_ : ∀ {k Γ Δ} → Substn k Γ Δ → Substn k Γ Δ → Set ρ ≈ σ = ∀ {T} x → ρ {T} x ≡ σ {T} x -- Identity substitution id : ∀ {k} Γ → Substn k Γ Γ id {var} Γ x = x id {exp var} Γ x = var x -- Product structure of substitutions fst : ∀ Γ Δ → Substn var (Γ ++ Δ) Γ fst Γ Δ x = x ≪ Δ snd : ∀ Γ Δ → Substn var (Γ ++ Δ) Δ snd Γ Δ x = Γ ≫ x choose : ∀ {k Γ Δ E T} → Substn k Γ Δ → Substn k Γ E → (Case T Δ E) → Thing k Γ T choose ρ σ (inj₁ x) = ρ x choose ρ σ (inj₂ x) = σ x _&&&_ : ∀ {k Γ Δ E} → Substn k Γ Δ → Substn k Γ E → Substn k Γ (Δ ++ E) (ρ &&& σ) = choose ρ σ ∘ case _ _ -- Singleton substitution ⟨_⟩ : ∀ {k Γ T} → Thing k Γ T → Substn k Γ [ T ] ⟨ M ⟩ x = subst (Thing _ _) (uniq x) M -- Cons on substitutions _◁_ : ∀ {k Γ Δ T} → Thing k Γ T → Substn k Γ Δ → Substn k Γ (T ∷ Δ) M ◁ σ = ⟨ M ⟩ &&& σ -- Applying a substitution mutual substn+ : ∀ {k} B Γ Δ → Substn k Γ Δ → ∀ {T} → Exp (B ++ Δ) T → Exp (B ++ Γ) T substn+ B Γ Δ σ (const c) = const c substn+ B Γ Δ σ (abs T M) = abs T (substn+ (T ∷ B) Γ Δ σ M) substn+ B Γ Δ σ (app M N) = app (substn+ B Γ Δ σ M) (substn+ B Γ Δ σ N) substn+ B Γ Δ σ (var x) = expr (xsubstn+ B Γ Δ σ (case B Δ x)) xsubstn+ : ∀ {k} B Γ Δ → Substn k Γ Δ → ∀ {T} → (Case T B Δ) → Thing k (B ++ Γ) T xsubstn+ B Γ Δ σ (inj₁ x) = thing (x ≪ Γ) xsubstn+ {var} B Γ Δ σ (inj₂ x) = B ≫ σ x xsubstn+ {exp var} B Γ Δ σ (inj₂ x) = substn+ [] (B ++ Γ) Γ (snd B Γ) (σ x) -- weaken* B (σ x) -- Shorthands substn* : ∀ {k Γ Δ} → Substn k Γ Δ → ∀ {T} → Exp Δ T → Exp Γ T substn* {k} {Γ} {Δ} = substn+ [] Γ Δ substn : ∀ {Γ T U} → Exp Γ T → Exp (T ∷ Γ) U → Exp Γ U substn {Γ} M = substn* (M ◁ id Γ) xweaken+ : ∀ B Γ Δ {T} → (T ∈ (B ++ Δ)) → (T ∈ (B ++ Γ ++ Δ)) xweaken+ B Γ Δ x = xsubstn+ B (Γ ++ Δ) Δ (snd Γ Δ) (case B Δ x) weaken+ : ∀ B Γ Δ {T} → Exp (B ++ Δ) T → Exp (B ++ Γ ++ Δ) T weaken+ B Γ Δ = substn+ B (Γ ++ Δ) Δ (snd Γ Δ) weaken* : ∀ Γ {Δ T} → Exp Δ T → Exp (Γ ++ Δ) T weaken* Γ {Δ} = weaken+ [] Γ Δ weakens* : ∀ {Γ Δ} E → Substn (exp var) Γ Δ → Substn (exp var) (E ++ Γ) Δ weakens* E σ x = weaken* E (σ x) weaken*ʳ : ∀ {Γ} Δ {T} → Exp Γ T → Exp (Γ ++ Δ) T weaken*ʳ {Γ} Δ = weaken+ Γ Δ [] weaken : ∀ {Γ} T {U} → Exp Γ U → Exp (T ∷ Γ) U weaken T = weaken* [ T ] -- Composition of substitutions _⊔_ : Kind → Kind → Kind k ⊔ var = k k ⊔ exp var = exp var _∙_ : ∀ {k l Γ Δ E} → Substn k Γ Δ → Substn l Δ E → Substn (k ⊔ l) Γ E _∙_ {k} {var} ρ σ = ρ ∘ σ _∙_ {k} {exp var} ρ σ = substn* ρ ∘ σ -- Functorial action of ++ on substitutions par : ∀ {k Γ Δ Φ Ψ T} → Substn k Γ Φ → Substn k Δ Ψ → (Case T Φ Ψ) → Thing k (Γ ++ Δ) T par {var} {Γ} {Δ} ρ σ (inj₁ x) = ρ x ≪ Δ par {var} {Γ} {Δ} ρ σ (inj₂ x) = Γ ≫ σ x par {exp var} {Γ} {Δ} ρ σ (inj₁ x) = weaken*ʳ Δ (ρ x) par {exp var} {Γ} {Δ} ρ σ (inj₂ x) = weaken* Γ (σ x) _+++_ : ∀ {k Γ Δ Φ Ψ} → Substn k Γ Δ → Substn k Φ Ψ → Substn k (Γ ++ Φ) (Δ ++ Ψ) (ρ +++ σ) = par ρ σ ∘ case _ _ -- Weakening a variable is a variable weaken*-var : ∀ Γ {Δ T} (x : T ∈ Δ) → weaken* Γ (var x) ≡ var (Γ ≫ x) weaken*-var Γ {Δ} x = cong (expr ∘ xsubstn+ [] (Γ ++ Δ) Δ (snd Γ Δ)) (case-≫ [] x) weaken*ʳ-var : ∀ {Γ} Δ {T} (x : T ∈ Γ) → weaken*ʳ Δ (var x) ≡ var (x ≪ Δ) weaken*ʳ-var {Γ} Δ x = cong (expr ∘ xsubstn+ Γ Δ [] (snd Δ [])) (case-≪ x []) weaken+-var₀ : ∀ B Γ Δ {T} → weaken+ (T ∷ B) Γ Δ (var₀ {B ++ Δ}) ≡ var₀ {B ++ Γ ++ Δ} weaken+-var₀ B Γ Δ {T} = cong (var ∘ xsubstn+ (T ∷ B) (Γ ++ Δ) Δ (snd Γ Δ)) (case-≪ (singleton T ≪ B) Δ) -- Substitution respects extensional equality substn+-cong : ∀ {k} B Γ Δ {σ : Substn k Γ Δ} {ρ : Substn k Γ Δ} → (σ ≈ ρ) → ∀ {T} M → substn+ B Γ Δ σ {T} M ≡ substn+ B Γ Δ ρ M substn+-cong B Γ Δ σ≈ρ (const c) = refl substn+-cong B Γ Δ σ≈ρ (abs T M) = cong (abs {B ++ Γ} T) (substn+-cong (T ∷ B) Γ Δ σ≈ρ M) substn+-cong B Γ Δ σ≈ρ (app M N) = cong₂ app (substn+-cong B Γ Δ σ≈ρ M) (substn+-cong B Γ Δ σ≈ρ N) substn+-cong B Γ Δ σ≈ρ (var x) = cong expr (xsubstn+-cong B Γ Δ σ≈ρ (case B Δ x)) where xsubstn+-cong : ∀ {k} B Γ Δ {σ : Substn k Γ Δ} {ρ : Substn k Γ Δ} → (σ ≈ ρ) → ∀ {T} x → xsubstn+ B Γ Δ σ {T} x ≡ xsubstn+ B Γ Δ ρ x xsubstn+-cong {var} B Γ Δ σ≈ρ (inj₁ x) = refl xsubstn+-cong {exp var} B Γ Δ σ≈ρ (inj₁ x) = refl xsubstn+-cong {var} B Γ Δ σ≈ρ (inj₂ x) = cong (_≫_ B) (σ≈ρ x) xsubstn+-cong {exp var} B Γ Δ σ≈ρ (inj₂ x) = cong (substn+ [] (B ++ Γ) Γ (snd B Γ)) (σ≈ρ x) substn*-cong : ∀ {k Γ Δ} {σ : Substn k Γ Δ} {ρ : Substn k Γ Δ} → (σ ≈ ρ) → ∀ {T} M → substn* σ {T} M ≡ substn* ρ M substn*-cong {k} {Γ} {Δ} = substn+-cong [] Γ Δ -- Identity of substitutions xsubstn+-id : ∀ {k} B Γ {T} (x : Case T B Γ) → expr (xsubstn+ B Γ Γ (id {k} Γ) x) ≡ var (case⁻¹ x) xsubstn+-id {var} B Γ (inj₁ x) = refl xsubstn+-id {exp var} B Γ (inj₁ x) = refl xsubstn+-id {var} B Γ (inj₂ x) = refl xsubstn+-id {exp var} B Γ (inj₂ x) = weaken*-var B x substn+-id : ∀ {k} B Γ {T} (M : Exp (B ++ Γ) T) → substn+ B Γ Γ (id {k} Γ) M ≡ M substn+-id B Γ (const c) = refl substn+-id B Γ (abs T M) = cong (abs {B ++ Γ} T) (substn+-id (T ∷ B) Γ M) substn+-id B Γ (app M N) = cong₂ app (substn+-id B Γ M) (substn+-id B Γ N) substn+-id {k} B Γ (var x) = begin substn+ B Γ Γ (id {k} Γ) (var x) ≡⟨ xsubstn+-id {k} B Γ (case B Γ x) ⟩ var (case⁻¹ (case B Γ x)) ≡⟨ cong var (case-iso B Γ x) ⟩ var x ∎ substn*-id : ∀ {k Γ T} (M : Exp Γ T) → substn* (id {k} Γ) M ≡ M substn*-id {k} {Γ} = substn+-id [] Γ weaken*-[] : ∀ {Γ T} (M : Exp Γ T) → weaken* [] M ≡ M weaken*-[] M = substn*-id M mutual -- Composition of substitutions substn+-∙ : ∀ {k l} B Γ Δ E (σ : Substn k Γ Δ) (ρ : Substn l Δ E) {T} (M : Exp (B ++ E) T) → (substn+ B Γ Δ σ (substn+ B Δ E ρ M) ≡ substn+ B Γ E (σ ∙ ρ) M) substn+-∙ B Γ Δ E ρ σ (const c) = refl substn+-∙ B Γ Δ E ρ σ (abs T M) = cong (abs {B ++ Γ} T) (substn+-∙ (T ∷ B) Γ Δ E ρ σ M) substn+-∙ B Γ Δ E ρ σ (app M N) = cong₂ app (substn+-∙ B Γ Δ E ρ σ M) (substn+-∙ B Γ Δ E ρ σ N) substn+-∙ B Γ Δ E ρ σ (var x) = xsubstn+-∙ B Γ Δ E ρ σ (case B E x) where xsubstn+-∙ : ∀ {k l} B Γ Δ E (σ : Substn k Γ Δ) (ρ : Substn l Δ E) {T} (x : Case T B E) → (substn+ B Γ Δ σ (expr (xsubstn+ B Δ E ρ x)) ≡ expr (xsubstn+ B Γ E (σ ∙ ρ) x)) xsubstn+-∙ {k} {var} B Γ Δ E σ ρ (inj₁ x) = cong (expr ∘ xsubstn+ B Γ Δ σ) (case-≪ x Δ) xsubstn+-∙ {var} {exp var} B Γ Δ E σ ρ (inj₁ x) = cong (expr ∘ xsubstn+ B Γ Δ σ) (case-≪ x Δ) xsubstn+-∙ {exp var} {exp var} B Γ Δ E σ ρ (inj₁ x) = cong (expr ∘ xsubstn+ B Γ Δ σ) (case-≪ x Δ) xsubstn+-∙ {var} {var} B Γ Δ E σ ρ (inj₂ x) = cong (expr ∘ xsubstn+ B Γ Δ σ) (case-≫ B (ρ x)) xsubstn+-∙ {exp var} {var} B Γ Δ E σ ρ (inj₂ x) = cong (expr ∘ xsubstn+ B Γ Δ σ) (case-≫ B (ρ x)) xsubstn+-∙ {var} {exp var} B Γ Δ E σ ρ (inj₂ x) = begin substn+ B Γ Δ σ (weaken* B (ρ x)) ≡⟨ substn+* B Γ Δ σ (weaken* B (ρ x)) ⟩ substn* (id B +++ σ) (weaken* B (ρ x)) ≡⟨ substn+-∙ [] (B ++ Γ) (B ++ Δ) Δ (id B +++ σ) (snd B Δ) (ρ x) ⟩ substn* ((id B +++ σ) ∙ snd B Δ) (ρ x) ≡⟨ substn*-cong (λ y → cong (par (id B) σ) (case-≫ B y)) (ρ x) ⟩ substn* (snd B Γ ∙ σ) (ρ x) ≡⟨ sym (substn+-∙ [] (B ++ Γ) Γ Δ (snd B Γ) σ (ρ x)) ⟩ weaken* B (substn* σ (ρ x)) ∎ xsubstn+-∙ {exp var} {exp var} B Γ Δ E σ ρ (inj₂ x) = begin substn+ B Γ Δ σ (weaken* B (ρ x)) ≡⟨ substn+* B Γ Δ σ (weaken* B (ρ x)) ⟩ substn* (id B +++ σ) (weaken* B (ρ x)) ≡⟨ substn+-∙ [] (B ++ Γ) (B ++ Δ) Δ (id B +++ σ) (snd B Δ) (ρ x) ⟩ substn* ((id B +++ σ) ∙ snd B Δ) (ρ x) ≡⟨ substn*-cong (λ y → cong (par (id B) σ) (case-≫ B y))(ρ x) ⟩ substn* (snd B Γ ∙ σ) (ρ x) ≡⟨ sym (substn+-∙ [] (B ++ Γ) Γ Δ (snd B Γ) σ (ρ x)) ⟩ weaken* B (substn* σ (ρ x)) ∎ substn*-∙ : ∀ {k l Γ Δ E} (σ : Substn k Γ Δ) (ρ : Substn l Δ E) {T} (M : Exp E T) → (substn* σ (substn* ρ M) ≡ substn* (σ ∙ ρ) M) substn*-∙ {k} {l} {Γ} {Δ} {E} = substn+-∙ [] Γ Δ E -- Proof uses the fact that substn+ is an instance of substn* substn++ : ∀ {k} A B Γ Δ (σ : Substn k Γ Δ) {T} (M : Exp (A ++ B ++ Δ) T) → substn+ (A ++ B) Γ Δ σ M ≡ substn+ A (B ++ Γ) (B ++ Δ) (id B +++ σ) M substn++ A B Γ Δ σ (const c) = refl substn++ A B Γ Δ σ (abs T M) = cong (abs {A ++ B ++ Γ} T) (substn++ (T ∷ A) B Γ Δ σ M) substn++ A B Γ Δ σ (app M N) = cong₂ app (substn++ A B Γ Δ σ M) (substn++ A B Γ Δ σ N) substn++ A B Γ Δ σ (var x) = cong expr (begin xsubstn+ (A ++ B) Γ Δ σ (case (A ++ B) Δ x) ≡⟨ cong (xsubstn+ (A ++ B) Γ Δ σ) (sym (caseˡ₃ A B Δ x)) ⟩ xsubstn+ (A ++ B) Γ Δ σ (caseˡ (case₃ A B Δ x)) ≡⟨ xsubstn++ A B Γ Δ σ (case₃ A B Δ x) ⟩ xsubstn+ A (B ++ Γ) (B ++ Δ) (id B +++ σ) (caseʳ (case₃ A B Δ x)) ≡⟨ cong (xsubstn+ A (B ++ Γ) (B ++ Δ) (id B +++ σ)) (caseʳ₃ A B Δ x) ⟩ xsubstn+ A (B ++ Γ) (B ++ Δ) (id B +++ σ) (case A (B ++ Δ) x) ∎) where xsubstn++ : ∀ {k} A B Γ Δ (σ : Substn k Γ Δ) {T} (x : Case₃ T A B Δ) → xsubstn+ (A ++ B) Γ Δ σ (caseˡ x) ≡ xsubstn+ A (B ++ Γ) (B ++ Δ) (id B +++ σ) (caseʳ x) xsubstn++ A B Γ Δ σ (inj₁ x) = refl xsubstn++ {var} A B Γ Δ σ (inj₂ x) = cong (λ X → A ≫ par (id B) σ X) (sym (case-≪ x Δ)) xsubstn++ {exp var} A B Γ Δ σ (inj₂ x) = begin var (A ≫ x ≪ Γ) ≡⟨ sym (weaken*-var A (x ≪ Γ)) ⟩ weaken* A (var (x ≪ Γ)) ≡⟨ cong (weaken* A) (sym (weaken*ʳ-var Γ x)) ⟩ weaken* A (weaken*ʳ Γ (var x)) ≡⟨ cong (weaken* A ∘ par (id B) σ) (sym (case-≪ x Δ)) ⟩ weaken* A ((id B +++ σ) (x ≪ Δ)) ∎ xsubstn++ {var} A B Γ Δ σ (inj₃ x) = cong (λ X → A ≫ par (id B) σ X) (sym (case-≫ B x)) xsubstn++ {exp var} A B Γ Δ σ (inj₃ x) = begin weaken* (A ++ B) (σ x) ≡⟨ sym (substn*-∙ (snd A (B ++ Γ)) (snd B Γ) (σ x)) ⟩ weaken* A (weaken* B (σ x)) ≡⟨ cong (weaken* A ∘ par (id B) σ) (sym (case-≫ B x)) ⟩ weaken* A ((id B +++ σ) (B ≫ x)) ∎ substn+* : ∀ {k} B Γ Δ (σ : Substn k Γ Δ) {T} (M : Exp (B ++ Δ) T) → substn+ B Γ Δ σ M ≡ substn* (id B +++ σ) M substn+* = substn++ [] -- Weakening of weakening is weakening weaken*-++ : ∀ A B Γ {T} (M : Exp Γ T) → weaken* A (weaken* B M) ≡ weaken* (A ++ B) M weaken*-++ A B Γ = substn*-∙ (snd A (B ++ Γ)) (snd B Γ) -- Weakening commutes with weakening weaken*-comm : ∀ A B Γ Δ {U} (M : Exp (B ++ Δ) U) → weaken* A (weaken+ B Γ Δ M) ≡ weaken+ (A ++ B) Γ Δ (weaken* A M) weaken*-comm A B Γ Δ M = begin weaken* A (weaken+ B Γ Δ M) ≡⟨ cong (substn* (snd A (B ++ Γ ++ Δ))) (substn+* B (Γ ++ Δ) Δ (snd Γ Δ) M) ⟩ substn* (snd A (B ++ Γ ++ Δ)) (substn* (id B +++ snd Γ Δ) M) ≡⟨ substn*-∙ (snd A (B ++ Γ ++ Δ)) (id B +++ snd Γ Δ) M ⟩ substn* (snd A (B ++ Γ ++ Δ) ∙ (id B +++ snd Γ Δ)) M ≡⟨ substn*-cong lemma₂ M ⟩ substn* ((id (A ++ B) +++ snd Γ Δ) ∙ snd A (B ++ Δ)) M ≡⟨ sym (substn*-∙ (id (A ++ B) +++ snd Γ Δ) (snd A (B ++ Δ)) M) ⟩ substn* (id (A ++ B) +++ snd Γ Δ) (substn* (snd A (B ++ Δ)) M) ≡⟨ sym (substn+* (A ++ B) (Γ ++ Δ) Δ (snd Γ Δ) (substn* (snd A (B ++ Δ)) M)) ⟩ weaken+ (A ++ B) Γ Δ (weaken* A M) ∎ where lemma₁ : ∀ {T} (x : Case T B Δ) → snd A (B ++ Γ ++ Δ) (par (id B) (snd Γ Δ) x) ≡ (par (id (A ++ B)) (snd Γ Δ) (A ⋙ x)) lemma₁ (inj₁ x) = refl lemma₁ (inj₂ x) = refl lemma₂ : (snd A (B ++ Γ ++ Δ) ∙ (id B +++ snd Γ Δ)) ≈ ((id (A ++ B) +++ snd Γ Δ) ∙ snd A (B ++ Δ)) lemma₂ {T} x = begin snd A (B ++ Γ ++ Δ) (par (id B) (snd Γ Δ) (case B Δ x)) ≡⟨ lemma₁ (case B Δ x) ⟩ par (id (A ++ B)) (snd Γ Δ) (A ⋙ (case B Δ x)) ≡⟨ cong (par (id (A ++ B)) (snd Γ Δ)) (case-⋙ A B Δ x) ⟩ par (id (A ++ B)) (snd Γ Δ) (case (A ++ B) Δ (A ≫ x)) ∎ weaken-comm : ∀ T B Γ Δ {U} (M : Exp (B ++ Δ) U) → weaken T (weaken+ B Γ Δ M) ≡ weaken+ (T ∷ B) Γ Δ (weaken T M) weaken-comm T = weaken*-comm [ T ] -- Weakening distributes through susbtn weaken-substn : ∀ B Γ Δ {T U} (M : Exp (B ++ Δ) T) (N : Exp (T ∷ B ++ Δ) U) → substn (weaken+ B Γ Δ M) (weaken+ (T ∷ B) Γ Δ N) ≡ weaken+ B Γ Δ (substn M N) weaken-substn B Γ Δ {T} M N = begin substn (weaken+ B Γ Δ M) (weaken+ (T ∷ B) Γ Δ N) ≡⟨ cong₂ substn (substn+* B (Γ ++ Δ) Δ (snd Γ Δ) M) (substn+* (T ∷ B) (Γ ++ Δ) Δ (snd Γ Δ) N) ⟩ substn (substn* (id B +++ snd Γ Δ) M) (substn* (id (T ∷ B) +++ snd Γ Δ) N) ≡⟨ substn*-∙ (substn* (id B +++ snd Γ Δ) M ◁ id (B ++ Γ ++ Δ)) (id (T ∷ B) +++ snd Γ Δ) N ⟩ substn* ((substn* (id B +++ snd Γ Δ) M ◁ id (B ++ Γ ++ Δ)) ∙ (id (T ∷ B) +++ snd Γ Δ)) N ≡⟨ substn*-cong lemma₂ N ⟩ substn* ((id B +++ snd Γ Δ) ∙ (M ◁ id (B ++ Δ))) N ≡⟨ sym (substn*-∙ (id B +++ snd Γ Δ) (M ◁ id (B ++ Δ)) N) ⟩ substn* (id B +++ snd Γ Δ) (substn M N) ≡⟨ sym (substn+* B (Γ ++ Δ) Δ (snd Γ Δ) (substn M N)) ⟩ weaken+ B Γ Δ (substn M N) ∎ where lemma₁ : ∀ {S} (x : Case₃ S [ T ] B Δ) → (substn* (id B +++ snd Γ Δ) M ◁ id (B ++ Γ ++ Δ)) (par (id (T ∷ B)) (snd Γ Δ) (caseˡ x)) ≡ substn* (id B +++ snd Γ Δ) (choose ⟨ M ⟩ (id (B ++ Δ)) (caseʳ x)) lemma₁ (inj₁ x) = begin (substn* (id B +++ snd Γ Δ) M ◁ id (B ++ Γ ++ Δ)) (x ≪ B ≪ Γ ≪ Δ) ≡⟨ cong (choose ⟨ substn* (id B +++ snd Γ Δ) M ⟩ (id (B ++ Γ ++ Δ))) (case-≪ x (B ++ Γ ++ Δ)) ⟩ ⟨ substn* (id B +++ snd Γ Δ) M ⟩ x ≡⟨ subst-natural (uniq x) (substn* (id B +++ snd Γ Δ)) M ⟩ substn* (id B +++ snd Γ Δ) (⟨ M ⟩ x) ∎ lemma₁ (inj₂ x) = begin (substn* (id B +++ snd Γ Δ) M ◁ id (B ++ Γ ++ Δ)) ([ T ] ≫ x ≪ Γ ≪ Δ) ≡⟨ cong (choose ⟨ substn* (id B +++ snd Γ Δ) M ⟩ (id (B ++ Γ ++ Δ))) (case-≫ [ T ] (x ≪ Γ ≪ Δ)) ⟩ var (x ≪ Γ ≪ Δ) ≡⟨ cong (var ∘ par (id B) (snd Γ Δ)) (sym (case-≪ x Δ)) ⟩ var ((id B +++ snd Γ Δ) (x ≪ Δ)) ≡⟨ cong (var ∘ xsubstn+ [] (B ++ Γ ++ Δ) (B ++ Δ) (id B +++ snd Γ Δ)) (sym (case-≫ [] (x ≪ Δ))) ⟩ substn* (id B +++ snd Γ Δ) (var (x ≪ Δ)) ∎ lemma₁ (inj₃ x) = begin (substn* (id B +++ snd Γ Δ) M ◁ id (B ++ Γ ++ Δ)) ([ T ] ≫ B ≫ Γ ≫ x) ≡⟨ cong (choose ⟨ substn* (id B +++ snd Γ Δ) M ⟩ (id (B ++ Γ ++ Δ))) (case-≫ [ T ] (B ≫ Γ ≫ x)) ⟩ var (B ≫ Γ ≫ x) ≡⟨ cong (var ∘ par (id B) (snd Γ Δ)) (sym (case-≫ B x)) ⟩ var ((id B +++ snd Γ Δ) (B ≫ x)) ≡⟨ cong (var ∘ xsubstn+ [] (B ++ Γ ++ Δ) (B ++ Δ) (id B +++ snd Γ Δ)) (sym (case-≫ [] (B ≫ x))) ⟩ substn* (id B +++ snd Γ Δ) (var (B ≫ x)) ∎ lemma₂ : ((substn* (id B +++ snd Γ Δ) M ◁ id (B ++ Γ ++ Δ)) ∙ (id (T ∷ B) +++ snd Γ Δ)) ≈ ((id B +++ snd Γ Δ) ∙ (M ◁ id (B ++ Δ))) lemma₂ {S} x = begin ((substn* (id B +++ snd Γ Δ) M ◁ id (B ++ Γ ++ Δ)) ∙ (id (T ∷ B) +++ snd Γ Δ)) x ≡⟨ cong (substn* (id B +++ snd Γ Δ) M ◁ id (B ++ Γ ++ Δ) ∘ par (id (T ∷ B)) (snd Γ Δ)) (sym (caseˡ₃ [ T ] B Δ x)) ⟩ (substn* (id B +++ snd Γ Δ) M ◁ id (B ++ Γ ++ Δ)) (par (id (T ∷ B)) (snd Γ Δ) (caseˡ (case₃ [ T ] B Δ x))) ≡⟨ lemma₁ (case₃ [ T ] B Δ x) ⟩ substn* (id B +++ snd Γ Δ) (choose ⟨ M ⟩ (id (B ++ Δ)) (caseʳ (case₃ [ T ] B Δ x))) ≡⟨ cong (substn* (id B +++ snd Γ Δ) ∘ choose ⟨ M ⟩ (id (B ++ Δ))) (caseʳ₃ [ T ] B Δ x) ⟩ ((id B +++ snd Γ Δ) ∙ (M ◁ id (B ++ Δ))) x ∎ -- Substitution into weakening discards the substitution substn-weaken : ∀ {Γ T U} (M : Exp Γ U) (N : Exp Γ T) → substn N (weaken T M) ≡ M substn-weaken {Γ} {T} M N = begin substn N (weaken T M) ≡⟨ substn*-∙ (N ◁ id Γ) (snd [ T ] Γ) M ⟩ substn* ((N ◁ id Γ) ∙ snd [ T ] Γ) M ≡⟨ substn*-cong (λ x → cong (choose ⟨ N ⟩ (id Γ)) (case-≫ [ T ] x)) M ⟩ substn* (id Γ) M ≡⟨ substn*-id M ⟩ M ∎ -- Substitution + weakening respects ◁ substn*-◁ : ∀ Γ Δ E {T U} (M : Exp (T ∷ Γ) U) (N : Exp (E ++ Δ) T) (σ : Substn (exp var) Δ Γ) → substn* (N ◁ weakens* E σ) M ≡ substn N (weaken+ [ T ] E Δ (substn+ [ T ] Δ Γ σ M)) substn*-◁ Γ Δ E {T} M N σ = begin substn* (N ◁ weakens* E σ) M ≡⟨ substn*-cong (λ x → lemma (case [ T ] Γ x)) M ⟩ substn* ((N ◁ id (E ++ Δ)) ∙ (id [ T ] +++ (snd E Δ ∙ σ))) M ≡⟨ sym (substn*-∙ (N ◁ id (E ++ Δ)) (id [ T ] +++ (snd E Δ ∙ σ)) M) ⟩ substn N (substn* (id [ T ] +++ (snd E Δ ∙ σ)) M) ≡⟨ cong (substn N) (sym (substn+* [ T ] (E ++ Δ) Γ (snd E Δ ∙ σ) M)) ⟩ substn N (substn+ [ T ] (E ++ Δ) Γ (snd E Δ ∙ σ) M) ≡⟨ cong (substn N) (sym (substn+-∙ [ T ] (E ++ Δ) Δ Γ (snd E Δ) σ M)) ⟩ substn N (weaken+ [ T ] E Δ (substn+ [ T ] Δ Γ σ M)) ∎ where lemma : ∀ {U} (x : Case U [ T ] Γ) → choose ⟨ N ⟩ (weakens* E σ) x ≡ substn N (par (id [ T ]) (snd E Δ ∙ σ) x) lemma (inj₁ x) = begin subst (Exp (E ++ Δ)) (uniq x) N ≡⟨ cong (choose ⟨ N ⟩ (id (E ++ Δ))) (sym (case-≪ x (E ++ Δ))) ⟩ (N ◁ id (E ++ Δ)) (x ≪ E ≪ Δ) ≡⟨ sym (weaken*-[] ((N ◁ id (E ++ Δ)) (x ≪ E ≪ Δ))) ⟩ weaken* [] ((N ◁ id (E ++ Δ)) (x ≪ E ≪ Δ)) ≡⟨ cong (xsubstn+ [] (E ++ Δ) ([ T ] ++ E ++ Δ) (N ◁ id (E ++ Δ))) (sym (case-≫ [] (x ≪ E ≪ Δ))) ⟩ substn N (var (x ≪ E ≪ Δ)) ≡⟨ cong (substn N) (sym (weaken*ʳ-var (E ++ Δ) x)) ⟩ substn N (weaken*ʳ (E ++ Δ) (var x)) ∎ lemma (inj₂ x) = sym (substn-weaken (weaken* E (σ x)) N)
{ "alphanum_fraction": 0.4706877114, "avg_line_length": 39.028, "ext": "agda", "hexsha": "ad25f3219509764ef99f57ef4887910b33c50028", "lang": "Agda", "max_forks_count": 2, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:38:44.000Z", "max_forks_repo_forks_event_min_datetime": "2018-03-03T04:39:31.000Z", "max_forks_repo_head_hexsha": "08337fdb8375137a52cc9b3ade766305191b2394", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "agda/agda-assoc-free", "max_forks_repo_path": "src/AssocFree/STLambdaC/Exp.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "08337fdb8375137a52cc9b3ade766305191b2394", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "agda/agda-assoc-free", "max_issues_repo_path": "src/AssocFree/STLambdaC/Exp.agda", "max_line_length": 101, "max_stars_count": 3, "max_stars_repo_head_hexsha": "08337fdb8375137a52cc9b3ade766305191b2394", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "agda/agda-assoc-free", "max_stars_repo_path": "src/AssocFree/STLambdaC/Exp.agda", "max_stars_repo_stars_event_max_datetime": "2020-08-27T20:56:20.000Z", "max_stars_repo_stars_event_min_datetime": "2016-11-22T11:48:31.000Z", "num_tokens": 9190, "size": 19514 }
{-# OPTIONS --without-K --safe #-} open import Level using (Level) open import Relation.Binary.PropositionalEquality open ≡-Reasoning open import Data.Nat using (ℕ) open import Data.Vec using (Vec; foldr; zipWith; map) open import FLA.Algebra.Structures open import FLA.Algebra.Properties.Field module FLA.Algebra.LinearAlgebra where private variable ℓ : Level A : Set ℓ m n p q : ℕ module _ {ℓ : Level} {A : Set ℓ} ⦃ F : Field A ⦄ where open Field F -- Vector addition _+ⱽ_ : Vec A n → Vec A n → Vec A n _+ⱽ_ = zipWith _+_ -- Vector substraction _-ⱽ_ : Vec A n → Vec A n → Vec A n a -ⱽ b = a +ⱽ (map (-_) b) -- Vector Hadamard product _*ⱽ_ : Vec A n → Vec A n → Vec A n _*ⱽ_ = zipWith _*_ -- Multiply vector by a constant _∘ⱽ_ : A → Vec A n → Vec A n c ∘ⱽ v = map (c *_) v -- Match the fixity of Haskell infixl 6 _+ⱽ_ infixl 6 _-ⱽ_ infixl 7 _*ⱽ_ infixl 10 _∘ⱽ_ sum : Vec A n → A sum = foldr _ _+_ 0ᶠ -- Inner product ⟨_,_⟩ : Vec A n → Vec A n → A ⟨ v₁ , v₂ ⟩ = sum (v₁ *ⱽ v₂)
{ "alphanum_fraction": 0.6138519924, "avg_line_length": 19.8867924528, "ext": "agda", "hexsha": "a25ad16d2b8f61cad3ee0900c1c3513fa79e3900", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2021-09-07T19:55:59.000Z", "max_forks_repo_forks_event_min_datetime": "2021-04-12T20:34:17.000Z", "max_forks_repo_head_hexsha": "375475a2daa57b5995ceb78b4bffcbfcbb5d8898", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "turion/functional-linear-algebra", "max_forks_repo_path": "src/FLA/Algebra/LinearAlgebra.agda", "max_issues_count": 6, "max_issues_repo_head_hexsha": "375475a2daa57b5995ceb78b4bffcbfcbb5d8898", "max_issues_repo_issues_event_max_datetime": "2022-01-07T05:27:53.000Z", "max_issues_repo_issues_event_min_datetime": "2020-09-01T01:42:12.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "turion/functional-linear-algebra", "max_issues_repo_path": "src/FLA/Algebra/LinearAlgebra.agda", "max_line_length": 54, "max_stars_count": 21, "max_stars_repo_head_hexsha": "375475a2daa57b5995ceb78b4bffcbfcbb5d8898", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "turion/functional-linear-algebra", "max_stars_repo_path": "src/FLA/Algebra/LinearAlgebra.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": 433, "size": 1054 }
{-# OPTIONS --safe --without-K #-} module Generics.HasDesc where open import Data.String.Base open import Generics.Prelude hiding (lookup ; pi) open import Generics.Telescope open import Generics.Desc import Generics.Accessibility as Accessibility private variable P : Telescope ⊤ I : ExTele P pi : ⟦ P , I ⟧xtel record HasDesc {ℓ} (A : Indexed P I ℓ) : Setω where A′ : ⟦ P , I ⟧xtel → Set ℓ A′ = uncurry P I A field {n} : ℕ D : DataDesc P I n names : Vec String n constr : ⟦ D ⟧Data A′ pi → A′ pi split : A′ pi → ⟦ D ⟧Data A′ pi constr∘split : (x : A′ pi ) → constr (split x) ≡ x split∘constr : (x : ⟦ D ⟧Data A′ pi) → split (constr x) ≡ω x open Accessibility A D split public field wf : (x : A′ pi) → Acc x split-injective : ∀ {pi} {x y : A′ pi} → split x ≡ω split y → x ≡ y split-injective {x = x} {y} sx≡sy = begin x ≡⟨ sym (constr∘split x) ⟩ constr (split x) ≡⟨ congω constr sx≡sy ⟩ constr (split y) ≡⟨ constr∘split y ⟩ y ∎ where open ≡-Reasoning
{ "alphanum_fraction": 0.5659340659, "avg_line_length": 23.2340425532, "ext": "agda", "hexsha": "ca7c1c76e63ecf06a79ede3425cdc0379b851414", "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": "src/Generics/HasDesc.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": "src/Generics/HasDesc.agda", "max_line_length": 69, "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": "src/Generics/HasDesc.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": 402, "size": 1092 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Some properties about subsets ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} module Data.Fin.Subset.Properties where open import Algebra import Algebra.FunctionProperties as AlgebraicProperties import Algebra.Structures as AlgebraicStructures import Algebra.Properties.Lattice as L import Algebra.Properties.DistributiveLattice as DL import Algebra.Properties.BooleanAlgebra as BA open import Data.Bool.Properties open import Data.Fin using (Fin; suc; zero) open import Data.Fin.Subset open import Data.Fin.Properties using (any?; decFinSubset) open import Data.Nat.Base using (ℕ; zero; suc; z≤n; s≤s; _≤_) open import Data.Nat.Properties using (≤-step) open import Data.Product as Product using (∃; ∄; _×_; _,_) open import Data.Sum as Sum using (_⊎_; inj₁; inj₂) open import Data.Vec open import Data.Vec.Properties open import Function using (_∘_; const; id; case_of_) open import Function.Equivalence using (_⇔_; equivalence) open import Relation.Binary as B hiding (Decidable) open import Relation.Binary.PropositionalEquality using (_≡_; refl; cong; cong₂; subst; isEquivalence) open import Relation.Nullary.Negation using (contradiction) open import Relation.Nullary using (Dec; yes; no) open import Relation.Unary using (Pred; Decidable) ------------------------------------------------------------------------ -- Constructor mangling drop-there : ∀ {s n x} {p : Subset n} → suc x ∈ s ∷ p → x ∈ p drop-there (there x∈p) = x∈p drop-∷-⊆ : ∀ {n s₁ s₂} {p₁ p₂ : Subset n} → s₁ ∷ p₁ ⊆ s₂ ∷ p₂ → p₁ ⊆ p₂ drop-∷-⊆ p₁s₁⊆p₂s₂ x∈p₁ = drop-there (p₁s₁⊆p₂s₂ (there x∈p₁)) ------------------------------------------------------------------------ -- _∈_ infix 4 _∈?_ _∈?_ : ∀ {n} x (p : Subset n) → Dec (x ∈ p) zero ∈? inside ∷ p = yes here zero ∈? outside ∷ p = no λ() suc n ∈? s ∷ p with n ∈? p ... | yes n∈p = yes (there n∈p) ... | no n∉p = no (n∉p ∘ drop-there) ------------------------------------------------------------------------ -- Empty drop-∷-Empty : ∀ {n s} {p : Subset n} → Empty (s ∷ p) → Empty p drop-∷-Empty ¬∃∈ (x , x∈p) = ¬∃∈ (suc x , there x∈p) Empty-unique : ∀ {n} {p : Subset n} → Empty p → p ≡ ⊥ Empty-unique {_} {[]} ¬∃∈ = refl Empty-unique {_} {inside ∷ p} ¬∃∈ = contradiction (zero , here) ¬∃∈ Empty-unique {_} {outside ∷ p} ¬∃∈ = cong (outside ∷_) (Empty-unique (drop-∷-Empty ¬∃∈)) nonempty? : ∀ {n} → Decidable (Nonempty {n}) nonempty? p = any? (_∈? p) ------------------------------------------------------------------------ -- ∣_∣ ∣p∣≤n : ∀ {n} (p : Subset n) → ∣ p ∣ ≤ n ∣p∣≤n = count≤n (_≟ inside) ------------------------------------------------------------------------ -- ⊥ ∉⊥ : ∀ {n} {x : Fin n} → x ∉ ⊥ ∉⊥ (there p) = ∉⊥ p ⊥⊆ : ∀ {n} {p : Subset n} → ⊥ ⊆ p ⊥⊆ x∈⊥ = contradiction x∈⊥ ∉⊥ ∣⊥∣≡0 : ∀ n → ∣ ⊥ {n = n} ∣ ≡ 0 ∣⊥∣≡0 zero = refl ∣⊥∣≡0 (suc n) = ∣⊥∣≡0 n ------------------------------------------------------------------------ -- ⊤ ∈⊤ : ∀ {n} {x : Fin n} → x ∈ ⊤ ∈⊤ {x = zero} = here ∈⊤ {x = suc x} = there ∈⊤ ⊆⊤ : ∀ {n} {p : Subset n} → p ⊆ ⊤ ⊆⊤ = const ∈⊤ ∣⊤∣≡n : ∀ n → ∣ ⊤ {n = n} ∣ ≡ n ∣⊤∣≡n zero = refl ∣⊤∣≡n (suc n) = cong suc (∣⊤∣≡n n) ------------------------------------------------------------------------ -- ⁅_⁆ x∈⁅x⁆ : ∀ {n} (x : Fin n) → x ∈ ⁅ x ⁆ x∈⁅x⁆ zero = here x∈⁅x⁆ (suc x) = there (x∈⁅x⁆ x) x∈⁅y⁆⇒x≡y : ∀ {n x} (y : Fin n) → x ∈ ⁅ y ⁆ → x ≡ y x∈⁅y⁆⇒x≡y zero here = refl x∈⁅y⁆⇒x≡y zero (there p) = contradiction p ∉⊥ x∈⁅y⁆⇒x≡y (suc y) (there p) = cong suc (x∈⁅y⁆⇒x≡y y p) x∈⁅y⁆⇔x≡y : ∀ {n} {x y : Fin n} → x ∈ ⁅ y ⁆ ⇔ x ≡ y x∈⁅y⁆⇔x≡y {_} {x} {y} = equivalence (x∈⁅y⁆⇒x≡y y) (λ x≡y → subst (λ y → x ∈ ⁅ y ⁆) x≡y (x∈⁅x⁆ x)) ∣⁅x⁆∣≡1 : ∀ {n} (i : Fin n) → ∣ ⁅ i ⁆ ∣ ≡ 1 ∣⁅x⁆∣≡1 {suc n} zero = cong suc (∣⊥∣≡0 n) ∣⁅x⁆∣≡1 {_} (suc i) = ∣⁅x⁆∣≡1 i ------------------------------------------------------------------------ -- _⊆_ ⊆-refl : ∀ {n} → Reflexive (_⊆_ {n}) ⊆-refl = id ⊆-reflexive : ∀ {n} → _≡_ ⇒ (_⊆_ {n}) ⊆-reflexive refl = ⊆-refl ⊆-trans : ∀ {n} → Transitive (_⊆_ {n}) ⊆-trans p⊆q q⊆r x∈p = q⊆r (p⊆q x∈p) ⊆-antisym : ∀ {n} → Antisymmetric _≡_ (_⊆_ {n}) ⊆-antisym {i = []} {[]} p⊆q q⊆p = refl ⊆-antisym {i = x ∷ xs} {y ∷ ys} p⊆q q⊆p with x | y ... | inside | inside = cong₂ _∷_ refl (⊆-antisym (drop-∷-⊆ p⊆q) (drop-∷-⊆ q⊆p)) ... | inside | outside = contradiction (p⊆q here) λ() ... | outside | inside = contradiction (q⊆p here) λ() ... | outside | outside = cong₂ _∷_ refl (⊆-antisym (drop-∷-⊆ p⊆q) (drop-∷-⊆ q⊆p)) ⊆-min : ∀ {n} → Minimum (_⊆_ {n}) ⊥ ⊆-min [] () ⊆-min (x ∷ xs) (there v∈⊥) = there (⊆-min xs v∈⊥) ⊆-max : ∀ {n} → Maximum (_⊆_ {n}) ⊤ ⊆-max [] () ⊆-max (inside ∷ xs) here = here ⊆-max (x ∷ xs) (there v∈xs) = there (⊆-max xs v∈xs) infix 4 _⊆?_ _⊆?_ : ∀ {n} → B.Decidable (_⊆_ {n = n}) [] ⊆? [] = yes id outside ∷ p ⊆? y ∷ q with p ⊆? q ... | yes p⊆q = yes λ { (there v∈p) → there (p⊆q v∈p)} ... | no p⊈q = no (p⊈q ∘ drop-∷-⊆) inside ∷ p ⊆? outside ∷ q = no (λ p⊆q → case (p⊆q here) of λ()) inside ∷ p ⊆? inside ∷ q with p ⊆? q ... | yes p⊆q = yes λ { here → here ; (there v) → there (p⊆q v)} ... | no p⊈q = no (p⊈q ∘ drop-∷-⊆) module _ (n : ℕ) where ⊆-isPreorder : IsPreorder _≡_ (_⊆_ {n}) ⊆-isPreorder = record { isEquivalence = isEquivalence ; reflexive = ⊆-reflexive ; trans = ⊆-trans } ⊆-preorder : Preorder _ _ _ ⊆-preorder = record { isPreorder = ⊆-isPreorder } ⊆-isPartialOrder : IsPartialOrder _≡_ (_⊆_ {n}) ⊆-isPartialOrder = record { isPreorder = ⊆-isPreorder ; antisym = ⊆-antisym } ⊆-poset : Poset _ _ _ ⊆-poset = record { isPartialOrder = ⊆-isPartialOrder } p⊆q⇒∣p∣<∣q∣ : ∀ {n} {p q : Subset n} → p ⊆ q → ∣ p ∣ ≤ ∣ q ∣ p⊆q⇒∣p∣<∣q∣ {p = []} {[]} p⊆q = z≤n p⊆q⇒∣p∣<∣q∣ {p = outside ∷ p} {outside ∷ q} p⊆q = p⊆q⇒∣p∣<∣q∣ (drop-∷-⊆ p⊆q) p⊆q⇒∣p∣<∣q∣ {p = outside ∷ p} {inside ∷ q} p⊆q = ≤-step (p⊆q⇒∣p∣<∣q∣ (drop-∷-⊆ p⊆q)) p⊆q⇒∣p∣<∣q∣ {p = inside ∷ p} {outside ∷ q} p⊆q = contradiction (p⊆q here) λ() p⊆q⇒∣p∣<∣q∣ {p = inside ∷ p} {inside ∷ q} p⊆q = s≤s (p⊆q⇒∣p∣<∣q∣ (drop-∷-⊆ p⊆q)) ------------------------------------------------------------------------ -- _∩_ module _ {n : ℕ} where open AlgebraicProperties {A = Subset n} _≡_ ∩-assoc : Associative _∩_ ∩-assoc = zipWith-assoc ∧-assoc ∩-comm : Commutative _∩_ ∩-comm = zipWith-comm ∧-comm ∩-idem : Idempotent _∩_ ∩-idem = zipWith-idem ∧-idem ∩-identityˡ : LeftIdentity ⊤ _∩_ ∩-identityˡ = zipWith-identityˡ ∧-identityˡ ∩-identityʳ : RightIdentity ⊤ _∩_ ∩-identityʳ = zipWith-identityʳ ∧-identityʳ ∩-identity : Identity ⊤ _∩_ ∩-identity = ∩-identityˡ , ∩-identityʳ ∩-zeroˡ : LeftZero ⊥ _∩_ ∩-zeroˡ = zipWith-zeroˡ ∧-zeroˡ ∩-zeroʳ : RightZero ⊥ _∩_ ∩-zeroʳ = zipWith-zeroʳ ∧-zeroʳ ∩-zero : Zero ⊥ _∩_ ∩-zero = ∩-zeroˡ , ∩-zeroʳ ∩-inverseˡ : LeftInverse ⊥ ∁ _∩_ ∩-inverseˡ = zipWith-inverseˡ ∧-inverseˡ ∩-inverseʳ : RightInverse ⊥ ∁ _∩_ ∩-inverseʳ = zipWith-inverseʳ ∧-inverseʳ ∩-inverse : Inverse ⊥ ∁ _∩_ ∩-inverse = ∩-inverseˡ , ∩-inverseʳ module _ (n : ℕ) where open AlgebraicStructures {A = Subset n} _≡_ ∩-isMagma : IsMagma _∩_ ∩-isMagma = record { isEquivalence = isEquivalence ; ∙-cong = cong₂ _∩_ } ∩-magma : Magma _ _ ∩-magma = record { isMagma = ∩-isMagma } ∩-isSemigroup : IsSemigroup _∩_ ∩-isSemigroup = record { isMagma = ∩-isMagma ; assoc = ∩-assoc } ∩-semigroup : Semigroup _ _ ∩-semigroup = record { isSemigroup = ∩-isSemigroup } ∩-isBand : IsBand _∩_ ∩-isBand = record { isSemigroup = ∩-isSemigroup ; idem = ∩-idem } ∩-band : Band _ _ ∩-band = record { isBand = ∩-isBand } ∩-isSemilattice : IsSemilattice _∩_ ∩-isSemilattice = record { isBand = ∩-isBand ; comm = ∩-comm } ∩-semilattice : Semilattice _ _ ∩-semilattice = record { isSemilattice = ∩-isSemilattice } ∩-isMonoid : IsMonoid _∩_ ⊤ ∩-isMonoid = record { isSemigroup = ∩-isSemigroup ; identity = ∩-identity } ∩-monoid : Monoid _ _ ∩-monoid = record { isMonoid = ∩-isMonoid } ∩-isCommutativeMonoid : IsCommutativeMonoid _∩_ ⊤ ∩-isCommutativeMonoid = record { isSemigroup = ∩-isSemigroup ; identityˡ = ∩-identityˡ ; comm = ∩-comm } ∩-commutativeMonoid : CommutativeMonoid _ _ ∩-commutativeMonoid = record { isCommutativeMonoid = ∩-isCommutativeMonoid } ∩-isIdempotentCommutativeMonoid : IsIdempotentCommutativeMonoid _∩_ ⊤ ∩-isIdempotentCommutativeMonoid = record { isCommutativeMonoid = ∩-isCommutativeMonoid ; idem = ∩-idem } ∩-idempotentCommutativeMonoid : IdempotentCommutativeMonoid _ _ ∩-idempotentCommutativeMonoid = record { isIdempotentCommutativeMonoid = ∩-isIdempotentCommutativeMonoid } p∩q⊆p : ∀ {n} (p q : Subset n) → p ∩ q ⊆ p p∩q⊆p [] [] x∈p∩q = x∈p∩q p∩q⊆p (inside ∷ p) (inside ∷ q) here = here p∩q⊆p (inside ∷ p) (_ ∷ q) (there ∈p∩q) = there (p∩q⊆p p q ∈p∩q) p∩q⊆p (outside ∷ p) (_ ∷ q) (there ∈p∩q) = there (p∩q⊆p p q ∈p∩q) p∩q⊆q : ∀ {n} (p q : Subset n) → p ∩ q ⊆ q p∩q⊆q p q rewrite ∩-comm p q = p∩q⊆p q p x∈p∩q⁺ : ∀ {n} {p q : Subset n} {x} → x ∈ p × x ∈ q → x ∈ p ∩ q x∈p∩q⁺ (here , here) = here x∈p∩q⁺ (there x∈p , there x∈q) = there (x∈p∩q⁺ (x∈p , x∈q)) x∈p∩q⁻ : ∀ {n} (p q : Subset n) {x} → x ∈ p ∩ q → x ∈ p × x ∈ q x∈p∩q⁻ [] [] () x∈p∩q⁻ (inside ∷ p) (inside ∷ q) here = here , here x∈p∩q⁻ (s ∷ p) (t ∷ q) (there x∈p∩q) = Product.map there there (x∈p∩q⁻ p q x∈p∩q) ∩⇔× : ∀ {n} {p q : Subset n} {x} → x ∈ p ∩ q ⇔ (x ∈ p × x ∈ q) ∩⇔× = equivalence (x∈p∩q⁻ _ _) x∈p∩q⁺ ------------------------------------------------------------------------ -- _∪_ module _ {n : ℕ} where open AlgebraicProperties {A = Subset n} _≡_ ∪-assoc : Associative _∪_ ∪-assoc = zipWith-assoc ∨-assoc ∪-comm : Commutative _∪_ ∪-comm = zipWith-comm ∨-comm ∪-idem : Idempotent _∪_ ∪-idem = zipWith-idem ∨-idem ∪-identityˡ : LeftIdentity ⊥ _∪_ ∪-identityˡ = zipWith-identityˡ ∨-identityˡ ∪-identityʳ : RightIdentity ⊥ _∪_ ∪-identityʳ = zipWith-identityʳ ∨-identityʳ ∪-identity : Identity ⊥ _∪_ ∪-identity = ∪-identityˡ , ∪-identityʳ ∪-zeroˡ : LeftZero ⊤ _∪_ ∪-zeroˡ = zipWith-zeroˡ ∨-zeroˡ ∪-zeroʳ : RightZero ⊤ _∪_ ∪-zeroʳ = zipWith-zeroʳ ∨-zeroʳ ∪-zero : Zero ⊤ _∪_ ∪-zero = ∪-zeroˡ , ∪-zeroʳ ∪-inverseˡ : LeftInverse ⊤ ∁ _∪_ ∪-inverseˡ = zipWith-inverseˡ ∨-inverseˡ ∪-inverseʳ : RightInverse ⊤ ∁ _∪_ ∪-inverseʳ = zipWith-inverseʳ ∨-inverseʳ ∪-inverse : Inverse ⊤ ∁ _∪_ ∪-inverse = ∪-inverseˡ , ∪-inverseʳ ∪-distribˡ-∩ : _∪_ DistributesOverˡ _∩_ ∪-distribˡ-∩ = zipWith-distribˡ ∨-distribˡ-∧ ∪-distribʳ-∩ : _∪_ DistributesOverʳ _∩_ ∪-distribʳ-∩ = zipWith-distribʳ ∨-distribʳ-∧ ∪-distrib-∩ : _∪_ DistributesOver _∩_ ∪-distrib-∩ = ∪-distribˡ-∩ , ∪-distribʳ-∩ ∩-distribˡ-∪ : _∩_ DistributesOverˡ _∪_ ∩-distribˡ-∪ = zipWith-distribˡ ∧-distribˡ-∨ ∩-distribʳ-∪ : _∩_ DistributesOverʳ _∪_ ∩-distribʳ-∪ = zipWith-distribʳ ∧-distribʳ-∨ ∩-distrib-∪ : _∩_ DistributesOver _∪_ ∩-distrib-∪ = ∩-distribˡ-∪ , ∩-distribʳ-∪ ∪-abs-∩ : _∪_ Absorbs _∩_ ∪-abs-∩ = zipWith-absorbs ∨-abs-∧ ∩-abs-∪ : _∩_ Absorbs _∪_ ∩-abs-∪ = zipWith-absorbs ∧-abs-∨ module _ (n : ℕ) where open AlgebraicStructures {A = Subset n} _≡_ ∪-isMagma : IsMagma _∪_ ∪-isMagma = record { isEquivalence = isEquivalence ; ∙-cong = cong₂ _∪_ } ∪-magma : Magma _ _ ∪-magma = record { isMagma = ∪-isMagma } ∪-isSemigroup : IsSemigroup _∪_ ∪-isSemigroup = record { isMagma = ∪-isMagma ; assoc = ∪-assoc } ∪-semigroup : Semigroup _ _ ∪-semigroup = record { isSemigroup = ∪-isSemigroup } ∪-isBand : IsBand _∪_ ∪-isBand = record { isSemigroup = ∪-isSemigroup ; idem = ∪-idem } ∪-band : Band _ _ ∪-band = record { isBand = ∪-isBand } ∪-isSemilattice : IsSemilattice _∪_ ∪-isSemilattice = record { isBand = ∪-isBand ; comm = ∪-comm } ∪-semilattice : Semilattice _ _ ∪-semilattice = record { isSemilattice = ∪-isSemilattice } ∪-isMonoid : IsMonoid _∪_ ⊥ ∪-isMonoid = record { isSemigroup = ∪-isSemigroup ; identity = ∪-identity } ∪-monoid : Monoid _ _ ∪-monoid = record { isMonoid = ∪-isMonoid } ∪-isCommutativeMonoid : IsCommutativeMonoid _∪_ ⊥ ∪-isCommutativeMonoid = record { isSemigroup = ∪-isSemigroup ; identityˡ = ∪-identityˡ ; comm = ∪-comm } ∪-commutativeMonoid : CommutativeMonoid _ _ ∪-commutativeMonoid = record { isCommutativeMonoid = ∪-isCommutativeMonoid } ∪-isIdempotentCommutativeMonoid : IsIdempotentCommutativeMonoid _∪_ ⊥ ∪-isIdempotentCommutativeMonoid = record { isCommutativeMonoid = ∪-isCommutativeMonoid ; idem = ∪-idem } ∪-idempotentCommutativeMonoid : IdempotentCommutativeMonoid _ _ ∪-idempotentCommutativeMonoid = record { isIdempotentCommutativeMonoid = ∪-isIdempotentCommutativeMonoid } ∪-∩-isLattice : IsLattice _∪_ _∩_ ∪-∩-isLattice = record { isEquivalence = isEquivalence ; ∨-comm = ∪-comm ; ∨-assoc = ∪-assoc ; ∨-cong = cong₂ _∪_ ; ∧-comm = ∩-comm ; ∧-assoc = ∩-assoc ; ∧-cong = cong₂ _∩_ ; absorptive = ∪-abs-∩ , ∩-abs-∪ } ∪-∩-lattice : Lattice _ _ ∪-∩-lattice = record { isLattice = ∪-∩-isLattice } ∪-∩-isDistributiveLattice : IsDistributiveLattice _∪_ _∩_ ∪-∩-isDistributiveLattice = record { isLattice = ∪-∩-isLattice ; ∨-∧-distribʳ = ∪-distribʳ-∩ } ∪-∩-distributiveLattice : DistributiveLattice _ _ ∪-∩-distributiveLattice = record { isDistributiveLattice = ∪-∩-isDistributiveLattice } ∪-∩-isBooleanAlgebra : IsBooleanAlgebra _∪_ _∩_ ∁ ⊤ ⊥ ∪-∩-isBooleanAlgebra = record { isDistributiveLattice = ∪-∩-isDistributiveLattice ; ∨-complementʳ = ∪-inverseʳ ; ∧-complementʳ = ∩-inverseʳ ; ¬-cong = cong ∁ } ∪-∩-booleanAlgebra : BooleanAlgebra _ _ ∪-∩-booleanAlgebra = record { isBooleanAlgebra = ∪-∩-isBooleanAlgebra } ∩-∪-isLattice : IsLattice _∩_ _∪_ ∩-∪-isLattice = L.∧-∨-isLattice ∪-∩-lattice ∩-∪-lattice : Lattice _ _ ∩-∪-lattice = L.∧-∨-lattice ∪-∩-lattice ∩-∪-isDistributiveLattice : IsDistributiveLattice _∩_ _∪_ ∩-∪-isDistributiveLattice = DL.∧-∨-isDistributiveLattice ∪-∩-distributiveLattice ∩-∪-distributiveLattice : DistributiveLattice _ _ ∩-∪-distributiveLattice = DL.∧-∨-distributiveLattice ∪-∩-distributiveLattice ∩-∪-isBooleanAlgebra : IsBooleanAlgebra _∩_ _∪_ ∁ ⊥ ⊤ ∩-∪-isBooleanAlgebra = BA.∧-∨-isBooleanAlgebra ∪-∩-booleanAlgebra ∩-∪-booleanAlgebra : BooleanAlgebra _ _ ∩-∪-booleanAlgebra = BA.∧-∨-booleanAlgebra ∪-∩-booleanAlgebra p⊆p∪q : ∀ {n p} (q : Subset n) → p ⊆ p ∪ q p⊆p∪q [] () p⊆p∪q (s ∷ q) here = here p⊆p∪q (s ∷ q) (there x∈p) = there (p⊆p∪q q x∈p) q⊆p∪q : ∀ {n} (p q : Subset n) → q ⊆ p ∪ q q⊆p∪q p q rewrite ∪-comm p q = p⊆p∪q p x∈p∪q⁻ : ∀ {n} (p q : Subset n) {x} → x ∈ p ∪ q → x ∈ p ⊎ x ∈ q x∈p∪q⁻ [] [] () x∈p∪q⁻ (inside ∷ p) (t ∷ q) here = inj₁ here x∈p∪q⁻ (outside ∷ p) (inside ∷ q) here = inj₂ here x∈p∪q⁻ (s ∷ p) (t ∷ q) (there x∈p∪q) = Sum.map there there (x∈p∪q⁻ p q x∈p∪q) x∈p∪q⁺ : ∀ {n} {p q : Subset n} {x} → x ∈ p ⊎ x ∈ q → x ∈ p ∪ q x∈p∪q⁺ (inj₁ x∈p) = p⊆p∪q _ x∈p x∈p∪q⁺ (inj₂ x∈q) = q⊆p∪q _ _ x∈q ∪⇔⊎ : ∀ {n} {p q : Subset n} {x} → x ∈ p ∪ q ⇔ (x ∈ p ⊎ x ∈ q) ∪⇔⊎ = equivalence (x∈p∪q⁻ _ _) x∈p∪q⁺ ------------------------------------------------------------------------ -- Lift Lift? : ∀ {n p} {P : Pred (Fin n) p} → Decidable P → Decidable (Lift P) Lift? P? p = decFinSubset (_∈? p) (λ {x} _ → P? x) ------------------------------------------------------------------------ -- Other anySubset? : ∀ {n} {P : Subset n → Set} → Decidable P → Dec (∃ P) anySubset? {zero} P? with P? [] ... | yes P[] = yes (_ , P[]) ... | no ¬P[] = no (λ {([] , P[]) → ¬P[] P[]}) anySubset? {suc n} P? with anySubset? (P? ∘ (inside ∷_)) ... | yes (_ , Pp) = yes (_ , Pp) ... | no ¬Pp with anySubset? (P? ∘ (outside ∷_)) ... | yes (_ , Pp) = yes (_ , Pp) ... | no ¬Pp' = no λ { (inside ∷ p , Pp) → ¬Pp (_ , Pp) ; (outside ∷ p , Pp') → ¬Pp' (_ , Pp') }
{ "alphanum_fraction": 0.5170145326, "avg_line_length": 28.0553691275, "ext": "agda", "hexsha": "e24fa2743654833b05d579e2d01e2d5c52d8c3bf", "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/Fin/Subset/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/Fin/Subset/Properties.agda", "max_line_length": 85, "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/Fin/Subset/Properties.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 7874, "size": 16721 }
module Haskell.Prim.Functor where open import Haskell.Prim open import Haskell.Prim.Either open import Haskell.Prim.List open import Haskell.Prim.Maybe open import Haskell.Prim.Tuple -------------------------------------------------- -- Functor record Functor (f : Set → Set) : Set₁ where field fmap : (a → b) → f a → f b infixl 1 _<&>_ infixl 4 _<$>_ _<$_ _$>_ _<$>_ : (a → b) → f a → f b _<$>_ = fmap _<&>_ : f a → (a → b) → f b m <&> f = fmap f m _<$_ : a → f b → f a x <$ m = fmap (const x) m _$>_ : f a → b → f b m $> x = x <$ m void : f a → f (Tuple []) void = [] <$_ open Functor ⦃ ... ⦄ public instance iFunctorList : Functor List iFunctorList .fmap = map iFunctorMaybe : Functor Maybe iFunctorMaybe .fmap f Nothing = Nothing iFunctorMaybe .fmap f (Just x) = Just (f x) iFunctorEither : Functor (Either a) iFunctorEither .fmap f (Left x) = Left x iFunctorEither .fmap f (Right y) = Right (f y) iFunctorFun : Functor (λ b → a → b) iFunctorFun .fmap = _∘_ iFunctorTuple₂ : Functor (a ×_) iFunctorTuple₂ .fmap f (x , y) = x , f y iFunctorTuple₃ : Functor (a × b ×_) iFunctorTuple₃ .fmap f (x , y , z) = x , y , f z iFunctorTuple₄ : Functor (λ d → Tuple (a ∷ b ∷ c ∷ d ∷ [])) iFunctorTuple₄ .fmap f (x ∷ y ∷ z ∷ w ∷ []) = x ∷ y ∷ z ∷ f w ∷ []
{ "alphanum_fraction": 0.5590669676, "avg_line_length": 22.15, "ext": "agda", "hexsha": "110e22419bda3212f498bcff730e3b80eecdda9a", "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": "4cb28f1b5032948b19b977b390fa260be292abf6", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "flupe/agda2hs", "max_forks_repo_path": "lib/Haskell/Prim/Functor.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "4cb28f1b5032948b19b977b390fa260be292abf6", "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": "flupe/agda2hs", "max_issues_repo_path": "lib/Haskell/Prim/Functor.agda", "max_line_length": 68, "max_stars_count": null, "max_stars_repo_head_hexsha": "4cb28f1b5032948b19b977b390fa260be292abf6", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "flupe/agda2hs", "max_stars_repo_path": "lib/Haskell/Prim/Functor.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 516, "size": 1329 }
{-# OPTIONS --without-K #-} open import lib.Base module test.succeed.Test0 where module _ where private data #I : Type₀ where #zero : #I #one : #I I : Type₀ I = #I zero : I zero = #zero one : I one = #one postulate seg : zero == one I-elim : ∀ {i} {P : I → Type i} (zero* : P zero) (one* : P one) (seg* : zero* == one* [ P ↓ seg ]) → Π I P I-elim zero* one* seg* #zero = zero* I-elim zero* one* seg* #one = one* postulate I-seg-β : ∀ {i} {P : I → Type i} (zero* : P zero) (one* : P one) (seg* : zero* == one* [ P ↓ seg ]) → apd (I-elim zero* one* seg*) seg == seg* test : ∀ {i} {P : I → Type i} (zero* : P zero) (one* : P one) (seg* : zero* == one* [ P ↓ seg ]) → (I-elim zero* one* seg*) zero == zero* test zero* one* seg* = idp
{ "alphanum_fraction": 0.4722550177, "avg_line_length": 21.175, "ext": "agda", "hexsha": "bfed118fef3b1df941d3855b43f8059a4851ae70", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "939a2d83e090fcc924f69f7dfa5b65b3b79fe633", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "nicolaikraus/HoTT-Agda", "max_forks_repo_path": "test/succeed/Test0.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "939a2d83e090fcc924f69f7dfa5b65b3b79fe633", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "nicolaikraus/HoTT-Agda", "max_issues_repo_path": "test/succeed/Test0.agda", "max_line_length": 68, "max_stars_count": 1, "max_stars_repo_head_hexsha": "f8fa68bf753d64d7f45556ca09d0da7976709afa", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "UlrikBuchholtz/HoTT-Agda", "max_stars_repo_path": "test/succeed/Test0.agda", "max_stars_repo_stars_event_max_datetime": "2021-06-30T00:17:55.000Z", "max_stars_repo_stars_event_min_datetime": "2021-06-30T00:17:55.000Z", "num_tokens": 317, "size": 847 }
{-# OPTIONS --rewriting #-} data FALSE : Set where CONTRADICTION : ∀ {A : Set} → FALSE → A CONTRADICTION () record TRUE : Set where {-# BUILTIN UNIT TRUE #-} data Bool : Set where false true : Bool {-# BUILTIN BOOL Bool #-} {-# BUILTIN TRUE true #-} {-# BUILTIN FALSE false #-} data Nat : Set where zero : Nat suc : Nat → Nat {-# BUILTIN NATURAL Nat #-} _+_ : Nat → Nat → Nat zero + m = m suc n + m = suc (n + m) {-# BUILTIN NATPLUS _+_ #-} _-_ : Nat → Nat → Nat n - zero = n zero - suc m = zero suc n - suc m = n - m {-# BUILTIN NATMINUS _-_ #-} _*_ : Nat → Nat → Nat zero * m = zero suc n * m = (n * m) + m {-# BUILTIN NATTIMES _*_ #-} _==_ : Nat → Nat → Bool zero == zero = true suc n == suc m = n == m _ == _ = false {-# BUILTIN NATEQUALS _==_ #-} postulate String : Set {-# BUILTIN STRING String #-} primitive primStringAppend : String → String → String primStringEquality : String → String → Bool _+++_ = primStringAppend _===_ = primStringEquality data List(A : Set) : Set where nil : List(A) _::_ : A → List(A) → List(A) {-# BUILTIN LIST List #-} data _≡_ {a} {A : Set a} (x : A) : A → Set a where refl : x ≡ x {-# BUILTIN EQUALITY _≡_ #-} {-# BUILTIN REWRITE _≡_ #-} cong : ∀ {a} {X Y : Set a} {x y : X} (f : X → Y) → (x ≡ y) → (f x ≡ f y) cong f refl = refl _≢_ : ∀ {a} {A : Set a} → A → A → Set a (x ≢ y) = (x ≡ y) → FALSE data Dec(A : Set) : Set where yes : A → Dec(A) no : (A → FALSE) → Dec(A) primitive primEraseEquality : ∀ {a} {A : Set a} {x y : A} → x ≡ y → x ≡ y primTrustMe : ∀ {a} {A : Set a} {x y : A} → x ≡ y primTrustMe {x = x} {y} = primEraseEquality unsafePrimTrustMe where postulate unsafePrimTrustMe : x ≡ y _≟String_ : (s t : String) → Dec(s ≡ t) (s ≟String t) with primStringEquality s t (s ≟String t) | true = yes primTrustMe (s ≟String t) | false = no unsafeNo where postulate unsafeNo : s ≢ t _≟Nat_ : (m n : Nat) → Dec(m ≡ n) (m ≟Nat n) with m == n (m ≟Nat n) | true = yes primTrustMe (m ≟Nat n) | false = no unsafeNo where postulate unsafeNo : m ≢ n data _≤_ : Nat → Nat → Set where zero : ∀ {x} → zero ≤ x suc : ∀ {x y} → (x ≤ y) → (suc x ≤ suc y) _≤?_ : (x y : Nat) → Dec(x ≤ y) zero ≤? y = yes zero suc x ≤? zero = no (λ ()) suc x ≤? suc y with (x ≤? y) ... | yes p = yes (suc p) ... | no p = no (λ { (suc q) → p q }) _<_ : Nat → Nat → Set m < n = (n ≤ m) → FALSE asym : ∀ {m n} → (m ≤ n) → (n ≤ m) → (m ≡ n) asym zero zero = refl asym (suc p) (suc q) with asym p q asym (suc p) (suc q) | refl = refl if : ∀ {X Y : Set} → Dec(X) → Y → Y → Y if (yes p) x y = x if (no p) x y = y +zero : ∀ {m} → (m + zero) ≡ m +zero {zero} = refl +zero {suc m} = cong suc +zero +suc : ∀ {m n} → (m + suc n) ≡ suc (m + n) +suc {zero} = refl +suc {suc m} = cong suc +suc {-# REWRITE +zero +suc #-}
{ "alphanum_fraction": 0.532953331, "avg_line_length": 22.456, "ext": "agda", "hexsha": "252de9cf9f1ad3f2693a1de66fa39060572263a9", "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": "de2ae6c24d001b85a5032c9e06cc731557dbc5e5", "max_forks_repo_licenses": [ "CC0-1.0" ], "max_forks_repo_name": "asajeffrey/tapl", "max_forks_repo_path": "prelude.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "de2ae6c24d001b85a5032c9e06cc731557dbc5e5", "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": "asajeffrey/tapl", "max_issues_repo_path": "prelude.agda", "max_line_length": 72, "max_stars_count": 3, "max_stars_repo_head_hexsha": "de2ae6c24d001b85a5032c9e06cc731557dbc5e5", "max_stars_repo_licenses": [ "CC0-1.0" ], "max_stars_repo_name": "asajeffrey/tapl", "max_stars_repo_path": "prelude.agda", "max_stars_repo_stars_event_max_datetime": "2021-03-15T12:09:59.000Z", "max_stars_repo_stars_event_min_datetime": "2021-03-12T22:44:19.000Z", "num_tokens": 1122, "size": 2807 }
{-# OPTIONS --safe --without-K #-} module Categories.Examples.Functor.Sets where import Data.List as List import Data.List.Properties open import Data.Nat using (ℕ) import Data.Product as Product import Data.Vec as Vec import Data.Vec.Properties open import Function using (id; λ-; _$-) open import Relation.Binary.PropositionalEquality using (refl) open import Categories.Category.Discrete using (Discrete) open import Categories.Category.Instance.Sets open import Categories.Functor using (Endofunctor) open import Categories.Functor.Bifunctor using (Bifunctor; appʳ) List : ∀ {o} → Endofunctor (Sets o) List = record { F₀ = List.List ; F₁ = List.map ; identity = map-id $- ; homomorphism = map-compose $- ; F-resp-≈ = λ f≈g → map-cong (λ- f≈g) $- } where open Data.List.Properties Vec′ : ∀ {o} → Bifunctor (Sets o) (Discrete ℕ) (Sets o) Vec′ = record { F₀ = Product.uncurry Vec.Vec ; F₁ = λ { (f , refl) → Vec.map f } ; identity = map-id $- ; homomorphism = λ { {_} {_} {_} {f , refl} {g , refl} → map-∘ g f _} ; F-resp-≈ = λ { {_} {_} {_} {_ , refl} (g , refl) → map-cong (λ- g) _} } where open Product using (_,_) open Data.Vec.Properties Vec : ∀ {o} → ℕ → Endofunctor (Sets o) Vec = appʳ Vec′
{ "alphanum_fraction": 0.6567524116, "avg_line_length": 28.9302325581, "ext": "agda", "hexsha": "a1a865a7319f6a4f09f4cbf6bfc1de75dce829b0", "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": "adfa1dee4f27286a2943863d7a0302e6ba26fffd", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "bond15/categories-examples", "max_forks_repo_path": "src/Categories/Examples/Functor/Sets.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "adfa1dee4f27286a2943863d7a0302e6ba26fffd", "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": "bond15/categories-examples", "max_issues_repo_path": "src/Categories/Examples/Functor/Sets.agda", "max_line_length": 73, "max_stars_count": null, "max_stars_repo_head_hexsha": "adfa1dee4f27286a2943863d7a0302e6ba26fffd", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "bond15/categories-examples", "max_stars_repo_path": "src/Categories/Examples/Functor/Sets.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 412, "size": 1244 }
{-# OPTIONS --safe #-} open import Definition.Typed.EqualityRelation module Definition.LogicalRelation.Properties {{eqrel : EqRelSet}} where open import Definition.LogicalRelation.Properties.Reflexivity public open import Definition.LogicalRelation.Properties.Symmetry public open import Definition.LogicalRelation.Properties.Transitivity public open import Definition.LogicalRelation.Properties.Conversion public open import Definition.LogicalRelation.Properties.Escape public open import Definition.LogicalRelation.Properties.Universe public open import Definition.LogicalRelation.Properties.Neutral public open import Definition.LogicalRelation.Properties.Reduction public open import Definition.LogicalRelation.Properties.Successor public open import Definition.LogicalRelation.Properties.MaybeEmb public
{ "alphanum_fraction": 0.8720787208, "avg_line_length": 45.1666666667, "ext": "agda", "hexsha": "453f9b49d5db60347a609bc48fb8cde3dafe36bf", "lang": "Agda", "max_forks_count": 2, "max_forks_repo_forks_event_max_datetime": "2022-02-15T19:42:19.000Z", "max_forks_repo_forks_event_min_datetime": "2022-01-26T14:55:51.000Z", "max_forks_repo_head_hexsha": "e0eeebc4aa5ed791ce3e7c0dc9531bd113dfcc04", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "CoqHott/logrel-mltt", "max_forks_repo_path": "Definition/LogicalRelation/Properties.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "e0eeebc4aa5ed791ce3e7c0dc9531bd113dfcc04", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "CoqHott/logrel-mltt", "max_issues_repo_path": "Definition/LogicalRelation/Properties.agda", "max_line_length": 71, "max_stars_count": 2, "max_stars_repo_head_hexsha": "e0eeebc4aa5ed791ce3e7c0dc9531bd113dfcc04", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "CoqHott/logrel-mltt", "max_stars_repo_path": "Definition/LogicalRelation/Properties.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": 141, "size": 813 }
{-# OPTIONS --without-K #-} open import HoTT open import cohomology.Exactness open import cohomology.Theory module cohomology.Unit {i} (CT : CohomologyTheory i) where open CohomologyTheory CT private ⊙LU = ⊙Lift {j = i} ⊙Unit G : fst (⊙CEl O (⊙Cof (⊙idf _)) ⊙→ ⊙CEl O ⊙LU) G = CF O (⊙cfcod (⊙idf _)) Cof-Unit-is-Unit : ⊙Cof (⊙idf ⊙LU) == ⊙LU Cof-Unit-is-Unit = ⊙ua e idp where e = equiv (λ _ → lift unit) (λ _ → cfbase (idf _)) (λ _ → idp) (Cofiber-elim (idf _) {P = λ c → cfbase (idf _) == c} idp (λ _ → cfglue (idf _) (lift unit)) (λ _ → ↓-cst=idf-in idp)) cfcod-is-idf : Path {A = Σ (Ptd i) (λ X → fst (⊙LU ⊙→ X))} (⊙Cof (⊙idf _) , ⊙cfcod (⊙idf _)) (⊙LU , ⊙idf _) cfcod-is-idf = pair= Cof-Unit-is-Unit (prop-has-all-paths-↓ (⊙→-level (Lift-level Unit-is-prop))) C₀-Unit-is-contr : is-contr (CEl O ⊙LU) C₀-Unit-is-contr = (Cid O ⊙LU , λ x → lemma₂ x ∙ app= (ap GroupHom.f (CF-ident O)) x) where lemma₁ : (x : CEl O (⊙Cof (⊙idf _))) → Cid O ⊙LU == fst G x lemma₁ x = ! (itok (C-exact O (⊙idf _)) (fst G x) [ x , idp ]) ∙ app= (ap GroupHom.f (CF-ident O)) (fst G x) lemma₂ : (x : CEl O ⊙LU) → Cid O ⊙LU == fst (CF O (⊙idf _)) x lemma₂ = transport {A = Σ (Ptd i) (λ X → fst (⊙LU ⊙→ X))} (λ {(X , H) → (c : CEl O X) → Cid O ⊙LU == fst (CF O H) c}) cfcod-is-idf lemma₁ Unit-is-Susp-Unit : ⊙LU == ⊙Susp ⊙LU Unit-is-Susp-Unit = ⊙ua (equiv (λ _ → north _) (λ _ → lift unit) (Suspension-elim _ {P = λ s → north _ == s} idp (merid _ (lift unit)) (λ _ → ↓-cst=idf-in idp)) (λ _ → idp)) idp C-Unit-is-trivial : (n : ℤ) → C n ⊙LU == LiftUnit-Group C-Unit-is-trivial O = contr-is-0ᴳ _ C₀-Unit-is-contr C-Unit-is-trivial (pos O) = ap (C (pos O)) Unit-is-Susp-Unit ∙ C-Susp O ⊙LU ∙ (contr-is-0ᴳ _ C₀-Unit-is-contr) C-Unit-is-trivial (pos (S m)) = ap (C (pos (S m))) Unit-is-Susp-Unit ∙ C-Susp (pos m) ⊙LU ∙ C-Unit-is-trivial (pos m) C-Unit-is-trivial (neg O) = ! (C-Susp (neg O) ⊙LU) ∙ ! (ap (C O) Unit-is-Susp-Unit) ∙ (contr-is-0ᴳ _ C₀-Unit-is-contr) C-Unit-is-trivial (neg (S m)) = ! (C-Susp (neg (S m)) ⊙LU) ∙ ! (ap (C (neg m)) Unit-is-Susp-Unit) ∙ C-Unit-is-trivial (neg m) C-Unit-is-contr : (n : ℤ) → is-contr (CEl n ⊙LU) C-Unit-is-contr n = transport (is-contr ∘ Group.El) (! (C-Unit-is-trivial n)) (Lift-level Unit-is-contr) C-Unit-is-prop : (n : ℤ) → is-prop (CEl n ⊙LU) C-Unit-is-prop n = transport (is-prop ∘ Group.El) (! (C-Unit-is-trivial n)) (Lift-level Unit-is-prop)
{ "alphanum_fraction": 0.4957446809, "avg_line_length": 31.6853932584, "ext": "agda", "hexsha": "b18dc447d6e045abc896198d8aa31fb1f5098322", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "1695a7f3dc60177457855ae846bbd86fcd96983e", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "danbornside/HoTT-Agda", "max_forks_repo_path": "cohomology/Unit.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "1695a7f3dc60177457855ae846bbd86fcd96983e", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "danbornside/HoTT-Agda", "max_issues_repo_path": "cohomology/Unit.agda", "max_line_length": 70, "max_stars_count": null, "max_stars_repo_head_hexsha": "1695a7f3dc60177457855ae846bbd86fcd96983e", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "danbornside/HoTT-Agda", "max_stars_repo_path": "cohomology/Unit.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1154, "size": 2820 }
{- This file contains a proof of the fact that the Brunerie number, i.e. absolute value of the Hopf invariant of [e , e] : π₃S², is 2. Here, e is the generator of π₂S² and [_,_] denotes the Whitehead product. The proof follows Proposition 5.4.4. in Brunerie (2016) closely, but, for simplicity, considers only the case n = 2. -} {-# OPTIONS --safe --experimental-lossy-unification #-} module Cubical.Homotopy.HopfInvariant.Brunerie where open import Cubical.Homotopy.HopfInvariant.Base open import Cubical.Homotopy.Group.Pi4S3.BrunerieNumber open import Cubical.Homotopy.Group.Pi4S3.S3PushoutIso open import Cubical.Homotopy.Whitehead open import Cubical.ZCohomology.Base open import Cubical.ZCohomology.GroupStructure open import Cubical.ZCohomology.MayerVietorisUnreduced open import Cubical.ZCohomology.Groups.Sn open import Cubical.ZCohomology.Groups.Wedge open import Cubical.ZCohomology.Groups.SphereProduct open import Cubical.ZCohomology.RingStructure.CupProduct open import Cubical.ZCohomology.RingStructure.RingLaws open import Cubical.ZCohomology.RingStructure.GradedCommutativity open import Cubical.Foundations.Prelude open import Cubical.Foundations.HLevels open import Cubical.Foundations.Function open import Cubical.Foundations.Pointed open import Cubical.Foundations.Isomorphism open import Cubical.Foundations.GroupoidLaws open import Cubical.Foundations.Equiv open import Cubical.Data.Sigma open import Cubical.Data.Int hiding (_+'_) open import Cubical.Data.Nat hiding (_+_) open import Cubical.Data.Unit open import Cubical.Data.Sum renaming (rec to ⊎rec) open import Cubical.HITs.Pushout open import Cubical.HITs.S1 open import Cubical.HITs.Sn open import Cubical.HITs.Join open import Cubical.HITs.Susp open import Cubical.HITs.Wedge open import Cubical.HITs.Truncation open import Cubical.HITs.SetTruncation renaming (elim to sElim ; elim2 to sElim2 ; map to sMap) open import Cubical.HITs.PropositionalTruncation renaming (map to pMap ; rec to pRec) open import Cubical.Algebra.Group open import Cubical.Algebra.Group.ZAction open import Cubical.Algebra.Group.Exact open import Cubical.Algebra.Group.Morphisms open import Cubical.Algebra.Group.MorphismProperties open import Cubical.Algebra.Group.Instances.Int open import Cubical.Algebra.Group.Instances.Unit open Iso open IsGroupHom open PlusBis -- Some abstract versions of imported lemmas/definitions from -- ZCohomology.Groups.SphereProduct for faster type checking. abstract H²-genₗabs : coHom 2 (S₊ 2 × S₊ 2) H²-genₗabs = H²-S²×S²-genₗ H²-genᵣabs : coHom 2 (S₊ 2 × S₊ 2) H²-genᵣabs = H²-S²×S²-genᵣ Hⁿ⁺ᵐ-Sⁿ×Sᵐ≅ℤ-abs : (n m : ℕ) → GroupIso (coHomGr ((suc n) +' (suc m)) (S₊ (suc n) × S₊ (suc m))) ℤGroup Hⁿ⁺ᵐ-Sⁿ×Sᵐ≅ℤ-abs = Hⁿ⁺ᵐ-Sⁿ×Sᵐ≅ℤ Hⁿ⁺ᵐ-Sⁿ×Sᵐ≅ℤ-abs≡ : (n m : ℕ) → Hⁿ⁺ᵐ-Sⁿ×Sᵐ≅ℤ-abs n m ≡ Hⁿ⁺ᵐ-Sⁿ×Sᵐ≅ℤ n m Hⁿ⁺ᵐ-Sⁿ×Sᵐ≅ℤ-abs≡ n m = refl Hⁿ⁺ᵐ-Sⁿ×Sᵐ≅ℤ-⌣ : fun (fst (Hⁿ⁺ᵐ-Sⁿ×Sᵐ≅ℤ-abs 1 1)) (H²-S²×S²-genₗ ⌣ H²-S²×S²-genᵣ) ≡ 1 Hⁿ⁺ᵐ-Sⁿ×Sᵐ≅ℤ-⌣ = fun (fst (Hⁿ⁺ᵐ-Sⁿ×Sᵐ≅ℤ-abs 1 1)) (H²-S²×S²-genₗ ⌣ H²-S²×S²-genᵣ) ≡⟨ cong (fun (fst (Hⁿ⁺ᵐ-Sⁿ×Sᵐ≅ℤ-abs 1 1))) (sym H²-S²≅H⁴-S²×S²⌣) ⟩ fun (fst (Hⁿ⁺ᵐ-Sⁿ×Sᵐ≅ℤ-abs 1 1)) (fun (fst (H²-S²≅H⁴-S²×S²)) ∣ ∣_∣ₕ ∣₂) ≡⟨ speedUp ∣_∣ₕ ⟩ fun (fst (Hⁿ-Sⁿ≅ℤ 1)) ∣ ∣_∣ₕ ∣₂ ≡⟨ refl ⟩ -- Computation! :-) 1 ∎ where speedUp : (f : _) → fun (fst (Hⁿ⁺ᵐ-Sⁿ×Sᵐ≅ℤ-abs 1 1)) (fun (fst (H²-S²≅H⁴-S²×S²)) ∣ f ∣₂) ≡ fun (fst (Hⁿ-Sⁿ≅ℤ 1)) ∣ f ∣₂ speedUp f i = fun (fst (Hⁿ-Sⁿ≅ℤ 1)) (leftInv (fst H²-S²≅H⁴-S²×S²) ∣ f ∣₂ i) -- Some abbreviations private inl' : S₊ 2 × S₊ 2 → Pushout⋁↪fold⋁ (S₊∙ 2) inl' = inl qHom : GroupHom (coHomGr 4 (Pushout⋁↪fold⋁ (S₊∙ 2))) (coHomGr 4 (S₊ 2 × S₊ 2)) qHom = coHomMorph 4 inl' qHomGen : (n : ℕ) → GroupHom (coHomGr n (Pushout⋁↪fold⋁ (S₊∙ 2))) (coHomGr n (S₊ 2 × S₊ 2)) qHomGen n = coHomMorph n inl' -- The type C and generator α, β in dim 2 and 4 respectively -- Recall, the goal is to prove that α ⌣ α = ±2 β CHopf : Type CHopf = HopfInvariantPush 0 fold∘W Hopfαfold∘W = Hopfα 0 (fold∘W , refl) Hopfβfold∘W = Hopfβ 0 (fold∘W , refl) -- Rewriting CHopf as our favourite pushout -- S²×S² ← S²∨S² → S² CHopfIso : Iso CHopf (Pushout⋁↪fold⋁ (S₊∙ 2)) CHopfIso = compIso (invIso (equivToIso (compEquiv (compEquiv pushoutSwitchEquiv (isoToEquiv (PushoutDistr.PushoutDistrIso fold⋁ W λ _ → tt))) pushoutSwitchEquiv))) (equivToIso Pushout-coFibW-fold⋁≃Pushout⋁↪fold⋁) -- Cohomology group version of the Iso coHomCHopfIso : (n : ℕ) → GroupIso (coHomGr n CHopf) (coHomGr n (Pushout⋁↪fold⋁ (S₊∙ 2))) coHomCHopfIso n = invGroupIso (coHomIso n CHopfIso) -- We instantiate Mayer-Vietoris for the pushout module MV-⋁↪-fold⋁ = MV _ _ (S₊∙ 2 ⋁ S₊∙ 2) ⋁↪ fold⋁ -- This give us an iso H⁴(S²×S² ← S²∨S² → S²) ≅ H⁴(S²×S²) isEquiv-qHom : GroupEquiv (coHomGr 4 (Pushout⋁↪fold⋁ (S₊∙ 2))) (coHomGr 4 (S₊ 2 × S₊ 2)) fst (fst isEquiv-qHom) = qHom .fst snd (fst isEquiv-qHom) = subst isEquiv (funExt (sElim (λ _ → isSetPathImplicit) (λ _ → refl))) (×UnitEquiv (isoToPath (invIso (fst (Hⁿ-Sᵐ≅0 3 1 λ p → snotz (cong predℕ p))))) _ isEquiv-i) where ×UnitEquiv : {A B C : Type} → Unit ≡ C → (f : A → B × C) → isEquiv f → isEquiv (fst ∘ f) ×UnitEquiv {A = A} {B = B} = J (λ C _ → (f : A → B × C) → isEquiv f → isEquiv (fst ∘ f)) λ f eq → record { equiv-proof = λ b → ((fst (fst (equiv-proof eq (b , tt)))) , cong fst (fst (equiv-proof eq (b , tt)) .snd)) , λ y → ΣPathP ((cong fst (equiv-proof eq (b , tt) .snd ((fst y) , ΣPathP ((snd y) , refl)))) , λ i j → equiv-proof eq (b , tt) .snd ((fst y) , ΣPathP ((snd y) , refl)) i .snd j .fst) } isEquiv-i : isEquiv (fst (MV-⋁↪-fold⋁.i 4)) isEquiv-i = SES→isEquiv (isContr→≡UnitGroup (isOfHLevelRetractFromIso 0 (compIso (fst (Hⁿ-⋁ (S₊∙ 2) (S₊∙ 2) 2)) (compIso (prodIso (fst (Hⁿ-Sᵐ≅0 2 1 λ p → snotz (cong predℕ p))) (fst (Hⁿ-Sᵐ≅0 2 1 λ p → snotz (cong predℕ p)))) rUnit×Iso)) isContrUnit)) ((isContr→≡UnitGroup (isOfHLevelRetractFromIso 0 (compIso (fst (Hⁿ-⋁ (S₊∙ 2) (S₊∙ 2) 3)) (compIso (prodIso (fst (Hⁿ-Sᵐ≅0 3 1 λ p → snotz (cong predℕ p))) (fst (Hⁿ-Sᵐ≅0 3 1 λ p → snotz (cong predℕ p)))) rUnit×Iso)) isContrUnit))) (MV-⋁↪-fold⋁.d 3) (MV-⋁↪-fold⋁.i 4) (MV-⋁↪-fold⋁.Δ 4) (MV-⋁↪-fold⋁.Ker-i⊂Im-d 3) (MV-⋁↪-fold⋁.Ker-Δ⊂Im-i 4) snd isEquiv-qHom = qHom .snd -- The goal now is reducing α ⌣ α = ±2 β to gₗ ⌣ gᵣ = e for -- gₗ, gᵣ generators of H²(S²×S²) ≅ ℤ × ℤ and e generator of -- H⁴(S²×S²) ≅ ℤ. This essentially just elementary linear algebra at -- this point. We do it for an arbitrary (well-behaved) iso -- H⁴(S²×S²) ≅ ℤ in order to speed up type checking. module BrunerieNumLem (is : GroupIso (coHomGr 4 (S₊ 2 × S₊ 2)) ℤGroup) (isEq : (fun (fst is) (H²-S²×S²-genₗ ⌣ H²-S²×S²-genᵣ) ≡ 1)) where x = H²-S²×S²-genₗ y = H²-S²×S²-genᵣ α = Hopfαfold∘W β = Hopfβfold∘W α' : coHom 2 (Pushout⋁↪fold⋁ (S₊∙ 2)) α' = fun (fst (coHomCHopfIso 2)) α β' : coHom 4 (Pushout⋁↪fold⋁ (S₊∙ 2)) β' = fun (fst (coHomCHopfIso 4)) β rewriteEquation : (α' ⌣ α' ≡ β' +ₕ β') ⊎ (α' ⌣ α' ≡ -ₕ (β' +ₕ β')) → (α ⌣ α ≡ β +ₕ β) ⊎ (α ⌣ α ≡ -ₕ (β +ₕ β)) rewriteEquation (inl x) = inl ((λ i → leftInv (fst (coHomCHopfIso 2)) α (~ i) ⌣ leftInv (fst (coHomCHopfIso 2)) α (~ i)) ∙∙ cong (inv (fst (coHomCHopfIso 4))) x ∙∙ leftInv (fst (coHomCHopfIso 4)) (β +ₕ β)) rewriteEquation (inr x) = inr ((λ i → leftInv (fst (coHomCHopfIso 2)) α (~ i) ⌣ leftInv (fst (coHomCHopfIso 2)) α (~ i)) ∙∙ cong (inv (fst (coHomCHopfIso 4))) x ∙∙ leftInv (fst (coHomCHopfIso 4)) (-ₕ (β +ₕ β))) rewriteEquation2 : (qHom .fst β' ≡ x ⌣ y) ⊎ (qHom .fst β' ≡ -ₕ (x ⌣ y)) rewriteEquation2 = ⊎rec (λ p → inl (sym (leftInv (fst is) (qHom .fst β')) ∙∙ cong (inv (fst is)) (p ∙ sym isEq) ∙∙ leftInv (fst is) (x ⌣ y))) (λ p → inr (sym (leftInv (fst is) (qHom .fst β')) ∙∙ cong (inv (fst is)) (p ∙ sym (cong (GroupStr.inv (snd ℤGroup)) isEq)) ∙∙ (presinv (invGroupIso is .snd) (fun (fst is) (x ⌣ y)) ∙ cong -ₕ_ (leftInv (fst is) (x ⌣ y))))) eqs where grIso : GroupEquiv (coHomGr 4 (HopfInvariantPush 0 fold∘W)) ℤGroup grIso = compGroupEquiv (GroupIso→GroupEquiv (coHomCHopfIso 4)) (compGroupEquiv isEquiv-qHom (GroupIso→GroupEquiv is)) eqs : (fst (fst grIso) β ≡ 1) ⊎ (fst (fst grIso) β ≡ -1) eqs = groupEquivPresGen _ (GroupIso→GroupEquiv (Hopfβ-Iso 0 (fold∘W , refl))) β (inl (Hopfβ↦1 0 (fold∘W , refl))) grIso qpres⌣ : (x y : coHom 2 _) → fst qHom (x ⌣ y) ≡ fst (qHomGen 2) x ⌣ fst (qHomGen 2) y qpres⌣ = sElim2 (λ _ _ → isSetPathImplicit) λ _ _ → refl α'↦x+y : fst (qHomGen 2) α' ≡ x +ₕ y α'↦x+y = lem ((coHomFun 2 (inv CHopfIso) α)) refl where lem : (x' : coHom 2 (Pushout⋁↪fold⋁ (S₊∙ 2))) → coHomFun 2 inr x' ≡ ∣ ∣_∣ ∣₂ → fst (qHomGen 2) x' ≡ x +ₕ y lem = sElim (λ _ → isSetΠ λ _ → isSetPathImplicit) λ f p → Cubical.HITs.PropositionalTruncation.rec (squash₂ _ _) (λ r → cong ∣_∣₂ (funExt (uncurry (wedgeconFun 1 1 (λ _ _ → isOfHLevelPath 4 (isOfHLevelTrunc 4) _ _) (λ x → cong f (push (inr x)) ∙∙ funExt⁻ r x ∙∙ refl) ((λ x → cong f (push (inl x)) ∙∙ funExt⁻ r x ∙∙ sym (rUnitₖ 2 ∣ x ∣ₕ))) (cong (_∙∙ funExt⁻ r north ∙∙ refl) (cong (cong f) λ j i → push (push tt j) i)))))) (fun PathIdTrunc₀Iso p) mainEq : ((fst qHom) (α' ⌣ α') ≡ qHom .fst (β' +ₕ β')) ⊎ ((fst qHom) (α' ⌣ α') ≡ qHom .fst (-ₕ (β' +ₕ β'))) mainEq = ⊎rec (λ id → inl (lem₁ ∙ lem₂ ∙ cong (λ x → x +ₕ x) (sym id) ∙ sym (pres· (snd qHom) β' β'))) (λ id → inr (lem₁ ∙ lem₂ ∙ ((sym (distLem (x ⌣ y)) ∙ cong -ₕ_ (cong (λ x → x +ₕ x) (sym id))) ∙ cong (-ₕ_) (pres· (snd qHom) β' β')) ∙ sym (presinv (snd qHom) (β' +ₕ β')))) rewriteEquation2 where triv⌣ : (a : S¹) → cong₂ (_⌣ₖ_ {n = 2} {m = 2}) (cong ∣_∣ₕ (merid a)) (cong ∣_∣ₕ (merid a)) ≡ λ _ → ∣ north ∣ₕ triv⌣ a = cong₂Funct (_⌣ₖ_ {n = 2} {m = 2}) (cong ∣_∣ₕ (merid a)) (cong ∣_∣ₕ (merid a)) ∙ sym (rUnit λ j → _⌣ₖ_ {n = 2} {m = 2} ∣ merid a j ∣ₕ ∣ north ∣) ∙ (λ i j → ⌣ₖ-0ₖ 2 2 ∣ merid a j ∣ₕ i) distLem : (x : coHom 4 (S₊ 2 × S₊ 2)) → -ₕ ((-ₕ x) +ₕ (-ₕ x)) ≡ x +ₕ x distLem = sElim (λ _ → isSetPathImplicit) λ f → cong ∣_∣₂ (funExt λ x → cong -ₖ_ (sym (-distrₖ 4 (f x) (f x))) ∙ -ₖ^2 (f x +ₖ f x)) x⌣x≡0 : x ⌣ x ≡ 0ₕ 4 x⌣x≡0 = cong ∣_∣₂ (funExt (uncurry λ { north y → refl ; south y → refl ; (merid a i) y j → triv⌣ a j i})) y⌣y≡0 : y ⌣ y ≡ 0ₕ 4 y⌣y≡0 = cong ∣_∣₂ (funExt (uncurry λ { x north → refl ; x south → refl ; x (merid a i) j → triv⌣ a j i})) -ₕ'Id : (x : coHom 4 (S₊ 2 × S₊ 2)) → (-ₕ'^ 2 · 2) x ≡ x -ₕ'Id = sElim (λ _ → isSetPathImplicit) λ f → cong ∣_∣₂ (funExt λ x → -ₖ'-gen-inl-left 2 2 tt (inl tt) (f x)) y⌣x≡x⌣y : y ⌣ x ≡ x ⌣ y y⌣x≡x⌣y = y ⌣ x ≡⟨ gradedComm'-⌣ 2 2 y x ⟩ (-ₕ'^ 2 · 2) (transport refl (x ⌣ y)) ≡⟨ -ₕ'Id (transport refl (x ⌣ y)) ⟩ transport refl (x ⌣ y) ≡⟨ transportRefl (x ⌣ y) ⟩ x ⌣ y ∎ lem₂ : (x +ₕ y) ⌣ (x +ₕ y) ≡ (x ⌣ y) +ₕ (x ⌣ y) lem₂ = (x +ₕ y) ⌣ (x +ₕ y) ≡⟨ leftDistr-⌣ 2 2 (x +ₕ y) x y ⟩ ((x +ₕ y) ⌣ x) +ₕ ((x +ₕ y) ⌣ y) ≡⟨ cong₂ _+ₕ_ (rightDistr-⌣ 2 2 x y x) (rightDistr-⌣ 2 2 x y y) ⟩ ((x ⌣ x +ₕ y ⌣ x)) +ₕ (x ⌣ y +ₕ y ⌣ y) ≡⟨ cong₂ _+ₕ_ (cong (_+ₕ y ⌣ x) x⌣x≡0 ∙ lUnitₕ 4 (y ⌣ x)) (cong (x ⌣ y +ₕ_) y⌣y≡0 ∙ rUnitₕ 4 (x ⌣ y)) ⟩ y ⌣ x +ₕ x ⌣ y ≡⟨ cong (_+ₕ (x ⌣ y)) y⌣x≡x⌣y ⟩ ((x ⌣ y) +ₕ (x ⌣ y)) ∎ lem₁ : (fst qHom) (α' ⌣ α') ≡ (x +ₕ y) ⌣ (x +ₕ y) lem₁ = fst qHom (α' ⌣ α') ≡⟨ refl ⟩ fst (qHomGen 2) α' ⌣ fst (qHomGen 2) α' ≡⟨ cong (λ x → x ⌣ x) α'↦x+y ⟩ ((x +ₕ y) ⌣ (x +ₕ y)) ∎ main⊎ : (HopfInvariant 0 (fold∘W , refl) ≡ 2) ⊎ (HopfInvariant 0 (fold∘W , refl) ≡ -2) main⊎ = ⊎rec (λ p → inl (lem₁ ∙ cong (fun (fst (Hopfβ-Iso 0 (fold∘W , refl)))) p ∙ pres· (Hopfβ-Iso 0 (fold∘W , refl) .snd) β β ∙ cong (λ x → x + x) (Hopfβ↦1 0 (fold∘W , refl)))) (λ p → inr (lem₁ ∙ cong (fun (fst (Hopfβ-Iso 0 (fold∘W , refl)))) p ∙ presinv (Hopfβ-Iso 0 (fold∘W , refl) .snd) (β +ₕ β) ∙ cong (GroupStr.inv (snd ℤGroup)) (pres· (Hopfβ-Iso 0 (fold∘W , refl) .snd) β β ∙ cong (λ x → x + x) (Hopfβ↦1 0 (fold∘W , refl))))) lem₂ where lem₁ : HopfInvariant 0 (fold∘W , refl) ≡ fun (fst (Hopfβ-Iso 0 (fold∘W , refl))) (α ⌣ α) lem₁ = cong (fun (fst (Hopfβ-Iso 0 (fold∘W , refl)))) (transportRefl (α ⌣ α)) lem₂ : (α ⌣ α ≡ β +ₕ β) ⊎ (α ⌣ α ≡ -ₕ (β +ₕ β)) lem₂ = rewriteEquation (⊎rec (λ p → inl (sym (retEq (fst isEquiv-qHom) (α' ⌣ α')) ∙∙ cong (invEq (fst isEquiv-qHom)) p ∙∙ retEq (fst isEquiv-qHom) (β' +ₕ β'))) (λ p → inr ((sym (retEq (fst isEquiv-qHom) (α' ⌣ α')) ∙∙ cong (invEq (fst isEquiv-qHom)) p ∙∙ retEq (fst isEquiv-qHom) (-ₕ (β' +ₕ β'))))) mainEq) main : abs (HopfInvariant 0 (fold∘W , refl)) ≡ 2 main = ⊎→abs _ 2 main⊎ -- We instantiate the module Brunerie'≡2 : abs (HopfInvariant 0 (fold∘W , refl)) ≡ 2 Brunerie'≡2 = BrunerieNumLem.main (Hⁿ⁺ᵐ-Sⁿ×Sᵐ≅ℤ-abs 1 1) Hⁿ⁺ᵐ-Sⁿ×Sᵐ≅ℤ-⌣ -- We rewrite the it slightly, to get the definition of the Brunerie -- number in Brunerie (2016) Brunerie'≡Brunerie : [ ∣ idfun∙ (S₊∙ 2) ∣₂ ∣ ∣ idfun∙ (S₊∙ 2) ∣₂ ]π' ≡ ∣ fold∘W , refl ∣₂ Brunerie'≡Brunerie = cong ∣_∣₂ ([]≡[]₂ (idfun∙ (S₊∙ 2)) (idfun∙ (S₊∙ 2)) ) ∙ sym fold∘W≡Whitehead ∙ cong ∣_∣₂ (∘∙-idˡ (fold∘W , refl)) -- And we get the main result Brunerie≡2 : Brunerie ≡ 2 Brunerie≡2 = cong abs (cong (HopfInvariant-π' 0) Brunerie'≡Brunerie) ∙ Brunerie'≡2
{ "alphanum_fraction": 0.5303654485, "avg_line_length": 37.3449131514, "ext": "agda", "hexsha": "03848c103252c2ab83db2291458bf18409840d74", "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/Homotopy/HopfInvariant/Brunerie.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/Homotopy/HopfInvariant/Brunerie.agda", "max_line_length": 112, "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/Homotopy/HopfInvariant/Brunerie.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 6907, "size": 15050 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Pointwise equality over lists parameterised by a setoid ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} open import Relation.Binary using (Setoid) module Data.List.Relation.Binary.Equality.Setoid {a ℓ} (S : Setoid a ℓ) where open import Data.Fin.Base open import Data.List.Base open import Data.List.Relation.Binary.Pointwise as PW using (Pointwise) open import Data.List.Relation.Unary.Unique.Setoid S using (Unique) open import Function using (_∘_) open import Level open import Relation.Binary renaming (Rel to Rel₂) open import Relation.Binary.PropositionalEquality as P using (_≡_) open import Relation.Binary.Properties.Setoid S using (≉-resp₂) open import Relation.Unary as U using (Pred) open Setoid S renaming (Carrier to A) private variable p q : Level ------------------------------------------------------------------------ -- Definition of equality ------------------------------------------------------------------------ infix 4 _≋_ _≋_ : Rel₂ (List A) (a ⊔ ℓ) _≋_ = Pointwise _≈_ open PW public using ([]; _∷_) ------------------------------------------------------------------------ -- Relational properties ------------------------------------------------------------------------ ≋-refl : Reflexive _≋_ ≋-refl = PW.refl refl ≋-reflexive : _≡_ ⇒ _≋_ ≋-reflexive P.refl = ≋-refl ≋-sym : Symmetric _≋_ ≋-sym = PW.symmetric sym ≋-trans : Transitive _≋_ ≋-trans = PW.transitive trans ≋-isEquivalence : IsEquivalence _≋_ ≋-isEquivalence = PW.isEquivalence isEquivalence ≋-setoid : Setoid _ _ ≋-setoid = PW.setoid S ------------------------------------------------------------------------ -- Relationships to predicates ------------------------------------------------------------------------ open PW public using () renaming ( Any-resp-Pointwise to Any-resp-≋ ; All-resp-Pointwise to All-resp-≋ ; AllPairs-resp-Pointwise to AllPairs-resp-≋ ) Unique-resp-≋ : Unique Respects _≋_ Unique-resp-≋ = AllPairs-resp-≋ ≉-resp₂ ------------------------------------------------------------------------ -- List operations ------------------------------------------------------------------------ ------------------------------------------------------------------------ -- length ≋-length : ∀ {xs ys} → xs ≋ ys → length xs ≡ length ys ≋-length = PW.Pointwise-length ------------------------------------------------------------------------ -- map module _ {b ℓ₂} (T : Setoid b ℓ₂) where open Setoid T using () renaming (_≈_ to _≈′_) private _≋′_ = Pointwise _≈′_ map⁺ : ∀ {f} → f Preserves _≈_ ⟶ _≈′_ → ∀ {xs ys} → xs ≋ ys → map f xs ≋′ map f ys map⁺ {f} pres xs≋ys = PW.map⁺ f f (PW.map pres xs≋ys) ------------------------------------------------------------------------ -- _++_ ++⁺ : ∀ {ws xs ys zs} → ws ≋ xs → ys ≋ zs → ws ++ ys ≋ xs ++ zs ++⁺ = PW.++⁺ ++-cancelˡ : ∀ xs {ys zs} → xs ++ ys ≋ xs ++ zs → ys ≋ zs ++-cancelˡ = PW.++-cancelˡ ++-cancelʳ : ∀ {xs} ys zs → ys ++ xs ≋ zs ++ xs → ys ≋ zs ++-cancelʳ = PW.++-cancelʳ ------------------------------------------------------------------------ -- concat concat⁺ : ∀ {xss yss} → Pointwise _≋_ xss yss → concat xss ≋ concat yss concat⁺ = PW.concat⁺ ------------------------------------------------------------------------ -- tabulate tabulate⁺ : ∀ {n} {f : Fin n → A} {g : Fin n → A} → (∀ i → f i ≈ g i) → tabulate f ≋ tabulate g tabulate⁺ = PW.tabulate⁺ tabulate⁻ : ∀ {n} {f : Fin n → A} {g : Fin n → A} → tabulate f ≋ tabulate g → (∀ i → f i ≈ g i) tabulate⁻ = PW.tabulate⁻ ------------------------------------------------------------------------ -- filter module _ {P : Pred A p} (P? : U.Decidable P) (resp : P Respects _≈_) where filter⁺ : ∀ {xs ys} → xs ≋ ys → filter P? xs ≋ filter P? ys filter⁺ xs≋ys = PW.filter⁺ P? P? resp (resp ∘ sym) xs≋ys ------------------------------------------------------------------------ -- reverse ʳ++⁺ : ∀{xs xs′ ys ys′} → xs ≋ xs′ → ys ≋ ys′ → xs ʳ++ ys ≋ xs′ ʳ++ ys′ ʳ++⁺ = PW.ʳ++⁺ reverse⁺ : ∀ {xs ys} → xs ≋ ys → reverse xs ≋ reverse ys reverse⁺ = PW.reverse⁺
{ "alphanum_fraction": 0.4377652051, "avg_line_length": 28.8571428571, "ext": "agda", "hexsha": "fc955a90b7ca827d180254050823f86d97320281", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "DreamLinuxer/popl21-artifact", "max_forks_repo_path": "agda-stdlib/src/Data/List/Relation/Binary/Equality/Setoid.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "DreamLinuxer/popl21-artifact", "max_issues_repo_path": "agda-stdlib/src/Data/List/Relation/Binary/Equality/Setoid.agda", "max_line_length": 77, "max_stars_count": 5, "max_stars_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "DreamLinuxer/popl21-artifact", "max_stars_repo_path": "agda-stdlib/src/Data/List/Relation/Binary/Equality/Setoid.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": 1188, "size": 4242 }
{-# OPTIONS --without-K --safe #-} {- Useful notation for Epimorphisms, Mononmorphisms, and isomorphisms -} module Categories.Morphism.Notation where open import Level open import Categories.Category.Core open import Categories.Morphism private variable o ℓ e : Level _[_↣_] : (𝒞 : Category o ℓ e) → (A B : Category.Obj 𝒞) → Set (o ⊔ ℓ ⊔ e) 𝒞 [ A ↣ B ] = _↣_ 𝒞 A B _[_↠_] : (𝒞 : Category o ℓ e) → (A B : Category.Obj 𝒞) → Set (o ⊔ ℓ ⊔ e) 𝒞 [ A ↠ B ] = _↠_ 𝒞 A B _[_≅_] : (𝒞 : Category o ℓ e) → (A B : Category.Obj 𝒞) → Set (ℓ ⊔ e) 𝒞 [ A ≅ B ] = _≅_ 𝒞 A B
{ "alphanum_fraction": 0.5964912281, "avg_line_length": 22.8, "ext": "agda", "hexsha": "42449f4d218c7bfe1a91ad99fe546751909ad0f5", "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/Morphism/Notation.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/Morphism/Notation.agda", "max_line_length": 72, "max_stars_count": 279, "max_stars_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Trebor-Huang/agda-categories", "max_stars_repo_path": "src/Categories/Morphism/Notation.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": 246, "size": 570 }
open import Agda.Builtin.Nat data V : (n : Nat) → Set where cons : (n : Nat) → V (suc n) -- ^ this n is forced -- v and this n is marked shape irrelevant g : ..(n : Nat) → V n → Nat g _ (cons n) = n -- ^ so we can't return n here, since we're really -- returning the shape irrelevant one.
{ "alphanum_fraction": 0.5468277946, "avg_line_length": 25.4615384615, "ext": "agda", "hexsha": "2b00d3c8a3132b55e6d08c9fc8ecb37803fd61ca", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_forks_event_min_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "alhassy/agda", "max_forks_repo_path": "test/Fail/BadForcedIrrelevance.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "alhassy/agda", "max_issues_repo_path": "test/Fail/BadForcedIrrelevance.agda", "max_line_length": 62, "max_stars_count": 1, "max_stars_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "alhassy/agda", "max_stars_repo_path": "test/Fail/BadForcedIrrelevance.agda", "max_stars_repo_stars_event_max_datetime": "2016-03-17T01:45:59.000Z", "max_stars_repo_stars_event_min_datetime": "2016-03-17T01:45:59.000Z", "num_tokens": 103, "size": 331 }
module Numbers where open import Haskell.Prelude open import Agda.Builtin.Nat posNatural : Nat posNatural = 14 posInteger : Integer posInteger = 52 negInteger : Integer negInteger = -1001 natToPos : Nat → Integer natToPos n = fromNat n natToNeg : Nat → Integer natToNeg n = fromNeg n {-# COMPILE AGDA2HS posNatural #-} {-# COMPILE AGDA2HS posInteger #-} {-# COMPILE AGDA2HS negInteger #-} {-# COMPILE AGDA2HS natToPos #-} {-# COMPILE AGDA2HS natToNeg #-}
{ "alphanum_fraction": 0.721627409, "avg_line_length": 17.2962962963, "ext": "agda", "hexsha": "552fc7326b8ee6a2d91e8fc5831ab2bad8c56f05", "lang": "Agda", "max_forks_count": 18, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:42:52.000Z", "max_forks_repo_forks_event_min_datetime": "2020-10-21T22:19:09.000Z", "max_forks_repo_head_hexsha": "160478a51bc78b0fdab07b968464420439f9fed6", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "seanpm2001/agda2hs", "max_forks_repo_path": "test/Numbers.agda", "max_issues_count": 63, "max_issues_repo_head_hexsha": "160478a51bc78b0fdab07b968464420439f9fed6", "max_issues_repo_issues_event_max_datetime": "2022-02-25T15:47:30.000Z", "max_issues_repo_issues_event_min_datetime": "2020-10-22T05:19:27.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "seanpm2001/agda2hs", "max_issues_repo_path": "test/Numbers.agda", "max_line_length": 34, "max_stars_count": 55, "max_stars_repo_head_hexsha": "8c8f24a079ed9677dbe6893cf786e7ed52dfe8b6", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "dxts/agda2hs", "max_stars_repo_path": "test/Numbers.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-26T21:57:56.000Z", "max_stars_repo_stars_event_min_datetime": "2020-10-20T13:36:25.000Z", "num_tokens": 142, "size": 467 }
{-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} -- Type classes following Kettelhoit's approach. module Kettelhoit where open import Data.Bool.Base open import Data.Nat hiding ( equal ) renaming ( suc to succ ) record Eq (A : Set) : Set where field equal : A → A → Bool open Eq {{...}} public boolEq : Bool → Bool → Bool boolEq true true = true boolEq false false = true {-# CATCHALL #-} boolEq _ _ = false natEq : ℕ → ℕ → Bool natEq zero zero = true natEq (succ m) (succ n) = natEq m n {-# CATCHALL #-} natEq _ _ = false instance eqInstanceBool : Eq Bool eqInstanceBool = record { equal = boolEq } eqInstanceℕ : Eq ℕ eqInstanceℕ = record { equal = natEq } test : Bool test = equal 5 3 ∨ equal true false
{ "alphanum_fraction": 0.6052036199, "avg_line_length": 22.6666666667, "ext": "agda", "hexsha": "a5270014792a1ad606a2716edb5a084591ba3661", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "asr/fotc", "max_forks_repo_path": "notes/type-classes/Kettelhoit.agda", "max_issues_count": 2, "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "asr/fotc", "max_issues_repo_path": "notes/type-classes/Kettelhoit.agda", "max_line_length": 62, "max_stars_count": 11, "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/fotc", "max_stars_repo_path": "notes/type-classes/Kettelhoit.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": 248, "size": 884 }