Search is not available for this dataset
text
string
meta
dict
------------------------------------------------------------------------ -- The Agda standard library -- -- Finite sets, based on AVL trees ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} open import Relation.Binary using (StrictTotalOrder) module Data.AVL.Sets {a ℓ₁ ℓ₂} (strictTotalOrder : StrictTotalOrder a ℓ₁ ℓ₂) where open import Data.Bool open import Data.List.Base as List using (List) open import Data.Maybe.Base as Maybe open import Data.Product as Prod using (_×_; _,_; proj₁) open import Data.Unit open import Function open import Level import Data.AVL strictTotalOrder as AVL open StrictTotalOrder strictTotalOrder renaming (Carrier to A) ------------------------------------------------------------------------ -- The set type (note that Set is a reserved word) ⟨Set⟩ : Set (a ⊔ ℓ₂) ⟨Set⟩ = AVL.Tree (AVL.const ⊤) ------------------------------------------------------------------------ -- Repackaged functions empty : ⟨Set⟩ empty = AVL.empty singleton : A → ⟨Set⟩ singleton k = AVL.singleton k _ insert : A → ⟨Set⟩ → ⟨Set⟩ insert k = AVL.insert k _ delete : A → ⟨Set⟩ → ⟨Set⟩ delete = AVL.delete infix 4 _∈?_ _∈?_ : A → ⟨Set⟩ → Bool _∈?_ = AVL._∈?_ headTail : ⟨Set⟩ → Maybe (A × ⟨Set⟩) headTail s = Maybe.map (Prod.map₁ proj₁) (AVL.headTail s) initLast : ⟨Set⟩ → Maybe (⟨Set⟩ × A) initLast s = Maybe.map (Prod.map₂ proj₁) (AVL.initLast s) fromList : List A → ⟨Set⟩ fromList = AVL.fromList ∘ List.map (_, _) toList : ⟨Set⟩ → List A toList = List.map proj₁ ∘ AVL.toList
{ "alphanum_fraction": 0.557827476, "avg_line_length": 24.8412698413, "ext": "agda", "hexsha": "afecf1637cd31650dc41b9d60a317ffa680fe033", "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/AVL/Sets.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/AVL/Sets.agda", "max_line_length": 72, "max_stars_count": null, "max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "omega12345/agda-mode", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Data/AVL/Sets.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 412, "size": 1565 }
{-# OPTIONS --warning=error --safe --without-K --guardedness #-} open import Everything.Safe open import Numbers.Reals.Definition open import Fields.Orders.Limits.Definition open import Rings.Orders.Partial.Bounded open import Rings.Orders.Total.Bounded open import Rings.Orders.Total.BaseExpansion open import Fields.Orders.Limits.Lemmas open import Rings.Orders.Total.Examples --open import Fields.CauchyCompletion.Archimedean open import Sets.Cardinality.Infinite.Examples open import ProjectEuler.Problem2 open import LectureNotes.NumbersAndSets.Examples1 open import LectureNotes.Groups.Lecture1 module Everything.Guardedness where
{ "alphanum_fraction": 0.8367029549, "avg_line_length": 29.2272727273, "ext": "agda", "hexsha": "8d7f7b856ba1e6d7c285183362a658e453e62b07", "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": "Everything/Guardedness.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": "Everything/Guardedness.agda", "max_line_length": 64, "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": "Everything/Guardedness.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": 142, "size": 643 }
module STLC.Properties.Determinism where open import STLC.Term open import STLC.Term.Reduction open import Data.Nat using (ℕ; _+_) open import Relation.Nullary using (¬_) open import Relation.Nullary.Negation using (contradiction) open import Data.Product using (Σ; _,_; ∃; Σ-syntax; ∃-syntax) open import Relation.Binary.PropositionalEquality as Eq using (refl; _≡_; cong₂) open Eq.≡-Reasoning using (begin_; _≡⟨⟩_; _∎) infix 4 _¬—→ _¬—→ : ∀ { n : ℕ } -> Term n -> Set t₁ ¬—→ = ¬ (∃[ t₂ ] (t₁ —→ t₂)) ¬—→-value : ∀ { n : ℕ } { t : Term n } -> Value t -- -------- -> t ¬—→ ¬—→-value {_} {ƛ _} v = λ () —→-¬value : ∀ { n : ℕ } { t₁ t₂ : Term n } -> t₁ —→ t₂ -- --------- -> ¬ Value t₁ —→-¬value { _ } { _ } { t₂ } s v = ¬—→-value v (t₂ , s) determinism : ∀ { n : ℕ } { t₁ t₂ t₃ : Term n } -> t₁ —→ t₂ -> t₁ —→ t₃ -- -------- -> t₂ ≡ t₃ determinism (β-·₁ s₁) (β-·₁ s₂) = cong₂ (_·_) (determinism s₁ s₂) refl determinism (β-·₂ _ s₁) (β-·₂ _ s₂) = cong₂ (_·_) refl (determinism s₁ s₂) determinism (β-ƛ _) (β-ƛ _) = refl determinism (β-·₁ s) (β-·₂ v _) = contradiction v (—→-¬value s) determinism (β-·₂ v _) (β-·₁ s) = contradiction v (—→-¬value s) determinism (β-·₂ _ s) (β-ƛ v) = contradiction v (—→-¬value s) determinism (β-ƛ v) (β-·₂ _ s) = contradiction v (—→-¬value s)
{ "alphanum_fraction": 0.5515151515, "avg_line_length": 26.4, "ext": "agda", "hexsha": "1a23e56ba958c034c5bcaef49e3f3de1a540a9e6", "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": "aeb2be63381d891fabe5317e3c27553deb6bca6d", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "johnyob/agda-types", "max_forks_repo_path": "src/STLC/Properties/Determinism.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "aeb2be63381d891fabe5317e3c27553deb6bca6d", "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": "johnyob/agda-types", "max_issues_repo_path": "src/STLC/Properties/Determinism.agda", "max_line_length": 75, "max_stars_count": null, "max_stars_repo_head_hexsha": "aeb2be63381d891fabe5317e3c27553deb6bca6d", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "johnyob/agda-types", "max_stars_repo_path": "src/STLC/Properties/Determinism.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 563, "size": 1320 }
-- Martin-Löf identity type {-# OPTIONS --without-K --safe #-} module TypeTheory.Identity where open import Level renaming (zero to lzero; suc to lsuc) open import Relation.Binary open import Relation.Binary.PropositionalEquality as P using (refl; _≡_) renaming (trans to ≡-trans; sym to ≡-sym; cong to ≡-cong) import Relation.Binary.Reasoning.Setoid as SetoidReasoning record JBundle a : Set (lsuc a) where field Carrier : Set a _≈_ : Rel Carrier a ≈-refl : ∀ {x} → x ≈ x J : (C : ∀ x y → x ≈ y → Set a) → (∀ x → C x x ≈-refl) → ∀ x y (p : x ≈ y) → C x y p J-β : ∀ (C : ∀ x y → x ≈ y → Set a) (c : ∀ x → C x x ≈-refl) x → J C c x x ≈-refl ≡ c x module JBundleProperties {a} (jBundle : JBundle a) where open JBundle jBundle renaming (Carrier to A) sym : ∀ {x y} → x ≈ y → y ≈ x sym {x} {y} x≈y = J (λ x₁ y₁ x₁≈y₁ → y₁ ≈ x₁) (λ _ → ≈-refl) x y x≈y sym-≈-refl : ∀ x → sym (≈-refl {x}) ≡ ≈-refl sym-≈-refl x = J-β (λ x₁ y₁ x₁≈y₁ → y₁ ≈ x₁) (λ _ → ≈-refl) x sym-involutive : ∀ {x y} (p : x ≈ y) → sym (sym p) ≡ p sym-involutive {x} {y} p = J (λ x₁ y₁ x₁≈y₁ → sym (sym x₁≈y₁) ≡ x₁≈y₁) (λ z → ≡-trans (≡-cong sym (sym-≈-refl z)) (sym-≈-refl z)) x y p sym-injective : ∀ {x y} {p q : x ≈ y} → sym p ≡ sym q → p ≡ q sym-injective {p = p} {q} eq = begin p ≡⟨ ≡-sym (sym-involutive p) ⟩ sym (sym p) ≡⟨ ≡-cong sym eq ⟩ sym (sym q) ≡⟨ sym-involutive q ⟩ q ∎ where open P.≡-Reasoning {- trans : ∀ {x y z} → x ≈ y → y ≈ z → x ≈ z trans {x} {y} {z} x≈y y≈z = J D (λ u → λ w q → q) x y x≈y z y≈z where D : ∀ u v → u ≈ v → Set _ D u v u≈v = ∀ w → (q : v ≈ w) → u ≈ w -} trans : ∀ {x y z} → x ≈ y → y ≈ z → x ≈ z trans {x} {y} {z} x≈y y≈z = J D (λ u → λ w q → J E (λ _ → ≈-refl) u w q) x y x≈y z y≈z where D : ∀ u v → u ≈ v → Set _ D u v u≈v = ∀ w → v ≈ w → u ≈ w E : ∀ u v → u ≈ v → Set _ E u v q = u ≈ v
{ "alphanum_fraction": 0.4865277072, "avg_line_length": 35.125, "ext": "agda", "hexsha": "00f4ae2789a07d86b4e28b09aaa70eb510d8d0dd", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "37200ea91d34a6603d395d8ac81294068303f577", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "rei1024/agda-misc", "max_forks_repo_path": "TypeTheory/Identity.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "37200ea91d34a6603d395d8ac81294068303f577", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "rei1024/agda-misc", "max_issues_repo_path": "TypeTheory/Identity.agda", "max_line_length": 88, "max_stars_count": 3, "max_stars_repo_head_hexsha": "37200ea91d34a6603d395d8ac81294068303f577", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "rei1024/agda-misc", "max_stars_repo_path": "TypeTheory/Identity.agda", "max_stars_repo_stars_event_max_datetime": "2020-04-21T00:03:43.000Z", "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:49:42.000Z", "num_tokens": 937, "size": 1967 }
module _ where open import Common.Prelude hiding (_>>=_) open import Common.Reflection open import Common.Equality infix 0 case_of_ case_of_ : ∀ {a b} {A : Set a} {B : Set b} → A → (A → B) → B case x of f = f x blockOnFresh : TC ⊤ blockOnFresh = checkType unknown unknown >>= λ { (meta m _) → blockOnMeta m ; _ → typeError (strErr "impossible" ∷ []) } macro weirdButShouldWork : Tactic weirdButShouldWork hole = inferType hole >>= λ goal → case goal of λ { (meta _ _) → blockOnFresh ; _ → unify hole (lit (nat 42)) } -- When the goal is a meta the tactic will block on a different, fresh, meta. -- That's silly, but should still work. Once the goal is resolved the tactic -- doesn't block any more so everything should be fine. thing : _ solves : Nat thing = weirdButShouldWork solves = thing check : thing ≡ 42 check = refl
{ "alphanum_fraction": 0.6689814815, "avg_line_length": 23.3513513514, "ext": "agda", "hexsha": "119d2d9465bb903f679cbd153a4a098adb7f0813", "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/Succeed/BlockOnFreshMeta.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/Succeed/BlockOnFreshMeta.agda", "max_line_length": 77, "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/Succeed/BlockOnFreshMeta.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 264, "size": 864 }
open import Syntax import Renaming import Instantiation module Theory (𝕊 : Signature) where open Expression 𝕊 open Instantiation open Renaming infix 5 □⦂_ infix 5 _≡_⦂type-by□ infix 5 _≡_⦂_by□ data BoundaryThesis : ∀ (cl : Class) (𝕄 : MShape) (γ : VShape) → Set where □⦂type : ∀ {𝕄 γ} → BoundaryThesis (obj Ty) 𝕄 γ □⦂_ : ∀ {𝕄 γ} (A : ExprTy 𝕄 γ) → BoundaryThesis (obj Tm) 𝕄 γ _≡_⦂type-by□ : ∀ {𝕄 γ} (A B : ExprTy 𝕄 γ) → BoundaryThesis EqTy 𝕄 γ _≡_⦂_by□ : ∀ {𝕄 γ} (u v : ExprTm 𝕄 γ) (A : ExprTy 𝕄 γ) → BoundaryThesis EqTm 𝕄 γ rename-boundary-thesis : ∀ {cl 𝕄 γ δ} → (γ →ʳ δ) → BoundaryThesis cl 𝕄 γ → BoundaryThesis cl 𝕄 δ rename-boundary-thesis ρ □⦂type = □⦂type rename-boundary-thesis ρ (□⦂ A) = □⦂ [ ρ ]ʳ A rename-boundary-thesis ρ (A ≡ B ⦂type-by□) = [ ρ ]ʳ A ≡ [ ρ ]ʳ B ⦂type-by□ rename-boundary-thesis ρ (u ≡ v ⦂ A by□) = [ ρ ]ʳ u ≡ [ ρ ]ʳ v ⦂ [ ρ ]ʳ A by□ instantiate-boundary-thesis : ∀ {cl 𝕂 𝕄 γ} → (𝕊 % 𝕂 →ⁱ 𝕄 ∥ γ) → BoundaryThesis cl 𝕂 γ → BoundaryThesis cl 𝕄 γ instantiate-boundary-thesis I □⦂type = □⦂type instantiate-boundary-thesis I (□⦂ A) = □⦂ [ I ]ⁱ A instantiate-boundary-thesis I (A ≡ B ⦂type-by□) = [ I ]ⁱ A ≡ [ I ]ⁱ B ⦂type-by□ instantiate-boundary-thesis I (u ≡ v ⦂ A by□) = [ I ]ⁱ u ≡ [ I ]ⁱ v ⦂ [ I ]ⁱ A by□ VContext : ∀ (𝕄 : MShape) (γ : VShape) → Set VContext 𝕄 γ = ∀ (x : var γ) → ExprTy 𝕄 γ instantiate-vcontext : ∀ {𝕂 𝕄 γ} (I : 𝕊 % 𝕂 →ⁱ 𝕄 ∥ γ) (Γ : VContext 𝕂 γ) → VContext 𝕄 γ instantiate-vcontext I Γ x = [ I ]ⁱ Γ x VExtension : ∀ (𝕄 : MShape) (γ δ : VShape) → Set VExtension 𝕄 γ δ = ∀ (x : var δ) → ExprTy 𝕄 (γ ⊕ δ) empty-vextension : ∀ {𝕄 γ} → VExtension 𝕄 γ 𝟘 empty-vextension () -- variable context extension infixl 6 _⊕ᶜ_ _⊕ᶜ_ : ∀ {𝕄 γ δ} → VContext 𝕄 γ → VExtension 𝕄 γ δ → VContext 𝕄 (γ ⊕ δ) (Γ ⊕ᶜ Δ) (var-left x) = [ var-left ]ʳ (Γ x) (Γ ⊕ᶜ Δ) (var-right y) = Δ y rename-vextension : ∀ {𝕄 β γ δ} → (β →ʳ γ) → VExtension 𝕄 β δ → VExtension 𝕄 γ δ rename-vextension ρ Δ x = [ [ (var-left ∘ʳ ρ) , var-right ]ʳ ]ʳ Δ x instantiate-vextension : ∀ {𝕂 𝕄 γ δ} → (I : 𝕊 % 𝕂 →ⁱ 𝕄 ∥ γ) → VExtension 𝕂 γ δ → VExtension 𝕄 γ δ instantiate-vextension I Δ x = [ ⇑ⁱ I ]ⁱ (Δ x) record JudgementThesis (cl : Class) (𝕄 : MShape) (γ : VShape) : Set where constructor _⟦_⟧ field jdg-bdry : BoundaryThesis cl 𝕄 γ jdg-head : Expr cl 𝕄 γ presupposition : ∀ {cl 𝕄 γ} → JudgementThesis cl 𝕄 γ → BoundaryThesis cl 𝕄 γ presupposition (𝒷 ⟦ _ ⟧) = 𝒷 -- shorthands for the four judgement forms infix 5 _⦂type _⦂type : ∀ {𝕄 γ} (A : ExprTy 𝕄 γ) → JudgementThesis (obj Ty) 𝕄 γ A ⦂type = □⦂type ⟦ A ⟧ infix 5 _⦂_ _⦂_ : ∀ {𝕄 γ} (e : ExprTm 𝕄 γ) (A : ExprTy 𝕄 γ) → JudgementThesis (obj Tm) 𝕄 γ e ⦂ A = (□⦂ A) ⟦ e ⟧ infix 5 _≡_by_ _≡_by_ : ∀ {𝕄 γ} (A B : ExprTy 𝕄 γ) (ξ : Expr EqTy 𝕄 γ) → JudgementThesis (EqTy) 𝕄 γ A ≡ B by ξ = (A ≡ B ⦂type-by□) ⟦ ξ ⟧ infix 5 _≡_⦂_by_ _≡_⦂_by_ : ∀ {𝕄 γ} (d e : ExprTm 𝕄 γ) (A : ExprTy 𝕄 γ) (ξ : Expr EqTm 𝕄 γ) → JudgementThesis (EqTm) 𝕄 γ d ≡ e ⦂ A by ξ = (d ≡ e ⦂ A by□) ⟦ ξ ⟧ rename-judgement-thesis : ∀ {cl 𝕄 γ δ} → (γ →ʳ δ) → JudgementThesis cl 𝕄 γ → JudgementThesis cl 𝕄 δ rename-judgement-thesis ρ (b ⟦ e ⟧) = (rename-boundary-thesis ρ b) ⟦ [ ρ ]ʳ e ⟧ instantiate-judgement-thesis : ∀ {cl 𝕂 𝕄 γ} → (𝕊 % 𝕂 →ⁱ 𝕄 ∥ γ) → JudgementThesis cl 𝕂 γ → JudgementThesis cl 𝕄 γ instantiate-judgement-thesis I (B ⟦ e ⟧) = (instantiate-boundary-thesis I B) ⟦ [ I ]ⁱ e ⟧ infix 4 ⟪_⟫_ record Abstracted (F : MShape → VShape → Set) (𝕄 : MShape) (γ δ : VShape) : Set where constructor ⟪_⟫_ field abstr-vextenson : VExtension 𝕄 γ δ abstr-body : F 𝕄 (γ ⊕ δ) non-abstracted : ∀ (F : MShape → VShape → Set) (r : ∀ {𝕄 β γ} → (β →ʳ γ) → F 𝕄 β → F 𝕄 γ) {𝕄 : MShape} {γ : VShape} (t : F 𝕄 γ) → Abstracted F 𝕄 γ 𝟘 non-abstracted F r t = ⟪ empty-vextension ⟫ (r var-left t) rename-abstracted : ∀ (F : MShape → VShape → Set) (r : ∀ {𝕄 β γ} → (β →ʳ γ) → F 𝕄 β → F 𝕄 γ) {𝕄 β γ δ} (ρ : β →ʳ γ) → Abstracted F 𝕄 β δ → Abstracted F 𝕄 γ δ rename-abstracted F r ρ (⟪ Δ ⟫ t) = ⟪ rename-vextension ρ Δ ⟫ (r (⇑ʳ ρ) t) instantiate-abstracted : ∀ (F : MShape → VShape → Set) (ι : ∀ {𝕂 𝕄 γ} → (𝕊 % 𝕂 →ⁱ 𝕄 ∥ γ) → F 𝕂 γ → F 𝕄 γ) {𝕂 𝕄 γ δ} (I : 𝕊 % 𝕂 →ⁱ 𝕄 ∥ γ) → Abstracted F 𝕂 γ δ → Abstracted F 𝕄 γ δ instantiate-abstracted F ι I (⟪ Δ ⟫ t) = ⟪ (instantiate-vextension I Δ) ⟫ ι (⇑ⁱ I) t AbstractedBoundary : ∀ cl 𝕄 γ δ → Set AbstractedBoundary cl 𝕄 γ δ = Abstracted (BoundaryThesis cl) 𝕄 γ δ infix 4 ⟪⟫ᵇ_ ⟪⟫ᵇ_ : ∀ {cl 𝕄 γ} → BoundaryThesis cl 𝕄 γ → AbstractedBoundary cl 𝕄 γ 𝟘 ⟪⟫ᵇ_ {cl = cl} 𝒷 = non-abstracted (BoundaryThesis cl) rename-boundary-thesis 𝒷 rename-abstracted-boundary : ∀ {cl 𝕄 β γ δ} (ρ : β →ʳ γ) → AbstractedBoundary cl 𝕄 β δ → AbstractedBoundary cl 𝕄 γ δ rename-abstracted-boundary {cl = cl} = rename-abstracted (BoundaryThesis cl) rename-boundary-thesis instantiate-abstracted-boundary : ∀ {cl 𝕂 𝕄 γ δ} (I : 𝕊 % 𝕂 →ⁱ 𝕄 ∥ γ) → AbstractedBoundary cl 𝕂 γ δ → AbstractedBoundary cl 𝕄 γ δ instantiate-abstracted-boundary {cl = cl} = instantiate-abstracted (BoundaryThesis cl) instantiate-boundary-thesis AbstractedJudgement : ∀ cl 𝕄 γ δ → Set AbstractedJudgement cl 𝕄 γ δ = Abstracted (JudgementThesis cl) 𝕄 γ δ infix 4 ⟪⟫ʲ_ ⟪⟫ʲ_ : ∀ {cl 𝕄 γ} → JudgementThesis cl 𝕄 γ → AbstractedJudgement cl 𝕄 γ 𝟘 ⟪⟫ʲ_ {cl = cl} 𝒷 = non-abstracted (JudgementThesis cl) rename-judgement-thesis 𝒷 fill-abstraction : ∀ {cl 𝕄 γ δ} (ℬ : AbstractedBoundary cl 𝕄 γ δ) → Arg cl 𝕄 γ δ → AbstractedJudgement cl 𝕄 γ δ fill-abstraction (⟪ Δ ⟫ 𝒷) e = ⟪ Δ ⟫ (𝒷 ⟦ e ⟧) rename-abstracted-judgement : ∀ {cl 𝕄 β γ δ} (ρ : β →ʳ γ) → AbstractedJudgement cl 𝕄 β δ → AbstractedJudgement cl 𝕄 γ δ rename-abstracted-judgement {cl = cl} = rename-abstracted (JudgementThesis cl) rename-judgement-thesis instantiate-abstracted-judgement : ∀ {cl 𝕂 𝕄 γ δ} (I : 𝕊 % 𝕂 →ⁱ 𝕄 ∥ γ) → AbstractedJudgement cl 𝕂 γ δ → AbstractedJudgement cl 𝕄 γ δ instantiate-abstracted-judgement {cl = cl} = instantiate-abstracted (JudgementThesis cl) instantiate-judgement-thesis MContext : ∀ (𝕄 : MShape) → Set MContext 𝕄 = ∀ {clᴹ : Class} {γᴹ : VShape} (M : [ clᴹ , γᴹ ]∈ 𝕄) → AbstractedBoundary clᴹ 𝕄 𝟘 γᴹ HypotheticalBoundary : ∀ cl {𝕄 : MShape} {γ} (Θ : MContext 𝕄) (Γ : VContext 𝕄 γ) δ → Set HypotheticalBoundary cl {𝕄 = 𝕄} {γ = γ} Θ Γ δ = Abstracted (BoundaryThesis cl) 𝕄 γ δ instantiate-hypothetical-boundary : ∀ {cl 𝕂 𝕄 γ δ} (I : 𝕊 % 𝕂 →ⁱ 𝕄 ∥ γ) {Ξ : MContext 𝕂} {Γ : VContext 𝕂 γ} {Θ : MContext 𝕄} → HypotheticalBoundary cl Ξ Γ δ → HypotheticalBoundary cl Θ (instantiate-vcontext I Γ) δ instantiate-hypothetical-boundary I B = instantiate-abstracted-boundary I B HypotheticalJudgement : ∀ cl {𝕄 : MShape} {γ} (Θ : MContext 𝕄) (Γ : VContext 𝕄 γ) δ → Set HypotheticalJudgement cl {𝕄 = 𝕄} {γ = γ} Θ Γ δ = Abstracted (JudgementThesis cl) 𝕄 γ δ instantiate-hypothetical-judgement : ∀ {cl 𝕂 𝕄 γ δ} (I : 𝕊 % 𝕂 →ⁱ 𝕄 ∥ γ) {Ξ : MContext 𝕂} {Γ : VContext 𝕂 γ} {Θ : MContext 𝕄} → HypotheticalJudgement cl Ξ Γ δ → HypotheticalJudgement cl Θ (instantiate-vcontext I Γ) δ instantiate-hypothetical-judgement I B = instantiate-abstracted-judgement I B infix 6 _⇛_ record Rule (cl : Class) (𝕄 : MShape) : Set where constructor _⇛_ field premises : MContext 𝕄 conclusion : JudgementThesis cl 𝕄 𝟘 Theory = ∀ {cl} {𝕄} → Rule cl 𝕄 → Set instantiate-conclusion : ∀ {cl 𝕂 𝕄 γ} (I : 𝕊 % 𝕂 →ⁱ 𝕄 ∥ γ) → JudgementThesis cl 𝕂 𝟘 → JudgementThesis cl 𝕄 γ instantiate-conclusion I 𝒿 = instantiate-judgement-thesis I (rename-judgement-thesis 𝟘-initial 𝒿) module Derivation (𝒯 : Theory) where open Rule infix 3 _,_⊢ʲ_ infix 3 _,_⊢ᵇ_ data _,_⊢ʲ_ : ∀ {cl 𝕄 γ δ} (Θ : MContext 𝕄) (Γ : VContext 𝕄 γ) (𝒥 : HypotheticalJudgement cl Θ Γ δ) → Set data _,_⊢ᵇ_ : ∀ {cl 𝕄 γ δ} (Θ : MContext 𝕄) (Γ : VContext 𝕄 γ) (ℬ : HypotheticalBoundary cl Θ Γ δ) → Set -- derivable instantiation is-derivable : ∀ {𝕂 𝕄 γ} (I : 𝕊 % 𝕂 →ⁱ 𝕄 ∥ γ) (Ξ : MContext 𝕂) (Θ : MContext 𝕄) (Γ : VContext 𝕄 γ) → Set is-derivable {𝕂 = 𝕂} I Ξ Θ Γ = ∀ {clᴷ γᴷ} (M : [ clᴷ , γᴷ ]∈ 𝕂) → Θ , Γ ⊢ʲ fill-abstraction (instantiate-abstracted-boundary I (rename-abstracted-boundary 𝟘-initial (Ξ M))) (I M) data _,_⊢ʲ_ where TT-VAR : ∀ {𝕄 γ} {Θ : MContext 𝕄} {Γ : VContext 𝕄 γ} (x : var γ) → Θ , Γ ⊢ʲ (⟪⟫ʲ (expr-var x ⦂ Γ x)) TT-RULE : ∀ {cl 𝕂 𝕄 γ} {Ξ : MContext 𝕂} {Θ : MContext 𝕄} {Γ : VContext 𝕄 γ} (I : 𝕊 % 𝕂 →ⁱ 𝕄 ∥ γ) {𝒿 : JudgementThesis cl 𝕂 𝟘} (R : 𝒯 (Ξ ⇛ 𝒿)) → Θ , Γ ⊢ᵇ ⟪⟫ᵇ instantiate-boundary-thesis I (rename-boundary-thesis 𝟘-initial (presupposition 𝒿)) → is-derivable I Ξ Θ Γ → Θ , Γ ⊢ʲ ⟪⟫ʲ instantiate-conclusion I 𝒿 TT-ABSTR : ∀ {cl 𝕄 γ δ} {Θ : MContext 𝕄} {Γ : VContext 𝕄 γ} {Δ : VExtension 𝕄 γ δ} {𝒿 : JudgementThesis cl 𝕄 (γ ⊕ δ) } → Θ , Γ ⊕ᶜ Δ ⊢ʲ ⟪⟫ʲ 𝒿 → Θ , Γ ⊢ʲ ⟪ Δ ⟫ 𝒿 TT-META : {!!} TT-META-CONGR : {!!} TT-EQTY-REFL : {!!} TT-EQTY-SYM : {!!} TT-EQTY-TRANS : {!!} TT-EQTM-REFL : {!!} TT-EQTM-SYM : {!!} TT-EQTM-TRANS : {!!} TT-CONV-TM : {!!} TT-CONV-EQTM : {!!} data _,_⊢ᵇ_ where TT-BDRY-TY : ∀ {𝕄 γ} {Θ : MContext 𝕄} {Γ : VContext 𝕄 γ} → Θ , Γ ⊢ᵇ ⟪⟫ᵇ □⦂type TT-BDRY-TM : ∀ {𝕄 γ} {Θ : MContext 𝕄} {Γ : VContext 𝕄 γ} {A} → Θ , Γ ⊢ʲ ⟪⟫ʲ A ⦂type → Θ , Γ ⊢ᵇ ⟪⟫ᵇ □⦂ A TT-BDRY-EQTY : ∀ {𝕄 γ} {Θ : MContext 𝕄} {Γ : VContext 𝕄 γ} {A B} → Θ , Γ ⊢ʲ ⟪⟫ʲ A ⦂type → Θ , Γ ⊢ʲ ⟪⟫ʲ B ⦂type → Θ , Γ ⊢ᵇ ⟪⟫ᵇ A ≡ B ⦂type-by□ TT-BDRY-EQTM : ∀ {𝕄 γ} {Θ : MContext 𝕄} {Γ : VContext 𝕄 γ} {u v A} → Θ , Γ ⊢ʲ ⟪⟫ʲ A ⦂type → Θ , Γ ⊢ʲ ⟪⟫ʲ u ⦂ A → Θ , Γ ⊢ʲ ⟪⟫ʲ v ⦂ A → Θ , Γ ⊢ᵇ ⟪⟫ᵇ u ≡ v ⦂ A by□ TT-BDRY-ABSTR : ∀ {cl 𝕄 γ δ} {Θ : MContext 𝕄} {Γ : VContext 𝕄 γ} {Δ : VExtension 𝕄 γ δ} {𝒷 : BoundaryThesis cl 𝕄 (γ ⊕ δ) } → Θ , Γ ⊕ᶜ Δ ⊢ᵇ ⟪⟫ᵇ 𝒷 → Θ , Γ ⊢ᵇ ⟪ Δ ⟫ 𝒷 -- Missing: well-formed extensions and contexts
{ "alphanum_fraction": 0.557948129, "avg_line_length": 39.2819548872, "ext": "agda", "hexsha": "b2cbf3fa3f1a95dcc1387d605a3190f7704d06f5", "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": "9b634d284a0ec5108c68489575194cd573f38908", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "andrejbauer/dependent-type-theory-syntax", "max_forks_repo_path": "src/Theory.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "9b634d284a0ec5108c68489575194cd573f38908", "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": "andrejbauer/dependent-type-theory-syntax", "max_issues_repo_path": "src/Theory.agda", "max_line_length": 121, "max_stars_count": 7, "max_stars_repo_head_hexsha": "9b634d284a0ec5108c68489575194cd573f38908", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "andrejbauer/dependent-type-theory-syntax", "max_stars_repo_path": "src/Theory.agda", "max_stars_repo_stars_event_max_datetime": "2021-10-14T01:48:00.000Z", "max_stars_repo_stars_event_min_datetime": "2021-05-25T11:14:42.000Z", "num_tokens": 4966, "size": 10449 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Non-empty lists ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} module Data.List.NonEmpty where open import Category.Monad open import Data.Bool.Base using (Bool; false; true; not; T) open import Data.Bool.Properties open import Data.List as List using (List; []; _∷_) open import Data.Maybe.Base using (Maybe ; nothing; just) open import Data.Nat as Nat open import Data.Product as Prod using (∃; _×_; proj₁; proj₂; _,_; -,_) open import Data.These as These using (These; this; that; these) open import Data.Sum as Sum using (_⊎_; inj₁; inj₂) open import Data.Unit open import Data.Vec as Vec using (Vec; []; _∷_) open import Function open import Function.Equality using (_⟨$⟩_) open import Function.Equivalence using () renaming (module Equivalence to Eq) open import Relation.Binary.PropositionalEquality as P using (_≡_; refl) open import Relation.Nullary.Decidable using (⌊_⌋) ------------------------------------------------------------------------ -- Non-empty lists infixr 5 _∷_ record List⁺ {a} (A : Set a) : Set a where constructor _∷_ field head : A tail : List A open List⁺ public -- Basic combinators module _ {a} {A : Set a} where uncons : List⁺ A → A × List A uncons (hd ∷ tl) = hd , tl [_] : A → List⁺ A [ x ] = x ∷ [] infixr 5 _∷⁺_ _∷⁺_ : A → List⁺ A → List⁺ A x ∷⁺ y ∷ xs = x ∷ y ∷ xs length : List⁺ A → ℕ length (x ∷ xs) = suc (List.length xs) ------------------------------------------------------------------------ -- Conversion module _ {a} {A : Set a} where toList : List⁺ A → List A toList (x ∷ xs) = x ∷ xs fromList : List A → Maybe (List⁺ A) fromList [] = nothing fromList (x ∷ xs) = just (x ∷ xs) fromVec : ∀ {n} → Vec A (suc n) → List⁺ A fromVec (x ∷ xs) = x ∷ Vec.toList xs toVec : (xs : List⁺ A) → Vec A (length xs) toVec (x ∷ xs) = x ∷ Vec.fromList xs lift : ∀ {a b} {A : Set a} {B : Set b} → (∀ {m} → Vec A (suc m) → ∃ λ n → Vec B (suc n)) → List⁺ A → List⁺ B lift f xs = fromVec (proj₂ (f (toVec xs))) ------------------------------------------------------------------------ -- Other operations map : ∀ {a b} {A : Set a} {B : Set b} → (A → B) → List⁺ A → List⁺ B map f (x ∷ xs) = (f x ∷ List.map f xs) -- Right fold. Note that s is only applied to the last element (see -- the examples below). foldr : ∀ {a b} {A : Set a} {B : Set b} → (A → B → B) → (A → B) → List⁺ A → B foldr {A = A} {B} c s (x ∷ xs) = foldr′ x xs where foldr′ : A → List A → B foldr′ x [] = s x foldr′ x (y ∷ xs) = c x (foldr′ y xs) -- Right fold. foldr₁ : ∀ {a} {A : Set a} → (A → A → A) → List⁺ A → A foldr₁ f = foldr f id -- Left fold. Note that s is only applied to the first element (see -- the examples below). foldl : ∀ {a b} {A : Set a} {B : Set b} → (B → A → B) → (A → B) → List⁺ A → B foldl c s (x ∷ xs) = List.foldl c (s x) xs -- Left fold. foldl₁ : ∀ {a} {A : Set a} → (A → A → A) → List⁺ A → A foldl₁ f = foldl f id -- Append (several variants). module _ {a} {A : Set a} where infixr 5 _⁺++⁺_ _++⁺_ _⁺++_ _⁺++⁺_ : List⁺ A → List⁺ A → List⁺ A (x ∷ xs) ⁺++⁺ (y ∷ ys) = x ∷ (xs List.++ y ∷ ys) _⁺++_ : List⁺ A → List A → List⁺ A (x ∷ xs) ⁺++ ys = x ∷ (xs List.++ ys) _++⁺_ : List A → List⁺ A → List⁺ A xs ++⁺ ys = List.foldr _∷⁺_ ys xs concat : List⁺ (List⁺ A) → List⁺ A concat (xs ∷ xss) = xs ⁺++ List.concat (List.map toList xss) concatMap : ∀ {a b} {A : Set a} {B : Set b} → (A → List⁺ B) → List⁺ A → List⁺ B concatMap f = concat ∘′ map f -- Reverse reverse : ∀ {a} {A : Set a} → List⁺ A → List⁺ A reverse = lift (-,_ ∘′ Vec.reverse) -- Align and Zip module _ {a b c} {A : Set a} {B : Set b} {C : Set c} where alignWith : (These A B → C) → List⁺ A → List⁺ B → List⁺ C alignWith f (a ∷ as) (b ∷ bs) = f (these a b) ∷ List.alignWith f as bs zipWith : (A → B → C) → List⁺ A → List⁺ B → List⁺ C zipWith f (a ∷ as) (b ∷ bs) = f a b ∷ List.zipWith f as bs unalignWith : (A → These B C) → List⁺ A → These (List⁺ B) (List⁺ C) unalignWith f = foldr (These.alignWith mcons mcons ∘′ f) (These.map [_] [_] ∘′ f) where mcons : ∀ {e} {E : Set e} → These E (List⁺ E) → List⁺ E mcons = These.fold [_] id _∷⁺_ unzipWith : (A → B × C) → List⁺ A → List⁺ B × List⁺ C unzipWith f (a ∷ as) = Prod.zip _∷_ _∷_ (f a) (List.unzipWith f as) module _ {a b} {A : Set a} {B : Set b} where align : List⁺ A → List⁺ B → List⁺ (These A B) align = alignWith id zip : List⁺ A → List⁺ B → List⁺ (A × B) zip = zipWith _,_ unalign : List⁺ (These A B) → These (List⁺ A) (List⁺ B) unalign = unalignWith id unzip : List⁺ (A × B) → List⁺ A × List⁺ B unzip = unzipWith id -- Snoc. infixl 5 _∷ʳ_ _⁺∷ʳ_ _∷ʳ_ : ∀ {a} {A : Set a} → List A → A → List⁺ A [] ∷ʳ y = [ y ] (x ∷ xs) ∷ʳ y = x ∷ (xs List.∷ʳ y) _⁺∷ʳ_ : ∀ {a} {A : Set a} → List⁺ A → A → List⁺ A xs ⁺∷ʳ x = toList xs ∷ʳ x -- A snoc-view of non-empty lists. infixl 5 _∷ʳ′_ data SnocView {a} {A : Set a} : List⁺ A → Set a where _∷ʳ′_ : (xs : List A) (x : A) → SnocView (xs ∷ʳ x) snocView : ∀ {a} {A : Set a} (xs : List⁺ A) → SnocView xs snocView (x ∷ xs) with List.initLast xs snocView (x ∷ .[]) | [] = [] ∷ʳ′ x snocView (x ∷ .(xs List.∷ʳ y)) | xs List.∷ʳ' y = (x ∷ xs) ∷ʳ′ y -- The last element in the list. last : ∀ {a} {A : Set a} → List⁺ A → A last xs with snocView xs last .(ys ∷ʳ y) | ys ∷ʳ′ y = y -- Groups all contiguous elements for which the predicate returns the -- same result into lists. split : ∀ {a} {A : Set a} (p : A → Bool) → List A → List (List⁺ (∃ (T ∘ p)) ⊎ List⁺ (∃ (T ∘ not ∘ p))) split p [] = [] split p (x ∷ xs) with p x | P.inspect p x | split p xs ... | true | P.[ px≡t ] | inj₁ xs′ ∷ xss = inj₁ ((x , Eq.from T-≡ ⟨$⟩ px≡t) ∷⁺ xs′) ∷ xss ... | true | P.[ px≡t ] | xss = inj₁ [ x , Eq.from T-≡ ⟨$⟩ px≡t ] ∷ xss ... | false | P.[ px≡f ] | inj₂ xs′ ∷ xss = inj₂ ((x , Eq.from T-not-≡ ⟨$⟩ px≡f) ∷⁺ xs′) ∷ xss ... | false | P.[ px≡f ] | xss = inj₂ [ x , Eq.from T-not-≡ ⟨$⟩ px≡f ] ∷ xss -- If we flatten the list returned by split, then we get the list we -- started with. flatten : ∀ {a p q} {A : Set a} {P : A → Set p} {Q : A → Set q} → List (List⁺ (∃ P) ⊎ List⁺ (∃ Q)) → List A flatten = List.concat ∘ List.map Sum.[ toList ∘ map proj₁ , toList ∘ map proj₁ ] flatten-split : ∀ {a} {A : Set a} (p : A → Bool) (xs : List A) → flatten (split p xs) ≡ xs flatten-split p [] = refl flatten-split p (x ∷ xs) with p x | P.inspect p x | split p xs | flatten-split p xs ... | true | P.[ _ ] | [] | hyp = P.cong (_∷_ x) hyp ... | true | P.[ _ ] | inj₁ _ ∷ _ | hyp = P.cong (_∷_ x) hyp ... | true | P.[ _ ] | inj₂ _ ∷ _ | hyp = P.cong (_∷_ x) hyp ... | false | P.[ _ ] | [] | hyp = P.cong (_∷_ x) hyp ... | false | P.[ _ ] | inj₁ _ ∷ _ | hyp = P.cong (_∷_ x) hyp ... | false | P.[ _ ] | inj₂ _ ∷ _ | hyp = P.cong (_∷_ x) hyp -- Groups all contiguous elements /not/ satisfying the predicate into -- lists. Elements satisfying the predicate are dropped. wordsBy : ∀ {a} {A : Set a} → (A → Bool) → List A → List (List⁺ A) wordsBy p = List.mapMaybe Sum.[ const nothing , just ∘′ map proj₁ ] ∘ split p ------------------------------------------------------------------------ -- Examples -- Note that these examples are simple unit tests, because the type -- checker verifies them. private module Examples {A B : Set} (_⊕_ : A → B → B) (_⊗_ : B → A → B) (_⊙_ : A → A → A) (f : A → B) (a b c : A) where hd : head (a ∷⁺ b ∷⁺ [ c ]) ≡ a hd = refl tl : tail (a ∷⁺ b ∷⁺ [ c ]) ≡ b ∷ c ∷ [] tl = refl mp : map f (a ∷⁺ b ∷⁺ [ c ]) ≡ f a ∷⁺ f b ∷⁺ [ f c ] mp = refl right : foldr _⊕_ f (a ∷⁺ b ∷⁺ [ c ]) ≡ (a ⊕ (b ⊕ f c)) right = refl right₁ : foldr₁ _⊙_ (a ∷⁺ b ∷⁺ [ c ]) ≡ (a ⊙ (b ⊙ c)) right₁ = refl left : foldl _⊗_ f (a ∷⁺ b ∷⁺ [ c ]) ≡ ((f a ⊗ b) ⊗ c) left = refl left₁ : foldl₁ _⊙_ (a ∷⁺ b ∷⁺ [ c ]) ≡ ((a ⊙ b) ⊙ c) left₁ = refl ⁺app⁺ : (a ∷⁺ b ∷⁺ [ c ]) ⁺++⁺ (b ∷⁺ [ c ]) ≡ a ∷⁺ b ∷⁺ c ∷⁺ b ∷⁺ [ c ] ⁺app⁺ = refl ⁺app : (a ∷⁺ b ∷⁺ [ c ]) ⁺++ (b ∷ c ∷ []) ≡ a ∷⁺ b ∷⁺ c ∷⁺ b ∷⁺ [ c ] ⁺app = refl app⁺ : (a ∷ b ∷ c ∷ []) ++⁺ (b ∷⁺ [ c ]) ≡ a ∷⁺ b ∷⁺ c ∷⁺ b ∷⁺ [ c ] app⁺ = refl conc : concat ((a ∷⁺ b ∷⁺ [ c ]) ∷⁺ [ b ∷⁺ [ c ] ]) ≡ a ∷⁺ b ∷⁺ c ∷⁺ b ∷⁺ [ c ] conc = refl rev : reverse (a ∷⁺ b ∷⁺ [ c ]) ≡ c ∷⁺ b ∷⁺ [ a ] rev = refl snoc : (a ∷ b ∷ c ∷ []) ∷ʳ a ≡ a ∷⁺ b ∷⁺ c ∷⁺ [ a ] snoc = refl snoc⁺ : (a ∷⁺ b ∷⁺ [ c ]) ⁺∷ʳ a ≡ a ∷⁺ b ∷⁺ c ∷⁺ [ a ] snoc⁺ = refl split-true : split (const true) (a ∷ b ∷ c ∷ []) ≡ inj₁ ((a , tt) ∷⁺ (b , tt) ∷⁺ [ c , tt ]) ∷ [] split-true = refl split-false : split (const false) (a ∷ b ∷ c ∷ []) ≡ inj₂ ((a , tt) ∷⁺ (b , tt) ∷⁺ [ c , tt ]) ∷ [] split-false = refl split-≡1 : split (λ n → ⌊ n Nat.≟ 1 ⌋) (1 ∷ 2 ∷ 3 ∷ 1 ∷ 1 ∷ 2 ∷ 1 ∷ []) ≡ inj₁ [ 1 , tt ] ∷ inj₂ ((2 , tt) ∷⁺ [ 3 , tt ]) ∷ inj₁ ((1 , tt) ∷⁺ [ 1 , tt ]) ∷ inj₂ [ 2 , tt ] ∷ inj₁ [ 1 , tt ] ∷ [] split-≡1 = refl wordsBy-true : wordsBy (const true) (a ∷ b ∷ c ∷ []) ≡ [] wordsBy-true = refl wordsBy-false : wordsBy (const false) (a ∷ b ∷ c ∷ []) ≡ (a ∷⁺ b ∷⁺ [ c ]) ∷ [] wordsBy-false = refl wordsBy-≡1 : wordsBy (λ n → ⌊ n Nat.≟ 1 ⌋) (1 ∷ 2 ∷ 3 ∷ 1 ∷ 1 ∷ 2 ∷ 1 ∷ []) ≡ (2 ∷⁺ [ 3 ]) ∷ [ 2 ] ∷ [] wordsBy-≡1 = refl
{ "alphanum_fraction": 0.4651973347, "avg_line_length": 29.2065868263, "ext": "agda", "hexsha": "db5182fa94833a670833b4a796413c42f673839c", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "omega12345/agda-mode", "max_forks_repo_path": "test/asset/agda-stdlib-1.0/Data/List/NonEmpty.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "omega12345/agda-mode", "max_issues_repo_path": "test/asset/agda-stdlib-1.0/Data/List/NonEmpty.agda", "max_line_length": 94, "max_stars_count": null, "max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "omega12345/agda-mode", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Data/List/NonEmpty.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 4126, "size": 9755 }
module Type.Properties.Singleton.Proofs where import Data.Tuple as Tuple open import Data.Proofs open import Function.Axioms open import Logic.Classical open import Logic import Lvl open import Type.Properties.Empty open import Type.Properties.Inhabited open import Type.Properties.MereProposition open import Type.Properties.Singleton open import Logic.Propositional open import Logic.Predicate open import Structure.Setoid open import Structure.Function open import Structure.Operator open import Structure.Relator.Equivalence open import Structure.Relator.Properties open import Structure.Type.Identity open import Syntax.Function open import Type.Dependent open import Type private variable ℓ ℓₑ ℓₑ₁ ℓₑ₂ ℓₑ₃ ℓₑ₄ ℓₑ₅ : Lvl.Level private variable A B T U P : Type{ℓ} module _ ⦃ equiv : Equiv{ℓₑ}(U) ⦄ where unit-is-pos : ⦃ proof : IsUnit(U) ⦄ → ◊(U) unit-is-pos ⦃ intro unit uniqueness ⦄ = intro ⦃ unit ⦄ unit-is-prop : ⦃ proof : IsUnit(U) ⦄ → MereProposition(U) unit-is-prop ⦃ intro unit uniqueness ⦄ = intro (\{x}{y} → transitivity(_≡_) (uniqueness{x}) (symmetry(_≡_)(uniqueness{y}))) pos-prop-is-unit : ⦃ _ : (◊ U) ⦄ → ⦃ _ : MereProposition(U) ⦄ → IsUnit(U) pos-prop-is-unit ⦃ intro ⦃ unit ⦄ ⦄ ⦃ intro uniqueness ⦄ = intro unit (\{x} → uniqueness{x}{unit}) module _ ⦃ equiv-p : Equiv{ℓₑ}(P) ⦄ ⦃ prop-p : MereProposition(P) ⦄ ⦃ equiv-a : Equiv{ℓₑ₁}(A) ⦄ where prop-fn-unique-value : ∀{f : P → A} → ⦃ _ : Function(f) ⦄ → (∀{x y} → (f(x) ≡ f(y))) prop-fn-unique-value {f = f}{x}{y} = congruence₁(f) (MereProposition.uniqueness(prop-p){x}{y}) module _ ⦃ equiv-u : Equiv{ℓₑ}(U) ⦄ ⦃ unit-u : IsUnit(U) ⦄ ⦃ equiv-a : Equiv{ℓₑ₁}(A) ⦄ where unit-fn-unique-value : ∀{f : U → A} → ⦃ _ : Function(f) ⦄ → (∀{x y} → (f(x) ≡ f(y))) unit-fn-unique-value = prop-fn-unique-value ⦃ prop-p = unit-is-prop ⦃ proof = unit-u ⦄ ⦄ module _ ⦃ equiv-a : Equiv{ℓₑ₁}(A) ⦄ ⦃ equiv-b : Equiv{ℓₑ₂}(B) ⦄ ⦃ equiv-ab : Equiv{ℓₑ₃}(A ∧ B) ⦄ ⦃ op : BinaryOperator([∧]-intro) ⦄ where instance prop-conjunction : ⦃ prop-a : MereProposition(A) ⦄ ⦃ prop-b : MereProposition(B) ⦄ → MereProposition(A ∧ B) MereProposition.uniqueness prop-conjunction {[∧]-intro a₁ b₁} {[∧]-intro a₂ b₂} = congruence₂([∧]-intro) (uniqueness(A)) (uniqueness(B)) module _ ⦃ equiv-b : Equiv{ℓₑ₁}(B) ⦄ ⦃ equiv-ab : Equiv{ℓₑ₂}(A → B) ⦄ ⦃ funcExt : FunctionExtensionality(A)(B) ⦄ where prop-implication : ⦃ prop-b : MereProposition(B) ⦄ → MereProposition(A → B) MereProposition.uniqueness prop-implication = functionExtensionality(A)(B) (uniqueness(B)) module _ {B : A → Type{ℓ}} ⦃ equiv-b : ∀{a} → Equiv{ℓₑ₁}(B(a)) ⦄ ⦃ equiv-ab : Equiv{ℓₑ₂}((a : A) → B(a)) ⦄ ⦃ funcExt : DependentFunctionExtensionality(A)(B) ⦄ where prop-dependent-implication : ⦃ prop-b : ∀{a} → MereProposition(B(a)) ⦄ → MereProposition((a : A) → B(a)) MereProposition.uniqueness prop-dependent-implication = dependentFunctionExtensionality(A)(B)(\{a} → uniqueness(B(a))) module _ ⦃ equiv-top : Equiv{ℓₑ}(⊤) ⦄ where instance prop-top : MereProposition(⊤) ⦃ equiv-top ⦄ prop-top = unit-is-prop module _ ⦃ equiv-bottom : Equiv{ℓₑ}(⊥) ⦄ where instance prop-bottom : MereProposition(⊥) ⦃ equiv-bottom ⦄ MereProposition.uniqueness prop-bottom {} module _ {P : A → Type{ℓ}} ⦃ equiv-p : ∀{x} → Equiv{ℓₑ₁}(P(x)) ⦄ ⦃ equiv-ap : Equiv{ℓₑ₂}(∀ₗ P) ⦄ ⦃ funcExt : DependentImplicitFunctionExtensionality(A)(P) ⦄ where prop-universal : ⦃ prop-p : ∀{x} → MereProposition(P(x)) ⦄ → MereProposition(∀ₗ P) MereProposition.uniqueness prop-universal = dependentImplicitFunctionExtensionality(A)(P) (\{x} → uniqueness(P(x))) module _ ⦃ equiv-a : Equiv{ℓₑ₁}(A) ⦄ ⦃ equiv-b : Equiv{ℓₑ₂}(B) ⦄ ⦃ equiv-ba : Equiv{ℓₑ₃}(A ← B) ⦄ ⦃ equiv-ab : Equiv{ℓₑ₄}(A → B) ⦄ ⦃ equiv-eq : Equiv{ℓₑ₅}(A ↔ B) ⦄ ⦃ op : BinaryOperator([↔]-intro) ⦄ ⦃ funcExtₗ : FunctionExtensionality(B)(A) ⦄ ⦃ funcExtᵣ : FunctionExtensionality(A)(B) ⦄ where prop-equivalence : ⦃ prop-a : MereProposition(A) ⦄ → ⦃ prop-b : MereProposition(B) ⦄ → MereProposition(A ↔ B) prop-equivalence = prop-conjunction ⦃ prop-a = prop-implication ⦄ ⦃ prop-b = prop-implication ⦄ module _ ⦃ equiv-a : Equiv{ℓₑ₁}(A) ⦄ ⦃ equiv-bottom : Equiv{ℓₑ₂}(⊥) ⦄ ⦃ equiv-na : Equiv{ℓₑ₃}(¬ A) ⦄ ⦃ funcExt : FunctionExtensionality (A)(⊥) ⦃ equiv-bottom ⦄ ⦄ where prop-negation : MereProposition(¬ A) prop-negation = prop-implication module _ ⦃ equiv-a : Equiv{ℓₑ₁}(A) ⦄ ⦃ equiv-b : Equiv{ℓₑ₂}(B) ⦄ ⦃ equiv-ab : Equiv{ℓₑ₃}(A ∨ B) ⦄ (left-right-neq : ∀{a : A}{b : B} → ([∨]-introₗ a ≢ [∨]-introᵣ b)) where not-prop-disjunction : MereProposition(A ∨ B) → IsEmpty(A ∧ B) IsEmpty.empty (not-prop-disjunction (intro uniqueness)) ([∧]-intro a b) with () ← left-right-neq(uniqueness{[∨]-introₗ a}{[∨]-introᵣ b}) {- module _ {B : A → Type{ℓ}} where open import Type.Identity open import Relator.Equals.Proofs.Equiv open import Structure.Relator open import Structure.Setoid.Uniqueness open import Syntax.Transitivity congruence₁-dependent : ∀{ℓ₁ ℓ₂}{A : Type{ℓ₁}}{B : A → Type{ℓ₂}}{a₁ a₂ : A} → (f : (a : A) → B(a)) → (pa : a₁ ≡ a₂) → (substitute₁(B) pa (f a₁) ≡ f a₂) congruence₁-dependent _ intro = intro -- congruence₂-dependent : ∀{C : (a : A) → B(a) → Type{ℓ}}{a₁ a₂ : A}{b₁ : B(a₁)}{b₂ : B(a₂)}{f : (a : A) → (b : B(a)) → C a b} → (pa : a₁ ≡ a₂) → (f a₁ b₁ ≡ f a₂ b₂) -- (substitute₁(B) ? b₁) prop-sigma : Unique(B) → (∀{a} → MereProposition(B(a))) → MereProposition(Σ A B) MereProposition.uniqueness (prop-sigma unique-B prop-B) {intro xa xb} {intro ya yb} = intro xa xb 🝖[ _≡_ ]-[ {!(congruence₁-dependent(intro) (unique-B xb yb))!} ] intro ya (substitute₁(B) (unique-B xb yb) xb) 🝖[ _≡_ ]-[ {!intro xa xb!} ] intro ya yb 🝖-end -} {- TODO module _ ⦃ equiv-a : Equiv(A) ⦄ {B : A → Type{ℓ}} ⦃ equiv-b : ∀{x} → Equiv(B(x)) ⦄ ⦃ equiv-sigma : Equiv(Σ A B) ⦄ -- TODO: Not an arbitrary one where prop-sigma : MereProposition(Σ A B) → ? -- TODO: Maybe MereProposition(B) → MereProposition(A) prop-sigma (intro uniqueness₁) = {!!} -} {- TODO: Maybe generalize and move the stuff from Data.Proofs to here -- Any binary relation on Unit is an equivalence given that it is reflexive. module _ ⦃ equiv-u : Equiv(U) ⦄ ⦃ is-unit : IsUnit(U) ⦄ {_▫_ : U → U → Stmt} where unit-equiv : Equiv(U) Equiv._≡_ unit-equiv = (_▫_) Reflexivity.proof (Equivalence.reflexivity (Equiv.equivalence unit-equiv)) = {!!} Symmetry.proof (Equivalence.symmetry (Equiv.equivalence unit-equiv)) _ = {!!} Transitivity.proof (Equivalence.transitivity (Equiv.equivalence unit-equiv)) _ _ = {!!} -}
{ "alphanum_fraction": 0.6352379532, "avg_line_length": 41.6335403727, "ext": "agda", "hexsha": "b29dda83751a64f1f7a509dde72cc66316b46c4e", "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/Properties/Singleton/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": "Type/Properties/Singleton/Proofs.agda", "max_line_length": 168, "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/Properties/Singleton/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": 2742, "size": 6703 }
-- Shadowing is allowed. module Shadow where module M (A : Set) where id : Set -> Set id A = A
{ "alphanum_fraction": 0.6116504854, "avg_line_length": 10.3, "ext": "agda", "hexsha": "9cb7f3ad1ff8806d26238dbbb5fe8fbd960de374", "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/Shadow.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/Shadow.agda", "max_line_length": 24, "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/Shadow.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 33, "size": 103 }
{-# OPTIONS --without-K #-} open import Base open import Homotopy.Connected {- Wedge is a pushout. -} module Homotopy.Wedge where import Homotopy.Pushout as P record wedge-diag i : Set (suc i) where constructor diag_,_,_,_ field A : Set i B : Set i a : A b : B f : unit {i} → A f _ = a g : unit {i} → B g _ = b wedge-diag-to-pushout-diag : ∀ {i} → wedge-diag i → P.pushout-diag i wedge-diag-to-pushout-diag {i} (diag A , B , a , b) = P.diag A , B , unit {i} , (λ _ → a) , (λ _ → b) wedge : ∀ {i} → wedge-diag i → Set i wedge d = P.pushout (wedge-diag-to-pushout-diag d) left : ∀ {i} {d : wedge-diag i} → wedge-diag.A d → wedge d left = P.left right : ∀ {i} {d : wedge-diag i} → wedge-diag.B d → wedge d right = P.right glue : ∀ {i} {d : wedge-diag i} → left (wedge-diag.a d) ≡ right (wedge-diag.b d) glue = P.glue tt wedge-rec : ∀ {i} {d : wedge-diag i} → let open wedge-diag d in ∀ {j} (P : wedge d → Set j) (left* : ∀ a → P (left a)) (right* : ∀ b → P (right b)) (glue* : transport P glue (left* a) ≡ right* b) → (∀ x → P x) wedge-rec P left* right* glue* = P.pushout-rec P left* right* (λ _ → glue*) wedge-rec-nondep : ∀ {i} {d : wedge-diag i} → let open wedge-diag d in ∀ {j} (P : Set j) (left* : ∀ a → P) (right* : ∀ b → P) (glue* : left* a ≡ right* b) → (wedge d → P) wedge-rec-nondep P left* right* glue* = P.pushout-rec-nondep P left* right* (λ _ → glue*) {- module _ (f : X → Y) where nA (A-is-conn : is-connected n A) nB (B-is-conn : is-connected n B) (P : A → B → Set k) ⦃ P-is-trunc : ∀ a b → is-connected (n +2+ m) (P a b) ⦄ extension : -}
{ "alphanum_fraction": 0.5285547786, "avg_line_length": 24.8695652174, "ext": "agda", "hexsha": "3b078cfd9fc19be00bed48c6091768c6ddc7ca0c", "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": "old/Homotopy/Wedge.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": "old/Homotopy/Wedge.agda", "max_line_length": 103, "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": "old/Homotopy/Wedge.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": 668, "size": 1716 }
-- Patterns are parsed as expressions. That means that expressions can contain -- pattern parts. That's of course not ok. module NotAnExpression where X = x @ y -- as pattern as an expression
{ "alphanum_fraction": 0.7525773196, "avg_line_length": 27.7142857143, "ext": "agda", "hexsha": "5ededc25716c5abc6ba6aa0c68bc36b885254ab9", "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/NotAnExpression.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/NotAnExpression.agda", "max_line_length": 78, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/Fail/NotAnExpression.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": 194 }
module Data.Bin.BitListBijection where -- -- This module gives a bijection between the two setoids: -- - the set (ℕ) -- - The set (List Bit), interpreted as least-significant-bit first, -- with the equivalence relation that ignores the zeroes at the end of the list open import Data.List open import Data.List.Properties import Data.Digit open Data.Digit using (Bit) open import Data.Fin using (zero; suc; Fin; inject₁) renaming (toℕ to finToℕ) open import Data.Nat using (ℕ; zero;suc) open import Data.Nat using (_+_) open import Data.Nat.Properties using (+-suc; +-identityʳ) renaming (suc-injective to suc-inj) open import Data.Fin.Properties using () renaming (suc-injective to fin-suc-inj) infix 3 _≈_ 0×_ : ℕ → List Bit 0× n = replicate n zero open import Relation.Binary using (IsEquivalence; Setoid; Reflexive; Symmetric; Transitive) import Relation.Binary.PropositionalEquality module PropEq = Relation.Binary.PropositionalEquality open import Algebra import Level open import Algebra.FunctionProperties open import Data.Product renaming (map to pmap) ₀ = Level.zero open PropEq using (_≡_) []-identityʳ : ∀ l → l ++ [] ≡ l []-identityʳ = proj₂ (Monoid.identity (Data.List.Properties.++-monoid Bit)) patternMatch : ∀ {A : Set} (P : A → Set) {x} → P x → ∃ λ z → P z × x ≡ z patternMatch _ {x = x} px = (x , (px , PropEq.refl)) generalizing_case_of_ : ∀ {a b} {A : Set a} {B : Set b} → (P : A → Set) → ∀ {x} → P x → (∀ {z} → P z → x ≡ z → B) → B generalizing P case p of f = f p PropEq.refl open import Data.Sum open import Function open import Data.Digit data All-zero : List Bit → Set where [] : All-zero [] cons : ∀ {t} → All-zero t → All-zero (0b ∷ t) -- ᵢ for "Inductive" data _≈_ : List Bit → List Bit → Set where both-zero : ∀ {a b} (a-zero : All-zero a) (b-zero : All-zero b) → a ≈ b heads-match : ∀ h at bt → at ≈ bt → (h ∷ at) ≈ (h ∷ bt) All-zero-respects-equivalence : ∀ {x y} → x ≈ y → All-zero x → All-zero y All-zero-respects-equivalence (both-zero a-zero b-zero) z = b-zero All-zero-respects-equivalence (heads-match .zero at bt eq) (cons z) = cons (All-zero-respects-equivalence eq z) ≈-sym : ∀ {a b} → a ≈ b → b ≈ a ≈-sym (both-zero a-zero b-zero) = both-zero b-zero a-zero ≈-sym (heads-match h at bt l) = heads-match h bt at (≈-sym l) ≈-trans : ∀ {a b c} → a ≈ b → b ≈ c → a ≈ c ≈-trans (both-zero a-zero b-zero) b≈c = both-zero a-zero (All-zero-respects-equivalence b≈c b-zero) ≈-trans a≈b (both-zero b-zero c-zero) = both-zero (All-zero-respects-equivalence (≈-sym a≈b) b-zero) c-zero ≈-trans (heads-match h at bt r1) (heads-match .h .bt bt₁ r2) = heads-match h _ _ (≈-trans r1 r2) 0×-is-all-zero : ∀ {n} → All-zero (0× n) 0×-is-all-zero {ℕ.zero} = [] 0×-is-all-zero {ℕ.suc n} = cons 0×-is-all-zero az-replicate : ∀ {a} → All-zero a → (0× length a) ≡ a az-replicate [] = PropEq.refl az-replicate (cons x) = PropEq.cong (λ z → 0b ∷ z) (az-replicate x) ≈-refl : Reflexive _≈_ ≈-refl {[]} = both-zero [] [] ≈-refl {x ∷ x₁} = heads-match x x₁ x₁ ≈-refl ≡→≈ : ∀ {x y} → x ≡ y → x ≈ y ≡→≈ {x} .{x} PropEq.refl = ≈-refl {x} isEquivalence : IsEquivalence _≈_ isEquivalence = record { refl = ≈-refl ; trans = ≈-trans ; sym = ≈-sym } setoid : Setoid ₀ ₀ setoid = record {isEquivalence = isEquivalence} toℕ : List Bit → ℕ toℕ = fromDigits open import Function using (_∘_; _⟨_⟩_) fromℕ : ℕ → List Bit fromℕ = proj₁ ∘ toDigits 2 ℕ-setoid = PropEq.setoid ℕ open import Function using (id) open import Function.Bijection using (Bijection; Bijective) open import Function.Equality using (_⟶_) zeroIsZero : ∀ {l} → All-zero l → toℕ l ≡ 0 zeroIsZero [] = PropEq.refl zeroIsZero (cons q) rewrite zeroIsZero q = PropEq.refl toℕ-cong : ∀ {x y} → x ≈ y → toℕ x ≡ toℕ y toℕ-cong (both-zero a-zero b-zero) = PropEq.trans (zeroIsZero a-zero) (PropEq.sym (zeroIsZero b-zero)) toℕ-cong (heads-match h at bt q) rewrite toℕ-cong q = PropEq.refl fromℕ⟶ : ℕ-setoid ⟶ setoid fromℕ⟶ = record { _⟨$⟩_ = fromℕ ; cong = λ eq → ≡→≈ (PropEq.cong fromℕ eq) } toℕ⟶ : setoid ⟶ ℕ-setoid toℕ⟶ = record { _⟨$⟩_ = toℕ ; cong = toℕ-cong } fromℕ-inj : ∀ {x y} → fromℕ x ≈ fromℕ y → x ≡ y fromℕ-inj {x} {y} eq = PropEq.trans (PropEq.sym (proj₂ (toDigits 2 x))) (PropEq.trans (toℕ-cong eq) (proj₂ (toDigits 2 y))) open import Data.Nat.DivMod bitToℕ : Bit → ℕ bitToℕ = Data.Fin.toℕ open Data.Nat using (_*_) +-inj₁ : ∀ c {a b} → c + a ≡ c + b → a ≡ b +-inj₁ zero eq = eq +-inj₁ (suc c) {a} {b} eq = +-inj₁ c {a} {b} (suc-inj eq) module DigitInj where open import Data.Nat.Properties using (isCommutativeSemiring) open import Algebra.Structures open IsCommutativeSemiring isCommutativeSemiring hiding (zero) open import Data.Empty using (⊥; ⊥-elim) finToℕ-inj : ∀ {base} {x y : Fin base} → finToℕ x ≡ finToℕ y → x ≡ y finToℕ-inj {.(suc _)} {zero} {zero} eq = PropEq.refl finToℕ-inj {.(suc _)} {zero} {suc y} () finToℕ-inj {.(suc _)} {suc x} {zero} () finToℕ-inj {.(suc _)} {suc x} {suc y} eq = PropEq.cong suc (finToℕ-inj (suc-inj eq)) fin-not-enough : ∀ {base} → (x : Fin base) → ∀ whatever → finToℕ x ≡ base + whatever → ⊥ fin-not-enough {.(suc _)} zero _ () fin-not-enough {.(suc _)} (suc x) _ eq = fin-not-enough _ _ (Data.Nat.Properties.suc-injective eq) digit-inj2 : ∀ {base : ℕ} (h₁ h₂ : Fin base) (t₁ t₂ : ℕ) → t₁ * base + finToℕ h₁ ≡ t₂ * base + finToℕ h₂ → h₁ ≡ h₂ × t₁ ≡ t₂ digit-inj2 x y zero zero eq = finToℕ-inj eq , PropEq.refl digit-inj2 {base} x y zero (suc ys) eq = ⊥-elim (fin-not-enough x (ys * base + finToℕ y) (PropEq.trans eq (+-assoc _ (ys * base) (finToℕ y)))) digit-inj2 {base} x y (suc xs) zero eq = ⊥-elim (fin-not-enough y (xs * base + finToℕ x) (PropEq.trans (PropEq.sym eq) (+-assoc _ (xs * base) (finToℕ x)))) digit-inj2 {base} x y (suc xs) (suc ys) eq = case digit-inj2 x y xs ys (+-inj₁ base eq') of λ { (eq1 , eq2) → eq1 , PropEq.cong suc eq2 } where eq' = PropEq.trans (PropEq.sym (+-assoc base (xs * base) _)) (PropEq.trans eq (+-assoc base (ys * base) _)) digit-inj : ∀ {base : ℕ} (h₁ h₂ : Fin base) (t₁ t₂ : ℕ) → finToℕ h₁ + t₁ * base ≡ finToℕ h₂ + t₂ * base → h₁ ≡ h₂ × t₁ ≡ t₂ digit-inj x y xs ys eq = digit-inj2 _ _ _ _ (PropEq.trans (+-comm (xs * _) (finToℕ x)) (PropEq.trans eq (+-comm _ (ys * _)))) digit-inj = DigitInj.digit-inj toℕ-inj-zero : ∀ xs → toℕ xs ≡ 0 → All-zero xs toℕ-inj-zero [] eq = [] toℕ-inj-zero (x ∷ xs) eq = case digit-inj x zero (toℕ xs) 0 eq of λ { (PropEq.refl , snd) → cons (toℕ-inj-zero xs snd) } toℕ-inj2 : ∀ {x y} → toℕ x ≡ toℕ y → x ≈ y toℕ-inj2 {[]} {ys} eq = both-zero [] (toℕ-inj-zero ys (PropEq.sym eq)) toℕ-inj2 {xs} {[]} eq = both-zero (toℕ-inj-zero xs eq) [] toℕ-inj2 {x ∷ xs} {y ∷ ys} eq = case digit-inj x y (fromDigits xs) (fromDigits ys) eq of λ { (PropEq.refl , eq) → heads-match x xs ys (toℕ-inj2 eq) } bijective : Bijective toℕ⟶ bijective = record { injective = toℕ-inj2 ; surjective = record { from = fromℕ⟶ ; right-inverse-of = proj₂ ∘ toDigits 2 } } bijection-to-ℕ : Bijection setoid ℕ-setoid bijection-to-ℕ = record { bijective = bijective }
{ "alphanum_fraction": 0.5898282695, "avg_line_length": 34.2533936652, "ext": "agda", "hexsha": "91ecdb44677fa5e9a060a01915b187ddabaa836b", "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": "09cc5104421e88da82f9fead5a43f0028f77810d", "max_forks_repo_licenses": [ "Unlicense" ], "max_forks_repo_name": "Rotsor/BinDivMod", "max_forks_repo_path": "Data/Bin/BitListBijection.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "09cc5104421e88da82f9fead5a43f0028f77810d", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "Unlicense" ], "max_issues_repo_name": "Rotsor/BinDivMod", "max_issues_repo_path": "Data/Bin/BitListBijection.agda", "max_line_length": 120, "max_stars_count": 1, "max_stars_repo_head_hexsha": "09cc5104421e88da82f9fead5a43f0028f77810d", "max_stars_repo_licenses": [ "Unlicense" ], "max_stars_repo_name": "Rotsor/BinDivMod", "max_stars_repo_path": "Data/Bin/BitListBijection.agda", "max_stars_repo_stars_event_max_datetime": "2019-11-18T13:58:14.000Z", "max_stars_repo_stars_event_min_datetime": "2019-11-18T13:58:14.000Z", "num_tokens": 2925, "size": 7570 }
------------------------------------------------------------------------ -- The Agda standard library -- -- The Conat type and some operations ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe --sized-types #-} module Codata.Conat where open import Size open import Codata.Thunk open import Data.Nat.Base using (ℕ ; zero ; suc) open import Relation.Nullary ------------------------------------------------------------------------ -- Definition and first values data Conat (i : Size) : Set where zero : Conat i suc : Thunk Conat i → Conat i infinity : ∀ {i} → Conat i infinity = suc λ where .force → infinity fromℕ : ℕ → Conat ∞ fromℕ zero = zero fromℕ (suc n) = suc λ where .force → fromℕ n ------------------------------------------------------------------------ -- Arithmetic operations pred : ∀ {i} {j : Size< i} → Conat i → Conat j pred zero = zero pred (suc n) = n .force infixl 6 _∸_ _+_ infixl 7 _*_ _∸_ : Conat ∞ → ℕ → Conat ∞ m ∸ zero = m m ∸ suc n = pred m ∸ n _ℕ+_ : ℕ → ∀ {i} → Conat i → Conat i zero ℕ+ n = n suc m ℕ+ n = suc λ where .force → m ℕ+ n _+ℕ_ : ∀ {i} → Conat i → ℕ → Conat i zero +ℕ n = fromℕ n suc m +ℕ n = suc λ where .force → (m .force) +ℕ n _+_ : ∀ {i} → Conat i → Conat i → Conat i zero + n = n suc m + n = suc λ where .force → (m .force) + n _*_ : ∀ {i} → Conat i → Conat i → Conat i m * zero = zero zero * n = zero suc m * suc n = suc λ where .force → n .force + (m .force * suc n) -- Max and Min infixl 6 _⊔_ infixl 7 _⊓_ _⊔_ : ∀ {i} → Conat i → Conat i → Conat i zero ⊔ n = n m ⊔ zero = m suc m ⊔ suc n = suc λ where .force → m .force ⊔ n .force _⊓_ : ∀ {i} → Conat i → Conat i → Conat i zero ⊓ n = zero m ⊓ zero = zero suc m ⊓ suc n = suc λ where .force → m .force ⊔ n .force ------------------------------------------------------------------------ -- Finiteness data Finite : Conat ∞ → Set where zero : Finite zero suc : ∀ {n} → Finite (n .force) → Finite (suc n) toℕ : ∀ {n} → Finite n → ℕ toℕ zero = zero toℕ (suc n) = suc (toℕ n) ¬Finite∞ : ¬ (Finite infinity) ¬Finite∞ (suc p) = ¬Finite∞ p ------------------------------------------------------------------------ -- Order wrt to Nat data _ℕ≤_ : ℕ → Conat ∞ → Set where zℕ≤n : ∀ {n} → zero ℕ≤ n sℕ≤s : ∀ {k n} → k ℕ≤ n .force → suc k ℕ≤ suc n _ℕ<_ : ℕ → Conat ∞ → Set k ℕ< n = suc k ℕ≤ n _ℕ≤infinity : ∀ k → k ℕ≤ infinity zero ℕ≤infinity = zℕ≤n suc k ℕ≤infinity = sℕ≤s (k ℕ≤infinity)
{ "alphanum_fraction": 0.4725318471, "avg_line_length": 24.1538461538, "ext": "agda", "hexsha": "a420f938126c00616a000d9368cb1495e879b05e", "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/Codata/Conat.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "omega12345/agda-mode", "max_issues_repo_path": "test/asset/agda-stdlib-1.0/Codata/Conat.agda", "max_line_length": 72, "max_stars_count": null, "max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "omega12345/agda-mode", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Codata/Conat.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 901, "size": 2512 }
{-# OPTIONS --rewriting --prop --confluence-check --cumulativity #-} open import Agda.Primitive open import Agda.Builtin.Bool open import Agda.Builtin.Nat open import Agda.Builtin.List open import Agda.Builtin.Equality open import Agda.Builtin.Equality.Rewrite open import Agda.Builtin.Sigma open import Agda.Builtin.Unit open import Data.Vec.Base open import Data.Bool open import Data.Sum open import Data.Product using (_×_) open import ett-rr {- Axiomatisation of the Cast calculus -} {- diagonal cases -} postulate cast : (A : Set ℓ) (B : Set ℓ₁) → A → B postulate cast-set : (A : Set ℓ) → cast (Set ℓ) (Set ℓ) A ≡ A {-# REWRITE cast-set #-} postulate cast-prop : (A : Prop ℓ) → cast (Prop ℓ) (Prop ℓ) A ≡ A {-# REWRITE cast-prop #-} postulate cast-Pi : (A : Set ℓ) (B : A → Set ℓ₁) (A' : Set ℓ₂) (B' : A' → Set ℓ₃) (f : (a : A) → B a) → cast ((a : A) → B a) ((a' : A') → B' a') f ≡ λ (a' : A') → cast _ _ (f (cast A' A a')) {-# REWRITE cast-Pi #-} postulate cast-Sigma : (A : Set ℓ) (B : A → Set ℓ₁) (A' : Set ℓ₂) (B' : A' → Set ℓ₃) (p : Σ {a = ℓ} {b = ℓ₁} A B) → cast (Σ A B) (Σ A' B') p ≡ (cast {ℓ = ℓ} {ℓ₁ = ℓ₂} A A' (p .fst) , cast (B (p .fst)) (B' (cast A A' (p .fst))) (p .snd)) {-# REWRITE cast-Sigma #-} postulate cast-Sum-inj₁ : (A A' : Set ℓ) (B B' : Set ℓ₁) (a : A) → cast (A ⊎ B) (A' ⊎ B') (inj₁ a) ≡ inj₁ (cast A A' a) postulate cast-Sum-inj₂ : (A A' : Set ℓ) (B B' : Set ℓ₁) (b : B) → cast (A ⊎ B) (A' ⊎ B') (inj₂ b) ≡ inj₂ (cast B B' b) postulate cast-Sum-raise : (A A' : Set ℓ) (B B' : Set ℓ₁) (a : A) → cast (A ⊎ B) (A' ⊎ B') (raise _) ≡ raise _ postulate cast-Sum-unk : (A A' : Set ℓ) (B B' : Set ℓ₁) (a : A) → cast (A ⊎ B) (A' ⊎ B') (unk _) ≡ unk _ {-# REWRITE cast-Sum-inj₁ #-} {-# REWRITE cast-Sum-inj₂ cast-Sum-raise cast-Sum-unk #-} postulate cast-List-nil : (A A' : Set ℓ) → cast (List A) (List A') [] ≡ [] postulate cast-List-cons : (A A' : Set ℓ) (a : A) (l : List {a = ℓ} A) → cast (List A) (List {a = ℓ} A') (a ∷ l) ≡ cast A A' a ∷ cast (List A) (List A') l postulate cast-List-raise : (A A' : Set ℓ) → cast (List A) (List A') (raise (List _)) ≡ raise (List _) postulate cast-List-unk : (A A' : Set ℓ) → cast (List A) (List A') (unk (List _)) ≡ unk (List _) {-# REWRITE cast-List-nil #-} {-# REWRITE cast-List-cons cast-List-raise cast-List-unk #-} postulate cast-Nat-zero : cast Nat Nat 0 ≡ 0 postulate cast-Nat-suc : (n : Nat ) → cast Nat Nat (suc n) ≡ suc (cast _ _ n) postulate cast-Nat-raise : cast Nat Nat (raise Nat) ≡ raise Nat postulate cast-Nat-unk : cast Nat Nat (unk Nat) ≡ unk Nat {-# REWRITE cast-Nat-zero cast-Nat-suc cast-Nat-raise cast-Nat-unk #-} postulate cast-Bool-true : cast Bool Bool true ≡ true postulate cast-Bool-false : cast Bool Bool false ≡ false postulate cast-Bool-raise : cast Bool Bool (raise Bool) ≡ raise Bool postulate cast-Bool-unk : cast Bool Bool (unk Bool) ≡ unk Bool {-# REWRITE cast-Bool-true cast-Bool-false cast-Bool-raise cast-Bool-unk #-} postulate cast-Unit : cast ⊤ ⊤ tt ≡ tt {- Beware that raise ⊤ ≡ tt ≡ unk ⊤ because of definitional singleton -} postulate cast-Unit-raise : cast ⊤ ⊤ (raise ⊤) ≡ raise ⊤ postulate cast-Unit-unk : cast ⊤ ⊤ (unk ⊤) ≡ unk ⊤ {-# REWRITE cast-Unit cast-Unit-raise cast-Unit-unk #-} {- non-diagonal cases -} postulate cast-Set-bad : (A : Set (lsuc ℓ)) → cast (Set (lsuc ℓ)) (Set ℓ) A ≡ raise _ {-# REWRITE cast-Set-bad #-} postulate cast-raise : ∀ ℓ ℓ₁ → (x : raise {ℓ = lsuc ℓ} (Set ℓ)) (A : Set ℓ₁) → cast (raise {ℓ = lsuc ℓ} (Set ℓ)) A x ≡ raise _ {-# REWRITE cast-raise #-} postulate cast-Pi-Sigma : (A A' : Set ℓ) (B : A → Set ℓ₁) (B' : A' → Set ℓ₁) (f : (a : A) → B a) → cast ((a : A) → B a) (Σ {a = ℓ} {b = ℓ₁} A' B') f ≡ raise (Σ A' B') {-# REWRITE cast-Pi-Sigma #-} postulate cast-Pi-Nat : (A : Set ℓ) (B : A → Set ℓ₁) (f : (a : A) → B a) → cast ((a : A) → B a) Nat f ≡ raise Nat {-# REWRITE cast-Pi-Nat #-} -- missing many conflict rules {- Rules specific to Unk -} {- unk-cast ℓ A a is just a copy of cast A (Unk ℓ) a but we need to split it off for rewriting. Making it private so that the only closed values we can create in Unk ℓ come from cast -} private postulate unk-cast : ∀ (A : Set ℓ) → A → Unk (lsuc ℓ) postulate cast-Unk : (A : Set ℓ) (B : Set ℓ₁) (f : A) → cast (Unk (lsuc ℓ)) B (unk-cast A f) ≡ cast A B f {-# REWRITE cast-Unk #-} postulate cast-Unk-raise : ∀ ℓ → (B : Set ℓ₁) → cast (Unk ℓ) B (raise _) ≡ raise _ {-# REWRITE cast-Unk-raise #-} postulate cast-Pi-Unk : (A : Set ℓ) (B : A → Set ℓ₁) (f : (a : A) → B a) → cast ((a : A) → B a) (Unk (lsuc (ℓ ⊔ ℓ₁))) f ≡ unk-cast (Unk ℓ → Unk ℓ₁) (cast ((a : A) → B a) (Unk ℓ → Unk ℓ₁) f) {-# REWRITE cast-Pi-Unk #-} postulate cast-Pi-Unk-bad : (f : Unk ℓ → Unk ℓ₁) → cast (Unk ℓ → Unk ℓ₁) (Unk (ℓ ⊔ ℓ₁)) f ≡ raise _ {-# REWRITE cast-Pi-Unk-bad #-} postulate cast-Sigma-Unk : (A : Set ℓ) (B : A → Set ℓ₁) (x : Σ {a = ℓ} {b = ℓ₁} A B) → cast (Σ A B) (Unk (lsuc (ℓ ⊔ ℓ₁))) x ≡ unk-cast (_×_ {a = ℓ} {b = ℓ₁} (Unk ℓ) (Unk ℓ₁)) (cast (Σ A B) (Unk ℓ × Unk ℓ₁) x) {-# REWRITE cast-Sigma-Unk #-} delta : Unk ℓ → Unk ℓ delta {ℓ} x = cast (Unk ℓ) (Unk ℓ → Unk ℓ) x x omega : Unk ℓ omega {ℓ} = delta {ℓ = ℓ} (cast (Unk ℓ → Unk ℓ) (Unk ℓ) (delta {ℓ = ℓ})) foo : Unk (lsuc lzero) foo = cast (Nat → Nat → Nat) (Unk _) _+_ postulate cast-Nat-Unk : (n : Nat) → cast Nat (Unk (lsuc lzero)) n ≡ unk-cast Nat n record i (A : Set ℓ) : Set (ℓ ⊔ ℓ₁) where constructor inj field uninj : A open i public postulate cast-Nat-Unk' : (n : Nat) → cast (i {ℓ = ℓ} {ℓ₁ = ℓ₁} Nat) (Unk (lsuc ℓ)) (inj n) ≡ unk-cast Nat n postulate cast-Nat-iNat : (n : Nat) → cast Nat (i {ℓ = ℓ} {ℓ₁ = ℓ₁} Nat) n ≡ inj n {-# REWRITE cast-Nat-Unk cast-Nat-Unk' cast-Nat-iNat #-} retr : (A : Set ℓ) (a : A) → A retr {ℓ} A a = cast (Unk (lsuc ℓ)) A (cast A (Unk (lsuc ℓ)) a) retr-0 : retr {lzero} Nat 0 ≡ 0 retr-0 = refl retr-arr : (A : Set ℓ) (a : A) → A retr-arr {ℓ} A = retr (A → A) (λ a → a) zero' : Nat zero' = uninj (retr-arr {lsuc lzero} (i {ℓ₁ = lsuc lzero} Nat) (inj 0))
{ "alphanum_fraction": 0.5378177309, "avg_line_length": 33.4300518135, "ext": "agda", "hexsha": "43d3323c1840b8a8f2c247c4dd5998ba48b3e904", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2021-01-06T13:36:28.000Z", "max_forks_repo_forks_event_min_datetime": "2018-04-23T17:34:44.000Z", "max_forks_repo_head_hexsha": "c93256a11d59038998f09a01c5b42f6ffe42d5c4", "max_forks_repo_licenses": [ "WTFPL" ], "max_forks_repo_name": "CoqHott/exceptional-tt", "max_forks_repo_path": "agda-rr/cast-cic.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "c93256a11d59038998f09a01c5b42f6ffe42d5c4", "max_issues_repo_issues_event_max_datetime": "2019-02-28T18:28:53.000Z", "max_issues_repo_issues_event_min_datetime": "2019-02-28T16:35:41.000Z", "max_issues_repo_licenses": [ "WTFPL" ], "max_issues_repo_name": "CoqHott/exceptional-tt", "max_issues_repo_path": "agda-rr/cast-cic.agda", "max_line_length": 145, "max_stars_count": 14, "max_stars_repo_head_hexsha": "c93256a11d59038998f09a01c5b42f6ffe42d5c4", "max_stars_repo_licenses": [ "WTFPL" ], "max_stars_repo_name": "CoqHott/exceptional-tt", "max_stars_repo_path": "agda-rr/cast-cic.agda", "max_stars_repo_stars_event_max_datetime": "2021-03-23T12:45:05.000Z", "max_stars_repo_stars_event_min_datetime": "2017-10-13T01:31:56.000Z", "num_tokens": 2595, "size": 6452 }
{- Byzantine Fault Tolerant Consensus Verification in Agda, version 0.9. Copyright (c) 2021, Oracle and/or its affiliates. Licensed under the Universal Permissive License v 1.0 as shown at https://opensource.oracle.com/licenses/upl -} open import LibraBFT.Concrete.Records open import LibraBFT.Concrete.System open import LibraBFT.Concrete.System.Parameters open import LibraBFT.Concrete.Obligations.PreferredRound import LibraBFT.Concrete.Properties.Common as Common import LibraBFT.Concrete.Properties.PreferredRound as PR open import LibraBFT.Impl.Consensus.Network as Network open import LibraBFT.Impl.Consensus.Network.Properties as NetworkProps open import LibraBFT.Impl.Consensus.RoundManager import LibraBFT.Impl.Handle as Handle open import LibraBFT.Impl.Handle.Properties open import LibraBFT.Impl.Handle.InitProperties open initHandlerSpec open import LibraBFT.Impl.IO.OBM.InputOutputHandlers open import LibraBFT.Impl.IO.OBM.Properties.InputOutputHandlers open import LibraBFT.Impl.Properties.Common open import LibraBFT.ImplShared.Consensus.Types open import LibraBFT.ImplShared.Consensus.Types.EpochDep open import LibraBFT.ImplShared.Interface.Output open import LibraBFT.ImplShared.Util.Crypto open import LibraBFT.ImplShared.Util.Dijkstra.All open ReachableSystemStateProps open import LibraBFT.Impl.Properties.Util open import Optics.All open import Util.Lemmas open import Util.PKCS open import Util.Prelude open Invariants open RoundManagerTransProps open import LibraBFT.Abstract.Types.EpochConfig UID NodeId open ParamsWithInitAndHandlers Handle.InitHandler.initAndHandlers open import LibraBFT.ImplShared.Util.HashCollisions Handle.InitHandler.initAndHandlers open import Yasm.Yasm ℓ-RoundManager ℓ-VSFP ConcSysParms Handle.InitHandler.initAndHandlers PeerCanSignForPK PeerCanSignForPK-stable open Structural impl-sps-avp -- This module proves the two "PreferredRound" proof obligations for our handler. module LibraBFT.Impl.Properties.PreferredRound (𝓔 : EpochConfig) where ------------------------------------------------------------------------------ preferredRound₁ : PR.ImplObligation₁ Handle.InitHandler.initAndHandlers 𝓔 preferredRound₁ {pid} {pid'} {pk = pk} {pre} preach sps@(step-init rm×acts uni) {v = v} {m = m} {v' = v'} {m' = m'} hpk v'⊂m' m'∈acts sig' ¬bootstrap' pcs4' v⊂m m∈pool sig ¬bootstrap eid≡ rnd< v≈vabs v'≈vabs' c3 with initHandlerSpec.contract pid fakeBootstrapInfo rm×acts ...| init-contract with initHandlerSpec.ContractOk.isInitPM init-contract m'∈acts ...| (_ , refl , noSigs) with v'⊂m' ...| vote∈qc vs∈qc _ qc∈pm = ⊥-elim (noSigs vs∈qc qc∈pm) preferredRound₁ {pid} {pid'} {pk = pk} {pre} preach sps@(step-msg {sndr , P vm} vm'∈pool ini) {v = v} {m = m} {v' = v'} {m' = m'} hpk v'⊂m' m'∈acts sig' ¬bootstrap' pcs4' v⊂m m∈pool sig ¬bootstrap eid≡ rnd< v≈vabs v'≈vabs' c3 = obm-dangerous-magic' "Extend and use handleProposalSpec.contract" preferredRound₁ {pid} {pre = pre} preach sps@(step-msg {_ , V vm} _ _) _ v'⊂m' m'∈acts sig' ¬bootstrap' ¬msb _ _ _ _ _ _ _ _ _ with v'⊂m' ...| vote∈qc vs∈qc v≈rbld qc∈m' rewrite cong _vSignature v≈rbld = ⊥-elim ∘′ ¬msb $ qcVoteSigsSentB4-handle pid preach sps m'∈acts qc∈m' sig' vs∈qc v≈rbld ¬bootstrap' ...| vote∈vm = ⊥-elim (sendVote∉actions{outs = hvOut}{st = hvPre} (sym noVotes) m'∈acts) where hvPre = peerStates pre pid hvOut = LBFT-outs (handleVote 0 vm) hvPre open handleVoteSpec.Contract (handleVoteSpec.contract! 0 vm (msgPool pre) hvPre) ------------------------------------------------------------------------------ -- This proof is essentially the same as the votesOnce₂: no handler sends two different Votes -- TODO-2: refactor for DRY? preferredRound₂ : PR.ImplObligation₂ Handle.InitHandler.initAndHandlers 𝓔 preferredRound₂ {pid} _ (step-init rm×acts uni) _ v⊂m m∈acts _ _ _ _ _ _ _ _ _ _ _ _ with initHandlerSpec.contract pid fakeBootstrapInfo rm×acts ...| init-contract with initHandlerSpec.ContractOk.isInitPM init-contract m∈acts ...| (_ , refl , noSigs) with v⊂m ...| vote∈qc vs∈qc _ qc∈pm = ⊥-elim (noSigs vs∈qc qc∈pm) preferredRound₂ {pid}{pk = pk}{pre} rss (step-msg{sndr , m“} m“∈pool ini) {v = v}{v' = v'} hpk v⊂m m∈acts sig ¬bootstrap ¬msb4 pcsfpk v'⊂m' m'∈acts sig' ¬bootstrap' ¬msb4' _ _ round< with v⊂m ...| vote∈qc vs∈qc v≈rbld qc∈m rewrite cong _vSignature v≈rbld = ⊥-elim ∘′ ¬msb4 $ qcVoteSigsSentB4-handle pid rss (step-msg m“∈pool ini) m∈acts qc∈m sig vs∈qc v≈rbld ¬bootstrap ...| vote∈vm with v'⊂m' ...| vote∈qc vs∈qc' v≈rbld' qc∈m' rewrite cong _vSignature v≈rbld' = ⊥-elim ∘′ ¬msb4' $ qcVoteSigsSentB4-handle pid rss (step-msg m“∈pool ini) m'∈acts qc∈m' sig' vs∈qc' v≈rbld' ¬bootstrap' ...| vote∈vm with m“ ...| P pm = ⊥-elim (<⇒≢ round< (cong (_^∙ vRound) v≡v')) where hpPool = msgPool pre hpPre = peerStates pre pid hpOut = LBFT-outs (handleProposal 0 pm) hpPre open handleProposalSpec.Contract (handleProposalSpec.contract! 0 pm hpPool hpPre) v≡v' : v ≡ v' v≡v' with BlockId-correct? (pm ^∙ pmProposal) ...| no ¬validProposal = ⊥-elim (sendVote∉actions {outs = hpOut} {st = hpPre} (sym (proj₂ $ invalidProposal ¬validProposal)) m∈acts) ...| yes refl with voteAttemptCorrect refl (nohc rss m“∈pool pid ini (invariantsCorrect pid pre ini rss) refl refl ) ...| Voting.mkVoteAttemptCorrectWithEpochReq (Left (_ , Voting.mkVoteUnsentCorrect noVoteMsgOuts _)) _ = ⊥-elim (sendVote∉actions{outs = hpOut}{st = hpPre} (sym noVoteMsgOuts) m∈acts) ...| Voting.mkVoteAttemptCorrectWithEpochReq (Right (Voting.mkVoteSentCorrect vm pid voteMsgOuts _)) _ = begin v ≡⟨ cong (_^∙ vmVote) (sendVote∈actions{outs = hpOut}{st = hpPre} (sym voteMsgOuts) m∈acts) ⟩ vm ^∙ vmVote ≡⟨ (sym $ cong (_^∙ vmVote) (sendVote∈actions{outs = hpOut}{st = hpPre} (sym voteMsgOuts) m'∈acts)) ⟩ v' ∎ where open ≡-Reasoning ... | V vm = ⊥-elim (sendVote∉actions{outs = hvOut}{st = hvPre} (sym noVotes) m∈acts) where hvPre = peerStates pre pid hvOut = LBFT-outs (handle pid (V vm) 0) hvPre open handleVoteSpec.Contract (handleVoteSpec.contract! 0 vm (msgPool pre) hvPre)
{ "alphanum_fraction": 0.6866635176, "avg_line_length": 48.4809160305, "ext": "agda", "hexsha": "4d702232f3795a3a4ac710f921768cf66180c0c9", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "a4674fc473f2457fd3fe5123af48253cfb2404ef", "max_forks_repo_licenses": [ "UPL-1.0" ], "max_forks_repo_name": "LaudateCorpus1/bft-consensus-agda", "max_forks_repo_path": "src/LibraBFT/Impl/Properties/PreferredRound.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "a4674fc473f2457fd3fe5123af48253cfb2404ef", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "UPL-1.0" ], "max_issues_repo_name": "LaudateCorpus1/bft-consensus-agda", "max_issues_repo_path": "src/LibraBFT/Impl/Properties/PreferredRound.agda", "max_line_length": 182, "max_stars_count": null, "max_stars_repo_head_hexsha": "a4674fc473f2457fd3fe5123af48253cfb2404ef", "max_stars_repo_licenses": [ "UPL-1.0" ], "max_stars_repo_name": "LaudateCorpus1/bft-consensus-agda", "max_stars_repo_path": "src/LibraBFT/Impl/Properties/PreferredRound.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 2114, "size": 6351 }
{-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.Functions.Embedding where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Function open import Cubical.Foundations.Equiv open import Cubical.Foundations.Equiv.Properties open import Cubical.Foundations.Equiv.HalfAdjoint open import Cubical.Foundations.HLevels open import Cubical.Foundations.Transport open import Cubical.Foundations.Isomorphism open import Cubical.Foundations.Path open import Cubical.Foundations.Powerset open import Cubical.Foundations.Prelude open import Cubical.Foundations.Univalence using (ua; univalence) open import Cubical.Functions.Fibration open import Cubical.Data.Sigma open import Cubical.Functions.Fibration open import Cubical.Functions.FunExtEquiv open import Cubical.Relation.Nullary using (Discrete; yes; no) open import Cubical.Structures.Axioms open import Cubical.Reflection.StrictEquiv open import Cubical.Data.Nat using (ℕ; zero; suc) open import Cubical.Data.Sigma private variable ℓ ℓ₁ ℓ₂ : Level A B : Type ℓ f h : A → B w x : A y z : B -- Embeddings are generalizations of injections. The usual -- definition of injection as: -- -- f x ≡ f y → x ≡ y -- -- is not well-behaved with higher h-levels, while embeddings -- are. isEmbedding : (A → B) → Type _ isEmbedding f = ∀ w x → isEquiv {A = w ≡ x} (cong f) isEmbeddingIsProp : isProp (isEmbedding f) isEmbeddingIsProp {f = f} = isPropΠ2 λ _ _ → isPropIsEquiv (cong f) -- If A and B are h-sets, then injective functions between -- them are embeddings. -- -- Note: It doesn't appear to be possible to omit either of -- the `isSet` hypotheses. injEmbedding : {f : A → B} → isSet A → isSet B → (∀{w x} → f w ≡ f x → w ≡ x) → isEmbedding f injEmbedding {f = f} iSA iSB inj w x = isoToIsEquiv (iso (cong f) inj sect retr) where sect : section (cong f) inj sect p = iSB (f w) (f x) _ p retr : retract (cong f) inj retr p = iSA w x _ p -- If `f` is an embedding, we'd expect the fibers of `f` to be -- propositions, like an injective function. hasPropFibers : (A → B) → Type _ hasPropFibers f = ∀ y → isProp (fiber f y) -- This can be relaxed to having all prop fibers over the image, see [hasPropFibersOfImage→isEmbedding] hasPropFibersOfImage : (A → B) → Type _ hasPropFibersOfImage f = ∀ x → isProp (fiber f (f x)) -- some notation _↪_ : Type ℓ₁ → Type ℓ₂ → Type (ℓ-max ℓ₁ ℓ₂) A ↪ B = Σ[ f ∈ (A → B) ] isEmbedding f hasPropFibersIsProp : isProp (hasPropFibers f) hasPropFibersIsProp = isPropΠ (λ _ → isPropIsProp) private lemma₀ : (p : y ≡ z) → fiber f y ≡ fiber f z lemma₀ {f = f} p = λ i → fiber f (p i) lemma₁ : isEmbedding f → ∀ x → isContr (fiber f (f x)) lemma₁ {f = f} iE x = value , path where value : fiber f (f x) value = (x , refl) path : ∀(fi : fiber f (f x)) → value ≡ fi path (w , p) i = case equiv-proof (iE w x) p of λ { ((q , sq) , _) → hfill (λ j → λ { (i = i0) → (x , refl) ; (i = i1) → (w , sq j) }) (inS (q (~ i) , λ j → f (q (~ i ∨ j)))) i1 } isEmbedding→hasPropFibers : isEmbedding f → hasPropFibers f isEmbedding→hasPropFibers iE y (x , p) = subst (λ f → isProp f) (lemma₀ p) (isContr→isProp (lemma₁ iE x)) (x , p) private fibCong→PathP : {f : A → B} → (p : f w ≡ f x) → (fi : fiber (cong f) p) → PathP (λ i → fiber f (p i)) (w , refl) (x , refl) fibCong→PathP p (q , r) i = q i , λ j → r j i PathP→fibCong : {f : A → B} → (p : f w ≡ f x) → (pp : PathP (λ i → fiber f (p i)) (w , refl) (x , refl)) → fiber (cong f) p PathP→fibCong p pp = (λ i → fst (pp i)) , (λ j i → snd (pp i) j) PathP≡fibCong : {f : A → B} → (p : f w ≡ f x) → PathP (λ i → fiber f (p i)) (w , refl) (x , refl) ≡ fiber (cong f) p PathP≡fibCong p = isoToPath (iso (PathP→fibCong p) (fibCong→PathP p) (λ _ → refl) (λ _ → refl)) hasPropFibers→isEmbedding : hasPropFibers f → isEmbedding f hasPropFibers→isEmbedding {f = f} iP w x .equiv-proof p = subst isContr (PathP≡fibCong p) (isProp→isContrPathP (λ i → iP (p i)) fw fx) where fw : fiber f (f w) fw = (w , refl) fx : fiber f (f x) fx = (x , refl) hasPropFibersOfImage→hasPropFibers : hasPropFibersOfImage f → hasPropFibers f hasPropFibersOfImage→hasPropFibers {f = f} fibImg y a b = subst (λ y → isProp (fiber f y)) (snd a) (fibImg (fst a)) a b hasPropFibersOfImage→isEmbedding : hasPropFibersOfImage f → isEmbedding f hasPropFibersOfImage→isEmbedding = hasPropFibers→isEmbedding ∘ hasPropFibersOfImage→hasPropFibers isEmbedding≡hasPropFibers : isEmbedding f ≡ hasPropFibers f isEmbedding≡hasPropFibers = isoToPath (iso isEmbedding→hasPropFibers hasPropFibers→isEmbedding (λ _ → hasPropFibersIsProp _ _) (λ _ → isEmbeddingIsProp _ _)) isEquiv→hasPropFibers : isEquiv f → hasPropFibers f isEquiv→hasPropFibers e b = isContr→isProp (equiv-proof e b) isEquiv→isEmbedding : isEquiv f → isEmbedding f isEquiv→isEmbedding e = λ _ _ → congEquiv (_ , e) .snd Equiv→Embedding : A ≃ B → A ↪ B Equiv→Embedding (f , isEquivF) = (f , isEquiv→isEmbedding isEquivF) iso→isEmbedding : ∀ {ℓ} {A B : Type ℓ} → (isom : Iso A B) ------------------------------- → isEmbedding (Iso.fun isom) iso→isEmbedding {A = A} {B} isom = (isEquiv→isEmbedding (equivIsEquiv (isoToEquiv isom))) isEmbedding→Injection : ∀ {ℓ} {A B C : Type ℓ} → (a : A → B) → (e : isEmbedding a) ---------------------- → ∀ {f g : C → A} → ∀ x → (a (f x) ≡ a (g x)) ≡ (f x ≡ g x) isEmbedding→Injection a e {f = f} {g} x = sym (ua (cong a , e (f x) (g x))) -- if `f` has a retract, then `cong f` has, as well. If `B` is a set, then `cong f` -- further has a section, making `f` an embedding. module _ {f : A → B} (retf : hasRetract f) where open Σ retf renaming (fst to g ; snd to ϕ) congRetract : f w ≡ f x → w ≡ x congRetract {w = w} {x = x} p = sym (ϕ w) ∙∙ cong g p ∙∙ ϕ x isRetractCongRetract : retract (cong {x = w} {y = x} f) congRetract isRetractCongRetract p = transport (PathP≡doubleCompPathˡ _ _ _ _) (λ i j → ϕ (p j) i) hasRetract→hasRetractCong : hasRetract (cong {x = w} {y = x} f) hasRetract→hasRetractCong = congRetract , isRetractCongRetract retractableIntoSet→isEmbedding : isSet B → isEmbedding f retractableIntoSet→isEmbedding setB w x = isoToIsEquiv (iso (cong f) congRetract (λ _ → setB _ _ _ _) (hasRetract→hasRetractCong .snd)) Embedding-into-Discrete→Discrete : A ↪ B → Discrete B → Discrete A Embedding-into-Discrete→Discrete (f , isEmbeddingF) _≟_ x y with f x ≟ f y ... | yes p = yes (invIsEq (isEmbeddingF x y) p) ... | no ¬p = no (¬p ∘ cong f) Embedding-into-isProp→isProp : A ↪ B → isProp B → isProp A Embedding-into-isProp→isProp (f , isEmbeddingF) isProp-B x y = invIsEq (isEmbeddingF x y) (isProp-B (f x) (f y)) Embedding-into-isSet→isSet : A ↪ B → isSet B → isSet A Embedding-into-isSet→isSet (f , isEmbeddingF) isSet-B x y p q = p ≡⟨ sym (retIsEq isEquiv-cong-f p) ⟩ cong-f⁻¹ (cong f p) ≡⟨ cong cong-f⁻¹ cong-f-p≡cong-f-q ⟩ cong-f⁻¹ (cong f q) ≡⟨ retIsEq isEquiv-cong-f q ⟩ q ∎ where cong-f-p≡cong-f-q = isSet-B (f x) (f y) (cong f p) (cong f q) isEquiv-cong-f = isEmbeddingF x y cong-f⁻¹ = invIsEq isEquiv-cong-f Embedding-into-hLevel→hLevel : ∀ n → A ↪ B → isOfHLevel (suc n) B → isOfHLevel (suc n) A Embedding-into-hLevel→hLevel zero = Embedding-into-isProp→isProp Embedding-into-hLevel→hLevel (suc n) (f , isEmbeddingF) Blvl x y = isOfHLevelRespectEquiv (suc n) (invEquiv equiv) subLvl where equiv : (x ≡ y) ≃ (f x ≡ f y) equiv .fst = cong f equiv .snd = isEmbeddingF x y subLvl : isOfHLevel (suc n) (f x ≡ f y) subLvl = Blvl (f x) (f y) -- We now show that the powerset is the subtype classifier -- i.e. ℙ X ≃ Σ[A ∈ Type ℓ] (A ↪ X) Embedding→Subset : {X : Type ℓ} → Σ[ A ∈ Type ℓ ] (A ↪ X) → ℙ X Embedding→Subset (_ , f , isEmbeddingF) x = fiber f x , isEmbedding→hasPropFibers isEmbeddingF x Subset→Embedding : {X : Type ℓ} → ℙ X → Σ[ A ∈ Type ℓ ] (A ↪ X) Subset→Embedding {X = X} A = D , fst , Ψ where D = Σ[ x ∈ X ] x ∈ A Ψ : isEmbedding fst Ψ w x = isEmbeddingFstΣProp (∈-isProp A) Subset→Embedding→Subset : {X : Type ℓ} → section (Embedding→Subset {ℓ} {X}) (Subset→Embedding {ℓ} {X}) Subset→Embedding→Subset _ = funExt λ x → Σ≡Prop (λ _ → isPropIsProp) (ua (FiberIso.fiberEquiv _ x)) Embedding→Subset→Embedding : {X : Type ℓ} → retract (Embedding→Subset {ℓ} {X}) (Subset→Embedding {ℓ} {X}) Embedding→Subset→Embedding {ℓ = ℓ} {X = X} (A , f , ψ) = cong (equivFun Σ-assoc-≃) (Σ≡Prop (λ _ → isEmbeddingIsProp) (secEq (fibrationEquiv X ℓ) (A , f))) Subset≃Embedding : {X : Type ℓ} → ℙ X ≃ (Σ[ A ∈ Type ℓ ] (A ↪ X)) Subset≃Embedding = isoToEquiv (iso Subset→Embedding Embedding→Subset Embedding→Subset→Embedding Subset→Embedding→Subset) Subset≡Embedding : {X : Type ℓ} → ℙ X ≡ (Σ[ A ∈ Type ℓ ] (A ↪ X)) Subset≡Embedding = ua Subset≃Embedding isEmbedding-∘ : isEmbedding f → isEmbedding h → isEmbedding (f ∘ h) isEmbedding-∘ {f = f} {h = h} Embf Embh w x = compEquiv (cong h , Embh w x) (cong f , Embf (h w) (h x)) .snd isEmbedding→embedsFibersIntoSingl : isEmbedding f → ∀ z → fiber f z ↪ singl z isEmbedding→embedsFibersIntoSingl {f = f} isE z = e , isEmbE where e : fiber f z → singl z e x = f (fst x) , sym (snd x) isEmbE : isEmbedding e isEmbE u v = goal where -- "adjust" ΣeqCf by trivial equivalences that hold judgementally, which should save compositions Dom′ : ∀ u v → Type _ Dom′ u v = Σ[ p ∈ fst u ≡ fst v ] PathP (λ i → f (p i) ≡ z) (snd u) (snd v) Cod′ : ∀ u v → Type _ Cod′ u v = Σ[ p ∈ f (fst u) ≡ f (fst v) ] PathP (λ i → p i ≡ z) (snd u) (snd v) ΣeqCf : Dom′ u v ≃ Cod′ u v ΣeqCf = Σ-cong-equiv-fst (_ , isE _ _) dom→ : u ≡ v → Dom′ u v dom→ p = cong fst p , cong snd p dom← : Dom′ u v → u ≡ v dom← p i = p .fst i , p .snd i cod→ : e u ≡ e v → Cod′ u v cod→ p = cong fst p , cong (sym ∘ snd) p cod← : Cod′ u v → e u ≡ e v cod← p i = p .fst i , sym (p .snd i) goal : isEquiv (cong e) goal .equiv-proof x .fst .fst = dom← (equivCtr ΣeqCf (cod→ x) .fst) goal .equiv-proof x .fst .snd j = cod← (equivCtr ΣeqCf (cod→ x) .snd j) goal .equiv-proof x .snd (g , p) i .fst = dom← (equivCtrPath ΣeqCf (cod→ x) (dom→ g , cong cod→ p) i .fst) goal .equiv-proof x .snd (g , p) i .snd j = cod← (equivCtrPath ΣeqCf (cod→ x) (dom→ g , cong cod→ p) i .snd j) isEmbedding→hasPropFibers′ : isEmbedding f → hasPropFibers f isEmbedding→hasPropFibers′ {f = f} iE z = Embedding-into-isProp→isProp (isEmbedding→embedsFibersIntoSingl iE z) isPropSingl universeEmbedding : ∀ {ℓ ℓ₁ : Level} → (F : Type ℓ → Type ℓ₁) → (∀ X → F X ≃ X) → isEmbedding F universeEmbedding F liftingEquiv = hasPropFibersOfImage→isEmbedding propFibersF where lemma : ∀ A B → (F A ≡ F B) ≃ (B ≡ A) lemma A B = (F A ≡ F B) ≃⟨ univalence ⟩ (F A ≃ F B) ≃⟨ equivComp (liftingEquiv A) (liftingEquiv B) ⟩ (A ≃ B) ≃⟨ invEquivEquiv ⟩ (B ≃ A) ≃⟨ invEquiv univalence ⟩ (B ≡ A) ■ fiberSingl : ∀ X → fiber F (F X) ≃ singl X fiberSingl X = Σ-cong-equiv-snd (λ _ → lemma _ _) propFibersF : hasPropFibersOfImage F propFibersF X = Embedding-into-isProp→isProp (Equiv→Embedding (fiberSingl X)) isPropSingl liftEmbedding : (ℓ ℓ₁ : Level) → isEmbedding (Lift {i = ℓ} {j = ℓ₁}) liftEmbedding ℓ ℓ₁ = universeEmbedding (Lift {j = ℓ₁}) (λ _ → invEquiv LiftEquiv) module FibrationIdentityPrinciple {B : Type ℓ} {ℓ₁} where -- note that fibrationEquiv (for good reason) uses ℓ₁ = ℓ-max ℓ ℓ₁, so we have to work -- some universe magic to achieve good universe polymorphism -- First, prove it for the case that's dealt with in fibrationEquiv Fibration′ = Fibration B (ℓ-max ℓ ℓ₁) module Lifted (f g : Fibration′) where f≃g′ : Type (ℓ-max ℓ ℓ₁) f≃g′ = ∀ b → fiber (f .snd) b ≃ fiber (g .snd) b Fibration′IP : f≃g′ ≃ (f ≡ g) Fibration′IP = f≃g′ ≃⟨ equivΠCod (λ _ → invEquiv univalence) ⟩ (∀ b → fiber (f .snd) b ≡ fiber (g .snd) b) ≃⟨ funExtEquiv ⟩ fiber (f .snd) ≡ fiber (g .snd) ≃⟨ invEquiv (congEquiv (fibrationEquiv B ℓ₁)) ⟩ f ≡ g ■ -- Then embed into the above case by lifting the type L : Type _ → Type _ -- local synonym fixing the levels of Lift L = Lift {i = ℓ₁} {j = ℓ} liftFibration : Fibration B ℓ₁ → Fibration′ liftFibration (A , f) = L A , f ∘ lower hasPropFibersLiftFibration : hasPropFibers liftFibration hasPropFibersLiftFibration (A , f) = Embedding-into-isProp→isProp (Equiv→Embedding fiberChar) (isPropΣ (isEmbedding→hasPropFibers (liftEmbedding _ _) A) λ _ → isEquiv→hasPropFibers (snd (invEquiv (preCompEquiv LiftEquiv))) _) where fiberChar : fiber liftFibration (A , f) ≃ (Σ[ (E , eq) ∈ fiber L A ] fiber (_∘ lower) (transport⁻ (λ i → eq i → B) f)) fiberChar = fiber liftFibration (A , f) ≃⟨ Σ-cong-equiv-snd (λ _ → invEquiv ΣPath≃PathΣ) ⟩ (Σ[ (E , g) ∈ Fibration B ℓ₁ ] Σ[ eq ∈ (L E ≡ A) ] PathP (λ i → eq i → B) (g ∘ lower) f) ≃⟨ boringSwap ⟩ (Σ[ (E , eq) ∈ fiber L A ] Σ[ g ∈ (E → B) ] PathP (λ i → eq i → B) (g ∘ lower) f) ≃⟨ Σ-cong-equiv-snd (λ _ → Σ-cong-equiv-snd λ _ → transportEquiv (PathP≡Path⁻ _ _ _)) ⟩ (Σ[ (E , eq) ∈ fiber L A ] fiber (_∘ lower) (transport⁻ (λ i → eq i → B) f)) ■ where unquoteDecl boringSwap = declStrictEquiv boringSwap (λ ((E , g) , (eq , p)) → ((E , eq) , (g , p))) (λ ((E , g) , (eq , p)) → ((E , eq) , (g , p))) isEmbeddingLiftFibration : isEmbedding liftFibration isEmbeddingLiftFibration = hasPropFibers→isEmbedding hasPropFibersLiftFibration -- and finish off module _ (f g : Fibration B ℓ₁) where open Lifted (liftFibration f) (liftFibration g) f≃g : Type (ℓ-max ℓ ℓ₁) f≃g = ∀ b → fiber (f .snd) b ≃ fiber (g .snd) b FibrationIP : f≃g ≃ (f ≡ g) FibrationIP = f≃g ≃⟨ equivΠCod (λ b → equivComp (Σ-cong-equiv-fst LiftEquiv) (Σ-cong-equiv-fst LiftEquiv)) ⟩ f≃g′ ≃⟨ Fibration′IP ⟩ (liftFibration f ≡ liftFibration g) ≃⟨ invEquiv (_ , isEmbeddingLiftFibration _ _) ⟩ (f ≡ g) ■ open FibrationIdentityPrinciple renaming (f≃g to _≃Fib_) using (FibrationIP) public Embedding : (B : Type ℓ₁) → (ℓ : Level) → Type (ℓ-max ℓ₁ (ℓ-suc ℓ)) Embedding B ℓ = Σ[ A ∈ Type ℓ ] A ↪ B module EmbeddingIdentityPrinciple {B : Type ℓ} {ℓ₁} (f g : Embedding B ℓ₁) where module _ where open Σ f renaming (fst to F) public open Σ g renaming (fst to G) public open Σ (f .snd) renaming (fst to ffun; snd to isEmbF) public open Σ (g .snd) renaming (fst to gfun; snd to isEmbG) public f≃g : Type _ f≃g = (∀ b → fiber ffun b → fiber gfun b) × (∀ b → fiber gfun b → fiber ffun b) toFibr : Embedding B ℓ₁ → Fibration B ℓ₁ toFibr (A , (f , _)) = (A , f) isEmbeddingToFibr : isEmbedding toFibr isEmbeddingToFibr w x = fullEquiv .snd where -- carefully managed such that (cong toFibr) is the equivalence fullEquiv : (w ≡ x) ≃ (toFibr w ≡ toFibr x) fullEquiv = compEquiv (congEquiv (invEquiv Σ-assoc-≃)) (invEquiv (Σ≡PropEquiv (λ _ → isEmbeddingIsProp))) EmbeddingIP : f≃g ≃ (f ≡ g) EmbeddingIP = f≃g ≃⟨ strictIsoToEquiv (invIso toProdIso) ⟩ (∀ b → (fiber ffun b → fiber gfun b) × (fiber gfun b → fiber ffun b)) ≃⟨ equivΠCod (λ _ → isEquivPropBiimpl→Equiv (isEmbedding→hasPropFibers isEmbF _) (isEmbedding→hasPropFibers isEmbG _)) ⟩ (∀ b → (fiber (f .snd .fst) b) ≃ (fiber (g .snd .fst) b)) ≃⟨ FibrationIP (toFibr f) (toFibr g) ⟩ (toFibr f ≡ toFibr g) ≃⟨ invEquiv (_ , isEmbeddingToFibr _ _) ⟩ f ≡ g ■ open EmbeddingIdentityPrinciple renaming (f≃g to _≃Emb_) using (EmbeddingIP) public
{ "alphanum_fraction": 0.6150536293, "avg_line_length": 37.4672897196, "ext": "agda", "hexsha": "b68a7f89e8f502c0220fab270e65a8a1af7fc256", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "5de11df25b79ee49d5c084fbbe6dfc66e4147a2e", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Edlyr/cubical", "max_forks_repo_path": "Cubical/Functions/Embedding.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "5de11df25b79ee49d5c084fbbe6dfc66e4147a2e", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Edlyr/cubical", "max_issues_repo_path": "Cubical/Functions/Embedding.agda", "max_line_length": 109, "max_stars_count": null, "max_stars_repo_head_hexsha": "5de11df25b79ee49d5c084fbbe6dfc66e4147a2e", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Edlyr/cubical", "max_stars_repo_path": "Cubical/Functions/Embedding.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 6353, "size": 16036 }
-- IIRDg is expressible in IIRDr + Identity module Proof where open import LF open import IIRD open import IIRDr open import DefinitionalEquality open import Identity open import Proof.Setup import Logic.ChainReasoning as Chain -- We can then define general IIRDs using the ε function from Proof.Setup. Ug : {I : Set}{D : I -> Set1} -> OPg I D -> I -> Set Ug γ = Ur (ε γ) Tg : {I : Set}{D : I -> Set1}(γ : OPg I D)(i : I) -> Ug γ i -> D i Tg γ = Tr (ε γ) introg : {I : Set}{D : I -> Set1}(γ : OPg I D)(a : Gu γ (Ug γ) (Tg γ)) -> Ug γ (Gi γ (Ug γ) (Tg γ) a) introg γ a = intror (G→H γ (Ug γ) (Tg γ) a) -- To prove the reduction behviour of Tg we first have to prove that the -- top-level reduction of the encoding behaves as it should. At bit simplified -- that Ht (ε γ) (Gi a) ≡ Gt γ a Tg-eq : {I : Set}{D : I -> Set1}(γ : OPg I D)(U : I -> Set)(T : (i : I) -> U i -> D i) (a : Gu γ U T) -> Ht (ε γ) U T (Gi γ U T a) (G→H γ U T a) ≡₁ Gt γ U T a Tg-eq {I}{D} (ι < i | e >') U T ★ = refl-≡₁ Tg-eq (σ A γ) U T < a | b > = Tg-eq (γ a) U T b Tg-eq (δ A i γ) U T < g | b > = Tg-eq (γ (T « i × g »)) U T b -- The statement we're interested in is a special case of the more general -- lemma above. Tg-equality : {I : Set}{D : I -> Set1}(γ : OPg I D)(a : Gu γ (Ug γ) (Tg γ)) -> Tg γ (Gi γ (Ug γ) (Tg γ) a) (introg γ a) ≡₁ Gt γ (Ug γ) (Tg γ) a Tg-equality γ a = Tg-eq γ (Ug γ) (Tg γ) a -- The elimination rule for generalised IIRDs. -- It's basically the elimination of the encoding followed by the elimination -- of the proof the the index is the right one. Rg : {I : Set}{D : I -> Set1}(γ : OPg I D)(F : (i : I) -> Ug γ i -> Set1) (h : (a : Gu γ (Ug γ) (Tg γ)) -> KIH γ (Ug γ) (Tg γ) F a -> F (Gi γ (Ug γ) (Tg γ) a) (introg γ a)) (i : I)(u : Ug γ i) -> F i u Rg {I}{D} γ F h = Rr (ε γ) F \i a ih -> G→H∘H→G-subst γ U T (\i a -> F i (intror a)) i a (lem1 i a ih) where U = Ug γ T = Tg γ lem1 : (i : I)(a : Hu (ε γ) U T i) -> KIH (ε γ i) U T F a -> F (Gi γ U T (H→G γ U T i a)) (intror (G→H γ U T (H→G γ U T i a))) lem1 i a ih = h (H→G γ U T i a) (\v -> εIArg-subst γ U T F i a v (ih (εIArg γ U T i a v))) open module Chain-≡ = Chain.Poly.Heterogenous1 _≡₁_ (\x -> refl-≡₁) trans-≡₁ open module Chain-≡₀ = Chain.Poly.Heterogenous _≡_ (\x -> refl-≡) trans-≡ renaming (chain>_ to chain>₀_; _===_ to _===₀_; _by_ to _by₀_) -- Again we have to generalise Rg-eq : {I : Set}{D : I -> Set1}(γ : OPg I D)(U : I -> Set)(T : (i : I) -> U i -> D i) (F : (i : I) -> U i -> Set1)(intro : (a : Gu γ U T) -> U (Gi γ U T a)) (g : (i : I)(u : U i) -> F i u) (h : (a : Gu γ U T) -> KIH γ U T F a -> F (Gi γ U T a) (intro a)) (a : Gu γ U T) -> let i = Gi γ U T a a' = G→H γ U T a in h (H→G γ U T i a') (\v -> εIArg-subst γ U T F i a' v (Kmap (ε γ i) U T F g a' (εIArg γ U T i a' v))) ≡₁ h a (Kmap γ U T F g a) Rg-eq {I}{D} γ U T F intro g h a = app-≡₁ (cong-≡₁⁰ h (H→G∘G→H-identity γ U T a)) (η-≡₁⁰ \x y p -> chain> εIArg-subst γ U T F i a' x (Kmap (ε γ i) U T F g a' (εIArg γ U T i a' x)) === Kmap (ε γ i) U T F g a' (εIArg γ U T i a' x) by εIArg-identity γ U T F a x (Kmap (ε γ i) U T F g a' (εIArg γ U T i a' x)) === Kmap γ U T F g a y by app-≡₁⁰ (cong-≡₁⁰ g (chain>₀ KIArg→I (ε γ i) U T a' (εIArg γ U T i a' x) ===₀ KIArg→I γ U T (H→G γ U T i a') x by₀ εIArg→I-identity γ U T i a' x ===₀ KIArg→I γ U T a y by₀ app-≡₀ (cong-≡' (KIArg→I γ U T) (H→G∘G→H-identity γ U T a) ) p ) ) (chain>₀ KIArg→U (ε γ i) U T a' (εIArg γ U T i a' x) ===₀ KIArg→U γ U T (H→G γ U T i a') x by₀ εIArg→U-identity γ U T i a' x ===₀ KIArg→U γ U T a y by₀ app-≡₀ (cong-≡' (KIArg→U γ U T) (H→G∘G→H-identity γ U T a) ) p ) ) where i = Gi γ U T a a' = G→H γ U T a Rg-equality : {I : Set}{D : I -> Set1}(γ : OPg I D)(F : (i : I) -> Ug γ i -> Set1) (h : (a : Gu γ (Ug γ) (Tg γ)) -> KIH γ (Ug γ) (Tg γ) F a -> F (Gi γ (Ug γ) (Tg γ) a) (introg γ a)) (a : Gu γ (Ug γ) (Tg γ)) -> Rg γ F h (Gi γ (Ug γ) (Tg γ) a) (introg γ a) ≡₁ h a (Kmap γ (Ug γ) (Tg γ) F (Rg γ F h) a) Rg-equality {I}{D} γ F h a = chain> Rg γ F h (Gi γ U T a) (introg γ a) === h'' i a' ih by refl-≡₁ === G→H∘H→G-subst γ U T F' i a' (h' i a' ih) by refl-≡₁ === h' i a' ih by G→H∘H→G-identity γ U T F' a (h' i a' ih) === h (H→G γ U T i a') (\v -> εIArg-subst γ U T F i a' v (ih (εIArg γ U T i a' v))) by refl-≡₁ === h a (Kmap γ U T F (Rg γ F h) a) by Rg-eq γ U T F (introg γ) (Rg γ F h) h a where U = Ug γ T = Tg γ F' = \i a -> F i (intror a) i = Gi γ U T a a' = G→H γ U T a h' : (i : I)(a : Hu (ε γ) U T i) -> KIH (ε γ i) U T F a -> F _ _ h' = \i a ih -> h (H→G γ U T i a) \v -> εIArg-subst γ U T F i a v (ih (εIArg γ U T i a v)) h'' = \i a ih -> G→H∘H→G-subst γ U T F' i a (h' i a ih) ih = Kmap (ε γ i) U T F (Rg γ F h) a'
{ "alphanum_fraction": 0.4258807115, "avg_line_length": 43.7709923664, "ext": "agda", "hexsha": "f625fdc7fa99d32f132a3efdf702423f511d277c", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_forks_event_min_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "masondesu/agda", "max_forks_repo_path": "examples/outdated-and-incorrect/iird/Proof.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.agda", "max_line_length": 112, "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.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": 2377, "size": 5734 }
module Deriv where open import Relation.Binary.Bundles using (DecSetoid) open import Algebra.Bundles using (Semiring) open import Level using (0ℓ) open import Relation.Nullary using (yes; no) module _ (S : DecSetoid 0ℓ 0ℓ) (Targ : Set) where open DecSetoid S renaming (Carrier to Key) infixl 6 _+_ infixl 7 _*_ data Expr : Set where ↑ : Targ → Expr ! : Key → Expr _+_ : Expr → Expr → Expr _*_ : Expr → Expr → Expr module _ {S : DecSetoid 0ℓ 0ℓ} (R : Semiring 0ℓ 0ℓ) where private module S = DecSetoid S open S renaming (Carrier to Key) private module R = Semiring R open R using (0#; 1#) renaming (Carrier to Targ) eval : (lookup : Key → Targ) → (expr : Expr S Targ) → Targ eval lookup (↑ x) = x eval lookup (! x) = lookup x eval lookup (x + x₁) = eval lookup x₁ R.+ eval lookup x₁ eval lookup (x * x₁) = eval lookup x₁ R.* eval lookup x₁ deriv : Expr S Targ → Key → Expr S Targ deriv (↑ x) k = ↑ 0# deriv (! x) k with x ≟ k deriv (! x) k | yes _ = ↑ 1# deriv (! x) k | no _ = ↑ 0# deriv (e + e₁) k = deriv e k + deriv e₁ k deriv (e * e₁) k = (deriv e k * e₁) + (e * deriv e₁ k) open import Data.Nat using (ℕ) open import Data.Nat.Properties using (+-*-semiring) open import Data.String open import Relation.Binary.PropositionalEquality using (decSetoid) asdf : Expr (decSetoid _≟_) ℕ asdf = ↑ 2 + (↑ 5 * (! "hello" * ! "goodbye")) asdf' : Expr (decSetoid _≟_) ℕ asdf' = deriv +-*-semiring asdf "hello" normalize : ∀ {D} → Expr D ℕ → Expr D ℕ normalize (x + y) with normalize x | normalize y normalize (x + y) | ↑ w | ↑ z = ↑ (w Data.Nat.+ z) normalize (x + y) | ↑ 0 | z = z normalize (x + y) | w | ↑ 0 = w normalize (x + y) | w | z = w + z normalize (x * y) with normalize x | normalize y normalize (x * y) | ↑ w | ↑ z = ↑ (w Data.Nat.* z) normalize (x * y) | ↑ 0 | z = ↑ 0 normalize (x * y) | w | ↑ 0 = ↑ 0 normalize (x * y) | ↑ 1 | z = z normalize (x * y) | w | ↑ 1 = w normalize (x * y) | w | z = w * z normalize z = z module _ (R : Semiring 0ℓ 0ℓ) where open Semiring R private module R = Semiring R asdf'' : Carrier asdf'' = 1# R.+ 0#
{ "alphanum_fraction": 0.5882352941, "avg_line_length": 27.3291139241, "ext": "agda", "hexsha": "cd4aeba472b17858c08a09a8683d46a004e02ff2", "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": "78c3dec24834ffeca5e74cb75578e9b210a5be62", "max_forks_repo_licenses": [ "CC0-1.0" ], "max_forks_repo_name": "cspollard/diff", "max_forks_repo_path": "src/Deriv.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "78c3dec24834ffeca5e74cb75578e9b210a5be62", "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": "cspollard/diff", "max_issues_repo_path": "src/Deriv.agda", "max_line_length": 67, "max_stars_count": null, "max_stars_repo_head_hexsha": "78c3dec24834ffeca5e74cb75578e9b210a5be62", "max_stars_repo_licenses": [ "CC0-1.0" ], "max_stars_repo_name": "cspollard/diff", "max_stars_repo_path": "src/Deriv.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 807, "size": 2159 }
-- Andreas, 2017-07-27 module _ where module A where record A : Set where open A open A -- ERROR WAS: -- Ambiguous module name A. It could refer to any one of -- A.A -- Issue705.A -- EXPECTED: -- Ambiguous module name A. It could refer to any one of -- A.A (record module) -- Issue705.A
{ "alphanum_fraction": 0.6534653465, "avg_line_length": 14.4285714286, "ext": "agda", "hexsha": "ce3b6ceb8761a698f3ebb552128462b1d41c7bf0", "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/Issue705-record.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/Issue705-record.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/Fail/Issue705-record.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": 95, "size": 303 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Polynomial reasoning ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} open import Tactic.RingSolver.Core.AlmostCommutativeRing -- Some specialised tools for equational reasoning. module Tactic.RingSolver.Core.Polynomial.Reasoning {a ℓ} (ring : AlmostCommutativeRing a ℓ) where open AlmostCommutativeRing ring open import Relation.Binary.Reasoning.Setoid setoid public infixr 1 ≪+_ +≫_ ≪*_ *≫_ infixr 0 _⊙_ ≪+_ : ∀ {x₁ x₂ y} → x₁ ≈ x₂ → x₁ + y ≈ x₂ + y ≪+ prf = +-cong prf refl {-# INLINE ≪+_ #-} +≫_ : ∀ {x y₁ y₂} → y₁ ≈ y₂ → x + y₁ ≈ x + y₂ +≫_ = +-cong refl {-# INLINE +≫_ #-} ≪*_ : ∀ {x₁ x₂ y} → x₁ ≈ x₂ → x₁ * y ≈ x₂ * y ≪* prf = *-cong prf refl {-# INLINE ≪*_ #-} *≫_ : ∀ {x y₁ y₂} → y₁ ≈ y₂ → x * y₁ ≈ x * y₂ *≫_ = *-cong refl {-# INLINE *≫_ #-} -- transitivity as an operator _⊙_ : ∀ {x y z} → x ≈ y → y ≈ z → x ≈ z _⊙_ = trans {-# INLINE _⊙_ #-}
{ "alphanum_fraction": 0.5024154589, "avg_line_length": 24.6428571429, "ext": "agda", "hexsha": "fdd85c74026506a6c02f050502e278083f582d4b", "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/Tactic/RingSolver/Core/Polynomial/Reasoning.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/Tactic/RingSolver/Core/Polynomial/Reasoning.agda", "max_line_length": 72, "max_stars_count": 5, "max_stars_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "DreamLinuxer/popl21-artifact", "max_stars_repo_path": "agda-stdlib/src/Tactic/RingSolver/Core/Polynomial/Reasoning.agda", "max_stars_repo_stars_event_max_datetime": "2020-10-10T21:41:32.000Z", "max_stars_repo_stars_event_min_datetime": "2020-10-07T12:07:53.000Z", "num_tokens": 383, "size": 1035 }
{-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.Data.Queue.Untruncated2ListInvariant where open import Cubical.Foundations.Everything open import Cubical.Data.Empty as ⊥ open import Cubical.Data.List open import Cubical.Data.Maybe open import Cubical.Data.Prod module Untruncated2ListInvariant {ℓ} (A : Type ℓ) where -- Invariant Inv : List A → List A → Type ℓ Inv xs ys = ys ≡ [] → xs ≡ [] isPropInv : (xs ys : List A) → isProp (Inv xs ys) isPropInv xs ys = isPropΠ λ _ → isPropXs≡[] Inv-ys≡ys' : {xs ys ys' : List A} → (p : ys ≡ ys') → (invL : Inv xs ys) → (invR : Inv xs ys') → PathP (λ i → Inv xs (p i)) invL invR Inv-ys≡ys' {xs = xs} p invL invR = isProp→PathP (λ i → isPropInv xs (p i)) invL invR inv-xs-∷ : {xs ys : List A} {y : A} → Inv xs (y ∷ ys) inv-xs-∷ contra = ⊥.rec (¬cons≡nil contra) inv-xs-∷ʳ : {xs ys : List A} → {y : A} → Inv xs (ys ∷ʳ y) inv-xs-∷ʳ contra = ⊥.rec (¬snoc≡nil contra) inv-[]-ys : {ys : List A} → Inv [] ys inv-[]-ys ys = refl inv-invalid : {xs : List A} {x : A} → Inv (xs ∷ʳ x) [] → ⊥ inv-invalid inv = ¬snoc≡nil (inv refl) -- Queue data Q : Type ℓ where Q⟨_,_!_⟩ : (xs ys : List A) → (inv : Inv xs ys) → Q tilt : ∀ xs ys z l r → Q⟨ xs ++ [ z ] , ys ! l ⟩ ≡ Q⟨ xs , ys ++ [ z ] ! r ⟩ Q-ys≡ys' : ∀ xs {ys ys' : List A} l r → (p : ys ≡ ys') → Q⟨ xs , ys ! l ⟩ ≡ Q⟨ xs , ys' ! r ⟩ Q-ys≡ys' xs l r p i = Q⟨ xs , p i ! Inv-ys≡ys' p l r i ⟩ flush-xs : ∀ xs ys l r → Q⟨ xs , ys ! l ⟩ ≡ Q⟨ [] , ys ++ rev xs ! r ⟩ flush-xs xs ys l r = helper xs ys l r (snocView xs) where helper : ∀ xs ys l r → SnocView xs → Q⟨ xs , ys ! l ⟩ ≡ Q⟨ [] , ys ++ rev xs ! r ⟩ helper .[] ys l r nil i = Q⟨ [] , ++-unit-r ys (~ i) ! Inv-ys≡ys' (++-unit-r ys ⁻¹) l r i ⟩ helper .(xs ∷ʳ x) ys l r (snoc x xs s) = move-x ∙ IH ∙ Q-ys≡ys' [] inv-[]-ys r lemma where move-x : Q⟨ xs ∷ʳ x , ys ! l ⟩ ≡ Q⟨ xs , ys ∷ʳ x ! inv-xs-∷ʳ ⟩ move-x = tilt xs ys x l inv-xs-∷ʳ IH : Q⟨ xs , ys ∷ʳ x ! inv-xs-∷ʳ ⟩ ≡ Q⟨ [] , (ys ∷ʳ x) ++ rev xs ! inv-[]-ys ⟩ IH = helper xs (ys ∷ʳ x) inv-xs-∷ʳ inv-[]-ys s lemma : (ys ∷ʳ x) ++ rev xs ≡ ys ++ rev (xs ∷ʳ x) lemma = ++-assoc ys (x ∷ []) (rev xs) ∙ cong (ys ++_) (cons≡rev-snoc x xs) emp : Q emp = Q⟨ [] , [] ! inv-[]-ys ⟩ enq : A → Q → Q enq a Q⟨ xs , [] ! inv ⟩ = Q⟨ xs , a ∷ [] ! inv-xs-∷ ⟩ enq a Q⟨ xs , y ∷ ys ! inv ⟩ = Q⟨ a ∷ xs , y ∷ ys ! inv-xs-∷ ⟩ enq a (tilt xs [] z l r i) = proof i where proof : Q⟨ xs ++ z ∷ [] , a ∷ [] ! inv-xs-∷ ⟩ ≡ Q⟨ a ∷ xs , z ∷ [] ! inv-xs-∷ ⟩ proof = ⊥.rec (inv-invalid l) enq a (tilt xs (y ∷ ys) z l r i) = tilt (a ∷ xs) (y ∷ ys) z inv-xs-∷ inv-xs-∷ i deq : Q → Maybe (Q × A) deq Q⟨ xs , [] ! inv ⟩ = nothing deq Q⟨ xs , y ∷ [] ! inv ⟩ = just (Q⟨ [] , rev xs ! inv-[]-ys ⟩ , y) deq Q⟨ xs , y₁ ∷ y₂ ∷ ys ! inv ⟩ = just (Q⟨ xs , y₂ ∷ ys ! inv-xs-∷ ⟩ , y₁) deq (tilt xs [] z l r i) = proof i where proof : nothing ≡ just (Q⟨ [] , rev xs ! inv-[]-ys ⟩ , z) proof = ⊥.rec (inv-invalid l) deq (tilt xs (y ∷ []) z l r i) = just (proof i , y) where proof : Q⟨ [] , rev (xs ∷ʳ z) ! inv-[]-ys ⟩ ≡ Q⟨ xs , z ∷ [] ! inv-xs-∷ ⟩ proof = Q-ys≡ys' [] inv-[]-ys inv-xs-∷ (cons≡rev-snoc z xs ⁻¹) ∙ flush-xs xs (z ∷ []) inv-xs-∷ inv-xs-∷ ⁻¹ deq (tilt xs (y₁ ∷ y₂ ∷ ys) z l r i) = just ((tilt xs (y₂ ∷ ys) z inv-xs-∷ inv-xs-∷ i) , y₁)
{ "alphanum_fraction": 0.4932895914, "avg_line_length": 40.8902439024, "ext": "agda", "hexsha": "c744cc6ac70bce8b5e48fb46d4fdc43e1a913b02", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-22T02:02:01.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-22T02:02:01.000Z", "max_forks_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "dan-iel-lee/cubical", "max_forks_repo_path": "Cubical/Data/Queue/Untruncated2ListInvariant.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/Queue/Untruncated2ListInvariant.agda", "max_line_length": 109, "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/Queue/Untruncated2ListInvariant.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1561, "size": 3353 }
module Numeral.Natural.Function.GreatestCommonDivisor.Proofs where open import Data open import Functional open import Logic.Propositional open import Numeral.Finite open import Numeral.Natural open import Numeral.Natural.Function.GreatestCommonDivisor open import Numeral.Natural.Oper open import Numeral.Natural.Oper.FlooredDivision open import Numeral.Natural.Oper.FlooredDivision.Proofs.Inverse open import Numeral.Natural.Oper.Modulo open import Numeral.Natural.Relation.Divisibility open import Numeral.Natural.Relation.Divisibility.Proofs open import Numeral.Natural.Relation.Divisibility.Proofs.Modulo open import Numeral.Natural.Relation.Order open import Relator.Equals open import Relator.Equals.Proofs.Equiv open import Structure.Relator open import Structure.Relator.Properties open import Structure.Operator open import Structure.Operator.Properties open import Syntax.Number open import Syntax.Transitivity private variable a b c d d₁ d₂ : ℕ gcd-same : (gcd(a)(a) ≡ a) gcd-same = [↔]-to-[→] Gcd-gcd-value (Gcd.intro₂ (reflexivity(_∣_)) (reflexivity(_∣_)) (const id)) instance gcd-identityₗ : Identityₗ(gcd)(𝟎) Identityₗ.proof gcd-identityₗ = [↔]-to-[→] Gcd-gcd-value (Gcd.intro₂ Div𝟎 (reflexivity(_∣_)) (const id)) instance gcd-identityᵣ : Identityᵣ(gcd)(𝟎) Identityᵣ.proof gcd-identityᵣ = [≡]-intro instance gcd-absorberₗ : Absorberₗ(gcd)(1) Absorberₗ.proof gcd-absorberₗ{b} = [↔]-to-[→] (Gcd-gcd-value{_}{b}) (Gcd.intro₂ [1]-divides [1]-divides const) instance gcd-absorberᵣ : Absorberᵣ(gcd)(1) Absorberᵣ.proof gcd-absorberᵣ{a} = [↔]-to-[→] (Gcd-gcd-value{a}{_}) (Gcd.intro₂ [1]-divides [1]-divides (const id)) instance gcd-commutativity : Commutativity(gcd) Commutativity.proof gcd-commutativity {x}{y} = [↔]-to-[→] (Gcd-gcd-value {x}{y}) (Gcd-swap Gcd-gcd) instance gcd-associativity : Associativity(gcd) Associativity.proof gcd-associativity {x}{y}{z} = [↔]-to-[→] (Gcd-gcd-value) (assoc Gcd-gcd Gcd-gcd Gcd-gcd) where assoc : Gcd x y d₁ → Gcd y z d₂ → Gcd x d₂ d → Gcd d₁ z d assoc xyd₁ yzd₂ xd₂d = let d₁x = Gcd.divisorₗ xyd₁ d₁y = Gcd.divisorᵣ xyd₁ xyd₁m = Gcd.maximum₂ xyd₁ d₂y = Gcd.divisorₗ yzd₂ d₂z = Gcd.divisorᵣ yzd₂ yzd₂m = Gcd.maximum₂ yzd₂ dx = Gcd.divisorₗ xd₂d dd₂ = Gcd.divisorᵣ xd₂d xd₂dm = Gcd.maximum₂ xd₂d in Gcd.intro₂ (xyd₁m dx (dd₂ 🝖 d₂y)) (dd₂ 🝖 d₂z) (\dd₁ dz → xd₂dm (dd₁ 🝖 d₁x) (xd₂dm (dd₁ 🝖 d₁x) (yzd₂m (dd₁ 🝖 d₁y) dz) 🝖 dd₂)) gcd-dividesₗ : (gcd(a)(b) ∣ a) gcd-dividesₗ {a}{b} = Gcd.divisorₗ{a}{b} Gcd-gcd gcd-dividesᵣ : (gcd(a)(b) ∣ b) gcd-dividesᵣ {a}{b} = Gcd.divisorᵣ{a}{b} Gcd-gcd gcd-divisors : (d ∣ a) → (d ∣ b) → (d ∣ gcd(a)(b)) gcd-divisors da db = Gcd.maximum₂ Gcd-gcd da db gcd-of-mod : (gcd(a mod 𝐒(b))(𝐒(b)) ≡ gcd(a)(𝐒(b))) gcd-of-mod{a}{b} = [↔]-to-[→] (Gcd-gcd-value{a mod 𝐒(b)}{𝐒(b)}) (p Gcd-gcd) where p : Gcd(a)(𝐒(b)) d → Gcd(a mod 𝐒(b))(𝐒(b)) d p abd = let da = Gcd.divisorₗ abd db = Gcd.divisorᵣ abd m = Gcd.maximum₂ abd in Gcd.intro₂ ([↔]-to-[→] (divides-mod db) da) db (Dab ↦ Db ↦ m ([↔]-to-[←] (divides-mod Db) Dab) Db) -- TODO: Is it neccessary to prove this? By gcd-dividesₗ and gcd-dividesᵣ, one get (gcd(a)(b) ∣ min(a)(b)) and the divisor is always smaller -- gcd-min-order : (gcd(a)(b) ≤ min(a)(b)) gcd-with-[+] : (gcd(a + b)(b) ≡ gcd(a)(b)) gcd-with-[+] {a}{b} = [↔]-to-[→] Gcd-gcd-value (p Gcd-gcd) where p : Gcd(a)(b) d → Gcd(a + b)(b) d p abd = let da = Gcd.divisorₗ abd db = Gcd.divisorᵣ abd m = Gcd.maximum₂ abd in Gcd.intro₂ (divides-with-[+] da db) db (Dab ↦ Db ↦ m ([↔]-to-[←] (divides-without-[+] Dab) Db) Db) gcd-with₁-[⋅] : (gcd(a ⋅ b)(b) ≡ b) gcd-with₁-[⋅] {a}{b} = [↔]-to-[→] (Gcd-gcd-value {a ⋅ b}{b}) (Gcd.intro₂ (divides-with-[⋅] {b}{a} ([∨]-introᵣ (reflexivity(_∣_)))) (reflexivity(_∣_)) (const id)) gcd-with-[⋅] : (gcd(a ⋅ c)(b ⋅ c) ≡ gcd(a)(b) ⋅ c) gcd-with-[⋅] {a}{𝟎} {b} = [≡]-intro gcd-with-[⋅] {a}{𝐒(c)}{b} = gcd(a ⋅ 𝐒(c)) (b ⋅ 𝐒(c)) 🝖[ _≡_ ]-[ q ]-sym gcd(a ⋅ 𝐒(c)) (b ⋅ 𝐒(c)) ⌊/⌋ 𝐒(c) ⋅ 𝐒(c) 🝖[ _≡_ ]-[ congruence₂ₗ(_⋅_)(𝐒(c)) ([↔]-to-[→] Gcd-gcd-value (p{gcd(a ⋅ 𝐒(c))(b ⋅ 𝐒(c)) ⌊/⌋ 𝐒(c)} ([↔]-to-[←] Gcd-gcd-value (symmetry(_≡_) q)))) ]-sym gcd(a)(b) ⋅ 𝐒(c) 🝖-end where p : Gcd a b d ← Gcd(a ⋅ 𝐒(c))(b ⋅ 𝐒(c))(d ⋅ 𝐒(c)) p acbcdc = let dcac = Gcd.divisorₗ acbcdc dcbc = Gcd.divisorᵣ acbcdc m = Gcd.maximum₂ acbcdc in Gcd.intro₂ (divides-without-[⋅]ᵣ-both {z = c} dcac) (divides-without-[⋅]ᵣ-both {z = c} dcbc) (\{D} → Da ↦ Db ↦ divides-without-[⋅]ᵣ-both {z = c} (m{D ⋅ 𝐒(c)} (divides-with-[⋅]ᵣ-both {z = 𝐒(c)} Da) (divides-with-[⋅]ᵣ-both {z = 𝐒(c)} Db))) q = [⋅][⌊/⌋]-inverseOperatorᵣ (gcd-divisors{𝐒(c)}{a ⋅ 𝐒(c)}{b ⋅ 𝐒(c)} (divides-with-[⋅] {𝐒(c)}{a} ([∨]-introᵣ (reflexivity(_∣_)))) (divides-with-[⋅] {𝐒(c)}{b} ([∨]-introᵣ (reflexivity(_∣_))))) gcd-0 : ((a ≡ 𝟎) ∧ (b ≡ 𝟎)) ↔ (gcd a b ≡ 𝟎) gcd-0 = [↔]-intro l r where l : ((a ≡ 𝟎) ∧ (b ≡ 𝟎)) ← (gcd a b ≡ 𝟎) l {𝟎} {𝟎} p = [∧]-intro [≡]-intro [≡]-intro l {𝐒 a} {𝐒 b} p with intro zv _ ← [↔]-to-[←] (Gcd-gcd-value{𝐒(a)}{𝐒(b)}) p with () ← [0]-divides-not (zv 𝟎) r : ((a ≡ 𝟎) ∧ (b ≡ 𝟎)) → (gcd a b ≡ 𝟎) r {𝟎} {𝟎} _ = [≡]-intro open import Logic.Classical open import Logic.Propositional.Theorems open import Numeral.Natural.Decidable open import Numeral.Natural.Relation open import Numeral.Natural.Relation.Proofs open import Type.Properties.Decidable.Proofs gcd-positive : (Positive(a) ∨ Positive(b)) ↔ Positive(gcd a b) gcd-positive{a}{b} = [↔]-transitivity ([∨]-map-[↔] Positive-non-zero Positive-non-zero) ([↔]-transitivity ([↔]-symmetry ([¬]-preserves-[∧][∨] ⦃ decider-classical(a ≡ 𝟎) ⦄ ⦃ decider-classical(b ≡ 𝟎) ⦄)) ([↔]-transitivity ([¬]-unaryOperator (gcd-0 {a}{b})) ([↔]-symmetry Positive-non-zero))) gcd-of-successor : ∀{n} → Gcd(n)(𝐒(n))(1) gcd-of-successor = Gcd.intro₂ [1]-divides [1]-divides p where p : ∀{d n} → (d ∣ n) → (d ∣ 𝐒(n)) → (d ∣ 1) p Div𝟎 dsn = dsn p (Div𝐒 dn) dsn = p dn ([↔]-to-[→] (divides-without-[+] dsn) (reflexivity(_∣_))) open import Logic.Propositional.Theorems open import Numeral.Natural.Coprime open import Numeral.Natural.Coprime.Proofs open import Numeral.Natural.Oper.FlooredDivision.Proofs open import Numeral.Natural.Oper.FlooredDivision.Proofs.Inverse open import Numeral.Natural.Oper.Proofs open import Numeral.Natural.Relation.Order.Proofs open import Syntax.Implication [⌊/⌋₀]-gcd-coprime : (Positive(a) ∨ Positive(b)) → Coprime(a ⌊/⌋₀ gcd(a)(b)) (b ⌊/⌋₀ gcd(a)(b)) [⌊/⌋₀]-gcd-coprime {a}{b} nz = let d = gcd(a)(b) D = gcd(a ⌊/⌋₀ d) (b ⌊/⌋₀ d) gcd-D = Gcd-gcd {a ⌊/⌋₀ d} {b ⌊/⌋₀ d} d-pos = [↔]-to-[→] Positive-greater-than-zero ([↔]-to-[→] gcd-positive nz) in • ( Gcd.divisorₗ gcd-D ⇒ (D ∣ (a ⌊/⌋₀ d)) ⇒-[ divides-with-[⋅]ᵣ-both {z = d} ] (D ⋅ d ∣ (a ⌊/⌋₀ d) ⋅ d) ⇒-[ substitute₂ᵣ(_∣_) ([⋅][⌊/⌋₀]-inverseOperatorᵣ d-pos (gcd-dividesₗ {b = b})) ] (D ⋅ d ∣ a) ⇒-[ substitute₂ₗ(_∣_) (commutativity(_⋅_) {D}{d}) ] (d ⋅ D ∣ a) ⇒-end ) • ( Gcd.divisorᵣ gcd-D ⇒ (D ∣ (b ⌊/⌋₀ d)) ⇒-[ divides-with-[⋅]ᵣ-both {z = d} ] (D ⋅ d ∣ (b ⌊/⌋₀ d) ⋅ d) ⇒-[ substitute₂ᵣ(_∣_) ([⋅][⌊/⌋₀]-inverseOperatorᵣ d-pos gcd-dividesᵣ) ] (D ⋅ d ∣ b) ⇒-[ substitute₂ₗ(_∣_) (commutativity(_⋅_) {D}{d}) ] (d ⋅ D ∣ b) ⇒-end ) ⇒₂-[ Gcd.maximum₂ Gcd-gcd ] ((d ⋅ D) ∣ d) ⇒-[] ((d ⋅ D) ∣ (d ⋅ 1)) ⇒-[ divides-without-[⋅]ₗ-both' d-pos ] (D ∣ 1) ⇒-[ [1]-only-divides-[1] ] (D ≡ 1) ⇒-[ [↔]-to-[←] Coprime-gcd ] Coprime(a ⌊/⌋₀ d) (b ⌊/⌋₀ d) ⇒-end [⌊/⌋]-gcd-coprime : (nz : Positive(a) ∨ Positive(b)) → Coprime((a ⌊/⌋ gcd(a)(b)) ⦃ [↔]-to-[→] gcd-positive nz ⦄) ((b ⌊/⌋ gcd(a)(b)) ⦃ [↔]-to-[→] gcd-positive nz ⦄) [⌊/⌋]-gcd-coprime {a}{b} nz = substitute₂(Coprime) ([⌊/⌋][⌊/⌋₀]-equality ⦃ [↔]-to-[→] gcd-positive nz ⦄) ([⌊/⌋][⌊/⌋₀]-equality ⦃ [↔]-to-[→] gcd-positive nz ⦄) ([⌊/⌋₀]-gcd-coprime nz)
{ "alphanum_fraction": 0.5747800587, "avg_line_length": 43.5319148936, "ext": "agda", "hexsha": "ef2c84883e8aff9fa1d00405f160bf03c0ef4a82", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_path": "Numeral/Natural/Function/GreatestCommonDivisor/Proofs.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_path": "Numeral/Natural/Function/GreatestCommonDivisor/Proofs.agda", "max_line_length": 289, "max_stars_count": 6, "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_path": "Numeral/Natural/Function/GreatestCommonDivisor/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": 3768, "size": 8184 }
open import Relation.Binary.Core module TreeSort.Impl1.Correctness.Order {A : Set} (_≤_ : A → A → Set) (tot≤ : Total _≤_) (trans≤ : Transitive _≤_) where open import BSTree _≤_ open import BSTree.Properties _≤_ trans≤ open import BTree {A} open import Data.List open import Data.Sum open import Function using (_∘_) open import List.Sorted _≤_ open import TreeSort.Impl1 _≤_ tot≤ lemma-insert-*⊴ : {x y : A}{t : BTree} → x ≤ y → t *⊴ y → insert x t *⊴ y lemma-insert-*⊴ x≤y lelf = lend x≤y lelf lemma-insert-*⊴ {x = x}{t = node z l r} x≤y (lend z≤y r≤y) with tot≤ x z ... | inj₁ x≤z = lend z≤y r≤y ... | inj₂ z≤x = lend z≤y (lemma-insert-*⊴ x≤y r≤y) lemma-insert-⊴* : {x y : A}{t : BTree} → y ≤ x → y ⊴* t → y ⊴* insert x t lemma-insert-⊴* y≤x gelf = gend y≤x gelf lemma-insert-⊴* {x = x} {t = node z l r} y≤x (gend y≤z y≤l) with tot≤ x z ... | inj₁ x≤z = gend y≤z (lemma-insert-⊴* y≤x y≤l) ... | inj₂ z≤x = gend y≤z y≤l lemma-insert-bst : {t : BTree}(x : A) → BSTree t → BSTree (insert x t) lemma-insert-bst x slf = snd slf slf lelf gelf lemma-insert-bst x (snd {x = y} sl sr l≤y y≤r) with tot≤ x y ... | inj₁ x≤y = snd (lemma-insert-bst x sl) sr (lemma-insert-*⊴ x≤y l≤y) y≤r ... | inj₂ y≤x = snd sl (lemma-insert-bst x sr) l≤y (lemma-insert-⊴* y≤x y≤r) lemma-treeSort-bst : (xs : List A) → BSTree (treeSort xs) lemma-treeSort-bst [] = slf lemma-treeSort-bst (x ∷ xs) = lemma-insert-bst x (lemma-treeSort-bst xs) theorem-treeSort-sorted : (xs : List A) → Sorted (flatten (treeSort xs)) theorem-treeSort-sorted = lemma-bst-sorted ∘ lemma-treeSort-bst
{ "alphanum_fraction": 0.5998778253, "avg_line_length": 34.1041666667, "ext": "agda", "hexsha": "fa5ac1f31386d9ea159bf9f8a52e86e71f9f4895", "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/TreeSort/Impl1/Correctness/Order.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/TreeSort/Impl1/Correctness/Order.agda", "max_line_length": 77, "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/TreeSort/Impl1/Correctness/Order.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": 693, "size": 1637 }
module HighlightPositivity where data A : Set where inA : (A -> A) -> A data B : Set data C : Set data B where inB : (C -> B) -> B data C where inC : B -> C record D : Set where inductive field outD : D -> D endo : Set -> Set endo X = X -> X data E : Set where inE : endo E -> E data F (X : Set -> Set) : Set where inF : X (F X) -> F X open import Agda.Builtin.Bool data GU : Set GT : Bool -> Set data GU where inGU : ∀ b → GT b -> GU GT false = Bool GT true = GU -> Bool open import Agda.Builtin.Equality data H : Set where inH : ∀ f → f ≡ (λ (x : H) → x) -> H -- non-positive occurrence is -- in the implicit type of f
{ "alphanum_fraction": 0.5459770115, "avg_line_length": 15.4666666667, "ext": "agda", "hexsha": "6770861c392ed1bc2b4ffbbddd2f8b16a13484ae", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cruhland/agda", "max_forks_repo_path": "test/interaction/HighlightPositivity.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "cruhland/agda", "max_issues_repo_path": "test/interaction/HighlightPositivity.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/interaction/HighlightPositivity.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": 237, "size": 696 }
import Loop import Loop.Bundles import Loop.Definitions import Loop.Properties import Loop.Structures import Magma import Magma.Bundles import Magma.Definitions import Magma.Properties import Magma.Structures import Morphism.Structures import Quasigroup import Quasigroup.Bundles import Quasigroup.Definitions import Quasigroup.Properties import Quasigroup.Structures
{ "alphanum_fraction": 0.8777173913, "avg_line_length": 21.6470588235, "ext": "agda", "hexsha": "2d5c3f802b60af21c66625d653d2125c30db2fbe", "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": "Everything.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": "Everything.agda", "max_line_length": 29, "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": "Everything.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": 90, "size": 368 }
module Lec3 where open import CS410-Prelude not : Two -> Two not tt = ff not ff = tt data TwoTestable (b : Two) : (x : Two) -> Set where same : TwoTestable b b diff : TwoTestable b (not b) twoTest : (b x : Two) -> TwoTestable b x twoTest tt tt = same twoTest tt ff = diff twoTest ff tt = diff twoTest ff ff = same twoTest' : (b x : Two) -> TwoTestable b x twoTest' = caseTwo (caseTwo same diff) (caseTwo diff same) xor : Two -> Two -> Two xor b x with twoTest b x xor b .b | same = ff xor b .(not b) | diff = tt xorHelp : (b x : Two) -> TwoTestable b x -> Two xorHelp b .b same = ff xorHelp b .(not b) diff = tt xor' : Two -> Two -> Two xor' b x = xorHelp b x (twoTest b x)
{ "alphanum_fraction": 0.6203438395, "avg_line_length": 21.1515151515, "ext": "agda", "hexsha": "7039ac296f6e59c4535a159d9901703af99b11ee", "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": "523a8749f49c914bcd28402116dcbe79a78dbbf4", "max_forks_repo_licenses": [ "CC0-1.0" ], "max_forks_repo_name": "clarkdm/CS410", "max_forks_repo_path": "Lec3.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "523a8749f49c914bcd28402116dcbe79a78dbbf4", "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": "clarkdm/CS410", "max_issues_repo_path": "Lec3.agda", "max_line_length": 58, "max_stars_count": null, "max_stars_repo_head_hexsha": "523a8749f49c914bcd28402116dcbe79a78dbbf4", "max_stars_repo_licenses": [ "CC0-1.0" ], "max_stars_repo_name": "clarkdm/CS410", "max_stars_repo_path": "Lec3.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 250, "size": 698 }
module _ (X : Set) where open import Agda.Builtin.Equality postulate A : Set data D : Set where c : A → D variable P : D → Set postulate p : (f : ∀ x → P (c x)) (x y : A) → f x ≡ f y
{ "alphanum_fraction": 0.556122449, "avg_line_length": 12.25, "ext": "agda", "hexsha": "452a8d5367e28403b8d9852be75c154b2026e7b8", "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/Issue3807.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/Issue3807.agda", "max_line_length": 47, "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/Issue3807.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": 79, "size": 196 }
{-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.Data.Prod where open import Cubical.Data.Prod.Base public open import Cubical.Data.Prod.Properties public
{ "alphanum_fraction": 0.7687861272, "avg_line_length": 28.8333333333, "ext": "agda", "hexsha": "45d63c43c1263091a4179699d214ea06bdb4b60b", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-22T02:02:01.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-22T02:02:01.000Z", "max_forks_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "dan-iel-lee/cubical", "max_forks_repo_path": "Cubical/Data/Prod.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/Prod.agda", "max_line_length": 50, "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/Prod.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 42, "size": 173 }
module Issue462 where data _≡_ {A : Set} : A → A → Set where ≡-refl : (x : A) → x ≡ x postulate A : Set record R (_≈_ _∼_ : A → A → Set) : Set where field ≈-refl : (x : A) → x ≈ x ∼-reflexive : (x y : A) → x ≈ y → x ∼ y ∼-refl : (x : A) → x ∼ x ∼-refl x = ∼-reflexive x x (≈-refl x) postulate _≈_ : A → A → Set ≈-refl : ((x : A) → x ≡ x) → (x : A) → x ≈ x ≈-irr : (x : A) (p : x ≈ x) → p ≡ p ≡-r : R _≡_ _≡_ ≡-r = record { ≈-refl = ≡-refl ; ∼-reflexive = λ _ _ p → p } ≈-reflexive : (x y : A) → x ≡ y → x ≈ y ≈-reflexive .x .x (≡-refl x) = ≈-refl (R.∼-refl ≡-r) x ≈-r : R _≡_ _≈_ ≈-r = record { ≈-refl = ≡-refl ; ∼-reflexive = ≈-reflexive } foo : A → Set₁ foo x with ≈-irr x (R.∼-refl ≈-r x) foo x | _ = Set -- The generated with function should not contain unsolved -- meta-variables.
{ "alphanum_fraction": 0.4628975265, "avg_line_length": 20.2142857143, "ext": "agda", "hexsha": "f9c05f60849cec8a3e5cd02b506bbd183f519567", "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/Issue462.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/Issue462.agda", "max_line_length": 58, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "test/Succeed/Issue462.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": 454, "size": 849 }
{- This file contains quotient groups -} {-# OPTIONS --safe #-} module Cubical.Algebra.Group.QuotientGroup where open import Cubical.Foundations.Prelude open import Cubical.Foundations.HLevels open import Cubical.Foundations.Isomorphism open import Cubical.Foundations.Structure open import Cubical.Foundations.Powerset open import Cubical.Foundations.GroupoidLaws hiding (assoc) open import Cubical.Data.Sigma open import Cubical.HITs.SetQuotients.Base renaming (_/_ to _/s_) open import Cubical.HITs.SetQuotients.Properties open import Cubical.Relation.Binary.Base open import Cubical.Algebra.Group.Base open import Cubical.Algebra.Group.Properties open import Cubical.Algebra.Group.Morphisms open import Cubical.Algebra.Group.MorphismProperties open import Cubical.Algebra.Group.Subgroup private variable ℓ : Level module _ (G' : Group ℓ) (H' : Subgroup G') (Hnormal : isNormal H') where open BinaryRelation open isSubgroup (snd H') open GroupStr (snd G') open GroupTheory G' private G = ⟨ G' ⟩ _~_ : G → G → Type ℓ x ~ y = x · inv y ∈ ⟪ H' ⟫ isRefl~ : isRefl _~_ isRefl~ x = subst-∈ ⟪ H' ⟫ (sym (·InvR x)) id-closed G/H : Type ℓ G/H = G /s _~_ 1/H : G/H 1/H = [ 1g ] _·/H_ : G/H → G/H → G/H x ·/H y = setQuotBinOp isRefl~ isRefl~ _·_ rem x y where rem : (a a' b b' : G) → a · inv a' ∈ ⟪ H' ⟫ → b · inv b' ∈ ⟪ H' ⟫ → (a · b) · inv (a' · b') ∈ ⟪ H' ⟫ rem a a' b b' haa' hbb' = subst-∈ ⟪ H' ⟫ (cong (_ ·_) (sym (invDistr _ _))) rem5 where rem1 : (inv a' · a) · b · inv b' ∈ ⟪ H' ⟫ rem1 = ·CommNormalSubgroup H' Hnormal (op-closed hbb' (·CommNormalSubgroup H' Hnormal haa')) rem2 : ((inv a' · a) · b) · inv b' ∈ ⟪ H' ⟫ rem2 = subst-∈ ⟪ H' ⟫ (·Assoc _ _ _) rem1 rem3 : inv b' · (inv a' · a) · b ∈ ⟪ H' ⟫ rem3 = ·CommNormalSubgroup H' Hnormal rem2 rem4 : (inv b' · inv a') · (a · b) ∈ ⟪ H' ⟫ rem4 = subst-∈ ⟪ H' ⟫ (cong (inv b' ·_) (sym (·Assoc _ _ _)) ∙ ·Assoc _ _ _) rem3 rem5 : (a · b) · inv b' · inv a' ∈ ⟪ H' ⟫ rem5 = ·CommNormalSubgroup H' Hnormal rem4 inv/H : G/H → G/H inv/H = setQuotUnaryOp inv rem where rem : (a a' : G) → a · inv a' ∈ ⟪ H' ⟫ → inv a · inv (inv a') ∈ ⟪ H' ⟫ rem a a' haa' = subst-∈ ⟪ H' ⟫ (cong (inv a ·_) (sym (invInv a'))) rem1 where ha'a : a' · inv a ∈ ⟪ H' ⟫ ha'a = subst-∈ ⟪ H' ⟫ (invDistr a (inv a') ∙ cong (_· inv a) (invInv a')) (inv-closed haa') rem1 : inv a · a' ∈ ⟪ H' ⟫ rem1 = ·CommNormalSubgroup H' Hnormal ha'a ·/H-assoc : (a b c : G/H) → (a ·/H (b ·/H c)) ≡ ((a ·/H b) ·/H c) ·/H-assoc = elimProp3 (λ x y z → squash/ _ _) λ x y z → cong [_] (·Assoc x y z) ·/H-rid : (a : G/H) → (a ·/H 1/H) ≡ a ·/H-rid = elimProp (λ x → squash/ _ _) λ x → cong [_] (·IdR x) ·/H-invr : (a : G/H) → (a ·/H inv/H a) ≡ 1/H ·/H-invr = elimProp (λ x → squash/ _ _) λ x → cong [_] (·InvR x) asGroup : Group ℓ asGroup = makeGroup-right 1/H _·/H_ inv/H squash/ ·/H-assoc ·/H-rid ·/H-invr _/_ : (G : Group ℓ) → (H : NormalSubgroup G) → Group ℓ G / H = asGroup G (H .fst) (H .snd) [_]/G : {G : Group ℓ} {H : NormalSubgroup G} → ⟨ G ⟩ → ⟨ G / H ⟩ [ x ]/G = [ x ] -- Quotienting by a trivial subgroup module _ {G' : Group ℓ} (H' : NormalSubgroup G') (contrH : (x y : fst G') → _~_ G' (fst H') (snd H') x y → x ≡ y) where private -- open isSubgroup (snd H') open GroupStr (snd G') open GroupTheory G' G = fst G' G/H' = fst (G' / H') Code : (g : G) → G/H' → hProp ℓ Code g = elim (λ _ → isSetHProp) (λ a → (g ≡ a) , is-set _ _) λ a b r → Σ≡Prop (λ _ → isPropIsProp) (cong (g ≡_) (contrH a b r)) decode : (g : G) (x : G/H') → [ g ] ≡ x → Code g x .fst decode g x = J (λ x _ → Code g x .fst) refl trivialRel→elimPath : {g h : G} → Path G/H' [ g ] [ h ] → g ≡ h trivialRel→elimPath {g = g} {h = h} = decode g [ h ] trivialRelIso : GroupIso G' (G' / H') Iso.fun (fst trivialRelIso) g = [ g ] Iso.inv (fst trivialRelIso) = rec is-set (λ g → g) contrH Iso.rightInv (fst trivialRelIso) = elimProp (λ _ → squash/ _ _) λ _ → refl Iso.leftInv (fst trivialRelIso) _ = refl snd trivialRelIso = makeIsGroupHom λ _ _ → refl
{ "alphanum_fraction": 0.5556863668, "avg_line_length": 30.7753623188, "ext": "agda", "hexsha": "f5e282940baadd0b26f3fee3169c1c2b92743373", "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/Group/QuotientGroup.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/Group/QuotientGroup.agda", "max_line_length": 97, "max_stars_count": null, "max_stars_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "thomas-lamiaux/cubical", "max_stars_repo_path": "Cubical/Algebra/Group/QuotientGroup.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1716, "size": 4247 }
{-# OPTIONS --cubical --safe #-} module Relation.Nullary where
{ "alphanum_fraction": 0.6875, "avg_line_length": 16, "ext": "agda", "hexsha": "88b9e19975f0ac6bfb3cb55b22e6d130c813ebd0", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-01-05T14:05:30.000Z", "max_forks_repo_forks_event_min_datetime": "2021-01-05T14:05:30.000Z", "max_forks_repo_head_hexsha": "3c176d4690566d81611080e9378f5a178b39b851", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "oisdk/combinatorics-paper", "max_forks_repo_path": "agda/Relation/Nullary.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "3c176d4690566d81611080e9378f5a178b39b851", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "oisdk/combinatorics-paper", "max_issues_repo_path": "agda/Relation/Nullary.agda", "max_line_length": 32, "max_stars_count": 6, "max_stars_repo_head_hexsha": "3c176d4690566d81611080e9378f5a178b39b851", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "oisdk/combinatorics-paper", "max_stars_repo_path": "agda/Relation/Nullary.agda", "max_stars_repo_stars_event_max_datetime": "2021-11-16T08:11:34.000Z", "max_stars_repo_stars_event_min_datetime": "2020-09-11T17:45:41.000Z", "num_tokens": 15, "size": 64 }
module HBound where import Relation.Unary.PredicateTransformer as PT open import Relation.Unary open import Level open import Relation.Binary using (Rel; IsEquivalence; module IsEquivalence; Reflexive; Symmetric; Transitive) open import Category.Applicative --naturalTrans : ∀ {a ℓ₁ ℓ₂ : Level } (ix : Set a ) (f : RU.Pred {a} ix ℓ₁ ) (g : RU.Pred {a} ix ℓ₂) -> Set (suc (ℓ₁ ∪ ℓ₂ ∪ a) ) -- naturalTrans ix f g = ∀ (x : ix) -> f x -> g x -- indexed natural transformation as family predicates -- note: this is not the most general notion of a natural transformation NatIx : ∀ {i j k : Level } (a : Set k) (f : Pred a i) (g : Pred a j) -> Set ( j ⊔ i ⊔ k) NatIx a f g = ∀ ( x : a ) -> (f x -> g x ) -- this is a simplified model of a homogenuous natural transformation Nat : ∀ {i j } -> ∀ { a : Set i} -> Rel (Pred a j) (i ⊔ j ) Nat f g = forall x -> (f x -> g x ) {- question: is using a formal model of categorical arrows useful here -} record NatFunctor {i j } {a : Set i} (t : Pred a j -> Pred a j) : Set ( i ⊔ suc j) where field natMap : ∀ {f g} -> Nat f g -> Nat (t f) (t g ) -- record NatTraverseable
{ "alphanum_fraction": 0.6109185442, "avg_line_length": 32.9714285714, "ext": "agda", "hexsha": "eab916700c42254b4e3f8b40ef42658c3866cc3a", "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": "e0de23b3c78313a7f6856c3d48c3d6a2ce3962dd", "max_forks_repo_licenses": [ "BSD-2-Clause" ], "max_forks_repo_name": "hopper-lang/hopper-v0", "max_forks_repo_path": "models/agda/HBound.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "e0de23b3c78313a7f6856c3d48c3d6a2ce3962dd", "max_issues_repo_issues_event_max_datetime": "2020-02-19T01:08:47.000Z", "max_issues_repo_issues_event_min_datetime": "2020-02-19T01:08:47.000Z", "max_issues_repo_licenses": [ "BSD-2-Clause" ], "max_issues_repo_name": "hopper-lang/hopper-v0", "max_issues_repo_path": "models/agda/HBound.agda", "max_line_length": 132, "max_stars_count": 17, "max_stars_repo_head_hexsha": "e0de23b3c78313a7f6856c3d48c3d6a2ce3962dd", "max_stars_repo_licenses": [ "BSD-2-Clause" ], "max_stars_repo_name": "hopper-lang/hopper-v0", "max_stars_repo_path": "models/agda/HBound.agda", "max_stars_repo_stars_event_max_datetime": "2019-03-18T03:02:06.000Z", "max_stars_repo_stars_event_min_datetime": "2016-09-23T16:03:03.000Z", "num_tokens": 391, "size": 1154 }
module DayConvolution where open import Library open import Functors open import Categories open import Categories.Sets open import MonoidalCat -- first draft ODay : ∀{l m}(M : Monoidal {l}{m}) (F G : Fun (Monoidal.C M) (Sets {l})) -> Cat.Obj (Monoidal.C M) -> Set _ ODay M F G X = Σ Obj \Y -> Σ Obj \Z -> OMap F Y × OMap G Z × Hom X (OMap ⊗ (Y , Z)) where open Monoidal M; open Cat C; open Fun HDay : ∀{l m}(M : Monoidal {l}{m}) (F G : Fun (Monoidal.C M) (Sets {l})) -> ∀{X X'} -> Cat.Hom (Monoidal.C M) X X' -> ODay M F G X' -> ODay M F G X HDay M F G f (y , z , fy , gz , g) = y , z , fy , gz , comp g f where open Monoidal M; open Cat C DayF : ∀{l m}(M : Monoidal {l}{m}) (F G : Fun (Monoidal.C M) (Sets {l})) -> Fun ((Monoidal.C M) Op) Sets DayF M F G = functor (ODay M F G) (HDay M F G) (\ {X} -> ext (\{ (y , z , fy , gz , g) -> cong (λ g → y , z , fy , gz , g) idr})) (\ {X Y Z h k} -> ext (\{ (y , z , fy , gz , g) -> cong (λ l → y , z , fy , gz , l) (sym ass)})) where open Monoidal M; open Cat C -- subject to some additional conditions -- forall h : y -> y'. -- (y , F h fy' , gz , g) ~ (y' , z , fy' , gz , [h,id] . g) -- -- forall k : z -> z' -- (y , z , fy , G k gz' , g) ~ (y , z' , fy , gz' , [id,k] . g)
{ "alphanum_fraction": 0.5019305019, "avg_line_length": 30.1162790698, "ext": "agda", "hexsha": "7d04a4b315fb2d870442155850497655edde7216", "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": "DayConvolution.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": "DayConvolution.agda", "max_line_length": 76, "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": "DayConvolution.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": 508, "size": 1295 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Substitution lemmas ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} module Data.Fin.Substitution.Lemmas where import Category.Applicative.Indexed as Applicative open import Data.Fin.Substitution open import Data.Nat hiding (_⊔_) open import Data.Fin using (Fin; zero; suc; lift) open import Data.Vec import Data.Vec.Properties as VecProp open import Function as Fun using (_∘_; _$_) open import Relation.Binary.PropositionalEquality as PropEq using (_≡_; refl; sym; cong; cong₂) open import Relation.Binary.Construct.Closure.ReflexiveTransitive using (Star; ε; _◅_; _▻_) open PropEq.≡-Reasoning open import Level using (Level; _⊔_) open import Relation.Unary using (Pred) -- A lemma which does not refer to any substitutions. lift-commutes : ∀ {n} k j (x : Fin (j + (k + n))) → lift j suc (lift j (lift k suc) x) ≡ lift j (lift (suc k) suc) (lift j suc x) lift-commutes k zero x = refl lift-commutes k (suc j) zero = refl lift-commutes k (suc j) (suc x) = cong suc (lift-commutes k j x) -- The modules below prove a number of substitution lemmas, on the -- assumption that the underlying substitution machinery satisfies -- certain properties. record Lemmas₀ {ℓ : Level} (T : Pred ℕ ℓ) : Set ℓ where field simple : Simple T open Simple simple extensionality : ∀ {m n} {ρ₁ ρ₂ : Sub T m n} → (∀ x → lookup ρ₁ x ≡ lookup ρ₂ x) → ρ₁ ≡ ρ₂ extensionality {ρ₁ = []} {[]} hyp = refl extensionality {ρ₁ = t₁ ∷ ρ₁} { t₂ ∷ ρ₂} hyp with hyp zero extensionality {ρ₁ = t₁ ∷ ρ₁} {.t₁ ∷ ρ₂} hyp | refl = cong (_∷_ t₁) (extensionality (hyp ∘ suc)) id-↑⋆ : ∀ {n} k → id ↑⋆ k ≡ id {k + n} id-↑⋆ zero = refl id-↑⋆ (suc k) = begin (id ↑⋆ k) ↑ ≡⟨ cong _↑ (id-↑⋆ k) ⟩ id ↑ ∎ lookup-map-weaken-↑⋆ : ∀ {m n} k x {ρ : Sub T m n} → lookup (map weaken ρ ↑⋆ k) x ≡ lookup ((ρ ↑) ↑⋆ k) (lift k suc x) lookup-map-weaken-↑⋆ zero x = refl lookup-map-weaken-↑⋆ (suc k) zero = refl lookup-map-weaken-↑⋆ (suc k) (suc x) {ρ} = begin lookup (map weaken (map weaken ρ ↑⋆ k)) x ≡⟨ VecProp.lookup-map x weaken (map weaken ρ ↑⋆ k) ⟩ weaken (lookup (map weaken ρ ↑⋆ k) x) ≡⟨ cong weaken (lookup-map-weaken-↑⋆ k x) ⟩ weaken (lookup ((ρ ↑) ↑⋆ k) (lift k suc x)) ≡⟨ sym $ VecProp.lookup-map (lift k suc x) weaken ((ρ ↑) ↑⋆ k) ⟩ lookup (map weaken ((ρ ↑) ↑⋆ k)) (lift k suc x) ∎ record Lemmas₁ {ℓ} (T : Pred ℕ ℓ) : Set ℓ where field lemmas₀ : Lemmas₀ T open Lemmas₀ lemmas₀ open Simple simple field weaken-var : ∀ {n} {x : Fin n} → weaken (var x) ≡ var (suc x) lookup-map-weaken : ∀ {m n} x {y} {ρ : Sub T m n} → lookup ρ x ≡ var y → lookup (map weaken ρ) x ≡ var (suc y) lookup-map-weaken x {y} {ρ} hyp = begin lookup (map weaken ρ) x ≡⟨ VecProp.lookup-map x weaken ρ ⟩ weaken (lookup ρ x) ≡⟨ cong weaken hyp ⟩ weaken (var y) ≡⟨ weaken-var ⟩ var (suc y) ∎ mutual lookup-id : ∀ {n} (x : Fin n) → lookup id x ≡ var x lookup-id zero = refl lookup-id (suc x) = lookup-wk x lookup-wk : ∀ {n} (x : Fin n) → lookup wk x ≡ var (suc x) lookup-wk x = lookup-map-weaken x {ρ = id} (lookup-id x) lookup-↑⋆ : ∀ {m n} (f : Fin m → Fin n) {ρ : Sub T m n} → (∀ x → lookup ρ x ≡ var (f x)) → ∀ k x → lookup (ρ ↑⋆ k) x ≡ var (lift k f x) lookup-↑⋆ f hyp zero x = hyp x lookup-↑⋆ f hyp (suc k) zero = refl lookup-↑⋆ f {ρ = ρ} hyp (suc k) (suc x) = lookup-map-weaken x {ρ = ρ ↑⋆ k} (lookup-↑⋆ f hyp k x) lookup-lift-↑⋆ : ∀ {m n} (f : Fin n → Fin m) {ρ : Sub T m n} → (∀ x → lookup ρ (f x) ≡ var x) → ∀ k x → lookup (ρ ↑⋆ k) (lift k f x) ≡ var x lookup-lift-↑⋆ f hyp zero x = hyp x lookup-lift-↑⋆ f hyp (suc k) zero = refl lookup-lift-↑⋆ f {ρ = ρ} hyp (suc k) (suc x) = lookup-map-weaken (lift k f x) {ρ = ρ ↑⋆ k} (lookup-lift-↑⋆ f hyp k x) lookup-wk-↑⋆ : ∀ {n} k (x : Fin (k + n)) → lookup (wk ↑⋆ k) x ≡ var (lift k suc x) lookup-wk-↑⋆ = lookup-↑⋆ suc lookup-wk lookup-wk-↑⋆-↑⋆ : ∀ {n} k j (x : Fin (j + (k + n))) → lookup (wk ↑⋆ k ↑⋆ j) x ≡ var (lift j (lift k suc) x) lookup-wk-↑⋆-↑⋆ k = lookup-↑⋆ (lift k suc) (lookup-wk-↑⋆ k) lookup-sub-↑⋆ : ∀ {n t} k (x : Fin (k + n)) → lookup (sub t ↑⋆ k) (lift k suc x) ≡ var x lookup-sub-↑⋆ = lookup-lift-↑⋆ suc lookup-id open Lemmas₀ lemmas₀ public record Lemmas₂ {ℓ} (T : Pred ℕ ℓ) : Set ℓ where field lemmas₁ : Lemmas₁ T application : Application T T open Lemmas₁ lemmas₁ subst : Subst T subst = record { simple = simple; application = application } open Subst subst field var-/ : ∀ {m n x} {ρ : Sub T m n} → var x / ρ ≡ lookup ρ x suc-/-sub : ∀ {n x} {t : T n} → var (suc x) / sub t ≡ var x suc-/-sub {x = x} {t} = begin var (suc x) / sub t ≡⟨ var-/ ⟩ lookup (sub t) (suc x) ≡⟨ refl ⟩ lookup id x ≡⟨ lookup-id x ⟩ var x ∎ lookup-⊙ : ∀ {m n k} x {ρ₁ : Sub T m n} {ρ₂ : Sub T n k} → lookup (ρ₁ ⊙ ρ₂) x ≡ lookup ρ₁ x / ρ₂ lookup-⊙ x {ρ₁} {ρ₂} = VecProp.lookup-map x (λ t → t / ρ₂) ρ₁ lookup-⨀ : ∀ {m n} x (ρs : Subs T m n) → lookup (⨀ ρs) x ≡ var x /✶ ρs lookup-⨀ x ε = lookup-id x lookup-⨀ x (ρ ◅ ε) = sym var-/ lookup-⨀ x (ρ ◅ (ρ′ ◅ ρs′)) = begin lookup (⨀ (ρ ◅ ρs)) x ≡⟨ refl ⟩ lookup (⨀ ρs ⊙ ρ) x ≡⟨ lookup-⊙ x {ρ₁ = ⨀ (ρ′ ◅ ρs′)} ⟩ lookup (⨀ ρs) x / ρ ≡⟨ cong₂ _/_ (lookup-⨀ x (ρ′ ◅ ρs′)) refl ⟩ var x /✶ ρs / ρ ∎ where ρs = ρ′ ◅ ρs′ id-⊙ : ∀ {m n} {ρ : Sub T m n} → id ⊙ ρ ≡ ρ id-⊙ {ρ = ρ} = extensionality λ x → begin lookup (id ⊙ ρ) x ≡⟨ lookup-⊙ x {ρ₁ = id} ⟩ lookup id x / ρ ≡⟨ cong₂ _/_ (lookup-id x) refl ⟩ var x / ρ ≡⟨ var-/ ⟩ lookup ρ x ∎ lookup-wk-↑⋆-⊙ : ∀ {m n} k {x} {ρ : Sub T (k + suc m) n} → lookup (wk ↑⋆ k ⊙ ρ) x ≡ lookup ρ (lift k suc x) lookup-wk-↑⋆-⊙ k {x} {ρ} = begin lookup (wk ↑⋆ k ⊙ ρ) x ≡⟨ lookup-⊙ x {ρ₁ = wk ↑⋆ k} ⟩ lookup (wk ↑⋆ k) x / ρ ≡⟨ cong₂ _/_ (lookup-wk-↑⋆ k x) refl ⟩ var (lift k suc x) / ρ ≡⟨ var-/ ⟩ lookup ρ (lift k suc x) ∎ wk-⊙-sub′ : ∀ {n} {t : T n} k → wk ↑⋆ k ⊙ sub t ↑⋆ k ≡ id wk-⊙-sub′ {t = t} k = extensionality λ x → begin lookup (wk ↑⋆ k ⊙ sub t ↑⋆ k) x ≡⟨ lookup-wk-↑⋆-⊙ k ⟩ lookup (sub t ↑⋆ k) (lift k suc x) ≡⟨ lookup-sub-↑⋆ k x ⟩ var x ≡⟨ sym (lookup-id x) ⟩ lookup id x ∎ wk-⊙-sub : ∀ {n} {t : T n} → wk ⊙ sub t ≡ id wk-⊙-sub = wk-⊙-sub′ zero var-/-wk-↑⋆ : ∀ {n} k (x : Fin (k + n)) → var x / wk ↑⋆ k ≡ var (lift k suc x) var-/-wk-↑⋆ k x = begin var x / wk ↑⋆ k ≡⟨ var-/ ⟩ lookup (wk ↑⋆ k) x ≡⟨ lookup-wk-↑⋆ k x ⟩ var (lift k suc x) ∎ wk-↑⋆-⊙-wk : ∀ {n} k j → wk {n} ↑⋆ k ↑⋆ j ⊙ wk ↑⋆ j ≡ wk ↑⋆ j ⊙ wk ↑⋆ suc k ↑⋆ j wk-↑⋆-⊙-wk k j = extensionality λ x → begin lookup (wk ↑⋆ k ↑⋆ j ⊙ wk ↑⋆ j) x ≡⟨ lookup-⊙ x {ρ₁ = wk ↑⋆ k ↑⋆ j} ⟩ lookup (wk ↑⋆ k ↑⋆ j) x / wk ↑⋆ j ≡⟨ cong₂ _/_ (lookup-wk-↑⋆-↑⋆ k j x) refl ⟩ var (lift j (lift k suc) x) / wk ↑⋆ j ≡⟨ var-/-wk-↑⋆ j (lift j (lift k suc) x) ⟩ var (lift j suc (lift j (lift k suc) x)) ≡⟨ cong var (lift-commutes k j x) ⟩ var (lift j (lift (suc k) suc) (lift j suc x)) ≡⟨ sym (lookup-wk-↑⋆-↑⋆ (suc k) j (lift j suc x)) ⟩ lookup (wk ↑⋆ suc k ↑⋆ j) (lift j suc x) ≡⟨ sym var-/ ⟩ var (lift j suc x) / wk ↑⋆ suc k ↑⋆ j ≡⟨ cong₂ _/_ (sym (lookup-wk-↑⋆ j x)) refl ⟩ lookup (wk ↑⋆ j) x / wk ↑⋆ suc k ↑⋆ j ≡⟨ sym (lookup-⊙ x {ρ₁ = wk ↑⋆ j}) ⟩ lookup (wk ↑⋆ j ⊙ wk ↑⋆ suc k ↑⋆ j) x ∎ open Subst subst public hiding (simple; application) open Lemmas₁ lemmas₁ public record Lemmas₃ {ℓ} (T : Pred ℕ ℓ) : Set ℓ where field lemmas₂ : Lemmas₂ T open Lemmas₂ lemmas₂ field /✶-↑✶ : ∀ {m n} (ρs₁ ρs₂ : Subs T m n) → (∀ k x → var x /✶ ρs₁ ↑✶ k ≡ var x /✶ ρs₂ ↑✶ k) → ∀ k t → t /✶ ρs₁ ↑✶ k ≡ t /✶ ρs₂ ↑✶ k /✶-↑✶′ : ∀ {m n} (ρs₁ ρs₂ : Subs T m n) → (∀ k → ⨀ (ρs₁ ↑✶ k) ≡ ⨀ (ρs₂ ↑✶ k)) → ∀ k t → t /✶ ρs₁ ↑✶ k ≡ t /✶ ρs₂ ↑✶ k /✶-↑✶′ ρs₁ ρs₂ hyp = /✶-↑✶ ρs₁ ρs₂ (λ k x → begin var x /✶ ρs₁ ↑✶ k ≡⟨ sym (lookup-⨀ x (ρs₁ ↑✶ k)) ⟩ lookup (⨀ (ρs₁ ↑✶ k)) x ≡⟨ cong (Fun.flip lookup x) (hyp k) ⟩ lookup (⨀ (ρs₂ ↑✶ k)) x ≡⟨ lookup-⨀ x (ρs₂ ↑✶ k) ⟩ var x /✶ ρs₂ ↑✶ k ∎) id-vanishes : ∀ {n} (t : T n) → t / id ≡ t id-vanishes = /✶-↑✶′ (ε ▻ id) ε id-↑⋆ zero ⊙-id : ∀ {m n} {ρ : Sub T m n} → ρ ⊙ id ≡ ρ ⊙-id {ρ = ρ} = begin map (λ t → t / id) ρ ≡⟨ VecProp.map-cong id-vanishes ρ ⟩ map Fun.id ρ ≡⟨ VecProp.map-id ρ ⟩ ρ ∎ open Lemmas₂ lemmas₂ public hiding (wk-⊙-sub′) record Lemmas₄ {ℓ} (T : Pred ℕ ℓ) : Set ℓ where field lemmas₃ : Lemmas₃ T open Lemmas₃ lemmas₃ field /-wk : ∀ {n} {t : T n} → t / wk ≡ weaken t private ↑-distrib′ : ∀ {m n k} {ρ₁ : Sub T m n} {ρ₂ : Sub T n k} → (∀ t → t / ρ₂ / wk ≡ t / wk / ρ₂ ↑) → (ρ₁ ⊙ ρ₂) ↑ ≡ ρ₁ ↑ ⊙ ρ₂ ↑ ↑-distrib′ {ρ₁ = ρ₁} {ρ₂} hyp = begin (ρ₁ ⊙ ρ₂) ↑ ≡⟨ refl ⟩ var zero ∷ map weaken (ρ₁ ⊙ ρ₂) ≡⟨ cong₂ _∷_ (sym var-/) lemma ⟩ var zero / ρ₂ ↑ ∷ map weaken ρ₁ ⊙ ρ₂ ↑ ≡⟨ refl ⟩ ρ₁ ↑ ⊙ ρ₂ ↑ ∎ where lemma = begin map weaken (map (λ t → t / ρ₂) ρ₁) ≡⟨ sym (VecProp.map-∘ _ _ _) ⟩ map (λ t → weaken (t / ρ₂)) ρ₁ ≡⟨ VecProp.map-cong (λ t → begin weaken (t / ρ₂) ≡⟨ sym /-wk ⟩ t / ρ₂ / wk ≡⟨ hyp t ⟩ t / wk / ρ₂ ↑ ≡⟨ cong₂ _/_ /-wk refl ⟩ weaken t / ρ₂ ↑ ∎) ρ₁ ⟩ map (λ t → weaken t / ρ₂ ↑) ρ₁ ≡⟨ VecProp.map-∘ _ _ _ ⟩ map (λ t → t / ρ₂ ↑) (map weaken ρ₁) ∎ ↑⋆-distrib′ : ∀ {m n o} {ρ₁ : Sub T m n} {ρ₂ : Sub T n o} → (∀ k t → t / ρ₂ ↑⋆ k / wk ≡ t / wk / ρ₂ ↑⋆ suc k) → ∀ k → (ρ₁ ⊙ ρ₂) ↑⋆ k ≡ ρ₁ ↑⋆ k ⊙ ρ₂ ↑⋆ k ↑⋆-distrib′ hyp zero = refl ↑⋆-distrib′ {ρ₁ = ρ₁} {ρ₂} hyp (suc k) = begin (ρ₁ ⊙ ρ₂) ↑⋆ suc k ≡⟨ cong _↑ (↑⋆-distrib′ hyp k) ⟩ (ρ₁ ↑⋆ k ⊙ ρ₂ ↑⋆ k) ↑ ≡⟨ ↑-distrib′ (hyp k) ⟩ ρ₁ ↑⋆ suc k ⊙ ρ₂ ↑⋆ suc k ∎ map-weaken : ∀ {m n} {ρ : Sub T m n} → map weaken ρ ≡ ρ ⊙ wk map-weaken {ρ = ρ} = begin map weaken ρ ≡⟨ VecProp.map-cong (λ _ → sym /-wk) ρ ⟩ map (λ t → t / wk) ρ ≡⟨ refl ⟩ ρ ⊙ wk ∎ private ⊙-wk′ : ∀ {m n} {ρ : Sub T m n} k → ρ ↑⋆ k ⊙ wk ↑⋆ k ≡ wk ↑⋆ k ⊙ ρ ↑ ↑⋆ k ⊙-wk′ {ρ = ρ} k = sym (begin wk ↑⋆ k ⊙ ρ ↑ ↑⋆ k ≡⟨ lemma ⟩ map weaken ρ ↑⋆ k ≡⟨ cong (λ ρ′ → ρ′ ↑⋆ k) map-weaken ⟩ (ρ ⊙ wk) ↑⋆ k ≡⟨ ↑⋆-distrib′ (λ k t → /✶-↑✶′ (ε ▻ wk ↑⋆ k ▻ wk) (ε ▻ wk ▻ wk ↑⋆ suc k) (wk-↑⋆-⊙-wk k) zero t) k ⟩ ρ ↑⋆ k ⊙ wk ↑⋆ k ∎) where lemma = extensionality λ x → begin lookup (wk ↑⋆ k ⊙ ρ ↑ ↑⋆ k) x ≡⟨ lookup-wk-↑⋆-⊙ k ⟩ lookup (ρ ↑ ↑⋆ k) (lift k suc x) ≡⟨ sym (lookup-map-weaken-↑⋆ k x) ⟩ lookup (map weaken ρ ↑⋆ k) x ∎ ⊙-wk : ∀ {m n} {ρ : Sub T m n} → ρ ⊙ wk ≡ wk ⊙ ρ ↑ ⊙-wk = ⊙-wk′ zero wk-commutes : ∀ {m n} {ρ : Sub T m n} t → t / ρ / wk ≡ t / wk / ρ ↑ wk-commutes {ρ = ρ} = /✶-↑✶′ (ε ▻ ρ ▻ wk) (ε ▻ wk ▻ ρ ↑) ⊙-wk′ zero ↑⋆-distrib : ∀ {m n o} {ρ₁ : Sub T m n} {ρ₂ : Sub T n o} → ∀ k → (ρ₁ ⊙ ρ₂) ↑⋆ k ≡ ρ₁ ↑⋆ k ⊙ ρ₂ ↑⋆ k ↑⋆-distrib = ↑⋆-distrib′ (λ _ → wk-commutes) /-⊙ : ∀ {m n k} {ρ₁ : Sub T m n} {ρ₂ : Sub T n k} t → t / ρ₁ ⊙ ρ₂ ≡ t / ρ₁ / ρ₂ /-⊙ {ρ₁ = ρ₁} {ρ₂} t = /✶-↑✶′ (ε ▻ ρ₁ ⊙ ρ₂) (ε ▻ ρ₁ ▻ ρ₂) ↑⋆-distrib zero t ⊙-assoc : ∀ {m n k o} {ρ₁ : Sub T m n} {ρ₂ : Sub T n k} {ρ₃ : Sub T k o} → ρ₁ ⊙ (ρ₂ ⊙ ρ₃) ≡ (ρ₁ ⊙ ρ₂) ⊙ ρ₃ ⊙-assoc {ρ₁ = ρ₁} {ρ₂} {ρ₃} = begin map (λ t → t / ρ₂ ⊙ ρ₃) ρ₁ ≡⟨ VecProp.map-cong /-⊙ ρ₁ ⟩ map (λ t → t / ρ₂ / ρ₃) ρ₁ ≡⟨ VecProp.map-∘ _ _ _ ⟩ map (λ t → t / ρ₃) (map (λ t → t / ρ₂) ρ₁) ∎ map-weaken-⊙-sub : ∀ {m n} {ρ : Sub T m n} {t} → map weaken ρ ⊙ sub t ≡ ρ map-weaken-⊙-sub {ρ = ρ} {t} = begin map weaken ρ ⊙ sub t ≡⟨ cong₂ _⊙_ map-weaken refl ⟩ ρ ⊙ wk ⊙ sub t ≡⟨ sym ⊙-assoc ⟩ ρ ⊙ (wk ⊙ sub t) ≡⟨ cong (_⊙_ ρ) wk-⊙-sub ⟩ ρ ⊙ id ≡⟨ ⊙-id ⟩ ρ ∎ sub-⊙ : ∀ {m n} {ρ : Sub T m n} t → sub t ⊙ ρ ≡ ρ ↑ ⊙ sub (t / ρ) sub-⊙ {ρ = ρ} t = begin sub t ⊙ ρ ≡⟨ refl ⟩ t / ρ ∷ id ⊙ ρ ≡⟨ cong (_∷_ (t / ρ)) id-⊙ ⟩ t / ρ ∷ ρ ≡⟨ cong (_∷_ (t / ρ)) (sym map-weaken-⊙-sub) ⟩ t / ρ ∷ map weaken ρ ⊙ sub (t / ρ) ≡⟨ cong₂ _∷_ (sym var-/) refl ⟩ ρ ↑ ⊙ sub (t / ρ) ∎ suc-/-↑ : ∀ {m n} {ρ : Sub T m n} x → var (suc x) / ρ ↑ ≡ var x / ρ / wk suc-/-↑ {ρ = ρ} x = begin var (suc x) / ρ ↑ ≡⟨ var-/ ⟩ lookup (map weaken ρ) x ≡⟨ cong (Fun.flip lookup x) (map-weaken {ρ = ρ}) ⟩ lookup (ρ ⊙ wk) x ≡⟨ lookup-⊙ x {ρ₁ = ρ} ⟩ lookup ρ x / wk ≡⟨ cong₂ _/_ (sym var-/) refl ⟩ var x / ρ / wk ∎ open Lemmas₃ lemmas₃ public hiding (/✶-↑✶; /✶-↑✶′; wk-↑⋆-⊙-wk; lookup-wk-↑⋆-⊙; lookup-map-weaken-↑⋆) -- For an example of how AppLemmas can be used, see -- Data.Fin.Substitution.List. record AppLemmas {ℓ₁ ℓ₂} (T₁ : Pred ℕ ℓ₁) (T₂ : Pred ℕ ℓ₂) : Set (ℓ₁ ⊔ ℓ₂) where field application : Application T₁ T₂ lemmas₄ : Lemmas₄ T₂ open Application application using (_/_; _/✶_) open Lemmas₄ lemmas₄ using (id; _⊙_; wk; weaken; sub; _↑; ⨀) renaming (_/_ to _⊘_) field id-vanishes : ∀ {n} (t : T₁ n) → t / id ≡ t /-⊙ : ∀ {m n k} {ρ₁ : Sub T₂ m n} {ρ₂ : Sub T₂ n k} t → t / ρ₁ ⊙ ρ₂ ≡ t / ρ₁ / ρ₂ private module L₄ = Lemmas₄ lemmas₄ /-⨀ : ∀ {m n} t (ρs : Subs T₂ m n) → t / ⨀ ρs ≡ t /✶ ρs /-⨀ t ε = id-vanishes t /-⨀ t (ρ ◅ ε) = refl /-⨀ t (ρ ◅ (ρ′ ◅ ρs′)) = begin t / ⨀ ρs ⊙ ρ ≡⟨ /-⊙ t ⟩ t / ⨀ ρs / ρ ≡⟨ cong₂ _/_ (/-⨀ t (ρ′ ◅ ρs′)) refl ⟩ t /✶ ρs / ρ ∎ where ρs = ρ′ ◅ ρs′ ⨀→/✶ : ∀ {m n} (ρs₁ ρs₂ : Subs T₂ m n) → ⨀ ρs₁ ≡ ⨀ ρs₂ → ∀ t → t /✶ ρs₁ ≡ t /✶ ρs₂ ⨀→/✶ ρs₁ ρs₂ hyp t = begin t /✶ ρs₁ ≡⟨ sym (/-⨀ t ρs₁) ⟩ t / ⨀ ρs₁ ≡⟨ cong (_/_ t) hyp ⟩ t / ⨀ ρs₂ ≡⟨ /-⨀ t ρs₂ ⟩ t /✶ ρs₂ ∎ wk-commutes : ∀ {m n} {ρ : Sub T₂ m n} t → t / ρ / wk ≡ t / wk / ρ ↑ wk-commutes {ρ = ρ} = ⨀→/✶ (ε ▻ ρ ▻ wk) (ε ▻ wk ▻ ρ ↑) L₄.⊙-wk sub-commutes : ∀ {m n} {t′} {ρ : Sub T₂ m n} t → t / sub t′ / ρ ≡ t / ρ ↑ / sub (t′ ⊘ ρ) sub-commutes {t′ = t′} {ρ} = ⨀→/✶ (ε ▻ sub t′ ▻ ρ) (ε ▻ ρ ↑ ▻ sub (t′ ⊘ ρ)) (L₄.sub-⊙ t′) wk-sub-vanishes : ∀ {n t′} (t : T₁ n) → t / wk / sub t′ ≡ t wk-sub-vanishes {t′ = t′} = ⨀→/✶ (ε ▻ wk ▻ sub t′) ε L₄.wk-⊙-sub /-weaken : ∀ {m n} {ρ : Sub T₂ m n} t → t / map weaken ρ ≡ t / ρ / wk /-weaken {ρ = ρ} = ⨀→/✶ (ε ▻ map weaken ρ) (ε ▻ ρ ▻ wk) L₄.map-weaken open Application application public open L₄ public hiding (application; _⊙_; _/_; _/✶_; id-vanishes; /-⊙; wk-commutes) record Lemmas₅ {ℓ} (T : Pred ℕ ℓ) : Set ℓ where field lemmas₄ : Lemmas₄ T private module L₄ = Lemmas₄ lemmas₄ appLemmas : AppLemmas T T appLemmas = record { application = L₄.application ; lemmas₄ = lemmas₄ ; id-vanishes = L₄.id-vanishes ; /-⊙ = L₄./-⊙ } open AppLemmas appLemmas public hiding (lemmas₄) ------------------------------------------------------------------------ -- Instantiations and code for facilitating instantiations -- Lemmas about variable substitutions (renamings). module VarLemmas where open VarSubst lemmas₃ : Lemmas₃ Fin lemmas₃ = record { lemmas₂ = record { lemmas₁ = record { lemmas₀ = record { simple = simple } ; weaken-var = refl } ; application = application ; var-/ = refl } ; /✶-↑✶ = λ _ _ hyp → hyp } private module L₃ = Lemmas₃ lemmas₃ lemmas₅ : Lemmas₅ Fin lemmas₅ = record { lemmas₄ = record { lemmas₃ = lemmas₃ ; /-wk = L₃.lookup-wk _ } } open Lemmas₅ lemmas₅ public hiding (lemmas₃) -- Lemmas about "term" substitutions. record TermLemmas (T : ℕ → Set) : Set₁ where field termSubst : TermSubst T open TermSubst termSubst field app-var : ∀ {T′} {lift : Lift T′ T} {m n x} {ρ : Sub T′ m n} → app lift (var x) ρ ≡ Lift.lift lift (lookup ρ x) /✶-↑✶ : ∀ {T₁ T₂} {lift₁ : Lift T₁ T} {lift₂ : Lift T₂ T} → let open Lifted lift₁ using () renaming (_↑✶_ to _↑✶₁_; _/✶_ to _/✶₁_) open Lifted lift₂ using () renaming (_↑✶_ to _↑✶₂_; _/✶_ to _/✶₂_) in ∀ {m n} (ρs₁ : Subs T₁ m n) (ρs₂ : Subs T₂ m n) → (∀ k x → var x /✶₁ ρs₁ ↑✶₁ k ≡ var x /✶₂ ρs₂ ↑✶₂ k) → ∀ k t → t /✶₁ ρs₁ ↑✶₁ k ≡ t /✶₂ ρs₂ ↑✶₂ k private module V = VarLemmas lemmas₃ : Lemmas₃ T lemmas₃ = record { lemmas₂ = record { lemmas₁ = record { lemmas₀ = record { simple = simple } ; weaken-var = λ {_ x} → begin var x /Var V.wk ≡⟨ app-var ⟩ var (lookup V.wk x) ≡⟨ cong var (V.lookup-wk x) ⟩ var (suc x) ∎ } ; application = Subst.application subst ; var-/ = app-var } ; /✶-↑✶ = /✶-↑✶ } private module L₃ = Lemmas₃ lemmas₃ lemmas₅ : Lemmas₅ T lemmas₅ = record { lemmas₄ = record { lemmas₃ = lemmas₃ ; /-wk = λ {_ t} → begin t / wk ≡⟨ /✶-↑✶ (ε ▻ wk) (ε ▻ V.wk) (λ k x → begin var x / wk ↑⋆ k ≡⟨ L₃.var-/-wk-↑⋆ k x ⟩ var (lift k suc x) ≡⟨ cong var (sym (V.var-/-wk-↑⋆ k x)) ⟩ var (lookup (V._↑⋆_ V.wk k) x) ≡⟨ sym app-var ⟩ var x /Var V._↑⋆_ V.wk k ∎) zero t ⟩ t /Var V.wk ≡⟨⟩ weaken t ∎ } } open Lemmas₅ lemmas₅ public hiding (lemmas₃)
{ "alphanum_fraction": 0.4356792315, "avg_line_length": 36.763915547, "ext": "agda", "hexsha": "2eb52a30b59fc0bc6a8b1e7b681795f93e6ce7dd", "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/Substitution/Lemmas.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/Substitution/Lemmas.agda", "max_line_length": 117, "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/Substitution/Lemmas.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 8783, "size": 19154 }
open import eq open import bool open import bool-relations using (transitive; total) open import maybe open import nat open import nat-thms using (≤-trans; ≤-total) open import product module z05-01-bst-test where open import bool-relations _≤_ hiding (transitive; total) import z05-01-bst as BST open BST nat _≤_ (λ {x} {y} {z} → ≤-trans {x} {y} {z}) (λ {x} {y} → ≤-total {x} {y}) empty : bst 0 0 empty = bst-leaf refl _ : bst-search 0 empty ≡ nothing _ = refl _ : bst-insert 5 empty ≡ bst-node 5 (bst-leaf refl) (bst-leaf refl) refl refl _ = refl bst-5 : bst 0 5 bst-5 = bst-insert 5 empty _ : maybe (Σ ℕ (λ z → (5 < z || 5 =ℕ z) && (z < 5 || z =ℕ 5) ≡ tt)) _ = bst-search 5 bst-5 _ : bst-insert 9 bst-5 ≡ bst-node 5 (bst-leaf refl) (bst-node 9 (bst-leaf refl) (bst-leaf refl) refl refl) refl refl _ = refl _ : bst 0 9 _ = bst-insert 9 bst-5 _ : bst 0 5 _ = bst-dec-lb {0} {0} {5} (bst-leaf refl) refl
{ "alphanum_fraction": 0.6012332991, "avg_line_length": 23.7317073171, "ext": "agda", "hexsha": "3d4e5fd9e8570c4dc79a5b0c96b7a4142052c5b7", "lang": "Agda", "max_forks_count": 8, "max_forks_repo_forks_event_max_datetime": "2021-09-21T15:58:10.000Z", "max_forks_repo_forks_event_min_datetime": "2015-04-13T21:40:15.000Z", "max_forks_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_forks_repo_licenses": [ "Unlicense" ], "max_forks_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_forks_repo_path": "agda/book/2015-Verified_Functional_programming_in_Agda-Stump/ial/z05-01-bst-test.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "Unlicense" ], "max_issues_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_issues_repo_path": "agda/book/2015-Verified_Functional_programming_in_Agda-Stump/ial/z05-01-bst-test.agda", "max_line_length": 91, "max_stars_count": 36, "max_stars_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_stars_repo_licenses": [ "Unlicense" ], "max_stars_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_stars_repo_path": "agda/book/2015-Verified_Functional_programming_in_Agda-Stump/ial/z05-01-bst-test.agda", "max_stars_repo_stars_event_max_datetime": "2021-07-30T06:55:03.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-29T14:37:15.000Z", "num_tokens": 369, "size": 973 }
module Data.TreeRep where open import Prelude hiding (_>>=_) renaming (_>>=′_ to _>>=_) open import Container.Traversable open import Builtin.Reflection open import Builtin.Float data Leaf : Set where char : Char → Leaf string : String → Leaf float : Float → Leaf name : Name → Leaf data TreeRep : Set where leaf : Leaf → TreeRep node : Nat → List TreeRep → TreeRep --- Eq instance --- private leaf-char-inj : ∀ {x y} → Leaf.char x ≡ char y → x ≡ y leaf-char-inj refl = refl leaf-string-inj : ∀ {x y} → Leaf.string x ≡ string y → x ≡ y leaf-string-inj refl = refl leaf-float-inj : ∀ {x y} → Leaf.float x ≡ float y → x ≡ y leaf-float-inj refl = refl leaf-name-inj : ∀ {x y} → Leaf.name x ≡ name y → x ≡ y leaf-name-inj refl = refl leaf-inj : ∀ {x y} → leaf x ≡ leaf y → x ≡ y leaf-inj refl = refl node-inj₁ : ∀ {x y z w} → node x z ≡ node y w → x ≡ y node-inj₁ refl = refl node-inj₂ : ∀ {x y z w} → node x z ≡ node y w → z ≡ w node-inj₂ refl = refl eq-leaf : (x y : Leaf) → Dec (x ≡ y) eq-leaf (char x) (char x₁) = decEq₁ leaf-char-inj (x == x₁) eq-leaf (string x) (string x₁) = decEq₁ leaf-string-inj (x == x₁) eq-leaf (float x) (float x₁) = decEq₁ leaf-float-inj (x == x₁) eq-leaf (name x) (name x₁) = decEq₁ leaf-name-inj (x == x₁) eq-leaf (char x) (string x₁) = no λ() eq-leaf (char x) (float x₁) = no λ() eq-leaf (char x) (name x₁) = no λ() eq-leaf (string x) (char x₁) = no λ() eq-leaf (string x) (float x₁) = no λ() eq-leaf (string x) (name x₁) = no λ() eq-leaf (float x) (char x₁) = no λ() eq-leaf (float x) (string x₁) = no λ() eq-leaf (float x) (name x₁) = no λ() eq-leaf (name x) (char x₁) = no λ() eq-leaf (name x) (string x₁) = no λ() eq-leaf (name x) (float x₁) = no λ() instance EqLeaf : Eq Leaf _==_ {{EqLeaf}} = eq-leaf private eq-tree : (x y : TreeRep) → Dec (x ≡ y) eq-trees : (xs ys : List TreeRep) → Dec (xs ≡ ys) eq-tree (leaf x) (leaf x₁) = decEq₁ leaf-inj (x == x₁) eq-tree (leaf x) (node x₁ x₂) = no λ() eq-tree (node x x₁) (leaf x₂) = no λ() eq-tree (node x xs) (node y ys) = decEq₂ node-inj₁ node-inj₂ (x == y) (eq-trees xs ys) eq-trees [] [] = yes refl eq-trees [] (x ∷ ys) = no λ() eq-trees (x ∷ xs) [] = no λ() eq-trees (x ∷ xs) (y ∷ ys) = decEq₂ cons-inj-head cons-inj-tail (eq-tree x y) (eq-trees xs ys) instance EqTree : Eq TreeRep _==_ {{EqTree}} = eq-tree --- Ord instance --- data LessLeaf : Leaf → Leaf → Set where char : ∀ {x y} → x < y → LessLeaf (char x) (char y) string : ∀ {x y} → x < y → LessLeaf (string x) (string y) float : ∀ {x y} → x < y → LessLeaf (float x) (float y) name : ∀ {x y} → x < y → LessLeaf (name x) (name y) char<string : ∀ {x y} → LessLeaf (char x) (string y) char<float : ∀ {x y} → LessLeaf (char x) (float y) char<name : ∀ {x y} → LessLeaf (char x) (name y) string<float : ∀ {x y} → LessLeaf (string x) (float y) string<name : ∀ {x y} → LessLeaf (string x) (name y) float<name : ∀ {x y} → LessLeaf (float x) (name y) private cmp-leaf : (a b : Leaf) → Comparison LessLeaf a b cmp-leaf (char x) (char x₁) = mapComparison char (compare x x₁) cmp-leaf (string x) (string x₁) = mapComparison string (compare x x₁) cmp-leaf (float x) (float x₁) = mapComparison float (compare x x₁) cmp-leaf (name x) (name x₁) = mapComparison name (compare x x₁) cmp-leaf (char x) (string x₁) = less char<string cmp-leaf (char x) (float x₁) = less char<float cmp-leaf (char x) (name x₁) = less char<name cmp-leaf (string x) (char x₁) = greater char<string cmp-leaf (string x) (float x₁) = less string<float cmp-leaf (string x) (name x₁) = less string<name cmp-leaf (float x) (char x₁) = greater char<float cmp-leaf (float x) (string x₁) = greater string<float cmp-leaf (float x) (name x₁) = less float<name cmp-leaf (name x) (char x₁) = greater char<name cmp-leaf (name x) (string x₁) = greater string<name cmp-leaf (name x) (float x₁) = greater float<name instance OrdLeaf : Ord Leaf OrdLeaf = defaultOrd cmp-leaf OrdLawsLeaf : Ord/Laws Leaf Ord/Laws.super OrdLawsLeaf = it less-antirefl {{OrdLawsLeaf}} (char lt) = less-antirefl {A = Nat } lt less-antirefl {{OrdLawsLeaf}} (string lt) = less-antirefl {A = List Char} lt less-antirefl {{OrdLawsLeaf}} (float lt) = less-antirefl {A = Float } lt less-antirefl {{OrdLawsLeaf}} (name lt) = less-antirefl {A = Name } lt less-trans {{OrdLawsLeaf}} (char lt) (char lt₁) = char (less-trans {A = Nat } lt lt₁) less-trans {{OrdLawsLeaf}} (string lt) (string lt₁) = string (less-trans {A = List Char} lt lt₁) less-trans {{OrdLawsLeaf}} (float lt) (float lt₁) = float (less-trans {A = Float } lt lt₁) less-trans {{OrdLawsLeaf}} (name lt) (name lt₁) = name (less-trans {A = Name } lt lt₁) less-trans {{OrdLawsLeaf}} (char lt) char<string = char<string less-trans {{OrdLawsLeaf}} (char lt) char<float = char<float less-trans {{OrdLawsLeaf}} (char lt) char<name = char<name less-trans {{OrdLawsLeaf}} (string lt) string<float = string<float less-trans {{OrdLawsLeaf}} (string lt) string<name = string<name less-trans {{OrdLawsLeaf}} (float lt) float<name = float<name less-trans {{OrdLawsLeaf}} char<string (string lt) = char<string less-trans {{OrdLawsLeaf}} char<string string<float = char<float less-trans {{OrdLawsLeaf}} char<string string<name = char<name less-trans {{OrdLawsLeaf}} char<float (float lt) = char<float less-trans {{OrdLawsLeaf}} char<float float<name = char<name less-trans {{OrdLawsLeaf}} char<name (name lt) = char<name less-trans {{OrdLawsLeaf}} string<float (float lt) = string<float less-trans {{OrdLawsLeaf}} string<float float<name = string<name less-trans {{OrdLawsLeaf}} string<name (name lt) = string<name less-trans {{OrdLawsLeaf}} float<name (name lt) = float<name data LessTree : TreeRep → TreeRep → Set where leaf : ∀ {x y} → x < y → LessTree (leaf x) (leaf y) leaf<node : ∀ {x y ys} → LessTree (leaf x) (node y ys) tag< : ∀ {x y xs ys} → x < y → LessTree (node x xs) (node y ys) children< : ∀ {x xs ys} → LessList LessTree xs ys → LessTree (node x xs) (node x ys) private cmp-tree : ∀ x y → Comparison LessTree x y cmp-trees : ∀ xs ys → Comparison (LessList LessTree) xs ys cmp-tree (leaf x) (leaf y) = mapComparison leaf (compare x y) cmp-tree (leaf _) (node _ _) = less leaf<node cmp-tree (node _ _) (leaf _) = greater leaf<node cmp-tree (node x xs) (node y ys) with compare x y cmp-tree (node x xs) (node y ys) | less x<y = less (tag< x<y) cmp-tree (node x xs) (node y ys) | greater x>y = greater (tag< x>y) cmp-tree (node x xs) (node .x ys) | equal refl with cmp-trees xs ys cmp-tree (node x xs) (node .x ys) | equal refl | less lt = less (children< lt) cmp-tree (node x xs) (node .x .xs) | equal refl | equal refl = equal refl cmp-tree (node x xs) (node .x ys) | equal refl | greater gt = greater (children< gt) cmp-trees [] [] = equal refl cmp-trees [] (x ∷ ys) = less nil<cons cmp-trees (x ∷ xs) [] = greater nil<cons cmp-trees (x ∷ xs) (y ∷ ys) = compareCons (cmp-tree x y) (cmp-trees xs ys) instance OrdTree : Ord TreeRep OrdTree = defaultOrd cmp-tree private antirefl : {t : TreeRep} → t < t → ⊥ antirefls : {ts : List TreeRep} → ts < ts → ⊥ antirefl (leaf lt) = less-antirefl {A = Leaf} lt antirefl (tag< lt) = less-antirefl {A = Nat} lt antirefl (children< lt) = antirefls lt antirefls (head< lt) = antirefl lt antirefls (tail< lt) = antirefls lt ltrans : {s t u : TreeRep} → s < t → t < u → s < u ltranss : {ss ts us : List TreeRep} → ss < ts → ts < us → ss < us ltrans (leaf lt) (leaf lt₁) = leaf (less-trans {A = Leaf} lt lt₁) ltrans (leaf lt) leaf<node = leaf<node ltrans leaf<node (tag< lt) = leaf<node ltrans leaf<node (children< lt) = leaf<node ltrans (tag< lt) (tag< lt₁) = tag< (less-trans {A = Nat} lt lt₁) ltrans (tag< lt) (children< lt₁) = tag< lt ltrans (children< lt) (tag< lt₁) = tag< lt₁ ltrans (children< lt) (children< lt₁) = children< (ltranss lt lt₁) ltranss nil<cons (head< lt) = nil<cons ltranss nil<cons (tail< lt₁) = nil<cons ltranss (head< lt) (head< lt₁) = head< (ltrans lt lt₁) ltranss (head< lt) (tail< lt₁) = head< lt ltranss (tail< lt) (head< lt₁) = head< lt₁ ltranss (tail< lt) (tail< lt₁) = tail< (ltranss lt lt₁) instance OrdLawsTree : Ord/Laws TreeRep Ord/Laws.super OrdLawsTree = it less-antirefl {{OrdLawsTree}} = antirefl less-trans {{OrdLawsTree}} = ltrans --- Encoding types as trees --- record TreeEncoding {a} (A : Set a) : Set a where constructor treeEncoding field treeEncode : A → TreeRep treeDecode : TreeRep → Maybe A isTreeEmbedding : ∀ x → treeDecode (treeEncode x) ≡ just x open TreeEncoding {{...}} public module _ {a} {A : Set a} {{_ : TreeEncoding A}} where private encode-injective : (x y : A) → treeEncode x ≡ treeEncode y → x ≡ y encode-injective x y eq = eraseEquality $ just-inj $ isTreeEmbedding x ʳ⟨≡⟩ cong treeDecode eq ⟨≡⟩ isTreeEmbedding y decTreeEq : (x y : A) → Dec (x ≡ y) decTreeEq x y with treeEncode x == treeEncode y decTreeEq x y | yes eq = yes (encode-injective x y eq) decTreeEq x y | no !eq = no λ x=y → !eq (cong treeEncode x=y) EqByTreeEncoding : Eq A _==_ {{EqByTreeEncoding}} = decTreeEq data LessEncoding (x y : A) : Set a where less-enc : treeEncode x < treeEncode y → LessEncoding x y OrdByTreeEncoding : Ord A OrdByTreeEncoding = defaultOrd λ x y → injectComparison (encode-injective _ _) less-enc $ (compare on treeEncode) x y OrdLawsByTreeEncoding : Ord/Laws A Ord/Laws.super OrdLawsByTreeEncoding = OrdByTreeEncoding less-antirefl {{OrdLawsByTreeEncoding}} (less-enc lt) = less-antirefl {A = TreeRep} lt less-trans {{OrdLawsByTreeEncoding}} (less-enc lt) (less-enc lt₁) = less-enc (less-trans {A = TreeRep} lt lt₁) --- Encodings for standard types --- instance EncodeNat : TreeEncoding Nat EncodeNat = treeEncoding enc dec (λ _ → refl) where enc : Nat → TreeRep enc n = node n [] dec : TreeRep → Maybe Nat dec (node n _) = just n dec (leaf _) = nothing EncodeBool : TreeEncoding Bool EncodeBool = treeEncoding enc dec emb where enc : Bool → TreeRep enc false = node 0 [] enc true = node 1 [] dec : TreeRep → Maybe Bool dec (node 0 _) = just false dec _ = just true emb : ∀ b → dec (enc b) ≡ just b emb false = refl emb true = refl EncodeMaybe : ∀ {a} {A : Set a} {{_ : TreeEncoding A}} → TreeEncoding (Maybe A) EncodeMaybe {A = A} = treeEncoding enc dec emb where enc : Maybe A → TreeRep enc nothing = node 0 [] enc (just x) = node 1 [ treeEncode x ] dec : TreeRep → Maybe (Maybe A) dec (node 0 _) = just nothing dec (node _ (x ∷ _)) = just <$> treeDecode x dec _ = nothing emb : ∀ x → dec (enc x) ≡ just x emb nothing = refl emb (just x) = just =$= isTreeEmbedding x EncodeSigma : ∀ {a b} {A : Set a} {B : A → Set b} {{EncA : TreeEncoding A}} {{EncB : ∀ {x} → TreeEncoding (B x)}} → TreeEncoding (Σ A B) EncodeSigma {A = A} {B = B} = treeEncoding enc dec emb where enc : Σ A B → TreeRep enc (x , y) = node 0 (treeEncode x ∷ treeEncode y ∷ []) dec : TreeRep → Maybe (Σ A B) dec (node _ (x ∷ y ∷ _)) = do x ← treeDecode x ofType Maybe A y ← treeDecode y just (x , y) dec _ = nothing emb : ∀ x → dec (enc x) ≡ just x emb (x , y) rewrite isTreeEmbedding x | isTreeEmbedding y = refl EncodeList : ∀ {a} {A : Set a} {{_ : TreeEncoding A}} → TreeEncoding (List A) treeEncode {{EncodeList}} xs = node 0 (map treeEncode xs) treeDecode {{EncodeList}} (node _ xs) = traverse′ treeDecode xs treeDecode {{EncodeList}} _ = nothing isTreeEmbedding {{EncodeList}} [] = refl isTreeEmbedding {{EncodeList}} (x ∷ xs) = _∷_ =$= isTreeEmbedding x =*= isTreeEmbedding xs --- Example --- -- private -- data TestData : Set where -- cA : TestData → TestData -- cB : TestData → TestData → TestData -- cC : TestData -- cD : TestData → TestData → TestData -- private -- encodeTest : TestData → TreeRep -- encodeTest (cA x) = node 0 (encodeTest x ∷ []) -- encodeTest (cB x y) = node 1 (encodeTest x ∷ encodeTest y ∷ []) -- encodeTest cC = node 2 [] -- encodeTest (cD x y) = node 3 (encodeTest x ∷ encodeTest y ∷ []) -- decodeTest : TreeRep → Maybe TestData -- decodeTest (leaf _) = nothing -- decodeTest (node 0 (x ∷ [])) = cA <$> decodeTest x -- decodeTest (node 1 (x ∷ y ∷ [])) = cB <$> decodeTest x <*> decodeTest y -- decodeTest (node 2 []) = just cC -- decodeTest (node 3 (x ∷ y ∷ [])) = cD <$> decodeTest x <*> decodeTest y -- decodeTest _ = nothing -- embeddingTest : ∀ x → decodeTest (encodeTest x) ≡ just x -- embeddingTest (cA x) = cA =$= embeddingTest x -- embeddingTest (cB x y) = cB =$= embeddingTest x =*= embeddingTest y -- embeddingTest cC = refl -- embeddingTest (cD x y) = cD =$= embeddingTest x =*= embeddingTest y -- instance -- EncodeTest : TreeEncoding TestData -- EncodeTest = record { treeEncode = encodeTest -- ; treeDecode = decodeTest -- ; isTreeEmbedding = embeddingTest } -- EqTest : Eq TestData -- EqTest = EqByTreeEncoding -- OrdTest : Ord TestData -- OrdTest = OrdByTreeEncoding
{ "alphanum_fraction": 0.5961068812, "avg_line_length": 39.106741573, "ext": "agda", "hexsha": "45def4d49f6b627e87871b5a31f3e4291fe9b86b", "lang": "Agda", "max_forks_count": 24, "max_forks_repo_forks_event_max_datetime": "2021-04-22T06:10:41.000Z", "max_forks_repo_forks_event_min_datetime": "2015-03-12T18:03:45.000Z", "max_forks_repo_head_hexsha": "158d299b1b365e186f00d8ef5b8c6844235ee267", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "L-TChen/agda-prelude", "max_forks_repo_path": "src/Data/TreeRep.agda", "max_issues_count": 59, "max_issues_repo_head_hexsha": "158d299b1b365e186f00d8ef5b8c6844235ee267", "max_issues_repo_issues_event_max_datetime": "2022-01-14T07:32:36.000Z", "max_issues_repo_issues_event_min_datetime": "2016-02-09T05:36:44.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "L-TChen/agda-prelude", "max_issues_repo_path": "src/Data/TreeRep.agda", "max_line_length": 115, "max_stars_count": 111, "max_stars_repo_head_hexsha": "158d299b1b365e186f00d8ef5b8c6844235ee267", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "L-TChen/agda-prelude", "max_stars_repo_path": "src/Data/TreeRep.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-12T23:29:26.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-05T11:28:15.000Z", "num_tokens": 4829, "size": 13922 }
module _ where open import Agda.Builtin.Reflection renaming (bindTC to _>>=_) open import Agda.Builtin.Unit open import Agda.Builtin.List open import Agda.Builtin.Nat open import Agda.Builtin.Equality open import Agda.Builtin.Bool _>>_ : {A B : Set} → TC A → TC B → TC B m >> m₁ = m >>= λ _ → m₁ data Fin : Nat → Set where zero : ∀ {n} → Fin (suc n) suc : ∀ {n} → Fin n → Fin (suc n) macro reflectAndCheck : ∀ {a} {A : Set a} → A → Term → TC ⊤ reflectAndCheck {A = A} x hole = withNormalisation true do `x ← quoteTC x `A ← quoteTC A ``x ← checkType `x `A >>= quoteTC unify hole ``x quoteUnquote : ∀ {a} {A : Set a} → A → Term → TC ⊤ quoteUnquote x hole = withNormalisation true do `x ← quoteTC x unify hole `x module _ (n : Nat) (A : Set) (m : Nat) (j : Fin m) where plam₁ : Fin n → Fin m plam₁ = λ where zero → j; (suc i) → j `plam₁ : Term `plam₁ = reflectAndCheck plam₁ plam₁′ : Fin n → Fin m plam₁′ = quoteUnquote plam₁ refined₁ : n ≡ suc m → Nat refined₁ refl = 0 where plam : Fin n → Fin m plam = λ where zero → j; (suc i) → i `plam : Term `plam = reflectAndCheck plam plam′ : Fin n → Fin m plam′ = quoteUnquote plam refined₂ : m ≡ suc n → Nat refined₂ refl = 0 where plam : Fin n → Fin m plam = λ where zero → j; (suc i) → suc (suc i) `plam : Term `plam = reflectAndCheck plam plam′ : Fin n → Fin m plam′ = quoteUnquote plam
{ "alphanum_fraction": 0.5807537012, "avg_line_length": 22.8615384615, "ext": "agda", "hexsha": "14f6201c2104d4d0750bc04aebd601794065c0f0", "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/QuotePatternLambda.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/QuotePatternLambda.agda", "max_line_length": 62, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/Succeed/QuotePatternLambda.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": 556, "size": 1486 }
{-# OPTIONS --safe #-} open import Definition.Typed.EqualityRelation module Definition.LogicalRelation.Substitution.Introductions.Universe {{eqrel : EqRelSet}} where open EqRelSet {{...}} open import Definition.Untyped open import Definition.Untyped.Properties open import Definition.Typed open import Definition.Typed.Properties open import Definition.Typed.Weakening open import Definition.LogicalRelation open import Definition.LogicalRelation.Irrelevance open import Definition.LogicalRelation.Properties open import Definition.LogicalRelation.Substitution open import Definition.LogicalRelation.Substitution.MaybeEmbed open import Tools.Product open import Tools.Empty import Definition.LogicalRelation.Weakening as wkLR import Tools.PropositionalEquality as PE import Data.Nat as Nat -- Validity of the universe type. U¹ᵛ : ∀ {Γ rU l} → (ι ¹ <∞ l) → ([Γ] : ⊩ᵛ Γ) → Γ ⊩ᵛ⟨ l ⟩ Univ rU ¹ ^ [ ! , ∞ ] / [Γ] U¹ᵛ {Γ} {rU} ∞< [Γ] ⊢Δ [σ] = Ugen ⊢Δ , (λ [σ′] [σ≡σ′] → id (Uⱼ ⊢Δ)) U⁰ᵛ : ∀ {Γ rU l' l} → (⁰ ≤ l') → (ι l' <∞ l) → ([Γ] : ⊩ᵛ Γ) → Γ ⊩ᵛ⟨ l ⟩ Univ rU ⁰ ^ [ ! , ι ¹ ] / [Γ] U⁰ᵛ {Γ} {rU} (<is≤ 0<1) ∞< [Γ] ⊢Δ [σ] = emb ∞< (Uᵣ (Uᵣ rU ⁰ emb< PE.refl [[ Ugenⱼ ⊢Δ , Ugenⱼ ⊢Δ , id (Ugenⱼ ⊢Δ) ]])) , (λ [σ′] [σ≡σ′] → id (Ugenⱼ ⊢Δ)) U⁰ᵛ {Γ} {rU} (≡is≤ PE.refl) l< [Γ] ⊢Δ [σ] = Uᵣ (Uᵣ rU ⁰ l< PE.refl [[ Ugenⱼ ⊢Δ , Ugenⱼ ⊢Δ , id (Ugenⱼ ⊢Δ) ]]) , (λ [σ′] [σ≡σ′] → id (Ugenⱼ ⊢Δ)) Uᵛgen : ∀ {Γ rU lU lU' l} → (lU ≤ lU') → (ι lU' <∞ l) → ([Γ] : ⊩ᵛ Γ) → Γ ⊩ᵛ⟨ l ⟩ Univ rU lU ^ [ ! , next lU ] / [Γ] Uᵛgen {lU = ⁰} = U⁰ᵛ Uᵛgen {lU = ¹} (≡is≤ PE.refl) = U¹ᵛ Uᵛ : ∀ {Γ rU lU l} → (ι lU <∞ l) → ([Γ] : ⊩ᵛ Γ) → Γ ⊩ᵛ⟨ l ⟩ Univ rU lU ^ [ ! , next lU ] / [Γ] Uᵛ = Uᵛgen (≡is≤ PE.refl) Uᵗᵛ₁ : ∀ {Γ rU} → (⊢Γ : ⊢ Γ) → Γ ⊩⟨ ∞ ⟩ Univ rU ⁰ ∷ Univ ! ¹ ^ [ ! , ∞ ] / Ugen ⊢Γ Uᵗᵛ₁ {Γ} {rU} ⊢Γ = Uₜ (Univ rU ⁰) (idRedTerm:*: (univ 0<1 ⊢Γ)) Uₙ (≅-U⁰refl ⊢Γ) (λ σ ⊢Δ₁ → Uᵣ′ (Univ rU ⁰) (ι ¹) rU ⁰ emb< PE.refl (idRed:*: (Ugenⱼ ⊢Δ₁))) Uᵗᵛ : ∀ {Γ rU} → ([Γ] : ⊩ᵛ Γ) → Γ ⊩ᵛ⟨ ∞ ⟩ Univ rU ⁰ ∷ Univ ! ¹ ^ [ ! , ∞ ] / [Γ] / Uᵛ ∞< [Γ] Uᵗᵛ {Γ} {rU} [Γ] = λ ⊢Δ [σ] → Uᵗᵛ₁ ⊢Δ , λ [σ′] [σ≡σ′] → Uₜ₌ (Uᵗᵛ₁ ⊢Δ) (Uᵗᵛ₁ ⊢Δ) (≅-U⁰refl ⊢Δ) λ [ρ] ⊢Δ → id (Ugenⱼ ⊢Δ) -- Valid terms of type U are valid types. univᵛ : ∀ {A Γ rU lU lU' l} ([Γ] : ⊩ᵛ Γ) (lU< : lU ≤ lU') ([U] : Γ ⊩ᵛ⟨ l ⟩ Univ rU lU ^ [ ! , next lU ] / [Γ]) → Γ ⊩ᵛ⟨ l ⟩ A ∷ Univ rU lU ^ [ ! , next lU ] / [Γ] / [U] → Γ ⊩ᵛ⟨ ι lU' ⟩ A ^ [ rU , ι lU ] / [Γ] univᵛ {lU = lU} {l = l} [Γ] lU< [U] [A] ⊢Δ [σ] = let [A]₁ = irrelevance-≤ lU< (univEq (proj₁ ([U] ⊢Δ [σ])) (proj₁ ([A] ⊢Δ [σ]))) in [A]₁ , λ [σ′] [σ≡σ′] → univEqEq (proj₁ ([U] ⊢Δ [σ])) [A]₁ ((proj₂ ([A] ⊢Δ [σ])) [σ′] [σ≡σ′]) -- Valid term equality of type U is valid type equality. univEqᵛ : ∀ {A B Γ rU lU l l′} ([Γ] : ⊩ᵛ Γ) ([U] : Γ ⊩ᵛ⟨ l′ ⟩ Univ rU lU ^ [ ! , next lU ] / [Γ]) ([A] : Γ ⊩ᵛ⟨ l ⟩ A ^ [ rU , ι lU ] / [Γ]) → Γ ⊩ᵛ⟨ l′ ⟩ A ≡ B ∷ Univ rU lU ^ [ ! , next lU ] / [Γ] / [U] → Γ ⊩ᵛ⟨ l ⟩ A ≡ B ^ [ rU , ι lU ] / [Γ] / [A] univEqᵛ {A} [Γ] [U] [A] [t≡u] ⊢Δ [σ] = univEqEq (proj₁ ([U] ⊢Δ [σ])) (proj₁ ([A] ⊢Δ [σ])) ([t≡u] ⊢Δ [σ]) univᵗᵛ : ∀ {Γ A t r l′} ([Γ] : ⊩ᵛ Γ) → ([U] : Γ ⊩ᵛ⟨ ∞ ⟩ Univ r l′ ^ [ ! , next l′ ] / [Γ] ) → ([A] : Γ ⊩ᵛ⟨ ∞ ⟩ A ∷ Univ r l′ ^ [ ! , next l′ ] / [Γ] / [U]) → Γ ⊩ᵛ⟨ ∞ ⟩ t ∷ A ^ [ r , ι l′ ] / [Γ] / maybeEmbᵛ {A = A} [Γ] (univᵛ {A = A} [Γ] (≡is≤ PE.refl) [U] [A]) → Γ ⊩ᵛ⟨ ι l′ ⟩ t ∷ A ^ [ r , ι l′ ] / [Γ] / univᵛ {A = A} [Γ] (≡is≤ PE.refl) [U] [A] univᵗᵛ {Γ} {A} {t} {r} {⁰} [Γ] [U] [A] [t] ⊢Δ [σ] = univEqTerm (proj₁ ([U] ⊢Δ [σ])) (proj₁ ([A] ⊢Δ [σ])) (proj₁ ([t] ⊢Δ [σ])) , λ [σ′] [σ≡σ′] → univEqEqTerm (proj₁ ([U] ⊢Δ [σ])) (proj₁ ([A] ⊢Δ [σ])) (proj₁ ([t] ⊢Δ [σ])) (proj₂ ([t] ⊢Δ [σ]) [σ′] [σ≡σ′]) univᵗᵛ {Γ} {A} {t} {r} {¹} [Γ] [U] [A] [t] ⊢Δ [σ] = univEqTerm (proj₁ ([U] ⊢Δ [σ])) (proj₁ ([A] ⊢Δ [σ])) (proj₁ ([t] ⊢Δ [σ])) , λ [σ′] [σ≡σ′] → univEqEqTerm (proj₁ ([U] ⊢Δ [σ])) (proj₁ ([A] ⊢Δ [σ])) (proj₁ ([t] ⊢Δ [σ])) (proj₂ ([t] ⊢Δ [σ]) [σ′] [σ≡σ′]) un-univᵛ : ∀ {A Γ r l} ([Γ] : ⊩ᵛ Γ) ([U] : Γ ⊩ᵛ⟨ next l ⟩ Univ r l ^ [ ! , next l ] / [Γ]) → Γ ⊩ᵛ⟨ ι l ⟩ A ^ [ r , ι l ] / [Γ] → Γ ⊩ᵛ⟨ next l ⟩ A ∷ Univ r l ^ [ ! , next l ] / [Γ] / [U] un-univᵛ {l = l} [Γ] [U] [A] = λ ⊢Δ [σ] → irrelevanceTerm (Ugen (wf (escape (proj₁ ([A] ⊢Δ [σ]))))) (proj₁ ([U] ⊢Δ [σ])) (un-univEq (proj₁ ([A] ⊢Δ [σ]))) , λ [σ′] [σ≡σ′] → irrelevanceEqTerm (Ugen (wf (escape (proj₁ ([A] ⊢Δ [σ]))))) (proj₁ ([U] ⊢Δ [σ])) (un-univEqEq (proj₁ ([A] ⊢Δ [σ])) (proj₁ ([A] ⊢Δ [σ′])) (proj₂ ([A] ⊢Δ [σ]) [σ′] [σ≡σ′])) un-univEqᵛ : ∀ {A B Γ r l} ([Γ] : ⊩ᵛ Γ) ([U] : Γ ⊩ᵛ⟨ next l ⟩ Univ r l ^ [ ! , next l ] / [Γ]) → ([A] : Γ ⊩ᵛ⟨ ι l ⟩ A ^ [ r , ι l ] / [Γ]) → ([B] : Γ ⊩ᵛ⟨ ι l ⟩ B ^ [ r , ι l ] / [Γ]) → Γ ⊩ᵛ⟨ ι l ⟩ A ≡ B ^ [ r , ι l ] / [Γ] / [A] → Γ ⊩ᵛ⟨ next l ⟩ A ≡ B ∷ Univ r l ^ [ ! , next l ] / [Γ] / [U] un-univEqᵛ {l = l} [Γ] [U] [A] [B] [A≡B] = λ ⊢Δ [σ] → irrelevanceEqTerm (Ugen (wf (escape (proj₁ ([A] ⊢Δ [σ]))))) (proj₁ ([U] ⊢Δ [σ])) (un-univEqEq (proj₁ ([A] ⊢Δ [σ])) (proj₁ ([B] ⊢Δ [σ])) ([A≡B] ⊢Δ [σ]))
{ "alphanum_fraction": 0.4423298731, "avg_line_length": 48.1666666667, "ext": "agda", "hexsha": "b3e324082c828ad979af32459dd050461fb0af5e", "lang": "Agda", "max_forks_count": 2, "max_forks_repo_forks_event_max_datetime": "2022-02-15T19:42:19.000Z", "max_forks_repo_forks_event_min_datetime": "2022-01-26T14:55:51.000Z", "max_forks_repo_head_hexsha": "e0eeebc4aa5ed791ce3e7c0dc9531bd113dfcc04", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "CoqHott/logrel-mltt", "max_forks_repo_path": "Definition/LogicalRelation/Substitution/Introductions/Universe.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "e0eeebc4aa5ed791ce3e7c0dc9531bd113dfcc04", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "CoqHott/logrel-mltt", "max_issues_repo_path": "Definition/LogicalRelation/Substitution/Introductions/Universe.agda", "max_line_length": 189, "max_stars_count": 2, "max_stars_repo_head_hexsha": "e0eeebc4aa5ed791ce3e7c0dc9531bd113dfcc04", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "CoqHott/logrel-mltt", "max_stars_repo_path": "Definition/LogicalRelation/Substitution/Introductions/Universe.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": 3062, "size": 5202 }
{-# OPTIONS --without-K --rewriting #-} open import HoTT open import cohomology.Theory open import groups.ExactSequence open import groups.Exactness open import groups.HomSequence open import groups.KernelImageUniqueFactorization import cw.cohomology.GridPtdMap as GPM open import cw.CW module cw.cohomology.HigherCohomologyGroups {i} (OT : OrdinaryTheory i) {n} (⊙skel : ⊙Skeleton {i} (S (S (S n)))) (ac : ⊙has-cells-with-choice 0 ⊙skel i) where private Sn≤SSSn : S n ≤ S (S (S n)) Sn≤SSSn = lteSR lteS n≤SSn : n ≤ S (S n) n≤SSn = lteSR lteS n≤SSSn : n ≤ S (S (S n)) n≤SSSn = lteSR (lteSR lteS) ⊙skel₋₁ = ⊙cw-init ⊙skel ac₋₁ = ⊙init-has-cells-with-choice ⊙skel ac ⊙skel₋₂ = ⊙cw-init ⊙skel₋₁ ⊙skel₋₃ = ⊙cw-take n≤SSSn ⊙skel ac₋₃ = ⊙take-has-cells-with-choice n≤SSSn ⊙skel ac open OrdinaryTheory OT open import cw.cohomology.HigherCoboundaryGrid OT open import cw.cohomology.Descending OT open import cw.cohomology.InnerGrid OT (ℕ-to-ℤ (S (S n))) (⊙cw-incl-last ⊙skel₋₂) (⊙cw-incl-last ⊙skel₋₁) (⊙cw-incl-last ⊙skel) open import cw.cohomology.WedgeOfCells OT open import cw.cohomology.HigherCoboundary OT ⊙skel import cw.cohomology.HigherCoboundary OT ⊙skel₋₁ as LC import cw.cohomology.GridLongExactSequence cohomology-theory as GLES {- H apex Coker ≃ C(X₂/X₀)<---C(X₃/X₀) ≃ C(X) ^ ^ | | | | C(X₂/X₁)<---C(X₃/X₁) ≃ Ker WoC G WoC := Wedges of Cells -} private C-apex : Group i C-apex = C (ℕ-to-ℤ (S (S n))) (⊙Cofiber (⊙cw-incl-tail n≤SSSn ⊙skel)) open import cohomology.LongExactSequence cohomology-theory (ℕ-to-ℤ (S n)) (⊙cw-incl-tail n≤SSSn ⊙skel) C-apex-iso-C-cw : C-apex ≃ᴳ C (ℕ-to-ℤ (S (S n))) ⊙⟦ ⊙skel ⟧ C-apex-iso-C-cw = Exact2.G-trivial-and-L-trivial-implies-H-iso-K (exact-seq-index 1 C-cofiber-exact-seq) (exact-seq-index 2 C-cofiber-exact-seq) (C-cw-at-higher ⊙skel₋₃ ltS ac₋₃) (C-cw-at-higher ⊙skel₋₃ (ltSR ltS) ac₋₃) G : Group i G = C (ℕ-to-ℤ (S (S n))) (⊙Cofiber (⊙cw-incl-tail Sn≤SSSn ⊙skel)) G-iso-Ker : G ≃ᴳ Ker.grp cw-co∂-last G-iso-Ker = Ker-cw-co∂-last ⊙skel ac H : Group i H = C (ℕ-to-ℤ (S (S n))) (⊙Cofiber (⊙cw-incl-tail n≤SSn ⊙skel₋₁)) Coker-iso-H : LC.CokerCo∂ ≃ᴳ H Coker-iso-H = Coker-cw-co∂-last ⊙skel₋₁ ac₋₁ module GLES-top = GLES (ℕ-to-ℤ (S n)) (⊙cw-incl-nth Sn≤SSSn ⊙skel) (⊙cw-incl-tail Sn≤SSSn ⊙skel) module GPM-top = GPM (⊙cw-incl-nth Sn≤SSSn ⊙skel) (⊙cw-incl-tail Sn≤SSSn ⊙skel) G-to-C-apex : G →ᴳ C-apex G-to-C-apex = C-fmap (ℕ-to-ℤ (S (S n))) GPM-top.Z/X-to-Z/Y abstract G-to-C-apex-is-surj : is-surjᴳ G-to-C-apex G-to-C-apex-is-surj = Exact.K-trivial-implies-φ-is-surj (exact-seq-index 2 GLES-top.C-grid-cofiber-exact-seq) (CXₙ/Xₙ₋₁->-is-trivial ⊙skel₋₂ ltS (⊙take-has-cells-with-choice Sn≤SSSn ⊙skel ac)) module GLES-right = GLES (ℕ-to-ℤ (S n)) (⊙cw-incl-tail n≤SSn ⊙skel₋₁) (⊙cw-incl-last ⊙skel) module GPM-right = GPM (⊙cw-incl-tail n≤SSn ⊙skel₋₁) (⊙cw-incl-last ⊙skel) C-apex-to-H : C-apex →ᴳ H C-apex-to-H = C-fmap (ℕ-to-ℤ (S (S n))) GPM-right.Y/X-to-Z/X abstract C-apex-to-H-is-inj : is-injᴳ C-apex-to-H C-apex-to-H-is-inj = Exact.G-trivial-implies-ψ-is-inj (exact-seq-index 2 GLES-right.C-grid-cofiber-exact-seq) (CXₙ/Xₙ₋₁-<-is-trivial ⊙skel ltS ac) C-WoC : Group i C-WoC = C (ℕ-to-ℤ (S (S n))) (⊙Cofiber (⊙cw-incl-last ⊙skel₋₁)) G-to-C-WoC : G →ᴳ C-WoC G-to-C-WoC = C-fmap (ℕ-to-ℤ (S (S n))) (GPM.Y/X-to-Z/X (⊙cw-incl-last ⊙skel₋₁) (⊙cw-incl-last ⊙skel)) C-WoC-to-H : C-WoC →ᴳ H C-WoC-to-H = C-fmap (ℕ-to-ℤ (S (S n))) (GPM.Z/X-to-Z/Y (⊙cw-incl-nth Sn≤SSSn ⊙skel) (⊙cw-incl-last ⊙skel₋₁)) open import groups.KernelImage cw-co∂-last LC.cw-co∂-last (CXₙ/Xₙ₋₁-is-abelian ⊙skel₋₁ (ℕ-to-ℤ (S (S n)))) C-cw-iso-ker/im : C (ℕ-to-ℤ (S (S n))) ⊙⟦ ⊙skel ⟧ ≃ᴳ Ker/Im C-cw-iso-ker/im = lemma ∘eᴳ C-apex-iso-C-cw ⁻¹ᴳ where lemma : C-apex ≃ᴳ Ker/Im lemma = H-iso-Ker/Im cw-co∂-last LC.cw-co∂-last (CXₙ/Xₙ₋₁-is-abelian ⊙skel₋₁ (ℕ-to-ℤ (S (S n)))) φ₁ φ₁-is-surj φ₂ φ₂-is-inj lemma-comm where φ₁ = G-to-C-apex ∘ᴳ GroupIso.g-hom G-iso-Ker abstract φ₁-is-surj : is-surjᴳ φ₁ φ₁-is-surj = ∘-is-surj G-to-C-apex-is-surj (equiv-is-surj (GroupIso.g-is-equiv G-iso-Ker)) φ₂ = GroupIso.g-hom Coker-iso-H ∘ᴳ C-apex-to-H abstract φ₂-is-inj : is-injᴳ φ₂ φ₂-is-inj = ∘-is-inj (equiv-is-inj (GroupIso.g-is-equiv Coker-iso-H)) C-apex-to-H-is-inj abstract lemma-comm : ∀ g → GroupIso.g Coker-iso-H (GroupHom.f (C-apex-to-H ∘ᴳ G-to-C-apex) (GroupIso.g G-iso-Ker g)) == q[ fst g ] lemma-comm g = GroupIso.g Coker-iso-H (GroupHom.f C-apex-to-H (GroupHom.f G-to-C-apex (GroupIso.g G-iso-Ker g))) =⟨ ap (GroupIso.g Coker-iso-H) (! (C-inner-grid-commutes □$ᴳ GroupIso.g G-iso-Ker g)) ⟩ GroupIso.g Coker-iso-H (GroupHom.f C-WoC-to-H (GroupHom.f G-to-C-WoC (GroupIso.g G-iso-Ker g))) =⟨ ap (GroupIso.g Coker-iso-H ∘ GroupHom.f C-WoC-to-H ∘ fst) (GroupIso.f-g G-iso-Ker g) ⟩ GroupIso.g Coker-iso-H (GroupHom.f C-WoC-to-H (fst g)) =⟨ GroupIso.g-f Coker-iso-H q[ fst g ] ⟩ q[ fst g ] =∎
{ "alphanum_fraction": 0.5968890555, "avg_line_length": 33.9872611465, "ext": "agda", "hexsha": "2d1a09ae3aaa003d1457e1d510e48e2b9c5730d8", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2018-12-26T21:31:57.000Z", "max_forks_repo_forks_event_min_datetime": "2018-12-26T21:31:57.000Z", "max_forks_repo_head_hexsha": "e7d663b63d89f380ab772ecb8d51c38c26952dbb", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "mikeshulman/HoTT-Agda", "max_forks_repo_path": "theorems/cw/cohomology/HigherCohomologyGroups.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "e7d663b63d89f380ab772ecb8d51c38c26952dbb", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "mikeshulman/HoTT-Agda", "max_issues_repo_path": "theorems/cw/cohomology/HigherCohomologyGroups.agda", "max_line_length": 107, "max_stars_count": null, "max_stars_repo_head_hexsha": "e7d663b63d89f380ab772ecb8d51c38c26952dbb", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "mikeshulman/HoTT-Agda", "max_stars_repo_path": "theorems/cw/cohomology/HigherCohomologyGroups.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 2440, "size": 5336 }
module PiNF-algebra where open import Data.Product hiding (map) open import Level open import Relation.Binary.Core open import Algebra import Algebra.FunctionProperties as FunctionProperties open import Algebra.FunctionProperties.Core open import Algebra.Structures open import PiNF-syntax ------------------------------------------------------------------------------ -- Establish that Pi syntactically is a commutative semiring ⟷IsEquivalence : IsEquivalence _⟷_ ⟷IsEquivalence = record { refl = id⟷ ; sym = sym ; trans = _◎_ } +IsSemigroup : IsSemigroup _⟷_ PLUS +IsSemigroup = record { isEquivalence = ⟷IsEquivalence ; assoc = λ x y z → assocr₊ {x} {y} {z} ; ∙-cong = _⊕_ } +0IsMonoid : IsMonoid _⟷_ PLUS ZERO +0IsMonoid = record { isSemigroup = +IsSemigroup ; identity = ((λ x → unite₊ {x}) , (λ x → swap₊ ◎ unite₊ {x})) } +0IsCommutativeMonoid : IsCommutativeMonoid _⟷_ PLUS ZERO +0IsCommutativeMonoid = record { isSemigroup = +IsSemigroup ; identityˡ = λ x → unite₊ {x} ; comm = λ x y → swap₊ {x} {y} } +0CommutativeMonoid : CommutativeMonoid _ _ +0CommutativeMonoid = record { Carrier = B ; _≈_ = _⟷_ ; _∙_ = PLUS ; ε = ZERO ; isCommutativeMonoid = +0IsCommutativeMonoid } -- ⋆IsSemigroup : IsSemigroup _⟷_ TIMES ⋆IsSemigroup = record { isEquivalence = ⟷IsEquivalence ; assoc = λ x y z → assocr⋆ {x} {y} {z} ; ∙-cong = _⊗_ } ⋆1IsMonoid : IsMonoid _⟷_ TIMES ONE ⋆1IsMonoid = record { isSemigroup = ⋆IsSemigroup ; identity = ((λ x → unite⋆ {x}) , (λ x → swap⋆ ◎ unite⋆ {x})) } ⋆1IsCommutativeMonoid : IsCommutativeMonoid _⟷_ TIMES ONE ⋆1IsCommutativeMonoid = record { isSemigroup = ⋆IsSemigroup ; identityˡ = λ x → unite⋆ {x} ; comm = λ x y → swap⋆ {x} {y} } ⋆1CommutativeMonoid : CommutativeMonoid _ _ ⋆1CommutativeMonoid = record { Carrier = B ; _≈_ = _⟷_ ; _∙_ = TIMES ; ε = ONE ; isCommutativeMonoid = ⋆1IsCommutativeMonoid } record IsCommutativeSemiringWithoutAnnihilatingZero {a ℓ} {A : Set a} (≈ : Rel A ℓ) (+ * : Op₂ A) (0# 1# : A) : Set (a ⊔ ℓ) where open FunctionProperties ≈ field +-isCommutativeMonoid : IsCommutativeMonoid ≈ + 0# *-isCommutativeMonoid : IsCommutativeMonoid ≈ * 1# distrib : * DistributesOver + record CommutativeSemiringWithoutAnnihilatingZero c ℓ : Set (suc (c ⊔ ℓ)) where field Carrier : Set c _≈_ : Rel Carrier ℓ _+_ : Op₂ Carrier _*_ : Op₂ Carrier 0# : Carrier 1# : Carrier isCommutativeSemiringWithoutAnnihilatingZero : IsCommutativeSemiringWithoutAnnihilatingZero _≈_ _+_ _*_ 0# 1# B-isCommutativeSemiringWithoutAnnihilatingZero : IsCommutativeSemiringWithoutAnnihilatingZero _⟷_ PLUS TIMES ZERO ONE B-isCommutativeSemiringWithoutAnnihilatingZero = record { +-isCommutativeMonoid = +0IsCommutativeMonoid ; *-isCommutativeMonoid = ⋆1IsCommutativeMonoid ; distrib = ( (λ x y z → dist' {x} {y} {z}) , (λ x y z → dist {y} {z} {x} )) } ------------------------------------------------------------------------------ -- Establish that Pi+negatives+fractionals syntactically is a meadow +0-IsGroup : IsGroup _⟷_ PLUS ZERO NEG +0-IsGroup = record { isMonoid = +0IsMonoid ; inverse = ( (λ x → swap₊ ◎ ε₊ {x}) , (λ x → ε₊ {x}) ); ⁻¹-cong = neg } +0-IsAbelianGroup : IsAbelianGroup _⟷_ PLUS ZERO NEG +0-IsAbelianGroup = record { isGroup = +0-IsGroup ; comm = λ x y → swap₊ {x} {y} } B-IsRing : IsRing _⟷_ PLUS TIMES NEG ZERO ONE B-IsRing = record { +-isAbelianGroup = +0-IsAbelianGroup ; *-isMonoid = ⋆1IsMonoid ; distrib = ( (λ x y z → dist' {x} {y} {z}) , (λ x y z → dist {y} {z} {x} )) } B-IsCommutativeRing : IsCommutativeRing _⟷_ PLUS TIMES NEG ZERO ONE B-IsCommutativeRing = record { isRing = B-IsRing ; *-comm = λ x y → swap⋆ {x} {y} } -- B-CommutativeRing : CommutativeRing _ _ B-CommutativeRing = record { Carrier = B ; _≈_ = _⟷_ ; _+_ = PLUS ; _*_ = TIMES ; -_ = NEG ; 0# = ZERO ; 1# = ONE ; isCommutativeRing = B-IsCommutativeRing } -- record IsMeadow {a ℓ} {A : Set a} (≈ : Rel A ℓ) (+ * : Op₂ A) (- r : Op₁ A) (0# 1# : A) : Set (a ⊔ ℓ) where open FunctionProperties ≈ field +*-isCommutativeRing : IsCommutativeRing ≈ + * - 0# 1# *-refl-l : ∀ x → ≈ (r (r x)) x *-refl-r : ∀ x → ≈ x (r (r x)) *-ril-l : ∀ x → ≈ (* x (* x (r x))) x *-ril-r : ∀ x → ≈ x (* x (* x (r x))) r-cong : ∀ x y → ≈ x y → ≈ (r x) (r y) record Meadow c ℓ : Set (suc (c ⊔ ℓ)) where field Carrier : Set c _≈_ : Rel Carrier ℓ _+_ : Op₂ Carrier _*_ : Op₂ Carrier -_ : Op₁ Carrier r : Op₁ Carrier 0# : Carrier 1# : Carrier isMeadow : IsMeadow _≈_ _+_ _*_ -_ r 0# 1# B-/IsMeadow : IsMeadow _⟷_ PLUS TIMES NEG RECIP ZERO ONE B-/IsMeadow = record { +*-isCommutativeRing = B-IsCommutativeRing ; *-refl-l = λ x → refe⋆ {x} ; *-refl-r = λ x → sym (refe⋆ {x}) ; *-ril-l = λ x → sym (rili⋆ {x}) ; *-ril-r = λ x → rili⋆ {x} ; r-cong = λ x y → recip {x} {y} } B-/Meadow : Meadow _ _ B-/Meadow = record { Carrier = B ; _≈_ = _⟷_ ; _+_ = PLUS ; _*_ = TIMES ; -_ = NEG ; r = RECIP ; 0# = ZERO ; 1# = ONE ; isMeadow = B-/IsMeadow } ------------------------------------------------------------------------------
{ "alphanum_fraction": 0.5616014559, "avg_line_length": 26.1666666667, "ext": "agda", "hexsha": "1f62762201f0d2ec4cc7575c3db09f4434f55b8a", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2019-09-10T09:47:13.000Z", "max_forks_repo_forks_event_min_datetime": "2016-05-29T01:56:33.000Z", "max_forks_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_forks_repo_licenses": [ "BSD-2-Clause" ], "max_forks_repo_name": "JacquesCarette/pi-dual", "max_forks_repo_path": "agda/PiNF-algebra.agda", "max_issues_count": 4, "max_issues_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_issues_repo_issues_event_max_datetime": "2021-10-29T20:41:23.000Z", "max_issues_repo_issues_event_min_datetime": "2018-06-07T16:27:41.000Z", "max_issues_repo_licenses": [ "BSD-2-Clause" ], "max_issues_repo_name": "JacquesCarette/pi-dual", "max_issues_repo_path": "agda/PiNF-algebra.agda", "max_line_length": 79, "max_stars_count": 14, "max_stars_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_stars_repo_licenses": [ "BSD-2-Clause" ], "max_stars_repo_name": "JacquesCarette/pi-dual", "max_stars_repo_path": "agda/PiNF-algebra.agda", "max_stars_repo_stars_event_max_datetime": "2021-05-05T01:07:57.000Z", "max_stars_repo_stars_event_min_datetime": "2015-08-18T21:40:15.000Z", "num_tokens": 2061, "size": 5495 }
open import Nat open import Prelude module core where -- types data τ̇ : Set where num : τ̇ ⦇-⦈ : τ̇ _==>_ : τ̇ → τ̇ → τ̇ -- expressions, prefixed with a · to distinguish name clashes with agda -- built-ins data ė : Set where _·:_ : ė → τ̇ → ė X : Nat → ė ·λ : Nat → ė → ė N : Nat → ė _·+_ : ė → ė → ė ⦇-⦈ : ė ⦇⌜_⌟⦈ : ė → ė _∘_ : ė → ė → ė ---- contexts and some operations on them -- variables are named with naturals in ė. therefore we represent -- contexts as functions from names for variables (nats) to possible -- bindings. ·ctx : Set ·ctx = Nat → Maybe τ̇ -- convenient shorthand for the (unique up to fun. ext.) empty context ∅ : ·ctx ∅ _ = None -- add a new binding to the context, clobbering anything that might have -- been there before. _,,_ : ·ctx → (Nat × τ̇) → ·ctx (Γ ,, (x , t)) y with natEQ x y (Γ ,, (x , t)) .x | Inl refl = Some t (Γ ,, (x , t)) y | Inr neq = Γ y -- membership, or presence, in a context _∈_ : (p : Nat × τ̇) → (Γ : ·ctx) → Set (x , t) ∈ Γ = (Γ x) == Some t -- apartness for contexts, so that we can follow barendregt's convention _#_ : (n : Nat) → (Γ : ·ctx) → Set x # Γ = (Γ x) == None -- without: remove a variable from a context _/_ : ·ctx → Nat → ·ctx (Γ / x) y with natEQ x y (Γ / x) .x | Inl refl = None (Γ / x) y | Inr neq = Γ y -- the type consistency judgement data _~_ : (t1 : τ̇) → (t2 : τ̇) → Set where TCRefl : {t : τ̇} → t ~ t TCHole1 : {t : τ̇} → t ~ ⦇-⦈ TCHole2 : {t : τ̇} → ⦇-⦈ ~ t TCArr : {t1 t2 t1' t2' : τ̇} → t1 ~ t1' → t2 ~ t2' → (t1 ==> t2) ~ (t1' ==> t2') -- type inconsistency. a judgmental version and associated proofs are in -- judgemental-inconsistency.agda. each definition implies the other, but -- the two are isomorphic only if you treat proofs of inconsistency at -- arrow types as being proof-irrelevant---that is, if you don't -- distinguish between cases where the inconsistency between a pair of -- function types stems from the domain, range, or both. we use the form -- below throughout the rest of the development because we do not care to -- make that distinction. _~̸_ : τ̇ → τ̇ → Set t1 ~̸ t2 = (t1 ~ t2) → ⊥ --- matching for arrows data _▸arr_ : τ̇ → τ̇ → Set where MAHole : ⦇-⦈ ▸arr (⦇-⦈ ==> ⦇-⦈) MAArr : {t1 t2 : τ̇} → (t1 ==> t2) ▸arr (t1 ==> t2) -- matching produces unique answers matcharrunicity : ∀{ t t2 t3 } → t ▸arr t2 → t ▸arr t3 → t2 == t3 matcharrunicity MAHole MAHole = refl matcharrunicity MAArr MAArr = refl -- if a type matches, then it's consistent with the least restrictive -- function type matchconsist : ∀{t t'} → t ▸arr t' → t ~ (⦇-⦈ ==> ⦇-⦈) matchconsist MAHole = TCHole2 matchconsist MAArr = TCArr TCHole1 TCHole1 matchnotnum : ∀{t1 t2} → num ▸arr (t1 ==> t2) → ⊥ matchnotnum () -- bidirectional type checking judgements for ė mutual -- synthesis data _⊢_=>_ : (Γ : ·ctx) → (e : ė) → (t : τ̇) → Set where SAsc : {Γ : ·ctx} {e : ė} {t : τ̇} → Γ ⊢ e <= t → Γ ⊢ (e ·: t) => t SVar : {Γ : ·ctx} {t : τ̇} {n : Nat} → (n , t) ∈ Γ → Γ ⊢ X n => t SAp : {Γ : ·ctx} {e1 e2 : ė} {t t' t2 : τ̇} → Γ ⊢ e1 => t → t ▸arr (t2 ==> t') → Γ ⊢ e2 <= t2 → Γ ⊢ (e1 ∘ e2) => t' SNum : {Γ : ·ctx} {n : Nat} → Γ ⊢ N n => num SPlus : {Γ : ·ctx} {e1 e2 : ė} → Γ ⊢ e1 <= num → Γ ⊢ e2 <= num → Γ ⊢ (e1 ·+ e2) => num SEHole : {Γ : ·ctx} → Γ ⊢ ⦇-⦈ => ⦇-⦈ SNEHole : {Γ : ·ctx} {e : ė} {t : τ̇} → Γ ⊢ e => t → Γ ⊢ ⦇⌜ e ⌟⦈ => ⦇-⦈ -- analysis data _⊢_<=_ : (Γ : ·ctx) → (e : ė) → (t : τ̇) → Set where ASubsume : {Γ : ·ctx} {e : ė} {t t' : τ̇} → Γ ⊢ e => t' → t ~ t' → Γ ⊢ e <= t ALam : {Γ : ·ctx} {e : ė} {t t1 t2 : τ̇} {x : Nat} → x # Γ → t ▸arr (t1 ==> t2) → (Γ ,, (x , t1)) ⊢ e <= t2 → Γ ⊢ (·λ x e) <= t ----- some theorems about the rules and judgement presented so far. -- a variable is apart from any context from which it is removed aar : (Γ : ·ctx) (x : Nat) → x # (Γ / x) aar Γ x with natEQ x x aar Γ x | Inl refl = refl aar Γ x | Inr x≠x = abort (x≠x refl) -- contexts give at most one binding for each variable ctxunicity : {Γ : ·ctx} {n : Nat} {t t' : τ̇} → (n , t) ∈ Γ → (n , t') ∈ Γ → t == t' ctxunicity {n = n} p q with natEQ n n ctxunicity p q | Inl refl = someinj (! p · q) ctxunicity _ _ | Inr x≠x = abort (x≠x refl) -- type consistency is symmetric ~sym : {t1 t2 : τ̇} → t1 ~ t2 → t2 ~ t1 ~sym TCRefl = TCRefl ~sym TCHole1 = TCHole2 ~sym TCHole2 = TCHole1 ~sym (TCArr p1 p2) = TCArr (~sym p1) (~sym p2) -- type consistency isn't transitive not-trans : ((t1 t2 t3 : τ̇) → t1 ~ t2 → t2 ~ t3 → t1 ~ t3) → ⊥ not-trans t with t (num ==> num) ⦇-⦈ num TCHole1 TCHole2 ... | () -- if the domain or codomain of a pair of arrows isn't consistent, the -- whole arrow isn't consistent. lemarr1 : {t1 t2 t3 t4 : τ̇} → (t1 ~ t3 → ⊥) → (t1 ==> t2) ~ (t3 ==> t4) → ⊥ lemarr1 v TCRefl = v TCRefl lemarr1 v (TCArr p _) = v p lemarr2 : {t1 t2 t3 t4 : τ̇} → (t2 ~ t4 → ⊥) → (t1 ==> t2) ~ (t3 ==> t4) → ⊥ lemarr2 v TCRefl = v TCRefl lemarr2 v (TCArr _ p) = v p -- every pair of types is either consistent or not consistent ~dec : (t1 t2 : τ̇) → ((t1 ~ t2) + (t1 ~̸ t2)) -- this takes care of all hole cases, so we don't consider them below ~dec _ ⦇-⦈ = Inl TCHole1 ~dec ⦇-⦈ _ = Inl TCHole2 -- num cases ~dec num num = Inl TCRefl ~dec num (t2 ==> t3) = Inr (λ ()) -- arrow cases ~dec (t1 ==> t2) num = Inr (λ ()) ~dec (t1 ==> t2) (t3 ==> t4) with ~dec t1 t3 | ~dec t2 t4 ... | Inl x | Inl y = Inl (TCArr x y) ... | Inl _ | Inr y = Inr (lemarr2 y) ... | Inr x | _ = Inr (lemarr1 x) -- theorem: no pair of types is both consistent and not consistent. this -- is immediate from our encoding of the ~̸ judgement in the formalism -- here; in the exact mathematics presented in the paper, this would -- require induction to relate the two judgements. ~apart : {t1 t2 : τ̇} → (t1 ~̸ t2) → (t1 ~ t2) → ⊥ ~apart v p = v p -- synthesis only produces equal types. note that there is no need for an -- analagous theorem for analytic positions because we think of -- the type as an input synthunicity : {Γ : ·ctx} {e : ė} {t t' : τ̇} → (Γ ⊢ e => t) → (Γ ⊢ e => t') → t == t' synthunicity (SAsc _) (SAsc _) = refl synthunicity {Γ = G} (SVar in1) (SVar in2) = ctxunicity {Γ = G} in1 in2 synthunicity (SAp D1 MAHole b) (SAp D2 MAHole y) = refl synthunicity (SAp D1 MAHole b) (SAp D2 MAArr y) with synthunicity D1 D2 ... | () synthunicity (SAp D1 MAArr b) (SAp D2 MAHole y) with synthunicity D1 D2 ... | () synthunicity (SAp D1 MAArr b) (SAp D2 MAArr y) with synthunicity D1 D2 ... | refl = refl synthunicity SNum SNum = refl synthunicity (SPlus _ _ ) (SPlus _ _ ) = refl synthunicity SEHole SEHole = refl synthunicity (SNEHole _) (SNEHole _) = refl ----- the zippered form of the forms above and the rules for actions on them -- those types without holes anywhere tcomplete : τ̇ → Set tcomplete num = ⊤ tcomplete ⦇-⦈ = ⊥ tcomplete (t1 ==> t2) = (tcomplete t1) × (tcomplete t2) -- similarly to the complete types, the complete expressions ecomplete : ė → Set ecomplete (e1 ·: t) = ecomplete e1 × tcomplete t ecomplete (X _) = ⊤ ecomplete (·λ _ e1) = ecomplete e1 ecomplete (N x) = ⊤ ecomplete (e1 ·+ e2) = ecomplete e1 × ecomplete e2 ecomplete ⦇-⦈ = ⊥ ecomplete ⦇⌜ e1 ⌟⦈ = ⊥ ecomplete (e1 ∘ e2) = ecomplete e1 × ecomplete e2 -- zippered form of types data τ̂ : Set where ▹_◃ : τ̇ → τ̂ _==>₁_ : τ̂ → τ̇ → τ̂ _==>₂_ : τ̇ → τ̂ → τ̂ -- zippered form of expressions data ê : Set where ▹_◃ : ė → ê _·:₁_ : ê → τ̇ → ê _·:₂_ : ė → τ̂ → ê ·λ : Nat → ê → ê _∘₁_ : ê → ė → ê _∘₂_ : ė → ê → ê _·+₁_ : ê → ė → ê _·+₂_ : ė → ê → ê ⦇⌜_⌟⦈ : ê → ê -- erasure of cursor for types and expressions, judgementally. see -- jugemental-erase.agda for an argument that this defines an isomorphic -- object to the direct metafunction provided in the text of the paper data erase-t : τ̂ → τ̇ → Set where ETTop : ∀{t} → erase-t (▹ t ◃) t ETArrL : ∀{t1 t1' t2} → erase-t t1 t1' → erase-t (t1 ==>₁ t2) (t1' ==> t2) ETArrR : ∀{t1 t2 t2'} → erase-t t2 t2' → erase-t (t1 ==>₂ t2) (t1 ==> t2') data erase-e : ê → ė → Set where EETop : ∀{x} → erase-e (▹ x ◃) x EEAscL : ∀{e e' t} → erase-e e e' → erase-e (e ·:₁ t) (e' ·: t) EEAscR : ∀{e t t'} → erase-t t t' → erase-e (e ·:₂ t) (e ·: t') EELam : ∀{x e e'} → erase-e e e' → erase-e (·λ x e) (·λ x e') EEApL : ∀{e1 e1' e2} → erase-e e1 e1' → erase-e (e1 ∘₁ e2) (e1' ∘ e2) EEApR : ∀{e1 e2 e2'} → erase-e e2 e2' → erase-e (e1 ∘₂ e2) (e1 ∘ e2') EEPlusL : ∀{e1 e1' e2} → erase-e e1 e1' → erase-e (e1 ·+₁ e2) (e1' ·+ e2) EEPlusR : ∀{e1 e2 e2'} → erase-e e2 e2' → erase-e (e1 ·+₂ e2) (e1 ·+ e2') EENEHole : ∀{e e'} → erase-e e e' → erase-e ⦇⌜ e ⌟⦈ ⦇⌜ e' ⌟⦈ -- the three grammars that define actions data direction : Set where child : Nat → direction parent : direction data shape : Set where arrow : shape num : shape asc : shape var : Nat → shape lam : Nat → shape ap : shape numlit : Nat → shape plus : shape nehole : shape data action : Set where move : direction → action construct : shape → action del : action finish : action -- type actions data _+_+>_ : (t : τ̂) → (α : action) → (t' : τ̂) → Set where TMArrChild1 : {t1 t2 : τ̇} → ▹ t1 ==> t2 ◃ + move (child 1) +> (▹ t1 ◃ ==>₁ t2) TMArrChild2 : {t1 t2 : τ̇} → ▹ t1 ==> t2 ◃ + move (child 2) +> (t1 ==>₂ ▹ t2 ◃) TMArrParent1 : {t1 t2 : τ̇} → (▹ t1 ◃ ==>₁ t2) + move parent +> ▹ t1 ==> t2 ◃ TMArrParent2 : {t1 t2 : τ̇} → (t1 ==>₂ ▹ t2 ◃) + move parent +> ▹ t1 ==> t2 ◃ TMDel : {t : τ̇} → (▹ t ◃) + del +> (▹ ⦇-⦈ ◃) TMConArrow : {t : τ̇} → (▹ t ◃) + construct arrow +> (t ==>₂ ▹ ⦇-⦈ ◃) TMConNum : (▹ ⦇-⦈ ◃) + construct num +> (▹ num ◃) TMArrZip1 : {t1 t1' : τ̂} {t2 : τ̇} {α : action} → (t1 + α +> t1') → ((t1 ==>₁ t2) + α +> (t1' ==>₁ t2)) TMArrZip2 : {t2 t2' : τ̂} {t1 : τ̇} {α : action} → (t2 + α +> t2') → ((t1 ==>₂ t2) + α +> (t1 ==>₂ t2')) -- expression movement data _+_+>e_ : (e : ê) → (α : action) → (e' : ê) → Set where -- rules for ascriptions EMAscChild1 : {e : ė} {t : τ̇} → (▹ e ·: t ◃) + move (child 1) +>e (▹ e ◃ ·:₁ t) EMAscChild2 : {e : ė} {t : τ̇} → (▹ e ·: t ◃) + move (child 2) +>e (e ·:₂ ▹ t ◃) EMAscParent1 : {e : ė} {t : τ̇} → (▹ e ◃ ·:₁ t) + move parent +>e (▹ e ·: t ◃) EMAscParent2 : {e : ė} {t : τ̇} → (e ·:₂ ▹ t ◃) + move parent +>e (▹ e ·: t ◃) -- rules for lambdas EMLamChild1 : {e : ė} {x : Nat} → ▹ (·λ x e) ◃ + move (child 1) +>e ·λ x (▹ e ◃) EMLamParent : {e : ė} {x : Nat} → ·λ x (▹ e ◃) + move parent +>e ▹ (·λ x e) ◃ -- rules for 2-ary constructors EMPlusChild1 : {e1 e2 : ė} → (▹ e1 ·+ e2 ◃) + move (child 1) +>e (▹ e1 ◃ ·+₁ e2) EMPlusChild2 : {e1 e2 : ė} → (▹ e1 ·+ e2 ◃) + move (child 2) +>e (e1 ·+₂ ▹ e2 ◃) EMPlusParent1 : {e1 e2 : ė} → (▹ e1 ◃ ·+₁ e2) + move parent +>e (▹ e1 ·+ e2 ◃) EMPlusParent2 : {e1 e2 : ė} → (e1 ·+₂ ▹ e2 ◃) + move parent +>e (▹ e1 ·+ e2 ◃) EMApChild1 : {e1 e2 : ė} → (▹ e1 ∘ e2 ◃) + move (child 1)+>e (▹ e1 ◃ ∘₁ e2) EMApChild2 : {e1 e2 : ė} → (▹ e1 ∘ e2 ◃) + move (child 2) +>e (e1 ∘₂ ▹ e2 ◃) EMApParent1 : {e1 e2 : ė} → (▹ e1 ◃ ∘₁ e2) + move parent +>e (▹ e1 ∘ e2 ◃) EMApParent2 : {e1 e2 : ė} → (e1 ∘₂ ▹ e2 ◃) + move parent +>e (▹ e1 ∘ e2 ◃) -- rules for non-empty holes EMNEHoleChild1 : {e : ė} → (▹ ⦇⌜ e ⌟⦈ ◃) + move (child 1) +>e ⦇⌜ ▹ e ◃ ⌟⦈ EMNEHoleParent : {e : ė} → ⦇⌜ ▹ e ◃ ⌟⦈ + move parent +>e (▹ ⦇⌜ e ⌟⦈ ◃) mutual -- synthetic action expressions data _⊢_=>_~_~>_=>_ : (Γ : ·ctx) → (e1 : ê) → (t1 : τ̇) → (α : action) → (e2 : ê) → (t2 : τ̇) → Set where SAMove : {δ : direction} {e e' : ê} {Γ : ·ctx} {t : τ̇} → (e + move δ +>e e') → Γ ⊢ e => t ~ move δ ~> e' => t SADel : {Γ : ·ctx} {e : ė} {t : τ̇} → Γ ⊢ ▹ e ◃ => t ~ del ~> ▹ ⦇-⦈ ◃ => ⦇-⦈ SAConAsc : {Γ : ·ctx} {e : ė} {t : τ̇} → Γ ⊢ ▹ e ◃ => t ~ construct asc ~> (e ·:₂ ▹ t ◃ ) => t SAConVar : {Γ : ·ctx} {x : Nat} {t : τ̇} → (p : (x , t) ∈ Γ) → Γ ⊢ ▹ ⦇-⦈ ◃ => ⦇-⦈ ~ construct (var x) ~> ▹ X x ◃ => t SAConLam : {Γ : ·ctx} {x : Nat} → (x # Γ) → Γ ⊢ ▹ ⦇-⦈ ◃ => ⦇-⦈ ~ construct (lam x) ~> ((·λ x ⦇-⦈) ·:₂ (▹ ⦇-⦈ ◃ ==>₁ ⦇-⦈)) => (⦇-⦈ ==> ⦇-⦈) SAConApArr : {Γ : ·ctx} {t t1 t2 : τ̇} {e : ė} → t ▸arr (t1 ==> t2) → Γ ⊢ ▹ e ◃ => t ~ construct ap ~> e ∘₂ ▹ ⦇-⦈ ◃ => t2 SAConApOtw : {Γ : ·ctx} {t : τ̇} {e : ė} → (t ~̸ (⦇-⦈ ==> ⦇-⦈)) → Γ ⊢ ▹ e ◃ => t ~ construct ap ~> ⦇⌜ e ⌟⦈ ∘₂ ▹ ⦇-⦈ ◃ => ⦇-⦈ SAConNumlit : {Γ : ·ctx} {n : Nat} → Γ ⊢ ▹ ⦇-⦈ ◃ => ⦇-⦈ ~ construct (numlit n) ~> ▹ N n ◃ => num SAConPlus1 : {Γ : ·ctx} {e : ė} {t : τ̇} → (t ~ num) → Γ ⊢ ▹ e ◃ => t ~ construct plus ~> e ·+₂ ▹ ⦇-⦈ ◃ => num SAConPlus2 : {Γ : ·ctx} {e : ė} {t : τ̇} → (t ~̸ num) → Γ ⊢ ▹ e ◃ => t ~ construct plus ~> ⦇⌜ e ⌟⦈ ·+₂ ▹ ⦇-⦈ ◃ => num SAConNEHole : {Γ : ·ctx} {e : ė} {t : τ̇} → Γ ⊢ ▹ e ◃ => t ~ construct nehole ~> ⦇⌜ ▹ e ◃ ⌟⦈ => ⦇-⦈ SAFinish : {Γ : ·ctx} {e : ė} {t : τ̇} → (Γ ⊢ e => t) → Γ ⊢ ▹ ⦇⌜ e ⌟⦈ ◃ => ⦇-⦈ ~ finish ~> ▹ e ◃ => t SAZipAsc1 : {Γ : ·ctx} {e e' : ê} {α : action} {t : τ̇} → (Γ ⊢ e ~ α ~> e' ⇐ t) → Γ ⊢ (e ·:₁ t) => t ~ α ~> (e' ·:₁ t) => t SAZipAsc2 : {Γ : ·ctx} {e : ė} {α : action} {t t' : τ̂} {t◆ t'◆ : τ̇} → (t + α +> t') → (erase-t t' t'◆) → (erase-t t t◆) → (Γ ⊢ e <= t'◆) → Γ ⊢ (e ·:₂ t) => t◆ ~ α ~> (e ·:₂ t') => t'◆ SAZipApArr : {Γ : ·ctx} {t t1 t2 t3 t4 : τ̇} {α : action} {eh eh' : ê} {e eh◆ : ė} → (t ▸arr (t3 ==> t4)) → (erase-e eh eh◆) → (Γ ⊢ (eh◆) => t2) → (Γ ⊢ eh => t2 ~ α ~> eh' => t) → (Γ ⊢ e <= t3) → Γ ⊢ (eh ∘₁ e) => t1 ~ α ~> (eh' ∘₁ e) => t4 SAZipApAna : {Γ : ·ctx} {t' t2 t : τ̇} {e : ė} {eh eh' : ê} {α : action} → (t' ▸arr (t2 ==> t)) → (Γ ⊢ e => t') → (Γ ⊢ eh ~ α ~> eh' ⇐ t2) → Γ ⊢ (e ∘₂ eh) => t ~ α ~> (e ∘₂ eh') => t SAZipPlus1 : {Γ : ·ctx} {e : ė} {eh eh' : ê} {α : action} → (Γ ⊢ eh ~ α ~> eh' ⇐ num) → Γ ⊢ (eh ·+₁ e) => num ~ α ~> (eh' ·+₁ e) => num SAZipPlus2 : {Γ : ·ctx} {e : ė} {eh eh' : ê} {α : action} → (Γ ⊢ eh ~ α ~> eh' ⇐ num) → Γ ⊢ (e ·+₂ eh) => num ~ α ~> (e ·+₂ eh') => num SAZipHole : {Γ : ·ctx} {e e' : ê} {t t' : τ̇} {α : action} {e◆ : ė} → (erase-e e e◆) → (Γ ⊢ e◆ => t) → (Γ ⊢ e => t ~ α ~> e' => t') → Γ ⊢ ⦇⌜ e ⌟⦈ => ⦇-⦈ ~ α ~> ⦇⌜ e' ⌟⦈ => ⦇-⦈ -- analytic action expressions data _⊢_~_~>_⇐_ : (Γ : ·ctx) → (e : ê) → (α : action) → (e' : ê) → (t : τ̇) → Set where AASubsume : {Γ : ·ctx} {e e' : ê} {t t' t'' : τ̇} {α : action} {e◆ : ė} → (erase-e e e◆) → (Γ ⊢ e◆ => t') → (Γ ⊢ e => t' ~ α ~> e' => t'') → (t ~ t'') → Γ ⊢ e ~ α ~> e' ⇐ t AAMove : {e e' : ê} {δ : direction} {Γ : ·ctx} {t : τ̇} → (e + move δ +>e e') → Γ ⊢ e ~ move δ ~> e' ⇐ t AADel : {e : ė} {Γ : ·ctx} {t : τ̇} → Γ ⊢ ▹ e ◃ ~ del ~> ▹ ⦇-⦈ ◃ ⇐ t AAConAsc : {Γ : ·ctx} {e : ė} {t : τ̇} → Γ ⊢ ▹ e ◃ ~ construct asc ~> (e ·:₂ ▹ t ◃) ⇐ t AAConVar : {Γ : ·ctx} {t t' : τ̇} {x : Nat} → (t ~̸ t') → (p : (x , t') ∈ Γ) → Γ ⊢ ▹ ⦇-⦈ ◃ ~ construct (var x) ~> ⦇⌜ ▹ X x ◃ ⌟⦈ ⇐ t AAConLam1 : {Γ : ·ctx} {x : Nat} {t t1 t2 : τ̇} → (x # Γ) → (t ▸arr (t1 ==> t2)) → Γ ⊢ ▹ ⦇-⦈ ◃ ~ construct (lam x) ~> ·λ x (▹ ⦇-⦈ ◃) ⇐ t AAConLam2 : {Γ : ·ctx} {x : Nat} {t : τ̇} → (x # Γ) → (t ~̸ (⦇-⦈ ==> ⦇-⦈)) → Γ ⊢ ▹ ⦇-⦈ ◃ ~ construct (lam x) ~> ⦇⌜ ·λ x ⦇-⦈ ·:₂ (▹ ⦇-⦈ ◃ ==>₁ ⦇-⦈) ⌟⦈ ⇐ t AAConNumlit : {Γ : ·ctx} {t : τ̇} {n : Nat} → (t ~̸ num) → Γ ⊢ ▹ ⦇-⦈ ◃ ~ construct (numlit n) ~> ⦇⌜ ▹ (N n) ◃ ⌟⦈ ⇐ t AAFinish : {Γ : ·ctx} {e : ė} {t : τ̇} → (Γ ⊢ e <= t) → Γ ⊢ ▹ ⦇⌜ e ⌟⦈ ◃ ~ finish ~> ▹ e ◃ ⇐ t AAZipLam : {Γ : ·ctx} {x : Nat} {t t1 t2 : τ̇} {e e' : ê} {α : action} → x # Γ → (t ▸arr (t1 ==> t2)) → ((Γ ,, (x , t1)) ⊢ e ~ α ~> e' ⇐ t2) → Γ ⊢ (·λ x e) ~ α ~> (·λ x e') ⇐ t
{ "alphanum_fraction": 0.4077968295, "avg_line_length": 39.0442105263, "ext": "agda", "hexsha": "0dc9c5dcc182723d6247555fe7cc8fc936c1ad8c", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-07-03T03:45:07.000Z", "max_forks_repo_forks_event_min_datetime": "2021-07-03T03:45:07.000Z", "max_forks_repo_head_hexsha": "db3d21a1e3f17ef77ad557ed12374979f381b6b7", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "hazelgrove/agda-popl17", "max_forks_repo_path": "core.agda", "max_issues_count": 37, "max_issues_repo_head_hexsha": "db3d21a1e3f17ef77ad557ed12374979f381b6b7", "max_issues_repo_issues_event_max_datetime": "2016-11-09T18:13:55.000Z", "max_issues_repo_issues_event_min_datetime": "2016-07-07T16:23:11.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "hazelgrove/agda-popl17", "max_issues_repo_path": "core.agda", "max_line_length": 92, "max_stars_count": 14, "max_stars_repo_head_hexsha": "db3d21a1e3f17ef77ad557ed12374979f381b6b7", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "hazelgrove/agda-popl17", "max_stars_repo_path": "core.agda", "max_stars_repo_stars_event_max_datetime": "2019-07-11T12:30:50.000Z", "max_stars_repo_stars_event_min_datetime": "2016-07-01T22:44:11.000Z", "num_tokens": 8452, "size": 18546 }
{-# OPTIONS --rewriting #-} module Properties.DecSubtyping where open import Agda.Builtin.Equality using (_≡_; refl) open import FFI.Data.Either using (Either; Left; Right; mapLR; swapLR; cond) open import Luau.FunctionTypes using (src; srcⁿ; tgt) open import Luau.Subtyping using (_<:_; _≮:_; Tree; Language; ¬Language; witness; unknown; never; scalar; function; scalar-function; scalar-function-ok; scalar-function-err; scalar-scalar; function-scalar; function-ok; function-err; left; right; _,_) open import Luau.Type using (Type; Scalar; nil; number; string; boolean; never; unknown; _⇒_; _∪_; _∩_) open import Properties.Contradiction using (CONTRADICTION; ¬) open import Properties.Functions using (_∘_) open import Properties.Subtyping using (<:-refl; <:-trans; ≮:-trans-<:; <:-trans-≮:; <:-never; <:-unknown; <:-∪-left; <:-∪-right; <:-∪-lub; ≮:-∪-left; ≮:-∪-right; <:-∩-left; <:-∩-right; <:-∩-glb; ≮:-∩-left; ≮:-∩-right; dec-language; scalar-<:; <:-everything; <:-function; ≮:-function-left; ≮:-function-right) open import Properties.TypeNormalization using (FunType; Normal; never; unknown; _∩_; _∪_; _⇒_; normal; <:-normalize; normalize-<:) open import Properties.FunctionTypes using (fun-¬scalar; ¬fun-scalar; fun-function; src-unknown-≮:; tgt-never-≮:; src-tgtᶠ-<:) open import Properties.Equality using (_≢_) -- Honest this terminates, since src and tgt reduce the depth of nested arrows {-# TERMINATING #-} dec-subtypingˢⁿ : ∀ {T U} → Scalar T → Normal U → Either (T ≮: U) (T <: U) dec-subtypingᶠ : ∀ {T U} → FunType T → FunType U → Either (T ≮: U) (T <: U) dec-subtypingᶠⁿ : ∀ {T U} → FunType T → Normal U → Either (T ≮: U) (T <: U) dec-subtypingⁿ : ∀ {T U} → Normal T → Normal U → Either (T ≮: U) (T <: U) dec-subtyping : ∀ T U → Either (T ≮: U) (T <: U) dec-subtypingˢⁿ T U with dec-language _ (scalar T) dec-subtypingˢⁿ T U | Left p = Left (witness (scalar T) (scalar T) p) dec-subtypingˢⁿ T U | Right p = Right (scalar-<: T p) dec-subtypingᶠ {T = T} _ (U ⇒ V) with dec-subtypingⁿ U (normal (src T)) | dec-subtypingⁿ (normal (tgt T)) V dec-subtypingᶠ {T = T} _ (U ⇒ V) | Left p | q = Left (≮:-trans-<: (src-unknown-≮: (≮:-trans-<: p (<:-normalize (src T)))) (<:-function <:-refl <:-unknown)) dec-subtypingᶠ {T = T} _ (U ⇒ V) | Right p | Left q = Left (≮:-trans-<: (tgt-never-≮: (<:-trans-≮: (normalize-<: (tgt T)) q)) (<:-trans (<:-function <:-never <:-refl) <:-∪-right)) dec-subtypingᶠ T (U ⇒ V) | Right p | Right q = Right (src-tgtᶠ-<: T (<:-trans p (normalize-<: _)) (<:-trans (<:-normalize _) q)) dec-subtypingᶠ T (U ∩ V) with dec-subtypingᶠ T U | dec-subtypingᶠ T V dec-subtypingᶠ T (U ∩ V) | Left p | q = Left (≮:-∩-left p) dec-subtypingᶠ T (U ∩ V) | Right p | Left q = Left (≮:-∩-right q) dec-subtypingᶠ T (U ∩ V) | Right p | Right q = Right (<:-∩-glb p q) dec-subtypingᶠⁿ T never = Left (witness function (fun-function T) never) dec-subtypingᶠⁿ T unknown = Right <:-unknown dec-subtypingᶠⁿ T (U ⇒ V) = dec-subtypingᶠ T (U ⇒ V) dec-subtypingᶠⁿ T (U ∩ V) = dec-subtypingᶠ T (U ∩ V) dec-subtypingᶠⁿ T (U ∪ V) with dec-subtypingᶠⁿ T U dec-subtypingᶠⁿ T (U ∪ V) | Left (witness t p q) = Left (witness t p (q , ¬fun-scalar V T p)) dec-subtypingᶠⁿ T (U ∪ V) | Right p = Right (<:-trans p <:-∪-left) dec-subtypingⁿ never U = Right <:-never dec-subtypingⁿ unknown unknown = Right <:-refl dec-subtypingⁿ unknown U with dec-subtypingᶠⁿ (never ⇒ unknown) U dec-subtypingⁿ unknown U | Left p = Left (<:-trans-≮: <:-unknown p) dec-subtypingⁿ unknown U | Right p₁ with dec-subtypingˢⁿ number U dec-subtypingⁿ unknown U | Right p₁ | Left p = Left (<:-trans-≮: <:-unknown p) dec-subtypingⁿ unknown U | Right p₁ | Right p₂ with dec-subtypingˢⁿ string U dec-subtypingⁿ unknown U | Right p₁ | Right p₂ | Left p = Left (<:-trans-≮: <:-unknown p) dec-subtypingⁿ unknown U | Right p₁ | Right p₂ | Right p₃ with dec-subtypingˢⁿ nil U dec-subtypingⁿ unknown U | Right p₁ | Right p₂ | Right p₃ | Left p = Left (<:-trans-≮: <:-unknown p) dec-subtypingⁿ unknown U | Right p₁ | Right p₂ | Right p₃ | Right p₄ with dec-subtypingˢⁿ boolean U dec-subtypingⁿ unknown U | Right p₁ | Right p₂ | Right p₃ | Right p₄ | Left p = Left (<:-trans-≮: <:-unknown p) dec-subtypingⁿ unknown U | Right p₁ | Right p₂ | Right p₃ | Right p₄ | Right p₅ = Right (<:-trans <:-everything (<:-∪-lub p₁ (<:-∪-lub p₂ (<:-∪-lub p₃ (<:-∪-lub p₄ p₅))))) dec-subtypingⁿ (S ⇒ T) U = dec-subtypingᶠⁿ (S ⇒ T) U dec-subtypingⁿ (S ∩ T) U = dec-subtypingᶠⁿ (S ∩ T) U dec-subtypingⁿ (S ∪ T) U with dec-subtypingⁿ S U | dec-subtypingˢⁿ T U dec-subtypingⁿ (S ∪ T) U | Left p | q = Left (≮:-∪-left p) dec-subtypingⁿ (S ∪ T) U | Right p | Left q = Left (≮:-∪-right q) dec-subtypingⁿ (S ∪ T) U | Right p | Right q = Right (<:-∪-lub p q) dec-subtyping T U with dec-subtypingⁿ (normal T) (normal U) dec-subtyping T U | Left p = Left (<:-trans-≮: (normalize-<: T) (≮:-trans-<: p (<:-normalize U))) dec-subtyping T U | Right p = Right (<:-trans (<:-normalize T) (<:-trans p (normalize-<: U)))
{ "alphanum_fraction": 0.6456104945, "avg_line_length": 69.7887323944, "ext": "agda", "hexsha": "332520a947967568e5e1e0ca0d16d984005e93eb", "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": "72d8d443431875607fd457a13fe36ea62804d327", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "TheGreatSageEqualToHeaven/luau", "max_forks_repo_path": "prototyping/Properties/DecSubtyping.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "72d8d443431875607fd457a13fe36ea62804d327", "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": "TheGreatSageEqualToHeaven/luau", "max_issues_repo_path": "prototyping/Properties/DecSubtyping.agda", "max_line_length": 310, "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/Properties/DecSubtyping.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": 1905, "size": 4955 }
record category { ℓ₀ ℓ₁ } { k : Set ℓ₀ } (_⇒_ : k → k → Set ℓ₁) : Set (lsuc lzero ⊔ ℓ₀ ⊔ ℓ₁) record groupoid { ℓ₀ ℓ₁ } { k : Set ℓ₀ } (_≈_ : k → k → Set ℓ₁) : Set (lsuc lzero ⊔ ℓ₀ ⊔ ℓ₁) record groupoid { ℓ₀ ℓ₁ } { k } _≈_ where coinductive field ⦃ cat ⦄ : category _≈_ field symmetry : ∀ { x y } → x ≈ y → y ≈ x record category { ℓ₀ ℓ₁ } { k } _⇒_ where coinductive field id : ∀ { a } → a ⇒ a _∘_ : ∀ { a b c } → b ⇒ c → a ⇒ b → a ⇒ c field _≈_ : { a b : k } → (f g : a ⇒ b) → Set ⦃ hom ⦄ : { a b : k } → groupoid { k = a ⇒ b } _≈_ field lunit : ∀ { a b } { x : a ⇒ b } → (id ∘ x) ≈ x runit : ∀ { a b } { x : a ⇒ b } → (x ∘ id) ≈ x assoc : ∀ { a b c d } { x : c ⇒ d } { y : b ⇒ c } { z : a ⇒ b } → (x ∘ (y ∘ z)) ≈ ((x ∘ y) ∘ z) open category ⦃ ... ⦄ open groupoid ⦃ ... ⦄
{ "alphanum_fraction": 0.3894500561, "avg_line_length": 35.64, "ext": "agda", "hexsha": "82ef0beb90dcd46c85ff8356a2f841f1a8d51c17", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "9fd9fbf9f265bf526a2ec83e9442dedc7106b80c", "max_forks_repo_licenses": [ "CC0-1.0" ], "max_forks_repo_name": "seanwestfall/agda_explorations", "max_forks_repo_path": "src/categories.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "9fd9fbf9f265bf526a2ec83e9442dedc7106b80c", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "CC0-1.0" ], "max_issues_repo_name": "seanwestfall/agda_explorations", "max_issues_repo_path": "src/categories.agda", "max_line_length": 99, "max_stars_count": null, "max_stars_repo_head_hexsha": "9fd9fbf9f265bf526a2ec83e9442dedc7106b80c", "max_stars_repo_licenses": [ "CC0-1.0" ], "max_stars_repo_name": "seanwestfall/agda_explorations", "max_stars_repo_path": "src/categories.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 426, "size": 891 }
module Data.List.Membership.Propositional.Instances where open import Data.List using (List; _∷_) open import Data.List.Relation.Unary.Any using (here; there) open import Data.List.Membership.Propositional using (_∈_) open import Relation.Binary.PropositionalEquality using (refl) open import Level using (Level) private variable a : Level A : Set a x y : A xs : List A instance ⦃here⦄ : x ∈ x ∷ xs ⦃here⦄ = here refl ⦃there⦄ : ⦃ x ∈ xs ⦄ → x ∈ y ∷ xs ⦃there⦄ ⦃ x∈xs ⦄ = there x∈xs
{ "alphanum_fraction": 0.6737864078, "avg_line_length": 21.4583333333, "ext": "agda", "hexsha": "b5481e594e8803a5306cf847bf7d10993b1c922e", "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": "921a0dc44a69a74391031ca61568c624ab7f9c94", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "johnyob/agda-union", "max_forks_repo_path": "src/Data/List/Membership/Propositional/Instances.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "921a0dc44a69a74391031ca61568c624ab7f9c94", "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": "johnyob/agda-union", "max_issues_repo_path": "src/Data/List/Membership/Propositional/Instances.agda", "max_line_length": 62, "max_stars_count": null, "max_stars_repo_head_hexsha": "921a0dc44a69a74391031ca61568c624ab7f9c94", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "johnyob/agda-union", "max_stars_repo_path": "src/Data/List/Membership/Propositional/Instances.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 183, "size": 515 }
{-# OPTIONS --safe --warning=error #-} open import Setoids.Setoids open import Groups.FreeGroup.Definition open import Groups.Definition open import Decidable.Sets open import Numbers.Naturals.Order open import LogicalFormulae open import Semirings.Definition module Groups.FreeGroup.Group {a : _} {A : Set a} (decA : DecidableSet A) where open import Groups.FreeGroup.Word decA prepend : ReducedWord → FreeCompletion A → ReducedWord prepend empty x = prependLetter x empty (wordEmpty refl) prepend (prependLetter (ofLetter y) w pr) (ofLetter x) = prependLetter (ofLetter x) (prependLetter (ofLetter y) w pr) (wordEnding (succIsPositive _) (freeCompletionEqualFalse decA {ofLetter x} {ofInv x} λ ())) prepend (prependLetter (ofInv y) w pr) (ofLetter x) with decA x y ... | inl x=y = w ... | inr x!=y = prependLetter (ofLetter x) (prependLetter (ofInv y) w pr) (wordEnding (succIsPositive _) (freeCompletionEqualFalse decA {ofLetter x} {ofLetter y} λ pr → x!=y (ofLetterInjective pr))) prepend (prependLetter (ofLetter y) w pr) (ofInv x) with decA x y ... | inl x=y = w ... | inr x!=y = prependLetter (ofInv x) (prependLetter (ofLetter y) w pr) (wordEnding (succIsPositive _) (freeCompletionEqualFalse decA λ pr → x!=y (ofInvInjective pr))) prepend (prependLetter (ofInv y) w pr) (ofInv x) = prependLetter (ofInv x) (prependLetter (ofInv y) w pr) (wordEnding (succIsPositive _) (freeCompletionEqualFalse decA {ofInv x} {ofLetter x} (λ ()))) _+W_ : ReducedWord → ReducedWord → ReducedWord empty +W b = b prependLetter letter a x +W b = prepend (a +W b) letter prependValid : (w : ReducedWord) (l : A) → (x : PrependIsValid w (ofLetter l)) → prepend w (ofLetter l) ≡ prependLetter (ofLetter l) w x prependValid empty l (wordEmpty refl) = refl prependValid (prependLetter (ofLetter l2) w x) l pr = prependLetterRefl prependValid (prependLetter (ofInv l2) w x) l pr with decA l l2 prependValid (prependLetter (ofInv l2) w x) .l2 (wordEnding _ x1) | inl refl = exFalso (freeCompletionEqualFalse' decA x1 refl) ... | inr l!=l2 = prependLetterRefl prependValid' : (w : ReducedWord) (l : A) → (x : PrependIsValid w (ofInv l)) → prepend w (ofInv l) ≡ prependLetter (ofInv l) w x prependValid' empty l (wordEmpty refl) = refl prependValid' (prependLetter (ofLetter l2) w x) l pr with decA l l2 prependValid' (prependLetter (ofLetter l2) w x) .l2 (wordEnding _ x1) | inl refl = exFalso (freeCompletionEqualFalse' decA x1 refl) ... | inr l!=l2 = prependLetterRefl prependValid' (prependLetter (ofInv l2) w x) l pr = prependLetterRefl prependInv : (w : ReducedWord) (l : A) → prepend (prepend w (ofLetter l)) (ofInv l) ≡ w prependInv empty l with decA l l ... | inl l=l = refl ... | inr l!=l = exFalso (l!=l refl) prependInv (prependLetter (ofLetter l2) w x) l with decA l l ... | inl l=l = refl ... | inr l!=l = exFalso (l!=l refl) prependInv (prependLetter (ofInv l2) w x) l with decA l l2 prependInv (prependLetter (ofInv l2) w x) .l2 | inl refl = prependValid' w l2 x ... | inr l!=l2 with decA l l prependInv (prependLetter (ofInv l2) w x) l | inr l!=l2 | inl refl = refl prependInv (prependLetter (ofInv l2) w x) l | inr l!=l2 | inr bad = exFalso (bad refl) prependInv' : (w : ReducedWord) (l : A) → prepend (prepend w (ofInv l)) (ofLetter l) ≡ w prependInv' empty l with decA l l ... | inl l=l = refl ... | inr l!=l = exFalso (l!=l refl) prependInv' (prependLetter (ofLetter l2) w x) l with decA l l2 prependInv' (prependLetter (ofLetter l2) w x) .l2 | inl refl = prependValid w l2 x ... | inr l!=l2 with decA l l ... | inl refl = refl ... | inr l!=l = exFalso (l!=l refl) prependInv' (prependLetter (ofInv l2) w x) l with decA l l prependInv' (prependLetter (ofInv l2) w x) l | inl refl = refl prependInv' (prependLetter (ofInv l2) w x) l | inr l!=l = exFalso (l!=l refl) prependAndAdd : (a b : ReducedWord) (l : FreeCompletion A) → prepend (a +W b) l ≡ (prepend a l) +W b prependAndAdd empty b l = refl prependAndAdd (prependLetter (ofLetter x) w pr) b (ofLetter y) = refl prependAndAdd (prependLetter (ofLetter x) w pr) b (ofInv y) with decA y x prependAndAdd (prependLetter (ofLetter x) w pr) b (ofInv .x) | inl refl = prependInv _ _ ... | inr y!=x = refl prependAndAdd (prependLetter (ofInv x) w pr) b (ofLetter y) with decA y x prependAndAdd (prependLetter (ofInv x) w pr) b (ofLetter .x) | inl refl = prependInv' _ _ ... | inr y!=x = refl prependAndAdd (prependLetter (ofInv x) w pr) b (ofInv y) = refl +WAssoc : (a b c : ReducedWord) → (a +W (b +W c)) ≡ ((a +W b) +W c) +WAssoc empty b c = refl +WAssoc (prependLetter letter a x) b c rewrite equalityCommutative (prependAndAdd (a +W b) c letter) | +WAssoc a b c = refl inverseW : ReducedWord → ReducedWord inverseW empty = empty inverseW (prependLetter letter w x) = (inverseW w) +W prependLetter (freeInverse letter) empty (wordEmpty refl) identRightW : (a : ReducedWord) → a +W empty ≡ a identRightW empty = refl identRightW (prependLetter (ofLetter l) a x) rewrite identRightW a = prependValid a l x identRightW (prependLetter (ofInv l) a x) rewrite identRightW a = prependValid' a l x invLeftW : (a : ReducedWord) → (inverseW a) +W a ≡ empty invLeftW empty = refl invLeftW (prependLetter (ofLetter l) a x) rewrite equalityCommutative (+WAssoc (inverseW a) (prependLetter (ofInv l) empty (wordEmpty refl)) (prependLetter (ofLetter l) a x)) = t where t : (inverseW a +W (prepend (prependLetter (ofLetter l) a x) (ofInv l))) ≡ empty t with decA l l ... | inl refl = invLeftW a ... | inr l!=l = exFalso (l!=l refl) invLeftW (prependLetter (ofInv l) a x) rewrite equalityCommutative (+WAssoc (inverseW a) (prependLetter (ofLetter l) empty (wordEmpty refl)) (prependLetter (ofInv l) a x)) = t where t : (inverseW a +W (prepend (prependLetter (ofInv l) a x) (ofLetter l))) ≡ empty t with decA l l ... | inl refl = invLeftW a ... | inr l!=l = exFalso (l!=l refl) invRightW : (a : ReducedWord) → a +W (inverseW a) ≡ empty invRightW empty = refl invRightW (prependLetter (ofLetter l) a x) rewrite +WAssoc a (inverseW a) (prependLetter (ofInv l) empty (wordEmpty refl)) | invRightW a = t where t : prepend (prependLetter (ofInv l) empty (wordEmpty refl)) (ofLetter l) ≡ empty t with decA l l ... | inl refl = refl ... | inr l!=l = exFalso (l!=l refl) invRightW (prependLetter (ofInv l) a x) rewrite +WAssoc a (inverseW a) (prependLetter (ofLetter l) empty (wordEmpty refl)) | invRightW a = t where t : prepend (prependLetter (ofLetter l) empty (wordEmpty refl)) (ofInv l) ≡ empty t with decA l l ... | inl refl = refl ... | inr l!=l = exFalso (l!=l refl) freeGroup : Group (reflSetoid ReducedWord) _+W_ Group.+WellDefined freeGroup refl refl = refl Group.0G freeGroup = empty Group.inverse freeGroup = inverseW Group.+Associative freeGroup {a} {b} {c} = +WAssoc a b c Group.identRight freeGroup {a} = identRightW a Group.identLeft freeGroup {a} = refl Group.invLeft freeGroup {a} = invLeftW a Group.invRight freeGroup {a} = invRightW a
{ "alphanum_fraction": 0.6952777379, "avg_line_length": 52.3834586466, "ext": "agda", "hexsha": "4bf45c11d0fa024c0e3246f276d65e0f53bee89f", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-29T13:23:07.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-29T13:23:07.000Z", "max_forks_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Smaug123/agdaproofs", "max_forks_repo_path": "Groups/FreeGroup/Group.agda", "max_issues_count": 14, "max_issues_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_issues_repo_issues_event_max_datetime": "2020-04-11T11:03:39.000Z", "max_issues_repo_issues_event_min_datetime": "2019-01-06T21:11:59.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Smaug123/agdaproofs", "max_issues_repo_path": "Groups/FreeGroup/Group.agda", "max_line_length": 209, "max_stars_count": 4, "max_stars_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Smaug123/agdaproofs", "max_stars_repo_path": "Groups/FreeGroup/Group.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": 2371, "size": 6967 }
module Type.Category.IntensionalFunctionsCategory{ℓ} where open import Data open import Functional open import Logic.Propositional open import Relator.Equals open import Relator.Equals.Proofs.Equiv open import Structure.Category open import Structure.Categorical.Properties open import Structure.Operator open import Type open import Type.Properties.Singleton -- The type category is a category containing all types of a single universe level in the language. -- The objects are all sets/types. -- The morphisms are all functions where the domain/codomain-pair are from these objects. typeIntensionalFnCategory : Category{Obj = Type{ℓ}}(_→ᶠ_) Category._∘_ typeIntensionalFnCategory = _∘_ Category.id typeIntensionalFnCategory = id BinaryOperator.congruence (Category.binaryOperator typeIntensionalFnCategory) [≡]-intro [≡]-intro = [≡]-intro Category.associativity typeIntensionalFnCategory = Morphism.intro [≡]-intro Category.identity typeIntensionalFnCategory = [∧]-intro (Morphism.intro [≡]-intro) (Morphism.intro [≡]-intro) typeIntensionalFnCategoryObject : CategoryObject typeIntensionalFnCategoryObject = intro typeIntensionalFnCategory Unit-terminalObject : Object.Terminal{Obj = Type{ℓ}}(_→ᶠ_) (Unit) IsUnit.unit Unit-terminalObject = const <> IsUnit.uniqueness Unit-terminalObject = [≡]-intro
{ "alphanum_fraction": 0.7926920209, "avg_line_length": 44.7, "ext": "agda", "hexsha": "e03c98df55652b4544cfefab99a87e824515410d", "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.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.agda", "max_line_length": 115, "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.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": 336, "size": 1341 }
{-# OPTIONS --universe-polymorphism #-} module Categories.Monoidal where open import Level open import Categories.Category open import Categories.Bifunctor using (Bifunctor) open import Categories.NaturalIsomorphism open import Categories.NaturalTransformation using (_∘₁_) renaming (_≡_ to _≡ⁿ_) open import Categories.Monoidal.Helpers record Monoidal {o ℓ e} (C : Category o ℓ e) : Set (o ⊔ ℓ ⊔ e) where private module C = Category C open C hiding (id; identityˡ; identityʳ; assoc) field ⊗ : Bifunctor C C C id : Obj open MonoidalHelperFunctors C ⊗ id field identityˡ : NaturalIsomorphism id⊗x x identityʳ : NaturalIsomorphism x⊗id x assoc : NaturalIsomorphism [x⊗y]⊗z x⊗[y⊗z] open Coherence identityˡ identityʳ assoc field .triangle : TriangleLeftSide ≡ⁿ (TriangleRightSide ∘₁ TriangleTopSide) .pentagon : (PentagonNESide ∘₁ PentagonNWSide) ≡ⁿ (PentagonSESide ∘₁ (PentagonSSide ∘₁ PentagonSWSide))
{ "alphanum_fraction": 0.7397691501, "avg_line_length": 28.8787878788, "ext": "agda", "hexsha": "5eba32fd20cd12caa9c9e284a22d75947c49b21f", "lang": "Agda", "max_forks_count": 23, "max_forks_repo_forks_event_max_datetime": "2021-11-11T13:50:56.000Z", "max_forks_repo_forks_event_min_datetime": "2015-02-05T13:03:09.000Z", "max_forks_repo_head_hexsha": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "p-pavel/categories", "max_forks_repo_path": "Categories/Monoidal.agda", "max_issues_count": 19, "max_issues_repo_head_hexsha": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2", "max_issues_repo_issues_event_max_datetime": "2019-08-09T16:31:40.000Z", "max_issues_repo_issues_event_min_datetime": "2015-05-23T06:47:10.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "p-pavel/categories", "max_issues_repo_path": "Categories/Monoidal.agda", "max_line_length": 107, "max_stars_count": 98, "max_stars_repo_head_hexsha": "36f4181d751e2ecb54db219911d8c69afe8ba892", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "copumpkin/categories", "max_stars_repo_path": "Categories/Monoidal.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-08T05:20:36.000Z", "max_stars_repo_stars_event_min_datetime": "2015-04-15T14:57:33.000Z", "num_tokens": 316, "size": 953 }
-- Andreas, 2016-02-16, issue 1777, reported by Martin Stone Davis data D : Set where c : D record R : Set where field f : D test : R → D test record { f = x } with x ... | y = {!y!} -- Splitting on y should give -- test record { f = x } | c = ?
{ "alphanum_fraction": 0.5787401575, "avg_line_length": 16.9333333333, "ext": "agda", "hexsha": "67482a4c470772d0bd50698ecebb9f2e32390d70", "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": "aac88412199dd4cbcb041aab499d8a6b7e3f4a2e", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "hborum/agda", "max_forks_repo_path": "test/interaction/Issue1777.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "aac88412199dd4cbcb041aab499d8a6b7e3f4a2e", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "hborum/agda", "max_issues_repo_path": "test/interaction/Issue1777.agda", "max_line_length": 66, "max_stars_count": 3, "max_stars_repo_head_hexsha": "aac88412199dd4cbcb041aab499d8a6b7e3f4a2e", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "hborum/agda", "max_stars_repo_path": "test/interaction/Issue1777.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": 89, "size": 254 }
open import Nat open import Prelude open import binders-disjoint-checks open import judgemental-erase open import lemmas-matching open import moveerase open import statics-core open import synth-unicity module sensibility where mutual -- if an action transforms a zexp in a synthetic posistion to another zexp, -- they have the same type up erasure of the cursor actsense-synth : {Γ : tctx} {e e' : zexp} {e◆ e'◆ : hexp} {t t' : htyp} {α : action} → erase-e e e◆ → erase-e e' e'◆ → Γ ⊢ e => t ~ α ~> e' => t' → Γ ⊢ e◆ => t → Γ ⊢ e'◆ => t' -- in the movement case, we defer to the movement erasure theorem actsense-synth er er' (SAMove x) wt with erasee-det (moveerasee' er x) er' ... | refl = wt -- in all the nonzipper cases, the cursor must be at the top for the -- action rule to apply, so we just build the new derivation -- directly. no recursion is needed; these are effectively base cases. actsense-synth _ EETop SADel _ = SEHole actsense-synth EETop (EEAscR ETTop) SAConAsc wt = SAsc (ASubsume wt TCRefl) actsense-synth _ EETop (SAConVar p) _ = SVar p actsense-synth EETop (EEHalfLamL ETTop) (SAConLam x) SEHole = SLam x SEHole actsense-synth EETop (EEApR EETop) (SAConApArr x) wt = SAp wt x (ASubsume SEHole TCHole1) actsense-synth EETop (EEApR EETop) (SAConApOtw x) wt = SAp (SNEHole wt) MAHole (ASubsume SEHole TCRefl) actsense-synth _ EETop SAConNumlit _ = SNum actsense-synth EETop (EEPlusR EETop) (SAConPlus1 TCRefl) wt = SPlus (ASubsume wt TCRefl) (ASubsume SEHole TCHole1) actsense-synth EETop (EEPlusR EETop) (SAConPlus1 TCHole2) wt = SPlus (ASubsume wt TCHole1) (ASubsume SEHole TCHole1) actsense-synth EETop (EEPlusR EETop) (SAConPlus2 _) wt = SPlus (ASubsume (SNEHole wt) TCHole1) (ASubsume SEHole TCHole1) actsense-synth EETop (EENEHole EETop) (SAConNEHole) wt = SNEHole wt actsense-synth _ EETop (SAFinish x) _ = x actsense-synth EETop (EEAscR (ETPlusL ETTop)) SAConInl SEHole = SAsc (AInl MSSum (ASubsume SEHole TCRefl)) actsense-synth EETop (EEAscR (ETPlusR ETTop)) SAConInr SEHole = SAsc (AInr MSSum (ASubsume SEHole TCRefl)) actsense-synth EETop (EEAscL (EECase2 EETop)) (SAConCase1 c d e₁) f = SAsc (ACase c d e₁ f (ASubsume SEHole TCRefl) (ASubsume SEHole TCRefl)) actsense-synth EETop (EEAscL (EECase1 (EENEHole EETop))) (SAConCase2 c d e₁) f = SAsc (ACase c d MSHole (SNEHole f) (ASubsume SEHole TCRefl) (ASubsume SEHole TCRefl)) actsense-synth EETop (EEPairL EETop) SAConPair SEHole = SPair SEHole SEHole actsense-synth EETop EETop (SAConFst1 pr) wt = SFst wt pr actsense-synth EETop (EEFst er) (SAConFst2 inc) wt with erase-e◆ er ... | refl = SFst (SNEHole wt) MPHole actsense-synth EETop EETop (SAConSnd1 pr) wt = SSnd wt pr actsense-synth EETop (EESnd er) (SAConSnd2 inc) wt with erase-e◆ er ... | refl = SSnd (SNEHole wt) MPHole --- zipper cases. in each, we recur on the smaller action derivation --- following the zipper structure, then reassemble the result actsense-synth (EEAscL er) (EEAscL er') (SAZipAsc1 x) (SAsc x₁) with actsense-ana er er' x x₁ ... | ih = SAsc ih actsense-synth (EEAscR x₁) (EEAscR x) (SAZipAsc2 x₂ x₃ x₄ x₅) (SAsc x₆) with eraset-det x x₃ ... | refl = SAsc x₅ actsense-synth (EEHalfLamL x₆) (EEHalfLamL x₇) (SAZipLam1 x x₁ x₂ x₃ x₄ x₅) (SLam x₈ wt) with eraset-det x₁ x₆ | eraset-det x₂ x₇ ... | refl | refl = SLam x₈ x₅ actsense-synth (EEHalfLamR er) (EEHalfLamR er') (SAZipLam2 x x₁ x₂ x₃) (SLam x₄ wt) with actsense-synth x₁ er' x₃ x₂ ... | ih = SLam x₄ ih actsense-synth er (EEApL er') (SAZipApArr x x₁ x₂ act x₃) wt with actsense-synth x₁ er' act x₂ ... | ih = SAp ih x x₃ actsense-synth (EEApR er) (EEApR er') (SAZipApAna x x₁ x₂) (SAp wt x₃ x₄) with synthunicity x₁ wt ... | refl with ▸arr-unicity x x₃ ... | refl with actsense-ana er er' x₂ x₄ ... | ih = SAp wt x ih actsense-synth (EEPlusL er) (EEPlusL er') (SAZipPlus1 x) (SPlus x₁ x₂) with actsense-ana er er' x x₁ ... | ih = SPlus ih x₂ actsense-synth (EEPlusR er) (EEPlusR er') (SAZipPlus2 x) (SPlus x₁ x₂) with actsense-ana er er' x x₂ ... | ih = SPlus x₁ ih actsense-synth er (EENEHole er') (SAZipNEHole x x₁ act) wt with actsense-synth x er' act x₁ ... | ih = SNEHole ih actsense-synth (EEPairL er) (EEPairL er') (SAZipPair1 x₁ x₂ y x₃) (SPair z₁ z₂) with actsense-synth er er' y z₁ ... | ih = SPair ih z₂ actsense-synth (EEPairR er) (EEPairR er') (SAZipPair2 x₁ x₂ x₃ y) (SPair z₁ z₂) with actsense-synth er er' y z₂ ... | ih = SPair z₁ ih actsense-synth (EEFst er) (EEFst er') (SAZipFst x₁ x₂ x₃ x₄ y) (SFst z₁ z₂) with actsense-synth x₃ er' y x₄ ... | ih = SFst ih x₂ actsense-synth (EESnd er) (EESnd er') (SAZipSnd x₁ x₂ x₃ x₄ y) (SSnd z₁ z₂) with actsense-synth x₃ er' y x₄ ... | ih = SSnd ih x₂ -- if an action transforms an zexp in an analytic posistion to another zexp, -- they have the same type up erasure of the cursor. actsense-ana : {Γ : tctx} {e e' : zexp} {e◆ e'◆ : hexp} {t : htyp} {α : action} → erase-e e e◆ → erase-e e' e'◆ → Γ ⊢ e ~ α ~> e' ⇐ t → Γ ⊢ e◆ <= t → Γ ⊢ e'◆ <= t -- in the subsumption case, punt to the other theorem actsense-ana er1 er2 (AASubsume x x₁ x₂ x₃) _ = ASubsume (actsense-synth x er2 x₂ x₁) x₃ -- for movement, appeal to the movement-erasure theorem actsense-ana er1 er2 (AAMove x) wt with erasee-det (moveerasee' er1 x) er2 ... | refl = wt -- in the nonzipper cases, we again know where the hole must be, so we -- force it and then build the relevant derivation directly. actsense-ana EETop EETop AADel wt = ASubsume SEHole TCHole1 actsense-ana EETop (EEAscR ETTop) AAConAsc wt = ASubsume (SAsc wt) TCRefl actsense-ana EETop (EENEHole EETop) (AAConVar x₁ p) wt = ASubsume (SNEHole (SVar p)) TCHole1 actsense-ana EETop (EELam EETop) (AAConLam1 x₁ x₂) wt = ALam x₁ x₂ (ASubsume SEHole TCHole1) actsense-ana EETop (EENEHole EETop) (AAConNumlit x) wt = ASubsume (SNEHole SNum) TCHole1 actsense-ana EETop EETop (AAFinish x) wt = x actsense-ana EETop (EENEHole (EEAscR (ETArrL ETTop))) (AAConLam2 x _) (ASubsume SEHole q) = ASubsume (SNEHole (SAsc (ALam x MAArr (ASubsume SEHole TCRefl)))) q -- all subsumptions in the right derivation are bogus, because there's no -- rule for lambdas synthetically actsense-ana (EELam _) (EELam _) (AAZipLam _ _ _) (ASubsume () _) -- that leaves only the zipper cases for lambda, where we force the -- forms and then recurr into the body of the lambda being checked. actsense-ana (EELam er1) (EELam er2) (AAZipLam x₁ x₂ act) (ALam x₄ x₅ wt) with ▸arr-unicity x₂ x₅ ... | refl with actsense-ana er1 er2 act wt ... | ih = ALam x₄ x₅ ih -- constructing injections actsense-ana EETop (EEInl EETop) (AAConInl1 e) _ = AInl e (ASubsume SEHole TCHole1) actsense-ana EETop (EENEHole (EEAscR (ETPlusL ETTop))) (AAConInl2 e) _ = ASubsume (SNEHole (SAsc (AInl MSSum (ASubsume SEHole TCRefl)))) TCHole1 actsense-ana EETop (EEInr EETop) (AAConInr1 e) _ = AInr e (ASubsume SEHole TCHole1) actsense-ana EETop (EENEHole (EEAscR (ETPlusL ETTop))) (AAConInr2 e) _ = ASubsume (SNEHole (SAsc (AInr MSSum (ASubsume SEHole TCRefl)))) TCHole1 -- constructing case actsense-ana EETop (EECase1 EETop) (AAConCase a b) wt = ACase a b MSHole SEHole (ASubsume SEHole TCHole1) (ASubsume SEHole TCHole1) -- the ASubsume cases are all impossible, by forcing the form via the erasure actsense-ana (EEInl _) (EEInl _) (AAZipInl _ _ ) (ASubsume () _) actsense-ana (EEInr _) (EEInr _) (AAZipInr _ _) (ASubsume () _) actsense-ana (EECase1 _) (EECase1 _) (AAZipCase1 _ _ _ _ _ _ _ _) (ASubsume () _) actsense-ana (EECase2 _) (EECase2 _) (AAZipCase2 _ _ _ _ _) (ASubsume () _) actsense-ana (EECase3 _) (EECase3 _) (AAZipCase3 _ _ _ _ _) (ASubsume () _) -- zipper cases for sum types actsense-ana (EEInl er1) (EEInl er2) (AAZipInl m1 b) (AInl m2 wt) with ▸sum-unicity m1 m2 ... | refl with actsense-ana er1 er2 b wt ... | wt' = AInl m1 wt' actsense-ana (EEInr er1) (EEInr er2) (AAZipInr m1 b) (AInr m2 wt) with ▸sum-unicity m1 m2 ... | refl with actsense-ana er1 er2 b wt ... | wt' = AInr m1 wt' actsense-ana (EECase1 er1) (EECase1 er2) (AAZipCase1 x₁ x₂ x₃ x₄ x₅ x₆ x₇ x₈) (ACase x₉ x₁₀ x₁₁ x₁₂ wt wt₁) with actsense-synth x₃ (rel◆ _) x₅ x₄ ... | ih = ACase x₉ x₁₀ x₆ (lem-synth-erase ih er2) x₇ x₈ actsense-ana (EECase2 er1) (EECase2 er2) (AAZipCase2 x₁ x₂ s1 x₄ x₅) (ACase x₇ x₈ x₉ s2 wt wt₁) with synthunicity s1 s2 ... | refl with ▸sum-unicity x₉ x₄ ... | refl with actsense-ana er1 er2 x₅ wt ... | ih = ACase x₇ x₈ x₉ s2 ih wt₁ actsense-ana (EECase3 er1) (EECase3 er2) (AAZipCase3 x₁ x₃ s1 x₄ x₆) (ACase x₇ x₈ x₉ s2 wt wt₁) with synthunicity s2 s1 ... | refl with ▸sum-unicity x₉ x₄ ... | refl with actsense-ana er1 er2 x₆ wt₁ ... | ih = ACase x₇ x₈ x₉ s2 wt ih
{ "alphanum_fraction": 0.6421252773, "avg_line_length": 51.172972973, "ext": "agda", "hexsha": "a458e310ffff1837d86e7290db94bbe59afbe2d7", "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": "sensibility.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": "sensibility.agda", "max_line_length": 96, "max_stars_count": null, "max_stars_repo_head_hexsha": "a3640d7b0f76cdac193afd382694197729ed6d57", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "hazelgrove/hazelnut-agda", "max_stars_repo_path": "sensibility.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 3768, "size": 9467 }
------------------------------------------------------------------------ -- A function that runs computations ------------------------------------------------------------------------ {-# OPTIONS --erased-cubical --safe #-} open import Prelude hiding (⊥) module Partiality-monad.Inductive.Approximate {a} {A : Type a} where open import Equality.Propositional.Cubical open import H-level.Truncation.Propositional equality-with-paths open import Partiality-monad.Inductive open import Partiality-monad.Inductive.Eliminators -- Runs the computation. The given number is used to decide which -- element to choose in sequences that are encountered. approximate : A ⊥ → ℕ → ∥ Maybe A ∥ approximate x n = ⊥-rec-⊥ (record { pe = ∣ nothing ∣ ; po = λ x → ∣ just x ∣ ; pl = λ _ rec → rec n ; pp = λ _ → truncation-is-proposition }) x
{ "alphanum_fraction": 0.5755813953, "avg_line_length": 28.6666666667, "ext": "agda", "hexsha": "f318a13ee6a1ccc71ab1e9e8e06dad427f9caa53", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "f69749280969f9093e5e13884c6feb0ad2506eae", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "nad/partiality-monad", "max_forks_repo_path": "src/Partiality-monad/Inductive/Approximate.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "f69749280969f9093e5e13884c6feb0ad2506eae", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "nad/partiality-monad", "max_issues_repo_path": "src/Partiality-monad/Inductive/Approximate.agda", "max_line_length": 72, "max_stars_count": 2, "max_stars_repo_head_hexsha": "f69749280969f9093e5e13884c6feb0ad2506eae", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "nad/partiality-monad", "max_stars_repo_path": "src/Partiality-monad/Inductive/Approximate.agda", "max_stars_repo_stars_event_max_datetime": "2020-07-03T08:56:08.000Z", "max_stars_repo_stars_event_min_datetime": "2020-05-21T22:59:18.000Z", "num_tokens": 213, "size": 860 }
module Categories.PushOuts where open import Library open import Categories open Cat record Square {a}{b}{C : Cat {a}{b}}{X Y Z}(f : Hom C Z X)(g : Hom C Z Y) : Set (a ⊔ b) where constructor square field W : Obj C h : Hom C X W k : Hom C Y W scom : comp C h f ≅ comp C k g record SqMap {a}{b}{C : Cat {a}{b}}{X Y Z : Obj C}{f : Hom C Z X}{g : Hom C Z Y} (sq sq' : Square {a}{b}{C} f g) : Set (a ⊔ b) where constructor sqmap open Square field sqMor : Hom C (W sq) (W sq') leftTr : comp C sqMor (h sq) ≅ h sq' rightTr : comp C sqMor (k sq) ≅ k sq' open SqMap record PushOut {a}{b}{C : Cat {a}{b}}{X Y Z}(f : Hom C Z X)(g : Hom C Z Y) : Set (a ⊔ b) where constructor pushout field sq : Square {a}{b}{C} f g uniqPush : (sq' : Square f g) → Σ (SqMap sq sq') \ u → (u' : SqMap sq sq') → sqMor u ≅ sqMor u'
{ "alphanum_fraction": 0.5223555071, "avg_line_length": 30.5666666667, "ext": "agda", "hexsha": "4dd46dfb2607ce0e84edddee3af5691eda962c5d", "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": "Categories/PushOuts.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": "Categories/PushOuts.agda", "max_line_length": 94, "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": "Categories/PushOuts.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": 347, "size": 917 }
-- Overlapping instances are only allowed if all valid candidates are -- overappable. module _ where postulate A : Set record B : Set where field overlap {{a}} : A record C : Set where field overlap {{a}} : A record D : Set where field {{a}} : A it : ∀ {a} {A : Set a} {{_ : A}} → A it {{x}} = x work : {{b : B}} {{c : C}} → A work = it -- One variable candidate fail₁ : {{a : A}} {{b : B}} → A fail₁ = it -- One non-overlappable field candidate fail₂ : {{c : C}} {{d : D}} → A fail₂ = it instance postulate a : A -- One top-level candidate fail₃ : {{b : B}} → A fail₃ = it
{ "alphanum_fraction": 0.5774410774, "avg_line_length": 15.6315789474, "ext": "agda", "hexsha": "950020cfb9755883eabb287ac5bdc315affa67fa", "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/DisallowedOverlaps.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/DisallowedOverlaps.agda", "max_line_length": 69, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "test/Fail/DisallowedOverlaps.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": 207, "size": 594 }
{-# OPTIONS -v tc.unquote:30 #-} open import Common.Prelude open import Common.Reflection open import Agda.Builtin.Sigma data Box : Bool → Set where box : (b : Bool) → Box b works : (b : Bool) → Box b → Bool works b (box .b) = unquote (give (var 0 [])) works₂ : (b : Bool) → Box b → Bool unquoteDef works₂ = defineFun works₂ (clause ( ("b" , vArg unknown) ∷ []) ( vArg (var 0) ∷ vArg (con (quote box) (vArg (dot unknown) ∷ [])) ∷ []) (var 0 []) ∷ []) works₃ : (b : Bool) → Box b → (x y : Bool) → Bool unquoteDef works₃ = defineFun works₃ (clause ( ("y" , vArg unknown) ∷ ("x" , vArg unknown) ∷ ("b" , vArg unknown) ∷ []) ( vArg (var 2) ∷ vArg (con (quote box) (vArg (dot unknown) ∷ [])) ∷ vArg (var 1) ∷ vArg (var 0) ∷ []) (var 2 []) ∷ [])
{ "alphanum_fraction": 0.5454545455, "avg_line_length": 23.2941176471, "ext": "agda", "hexsha": "b6742216a5b11b6c6ddba20ab0978916f4e73592", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "cc026a6a97a3e517bb94bafa9d49233b067c7559", "max_forks_repo_licenses": [ "BSD-2-Clause" ], "max_forks_repo_name": "cagix/agda", "max_forks_repo_path": "test/Succeed/Issue1344.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "cc026a6a97a3e517bb94bafa9d49233b067c7559", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "BSD-2-Clause" ], "max_issues_repo_name": "cagix/agda", "max_issues_repo_path": "test/Succeed/Issue1344.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/Succeed/Issue1344.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": 304, "size": 792 }
{-# OPTIONS --safe --experimental-lossy-unification #-} module Cubical.Algebra.Polynomials.Multivariate.Equiv.Poly1-Poly where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Isomorphism open import Cubical.Data.Nat renaming (_+_ to _+n_; _·_ to _·n_) open import Cubical.Data.Vec renaming ( [] to <> ; _∷_ to _::_) open import Cubical.Algebra.Ring open import Cubical.Algebra.CommRing open import Cubical.Algebra.Polynomials.Univariate.Base open import Cubical.Algebra.Polynomials.Univariate.Properties open import Cubical.Algebra.CommRing.Instances.UnivariatePoly open import Cubical.Algebra.Polynomials.Multivariate.Base open import Cubical.Algebra.Polynomials.Multivariate.Properties open import Cubical.Algebra.CommRing.Instances.MultivariatePoly private variable ℓ : Level module Equiv-Poly1-Poly: (A' : CommRing ℓ) where private A = fst A' open PolyMod A' renaming ( Poly to Poly: ; isSetPoly to isSetPoly: ) open PolyModTheory A' renaming ( 0P to 0P: ; Poly- to Poly:- ; _Poly+_ to _Poly:+_ ; Poly+Lid to Poly:+Lid ; Poly+Rid to Poly:+Rid ; Poly+Assoc to Poly:+Assoc ; Poly+Inverses to Poly:+Inverses ; Poly+Comm to Poly:+Comm ; _Poly*_ to _Poly:*_ ; 1P to 1P: ; 0PRightAnnihilates to 0PRightAnnihilates: ; 0PLeftAnnihilates to 0PLeftAnnihilates: ; Poly*Lid to Poly:*Lid ; Poly*Rid to Poly:*Rid ; Poly*Associative to Poly:*Assoc ; Poly*Commutative to Poly:*Comm ; prod-Xn-0P to prod-Xn-0P: ) open Nth-Poly-structure A' 1 -- Notation P, Q, R... for Poly 1 -- x, y, w... for Poly: -- a,b,c... for A ----------------------------------------------------------------------------- -- direct trad-base : (v : Vec ℕ 1) → A → Poly: trad-base (n :: <>) a = prod-Xn n [ a ] trad-base-neutral : (v : Vec ℕ 1) → trad-base v 0r ≡ [] trad-base-neutral (n :: <>) = cong (prod-Xn n) drop0 ∙ prod-Xn-0P: n trad-base-add : (v : Vec ℕ 1) → (a b : A) → (trad-base v a) Poly:+ (trad-base v b) ≡ trad-base v (a + b) trad-base-add (n :: <>) a b = prod-Xn-sum n (a ∷ []) (b ∷ []) Poly1→Poly: : Poly A' 1 → Poly: Poly1→Poly: = Poly-Rec-Set.f A' 1 Poly: isSetPoly: [] trad-base (λ x y → x Poly:+ y) Poly:+Assoc Poly:+Rid Poly:+Comm trad-base-neutral trad-base-add Poly1→Poly:-gmorph : (P Q : Poly A' 1) → Poly1→Poly: (P Poly+ Q) ≡ (Poly1→Poly: P) Poly:+ (Poly1→Poly: Q) Poly1→Poly:-gmorph P Q = refl ----------------------------------------------------------------------------- -- converse Poly:→Poly1-int : (n : ℕ) → Poly: → Poly A' 1 Poly:→Poly1-int n [] = 0P Poly:→Poly1-int n (a ∷ x) = (base (n :: <>) a) Poly+ Poly:→Poly1-int (suc n) x Poly:→Poly1-int n (drop0 i) = ((cong (λ X → X Poly+ 0P) (base-0P (n :: <>))) ∙ (Poly+-Rid 0P)) i Poly:→Poly1 : Poly: → Poly A' 1 Poly:→Poly1 x = Poly:→Poly1-int 0 x Poly:→Poly1-int-gmorph : (x y : Poly:) → (n : ℕ) → Poly:→Poly1-int n (x Poly:+ y) ≡ (Poly:→Poly1-int n x) Poly+ (Poly:→Poly1-int n y) Poly:→Poly1-int-gmorph = ElimProp.f (λ x → (y : Poly:) → (n : ℕ) → Poly:→Poly1-int n (x Poly:+ y) ≡ (Poly:→Poly1-int n x Poly+ Poly:→Poly1-int n y)) (λ y n → (cong (Poly:→Poly1-int n) (Poly:+Lid y)) ∙ (sym (Poly+-Lid (Poly:→Poly1-int n y)))) (λ a x ind-x → ElimProp.f (λ y → (n : ℕ) → Poly:→Poly1-int n ((a ∷ x) Poly:+ y) ≡ (Poly:→Poly1-int n (a ∷ x) Poly+ Poly:→Poly1-int n y)) (λ n → sym (Poly+-Rid (Poly:→Poly1-int n (a ∷ x)))) (λ b y ind-y n → sym ( (Poly-com-adv (base (n :: <>) a) (Poly:→Poly1-int (suc n) x) (base (n :: <>) b) (Poly:→Poly1-int (suc n) y)) ∙ (cong₂ _Poly+_ (base-Poly+ (n :: <>) a b) (sym (ind-x y (suc n))))) ) λ {y} p q i n j → trunc (Poly:→Poly1-int n ((a ∷ x) Poly:+ y)) (Poly:→Poly1-int n (a ∷ x) Poly+ Poly:→Poly1-int n y) (p n) (q n) i j ) λ {x} p q i y n j → trunc (Poly:→Poly1-int n (x Poly:+ y)) (Poly:→Poly1-int n x Poly+ Poly:→Poly1-int n y) (p y n) (q y n) i j Poly:→Poly1-gmorph : (x y : Poly:) → Poly:→Poly1 (x Poly:+ y) ≡ (Poly:→Poly1 x) Poly+ (Poly:→Poly1 y) Poly:→Poly1-gmorph x y = Poly:→Poly1-int-gmorph x y 0 ----------------------------------------------------------------------------- -- section e-sect-int : (x : Poly:) → (n : ℕ) → Poly1→Poly: (Poly:→Poly1-int n x) ≡ prod-Xn n x e-sect-int = ElimProp.f (λ z → (n : ℕ) → Poly1→Poly: (Poly:→Poly1-int n z) ≡ prod-Xn n z) (λ n → sym (prod-Xn-0P: n)) (λ a x ind-x n → ((prod-Xn n [ a ] ) Poly:+ (Poly1→Poly: (Poly:→Poly1-int (suc n) x))) ≡⟨ cong (λ X → prod-Xn n [ a ] Poly:+ X) (ind-x (suc n)) ⟩ (prod-Xn n (a ∷ []) Poly:+ ( 0r ∷ prod-Xn n x)) ≡⟨ prod-Xn-∷ n a x ⟩ prod-Xn n (a ∷ x) ∎) (λ {x} p q i n j → isSetPoly: (Poly1→Poly: (Poly:→Poly1-int n x)) (prod-Xn n x) (p n) (q n) i j) e-sect : (x : Poly:) → Poly1→Poly: (Poly:→Poly1 x) ≡ x e-sect x = e-sect-int x 0 ----------------------------------------------------------------------------- -- retraction idde : (m n : ℕ) → (a : A) → Poly:→Poly1-int n (prod-Xn m [ a ]) ≡ base ((n +n m) :: <>) a idde zero n a = Poly+-Rid (base (n :: <>) a) ∙ cong (λ X → base (X :: <>) a) (sym (+-zero n)) idde (suc m) n a = cong (λ X → X Poly+ Poly:→Poly1-int (suc n) (prod-Xn m (a ∷ []))) (base-0P (n :: <>)) ∙ Poly+-Lid (Poly:→Poly1-int (suc n) (prod-Xn m (a ∷ []))) ∙ idde m (suc n) a ∙ cong (λ X → base (X :: <>) a) (sym (+-suc n m)) idde-v : (v : Vec ℕ 1) → (a : A) → Poly:→Poly1-int 0 (trad-base v a) ≡ base v a idde-v (n :: <>) a = (idde n 0 a) e-retr : (P : Poly A' 1) → Poly:→Poly1 (Poly1→Poly: P) ≡ P e-retr = Poly-Ind-Prop.f A' 1 (λ P → Poly:→Poly1 (Poly1→Poly: P) ≡ P) (λ _ → trunc _ _) refl (λ v a → idde-v v a) λ {P Q} ind-P ind-Q → cong Poly:→Poly1 (Poly1→Poly:-gmorph P Q) ∙ Poly:→Poly1-gmorph (Poly1→Poly: P) (Poly1→Poly: Q) ∙ cong₂ _Poly+_ ind-P ind-Q ----------------------------------------------------------------------------- -- Ring morphism map-1P : Poly1→Poly: 1P ≡ 1P: map-1P = refl trad-base-prod : (v v' : Vec ℕ 1) → (a a' : A) → trad-base (v +n-vec v') (a · a') ≡ (trad-base v a Poly:* trad-base v' a') trad-base-prod (k :: <>) (l :: <>) a a' = sym ((prod-Xn-prod k l [ a ] [ a' ]) ∙ cong (λ X → prod-Xn (k +n l) [ X ]) (+Rid (a · a'))) Poly1→Poly:-rmorph : (P Q : Poly A' 1) → Poly1→Poly: (P Poly* Q) ≡ (Poly1→Poly: P) Poly:* (Poly1→Poly: Q) Poly1→Poly:-rmorph = Poly-Ind-Prop.f A' 1 (λ P → (Q : Poly A' 1) → Poly1→Poly: (P Poly* Q) ≡ (Poly1→Poly: P Poly:* Poly1→Poly: Q)) (λ P p q i Q j → isSetPoly: (Poly1→Poly: (P Poly* Q)) (Poly1→Poly: P Poly:* Poly1→Poly: Q) (p Q) (q Q) i j) (λ Q → refl) (λ v a → Poly-Ind-Prop.f A' 1 (λ P → Poly1→Poly: (base v a Poly* P) ≡ (Poly1→Poly: (base v a) Poly:* Poly1→Poly: P)) (λ _ → isSetPoly: _ _) (sym (0PLeftAnnihilates: (trad-base v a))) (λ v' a' → trad-base-prod v v' a a') λ {U V} ind-U ind-V → (cong₂ _Poly:+_ ind-U ind-V) ∙ sym (Poly*LDistrPoly+ (Poly1→Poly: (base v a)) (Poly1→Poly: U) (Poly1→Poly: V))) λ {U V} ind-U ind-V Q → (cong₂ _Poly:+_ (ind-U Q) (ind-V Q)) ∙ sym (Poly*RDistrPoly+ (Poly1→Poly: U) (Poly1→Poly: V) (Poly1→Poly: Q)) -- ----------------------------------------------------------------------------- -- -- Ring Equivalences module _ (A' : CommRing ℓ) where open Equiv-Poly1-Poly: A' CRE-Poly1-Poly: : CommRingEquiv (PolyCommRing A' 1) (UnivariatePoly A') fst CRE-Poly1-Poly: = isoToEquiv is where is : Iso _ _ Iso.fun is = Poly1→Poly: Iso.inv is = Poly:→Poly1 Iso.rightInv is = e-sect Iso.leftInv is = e-retr snd CRE-Poly1-Poly: = makeIsRingHom map-1P Poly1→Poly:-gmorph Poly1→Poly:-rmorph
{ "alphanum_fraction": 0.4424541457, "avg_line_length": 44.1848341232, "ext": "agda", "hexsha": "092d7b862a3b3ca6053cdc7ed4cd4bbe4b3f99b8", "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/Algebra/Polynomials/Multivariate/Equiv/Poly1-Poly.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/Algebra/Polynomials/Multivariate/Equiv/Poly1-Poly.agda", "max_line_length": 166, "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/Algebra/Polynomials/Multivariate/Equiv/Poly1-Poly.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 3063, "size": 9323 }
test.id : (A:Set) -> (x:A) -> A test.id A x = x nat.plus : (x:Nat) -> (y:Nat) -> Nat nat.plus (nat.suc x) y = nat.suc (nat.plus x y) nat.plus nat.zero y = y
{ "alphanum_fraction": 0.5375, "avg_line_length": 17.7777777778, "ext": "agda", "hexsha": "3239a66da9d0ef50ce7456f32b9fd649ad0659d0", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_forks_event_min_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "masondesu/agda", "max_forks_repo_path": "test/core/core.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "masondesu/agda", "max_issues_repo_path": "test/core/core.agda", "max_line_length": 47, "max_stars_count": 1, "max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/agda-kanso", "max_stars_repo_path": "test/core/core.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": 67, "size": 160 }
import Lvl open import Structure.Setoid open import Type module Structure.Operator.Vector.Subspaces.Image {ℓₛ ℓₛₑ} {S : Type{ℓₛ}} ⦃ equiv-S : Equiv{ℓₛₑ}(S) ⦄ {_+ₛ_ _⋅ₛ_ : S → S → S} where open import Logic.Predicate open import Sets.ExtensionalPredicateSet as PredSet using (PredSet ; _∈_ ; [∋]-binaryRelator) open import Structure.Container.SetLike as SetLike using (SetElement) open import Structure.Function.Multi open import Structure.Operator open import Structure.Operator.Properties open import Structure.Operator.Vector open import Structure.Operator.Vector.LinearMap open import Structure.Operator.Vector.Proofs open import Structure.Operator.Vector.Subspace open import Structure.Relator.Properties open import Syntax.Function open import Syntax.Implication open import Syntax.Transitivity open VectorSpace ⦃ … ⦄ open VectorSpaceVObject ⦃ … ⦄ using (_+ᵥ_; _⋅ₛᵥ_) open VectorSpaceVObject using (Vector) private variable ℓ ℓᵥ ℓᵥₑ : Lvl.Level private variable V W : VectorSpaceVObject {ℓᵥ = ℓᵥ} {ℓᵥₑ = ℓᵥₑ} ⦃ equiv-S = equiv-S ⦄ (_+ₛ_)(_⋅ₛ_) private variable F : V →ˡⁱⁿᵉᵃʳᵐᵃᵖ W image : (V →ˡⁱⁿᵉᵃʳᵐᵃᵖ W) → PredSet(Vector(W)) image {V = V}{W = W} ([∃]-intro f) = PredSet.⊶ f image-subspace : Subspace(image(F)) SetLike.FunctionProperties._closed-under₂_.proof (Subspace.add-closure (image-subspace {_} {_} {V} {_} {_} {W} {F = F@([∃]-intro f)})) {x} {y} xim yim = • ( xim ⇒ x ∈ image(F) ⇒-[] ∃(a ↦ f(a) ≡ x) ⇒-end ) • ( yim ⇒ y ∈ image(F) ⇒-[] ∃(a ↦ f(a) ≡ y) ⇒-end ) ⇒₂-[ [∃]-map₂ (_+ᵥ_) (p ↦ q ↦ (preserving₂(f)(_+ᵥ_)(_+ᵥ_) 🝖 congruence₂(_+ᵥ_) p q)) ] ∃(a ↦ f(a) ≡ x +ᵥ y) ⇒-[] (x +ᵥ y) ∈ image(F) ⇒-end where instance _ = V instance _ = W SetLike.FunctionProperties._closed-under₁_.proof (Subspace.mul-closure (image-subspace {_} {_} {V} {_} {_} {W} {F = F@([∃]-intro f)}) {s}) {v} vim = vim ⇒ v ∈ image(F) ⇒-[] ∃(x ↦ f(x) ≡ v) ⇒-[ [∃]-map-proof (congruence₂ᵣ(_⋅ₛᵥ_)(s)) ] ∃(x ↦ s ⋅ₛᵥ f(x) ≡ s ⋅ₛᵥ v) ⇒-[ [∃]-map (s ⋅ₛᵥ_) (preserving₁(f)(s ⋅ₛᵥ_)(s ⋅ₛᵥ_) 🝖_) ] ∃(x ↦ f(x) ≡ s ⋅ₛᵥ v) ⇒-[] (s ⋅ₛᵥ v) ∈ image(F) ⇒-end where instance _ = V instance _ = W
{ "alphanum_fraction": 0.6087149844, "avg_line_length": 34.6, "ext": "agda", "hexsha": "f92df6a73514bcefe518a9fb76971fe3b6794db9", "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/Operator/Vector/Subspaces/Image.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/Operator/Vector/Subspaces/Image.agda", "max_line_length": 152, "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/Operator/Vector/Subspaces/Image.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": 954, "size": 2249 }
{-# OPTIONS --without-K --rewriting #-} open import HoTT open import cw.CW open import cw.FinCW open import cw.FinBoundary open import cohomology.Theory {- The reason that RephraseDualizedFirstFinBoundary did not handle this case is because [FinSkeleton n] does not compute. -} module cw.cohomology.cochainequiv.DualizedFirstBoundary (OT : OrdinaryTheory lzero) (⊙fin-skel : ⊙FinSkeleton 1) where open OrdinaryTheory OT private fin-skel = ⊙FinSkeleton.skel ⊙fin-skel I = AttachedFinSkeleton.numCells fin-skel I₋₁ = AttachedFinSkeleton.skel fin-skel abstract rephrase-dualized-first-boundary-in-degree : ∀ g <I → FormalSum-extend (C2-abgroup 0) g (GroupHom.f (fboundary-last fin-skel) fs[ inl <I :: nil ]) == Group.sum (C2 0) (λ <I₋₁ → Group.exp (C2 0) (g <I₋₁) (fdegree-last fin-skel <I <I₋₁)) rephrase-dualized-first-boundary-in-degree g <I = FormalSum-extend (C2-abgroup 0) g (GroupHom.f (fboundary-last fin-skel) fs[ inl <I :: nil ]) =⟨ ap (FormalSum-extend (C2-abgroup 0) g) $ app= (is-equiv.g-f (FreeAbGroup-extend-is-equiv (FreeAbGroup (Fin I₋₁))) (fboundary'-last fin-skel)) <I ⟩ FormalSum-extend (C2-abgroup 0) g (Group.sum (FreeAbGroup.grp (Fin I₋₁)) (λ <I₋₁ → Group.exp (FreeAbGroup.grp (Fin I₋₁)) fs[ inl <I₋₁ :: nil ] (fdegree-last fin-skel <I <I₋₁))) =⟨ GroupHom.pres-sum (FreeAbGroup-extend (C2-abgroup 0) g) (λ <I₋₁ → Group.exp (FreeAbGroup.grp (Fin I₋₁)) fs[ inl <I₋₁ :: nil ] (fdegree-last fin-skel <I <I₋₁)) ⟩ Group.sum (C2 0) (λ <I₋₁ → (FormalSum-extend (C2-abgroup 0) g (Group.exp (FreeAbGroup.grp (Fin I₋₁)) fs[ inl <I₋₁ :: nil ] (fdegree-last fin-skel <I <I₋₁)))) =⟨ ap (Group.sum (C2 0)) (λ= λ <I₋₁ → GroupHom.pres-exp (FreeAbGroup-extend (C2-abgroup 0) g) fs[ inl <I₋₁ :: nil ] (fdegree-last fin-skel <I <I₋₁)) ⟩ Group.sum (C2 0) (λ <I₋₁ → (Group.exp (C2 0) (FormalSum-extend (C2-abgroup 0) g fs[ inl <I₋₁ :: nil ]) (fdegree-last fin-skel <I <I₋₁))) =⟨ ap (Group.sum (C2 0)) (λ= λ <I₋₁ → ap (λ g → Group.exp (C2 0) g (fdegree-last fin-skel <I <I₋₁)) $ app= (is-equiv.g-f (FreeAbGroup-extend-is-equiv (C2-abgroup 0)) g) <I₋₁) ⟩ Group.sum (C2 0) (λ <I₋₁ → (Group.exp (C2 0) (g <I₋₁) (fdegree-last fin-skel <I <I₋₁))) =∎
{ "alphanum_fraction": 0.6030949394, "avg_line_length": 43.4727272727, "ext": "agda", "hexsha": "5592b97a86b1be470a5dd75c5ac19657f3a452d1", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "timjb/HoTT-Agda", "max_forks_repo_path": "theorems/cw/cohomology/cochainequiv/DualizedFirstBoundary.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "timjb/HoTT-Agda", "max_issues_repo_path": "theorems/cw/cohomology/cochainequiv/DualizedFirstBoundary.agda", "max_line_length": 115, "max_stars_count": null, "max_stars_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "timjb/HoTT-Agda", "max_stars_repo_path": "theorems/cw/cohomology/cochainequiv/DualizedFirstBoundary.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 917, "size": 2391 }
open import SOAS.Common open import SOAS.Families.Core open import Categories.Object.Initial open import SOAS.Coalgebraic.Strength import SOAS.Metatheory.MetaAlgebra -- Initial-algebra semantics module SOAS.Metatheory.Semantics {T : Set} (⅀F : Functor 𝔽amiliesₛ 𝔽amiliesₛ) (⅀:Str : Strength ⅀F) (𝔛 : Familyₛ) (open SOAS.Metatheory.MetaAlgebra ⅀F 𝔛) (𝕋:Init : Initial 𝕄etaAlgebras) where open import SOAS.Context open import SOAS.Variable open import SOAS.Construction.Structure as Structure open import SOAS.Abstract.Hom import SOAS.Abstract.Coalgebra as →□ ; open →□.Sorted import SOAS.Abstract.Box as □ ; open □.Sorted open import SOAS.Metatheory.Algebra ⅀F open Strength ⅀:Str private variable Γ Δ Θ Π : Ctx α β : T 𝒫 𝒬 𝒜 : Familyₛ open Initial 𝕋:Init open Object ⊥ public renaming (𝐶 to 𝕋 ; ˢ to 𝕋ᵃ) open MetaAlg 𝕋ᵃ public renaming (𝑎𝑙𝑔 to 𝕒𝕝𝕘 ; 𝑣𝑎𝑟 to 𝕧𝕒𝕣 ; 𝑚𝑣𝑎𝑟 to 𝕞𝕧𝕒𝕣 ; 𝑚≈₁ to 𝕞≈₁ ; 𝑚≈₂ to 𝕞≈₂) module Semantics (𝒜ᵃ : MetaAlg 𝒜) where open Morphism (! {𝒜 ⋉ 𝒜ᵃ}) public renaming (𝑓 to 𝕤𝕖𝕞 ; ˢ⇒ to 𝕤𝕖𝕞ᵃ⇒) open MetaAlg⇒ 𝕤𝕖𝕞ᵃ⇒ public renaming (⟨𝑎𝑙𝑔⟩ to ⟨𝕒⟩ ; ⟨𝑣𝑎𝑟⟩ to ⟨𝕧⟩ ; ⟨𝑚𝑣𝑎𝑟⟩ to ⟨𝕞⟩) open MetaAlg 𝒜ᵃ module 𝒜 = MetaAlg 𝒜ᵃ eq : {g h : 𝕋 ⇾̣ 𝒜} (gᵃ : MetaAlg⇒ 𝕋ᵃ 𝒜ᵃ g) (hᵃ : MetaAlg⇒ 𝕋ᵃ 𝒜ᵃ h) (t : 𝕋 α Γ) → g t ≡ h t eq {g = g}{h} gᵃ hᵃ t = !-unique₂ (g ⋉ gᵃ) (h ⋉ hᵃ) {x = t} -- The interpretation is equal to any other pointed meta-Λ-algebra 𝕤𝕖𝕞! : {g : 𝕋 ⇾̣ 𝒜}(gᵃ : MetaAlg⇒ 𝕋ᵃ 𝒜ᵃ g)(t : 𝕋 α Γ) → 𝕤𝕖𝕞 t ≡ g t 𝕤𝕖𝕞! {g = g} gᵃ t = !-unique (g ⋉ gᵃ) {x = t} -- Corollaries: every meta-algebra endo-homomorphism is the identity, including 𝕤𝕖𝕞 eq-id : {g : 𝕋 ⇾̣ 𝕋} (gᵃ : MetaAlg⇒ 𝕋ᵃ 𝕋ᵃ g) (t : 𝕋 α Γ) → g t ≡ t eq-id gᵃ t = Semantics.eq 𝕋ᵃ gᵃ (idᵃ 𝕋ᵃ) t 𝕤𝕖𝕞-id : {t : 𝕋 α Γ} → Semantics.𝕤𝕖𝕞 𝕋ᵃ t ≡ t 𝕤𝕖𝕞-id {t = t} = eq-id (Semantics.𝕤𝕖𝕞ᵃ⇒ 𝕋ᵃ) t
{ "alphanum_fraction": 0.6373448462, "avg_line_length": 30.3770491803, "ext": "agda", "hexsha": "0e09b13a713739e33e0bb5341e26809e487b383f", "lang": "Agda", "max_forks_count": 4, "max_forks_repo_forks_event_max_datetime": "2022-01-24T12:49:17.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-09T20:39:59.000Z", "max_forks_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "JoeyEremondi/agda-soas", "max_forks_repo_path": "SOAS/Metatheory/Semantics.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8", "max_issues_repo_issues_event_max_datetime": "2021-11-21T12:19:32.000Z", "max_issues_repo_issues_event_min_datetime": "2021-11-21T12:19:32.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "JoeyEremondi/agda-soas", "max_issues_repo_path": "SOAS/Metatheory/Semantics.agda", "max_line_length": 83, "max_stars_count": 39, "max_stars_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "JoeyEremondi/agda-soas", "max_stars_repo_path": "SOAS/Metatheory/Semantics.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-19T17:33:12.000Z", "max_stars_repo_stars_event_min_datetime": "2021-11-09T20:39:55.000Z", "num_tokens": 1079, "size": 1853 }
{-# OPTIONS --without-K --rewriting #-} open import HoTT.Base open import HoTT.HLevel module HoTT.HLevel.Truncate where open variables postulate _↦_ : ∀ {a} {A : Set a} → A → A → Set a {-# BUILTIN REWRITE _↦_ #-} postulate ∥_∥ : 𝒰 i → 𝒰 i ∣_∣ : A → ∥ A ∥ instance ∥-hlevel : hlevel 1 ∥ A ∥ ∥-rec : ⦃ hlevel 1 B ⦄ → (A → B) → ∥ A ∥ → B ∥-β : ⦃ _ : hlevel 1 B ⦄ → (f : A → B) (x : A) → ∥-rec f ∣ x ∣ ↦ f x {-# REWRITE ∥-β #-} {- data Squash (A : 𝒰 i) : 𝒰 i where squash : A → Squash A ∥_∥ : 𝒰 i → 𝒰 i ∥_∥ = Squash ∣_∣ : A → ∥ A ∥ ∣_∣ = squash postulate instance ∥-hlevel : hlevel 1 ∥ A ∥ ∥-rec : {B : 𝒰 i} → ⦃ hlevel 1 B ⦄ → (A → B) → ∥ A ∥ → B ∥-rec f (squash x) = f x -}
{ "alphanum_fraction": 0.4956896552, "avg_line_length": 19.8857142857, "ext": "agda", "hexsha": "665068a4a5cf37e24ecd1e81d4e47f79e99e91d0", "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": "ef4d9fbb9cc0352657f1a6d0d3534d4c8a6fd508", "max_forks_repo_licenses": [ "0BSD" ], "max_forks_repo_name": "michaelforney/hott", "max_forks_repo_path": "HoTT/HLevel/Truncate.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "ef4d9fbb9cc0352657f1a6d0d3534d4c8a6fd508", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "0BSD" ], "max_issues_repo_name": "michaelforney/hott", "max_issues_repo_path": "HoTT/HLevel/Truncate.agda", "max_line_length": 70, "max_stars_count": null, "max_stars_repo_head_hexsha": "ef4d9fbb9cc0352657f1a6d0d3534d4c8a6fd508", "max_stars_repo_licenses": [ "0BSD" ], "max_stars_repo_name": "michaelforney/hott", "max_stars_repo_path": "HoTT/HLevel/Truncate.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 362, "size": 696 }
module Issue296 where postulate Unit : Set IO : Set → Set foo : ((A B : Set) → Unit) → IO Unit bar : (A B : Set) → Unit {-# BUILTIN IO IO #-} {-# COMPILE GHC IO = type IO #-} {-# COMPILE GHC Unit = type () #-} {-# COMPILE GHC bar = undefined #-} main : IO Unit main = foo bar
{ "alphanum_fraction": 0.5567010309, "avg_line_length": 18.1875, "ext": "agda", "hexsha": "ad5f6f4712d08c5cdae4bf98a53bdb6f6a6e3c0a", "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/Issue296.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/Issue296.agda", "max_line_length": 39, "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/Issue296.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 93, "size": 291 }
{-# OPTIONS --without-K --rewriting #-} open import HoTT open import groups.Cokernel open import groups.Exactness open import groups.ExactSequence open import cohomology.Theory open import cw.CW open import cw.WedgeOfCells module cw.cohomology.reconstructed.TipCoboundary {i} (OT : OrdinaryTheory i) (⊙skel : ⊙Skeleton {i} 1) where open OrdinaryTheory OT open import cohomology.LongExactSequence cohomology-theory 0 (⊙cw-incl-last ⊙skel) open import cw.cohomology.WedgeOfCells OT ⊙skel open import cw.cohomology.reconstructed.TipAndAugment OT (⊙cw-init ⊙skel) CX₁/X₀-is-abelian = CXₙ/Xₙ₋₁-is-abelian 1 cw-co∂-head' : CX₀ 0 →ᴳ CXₙ/Xₙ₋₁ 1 cw-co∂-head' = co∂ ⊙cw-∂-head'-before-Susp : ⊙Xₙ/Xₙ₋₁ (⊙Skeleton.skel ⊙skel) ⊙→ ⊙Susp (⊙cw-head ⊙skel) ⊙cw-∂-head'-before-Susp = ⊙∂-before-Susp cw-∂-head'-before-Susp : Xₙ/Xₙ₋₁ (⊙Skeleton.skel ⊙skel) → Susp (cw-head (⊙Skeleton.skel ⊙skel)) cw-∂-head'-before-Susp = ∂-before-Susp abstract cw-∂-head'-before-Susp-glue-β : ∀ x → ap cw-∂-head'-before-Susp (cfglue x) == merid x cw-∂-head'-before-Susp-glue-β = ∂-before-Susp-glue-β cw-co∂-head : C2×CX₀ 0 →ᴳ CXₙ/Xₙ₋₁ 1 cw-co∂-head = record {f = GroupHom.f cw-co∂-head' ∘ snd; pres-comp = lemma} where abstract lemma = ∘ᴳ-pres-comp cw-co∂-head' (×ᴳ-snd {G = C2 0} {H = CX₀ 0}) abstract -- This relies on the [lemma] above being non-abstract within this scope. co∂-head-incl-exact : is-exact cw-co∂-head (C-fmap 1 (⊙cfcod' (⊙cw-incl-last ⊙skel))) co∂-head-incl-exact = pre∘-is-exact (×ᴳ-snd {G = C2 0} {H = CX₀ 0}) (×ᴳ-snd-is-surj {G = C2 0} {H = CX₀ 0}) (exact-seq-index 1 C-cofiber-exact-seq) module CokerCo∂Head where grp = Coker cw-co∂-head CX₁/X₀-is-abelian open Group grp public
{ "alphanum_fraction": 0.6830697129, "avg_line_length": 34.14, "ext": "agda", "hexsha": "6924342e2ce0f49aeefda7c0ecf1e06383a52163", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "timjb/HoTT-Agda", "max_forks_repo_path": "theorems/cw/cohomology/reconstructed/TipCoboundary.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "timjb/HoTT-Agda", "max_issues_repo_path": "theorems/cw/cohomology/reconstructed/TipCoboundary.agda", "max_line_length": 95, "max_stars_count": null, "max_stars_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "timjb/HoTT-Agda", "max_stars_repo_path": "theorems/cw/cohomology/reconstructed/TipCoboundary.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 744, "size": 1707 }
------------------------------------------------------------------------------ -- Reasoning partially about functions ------------------------------------------------------------------------------ {-# OPTIONS --allow-unsolved-metas #-} {-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} -- We cannot reasoning partially about partial functions intended to -- operate in total values. module FOT.FOTC.Data.Nat.AddPartialRightIdentity where open import FOTC.Base open import FOTC.Data.Nat ------------------------------------------------------------------------------ -- How proceed? +-partialRightIdentity : ∀ n → n + zero ≡ n +-partialRightIdentity n = {!!}
{ "alphanum_fraction": 0.4550063371, "avg_line_length": 32.875, "ext": "agda", "hexsha": "31e236aff4bebbb443625deaab653c5d4c368b23", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "asr/fotc", "max_forks_repo_path": "notes/FOT/FOTC/Data/Nat/AddPartialRightIdentity.agda", "max_issues_count": 2, "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "asr/fotc", "max_issues_repo_path": "notes/FOT/FOTC/Data/Nat/AddPartialRightIdentity.agda", "max_line_length": 78, "max_stars_count": 11, "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/fotc", "max_stars_repo_path": "notes/FOT/FOTC/Data/Nat/AddPartialRightIdentity.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": 131, "size": 789 }
test = forall _Set_ → Set
{ "alphanum_fraction": 0.6923076923, "avg_line_length": 13, "ext": "agda", "hexsha": "6f404304410f985fce70c6597bbb2a3e5d15ae84", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2015-09-15T14:36:15.000Z", "max_forks_repo_forks_event_min_datetime": "2015-09-15T14:36:15.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/InvalidNamePartSet.agda", "max_issues_count": 3, "max_issues_repo_head_hexsha": "aac88412199dd4cbcb041aab499d8a6b7e3f4a2e", "max_issues_repo_issues_event_max_datetime": "2019-04-01T19:39:26.000Z", "max_issues_repo_issues_event_min_datetime": "2018-11-14T15:31:44.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "hborum/agda", "max_issues_repo_path": "test/Fail/InvalidNamePartSet.agda", "max_line_length": 25, "max_stars_count": 2, "max_stars_repo_head_hexsha": "aac88412199dd4cbcb041aab499d8a6b7e3f4a2e", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "hborum/agda", "max_stars_repo_path": "test/Fail/InvalidNamePartSet.agda", "max_stars_repo_stars_event_max_datetime": "2020-09-20T00:28:57.000Z", "max_stars_repo_stars_event_min_datetime": "2019-10-29T09:40:30.000Z", "num_tokens": 9, "size": 26 }
open import Prelude module List where data List (A : Set) : Set where [] : List A _::_ : (a : A) (as : List A) → List A -- list append, structural on the left _++_ : {A : Set} → List A → List A → List A [] ++ l₂ = l₂ (h :: l₁) ++ l₂ = h :: (l₁ ++ l₂) -- list membership, as a proposition data _inList_ {A : Set} : A → List A → Set where InH : {a : A} {as : List A} → a inList (a :: as) InT : {a a' : A} {as : List A} → a inList as → a inList (a' :: as) -- if everything isn't in a list, it's the empty list ∅∈l→l==[] : {A : Set} {l : List A} → ((a : A) → a inList l → ⊥) → l == [] ∅∈l→l==[] {l = []} h = refl ∅∈l→l==[] {l = a' :: as} h = abort (h a' InH) -- if a isn't in a cons, it's not in the tail either a∉a'::as→a∉as : {A : Set} {as : List A} {a a' : A} → (a inList (a' :: as) → ⊥) → a inList as → ⊥ a∉a'::as→a∉as h h' = h (InT h') -- if x isn't in either side of an append, it's not in the result not-in-append-comm : {A : Set} {x : A} {l₁ l₂ : List A} → dec A → (x inList l₁ → ⊥) → (x inList l₂ → ⊥) → x inList (l₁ ++ l₂) → ⊥ not-in-append-comm {l₁ = []} dec h₁ h₂ h₃ = h₂ h₃ not-in-append-comm {x = x} {a₁ :: _} dec h₁ h₂ h₃ with dec a₁ x not-in-append-comm {l₁ = l₁} dec h₁ h₂ h₃ | Inl h = h₁ (tr (λ y → y inList l₁) h InH) not-in-append-comm dec h₁ h₂ InH | Inr h = abort (h refl) not-in-append-comm dec h₁ h₂ (InT h₃) | Inr h = not-in-append-comm dec (a∉a'::as→a∉as h₁) h₂ h₃ remove-all : {A : Set} → dec A → List A → A → List A remove-all dec [] a = [] remove-all dec (a' :: as) a with dec a a' | remove-all dec as a ... | Inl _ | l' = l' ... | Inr _ | l' = a' :: l' -- (homomorphism) removing distributes over append remove-all-append-comm : {A : Set} → (dec : dec A) → (l₁ l₂ : List A) → (a : A) → remove-all dec l₁ a ++ remove-all dec l₂ a == remove-all dec (l₁ ++ l₂) a remove-all-append-comm dec [] l₂ a = refl remove-all-append-comm dec (a₁ :: as₁) l₂ a with dec a a₁ | remove-all-append-comm dec as₁ l₂ a remove-all-append-comm dec (a₁ :: as₁) l₂ a | Inl refl | h = h remove-all-append-comm dec (a₁ :: as₁) l₂ a | Inr _ | h = ap1 (λ y → a₁ :: y) h -- an element isn't in the list that results from removing all instances of it remove-all-not-in : {A : Set} → (dec : dec A) → (l : List A) → (a : A) → a inList remove-all dec l a → ⊥ remove-all-not-in dec [] a () remove-all-not-in dec (a' :: as) a h with dec a a' remove-all-not-in dec (a' :: as) a h | Inl refl = remove-all-not-in dec as a' h remove-all-not-in dec (a' :: as) .a' InH | Inr a≠a' = a≠a' refl remove-all-not-in dec (a' :: as) a (InT h) | Inr a≠a' = remove-all-not-in dec as a h -- an element that was never in a list still isn't once you remove any element. a∉l→a∉remove-all-l-a' : {A : Set} → {l : List A} → {a a' : A} → (dec : dec A) → (a inList l → ⊥) → a inList remove-all dec l a' → ⊥ a∉l→a∉remove-all-l-a' {l = []} {a} _ h₁ h₂ = h₁ h₂ a∉l→a∉remove-all-l-a' {l = lh :: lt} {a} {a'} dec h₁ h₂ with dec a lh | dec a' lh a∉l→a∉remove-all-l-a' {l = lh :: lt} {a} dec h₁ h₂ | Inl a==lh | _ = h₁ (tr (λ y → a inList (y :: lt) ) a==lh InH) a∉l→a∉remove-all-l-a' {l = lh :: lt} dec h₁ h₂ | Inr _ | Inl _ = a∉l→a∉remove-all-l-a' dec (a∉a'::as→a∉as h₁) h₂ a∉l→a∉remove-all-l-a' {l = lh :: lt} dec h₁ InH | Inr a≠lh | Inr _ = a≠lh refl a∉l→a∉remove-all-l-a' {l = lh :: lt} dec h₁ (InT h₂) | Inr _ | Inr _ = a∉l→a∉remove-all-l-a' dec (a∉a'::as→a∉as h₁) h₂ -- if an element is in an append, it's in one side or the other inList++ : {A : Set} {x : A} → ∀{l1 l2} → dec A → x inList (l1 ++ l2) → (x inList l1) + (x inList l2) inList++ {l1 = []} dec xin = Inr xin inList++ {x = x} {l1 = a :: l1} dec inl with dec x a inList++ {x = .a} {a :: l1} dec inl | Inl refl = Inl InH inList++ {x = .a} {a :: l1} dec InH | Inr x₁ = abort (x₁ refl) inList++ {x = x} {a :: l1} dec (InT inl) | Inr x₁ with inList++ {l1 = l1} dec inl inList++ {x = x} {a :: l1} dec (InT inl) | Inr x₁ | Inl x₂ = Inl (InT x₂) inList++ {x = x} {a :: l1} dec (InT inl) | Inr x₁ | Inr x₂ = Inr x₂
{ "alphanum_fraction": 0.4516327788, "avg_line_length": 50.1958762887, "ext": "agda", "hexsha": "96513ee4581472813b09d336cbfe93d9b8723060", "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": "c3225acc3c94c56376c6842b82b8b5d76912df2a", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "hazelgrove/hazelnut-livelits-agda", "max_forks_repo_path": "List.agda", "max_issues_count": 9, "max_issues_repo_head_hexsha": "c3225acc3c94c56376c6842b82b8b5d76912df2a", "max_issues_repo_issues_event_max_datetime": "2020-10-20T20:44:13.000Z", "max_issues_repo_issues_event_min_datetime": "2020-09-30T20:27:56.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "hazelgrove/hazel-palette-agda", "max_issues_repo_path": "List.agda", "max_line_length": 134, "max_stars_count": 4, "max_stars_repo_head_hexsha": "c3225acc3c94c56376c6842b82b8b5d76912df2a", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "hazelgrove/hazel-palette-agda", "max_stars_repo_path": "List.agda", "max_stars_repo_stars_event_max_datetime": "2021-12-19T15:38:31.000Z", "max_stars_repo_stars_event_min_datetime": "2020-10-04T06:45:06.000Z", "num_tokens": 1877, "size": 4869 }
-- Andreas, 2012-01-13 module Issue555a where -- Do we want to allow this? data Exp : Set → Set1 data Exp Γ where -- needs to report that too many parameters are given var : Exp Γ bla : {Δ : Set} → Exp Δ → Exp (Δ → Γ) → Exp Γ -- A declared index is turned into a parameter by the definition. data ℕ : Set where zero : ℕ suc : ℕ → ℕ data Vec : Set → ℕ → Set data Vec A where nil : Vec A zero _∷_ : {n : ℕ} → A → Vec A n → Vec A (suc n)
{ "alphanum_fraction": 0.6194690265, "avg_line_length": 22.6, "ext": "agda", "hexsha": "e1fa32c88e9be57be97131284acbb206996a7cfc", "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/Issue555a.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/Issue555a.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/Issue555a.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 156, "size": 452 }
open import SOAS.Common {- Framework for constructing categories of objects with extra structure. The definitions required to construct a category is: * the category of carrier objects (e.g. sets, presheaves, etc.) * the extra operations and laws that the carrier objects are equipped with * the preservation properties of morphisms between the structures * proofs that the identities and composition of the carrier category preserve the extra structure -} module SOAS.Construction.Structure (CarrierCat : Category 1ℓ 0ℓ 0ℓ) (HasStruct : Category.Obj CarrierCat → Set) where private module ℂ = Category CarrierCat -- The carrier of the structure, e.g. sets, presheaves, etc. Carrier : Set₁ Carrier = ℂ.Obj infix 1 _⋉_ -- Objects in the category for the structure: a carrier object together with -- the algebraic structure record Object : Set₁ where constructor _⋉_ field 𝐶 : Carrier ˢ : HasStruct 𝐶 open Object public -- Properties of the morphisms between two objects, usually concerning -- the preservation of the extra operations MorphismProps : Set₁ MorphismProps = {𝐶₁ 𝐶₂ : Carrier} → HasStruct 𝐶₁ → HasStruct 𝐶₂ → CarrierCat [ 𝐶₁ , 𝐶₂ ] → Set -- Morphisms in the category for the algebraic structure: an underlying -- morphism with preservation properties of the extra structure record Morphism (IsHomomorphism : MorphismProps) (O₁ O₂ : Object) : Set where constructor _⋉_ field 𝑓 : CarrierCat [ 𝐶 O₁ , 𝐶 O₂ ] ˢ⇒ : IsHomomorphism (ˢ O₁)(ˢ O₂) 𝑓 open Morphism public -- Properties required to turn the objects and morphisms into a category; namely -- that the identity and composition in the carrier category are homomorphisms record CategoryProps : Set₁ where field IsHomomorphism : MorphismProps id-hom : {𝐶 : Carrier}{𝐶ˢ : HasStruct 𝐶} → IsHomomorphism 𝐶ˢ 𝐶ˢ ℂ.id comp-hom : {𝐶 𝐷 𝐸 : Carrier} {𝐶ˢ : HasStruct 𝐶}{𝐷ˢ : HasStruct 𝐷}{𝐸ˢ : HasStruct 𝐸} → (𝑔 : CarrierCat [ 𝐷 , 𝐸 ])(𝑓 : CarrierCat [ 𝐶 , 𝐷 ]) → (𝑔ʰ : IsHomomorphism 𝐷ˢ 𝐸ˢ 𝑔)(𝑓ʰ : IsHomomorphism 𝐶ˢ 𝐷ˢ 𝑓) → IsHomomorphism 𝐶ˢ 𝐸ˢ (𝑔 ℂ.∘ 𝑓) module _ (P : CategoryProps) where open CategoryProps P -- Category generated from the algebraic structure StructCat : Category 1ℓ 0ℓ 0ℓ StructCat = categoryHelper (record { Obj = Object ; _⇒_ = Morphism IsHomomorphism ; _≈_ = λ g₁ g₂ → 𝑓 g₁ ℂ.≈ 𝑓 g₂ ; id = ℂ.id ⋉ id-hom ; _∘_ = λ{ (𝑔 ⋉ 𝑔ˢ⇒) (𝑓 ⋉ 𝑓ˢ⇒) → (𝑔 ℂ.∘ 𝑓) ⋉ (comp-hom 𝑔 𝑓 𝑔ˢ⇒ 𝑓ˢ⇒)} ; assoc = ℂ.assoc ; identityˡ = ℂ.identityˡ ; identityʳ = ℂ.identityʳ ; equiv = record { refl = ℂ.Equiv.refl ; sym = ℂ.Equiv.sym ; trans = ℂ.Equiv.trans } ; ∘-resp-≈ = ℂ.∘-resp-≈ }) -- Forget the structure of a carrier object Forget : Object → Carrier Forget (𝐶 ⋉ _) = 𝐶 -- Forgetful functor from the structure category to the carrier category ForgetF : Functor StructCat CarrierCat ForgetF = record { F₀ = Forget ; F₁ = λ (𝑓 ⋉ _) → 𝑓 ; identity = ℂ.Equiv.refl ; homomorphism = ℂ.Equiv.refl ; F-resp-≈ = λ x → x } where open ≡-Reasoning -- Free constructions with respect to the forgetful functor module Free where open import SOAS.Construction.Free ForgetF public
{ "alphanum_fraction": 0.6717417783, "avg_line_length": 31.8834951456, "ext": "agda", "hexsha": "f58713df891456aae68829fc3fbd7bd34db45244", "lang": "Agda", "max_forks_count": 4, "max_forks_repo_forks_event_max_datetime": "2022-01-24T12:49:17.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-09T20:39:59.000Z", "max_forks_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "JoeyEremondi/agda-soas", "max_forks_repo_path": "SOAS/Construction/Structure.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8", "max_issues_repo_issues_event_max_datetime": "2021-11-21T12:19:32.000Z", "max_issues_repo_issues_event_min_datetime": "2021-11-21T12:19:32.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "JoeyEremondi/agda-soas", "max_issues_repo_path": "SOAS/Construction/Structure.agda", "max_line_length": 88, "max_stars_count": 39, "max_stars_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "JoeyEremondi/agda-soas", "max_stars_repo_path": "SOAS/Construction/Structure.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-19T17:33:12.000Z", "max_stars_repo_stars_event_min_datetime": "2021-11-09T20:39:55.000Z", "num_tokens": 1162, "size": 3284 }
{-# OPTIONS --without-K --safe #-} open import Categories.Category.Core module Categories.Morphism.Extremal.Properties {o ℓ e} (𝒞 : Category o ℓ e) where open import Level open import Function using (_$_) open import Categories.Diagram.Equalizer 𝒞 open import Categories.Diagram.Coequalizer 𝒞 open import Categories.Morphism 𝒞 open import Categories.Morphism.Extremal 𝒞 open import Categories.Morphism.Properties 𝒞 open import Categories.Morphism.Reasoning 𝒞 open import Categories.Morphism.Regular 𝒞 open Category 𝒞 open HomReasoning private variable A B : Obj f g : A ⇒ B -------------------------------------------------------------------------------- -- Extremal Epimorphisms RegularEpi⇒IsExtremalEpi : ∀ {A B} {f : A ⇒ B} (e : RegularEpi f) → IsExtremalEpi (RegularEpi⇒Epi e) RegularEpi⇒IsExtremalEpi {A = A} {B = B} {f = f} regular {X = X} {i = i} {g = k} i-mono f≈i∘k = record { inv = i⁻¹ ; iso = record { isoˡ = isoˡ ; isoʳ = isoʳ } } where open RegularEpi regular renaming (g to r; h to s) open IsCoequalizer coequalizer i⁻¹ : B ⇒ X i⁻¹ = coequalize $ i-mono (k ∘ s) (k ∘ r) $ begin i ∘ k ∘ s ≈⟨ pullˡ (⟺ f≈i∘k) ⟩ f ∘ s ≈⟨ equality ⟩ f ∘ r ≈⟨ pushˡ f≈i∘k ⟩ i ∘ k ∘ r ∎ isoʳ : i ∘ i⁻¹ ≈ id isoʳ = RegularEpi⇒Epi regular (i ∘ i⁻¹) id $ begin (i ∘ i⁻¹) ∘ f ≈⟨ pullʳ (⟺ universal) ⟩ i ∘ k ≈˘⟨ f≈i∘k ⟩ f ≈˘⟨ identityˡ ⟩ id ∘ f ∎ isoˡ : i⁻¹ ∘ i ≈ id isoˡ = i-mono (i⁻¹ ∘ i) id $ begin i ∘ i⁻¹ ∘ i ≈⟨ cancelˡ isoʳ ⟩ i ≈˘⟨ identityʳ ⟩ i ∘ id ∎ RegularEpi⇒ExtremalEpi : (e : RegularEpi f) → ExtremalEpi f RegularEpi⇒ExtremalEpi e = record { epi = RegularEpi⇒Epi e ; extremal = RegularEpi⇒IsExtremalEpi e } ExtremalEpi-∘₂ : ExtremalEpi (f ∘ g) → ExtremalEpi f ExtremalEpi-∘₂ fg-extremal = record { epi = Epi-∘₂ epi ; extremal = λ i-mono eq → extremal i-mono (pushˡ eq) } where open ExtremalEpi fg-extremal ExtremalEpi-∘ : ∀ {A B C} {f : B ⇒ C} {g : A ⇒ B} → ExtremalEpi f → RegularEpi g → ExtremalEpi (f ∘ g) ExtremalEpi-∘ {A = A} {B = B} {C = C} {f = f} {g = g} f-extremal g-regular = record { epi = fg-epi ; extremal = fg-extremal } where module f-extremal = ExtremalEpi f-extremal module g-regular = RegularEpi g-regular open IsCoequalizer g-regular.coequalizer g-epi : Epi g g-epi = RegularEpi⇒Epi g-regular fg-epi : Epi (f ∘ g) fg-epi = Epi-∘ f-extremal.epi g-epi fg-extremal : IsExtremalEpi fg-epi fg-extremal {X = X} {i = i} {g = h} i-mono f∘g≈i∘h = f-extremal.extremal i-mono $ g-epi _ _ $ begin f ∘ g ≈⟨ f∘g≈i∘h ⟩ i ∘ h ≈⟨ pushʳ universal ⟩ (i ∘ k) ∘ g ∎ where k : B ⇒ X k = coequalize $ i-mono _ _ $ begin i ∘ h ∘ g-regular.h ≈⟨ extendʳ (⟺ f∘g≈i∘h) ⟩ f ∘ g ∘ g-regular.h ≈⟨ refl⟩∘⟨ equality ⟩ f ∘ g ∘ g-regular.g ≈⟨ extendʳ f∘g≈i∘h ⟩ i ∘ h ∘ g-regular.g ∎ ExtremalEpi+Mono⇒IsIso : ExtremalEpi f → Mono f → IsIso f ExtremalEpi+Mono⇒IsIso {f = f} f-extremal f-mono = extremal f-mono (⟺ identityʳ) where open ExtremalEpi f-extremal -------------------------------------------------------------------------------- -- Extremal Monomorphisms RegularMono⇒IsExtremalMono : ∀ {A B} {f : A ⇒ B} (m : RegularMono f) → IsExtremalMono (RegularMono⇒Mono m) RegularMono⇒IsExtremalMono {A = A} {B = B} {f = f} regular {X = X} {g = k} {i = i} i-epi f≈k∘i = record { inv = i⁻¹ ; iso = record { isoˡ = isoˡ ; isoʳ = isoʳ } } where open RegularMono regular renaming (g to r; h to s) open IsEqualizer equalizer i⁻¹ : X ⇒ A i⁻¹ = equalize $ i-epi (s ∘ k) (r ∘ k) $ begin (s ∘ k) ∘ i ≈⟨ pullʳ (⟺ f≈k∘i) ⟩ s ∘ f ≈⟨ equality ⟩ r ∘ f ≈⟨ pushʳ f≈k∘i ⟩ (r ∘ k) ∘ i ∎ isoˡ : i⁻¹ ∘ i ≈ id isoˡ = RegularMono⇒Mono regular (i⁻¹ ∘ i) id $ begin f ∘ i⁻¹ ∘ i ≈⟨ pullˡ (⟺ universal) ⟩ k ∘ i ≈˘⟨ f≈k∘i ⟩ f ≈˘⟨ identityʳ ⟩ f ∘ id ∎ isoʳ : i ∘ i⁻¹ ≈ id isoʳ = i-epi (i ∘ i⁻¹) id $ begin (i ∘ i⁻¹) ∘ i ≈⟨ cancelʳ isoˡ ⟩ i ≈˘⟨ identityˡ ⟩ id ∘ i ∎ RegularMono⇒ExtremalMono : RegularMono f → ExtremalMono f RegularMono⇒ExtremalMono m = record { mono = RegularMono⇒Mono m ; extremal = RegularMono⇒IsExtremalMono m } ExtremalMono-∘₂ : ExtremalMono (f ∘ g) → ExtremalMono g ExtremalMono-∘₂ fg-extremal = record { mono = Mono-∘₂ mono ; extremal = λ i-epi eq → extremal i-epi (pushʳ eq) } where open ExtremalMono fg-extremal ExtremalMono-∘ : ∀ {A B C} {f : B ⇒ C} {g : A ⇒ B} → RegularMono f → ExtremalMono g → ExtremalMono (f ∘ g) ExtremalMono-∘ {A = A} {B = B} {f = f} {g = g} f-regular g-extremal = record { mono = fg-mono ; extremal = fg-extremal } where module f-regular = RegularMono f-regular open IsEqualizer f-regular.equalizer module g-extremal = ExtremalMono g-extremal f-mono : Mono f f-mono = (RegularMono⇒Mono f-regular) fg-mono : Mono (f ∘ g) fg-mono = Mono-∘ f-mono g-extremal.mono fg-extremal : IsExtremalMono fg-mono fg-extremal {X = X} {g = h} {i = e} e-epi f∘g≈h∘e = g-extremal.extremal e-epi $ f-mono _ _ $ begin f ∘ g ≈⟨ f∘g≈h∘e ⟩ h ∘ e ≈⟨ pushˡ universal ⟩ f ∘ k ∘ e ∎ where k : X ⇒ B k = equalize $ e-epi _ _ $ begin (f-regular.h ∘ h) ∘ e ≈⟨ extendˡ (⟺ f∘g≈h∘e) ⟩ (f-regular.h ∘ f) ∘ g ≈⟨ equality ⟩∘⟨refl ⟩ (f-regular.g ∘ f) ∘ g ≈⟨ extendˡ f∘g≈h∘e ⟩ (f-regular.g ∘ h) ∘ e ∎ ExtremalMono+Epi⇒IsIso : ExtremalMono f → Epi f → IsIso f ExtremalMono+Epi⇒IsIso {f = f} f-extremal f-epi = extremal f-epi (⟺ identityˡ) where open ExtremalMono f-extremal -------------------------------------------------------------------------------- -- Extremal Morphisms in Balanced Categories -- https://ncatlab.org/nlab/show/balanced+category module _ (balanced : ∀ {A B} {f : A ⇒ B} → Mono f → Epi f → IsIso f) where Mono+Epi⇒IsExtremalEpi : (e : Epi f) → IsExtremalEpi e Mono+Epi⇒IsExtremalEpi {f = f} f-epi {i = i} {g = g} i-mono f≈i∘g = balanced i-mono i-epi where i-epi : Epi i i-epi g₁ g₂ g₁∘i≈g₂∘i = f-epi g₁ g₂ $ begin g₁ ∘ f ≈⟨ pushʳ f≈i∘g ⟩ (g₁ ∘ i) ∘ g ≈⟨ g₁∘i≈g₂∘i ⟩∘⟨refl ⟩ (g₂ ∘ i) ∘ g ≈⟨ pullʳ (⟺ f≈i∘g) ⟩ g₂ ∘ f ∎ Mono+Epi⇒IsExtremalMono : (m : Mono f) → IsExtremalMono m Mono+Epi⇒IsExtremalMono {f = f} f-mono {g = g} {i = i} i-epi f≈g∘i = balanced i-mono i-epi where i-mono : Mono i i-mono g₁ g₂ i∘g₁≈i∘g₂ = f-mono g₁ g₂ $ begin f ∘ g₁ ≈⟨ pushˡ f≈g∘i ⟩ g ∘ i ∘ g₁ ≈⟨ refl⟩∘⟨ i∘g₁≈i∘g₂ ⟩ g ∘ i ∘ g₂ ≈⟨ pullˡ (⟺ f≈g∘i) ⟩ f ∘ g₂ ∎
{ "alphanum_fraction": 0.530762565, "avg_line_length": 31.1891891892, "ext": "agda", "hexsha": "c15eb7de05cea4fd91ad1bcf1fae3974c04f7235", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "8f3c844d929508040dfa21f681fa260056214b73", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "maxsnew/agda-categories", "max_forks_repo_path": "src/Categories/Morphism/Extremal/Properties.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "8f3c844d929508040dfa21f681fa260056214b73", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "maxsnew/agda-categories", "max_issues_repo_path": "src/Categories/Morphism/Extremal/Properties.agda", "max_line_length": 106, "max_stars_count": null, "max_stars_repo_head_hexsha": "8f3c844d929508040dfa21f681fa260056214b73", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "maxsnew/agda-categories", "max_stars_repo_path": "src/Categories/Morphism/Extremal/Properties.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 3109, "size": 6924 }
{-# OPTIONS --safe #-} module Cubical.Algebra.Group.Instances.Int where open import Cubical.Foundations.Prelude open import Cubical.Data.Int renaming (Int to IntType ; _+_ to _+Int_ ; _-_ to _-Int_; -_ to -Int_ ; _·_ to _·Int_) open import Cubical.Algebra.Group.Base open GroupStr Int : Group₀ fst Int = IntType 1g (snd Int) = 0 _·_ (snd Int) = _+Int_ inv (snd Int) = _-Int_ 0 isGroup (snd Int) = isGroupInt where abstract isGroupInt : IsGroup (pos 0) _+Int_ (_-Int_ (pos 0)) isGroupInt = makeIsGroup isSetInt +-assoc (λ x → refl) (λ x → +-comm 0 x) (λ x → +-comm x (pos 0 -Int x) ∙ minusPlus x 0) (λ x → minusPlus x 0)
{ "alphanum_fraction": 0.6436090226, "avg_line_length": 31.6666666667, "ext": "agda", "hexsha": "76030b039e3631979f1d3847c2587969bd6af914", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-03-12T20:08:45.000Z", "max_forks_repo_forks_event_min_datetime": "2021-03-12T20:08:45.000Z", "max_forks_repo_head_hexsha": "94b474af2909727d04706d562d949928c19faf7b", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "jespercockx/cubical", "max_forks_repo_path": "Cubical/Algebra/Group/Instances/Int.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "94b474af2909727d04706d562d949928c19faf7b", "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": "jespercockx/cubical", "max_issues_repo_path": "Cubical/Algebra/Group/Instances/Int.agda", "max_line_length": 115, "max_stars_count": null, "max_stars_repo_head_hexsha": "94b474af2909727d04706d562d949928c19faf7b", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "jespercockx/cubical", "max_stars_repo_path": "Cubical/Algebra/Group/Instances/Int.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 233, "size": 665 }
{-# OPTIONS --without-K #-} -- This module implements the dependent Σ-type. module hott.core.sigma where open import hott.core.universe record Σ {ℓ₀ ℓ₁} {A : Type ℓ₀} (B : A → Type ℓ₁) : Type (ℓ₀ ⊔ ℓ₁) where constructor _,_ field proj₁ : A proj₂ : B proj₁ -- The product type is just the non-dependent Σ-type. _×_ : ∀{ℓ₀ ℓ₁} (A : Type ℓ₀) (B : Type ℓ₁) → Type (ℓ₀ ⊔ ℓ₁) A × B = Σ λ (_ : A) → B -- Since the , constructor is infixr, we can write (a , (b , c)) as -- just (a , b , c). The convention that we follow for tuples is that -- of a list. We assign the paring function the least precedence -- because we would like to write all other stuff inside the tuple -- naturally e.g. (p ≡ q , q ≡ r) etc. We ensure that no other -- operator has 0 precedence. infixr 0 _,_ infixr 0 _×_ -- The projection to the first component. fst : ∀{ℓ₀ ℓ₁} {A : Type ℓ₀} {B : A → Type ℓ₁} → Σ B → A fst = Σ.proj₁ -- The projection to the second component. snd : ∀{ℓ₀ ℓ₁} {A : Type ℓ₀} {B : A → Type ℓ₁} → (σ : Σ B) → B (fst σ) snd = Σ.proj₂
{ "alphanum_fraction": 0.608897127, "avg_line_length": 26.975, "ext": "agda", "hexsha": "4c7a3600d00485d0d260c567534221ffb985ae5e", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "876ecdcfddca1abf499e8f00db321c6dc3d5b2bc", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "piyush-kurur/hott", "max_forks_repo_path": "agda/hott/core/sigma.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "876ecdcfddca1abf499e8f00db321c6dc3d5b2bc", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "piyush-kurur/hott", "max_issues_repo_path": "agda/hott/core/sigma.agda", "max_line_length": 69, "max_stars_count": null, "max_stars_repo_head_hexsha": "876ecdcfddca1abf499e8f00db321c6dc3d5b2bc", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "piyush-kurur/hott", "max_stars_repo_path": "agda/hott/core/sigma.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 393, "size": 1079 }
{-# OPTIONS --without-K --safe #-} open import Categories.Category.Core open import Categories.Comonad -- verbatim dual of Categories.Adjoint.Construction.EilenbergMoore module Categories.Adjoint.Construction.CoEilenbergMoore {o ℓ e} {C : Category o ℓ e} (M : Comonad C) where open import Categories.Category.Construction.CoEilenbergMoore M open import Categories.Adjoint open import Categories.Functor open import Categories.Functor.Properties open import Categories.NaturalTransformation.NaturalIsomorphism using (niHelper) open import Categories.NaturalTransformation.Core open import Categories.NaturalTransformation.NaturalIsomorphism using (_≃_) open import Categories.Morphism.Reasoning C private module C = Category C module M = Comonad M open M.F open C open HomReasoning open Equiv Forgetful : Functor CoEilenbergMoore C Forgetful = record { F₀ = Comodule.A ; F₁ = Comodule⇒.arr ; identity = refl ; homomorphism = refl ; F-resp-≈ = λ eq → eq } Cofree : Functor C CoEilenbergMoore Cofree = record { F₀ = λ A → record { A = F₀ A ; coaction = M.δ.η A ; commute = M.sym-assoc ; identity = Comonad.identityʳ M } ; F₁ = λ f → record { arr = F₁ f ; commute = M.δ.commute f } ; identity = identity ; homomorphism = homomorphism ; F-resp-≈ = F-resp-≈ } UC≃M : Forgetful ∘F Cofree ≃ M.F UC≃M = niHelper (record { η = λ _ → F₁ C.id ; η⁻¹ = λ _ → F₁ C.id ; commute = λ f → [ M.F ]-resp-square id-comm-sym ; iso = λ _ → record { isoˡ = elimˡ identity ○ identity ; isoʳ = elimˡ identity ○ identity } }) Forgetful⊣Cofree : Forgetful ⊣ Cofree Forgetful⊣Cofree = record { unit = record { η = λ X → let module X = Comodule X in record { arr = X.coaction ; commute = ⟺ X.commute } ; commute = Comodule⇒.commute ; sym-commute = λ f → ⟺ (Comodule⇒.commute f) } ; counit = record { η = M.ε.η ; commute = M.ε.commute ; sym-commute = M.ε.sym-commute } ; zig = λ {A} → Comodule.identity A ; zag = λ {B} → Comonad.identityˡ M }
{ "alphanum_fraction": 0.6644067797, "avg_line_length": 25.4938271605, "ext": "agda", "hexsha": "d4ba7604f17c7640d7e3d07fe6c26364dd714bbc", "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/Adjoint/Construction/CoEilenbergMoore.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/Adjoint/Construction/CoEilenbergMoore.agda", "max_line_length": 106, "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/Adjoint/Construction/CoEilenbergMoore.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": 696, "size": 2065 }
------------------------------------------------------------------------------ -- Axiomatic Peano arithmetic base ------------------------------------------------------------------------------ {-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} module PA.Axiomatic.Standard.Base where infixl 7 _*_ infixl 6 _+_ ------------------------------------------------------------------------------ -- First-order logic with equality. open import Common.FOL.FOL-Eq public renaming ( D to ℕ ) -- Common definitions. open import Common.DefinitionsATP -- Non-logical constants postulate zero : ℕ succ : ℕ → ℕ _+_ _*_ : ℕ → ℕ → ℕ -- Proper axioms -- From (Machover 1996, p. 263) and (Hájek and Pudlák 1998, p. 28): -- -- PA₁. 0 ≠ n' -- PA₂. m' = n' → m = n -- PA₃. 0 + n = n -- PA₄. m' + n = (m + n)' -- PA₅. 0 * n = 0 -- PA₆. m' * n = n + (m * n) -- Axiom of induction: -- φ(0) → (∀n.φ(n) → φ(succ n)) → ∀n.φ(n), for any formulae φ postulate PA₁ : ∀ {n} → zero ≢ succ n PA₂ : ∀ {m n} → succ m ≡ succ n → m ≡ n PA₃ : ∀ n → zero + n ≡ n PA₄ : ∀ m n → succ m + n ≡ succ (m + n) PA₅ : ∀ n → zero * n ≡ zero PA₆ : ∀ m n → succ m * n ≡ n + m * n {-# ATP axioms PA₁ PA₂ PA₃ PA₄ PA₅ PA₆ #-} -- The axiom of induction is an axiom schema, therefore we do not -- translate it to TPTP. postulate ℕ-ind : (A : ℕ → Set) → A zero → (∀ n → A n → A (succ n)) → ∀ n → A n ------------------------------------------------------------------------------ -- References -- -- Machover, Moshé (1996). Set theory, Logic and their -- Limitations. Cambridge University Press. -- Hájek, Petr and Pudlák, Pavel (1998). Metamathematics of -- First-Order Arithmetic. 2nd printing. Springer.
{ "alphanum_fraction": 0.471468144, "avg_line_length": 29.1129032258, "ext": "agda", "hexsha": "091823e4663fcf069ee11344f139ef16316cc48b", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "asr/fotc", "max_forks_repo_path": "src/fot/PA/Axiomatic/Standard/Base.agda", "max_issues_count": 2, "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "asr/fotc", "max_issues_repo_path": "src/fot/PA/Axiomatic/Standard/Base.agda", "max_line_length": 78, "max_stars_count": 11, "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/fotc", "max_stars_repo_path": "src/fot/PA/Axiomatic/Standard/Base.agda", "max_stars_repo_stars_event_max_datetime": "2021-09-12T16:09:54.000Z", "max_stars_repo_stars_event_min_datetime": "2015-09-03T20:53:42.000Z", "num_tokens": 565, "size": 1805 }
{-# OPTIONS --without-K #-} module Data.ByteString.IO where import Data.ByteString.Primitive as Prim open import Data.ByteString open import Data.Word8 using (Word8) open import Data.Nat using (ℕ) open import Data.Colist using (Colist) open import Data.List using (List) open import Data.String using (String) open import IO using (IO; _>>_; _>>=_; lift; return) open import Data.Unit using (⊤) open import Coinduction using (♯_) readBinaryFile : ∀ {k} → String → IO (ByteString k) readBinaryFile {Lazy} f = lift (Prim.readBinaryFileLazy f) readBinaryFile {Strict} f = lift (Prim.readBinaryFileStrict f) readBinaryFile′ : ∀ {k} → String → IO (ByteStringRep k) readBinaryFile′ {k} f = ♯ readBinaryFile f >>= (λ bs → ♯ return (unpack bs)) writeBinaryFile : ∀ {k} → String → ByteString k → IO ⊤ writeBinaryFile {Lazy} f s = ♯ lift (Prim.writeBinaryFileLazy f s) >> ♯ return _ writeBinaryFile {Strict} f s = ♯ lift (Prim.writeBinaryFileStrict f s) >> ♯ return _ writeBinaryFile′ : ∀ {k} → String → ByteStringRep k → IO ⊤ writeBinaryFile′ {k} f bs = writeBinaryFile f (pack bs)
{ "alphanum_fraction": 0.706959707, "avg_line_length": 28.7368421053, "ext": "agda", "hexsha": "897582f1c0ca63a631f558434e8c6a7c52f95471", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "98a53f35fca27e3379cf851a9a6bdfe5bd8c9626", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "semenov-vladyslav/bytes-agda", "max_forks_repo_path": "src/Data/ByteString/IO.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "98a53f35fca27e3379cf851a9a6bdfe5bd8c9626", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "semenov-vladyslav/bytes-agda", "max_issues_repo_path": "src/Data/ByteString/IO.agda", "max_line_length": 76, "max_stars_count": null, "max_stars_repo_head_hexsha": "98a53f35fca27e3379cf851a9a6bdfe5bd8c9626", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "semenov-vladyslav/bytes-agda", "max_stars_repo_path": "src/Data/ByteString/IO.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 321, "size": 1092 }
------------------------------------------------------------------------------ -- Mutual recursive functions ------------------------------------------------------------------------------ {-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} module FOT.FOTC.Data.Nat.MutualRecursiveFunctions where open import FOTC.Base open import FOTC.Data.Nat.UnaryNumbers ------------------------------------------------------------------------------ postulate even : D → D odd : D → D even-0 : even zero ≡ true even-S : ∀ d → even (succ₁ d) ≡ odd d odd-0 : odd zero ≡ false odd-S : ∀ d → odd (succ₁ d) ≡ even d {-# ATP axioms even-0 even-S odd-0 odd-S #-} postulate even-2 : even 2' ≡ true {-# ATP prove even-2 #-} postulate even-3 : even 3' ≡ false {-# ATP prove even-3 #-} postulate odd-2 : odd 2' ≡ false {-# ATP prove odd-2 #-} postulate odd-3 : odd 3' ≡ true {-# ATP prove odd-3 #-}
{ "alphanum_fraction": 0.4451923077, "avg_line_length": 26.6666666667, "ext": "agda", "hexsha": "dc225caf35e9dd212e56f088263d129ae2e92d8e", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "asr/fotc", "max_forks_repo_path": "notes/FOT/FOTC/Data/Nat/MutualRecursiveFunctions.agda", "max_issues_count": 2, "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "asr/fotc", "max_issues_repo_path": "notes/FOT/FOTC/Data/Nat/MutualRecursiveFunctions.agda", "max_line_length": 78, "max_stars_count": 11, "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/fotc", "max_stars_repo_path": "notes/FOT/FOTC/Data/Nat/MutualRecursiveFunctions.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": 255, "size": 1040 }
{-# OPTIONS --sized-types #-} open import Relation.Binary.Core module Mergesort.Impl1 {A : Set} (_≤_ : A → A → Set) (tot≤ : Total _≤_) where open import Bound.Lower A open import Bound.Lower.Order _≤_ open import Data.Product open import Data.Sum open import Size open import SList open import SOList.Lower _≤_ deal : {ι : Size} → SList A {ι} → SList A {ι} × SList A {ι} deal snil = (snil , snil) deal (x ∙ snil) = (x ∙ snil , snil) deal (x ∙ (y ∙ xs)) with deal xs ... | (ys , zs) = (x ∙ ys , y ∙ zs) merge : {ι ι' : Size}{b : Bound} → SOList {ι} b → SOList {ι'} b → SOList b merge onil ys = ys merge xs onil = xs merge (:< {x = x} b≤x xs) (:< {x = y} b≤y ys) with tot≤ x y ... | inj₁ x≤y = :< b≤x (merge xs (:< (lexy x≤y) ys)) ... | inj₂ y≤x = :< b≤y (merge (:< (lexy y≤x) xs) ys) mergesort : {ι : Size} → SList A {↑ ι} → SOList bot mergesort snil = onil mergesort (x ∙ snil) = :< {x = x} lebx onil mergesort (x ∙ (y ∙ xs)) with deal xs ... | (ys , zs) = merge (mergesort (x ∙ ys)) (mergesort (y ∙ zs))
{ "alphanum_fraction": 0.5481758653, "avg_line_length": 28.8918918919, "ext": "agda", "hexsha": "bf5619ee91afa276edd084c120ef7bcc36b5682f", "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/Mergesort/Impl1.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/Mergesort/Impl1.agda", "max_line_length": 75, "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/Mergesort/Impl1.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": 444, "size": 1069 }
{-# OPTIONS --without-K --safe #-} open import Categories.Category module Categories.Category.BicartesianClosed {o ℓ e} (𝒞 : Category o ℓ e) where open import Level open import Categories.Category.CartesianClosed 𝒞 open import Categories.Category.Cocartesian 𝒞 record BicartesianClosed : Set (levelOfTerm 𝒞) where field cartesianClosed : CartesianClosed cocartesian : Cocartesian module cartesianClosed = CartesianClosed cartesianClosed module cocartesian = Cocartesian cocartesian open cartesianClosed public open cocartesian public
{ "alphanum_fraction": 0.7813051146, "avg_line_length": 25.7727272727, "ext": "agda", "hexsha": "dda23fc72e4fff896674e51df089381d3d2ee8ae", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "58e5ec015781be5413bdf968f7ec4fdae0ab4b21", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "MirceaS/agda-categories", "max_forks_repo_path": "src/Categories/Category/BicartesianClosed.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "58e5ec015781be5413bdf968f7ec4fdae0ab4b21", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "MirceaS/agda-categories", "max_issues_repo_path": "src/Categories/Category/BicartesianClosed.agda", "max_line_length": 79, "max_stars_count": null, "max_stars_repo_head_hexsha": "58e5ec015781be5413bdf968f7ec4fdae0ab4b21", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "MirceaS/agda-categories", "max_stars_repo_path": "src/Categories/Category/BicartesianClosed.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 142, "size": 567 }
open import Prelude open import Data.Nat open import Data.Nat.Properties open import Induction.Nat module Implicits.Resolution.GenericFinite.Examples.MaximumDepth where open import Implicits.Resolution.GenericFinite.TerminationCondition _<′?_ : (x y : ℕ) → Dec (x <′ y) x <′? y with (suc x) ≤? y x <′? y | yes p = yes (≤⇒≤′ p) x <′? y | no ¬p = no (λ p → ¬p (≤′⇒≤ p)) MaxDepthCondition : TerminationCondition MaxDepthCondition = record { TCtx = ℕ ; _<_ = _<′_ ; _<?_ = _<′?_ ; step = λ n _ _ _ _ → n ∸ 1 ; wf-< = <-well-founded }
{ "alphanum_fraction": 0.6304347826, "avg_line_length": 22.08, "ext": "agda", "hexsha": "27775eb790a0231807c88abe2ede4dc58fe819e1", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "7fe638b87de26df47b6437f5ab0a8b955384958d", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "metaborg/ts.agda", "max_forks_repo_path": "src/Implicits/Resolution/GenericFinite/Examples/MaximumDepth.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "7fe638b87de26df47b6437f5ab0a8b955384958d", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "metaborg/ts.agda", "max_issues_repo_path": "src/Implicits/Resolution/GenericFinite/Examples/MaximumDepth.agda", "max_line_length": 67, "max_stars_count": 4, "max_stars_repo_head_hexsha": "7fe638b87de26df47b6437f5ab0a8b955384958d", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "metaborg/ts.agda", "max_stars_repo_path": "src/Implicits/Resolution/GenericFinite/Examples/MaximumDepth.agda", "max_stars_repo_stars_event_max_datetime": "2021-05-07T04:08:41.000Z", "max_stars_repo_stars_event_min_datetime": "2019-04-05T17:57:11.000Z", "num_tokens": 210, "size": 552 }
-- Andreas, 2016-10-03, re issue #2231 -- Testing whether the {-# OPTIONS --guardedness-preserving-type-constructors #-} -- stuff works in abstract blocks -- {-# OPTIONS -v term:30 -v tc.term.expr.coind:100 #-} module AbstractGuardednessPreservingTypeConstructors where infix 1000 ♯_ postulate ∞ : ∀ {a} (A : Set a) → Set a ♯_ : ∀ {a} {A : Set a} → A → ∞ A ♭ : ∀ {a} {A : Set a} → ∞ A → A {-# BUILTIN INFINITY ∞ #-} {-# BUILTIN SHARP ♯_ #-} {-# BUILTIN FLAT ♭ #-} -- Preliminaries. data ⊥ : Set where record ⊤ : Set where constructor tt data Bool : Set where true false : Bool data _⊎_ (A B : Set) : Set where inj₁ : A → A ⊎ B inj₂ : B → A ⊎ B -- Σ cannot be a record type below. data Σ (A : Set) (B : A → Set) : Set where _,_ : (x : A) → B x → Σ A B syntax Σ A (λ x → B) = Σ[ x ∶ A ] B data Rec (A : ∞ Set) : Set where fold : ♭ A → Rec A abstract -- Corecursive definition of the natural numbers. ℕ : Set ℕ = ⊤ ⊎ Rec (♯ ℕ) zero : ℕ zero = inj₁ _ suc : ℕ → ℕ suc n = inj₂ (fold n) ℕ-rec : (P : ℕ → Set) → P zero → (∀ n → P n → P (suc n)) → ∀ n → P n ℕ-rec P z s (inj₁ _) = z ℕ-rec P z s (inj₂ (fold n)) = s n (ℕ-rec P z s n) -- Corecursive definition of the W-type. W : (A : Set) → (A → Set) → Set W A B = Rec (♯ (Σ[ x ∶ A ] (B x → W A B))) syntax W A (λ x → B) = W[ x ∶ A ] B sup : {A : Set} {B : A → Set} (x : A) (f : B x → W A B) → W A B sup x f = fold (x , f) W-rec : {A : Set} {B : A → Set} (P : W A B → Set) → (∀ {x} {f : B x → W A B} → (∀ y → P (f y)) → P (sup x f)) → ∀ x → P x W-rec P h (fold (x , f)) = h (λ y → W-rec P h (f y)) -- Induction-recursion encoded as corecursion-recursion. -- The following definitions are needed on the type level, so we cannot make them abstract. data Label : Set where ′0 ′1 ′2 ′σ ′π ′w : Label mutual U : Set U = Σ Label U′ U′ : Label → Set U′ ′0 = ⊤ U′ ′1 = ⊤ U′ ′2 = ⊤ U′ ′σ = Rec (♯ (Σ[ a ∶ U ] (El a → U))) U′ ′π = Rec (♯ (Σ[ a ∶ U ] (El a → U))) U′ ′w = Rec (♯ (Σ[ a ∶ U ] (El a → U))) El : U → Set El (′0 , _) = ⊥ El (′1 , _) = ⊤ El (′2 , _) = Bool El (′σ , fold (a , b)) = Σ[ x ∶ El a ] El (b x) El (′π , fold (a , b)) = (x : El a) → El (b x) El (′w , fold (a , b)) = W[ x ∶ El a ] El (b x) -- The recursor can be abstract. abstract U-rec : (P : ∀ u → El u → Set) → P (′1 , _) tt → P (′2 , _) true → P (′2 , _) false → (∀ {a b x y} → P a x → P (b x) y → P (′σ , fold (a , b)) (x , y)) → (∀ {a b f} → (∀ x → P (b x) (f x)) → P (′π , fold (a , b)) f) → (∀ {a b x f} → (∀ y → P (′w , fold (a , b)) (f y)) → P (′w , fold (a , b)) (sup x f)) → ∀ u (x : El u) → P u x U-rec P P1 P2t P2f Pσ Pπ Pw = rec where rec : ∀ u (x : El u) → P u x rec (′0 , _) () rec (′1 , _) _ = P1 rec (′2 , _) true = P2t rec (′2 , _) false = P2f rec (′σ , fold (a , b)) (x , y) = Pσ (rec _ x) (rec _ y) rec (′π , fold (a , b)) f = Pπ (λ x → rec _ (f x)) rec (′w , fold (a , b)) (fold (x , f)) = Pw (λ y → rec _ (f y))
{ "alphanum_fraction": 0.4206253758, "avg_line_length": 24.637037037, "ext": "agda", "hexsha": "e057cda29d8963a847512d9ee2eb42a4b87ac06d", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_forks_event_min_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_path": "test/Fail/AbstractGuardednessPreservingTypeConstructors.agda", "max_issues_count": 3, "max_issues_repo_head_hexsha": "aac88412199dd4cbcb041aab499d8a6b7e3f4a2e", "max_issues_repo_issues_event_max_datetime": "2019-04-01T19:39:26.000Z", "max_issues_repo_issues_event_min_datetime": "2018-11-14T15:31:44.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "hborum/agda", "max_issues_repo_path": "test/Fail/AbstractGuardednessPreservingTypeConstructors.agda", "max_line_length": 91, "max_stars_count": 3, "max_stars_repo_head_hexsha": "aac88412199dd4cbcb041aab499d8a6b7e3f4a2e", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "hborum/agda", "max_stars_repo_path": "test/Fail/AbstractGuardednessPreservingTypeConstructors.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": 1398, "size": 3326 }
{-# OPTIONS --allow-unsolved-metas #-} module nat where open import Data.Nat open import Data.Nat.Properties open import Data.Empty open import Relation.Nullary open import Relation.Binary.PropositionalEquality open import Relation.Binary.Core open import Relation.Binary.Definitions open import logic nat-<> : { x y : ℕ } → x < y → y < x → ⊥ nat-<> (s≤s x<y) (s≤s y<x) = nat-<> x<y y<x nat-≤> : { x y : ℕ } → x ≤ y → y < x → ⊥ nat-≤> (s≤s x<y) (s≤s y<x) = nat-≤> x<y y<x nat-<≡ : { x : ℕ } → x < x → ⊥ nat-<≡ (s≤s lt) = nat-<≡ lt nat-≡< : { x y : ℕ } → x ≡ y → x < y → ⊥ nat-≡< refl lt = nat-<≡ lt ¬a≤a : {la : ℕ} → suc la ≤ la → ⊥ ¬a≤a (s≤s lt) = ¬a≤a lt a<sa : {la : ℕ} → la < suc la a<sa {zero} = s≤s z≤n a<sa {suc la} = s≤s a<sa refl-≤s : {x : ℕ } → x ≤ suc x refl-≤s {zero} = z≤n refl-≤s {suc x} = s≤s (refl-≤s {x}) a≤sa : {x : ℕ } → x ≤ suc x a≤sa {zero} = z≤n a≤sa {suc x} = s≤s (a≤sa {x}) =→¬< : {x : ℕ } → ¬ ( x < x ) =→¬< {zero} () =→¬< {suc x} (s≤s lt) = =→¬< lt >→¬< : {x y : ℕ } → (x < y ) → ¬ ( y < x ) >→¬< (s≤s x<y) (s≤s y<x) = >→¬< x<y y<x <-∨ : { x y : ℕ } → x < suc y → ( (x ≡ y ) ∨ (x < y) ) <-∨ {zero} {zero} (s≤s z≤n) = case1 refl <-∨ {zero} {suc y} (s≤s lt) = case2 (s≤s z≤n) <-∨ {suc x} {zero} (s≤s ()) <-∨ {suc x} {suc y} (s≤s lt) with <-∨ {x} {y} lt <-∨ {suc x} {suc y} (s≤s lt) | case1 eq = case1 (cong (λ k → suc k ) eq) <-∨ {suc x} {suc y} (s≤s lt) | case2 lt1 = case2 (s≤s lt1) n≤n : (n : ℕ) → n Data.Nat.≤ n n≤n zero = z≤n n≤n (suc n) = s≤s (n≤n n) <→m≤n : {m n : ℕ} → m < n → m Data.Nat.≤ n <→m≤n {zero} lt = z≤n <→m≤n {suc m} {zero} () <→m≤n {suc m} {suc n} (s≤s lt) = s≤s (<→m≤n lt) max : (x y : ℕ) → ℕ max zero zero = zero max zero (suc x) = (suc x) max (suc x) zero = (suc x) max (suc x) (suc y) = suc ( max x y ) -- _*_ : ℕ → ℕ → ℕ -- _*_ zero _ = zero -- _*_ (suc n) m = m + ( n * m ) exp : ℕ → ℕ → ℕ exp _ zero = 1 exp n (suc m) = n * ( exp n m ) minus : (a b : ℕ ) → ℕ minus a zero = a minus zero (suc b) = zero minus (suc a) (suc b) = minus a b _-_ = minus m+= : {i j m : ℕ } → m + i ≡ m + j → i ≡ j m+= {i} {j} {zero} refl = refl m+= {i} {j} {suc m} eq = m+= {i} {j} {m} ( cong (λ k → pred k ) eq ) +m= : {i j m : ℕ } → i + m ≡ j + m → i ≡ j +m= {i} {j} {m} eq = m+= ( subst₂ (λ j k → j ≡ k ) (+-comm i _ ) (+-comm j _ ) eq ) less-1 : { n m : ℕ } → suc n < m → n < m less-1 {zero} {suc (suc _)} (s≤s (s≤s z≤n)) = s≤s z≤n less-1 {suc n} {suc m} (s≤s lt) = s≤s (less-1 {n} {m} lt) sa=b→a<b : { n m : ℕ } → suc n ≡ m → n < m sa=b→a<b {0} {suc zero} refl = s≤s z≤n sa=b→a<b {suc n} {suc (suc n)} refl = s≤s (sa=b→a<b refl) minus+n : {x y : ℕ } → suc x > y → minus x y + y ≡ x minus+n {x} {zero} _ = trans (sym (+-comm zero _ )) refl minus+n {zero} {suc y} (s≤s ()) minus+n {suc x} {suc y} (s≤s lt) = begin minus (suc x) (suc y) + suc y ≡⟨ +-comm _ (suc y) ⟩ suc y + minus x y ≡⟨ cong ( λ k → suc k ) ( begin y + minus x y ≡⟨ +-comm y _ ⟩ minus x y + y ≡⟨ minus+n {x} {y} lt ⟩ x ∎ ) ⟩ suc x ∎ where open ≡-Reasoning sn-m=sn-m : {m n : ℕ } → m ≤ n → suc n - m ≡ suc ( n - m ) sn-m=sn-m {0} {n} z≤n = refl sn-m=sn-m {suc m} {suc n} (s≤s m<n) = sn-m=sn-m m<n si-sn=i-n : {i n : ℕ } → n < i → suc (i - suc n) ≡ (i - n) si-sn=i-n {i} {n} n<i = begin suc (i - suc n) ≡⟨ sym (sn-m=sn-m n<i ) ⟩ suc i - suc n ≡⟨⟩ i - n ∎ where open ≡-Reasoning n-m<n : (n m : ℕ ) → n - m ≤ n n-m<n zero zero = z≤n n-m<n (suc n) zero = s≤s (n-m<n n zero) n-m<n zero (suc m) = z≤n n-m<n (suc n) (suc m) = ≤-trans (n-m<n n m ) refl-≤s n-n-m=m : {m n : ℕ } → m ≤ n → m ≡ (n - (n - m)) n-n-m=m {0} {zero} z≤n = refl n-n-m=m {0} {suc n} z≤n = n-n-m=m {0} {n} z≤n n-n-m=m {suc m} {suc n} (s≤s m≤n) = sym ( begin suc n - ( n - m ) ≡⟨ sn-m=sn-m (n-m<n n m) ⟩ suc (n - ( n - m )) ≡⟨ cong (λ k → suc k ) (sym (n-n-m=m m≤n)) ⟩ suc m ∎ ) where open ≡-Reasoning 0<s : {x : ℕ } → zero < suc x 0<s {_} = s≤s z≤n <-minus-0 : {x y z : ℕ } → z + x < z + y → x < y <-minus-0 {x} {suc _} {zero} lt = lt <-minus-0 {x} {y} {suc z} (s≤s lt) = <-minus-0 {x} {y} {z} lt <-minus : {x y z : ℕ } → x + z < y + z → x < y <-minus {x} {y} {z} lt = <-minus-0 ( subst₂ ( λ j k → j < k ) (+-comm x _) (+-comm y _ ) lt ) x≤x+y : {z y : ℕ } → z ≤ z + y x≤x+y {zero} {y} = z≤n x≤x+y {suc z} {y} = s≤s (x≤x+y {z} {y}) <-plus : {x y z : ℕ } → x < y → x + z < y + z <-plus {zero} {suc y} {z} (s≤s z≤n) = s≤s (subst (λ k → z ≤ k ) (+-comm z _ ) x≤x+y ) <-plus {suc x} {suc y} {z} (s≤s lt) = s≤s (<-plus {x} {y} {z} lt) <-plus-0 : {x y z : ℕ } → x < y → z + x < z + y <-plus-0 {x} {y} {z} lt = subst₂ (λ j k → j < k ) (+-comm _ z) (+-comm _ z) ( <-plus {x} {y} {z} lt ) ≤-plus : {x y z : ℕ } → x ≤ y → x + z ≤ y + z ≤-plus {0} {y} {zero} z≤n = z≤n ≤-plus {0} {y} {suc z} z≤n = subst (λ k → z < k ) (+-comm _ y ) x≤x+y ≤-plus {suc x} {suc y} {z} (s≤s lt) = s≤s ( ≤-plus {x} {y} {z} lt ) ≤-plus-0 : {x y z : ℕ } → x ≤ y → z + x ≤ z + y ≤-plus-0 {x} {y} {zero} lt = lt ≤-plus-0 {x} {y} {suc z} lt = s≤s ( ≤-plus-0 {x} {y} {z} lt ) x+y<z→x<z : {x y z : ℕ } → x + y < z → x < z x+y<z→x<z {zero} {y} {suc z} (s≤s lt1) = s≤s z≤n x+y<z→x<z {suc x} {y} {suc z} (s≤s lt1) = s≤s ( x+y<z→x<z {x} {y} {z} lt1 ) *≤ : {x y z : ℕ } → x ≤ y → x * z ≤ y * z *≤ lt = *-mono-≤ lt ≤-refl *< : {x y z : ℕ } → x < y → x * suc z < y * suc z *< {zero} {suc y} lt = s≤s z≤n *< {suc x} {suc y} (s≤s lt) = <-plus-0 (*< lt) <to<s : {x y : ℕ } → x < y → x < suc y <to<s {zero} {suc y} (s≤s lt) = s≤s z≤n <to<s {suc x} {suc y} (s≤s lt) = s≤s (<to<s {x} {y} lt) <tos<s : {x y : ℕ } → x < y → suc x < suc y <tos<s {zero} {suc y} (s≤s z≤n) = s≤s (s≤s z≤n) <tos<s {suc x} {suc y} (s≤s lt) = s≤s (<tos<s {x} {y} lt) ≤to< : {x y : ℕ } → x < y → x ≤ y ≤to< {zero} {suc y} (s≤s z≤n) = z≤n ≤to< {suc x} {suc y} (s≤s lt) = s≤s (≤to< {x} {y} lt) x<y→≤ : {x y : ℕ } → x < y → x ≤ suc y x<y→≤ {zero} {.(suc _)} (s≤s z≤n) = z≤n x<y→≤ {suc x} {suc y} (s≤s lt) = s≤s (x<y→≤ {x} {y} lt) open import Data.Product minus<=0 : {x y : ℕ } → x ≤ y → minus x y ≡ 0 minus<=0 {0} {zero} z≤n = refl minus<=0 {0} {suc y} z≤n = refl minus<=0 {suc x} {suc y} (s≤s le) = minus<=0 {x} {y} le minus>0 : {x y : ℕ } → x < y → 0 < minus y x minus>0 {zero} {suc _} (s≤s z≤n) = s≤s z≤n minus>0 {suc x} {suc y} (s≤s lt) = minus>0 {x} {y} lt distr-minus-* : {x y z : ℕ } → (minus x y) * z ≡ minus (x * z) (y * z) distr-minus-* {x} {zero} {z} = refl distr-minus-* {x} {suc y} {z} with <-cmp x y distr-minus-* {x} {suc y} {z} | tri< a ¬b ¬c = begin minus x (suc y) * z ≡⟨ cong (λ k → k * z ) (minus<=0 {x} {suc y} (x<y→≤ a)) ⟩ 0 * z ≡⟨ sym (minus<=0 {x * z} {z + y * z} le ) ⟩ minus (x * z) (z + y * z) ∎ where open ≡-Reasoning le : x * z ≤ z + y * z le = ≤-trans lemma (subst (λ k → y * z ≤ k ) (+-comm _ z ) (x≤x+y {y * z} {z} ) ) where lemma : x * z ≤ y * z lemma = *≤ {x} {y} {z} (≤to< a) distr-minus-* {x} {suc y} {z} | tri≈ ¬a refl ¬c = begin minus x (suc y) * z ≡⟨ cong (λ k → k * z ) (minus<=0 {x} {suc y} refl-≤s ) ⟩ 0 * z ≡⟨ sym (minus<=0 {x * z} {z + y * z} (lt {x} {z} )) ⟩ minus (x * z) (z + y * z) ∎ where open ≡-Reasoning lt : {x z : ℕ } → x * z ≤ z + x * z lt {zero} {zero} = z≤n lt {suc x} {zero} = lt {x} {zero} lt {x} {suc z} = ≤-trans lemma refl-≤s where lemma : x * suc z ≤ z + x * suc z lemma = subst (λ k → x * suc z ≤ k ) (+-comm _ z) (x≤x+y {x * suc z} {z}) distr-minus-* {x} {suc y} {z} | tri> ¬a ¬b c = +m= {_} {_} {suc y * z} ( begin minus x (suc y) * z + suc y * z ≡⟨ sym (proj₂ *-distrib-+ z (minus x (suc y) ) _) ⟩ ( minus x (suc y) + suc y ) * z ≡⟨ cong (λ k → k * z) (minus+n {x} {suc y} (s≤s c)) ⟩ x * z ≡⟨ sym (minus+n {x * z} {suc y * z} (s≤s (lt c))) ⟩ minus (x * z) (suc y * z) + suc y * z ∎ ) where open ≡-Reasoning lt : {x y z : ℕ } → suc y ≤ x → z + y * z ≤ x * z lt {x} {y} {z} le = *≤ le minus- : {x y z : ℕ } → suc x > z + y → minus (minus x y) z ≡ minus x (y + z) minus- {x} {y} {z} gt = +m= {_} {_} {z} ( begin minus (minus x y) z + z ≡⟨ minus+n {_} {z} lemma ⟩ minus x y ≡⟨ +m= {_} {_} {y} ( begin minus x y + y ≡⟨ minus+n {_} {y} lemma1 ⟩ x ≡⟨ sym ( minus+n {_} {z + y} gt ) ⟩ minus x (z + y) + (z + y) ≡⟨ sym ( +-assoc (minus x (z + y)) _ _ ) ⟩ minus x (z + y) + z + y ∎ ) ⟩ minus x (z + y) + z ≡⟨ cong (λ k → minus x k + z ) (+-comm _ y ) ⟩ minus x (y + z) + z ∎ ) where open ≡-Reasoning lemma1 : suc x > y lemma1 = x+y<z→x<z (subst (λ k → k < suc x ) (+-comm z _ ) gt ) lemma : suc (minus x y) > z lemma = <-minus {_} {_} {y} ( subst ( λ x → z + y < suc x ) (sym (minus+n {x} {y} lemma1 )) gt ) minus-* : {M k n : ℕ } → n < k → minus k (suc n) * M ≡ minus (minus k n * M ) M minus-* {zero} {k} {n} lt = begin minus k (suc n) * zero ≡⟨ *-comm (minus k (suc n)) zero ⟩ zero * minus k (suc n) ≡⟨⟩ 0 * minus k n ≡⟨ *-comm 0 (minus k n) ⟩ minus (minus k n * 0 ) 0 ∎ where open ≡-Reasoning minus-* {suc m} {k} {n} lt with <-cmp k 1 minus-* {suc m} {.0} {zero} lt | tri< (s≤s z≤n) ¬b ¬c = refl minus-* {suc m} {.0} {suc n} lt | tri< (s≤s z≤n) ¬b ¬c = refl minus-* {suc zero} {.1} {zero} lt | tri≈ ¬a refl ¬c = refl minus-* {suc (suc m)} {.1} {zero} lt | tri≈ ¬a refl ¬c = minus-* {suc m} {1} {zero} lt minus-* {suc m} {.1} {suc n} (s≤s ()) | tri≈ ¬a refl ¬c minus-* {suc m} {k} {n} lt | tri> ¬a ¬b c = begin minus k (suc n) * M ≡⟨ distr-minus-* {k} {suc n} {M} ⟩ minus (k * M ) ((suc n) * M) ≡⟨⟩ minus (k * M ) (M + n * M ) ≡⟨ cong (λ x → minus (k * M) x) (+-comm M _ ) ⟩ minus (k * M ) ((n * M) + M ) ≡⟨ sym ( minus- {k * M} {n * M} (lemma lt) ) ⟩ minus (minus (k * M ) (n * M)) M ≡⟨ cong (λ x → minus x M ) ( sym ( distr-minus-* {k} {n} )) ⟩ minus (minus k n * M ) M ∎ where M = suc m lemma : {n k m : ℕ } → n < k → suc (k * suc m) > suc m + n * suc m lemma {zero} {suc k} {m} (s≤s lt) = s≤s (s≤s (subst (λ x → x ≤ m + k * suc m) (+-comm 0 _ ) x≤x+y )) lemma {suc n} {suc k} {m} lt = begin suc (suc m + suc n * suc m) ≡⟨⟩ suc ( suc (suc n) * suc m) ≤⟨ ≤-plus-0 {_} {_} {1} (*≤ lt ) ⟩ suc (suc k * suc m) ∎ where open ≤-Reasoning open ≡-Reasoning open import Data.List ℕL-inject : {h h1 : ℕ } {x y : List ℕ } → h ∷ x ≡ h1 ∷ y → h ≡ h1 ℕL-inject refl = refl ℕL-inject-t : {h h1 : ℕ } {x y : List ℕ } → h ∷ x ≡ h1 ∷ y → x ≡ y ℕL-inject-t refl = refl ℕL-eq? : (x y : List ℕ ) → Dec (x ≡ y ) ℕL-eq? [] [] = yes refl ℕL-eq? [] (x ∷ y) = no (λ ()) ℕL-eq? (x ∷ x₁) [] = no (λ ()) ℕL-eq? (h ∷ x) (h1 ∷ y) with h ≟ h1 | ℕL-eq? x y ... | yes y1 | yes y2 = yes ( cong₂ (λ j k → j ∷ k ) y1 y2 ) ... | yes y1 | no n = no (λ e → n (ℕL-inject-t e)) ... | no n | t = no (λ e → n (ℕL-inject e))
{ "alphanum_fraction": 0.3982225261, "avg_line_length": 34.3167155425, "ext": "agda", "hexsha": "0d913994c9f6e4e21cb34ea86752f4ca59a4219b", "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": "bf000643c139f40d5783e962bb3b63353ba3d6e4", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "shinji-kono/Galois", "max_forks_repo_path": "src/nat.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "bf000643c139f40d5783e962bb3b63353ba3d6e4", "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/Galois", "max_issues_repo_path": "src/nat.agda", "max_line_length": 113, "max_stars_count": 1, "max_stars_repo_head_hexsha": "bf000643c139f40d5783e962bb3b63353ba3d6e4", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "shinji-kono/Galois", "max_stars_repo_path": "src/nat.agda", "max_stars_repo_stars_event_max_datetime": "2021-10-16T03:37:05.000Z", "max_stars_repo_stars_event_min_datetime": "2021-10-16T03:37:05.000Z", "num_tokens": 5784, "size": 11702 }
{-# OPTIONS --without-K --safe #-} module Categories.Functor.Instance.UnderlyingQuiver where -- The forgetful functor from categories to its underlying quiver -- **except** that this functor only goes from **StrictCats**, -- i.e. where Functor equivalence is propositional equality, not -- NaturalIsomorphism. open import Level using (Level) -- open import Function using (_$_; flip) open import Relation.Binary.PropositionalEquality using (refl) open import Relation.Binary.PropositionalEquality.Subst.Properties using (module Transport) open import Data.Quiver using (Quiver) open import Data.Quiver.Morphism using (Morphism; _≃_) open import Categories.Category.Core using (Category) open import Categories.Category.Instance.Quivers using (Quivers) open import Categories.Category.Instance.StrictCats open import Categories.Functor using (Functor) open import Categories.Functor.Equivalence using (_≡F_) import Categories.Morphism.HeterogeneousIdentity as HId private variable o ℓ e o′ ℓ′ e′ : Level A B : Category o ℓ e Underlying₀ : Category o ℓ e → Quiver o ℓ e Underlying₀ C = record { Category C } Underlying₁ : Functor A B → Morphism (Underlying₀ A) (Underlying₀ B) Underlying₁ F = record { Functor F } private ≡F-resp-≃ : {F G : Functor A B} → F ≡F G → Underlying₁ F ≃ Underlying₁ G ≡F-resp-≃ {B = B} {F} {G} F≈G = record { F₀≡ = λ {X} → eq₀ F≈G X ; F₁≡ = λ {x} {y} {f} → let open Category B using (_∘_) open HId B UB = Underlying₀ B open Transport (Quiver._⇒_ UB) using (_▸_; _◂_) module F = Functor F using (₁) module G = Functor G using (₁) open Quiver.EdgeReasoning (Underlying₀ B) in begin F.₁ f ▸ eq₀ F≈G y ≈⟨ hid-subst-cod (F.₁ f) (eq₀ F≈G y) ⟩ hid (eq₀ F≈G y) ∘ F.₁ f ≈⟨ eq₁ F≈G f ⟩ G.₁ f ∘ hid (eq₀ F≈G x) ≈˘⟨ hid-subst-dom (eq₀ F≈G x) (G.₁ f) ⟩ eq₀ F≈G x ◂ G.₁ f ∎ } where open _≡F_ Underlying : Functor (StrictCats o ℓ e) (Quivers o ℓ e) Underlying = record { F₀ = Underlying₀ ; F₁ = Underlying₁ ; identity = λ {A} → record { F₀≡ = refl ; F₁≡ = Category.Equiv.refl A } ; homomorphism = λ where {Z = Z} → record { F₀≡ = refl ; F₁≡ = Category.Equiv.refl Z } ; F-resp-≈ = ≡F-resp-≃ }
{ "alphanum_fraction": 0.6516015796, "avg_line_length": 35.0615384615, "ext": "agda", "hexsha": "eeaddf12374698fd0733f1e455f94513c8d94061", "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": "602ed2ae05dd449d77fc299c07a1cdd02ee5b823", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "sstucki/agda-categories", "max_forks_repo_path": "src/Categories/Functor/Instance/UnderlyingQuiver.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "602ed2ae05dd449d77fc299c07a1cdd02ee5b823", "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": "sstucki/agda-categories", "max_issues_repo_path": "src/Categories/Functor/Instance/UnderlyingQuiver.agda", "max_line_length": 88, "max_stars_count": null, "max_stars_repo_head_hexsha": "602ed2ae05dd449d77fc299c07a1cdd02ee5b823", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "sstucki/agda-categories", "max_stars_repo_path": "src/Categories/Functor/Instance/UnderlyingQuiver.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 767, "size": 2279 }
module Eta (Gnd : Set)(U : Set)(El : U -> Set) where open import Basics open import Pr open import Nom import Kind open Kind Gnd U El import Cxt open Cxt Kind import Loc open Loc Kind import Term open Term Gnd U El import Shift open Shift Gnd U El data Sawn (G : Cxt)(C : Kind)(L : Loc)(R : Kind) : Kind -> Set where snil : Sawn G C L R R scons : {S T : Kind} -> Sawn G C L R (S |> T) -> G [ L / Term C ]- S -> Sawn G C L R T sarg : {A : U}{K : El A -> Kind} -> Sawn G C L R (Pi A K) -> (a : El A) -> Sawn G C L R (K a) stitch : {G : Cxt}{C : Kind}{Z : Gnd}{L : Loc}{R S : Kind} -> Sawn G C L R S -> G [ L / Args C Z ]- S -> G [ L / Args C Z ]- R stitch snil s = s stitch (scons r s) t = stitch r (s G& t) stitch (sarg r a) t = stitch r (a G^ t) sawsh : {G : Cxt}{C : Kind}{L M : Loc} -> ({T : Kind} -> G [ L / Head ]- T -> G [ M / Head ]- T) -> {R S : Kind} -> Sawn G C L R S -> Sawn G C M R S sawsh rho snil = snil sawsh rho (scons r s) = scons (sawsh rho r) (shift rho s) sawsh rho (sarg r a) = sarg (sawsh rho r) a long : {G : Cxt}{C : Kind}{L : Loc}(S : Kind){T : Kind} -> G [ L / Head ]- T -> Sawn G C L T S -> G [ L / Term C ]- S long (Ty Z) h s = h G$ (stitch s Gnil) long (Pi A K) h s = Gfn A \ a -> long (K a) h (sarg s a) long (S |> T) h s = G\\ (long T (popH h) (scons (sawsh popH s) (long S (# top -! _) snil))) var : {G : Cxt}{C : Kind}(x : Nom){Gx : [| G Has x |]} -> G [ EL / Term C ]- (wit ((G ?- x) {Gx})) var {G} x {Gx} with (G ?- x) {Gx} ... | [ T / g ] = long T (` x -! g) snil
{ "alphanum_fraction": 0.4795856185, "avg_line_length": 31.5576923077, "ext": "agda", "hexsha": "f55d1cd89b0ed81c3ecc0a521c6da6a17eb3905e", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "masondesu/agda", "max_forks_repo_path": "benchmark/Syntacticosmos/Eta.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "masondesu/agda", "max_issues_repo_path": "benchmark/Syntacticosmos/Eta.agda", "max_line_length": 74, "max_stars_count": 1, "max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/agda-kanso", "max_stars_repo_path": "benchmark/Syntacticosmos/Eta.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": 671, "size": 1641 }
module Structure.Groupoid.Groupoids where open import Data open import Data.Proofs open import Functional open import Logic import Lvl import Relator.Equals as Eq open import Structure.Setoid open import Structure.Groupoid open import Structure.Categorical.Proofs open import Structure.Categorical.Properties open import Structure.Operator open import Type private variable ℓ ℓ₁ ℓ₂ ℓₑ : Lvl.Level private variable Obj A B : Type{ℓ} private variable _▫_ : Obj → Obj → Type{ℓ} private variable f : A → B emptyGroupoid : Groupoid{ℓ₁}{ℓ₂}{ℓₑ}(empty-morphism) ⦃ \{} ⦄ Groupoid._∘_ emptyGroupoid = empty-comp Groupoid.id emptyGroupoid = empty-id Groupoid.inv emptyGroupoid = empty-inv Groupoid.binaryOperator emptyGroupoid {} Groupoid.associativity emptyGroupoid = empty-associativity ⦃ \{} ⦄ Groupoid.identity emptyGroupoid = empty-identity ⦃ \{} ⦄ Groupoid.inverter emptyGroupoid = empty-inverter ⦃ \{} ⦄ singleGroupoid : ∀{ℓₒ ℓᵢ ℓₚₐ₁ ℓₚₐ₂ ℓₚᵢ₁ ℓₚᵢ₂ ℓₚᵢ₃ ℓᵢₙ : Lvl.Level} → Groupoid{ℓ₁}{ℓ₂}(single-morphism) Groupoid._∘_ (singleGroupoid{ℓ₁}{ℓ₂}{ℓₒ}{ℓᵢ}{ℓₚₐ₁}{ℓₚₐ₂}{ℓₚᵢ₁}{ℓₚᵢ₂}{ℓₚᵢ₃}) = single-comp{ℓ₂}{ℓₒ} Groupoid.id (singleGroupoid{ℓ₁}{ℓ₂}{ℓₒ}{ℓᵢ}{ℓₚₐ₁}{ℓₚₐ₂}{ℓₚᵢ₁}{ℓₚᵢ₂}{ℓₚᵢ₃}) = single-id{ℓ₂}{ℓᵢ} Groupoid.inv (singleGroupoid{ℓ₁}{ℓ₂}{ℓₒ}{ℓᵢ}{ℓₚₐ₁}{ℓₚₐ₂}{ℓₚᵢ₁}{ℓₚᵢ₂}{ℓₚᵢ₃}) = single-inv{ℓ₂}{ℓᵢ} BinaryOperator.congruence (Groupoid.binaryOperator singleGroupoid) Eq.[≡]-intro Eq.[≡]-intro = Eq.[≡]-intro Groupoid.associativity (singleGroupoid{ℓ₁}{ℓ₂}{ℓₒ}{ℓᵢ}{ℓₚₐ₁}{ℓₚₐ₂}{ℓₚᵢ₁}{ℓₚᵢ₂}{ℓₚᵢ₃}) = single-associativity{ℓ₂}{ℓ₂}{ℓₚₐ₁}{ℓ₁}{ℓₚₐ₂} Groupoid.identity (singleGroupoid{ℓ₁}{ℓ₂}{ℓₒ}{ℓᵢ}{ℓₚₐ₁}{ℓₚₐ₂}{ℓₚᵢ₁}{ℓₚᵢ₂}{ℓₚᵢ₃}) = single-identity{ℓ₂}{ℓ₂}{ℓₚᵢ₁}{ℓ₁}{ℓₚᵢ₂}{ℓₚᵢ₃} Groupoid.inverter (singleGroupoid{ℓ₁}{ℓ₂}{ℓₒ}{ℓᵢ}{ℓₚₐ₁}{ℓₚₐ₂}{ℓₚᵢ₁}{ℓₚᵢ₂}{ℓₚᵢ₃}{ℓᵢₙ}) = single-inverter{ℓ₂}{ℓ₂}{ℓₚᵢ₁}{ℓ₁}{ℓₚᵢ₂}{ℓₚᵢ₃}{ℓᵢₙ} on₂-groupoid : ⦃ morphism-equiv : ∀{x y} → Equiv{ℓₑ}{ℓ}(x ▫ y) ⦄ → Groupoid{Obj = B}(_▫_) ⦃ morphism-equiv ⦄ → (f : A → B) → Groupoid((_▫_) on₂ f) Groupoid._∘_ (on₂-groupoid C _) = Groupoid._∘_ C Groupoid.id (on₂-groupoid C _) = Groupoid.id C Groupoid.inv (on₂-groupoid C _) = Groupoid.inv C BinaryOperator.congruence (Groupoid.binaryOperator (on₂-groupoid C _)) = BinaryOperator.congruence(Groupoid.binaryOperator C) Groupoid.associativity (on₂-groupoid C f) = on₂-associativity f (Groupoid.associativity C) Groupoid.identity (on₂-groupoid C f) = on₂-identity f (Groupoid.identity C) Groupoid.inverter (on₂-groupoid C f) = on₂-inverter f (Groupoid.inverter C)
{ "alphanum_fraction": 0.7163593566, "avg_line_length": 54.2340425532, "ext": "agda", "hexsha": "b4bec304cad6a5266415ef7a319142fc43dca553", "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/Groupoid/Groupoids.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/Groupoid/Groupoids.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": "Structure/Groupoid/Groupoids.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": 1246, "size": 2549 }
-- Andreas, 2012-10-18 module Issue481a where open import Common.Issue481ParametrizedModule Set1 -- ommon.Issue481ParametrizedModule should not be in scope module PM = Common.Issue481ParametrizedModule
{ "alphanum_fraction": 0.8173076923, "avg_line_length": 18.9090909091, "ext": "agda", "hexsha": "c6d69336395a8645d6898619db2d97192665f7b4", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "masondesu/agda", "max_forks_repo_path": "test/fail/Issue481a.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "masondesu/agda", "max_issues_repo_path": "test/fail/Issue481a.agda", "max_line_length": 59, "max_stars_count": 1, "max_stars_repo_head_hexsha": "20596e9dd9867166a64470dd24ea68925ff380ce", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "np/agda-git-experiment", "max_stars_repo_path": "test/fail/Issue481a.agda", "max_stars_repo_stars_event_max_datetime": "2019-11-27T04:41:05.000Z", "max_stars_repo_stars_event_min_datetime": "2019-11-27T04:41:05.000Z", "num_tokens": 59, "size": 208 }
------------------------------------------------------------------------ -- The Agda standard library -- -- The free monad construction on containers ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe --sized-types #-} module Data.Container.FreeMonad where open import Level open import Data.Sum using (inj₁; inj₂ ; [_,_]′) open import Data.Product open import Data.Container open import Data.Container.Combinator using (const; _⊎_) open import Data.W open import Category.Monad infixl 1 _⋆C_ infix 1 _⋆_ ------------------------------------------------------------------------ -- The free monad construction over a container and a set is, in -- universal algebra terminology, also known as the term algebra over a -- signature (a container) and a set (of variable symbols). The return -- of the free monad corresponds to variables and the bind operator -- corresponds to (parallel) substitution. -- A useful intuition is to think of containers describing single -- operations and the free monad construction over a container and a set -- describing a tree of operations as nodes and elements of the set as -- leafs. If one starts at the root, then any path will pass finitely -- many nodes (operations described by the container) and eventually end -- up in a leaf (element of the set) -- hence the Kleene star notation -- (the type can be read as a regular expression). _⋆C_ : ∀ {x s p} → Container s p → Set x → Container (s ⊔ x) p C ⋆C X = const X ⊎ C _⋆_ : ∀ {x s p} → Container s p → Set x → Set (x ⊔ s ⊔ p) C ⋆ X = μ (C ⋆C X) module _ {s p} {C : Container s p} where inn : ∀ {x} {X : Set x} → ⟦ C ⟧ (C ⋆ X) → C ⋆ X inn (s , f) = sup (inj₂ s , f) rawMonad : ∀ {x} → RawMonad {s ⊔ p ⊔ x} (C ⋆_) rawMonad = record { return = return; _>>=_ = _>>=_ } where return : ∀ {X} → X → C ⋆ X return x = sup (inj₁ x , λ ()) _>>=_ : ∀ {X Y} → C ⋆ X → (X → C ⋆ Y) → C ⋆ Y sup (inj₁ x , _) >>= k = k x sup (inj₂ s , f) >>= k = inn (s , λ p → f p >>= k)
{ "alphanum_fraction": 0.5747182754, "avg_line_length": 35.8070175439, "ext": "agda", "hexsha": "6de62f4c1b904e7c3b8c432ed87bc00df713e681", "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/Container/FreeMonad.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/Container/FreeMonad.agda", "max_line_length": 72, "max_stars_count": null, "max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "omega12345/agda-mode", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Data/Container/FreeMonad.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 600, "size": 2041 }
{-# OPTIONS --without-K #-} open import HoTT.Base module HoTT.Transport.Coproduct where private variable i : Level X : 𝒰 i A B : X → 𝒰 i x₁ x₂ : X transport-+ : (p : x₁ == x₂) → transport (λ x → A x + B x) p ~ +-rec (inl ∘ transport A p) (inr ∘ transport B p) transport-+ refl (inl a) = refl transport-+ refl (inr b) = refl
{ "alphanum_fraction": 0.5442359249, "avg_line_length": 20.7222222222, "ext": "agda", "hexsha": "b9ca2677d9a99d6d04ae3a1d534412c84ff25a11", "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": "ef4d9fbb9cc0352657f1a6d0d3534d4c8a6fd508", "max_forks_repo_licenses": [ "0BSD" ], "max_forks_repo_name": "michaelforney/hott", "max_forks_repo_path": "HoTT/Transport/Coproduct.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "ef4d9fbb9cc0352657f1a6d0d3534d4c8a6fd508", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "0BSD" ], "max_issues_repo_name": "michaelforney/hott", "max_issues_repo_path": "HoTT/Transport/Coproduct.agda", "max_line_length": 63, "max_stars_count": null, "max_stars_repo_head_hexsha": "ef4d9fbb9cc0352657f1a6d0d3534d4c8a6fd508", "max_stars_repo_licenses": [ "0BSD" ], "max_stars_repo_name": "michaelforney/hott", "max_stars_repo_path": "HoTT/Transport/Coproduct.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 133, "size": 373 }
{-# OPTIONS --verbose=10 #-} module inorder where open import Data.Nat open import Data.Vec open import Agda.Builtin.Sigma open import Data.Product open import Data.Fin using (fromℕ) open import trees open import optics open import lemmas inorderTree : {A : Set} -> Tree A -> Σ[ n ∈ ℕ ] Vec A n × (Vec A n -> Tree A) inorderTree empty = (0 , ([] , λ _ -> empty)) inorderTree {A} (node t x t₁) with inorderTree t | inorderTree t₁ ... | (n₁ , (g₁ , p₁)) | (n₂ , (g₂ , p₂)) = (n₁ + (1 + n₂) , (g₁ ++ (x ∷ g₂) , λ v -> node (p₁ (take n₁ v)) (head (drop n₁ v)) (righttree v))) where righttree : Vec A (n₁ + (1 + n₂)) -> Tree A -- righttree v = p₂ (drop 1 (drop n₁ v)) righttree v rewrite +-suc n₁ n₂ = p₂ (drop (1 + n₁) v) inorder : {A : Set} -> Traversal (Tree A) (Tree A) A A inorder = record{ extract = inorderTree } module tests where tree1 : Tree ℕ tree1 = node (node empty 1 empty) 3 empty open Traversal inorder1 : Vec ℕ 2 inorder1 = get inorder tree1 updatedinorder1 : Tree ℕ updatedinorder1 = put inorder tree1 (2 ∷ 3 ∷ [])
{ "alphanum_fraction": 0.5617597293, "avg_line_length": 28.8292682927, "ext": "agda", "hexsha": "e02c4e68a2dcd67b2c258ec300a99022ce54580b", "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": "90fc9586f4c126ee83b8aa54ad417bb7a5325b1b", "max_forks_repo_licenses": [ "Apache-2.0" ], "max_forks_repo_name": "hablapps/safeoptics", "max_forks_repo_path": "src/main/agda/inorder.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "90fc9586f4c126ee83b8aa54ad417bb7a5325b1b", "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": "hablapps/safeoptics", "max_issues_repo_path": "src/main/agda/inorder.agda", "max_line_length": 80, "max_stars_count": null, "max_stars_repo_head_hexsha": "90fc9586f4c126ee83b8aa54ad417bb7a5325b1b", "max_stars_repo_licenses": [ "Apache-2.0" ], "max_stars_repo_name": "hablapps/safeoptics", "max_stars_repo_path": "src/main/agda/inorder.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 399, "size": 1182 }
open import Function using (flip; _∘_; _$_) open import Auto.Counting open import Data.Nat using (ℕ) open import Data.List using (List; _∷_; []) open import Data.Product using (∃; _,_; proj₂) open import Data.Maybe open import Data.Sum using (inj₁; inj₂; isInj₂) module Auto.Example.Sublists where infix 3 _⊆_ data _⊆_ {a} {A : Set a} : List A → List A → Set a where stop : [] ⊆ [] drop : ∀ {xs y ys} → xs ⊆ ys → xs ⊆ y ∷ ys keep : ∀ {x xs ys} → xs ⊆ ys → x ∷ xs ⊆ x ∷ ys refl : ∀ {a} {A : Set a} {xs : List A} → xs ⊆ xs refl {xs = []} = stop refl {xs = x ∷ xs} = keep refl trans : ∀ {a} {A : Set a} {xs ys zs : List A} → xs ⊆ ys → ys ⊆ zs → xs ⊆ zs trans p stop = p trans p (drop q) = drop (trans p q) trans (drop p) (keep q) = drop (trans p q) trans (keep p) (keep q) = keep (trans p q) hintdb₁ : HintDB hintdb₁ = ε << quote drop << quote keep << quote trans lemma₁ : {ws xs ys zs : List ℕ} → ws ⊆ 1 ∷ xs → xs ⊆ ys → ys ⊆ zs → ws ⊆ 1 ∷ 2 ∷ zs lemma₁ = tactic (auto dfs 10 hintdb₁) lemma₂ : {ws xs ys zs : List ℕ} → ws ⊆ 1 ∷ xs → xs ⊆ ys → ys ⊆ zs → ws ⊆ 2 ∷ zs lemma₂ = tactic (auto dfs 10 hintdb₁) {- db₂ : HintDB db₂ = ε << quote trans << quote keep << quote drop test₂ : {A : Set} {ws xs ys zs : List A} → ws ⊆ xs → ys ⊆ zs → ws ⊆ zs test₂ = tactic (auto dfs 10 db₁) -}
{ "alphanum_fraction": 0.5335235378, "avg_line_length": 26.4528301887, "ext": "agda", "hexsha": "d73ebe99beab85d9d25e3a54af78a3a98f23942b", "lang": "Agda", "max_forks_count": 2, "max_forks_repo_forks_event_max_datetime": "2019-07-07T07:37:07.000Z", "max_forks_repo_forks_event_min_datetime": "2018-07-10T10:47:30.000Z", "max_forks_repo_head_hexsha": "f384b5c236645fcf8ab93179723a7355383a8716", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "wenkokke/AutoInAgda", "max_forks_repo_path": "src/Auto/Example/Sublists.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "f384b5c236645fcf8ab93179723a7355383a8716", "max_issues_repo_issues_event_max_datetime": "2017-11-06T16:49:27.000Z", "max_issues_repo_issues_event_min_datetime": "2017-11-03T09:46:19.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "wenkokke/AutoInAgda", "max_issues_repo_path": "src/Auto/Example/Sublists.agda", "max_line_length": 75, "max_stars_count": 22, "max_stars_repo_head_hexsha": "f384b5c236645fcf8ab93179723a7355383a8716", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "wenkokke/AutoInAgda", "max_stars_repo_path": "src/Auto/Example/Sublists.agda", "max_stars_repo_stars_event_max_datetime": "2021-03-20T15:04:47.000Z", "max_stars_repo_stars_event_min_datetime": "2017-07-18T18:14:09.000Z", "num_tokens": 539, "size": 1402 }
module Issue1441 where open import Common.Nat open import Common.Unit open import Common.IO data Sing : (n : Nat) → Set where sing : ∀ n → Sing n data D : Set → Set where c : ∀ n → D (Sing n) test : (A : Set) → D A → Nat test .(Sing n) (c n) = n main : IO Unit main = printNat (test (Sing 1) (c 1)) -- should succeed and print 1
{ "alphanum_fraction": 0.6205882353, "avg_line_length": 16.1904761905, "ext": "agda", "hexsha": "44c9f1760bf7cb9a962be47cc2c4a118e38fecc6", "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/Issue1441.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/Issue1441.agda", "max_line_length": 37, "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/Issue1441.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": 117, "size": 340 }
open import Common.Size postulate A : Set f : Size → A -- k < j ==> ∃ l < j works : ∀ i (j : Size< (↑ i)) (k : Size< j) → (((l : Size< j) → A) → A) → A works i j k ret = ret λ l → f l -- k < j <= i ==> ∃ l < i test1 : ∀ i (j : Size< (↑ i)) (k : Size< j) → (((l : Size< i) → A) → A) → A test1 i j k ret = ret λ l → f l -- k' < k < j <= i + 1 ==> ∃ l < i test : ∀ i (j : Size< (↑ ↑ i)) (k : Size< j) (k' : Size< k) → (((l : Size< i) → A) → A) → A test i j k k' ret = ret λ l → f l
{ "alphanum_fraction": 0.4004106776, "avg_line_length": 27.0555555556, "ext": "agda", "hexsha": "20d1f7c753ac8f6f2e2a67f8318e619f3d3531b8", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2015-09-15T14:36:15.000Z", "max_forks_repo_forks_event_min_datetime": "2015-09-15T14:36:15.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/Issue1523d.agda", "max_issues_count": 3, "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_issues_event_max_datetime": "2019-04-01T19:39:26.000Z", "max_issues_repo_issues_event_min_datetime": "2018-11-14T15:31:44.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "shlevy/agda", "max_issues_repo_path": "test/Succeed/Issue1523d.agda", "max_line_length": 91, "max_stars_count": 3, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "test/Succeed/Issue1523d.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": 226, "size": 487 }
module Tactic.Deriving where open import Prelude hiding (abs) open import Tactic.Reflection private makeArgs : Nat → List (Arg Nat) → List (Arg Term) makeArgs n xs = reverse $ map (fmap (λ i → var (n - i - 1) [])) xs computeInstanceType : Name → Nat → List (Arg Nat) → Type → Maybe Term computeInstanceType class n xs (agda-sort _) = just (def class (vArg (var n (makeArgs n xs)) ∷ [])) computeInstanceType class n xs (pi a (abs s b)) = pi (hArg (unArg a)) ∘ abs s <$> computeInstanceType class (suc n) ((n <$ a) ∷ xs) b computeInstanceType _ _ _ _ = nothing computeTel : Name → Nat → List (Arg Nat) → Telescope → Telescope → Telescope × List (Arg Term) computeTel d n xs is [] = reverse is , makeArgs (n + length is) xs computeTel d n xs is (a ∷ tel) = first (hArg (unArg a) ∷_) $ case computeInstanceType d 0 [] (weaken 1 $ unArg a) of λ { (just i) → computeTel d (1 + n) ((n <$ a) ∷ xs) (iArg (weaken (length is) i) ∷ weaken 1 is) tel ; nothing → computeTel d (1 + n) ((n <$ a) ∷ xs) (weaken 1 is) tel } -- Computes the telescope of instances for a given datatype and class. For instance, -- instanceTelescope (quote Vec) (quote Eq) computes to -- {a : Level} {A : Set a} {{_ : Eq A}} {n : Nat} , 3 ∷ 2 ∷ 0 ∷ [] instanceTelescope : Name → Name → TC (Telescope × List (Arg Term)) instanceTelescope d class = computeTel class 0 [] [] <$> (fst ∘ telView <$> getType d) -- Compute the type of an instance declaration for an arbitrary datatype and class. instanceType : Name → Name → TC Type instanceType d class = caseM instanceTelescope d class of λ { (tel , vs) → pure $ telPi tel $ def₁ class (def d vs) }
{ "alphanum_fraction": 0.6286894923, "avg_line_length": 43.4358974359, "ext": "agda", "hexsha": "b7a7580fcd172ab684d00aec6777820f694c231f", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "75016b4151ed601e28f4462cd7b6b1aaf5d0d1a6", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "lclem/agda-prelude", "max_forks_repo_path": "src/Tactic/Deriving.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "75016b4151ed601e28f4462cd7b6b1aaf5d0d1a6", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "lclem/agda-prelude", "max_issues_repo_path": "src/Tactic/Deriving.agda", "max_line_length": 96, "max_stars_count": null, "max_stars_repo_head_hexsha": "75016b4151ed601e28f4462cd7b6b1aaf5d0d1a6", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "lclem/agda-prelude", "max_stars_repo_path": "src/Tactic/Deriving.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 535, "size": 1694 }
{-# OPTIONS --no-termination-check #-} module oldPi where open import Data.Nat hiding (_⊔_; suc; _+_; _*_) open import Data.Vec open import Data.Empty open import Data.Unit open import Data.Sum hiding (map) open import Data.Product hiding (map) open import Function open import Level open import Relation.Binary.PropositionalEquality hiding (sym) open import Relation.Binary.Core open import Algebra import Algebra.FunctionProperties as FunctionProperties open import Algebra.FunctionProperties.Core open import Algebra.Structures infixr 30 _⟷_ infixr 30 _⟺_ infixr 20 _⊙_ infixr 20 _◎_ ------------------------------------------------------------------------------ -- First we define a universe of our value types data B : Set where ZERO : B ONE : B PLUS : B → B → B NEG : B → B TIMES : B → B → B RECIP : B → B ⟦_⟧ : B → Set ⟦ ZERO ⟧ = ⊥ ⟦ ONE ⟧ = ⊤ ⟦ PLUS b1 b2 ⟧ = ⟦ b1 ⟧ ⊎ ⟦ b2 ⟧ ⟦ NEG b ⟧ = {!!} ⟦ TIMES b1 b2 ⟧ = ⟦ b1 ⟧ × ⟦ b2 ⟧ ⟦ RECIP b ⟧ = {!!} ------------------------------------------------------------------------------ -- Now we define another universe for our equivalences. First the codes for -- equivalences. data _⟷_ : B → B → Set where unite₊ : { b : B } → PLUS ZERO b ⟷ b uniti₊ : { b : B } → b ⟷ PLUS ZERO b swap₊ : { b₁ b₂ : B } → PLUS b₁ b₂ ⟷ PLUS b₂ b₁ assocl₊ : { b₁ b₂ b₃ : B } → PLUS b₁ (PLUS b₂ b₃) ⟷ PLUS (PLUS b₁ b₂) b₃ assocr₊ : { b₁ b₂ b₃ : B } → PLUS (PLUS b₁ b₂) b₃ ⟷ PLUS b₁ (PLUS b₂ b₃) unite⋆ : { b : B } → TIMES ONE b ⟷ b uniti⋆ : { b : B } → b ⟷ TIMES ONE b swap⋆ : { b₁ b₂ : B } → TIMES b₁ b₂ ⟷ TIMES b₂ b₁ assocl⋆ : { b₁ b₂ b₃ : B } → TIMES b₁ (TIMES b₂ b₃) ⟷ TIMES (TIMES b₁ b₂) b₃ assocr⋆ : { b₁ b₂ b₃ : B } → TIMES (TIMES b₁ b₂) b₃ ⟷ TIMES b₁ (TIMES b₂ b₃) dist : { b₁ b₂ b₃ : B } → TIMES (PLUS b₁ b₂) b₃ ⟷ PLUS (TIMES b₁ b₃) (TIMES b₂ b₃) factor : { b₁ b₂ b₃ : B } → PLUS (TIMES b₁ b₃) (TIMES b₂ b₃) ⟷ TIMES (PLUS b₁ b₂) b₃ η₊ : { b : B } → ZERO ⟷ PLUS (NEG b) b ε₊ : { b : B } → PLUS b (NEG b) ⟷ ZERO refe⋆ : { b : B } → RECIP (RECIP b) ⟷ b refi⋆ : { b : B } → b ⟷ RECIP (RECIP b) rile⋆ : { b : B } → TIMES b (TIMES b (RECIP b)) ⟷ b rili⋆ : { b : B } → b ⟷ TIMES b (TIMES b (RECIP b)) id⟷ : { b : B } → b ⟷ b sym : { b₁ b₂ : B } → (b₁ ⟷ b₂) → (b₂ ⟷ b₁) _◎_ : { b₁ b₂ b₃ : B } → (b₁ ⟷ b₂) → (b₂ ⟷ b₃) → (b₁ ⟷ b₃) _⊕_ : { b₁ b₂ b₃ b₄ : B } → (b₁ ⟷ b₃) → (b₂ ⟷ b₄) → (PLUS b₁ b₂ ⟷ PLUS b₃ b₄) _⊗_ : { b₁ b₂ b₃ b₄ : B } → (b₁ ⟷ b₃) → (b₂ ⟷ b₄) → (TIMES b₁ b₂ ⟷ TIMES b₃ b₄) -- dist' : {b₁ b₂ b₃ : B} → TIMES b₁ (PLUS b₂ b₃) ⟷ PLUS (TIMES b₁ b₂) (TIMES b₁ b₃) dist' = swap⋆ ◎ dist ◎ (swap⋆ ⊕ swap⋆) midtofront : {a b c : B} → TIMES a (TIMES b c) ⟷ TIMES b (TIMES a c) midtofront = assocl⋆ ◎ (swap⋆ ⊗ id⟷) ◎ assocr⋆ ------------------------------------------------------------------------------ -- Establish that syntactically we have a commutative semiring ⟷IsEquivalence : IsEquivalence _⟷_ ⟷IsEquivalence = record { refl = id⟷ ; sym = sym ; trans = _◎_ } +IsSemigroup : IsSemigroup _⟷_ PLUS +IsSemigroup = record { isEquivalence = ⟷IsEquivalence ; assoc = λ x y z → assocr₊ {x} {y} {z} ; ∙-cong = _⊕_ } +0IsMonoid : IsMonoid _⟷_ PLUS ZERO +0IsMonoid = record { isSemigroup = +IsSemigroup ; identity = ((λ x → unite₊ {x}) , (λ x → swap₊ ◎ unite₊ {x})) } +0IsCommutativeMonoid : IsCommutativeMonoid _⟷_ PLUS ZERO +0IsCommutativeMonoid = record { isSemigroup = +IsSemigroup ; identityˡ = λ x → unite₊ {x} ; comm = λ x y → swap₊ {x} {y} } +0CommutativeMonoid : CommutativeMonoid _ _ +0CommutativeMonoid = record { Carrier = B ; _≈_ = _⟷_ ; _∙_ = PLUS ; ε = ZERO ; isCommutativeMonoid = +0IsCommutativeMonoid } -- ⋆IsSemigroup : IsSemigroup _⟷_ TIMES ⋆IsSemigroup = record { isEquivalence = ⟷IsEquivalence ; assoc = λ x y z → assocr⋆ {x} {y} {z} ; ∙-cong = _⊗_ } ⋆1IsMonoid : IsMonoid _⟷_ TIMES ONE ⋆1IsMonoid = record { isSemigroup = ⋆IsSemigroup ; identity = ((λ x → unite⋆ {x}) , (λ x → swap⋆ ◎ unite⋆ {x})) } ⋆1IsCommutativeMonoid : IsCommutativeMonoid _⟷_ TIMES ONE ⋆1IsCommutativeMonoid = record { isSemigroup = ⋆IsSemigroup ; identityˡ = λ x → unite⋆ {x} ; comm = λ x y → swap⋆ {x} {y} } ⋆1CommutativeMonoid : CommutativeMonoid _ _ ⋆1CommutativeMonoid = record { Carrier = B ; _≈_ = _⟷_ ; _∙_ = TIMES ; ε = ONE ; isCommutativeMonoid = ⋆1IsCommutativeMonoid } record IsCommutativeSemiringWithoutAnnihilatingZero {a ℓ} {A : Set a} (≈ : Rel A ℓ) (+ * : Op₂ A) (0# 1# : A) : Set (a ⊔ ℓ) where open FunctionProperties ≈ field +-isCommutativeMonoid : IsCommutativeMonoid ≈ + 0# *-isCommutativeMonoid : IsCommutativeMonoid ≈ * 1# distrib : * DistributesOver + record CommutativeSemiringWithoutAnnihilatingZero c ℓ : Set (suc (c ⊔ ℓ)) where field Carrier : Set c _≈_ : Rel Carrier ℓ _+_ : Op₂ Carrier _*_ : Op₂ Carrier 0# : Carrier 1# : Carrier isCommutativeSemiringWithoutAnnihilatingZero : IsCommutativeSemiringWithoutAnnihilatingZero _≈_ _+_ _*_ 0# 1# B-isCommutativeSemiringWithoutAnnihilatingZero : IsCommutativeSemiringWithoutAnnihilatingZero _⟷_ PLUS TIMES ZERO ONE B-isCommutativeSemiringWithoutAnnihilatingZero = record { +-isCommutativeMonoid = +0IsCommutativeMonoid ; *-isCommutativeMonoid = ⋆1IsCommutativeMonoid ; distrib = ( (λ x y z → dist' {x} {y} {z}) , (λ x y z → dist {y} {z} {x} )) } ------------------------------------------------------------------------------ -- Now we want to add negatives and fractionals... -- Define module over a ring (the types bot, top, disjoint union, and product -- do form a ring as shown in the type-iso library) module MR (C : CommutativeSemiringWithoutAnnihilatingZero Level.zero Level.zero) where open Data.Nat using (ℕ; zero; suc; _*_) open Data.Vec using ([]; _∷_; map; _++_) open CommutativeSemiringWithoutAnnihilatingZero using (Carrier; _+_) R-module : Set → ℕ → Set R-module c dim = Vec c dim {-- zeroV : ∀ {b : Set} → R-module b 0 zeroV = [] tensorV : {b₁ b₂ : Set } {m₁ m₂ : ℕ} → R-module b₁ m₁ → R-module b₂ m₂ → R-module (b₁ × b₂) (m₁ * m₂) tensorV [] _ = [] tensorV (x ∷ xs) ys = (map (λ y → (x , y)) ys) ++ (tensorV xs ys) --} addV : {n : ℕ} → R-module (Carrier C) n → R-module (Carrier C) n → R-module (Carrier C) n addV x y = Data.Vec.zipWith (_+_ C) x y open MR -- neg : {b₁ b₂ : B} → (b₁ ⟷ b₂) → (NEG b₁ ⟷ NEG b₂) neg {b₁} {b₂} c = -- -b1 uniti₊ ◎ -- 0 + (-b1) (η₊ {b₂} ⊕ id⟷) ◎ -- (-b2 + b2) + (-b1) ((id⟷ ⊕ sym c) ⊕ id⟷) ◎ -- (-b2 + b1) + (-b1) assocr₊ ◎ -- (-b2) + (b1 + (-b1)) (id⟷ ⊕ ε₊) ◎ -- (-b2) + 0 swap₊ ◎ -- 0 + (-b2) unite₊ -- -b2 -- mul0 : {b : B} → TIMES ZERO b ⟷ ZERO mul0 = -- 0*b uniti₊ ◎ -- 0 + 0*b (η₊ ⊕ id⟷) ◎ -- (-(0*b) + 0*b) + 0*b assocr₊ ◎ -- -(0*b) + (0*b + 0*b) (id⟷ ⊕ factor) ◎ -- -(0*b) + (0+0)*b (id⟷ ⊕ (unite₊ ⊗ id⟷)) ◎ -- -(0*b) + 0*b swap₊ ◎ ε₊ -- 0 inv0 : TIMES ZERO (RECIP ZERO) ⟷ ZERO inv0 = mul0 -- recip : {b₁ b₂ : B} → (b₁ ⟷ b₂) → (RECIP b₁ ⟷ RECIP b₂) recip {b₁} {b₂} c = -- 1/a rili⋆ {RECIP b₁} ◎ -- 1/a * (1/a * 1/1/a) (id⟷ ⊗ (id⟷ ⊗ refe⋆)) ◎ -- 1/a * (1/a * a) assocl⋆ ◎ -- (1/a * 1/a) * a (id⟷ ⊗ reciplem c) ◎ -- (1/a * 1/a) * (a * ((a * 1/b) * (b * 1/b))) assocl⋆ ◎ -- (((1/a * 1/a) * a) * ((a * 1/b) * (b * 1/b))) ((id⟷ ⊗ refi⋆ ) ⊗ id⟷) ◎ -- (((1/a *1/a) * 1/(1/a)) * ((a * 1/b) * (b * 1/b)) ((assocr⋆ ◎ rile⋆ ) ⊗ (id⟷ ⊗ ((sym c) ⊗ id⟷))) ◎ -- 1/a * ((a * 1/b) * (a * 1/b)) (id⟷ ⊗ (assocr⋆ ◎ (id⟷ ⊗ midtofront))) ◎ -- 1/a * (a * (a * (1/b * 1/b))) (assocl⋆ ◎ assocl⋆) ◎ -- ((1/a * a) * a) * (1/b * 1/b) (((swap⋆ ⊗ id⟷) ◎ swap⋆) ⊗ id⟷) ◎ -- ((a * (a * 1/a)) * (1/b * 1/b)) (rile⋆ ⊗ id⟷ ) ◎ -- a * (1/b * 1/b) ((c ◎ refi⋆ ) ⊗ id⟷) ◎ swap⋆ ◎ -- (1/b * 1/b) * 1/(1/b) assocr⋆ ◎ rile⋆ -- 1/b where reciplem : {b₁ b₂ : B} → (b₁ ⟷ b₂) → (b₁ ⟷ (TIMES b₁ (TIMES (TIMES b₁ (RECIP b₂)) (TIMES b₂ (RECIP b₂))))) reciplem {b₁} {b₂} c = c ◎ -- b rili⋆ ◎ -- b * (b * 1/b) (rili⋆ ⊗ id⟷) ◎ -- (b * (b * 1/b)) * (b * 1/b) (((sym c) ⊗ ((sym c) ⊗ id⟷)) ⊗ id⟷) ◎ -- ((a * (a * 1/b)) * (b * 1/b)) assocr⋆ -- a * ((a * 1/b) * (b * 1/b)) -- adjoint : { b₁ b₂ : B } → (b₁ ⟷ b₂) → (b₂ ⟷ b₁) adjoint unite₊ = uniti₊ adjoint uniti₊ = unite₊ adjoint swap₊ = swap₊ adjoint assocl₊ = assocr₊ adjoint assocr₊ = assocl₊ adjoint unite⋆ = uniti⋆ adjoint uniti⋆ = unite⋆ adjoint swap⋆ = swap⋆ adjoint assocl⋆ = assocr⋆ adjoint assocr⋆ = assocl⋆ adjoint dist = factor adjoint factor = dist adjoint η₊ = swap₊ ◎ ε₊ adjoint ε₊ = η₊ ◎ swap₊ adjoint refe⋆ = refi⋆ adjoint refi⋆ = refe⋆ adjoint rile⋆ = rili⋆ adjoint rili⋆ = rile⋆ adjoint id⟷ = id⟷ adjoint (sym c) = c adjoint (c₁ ◎ c₂) = adjoint c₂ ◎ adjoint c₁ adjoint (c₁ ⊕ c₂) = adjoint c₁ ⊕ adjoint c₂ adjoint (c₁ ⊗ c₂) = adjoint c₁ ⊗ adjoint c₂ eval :{ b₁ b₂ : B } → (b₁ ⟷ b₂) → ⟦ b₁ ⟧ → ⟦ b₂ ⟧ eval unite₊ (inj₁ ()) eval unite₊ (inj₂ v) = v eval uniti₊ v = inj₂ v eval swap₊ (inj₁ v) = inj₂ v eval swap₊ (inj₂ v) = inj₁ v eval assocl₊ (inj₁ v) = inj₁ (inj₁ v) eval assocl₊ (inj₂ (inj₁ v)) = inj₁ (inj₂ v) eval assocl₊ (inj₂ (inj₂ v)) = inj₂ v eval assocr₊ (inj₁ (inj₁ v)) = inj₁ v eval assocr₊ (inj₁ (inj₂ v)) = inj₂ (inj₁ v) eval assocr₊ (inj₂ v) = inj₂ (inj₂ v) eval unite⋆ (tt , v) = v eval uniti⋆ v = (tt , v) eval swap⋆ (v₁ , v₂) = (v₂ , v₁) eval assocl⋆ (v₁ , (v₂ , v₃)) = ((v₁ , v₂) , v₃) eval assocr⋆ ((v₁ , v₂) , v₃) = (v₁ , (v₂ , v₃)) eval dist (inj₁ v₁ , v₃) = inj₁ (v₁ , v₃) eval dist (inj₂ v₂ , v₃) = inj₂ (v₂ , v₃) eval factor (inj₁ (v₁ , v₃)) = (inj₁ v₁ , v₃) eval factor (inj₂ (v₂ , v₃)) = (inj₂ v₂ , v₃) eval η₊ () eval ε₊ (inj₁ x) = {!!} eval ε₊ (inj₂ y) = {!!} eval refe⋆ v = {!!} eval refi⋆ v = {!!} eval rile⋆ v = {!!} eval rili⋆ v = {!!} eval id⟷ v = v eval (sym c) v = eval (adjoint c) v eval (c₁ ◎ c₂) v = eval c₂ (eval c₁ v) eval (c₁ ⊕ c₂) (inj₁ v) = inj₁ (eval c₁ v) eval (c₁ ⊕ c₂) (inj₂ v) = inj₂ (eval c₂ v) eval (c₁ ⊗ c₂) (v₁ , v₂) = (eval c₁ v₁ , eval c₂ v₂) ------------------------------------------------------------------------------ -- Define the alternative semantics based on small-step semantics -- +0-IsGroup : IsGroup _⟷_ PLUS ZERO NEG +0-IsGroup = record { isMonoid = +0IsMonoid ; inverse = ( (λ x → swap₊ ◎ ε₊ {x}) , (λ x → ε₊ {x}) ); ⁻¹-cong = neg } +0-IsAbelianGroup : IsAbelianGroup _⟷_ PLUS ZERO NEG +0-IsAbelianGroup = record { isGroup = +0-IsGroup ; comm = λ x y → swap₊ {x} {y} } B-IsRing : IsRing _⟷_ PLUS TIMES NEG ZERO ONE B-IsRing = record { +-isAbelianGroup = +0-IsAbelianGroup ; *-isMonoid = ⋆1IsMonoid ; distrib = ( (λ x y z → dist' {x} {y} {z}) , (λ x y z → dist {y} {z} {x} )) } B-IsCommutativeRing : IsCommutativeRing _⟷_ PLUS TIMES NEG ZERO ONE B-IsCommutativeRing = record { isRing = B-IsRing ; *-comm = λ x y → swap⋆ {x} {y} } -- B-CommutativeRing : CommutativeRing _ _ B-CommutativeRing = record { Carrier = B ; _≈_ = _⟷_ ; _+_ = PLUS ; _*_ = TIMES ; -_ = NEG ; 0# = ZERO ; 1# = ONE ; isCommutativeRing = B-IsCommutativeRing } -- record IsMeadow {a ℓ} {A : Set a} (≈ : Rel A ℓ) (+ * : Op₂ A) (- r : Op₁ A) (0# 1# : A) : Set (a ⊔ ℓ) where open FunctionProperties ≈ field +*-isCommutativeRing : IsCommutativeRing ≈ + * - 0# 1# *-refl-l : ∀ x → ≈ (r (r x)) x *-refl-r : ∀ x → ≈ x (r (r x)) *-ril-l : ∀ x → ≈ (* x (* x (r x))) x *-ril-r : ∀ x → ≈ x (* x (* x (r x))) r-cong : ∀ x y → ≈ x y → ≈ (r x) (r y) record Meadow c ℓ : Set (suc (c ⊔ ℓ)) where field Carrier : Set c _≈_ : Rel Carrier ℓ _+_ : Op₂ Carrier _*_ : Op₂ Carrier -_ : Op₁ Carrier r : Op₁ Carrier 0# : Carrier 1# : Carrier isMeadow : IsMeadow _≈_ _+_ _*_ -_ r 0# 1# B-/IsMeadow : IsMeadow _⟷_ PLUS TIMES NEG RECIP ZERO ONE B-/IsMeadow = record { +*-isCommutativeRing = B-IsCommutativeRing ; *-refl-l = λ x → refe⋆ {x} ; *-refl-r = λ x → sym (refe⋆ {x}) ; *-ril-l = λ x → sym (rili⋆ {x}) ; *-ril-r = λ x → rili⋆ {x} ; r-cong = λ x y → recip {x} {y} } B-/Meadow : Meadow _ _ B-/Meadow = record { Carrier = B ; _≈_ = _⟷_ ; _+_ = PLUS ; _*_ = TIMES ; -_ = NEG ; r = RECIP ; 0# = ZERO ; 1# = ONE ; isMeadow = B-/IsMeadow } ------------------------------------------------------------------------------ -- NOW WE DEFINE THE SEMANTIC NOTION OF EQUIVALENCE record _⟺_ (b₁ b₂ : B) : Set where constructor equiv field f₁₂ : ⟦ b₁ ⟧ → ⟦ b₂ ⟧ f₂₁ : ⟦ b₂ ⟧ → ⟦ b₁ ⟧ p₁ : ∀ { x : ⟦ b₁ ⟧ } → f₂₁ (f₁₂ x) ≡ x p₂ : ∀ { x : ⟦ b₂ ⟧ } → f₁₂ (f₂₁ x) ≡ x open _⟺_ public lem-⟺-inv : ∀{A B C : Set }(g₁₂ : A → B )(g₂₁ : B → A) (g₂₃ : B → C)(g₃₂ : C → B) → (∀ {x : B } → g₁₂ (g₂₁ x) ≡ x) → ({y : C } → g₂₃ (g₃₂ y) ≡ y ) → (∀ {z} → g₂₃ (g₁₂ (g₂₁ (g₃₂ z))) ≡ z) lem-⟺-inv g₁₂ g₂₁ g₂₃ g₃₂ p₁ p₂ {z = z} = trans p p₂ where w = g₁₂ (g₂₁ (g₃₂ z)) p = cong g₂₃ {w} p₁ _⊙_ : {b₁ b₂ b₃ : B} → b₁ ⟺ b₂ → b₂ ⟺ b₃ → b₁ ⟺ b₃ r ⊙ s = equiv (λ x → f₁₂ s ( f₁₂ r x)) (λ x → f₂₁ r ( f₂₁ s x)) (lem-⟺-inv (f₂₁ s) (f₁₂ s) (f₂₁ r) (f₁₂ r) (p₁ s) (p₁ r)) (lem-⟺-inv (f₁₂ r) (f₂₁ r) (f₁₂ s) (f₂₁ s) (p₂ r) (p₂ s)) -- THESE ARE NEEDED MULTIPLE TIMES, FACTOR OUT zeroe : {A : Set} → ⊥ ⊎ A → A zeroe (inj₁ ()) zeroe (inj₂ V) = V zeroi : {A : Set} → A → ⊥ ⊎ A zeroi v = inj₂ v zeroeip : { A : Set } { x : ⊥ ⊎ A } → zeroi (zeroe x) ≡ x zeroeip { x = inj₁ () } zeroeip { x = inj₂ v } = refl sw : {A₁ A₂ : Set} → A₁ ⊎ A₂ → A₂ ⊎ A₁ sw (inj₁ v) = inj₂ v sw (inj₂ v) = inj₁ v swp : { A₁ A₂ : Set } → { x : A₁ ⊎ A₂ } → sw (sw x) ≡ x swp { x = inj₁ v } = refl swp { x = inj₂ v } = refl -- And finally we map each code to an actual equivalence iso : { b₁ b₂ : B } → b₁ ⟷ b₂ → b₁ ⟺ b₂ iso id⟷ = equiv id id refl refl iso (f ◎ g) = (iso f) ⊙ (iso g) iso unite₊ = equiv zeroe zeroi zeroeip refl iso swap₊ = equiv sw sw swp swp iso _ = {!!} ------------------------------------------------------------------------------ -- Examples BOOL : B BOOL = PLUS ONE ONE BOOL² : B BOOL² = TIMES BOOL BOOL BOOL³ : B BOOL³ = TIMES BOOL BOOL² unitπ : ⟦ ONE ⟧ unitπ = tt trueπ : ⟦ BOOL ⟧ trueπ = inj₁ tt falseπ : ⟦ BOOL ⟧ falseπ = inj₂ tt e0 : ⟦ BOOL² ⟧ e0 = (falseπ , falseπ) e1 : ⟦ BOOL² ⟧ e1 = (falseπ , trueπ) e2 : ⟦ BOOL² ⟧ e2 = (trueπ , falseπ) e3 : ⟦ BOOL² ⟧ e3 = (trueπ , trueπ) notπ : BOOL ⟷ BOOL notπ = swap₊ ifc : { b : B } → (b ⟷ b) → (TIMES BOOL b ⟷ TIMES BOOL b) ifc c = dist ◎ ((id⟷ ⊗ c) ⊕ id⟷) ◎ factor cnot : BOOL² ⟷ BOOL² cnot = ifc notπ toffoli : BOOL³ ⟷ BOOL³ toffoli = ifc cnot test1 : ⟦ BOOL³ ⟧ test1 = eval toffoli (trueπ , (trueπ , trueπ)) ------------------------------------------------------------------------------
{ "alphanum_fraction": 0.4909417962, "avg_line_length": 29.2045028143, "ext": "agda", "hexsha": "6b9d12285421898b1cf9101ba9ca572a19d8ffff", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2019-09-10T09:47:13.000Z", "max_forks_repo_forks_event_min_datetime": "2016-05-29T01:56:33.000Z", "max_forks_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_forks_repo_licenses": [ "BSD-2-Clause" ], "max_forks_repo_name": "JacquesCarette/pi-dual", "max_forks_repo_path": "agda/oldPi.agda", "max_issues_count": 4, "max_issues_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_issues_repo_issues_event_max_datetime": "2021-10-29T20:41:23.000Z", "max_issues_repo_issues_event_min_datetime": "2018-06-07T16:27:41.000Z", "max_issues_repo_licenses": [ "BSD-2-Clause" ], "max_issues_repo_name": "JacquesCarette/pi-dual", "max_issues_repo_path": "agda/oldPi.agda", "max_line_length": 110, "max_stars_count": 14, "max_stars_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_stars_repo_licenses": [ "BSD-2-Clause" ], "max_stars_repo_name": "JacquesCarette/pi-dual", "max_stars_repo_path": "agda/oldPi.agda", "max_stars_repo_stars_event_max_datetime": "2021-05-05T01:07:57.000Z", "max_stars_repo_stars_event_min_datetime": "2015-08-18T21:40:15.000Z", "num_tokens": 6843, "size": 15566 }
postulate A : Set a : A record B : Set where constructor i field b : A open B data D : (X : Set) → X → Set where c : D B (record { b = a }) accepted : (X : Set) (x : X) → D X x → Set accepted .B (i a) c = A rejected : (X : Set) (x : X) → D X x → Set rejected .B (record { b = a }) c = A -- WAS: -- I'm not sure if there should be a case for the constructor c, -- because I get stuck when trying to solve the following unification -- problems (inferred index ≟ expected index): -- B ≟ X -- record { b = a } ≟ x -- when checking that the pattern c has type D X x -- SHOULD: succeed
{ "alphanum_fraction": 0.5923460899, "avg_line_length": 20.724137931, "ext": "agda", "hexsha": "d980e0c78301e6121f261eada48fad6c608c3db6", "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/Issue2850.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/Issue2850.agda", "max_line_length": 69, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "test/Succeed/Issue2850.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": 203, "size": 601 }
module SystemF.Syntax.Type where open import Prelude open import Data.Fin hiding (lift) open import Data.Fin.Substitution open import Extensions.Substitution open import Data.Star using (Star; ε; _◅_) infixl 10 _→'_ data Type (ν : ℕ) : Set where tc : ℕ → Type ν tvar : (n : Fin ν) → Type ν _→'_ : Type ν → Type ν → Type ν _⟶_ : Type ν → Type ν → Type ν ∀' : Type (suc ν) → Type ν data Base {ν} : (Type ν) → Set where tc : ∀ n → Base (tc n) tvar : ∀ n → Base (tvar n) _⟶_ : ∀ a b → Base (a ⟶ b) module Functions where -- proposition that states that the given polytype -- is a (possibly polymorphic) function data IsFunction {ν : ℕ} : Type ν → Set where lambda : (a b : Type ν) → IsFunction (a →' b) ∀'-lambda : ∀ {f} → IsFunction f → IsFunction (∀' f) -- decision procedure for IsFunction is-function : ∀ {ν} → (a : Type ν) → Dec (IsFunction a) is-function (tc c) = no (λ ()) is-function (tvar n) = no (λ ()) is-function (a →' b) = yes (lambda a b) is-function (a ⟶ b) = no (λ ()) is-function (∀' a) with is-function a is-function (∀' a) | yes a-is-f = yes $ ∀'-lambda a-is-f is-function (∀' a) | no a-not-f = no (λ{ (∀'-lambda a-is-f) → a-not-f a-is-f }) domain : ∀ {ν} {f : Type ν} → IsFunction f → Type ν domain (lambda a b) = a domain (∀'-lambda f) = ∀' (domain f) codomain : ∀ {ν} {f : Type ν} → IsFunction f → Type ν codomain (lambda a b) = b codomain (∀'-lambda f) = ∀' (codomain f) open Functions public
{ "alphanum_fraction": 0.5884330868, "avg_line_length": 30.3469387755, "ext": "agda", "hexsha": "7bd68b637b832b76166a516ff565370b24074aa8", "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/Syntax/Type.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/Syntax/Type.agda", "max_line_length": 81, "max_stars_count": 4, "max_stars_repo_head_hexsha": "7fe638b87de26df47b6437f5ab0a8b955384958d", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "metaborg/ts.agda", "max_stars_repo_path": "src/SystemF/Syntax/Type.agda", "max_stars_repo_stars_event_max_datetime": "2021-05-07T04:08:41.000Z", "max_stars_repo_stars_event_min_datetime": "2019-04-05T17:57:11.000Z", "num_tokens": 530, "size": 1487 }
module NoQualifiedInstances.Import.A where record I : Set where instance postulate i : I
{ "alphanum_fraction": 0.7741935484, "avg_line_length": 13.2857142857, "ext": "agda", "hexsha": "87c9a85924c42d677f16f0df93ec6b7ecd8d9e02", "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/NoQualifiedInstances/Import/A.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/NoQualifiedInstances/Import/A.agda", "max_line_length": 42, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/Succeed/NoQualifiedInstances/Import/A.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 23, "size": 93 }
open import Categories open import Monads module Monads.EM.Adjunction {a b}{C : Cat {a}{b}}(M : Monad C) where open import Library open import Functors open import Adjunctions open import Monads.EM M open import Monads.EM.Functors M open Cat C open Fun open Monad M open Adj open Alg open AlgMorph EMAdj : Adj C EM EMAdj = record { L = EML; R = EMR; left = λ f → comp (amor f) η; right = λ {X}{Y} f → record{amor = astr Y X f; ahom = λ {Z}{g} → proof comp (astr Y X f) (astr (OMap EML X) Z g) ≅⟨ sym (alaw2 Y) ⟩ astr Y Z (comp (astr Y X f) g) ∎}; lawa = λ {X}{Y}(f : AlgMorph (OMap EML X) Y) → AlgMorphEq ( proof astr Y X (comp (amor f) η) ≅⟨ sym (ahom f) ⟩ comp (amor f) (astr (OMap EML X) X η) ≡⟨⟩ comp (amor f) (bind η) ≅⟨ cong (comp (amor f)) law1 ⟩ comp (amor f) iden ≅⟨ idr ⟩ amor f ∎); lawb = λ {X}{Y} f → proof comp (astr Y X f) η ≅⟨ sym (alaw1 Y) ⟩ f ∎; natleft = λ{X}{X'}{Y}{Y'} f g h → proof comp (amor g) (comp (comp (amor h) η) f) ≅⟨ cong (comp (amor g)) ass ⟩ comp (amor g) (comp (amor h) (comp η f)) ≅⟨ cong (comp (amor g) ∘ comp (amor h)) (sym law2) ⟩ comp (amor g) (comp (amor h) (comp (bind (comp η f)) η)) ≅⟨ cong (comp (amor g)) (sym ass) ⟩ comp (amor g) (comp (comp (amor h) (bind (comp η f))) η) ≅⟨ sym ass ⟩ comp (comp (amor g) (comp (amor h) (bind (comp η f)))) η ∎; natright = λ{X}{X'}{Y}{Y'} f g h → AlgMorphEq ( proof astr Y' X' (comp (amor g) (comp h f)) ≅⟨ sym (ahom g) ⟩ comp (amor g) (astr Y X' (comp h f)) ≅⟨ cong (λ h → comp (amor g) (astr Y X' (comp h f))) (alaw1 Y) ⟩ comp (amor g) (astr Y X' (comp (comp (astr Y X h) η) f)) ≅⟨ cong (comp (amor g) ∘ astr Y X') ass ⟩ comp (amor g) (astr Y X' (comp (astr Y X h) (comp η f))) ≅⟨ cong (comp (amor g)) (alaw2 Y) ⟩ comp (amor g) (comp (astr Y X h) (bind (comp η f))) ∎)}
{ "alphanum_fraction": 0.5091538842, "avg_line_length": 26.9466666667, "ext": "agda", "hexsha": "9d0f2863cb038dc652abc780245c42acf50dcef0", "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/EM/Adjunction.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/EM/Adjunction.agda", "max_line_length": 68, "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/EM/Adjunction.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": 884, "size": 2021 }
{-# OPTIONS --without-K --safe #-} {- Extremal Mono and Epimorphisms. https://ncatlab.org/nlab/show/extremal+epimorphism -} open import Categories.Category.Core module Categories.Morphism.Extremal {o ℓ e} (𝒞 : Category o ℓ e) where open import Level open import Categories.Morphism 𝒞 open Category 𝒞 IsExtremalEpi : ∀ {A B} {f : A ⇒ B} → Epi f → Set (o ⊔ ℓ ⊔ e) IsExtremalEpi {A = A} {B = B} {f = f} epi = ∀ {X} {i : X ⇒ B} {g : A ⇒ X} → Mono i → f ≈ i ∘ g → IsIso i IsExtremalMono : ∀ {A B} {f : A ⇒ B} → Mono f → Set (o ⊔ ℓ ⊔ e) IsExtremalMono {A = A} {B = B} {f = f} mono = ∀ {X} {g : X ⇒ B} {i : A ⇒ X} → Epi i → f ≈ g ∘ i → IsIso i record ExtremalEpi {A B} (f : A ⇒ B) : Set (o ⊔ ℓ ⊔ e) where field epi : Epi f extremal : IsExtremalEpi epi record ExtremalMono {A B} (f : A ⇒ B) : Set (o ⊔ ℓ ⊔ e) where field mono : Mono f extremal : IsExtremalMono mono
{ "alphanum_fraction": 0.5725359911, "avg_line_length": 25.0833333333, "ext": "agda", "hexsha": "375d5a75dbbc19f2f5d4664569d7a2128e8a250b", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "8f3c844d929508040dfa21f681fa260056214b73", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "maxsnew/agda-categories", "max_forks_repo_path": "src/Categories/Morphism/Extremal.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "8f3c844d929508040dfa21f681fa260056214b73", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "maxsnew/agda-categories", "max_issues_repo_path": "src/Categories/Morphism/Extremal.agda", "max_line_length": 70, "max_stars_count": null, "max_stars_repo_head_hexsha": "8f3c844d929508040dfa21f681fa260056214b73", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "maxsnew/agda-categories", "max_stars_repo_path": "src/Categories/Morphism/Extremal.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 383, "size": 903 }
{-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.Homotopy.Loopspace where open import Cubical.Core.Everything open import Cubical.Data.Nat open import Cubical.Foundations.Prelude open import Cubical.Foundations.Pointed open import Cubical.Foundations.HLevels open import Cubical.Foundations.GroupoidLaws open import Cubical.HITs.SetTruncation open import Cubical.HITs.Truncation hiding (elim2) {- loop space of a pointed type -} Ω : {ℓ : Level} → Pointed ℓ → Pointed ℓ Ω (_ , a) = ((a ≡ a) , refl) {- n-fold loop space of a pointed type -} Ω^_ : ∀ {ℓ} → ℕ → Pointed ℓ → Pointed ℓ (Ω^ 0) p = p (Ω^ (suc n)) p = Ω ((Ω^ n) p) {- homotopy Group -} π : ∀ {ℓ} (n : ℕ) (A : Pointed ℓ) → Type ℓ π n A = ∥ typ ((Ω^ n) A) ∥ 2 {- loop space map -} Ω→ : ∀ {ℓA ℓB} {A : Pointed ℓA} {B : Pointed ℓB} (f : A →∙ B) → (Ω A →∙ Ω B) Ω→ (f , f∙) = (λ p → (sym f∙ ∙ cong f p) ∙ f∙) , cong (λ q → q ∙ f∙) (sym (rUnit (sym f∙))) ∙ lCancel f∙ Eckmann-Hilton : ∀ {ℓ} {A : Pointed ℓ} (n : ℕ) (α β : typ ((Ω^ (2 + n)) A)) → α ∙ β ≡ β ∙ α Eckmann-Hilton {A = A} n α β i = comp (λ k → rUnit (snd ((Ω^ (1 + n)) A)) (~ k) ≡ rUnit (snd ((Ω^ (1 + n)) A)) (~ k)) -- note : rUnit refl := lUnit refl (λ k → λ { (i = i0) → (cong (λ x → rUnit x (~ k)) α) ∙ cong (λ x → lUnit x (~ k)) β ; (i = i1) → (cong (λ x → lUnit x (~ k)) β) ∙ cong (λ x → rUnit x (~ k)) α}) ((λ j → α (j ∧ ~ i) ∙ β (j ∧ i)) ∙ λ j → α (~ i ∨ j) ∙ β (i ∨ j)) {- Homotopy group version -} π-comp : ∀ {ℓ} {A : Pointed ℓ} (n : ℕ) → ∥ typ ((Ω^ (suc n)) A) ∥₂ → ∥ typ ((Ω^ (suc n)) A) ∥₂ → ∥ typ ((Ω^ (suc n)) A) ∥₂ π-comp n = elim2 (λ _ _ → setTruncIsSet) λ p q → ∣ p ∙ q ∣₂ Eckmann-Hilton-π : ∀ {ℓ} {A : Pointed ℓ} (n : ℕ) (p q : ∥ typ ((Ω^ (2 + n)) A) ∥₂) → π-comp (1 + n) p q ≡ π-comp (1 + n) q p Eckmann-Hilton-π n = elim2 (λ x y → isOfHLevelPath 2 setTruncIsSet _ _) λ p q → cong ∣_∣₂ (Eckmann-Hilton n p q)
{ "alphanum_fraction": 0.514750763, "avg_line_length": 39.32, "ext": "agda", "hexsha": "bf19f964b95d30326261afca816528bfefbce24f", "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": "f25b8479fe8160fa4ddbb32e288ba26be6cc242f", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "ayberkt/cubical", "max_forks_repo_path": "Cubical/Homotopy/Loopspace.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "f25b8479fe8160fa4ddbb32e288ba26be6cc242f", "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": "ayberkt/cubical", "max_issues_repo_path": "Cubical/Homotopy/Loopspace.agda", "max_line_length": 121, "max_stars_count": null, "max_stars_repo_head_hexsha": "f25b8479fe8160fa4ddbb32e288ba26be6cc242f", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "ayberkt/cubical", "max_stars_repo_path": "Cubical/Homotopy/Loopspace.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 887, "size": 1966 }
open import Mockingbird.Forest using (Forest) -- A Gallery of Sage Birds module Mockingbird.Problems.Chapter13 {b ℓ} (forest : Forest {b} {ℓ}) where open import Function using (_$_) open import Data.Product using (proj₂) open import Mockingbird.Forest.Birds forest import Mockingbird.Problems.Chapter09 forest as Chapter₉ import Mockingbird.Problems.Chapter10 forest as Chapter₁₀ import Mockingbird.Problems.Chapter11 forest as Chapter₁₁ import Mockingbird.Problems.Chapter12 forest as Chapter₁₂ open Forest forest problem₁ : ⦃ _ : HasBluebird ⦄ ⦃ _ : HasMockingbird ⦄ ⦃ _ : HasRobin ⦄ → HasSageBird problem₁ = record { Θ = B ∙ M ∙ (R ∙ M ∙ B) ; isSageBird = λ x → begin x ∙ (B ∙ M ∙ (R ∙ M ∙ B) ∙ x) ≈⟨ congˡ lemma ⟩ x ∙ (M ∙ (B ∙ x ∙ M)) ≈⟨ isFond ⟩ M ∙ (B ∙ x ∙ M) ≈˘⟨ lemma ⟩ B ∙ M ∙ (R ∙ M ∙ B) ∙ x ∎ } where isFond = λ {x} → proj₂ (Chapter₁₁.problem₂ x) lemma : ∀ {x} → B ∙ M ∙ (R ∙ M ∙ B) ∙ x ≈ M ∙ (B ∙ x ∙ M) lemma {x} = begin B ∙ M ∙ (R ∙ M ∙ B) ∙ x ≈⟨ isBluebird M (R ∙ M ∙ B) x ⟩ M ∙ (R ∙ M ∙ B ∙ x) ≈⟨ congˡ $ isRobin M B x ⟩ M ∙ (B ∙ x ∙ M) ∎ problem₂ : ⦃ _ : HasBluebird ⦄ ⦃ _ : HasMockingbird ⦄ ⦃ _ : HasCardinal ⦄ → HasSageBird problem₂ = record { Θ = B ∙ M ∙ (C ∙ B ∙ M) ; isSageBird = λ x → begin x ∙ (B ∙ M ∙ (C ∙ B ∙ M) ∙ x) ≈⟨ congˡ lemma ⟩ x ∙ (M ∙ (B ∙ x ∙ M)) ≈⟨ isFond ⟩ M ∙ (B ∙ x ∙ M) ≈˘⟨ lemma ⟩ B ∙ M ∙ (C ∙ B ∙ M) ∙ x ∎ } where isFond = λ {x} → proj₂ (Chapter₁₁.problem₂ x) lemma : ∀ {x} → B ∙ M ∙ (C ∙ B ∙ M) ∙ x ≈ M ∙ (B ∙ x ∙ M) lemma {x} = begin B ∙ M ∙ (C ∙ B ∙ M) ∙ x ≈⟨ isBluebird M (C ∙ B ∙ M) x ⟩ M ∙ (C ∙ B ∙ M ∙ x) ≈⟨ congˡ $ isCardinal B M x ⟩ M ∙ (B ∙ x ∙ M) ∎ problem₃ : ⦃ _ : HasMockingbird ⦄ ⦃ _ : HasBluebird ⦄ ⦃ _ : HasLark ⦄ → HasSageBird problem₃ = record { Θ = B ∙ M ∙ L ; isSageBird = isSageBird ⦃ Chapter₁₀.hasSageBird ⦄ } where instance hasComposition = Chapter₁₁.problem₁ problem₄ : ⦃ _ : HasMockingbird ⦄ ⦃ _ : HasBluebird ⦄ ⦃ _ : HasWarbler ⦄ → HasSageBird problem₄ = record { Θ = B ∙ M ∙ (B ∙ W ∙ B) ; isSageBird = isSageBird ⦃ problem₃ ⦄ } where instance hasLark = Chapter₁₂.problem₃ problem₆ : ⦃ _ : HasQueerBird ⦄ ⦃ _ : HasLark ⦄ ⦃ _ : HasWarbler ⦄ → HasSageBird problem₆ = record { Θ = W ∙ (Q ∙ L ∙ (Q ∙ L)) ; isSageBird = λ x → begin x ∙ (W ∙ (Q ∙ L ∙ (Q ∙ L)) ∙ x) ≈⟨ congˡ lemma ⟩ x ∙ (L ∙ x ∙ (L ∙ x)) ≈⟨ isFond ⟩ L ∙ x ∙ (L ∙ x) ≈˘⟨ lemma ⟩ W ∙ (Q ∙ L ∙ (Q ∙ L)) ∙ x ∎ } where isFond = λ {x} → proj₂ (Chapter₉.problem₂₅ x) lemma : ∀ {x} → W ∙ (Q ∙ L ∙ (Q ∙ L)) ∙ x ≈ L ∙ x ∙ (L ∙ x) lemma {x} = begin W ∙ (Q ∙ L ∙ (Q ∙ L)) ∙ x ≈⟨ isWarbler (Q ∙ L ∙ (Q ∙ L)) x ⟩ Q ∙ L ∙ (Q ∙ L) ∙ x ∙ x ≈⟨ congʳ $ isQueerBird L (Q ∙ L) x ⟩ Q ∙ L ∙ (L ∙ x) ∙ x ≈⟨ isQueerBird L (L ∙ x) x ⟩ L ∙ x ∙ (L ∙ x) ∎ problem₅ : ⦃ _ : HasBluebird ⦄ ⦃ _ : HasCardinal ⦄ ⦃ _ : HasWarbler ⦄ → HasSageBird problem₅ = problem₆ where instance hasQueerBird = Chapter₁₁.problem₃₇′ hasLark = Chapter₁₂.problem₃ problem₇ = problem₅ problem₈ : ⦃ _ : HasMockingbird ⦄ ⦃ _ : HasQueerBird ⦄ → HasSageBird problem₈ = record { Θ = Q ∙ (Q ∙ M) ∙ M ; isSageBird = λ x → sym $ begin Q ∙ (Q ∙ M) ∙ M ∙ x ≈⟨ isQueerBird (Q ∙ M) M x ⟩ M ∙ (Q ∙ M ∙ x) ≈⟨ isMockingbird (Q ∙ M ∙ x) ⟩ Q ∙ M ∙ x ∙ (Q ∙ M ∙ x) ≈⟨ isQueerBird M x (Q ∙ M ∙ x) ⟩ x ∙ (M ∙ (Q ∙ M ∙ x)) ≈˘⟨ congˡ $ isQueerBird (Q ∙ M) M x ⟩ x ∙ (Q ∙ (Q ∙ M) ∙ M ∙ x) ∎ } -- TODO: formalise regularity. problem₉ : ⦃ _ : HasStarling ⦄ ⦃ _ : HasLark ⦄ → HasSageBird problem₉ = record { Θ = S ∙ L ∙ L ; isSageBird = λ x → begin x ∙ (S ∙ L ∙ L ∙ x) ≈⟨ congˡ $ isStarling L L x ⟩ x ∙ (L ∙ x ∙ (L ∙ x)) ≈⟨ isFond ⟩ L ∙ x ∙ (L ∙ x) ≈˘⟨ isStarling L L x ⟩ S ∙ L ∙ L ∙ x ∎ } where isFond = λ {x} → proj₂ (Chapter₉.problem₂₅ x) problem₁₀ : ⦃ _ : HasBluebird ⦄ ⦃ _ : HasWarbler ⦄ ⦃ _ : HasStarling ⦄ → HasSageBird problem₁₀ = record { Θ = W ∙ S ∙ (B ∙ W ∙ B) ; isSageBird = λ x → begin x ∙ (W ∙ S ∙ (B ∙ W ∙ B) ∙ x) ≈⟨⟩ x ∙ (W ∙ S ∙ L ∙ x) ≈⟨ congˡ $ congʳ $ isWarbler S L ⟩ x ∙ (S ∙ L ∙ L ∙ x) ≈⟨ isSageBird ⦃ problem₉ ⦄ x ⟩ S ∙ L ∙ L ∙ x ≈˘⟨ congʳ $ isWarbler S L ⟩ W ∙ S ∙ L ∙ x ≈⟨⟩ W ∙ S ∙ (B ∙ W ∙ B) ∙ x ∎ } where instance hasLark = Chapter₁₂.problem₃ problem₁₁ : ⦃ _ : HasBluebird ⦄ ⦃ _ : HasMockingbird ⦄ ⦃ _ : HasThrush ⦄ → HasTuringBird problem₁₁ = record { U = B ∙ (B ∙ W ∙ (C ∙ B)) ∙ M ; isTuringBird = λ x y → begin B ∙ (B ∙ W ∙ (C ∙ B)) ∙ M ∙ x ∙ y ≈⟨ congʳ $ isBluebird (B ∙ W ∙ (C ∙ B)) M x ⟩ B ∙ W ∙ (C ∙ B) ∙ (M ∙ x) ∙ y ≈⟨ congʳ $ isBluebird W (C ∙ B) (M ∙ x) ⟩ W ∙ (C ∙ B ∙ (M ∙ x)) ∙ y ≈⟨ isWarbler (C ∙ B ∙ (M ∙ x)) y ⟩ C ∙ B ∙ (M ∙ x) ∙ y ∙ y ≈⟨ congʳ $ isCardinal B (M ∙ x) y ⟩ B ∙ y ∙ (M ∙ x) ∙ y ≈⟨ isBluebird y (M ∙ x) y ⟩ y ∙ (M ∙ x ∙ y) ≈⟨ congˡ $ congʳ $ isMockingbird x ⟩ y ∙ (x ∙ x ∙ y) ∎ } where instance hasCardinal = Chapter₁₁.problem₂₁′ hasLark = Chapter₁₂.problem₇ problem₁₂ : ⦃ _ : HasTuringBird ⦄ → HasSageBird problem₁₂ = record { Θ = U ∙ U ; isSageBird = λ x → sym $ isTuringBird U x } problem₁₃ : ⦃ _ : HasQueerBird ⦄ ⦃ _ : HasWarbler ⦄ → HasOwl problem₁₃ = record { O = Q ∙ Q ∙ W ; isOwl = λ x y → begin Q ∙ Q ∙ W ∙ x ∙ y ≈⟨ congʳ $ isQueerBird Q W x ⟩ W ∙ (Q ∙ x) ∙ y ≈⟨ isWarbler (Q ∙ x) y ⟩ Q ∙ x ∙ y ∙ y ≈⟨ isQueerBird x y y ⟩ y ∙ (x ∙ y) ∎ } problem₁₄ : ⦃ _ : HasOwl ⦄ ⦃ _ : HasLark ⦄ → HasTuringBird problem₁₄ = record { U = L ∙ O ; isTuringBird = λ x y → begin L ∙ O ∙ x ∙ y ≈⟨ congʳ $ isLark O x ⟩ O ∙ (x ∙ x) ∙ y ≈⟨ isOwl (x ∙ x) y ⟩ y ∙ (x ∙ x ∙ y) ∎ } problem₁₅ : ⦃ _ : HasOwl ⦄ ⦃ _ : HasIdentity ⦄ → HasMockingbird problem₁₅ = record { M = O ∙ I ; isMockingbird = λ x → begin O ∙ I ∙ x ≈⟨ isOwl I x ⟩ x ∙ (I ∙ x) ≈⟨ congˡ $ isIdentity x ⟩ x ∙ x ∎ } problem₁₆ : ⦃ _ : HasStarling ⦄ ⦃ _ : HasIdentity ⦄ → HasOwl problem₁₆ = record { O = S ∙ I ; isOwl = λ x y → begin S ∙ I ∙ x ∙ y ≈⟨ isStarling I x y ⟩ I ∙ y ∙ (x ∙ y) ≈⟨ congʳ $ isIdentity y ⟩ y ∙ (x ∙ y) ∎ } problem₁₇ : ∀ x y → x IsFondOf y → x IsFondOf x ∙ y problem₁₇ x y xy≈y = begin x ∙ (x ∙ y) ≈⟨ congˡ xy≈y ⟩ x ∙ y ∎ problem₁₈ : ⦃ _ : HasOwl ⦄ ⦃ _ : HasSageBird ⦄ → IsSageBird (O ∙ Θ) problem₁₈ x = begin x ∙ (O ∙ Θ ∙ x) ≈⟨ congˡ $ isOwl Θ x ⟩ x ∙ (x ∙ (Θ ∙ x)) ≈⟨ isFond ⟩ x ∙ (Θ ∙ x) ≈˘⟨ isOwl Θ x ⟩ O ∙ Θ ∙ x ∎ where isFond : x IsFondOf (x ∙ (Θ ∙ x)) isFond = problem₁₇ x (Θ ∙ x) (isSageBird x) problem₁₉ : ⦃ _ : HasOwl ⦄ ⦃ _ : HasSageBird ⦄ → IsSageBird (Θ ∙ O) problem₁₉ x = sym $ begin Θ ∙ O ∙ x ≈˘⟨ congʳ $ isSageBird O ⟩ O ∙ (Θ ∙ O) ∙ x ≈⟨ isOwl (Θ ∙ O) x ⟩ x ∙ (Θ ∙ O ∙ x) ∎ problem₂₀ : ⦃ _ : HasOwl ⦄ → ∀ A → O IsFondOf A → IsSageBird A problem₂₀ A OA≈A x = begin x ∙ (A ∙ x) ≈˘⟨ isOwl A x ⟩ O ∙ A ∙ x ≈⟨ congʳ OA≈A ⟩ A ∙ x ∎ problem₂₁ : ⦃ _ : HasSageBird ⦄ → ∀ A → IsChoosy A → IsSageBird (Θ ∙ A) problem₂₁ A isChoosy = isChoosy (Θ ∙ A) $ isSageBird A open import Mockingbird.Forest.Extensionality forest problem₂₂ : ⦃ _ : HasOwl ⦄ ⦃ _ : HasSageBird ⦄ → O ∙ Θ ≋ Θ problem₂₂ x = begin O ∙ Θ ∙ x ≈⟨ isOwl Θ x ⟩ x ∙ (Θ ∙ x) ≈⟨ isSageBird x ⟩ Θ ∙ x ∎ problem₂₃ : ⦃ _ : Extensional ⦄ ⦃ _ : HasOwl ⦄ ⦃ _ : HasSageBird ⦄ → O IsFondOf Θ problem₂₃ = ext problem₂₂
{ "alphanum_fraction": 0.4790757381, "avg_line_length": 34.4690265487, "ext": "agda", "hexsha": "1be4ede685cf02564cf7978c5b3b3aac8b060122", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "df8bf877e60b3059532c54a247a36a3d83cd55b0", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "splintah/combinatory-logic", "max_forks_repo_path": "Mockingbird/Problems/Chapter13.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "df8bf877e60b3059532c54a247a36a3d83cd55b0", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "splintah/combinatory-logic", "max_issues_repo_path": "Mockingbird/Problems/Chapter13.agda", "max_line_length": 88, "max_stars_count": 1, "max_stars_repo_head_hexsha": "df8bf877e60b3059532c54a247a36a3d83cd55b0", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "splintah/combinatory-logic", "max_stars_repo_path": "Mockingbird/Problems/Chapter13.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-28T23:44:42.000Z", "max_stars_repo_stars_event_min_datetime": "2022-02-28T23:44:42.000Z", "num_tokens": 4032, "size": 7790 }
open import Prelude open import Nat open import List open import contexts module unions where -- values mapped in Γ2 replace those mapped in Γ1 _∪_ : {A : Set} → A ctx → A ctx → A ctx Γ1 ∪ Γ2 = union (λ a b → b) Γ1 Γ2 -- duplicate mappings are combined by append (_++_) _⊎_ : {A : Set} → (List A) ctx → (List A) ctx → (List A) ctx Γ1 ⊎ Γ2 = union (λ a b → a ++ b) Γ1 Γ2 infixl 50 _∪_ infixl 50 _⊎_
{ "alphanum_fraction": 0.618705036, "avg_line_length": 24.5294117647, "ext": "agda", "hexsha": "6598e58a5f5717018d5df71ae94851c7e08c93e6", "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": "a8f9299090d95f4ef1a6c2f15954c2981c0ee25c", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "hazelgrove/hazelnat-myth-", "max_forks_repo_path": "unions.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "a8f9299090d95f4ef1a6c2f15954c2981c0ee25c", "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/hazelnat-myth-", "max_issues_repo_path": "unions.agda", "max_line_length": 62, "max_stars_count": 1, "max_stars_repo_head_hexsha": "a8f9299090d95f4ef1a6c2f15954c2981c0ee25c", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "hazelgrove/hazelnat-myth-", "max_stars_repo_path": "unions.agda", "max_stars_repo_stars_event_max_datetime": "2019-12-19T23:42:31.000Z", "max_stars_repo_stars_event_min_datetime": "2019-12-19T23:42:31.000Z", "num_tokens": 160, "size": 417 }
open import Data.Word.Primitive public using ( Word8 ; Word16 ; Word32 ; Word64 ) module Data.Word where data WordSize : Set where #8 #16 #32 #64 : WordSize Word : WordSize → Set Word #8 = Word8 Word #16 = Word16 Word #32 = Word32 Word #64 = Word64 Byte : Set Byte = Word8
{ "alphanum_fraction": 0.6857142857, "avg_line_length": 17.5, "ext": "agda", "hexsha": "ddd67fd015a2616e971a3856c68659e619f32f89", "lang": "Agda", "max_forks_count": 2, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:40:23.000Z", "max_forks_repo_forks_event_min_datetime": "2017-08-10T06:12:54.000Z", "max_forks_repo_head_hexsha": "d06c219c7b7afc85aae3b1d4d66951b889aa7371", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "ilya-fiveisky/agda-system-io", "max_forks_repo_path": "src/Data/Word.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "d06c219c7b7afc85aae3b1d4d66951b889aa7371", "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": "ilya-fiveisky/agda-system-io", "max_issues_repo_path": "src/Data/Word.agda", "max_line_length": 81, "max_stars_count": 10, "max_stars_repo_head_hexsha": "d06c219c7b7afc85aae3b1d4d66951b889aa7371", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "ilya-fiveisky/agda-system-io", "max_stars_repo_path": "src/Data/Word.agda", "max_stars_repo_stars_event_max_datetime": "2021-09-15T04:35:41.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-04T13:45:16.000Z", "num_tokens": 91, "size": 280 }
open import Data.Empty using ( ⊥ ) open import FRP.LTL.RSet.Core using ( RSet ) module FRP.LTL.RSet.Empty where F : RSet F t = ⊥
{ "alphanum_fraction": 0.6818181818, "avg_line_length": 14.6666666667, "ext": "agda", "hexsha": "9bb11d3958cd075aeceef65830c697fc2af3446f", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:39:04.000Z", "max_forks_repo_forks_event_min_datetime": "2015-03-01T07:33:00.000Z", "max_forks_repo_head_hexsha": "e88107d7d192cbfefd0a94505e6a5793afe1a7a5", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "agda/agda-frp-ltl", "max_forks_repo_path": "src/FRP/LTL/RSet/Empty.agda", "max_issues_count": 2, "max_issues_repo_head_hexsha": "e88107d7d192cbfefd0a94505e6a5793afe1a7a5", "max_issues_repo_issues_event_max_datetime": "2015-03-02T15:23:53.000Z", "max_issues_repo_issues_event_min_datetime": "2015-03-01T07:01:31.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "agda/agda-frp-ltl", "max_issues_repo_path": "src/FRP/LTL/RSet/Empty.agda", "max_line_length": 44, "max_stars_count": 21, "max_stars_repo_head_hexsha": "e88107d7d192cbfefd0a94505e6a5793afe1a7a5", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "agda/agda-frp-ltl", "max_stars_repo_path": "src/FRP/LTL/RSet/Empty.agda", "max_stars_repo_stars_event_max_datetime": "2020-06-15T02:51:13.000Z", "max_stars_repo_stars_event_min_datetime": "2015-07-02T20:25:05.000Z", "num_tokens": 44, "size": 132 }